diff --git a/Makefile.am b/Makefile.am index d801ee51..06f4a80b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -122,6 +122,7 @@ vkd3d_shader_tests = \ tests/hlsl/expr-indexing.shader_test \ tests/hlsl/f16tof32.shader_test \ tests/hlsl/faceforward.shader_test \ + tests/hlsl/ffp-point-size.shader_test \ tests/hlsl/float-comparison.shader_test \ tests/hlsl/floor.shader_test \ tests/hlsl/fmod.shader_test \ diff --git a/tests/hlsl/ffp-point-size.shader_test b/tests/hlsl/ffp-point-size.shader_test new file mode 100644 index 00000000..e368eff9 --- /dev/null +++ b/tests/hlsl/ffp-point-size.shader_test @@ -0,0 +1,35 @@ +[require] +point-size + +[input layout] +0 r32g32-float position + +[vb 0] +-0.5 0 + 0.5 0 + +[vertex shader] +float4 main(float4 pos : position) : sv_position +{ + return pos; +} + +[pixel shader] +float4 main() : sv_target +{ + return float4(0, 1, 0, 1); +} + +[test] +point-size 40.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) diff --git a/tests/shader_runner.c b/tests/shader_runner.c index d5d5281d..201f3309 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -410,6 +410,10 @@ static void parse_require_directive(struct shader_runner *runner, const char *li { runner->require_clip_planes = true; } + else if (match_string(line, "point-size", &line)) + { + runner->require_point_size = true; + } else { fatal_error("Unknown require directive '%s'.\n", line); @@ -1319,6 +1323,10 @@ static void parse_test_directive(struct shader_runner *runner, const char *line) runner->clip_plane_mask |= (1u << index); } } + else if (match_string(line, "point-size", &line)) + { + runner->point_size = strtof(line, &rest); + } else { fatal_error("Unknown test directive '%s'.\n", line); @@ -1563,6 +1571,8 @@ static bool check_capabilities(const struct shader_runner *runner, const struct return false; if (runner->require_clip_planes && !caps->clip_planes) return false; + if (runner->require_point_size && !caps->point_size) + return false; for (i = 0; i < ARRAY_SIZE(runner->require_format_caps); ++i) { @@ -1680,6 +1690,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c trace(" wave-ops: %u.\n", caps->wave_ops); trace(" depth-bounds: %u.\n", caps->depth_bounds); trace(" clip-planes: %u.\n", caps->clip_planes); + trace(" point-size: %u.\n", caps->point_size); trace_format_cap(caps, FORMAT_CAP_UAV_LOAD, "uav-load"); if (!test_options.filename) @@ -1694,6 +1705,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c runner->minimum_shader_model = caps->minimum_shader_model; runner->maximum_shader_model = caps->maximum_shader_model; runner->alpha_test_func = VKD3D_SHADER_COMPARISON_FUNC_ALWAYS; + runner->point_size = 1.0f; runner->sample_mask = ~0u; runner->depth_bounds = false; @@ -1944,6 +1956,7 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c runner->require_wave_ops = false; runner->require_depth_bounds = false; runner->require_clip_planes = false; + runner->require_point_size = false; memset(runner->require_format_caps, 0, sizeof(runner->require_format_caps)); runner->compile_options = 0; test_action = TEST_ACTION_RUN; diff --git a/tests/shader_runner.h b/tests/shader_runner.h index 99078cc6..c86de942 100644 --- a/tests/shader_runner.h +++ b/tests/shader_runner.h @@ -148,6 +148,7 @@ struct shader_runner_caps bool wave_ops; bool depth_bounds; bool clip_planes; + bool point_size; uint32_t format_caps[DXGI_FORMAT_COUNT]; }; @@ -186,6 +187,7 @@ struct shader_runner bool require_wave_ops; bool require_depth_bounds; bool require_clip_planes; + bool require_point_size; uint32_t require_format_caps[DXGI_FORMAT_COUNT]; bool last_render_failed; @@ -219,6 +221,7 @@ struct shader_runner bool flat_shading; uint8_t clip_plane_mask; struct vec4 clip_planes[8]; + float point_size; }; struct shader_runner_ops diff --git a/tests/shader_runner_d3d9.c b/tests/shader_runner_d3d9.c index 48683af0..07278571 100644 --- a/tests/shader_runner_d3d9.c +++ b/tests/shader_runner_d3d9.c @@ -153,6 +153,7 @@ static bool init_test_context(struct d3d9_shader_runner *runner) runner->caps.minimum_shader_model = SHADER_MODEL_2_0; runner->caps.maximum_shader_model = SHADER_MODEL_3_0; runner->caps.clip_planes = true; + runner->caps.point_size = true; return true; } @@ -485,6 +486,9 @@ static bool d3d9_runner_draw(struct shader_runner *r, ok(hr == D3D_OK, "Failed to set clip plane, hr %#lx.\n", hr); } + 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_CreateVertexDeclaration(device, decl_elements, &vertex_declaration); ok(hr == D3D_OK, "Failed to create vertex declaration, hr %#lx.\n", hr); hr = IDirect3DDevice9_CreateVertexShader(device, ID3D10Blob_GetBufferPointer(vs_code), &vs); diff --git a/tests/shader_runner_vulkan.c b/tests/shader_runner_vulkan.c index 33e30cbd..dba07e39 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[13]; + struct vkd3d_shader_parameter1 parameters[14]; struct vkd3d_shader_compile_option *option; unsigned int i, compile_options; char profile[7]; @@ -457,6 +457,11 @@ static bool compile_shader(struct vulkan_shader_runner *runner, const char *sour memcpy(parameters[5 + i].u.immediate_constant.u.f32_vec4, &runner->r.clip_planes[i], 4 * sizeof(float)); } + parameters[13].name = VKD3D_SHADER_PARAMETER_NAME_POINT_SIZE; + parameters[13].type = VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT; + parameters[13].data_type = VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32; + parameters[13].u.immediate_constant.u.f32 = runner->r.point_size; + parameter_info.parameter_count = ARRAY_SIZE(parameters); parameter_info.parameters = parameters; @@ -1540,6 +1545,7 @@ static bool init_vulkan_runner(struct vulkan_shader_runner *runner) ret_features = &device_info.features2.features; runner->caps.clip_planes = true; + runner->caps.point_size = true; device_desc.pEnabledFeatures = &features; memset(&features, 0, sizeof(features)); diff --git a/tests/utils.h b/tests/utils.h index ae042a37..00ca25a4 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -92,6 +92,18 @@ struct resource_readback void *data; }; +static inline uint32_t float_to_int(float f) +{ + union + { + uint32_t u; + float f; + } u; + + u.f = f; + return u.u; +} + static inline bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size) { size_t new_capacity, max_capacity;