diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 87dccdf6..20bd3b0d 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -1916,12 +1916,6 @@ static bool copy_propagation_replace_with_deref(struct hlsl_ctx *ctx, if (!nonconst_index_from_deref(ctx, deref, &nonconst_i, &base, &scale, &count)) return false; - if (hlsl_version_lt(ctx, 4, 0)) - { - TRACE("Non-constant index propagation is not yet supported for SM1.\n"); - return false; - } - VKD3D_ASSERT(count); hlsl_block_init(&block); @@ -1950,6 +1944,12 @@ static bool copy_propagation_replace_with_deref(struct hlsl_ctx *ctx, else if (x != idx->src.var) goto done; + if (hlsl_version_lt(ctx, 4, 0) && x->is_uniform && ctx->profile->type != VKD3D_SHADER_TYPE_VERTEX) + { + TRACE("Skipping propagating non-constant deref to SM1 uniform %s.\n", var->name); + goto done; + } + if (i == 0) { path_len = idx->src.path_len; diff --git a/tests/hlsl/non-const-indexing.shader_test b/tests/hlsl/non-const-indexing.shader_test index 80a1f30d..39dae791 100644 --- a/tests/hlsl/non-const-indexing.shader_test +++ b/tests/hlsl/non-const-indexing.shader_test @@ -400,15 +400,15 @@ probe (0, 0) rgba(9.0, 10.0, 11.0, 12.0) if(sm<4) uniform 12 float4 0.5 0 0 0 if(sm>=4) uniform 12 int4 0 0 0 0 todo(msl) draw quad -todo(sm<4) probe (0, 0) rgba(1.0, 2.0, 3.0, 4.0) +probe (0, 0) rgba(1.0, 2.0, 3.0, 4.0) if(sm<4) uniform 12 float4 0 1.4 0 0 if(sm>=4) uniform 12 int4 0 1 0 0 0 todo(msl) draw quad -todo(sm<4) probe (0, 0) rgba(5.0, 6.0, 7.0, 8.0) +probe (0, 0) rgba(5.0, 6.0, 7.0, 8.0) if(sm<4) uniform 12 float4 1.5 0 0 0 if(sm>=4) uniform 12 int4 2 0 0 0 todo(msl) draw quad -todo(sm<4) probe (0, 0) rgba(9.0, 10.0, 11.0, 12.0) +probe (0, 0) rgba(9.0, 10.0, 11.0, 12.0) [require] shader model >= 4.0 diff --git a/tests/hlsl/sm1-const-allocation.shader_test b/tests/hlsl/sm1-const-allocation.shader_test index a7269473..5968b282 100644 --- a/tests/hlsl/sm1-const-allocation.shader_test +++ b/tests/hlsl/sm1-const-allocation.shader_test @@ -471,7 +471,7 @@ uniform 8 float 2 uniform 12 float 3 uniform 16 float 0 draw quad -todo probe (0, 0) rgba(1, 1, 1, 1) +probe (0, 0) rgba(1, 1, 1, 1) uniform 16 float 1 draw quad -todo probe (0, 0) rgba(2, 2, 2, 2) +probe (0, 0) rgba(2, 2, 2, 2)