wined3d: Fix the texture unit map

H. Verbeet hverbeet at gmail.com
Mon Dec 25 16:02:41 CST 2006


The code that maps texture stages to texture units currently skips
non-NULL textures instead of NULL textures. This patch fixes that and
assignes -1 to stages that are skipped, so that we can be sure that
when something is assigned to that stage at a later time the
corresponding state will be marked dirty. Also downgrade the FIXME to
a WARN (requested by Stefan). Although this patch doesn't directly
depend on the 2 patches I sent earlier today, it should probably be
applied after them, or the offsets will be slightly off. This patch
fixes a regression in U2:XMP.

Changelog:
  - Skip NULL textures rather than non-NULL ones, assign -1 to skipped stages
  - Downgrade a FIXME to a WARN
-------------- next part --------------
---

 dlls/wined3d/device.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 3ff851a..0cbfe57 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3735,15 +3735,26 @@ static void IWineD3DDeviceImpl_FindTexUn
         /* Now work out the mapping */
         tex = 0;
         This->oneToOneTexUnitMap = FALSE;
-        FIXME("Non 1:1 mapping UNTESTED!\n");
+        WARN("Non 1:1 mapping UNTESTED!\n");
         for(i = 0; i < This->stateBlock->lowest_disabled_stage; i++) {
-            if(This->stateBlock->textures[i] == NULL) tex++;
+            /* Skip NULL textures */
+            if (!This->stateBlock->textures[i]) {
+                /* Map to -1, so the check below doesn't fail if a non-NULL
+                 * texture is set on this stage */
+                TRACE("Mapping texture stage %d to -1\n", i);
+                This->texUnitMap[i] = -1;
+
+                continue;
+            }
+
             TRACE("Mapping texture stage %d to unit %d\n", i, tex);
             if(This->texUnitMap[i] != tex) {
                 This->texUnitMap[i] = tex;
                 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i));
                 markTextureStagesDirty(This, i);
             }
+
+            ++tex;
         }
     }
 }


More information about the wine-patches mailing list