Mesa (staging/21.2): zink: always use explicit lod for texture() when legal in non-fragment stages
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Oct 29 16:34:58 UTC 2021
Module: Mesa
Branch: staging/21.2
Commit: b84542fe11ffeddf31120c5f1e5d9d15d929b597
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b84542fe11ffeddf31120c5f1e5d9d15d929b597
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 a163884c5be..df3ab1e2f11 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -931,7 +931,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 8cfedc21283..818cc2a8967 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;
@@ -3023,6 +3025,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,
@@ -3665,6 +3670,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