vkd3d-shader/hlsl: Handle "unsigned int" type.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov
2024-05-18 23:29:58 +02:00
committed by Alexandre Julliard
parent 36c123c005
commit ea177a7750
Notes: Alexandre Julliard 2024-05-30 23:26:49 +02:00
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/871
4 changed files with 90 additions and 1 deletions

View File

@@ -49,7 +49,7 @@ static void update_location(struct hlsl_ctx *ctx, YYLTYPE *loc);
RESERVED1 auto|catch|char|class|const_cast|delete|dynamic_cast|enum
RESERVED2 explicit|friend|goto|long|mutable|new|operator|private|protected|public
RESERVED3 reinterpret_cast|short|signed|sizeof|static_cast|template|this|throw|try
RESERVED4 typename|union|unsigned|using|virtual
RESERVED4 typename|union|using|virtual
WS [ \t]
NEWLINE (\n)|(\r\n)
@@ -164,6 +164,7 @@ textureCUBE {return KW_TEXTURECUBE; }
TextureCubeArray {return KW_TEXTURECUBEARRAY; }
true {return KW_TRUE; }
typedef {return KW_TYPEDEF; }
unsigned {return KW_UNSIGNED; }
uniform {return KW_UNIFORM; }
vector {return KW_VECTOR; }
VertexShader {return KW_VERTEXSHADER; }

View File

@@ -5566,6 +5566,7 @@ static bool state_block_add_entry(struct hlsl_state_block *state_block, struct h
%token KW_TEXTURECUBEARRAY
%token KW_TRUE
%token KW_TYPEDEF
%token KW_UNSIGNED
%token KW_UNIFORM
%token KW_VECTOR
%token KW_VERTEXSHADER
@@ -6713,6 +6714,26 @@ type_no_void:
}
vkd3d_free($1);
}
| KW_UNSIGNED TYPE_IDENTIFIER
{
struct hlsl_type *type = hlsl_get_type(ctx->cur_scope, $2, true, true);
if (hlsl_is_numeric_type(type) && type->e.numeric.type == HLSL_TYPE_INT)
{
if (!(type = hlsl_type_clone(ctx, type, 0, 0)))
YYABORT;
vkd3d_free((void *)type->name);
type->name = NULL;
type->e.numeric.type = HLSL_TYPE_UINT;
}
else
{
hlsl_error(ctx, &@2, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"The 'unsigned' keyword can't be used with type %s.", $2);
}
$$ = type;
}
| KW_STRUCT TYPE_IDENTIFIER
{
$$ = hlsl_get_type(ctx->cur_scope, $2, true, true);