[5/5] wined3d: Split of the mapping of pixel shader samplers from IWineD3DDeviceImpl_FindTexUnitMap()

H. Verbeet hverbeet at gmail.com
Fri Jun 22 13:43:42 CDT 2007


Similar to patch 3 in this set, with the difference that this also
removes the checking and setting of This->oneToOneTexUnitMap, since I
doubt it makes much of a difference and removing it makes mapping
vertex samplers slightly more convenient. It can still be added back
at a later point, should it turn out to be necessary.

Changelog:
  - Split of the mapping of pixel shader samplers from
IWineD3DDeviceImpl_FindTexUnitMap()
-------------- next part --------------
---

 dlls/wined3d/device.c |   38 +++++++++++++++++---------------------
 1 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index c81b5b8..5106b6d 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3296,8 +3296,22 @@ static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This) {
     }
 }
 
+static void device_map_psamplers(IWineD3DDeviceImpl *This) {
+    int i;
+
+    for (i = 0; i < MAX_SAMPLERS; ++i) {
+        if (This->texUnitMap[i] != i) {
+            device_map_stage(This, i, i);
+            IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i));
+            if (i < MAX_TEXTURES) {
+                markTextureStagesDirty(This, i);
+            }
+        }
+    }
+}
+
 void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) {
-    DWORD i;
+    BOOL ps = use_ps(This);
     /* This code can assume that GL_NV_register_combiners are supported, otherwise
      * it is never called.
      *
@@ -3306,27 +3320,9 @@ void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) {
      * that would be really messy and require shader recompilation
      * -> When the mapping of a stage is changed, sampler and ALL texture stage states have
      * to be reset. Because of that try to work with a 1:1 mapping as much as possible
-     * -> Whith a 1:1 mapping oneToOneTexUnitMap is set to avoid checking MAX_SAMPLERS array
-     * entries to make pixel shaders cheaper. MAX_SAMPLERS will be 128 in dx10
      */
-    if (This->stateBlock->pixelShader) {
-        if(This->oneToOneTexUnitMap) {
-            TRACE("Not touching 1:1 map\n");
-            return;
-        }
-        TRACE("Restoring 1:1 texture unit mapping\n");
-        /* Restore a 1:1 mapping */
-        for(i = 0; i < MAX_SAMPLERS; i++) {
-            if(This->texUnitMap[i] != i) {
-                device_map_stage(This, i, i);
-                IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i));
-                if (i < MAX_TEXTURES) {
-                    markTextureStagesDirty(This, i);
-                }
-            }
-        }
-        This->oneToOneTexUnitMap = TRUE;
-        return;
+    if (ps) {
+        device_map_psamplers(This);
     } else {
         device_map_fixed_function_samplers(This);
     }


More information about the wine-patches mailing list