From 5b3c1a2082f78eba5061c84ad2f41988feb8a26c Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 16 Sep 2010 11:19:57 +0200 Subject: [PATCH] wined3d: Move texture states to wined3d_state. --- dlls/wined3d/arb_program_shader.c | 45 +++++++++++----------- dlls/wined3d/ati_fragment_shader.c | 8 ++-- dlls/wined3d/device.c | 49 ++++++++++++++---------- dlls/wined3d/drawprim.c | 4 +- dlls/wined3d/glsl_shader.c | 19 +++++----- dlls/wined3d/nvidia_texture_shader.c | 57 +++++++++++++++------------- dlls/wined3d/state.c | 54 +++++++++++++------------- dlls/wined3d/stateblock.c | 53 +++++++++++++------------- dlls/wined3d/utils.c | 40 ++++++++++--------- dlls/wined3d/wined3d_private.h | 6 +-- 10 files changed, 179 insertions(+), 156 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index acde513f570..2b396b9a95c 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -177,7 +177,7 @@ static const char *arb_get_helper_value(enum wined3d_shader_type shader, enum ar static inline BOOL ffp_clip_emul(IWineD3DStateBlockImpl *stateblock) { - return stateblock->lowest_disabled_stage < 7; + return stateblock->state.lowest_disabled_stage < 7; } /* ARB_program_shader private data */ @@ -542,8 +542,9 @@ static inline void shader_arb_ps_local_constants(IWineD3DDeviceImpl* deviceImpl) int texunit = gl_shader->bumpenvmatconst[i].texunit; /* The state manager takes care that this function is always called if the bump env matrix changes */ - const float *data = (const float *)&stateBlock->textureState[texunit][WINED3DTSS_BUMPENVMAT00]; - GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, gl_shader->bumpenvmatconst[i].const_num, data)); + const float *data = (const float *)&stateBlock->state.texture_states[texunit][WINED3DTSS_BUMPENVMAT00]; + GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, + gl_shader->bumpenvmatconst[i].const_num, data)); if (gl_shader->luminanceconst[i].const_num != WINED3D_CONST_NUM_UNUSED) { @@ -552,8 +553,9 @@ static inline void shader_arb_ps_local_constants(IWineD3DDeviceImpl* deviceImpl) * don't care about them. The pointers are valid for sure because the stateblock is bigger. * (they're WINED3DTSS_TEXTURETRANSFORMFLAGS and WINED3DTSS_ADDRESSW, so most likely 0 or NaN */ - const float *scale = (const float *)&stateBlock->textureState[texunit][WINED3DTSS_BUMPENVLSCALE]; - GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, gl_shader->luminanceconst[i].const_num, scale)); + const float *scale = (const float *)&stateBlock->state.texture_states[texunit][WINED3DTSS_BUMPENVLSCALE]; + GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, + gl_shader->luminanceconst[i].const_num, scale)); } } checkGLcall("Load bumpmap consts"); @@ -1920,12 +1922,10 @@ static void pshader_hw_tex(const struct wined3d_shader_instruction *ins) if (shader_version < WINED3D_SHADER_VERSION(1,4)) { DWORD flags = 0; - if(reg_sampler_code < MAX_TEXTURES) { - flags = deviceImpl->stateBlock->textureState[reg_sampler_code][WINED3DTSS_TEXTURETRANSFORMFLAGS]; - } - if (flags & WINED3DTTFF_PROJECTED) { + if (reg_sampler_code < MAX_TEXTURES) + flags = deviceImpl->stateBlock->state.texture_states[reg_sampler_code][WINED3DTSS_TEXTURETRANSFORMFLAGS]; + if (flags & WINED3DTTFF_PROJECTED) myflags |= TEX_PROJ; - } } else if (shader_version < WINED3D_SHADER_VERSION(2,0)) { @@ -1987,7 +1987,7 @@ static void pshader_hw_texreg2ar(const struct wined3d_shader_instruction *ins) /* Move .x first in case src_str is "TA" */ shader_addline(buffer, "MOV TA.y, %s.x;\n", src_str); shader_addline(buffer, "MOV TA.x, %s.w;\n", src_str); - flags = reg1 < MAX_TEXTURES ? deviceImpl->stateBlock->textureState[reg1][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0; + flags = reg1 < MAX_TEXTURES ? deviceImpl->stateBlock->state.texture_states[reg1][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0; shader_hw_sample(ins, reg1, dst_str, "TA", flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0, NULL, NULL); } @@ -2054,7 +2054,8 @@ static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins) /* with projective textures, texbem only divides the static texture coord, not the displacement, * so we can't let the GL handle this. */ - if (device->stateBlock->textureState[reg_dest_code][WINED3DTSS_TEXTURETRANSFORMFLAGS] & WINED3DTTFF_PROJECTED) + if (device->stateBlock->state.texture_states[reg_dest_code][WINED3DTSS_TEXTURETRANSFORMFLAGS] + & WINED3DTTFF_PROJECTED) { shader_addline(buffer, "RCP TB.w, %s.w;\n", reg_coord); shader_addline(buffer, "MUL TB.xy, %s, TB.w;\n", reg_coord); @@ -2109,7 +2110,7 @@ static void pshader_hw_texm3x2tex(const struct wined3d_shader_instruction *ins) shader_arb_get_dst_param(ins, &ins->dst[0], dst_str); shader_arb_get_src_param(ins, &ins->src[0], 0, src0_name); shader_addline(buffer, "DP3 %s.y, fragment.texcoord[%u], %s;\n", dst_reg, reg, src0_name); - flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->textureState[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0; + flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->state.texture_states[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0; shader_hw_sample(ins, reg, dst_str, dst_reg, flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0, NULL, NULL); } @@ -2154,7 +2155,7 @@ static void pshader_hw_texm3x3tex(const struct wined3d_shader_instruction *ins) /* Sample the texture using the calculated coordinates */ shader_arb_get_dst_param(ins, &ins->dst[0], dst_str); - flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->textureState[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0; + flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->state.texture_states[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0; shader_hw_sample(ins, reg, dst_str, dst_name, flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0, NULL, NULL); current_state->current_row = 0; } @@ -2196,7 +2197,7 @@ static void pshader_hw_texm3x3vspec(const struct wined3d_shader_instruction *ins /* Sample the texture using the calculated coordinates */ shader_arb_get_dst_param(ins, &ins->dst[0], dst_str); - flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->textureState[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0; + flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->state.texture_states[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0; shader_hw_sample(ins, reg, dst_str, dst_reg, flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0, NULL, NULL); current_state->current_row = 0; } @@ -2238,7 +2239,7 @@ static void pshader_hw_texm3x3spec(const struct wined3d_shader_instruction *ins) /* Sample the texture using the calculated coordinates */ shader_arb_get_dst_param(ins, &ins->dst[0], dst_str); - flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->textureState[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0; + flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->state.texture_states[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0; shader_hw_sample(ins, reg, dst_str, dst_reg, flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0, NULL, NULL); current_state->current_row = 0; } @@ -5601,10 +5602,10 @@ static void set_bumpmat_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock, s device->highest_dirty_ps_const = max(device->highest_dirty_ps_const, ARB_FFP_CONST_BUMPMAT(stage) + 1); } - mat[0][0] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT00]); - mat[0][1] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT01]); - mat[1][0] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT10]); - mat[1][1] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT11]); + mat[0][0] = *((float *)&stateblock->state.texture_states[stage][WINED3DTSS_BUMPENVMAT00]); + mat[0][1] = *((float *)&stateblock->state.texture_states[stage][WINED3DTSS_BUMPENVMAT01]); + mat[1][0] = *((float *)&stateblock->state.texture_states[stage][WINED3DTSS_BUMPENVMAT10]); + mat[1][1] = *((float *)&stateblock->state.texture_states[stage][WINED3DTSS_BUMPENVMAT11]); GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_BUMPMAT(stage), &mat[0][0])); checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_BUMPMAT(stage), &mat[0][0])"); @@ -5638,8 +5639,8 @@ static void tex_bumpenvlum_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock device->highest_dirty_ps_const = max(device->highest_dirty_ps_const, ARB_FFP_CONST_LUMINANCE(stage) + 1); } - param[0] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVLSCALE]); - param[1] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVLOFFSET]); + param[0] = *((float *)&stateblock->state.texture_states[stage][WINED3DTSS_BUMPENVLSCALE]); + param[1] = *((float *)&stateblock->state.texture_states[stage][WINED3DTSS_BUMPENVLOFFSET]); param[2] = 0.0f; param[3] = 0.0f; diff --git a/dlls/wined3d/ati_fragment_shader.c b/dlls/wined3d/ati_fragment_shader.c index a120a7b0c0f..34987186ff2 100644 --- a/dlls/wined3d/ati_fragment_shader.c +++ b/dlls/wined3d/ati_fragment_shader.c @@ -861,10 +861,10 @@ static void set_bumpmat(DWORD state, IWineD3DStateBlockImpl *stateblock, struct const struct wined3d_gl_info *gl_info = context->gl_info; float mat[2][2]; - mat[0][0] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT00]); - mat[1][0] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT01]); - mat[0][1] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT10]); - mat[1][1] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT11]); + mat[0][0] = *((float *)&stateblock->state.texture_states[stage][WINED3DTSS_BUMPENVMAT00]); + mat[1][0] = *((float *)&stateblock->state.texture_states[stage][WINED3DTSS_BUMPENVMAT01]); + mat[0][1] = *((float *)&stateblock->state.texture_states[stage][WINED3DTSS_BUMPENVMAT10]); + mat[1][1] = *((float *)&stateblock->state.texture_states[stage][WINED3DTSS_BUMPENVMAT11]); /* GL_ATI_fragment_shader allows only constants from 0.0 to 1.0, but the bumpmat * constants can be in any range. While they should stay between [-1.0 and 1.0] because * Shader Model 1.x pixel shaders are clamped to that range negative values are used occasionally, diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 3d930f99695..814f06074d6 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3427,15 +3427,17 @@ static void device_update_fixed_function_usage_map(IWineD3DDeviceImpl *This) { int i; This->fixed_function_usage_map = 0; - for (i = 0; i < MAX_TEXTURES; ++i) { - WINED3DTEXTUREOP color_op = This->stateBlock->textureState[i][WINED3DTSS_COLOROP]; - WINED3DTEXTUREOP alpha_op = This->stateBlock->textureState[i][WINED3DTSS_ALPHAOP]; - DWORD color_arg1 = This->stateBlock->textureState[i][WINED3DTSS_COLORARG1] & WINED3DTA_SELECTMASK; - DWORD color_arg2 = This->stateBlock->textureState[i][WINED3DTSS_COLORARG2] & WINED3DTA_SELECTMASK; - DWORD color_arg3 = This->stateBlock->textureState[i][WINED3DTSS_COLORARG0] & WINED3DTA_SELECTMASK; - DWORD alpha_arg1 = This->stateBlock->textureState[i][WINED3DTSS_ALPHAARG1] & WINED3DTA_SELECTMASK; - DWORD alpha_arg2 = This->stateBlock->textureState[i][WINED3DTSS_ALPHAARG2] & WINED3DTA_SELECTMASK; - DWORD alpha_arg3 = This->stateBlock->textureState[i][WINED3DTSS_ALPHAARG0] & WINED3DTA_SELECTMASK; + for (i = 0; i < MAX_TEXTURES; ++i) + { + const struct wined3d_state *state = &This->stateBlock->state; + WINED3DTEXTUREOP color_op = state->texture_states[i][WINED3DTSS_COLOROP]; + WINED3DTEXTUREOP alpha_op = state->texture_states[i][WINED3DTSS_ALPHAOP]; + DWORD color_arg1 = state->texture_states[i][WINED3DTSS_COLORARG1] & WINED3DTA_SELECTMASK; + DWORD color_arg2 = state->texture_states[i][WINED3DTSS_COLORARG2] & WINED3DTA_SELECTMASK; + DWORD color_arg3 = state->texture_states[i][WINED3DTSS_COLORARG0] & WINED3DTA_SELECTMASK; + DWORD alpha_arg1 = state->texture_states[i][WINED3DTSS_ALPHAARG1] & WINED3DTA_SELECTMASK; + DWORD alpha_arg2 = state->texture_states[i][WINED3DTSS_ALPHAARG2] & WINED3DTA_SELECTMASK; + DWORD alpha_arg3 = state->texture_states[i][WINED3DTSS_ALPHAARG0] & WINED3DTA_SELECTMASK; if (color_op == WINED3DTOP_DISABLE) { /* Not used, and disable higher stages */ @@ -3466,7 +3468,7 @@ static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This, const s ffu_map = This->fixed_function_usage_map; if (This->max_ffp_textures == gl_info->limits.texture_stages - || This->stateBlock->lowest_disabled_stage <= This->max_ffp_textures) + || This->stateBlock->state.lowest_disabled_stage <= This->max_ffp_textures) { for (i = 0; ffu_map; ffu_map >>= 1, ++i) { @@ -4228,9 +4230,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *if return WINED3D_OK; } - oldValue = This->updateStateBlock->textureState[Stage][Type]; + oldValue = This->updateStateBlock->state.texture_states[Stage][Type]; This->updateStateBlock->changed.textureState[Stage] |= 1 << Type; - This->updateStateBlock->textureState[Stage][Type] = Value; + This->updateStateBlock->state.texture_states[Stage][Type] = Value; if (This->isRecordingState) { TRACE("Recording... not performing anything\n"); @@ -4243,8 +4245,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *if return WINED3D_OK; } - if(Stage > This->stateBlock->lowest_disabled_stage && - This->StateTable[STATE_TEXTURESTAGE(0, Type)].representative == STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP)) { + if (Stage > This->stateBlock->state.lowest_disabled_stage + && This->StateTable[STATE_TEXTURESTAGE(0, Type)].representative + == STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP)) + { /* Colorop change above lowest disabled stage? That won't change anything in the gl setup * Changes in other states are important on disabled stages too */ @@ -4260,11 +4264,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *if * * The current stage is dirtified below. */ - for(i = Stage + 1; i < This->stateBlock->lowest_disabled_stage; i++) { + for (i = Stage + 1; i < This->stateBlock->state.lowest_disabled_stage; ++i) + { TRACE("Additionally dirtifying stage %u\n", i); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP)); } - This->stateBlock->lowest_disabled_stage = Stage; + This->stateBlock->state.lowest_disabled_stage = Stage; TRACE("New lowest disabled: %u\n", Stage); } else if(Value != WINED3DTOP_DISABLE && oldValue == WINED3DTOP_DISABLE) { /* Previously disabled stage enabled. Stages above it may need enabling @@ -4276,13 +4281,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *if for (i = Stage + 1; i < This->adapter->gl_info.limits.texture_stages; ++i) { - if(This->updateStateBlock->textureState[i][WINED3DTSS_COLOROP] == WINED3DTOP_DISABLE) { + if (This->updateStateBlock->state.texture_states[i][WINED3DTSS_COLOROP] == WINED3DTOP_DISABLE) break; - } TRACE("Additionally dirtifying stage %u due to enable\n", i); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP)); } - This->stateBlock->lowest_disabled_stage = i; + This->stateBlock->state.lowest_disabled_stage = i; TRACE("New lowest disabled: %u\n", i); } } @@ -4296,15 +4300,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetTextureStageState(IWineD3DDevice *if { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + TRACE("iface %p, stage %u, state %s, value %p.\n", + iface, Stage, debug_d3dtexturestate(Type), pValue); + if (Type > WINED3D_HIGHEST_TEXTURE_STATE) { WARN("Invalid Type %d passed.\n", Type); return WINED3D_OK; } - TRACE("(%p) : requesting Stage %d, Type %d getting %d\n", This, Stage, Type, This->updateStateBlock->textureState[Stage][Type]); + *pValue = This->updateStateBlock->state.texture_states[Stage][Type]; + TRACE("Returning %#x.\n", *pValue); - *pValue = This->updateStateBlock->textureState[Stage][Type]; return WINED3D_OK; } diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index 46b8096a81d..011837f691b 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -169,7 +169,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 coordIdx = This->stateBlock->state.texture_states[textureNo][WINED3DTSS_TEXCOORDINDEX]; DWORD texture_idx = This->texUnitMap[textureNo]; if (!gl_info->supported[ARB_MULTITEXTURE] && textureNo > 0) @@ -239,7 +239,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context if (!(tmp_tex_mask & 1)) continue; - coord_idx = This->stateBlock->textureState[texture][WINED3DTSS_TEXCOORDINDEX]; + coord_idx = This->stateBlock->state.texture_states[texture][WINED3DTSS_TEXCOORDINDEX]; ptr = texCoords[coord_idx] + (SkipnStrides * si->elements[WINED3D_FFP_TEXCOORD0 + coord_idx].stride); texture_idx = This->texUnitMap[texture]; diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index a04cf410d5b..e757f6d0c6e 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -796,16 +796,17 @@ static void shader_glsl_load_constants(const struct wined3d_context *context, if(prog->bumpenvmat_location[i] == -1) continue; - data = (const float *)&stateBlock->textureState[i][WINED3DTSS_BUMPENVMAT00]; + data = (const float *)&stateBlock->state.texture_states[i][WINED3DTSS_BUMPENVMAT00]; GL_EXTCALL(glUniformMatrix2fvARB(prog->bumpenvmat_location[i], 1, 0, data)); checkGLcall("glUniformMatrix2fvARB"); - /* texbeml needs the luminance scale and offset too. If texbeml is used, needsbumpmat - * is set too, so we can check that in the needsbumpmat check - */ - if(prog->luminancescale_location[i] != -1) { - const GLfloat *scale = (const GLfloat *)&stateBlock->textureState[i][WINED3DTSS_BUMPENVLSCALE]; - const GLfloat *offset = (const GLfloat *)&stateBlock->textureState[i][WINED3DTSS_BUMPENVLOFFSET]; + /* texbeml needs the luminance scale and offset too. If texbeml + * is used, needsbumpmat is set too, so we can check that in the + * needsbumpmat check. */ + if (prog->luminancescale_location[i] != -1) + { + const GLfloat *scale = (const GLfloat *)&stateBlock->state.texture_states[i][WINED3DTSS_BUMPENVLSCALE]; + const GLfloat *offset = (const GLfloat *)&stateBlock->state.texture_states[i][WINED3DTSS_BUMPENVLOFFSET]; GL_EXTCALL(glUniform1fvARB(prog->luminancescale_location[i], 1, scale)); checkGLcall("glUniform1fvARB"); @@ -3027,7 +3028,7 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins) if (shader_version < WINED3D_SHADER_VERSION(1,4)) { - DWORD flags = deviceImpl->stateBlock->textureState[sampler_idx][WINED3DTSS_TEXTURETRANSFORMFLAGS]; + DWORD flags = deviceImpl->stateBlock->state.texture_states[sampler_idx][WINED3DTSS_TEXTURETRANSFORMFLAGS]; WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx]; /* Projected cube textures don't make a lot of sense, the resulting coordinates stay the same. */ @@ -3474,7 +3475,7 @@ static void shader_glsl_texbem(const struct wined3d_shader_instruction *ins) char coord_mask[6]; sampler_idx = ins->dst[0].reg.idx; - flags = deviceImpl->stateBlock->textureState[sampler_idx][WINED3DTSS_TEXTURETRANSFORMFLAGS]; + flags = deviceImpl->stateBlock->state.texture_states[sampler_idx][WINED3DTSS_TEXTURETRANSFORMFLAGS]; /* Dependent read, not valid with conditional NP2 */ shader_glsl_get_sample_function(ins->ctx, sampler_idx, 0, &sample_function); diff --git a/dlls/wined3d/nvidia_texture_shader.c b/dlls/wined3d/nvidia_texture_shader.c index 7d5cc5bd82b..dc873be97f1 100644 --- a/dlls/wined3d/nvidia_texture_shader.c +++ b/dlls/wined3d/nvidia_texture_shader.c @@ -34,8 +34,9 @@ static void nvts_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateb { BOOL bumpmap = FALSE; - if(stage > 0 && (stateblock->textureState[stage - 1][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAPLUMINANCE || - stateblock->textureState[stage - 1][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAP)) { + if (stage > 0 && (stateblock->state.texture_states[stage - 1][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAPLUMINANCE + || stateblock->state.texture_states[stage - 1][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAP)) + { bumpmap = TRUE; context->texShaderBumpMap |= (1 << stage); } else { @@ -477,13 +478,17 @@ static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct checkGLcall("glActiveTextureARB"); } - if(stateblock->lowest_disabled_stage > 0) { + if (stateblock->state.lowest_disabled_stage > 0) + { glEnable(GL_REGISTER_COMBINERS_NV); - GL_EXTCALL(glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, stateblock->lowest_disabled_stage)); - } else { + GL_EXTCALL(glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, stateblock->state.lowest_disabled_stage)); + } + else + { glDisable(GL_REGISTER_COMBINERS_NV); } - if(stage >= stateblock->lowest_disabled_stage) { + if (stage >= stateblock->state.lowest_disabled_stage) + { TRACE("Stage disabled\n"); if (mapped_stage != WINED3D_UNMAPPED_STAGE) { @@ -531,22 +536,23 @@ static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct /* Set the texture combiners */ set_tex_op_nvrc((IWineD3DDevice *)stateblock->device, FALSE, stage, - stateblock->textureState[stage][WINED3DTSS_COLOROP], - stateblock->textureState[stage][WINED3DTSS_COLORARG1], - stateblock->textureState[stage][WINED3DTSS_COLORARG2], - stateblock->textureState[stage][WINED3DTSS_COLORARG0], - mapped_stage, - stateblock->textureState[stage][WINED3DTSS_RESULTARG]); + stateblock->state.texture_states[stage][WINED3DTSS_COLOROP], + stateblock->state.texture_states[stage][WINED3DTSS_COLORARG1], + stateblock->state.texture_states[stage][WINED3DTSS_COLORARG2], + stateblock->state.texture_states[stage][WINED3DTSS_COLORARG0], + mapped_stage, + stateblock->state.texture_states[stage][WINED3DTSS_RESULTARG]); /* In register combiners bump mapping is done in the stage AFTER the one that has the bump map operation set, * thus the texture shader may have to be updated */ if (gl_info->supported[NV_TEXTURE_SHADER2]) { - BOOL usesBump = (stateblock->textureState[stage][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAPLUMINANCE || - stateblock->textureState[stage][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAP) ? TRUE : FALSE; - BOOL usedBump = (context->texShaderBumpMap & 1 << (stage + 1)) ? TRUE : FALSE; - if(usesBump != usedBump) { + BOOL usesBump = (stateblock->state.texture_states[stage][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAPLUMINANCE + || stateblock->state.texture_states[stage][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAP); + BOOL usedBump = !!(context->texShaderBumpMap & 1 << (stage + 1)); + if (usesBump != usedBump) + { GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage + 1)); checkGLcall("glActiveTextureARB"); nvts_activate_dimensions(stage + 1, stateblock, context); @@ -566,8 +572,8 @@ static void nvts_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, struct * will take care of this business */ if (mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= context->gl_info->limits.textures) return; - if(sampler >= stateblock->lowest_disabled_stage) return; - if(isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) return; + if (sampler >= stateblock->state.lowest_disabled_stage) return; + if (isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) return; nvts_activate_dimensions(sampler, stateblock, context); } @@ -590,14 +596,13 @@ static void nvts_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, str GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage)); checkGLcall("GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage))"); - /* We can't just pass a pointer to the stateblock to GL due to the different matrix - * format(column major vs row major) - */ - mat[0][0] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT00]); - mat[1][0] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT01]); - mat[0][1] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT10]); - mat[1][1] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT11]); - glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, (float *) mat); + /* We can't just pass a pointer to the stateblock to GL due to the + * different matrix format (column major vs row major). */ + mat[0][0] = *((float *)&stateblock->state.texture_states[stage][WINED3DTSS_BUMPENVMAT00]); + mat[1][0] = *((float *)&stateblock->state.texture_states[stage][WINED3DTSS_BUMPENVMAT01]); + mat[0][1] = *((float *)&stateblock->state.texture_states[stage][WINED3DTSS_BUMPENVMAT10]); + mat[1][1] = *((float *)&stateblock->state.texture_states[stage][WINED3DTSS_BUMPENVMAT11]); + glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, (float *)mat); checkGLcall("glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, mat)"); } } diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index e640b54c1e0..36e605dae64 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -1685,7 +1685,7 @@ static void state_pointsprite(DWORD state, IWineD3DStateBlockImpl *stateblock, s if (gl_info->limits.point_sprite_units < gl_info->limits.textures && !warned) { - if (use_ps(stateblock) || stateblock->lowest_disabled_stage > gl_info->limits.point_sprite_units) + if (use_ps(stateblock) || stateblock->state.lowest_disabled_stage > gl_info->limits.point_sprite_units) { FIXME("The app uses point sprite texture coordinates on more units than supported by the driver\n"); warned = TRUE; @@ -3017,11 +3017,10 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if { DWORD op2; - if (isAlpha) { - op2 = This->stateBlock->textureState[Stage][WINED3DTSS_COLOROP]; - } else { - op2 = This->stateBlock->textureState[Stage][WINED3DTSS_ALPHAOP]; - } + if (isAlpha) + op2 = This->stateBlock->state.texture_states[Stage][WINED3DTSS_COLOROP]; + else + op2 = This->stateBlock->state.texture_states[Stage][WINED3DTSS_ALPHAOP]; /* Note: If COMBINE4 in effect can't go back to combine! */ switch (op2) { @@ -3084,7 +3083,8 @@ static void tex_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct checkGLcall("glActiveTextureARB"); } - if(stage >= stateblock->lowest_disabled_stage) { + if (stage >= stateblock->state.lowest_disabled_stage) + { TRACE("Stage disabled\n"); if (mapped_stage != WINED3D_UNMAPPED_STAGE) { @@ -3116,10 +3116,10 @@ static void tex_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct } set_tex_op(context, (IWineD3DDevice *)stateblock->device, FALSE, stage, - stateblock->textureState[stage][WINED3DTSS_COLOROP], - stateblock->textureState[stage][WINED3DTSS_COLORARG1], - stateblock->textureState[stage][WINED3DTSS_COLORARG2], - stateblock->textureState[stage][WINED3DTSS_COLORARG0]); + stateblock->state.texture_states[stage][WINED3DTSS_COLOROP], + stateblock->state.texture_states[stage][WINED3DTSS_COLORARG1], + stateblock->state.texture_states[stage][WINED3DTSS_COLORARG2], + stateblock->state.texture_states[stage][WINED3DTSS_COLORARG0]); } void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) @@ -3143,10 +3143,10 @@ void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d checkGLcall("glActiveTextureARB"); } - op = stateblock->textureState[stage][WINED3DTSS_ALPHAOP]; - arg1 = stateblock->textureState[stage][WINED3DTSS_ALPHAARG1]; - arg2 = stateblock->textureState[stage][WINED3DTSS_ALPHAARG2]; - arg0 = stateblock->textureState[stage][WINED3DTSS_ALPHAARG0]; + op = stateblock->state.texture_states[stage][WINED3DTSS_ALPHAOP]; + arg1 = stateblock->state.texture_states[stage][WINED3DTSS_ALPHAARG1]; + arg2 = stateblock->state.texture_states[stage][WINED3DTSS_ALPHAARG2]; + arg0 = stateblock->state.texture_states[stage][WINED3DTSS_ALPHAARG0]; if (stateblock->state.render_states[WINED3DRS_COLORKEYENABLE] && !stage && stateblock->textures[0]) { @@ -3215,7 +3215,7 @@ void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d if (gl_info->supported[NV_REGISTER_COMBINERS]) { set_tex_op_nvrc((IWineD3DDevice *)stateblock->device, TRUE, stage, op, arg1, arg2, arg0, - mapped_stage, stateblock->textureState[stage][WINED3DTSS_RESULTARG]); + mapped_stage, stateblock->state.texture_states[stage][WINED3DTSS_RESULTARG]); } else { @@ -3243,11 +3243,13 @@ static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock, s GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage)); checkGLcall("glActiveTextureARB"); - generated = (stateblock->textureState[texUnit][WINED3DTSS_TEXCOORDINDEX] & 0xFFFF0000) != WINED3DTSS_TCI_PASSTHRU; - coordIdx = min(stateblock->textureState[texUnit][WINED3DTSS_TEXCOORDINDEX & 0x0000FFFF], MAX_TEXTURES - 1); + generated = (stateblock->state.texture_states[texUnit][WINED3DTSS_TEXCOORDINDEX] & 0xffff0000) + != WINED3DTSS_TCI_PASSTHRU; + coordIdx = min(stateblock->state.texture_states[texUnit][WINED3DTSS_TEXCOORDINDEX & 0x0000ffff], MAX_TEXTURES - 1); set_texture_matrix(&stateblock->state.transforms[WINED3DTS_TEXTURE0 + texUnit].u.m[0][0], - stateblock->textureState[texUnit][WINED3DTSS_TEXTURETRANSFORMFLAGS], generated, context->last_was_rhw, + stateblock->state.texture_states[texUnit][WINED3DTSS_TEXTURETRANSFORMFLAGS], + generated, context->last_was_rhw, stateblock->device->strided_streams.use_map & (1 << (WINED3D_FFP_TEXCOORD0 + coordIdx)) ? stateblock->device->strided_streams.elements[WINED3D_FFP_TEXCOORD0 + coordIdx].format->id : WINED3DFMT_UNKNOWN, @@ -3287,7 +3289,7 @@ static void loadTexCoords(const struct wined3d_gl_info *gl_info, IWineD3DStateBl for (textureNo = 0; textureNo < gl_info->limits.texture_stages; ++textureNo) { - int coordIdx = stateblock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX]; + int coordIdx = stateblock->state.texture_states[textureNo][WINED3DTSS_TEXCOORDINDEX]; mapped_stage = stateblock->device->texUnitMap[textureNo]; if (mapped_stage == WINED3D_UNMAPPED_STAGE) continue; @@ -3363,7 +3365,7 @@ static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, stru * state. We do not (yet) support the WINED3DRENDERSTATE_WRAPx values, nor tie them up * to the TEXCOORDINDEX value */ - switch (stateblock->textureState[stage][WINED3DTSS_TEXCOORDINDEX] & 0xffff0000) + switch (stateblock->state.texture_states[stage][WINED3DTSS_TEXCOORDINDEX] & 0xffff0000) { case WINED3DTSS_TCI_PASSTHRU: /* Use the specified texture coordinates contained within the @@ -3477,8 +3479,8 @@ static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, stru break; default: - FIXME("Unhandled WINED3DTSS_TEXCOORDINDEX %#x\n", - stateblock->textureState[stage][WINED3DTSS_TEXCOORDINDEX]); + FIXME("Unhandled WINED3DTSS_TEXCOORDINDEX %#x.\n", + stateblock->state.texture_states[stage][WINED3DTSS_TEXCOORDINDEX]); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glDisable(GL_TEXTURE_GEN_R); @@ -3599,7 +3601,7 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine IWineD3DBaseTextureImpl *tex_impl = (IWineD3DBaseTextureImpl *) stateblock->textures[sampler]; IWineD3DBaseTexture_BindTexture(stateblock->textures[sampler], srgb); basetexture_apply_state_changes(stateblock->textures[sampler], - stateblock->textureState[sampler], stateblock->samplerState[sampler], gl_info); + stateblock->state.texture_states[sampler], stateblock->samplerState[sampler], gl_info); if (gl_info->supported[EXT_TEXTURE_LOD_BIAS]) { @@ -3610,7 +3612,7 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine checkGLcall("glTexEnvi(GL_TEXTURE_LOD_BIAS_EXT, ...)"); } - if (!use_ps(stateblock) && sampler < stateblock->lowest_disabled_stage) + if (!use_ps(stateblock) && sampler < stateblock->state.lowest_disabled_stage) { if (stateblock->state.render_states[WINED3DRS_COLORKEYENABLE] && !sampler) { @@ -3631,7 +3633,7 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine } else if (mapped_stage < gl_info->limits.textures) { - if (sampler < stateblock->lowest_disabled_stage) + if (sampler < stateblock->state.lowest_disabled_stage) { /* TODO: What should I do with pixel shaders here ??? */ if (stateblock->state.render_states[WINED3DRS_COLORKEYENABLE] && !sampler) diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 236c0678aed..c952697158d 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -827,10 +827,11 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface) DWORD stage = This->contained_tss_states[i].stage; DWORD state = This->contained_tss_states[i].state; - TRACE("Updating texturestage state %u, %u to %u (was %u).\n", stage, state, - targetStateBlock->textureState[stage][state], This->textureState[stage][state]); + TRACE("Updating texturestage state %u, %u to %#x (was %#x).\n", stage, state, + targetStateBlock->state.texture_states[stage][state], + This->state.texture_states[stage][state]); - This->textureState[stage][state] = targetStateBlock->textureState[stage][state]; + This->state.texture_states[stage][state] = targetStateBlock->state.texture_states[stage][state]; } /* Samplers */ @@ -951,7 +952,7 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Apply(IWineD3DStateBlock *iface) DWORD stage = This->contained_tss_states[i].stage; DWORD state = This->contained_tss_states[i].state; - IWineD3DDevice_SetTextureStageState(device, stage, state, This->textureState[stage][state]); + IWineD3DDevice_SetTextureStageState(device, stage, state, This->state.texture_states[stage][state]); } /* Sampler states */ @@ -1044,12 +1045,12 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Apply(IWineD3DStateBlock *iface) IWineD3DDevice_SetClipPlane(device, i, clip); } - This->device->stateBlock->lowest_disabled_stage = MAX_TEXTURES - 1; + This->device->stateBlock->state.lowest_disabled_stage = MAX_TEXTURES - 1; for (i = 0; i < MAX_TEXTURES - 1; ++i) { - if (This->device->stateBlock->textureState[i][WINED3DTSS_COLOROP] == WINED3DTOP_DISABLE) + if (This->device->stateBlock->state.texture_states[i][WINED3DTSS_COLOROP] == WINED3DTOP_DISABLE) { - This->device->stateBlock->lowest_disabled_stage = i; + This->device->stateBlock->state.lowest_disabled_stage = i; break; } } @@ -1231,27 +1232,27 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat /* Texture Stage States - Put directly into state block, we will call function below */ for (i = 0; i < MAX_TEXTURES; ++i) { - TRACE("Setting up default texture states for texture Stage %d\n", i); + TRACE("Setting up default texture states for texture Stage %u.\n", i); memcpy(&This->state.transforms[WINED3DTS_TEXTURE0 + i], identity, sizeof(identity)); - This->textureState[i][WINED3DTSS_COLOROP ] = i ? WINED3DTOP_DISABLE : WINED3DTOP_MODULATE; - This->textureState[i][WINED3DTSS_COLORARG1 ] = WINED3DTA_TEXTURE; - This->textureState[i][WINED3DTSS_COLORARG2 ] = WINED3DTA_CURRENT; - This->textureState[i][WINED3DTSS_ALPHAOP ] = i ? WINED3DTOP_DISABLE : WINED3DTOP_SELECTARG1; - This->textureState[i][WINED3DTSS_ALPHAARG1 ] = WINED3DTA_TEXTURE; - This->textureState[i][WINED3DTSS_ALPHAARG2 ] = WINED3DTA_CURRENT; - This->textureState[i][WINED3DTSS_BUMPENVMAT00 ] = 0; - This->textureState[i][WINED3DTSS_BUMPENVMAT01 ] = 0; - This->textureState[i][WINED3DTSS_BUMPENVMAT10 ] = 0; - This->textureState[i][WINED3DTSS_BUMPENVMAT11 ] = 0; - This->textureState[i][WINED3DTSS_TEXCOORDINDEX ] = i; - This->textureState[i][WINED3DTSS_BUMPENVLSCALE ] = 0; - This->textureState[i][WINED3DTSS_BUMPENVLOFFSET ] = 0; - This->textureState[i][WINED3DTSS_TEXTURETRANSFORMFLAGS ] = WINED3DTTFF_DISABLE; - This->textureState[i][WINED3DTSS_COLORARG0 ] = WINED3DTA_CURRENT; - This->textureState[i][WINED3DTSS_ALPHAARG0 ] = WINED3DTA_CURRENT; - This->textureState[i][WINED3DTSS_RESULTARG ] = WINED3DTA_CURRENT; + This->state.texture_states[i][WINED3DTSS_COLOROP] = i ? WINED3DTOP_DISABLE : WINED3DTOP_MODULATE; + This->state.texture_states[i][WINED3DTSS_COLORARG1] = WINED3DTA_TEXTURE; + This->state.texture_states[i][WINED3DTSS_COLORARG2] = WINED3DTA_CURRENT; + This->state.texture_states[i][WINED3DTSS_ALPHAOP] = i ? WINED3DTOP_DISABLE : WINED3DTOP_SELECTARG1; + This->state.texture_states[i][WINED3DTSS_ALPHAARG1] = WINED3DTA_TEXTURE; + This->state.texture_states[i][WINED3DTSS_ALPHAARG2] = WINED3DTA_CURRENT; + This->state.texture_states[i][WINED3DTSS_BUMPENVMAT00] = 0; + This->state.texture_states[i][WINED3DTSS_BUMPENVMAT01] = 0; + This->state.texture_states[i][WINED3DTSS_BUMPENVMAT10] = 0; + This->state.texture_states[i][WINED3DTSS_BUMPENVMAT11] = 0; + This->state.texture_states[i][WINED3DTSS_TEXCOORDINDEX] = i; + This->state.texture_states[i][WINED3DTSS_BUMPENVLSCALE] = 0; + This->state.texture_states[i][WINED3DTSS_BUMPENVLOFFSET] = 0; + This->state.texture_states[i][WINED3DTSS_TEXTURETRANSFORMFLAGS] = WINED3DTTFF_DISABLE; + This->state.texture_states[i][WINED3DTSS_COLORARG0] = WINED3DTA_CURRENT; + This->state.texture_states[i][WINED3DTSS_ALPHAARG0] = WINED3DTA_CURRENT; + This->state.texture_states[i][WINED3DTSS_RESULTARG] = WINED3DTA_CURRENT; } - This->lowest_disabled_stage = 1; + This->state.lowest_disabled_stage = 1; /* Sampler states*/ for (i = 0 ; i < MAX_COMBINED_SAMPLERS; i++) { diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 4d1acdb24d0..9c539bf4b44 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -2728,7 +2728,8 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting { IWineD3DBaseTextureImpl *texture; settings->op[i].padding = 0; - if(stateblock->textureState[i][WINED3DTSS_COLOROP] == WINED3DTOP_DISABLE) { + if (stateblock->state.texture_states[i][WINED3DTSS_COLOROP] == WINED3DTOP_DISABLE) + { settings->op[i].cop = WINED3DTOP_DISABLE; settings->op[i].aop = WINED3DTOP_DISABLE; settings->op[i].carg0 = settings->op[i].carg1 = settings->op[i].carg2 = ARG_UNUSED; @@ -2772,12 +2773,12 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting settings->op[i].tex_type = tex_1d; } - cop = stateblock->textureState[i][WINED3DTSS_COLOROP]; - aop = stateblock->textureState[i][WINED3DTSS_ALPHAOP]; + cop = stateblock->state.texture_states[i][WINED3DTSS_COLOROP]; + aop = stateblock->state.texture_states[i][WINED3DTSS_ALPHAOP]; - carg1 = (args[cop] & ARG1) ? stateblock->textureState[i][WINED3DTSS_COLORARG1] : ARG_UNUSED; - carg2 = (args[cop] & ARG2) ? stateblock->textureState[i][WINED3DTSS_COLORARG2] : ARG_UNUSED; - carg0 = (args[cop] & ARG0) ? stateblock->textureState[i][WINED3DTSS_COLORARG0] : ARG_UNUSED; + carg1 = (args[cop] & ARG1) ? stateblock->state.texture_states[i][WINED3DTSS_COLORARG1] : ARG_UNUSED; + carg2 = (args[cop] & ARG2) ? stateblock->state.texture_states[i][WINED3DTSS_COLORARG2] : ARG_UNUSED; + carg0 = (args[cop] & ARG0) ? stateblock->state.texture_states[i][WINED3DTSS_COLORARG0] : ARG_UNUSED; if(is_invalid_op(device, i, cop, carg1, carg2, carg0)) { carg0 = ARG_UNUSED; @@ -2794,10 +2795,12 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting aarg1 = carg1; aarg2 = carg2; aarg0 = carg0; - } else { - aarg1 = (args[aop] & ARG1) ? stateblock->textureState[i][WINED3DTSS_ALPHAARG1] : ARG_UNUSED; - aarg2 = (args[aop] & ARG2) ? stateblock->textureState[i][WINED3DTSS_ALPHAARG2] : ARG_UNUSED; - aarg0 = (args[aop] & ARG0) ? stateblock->textureState[i][WINED3DTSS_ALPHAARG0] : ARG_UNUSED; + } + else + { + aarg1 = (args[aop] & ARG1) ? stateblock->state.texture_states[i][WINED3DTSS_ALPHAARG1] : ARG_UNUSED; + aarg2 = (args[aop] & ARG2) ? stateblock->state.texture_states[i][WINED3DTSS_ALPHAARG2] : ARG_UNUSED; + aarg0 = (args[aop] & ARG0) ? stateblock->state.texture_states[i][WINED3DTSS_ALPHAARG0] : ARG_UNUSED; } if (!i && stateblock->textures[0] && stateblock->state.render_states[WINED3DRS_COLORKEYENABLE]) @@ -2845,10 +2848,12 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting aop = WINED3DTOP_SELECTARG1; } - if(carg1 == WINED3DTA_TEXTURE || carg2 == WINED3DTA_TEXTURE || carg0 == WINED3DTA_TEXTURE || - aarg1 == WINED3DTA_TEXTURE || aarg2 == WINED3DTA_TEXTURE || aarg0 == WINED3DTA_TEXTURE) { - ttff = stateblock->textureState[i][WINED3DTSS_TEXTURETRANSFORMFLAGS]; - if(ttff == (WINED3DTTFF_PROJECTED | WINED3DTTFF_COUNT3)) { + if (carg1 == WINED3DTA_TEXTURE || carg2 == WINED3DTA_TEXTURE || carg0 == WINED3DTA_TEXTURE + || aarg1 == WINED3DTA_TEXTURE || aarg2 == WINED3DTA_TEXTURE || aarg0 == WINED3DTA_TEXTURE) + { + ttff = stateblock->state.texture_states[i][WINED3DTSS_TEXTURETRANSFORMFLAGS]; + if (ttff == (WINED3DTTFF_PROJECTED | WINED3DTTFF_COUNT3)) + { settings->op[i].projected = proj_count3; } else if(ttff == (WINED3DTTFF_PROJECTED | WINED3DTTFF_COUNT4)) { settings->op[i].projected = proj_count4; @@ -2868,7 +2873,8 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting settings->op[i].aarg1 = aarg1; settings->op[i].aarg2 = aarg2; - if(stateblock->textureState[i][WINED3DTSS_RESULTARG] == WINED3DTA_TEMP) { + if (stateblock->state.texture_states[i][WINED3DTSS_RESULTARG] == WINED3DTA_TEMP) + { settings->op[i].dst = tempreg; } else { settings->op[i].dst = resultreg; @@ -3060,8 +3066,8 @@ void sampler_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine * will take care of this business */ if (mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= context->gl_info->limits.textures) return; - if(sampler >= stateblock->lowest_disabled_stage) return; - if(isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) return; + if (sampler >= stateblock->state.lowest_disabled_stage) return; + if (isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) return; texture_activate_dimensions(sampler, stateblock, context); } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index c11ed640a12..61c46535d2d 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2349,6 +2349,9 @@ struct wined3d_stream_state struct wined3d_state { + DWORD texture_states[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1]; + DWORD lowest_disabled_stage; + WINED3DMATRIX transforms[HIGHEST_TRANSFORMSTATE + 1]; WINED3DMATERIAL material; WINED3DVIEWPORT viewport; @@ -2415,9 +2418,6 @@ struct IWineD3DStateBlockImpl /* Texture */ IWineD3DBaseTexture *textures[MAX_COMBINED_SAMPLERS]; - /* Texture State Stage */ - DWORD textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1]; - DWORD lowest_disabled_stage; /* Sampler States */ DWORD samplerState[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];