[20/20] WineD3D: Fix np2 textures
Stefan Dösinger
stefan at codeweavers.com
Sat Jan 6 11:43:08 CST 2007
The code in the sampler state handling them right now is just broken. It uses
a == NP2_NATIVE comparison instead of !=, and does not take care for
switching out of np2 mode.
-------------- next part --------------
From 9eb083ebbead94343447a3f5a7ce263754399bab Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Sat, 6 Jan 2007 18:04:45 +0100
Subject: [PATCH] WineD3D: Fix np2 textures
---
dlls/wined3d/state.c | 27 +++++++++++++++++++++------
dlls/wined3d/wined3d_private.h | 1 +
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index e2ed6ce..af899e5 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -1752,13 +1752,28 @@ static void sampler(DWORD state, IWineD3
}
if(stateblock->textures[sampler]) {
+ BOOL texIsPow2 = FALSE;
- /* NP2 textures need the texture matrix set properly for the stage */
- if(wined3d_settings.nonpower2_mode == NP2_NATIVE && sampler < MAX_TEXTURES - 1 &&
- stateblock->textureDimensions[sampler] == GL_TEXTURE_2D &&
- (((IWineD3DTextureImpl *) stateblock->textures[sampler])->pow2scalingFactorX != 1.0 ||
- ((IWineD3DTextureImpl *) stateblock->textures[sampler])->pow2scalingFactorY != 1.0 ) ) {
- transform_texture(STATE_TRANSFORM(WINED3DTS_TEXTURE0 + stateblock->wineD3DDevice->texUnitMap[sampler]), stateblock);
+ /* The fixed function np2 texture emulation uses the texture matrix to fix up the coordinates
+ * IWineD3DBaseTexture::ApplyStateChanges multiplies the set matrix with a fixup matrix. Before the
+ * scaling is reapplied or removed, the texture matrix has to be reapplied
+ */
+ if(wined3d_settings.nonpower2_mode != NP2_NATIVE && sampler < MAX_TEXTURES) {
+ if(stateblock->textureDimensions[sampler] == GL_TEXTURE_2D) {
+ if(((IWineD3DTextureImpl *) stateblock->textures[sampler])->pow2scalingFactorX != 1.0 ||
+ ((IWineD3DTextureImpl *) stateblock->textures[sampler])->pow2scalingFactorY != 1.0 ) {
+ texIsPow2 = TRUE;
+ }
+ } else if(stateblock->textureDimensions[sampler] == GL_TEXTURE_CUBE_MAP_ARB) {
+ if(((IWineD3DCubeTextureImpl *) stateblock->textures[sampler])->pow2scalingFactor != 1.0) {
+ texIsPow2 = TRUE;
+ }
+ }
+
+ if(texIsPow2 || stateblock->wineD3DDevice->lastWasPow2Texture[sampler]) {
+ transform_texture(STATE_TRANSFORM(WINED3DTS_TEXTURE0 + stateblock->wineD3DDevice->texUnitMap[sampler]), stateblock);
+ stateblock->wineD3DDevice->lastWasPow2Texture[sampler] = texIsPow2;
+ }
}
IWineD3DBaseTexture_PreLoad((IWineD3DBaseTexture *) stateblock->textures[sampler]);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index f50182a..c018c27 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -583,6 +583,7 @@ #define NEEDS_DI
BOOL last_was_vshader;
BOOL last_was_foggy_shader;
BOOL namedArraysLoaded, numberedArraysLoaded;
+ BOOL lastWasPow2Texture[MAX_TEXTURES];
/* State block related */
BOOL isRecordingState;
--
1.4.2.4
More information about the wine-patches
mailing list