Add support for interpolation qualifiers for sm4/sm5 pixel shader inputs in wined3d Accepted

Revisions: 

Revision 1

user image Michael Müller Author
08 Sep. 17

Slightly modified patches from Józef Kucia plus a d3d11 test for the nointerpolation qualifier. Should fix bug https://bugs.winehq.org/show_bug.cgi?id=43239.

Single files Merged diff Tar archive
You have unsaved changes. Press CTRL + ENTER in a text field to submit your comments.

0001-d3d11-tests-Add-test-for-nointerpolation-modifier.patch

From 3881dd1f8540fa440b8843efc0a6500e4835ba10 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Fri, 8 Sep 2017 00:06:15 +0200
Subject: d3d11/tests: Add test for nointerpolation modifier.
---
dlls/d3d11/tests/d3d11.c | 195 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 195 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index b2516b3928..1d0fc3960a 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -22269,6 +22269,200 @@ static void test_dual_blending(void)
release_test_context(&test_context);
}
+static void test_interpolation(void)
+{
+ struct d3d11_test_context test_context;
+ D3D11_TEXTURE2D_DESC texture_desc;
+ ID3D11InputLayout *input_layout;
+ ID3D11Texture2D *render_target;
+ ID3D11RenderTargetView *rtv[2];
+ ID3D11DeviceContext *context;
+ ID3D11VertexShader *vs;
+ ID3D11PixelShader *ps;
+ ID3D11Device *device;
+ UINT offset, stride;
+ ID3D11Buffer *vb;
+ DWORD color;
+ HRESULT hr;
+
+ static const struct
+ {
+ struct vec4 position;
+ DWORD color;
+ }
+ triangle[] =
+ {
+ {{-1.0f, -1.0f, 0.0f, 1.0f}, 0xff0000ff},
+ {{ 0.0f, 1.0f, 0.0f, 1.0f}, 0x0000ffff},
+ {{ 1.0f, -1.0f, 0.0f, 1.0f}, 0x00ff00ff},
+ };
+
+ static const D3D11_INPUT_ELEMENT_DESC layout_desc[] =
+ {
+ {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
+ {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0},
+ };
+
+ static const DWORD vs_code[] =
+ {
+#if 0
+ struct output
+ {
+ float4 position : SV_POSITION;
+ float4 color0 : COLOR0;
+ float4 color1 : COLOR1;
+ };
+
+ output main(float4 position : POSITION, float4 color : COLOR)
+ {
+ output o;
+
+ o.position = position;
+ o.color0 = color;
+ o.color1 = color;
+
+ return o;
+ }
+#endif
+ 0x43425844, 0x8673452e, 0xedbba3e0, 0x79351b0d, 0xacbebd3e, 0x00000001, 0x00000178, 0x00000003,
+ 0x0000002c, 0x0000007c, 0x000000e8, 0x4e475349, 0x00000048, 0x00000002, 0x00000008, 0x00000038,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000001, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f,
+ 0x00000064, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
+ 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x0000005c,
+ 0x00000001, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5469536f, 0x006e6f69,
+ 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000088, 0x00010040, 0x00000022, 0x0300005f, 0x001010f2,
+ 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
+ 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x05000036, 0x001020f2,
+ 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001,
+ 0x05000036, 0x001020f2, 0x00000002, 0x00101e46, 0x00000001, 0x0100003e,
+ };
+ static const DWORD ps_code[] =
+ {
+#if 0
+ struct input
+ {
+ float4 position : SV_POSITION;
+ linear float4 color0 : COLOR0;
+ nointerpolation float4 color1 : COLOR1;
+ };
+
+ struct output
+ {
+ float4 target0 : SV_Target0;
+ float4 target1 : SV_Target1;
+ };
+
+ void main(const in input i, out output o)
+ {
+ o.target0 = i.color0;
+ o.target1 = i.color1;
+ }
+#endif
+ 0x43425844, 0x97f004eb, 0x5129291d, 0xa12354d7, 0xe07ae35c, 0x00000001, 0x00000150, 0x00000003,
+ 0x0000002c, 0x00000098, 0x000000e4, 0x4e475349, 0x00000064, 0x00000003, 0x00000008, 0x00000050,
+ 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000001, 0x00000f0f, 0x0000005c, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
+ 0x00000f0f, 0x505f5653, 0x5469536f, 0x006e6f69, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x00000044,
+ 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f,
+ 0x00000038, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x545f5653, 0x65677261,
+ 0xabab0074, 0x52444853, 0x00000064, 0x00000040, 0x00000019, 0x03001062, 0x001010f2, 0x00000001,
+ 0x03000862, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2,
+ 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x05000036, 0x001020f2,
+ 0x00000001, 0x00101e46, 0x00000002, 0x0100003e
+ };
+
+ static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
+
+ if (!init_test_context(&test_context, NULL))
+ return;
+
+ device = test_context.device;
+ context = test_context.immediate_context;
+
+ hr = ID3D11Device_CreateVertexShader(device, vs_code, sizeof(vs_code), NULL, &vs);
+ ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
+ hr = ID3D11Device_CreatePixelShader(device, ps_code, sizeof(ps_code), NULL, &ps);
+ ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+
+ ID3D11Texture2D_GetDesc(test_context.backbuffer, &texture_desc);
+ hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &render_target);
+ ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+
+ rtv[0] = test_context.backbuffer_rtv;
+ hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)render_target, NULL, &rtv[1]);
+ ok(SUCCEEDED(hr), "Failed to create render target view, hr %#x.\n", hr);
+
+ ID3D11DeviceContext_VSSetShader(context, vs, NULL, 0);
+ ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0);
+
+ hr = ID3D11Device_CreateInputLayout(device, layout_desc, ARRAY_SIZE(layout_desc),
+ vs_code, sizeof(vs_code), &input_layout);
+ ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
+ vb = create_buffer(device, D3D11_BIND_VERTEX_BUFFER, sizeof(triangle), triangle);
+
+ ID3D11DeviceContext_IASetInputLayout(context, input_layout);
+ ID3D11DeviceContext_IASetPrimitiveTopology(context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+ stride = sizeof(*triangle);
+ offset = 0;
+ ID3D11DeviceContext_IASetVertexBuffers(context, 0, 1, &vb, &stride, &offset);
+ ID3D11DeviceContext_OMSetRenderTargets(context, 2, rtv, NULL);
+
+ ID3D11DeviceContext_ClearRenderTargetView(context, rtv[0], white);
+ ID3D11DeviceContext_ClearRenderTargetView(context, rtv[1], white);
+ ID3D11DeviceContext_Draw(context, 3, 0);
+
+ color = get_texture_color(test_context.backbuffer, 0, 0);
+ ok(compare_color(color, 0xffffffff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(test_context.backbuffer, 640, 0);
+ ok(compare_color(color, 0xffffffff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(test_context.backbuffer, 320, 2);
+ ok(compare_color(color, 0x0001feff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(test_context.backbuffer, 0, 479);
+ ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(test_context.backbuffer, 639, 479);
+ ok(compare_color(color, 0x00ff00ff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(test_context.backbuffer, 319, 479);
+ ok(compare_color(color, 0x807f00ff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(test_context.backbuffer, 319, 400);
+ ok(compare_color(color, 0x6b6a2aff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(test_context.backbuffer, 319, 200);
+ ok(compare_color(color, 0x353594ff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(test_context.backbuffer, 350, 300);
+ ok(compare_color(color, 0x445c5fff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(test_context.backbuffer, 320, 300);
+ ok(compare_color(color, 0x50505fff, 1), "Got unexpected color 0x%08x.\n", color);
+
+ color = get_texture_color(render_target, 0, 0);
+ ok(compare_color(color, 0xffffffff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(render_target, 640, 0);
+ ok(compare_color(color, 0xffffffff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(render_target, 320, 2);
+ todo_wine ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(render_target, 0, 479);
+ ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(render_target, 639, 479);
+ todo_wine ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(render_target, 319, 479);
+ todo_wine ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(render_target, 319, 400);
+ todo_wine ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(render_target, 319, 200);
+ todo_wine ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(render_target, 350, 300);
+ todo_wine ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ color = get_texture_color(render_target, 320, 300);
+ todo_wine ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
+
+ ID3D11InputLayout_Release(input_layout);
+ ID3D11RenderTargetView_Release(rtv[1]);
+ ID3D11Texture2D_Release(render_target);
+ ID3D11Buffer_Release(vb);
+ ID3D11PixelShader_Release(ps);
+ ID3D11VertexShader_Release(vs);
+ release_test_context(&test_context);
+}
+
START_TEST(d3d11)
{
test_create_device();
@@ -22373,4 +22567,5 @@ START_TEST(d3d11)
test_negative_viewports();
test_early_depth_stencil();
test_dual_blending();
+ test_interpolation();
}
--
2.14.1

0002-wined3d-Unroll-vertex-geometry-shader-outputs-and-pi.patch

From 107e1c339728093df5e99b0af200426538e301b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B3zef=20Kucia?= <jkucia@codeweavers.com>
Date: Fri, 8 Sep 2017 01:03:52 +0200
Subject: wined3d: Unroll vertex / geometry shader outputs and pixel shader
inputs for >= sm4.
---
dlls/wined3d/glsl_shader.c | 84 +++++++++++++++++++++++++++++++++++-----------
1 file changed, 64 insertions(+), 20 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 31b892faf6..2c97ba8ef8 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -841,7 +841,7 @@ static void shader_glsl_generate_transform_feedback_varyings(const struct wined3
continue;
}
- string_buffer_sprintf(buffer, "shader_in_out.reg[%u]", e->register_idx);
+ string_buffer_sprintf(buffer, "shader_in_out.reg%u", e->register_idx);
append_transform_feedback_varying(varyings, &count, &strings, &length, buffer);
}
@@ -1849,21 +1849,53 @@ static const char *shader_glsl_shader_output_name(const struct wined3d_gl_info *
}
static void shader_glsl_declare_shader_inputs(const struct wined3d_gl_info *gl_info,
- struct wined3d_string_buffer *buffer, unsigned int element_count)
+ struct wined3d_string_buffer *buffer, unsigned int element_count, BOOL unroll)
{
if (shader_glsl_use_interface_blocks(gl_info))
- shader_addline(buffer, "in shader_in_out { vec4 reg[%u]; } shader_in;\n", element_count);
+ {
+ if (unroll)
+ {
+ unsigned int i;
+
+ shader_addline(buffer, "in shader_in_out {\n");
+ for (i = 0; i < element_count; ++i)
+ shader_addline(buffer, "vec4 reg%u;\n", i);
+ shader_addline(buffer, "} shader_in;\n");
+ }
+ else
+ {
+ shader_addline(buffer, "in shader_in_out { vec4 reg[%u]; } shader_in;\n", element_count);
+ }
+ }
else
+ {
declare_in_varying(gl_info, buffer, FALSE, "vec4 ps_link[%u];\n", element_count);
+ }
}
static void shader_glsl_declare_shader_outputs(const struct wined3d_gl_info *gl_info,
- struct wined3d_string_buffer *buffer, unsigned int element_count)
+ struct wined3d_string_buffer *buffer, unsigned int element_count, BOOL unroll)
{
+ unsigned int i;
+
if (shader_glsl_use_interface_blocks(gl_info))
- shader_addline(buffer, "out shader_in_out { vec4 reg[%u]; } shader_out;\n", element_count);
+ {
+ if (unroll)
+ {
+ shader_addline(buffer, "out shader_in_out {\n");
+ for (i = 0; i < element_count; ++i)
+ shader_addline(buffer, " vec4 reg%u;\n", i);
+ shader_addline(buffer, "} shader_out;\n");
+ }
+ else
+ {
+ shader_addline(buffer, "out shader_in_out { vec4 reg[%u]; } shader_out;\n", element_count);
+ }
+ }
else
+ {
declare_out_varying(gl_info, buffer, FALSE, "vec4 ps_link[%u];\n", element_count);
+ }
}
static const char *glsl_primitive_type_from_d3d(enum wined3d_primitive_type primitive_type)
@@ -6304,7 +6336,7 @@ static void shader_glsl_dp2add(const struct wined3d_shader_instruction *ins)
static void shader_glsl_input_pack(const struct wined3d_shader *shader, struct wined3d_string_buffer *buffer,
const struct wined3d_shader_signature *input_signature,
const struct wined3d_shader_reg_maps *reg_maps,
- const struct ps_compile_args *args, const struct wined3d_gl_info *gl_info)
+ const struct ps_compile_args *args, const struct wined3d_gl_info *gl_info, BOOL unroll)
{
unsigned int i;
@@ -6351,10 +6383,16 @@ static void shader_glsl_input_pack(const struct wined3d_shader *shader, struct w
{
if (input->sysval_semantic)
FIXME("Unhandled sysval semantic %#x.\n", input->sysval_semantic);
- shader_addline(buffer, "ps_in[%u]%s = %s[%u]%s;\n",
- shader->u.ps.input_reg_map[input->register_idx], reg_mask,
- shader_glsl_shader_input_name(gl_info),
- shader->u.ps.input_reg_map[input->register_idx], reg_mask);
+ if (unroll)
+ shader_addline(buffer, "ps_in[%u]%s = %s%u%s;\n",
+ shader->u.ps.input_reg_map[input->register_idx], reg_mask,
+ shader_glsl_shader_input_name(gl_info),
+ shader->u.ps.input_reg_map[input->register_idx], reg_mask);
+ else
+ shader_addline(buffer, "ps_in[%u]%s = %s[%u]%s;\n",
+ shader->u.ps.input_reg_map[input->register_idx], reg_mask,
+ shader_glsl_shader_input_name(gl_info),
+ shader->u.ps.input_reg_map[input->register_idx], reg_mask);
}
}
else if (shader_match_semantic(semantic_name, WINED3D_DECL_USAGE_TEXCOORD))
@@ -6545,7 +6583,8 @@ static void shader_glsl_setup_vs3_output(struct shader_glsl_priv *priv,
static void shader_glsl_setup_sm4_shader_output(struct shader_glsl_priv *priv,
unsigned int input_count, const struct wined3d_shader_signature *output_signature,
- const struct wined3d_shader_reg_maps *reg_maps_out, const char *output_variable_name)
+ const struct wined3d_shader_reg_maps *reg_maps_out, const char *output_variable_name,
+ BOOL rasterizer_setup)
{
struct wined3d_string_buffer *buffer = &priv->shader_buffer;
char reg_mask[6];
@@ -6566,8 +6605,12 @@ static void shader_glsl_setup_sm4_shader_output(struct shader_glsl_priv *priv,
shader_glsl_write_mask_to_str(output->mask, reg_mask);
- shader_addline(buffer, "%s.reg[%u]%s = outputs[%u]%s;\n",
- output_variable_name, output->register_idx, reg_mask, output->register_idx, reg_mask);
+ if (rasterizer_setup)
+ shader_addline(buffer, "%s.reg%u%s = outputs[%u]%s;\n",
+ output_variable_name, output->register_idx, reg_mask, output->register_idx, reg_mask);
+ else
+ shader_addline(buffer, "%s.reg[%u]%s = outputs[%u]%s;\n",
+ output_variable_name, output->register_idx, reg_mask, output->register_idx, reg_mask);
}
}
@@ -6625,7 +6668,7 @@ static void shader_glsl_setup_sm3_rasterizer_input(struct shader_glsl_priv *priv
shader_glsl_setup_vs3_output(priv, gl_info, map, input_signature, reg_maps_in,
output_signature, reg_maps_out);
else
- shader_glsl_setup_sm4_shader_output(priv, input_count, output_signature, reg_maps_out, "shader_out");
+ shader_glsl_setup_sm4_shader_output(priv, input_count, output_signature, reg_maps_out, "shader_out", TRUE);
}
/* Context activation is done by the caller. */
@@ -6757,7 +6800,7 @@ static GLuint shader_glsl_generate_vs3_rasterizer_input_setup(struct shader_glsl
{
unsigned int in_count = min(vec4_varyings(ps_major, gl_info), ps->limits->packed_input);
- shader_glsl_declare_shader_outputs(gl_info, buffer, in_count);
+ shader_glsl_declare_shader_outputs(gl_info, buffer, in_count, FALSE);
shader_addline(buffer, "void setup_vs_output(in vec4 outputs[%u])\n{\n", vs->limits->packed_output);
shader_glsl_setup_sm3_rasterizer_input(priv, gl_info, ps->u.ps.input_reg_map, &ps->input_signature,
&ps->reg_maps, 0, &vs->output_signature, &vs->reg_maps, per_vertex_point_size);
@@ -6783,7 +6826,7 @@ static void shader_glsl_generate_sm4_output_setup(struct shader_glsl_priv *priv,
input_count = min(vec4_varyings(4, gl_info), input_count);
if (input_count)
- shader_glsl_declare_shader_outputs(gl_info, buffer, input_count);
+ shader_glsl_declare_shader_outputs(gl_info, buffer, input_count, rasterizer_setup);
shader_addline(buffer, "void setup_%s_output(in vec4 outputs[%u])\n{\n",
prefix, shader->limits->packed_output);
@@ -6793,7 +6836,7 @@ static void shader_glsl_generate_sm4_output_setup(struct shader_glsl_priv *priv,
NULL, input_count, &shader->output_signature, &shader->reg_maps, FALSE);
else
shader_glsl_setup_sm4_shader_output(priv, input_count, &shader->output_signature,
- &shader->reg_maps, "shader_out");
+ &shader->reg_maps, "shader_out", rasterizer_setup);
shader_addline(buffer, "}\n");
}
@@ -7119,7 +7162,7 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
unsigned int in_count = min(vec4_varyings(version->major, gl_info), shader->limits->packed_input);
if (args->vp_mode == vertexshader && reg_maps->input_registers)
- shader_glsl_declare_shader_inputs(gl_info, buffer, in_count);
+ shader_glsl_declare_shader_inputs(gl_info, buffer, in_count, version->major >= 4);
shader_addline(buffer, "vec4 %s_in[%u];\n", prefix, in_count);
}
@@ -7265,7 +7308,8 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
/* Pack 3.0 inputs */
if (reg_maps->shader_version.major >= 3)
- shader_glsl_input_pack(shader, buffer, &shader->input_signature, reg_maps, args, gl_info);
+ shader_glsl_input_pack(shader, buffer, &shader->input_signature, reg_maps, args, gl_info,
+ reg_maps->shader_version.major >= 4);
/* Base Shader Body */
if (FAILED(shader_generate_code(shader, buffer, reg_maps, &priv_ctx, NULL, NULL)))
@@ -7494,7 +7538,7 @@ static GLuint shader_glsl_generate_hull_shader(const struct wined3d_context *con
shader_addline(buffer, "void setup_hs_output(in vec4 outputs[%u])\n{\n",
shader->limits->packed_output);
shader_glsl_setup_sm4_shader_output(priv, shader->limits->packed_output, &shader->output_signature,
- &shader->reg_maps, "shader_out[gl_InvocationID]");
+ &shader->reg_maps, "shader_out[gl_InvocationID]", FALSE);
shader_addline(buffer, "}\n");
}
--
2.14.1

0003-wined3d-Add-support-for-interpolation-modifiers-in-s.patch

From 7b7b04a75fd3ecaf5323582f7833a8abab505a28 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B3zef=20Kucia?= <jkucia@codeweavers.com>
Date: Fri, 8 Sep 2017 01:43:04 +0200
Subject: wined3d: Add support for interpolation modifiers in sm4/sm5 pixel
shader inputs.
---
dlls/d3d11/tests/d3d11.c | 14 +++++------
dlls/wined3d/glsl_shader.c | 56 ++++++++++++++++++++++++++++++++++++++----
dlls/wined3d/shader.c | 14 +++++++++++
dlls/wined3d/wined3d_private.h | 2 ++
4 files changed, 74 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 1d0fc3960a..692d1bf879 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -22438,21 +22438,21 @@ static void test_interpolation(void)
color = get_texture_color(render_target, 640, 0);
ok(compare_color(color, 0xffffffff, 1), "Got unexpected color 0x%08x.\n", color);
color = get_texture_color(render_target, 320, 2);
- todo_wine ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
color = get_texture_color(render_target, 0, 479);
ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
color = get_texture_color(render_target, 639, 479);
- todo_wine ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
color = get_texture_color(render_target, 319, 479);
- todo_wine ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
color = get_texture_color(render_target, 319, 400);
- todo_wine ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
color = get_texture_color(render_target, 319, 200);
- todo_wine ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
color = get_texture_color(render_target, 350, 300);
- todo_wine ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
color = get_texture_color(render_target, 320, 300);
- todo_wine ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
+ ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color);
ID3D11InputLayout_Release(input_layout);
ID3D11RenderTargetView_Release(rtv[1]);
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 2c97ba8ef8..59bba75b23 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -387,7 +387,9 @@ static const char *shader_glsl_get_prefix(enum wined3d_shader_type type)
static unsigned int shader_glsl_get_version(const struct wined3d_gl_info *gl_info)
{
- if (gl_info->glsl_version >= MAKEDWORD_VERSION(1, 50))
+ if (gl_info->glsl_version >= MAKEDWORD_VERSION(4, 40))
+ return 440;
+ else if (gl_info->glsl_version >= MAKEDWORD_VERSION(1, 50))
return 150;
else if (gl_info->glsl_version >= MAKEDWORD_VERSION(1, 30))
return 130;
@@ -1848,8 +1850,51 @@ static const char *shader_glsl_shader_output_name(const struct wined3d_gl_info *
return shader_glsl_use_interface_blocks(gl_info) ? "shader_out.reg" : "ps_link";
}
+static const char *shader_glsl_get_interpolation(const struct wined3d_gl_info *gl_info, enum wined3d_shader_interpolation_mode mode)
+{
+ const char *inter;
+
+ switch (mode)
+ {
+ case WINED3DSIM_NONE:
+ case WINED3DSIM_LINEAR:
+ return "";
+ case WINED3DSIM_CONSTANT:
+ inter = "flat";
+ break;
+ case WINED3DSIM_LINEAR_CENTROID:
+ inter = "centroid";
+ break;
+ case WINED3DSIM_LINEAR_NOPERSPECTIVE:
+ inter = "noperspective";
+ break;
+ case WINED3DSIM_LINEAR_NOPERSPECTIVE_CENTROID:
+ inter = "noperspective centroid";
+ break;
+ case WINED3DSIM_LINEAR_SAMPLE:
+ inter = "sample";
+ break;
+ case WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE:
+ inter = "noperspective sample";
+ break;
+ default:
+ FIXME("Unhandled interpolation mode %#x.\n", mode);
+ return "";
+ }
+
+ if (shader_glsl_get_version(gl_info) < 440)
+ {
+ FIXME("Interpolation mode %x requires support for glsl 4.40\n", mode);
+ return "";
+ }
+
+ return inter;
+}
+
static void shader_glsl_declare_shader_inputs(const struct wined3d_gl_info *gl_info,
- struct wined3d_string_buffer *buffer, unsigned int element_count, BOOL unroll)
+ struct wined3d_string_buffer *buffer, unsigned int element_count,
+ const enum wined3d_shader_interpolation_mode *interpolation_mode,
+ BOOL unroll)
{
if (shader_glsl_use_interface_blocks(gl_info))
{
@@ -1859,7 +1904,7 @@ static void shader_glsl_declare_shader_inputs(const struct wined3d_gl_info *gl_i
shader_addline(buffer, "in shader_in_out {\n");
for (i = 0; i < element_count; ++i)
- shader_addline(buffer, "vec4 reg%u;\n", i);
+ shader_addline(buffer, "%s vec4 reg%u;\n", shader_glsl_get_interpolation(gl_info, interpolation_mode[i]), i);
shader_addline(buffer, "} shader_in;\n");
}
else
@@ -7162,7 +7207,8 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
unsigned int in_count = min(vec4_varyings(version->major, gl_info), shader->limits->packed_input);
if (args->vp_mode == vertexshader && reg_maps->input_registers)
- shader_glsl_declare_shader_inputs(gl_info, buffer, in_count, version->major >= 4);
+ shader_glsl_declare_shader_inputs(gl_info, buffer, in_count,
+ shader->u.ps.interpolation_mode, version->major >= 4);
shader_addline(buffer, "vec4 %s_in[%u];\n", prefix, in_count);
}
@@ -10613,7 +10659,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
/* WINED3DSIH_DCL_INPUT */ shader_glsl_nop,
/* WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT */ shader_glsl_nop,
/* WINED3DSIH_DCL_INPUT_PRIMITIVE */ shader_glsl_nop,
- /* WINED3DSIH_DCL_INPUT_PS */ NULL,
+ /* WINED3DSIH_DCL_INPUT_PS */ shader_glsl_nop,
/* WINED3DSIH_DCL_INPUT_PS_SGV */ NULL,
/* WINED3DSIH_DCL_INPUT_PS_SIV */ NULL,
/* WINED3DSIH_DCL_INPUT_SGV */ shader_glsl_nop,
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index ad0002b57d..24fcdb4209 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -1159,6 +1159,20 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
FIXME("Invalid instruction depth declaration for shader type %#x.\n", shader_version.type);
}
}
+ else if (ins.handler_idx == WINED3DSIH_DCL_INPUT_PS)
+ {
+ unsigned int reg_idx = ins.declaration.dst.reg.idx[0].offset;
+ if (reg_idx >= ARRAY_SIZE(shader->u.ps.interpolation_mode))
+ {
+ ERR("Invalid register index %u.\n", reg_idx);
+ break;
+ }
+ if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
+ shader->u.ps.interpolation_mode[reg_idx] = ins.flags;
+ else
+ FIXME("Invalid instruction %#x for shader type %#x.\n",
+ ins.handler_idx, shader_version.type);
+ }
else if (ins.handler_idx == WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT)
{
if (shader_version.type == WINED3D_SHADER_TYPE_HULL)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 5089e6b8c3..bb58b92199 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -553,6 +553,7 @@ enum wined3d_shader_dst_modifier
enum wined3d_shader_interpolation_mode
{
+ WINED3DSIM_NONE = 0,
WINED3DSIM_CONSTANT = 1,
WINED3DSIM_LINEAR = 2,
WINED3DSIM_LINEAR_CENTROID = 3,
@@ -3991,6 +3992,7 @@ struct wined3d_pixel_shader
BOOL force_early_depth_stencil;
DWORD depth_compare;
+ enum wined3d_shader_interpolation_mode interpolation_mode[MAX_REG_INPUT];
};
struct wined3d_compute_shader
--
2.14.1