diff --git a/Makefile.am b/Makefile.am index da6200bb..c7cc579f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -84,6 +84,7 @@ vkd3d_shader_tests = \ tests/hlsl/compute.shader_test \ tests/hlsl/conditional.shader_test \ tests/hlsl/const.shader_test \ + tests/hlsl/coverage.shader_test \ tests/hlsl/cross.shader_test \ tests/hlsl/d3dcolor-to-ubyte4.shader_test \ tests/hlsl/ddxddy.shader_test \ diff --git a/tests/hlsl/coverage.shader_test b/tests/hlsl/coverage.shader_test new file mode 100644 index 00000000..ac098761 --- /dev/null +++ b/tests/hlsl/coverage.shader_test @@ -0,0 +1,56 @@ +[require] +shader model >= 5.0 + +[rtv 0] +format r32g32b32a32 float +size (2dms, 4, 640, 480) + +[uav 1] +format r32 uint +size (2d, 4, 4) +0 0 0 0 +0 0 0 0 +0 0 0 0 +0 0 0 0 + +[pixel shader todo] +RWTexture2D u : register(u1); + +float4 main(float4 position : SV_Position, uint coverage : SV_Coverage) : SV_Target +{ + InterlockedOr(u[uint2(position.x, position.y)], coverage); + return float4(0.0, 1.0, 0.0, 1.0); +} + +[test] +sample mask 0x01 +todo draw quad +probe all rgba (0.0, 0.25, 0.0, 0.25) +probe uav 1 all rui (0x01) +sample mask 0x03 +todo draw quad +probe all rgba (0.0, 0.5, 0.0, 0.5) +probe uav 1 all rui (0x03) +sample mask 0x07 +todo draw quad +probe all rgba (0.0, 0.75, 0.0, 0.75) +probe uav 1 all rui (0x07) + +[uav 1] +format r32 uint +size (2d, 4, 4) +0 0 0 0 +0 0 0 0 +0 0 0 0 +0 0 0 0 + +[test] +clear rtv 0 0.0 0.0 0.0 0.0 +sample mask 0x09 +todo draw quad +probe all rgba (0.0, 0.5, 0.0, 0.5) +probe uav 1 all rui (0x09) +sample mask 0x0f +todo draw quad +probe all rgba (0.0, 1.0, 0.0, 1.0) +probe uav 1 all rui (0x0f) diff --git a/tests/shader_runner.c b/tests/shader_runner.c index b4b440de..68a7a9c5 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -1231,6 +1231,13 @@ static void parse_test_directive(struct shader_runner *runner, const char *line) fatal_error("Unknown uniform type '%s'.\n", line); } } + else if (match_string(line, "sample mask", &line)) + { + unsigned int sample_mask; + + read_uint(&line, &sample_mask, false); + runner->sample_mask = sample_mask; + } else { fatal_error("Unknown test directive '%s'.\n", line); diff --git a/tests/shader_runner.h b/tests/shader_runner.h index 9d41d759..0457db96 100644 --- a/tests/shader_runner.h +++ b/tests/shader_runner.h @@ -175,6 +175,8 @@ struct shader_runner uint32_t *uniforms; size_t uniform_count, uniform_capacity; + uint32_t sample_mask; + struct resource *resources[MAX_RESOURCES]; size_t resource_count; uint32_t failed_resources[RESOURCE_TYPE_VERTEX_BUFFER + 1][VKD3D_BITMAP_SIZE(MAX_RESOURCES)]; diff --git a/tests/shader_runner_d3d11.c b/tests/shader_runner_d3d11.c index 9eb8ac4e..e937040f 100644 --- a/tests/shader_runner_d3d11.c +++ b/tests/shader_runner_d3d11.c @@ -803,6 +803,8 @@ static bool d3d11_runner_draw(struct shader_runner *r, ID3D10Blob_Release(vs_code); + if (r->sample_mask) + ID3D11DeviceContext_OMSetBlendState(context, NULL, NULL, r->sample_mask); ID3D11DeviceContext_IASetPrimitiveTopology(context, primitive_topology); ID3D11DeviceContext_VSSetShader(context, vs, NULL, 0); ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0); diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c index 37780682..593d0759 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -590,7 +590,7 @@ static bool d3d12_runner_draw(struct shader_runner *r, pso_desc.RasterizerState.FillMode = D3D12_FILL_MODE_SOLID; pso_desc.RasterizerState.CullMode = D3D12_CULL_MODE_NONE; pso_desc.SampleDesc.Count = sample_count; - pso_desc.SampleMask = ~(UINT)0; + pso_desc.SampleMask = r->sample_mask ? r->sample_mask : ~(UINT)0; pso_desc.pRootSignature = test_context->root_signature; input_element_descs = calloc(runner->r.input_element_count, sizeof(*input_element_descs)); diff --git a/tests/shader_runner_gl.c b/tests/shader_runner_gl.c index 2649dc55..601307ff 100644 --- a/tests/shader_runner_gl.c +++ b/tests/shader_runner_gl.c @@ -1119,6 +1119,8 @@ static bool gl_runner_draw(struct shader_runner *r, } } + /* TODO: sample count and mask. */ + glViewport(0, 0, RENDER_TARGET_WIDTH, RENDER_TARGET_HEIGHT); glScissor(0, 0, RENDER_TARGET_WIDTH, RENDER_TARGET_HEIGHT); glDrawBuffers(rt_count, draw_buffers); diff --git a/tests/shader_runner_vulkan.c b/tests/shader_runner_vulkan.c index 8c48c107..3d02639f 100644 --- a/tests/shader_runner_vulkan.c +++ b/tests/shader_runner_vulkan.c @@ -845,6 +845,7 @@ static VkPipeline create_graphics_pipeline(struct vulkan_shader_runner *runner, rs_desc.frontFace = VK_FRONT_FACE_CLOCKWISE; rs_desc.lineWidth = 1.0f; + /* TODO: sample count and mask. */ ms_desc.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; pipeline_desc.stageCount = stage_count;