Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- v5: New patch.
Makefile.am | 1 + tests/shader_runner.c | 22 ++++++++++++-- tests/shader_runner_d3d12.c | 10 +++++-- tests/shader_runner_vulkan.c | 12 ++++---- tests/uav.shader_test | 56 ++++++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 11 deletions(-) create mode 100644 tests/uav.shader_test
diff --git a/Makefile.am b/Makefile.am index dd3ce1ff6..400dc8aae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -132,6 +132,7 @@ vkd3d_shader_tests = \ tests/texture-load.shader_test \ tests/texture-load-typed.shader_test \ tests/trigonometry.shader_test \ + tests/uav.shader_test \ tests/writemask-assignop-0.shader_test \ tests/writemask-assignop-1.shader_test \ tests/writemask-assignop-2.shader_test \ diff --git a/tests/shader_runner.c b/tests/shader_runner.c index f367027f7..e2dc2dda6 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -370,6 +370,8 @@ static void set_uniforms(struct shader_runner *runner, size_t offset, size_t cou
static void parse_test_directive(struct shader_runner *runner, const char *line) { + char *rest; + runner->is_todo = false;
if (match_string(line, "todo", &line)) @@ -475,19 +477,33 @@ static void parse_test_directive(struct shader_runner *runner, const char *line) if (runner->last_render_failed) return;
- resource = get_resource(runner, RESOURCE_TYPE_RENDER_TARGET, 0); + if (match_string(line, "uav", &line)) + { + unsigned int slot = strtoul(line, &rest, 10); + + if (rest == line) + fatal_error("Malformed UAV index '%s'.\n", line); + line = rest; + + resource = get_resource(runner, RESOURCE_TYPE_UAV, slot); + } + else + { + resource = get_resource(runner, RESOURCE_TYPE_RENDER_TARGET, 0); + } + rb = runner->ops->get_resource_readback(runner, resource);
if (match_string(line, "all", &line)) { set_rect(&rect, 0, 0, resource->width, resource->height); } - else if (sscanf(line, "( %d , %d , %d , %d )%n", &left, &top, &right, &bottom, &len) == 4) + else if (sscanf(line, " ( %d , %d , %d , %d )%n", &left, &top, &right, &bottom, &len) == 4) { set_rect(&rect, left, top, right, bottom); line += len; } - else if (sscanf(line, "( %u , %u )%n", &left, &top, &len) == 2) + else if (sscanf(line, " ( %u , %u )%n", &left, &top, &len) == 2) { set_rect(&rect, left, top, left + 1, top + 1); line += len; diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c index b916de3c2..02d625c64 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -381,16 +381,20 @@ static struct resource_readback *d3d12_runner_get_resource_readback(struct shade struct test_context *test_context = &runner->test_context; struct d3d12_resource_readback *rb = malloc(sizeof(*rb)); struct d3d12_resource *resource = d3d12_resource(res); + D3D12_RESOURCE_STATES state;
- assert(resource->r.type == RESOURCE_TYPE_RENDER_TARGET); + if (resource->r.type == RESOURCE_TYPE_RENDER_TARGET) + state = D3D12_RESOURCE_STATE_RENDER_TARGET; + else + state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
transition_resource_state(test_context->list, resource->resource, - D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); + state, D3D12_RESOURCE_STATE_COPY_SOURCE); get_texture_readback_with_command_list(resource->resource, 0, rb, test_context->queue, test_context->list); reset_command_list(test_context->list, test_context->allocator); transition_resource_state(test_context->list, resource->resource, - D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET); + D3D12_RESOURCE_STATE_COPY_SOURCE, state);
return &rb->rb; } diff --git a/tests/shader_runner_vulkan.c b/tests/shader_runner_vulkan.c index adb69a7ce..190441263 100644 --- a/tests/shader_runner_vulkan.c +++ b/tests/shader_runner_vulkan.c @@ -943,8 +943,12 @@ static struct resource_readback *vulkan_runner_get_resource_readback(struct shad struct vulkan_resource *resource = vulkan_resource(res); VkDevice device = runner->device; VkBufferImageCopy region = {0}; + VkImageLayout layout;
- assert(resource->r.type == RESOURCE_TYPE_RENDER_TARGET); + if (resource->r.type == RESOURCE_TYPE_RENDER_TARGET) + layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; + else + layout = VK_IMAGE_LAYOUT_GENERAL;
rb->rb.width = resource->r.width; rb->rb.height = resource->r.height; @@ -957,8 +961,7 @@ static struct resource_readback *vulkan_runner_get_resource_readback(struct shad
begin_command_buffer(runner);
- transition_image_layout(runner, resource->image, - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); + transition_image_layout(runner, resource->image, layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; region.imageSubresource.layerCount = 1; @@ -969,8 +972,7 @@ static struct resource_readback *vulkan_runner_get_resource_readback(struct shad VK_CALL(vkCmdCopyImageToBuffer(runner->cmd_buffer, resource->image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, rb->buffer, 1, ®ion));
- transition_image_layout(runner, resource->image, - VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); + transition_image_layout(runner, resource->image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, layout);
end_command_buffer(runner);
diff --git a/tests/uav.shader_test b/tests/uav.shader_test new file mode 100644 index 000000000..09ca05ece --- /dev/null +++ b/tests/uav.shader_test @@ -0,0 +1,56 @@ +[require] +shader model >= 5.0 + +[pixel shader fail] +RWTexture2D<float4> u; + +float4 main() : sv_target +{ + /* All four components must be written in a single statement. */ + u[uint2(0, 0)].xy = float4(1, 2); + u[uint2(0, 0)].zw = float4(3, 4); + return 0; +} + +[pixel shader fail] +Texture2D<float4> u; + +float4 main() : sv_target +{ + /* SRVs are not writable. */ + u[uint2(0, 0)].xyzw = float4(1, 2, 3, 4); + return 0; +} + +[uav 1] +format r32 float +size (2, 2) + +0.1 0.2 +0.3 0.4 + +[uav 2] +size (1, 1) + +0.5 0.6 0.7 0.8 + +[pixel shader] +RWTexture2D<float> u; +RWTexture2D<float4> v; + +float4 main() : sv_target +{ + u[uint2(0, 0)] = 0.5; + u[uint2(0, 1)].x = 0.6; + u[uint2(1, 1)] = 0.7; + v[uint2(0, 0)].yxwz = float4(1, 2, 3, 4); + return 0; +} + +[test] +todo draw quad +probe uav 1 (0, 0) r (0.5) +probe uav 1 (0, 1) r (0.6) +probe uav 1 (1, 0) r (0.2) +probe uav 1 (1, 1) r (0.7) +probe uav 2 (0, 0) rgba (2.0, 1.0, 4.0, 3.0)