mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader/hlsl: Parse primitive type modifiers in geometry shaders.
This commit is contained in:
Notes:
Henri Verbeet
2025-03-12 22:20:50 +01:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1405
@@ -3202,6 +3202,16 @@ struct vkd3d_string_buffer *hlsl_modifiers_to_string(struct hlsl_ctx *ctx, uint3
|
||||
vkd3d_string_buffer_printf(string, "row_major ");
|
||||
if (modifiers & HLSL_MODIFIER_COLUMN_MAJOR)
|
||||
vkd3d_string_buffer_printf(string, "column_major ");
|
||||
if (modifiers & HLSL_PRIMITIVE_POINT)
|
||||
vkd3d_string_buffer_printf(string, "point ");
|
||||
if (modifiers & HLSL_PRIMITIVE_LINE)
|
||||
vkd3d_string_buffer_printf(string, "line ");
|
||||
if (modifiers & HLSL_PRIMITIVE_TRIANGLE)
|
||||
vkd3d_string_buffer_printf(string, "triangle ");
|
||||
if (modifiers & HLSL_PRIMITIVE_LINEADJ)
|
||||
vkd3d_string_buffer_printf(string, "lineadj ");
|
||||
if (modifiers & HLSL_PRIMITIVE_TRIANGLEADJ)
|
||||
vkd3d_string_buffer_printf(string, "triangleadj ");
|
||||
if ((modifiers & (HLSL_STORAGE_IN | HLSL_STORAGE_OUT)) == (HLSL_STORAGE_IN | HLSL_STORAGE_OUT))
|
||||
vkd3d_string_buffer_printf(string, "inout ");
|
||||
else if (modifiers & HLSL_STORAGE_IN)
|
||||
|
@@ -417,6 +417,11 @@ struct hlsl_attribute
|
||||
#define HLSL_STORAGE_ANNOTATION 0x00080000
|
||||
#define HLSL_MODIFIER_UNORM 0x00100000
|
||||
#define HLSL_MODIFIER_SNORM 0x00200000
|
||||
#define HLSL_PRIMITIVE_POINT 0x00400000
|
||||
#define HLSL_PRIMITIVE_LINE 0x00800000
|
||||
#define HLSL_PRIMITIVE_TRIANGLE 0x01000000
|
||||
#define HLSL_PRIMITIVE_LINEADJ 0x02000000
|
||||
#define HLSL_PRIMITIVE_TRIANGLEADJ 0x04000000
|
||||
|
||||
#define HLSL_TYPE_MODIFIERS_MASK (HLSL_MODIFIER_PRECISE | HLSL_MODIFIER_VOLATILE | \
|
||||
HLSL_MODIFIER_CONST | HLSL_MODIFIER_ROW_MAJOR | \
|
||||
@@ -427,6 +432,9 @@ struct hlsl_attribute
|
||||
|
||||
#define HLSL_MODIFIERS_MAJORITY_MASK (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)
|
||||
|
||||
#define HLSL_PRIMITIVE_MODIFIERS_MASK (HLSL_PRIMITIVE_POINT | HLSL_PRIMITIVE_LINE | HLSL_PRIMITIVE_TRIANGLE | \
|
||||
HLSL_PRIMITIVE_LINEADJ | HLSL_PRIMITIVE_TRIANGLEADJ)
|
||||
|
||||
#define HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT 0
|
||||
|
||||
/* Reservation of a register and/or an offset for objects inside constant buffers, to be used as a
|
||||
|
@@ -106,6 +106,8 @@ inline {return KW_INLINE; }
|
||||
inout {return KW_INOUT; }
|
||||
InputPatch {return KW_INPUTPATCH; }
|
||||
LineStream {return KW_LINESTREAM; }
|
||||
line {return KW_LINE; }
|
||||
lineadj {return KW_LINEADJ; }
|
||||
linear {return KW_LINEAR; }
|
||||
matrix {return KW_MATRIX; }
|
||||
namespace {return KW_NAMESPACE; }
|
||||
@@ -119,6 +121,7 @@ pass {return KW_PASS; }
|
||||
PixelShader {return KW_PIXELSHADER; }
|
||||
PointStream {return KW_POINTSTREAM; }
|
||||
pixelshader {return KW_PIXELSHADER; }
|
||||
point {return KW_POINT; }
|
||||
RasterizerOrderedBuffer {return KW_RASTERIZERORDEREDBUFFER; }
|
||||
RasterizerOrderedStructuredBuffer {return KW_RASTERIZERORDEREDSTRUCTUREDBUFFER; }
|
||||
RasterizerOrderedTexture1D {return KW_RASTERIZERORDEREDTEXTURE1D; }
|
||||
@@ -175,6 +178,8 @@ TextureCube {return KW_TEXTURECUBE; }
|
||||
textureCUBE {return KW_TEXTURECUBE; }
|
||||
TextureCubeArray {return KW_TEXTURECUBEARRAY; }
|
||||
TriangleStream {return KW_TRIANGLESTREAM; }
|
||||
triangle {return KW_TRIANGLE; }
|
||||
triangleadj {return KW_TRIANGLEADJ; }
|
||||
true {return KW_TRUE; }
|
||||
typedef {return KW_TYPEDEF; }
|
||||
unsigned {return KW_UNSIGNED; }
|
||||
|
@@ -2401,10 +2401,10 @@ static bool type_has_numeric_components(struct hlsl_type *type)
|
||||
return false;
|
||||
}
|
||||
|
||||
static void check_invalid_in_out_modifiers(struct hlsl_ctx *ctx, unsigned int modifiers,
|
||||
static void check_invalid_non_parameter_modifiers(struct hlsl_ctx *ctx, unsigned int modifiers,
|
||||
const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
modifiers &= (HLSL_STORAGE_IN | HLSL_STORAGE_OUT);
|
||||
modifiers &= (HLSL_STORAGE_IN | HLSL_STORAGE_OUT | HLSL_PRIMITIVE_MODIFIERS_MASK);
|
||||
if (modifiers)
|
||||
{
|
||||
struct vkd3d_string_buffer *string;
|
||||
@@ -6816,6 +6816,8 @@ static void validate_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim,
|
||||
%token KW_INLINE
|
||||
%token KW_INOUT
|
||||
%token KW_INPUTPATCH
|
||||
%token KW_LINE
|
||||
%token KW_LINEADJ
|
||||
%token KW_LINEAR
|
||||
%token KW_LINESTREAM
|
||||
%token KW_MATRIX
|
||||
@@ -6828,6 +6830,7 @@ static void validate_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim,
|
||||
%token KW_PACKOFFSET
|
||||
%token KW_PASS
|
||||
%token KW_PIXELSHADER
|
||||
%token KW_POINT
|
||||
%token KW_POINTSTREAM
|
||||
%token KW_RASTERIZERORDEREDBUFFER
|
||||
%token KW_RASTERIZERORDEREDSTRUCTUREDBUFFER
|
||||
@@ -6878,6 +6881,8 @@ static void validate_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim,
|
||||
%token KW_TEXTURE3D
|
||||
%token KW_TEXTURECUBE
|
||||
%token KW_TEXTURECUBEARRAY
|
||||
%token KW_TRIANGLE
|
||||
%token KW_TRIANGLEADJ
|
||||
%token KW_TRIANGLESTREAM
|
||||
%token KW_TRUE
|
||||
%token KW_TYPEDEF
|
||||
@@ -7885,7 +7890,8 @@ parameter:
|
||||
parameter_decl:
|
||||
var_modifiers type_no_void any_identifier arrays colon_attributes
|
||||
{
|
||||
uint32_t modifiers = $1;
|
||||
uint32_t prim_modifiers = $1 & HLSL_PRIMITIVE_MODIFIERS_MASK;
|
||||
uint32_t modifiers = $1 & ~HLSL_PRIMITIVE_MODIFIERS_MASK;
|
||||
struct hlsl_type *type;
|
||||
unsigned int i;
|
||||
|
||||
@@ -7910,6 +7916,22 @@ parameter_decl:
|
||||
}
|
||||
vkd3d_free($4.sizes);
|
||||
|
||||
if (prim_modifiers && (prim_modifiers & (prim_modifiers - 1)))
|
||||
{
|
||||
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
|
||||
"Primitive type modifiers are mutually exclusive.");
|
||||
prim_modifiers = 0;
|
||||
}
|
||||
|
||||
if (prim_modifiers)
|
||||
{
|
||||
if (type->class != HLSL_CLASS_ARRAY)
|
||||
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
|
||||
"Primitive type modifiers can only be applied to arrays.");
|
||||
else
|
||||
type->modifiers |= prim_modifiers;
|
||||
}
|
||||
|
||||
$$.type = type;
|
||||
|
||||
if (hlsl_version_ge(ctx, 5, 1) && type->class == HLSL_CLASS_ARRAY && hlsl_type_is_resource(type))
|
||||
@@ -8629,7 +8651,7 @@ variable_def_typed:
|
||||
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1)))
|
||||
YYABORT;
|
||||
|
||||
check_invalid_in_out_modifiers(ctx, modifiers, &@1);
|
||||
check_invalid_non_parameter_modifiers(ctx, modifiers, &@1);
|
||||
|
||||
$$ = $3;
|
||||
$$->basic_type = type;
|
||||
@@ -8644,7 +8666,7 @@ variable_def_typed:
|
||||
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, true, &@1)))
|
||||
YYABORT;
|
||||
|
||||
check_invalid_in_out_modifiers(ctx, modifiers, &@1);
|
||||
check_invalid_non_parameter_modifiers(ctx, modifiers, &@1);
|
||||
|
||||
$$ = $3;
|
||||
$$->basic_type = type;
|
||||
@@ -8785,6 +8807,26 @@ var_modifiers:
|
||||
{
|
||||
$$ = add_modifiers(ctx, $2, HLSL_MODIFIER_SNORM, &@1);
|
||||
}
|
||||
| KW_LINE var_modifiers
|
||||
{
|
||||
$$ = add_modifiers(ctx, $2, HLSL_PRIMITIVE_LINE, &@1);
|
||||
}
|
||||
| KW_LINEADJ var_modifiers
|
||||
{
|
||||
$$ = add_modifiers(ctx, $2, HLSL_PRIMITIVE_LINEADJ, &@1);
|
||||
}
|
||||
| KW_POINT var_modifiers
|
||||
{
|
||||
$$ = add_modifiers(ctx, $2, HLSL_PRIMITIVE_POINT, &@1);
|
||||
}
|
||||
| KW_TRIANGLE var_modifiers
|
||||
{
|
||||
$$ = add_modifiers(ctx, $2, HLSL_PRIMITIVE_TRIANGLE, &@1);
|
||||
}
|
||||
| KW_TRIANGLEADJ var_modifiers
|
||||
{
|
||||
$$ = add_modifiers(ctx, $2, HLSL_PRIMITIVE_TRIANGLEADJ, &@1);
|
||||
}
|
||||
| var_identifier var_modifiers
|
||||
{
|
||||
$$ = $2;
|
||||
|
Reference in New Issue
Block a user