mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Error out when a semantic is used with incompatible types.
Considering row vectors from row_major matrices as having a different layout as regular vectors, and error out in that case, is left as todo.
This commit is contained in:
parent
d96e9665b1
commit
537d7c27a2
Notes:
Alexandre Julliard
2023-05-01 22:24:44 +02: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/148
@ -215,6 +215,10 @@ struct hlsl_semantic
|
||||
/* In case the variable or field that stores this semantic has already reported to use a
|
||||
* duplicated output semantic, this value stores the last reported index + 1. Otherwise it is 0. */
|
||||
uint32_t reported_duplicated_output_next_index;
|
||||
/* In case the variable or field that stores this semantic has already reported to use a
|
||||
* duplicated input semantic with incompatible values, this value stores the last reported
|
||||
* index + 1. Otherwise it is 0. */
|
||||
uint32_t reported_duplicated_input_incompatible_next_index;
|
||||
};
|
||||
|
||||
/* A field within a struct type declaration, used in hlsl_type.e.fields. */
|
||||
|
@ -4785,6 +4785,7 @@ semantic:
|
||||
$$.index = atoi(p);
|
||||
$$.reported_missing = false;
|
||||
$$.reported_duplicated_output_next_index = 0;
|
||||
$$.reported_duplicated_input_incompatible_next_index = 0;
|
||||
*p = 0;
|
||||
}
|
||||
|
||||
|
@ -232,6 +232,27 @@ static void validate_field_semantic(struct hlsl_ctx *ctx, struct hlsl_struct_fie
|
||||
}
|
||||
}
|
||||
|
||||
static enum hlsl_base_type base_type_get_semantic_equivalent(enum hlsl_base_type base)
|
||||
{
|
||||
if (base == HLSL_TYPE_BOOL)
|
||||
return HLSL_TYPE_UINT;
|
||||
if (base == HLSL_TYPE_INT)
|
||||
return HLSL_TYPE_UINT;
|
||||
if (base == HLSL_TYPE_HALF)
|
||||
return HLSL_TYPE_FLOAT;
|
||||
return base;
|
||||
}
|
||||
|
||||
static bool types_are_semantic_equivalent(struct hlsl_ctx *ctx, const struct hlsl_type *type1,
|
||||
const struct hlsl_type *type2)
|
||||
{
|
||||
if (type1->dimx != type2->dimx)
|
||||
return false;
|
||||
|
||||
return base_type_get_semantic_equivalent(type1->base_type)
|
||||
== base_type_get_semantic_equivalent(type2->base_type);
|
||||
}
|
||||
|
||||
static struct hlsl_ir_var *add_semantic_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *var,
|
||||
struct hlsl_type *type, unsigned int modifiers, struct hlsl_semantic *semantic,
|
||||
uint32_t index, bool output, const struct vkd3d_shader_location *loc)
|
||||
@ -259,6 +280,19 @@ static struct hlsl_ir_var *add_semantic_var(struct hlsl_ctx *ctx, struct hlsl_ir
|
||||
semantic->reported_duplicated_output_next_index = index + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (index >= semantic->reported_duplicated_input_incompatible_next_index
|
||||
&& !types_are_semantic_equivalent(ctx, ext_var->data_type, type))
|
||||
{
|
||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
|
||||
"Input semantic \"%s%u\" is used multiple times with incompatible types.",
|
||||
semantic->name, index);
|
||||
hlsl_note(ctx, &ext_var->loc, HLSL_LEVEL_ERROR,
|
||||
"First declaration of \"%s%u\" is here.", semantic->name, index);
|
||||
semantic->reported_duplicated_input_incompatible_next_index = index + 1;
|
||||
}
|
||||
}
|
||||
|
||||
hlsl_release_string_buffer(ctx, name);
|
||||
return ext_var;
|
||||
|
@ -295,14 +295,14 @@ float4 main(in uint2 a : TEXCOORD0, in int2 b : TEXCOORD0, in int2x1 c : TEXCOOR
|
||||
shader model >= 4.0
|
||||
|
||||
|
||||
[pixel shader fail todo]
|
||||
[pixel shader fail]
|
||||
float4 main(in float2 a : TEXCOORD0, in float3 b : TEXCOORD0) : sv_target
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
[pixel shader fail todo]
|
||||
[pixel shader fail]
|
||||
float4 main(in float2 a : TEXCOORD0, in int2 b : TEXCOORD0) : sv_target
|
||||
{
|
||||
return 0.0;
|
||||
@ -317,7 +317,7 @@ float4 main(in float2 a : TEXCOORD0, row_major float1x2 b : TEXCOORD0) : sv_targ
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
[pixel shader fail todo]
|
||||
[pixel shader fail]
|
||||
float4 main(in float2 a : TEXCOORD0, row_major float2x1 b : TEXCOORD0) : sv_target
|
||||
{
|
||||
return 0.0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user