[10/10] DDraw: Forward D3DRS_TEXTUREADDRESS* and D3DTSS_ADDRESS* to sampler states

Stefan Dösinger stefan at codeweavers.com
Wed Feb 14 20:05:06 CST 2007


-------------- next part --------------
From a84fb5ca7ecc4b4a76a47bbb8ac88ba5d530fba5 Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Sat, 10 Feb 2007 17:48:54 +0100
Subject: [PATCH] DDraw: Forward D3DRS_TEXTUREADDRESS* and D3DTSS_ADDRESS* to sampler states

D3DRENDERSTATE_TEXTUREADDRESSU and V should be forwarded to WINED3DSAMP_ADDRESSU/V, the same for D3DTEXTURESTAGESTATE_ADDRESSU/V.
The ADDRESS state without the U / V is a bit tricky though. The msdn says it sets both U and V. In theory those states should be
versioned, an application shouldn't be able to access all states at the same time, but I do not see any point in implementing a
version check until we find an app that needs it
---
 dlls/ddraw/device.c |   94 ++++++++++++++++++++++++++++++++------------------
 1 files changed, 60 insertions(+), 34 deletions(-)

diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 12455fd..d4a64cc 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -2199,23 +2199,26 @@ IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
         case D3DRENDERSTATE_TEXTUREADDRESSV:
         case D3DRENDERSTATE_TEXTUREADDRESS:
         {
-            WINED3DTEXTURESTAGESTATETYPE TexStageStateType;
+            WINED3DSAMPLERSTATETYPE SampType;
 
             if (RenderStateType == D3DRENDERSTATE_TEXTUREADDRESS)
             {
-                TexStageStateType = WINED3DTSS_ADDRESS;
+                /* In theory these values should be versioned so an app can never use ADDRESS
+                 * and ADDRESSU/ADDRESSV at the same time
+                 */
+                SampType = WINED3DSAMP_ADDRESSU;
             }
             else if (RenderStateType == D3DRENDERSTATE_TEXTUREADDRESSU)
             {
-                TexStageStateType = WINED3DTSS_ADDRESSU;
+                SampType = WINED3DSAMP_ADDRESSU;
             }
             else
             {
-                TexStageStateType = WINED3DTSS_ADDRESSV;
+                SampType = WINED3DSAMP_ADDRESSV;
             }
-            return IWineD3DDevice_GetTextureStageState(This->wineD3DDevice,
-                                                       0, TexStageStateType,
-                                                       Value);
+            return IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
+                                                  0, SampType,
+                                                  Value);
         }
 
         default:
@@ -2348,29 +2351,19 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
                                                   tex_min);
         }
 
+        case D3DRENDERSTATE_TEXTUREADDRESS:
+                   IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
+                                                  0, WINED3DSAMP_ADDRESSV,
+                                                  Value);
+            /* Drop through */
         case D3DRENDERSTATE_TEXTUREADDRESSU:
+            return IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
+                                                  0, WINED3DSAMP_ADDRESSU,
+                                                  Value);
         case D3DRENDERSTATE_TEXTUREADDRESSV:
-        case D3DRENDERSTATE_TEXTUREADDRESS:
-        {
-            WINED3DTEXTURESTAGESTATETYPE TexStageStateType;
-
-            if (RenderStateType == D3DRENDERSTATE_TEXTUREADDRESS)
-            {
-                TexStageStateType = WINED3DTSS_ADDRESS;
-            }
-            else if (RenderStateType == D3DRENDERSTATE_TEXTUREADDRESSU)
-            {
-                TexStageStateType = WINED3DTSS_ADDRESSU;
-            }
-            else
-            {
-                TexStageStateType = WINED3DTSS_ADDRESSV;
-            }
-
-            return IWineD3DDevice_SetTextureStageState(This->wineD3DDevice,
-                                                       0, TexStageStateType,
-                                                       Value);
-        }
+            return IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
+                                                  0, WINED3DSAMP_ADDRESSV,
+                                                  Value);
 
         case D3DRENDERSTATE_TEXTUREMAPBLEND:
         {
@@ -4020,11 +4013,28 @@ IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7 *iface,
                                                   Stage,
                                                   WINED3DSAMP_MAGFILTER,
                                                   State);
+
+        case D3DTSS_ADDRESSU:
+            return IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
+                                                  Stage,
+                                                  WINED3DSAMP_ADDRESSU,
+                                                  State);
+        case D3DTSS_ADDRESSV:
+            return IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
+                                                  Stage,
+                                                  WINED3DSAMP_ADDRESSV,
+                                                  State);
+        case D3DTSS_ADDRESS:
+            return IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
+                                                  Stage,
+                                                  WINED3DSAMP_ADDRESSW,
+                                                  State);
+
         default:
             return IWineD3DDevice_GetTextureStageState(This->wineD3DDevice,
-                                                    Stage,
-                                                    TexStageStateType,
-                                                    State);
+                                                       Stage,
+                                                       TexStageStateType,
+                                                       State);
     }
 }
 
@@ -4103,12 +4113,28 @@ IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7 *iface,
                                                   WINED3DSAMP_MAGFILTER,
                                                   State);
 
+        case D3DTSS_ADDRESS:
+                   IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
+                                                  Stage,
+                                                  WINED3DSAMP_ADDRESSV,
+                                                  State);
+            /* Drop through */
+        case D3DTSS_ADDRESSU:
+            return IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
+                                                  Stage,
+                                                  WINED3DSAMP_ADDRESSU,
+                                                  State);
+        case D3DTSS_ADDRESSV:
+            return IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
+                                                  Stage,
+                                                  WINED3DSAMP_ADDRESSV,
+                                                  State);
         default:
 
             return IWineD3DDevice_SetTextureStageState(This->wineD3DDevice,
-                                                      Stage,
-                                                      TexStageStateType,
-                                                      State);
+                                                       Stage,
+                                                       TexStageStateType,
+                                                       State);
     }
 }
 
-- 
1.4.4.3



More information about the wine-patches mailing list