Mesa (master): zink: omit Lod image operand in ntv when not using an image texture dim
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jul 22 14:11:24 UTC 2020
Module: Mesa
Branch: master
Commit: 3f783a3c507e16bffb2e460484fbf65eb11ba826
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3f783a3c507e16bffb2e460484fbf65eb11ba826
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Thu Jul 2 11:46:28 2020 -0400
zink: omit Lod image operand in ntv when not using an image texture dim
according to spec, this is invalid (and it's not being used anyway)
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5911>
---
src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
index 968665f0c7a..f8abd901640 100644
--- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
+++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
@@ -1762,6 +1762,19 @@ get_src_int(struct ntv_context *ctx, nir_src *src)
return bitcast_to_ivec(ctx, def, bit_size, num_components);
}
+static inline bool
+tex_instr_is_lod_allowed(nir_tex_instr *tex)
+{
+ /* This can only be used with an OpTypeImage that has a Dim operand of 1D, 2D, 3D, or Cube
+ * - SPIR-V: 3.14. Image Operands
+ */
+
+ return (tex->sampler_dim == GLSL_SAMPLER_DIM_1D ||
+ tex->sampler_dim == GLSL_SAMPLER_DIM_2D ||
+ tex->sampler_dim == GLSL_SAMPLER_DIM_3D ||
+ tex->sampler_dim == GLSL_SAMPLER_DIM_CUBE);
+}
+
static SpvId
pad_coord_vector(struct ntv_context *ctx, SpvId orig, unsigned old_size, unsigned new_size)
{
@@ -1882,6 +1895,8 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex)
SpvId dest_type = get_dest_type(ctx, &tex->dest, tex->dest_type);
+ if (!tex_instr_is_lod_allowed(tex))
+ lod = 0;
if (tex->op == nir_texop_txs) {
SpvId image = spirv_builder_emit_image(&ctx->builder, image_type, load);
SpvId result = spirv_builder_emit_image_query_size(&ctx->builder,
More information about the mesa-commit
mailing list