vkd3d-shader/hlsl: Make single-component swizzles retrieve a scalar.

This commit is contained in:
Francisco Casas 2023-01-05 12:13:46 -03:00 committed by Alexandre Julliard
parent edf86b2248
commit f33ca836d7
Notes: Alexandre Julliard 2023-01-26 23:11:28 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/70
3 changed files with 12 additions and 8 deletions

View File

@ -1164,11 +1164,15 @@ struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned
struct hlsl_ir_node *val, const struct vkd3d_shader_location *loc) struct hlsl_ir_node *val, const struct vkd3d_shader_location *loc)
{ {
struct hlsl_ir_swizzle *swizzle; struct hlsl_ir_swizzle *swizzle;
struct hlsl_type *type;
if (!(swizzle = hlsl_alloc(ctx, sizeof(*swizzle)))) if (!(swizzle = hlsl_alloc(ctx, sizeof(*swizzle))))
return NULL; return NULL;
init_node(&swizzle->node, HLSL_IR_SWIZZLE, if (components == 1)
hlsl_get_vector_type(ctx, val->data_type->base_type, components), loc); type = hlsl_get_scalar_type(ctx, val->data_type->base_type);
else
type = hlsl_get_vector_type(ctx, val->data_type->base_type, components);
init_node(&swizzle->node, HLSL_IR_SWIZZLE, type, loc);
hlsl_src_from_node(&swizzle->val, val); hlsl_src_from_node(&swizzle->val, val);
swizzle->swizzle = s; swizzle->swizzle = s;
return swizzle; return swizzle;

View File

@ -1,4 +1,4 @@
[pixel shader todo] [pixel shader]
void sub2(in uniform float4 i, out float4 o) void sub2(in uniform float4 i, out float4 o)
{ {
o = i; o = i;
@ -17,5 +17,5 @@ void main(in uniform float4 a, uniform float4 b, out float4 o : sv_target)
[test] [test]
uniform 0 float4 0.1 0.0 0.0 0.0 uniform 0 float4 0.1 0.0 0.0 0.0
uniform 4 float4 0.2 0.0 0.0 0.0 uniform 4 float4 0.2 0.0 0.0 0.0
todo draw quad draw quad
probe all rgba (0.1, 0.2, 0.3, 0.4) todo probe all rgba (0.1, 0.2, 0.3, 0.4)

View File

@ -37,7 +37,7 @@ float4 main() : SV_TARGET
} }
[pixel shader todo] [pixel shader]
float4 main() : SV_TARGET float4 main() : SV_TARGET
{ {
float4 vec = {0, 1, 2, 3}; float4 vec = {0, 1, 2, 3};
@ -47,5 +47,5 @@ float4 main() : SV_TARGET
} }
[test] [test]
todo draw quad draw quad
todo probe all rgba (2.0, 2.0, 2.0, 2.0) probe all rgba (2.0, 2.0, 2.0, 2.0)