mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Apply latent majority modifiers to typedefs as well.
This commit is contained in:
parent
322963add8
commit
5838364886
Notes:
Alexandre Julliard
2023-02-28 22:10:58 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/102
@ -877,7 +877,7 @@ static const struct hlsl_struct_field *get_struct_field(const struct hlsl_struct
|
||||
}
|
||||
|
||||
static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_type *type,
|
||||
unsigned int *modifiers, struct vkd3d_shader_location loc)
|
||||
unsigned int *modifiers, bool force_majority, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
unsigned int default_majority = 0;
|
||||
struct hlsl_type *new_type;
|
||||
@ -886,12 +886,12 @@ static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_
|
||||
&& !(type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK)
|
||||
&& type->type == HLSL_CLASS_MATRIX)
|
||||
{
|
||||
if (!(default_majority = ctx->matrix_majority))
|
||||
if (!(default_majority = ctx->matrix_majority) && force_majority)
|
||||
default_majority = HLSL_MODIFIER_COLUMN_MAJOR;
|
||||
}
|
||||
else if (type->type != HLSL_CLASS_MATRIX)
|
||||
{
|
||||
check_invalid_matrix_modifiers(ctx, *modifiers, loc);
|
||||
check_invalid_matrix_modifiers(ctx, *modifiers, *loc);
|
||||
}
|
||||
|
||||
if (!default_majority && !(*modifiers & HLSL_TYPE_MODIFIERS_MASK))
|
||||
@ -903,7 +903,7 @@ static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_
|
||||
*modifiers &= ~HLSL_TYPE_MODIFIERS_MASK;
|
||||
|
||||
if ((new_type->modifiers & HLSL_MODIFIER_ROW_MAJOR) && (new_type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR))
|
||||
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
|
||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
|
||||
"'row_major' and 'column_major' modifiers are mutually exclusive.");
|
||||
|
||||
return new_type;
|
||||
@ -995,8 +995,7 @@ static bool gen_struct_fields(struct hlsl_ctx *ctx, struct parse_fields *fields,
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool add_typedef(struct hlsl_ctx *ctx, const unsigned int modifiers,
|
||||
struct hlsl_type *const orig_type, struct list *list)
|
||||
static bool add_typedef(struct hlsl_ctx *ctx, struct hlsl_type *const orig_type, struct list *list)
|
||||
{
|
||||
struct parse_variable_def *v, *v_next;
|
||||
struct hlsl_type *type;
|
||||
@ -1007,22 +1006,17 @@ static bool add_typedef(struct hlsl_ctx *ctx, const unsigned int modifiers,
|
||||
{
|
||||
if (!v->arrays.count)
|
||||
{
|
||||
/* Do not use apply_type_modifiers() here. We should not apply the
|
||||
* latent matrix majority to plain matrix types. */
|
||||
if (!(type = hlsl_type_clone(ctx, orig_type, 0, modifiers)))
|
||||
if (!(type = hlsl_type_clone(ctx, orig_type, 0, 0)))
|
||||
{
|
||||
free_parse_variable_def(v);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type->type != HLSL_CLASS_MATRIX)
|
||||
check_invalid_matrix_modifiers(ctx, modifiers, v->loc);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int var_modifiers = modifiers;
|
||||
unsigned int var_modifiers = 0;
|
||||
|
||||
if (!(type = apply_type_modifiers(ctx, orig_type, &var_modifiers, v->loc)))
|
||||
if (!(type = apply_type_modifiers(ctx, orig_type, &var_modifiers, true, &v->loc)))
|
||||
{
|
||||
free_parse_variable_def(v);
|
||||
continue;
|
||||
@ -1052,11 +1046,6 @@ static bool add_typedef(struct hlsl_ctx *ctx, const unsigned int modifiers,
|
||||
vkd3d_free((void *)type->name);
|
||||
type->name = v->name;
|
||||
|
||||
if ((type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR)
|
||||
&& (type->modifiers & HLSL_MODIFIER_ROW_MAJOR))
|
||||
hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
|
||||
"'row_major' and 'column_major' modifiers are mutually exclusive.");
|
||||
|
||||
ret = hlsl_scope_add_type(ctx->cur_scope, type);
|
||||
if (!ret)
|
||||
hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
|
||||
@ -4065,7 +4054,7 @@ struct_declaration:
|
||||
"Modifiers are not allowed on struct type declarations.");
|
||||
}
|
||||
|
||||
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1)))
|
||||
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1)))
|
||||
YYABORT;
|
||||
$$ = declare_vars(ctx, type, modifiers, &@1, $3);
|
||||
}
|
||||
@ -4150,7 +4139,7 @@ field:
|
||||
struct hlsl_type *type;
|
||||
unsigned int modifiers = $1;
|
||||
|
||||
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1)))
|
||||
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1)))
|
||||
YYABORT;
|
||||
if (modifiers & ~HLSL_STORAGE_NOINTERPOLATION)
|
||||
{
|
||||
@ -4300,7 +4289,7 @@ func_prototype_no_attrs:
|
||||
if (modifiers & ~HLSL_MODIFIERS_MAJORITY_MASK)
|
||||
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
|
||||
"Only majority modifiers are allowed on functions.");
|
||||
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1)))
|
||||
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1)))
|
||||
YYABORT;
|
||||
if ((var = hlsl_get_var(ctx->globals, $3)))
|
||||
{
|
||||
@ -4526,7 +4515,7 @@ parameter:
|
||||
struct hlsl_type *type;
|
||||
unsigned int i;
|
||||
|
||||
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1)))
|
||||
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1)))
|
||||
YYABORT;
|
||||
|
||||
$$.modifiers = modifiers;
|
||||
@ -4758,9 +4747,20 @@ typedef_type:
|
||||
typedef:
|
||||
KW_TYPEDEF var_modifiers typedef_type type_specs ';'
|
||||
{
|
||||
if ($2 & ~HLSL_TYPE_MODIFIERS_MASK)
|
||||
struct parse_variable_def *v, *v_next;
|
||||
unsigned int modifiers = $2;
|
||||
struct hlsl_type *type;
|
||||
|
||||
if (!(type = apply_type_modifiers(ctx, $3, &modifiers, false, &@2)))
|
||||
{
|
||||
LIST_FOR_EACH_ENTRY_SAFE(v, v_next, $4, struct parse_variable_def, entry)
|
||||
free_parse_variable_def(v);
|
||||
vkd3d_free($4);
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
if (modifiers)
|
||||
{
|
||||
struct parse_variable_def *v, *v_next;
|
||||
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
|
||||
"Storage modifiers are not allowed on typedefs.");
|
||||
LIST_FOR_EACH_ENTRY_SAFE(v, v_next, $4, struct parse_variable_def, entry)
|
||||
@ -4768,7 +4768,7 @@ typedef:
|
||||
vkd3d_free($4);
|
||||
YYABORT;
|
||||
}
|
||||
if (!add_typedef(ctx, $2, $3, $4))
|
||||
if (!add_typedef(ctx, type, $4))
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
@ -4800,7 +4800,7 @@ declaration:
|
||||
struct hlsl_type *type;
|
||||
unsigned int modifiers = $1;
|
||||
|
||||
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1)))
|
||||
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1)))
|
||||
YYABORT;
|
||||
$$ = declare_vars(ctx, type, modifiers, &@1, $3);
|
||||
}
|
||||
|
@ -112,12 +112,12 @@ float4 main() : sv_target
|
||||
uniform 0 float4 0.1 0.2 0.0 0.0
|
||||
uniform 4 float4 0.3 0.4 0.0 0.0
|
||||
draw quad
|
||||
todo probe all rgba (0.1, 0.2, 0.3, 0.4)
|
||||
probe all rgba (0.1, 0.2, 0.3, 0.4)
|
||||
|
||||
|
||||
% In fact, it's illegal to specify a contradictory majority.
|
||||
|
||||
[pixel shader fail todo]
|
||||
[pixel shader fail]
|
||||
#pragma pack_matrix(row_major)
|
||||
typedef float2x2 mat_t;
|
||||
uniform column_major mat_t m;
|
||||
|
Loading…
x
Reference in New Issue
Block a user