vkd3d-shader/hlsl: Store the matrix majority as a type modifiers bitmask.

This commit is contained in:
Zebediah Figura 2022-03-29 18:49:10 -05:00 committed by Alexandre Julliard
parent b3c620954b
commit 75ab9d31ef
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
4 changed files with 5 additions and 14 deletions

View File

@ -2973,7 +2973,7 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const char *source_name,
ctx->location.line = ctx->location.column = 1; ctx->location.line = ctx->location.column = 1;
vkd3d_string_buffer_cache_init(&ctx->string_buffers); vkd3d_string_buffer_cache_init(&ctx->string_buffers);
ctx->matrix_majority = HLSL_COLUMN_MAJOR; ctx->matrix_majority = HLSL_MODIFIER_COLUMN_MAJOR;
list_init(&ctx->scopes); list_init(&ctx->scopes);

View File

@ -116,12 +116,6 @@ enum hlsl_sampler_dim
HLSL_SAMPLER_DIM_MAX = HLSL_SAMPLER_DIM_CUBEARRAY, HLSL_SAMPLER_DIM_MAX = HLSL_SAMPLER_DIM_CUBEARRAY,
}; };
enum hlsl_matrix_majority
{
HLSL_COLUMN_MAJOR,
HLSL_ROW_MAJOR
};
enum hlsl_regset enum hlsl_regset
{ {
HLSL_REGSET_SAMPLERS, HLSL_REGSET_SAMPLERS,
@ -735,7 +729,7 @@ struct hlsl_ctx
const struct hlsl_ir_function_decl *cur_function; const struct hlsl_ir_function_decl *cur_function;
/* Default matrix majority for matrix types. Can be set by a pragma within the HLSL source. */ /* Default matrix majority for matrix types. Can be set by a pragma within the HLSL source. */
enum hlsl_matrix_majority matrix_majority; unsigned int matrix_majority;
/* Basic data types stored for convenience. */ /* Basic data types stored for convenience. */
struct struct

View File

@ -233,14 +233,14 @@ row_major {return KW_ROW_MAJOR; }
struct hlsl_ctx *ctx = yyget_extra(yyscanner); struct hlsl_ctx *ctx = yyget_extra(yyscanner);
TRACE("#pragma setting row_major mode.\n"); TRACE("#pragma setting row_major mode.\n");
ctx->matrix_majority = HLSL_ROW_MAJOR; ctx->matrix_majority = HLSL_MODIFIER_ROW_MAJOR;
BEGIN(pp_ignore); BEGIN(pp_ignore);
} }
<pp_pragma>pack_matrix{WS}*\({WS}*column_major{WS}*\) { <pp_pragma>pack_matrix{WS}*\({WS}*column_major{WS}*\) {
struct hlsl_ctx *ctx = yyget_extra(yyscanner); struct hlsl_ctx *ctx = yyget_extra(yyscanner);
TRACE("#pragma setting column_major mode.\n"); TRACE("#pragma setting column_major mode.\n");
ctx->matrix_majority = HLSL_COLUMN_MAJOR; ctx->matrix_majority = HLSL_MODIFIER_COLUMN_MAJOR;
BEGIN(pp_ignore); BEGIN(pp_ignore);
} }
<pp_pragma>{NEWLINE} { <pp_pragma>{NEWLINE} {

View File

@ -886,10 +886,7 @@ static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_
&& !(type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK) && !(type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK)
&& type->type == HLSL_CLASS_MATRIX) && type->type == HLSL_CLASS_MATRIX)
{ {
if (ctx->matrix_majority == HLSL_COLUMN_MAJOR) default_majority = ctx->matrix_majority;
default_majority = HLSL_MODIFIER_COLUMN_MAJOR;
else
default_majority = HLSL_MODIFIER_ROW_MAJOR;
} }
else if (type->type != HLSL_CLASS_MATRIX) else if (type->type != HLSL_CLASS_MATRIX)
{ {