tests/shader-runner: Set the correct flag and format for raw UAVs.

This commit is contained in:
Conor McCarthy 2024-05-31 23:46:38 +10:00 committed by Henri Verbeet
parent 2f88442d7d
commit 7534b88a15
Notes: Henri Verbeet 2024-06-11 17:09:34 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/910
7 changed files with 40 additions and 17 deletions

View File

@ -2,8 +2,8 @@
shader model >= 5.0 shader model >= 5.0
[uav 1] [uav 1]
format r32 uint format r32 typeless
size (buffer, 4) size (raw_buffer, 4)
1 0 0 0 1 0 0 0
@ -32,8 +32,8 @@ probe uav 1 (3) rui (99)
[uav 1] [uav 1]
format r32 sint format r32 typeless
size (buffer, 4) size (raw_buffer, 4)
1 0 0 0 1 0 0 0
@ -136,8 +136,8 @@ probe uav 2 (7) ri (4)
[uav 1] [uav 1]
format r32 uint format r32 typeless
size (buffer, 1) size (raw_buffer, 1)
0 0

View File

@ -2,10 +2,10 @@
shader model >= 5.0 shader model >= 5.0
[uav 1] [uav 1]
format r32 float format r32 typeless
size (buffer, 4) size (raw_buffer, 4)
0.1 0.2 0.3 0.4 1 2 3 4
[pixel shader todo] [pixel shader todo]
RWByteAddressBuffer u : register(u1); RWByteAddressBuffer u : register(u1);

View File

@ -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 float", TEXTURE_DATA_FLOAT, 4, DXGI_FORMAT_R32_FLOAT},
{"r32 sint", TEXTURE_DATA_SINT, 4, DXGI_FORMAT_R32_SINT}, {"r32 sint", TEXTURE_DATA_SINT, 4, DXGI_FORMAT_R32_SINT},
{"r32 uint", TEXTURE_DATA_UINT, 4, DXGI_FORMAT_R32_UINT}, {"r32 uint", TEXTURE_DATA_UINT, 4, DXGI_FORMAT_R32_UINT},
{"r32 typeless", TEXTURE_DATA_UINT, 4, DXGI_FORMAT_R32_TYPELESS},
}; };
unsigned int i; unsigned int i;
@ -511,6 +512,12 @@ 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, "( 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) else if (sscanf(line, "( counter_buffer , %u ) ", &resource->width) == 1)
{ {
resource->dimension = RESOURCE_DIMENSION_BUFFER; resource->dimension = RESOURCE_DIMENSION_BUFFER;

View File

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

View File

@ -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, 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_SUBRESOURCE_DATA resource_data;
D3D11_BUFFER_DESC buffer_desc; 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.Usage = D3D11_USAGE_DEFAULT;
buffer_desc.BindFlags = bind_flags; buffer_desc.BindFlags = bind_flags;
buffer_desc.CPUAccessFlags = 0; 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; buffer_desc.StructureByteStride = stride;
resource_data.pSysMem = data; resource_data.pSysMem = data;
@ -443,7 +448,8 @@ static void init_resource_srv_buffer(struct d3d11_shader_runner *runner, struct
ID3D11Device *device = runner->device; ID3D11Device *device = runner->device;
HRESULT hr; 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; resource->resource = (ID3D11Resource *)resource->buffer;
srv_desc.Format = params->format; 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; ID3D11Device *device = runner->device;
HRESULT hr; 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->resource = (ID3D11Resource *)resource->buffer;
resource->is_uav_counter = params->is_uav_counter; 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.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 = 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); 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);
} }
@ -502,7 +514,8 @@ static struct resource *d3d11_runner_create_resource(struct shader_runner *r, co
break; break;
case RESOURCE_TYPE_VERTEX_BUFFER: 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; resource->resource = (ID3D11Resource *)resource->buffer;
break; break;
} }
@ -568,7 +581,7 @@ static bool d3d11_runner_dispatch(struct shader_runner *r, unsigned int x, unsig
ID3D11Buffer *cb; ID3D11Buffer *cb;
cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, 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); ID3D11DeviceContext_CSSetConstantBuffers(context, 0, 1, &cb);
ID3D11Buffer_Release(cb); ID3D11Buffer_Release(cb);
} }
@ -730,7 +743,7 @@ static bool d3d11_runner_draw(struct shader_runner *r,
if (runner->r.uniform_count) if (runner->r.uniform_count)
{ {
cb = create_buffer(device, D3D11_BIND_CONSTANT_BUFFER, 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_VSSetConstantBuffers(context, 0, 1, &cb);
ID3D11DeviceContext_PSSetConstantBuffers(context, 0, 1, &cb); ID3D11DeviceContext_PSSetConstantBuffers(context, 0, 1, &cb);
if (hs_code) if (hs_code)

View File

@ -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.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
uav_desc.Buffer.NumElements = params->width * params->height; uav_desc.Buffer.NumElements = params->width * params->height;
uav_desc.Buffer.StructureByteStride = params->stride; uav_desc.Buffer.StructureByteStride = params->stride;
uav_desc.Buffer.Flags = params->is_raw ? D3D12_BUFFER_UAV_FLAG_RAW : 0;
ID3D12Device_CreateUnorderedAccessView(device, resource->resource, ID3D12Device_CreateUnorderedAccessView(device, resource->resource,
params->is_uav_counter ? resource->resource : NULL, &uav_desc, params->is_uav_counter ? resource->resource : NULL, &uav_desc,

View File

@ -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_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_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_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) for (i = 0; i < ARRAY_SIZE(format_info); ++i)