From: Nikolay Sivov nsivov@codeweavers.com
--- libs/vkd3d-shader/hlsl.c | 18 +++++++++++++++--- libs/vkd3d-shader/hlsl.h | 18 +++++++++++++++--- libs/vkd3d-shader/hlsl.y | 15 ++++++++++----- 3 files changed, 40 insertions(+), 11 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index fbe555c9..df8ae331 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -664,7 +664,7 @@ struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_ return type; }
-struct hlsl_type *hlsl_new_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format) +struct hlsl_type *hlsl_new_uav_type(struct hlsl_ctx *ctx, enum hlsl_uav_type uav_type, struct hlsl_type *format) { struct hlsl_type *type;
@@ -674,8 +674,20 @@ struct hlsl_type *hlsl_new_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim type->base_type = HLSL_TYPE_UAV; type->dimx = format->dimx; type->dimy = 1; - type->sampler_dim = dim; - type->e.resource_format = format; + switch (uav_type) + { + case HLSL_UAV_RWTEXTURE2D: + type->sampler_dim = HLSL_SAMPLER_DIM_2D; + break; + case HLSL_UAV_RWTEXTURE3D: + type->sampler_dim = HLSL_SAMPLER_DIM_3D; + break; + default: + type->sampler_dim = HLSL_SAMPLER_DIM_1D; + break; + } + type->e.uav.format = format; + type->e.uav.uav_type = uav_type; hlsl_type_calculate_reg_size(ctx, type); list_add_tail(&ctx->types, &type->entry); return type; diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 0256339c..7186ddd3 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -118,6 +118,13 @@ enum hlsl_sampler_dim HLSL_SAMPLER_DIM_MAX = HLSL_SAMPLER_DIM_CUBEARRAY, };
+enum hlsl_uav_type +{ + HLSL_UAV_RWTEXTURE1D, + HLSL_UAV_RWTEXTURE2D, + HLSL_UAV_RWTEXTURE3D, +}; + enum hlsl_regset { HLSL_REGSET_SAMPLERS, @@ -186,8 +193,13 @@ struct hlsl_type /* Array length, or HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT if it is not known yet at parse time. */ unsigned int elements_count; } array; - /* Format of the data contained within the type if the base_type is HLSL_TYPE_TEXTURE or - * HLSL_TYPE_UAV. */ + /* Additional information if type is HLSL_TYPE_UAV. */ + struct + { + struct hlsl_type *format; + enum hlsl_uav_type uav_type; + } uav; + /* Format of the data contained within the type if the base_type is HLSL_TYPE_TEXTURE */ struct hlsl_type *resource_format; } e;
@@ -1122,7 +1134,7 @@ struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *tem struct hlsl_type *type, const struct vkd3d_shader_location *loc); struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format, unsigned int sample_count); -struct hlsl_type *hlsl_new_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format); +struct hlsl_type *hlsl_new_uav_type(struct hlsl_ctx *ctx, enum hlsl_uav_type type, struct hlsl_type *format); struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n, const struct vkd3d_shader_location *loc); struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index ab0b3f65..3741761d 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -781,7 +781,10 @@ static bool add_array_access(struct hlsl_ctx *ctx, struct list *instrs, struct h if (!(index = add_zero_mipmap_level(ctx, instrs, index, dim_count, loc))) return false;
- load_params.format = expr_type->e.resource_format; + if (expr_type->base_type == HLSL_TYPE_TEXTURE) + load_params.format = expr_type->e.resource_format; + else + load_params.format = expr_type->e.uav.format; load_params.resource = array; load_params.coords = index;
@@ -4111,6 +4114,7 @@ static void validate_texture_format_type(struct hlsl_ctx *ctx, struct hlsl_type struct hlsl_semantic semantic; enum hlsl_buffer_type buffer_type; enum hlsl_sampler_dim sampler_dim; + enum hlsl_uav_type uav_type; struct hlsl_attribute *attr; struct parse_attribute_list attr_list; } @@ -4300,7 +4304,8 @@ static void validate_texture_format_type(struct hlsl_ctx *ctx, struct hlsl_type %type <reg_reservation> register_opt %type <reg_reservation> packoffset_opt
-%type <sampler_dim> texture_type texture_ms_type uav_type +%type <sampler_dim> texture_type texture_ms_type +%type <uav_type> uav_type
%type <semantic> semantic
@@ -4962,15 +4967,15 @@ texture_ms_type: uav_type: KW_RWTEXTURE1D { - $$ = HLSL_SAMPLER_DIM_1D; + $$ = HLSL_UAV_RWTEXTURE1D; } | KW_RWTEXTURE2D { - $$ = HLSL_SAMPLER_DIM_2D; + $$ = HLSL_UAV_RWTEXTURE2D; } | KW_RWTEXTURE3D { - $$ = HLSL_SAMPLER_DIM_3D; + $$ = HLSL_UAV_RWTEXTURE3D; }
type_no_void: