mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
tests/shader_runner: Allow UAV resources to be created without initial data.
We can e.g. initialise these with a shader.
This commit is contained in:
parent
7d51a7d99c
commit
f614d98759
Notes:
Alexandre Julliard
2024-02-14 23:28:07 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/651
@ -130,6 +130,7 @@ static struct resource *d3d12_runner_create_resource(struct shader_runner *r, co
|
||||
D3D12_SUBRESOURCE_DATA resource_data[2];
|
||||
struct d3d12_resource *resource;
|
||||
unsigned int buffer_offset = 0;
|
||||
D3D12_RESOURCE_STATES state;
|
||||
|
||||
if (params->level_count > ARRAY_SIZE(resource_data))
|
||||
fatal_error("Level count %u is too high.\n", params->level_count);
|
||||
@ -185,14 +186,18 @@ static struct resource *d3d12_runner_create_resource(struct shader_runner *r, co
|
||||
runner->heap = create_gpu_descriptor_heap(device,
|
||||
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, MAX_RESOURCE_DESCRIPTORS);
|
||||
|
||||
resource->resource = create_default_texture2d(device, params->width, params->height, 1, params->level_count,
|
||||
params->format, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_DEST);
|
||||
state = params->data ? D3D12_RESOURCE_STATE_COPY_DEST : D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||
resource->resource = create_default_texture2d(device, params->width, params->height, 1,
|
||||
params->level_count, params->format, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, state);
|
||||
if (params->data)
|
||||
{
|
||||
upload_texture_data_with_states(resource->resource, resource_data,
|
||||
params->level_count, test_context->queue, test_context->list,
|
||||
RESOURCE_STATE_DO_NOT_CHANGE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
reset_command_list(test_context->list, test_context->allocator);
|
||||
ID3D12Device_CreateUnorderedAccessView(device, resource->resource,
|
||||
NULL, NULL, get_cpu_descriptor_handle(test_context, runner->heap, resource->r.slot + MAX_RESOURCES));
|
||||
}
|
||||
ID3D12Device_CreateUnorderedAccessView(device, resource->resource, NULL, NULL,
|
||||
get_cpu_descriptor_handle(test_context, runner->heap, resource->r.slot + MAX_RESOURCES));
|
||||
break;
|
||||
|
||||
case RESOURCE_TYPE_BUFFER_UAV:
|
||||
|
@ -310,6 +310,15 @@ static struct resource *vulkan_runner_create_resource(struct shader_runner *r, c
|
||||
usage, format, &resource->memory);
|
||||
resource->image_view = create_2d_image_view(runner, resource->image, format);
|
||||
|
||||
if (!params->data)
|
||||
{
|
||||
begin_command_buffer(runner);
|
||||
transition_image_layout(runner, resource->image,
|
||||
VK_IMAGE_LAYOUT_UNDEFINED, layout);
|
||||
end_command_buffer(runner);
|
||||
break;
|
||||
}
|
||||
|
||||
staging_buffer = create_buffer(runner, params->data_size,
|
||||
VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &staging_memory);
|
||||
VK_CALL(vkMapMemory(device, staging_memory, 0, VK_WHOLE_SIZE, 0, &data));
|
||||
|
Loading…
Reference in New Issue
Block a user