diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 4cfc1437c..cd1a849c0 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -538,8 +538,6 @@ static void prepend_input_copy_recurse(struct hlsl_ctx *ctx, struct hlsl_ir_func } else { - struct hlsl_semantic semantic_copy; - field = &type->e.record.fields[i]; if (hlsl_type_is_resource(field->type)) { @@ -549,13 +547,24 @@ static void prepend_input_copy_recurse(struct hlsl_ctx *ctx, struct hlsl_ir_func element_modifiers = combine_field_storage_modifiers(modifiers, field->storage_modifiers); force_align = (i == 0); - validate_field_semantic(ctx, field); + if (semantic->name) + { + warn_on_field_semantic(ctx, field, semantic); + prepend_input_copy_recurse(ctx, func, block, prim_index, + element_load, element_modifiers, semantic, force_align); + } + else + { + struct hlsl_semantic semantic_copy; - if (!hlsl_clone_semantic(ctx, &semantic_copy, &field->semantic)) - return; - prepend_input_copy_recurse(ctx, func, block, prim_index, - element_load, element_modifiers, &semantic_copy, force_align); - hlsl_cleanup_semantic(&semantic_copy); + validate_field_semantic(ctx, field); + + if (!(hlsl_clone_semantic(ctx, &semantic_copy, &field->semantic))) + return; + prepend_input_copy_recurse(ctx, func, block, prim_index, + element_load, element_modifiers, &semantic_copy, force_align); + hlsl_cleanup_semantic(&semantic_copy); + } } } } diff --git a/tests/hlsl/semantic-cascading.shader_test b/tests/hlsl/semantic-cascading.shader_test index 58ca81448..95a9d7a2c 100644 --- a/tests/hlsl/semantic-cascading.shader_test +++ b/tests/hlsl/semantic-cascading.shader_test @@ -25,7 +25,7 @@ float4 main(float4 pos : sv_position, float4 res : RESULT) : sv_target 0.0 1.0 2.0 2.1 0.0 1.0 2.0 2.1 -[vertex shader todo] +[vertex shader] struct apple { float aa; // Ends up as CASCADE0 @@ -41,7 +41,7 @@ float4 main(float4 position : position, struct apple ap : CASCADE, out float4 re [test] clear rtv 0 0.0 0.0 0.0 0.0 -todo(sm<6) draw triangle strip 4 +draw triangle strip 4 probe (0, 0) f32(0.0, 1.0, 2.0, 2.1) @@ -60,7 +60,7 @@ probe (0, 0) f32(0.0, 1.0, 2.0, 2.1) 0.0 1.0 2.0 3.0 4.0 5.0 5.1 0.0 1.0 2.0 3.0 4.0 5.0 5.1 -[vertex shader todo] +[vertex shader] struct apple { float aa; // Ends up as CASCADE0 @@ -76,7 +76,7 @@ float4 main(float4 position : position, struct apple ap : CASCADE, out float4 re [test] clear rtv 0 0.0 0.0 0.0 0.0 -todo(sm<6) draw triangle strip 4 +draw triangle strip 4 probe (0, 0) f32(0.0, 3.0, 5.0, 5.1) @@ -94,7 +94,7 @@ probe (0, 0) f32(0.0, 3.0, 5.0, 5.1) 0.0 0.1 1.0 2.0 2.1 3.0 3.1 % Test nested structs. -[vertex shader todo] +[vertex shader] struct apple { float aa; // Gets CASCADE1 @@ -116,7 +116,7 @@ float4 main(float4 position : position, struct banana ba : CASCADE, out float4 r [test] clear rtv 0 0.0 0.0 0.0 0.0 -todo(sm<6) draw triangle strip 4 +draw triangle strip 4 probe (0, 0) f32(0.1, 2.0, 2.1, 3.1) @@ -136,7 +136,7 @@ probe (0, 0) f32(0.1, 2.0, 2.1, 3.1) 0.0 1.0 2.0 2.1 3.0 4.0 4.1 5.0 % Test nested struct array. -[vertex shader todo] +[vertex shader] struct apple { float aa; @@ -158,7 +158,7 @@ float4 main(float4 position : position, struct banana ba : CASCADE, out float4 r [test] clear rtv 0 0.0 0.0 0.0 0.0 -todo draw triangle strip 4 +todo(sm>=6) draw triangle strip 4 probe (0, 0) f32(1.0, 4.0, 4.1, 5.0) @@ -178,7 +178,7 @@ probe (0, 0) f32(1.0, 4.0, 4.1, 5.0) 0.0 1.0 1.1 2.0 3.0 3.1 4.0 5.0 5.1 % Test array. The semantic indexes of each array element don't overlap. -[vertex shader todo] +[vertex shader] struct apple { float aa; @@ -193,7 +193,7 @@ float4 main(float4 position : position, struct apple ap[3] : CASCADE, out float4 [test] clear rtv 0 0.0 0.0 0.0 0.0 -todo draw triangle strip 4 +todo(sm>=6) draw triangle strip 4 probe (0, 0) f32(0.0, 3.0, 3.1, 4.0) @@ -209,7 +209,7 @@ probe (0, 0) f32(0.0, 3.0, 3.1, 4.0) 0.0 1.0 1.1 % Test for overriding. -[vertex shader todo] +[vertex shader] struct apple { float aa; @@ -224,8 +224,8 @@ float4 main(float4 position : position, struct apple ap : CASCADE, out float4 re [test] clear rtv 0 0.0 0.0 0.0 0.0 -todo(sm<6) draw triangle strip 4 -probe (0, 0) f32(0.0, 1.0, 1.1, 0.0) +draw triangle strip 4 +todo(opengl) probe (0, 0) f32(0.0, 1.0, 1.1, 0.0) [input layout] @@ -241,7 +241,7 @@ probe (0, 0) f32(0.0, 1.0, 1.1, 0.0) 0.0 1.0 2.0 % The outermost semantic overrides all others. -[vertex shader todo] +[vertex shader] struct apple { float aa : INPLACE; // Gets CASCADE1 @@ -262,5 +262,5 @@ float4 main(float4 position : position, struct banana ba : CASCADE, out float4 r [test] clear rtv 0 0.0 0.0 0.0 0.0 -todo(sm<6) draw triangle strip 4 +draw triangle strip 4 probe (0, 0) f32(0.0, 1.0, 2.0, 0.0)