tests/hlsl: Add UAV counter tests.

This commit is contained in:
Conor McCarthy 2024-03-13 16:36:59 +10:00 committed by Alexandre Julliard
parent 8c15377ffc
commit 52a831ba0d
Notes: Alexandre Julliard 2024-03-18 23:24:56 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/714
6 changed files with 59 additions and 3 deletions

View File

@ -205,6 +205,7 @@ vkd3d_shader_tests = \
tests/hlsl/trunc.shader_test \ tests/hlsl/trunc.shader_test \
tests/hlsl/type-names.shader_test \ tests/hlsl/type-names.shader_test \
tests/hlsl/uav-atomics.shader_test \ tests/hlsl/uav-atomics.shader_test \
tests/hlsl/uav-counter.shader_test \
tests/hlsl/uav-load.shader_test \ tests/hlsl/uav-load.shader_test \
tests/hlsl/uav-out-param.shader_test \ tests/hlsl/uav-out-param.shader_test \
tests/hlsl/uav-rwbuffer.shader_test \ tests/hlsl/uav-rwbuffer.shader_test \

View File

@ -0,0 +1,39 @@
[require]
shader model >= 5.0
[uav 1]
format r32 uint
size (counter_buffer, 1)
0
[compute shader todo]
RWStructuredBuffer<uint> u : register(u1);
[numthreads(4, 1, 1)]
void main()
{
u.IncrementCounter();
}
[test]
todo dispatch 3 1 1
probe uav 1 (0) rui (12)
[uav 1]
format r32 sint
size (counter_buffer, 1)
0
[compute shader todo]
RWStructuredBuffer<int> u : register(u1);
[numthreads(4, 1, 1)]
void main()
{
u.DecrementCounter();
}
[test]
todo dispatch 3 1 1
probe uav 1 (0) ri (-12)

View File

@ -481,6 +481,15 @@ static void parse_resource_directive(struct resource_params *resource, const cha
resource->dimension = RESOURCE_DIMENSION_BUFFER; resource->dimension = RESOURCE_DIMENSION_BUFFER;
resource->height = 1; resource->height = 1;
} }
else if (sscanf(line, "( counter_buffer , %u ) ", &resource->width) == 1)
{
resource->dimension = RESOURCE_DIMENSION_BUFFER;
resource->height = 1;
resource->is_uav_counter = true;
resource->stride = sizeof(uint32_t);
resource->texel_size = resource->stride;
resource->format = DXGI_FORMAT_UNKNOWN;
}
else if (sscanf(line, "( 2d , %u , %u ) ", &resource->width, &resource->height) == 2) else if (sscanf(line, "( 2d , %u , %u ) ", &resource->width, &resource->height) == 2)
{ {
resource->dimension = RESOURCE_DIMENSION_2D; resource->dimension = RESOURCE_DIMENSION_2D;

View File

@ -88,6 +88,7 @@ struct resource_params
DXGI_FORMAT format; DXGI_FORMAT format;
bool is_shadow; bool is_shadow;
bool is_uav_counter;
enum texture_data_type data_type; enum texture_data_type data_type;
unsigned int texel_size; unsigned int texel_size;
unsigned int stride; unsigned int stride;

View File

@ -49,6 +49,7 @@ struct d3d11_resource
ID3D11RenderTargetView *rtv; ID3D11RenderTargetView *rtv;
ID3D11ShaderResourceView *srv; ID3D11ShaderResourceView *srv;
ID3D11UnorderedAccessView *uav; ID3D11UnorderedAccessView *uav;
bool is_uav_counter;
}; };
static struct d3d11_resource *d3d11_resource(struct resource *r) static struct d3d11_resource *d3d11_resource(struct resource *r)
@ -438,12 +439,13 @@ static void init_resource_uav_buffer(struct d3d11_shader_runner *runner, struct
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->stride, params->data);
resource->resource = (ID3D11Resource *)resource->buffer; resource->resource = (ID3D11Resource *)resource->buffer;
resource->is_uav_counter = params->is_uav_counter;
uav_desc.Format = params->format; uav_desc.Format = params->format;
uav_desc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER; uav_desc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
uav_desc.Buffer.FirstElement = 0; uav_desc.Buffer.FirstElement = 0;
uav_desc.Buffer.NumElements = params->data_size / params->texel_size; uav_desc.Buffer.NumElements = params->data_size / params->texel_size;
uav_desc.Buffer.Flags = 0; uav_desc.Buffer.Flags = params->is_uav_counter ? D3D11_BUFFER_UAV_FLAG_COUNTER : 0;
hr = ID3D11Device_CreateUnorderedAccessView(device, resource->resource, &uav_desc, &resource->uav); hr = ID3D11Device_CreateUnorderedAccessView(device, resource->resource, &uav_desc, &resource->uav);
ok(hr == S_OK, "Failed to create view, hr %#lx.\n", hr); ok(hr == S_OK, "Failed to create view, hr %#lx.\n", hr);
} }
@ -754,7 +756,10 @@ static struct resource_readback *d3d11_runner_get_resource_readback(struct shade
assert(0); assert(0);
} }
ID3D11DeviceContext_CopyResource(runner->immediate_context, rb->resource, resource->resource); if (resource->is_uav_counter)
ID3D11DeviceContext_CopyStructureCount(runner->immediate_context, (ID3D11Buffer *)rb->resource, 0, resource->uav);
else
ID3D11DeviceContext_CopyResource(runner->immediate_context, rb->resource, resource->resource);
hr = ID3D11DeviceContext_Map(runner->immediate_context, rb->resource, 0, D3D11_MAP_READ, 0, &map_desc); hr = ID3D11DeviceContext_Map(runner->immediate_context, rb->resource, 0, D3D11_MAP_READ, 0, &map_desc);
ok(hr == S_OK, "Failed to map texture, hr %#lx.\n", hr); ok(hr == S_OK, "Failed to map texture, hr %#lx.\n", hr);

View File

@ -203,7 +203,8 @@ static struct resource *d3d12_runner_create_resource(struct shader_runner *r, co
uav_desc.Buffer.StructureByteStride = params->stride; uav_desc.Buffer.StructureByteStride = params->stride;
ID3D12Device_CreateUnorderedAccessView(device, resource->resource, ID3D12Device_CreateUnorderedAccessView(device, resource->resource,
NULL, &uav_desc, get_cpu_descriptor_handle(test_context, runner->heap, resource->r.slot + MAX_RESOURCES)); params->is_uav_counter ? resource->resource : NULL, &uav_desc,
get_cpu_descriptor_handle(test_context, runner->heap, resource->r.slot + MAX_RESOURCES));
} }
else else
{ {