Module: wine Branch: master Commit: 4ff5736edf6f3a0b6f6db295f1650543846cc898 URL: http://source.winehq.org/git/wine.git/?a=commit;h=4ff5736edf6f3a0b6f6db295f1...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Mon Mar 9 14:31:28 2009 +0100
wined3d: Don't compare texUnitMap entries to -1.
---
dlls/wined3d/ati_fragment_shader.c | 3 ++- dlls/wined3d/device.c | 3 ++- dlls/wined3d/glsl_shader.c | 10 ++++++---- dlls/wined3d/nvidia_texture_shader.c | 8 +++++--- dlls/wined3d/state.c | 19 ++++++++++++------- dlls/wined3d/utils.c | 2 +- dlls/wined3d/wined3d_private.h | 2 ++ 7 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/dlls/wined3d/ati_fragment_shader.c b/dlls/wined3d/ati_fragment_shader.c index 5555208..a8c137f 100644 --- a/dlls/wined3d/ati_fragment_shader.c +++ b/dlls/wined3d/ati_fragment_shader.c @@ -834,7 +834,8 @@ static void set_tex_op_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, Wi */ for(i = 0; i < desc->num_textures_used; i++) { mapped_stage = This->texUnitMap[i]; - if(mapped_stage != -1) { + if (mapped_stage != WINED3D_UNMAPPED_STAGE) + { GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage)); checkGLcall("glActiveTextureARB"); texture_activate_dimensions(i, stateblock, context); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index d21b132..63f7352 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4059,7 +4059,8 @@ static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps) { for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i) { int vsampler_idx = i + MAX_FRAGMENT_SAMPLERS; if (vshader_sampler_tokens[i]) { - if (This->texUnitMap[vsampler_idx] != -1) { + if (This->texUnitMap[vsampler_idx] != WINED3D_UNMAPPED_STAGE) + { /* Already mapped somewhere */ continue; } diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 3a89f74..6d82a6a 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -189,8 +189,9 @@ static void shader_glsl_load_psamplers(const WineD3D_GL_Info *gl_info, IWineD3DS snprintf(sampler_name, sizeof(sampler_name), "Psampler%d", i); name_loc = GL_EXTCALL(glGetUniformLocationARB(programId, sampler_name)); if (name_loc != -1) { - int mapped_unit = stateBlock->wineD3DDevice->texUnitMap[i]; - if (mapped_unit != -1 && mapped_unit < GL_LIMITS(fragment_samplers)) { + DWORD mapped_unit = stateBlock->wineD3DDevice->texUnitMap[i]; + if (mapped_unit != WINED3D_UNMAPPED_STAGE && mapped_unit < GL_LIMITS(fragment_samplers)) + { TRACE("Loading %s for texture %d\n", sampler_name, mapped_unit); GL_EXTCALL(glUniform1iARB(name_loc, mapped_unit)); checkGLcall("glUniform1iARB"); @@ -212,8 +213,9 @@ static void shader_glsl_load_vsamplers(const WineD3D_GL_Info *gl_info, IWineD3DS snprintf(sampler_name, sizeof(sampler_name), "Vsampler%d", i); name_loc = GL_EXTCALL(glGetUniformLocationARB(programId, sampler_name)); if (name_loc != -1) { - int mapped_unit = stateBlock->wineD3DDevice->texUnitMap[MAX_FRAGMENT_SAMPLERS + i]; - if (mapped_unit != -1 && mapped_unit < GL_LIMITS(combined_samplers)) { + DWORD mapped_unit = stateBlock->wineD3DDevice->texUnitMap[MAX_FRAGMENT_SAMPLERS + i]; + if (mapped_unit != WINED3D_UNMAPPED_STAGE && mapped_unit < GL_LIMITS(combined_samplers)) + { TRACE("Loading %s for texture %d\n", sampler_name, mapped_unit); GL_EXTCALL(glUniform1iARB(name_loc, mapped_unit)); checkGLcall("glUniform1iARB"); diff --git a/dlls/wined3d/nvidia_texture_shader.c b/dlls/wined3d/nvidia_texture_shader.c index fc727d6..f7e331d 100644 --- a/dlls/wined3d/nvidia_texture_shader.c +++ b/dlls/wined3d/nvidia_texture_shader.c @@ -462,7 +462,8 @@ static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3
if (stage != mapped_stage) WARN("Using non 1:1 mapping: %d -> %d!\n", stage, mapped_stage);
- if (mapped_stage != -1) { + if (mapped_stage != WINED3D_UNMAPPED_STAGE) + { if (tex_used && mapped_stage >= GL_LIMITS(textures)) { FIXME("Attempt to enable unsupported stage!\n"); return; @@ -479,7 +480,8 @@ static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3 } if(stage >= stateblock->lowest_disabled_stage) { TRACE("Stage disabled\n"); - if (mapped_stage != -1) { + if (mapped_stage != WINED3D_UNMAPPED_STAGE) + { /* Disable everything here */ glDisable(GL_TEXTURE_2D); checkGLcall("glDisable(GL_TEXTURE_2D)"); @@ -548,7 +550,7 @@ static void nvts_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D * handler takes care. Also no action is needed with pixel shaders, or if tex_colorop * will take care of this business */ - if(mapped_stage == -1 || mapped_stage >= GL_LIMITS(textures)) return; + if(mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= GL_LIMITS(textures)) return; if(sampler >= stateblock->lowest_disabled_stage) return; if(isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) return;
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index d26f5f1..c8f252f 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -2852,7 +2852,8 @@ static void tex_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D
if (stage != mapped_stage) WARN("Using non 1:1 mapping: %d -> %d!\n", stage, mapped_stage);
- if (mapped_stage != -1) { + if (mapped_stage != WINED3D_UNMAPPED_STAGE) + { if (tex_used && mapped_stage >= GL_LIMITS(textures)) { FIXME("Attempt to enable unsupported stage!\n"); return; @@ -2863,7 +2864,8 @@ static void tex_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D
if(stage >= stateblock->lowest_disabled_stage) { TRACE("Stage disabled\n"); - if (mapped_stage != -1) { + if (mapped_stage != WINED3D_UNMAPPED_STAGE) + { /* Disable everything here */ glDisable(GL_TEXTURE_2D); checkGLcall("glDisable(GL_TEXTURE_2D)"); @@ -2904,7 +2906,8 @@ void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext
TRACE("Setting alpha op for stage %d\n", stage); /* Do not care for enabled / disabled stages, just assign the settings. colorop disables / enables required stuff */ - if (mapped_stage != -1) { + if (mapped_stage != WINED3D_UNMAPPED_STAGE) + { if (tex_used && mapped_stage >= GL_LIMITS(textures)) { FIXME("Attempt to enable unsupported stage!\n"); return; @@ -3008,7 +3011,7 @@ static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock, W return; }
- if (mapped_stage == -1) return; + if (mapped_stage == WINED3D_UNMAPPED_STAGE) return;
if(mapped_stage >= GL_LIMITS(textures)) { return; @@ -3057,7 +3060,7 @@ static void loadTexCoords(IWineD3DStateBlockImpl *stateblock, const WineDirect3D int coordIdx = stateblock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
mapped_stage = stateblock->wineD3DDevice->texUnitMap[textureNo]; - if (mapped_stage == -1) continue; + if (mapped_stage == WINED3D_UNMAPPED_STAGE) continue;
if (coordIdx < MAX_TEXTURES && (sd->u.s.texCoords[coordIdx].lpData || sd->u.s.texCoords[coordIdx].VBO)) { TRACE("Setting up texture %u, idx %d, cordindx %u, data %p\n", @@ -3101,7 +3104,8 @@ static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine static const GLfloat r_plane[] = { 0.0, 0.0, 1.0, 0.0 }; static const GLfloat q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
- if (mapped_stage == -1) { + if (mapped_stage == WINED3D_UNMAPPED_STAGE) + { TRACE("No texture unit mapped to stage %d. Skipping texture coordinates.\n", stage); return; } @@ -3341,7 +3345,8 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCont * only has to bind textures and set the per texture states */
- if (mapped_stage == -1) { + if (mapped_stage == WINED3D_UNMAPPED_STAGE) + { TRACE("No sampler mapped to stage %d. Returning.\n", sampler); return; } diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 5fa4a1f..6d19010 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -2385,7 +2385,7 @@ void sampler_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCont * handler takes care. Also no action is needed with pixel shaders, or if tex_colorop * will take care of this business */ - if(mapped_stage == -1 || mapped_stage >= GL_LIMITS(textures)) return; + if(mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= GL_LIMITS(textures)) return; if(sampler >= stateblock->lowest_disabled_stage) return; if(isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) return;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 7aa4eb4..b905aea 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1039,6 +1039,8 @@ void dumpResources(struct list *list); /***************************************************************************** * IWineD3DDevice implementation structure */ +#define WINED3D_UNMAPPED_STAGE ~0U + struct IWineD3DDeviceImpl { /* IUnknown fields */