[4/5] wined3d: Load texture coordinates even if no texture is bound to that stage at this time

H. Verbeet hverbeet at gmail.com
Wed May 9 12:08:27 CDT 2007


Currently texture coordinates aren't loaded if the corresponding stage
doesn't have a texture assigned. If at a later time a texture is
assigned to that stage without causing a reload of the vertex data
before drawing, the texture coordinates for that stage are missing.
This fixes a (somewhat hard to spot) regression introduced by commit
d5f18e6a631159a655698765361e7d8e50c953a2.

Changelog:
  - Load texture coordinates even if no texture is bound to that stage
at this time
-------------- next part --------------
---

 dlls/wined3d/state.c |   63 +++++++++++++++++++++++---------------------------
 1 files changed, 29 insertions(+), 34 deletions(-)

diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index c0643a2..ba25501 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -1825,46 +1825,41 @@ static void loadTexCoords(IWineD3DStateBlockImpl *stateblock, WineDirect3DVertex
     unsigned int mapped_stage = 0;
     unsigned int textureNo = 0;
 
+    /* The code below uses glClientActiveTexture and glMultiTexCoord* which are all part of the GL_ARB_multitexture extension. */
+    /* Abort if we don't support the extension. */
+    if (!GL_SUPPORT(ARB_MULTITEXTURE)) {
+        FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
+        return;
+    }
+
     for (textureNo = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) {
-        /* The code below uses glClientActiveTexture and glMultiTexCoord* which are all part of the GL_ARB_multitexture extension. */
-        /* Abort if we don't support the extension. */
-        if (!GL_SUPPORT(ARB_MULTITEXTURE)) {
-            FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
-            continue;
-        }
+        int coordIdx = stateblock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
 
-        if (stateblock->textures[textureNo]) {
-            int coordIdx = stateblock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
+        mapped_stage = stateblock->wineD3DDevice->texUnitMap[textureNo];
+        if (mapped_stage == -1) continue;
+
+        if (coordIdx < MAX_TEXTURES && (sd->u.s.texCoords[coordIdx].lpData || sd->u.s.texCoords[coordIdx].VBO)) {
+            TRACE("Setting up texture %u, idx %d, cordindx %u, data %p\n",
+                    textureNo, mapped_stage, coordIdx, sd->u.s.texCoords[coordIdx].lpData);
+
+            if (*curVBO != sd->u.s.texCoords[coordIdx].VBO) {
+                GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.texCoords[coordIdx].VBO));
+                checkGLcall("glBindBufferARB");
+                *curVBO = sd->u.s.texCoords[coordIdx].VBO;
+            }
 
-            mapped_stage = stateblock->wineD3DDevice->texUnitMap[textureNo];
-            /* The gl texture unit will never be -1 for a bound texture */
             GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
             checkGLcall("glClientActiveTextureARB");
 
-            if (coordIdx >= MAX_TEXTURES) {
-                VTRACE(("tex: %d - Skip tex coords, as being system generated\n", textureNo));
-                GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + mapped_stage, 0, 0, 0, 1));
-            } else if (sd->u.s.texCoords[coordIdx].lpData == NULL && sd->u.s.texCoords[coordIdx].VBO == 0) {
-                VTRACE(("Bound texture but no texture coordinates supplied, so skipping\n"));
-                GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + mapped_stage, 0, 0, 0, 1));
-            } else {
-                TRACE("Setting up texture %u, idx %d, cordindx %u, data %p\n",
-                        textureNo, mapped_stage, coordIdx, sd->u.s.texCoords[coordIdx].lpData);
-                if (*curVBO != sd->u.s.texCoords[coordIdx].VBO) {
-                    GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.texCoords[coordIdx].VBO));
-                    checkGLcall("glBindBufferARB");
-                    *curVBO = sd->u.s.texCoords[coordIdx].VBO;
-                }
-                /* The coords to supply depend completely on the fvf / vertex shader */
-                glTexCoordPointer(
-                        WINED3D_ATR_SIZE(sd->u.s.texCoords[coordIdx].dwType),
-                        WINED3D_ATR_GLTYPE(sd->u.s.texCoords[coordIdx].dwType),
-                        sd->u.s.texCoords[coordIdx].dwStride,
-                        sd->u.s.texCoords[coordIdx].lpData + stateblock->loadBaseVertexIndex * sd->u.s.texCoords[coordIdx].dwStride + offset[sd->u.s.texCoords[coordIdx].streamNo]);
-                glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-            }
-        } else if (!GL_SUPPORT(NV_REGISTER_COMBINERS)) {
-            GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + textureNo, 0, 0, 0, 1));
+            /* The coords to supply depend completely on the fvf / vertex shader */
+            glTexCoordPointer(
+                    WINED3D_ATR_SIZE(sd->u.s.texCoords[coordIdx].dwType),
+                    WINED3D_ATR_GLTYPE(sd->u.s.texCoords[coordIdx].dwType),
+                    sd->u.s.texCoords[coordIdx].dwStride,
+                    sd->u.s.texCoords[coordIdx].lpData + stateblock->loadBaseVertexIndex * sd->u.s.texCoords[coordIdx].dwStride + offset[sd->u.s.texCoords[coordIdx].streamNo]);
+            glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+        } else {
+            GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + mapped_stage, 0, 0, 0, 1));
         }
     }
     if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {


More information about the wine-patches mailing list