mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
tests/shader-runner: Support structured buffer UAVs.
This commit is contained in:
parent
edc8e38bd9
commit
081c9dbc96
Notes:
Alexandre Julliard
2024-02-22 23:03:08 +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/642
@ -1,6 +1,12 @@
|
|||||||
[require]
|
[require]
|
||||||
shader model >= 5.0
|
shader model >= 5.0
|
||||||
|
|
||||||
|
[uav 2]
|
||||||
|
stride 16
|
||||||
|
size (buffer, 2)
|
||||||
|
|
||||||
|
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
|
||||||
|
|
||||||
[pixel shader todo]
|
[pixel shader todo]
|
||||||
struct s
|
struct s
|
||||||
{
|
{
|
||||||
@ -22,9 +28,15 @@ RWStructuredBuffer<struct s2> u5;
|
|||||||
float4 main() : sv_target1
|
float4 main() : sv_target1
|
||||||
{
|
{
|
||||||
u[0] = float4(11.1, 12.2, 13.3, 14.4);
|
u[0] = float4(11.1, 12.2, 13.3, 14.4);
|
||||||
|
u[1] = float4(15.5, 16.6, 17.7, 18.8);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[test]
|
||||||
|
todo draw quad
|
||||||
|
probe uav 2 (0) rgba (11.1, 12.2, 13.3, 14.4)
|
||||||
|
probe uav 2 (1) rgba (15.5, 16.6, 17.7, 18.8)
|
||||||
|
|
||||||
[pixel shader todo]
|
[pixel shader todo]
|
||||||
struct s
|
struct s
|
||||||
{
|
{
|
||||||
|
@ -427,6 +427,13 @@ static void parse_resource_directive(struct resource_params *resource, const cha
|
|||||||
{
|
{
|
||||||
resource->format = parse_format(line, &resource->data_type, &resource->texel_size, &line);
|
resource->format = parse_format(line, &resource->data_type, &resource->texel_size, &line);
|
||||||
}
|
}
|
||||||
|
else if (match_string(line, "stride", &line))
|
||||||
|
{
|
||||||
|
if (sscanf(line, "%u", &resource->stride) < 1)
|
||||||
|
fatal_error("Malformed texture stride '%s'.\n", line);
|
||||||
|
resource->texel_size = resource->stride;
|
||||||
|
resource->format = DXGI_FORMAT_UNKNOWN;
|
||||||
|
}
|
||||||
else if (match_string(line, "size", &line))
|
else if (match_string(line, "size", &line))
|
||||||
{
|
{
|
||||||
if (sscanf(line, "( buffer , %u ) ", &resource->width) == 1)
|
if (sscanf(line, "( buffer , %u ) ", &resource->width) == 1)
|
||||||
|
@ -87,6 +87,7 @@ struct resource_params
|
|||||||
DXGI_FORMAT format;
|
DXGI_FORMAT format;
|
||||||
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 width, height;
|
unsigned int width, height;
|
||||||
unsigned int level_count;
|
unsigned int level_count;
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
|
@ -330,7 +330,8 @@ static void destroy_test_context(struct d3d11_shader_runner *runner)
|
|||||||
ok(!ref, "Device has %lu references left.\n", ref);
|
ok(!ref, "Device has %lu references left.\n", ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ID3D11Buffer *create_buffer(ID3D11Device *device, unsigned int bind_flags, unsigned int size, const void *data)
|
static ID3D11Buffer *create_buffer(ID3D11Device *device, unsigned int bind_flags, unsigned int size,
|
||||||
|
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;
|
||||||
@ -341,8 +342,8 @@ 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 = 0;
|
buffer_desc.MiscFlags = stride ? D3D11_RESOURCE_MISC_BUFFER_STRUCTURED : 0;
|
||||||
buffer_desc.StructureByteStride = 0;
|
buffer_desc.StructureByteStride = stride;
|
||||||
|
|
||||||
resource_data.pSysMem = data;
|
resource_data.pSysMem = data;
|
||||||
resource_data.SysMemPitch = 0;
|
resource_data.SysMemPitch = 0;
|
||||||
@ -417,7 +418,7 @@ 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->data);
|
resource->buffer = create_buffer(device, D3D11_BIND_SHADER_RESOURCE, params->data_size, params->stride, params->data);
|
||||||
resource->resource = (ID3D11Resource *)resource->buffer;
|
resource->resource = (ID3D11Resource *)resource->buffer;
|
||||||
|
|
||||||
srv_desc.Format = params->format;
|
srv_desc.Format = params->format;
|
||||||
@ -435,7 +436,7 @@ 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->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;
|
||||||
|
|
||||||
uav_desc.Format = params->format;
|
uav_desc.Format = params->format;
|
||||||
@ -474,7 +475,7 @@ 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->data);
|
resource->buffer = create_buffer(device, D3D11_BIND_VERTEX_BUFFER, params->data_size, params->stride, params->data);
|
||||||
resource->resource = (ID3D11Resource *)resource->buffer;
|
resource->resource = (ID3D11Resource *)resource->buffer;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -538,7 +539,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), runner->r.uniforms);
|
runner->r.uniform_count * sizeof(*runner->r.uniforms), 0, runner->r.uniforms);
|
||||||
ID3D11DeviceContext_CSSetConstantBuffers(context, 0, 1, &cb);
|
ID3D11DeviceContext_CSSetConstantBuffers(context, 0, 1, &cb);
|
||||||
ID3D11Buffer_Release(cb);
|
ID3D11Buffer_Release(cb);
|
||||||
}
|
}
|
||||||
@ -618,7 +619,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), runner->r.uniforms);
|
runner->r.uniform_count * sizeof(*runner->r.uniforms), 0, runner->r.uniforms);
|
||||||
ID3D11DeviceContext_PSSetConstantBuffers(context, 0, 1, &cb);
|
ID3D11DeviceContext_PSSetConstantBuffers(context, 0, 1, &cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,6 +200,7 @@ static struct resource *d3d12_runner_create_resource(struct shader_runner *r, co
|
|||||||
uav_desc.Format = params->format;
|
uav_desc.Format = params->format;
|
||||||
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;
|
||||||
|
|
||||||
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));
|
NULL, &uav_desc, get_cpu_descriptor_handle(test_context, runner->heap, resource->r.slot + MAX_RESOURCES));
|
||||||
|
@ -290,6 +290,7 @@ static const struct format_info *get_format_info(enum DXGI_FORMAT format)
|
|||||||
|
|
||||||
static const struct format_info format_info[] =
|
static const struct format_info format_info[] =
|
||||||
{
|
{
|
||||||
|
{DXGI_FORMAT_UNKNOWN, 1, true, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT},
|
||||||
{DXGI_FORMAT_R32G32B32A32_FLOAT, 4, false, GL_RGBA32F, GL_RGBA, GL_FLOAT},
|
{DXGI_FORMAT_R32G32B32A32_FLOAT, 4, false, GL_RGBA32F, GL_RGBA, GL_FLOAT},
|
||||||
{DXGI_FORMAT_R32G32B32A32_UINT, 4, true, GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT},
|
{DXGI_FORMAT_R32G32B32A32_UINT, 4, true, GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT},
|
||||||
{DXGI_FORMAT_R32G32_FLOAT, 2, false, GL_RG32F, GL_RG, GL_FLOAT},
|
{DXGI_FORMAT_R32G32_FLOAT, 2, false, GL_RG32F, GL_RG, GL_FLOAT},
|
||||||
|
@ -330,6 +330,10 @@ static void resource_init_buffer(struct vulkan_shader_runner *runner, struct vul
|
|||||||
else
|
else
|
||||||
usage = VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT;
|
usage = VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT;
|
||||||
|
|
||||||
|
/* d3d12 requires DXGI_FORMAT_UNKNOWN for structured buffers, but Vulkan requires a defined format. */
|
||||||
|
if (format == VK_FORMAT_UNDEFINED && params->stride)
|
||||||
|
format = VK_FORMAT_R32_UINT;
|
||||||
|
|
||||||
resource->buffer = create_buffer(runner, params->data_size, usage,
|
resource->buffer = create_buffer(runner, params->data_size, usage,
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &resource->memory);
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &resource->memory);
|
||||||
resource->buffer_view = create_buffer_view(runner, resource->buffer, format);
|
resource->buffer_view = create_buffer_view(runner, resource->buffer, format);
|
||||||
|
Loading…
Reference in New Issue
Block a user