[PATCH 4/5] wined3d: Either set SM3 for both vertex and fragment shaders or for neither.

Henri Verbeet hverbeet at codeweavers.com
Mon Apr 25 15:54:14 CDT 2011


---
 dlls/wined3d/glsl_shader.c |   56 +++++++++++++++++++------------------------
 1 files changed, 25 insertions(+), 31 deletions(-)

diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 0fb0596..ba5a159 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -4924,39 +4924,29 @@ static BOOL shader_glsl_dirty_const(void)
 
 static void shader_glsl_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps)
 {
-    /* Nvidia Geforce6/7 or Ati R4xx/R5xx cards with GLSL support, support VS 3.0 but older Nvidia/Ati
-     * models with GLSL support only support 2.0. In case of nvidia we can detect VS 2.0 support based
-     * on the version of NV_vertex_program.
-     * For Ati cards there's no way using glsl (it abstracts the lowlevel info away) and also not
-     * using ARB_vertex_program. It is safe to assume that when a card supports pixel shader 2.0 it
-     * supports vertex shader 2.0 too and the way around. We can detect ps2.0 using the maximum number
-     * of native instructions, so use that here. For more info see the pixel shader versioning code below.
-     */
-    if ((gl_info->supported[NV_VERTEX_PROGRAM2] && !gl_info->supported[NV_VERTEX_PROGRAM3])
-            || gl_info->limits.arb_ps_instructions <= 512)
-        pCaps->VertexShaderVersion = WINED3DVS_VERSION(2,0);
-    else
+    /* NVIDIA GeForce 6 / 7 or ATI R4xx / R5xx cards with GLSL support
+     * support SM3, but older NVIDIA / ATI models with GLSL support only
+     * support SM2. In case of NVIDIA we can detect SM3 support based on the
+     * version of NV_vertex_program / NV_fragment_program. For other cards we
+     * try to detect SM3 based on the maximum number of native fragment
+     * program instructions. PS2.0 requires at least 96 instructions, 2.0a/b
+     * goes up to 512. Assume that if the number of instructions is 512 or
+     * less we have to do with SM2 hardware. NOTE: SM3 requires 512 or more
+     * instructions but ATI and NVIDIA offer more than that (1024 vs 4096) on
+     * their most basic SM3 hardware. */
+    if ((gl_info->supported[NV_VERTEX_PROGRAM3] && gl_info->supported[NV_FRAGMENT_PROGRAM2])
+            || gl_info->limits.arb_ps_instructions > 512)
+    {
         pCaps->VertexShaderVersion = WINED3DVS_VERSION(3,0);
-    TRACE_(d3d_caps)("Hardware vertex shader version %d.%d enabled (GLSL)\n", (pCaps->VertexShaderVersion >> 8) & 0xff, pCaps->VertexShaderVersion & 0xff);
-    pCaps->MaxVertexShaderConst = gl_info->limits.glsl_vs_float_constants;
-
-    /* Older DX9-class videocards (GeforceFX / Radeon >9500/X*00) only support pixel shader 2.0/2.0a/2.0b.
-     * In OpenGL the extensions related to GLSL abstract lowlevel GL info away which is needed
-     * to distinguish between 2.0 and 3.0 (and 2.0a/2.0b). In case of Nvidia we use their fragment
-     * program extensions. On other hardware including ATI GL_ARB_fragment_program offers the info
-     * in max native instructions. Intel and others also offer the info in this extension but they
-     * don't support GLSL (at least on Windows).
-     *
-     * PS2.0 requires at least 96 instructions, 2.0a/2.0b go up to 512. Assume that if the number
-     * of instructions is 512 or less we have to do with ps2.0 hardware.
-     * NOTE: ps3.0 hardware requires 512 or more instructions but ati and nvidia offer 'enough' (1024 vs 4096) on their most basic ps3.0 hardware.
-     */
-    if ((gl_info->supported[NV_FRAGMENT_PROGRAM] && !gl_info->supported[NV_FRAGMENT_PROGRAM2])
-            || gl_info->limits.arb_ps_instructions <= 512)
-        pCaps->PixelShaderVersion = WINED3DPS_VERSION(2,0);
-    else
         pCaps->PixelShaderVersion = WINED3DPS_VERSION(3,0);
+    }
+    else
+    {
+        pCaps->VertexShaderVersion = WINED3DVS_VERSION(2,0);
+        pCaps->PixelShaderVersion = WINED3DPS_VERSION(2,0);
+    }
 
+    pCaps->MaxVertexShaderConst = gl_info->limits.glsl_vs_float_constants;
     pCaps->MaxPixelShaderConst = gl_info->limits.glsl_ps_float_constants;
 
     /* FIXME: The following line is card dependent. -8.0 to 8.0 is the
@@ -4972,9 +4962,13 @@ static void shader_glsl_get_caps(const struct wined3d_gl_info *gl_info, struct s
      * offer a way to query this.
      */
     pCaps->PixelShader1xMaxValue = 8.0;
-    TRACE_(d3d_caps)("Hardware pixel shader version %d.%d enabled (GLSL)\n", (pCaps->PixelShaderVersion >> 8) & 0xff, pCaps->PixelShaderVersion & 0xff);
 
     pCaps->VSClipping = TRUE;
+
+    TRACE_(d3d_caps)("Hardware vertex shader version %u.%u enabled (GLSL).\n",
+            (pCaps->VertexShaderVersion >> 8) & 0xff, pCaps->VertexShaderVersion & 0xff);
+    TRACE_(d3d_caps)("Hardware pixel shader version %u.%u enabled (GLSL).\n",
+            (pCaps->PixelShaderVersion >> 8) & 0xff, pCaps->PixelShaderVersion & 0xff);
 }
 
 static BOOL shader_glsl_color_fixup_supported(struct color_fixup_desc fixup)
-- 
1.7.3.4




More information about the wine-patches mailing list