Commit 7f741f04 authored by H. Verbeet's avatar H. Verbeet Committed by Alexandre Julliard

wined3d: Use rev_tex_unit_map instead of assuming there's a 1:1 mapping between…

wined3d: Use rev_tex_unit_map instead of assuming there's a 1:1 mapping between samplers and texture units.
parent be405c71
...@@ -640,7 +640,7 @@ static inline void set_blit_dimension(UINT width, UINT height) { ...@@ -640,7 +640,7 @@ static inline void set_blit_dimension(UINT width, UINT height) {
* *
*****************************************************************************/ *****************************************************************************/
static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *context, UINT width, UINT height) { static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *context, UINT width, UINT height) {
int i; int i, sampler;
const struct StateEntry *StateTable = This->StateTable; const struct StateEntry *StateTable = This->StateTable;
TRACE("Setting up context %p for blitting\n", context); TRACE("Setting up context %p for blitting\n", context);
...@@ -677,6 +677,7 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex ...@@ -677,6 +677,7 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex
* function texture unit. No need to care for higher samplers * function texture unit. No need to care for higher samplers
*/ */
for(i = GL_LIMITS(textures) - 1; i > 0 ; i--) { for(i = GL_LIMITS(textures) - 1; i > 0 ; i--) {
sampler = This->rev_tex_unit_map[i];
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i)); GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
checkGLcall("glActiveTextureARB"); checkGLcall("glActiveTextureARB");
...@@ -692,12 +693,19 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex ...@@ -692,12 +693,19 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);"); checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);");
Context_MarkStateDirty(context, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP), StateTable); if (sampler != -1) {
Context_MarkStateDirty(context, STATE_SAMPLER(i), StateTable); if (sampler < MAX_TEXTURES) {
Context_MarkStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP), StateTable);
}
Context_MarkStateDirty(context, STATE_SAMPLER(sampler), StateTable);
}
} }
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB)); GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
checkGLcall("glActiveTextureARB"); checkGLcall("glActiveTextureARB");
} }
sampler = This->rev_tex_unit_map[0];
if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) { if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) {
glDisable(GL_TEXTURE_CUBE_MAP_ARB); glDisable(GL_TEXTURE_CUBE_MAP_ARB);
checkGLcall("glDisable GL_TEXTURE_CUBE_MAP_ARB"); checkGLcall("glDisable GL_TEXTURE_CUBE_MAP_ARB");
...@@ -713,7 +721,6 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex ...@@ -713,7 +721,6 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex
checkGLcall("glMatrixMode(GL_TEXTURE)"); checkGLcall("glMatrixMode(GL_TEXTURE)");
glLoadIdentity(); glLoadIdentity();
checkGLcall("glLoadIdentity()"); checkGLcall("glLoadIdentity()");
Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_TEXTURE0), StateTable);
if (GL_SUPPORT(EXT_TEXTURE_LOD_BIAS)) { if (GL_SUPPORT(EXT_TEXTURE_LOD_BIAS)) {
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
...@@ -721,8 +728,14 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex ...@@ -721,8 +728,14 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex
0.0); 0.0);
checkGLcall("glTexEnvi GL_TEXTURE_LOD_BIAS_EXT ..."); checkGLcall("glTexEnvi GL_TEXTURE_LOD_BIAS_EXT ...");
} }
Context_MarkStateDirty(context, STATE_SAMPLER(0), StateTable);
Context_MarkStateDirty(context, STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), StateTable); if (sampler != -1) {
if (sampler < MAX_TEXTURES) {
Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_TEXTURE0 + sampler), StateTable);
Context_MarkStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP), StateTable);
}
Context_MarkStateDirty(context, STATE_SAMPLER(sampler), StateTable);
}
/* Other misc states */ /* Other misc states */
glDisable(GL_ALPHA_TEST); glDisable(GL_ALPHA_TEST);
......
...@@ -5752,6 +5752,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface, ...@@ -5752,6 +5752,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
int rowoffset = 0; /* how many bytes to add onto the end of a row to wraparound to the beginning of the next */ int rowoffset = 0; /* how many bytes to add onto the end of a row to wraparound to the beginning of the next */
glDescriptor *glDescription = NULL; glDescriptor *glDescription = NULL;
GLenum dummy; GLenum dummy;
int sampler;
int bpp; int bpp;
CONVERT_TYPES convert = NO_CONVERSION; CONVERT_TYPES convert = NO_CONVERSION;
...@@ -5922,7 +5923,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface, ...@@ -5922,7 +5923,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
LEAVE_GL(); LEAVE_GL();
IWineD3DSurface_ModifyLocation(pDestinationSurface, SFLAG_INTEXTURE, TRUE); IWineD3DSurface_ModifyLocation(pDestinationSurface, SFLAG_INTEXTURE, TRUE);
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(0)); sampler = This->rev_tex_unit_map[0];
if (sampler != -1) {
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(sampler));
}
return WINED3D_OK; return WINED3D_OK;
} }
...@@ -6854,7 +6858,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice* i ...@@ -6854,7 +6858,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice* i
INT height = This->cursorHeight; INT height = This->cursorHeight;
INT width = This->cursorWidth; INT width = This->cursorWidth;
INT bpp = tableEntry->bpp; INT bpp = tableEntry->bpp;
INT i; INT i, sampler;
/* Reformat the texture memory (pitch and width can be /* Reformat the texture memory (pitch and width can be
* different) */ * different) */
...@@ -6874,7 +6878,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice* i ...@@ -6874,7 +6878,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice* i
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB)); GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
checkGLcall("glActiveTextureARB"); checkGLcall("glActiveTextureARB");
} }
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(0)); sampler = This->rev_tex_unit_map[0];
if (sampler != -1) {
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(sampler));
}
/* Create a new cursor texture */ /* Create a new cursor texture */
glGenTextures(1, &This->cursorTexture); glGenTextures(1, &This->cursorTexture);
checkGLcall("glGenTextures"); checkGLcall("glGenTextures");
......
...@@ -40,7 +40,7 @@ static inline void clear_unused_channels(IWineD3DSurfaceImpl *This); ...@@ -40,7 +40,7 @@ static inline void clear_unused_channels(IWineD3DSurfaceImpl *This);
static void surface_remove_pbo(IWineD3DSurfaceImpl *This); static void surface_remove_pbo(IWineD3DSurfaceImpl *This);
static void surface_bind_and_dirtify(IWineD3DSurfaceImpl *This) { static void surface_bind_and_dirtify(IWineD3DSurfaceImpl *This) {
GLint active_texture; int active_sampler;
/* We don't need a specific texture unit, but after binding the texture the current unit is dirty. /* We don't need a specific texture unit, but after binding the texture the current unit is dirty.
* Read the unit back instead of switching to 0, this avoids messing around with the state manager's * Read the unit back instead of switching to 0, this avoids messing around with the state manager's
...@@ -49,14 +49,18 @@ static void surface_bind_and_dirtify(IWineD3DSurfaceImpl *This) { ...@@ -49,14 +49,18 @@ static void surface_bind_and_dirtify(IWineD3DSurfaceImpl *This) {
* TODO: Track the current active texture per GL context instead of using glGet * TODO: Track the current active texture per GL context instead of using glGet
*/ */
if (GL_SUPPORT(ARB_MULTITEXTURE)) { if (GL_SUPPORT(ARB_MULTITEXTURE)) {
GLint active_texture;
ENTER_GL(); ENTER_GL();
glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
LEAVE_GL(); LEAVE_GL();
active_texture -= GL_TEXTURE0_ARB; active_sampler = This->resource.wineD3DDevice->rev_tex_unit_map[active_texture - GL_TEXTURE0_ARB];
} else { } else {
active_texture = 0; active_sampler = 0;
}
if (active_sampler != -1) {
IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(active_sampler));
} }
IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(active_texture));
IWineD3DSurface_BindTexture((IWineD3DSurface *)This); IWineD3DSurface_BindTexture((IWineD3DSurface *)This);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment