H. Verbeet : wined3d: Fix uploading of textures for shaders.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jun 28 10:38:53 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: ac98d566acc20b0334d3deacd7c95869336f4d53
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=ac98d566acc20b0334d3deacd7c95869336f4d53

Author: H. Verbeet <hverbeet at gmail.com>
Date:   Tue Jun 27 23:41:27 2006 +0200

wined3d: Fix uploading of textures for shaders.

The code for uploading / binding textures for use with pixel shaders
is slightly different from the one for uploading / binding textures
for use with the fixed function pipeline. It would be possible to keep
the code in a single function with a couple of conditionals, but in
combination with the changes needed for register combiners that would
become quite messy.

---

 dlls/wined3d/drawprim.c |   47 +++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index 675813f..157ec0f 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -2076,6 +2076,46 @@ void inline drawPrimitiveTraceDataLocati
 
 }
 
+static void drawPrimitiveUploadTexturesPS(IWineD3DDeviceImpl* This) {
+    INT i;
+
+    for (i = 0; i < GL_LIMITS(samplers); ++i) {
+        /* Pixel shader support should imply multitexture support. */
+        if (GL_SUPPORT(ARB_MULTITEXTURE)) {
+            GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
+            checkGLcall("glActiveTextureARB");
+        } else if (i) {
+            WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
+        }
+
+        if (!This->stateBlock->textures[i]) continue;
+
+        /* Enable the correct target. Is this required for GLSL? For ARB_fragment_program it isn't, afaik. */
+        glDisable(GL_TEXTURE_1D);
+        This->stateBlock->textureDimensions[i] = IWineD3DBaseTexture_GetTextureDimensions(This->stateBlock->textures[i]);
+        switch(This->stateBlock->textureDimensions[i]) {
+            case GL_TEXTURE_2D:
+                glDisable(GL_TEXTURE_3D);
+                glDisable(GL_TEXTURE_CUBE_MAP_ARB);
+                break;
+            case GL_TEXTURE_3D:
+                glDisable(GL_TEXTURE_CUBE_MAP_ARB);
+                glDisable(GL_TEXTURE_2D);
+                break;
+            case GLTEXTURECUBEMAP:
+                glDisable(GL_TEXTURE_2D);
+                glDisable(GL_TEXTURE_3D);
+                break;
+        }
+        glEnable(This->stateBlock->textureDimensions[i]);
+
+        /* Upload texture, apply states */
+        IWineD3DBaseTexture_PreLoad((IWineD3DBaseTexture *) This->stateBlock->textures[i]);
+        IWineD3DDevice_SetupTextureStates((IWineD3DDevice *)This, i, REAPPLY_ALPHAOP);
+        IWineD3DBaseTexture_ApplyStateChanges(This->stateBlock->textures[i], This->stateBlock->textureState[i], This->stateBlock->samplerState[i]);
+    }
+}
+
 /* uploads textures and setup texture states ready for rendering */
 void inline drawPrimitiveUploadTextures(IWineD3DDeviceImpl* This) {
 
@@ -2282,8 +2322,11 @@ void drawPrimitive(IWineD3DDevice *iface
     /* Now initialize the materials state */
     init_materials(iface, (dataLocations->u.s.diffuse.lpData != NULL || dataLocations->u.s.diffuse.VBO != 0));
 
-    drawPrimitiveUploadTextures(This);
-
+    if (usePixelShaderFunction) {
+        drawPrimitiveUploadTexturesPS(This);
+    } else {
+        drawPrimitiveUploadTextures(This);
+    }
 
     {
         GLenum glPrimType;




More information about the wine-cvs mailing list