[PATCH 2/2] wined3d: Reserve one vs constant on r200

Stefan Dösinger stefan at codeweavers.com
Fri Feb 8 16:19:47 CST 2013


See the comment added in directx.c for the reason why the constant is
needed. I do not see a way to fix this in the general case, but I don't
have the hardware docs, so I am open to suggestions.

Some optimizations are plausible, like cases where fog is off, or fog
with start and end params of 0.0 and 1.0 is used, or the d3d vertex
shader fog case with start and end params of 1.0 and 0.0. Those
optimizations would require ugly code in the driver and r200-specific
code in arb_program_shader.c to detect situations where the driver still
needs its private constant.
---
 dlls/wined3d/arb_program_shader.c |  1 +
 dlls/wined3d/directx.c            | 26 ++++++++++++++++++++++++++
 dlls/wined3d/wined3d_private.h    |  2 +-
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 2fd5108..e8da805 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -821,6 +821,7 @@ static DWORD shader_generate_arb_declarations(const struct wined3d_shader *shade
 
             max_constantsF -= reserved_vs_const(shader_data, reg_maps, gl_info);
             max_constantsF -= count_bits(reg_maps->integer_constants);
+            max_constantsF -= gl_info->reserved_arb_constants;
 
             for (i = 0; i < shader->limits.constant_float; ++i)
             {
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index f42299e..acdcc57 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -751,6 +751,14 @@ static BOOL match_fglrx(const struct wined3d_gl_info *gl_info, const char *gl_re
     return gl_vendor == GL_VENDOR_FGLRX;
 }
 
+static BOOL match_r200(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
+        enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
+{
+    if (card_vendor != HW_VENDOR_AMD) return FALSE;
+    if (device == CARD_AMD_RADEON_8500) return TRUE;
+    return FALSE;
+}
+
 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.
@@ -861,6 +869,19 @@ static void quirk_limited_tex_filtering(struct wined3d_gl_info *gl_info)
     gl_info->quirks |= WINED3D_QUIRK_LIMITED_TEX_FILTERING;
 }
 
+static void quirk_r200_constants(struct wined3d_gl_info *gl_info)
+{
+    /* The Mesa r200 driver (and there is no other driver for this GPU Wine would run on)
+     * loads some fog parameters (start, end, exponent, but not the color) into the
+     * program.
+     *
+     * Apparently the fog hardware is only able to handle linear fog with a range of 0.0;1.0,
+     * and it is the responsibility of the vertex pipeline to handle non-linear fog and
+     * linear fog with start and end other than 0.0 and 1.0. */
+    TRACE("Reserving 1 ARB constant for compiler private use.\n");
+    gl_info->reserved_arb_constants = max(gl_info->reserved_arb_constants, 1);
+}
+
 struct driver_quirk
 {
     BOOL (*match)(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
@@ -941,6 +962,11 @@ static const struct driver_quirk quirk_table[] =
         quirk_limited_tex_filtering,
         "Texture filtering, blending and VTF support is limited"
     },
+    {
+        match_r200,
+        quirk_r200_constants,
+        "r200 vertex shader constants"
+    },
 };
 
 /* Certain applications (Steam) complain if we report an outdated driver version. In general,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 0ce0c65..45f6b29 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1532,7 +1532,7 @@ struct wined3d_gl_info
 {
     DWORD glsl_version;
     struct wined3d_gl_limits limits;
-    DWORD reserved_glsl_constants;
+    DWORD reserved_glsl_constants, reserved_arb_constants;
     DWORD quirks;
     BOOL supported[WINED3D_GL_EXT_COUNT];
     GLint wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP + 1];
-- 
1.7.12.4




More information about the wine-patches mailing list