From 7534b88a15c803aa6232d8ea5ed65f8e3f835ce9 Mon Sep 17 00:00:00 2001 From: Conor McCarthy Date: Fri, 31 May 2024 23:46:38 +1000 Subject: [PATCH] tests/shader-runner: Set the correct flag and format for raw UAVs. --- tests/hlsl/tgsm.shader_test | 12 ++++---- .../hlsl/uav-rwbyteaddressbuffer.shader_test | 6 ++-- tests/shader_runner.c | 7 +++++ tests/shader_runner.h | 1 + tests/shader_runner_d3d11.c | 29 ++++++++++++++----- tests/shader_runner_d3d12.c | 1 + tests/shader_runner_gl.c | 1 + 7 files changed, 40 insertions(+), 17 deletions(-) diff --git a/tests/hlsl/tgsm.shader_test b/tests/hlsl/tgsm.shader_test index c18e7c1d..a4213597 100644 --- a/tests/hlsl/tgsm.shader_test +++ b/tests/hlsl/tgsm.shader_test @@ -2,8 +2,8 @@ shader model >= 5.0 [uav 1] -format r32 uint -size (buffer, 4) +format r32 typeless +size (raw_buffer, 4) 1 0 0 0 @@ -32,8 +32,8 @@ probe uav 1 (3) rui (99) [uav 1] -format r32 sint -size (buffer, 4) +format r32 typeless +size (raw_buffer, 4) 1 0 0 0 @@ -136,8 +136,8 @@ probe uav 2 (7) ri (4) [uav 1] -format r32 uint -size (buffer, 1) +format r32 typeless +size (raw_buffer, 1) 0 diff --git a/tests/hlsl/uav-rwbyteaddressbuffer.shader_test b/tests/hlsl/uav-rwbyteaddressbuffer.shader_test index 556d0fb3..c7b3be21 100644 --- a/tests/hlsl/uav-rwbyteaddressbuffer.shader_test +++ b/tests/hlsl/uav-rwbyteaddressbuffer.shader_test @@ -2,10 +2,10 @@ shader model >= 5.0 [uav 1] -format r32 float -size (buffer, 4) +format r32 typeless +size (raw_buffer, 4) -0.1 0.2 0.3 0.4 +1 2 3 4 [pixel shader todo] RWByteAddressBuffer u : register(u1); diff --git a/tests/shader_runner.c b/tests/shader_runner.c index c2fc30d1..dd2f0b0d 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -374,6 +374,7 @@ static DXGI_FORMAT parse_format(const char *line, enum texture_data_type *data_t {"r32 float", TEXTURE_DATA_FLOAT, 4, DXGI_FORMAT_R32_FLOAT}, {"r32 sint", TEXTURE_DATA_SINT, 4, DXGI_FORMAT_R32_SINT}, {"r32 uint", TEXTURE_DATA_UINT, 4, DXGI_FORMAT_R32_UINT}, + {"r32 typeless", TEXTURE_DATA_UINT, 4, DXGI_FORMAT_R32_TYPELESS}, }; unsigned int i; @@ -511,6 +512,12 @@ static void parse_resource_directive(struct resource_params *resource, const cha resource->dimension = RESOURCE_DIMENSION_BUFFER; resource->height = 1; } + else if (sscanf(line, "( raw_buffer , %u ) ", &resource->width) == 1) + { + resource->dimension = RESOURCE_DIMENSION_BUFFER; + resource->height = 1; + resource->is_raw = true; + } else if (sscanf(line, "( counter_buffer , %u ) ", &resource->width) == 1) { resource->dimension = RESOURCE_DIMENSION_BUFFER; diff --git a/tests/shader_runner.h b/tests/shader_runner.h index 60dc9ff3..91a499ed 100644 --- a/tests/shader_runner.h +++ b/tests/shader_runner.h @@ -92,6 +92,7 @@ struct resource_params DXGI_FORMAT format; bool is_shadow; + bool is_raw; bool is_uav_counter; enum texture_data_type data_type; unsigned int texel_size; diff --git a/tests/shader_runner_d3d11.c b/tests/shader_runner_d3d11.c index a21f2ea4..941709c4 100644 --- a/tests/shader_runner_d3d11.c +++ b/tests/shader_runner_d3d11.c @@ -333,7 +333,7 @@ static void destroy_test_context(struct d3d11_shader_runner *runner) } static ID3D11Buffer *create_buffer(ID3D11Device *device, unsigned int bind_flags, unsigned int size, - unsigned int stride, const void *data) + bool is_raw, unsigned int stride, const void *data) { D3D11_SUBRESOURCE_DATA resource_data; D3D11_BUFFER_DESC buffer_desc; @@ -344,7 +344,12 @@ static ID3D11Buffer *create_buffer(ID3D11Device *device, unsigned int bind_flags buffer_desc.Usage = D3D11_USAGE_DEFAULT; buffer_desc.BindFlags = bind_flags; buffer_desc.CPUAccessFlags = 0; - buffer_desc.MiscFlags = stride ? D3D11_RESOURCE_MISC_BUFFER_STRUCTURED : 0; + if (is_raw) + buffer_desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS; + else if (stride) + buffer_desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; + else + buffer_desc.MiscFlags = 0; buffer_desc.StructureByteStride = stride; resource_data.pSysMem = data; @@ -443,7 +448,8 @@ static void init_resource_srv_buffer(struct d3d11_shader_runner *runner, struct ID3D11Device *device = runner->device; HRESULT hr; - resource->buffer = create_buffer(device, D3D11_BIND_SHADER_RESOURCE, params->data_size, params->stride, params->data); + resource->buffer = create_buffer(device, D3D11_BIND_SHADER_RESOURCE, params->data_size, params->is_raw, + params->stride, params->data); resource->resource = (ID3D11Resource *)resource->buffer; srv_desc.Format = params->format; @@ -461,7 +467,8 @@ static void init_resource_uav_buffer(struct d3d11_shader_runner *runner, struct ID3D11Device *device = runner->device; HRESULT hr; - resource->buffer = create_buffer(device, D3D11_BIND_UNORDERED_ACCESS, params->data_size, params->stride, params->data); + resource->buffer = create_buffer(device, D3D11_BIND_UNORDERED_ACCESS, params->data_size, params->is_raw, + params->stride, params->data); resource->resource = (ID3D11Resource *)resource->buffer; resource->is_uav_counter = params->is_uav_counter; @@ -469,7 +476,12 @@ static void init_resource_uav_buffer(struct d3d11_shader_runner *runner, struct uav_desc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER; uav_desc.Buffer.FirstElement = 0; uav_desc.Buffer.NumElements = params->data_size / params->texel_size; - uav_desc.Buffer.Flags = params->is_uav_counter ? D3D11_BUFFER_UAV_FLAG_COUNTER : 0; + if (params->is_raw) + uav_desc.Buffer.Flags = D3D11_BUFFER_UAV_FLAG_RAW; + else if (params->is_uav_counter) + uav_desc.Buffer.Flags = D3D11_BUFFER_UAV_FLAG_COUNTER; + else + uav_desc.Buffer.Flags = 0; hr = ID3D11Device_CreateUnorderedAccessView(device, resource->resource, &uav_desc, &resource->uav); ok(hr == S_OK, "Failed to create view, hr %#lx.\n", hr); } @@ -502,7 +514,8 @@ static struct resource *d3d11_runner_create_resource(struct shader_runner *r, co break; case RESOURCE_TYPE_VERTEX_BUFFER: - resource->buffer = create_buffer(device, D3D11_BIND_VERTEX_BUFFER, params->data_size, params->stride, params->data); + resource->buffer = create_buffer(device, D3D11_BIND_VERTEX_BUFFER, params->data_size, params->is_raw, + params->stride, params->data); resource->resource = (ID3D11Resource *)resource->buffer; break; } @@ -568,7 +581,7 @@ static bool d3d11_runner_dispatch(struct shader_runner *r, unsigned int x, unsig ID3D11Buffer *cb; cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, - runner->r.uniform_count * sizeof(*runner->r.uniforms), 0, runner->r.uniforms); + runner->r.uniform_count * sizeof(*runner->r.uniforms), false, 0, runner->r.uniforms); ID3D11DeviceContext_CSSetConstantBuffers(context, 0, 1, &cb); ID3D11Buffer_Release(cb); } @@ -730,7 +743,7 @@ static bool d3d11_runner_draw(struct shader_runner *r, if (runner->r.uniform_count) { cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, - runner->r.uniform_count * sizeof(*runner->r.uniforms), 0, runner->r.uniforms); + runner->r.uniform_count * sizeof(*runner->r.uniforms), false, 0, runner->r.uniforms); ID3D11DeviceContext_VSSetConstantBuffers(context, 0, 1, &cb); ID3D11DeviceContext_PSSetConstantBuffers(context, 0, 1, &cb); if (hs_code) diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c index a9b4f244..8734524f 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -230,6 +230,7 @@ static struct resource *d3d12_runner_create_resource(struct shader_runner *r, co uav_desc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; uav_desc.Buffer.NumElements = params->width * params->height; uav_desc.Buffer.StructureByteStride = params->stride; + uav_desc.Buffer.Flags = params->is_raw ? D3D12_BUFFER_UAV_FLAG_RAW : 0; ID3D12Device_CreateUnorderedAccessView(device, resource->resource, params->is_uav_counter ? resource->resource : NULL, &uav_desc, diff --git a/tests/shader_runner_gl.c b/tests/shader_runner_gl.c index 4a4717a1..a1544336 100644 --- a/tests/shader_runner_gl.c +++ b/tests/shader_runner_gl.c @@ -341,6 +341,7 @@ static const struct format_info *get_format_info(enum DXGI_FORMAT format, bool i {DXGI_FORMAT_D32_FLOAT, 1, false, true, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT}, {DXGI_FORMAT_R32_UINT, 1, true, false, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT}, {DXGI_FORMAT_R32_SINT, 1, true, false, GL_R32I, GL_RED_INTEGER, GL_INT}, + {DXGI_FORMAT_R32_TYPELESS, 1, true, false, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT}, }; for (i = 0; i < ARRAY_SIZE(format_info); ++i)