Added patch to fix regression causing too dark/missing textures in several games.

This commit is contained in:
Sebastian Lackner 2015-03-20 21:46:12 +01:00
parent 5ee34a9309
commit dab39259ab
5 changed files with 177 additions and 1 deletions

View File

@ -38,13 +38,14 @@ Wine. All those differences are also documented on the
Included bug fixes and improvements
===================================
**Bugfixes and features included in the next upcoming release [13]:**
**Bugfixes and features included in the next upcoming release [14]:**
* Add stub for PowerCreateRequest
* Add stub for wininet.ParseX509EncodedCertificateForListBoxEntry ([Wine Bug #29842](https://bugs.winehq.org/show_bug.cgi?id=29842))
* Allow to edit winecfg library override by double clicking
* Fix caps lock state issues with multiple processes ([Wine Bug #35907](https://bugs.winehq.org/show_bug.cgi?id=35907))
* Fix multithreading issues with fullscreen clipping ([Wine Bug #38087](https://bugs.winehq.org/show_bug.cgi?id=38087))
* Fix regression causing too dark/missing textures in several games ([Wine Bug #38256](https://bugs.winehq.org/show_bug.cgi?id=38256))
* Fix wrong version of ID3DXEffect interface for d3dx9_24
* Fix wrong version of ID3DXEffect interface for d3dx9_25 ([Wine Bug #25138](https://bugs.winehq.org/show_bug.cgi?id=25138))
* GetMessage should remove already seen messages with higher priority ([Wine Bug #28884](https://bugs.winehq.org/show_bug.cgi?id=28884))

1
debian/changelog vendored
View File

@ -25,6 +25,7 @@ wine-staging (1.7.39) UNRELEASED; urgency=low
* Added patch to implement combase.WindowsSubstring function.
* Added patch with stub for wininet.ParseX509EncodedCertificateForListBoxEntry.
* Added patch to allow to edit winecfg library override by double clicking.
* Added patch to fix regression causing too dark/missing textures in several games.
* Removed patch to avoid hardcoded values for sizeof(GUID) (accepted upstream).
* Removed patches for SLGetWindowsInformationDWORD (accepted upstream).
* Removed patches for _ismbckata and _mbctohira (fixed upstream).

View File

@ -215,6 +215,7 @@ patch_enable_all ()
enable_wined3d_CSMT_Main="$1"
enable_wined3d_DXTn="$1"
enable_wined3d_Multisampling="$1"
enable_wined3d_NormalMatrix="$1"
enable_wined3d_Revert_PixelFormat="$1"
enable_wined3d_UnhandledBlendFactor="$1"
enable_winedevice_Fix_Relocation="$1"
@ -701,6 +702,9 @@ patch_enable ()
wined3d-Multisampling)
enable_wined3d_Multisampling="$2"
;;
wined3d-NormalMatrix)
enable_wined3d_NormalMatrix="$2"
;;
wined3d-Revert_PixelFormat)
enable_wined3d_Revert_PixelFormat="$2"
;;
@ -1843,6 +1847,21 @@ if test "$enable_wined3d_Multisampling" -eq 1; then
) >> "$patchlist"
fi
# Patchset wined3d-NormalMatrix
# |
# | This patchset fixes the following Wine bugs:
# | * [#38256] Fix regression causing too dark/missing textures in several games
# |
# | Modified files:
# | * dlls/wined3d/glsl_shader.c
# |
if test "$enable_wined3d_NormalMatrix" -eq 1; then
patch_apply wined3d-NormalMatrix/0001-wined3d-Don-t-use-the-builtin-FFP-uniform-for-the-no.patch
(
echo '+ { "Matteo Bruni", "wined3d: Don'\''t use the builtin FFP uniform for the normal matrix.", 1 },';
) >> "$patchlist"
fi
# Patchset wined3d-Revert_PixelFormat
# |
# | This patchset fixes the following Wine bugs:

View File

@ -0,0 +1,154 @@
From 8456f447a55b969ee02f6d972885274660e6e29e Mon Sep 17 00:00:00 2001
From: Matteo Bruni <mbruni@codeweavers.com>
Date: Fri, 20 Mar 2015 18:56:53 +0100
Subject: wined3d: Don't use the builtin FFP uniform for the normal matrix.
---
dlls/wined3d/glsl_shader.c | 95 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 93 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index e38cd18..0f1ba8e 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -118,6 +118,7 @@ struct glsl_vs_program
GLint pos_fixup_location;
GLint modelview_matrix_location;
+ GLint normal_matrix_location;
};
struct glsl_gs_program
@@ -735,6 +736,92 @@ static void shader_glsl_load_np2fixup_constants(const struct glsl_ps_program *ps
GL_EXTCALL(glUniform4fv(ps->np2_fixup_location, ps->np2_fixup_info->num_consts, np2fixup_constants));
}
+/* Taken and adapted from Mesa. */
+static BOOL invert_matrix_3d_general(struct wined3d_matrix *out, const struct wined3d_matrix *in)
+{
+ float pos, neg, t;
+ float det;
+ struct wined3d_matrix temp;
+
+ /* Calculate the determinant of upper left 3x3 submatrix and
+ * determine if the matrix is singular. */
+ pos = neg = 0.0f;
+ t = in->_11 * in->_22 * in->_33;
+ if (t >= 0.0f)
+ pos += t;
+ else
+ neg += t;
+
+ t = in->_21 * in->_32 * in->_13;
+ if (t >= 0.0f)
+ pos += t;
+ else
+ neg += t;
+ t = in->_31 * in->_12 * in->_23;
+ if (t >= 0.0f)
+ pos += t;
+ else
+ neg += t;
+
+ t = -in->_31 * in->_22 * in->_13;
+ if (t >= 0.0f)
+ pos += t;
+ else
+ neg += t;
+ t = -in->_21 * in->_12 * in->_33;
+ if (t >= 0.0f)
+ pos += t;
+ else
+ neg += t;
+
+ t = -in->_11 * in->_32 * in->_23;
+ if (t >= 0.0f)
+ pos += t;
+ else
+ neg += t;
+
+ det = pos + neg;
+
+ if (fabsf(det) < 1e-25f)
+ return FALSE;
+
+ det = 1.0f / det;
+ temp._11 = (in->_22 * in->_33 - in->_32 * in->_23) * det;
+ temp._12 = -(in->_12 * in->_33 - in->_32 * in->_13) * det;
+ temp._13 = (in->_12 * in->_23 - in->_22 * in->_13) * det;
+ temp._21 = -(in->_21 * in->_33 - in->_31 * in->_23) * det;
+ temp._22 = (in->_11 * in->_33 - in->_31 * in->_13) * det;
+ temp._23 = -(in->_11 * in->_23 - in->_21 * in->_13) * det;
+ temp._31 = (in->_21 * in->_32 - in->_31 * in->_22) * det;
+ temp._32 = -(in->_11 * in->_32 - in->_31 * in->_12) * det;
+ temp._33 = (in->_11 * in->_22 - in->_21 * in->_12) * det;
+
+ memcpy(out, &temp, sizeof(temp));
+ return TRUE;
+}
+
+static void shader_glsl_ffp_vertex_normalmatrix_uniform(const struct wined3d_context *context,
+ const struct wined3d_state *state, struct glsl_shader_prog_link *prog)
+{
+ const struct wined3d_gl_info *gl_info = context->gl_info;
+ float mat[3][3];
+ struct wined3d_matrix mv;
+ unsigned int i, j;
+
+ /* gl_NormalMatrix is defined in the spec as "transpose of the inverse of the
+ * upper leftmost 3x3 of gl_ModelViewMatrix". */
+ get_modelview_matrix(context, state, &mv);
+ /* TODO: Could check for and use optimized matrix inversion functions for
+ * special (common) cases, like Mesa does. */
+ invert_matrix_3d_general(&mv, &mv);
+ for (i = 0; i < 3; ++i)
+ for (j = 0; j < 3; ++j)
+ mat[i][j] = ((float *)&mv)[i * 4 + j];
+
+ GL_EXTCALL(glUniformMatrix3fv(prog->vs.normal_matrix_location, 1, FALSE, (GLfloat *)mat));
+ checkGLcall("glUniformMatrix3fv");
+}
+
/* Context activation is done by the caller (state handler). */
static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context *context,
const struct wined3d_state *state)
@@ -784,6 +871,8 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
get_modelview_matrix(context, state, &mat);
GL_EXTCALL(glUniformMatrix4fv(prog->vs.modelview_matrix_location, 1, FALSE, &mat._11));
checkGLcall("glUniformMatrix4fv");
+
+ shader_glsl_ffp_vertex_normalmatrix_uniform(context, state, prog);
}
if (update_mask & WINED3D_SHADER_CONST_PS_F)
@@ -4989,6 +5078,7 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct wined3d_shader_buffe
shader_addline(buffer, "\n");
shader_addline(buffer, "uniform mat4 ffp_modelview_matrix;\n");
+ shader_addline(buffer, "uniform mat3 ffp_normal_matrix;\n");
shader_addline(buffer, "\nvoid main()\n{\n");
shader_addline(buffer, "float m;\n");
@@ -5012,9 +5102,9 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct wined3d_shader_buffe
if (!settings->normal)
shader_addline(buffer, "vec3 normal = vec3(0.0);\n");
else if (settings->normalize)
- shader_addline(buffer, "vec3 normal = normalize(gl_NormalMatrix * gl_Normal);\n");
+ shader_addline(buffer, "vec3 normal = normalize(ffp_normal_matrix * gl_Normal);\n");
else
- shader_addline(buffer, "vec3 normal = gl_NormalMatrix * gl_Normal;\n");
+ shader_addline(buffer, "vec3 normal = ffp_normal_matrix * gl_Normal;\n");
shader_glsl_ffp_vertex_lighting(buffer, settings, gl_info);
@@ -5771,6 +5861,7 @@ static void shader_glsl_init_vs_uniform_locations(const struct wined3d_gl_info *
vs->pos_fixup_location = GL_EXTCALL(glGetUniformLocation(program_id, "posFixup"));
vs->modelview_matrix_location = GL_EXTCALL(glGetUniformLocation(program_id, "ffp_modelview_matrix"));
+ vs->normal_matrix_location = GL_EXTCALL(glGetUniformLocation(program_id, "ffp_normal_matrix"));
}
static void shader_glsl_init_ps_uniform_locations(const struct wined3d_gl_info *gl_info,
--
2.3.2

View File

@ -0,0 +1 @@
Fixes: [38256] Fix regression causing too dark/missing textures in several games