Added patch to implement support for interpolation modifiers in sm4/sm5 pixel shaders.

This commit is contained in:
Sebastian Lackner 2017-09-08 17:06:22 +02:00
parent 1767361878
commit 36f5d4da6c
6 changed files with 679 additions and 22 deletions

View File

@ -454,6 +454,7 @@ patch_enable_all ()
enable_wined3d_Dual_Source_Blending="$1"
enable_wined3d_GTX_560M="$1"
enable_wined3d_Indexed_Vertex_Blending="$1"
enable_wined3d_Interpolation_Modifiers="$1"
enable_wined3d_Limit_Vram="$1"
enable_wined3d_QUERY_Stubs="$1"
enable_wined3d_Revert_Buffer_Upload="$1"
@ -1640,6 +1641,9 @@ patch_enable ()
wined3d-Indexed_Vertex_Blending)
enable_wined3d_Indexed_Vertex_Blending="$2"
;;
wined3d-Interpolation_Modifiers)
enable_wined3d_Interpolation_Modifiers="$2"
;;
wined3d-Limit_Vram)
enable_wined3d_Limit_Vram="$2"
;;
@ -2229,6 +2233,17 @@ if test "$enable_wined3d_CSMT_Main" -eq 1; then
enable_wined3d_CSMT_Helper=1
fi
if test "$enable_wined3d_Interpolation_Modifiers" -eq 1; then
if test "$enable_wined3d_Dual_Source_Blending" -gt 1; then
abort "Patchset wined3d-Dual_Source_Blending disabled, but wined3d-Interpolation_Modifiers depends on that."
fi
if test "$enable_wined3d_conservative_depth" -gt 1; then
abort "Patchset wined3d-conservative_depth disabled, but wined3d-Interpolation_Modifiers depends on that."
fi
enable_wined3d_Dual_Source_Blending=1
enable_wined3d_conservative_depth=1
fi
if test "$enable_wined3d_conservative_depth" -eq 1; then
if test "$enable_wined3d_Copy_Resource_Typeless" -gt 1; then
abort "Patchset wined3d-Copy_Resource_Typeless disabled, but wined3d-conservative_depth depends on that."
@ -9853,6 +9868,47 @@ if test "$enable_wined3d_Indexed_Vertex_Blending" -eq 1; then
) >> "$patchlist"
fi
# Patchset wined3d-conservative_depth
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * d3d11-Depth_Bias, wined3d-1DTextures, wined3d-Copy_Resource_Typeless
# |
# | Modified files:
# | * dlls/wined3d/arb_program_shader.c, dlls/wined3d/directx.c, dlls/wined3d/glsl_shader.c, dlls/wined3d/shader.c,
# | dlls/wined3d/shader_sm4.c, dlls/wined3d/wined3d_gl.h, dlls/wined3d/wined3d_private.h
# |
if test "$enable_wined3d_conservative_depth" -eq 1; then
patch_apply wined3d-conservative_depth/0001-wined3d-Recognize-conservative-depth-output-register.patch
patch_apply wined3d-conservative_depth/0002-wined3d-Add-conservative-depth-access-information-to.patch
(
printf '%s\n' '+ { "Michael Müller", "wined3d: Recognize conservative depth output registers in sm4.", 1 },';
printf '%s\n' '+ { "Michael Müller", "wined3d: Add conservative depth access information to glsl pixel shaders.", 1 },';
) >> "$patchlist"
fi
# Patchset wined3d-Interpolation_Modifiers
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * d3d11-Depth_Bias, wined3d-Core_Context, wined3d-Viewports, wined3d-Dual_Source_Blending, wined3d-1DTextures, wined3d-
# | Copy_Resource_Typeless, wined3d-conservative_depth
# |
# | This patchset fixes the following Wine bugs:
# | * [#43239] Implement support for interpolation modifiers in sm4/sm5 pixel shaders
# |
# | Modified files:
# | * dlls/d3d11/tests/d3d11.c, dlls/wined3d/glsl_shader.c, dlls/wined3d/shader.c, dlls/wined3d/wined3d_private.h
# |
if test "$enable_wined3d_Interpolation_Modifiers" -eq 1; then
patch_apply wined3d-Interpolation_Modifiers/0001-d3d11-tests-Add-test-for-nointerpolation-modifier.patch
patch_apply wined3d-Interpolation_Modifiers/0002-wined3d-Unroll-vertex-geometry-shader-outputs-and-pi.patch
patch_apply wined3d-Interpolation_Modifiers/0003-wined3d-Add-support-for-interpolation-modifiers-in-s.patch
(
printf '%s\n' '+ { "Michael Müller", "d3d11/tests: Add test for nointerpolation modifier.", 1 },';
printf '%s\n' '+ { "Józef Kucia", "wined3d: Unroll vertex / geometry shader outputs and pixel shader inputs for >= sm4.", 1 },';
printf '%s\n' '+ { "Józef Kucia", "wined3d: Add support for interpolation modifiers in sm4/sm5 pixel shader inputs.", 1 },';
) >> "$patchlist"
fi
# Patchset wined3d-Limit_Vram
# |
# | Modified files:
@ -9904,24 +9960,6 @@ if test "$enable_wined3d_buffer_create" -eq 1; then
) >> "$patchlist"
fi
# Patchset wined3d-conservative_depth
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * d3d11-Depth_Bias, wined3d-1DTextures, wined3d-Copy_Resource_Typeless
# |
# | Modified files:
# | * dlls/wined3d/arb_program_shader.c, dlls/wined3d/directx.c, dlls/wined3d/glsl_shader.c, dlls/wined3d/shader.c,
# | dlls/wined3d/shader_sm4.c, dlls/wined3d/wined3d_gl.h, dlls/wined3d/wined3d_private.h
# |
if test "$enable_wined3d_conservative_depth" -eq 1; then
patch_apply wined3d-conservative_depth/0001-wined3d-Recognize-conservative-depth-output-register.patch
patch_apply wined3d-conservative_depth/0002-wined3d-Add-conservative-depth-access-information-to.patch
(
printf '%s\n' '+ { "Michael Müller", "wined3d: Recognize conservative depth output registers in sm4.", 1 },';
printf '%s\n' '+ { "Michael Müller", "wined3d: Add conservative depth access information to glsl pixel shaders.", 1 },';
) >> "$patchlist"
fi
# Patchset wined3d-sample_c_lz
# |
# | This patchset fixes the following Wine bugs:

