Ivan Gyurdiev : wined3d: Only link and use GLSL program if at least one GLSL shader is available.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jul 7 11:10:20 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: fc2611d4a8deb200f1a986a60dca2af167803923
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=fc2611d4a8deb200f1a986a60dca2af167803923

Author: Ivan Gyurdiev <ivg231 at gmail.com>
Date:   Fri Jul  7 00:17:58 2006 -0600

wined3d: Only link and use GLSL program if at least one GLSL shader is available.

---

 dlls/wined3d/device.c   |    6 ------
 dlls/wined3d/drawprim.c |   15 ++++++++++-----
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 714bb1d..7176954 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -282,12 +282,6 @@ void set_glsl_shader_program(IWineD3DDev
     struct list *ptr                       = NULL;
     GLhandleARB programId                  = 0;
     
-    if (NULL == vshader && NULL == pshader) {
-        /* No pixel or vertex shader specified */
-        This->stateBlock->shaderPrgId = 0;
-        return;
-    }
-
     ptr = list_head( &This->glsl_shader_progs );
     while (ptr) {
         /* At least one program exists - see if it matches our ps/vs combination */
diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index 075fe9b..15d0d7d 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -1926,13 +1926,18 @@ #undef BUFFER_OR_DATA
         useDrawStridedSlow = TRUE;
     }
 
-    /* Bind the correct GLSL shader program based on the currently set vertex & pixel shaders. */
-    if (wined3d_settings.vs_selected_mode == SHADER_GLSL ||
+    /* If GLSL is used for either pixel or vertex shaders, make a GLSL program 
+     * Otherwise set 0, which restores fixed function */
+    if ((wined3d_settings.vs_selected_mode == SHADER_GLSL && useVertexShaderFunction) ||
+        (wined3d_settings.ps_selected_mode == SHADER_GLSL && usePixelShaderFunction)) 
+        set_glsl_shader_program(iface);
+    else
+        This->stateBlock->shaderPrgId = 0;
+
+    /* If GLSL is used now, or might have been used before, (re)set the program */
+    if (wined3d_settings.vs_selected_mode == SHADER_GLSL || 
         wined3d_settings.ps_selected_mode == SHADER_GLSL) {
 
-        set_glsl_shader_program(iface);
-        /* Start using this program ID (if it's 0, there is no shader program to use, so 
-         * glUseProgramObjectARB(0) will disable the use of any shaders) */
         if (This->stateBlock->shaderPrgId) 
             TRACE_(d3d_shader)("Using GLSL program %u\n", This->stateBlock->shaderPrgId);
         GL_EXTCALL(glUseProgramObjectARB(This->stateBlock->shaderPrgId));




More information about the wine-cvs mailing list