Henri Verbeet : wined3d: Use WINED3D_UNMAPPED_STAGE in some more places.
Alexandre Julliard
julliard at winehq.org
Mon Aug 17 11:24:01 CDT 2009
Module: wine
Branch: master
Commit: b8078fc747e73e0437ab2f46447c958d7526d4c2
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b8078fc747e73e0437ab2f46447c958d7526d4c2
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Mon Aug 17 09:39:07 2009 +0200
wined3d: Use WINED3D_UNMAPPED_STAGE in some more places.
---
dlls/wined3d/context.c | 9 ++++++---
dlls/wined3d/device.c | 44 ++++++++++++++++++++++++--------------------
dlls/wined3d/drawprim.c | 6 +++---
dlls/wined3d/surface.c | 5 +++--
dlls/wined3d/volume.c | 5 +++--
5 files changed, 39 insertions(+), 30 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 09743c6..87416b7 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1513,9 +1513,10 @@ static inline void set_blit_dimension(UINT width, UINT height) {
/* Context activation is done by the caller. */
static inline void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context *context, UINT width, UINT height)
{
- int i, sampler;
+ int i;
const struct StateEntry *StateTable = This->StateTable;
const struct wined3d_gl_info *gl_info = context->gl_info;
+ DWORD sampler;
TRACE("Setting up context %p for blitting\n", context);
if(context->last_was_blit) {
@@ -1578,7 +1579,8 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);");
- if (sampler != -1) {
+ if (sampler != WINED3D_UNMAPPED_STAGE)
+ {
if (sampler < MAX_TEXTURES) {
Context_MarkStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP), StateTable);
}
@@ -1617,7 +1619,8 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context
checkGLcall("glTexEnvi GL_TEXTURE_LOD_BIAS_EXT ...");
}
- if (sampler != -1) {
+ if (sampler != WINED3D_UNMAPPED_STAGE)
+ {
if (sampler < MAX_TEXTURES) {
Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_TEXTURE0 + sampler), StateTable);
Context_MarkStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP), StateTable);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 256d6dc..6afd5da 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2113,8 +2113,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
This->texUnitMap[state] = state;
This->rev_tex_unit_map[state] = state;
} else {
- This->texUnitMap[state] = -1;
- This->rev_tex_unit_map[state] = -1;
+ This->texUnitMap[state] = WINED3D_UNMAPPED_STAGE;
+ This->rev_tex_unit_map[state] = WINED3D_UNMAPPED_STAGE;
}
}
@@ -3635,18 +3635,21 @@ static inline void markTextureStagesDirty(IWineD3DDeviceImpl *This, DWORD stage)
}
}
-static void device_map_stage(IWineD3DDeviceImpl *This, int stage, int unit) {
- int i = This->rev_tex_unit_map[unit];
- int j = This->texUnitMap[stage];
+static void device_map_stage(IWineD3DDeviceImpl *This, DWORD stage, DWORD unit)
+{
+ DWORD i = This->rev_tex_unit_map[unit];
+ DWORD j = This->texUnitMap[stage];
This->texUnitMap[stage] = unit;
- if (i != -1 && i != stage) {
- This->texUnitMap[i] = -1;
+ if (i != WINED3D_UNMAPPED_STAGE && i != stage)
+ {
+ This->texUnitMap[i] = WINED3D_UNMAPPED_STAGE;
}
This->rev_tex_unit_map[unit] = stage;
- if (j != -1 && j != unit) {
- This->rev_tex_unit_map[j] = -1;
+ if (j != WINED3D_UNMAPPED_STAGE && j != unit)
+ {
+ This->rev_tex_unit_map[j] = WINED3D_UNMAPPED_STAGE;
}
}
@@ -3740,14 +3743,12 @@ static void device_map_psamplers(IWineD3DDeviceImpl *This) {
}
static BOOL device_unit_free_for_vs(IWineD3DDeviceImpl *This, const DWORD *pshader_sampler_tokens,
- const DWORD *vshader_sampler_tokens, int unit)
+ const DWORD *vshader_sampler_tokens, DWORD unit)
{
- int current_mapping = This->rev_tex_unit_map[unit];
+ DWORD current_mapping = This->rev_tex_unit_map[unit];
- if (current_mapping == -1) {
- /* Not currently used */
- return TRUE;
- }
+ /* Not currently used */
+ if (current_mapping == WINED3D_UNMAPPED_STAGE) return TRUE;
if (current_mapping < MAX_FRAGMENT_SAMPLERS) {
/* Used by a fragment sampler */
@@ -3781,7 +3782,7 @@ static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps) {
}
for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i) {
- int vsampler_idx = i + MAX_FRAGMENT_SAMPLERS;
+ DWORD vsampler_idx = i + MAX_FRAGMENT_SAMPLERS;
if (vshader_sampler_type[i])
{
if (This->texUnitMap[vsampler_idx] != WINED3D_UNMAPPED_STAGE)
@@ -5731,7 +5732,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 */
const struct GlPixelFormatDesc *src_format_desc, *dst_format_desc;
GLenum dummy;
- int sampler;
+ DWORD sampler;
int bpp;
CONVERT_TYPES convert = NO_CONVERSION;
@@ -5871,7 +5872,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
IWineD3DSurface_ModifyLocation(pDestinationSurface, SFLAG_INTEXTURE, TRUE);
sampler = This->rev_tex_unit_map[0];
- if (sampler != -1) {
+ if (sampler != WINED3D_UNMAPPED_STAGE)
+ {
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(sampler));
}
@@ -6680,7 +6682,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice* i
INT height = This->cursorHeight;
INT width = This->cursorWidth;
INT bpp = glDesc->byte_count;
- INT i, sampler;
+ DWORD sampler;
+ INT i;
/* Reformat the texture memory (pitch and width can be
* different) */
@@ -6702,7 +6705,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice* i
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
checkGLcall("glActiveTextureARB");
sampler = This->rev_tex_unit_map[0];
- if (sampler != -1) {
+ if (sampler != WINED3D_UNMAPPED_STAGE)
+ {
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(sampler));
}
/* Create a new cursor texture */
diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index 9a5aef7..a2a4620 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -164,7 +164,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context
for (textureNo = 0; textureNo < texture_stages; ++textureNo)
{
int coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
- int texture_idx = This->texUnitMap[textureNo];
+ DWORD texture_idx = This->texUnitMap[textureNo];
if (!GL_SUPPORT(ARB_MULTITEXTURE) && textureNo > 0)
{
@@ -174,7 +174,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context
if (!pixelShader && !This->stateBlock->textures[textureNo]) continue;
- if (texture_idx == -1) continue;
+ if (texture_idx == WINED3D_UNMAPPED_STAGE) continue;
if (coordIdx > 7)
{
@@ -232,7 +232,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context
{
int coord_idx;
const void *ptr;
- int texture_idx;
+ DWORD texture_idx;
if (!(tmp_tex_mask & 1)) continue;
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 781a6b2..865cbc7 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -301,7 +301,7 @@ void surface_set_texture_target(IWineD3DSurface *iface, GLenum target)
/* Context activation is done by the caller. */
static void surface_bind_and_dirtify(IWineD3DSurfaceImpl *This, BOOL srgb) {
- int active_sampler;
+ DWORD active_sampler;
/* 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
@@ -320,7 +320,8 @@ static void surface_bind_and_dirtify(IWineD3DSurfaceImpl *This, BOOL srgb) {
LEAVE_GL();
active_sampler = This->resource.wineD3DDevice->rev_tex_unit_map[active_texture - GL_TEXTURE0_ARB];
- if (active_sampler != -1) {
+ if (active_sampler != WINED3D_UNMAPPED_STAGE)
+ {
IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(active_sampler));
}
IWineD3DSurface_BindTexture((IWineD3DSurface *)This, srgb);
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index 871fdf7..85e8f3a 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -30,7 +30,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
static void volume_bind_and_dirtify(IWineD3DVolume *iface) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
IWineD3DVolumeTexture *texture;
- int active_sampler;
+ DWORD active_sampler;
/* 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
@@ -53,7 +53,8 @@ static void volume_bind_and_dirtify(IWineD3DVolume *iface) {
active_sampler = 0;
}
- if (active_sampler != -1) {
+ if (active_sampler != WINED3D_UNMAPPED_STAGE)
+ {
IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(active_sampler));
}
More information about the wine-cvs
mailing list