H. Verbeet : wined3d: Map vertex sampler numbers to the correct internal array indices for GetTexture and SetTexture .

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jun 26 07:11:56 CDT 2007


Module: wine
Branch: master
Commit: 3220ba45e83d460337252079e3a77ecae0432ba0
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3220ba45e83d460337252079e3a77ecae0432ba0

Author: H. Verbeet <hverbeet at gmail.com>
Date:   Mon Jun 25 22:46:01 2007 +0200

wined3d: Map vertex sampler numbers to the correct internal array indices for GetTexture and SetTexture.

---

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

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 2fafca3..8f2905f 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4037,19 +4037,16 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetTextureStageState(IWineD3DDevice *if
  * Get / Set Texture
  *****/
 static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface, DWORD Stage, IWineD3DBaseTexture* pTexture) {
-
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    IWineD3DBaseTexture   *oldTexture;
+    IWineD3DBaseTexture *oldTexture;
 
-    oldTexture = This->updateStateBlock->textures[Stage];
-    TRACE("(%p) : Stage(%d), Texture (%p)\n", This, Stage, pTexture);
+    TRACE("(%p) : Stage %#x, Texture %p\n", This, Stage, pTexture);
 
-#if 0 /* TODO: check so vertex textures */
-    if (Stage >= D3DVERTEXTEXTURESAMPLER && Stage <= D3DVERTEXTEXTURESAMPLER3){
-        This->updateStateBlock->vertexTextures[Stage - D3DVERTEXTEXTURESAMPLER] = pTexture;
-        return WINED3D_OK;
+    if (Stage >= WINED3DVERTEXTEXTURESAMPLER0 && Stage <= WINED3DVERTEXTEXTURESAMPLER3) {
+        Stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
     }
-#endif
+
+    oldTexture = This->updateStateBlock->textures[Stage];
 
     if(pTexture != NULL) {
         /* SetTexture isn't allowed on textures in WINED3DPOOL_SCRATCH; 
@@ -4119,7 +4116,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface, DWORD
              * Shouldn't happen as long as apps bind a texture only to one stage
              */
             TRACE("Searcing for other sampler / stage id where the texture is bound to\n");
-            for(i = 0; i < GL_LIMITS(sampler_stages); i++) {
+            for(i = 0; i < MAX_COMBINED_SAMPLERS; i++) {
                 if(This->updateStateBlock->textures[i] == oldTexture) {
                     old->baseTexture.sampler = i;
                     break;
@@ -4135,12 +4132,19 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface, DWORD
 
 static HRESULT WINAPI IWineD3DDeviceImpl_GetTexture(IWineD3DDevice *iface, DWORD Stage, IWineD3DBaseTexture** ppTexture) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    TRACE("(%p) : (%d /* Stage */,%p /* ppTexture */)\n", This, Stage, ppTexture);
+
+    TRACE("(%p) : Stage %#x, ppTexture %p\n", This, Stage, ppTexture);
+
+    if (Stage >= WINED3DVERTEXTEXTURESAMPLER0 && Stage <= WINED3DVERTEXTEXTURESAMPLER3) {
+        Stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
+    }
 
     *ppTexture=This->stateBlock->textures[Stage];
     if (*ppTexture)
         IWineD3DBaseTexture_AddRef(*ppTexture);
 
+    TRACE("(%p) : Returning %p\n", This, *ppTexture);
+
     return WINED3D_OK;
 }
 




More information about the wine-cvs mailing list