From cf27065b7d94c8947cd3ee6c8bcffcf1f98cafe4 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 25 Oct 2024 08:39:49 +0200 Subject: [PATCH] vkd3d-shader/hlsl: Add parser support for the RWByteAddressBuffer type. Signed-off-by: Nikolay Sivov --- libs/vkd3d-shader/hlsl.c | 5 +++++ libs/vkd3d-shader/hlsl.h | 4 +++- libs/vkd3d-shader/hlsl.l | 1 + libs/vkd3d-shader/hlsl.y | 32 +++++++++++++++++++------------- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index d0cfc285..1f90a4ba 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -2799,6 +2799,11 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru return string; case HLSL_CLASS_UAV: + if (type->sampler_dim == HLSL_SAMPLER_DIM_RAW_BUFFER) + { + vkd3d_string_buffer_printf(string, "RWByteAddressBuffer"); + return string; + } if (type->sampler_dim == HLSL_SAMPLER_DIM_BUFFER) vkd3d_string_buffer_printf(string, "RWBuffer"); else if (type->sampler_dim == HLSL_SAMPLER_DIM_STRUCTURED_BUFFER) diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index af3999e6..be63e742 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -136,7 +136,8 @@ enum hlsl_sampler_dim HLSL_SAMPLER_DIM_CUBEARRAY, HLSL_SAMPLER_DIM_BUFFER, HLSL_SAMPLER_DIM_STRUCTURED_BUFFER, - HLSL_SAMPLER_DIM_MAX = HLSL_SAMPLER_DIM_STRUCTURED_BUFFER, + HLSL_SAMPLER_DIM_RAW_BUFFER, + HLSL_SAMPLER_DIM_MAX = HLSL_SAMPLER_DIM_RAW_BUFFER, /* NOTE: Remember to update object_methods[] in hlsl.y if this enum is modified. */ }; @@ -1394,6 +1395,7 @@ static inline unsigned int hlsl_sampler_dim_count(enum hlsl_sampler_dim dim) { case HLSL_SAMPLER_DIM_1D: case HLSL_SAMPLER_DIM_BUFFER: + case HLSL_SAMPLER_DIM_RAW_BUFFER: case HLSL_SAMPLER_DIM_STRUCTURED_BUFFER: return 1; case HLSL_SAMPLER_DIM_1DARRAY: diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l index ca983fc5..18effcc5 100644 --- a/libs/vkd3d-shader/hlsl.l +++ b/libs/vkd3d-shader/hlsl.l @@ -127,6 +127,7 @@ RenderTargetView {return KW_RENDERTARGETVIEW; } return {return KW_RETURN; } row_major {return KW_ROW_MAJOR; } RWBuffer {return KW_RWBUFFER; } +RWByteAddressBuffer {return KW_RWBYTEADDRESSBUFFER; } RWStructuredBuffer {return KW_RWSTRUCTUREDBUFFER; } RWTexture1D {return KW_RWTEXTURE1D; } RWTexture1DArray {return KW_RWTEXTURE1DARRAY; } diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 53b0f673..34e58f34 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -5579,6 +5579,7 @@ static unsigned int hlsl_offset_dim_count(enum hlsl_sampler_dim dim) case HLSL_SAMPLER_DIM_CUBE: case HLSL_SAMPLER_DIM_CUBEARRAY: case HLSL_SAMPLER_DIM_BUFFER: + case HLSL_SAMPLER_DIM_RAW_BUFFER: /* Offset parameters not supported for these types. */ return 0; default: @@ -6205,22 +6206,22 @@ static const struct method_function } object_methods[] = { - { "Gather", add_gather_method_call, "0001010100100" }, - { "GatherAlpha", add_gather_method_call, "0001010100100" }, - { "GatherBlue", add_gather_method_call, "0001010100100" }, - { "GatherGreen", add_gather_method_call, "0001010100100" }, - { "GatherRed", add_gather_method_call, "0001010100100" }, + { "Gather", add_gather_method_call, "00010101001000" }, + { "GatherAlpha", add_gather_method_call, "00010101001000" }, + { "GatherBlue", add_gather_method_call, "00010101001000" }, + { "GatherGreen", add_gather_method_call, "00010101001000" }, + { "GatherRed", add_gather_method_call, "00010101001000" }, - { "GetDimensions", add_getdimensions_method_call, "0011111111111" }, + { "GetDimensions", add_getdimensions_method_call, "00111111111110" }, - { "Load", add_load_method_call, "0011101111011" }, + { "Load", add_load_method_call, "00111011110110" }, - { "Sample", add_sample_method_call, "0011111100100" }, - { "SampleBias", add_sample_lod_method_call, "0011111100100" }, - { "SampleCmp", add_sample_cmp_method_call, "0011111100100" }, - { "SampleCmpLevelZero", add_sample_cmp_method_call, "0011111100100" }, - { "SampleGrad", add_sample_grad_method_call, "0011111100100" }, - { "SampleLevel", add_sample_lod_method_call, "0011111100100" }, + { "Sample", add_sample_method_call, "00111111001000" }, + { "SampleBias", add_sample_lod_method_call, "00111111001000" }, + { "SampleCmp", add_sample_cmp_method_call, "00111111001000" }, + { "SampleCmpLevelZero", add_sample_cmp_method_call, "00111111001000" }, + { "SampleGrad", add_sample_grad_method_call, "00111111001000" }, + { "SampleLevel", add_sample_lod_method_call, "00111111001000" }, }; static int object_method_function_name_compare(const void *a, const void *b) @@ -6492,6 +6493,7 @@ static void validate_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, %token KW_REGISTER %token KW_ROW_MAJOR %token KW_RWBUFFER +%token KW_RWBYTEADDRESSBUFFER %token KW_RWSTRUCTUREDBUFFER %token KW_RWTEXTURE1D %token KW_RWTEXTURE1DARRAY @@ -7806,6 +7808,10 @@ type_no_void: validate_uav_type(ctx, $1, $3, &@4); $$ = hlsl_new_uav_type(ctx, $1, $3, true); } + | KW_RWBYTEADDRESSBUFFER + { + $$ = hlsl_new_uav_type(ctx, HLSL_SAMPLER_DIM_RAW_BUFFER, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), false); + } | KW_STRING { $$ = ctx->builtin_types.string;