Mesa (staging/21.3): zink: always use explicit lod for texture() when legal in non-fragment stages
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Oct 28 20:03:31 UTC 2021
Module: Mesa
Branch: staging/21.3
Commit: 66e0bf280e19b0e3b5c851f2a257c3116f01462b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=66e0bf280e19b0e3b5c851f2a257c3116f01462b
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Wed Oct 27 17:37:30 2021 -0400
zink: always use explicit lod for texture() when legal in non-fragment stages
implicit lod is something else entirely
fixes #5566
cc: mesa-stable
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13563>
(cherry picked from commit 3ad06b69490fa990c473e16f78ce658b0eb43b47)
---
.pick_status.json | 2 +-
src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/.pick_status.json b/.pick_status.json
index b35fff27030..62241299341 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -166,7 +166,7 @@
"description": "zink: always use explicit lod for texture() when legal in non-fragment stages",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": null
},
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 b94f5e7533e..7af2746ab6f 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
@@ -40,6 +40,8 @@ struct ntv_context {
*/
bool spirv_1_4_interfaces;
+ bool explicit_lod; //whether to set lod=0 for texture()
+
struct spirv_builder builder;
struct hash_table *glsl_types;
@@ -3217,6 +3219,9 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex)
if (!tex_instr_is_lod_allowed(tex))
lod = 0;
+ else if (ctx->stage != MESA_SHADER_FRAGMENT &&
+ tex->op == nir_texop_tex && ctx->explicit_lod && !lod && !proj && !bias && !dref && !dx && !dy)
+ lod = emit_float_const(ctx, 32, 0.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,
@@ -3860,6 +3865,7 @@ nir_to_spirv(struct nir_shader *s, const struct zink_so_info *so_info, uint32_t
ctx.stage = s->info.stage;
ctx.so_info = so_info;
ctx.GLSL_std_450 = spirv_builder_import(&ctx.builder, "GLSL.std.450");
+ ctx.explicit_lod = true;
spirv_builder_emit_source(&ctx.builder, SpvSourceLanguageUnknown, 0);
if (s->info.stage == MESA_SHADER_COMPUTE) {
More information about the mesa-commit
mailing list