wined3d-Interpolation_Modifiers: Add quirk for broken auxiliary qualifier matching in wined3d.

This commit is contained in:
Sebastian Lackner 2017-10-02 15:11:17 +02:00
parent 65acc06d90
commit b6b1505f12
4 changed files with 174 additions and 6 deletions

View File

@ -9774,16 +9774,19 @@ fi
# | * [#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
# | * dlls/d3d11/tests/d3d11.c, dlls/wined3d/directx.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
patch_apply wined3d-Interpolation_Modifiers/0004-wined3d-Add-quirk-for-broken-auxiliary-qualifier-mat.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 },';
printf '%s\n' '+ { "Michael Müller", "wined3d: Add quirk for broken auxiliary qualifier matching.", 1 },';
) >> "$patchlist"
fi

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
@@ -2850,6 +2850,16 @@ static inline BOOL wined3d_dualblend_enabled(const struct wined3d_state *state,
@@ -2851,6 +2851,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
@@ -2961,6 +2971,12 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL
@@ -2962,6 +2972,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)
{
@@ -3148,7 +3164,11 @@ struct wined3d_texture
@@ -3149,7 +3165,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];
};
@@ -3464,6 +3484,9 @@ struct wined3d_cs_queue
@@ -3465,6 +3485,9 @@ struct wined3d_cs_queue
struct wined3d_cs_ops
{

View File

@ -97,7 +97,7 @@ index a74f609e212..417f267fddc 100644
+
+ if (shader_glsl_get_version(gl_info) < 440)
+ {
+ FIXME("Interpolation mode %x requires support for glsl 4.40\n", mode);
+ FIXME("Interpolation mode %x requires support for glsl 4.40.\n", mode);
+ return "";
+ }
+

View File

@ -0,0 +1,165 @@
From 6c58c594500ae6de458b6f0b725d7912b0beb6fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sun, 1 Oct 2017 15:38:28 +0200
Subject: wined3d: Add quirk for broken auxiliary qualifier matching.
---
dlls/wined3d/directx.c | 96 ++++++++++++++++++++++++++++++++++++++++++
dlls/wined3d/glsl_shader.c | 7 +++
dlls/wined3d/wined3d_private.h | 1 +
3 files changed, 104 insertions(+)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 5bca150305a..2a56bb73411 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -943,6 +943,92 @@ static BOOL match_broken_viewport_subpixel_bits(const struct wined3d_gl_info *gl
return !wined3d_caps_gl_ctx_test_viewport_subpixel_bits(ctx);
}
+static GLuint compile_glsl_shader(const struct wined3d_gl_info *gl_info, GLenum type, const GLchar *src)
+{
+ GLchar log[4096];
+ GLuint shader;
+ GLint status;
+
+ shader = GL_EXTCALL(glCreateShader(type));
+ if (!shader)
+ {
+ ERR("Failed to create shader\n");
+ return 0;
+ }
+
+ GL_EXTCALL(glShaderSource(shader, 1, &src, NULL));
+ GL_EXTCALL(glCompileShader(shader));
+
+ GL_EXTCALL(glGetShaderiv(shader, GL_COMPILE_STATUS, &status));
+ if (!status)
+ {
+ GL_EXTCALL(glGetShaderInfoLog(shader, sizeof(log), NULL, log));
+ ERR("Failed to compile inferface matching shader %x: %s\n", type, (char *)log);
+ GL_EXTCALL(glDeleteShader(shader));
+ return 0;
+ }
+ return shader;
+}
+
+/* Context activation is done by the caller. */
+static BOOL match_broken_interface_matching(const struct wined3d_gl_info *gl_info,
+ struct wined3d_caps_gl_ctx *ctx, const char *gl_renderer, enum wined3d_gl_vendor gl_vendor,
+ enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
+{
+ static const char vertex_src[] =
+ "#version 440\n"
+ "in vec4 vs_in0;\n"
+ "out shader_in_out { vec4 reg0; } shader_out;\n"
+ "void main()\n"
+ "{\n"
+ " shader_out.reg0 = (vs_in0.xyzw);\n"
+ "}";
+ static const char frag_src[] =
+ "#version 440\n"
+ "in shader_in_out { centroid vec4 reg0; } shader_in;\n"
+ "out vec4 ps_out0;\n"
+ "void main()\n"
+ "{\n"
+ " ps_out0 = vec4(1.0, 0.0, 1.0, 1.0);\n"
+ "}";
+
+ GLuint vs = 0, ps = 0, prog = 0;
+ GLchar log[4096];
+ BOOL ret = TRUE;
+ GLint status;
+
+ if (!wined3d_settings.glslRequested || gl_info->glsl_version < MAKEDWORD_VERSION(4, 40))
+ return FALSE;
+
+ if (!(vs = compile_glsl_shader(gl_info, GL_VERTEX_SHADER, vertex_src)))
+ return TRUE;
+
+ if (!(ps = compile_glsl_shader(gl_info, GL_FRAGMENT_SHADER, frag_src)))
+ goto done;
+
+ prog = GL_EXTCALL(glCreateProgram());
+ if (!prog) goto done;
+
+ GL_EXTCALL(glAttachShader(prog, vs));
+ GL_EXTCALL(glAttachShader(prog, ps));
+
+ GL_EXTCALL(glLinkProgram(prog));
+ GL_EXTCALL(glGetProgramiv(prog, GL_LINK_STATUS, &status));
+ if (!status)
+ {
+ GL_EXTCALL(glGetProgramInfoLog(prog, sizeof(log), NULL, log));
+ WARN("OpenGL implementation has broken matching for storage qualifiers: %s\n", log);
+ }
+ else
+ ret = FALSE;
+
+done:
+ if (prog) GL_EXTCALL(glDeleteProgram(prog));
+ if (vs) GL_EXTCALL(glDeleteShader(vs));
+ if (ps) GL_EXTCALL(glDeleteShader(ps));
+ return ret;
+}
+
static void quirk_apple_glsl_constants(struct wined3d_gl_info *gl_info)
{
/* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
@@ -1080,6 +1166,11 @@ static void quirk_broken_viewport_subpixel_bits(struct wined3d_gl_info *gl_info)
}
}
+static void quirk_broken_interface_matching(struct wined3d_gl_info *gl_info)
+{
+ gl_info->quirks |= WINED3D_QUIRK_BROKEN_STORAGE_MATCHING;
+}
+
struct driver_quirk
{
BOOL (*match)(const struct wined3d_gl_info *gl_info, struct wined3d_caps_gl_ctx *ctx,
@@ -1176,6 +1267,11 @@ static const struct driver_quirk quirk_table[] =
quirk_broken_viewport_subpixel_bits,
"Nvidia viewport subpixel bits bug"
},
+ {
+ match_broken_interface_matching,
+ quirk_broken_interface_matching,
+ "Mesa broken shader interface matching"
+ },
};
/* Certain applications (Steam) complain if we report an outdated driver version. In general,
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index dee797a4e1f..16db7069654 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -1888,6 +1888,13 @@ static const char *shader_glsl_get_interpolation(const struct wined3d_gl_info *g
return "";
}
+ if ((gl_info->quirks & WINED3D_QUIRK_BROKEN_STORAGE_MATCHING) &&
+ (strstr(inter, "centroid") || strstr(inter, "sample")))
+ {
+ FIXME("Auxiliary matching for %s broken in host OpenGL implementation, ignoring it.\n", inter);
+ return "";
+ }
+
return inter;
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 38cbfbe1c25..09ae7a23b89 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -72,6 +72,7 @@
#define WINED3D_QUIRK_INFO_LOG_SPAM 0x00000080
#define WINED3D_QUIRK_LIMITED_TEX_FILTERING 0x00000100
#define WINED3D_QUIRK_BROKEN_ARB_FOG 0x00000200
+#define WINED3D_QUIRK_BROKEN_STORAGE_MATCHING 0x00000400
enum wined3d_ffp_idx
{
--
2.14.1