Commit 4ff5736e authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Don't compare texUnitMap entries to -1.

parent a3df4767
......@@ -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);
......
......@@ -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;
}
......
......@@ -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");
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -1039,6 +1039,8 @@ void dumpResources(struct list *list);
/*****************************************************************************
* IWineD3DDevice implementation structure
*/
#define WINED3D_UNMAPPED_STAGE ~0U
struct IWineD3DDeviceImpl
{
/* IUnknown fields */
......
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