From 6fd1a1ce7e911a534d49740472d05ef8519c8cc1 Mon Sep 17 00:00:00 2001 From: Elizabeth Figura Date: Tue, 15 Oct 2024 19:04:25 -0500 Subject: [PATCH] tests: Test point sprite. --- Makefile.am | 1 + tests/hlsl/point-sprite.shader_test | 48 +++++++++++++++++++++++++++++ tests/shader_runner.c | 7 +++++ tests/shader_runner.h | 1 + tests/shader_runner_d3d9.c | 2 ++ tests/shader_runner_vulkan.c | 7 ++++- 6 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 tests/hlsl/point-sprite.shader_test diff --git a/Makefile.am b/Makefile.am index b8e4aa4b..51ff440f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -190,6 +190,7 @@ vkd3d_shader_tests = \ tests/hlsl/object-field-offsets.shader_test \ tests/hlsl/object-parameters.shader_test \ tests/hlsl/object-references.shader_test \ + tests/hlsl/point-sprite.shader_test \ tests/hlsl/pointer-cast.shader_test \ tests/hlsl/pow.shader_test \ tests/hlsl/precise-modifier.shader_test \ diff --git a/tests/hlsl/point-sprite.shader_test b/tests/hlsl/point-sprite.shader_test new file mode 100644 index 00000000..f2c0a172 --- /dev/null +++ b/tests/hlsl/point-sprite.shader_test @@ -0,0 +1,48 @@ +[require] +point-size +% For tex2D() with newer shader models. +options: backcompat +shader model < 6.0 + +[sampler 0] +filter linear linear linear +address clamp clamp clamp + +[srv 0] +size (2d, 2, 2) +1 1 0 1 0 1 1 1 +1 0 0 1 1 0 1 1 + +[vertex shader] +float4 main(out float2 t : texcoord) : sv_position +{ + t = float2(1, 1); + return float4(0, 0, 0, 1); +} + +[pixel shader] +sampler2D s; + +float4 main(float2 t : texcoord) : sv_target +{ + return tex2D(s, t); +} + +[test] +clear rtv 0 0 0 0 0 +point-size 30.0 1.0 64.0 +point-sprite off +draw point list 1 +probe (310, 230) rgba (1, 0, 1, 1) +probe (330, 230) rgba (1, 0, 1, 1) +probe (310, 250) rgba (1, 0, 1, 1) +probe (330, 250) rgba (1, 0, 1, 1) + +clear rtv 0 0 0 0 0 +point-size 30.0 1.0 64.0 +point-sprite on +draw point list 1 +probe (310, 230) rgba (1, 1, 0, 1) +probe (330, 230) rgba (0, 1, 1, 1) +probe (310, 250) rgba (1, 0, 0, 1) +probe (330, 250) rgba (1, 0, 1, 1) diff --git a/tests/shader_runner.c b/tests/shader_runner.c index c506dc38..e44e7ca5 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -1335,6 +1335,13 @@ static void parse_test_directive(struct shader_runner *runner, const char *line) line = rest; runner->point_size_max = strtof(line, &rest); } + else if (match_string(line, "point-sprite", &line)) + { + if (match_string(line, "on", &line)) + runner->point_sprite = true; + else + runner->point_sprite = false; + } else { fatal_error("Unknown test directive '%s'.\n", line); diff --git a/tests/shader_runner.h b/tests/shader_runner.h index 8a886091..0ffce38f 100644 --- a/tests/shader_runner.h +++ b/tests/shader_runner.h @@ -224,6 +224,7 @@ struct shader_runner uint8_t clip_plane_mask; struct vec4 clip_planes[8]; float point_size, point_size_min, point_size_max; + bool point_sprite; }; struct shader_runner_ops diff --git a/tests/shader_runner_d3d9.c b/tests/shader_runner_d3d9.c index 8dd020bb..549a5f37 100644 --- a/tests/shader_runner_d3d9.c +++ b/tests/shader_runner_d3d9.c @@ -492,6 +492,8 @@ static bool d3d9_runner_draw(struct shader_runner *r, 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_SetRenderState(device, D3DRS_POINTSPRITEENABLE, runner->r.point_sprite); + 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 deca5d60..0d2fd1b6 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[16]; + struct vkd3d_shader_parameter1 parameters[17]; struct vkd3d_shader_compile_option *option; unsigned int i, compile_options; char profile[7]; @@ -472,6 +472,11 @@ static bool compile_shader(struct vulkan_shader_runner *runner, const char *sour parameters[15].data_type = VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32; parameters[15].u.immediate_constant.u.f32 = runner->r.point_size_max; + parameters[16].name = VKD3D_SHADER_PARAMETER_NAME_POINT_SPRITE; + parameters[16].type = VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT; + parameters[16].data_type = VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32; + parameters[16].u.immediate_constant.u.u32 = runner->r.point_sprite; + parameter_info.parameter_count = ARRAY_SIZE(parameters); parameter_info.parameters = parameters;