From: Nikolay Sivov nsivov@codeweavers.com
--- libs/vkd3d-shader/hlsl.h | 2 ++ libs/vkd3d-shader/hlsl.y | 55 +++++++++++++++++++++++++++++++--------- 2 files changed, 45 insertions(+), 12 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 24d0f517..e97c2521 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -166,6 +166,8 @@ struct hlsl_type * Otherwise both dimx = 1 and dimy = 1. */ unsigned int dimx; unsigned int dimy; + /* Sample count for HLSL_SAMPLER_DIM_2DMS or HLSL_SAMPLER_DIM_2DMSARRAY. */ + unsigned int sample_count;
union { diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index e011ea24..3d7be51a 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1122,7 +1122,7 @@ static struct list *make_list(struct hlsl_ctx *ctx, struct hlsl_ir_node *node) return list; }
-static unsigned int evaluate_array_dimension(struct hlsl_ir_node *node) +static unsigned int evaluate_static_expression(struct hlsl_ir_node *node) { if (node->data_type->type != HLSL_CLASS_SCALAR) return 0; @@ -3729,6 +3729,21 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl } }
+static void validate_texture_format_type(struct hlsl_ctx *ctx, struct hlsl_type *format, + const struct vkd3d_shader_location *loc) +{ + if (format->type > HLSL_CLASS_VECTOR) + { + struct vkd3d_string_buffer *string; + + string = hlsl_type_to_string(ctx, format); + if (string) + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + "Texture data type %s is not scalar or vector.", string->buffer); + hlsl_release_string_buffer(ctx, string); + } +} + }
%locations @@ -3949,7 +3964,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
%type <reg_reservation> register_opt
-%type <sampler_dim> texture_type uav_type +%type <sampler_dim> texture_type texture_ms_type uav_type
%type <semantic> semantic
@@ -4562,6 +4577,16 @@ texture_type: $$ = HLSL_SAMPLER_DIM_CUBEARRAY; }
+texture_ms_type: + KW_TEXTURE2DMS + { + $$ = HLSL_SAMPLER_DIM_2DMS; + } + | KW_TEXTURE2DMSARRAY + { + $$ = HLSL_SAMPLER_DIM_2DMSARRAY; + } + uav_type: KW_RWTEXTURE1D { @@ -4667,18 +4692,24 @@ type_no_void: } | texture_type '<' type '>' { - if ($3->type > HLSL_CLASS_VECTOR) - { - struct vkd3d_string_buffer *string; + validate_texture_format_type(ctx, $3, &@3); + $$ = hlsl_new_texture_type(ctx, $1, $3); + } + | texture_ms_type '<' type '>' + { + validate_texture_format_type(ctx, $3, &@3);
- string = hlsl_type_to_string(ctx, $3); - if (string) - hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, - "Texture data type %s is not scalar or vector.", string->buffer); - hlsl_release_string_buffer(ctx, string); - } + /* TODO: unspecified sample count is not allowed for all targets */ $$ = hlsl_new_texture_type(ctx, $1, $3); } + | texture_ms_type '<' type ',' shift_expr '>' + { + unsigned int sample_count = evaluate_static_expression(node_from_list($5)); + destroy_instr_list($5); + + if (($$ = hlsl_new_texture_type(ctx, $1, $3))) + $$->sample_count = sample_count; + } | uav_type '<' type '>' { if ($3->type > HLSL_CLASS_VECTOR) @@ -4868,7 +4899,7 @@ arrays: } | '[' expr ']' arrays { - unsigned int size = evaluate_array_dimension(node_from_list($2)); + unsigned int size = evaluate_static_expression(node_from_list($2)); uint32_t *new_array;
destroy_instr_list($2);