tests: Test shade mode.

This commit is contained in:
Elizabeth Figura 2024-07-11 17:31:02 -05:00 committed by Henri Verbeet
parent ae5cd6573f
commit 947b937a1a
Notes: Henri Verbeet 2024-07-24 16:17:06 +02:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/960
6 changed files with 43 additions and 1 deletions

View File

@ -196,6 +196,7 @@ vkd3d_shader_tests = \
tests/hlsl/sampler-offset.shader_test \ tests/hlsl/sampler-offset.shader_test \
tests/hlsl/sampler.shader_test \ tests/hlsl/sampler.shader_test \
tests/hlsl/saturate.shader_test \ tests/hlsl/saturate.shader_test \
tests/hlsl/shade-mode.shader_test \
tests/hlsl/shader-interstage-interface.shader_test \ tests/hlsl/shader-interstage-interface.shader_test \
tests/hlsl/shape.shader_test \ tests/hlsl/shape.shader_test \
tests/hlsl/side-effects.shader_test \ tests/hlsl/side-effects.shader_test \

View File

@ -0,0 +1,24 @@
[require]
shader model < 4.0
[vertex shader]
void main(inout float4 pos : position, out float4 tex : texcoord, out float4 diffuse : color)
{
diffuse = tex = (pos + 4) / 10;
}
[pixel shader]
float4 main(float4 tex : texcoord, float4 diffuse : color) : sv_target
{
return float4(tex.xy, diffuse.xy);
}
[test]
shade mode flat
draw quad
probe (320, 0) rgba (0.4, 0.5, 0.2, 0.2) 4
shade mode linear
draw quad
probe (320, 0) rgba (0.4, 0.5, 0.4, 0.5) 4

View File

@ -1255,6 +1255,13 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
runner->alpha_test_ref = strtof(line, &rest); runner->alpha_test_ref = strtof(line, &rest);
line = rest; line = rest;
} }
else if (match_string(line, "shade mode", &line))
{
if (match_string(line, "flat", &line))
runner->flat_shading = true;
else
runner->flat_shading = false;
}
else else
{ {
fatal_error("Unknown test directive '%s'.\n", line); fatal_error("Unknown test directive '%s'.\n", line);

View File

@ -200,6 +200,7 @@ struct shader_runner
enum vkd3d_shader_comparison_func alpha_test_func; enum vkd3d_shader_comparison_func alpha_test_func;
float alpha_test_ref; float alpha_test_ref;
bool flat_shading;
}; };
struct shader_runner_ops struct shader_runner_ops

View File

@ -465,6 +465,10 @@ static bool d3d9_runner_draw(struct shader_runner *r,
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHAREF, runner->r.alpha_test_ref * 255.0); hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHAREF, runner->r.alpha_test_ref * 255.0);
ok(hr == D3D_OK, "Failed to set render state, hr %#lx.\n", hr); ok(hr == D3D_OK, "Failed to set render state, hr %#lx.\n", hr);
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SHADEMODE,
runner->r.flat_shading ? D3DSHADE_FLAT : D3DSHADE_GOURAUD);
ok(hr == D3D_OK, "Failed to set render state, hr %#lx.\n", hr);
hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration); hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
ok(hr == D3D_OK, "Failed to create vertex declaration, hr %#lx.\n", hr); ok(hr == D3D_OK, "Failed to create vertex declaration, hr %#lx.\n", hr);
hr = IDirect3DDevice9_CreateVertexShader(device, ID3D10Blob_GetBufferPointer(vs_code), &vs); hr = IDirect3DDevice9_CreateVertexShader(device, ID3D10Blob_GetBufferPointer(vs_code), &vs);

View File

@ -451,7 +451,7 @@ static bool compile_shader(struct vulkan_shader_runner *runner, const char *sour
enum vkd3d_shader_spirv_extension spirv_extensions[2]; enum vkd3d_shader_spirv_extension spirv_extensions[2];
struct vkd3d_shader_resource_binding *binding; struct vkd3d_shader_resource_binding *binding;
struct vkd3d_shader_compile_option options[3]; struct vkd3d_shader_compile_option options[3];
struct vkd3d_shader_parameter1 parameters[3]; struct vkd3d_shader_parameter1 parameters[4];
struct vkd3d_shader_compile_option *option; struct vkd3d_shader_compile_option *option;
unsigned int i, compile_options; unsigned int i, compile_options;
char profile[7]; char profile[7];
@ -616,6 +616,11 @@ static bool compile_shader(struct vulkan_shader_runner *runner, const char *sour
parameters[2].data_type = VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32; parameters[2].data_type = VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32;
parameters[2].u.immediate_constant.u.f32 = runner->r.alpha_test_ref; parameters[2].u.immediate_constant.u.f32 = runner->r.alpha_test_ref;
parameters[3].name = VKD3D_SHADER_PARAMETER_NAME_FLAT_INTERPOLATION;
parameters[3].type = VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT;
parameters[3].data_type = VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32;
parameters[3].u.immediate_constant.u.u32 = runner->r.flat_shading;
parameter_info.parameter_count = ARRAY_SIZE(parameters); parameter_info.parameter_count = ARRAY_SIZE(parameters);
parameter_info.parameters = parameters; parameter_info.parameters = parameters;