vkd3d-shader/hlsl: Allocate return variables before other outputs.

point-sprite.shader_test is not technically well formed since, in SM4,
the vertex output signature should be:

// Output signature:
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// sv_position              0   xyzw        0      POS   float   xyzw
// texcoord                 0   xy          1     NONE   float   xy

and the pixel input signature should be:

// Input signature:
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// texcoord                 0   xy          0     NONE   float   xy

so we are not passing "texcoord" properly to the pixel shader, even on
Windows.
This commit is contained in:
Francisco Casas
2025-06-18 14:59:01 -04:00
committed by Henri Verbeet
parent e0359c5299
commit 2e0cbff3a0
Notes: Henri Verbeet 2025-06-23 20:18:28 +02:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1578
3 changed files with 23 additions and 19 deletions

View File

@@ -13574,6 +13574,19 @@ static void process_entry_function(struct hlsl_ctx *ctx,
lower_ir(ctx, lower_matrix_swizzles, body); lower_ir(ctx, lower_matrix_swizzles, body);
lower_ir(ctx, lower_index_loads, body); lower_ir(ctx, lower_index_loads, body);
if (entry_func->return_var)
{
if (profile->type == VKD3D_SHADER_TYPE_GEOMETRY)
hlsl_error(ctx, &entry_func->loc, VKD3D_SHADER_ERROR_HLSL_INCOMPATIBLE_PROFILE,
"Geometry shaders cannot return values.");
else if (entry_func->return_var->data_type->class != HLSL_CLASS_STRUCT
&& !entry_func->return_var->semantic.name)
hlsl_error(ctx, &entry_func->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC,
"Entry point \"%s\" is missing a return value semantic.", entry_func->func->name);
append_output_var_copy(ctx, entry_func, entry_func->return_var);
}
for (i = 0; i < entry_func->parameters.count; ++i) for (i = 0; i < entry_func->parameters.count; ++i)
{ {
var = entry_func->parameters.vars[i]; var = entry_func->parameters.vars[i];
@@ -13678,18 +13691,9 @@ static void process_entry_function(struct hlsl_ctx *ctx,
} }
} }
} }
if (entry_func->return_var) if (entry_func->return_var)
{ {
if (profile->type == VKD3D_SHADER_TYPE_GEOMETRY)
hlsl_error(ctx, &entry_func->loc, VKD3D_SHADER_ERROR_HLSL_INCOMPATIBLE_PROFILE,
"Geometry shaders cannot return values.");
else if (entry_func->return_var->data_type->class != HLSL_CLASS_STRUCT
&& !entry_func->return_var->semantic.name)
hlsl_error(ctx, &entry_func->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC,
"Entry point \"%s\" is missing a return value semantic.", entry_func->func->name);
append_output_var_copy(ctx, entry_func, entry_func->return_var);
if (profile->type == VKD3D_SHADER_TYPE_HULL && !ctx->is_patch_constant_func) if (profile->type == VKD3D_SHADER_TYPE_HULL && !ctx->is_patch_constant_func)
ctx->output_control_point_type = entry_func->return_var->data_type; ctx->output_control_point_type = entry_func->return_var->data_type;
} }

View File

@@ -33,16 +33,16 @@ clear rtv 0 0 0 0 0
point-size 30.0 1.0 64.0 point-size 30.0 1.0 64.0
point-sprite off point-sprite off
draw point list 1 draw point list 1
probe (310, 230) rgba (1, 0, 1, 1) todo(sm>=4 & sm<6) probe (310, 230) f32(1, 0, 1, 1)
probe (330, 230) rgba (1, 0, 1, 1) todo(sm>=4 & sm<6) probe (330, 230) f32(1, 0, 1, 1)
probe (310, 250) rgba (1, 0, 1, 1) todo(sm>=4 & sm<6) probe (310, 250) f32(1, 0, 1, 1)
probe (330, 250) rgba (1, 0, 1, 1) todo(sm>=4 & sm<6) probe (330, 250) f32(1, 0, 1, 1)
clear rtv 0 0 0 0 0 clear rtv 0 0 0 0 0
point-size 30.0 1.0 64.0 point-size 30.0 1.0 64.0
point-sprite on point-sprite on
draw point list 1 draw point list 1
probe (310, 230) rgba (1, 1, 0, 1) bug(mvk & sm>=4 & sm<6) probe (310, 230) f32(1, 1, 0, 1)
probe (330, 230) rgba (0, 1, 1, 1) bug(mvk & sm>=4 & sm<6) probe (330, 230) f32(0, 1, 1, 1)
probe (310, 250) rgba (1, 0, 0, 1) bug(mvk & sm>=4 & sm<6) probe (310, 250) f32(1, 0, 0, 1)
probe (330, 250) rgba (1, 0, 1, 1) bug(mvk & sm>=4 & sm<6) probe (330, 250) f32(1, 0, 1, 1)

View File

@@ -39,4 +39,4 @@ float4 main(float cc : SEMC, float aa : SEMA, float bb[2] : SEMB) : sv_target
[test] [test]
bug(mvk & sm>=6) draw quad bug(mvk & sm>=6) draw quad
todo(sm<6) probe (0, 0) f32(300, 100, 200, 201) probe (0, 0) f32(300, 100, 200, 201)