From: Henri Verbeet hverbeet@codeweavers.com
--- libs/vkd3d-shader/hlsl.c | 16 ++++++++-------- libs/vkd3d-shader/hlsl.h | 10 +++++++--- libs/vkd3d-shader/hlsl.y | 16 ++++++++-------- libs/vkd3d-shader/hlsl_codegen.c | 2 +- libs/vkd3d-shader/tpf.c | 6 +++--- 5 files changed, 27 insertions(+), 23 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index edd99238d..60ed77ab5 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -751,7 +751,7 @@ struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_ type->dimx = 4; type->dimy = 1; type->sampler_dim = dim; - type->e.resource_format = format; + type->e.resource.format = format; type->sample_count = sample_count; hlsl_type_calculate_reg_size(ctx, type); list_add_tail(&ctx->types, &type->entry); @@ -771,7 +771,7 @@ struct hlsl_type *hlsl_new_uav_type(struct hlsl_ctx *ctx, type->dimy = 1; type->sampler_dim = dim; type->modifiers = modifiers; - type->e.resource_format = format; + type->e.resource.format = format; hlsl_type_calculate_reg_size(ctx, type); list_add_tail(&ctx->types, &type->entry); return type; @@ -888,7 +888,7 @@ bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2 if (t1->sampler_dim != t2->sampler_dim) return false; if (t1->base_type == HLSL_TYPE_TEXTURE && t1->sampler_dim != HLSL_SAMPLER_DIM_GENERIC - && !hlsl_types_are_equal(t1->e.resource_format, t2->e.resource_format)) + && !hlsl_types_are_equal(t1->e.resource.format, t2->e.resource.format)) return false; } if ((t1->modifiers & HLSL_MODIFIER_ROW_MAJOR) @@ -1009,7 +1009,7 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old, if (type->base_type == HLSL_TYPE_TECHNIQUE) type->e.version = old->e.version; if (old->base_type == HLSL_TYPE_TEXTURE || old->base_type == HLSL_TYPE_UAV) - type->e.resource_format = old->e.resource_format; + type->e.resource.format = old->e.resource.format; break;
default: @@ -1573,7 +1573,7 @@ struct hlsl_ir_node *hlsl_new_index(struct hlsl_ctx *ctx, struct hlsl_ir_node *v return NULL;
if (type->class == HLSL_CLASS_OBJECT) - type = type->e.resource_format; + type = type->e.resource.format; else if (type->class == HLSL_CLASS_MATRIX) type = hlsl_get_vector_type(ctx, type->base_type, type->dimx); else @@ -2201,7 +2201,7 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru return string; }
- assert(type->e.resource_format->base_type < ARRAY_SIZE(base_types)); + assert(type->e.resource.format->base_type < ARRAY_SIZE(base_types)); if (type->sampler_dim == HLSL_SAMPLER_DIM_BUFFER) { vkd3d_string_buffer_printf(string, "Buffer"); @@ -2211,7 +2211,7 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru assert(type->sampler_dim < ARRAY_SIZE(dimensions)); vkd3d_string_buffer_printf(string, "Texture%s", dimensions[type->sampler_dim]); } - if ((inner_string = hlsl_type_to_string(ctx, type->e.resource_format))) + if ((inner_string = hlsl_type_to_string(ctx, type->e.resource.format))) { vkd3d_string_buffer_printf(string, "<%s>", inner_string->buffer); hlsl_release_string_buffer(ctx, inner_string); @@ -2225,7 +2225,7 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru vkd3d_string_buffer_printf(string, "RWStructuredBuffer"); else vkd3d_string_buffer_printf(string, "RWTexture%s", dimensions[type->sampler_dim]); - if ((inner_string = hlsl_type_to_string(ctx, type->e.resource_format))) + if ((inner_string = hlsl_type_to_string(ctx, type->e.resource.format))) { vkd3d_string_buffer_printf(string, "<%s>", inner_string->buffer); hlsl_release_string_buffer(ctx, inner_string); diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 0b9218ba7..5deac632b 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -194,9 +194,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. */ - struct hlsl_type *resource_format; + /* Additional information if the base_type is HLSL_TYPE_TEXTURE or + * HLSL_TYPE_UAV. */ + struct + { + /* Format of the data contained within the type. */ + struct hlsl_type *format; + } resource; /* Additional field to distinguish object types. Currently used only for technique types. */ unsigned int version; } e; diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 000e14b6d..5a5f77ed3 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1942,7 +1942,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct hlsl_blo
dim_count = hlsl_sampler_dim_count(resource_type->sampler_dim);
- if (writemask != ((1u << resource_type->e.resource_format->dimx) - 1)) + if (writemask != ((1u << resource_type->e.resource.format->dimx) - 1)) hlsl_error(ctx, &lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_WRITEMASK, "Resource store expressions must write to all components.");
@@ -4308,7 +4308,7 @@ static bool add_load_method_call(struct hlsl_ctx *ctx, struct hlsl_block *block, hlsl_get_vector_type(ctx, HLSL_TYPE_INT, sampler_dim + !multisampled), loc))) return false;
- load_params.format = object_type->e.resource_format; + load_params.format = object_type->e.resource.format; load_params.resource = object;
if (!(load = hlsl_new_resource_load(ctx, &load_params, loc))) @@ -4366,7 +4366,7 @@ static bool add_sample_method_call(struct hlsl_ctx *ctx, struct hlsl_block *bloc if (params->args_count > 3 + !!offset_dim) hlsl_fixme(ctx, loc, "Tiled resource status argument.");
- load_params.format = object_type->e.resource_format; + load_params.format = object_type->e.resource.format; load_params.resource = object; load_params.sampler = params->args[0];
@@ -4436,7 +4436,7 @@ static bool add_sample_cmp_method_call(struct hlsl_ctx *ctx, struct hlsl_block * if (params->args_count > 4 + !!offset_dim) hlsl_fixme(ctx, loc, "Tiled resource status argument.");
- load_params.format = object_type->e.resource_format; + load_params.format = object_type->e.resource.format; load_params.resource = object; load_params.sampler = params->args[0];
@@ -4526,7 +4526,7 @@ static bool add_gather_method_call(struct hlsl_ctx *ctx, struct hlsl_block *bloc return false; }
- if (read_channel >= object_type->e.resource_format->dimx) + if (read_channel >= object_type->e.resource.format->dimx) { hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Method %s() requires at least %u channels.", name, read_channel + 1); @@ -4537,7 +4537,7 @@ static bool add_gather_method_call(struct hlsl_ctx *ctx, struct hlsl_block *bloc hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, sampler_dim), loc))) return false;
- load_params.format = hlsl_get_vector_type(ctx, object_type->e.resource_format->base_type, 4); + load_params.format = hlsl_get_vector_type(ctx, object_type->e.resource.format->base_type, 4); load_params.resource = object; load_params.sampler = params->args[0];
@@ -4781,7 +4781,7 @@ static bool add_sample_lod_method_call(struct hlsl_ctx *ctx, struct hlsl_block * if (params->args_count > 3 + !!offset_dim) hlsl_fixme(ctx, loc, "Tiled resource status argument.");
- load_params.format = object_type->e.resource_format; + load_params.format = object_type->e.resource.format; load_params.resource = object; load_params.sampler = params->args[0];
@@ -4848,7 +4848,7 @@ static bool add_sample_grad_method_call(struct hlsl_ctx *ctx, struct hlsl_block if (params->args_count > 4 + !!offset_dim) hlsl_fixme(ctx, loc, "Tiled resource status argument.");
- load_params.format = object_type->e.resource_format; + load_params.format = object_type->e.resource.format; load_params.resource = object; load_params.sampler = params->args[0];
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 7da427796..307f86f55 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -1107,7 +1107,7 @@ static bool lower_index_loads(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, params.type = HLSL_RESOURCE_LOAD; params.resource = val; params.coords = coords; - params.format = val->data_type->e.resource_format; + params.format = val->data_type->e.resource.format;
if (!(resource_load = hlsl_new_resource_load(ctx, ¶ms, &instr->loc))) return false; diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index 492e5ec02..6561f1fbd 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -3156,7 +3156,7 @@ static D3D_RESOURCE_RETURN_TYPE sm4_resource_format(const struct hlsl_type *type if (type->class == HLSL_CLASS_ARRAY) return sm4_resource_format(type->e.array.type);
- switch (type->e.resource_format->base_type) + switch (type->e.resource.format->base_type) { case HLSL_TYPE_DOUBLE: return D3D_RETURN_TYPE_DOUBLE; @@ -3446,7 +3446,7 @@ static void write_sm4_rdef(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc) } else { - unsigned int dimx = hlsl_type_get_component_type(ctx, resource->data_type, 0)->e.resource_format->dimx; + unsigned int dimx = hlsl_type_get_component_type(ctx, resource->data_type, 0)->e.resource.format->dimx;
put_u32(&buffer, sm4_resource_format(resource->data_type)); put_u32(&buffer, sm4_rdef_resource_dimension(resource->data_type)); @@ -4253,7 +4253,7 @@ static void write_sm4_dcl_textures(const struct tpf_writer *tpf, const struct ex { case HLSL_SAMPLER_DIM_STRUCTURED_BUFFER: instr.opcode = VKD3D_SM5_OP_DCL_UAV_STRUCTURED; - instr.byte_stride = resource->data_type->e.resource_format->reg_size[HLSL_REGSET_NUMERIC] * 4; + instr.byte_stride = resource->data_type->e.resource.format->reg_size[HLSL_REGSET_NUMERIC] * 4; break; default: instr.opcode = VKD3D_SM5_OP_DCL_UAV_TYPED;
From: Henri Verbeet hverbeet@codeweavers.com
--- libs/vkd3d-shader/hlsl.c | 11 ++++++++--- libs/vkd3d-shader/hlsl.h | 9 +++++---- libs/vkd3d-shader/hlsl.y | 4 ++-- libs/vkd3d-shader/tpf.c | 6 +++--- 4 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 60ed77ab5..353e34d21 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -758,8 +758,8 @@ 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, uint32_t modifiers) +struct hlsl_type *hlsl_new_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, + struct hlsl_type *format, bool rasteriser_ordered) { struct hlsl_type *type;
@@ -770,8 +770,8 @@ struct hlsl_type *hlsl_new_uav_type(struct hlsl_ctx *ctx, type->dimx = format->dimx; type->dimy = 1; type->sampler_dim = dim; - type->modifiers = modifiers; type->e.resource.format = format; + type->e.resource.rasteriser_ordered = rasteriser_ordered; hlsl_type_calculate_reg_size(ctx, type); list_add_tail(&ctx->types, &type->entry); return type; @@ -890,6 +890,8 @@ bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2 if (t1->base_type == HLSL_TYPE_TEXTURE && t1->sampler_dim != HLSL_SAMPLER_DIM_GENERIC && !hlsl_types_are_equal(t1->e.resource.format, t2->e.resource.format)) return false; + if (t1->base_type == HLSL_TYPE_UAV && t1->e.resource.rasteriser_ordered != t2->e.resource.rasteriser_ordered) + return false; } if ((t1->modifiers & HLSL_MODIFIER_ROW_MAJOR) != (t2->modifiers & HLSL_MODIFIER_ROW_MAJOR)) @@ -1009,7 +1011,10 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old, if (type->base_type == HLSL_TYPE_TECHNIQUE) type->e.version = old->e.version; if (old->base_type == HLSL_TYPE_TEXTURE || old->base_type == HLSL_TYPE_UAV) + { type->e.resource.format = old->e.resource.format; + type->e.resource.rasteriser_ordered = old->e.resource.rasteriser_ordered; + } break;
default: diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 5deac632b..5b73857b9 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -200,6 +200,8 @@ struct hlsl_type { /* Format of the data contained within the type. */ struct hlsl_type *format; + /* The type is a rasteriser-ordered view. */ + bool rasteriser_ordered; } resource; /* Additional field to distinguish object types. Currently used only for technique types. */ unsigned int version; @@ -370,11 +372,10 @@ struct hlsl_attribute #define HLSL_STORAGE_CENTROID 0x00004000 #define HLSL_STORAGE_NOPERSPECTIVE 0x00008000 #define HLSL_STORAGE_LINEAR 0x00010000 -#define HLSL_MODIFIER_RASTERIZER_ORDERED 0x00020000
#define HLSL_TYPE_MODIFIERS_MASK (HLSL_MODIFIER_PRECISE | HLSL_MODIFIER_VOLATILE | \ HLSL_MODIFIER_CONST | HLSL_MODIFIER_ROW_MAJOR | \ - HLSL_MODIFIER_COLUMN_MAJOR | HLSL_MODIFIER_RASTERIZER_ORDERED) + HLSL_MODIFIER_COLUMN_MAJOR)
#define HLSL_INTERPOLATION_MODIFIERS_MASK (HLSL_STORAGE_NOINTERPOLATION | HLSL_STORAGE_CENTROID | \ HLSL_STORAGE_NOPERSPECTIVE | HLSL_STORAGE_LINEAR) @@ -1282,8 +1283,8 @@ struct hlsl_ir_var *hlsl_new_synthetic_var_named(struct hlsl_ctx *ctx, const cha struct hlsl_type *type, const struct vkd3d_shader_location *loc, bool dummy_scope); 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, uint32_t modifiers); +struct hlsl_type *hlsl_new_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, + struct hlsl_type *format, bool rasteriser_ordered); struct hlsl_ir_node *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 5a5f77ed3..dc7b4c1bc 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -6263,12 +6263,12 @@ type_no_void: | uav_type '<' type '>' { validate_uav_type(ctx, $1, $3, &@3); - $$ = hlsl_new_uav_type(ctx, $1, $3, 0); + $$ = hlsl_new_uav_type(ctx, $1, $3, false); } | rov_type '<' type '>' { validate_uav_type(ctx, $1, $3, &@3); - $$ = hlsl_new_uav_type(ctx, $1, $3, HLSL_MODIFIER_RASTERIZER_ORDERED); + $$ = hlsl_new_uav_type(ctx, $1, $3, true); } | TYPE_IDENTIFIER { diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index 6561f1fbd..10dde9852 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -4259,6 +4259,9 @@ static void write_sm4_dcl_textures(const struct tpf_writer *tpf, const struct ex instr.opcode = VKD3D_SM5_OP_DCL_UAV_TYPED; break; } + + if (resource->data_type->e.resource.rasteriser_ordered) + instr.opcode |= VKD3DSUF_RASTERISER_ORDERED_VIEW << VKD3D_SM5_UAV_FLAGS_SHIFT; } else { @@ -4272,9 +4275,6 @@ static void write_sm4_dcl_textures(const struct tpf_writer *tpf, const struct ex instr.extra_bits |= component_type->sample_count << VKD3D_SM4_RESOURCE_SAMPLE_COUNT_SHIFT; }
- if (resource->data_type->modifiers & HLSL_MODIFIER_RASTERIZER_ORDERED) - instr.opcode |= VKD3DSUF_RASTERISER_ORDERED_VIEW << VKD3D_SM5_UAV_FLAGS_SHIFT; - write_sm4_instruction(tpf, &instr); } }
This merge request was approved by Giovanni Mascellani.
This merge request was approved by Henri Verbeet.