mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Accept multiple colon-separated attributes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
794f4c30f4
commit
5ea946aa90
Notes:
Henri Verbeet
2024-11-05 20:05:24 +01:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1230
@ -53,7 +53,7 @@ struct parse_parameter
|
||||
struct parse_initializer initializer;
|
||||
};
|
||||
|
||||
struct parse_colon_attribute
|
||||
struct parse_colon_attributes
|
||||
{
|
||||
struct hlsl_semantic semantic;
|
||||
struct hlsl_reg_reservation reg_reservation;
|
||||
@ -6490,7 +6490,7 @@ static void validate_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim,
|
||||
struct parse_if_body if_body;
|
||||
enum parse_assign_op assign_op;
|
||||
struct hlsl_reg_reservation reg_reservation;
|
||||
struct parse_colon_attribute colon_attribute;
|
||||
struct parse_colon_attributes colon_attributes;
|
||||
struct hlsl_semantic semantic;
|
||||
enum hlsl_buffer_type buffer_type;
|
||||
enum hlsl_sampler_dim sampler_dim;
|
||||
@ -6687,7 +6687,7 @@ static void validate_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim,
|
||||
|
||||
%type <buffer_type> buffer_type
|
||||
|
||||
%type <colon_attribute> colon_attribute
|
||||
%type <colon_attributes> colon_attributes
|
||||
|
||||
%type <fields> field
|
||||
%type <fields> fields_list
|
||||
@ -6875,7 +6875,7 @@ effect_group:
|
||||
}
|
||||
|
||||
buffer_declaration:
|
||||
var_modifiers buffer_type any_identifier colon_attribute annotations_opt
|
||||
var_modifiers buffer_type any_identifier colon_attributes annotations_opt
|
||||
{
|
||||
if ($4.semantic.name)
|
||||
hlsl_error(ctx, &@4, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Semantics are not allowed on buffers.");
|
||||
@ -7200,7 +7200,7 @@ func_declaration:
|
||||
|
||||
func_prototype_no_attrs:
|
||||
/* var_modifiers is necessary to avoid shift/reduce conflicts. */
|
||||
var_modifiers type var_identifier '(' parameters ')' colon_attribute
|
||||
var_modifiers type var_identifier '(' parameters ')' colon_attributes
|
||||
{
|
||||
uint32_t modifiers = $1;
|
||||
struct hlsl_ir_var *var;
|
||||
@ -7377,28 +7377,39 @@ var_identifier:
|
||||
VAR_IDENTIFIER
|
||||
| NEW_IDENTIFIER
|
||||
|
||||
colon_attribute:
|
||||
colon_attributes:
|
||||
%empty
|
||||
{
|
||||
$$.semantic = (struct hlsl_semantic){0};
|
||||
$$.reg_reservation.reg_type = 0;
|
||||
$$.reg_reservation.offset_type = 0;
|
||||
}
|
||||
| semantic
|
||||
| colon_attributes semantic
|
||||
{
|
||||
$$.semantic = $1;
|
||||
$$.reg_reservation.reg_type = 0;
|
||||
$$.reg_reservation.offset_type = 0;
|
||||
hlsl_cleanup_semantic(&$$.semantic);
|
||||
$$.semantic = $2;
|
||||
}
|
||||
| register_reservation
|
||||
| colon_attributes register_reservation
|
||||
{
|
||||
$$.semantic = (struct hlsl_semantic){0};
|
||||
$$.reg_reservation = $1;
|
||||
if ($$.reg_reservation.reg_type)
|
||||
hlsl_fixme(ctx, &@2, "Multiple register() reservations.");
|
||||
|
||||
$$.reg_reservation.reg_type = $2.reg_type;
|
||||
$$.reg_reservation.reg_index = $2.reg_index;
|
||||
$$.reg_reservation.reg_space = $2.reg_space;
|
||||
}
|
||||
| packoffset_reservation
|
||||
| colon_attributes packoffset_reservation
|
||||
{
|
||||
$$.semantic = (struct hlsl_semantic){0};
|
||||
$$.reg_reservation = $1;
|
||||
if (ctx->cur_buffer == ctx->globals_buffer)
|
||||
{
|
||||
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION,
|
||||
"The packoffset() reservation is only allowed within 'cbuffer' blocks.");
|
||||
}
|
||||
else
|
||||
{
|
||||
$$.reg_reservation.offset_type = $2.offset_type;
|
||||
$$.reg_reservation.offset_index = $2.offset_index;
|
||||
}
|
||||
}
|
||||
|
||||
semantic:
|
||||
@ -7594,7 +7605,7 @@ parameter:
|
||||
}
|
||||
|
||||
parameter_decl:
|
||||
var_modifiers type_no_void any_identifier arrays colon_attribute
|
||||
var_modifiers type_no_void any_identifier arrays colon_attributes
|
||||
{
|
||||
uint32_t modifiers = $1;
|
||||
struct hlsl_type *type;
|
||||
@ -8095,7 +8106,7 @@ variables_def_typed:
|
||||
}
|
||||
|
||||
variable_decl:
|
||||
any_identifier arrays colon_attribute annotations_opt
|
||||
any_identifier arrays colon_attributes annotations_opt
|
||||
{
|
||||
$$ = hlsl_alloc(ctx, sizeof(*$$));
|
||||
$$->loc = @1;
|
||||
|
@ -639,7 +639,7 @@ float4 main() : sv_target
|
||||
return tex.Sample(sam, float2(0, 0));
|
||||
}
|
||||
|
||||
[pixel shader todo]
|
||||
[pixel shader]
|
||||
Texture2D tex;
|
||||
|
||||
cbuffer buffer
|
||||
|
@ -39,6 +39,16 @@ float4 main(float tex : texcoord) : sv_target
|
||||
todo(msl) draw quad
|
||||
probe (0, 0) rgba (0.2, 0.2, 0.2, 0.2)
|
||||
|
||||
[pixel shader fail(sm>=6)]
|
||||
float4 main(float tex : texcoord) : semantic : sv_target
|
||||
{
|
||||
return tex;
|
||||
}
|
||||
|
||||
[test]
|
||||
todo(msl) draw quad
|
||||
probe (0, 0) rgba (0.2, 0.2, 0.2, 0.2)
|
||||
|
||||
[pixel shader]
|
||||
|
||||
float4 main(float tex : texcoord) : sv_target
|
||||
@ -76,7 +86,7 @@ float4 main(in float2 arr[2]) : sv_target
|
||||
[pixel shader]
|
||||
struct apple
|
||||
{
|
||||
float3 tp[4] : TEXCOORD0;
|
||||
float3 tp[4] : BOGUS : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4 main(in apple a) : sv_target
|
||||
|
@ -224,7 +224,7 @@ uniform 4 float 101
|
||||
todo(msl) draw quad
|
||||
probe (0, 0) rgba (100, 100, 100, 100)
|
||||
|
||||
[pixel shader todo]
|
||||
[pixel shader]
|
||||
cbuffer c
|
||||
{
|
||||
float a : packoffset(c1);
|
||||
@ -241,9 +241,26 @@ float4 main() : sv_target
|
||||
uniform 0 float 200
|
||||
uniform 4 float 201
|
||||
uniform 8 float 202
|
||||
todo(sm<6) draw quad
|
||||
todo(sm<6) probe (0,0) rgba (201.0, 202.0, 0.0, 0.0)
|
||||
draw quad
|
||||
probe (0,0) rgba (201.0, 202.0, 0.0, 0.0)
|
||||
|
||||
[pixel shader]
|
||||
cbuffer c
|
||||
{
|
||||
float a : packoffset(c1) : packoffset(c2);
|
||||
}
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return float4(a, 0, 0, 0);
|
||||
}
|
||||
|
||||
[test]
|
||||
uniform 0 float 201
|
||||
uniform 4 float 202
|
||||
uniform 8 float 203
|
||||
draw quad
|
||||
probe (0,0) rgba (203.0, 0.0, 0.0, 0.0)
|
||||
|
||||
[pixel shader fail(sm<4)]
|
||||
int k : register(i0); // register(cX) is also required.
|
||||
|
@ -26,3 +26,17 @@ float4 main() : sv_target
|
||||
uniform 0 float4 4.0 5.0 6.0 7.0
|
||||
todo(msl) draw quad
|
||||
probe (0, 0) rgba (4.0, 5.0, 4.0, 5.0)
|
||||
|
||||
|
||||
[pixel shader]
|
||||
float a : SEMANTIC : ANOTHER_SEMANTIC;
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
[test]
|
||||
uniform 0 float 3.5
|
||||
todo(msl) draw quad
|
||||
probe (0, 0) rgba (3.5, 3.5, 3.5, 3.5)
|
||||
|
Loading…
Reference in New Issue
Block a user