View File

@ -619,7 +619,7 @@ diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2849,6 +2849,16 @@ static inline BOOL wined3d_dualblend_enabled(const struct wined3d_state *state,
@@ -2850,6 +2850,16 @@ static inline BOOL wined3d_dualblend_enabled(const struct wined3d_state *state,
return FALSE;
}
@ -636,7 +636,7 @@ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
#define WINED3D_UNMAPPED_STAGE ~0u
/* Multithreaded flag. Removed from the public header to signal that
@@ -2960,6 +2970,12 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL
@@ -2961,6 +2971,12 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL
void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void device_invalidate_state(const struct wined3d_device *device, DWORD state) DECLSPEC_HIDDEN;
@ -649,7 +649,7 @@ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
static inline BOOL isStateDirty(const struct wined3d_context *context, DWORD state)
{
@@ -3147,7 +3163,11 @@ struct wined3d_texture
@@ -3148,7 +3164,11 @@ struct wined3d_texture
unsigned int map_count;
DWORD locations;
@ -661,7 +661,7 @@ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
} sub_resources[1];
};
@@ -3462,6 +3482,9 @@ struct wined3d_cs_queue
@@ -3463,6 +3483,9 @@ struct wined3d_cs_queue
struct wined3d_cs_ops
{

View File

@ -0,0 +1,223 @@
From 77064634e962d24ab755c78c4b0c61cd64efe7ef 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 b2516b3928a..1d0fc3960a0 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

View File

@ -0,0 +1,203 @@
From f851b588d460fd11fcf0e2abde1051b4029457f2 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 31b892faf65..2c97ba8ef8d 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

View File

@ -0,0 +1,190 @@
From 99875453e00427ccc918e237857d12cd818b8fdf 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 1d0fc3960a0..692d1bf8796 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 2c97ba8ef8d..59bba75b230 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 ad0002b57d7..24fcdb4209a 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 610b7b04160..dbb0399b12e 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

View File

@ -0,0 +1,3 @@
Fixes: [43239] Implement support for interpolation modifiers in sm4/sm5 pixel shaders
Depends: wined3d-Dual_Source_Blending
Depends: wined3d-conservative_depth