[1/3] wined3d: Cleanup device_map_fixed_function_samplers()

H. Verbeet hverbeet at gmail.com
Thu Jun 28 16:32:38 CDT 2007


We should only touch the mapping for stages that are actually used.
Also gets rid of the piece of code that returns if we haven't got
enough texture units available, since returning isn't really better
than simply trying to map whatever we've got. And since we now check
if a texture set on a particular stage is actually used, it's also
less likely to happen in the first place.

Changelog:
  - Cleanup device_map_fixed_function_samplers()
-------------- next part --------------
---

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

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 55b161d..5d3a7ce 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3263,47 +3263,23 @@ static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This) {
     device_update_fixed_function_usage_map(This);
 
     if (This->stateBlock->lowest_disabled_stage <= GL_LIMITS(textures)) {
-        for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i) {
+        for (i = 0; i < This->stateBlock->lowest_disabled_stage; ++i) {
+            if (!This->fixed_function_usage_map[i]) continue;
+
             if (This->texUnitMap[i] != i) {
                 device_map_stage(This, i, i);
                 IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i));
-                if (i < MAX_TEXTURES) {
-                    markTextureStagesDirty(This, i);
-                }
+                markTextureStagesDirty(This, i);
             }
         }
         return;
     }
 
-    /* No pixel shader, and we do not have enough texture units available. Try to skip NULL textures
-     * First, see if we can succeed at all
-     */
-    tex = 0;
-    for (i = 0; i < This->stateBlock->lowest_disabled_stage; ++i) {
-        if (!This->fixed_function_usage_map[i]) ++tex;
-    }
-
-    if (GL_LIMITS(textures) + tex < This->stateBlock->lowest_disabled_stage) {
-        FIXME("Too many bound textures to support the combiner settings\n");
-        return;
-    }
-
     /* Now work out the mapping */
     tex = 0;
-    This->oneToOneTexUnitMap = FALSE;
-    WARN("Non 1:1 mapping UNTESTED!\n");
     for (i = 0; i < This->stateBlock->lowest_disabled_stage; ++i) {
-        /* Skip NULL textures */
-        if (!This->fixed_function_usage_map[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);
-            device_map_stage(This, i, -1);
-
-            continue;
-        }
+        if (!This->fixed_function_usage_map[i]) continue;
 
-        TRACE("Mapping texture stage %d to unit %d\n", i, tex);
         if (This->texUnitMap[i] != tex) {
             device_map_stage(This, i, tex);
             IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i));


More information about the wine-patches mailing list