From 56dd8ebd82fa8fe7e46dbfc746403bae553e2e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kro=C5=A1l=C3=A1k?= Date: Thu, 2 Jul 2020 18:08:57 -0400 Subject: [PATCH] spirv: Fix texcoord use before load --- profiles/mojoshader_profile_spirv.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/profiles/mojoshader_profile_spirv.c b/profiles/mojoshader_profile_spirv.c index 2e03fade..06df1b9d 100644 --- a/profiles/mojoshader_profile_spirv.c +++ b/profiles/mojoshader_profile_spirv.c @@ -3528,6 +3528,11 @@ void emit_SPIRV_TEXLD(Context *ctx) return; } // if + // OpImageSampleImplicitLod should ignore the components of this argument that + // it doesn't need, so we don't need to mask it + uint32 texcoord = spv_load_srcarg_full(ctx, 0).id; + uint32 sampler = spv_load_srcarg_full(ctx, 1).id; + // Special case for TEXLDB // !!! FIXME: does the d3d bias value map directly to GLSL? uint32 bias; @@ -3540,7 +3545,7 @@ void emit_SPIRV_TEXLD(Context *ctx) // The w component of texcoord_reg specifies the bias. Extract it from texcoord_reg push_output(ctx, &ctx->mainline); - spv_emit(ctx, 4 + 1, SpvOpCompositeExtract, float_tid, bias, texcoord_reg->spirv.iddecl, 3); + spv_emit(ctx, 4 + 1, SpvOpCompositeExtract, float_tid, bias, texcoord, 3); pop_output(ctx); } // if else @@ -3563,10 +3568,6 @@ void emit_SPIRV_TEXLD(Context *ctx) // Prep the result uint32 vec4_tid = spv_get_type(ctx, STI_VEC4); uint32 result = spv_bumpid(ctx); - uint32 sampler = spv_load_srcarg_full(ctx, 1).id; - // OpImageSampleImplicitLod should ignore the components of this argument that - // it doesn't need, so we don't need to mask it - uint32 texcoord = spv_load_srcarg_full(ctx, 0).id; // Generate the instruction. // OpImageSampleImplicitLod should ignore the components of the