From 164076d176dcb857d8e76e7e9a122cb665ea0db7 Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Wed, 31 Jul 2024 21:48:19 -0400 Subject: [PATCH] tests/shader_runner: Require explicit formats for UAV resources. The current default is r32g32b32a32 but it requires special support which is not available on all GPUs, so it is not a very convenient default. Instead of changing the default making it different from RTV resoures, the format is required to always be explicit for UAVs. The exceptions are counter_buffer and buffers with "stride", which don't require a format because it is already implied. --- tests/hlsl/sm6-uav-rwtexture.shader_test | 4 ++++ tests/hlsl/uav-counter.shader_test | 2 -- tests/hlsl/uav-rwbuffer.shader_test | 1 + tests/hlsl/uav-rwtexture.shader_test | 5 +++++ tests/shader_runner.c | 9 +++++++++ tests/shader_runner.h | 1 + 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/hlsl/sm6-uav-rwtexture.shader_test b/tests/hlsl/sm6-uav-rwtexture.shader_test index 1e4cc639..8eb73382 100644 --- a/tests/hlsl/sm6-uav-rwtexture.shader_test +++ b/tests/hlsl/sm6-uav-rwtexture.shader_test @@ -8,6 +8,7 @@ size (2d, 2, 2) 0.3 0.4 [uav 1] +format r32g32b32a32 float size (2d, 1, 1) 0.5 0.6 0.7 0.8 @@ -59,6 +60,7 @@ probe uav 1 (0, 0) rgba (2.0, 1.0, 4.0, 3.0) [uav 2] +format r32g32b32a32 float size (2d, 1, 1) 0.1 0.2 0.3 0.4 @@ -92,10 +94,12 @@ probe uav 2 (0, 0) rgba (0.9, 0.8, 0.7, 0.6) % Test that we can declare and use an array of UAVs. [uav 1] +format r32g32b32a32 float size (2d, 1, 1) 0.1 0.2 0.3 0.4 [uav 2] +format r32g32b32a32 float size (2d, 1, 1) 0.5 0.6 0.7 0.8 diff --git a/tests/hlsl/uav-counter.shader_test b/tests/hlsl/uav-counter.shader_test index 0f05e1a5..2e5bf55d 100644 --- a/tests/hlsl/uav-counter.shader_test +++ b/tests/hlsl/uav-counter.shader_test @@ -2,7 +2,6 @@ shader model >= 5.0 [uav 1] -format r32 uint size (counter_buffer, 1) 0 @@ -21,7 +20,6 @@ probe uav 1 (0) rui (12) [uav 1] -format r32 sint size (counter_buffer, 1) 0 diff --git a/tests/hlsl/uav-rwbuffer.shader_test b/tests/hlsl/uav-rwbuffer.shader_test index 42657ef7..a094e678 100644 --- a/tests/hlsl/uav-rwbuffer.shader_test +++ b/tests/hlsl/uav-rwbuffer.shader_test @@ -185,6 +185,7 @@ probe uav 1 (0) rgbai (11, -12, 13, -14) probe uav 1 (1) rgbai (-15, 16, -17, 18) [uav 2] +format r32g32b32a32 float size (buffer, 1) 0.1 0.2 0.3 0.4 diff --git a/tests/hlsl/uav-rwtexture.shader_test b/tests/hlsl/uav-rwtexture.shader_test index 64061244..ef3dffd7 100644 --- a/tests/hlsl/uav-rwtexture.shader_test +++ b/tests/hlsl/uav-rwtexture.shader_test @@ -32,6 +32,7 @@ size (2d, 2, 2) 0.3 0.4 [uav 2] +format r32g32b32a32 float size (2d, 1, 1) 0.5 0.6 0.7 0.8 @@ -68,6 +69,7 @@ format r32g32b32a32 float size (2d, 640, 480) [uav 2] +format r32g32b32a32 float size (2d, 1, 1) 0.1 0.2 0.3 0.4 @@ -105,6 +107,7 @@ probe uav 2 (0, 0) rgba (0.9, 0.8, 0.7, 0.6) [uav 3] +format r32g32b32a32 float size (2d, 1, 1) 0.1 0.2 0.3 0.4 @@ -139,11 +142,13 @@ probe uav 3 (0, 0) rgba (0.9, 0.8, 0.7, 0.6) % Test that we can declare and use an array of UAVs. [uav 2] +format r32g32b32a32 float size (2d, 1, 1) 0.1 0.2 0.3 0.4 [uav 3] +format r32g32b32a32 float size (2d, 1, 1) 0.5 0.6 0.7 0.8 diff --git a/tests/shader_runner.c b/tests/shader_runner.c index d785e355..ebee5987 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -498,6 +498,8 @@ static void parse_resource_directive(struct resource_params *resource, const cha { resource->desc.format = parse_format(line, &resource->data_type, &resource->desc.texel_size, &resource->is_shadow, &line); + assert_that(!resource->explicit_format, "Resource format already specified.\n"); + resource->explicit_format = true; } else if (match_string(line, "stride", &line)) { @@ -505,6 +507,8 @@ static void parse_resource_directive(struct resource_params *resource, const cha fatal_error("Malformed texture stride '%s'.\n", line); resource->desc.texel_size = resource->stride; resource->desc.format = DXGI_FORMAT_UNKNOWN; + assert_that(!resource->explicit_format, "Resource format already specified.\n"); + resource->explicit_format = true; } else if (match_string(line, "size", &line)) { @@ -527,6 +531,8 @@ static void parse_resource_directive(struct resource_params *resource, const cha resource->stride = sizeof(uint32_t); resource->desc.texel_size = resource->stride; resource->desc.format = DXGI_FORMAT_UNKNOWN; + assert_that(!resource->explicit_format, "Resource format already specified.\n"); + resource->explicit_format = true; } else if (sscanf(line, "( 2d , %u , %u ) ", &resource->desc.width, &resource->desc.height) == 2) { @@ -1698,6 +1704,9 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c if (current_resource.desc.type == RESOURCE_TYPE_VERTEX_BUFFER) current_resource.desc.width = current_resource.data_size; + if (current_resource.desc.type == RESOURCE_TYPE_UAV) + assert_that(current_resource.explicit_format, "Format must be specified for UAV resources.\n"); + /* Not every backend supports every resource type * (specifically, D3D9 doesn't support UAVs and * textures with data type other than float). */ diff --git a/tests/shader_runner.h b/tests/shader_runner.h index 7215c570..14f691aa 100644 --- a/tests/shader_runner.h +++ b/tests/shader_runner.h @@ -104,6 +104,7 @@ struct resource_params bool is_shadow; bool is_raw; bool is_uav_counter; + bool explicit_format; enum texture_data_type data_type; unsigned int stride;