From cd249a47b86545fe0b3a4b477f854965e858b744 Mon Sep 17 00:00:00 2001 From: Elizabeth Figura Date: Thu, 3 Oct 2024 17:55:33 -0500 Subject: [PATCH] tests: Test FFP point size clamping. --- tests/hlsl/ffp-point-size.shader_test | 31 +++++++++++++++++++++++- tests/hlsl/shader-point-size.shader_test | 20 +++++++++++++++ tests/shader_runner.c | 6 +++++ tests/shader_runner.h | 2 +- tests/shader_runner_d3d9.c | 4 +++ tests/shader_runner_vulkan.c | 12 ++++++++- 6 files changed, 72 insertions(+), 3 deletions(-) diff --git a/tests/hlsl/ffp-point-size.shader_test b/tests/hlsl/ffp-point-size.shader_test index e368eff9..2494339e 100644 --- a/tests/hlsl/ffp-point-size.shader_test +++ b/tests/hlsl/ffp-point-size.shader_test @@ -21,7 +21,36 @@ float4 main() : sv_target } [test] -point-size 40.0 +clear rtv 0 0 0 0 0 +point-size 40.0 1.0 64.0 +draw point list 2 + +probe (139, 240) rgba (0, 0, 0, 0) +probe (141, 240) rgba (0, 1, 0, 1) +probe (179, 240) rgba (0, 1, 0, 1) +probe (181, 240) rgba (0, 0, 0, 0) + +probe (459, 240) rgba (0, 0, 0, 0) +probe (461, 240) rgba (0, 1, 0, 1) +probe (499, 240) rgba (0, 1, 0, 1) +probe (501, 240) rgba (0, 0, 0, 0) + +clear rtv 0 0 0 0 0 +point-size 40.0 1.0 20.0 +draw point list 2 + +probe (149, 240) rgba (0, 0, 0, 0) +probe (151, 240) rgba (0, 1, 0, 1) +probe (169, 240) rgba (0, 1, 0, 1) +probe (171, 240) rgba (0, 0, 0, 0) + +probe (469, 240) rgba (0, 0, 0, 0) +probe (471, 240) rgba (0, 1, 0, 1) +probe (489, 240) rgba (0, 1, 0, 1) +probe (491, 240) rgba (0, 0, 0, 0) + +clear rtv 0 0 0 0 0 +point-size 20.0 40.0 64.0 draw point list 2 probe (139, 240) rgba (0, 0, 0, 0) diff --git a/tests/hlsl/shader-point-size.shader_test b/tests/hlsl/shader-point-size.shader_test index cab511aa..5936993a 100644 --- a/tests/hlsl/shader-point-size.shader_test +++ b/tests/hlsl/shader-point-size.shader_test @@ -21,6 +21,7 @@ float4 main() : color } [test] +clear rtv 0 0 0 0 0 draw point list 2 probe (149, 240) rgba (0, 0, 0, 0) @@ -32,3 +33,22 @@ probe (459, 240) rgba (0, 0, 0, 0) probe (461, 240) rgba (0, 1, 0, 1) probe (499, 240) rgba (0, 1, 0, 1) probe (501, 240) rgba (0, 0, 0, 0) + +[require] +shader model < 4.0 +point-size + +[test] +clear rtv 0 0 0 0 0 +point-size 1.0 24.0 36.0 +draw point list 2 + +probe (147, 240) rgba (0, 0, 0, 0) +probe (149, 240) rgba (0, 1, 0, 1) +probe (171, 240) rgba (0, 1, 0, 1) +probe (173, 240) rgba (0, 0, 0, 0) + +probe (461, 240) rgba (0, 0, 0, 0) +probe (463, 240) rgba (0, 1, 0, 1) +probe (497, 240) rgba (0, 1, 0, 1) +probe (499, 240) rgba (0, 0, 0, 0) diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 201f3309..8fff287e 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -1326,6 +1326,10 @@ static void parse_test_directive(struct shader_runner *runner, const char *line) else if (match_string(line, "point-size", &line)) { runner->point_size = strtof(line, &rest); + line = rest; + runner->point_size_min = strtof(line, &rest); + line = rest; + runner->point_size_max = strtof(line, &rest); } else { @@ -1706,6 +1710,8 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c runner->maximum_shader_model = caps->maximum_shader_model; runner->alpha_test_func = VKD3D_SHADER_COMPARISON_FUNC_ALWAYS; runner->point_size = 1.0f; + runner->point_size_min = 1.0f; + runner->point_size_max = FLT_MAX; runner->sample_mask = ~0u; runner->depth_bounds = false; diff --git a/tests/shader_runner.h b/tests/shader_runner.h index c86de942..992867e1 100644 --- a/tests/shader_runner.h +++ b/tests/shader_runner.h @@ -221,7 +221,7 @@ struct shader_runner bool flat_shading; uint8_t clip_plane_mask; struct vec4 clip_planes[8]; - float point_size; + float point_size, point_size_min, point_size_max; }; struct shader_runner_ops diff --git a/tests/shader_runner_d3d9.c b/tests/shader_runner_d3d9.c index 07278571..8dd020bb 100644 --- a/tests/shader_runner_d3d9.c +++ b/tests/shader_runner_d3d9.c @@ -488,6 +488,10 @@ static bool d3d9_runner_draw(struct shader_runner *r, hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, float_to_int(runner->r.point_size)); ok(hr == D3D_OK, "Failed to set render state, hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE_MIN, float_to_int(runner->r.point_size_min)); + ok(hr == D3D_OK, "Failed to set render state, hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE_MAX, float_to_int(runner->r.point_size_max)); + ok(hr == D3D_OK, "Failed to set render state, hr %#lx.\n", hr); hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration); ok(hr == D3D_OK, "Failed to create vertex declaration, hr %#lx.\n", hr); diff --git a/tests/shader_runner_vulkan.c b/tests/shader_runner_vulkan.c index dba07e39..d403ebc8 100644 --- a/tests/shader_runner_vulkan.c +++ b/tests/shader_runner_vulkan.c @@ -274,7 +274,7 @@ static bool compile_shader(struct vulkan_shader_runner *runner, const char *sour enum vkd3d_shader_spirv_extension spirv_extensions[2]; struct vkd3d_shader_resource_binding *binding; struct vkd3d_shader_compile_option options[3]; - struct vkd3d_shader_parameter1 parameters[14]; + struct vkd3d_shader_parameter1 parameters[16]; struct vkd3d_shader_compile_option *option; unsigned int i, compile_options; char profile[7]; @@ -462,6 +462,16 @@ static bool compile_shader(struct vulkan_shader_runner *runner, const char *sour parameters[13].data_type = VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32; parameters[13].u.immediate_constant.u.f32 = runner->r.point_size; + parameters[14].name = VKD3D_SHADER_PARAMETER_NAME_POINT_SIZE_MIN; + parameters[14].type = VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT; + parameters[14].data_type = VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32; + parameters[14].u.immediate_constant.u.f32 = runner->r.point_size_min; + + parameters[15].name = VKD3D_SHADER_PARAMETER_NAME_POINT_SIZE_MAX; + parameters[15].type = VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT; + parameters[15].data_type = VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32; + parameters[15].u.immediate_constant.u.f32 = runner->r.point_size_max; + parameter_info.parameter_count = ARRAY_SIZE(parameters); parameter_info.parameters = parameters;