wined3d: Move texture bindings to wined3d_state.

oldstable
Henri Verbeet 2010-09-17 11:59:40 +02:00 committed by Alexandre Julliard
parent 5a3a4ac77a
commit d728d5f0ec
10 changed files with 77 additions and 78 deletions

View File

@ -503,8 +503,8 @@ static void shader_arb_load_np2fixup_constants(
for (i = 0; active; active >>= 1, ++i) {
const unsigned char idx = fixup->super.idx[i];
const IWineD3DTextureImpl* const tex = (const IWineD3DTextureImpl*) stateBlock->textures[i];
GLfloat* tex_dim = &np2fixup_constants[(idx >> 1) * 4];
const IWineD3DBaseTextureImpl *tex = stateBlock->state.textures[i];
GLfloat *tex_dim = &np2fixup_constants[(idx >> 1) * 4];
if (!(active & 1)) continue;
@ -1326,6 +1326,7 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
{
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
DWORD sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx];
IWineD3DBaseTextureImpl *texture;
const char *tex_type;
BOOL np2_fixup = FALSE;
IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
@ -1343,9 +1344,8 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
break;
case WINED3DSTT_2D:
if (device->stateBlock->textures[sampler_idx]
&& ((IWineD3DBaseTextureImpl *)device->stateBlock->textures[sampler_idx])->baseTexture.target
== GL_TEXTURE_RECTANGLE_ARB)
texture = device->stateBlock->state.textures[sampler_idx];
if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
{
tex_type = "RECT";
} else {
@ -4229,6 +4229,7 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, struct
/* GL locking is done by the caller */
static struct arb_ps_compiled_shader *find_arb_pshader(IWineD3DPixelShaderImpl *shader, const struct arb_ps_compile_args *args)
{
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)shader->baseShader.device;
UINT i;
DWORD new_size;
struct arb_ps_compiled_shader *new_array;
@ -4238,7 +4239,6 @@ static struct arb_ps_compiled_shader *find_arb_pshader(IWineD3DPixelShaderImpl *
if (!shader->baseShader.backend_data)
{
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) shader->baseShader.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct shader_arb_priv *priv = device->shader_priv;
@ -4293,7 +4293,7 @@ static struct arb_ps_compiled_shader *find_arb_pshader(IWineD3DPixelShaderImpl *
shader_data->gl_shaders[shader_data->num_gl_shaders].args = *args;
pixelshader_update_samplers(&shader->baseShader.reg_maps,
((IWineD3DDeviceImpl *)shader->baseShader.device)->stateBlock->textures);
(IWineD3DBaseTexture **)device->stateBlock->state.textures);
if (!shader_buffer_init(&buffer))
{

View File

@ -458,7 +458,7 @@ static void device_preload_texture(IWineD3DStateBlockImpl *stateblock, unsigned
IWineD3DBaseTextureImpl *texture;
enum WINED3DSRGB srgb;
if (!(texture = (IWineD3DBaseTextureImpl *)stateblock->textures[idx])) return;
if (!(texture = stateblock->state.textures[idx])) return;
srgb = stateblock->state.sampler_states[idx][WINED3DSAMP_SRGBTEXTURE] ? SRGB_SRGB : SRGB_RGB;
texture->baseTexture.internal_preload((IWineD3DBaseTexture *)texture, srgb);
}
@ -4319,7 +4319,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface,
stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
/* Windows accepts overflowing this array... we do not. */
if (stage >= sizeof(This->stateBlock->textures) / sizeof(*This->stateBlock->textures))
if (stage >= sizeof(This->stateBlock->state.textures) / sizeof(*This->stateBlock->state.textures))
{
WARN("Ignoring invalid stage %u.\n", stage);
return WINED3D_OK;
@ -4334,7 +4334,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface,
This->updateStateBlock->changed.textures |= 1 << stage;
prev = This->updateStateBlock->textures[stage];
prev = (IWineD3DBaseTexture *)This->updateStateBlock->state.textures[stage];
TRACE("Previous texture %p.\n", prev);
if (texture == prev)
@ -4344,7 +4344,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface,
}
TRACE("Setting new texture to %p.\n", texture);
This->updateStateBlock->textures[stage] = texture;
This->updateStateBlock->state.textures[stage] = (IWineD3DBaseTextureImpl *)texture;
if (This->isRecordingState)
{
@ -4401,7 +4401,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface,
TRACE("Searching for other stages the texture is bound to.\n");
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
{
if (This->updateStateBlock->textures[i] == prev)
if (This->updateStateBlock->state.textures[i] == t)
{
TRACE("Texture is also bound to stage %u.\n", i);
t->baseTexture.sampler = i;
@ -4425,12 +4425,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetTexture(IWineD3DDevice *iface, DWORD
Stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
}
if (Stage >= sizeof(This->stateBlock->textures)/sizeof(This->stateBlock->textures[0])) {
if (Stage >= sizeof(This->stateBlock->state.textures) / sizeof(*This->stateBlock->state.textures))
{
ERR("Current stage overflows textures array (stage %d)\n", Stage);
return WINED3D_OK; /* Windows accepts overflowing this array ... we do not. */
}
*ppTexture=This->stateBlock->textures[Stage];
*ppTexture = (IWineD3DBaseTexture *)This->stateBlock->state.textures[Stage];
if (*ppTexture)
IWineD3DBaseTexture_AddRef(*ppTexture);
@ -5068,7 +5069,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ValidateDevice(IWineD3DDevice *iface,
return WINED3DERR_UNSUPPORTEDTEXTUREFILTER;
}
texture = (IWineD3DBaseTextureImpl *) This->stateBlock->textures[i];
texture = This->stateBlock->state.textures[i];
if (!texture || texture->resource.format->Flags & WINED3DFMT_FLAG_FILTERING) continue;
if (This->stateBlock->state.sampler_states[i][WINED3DSAMP_MAGFILTER] != WINED3DTEXF_POINT)
@ -5102,7 +5103,7 @@ static void dirtify_p8_texture_samplers(IWineD3DDeviceImpl *device)
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl*)device->stateBlock->textures[i];
IWineD3DBaseTextureImpl *texture = device->stateBlock->state.textures[i];
if (texture && (texture->resource.format->id == WINED3DFMT_P8_UINT
|| texture->resource.format->id == WINED3DFMT_P8_UINT_A8_UNORM))
{
@ -6593,19 +6594,19 @@ void device_resource_released(IWineD3DDeviceImpl *device, IWineD3DResource *reso
case WINED3DRTYPE_VOLUMETEXTURE:
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
{
if (device->stateBlock && device->stateBlock->textures[i] == (IWineD3DBaseTexture *)resource)
if (device->stateBlock && device->stateBlock->state.textures[i] == (IWineD3DBaseTextureImpl *)resource)
{
ERR("Texture %p is still in use by stateblock %p, stage %u.\n",
resource, device->stateBlock, i);
device->stateBlock->textures[i] = NULL;
device->stateBlock->state.textures[i] = NULL;
}
if (device->updateStateBlock != device->stateBlock
&& device->updateStateBlock->textures[i] == (IWineD3DBaseTexture *)resource)
&& device->updateStateBlock->state.textures[i] == (IWineD3DBaseTextureImpl *)resource)
{
ERR("Texture %p is still in use by stateblock %p, stage %u.\n",
resource, device->updateStateBlock, i);
device->updateStateBlock->textures[i] = NULL;
device->updateStateBlock->state.textures[i] = NULL;
}
}
break;

View File

@ -178,7 +178,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context
continue;
}
if (!pixelShader && !This->stateBlock->textures[textureNo]) continue;
if (!pixelShader && !This->stateBlock->state.textures[textureNo]) continue;
if (texture_idx == WINED3D_UNMAPPED_STAGE) continue;

View File

@ -708,8 +708,8 @@ static void shader_glsl_load_np2fixup_constants(
for (i = 0; fixup; fixup >>= 1, ++i) {
const unsigned char idx = prog->np2Fixup_info->idx[i];
const IWineD3DBaseTextureImpl* const tex = (const IWineD3DBaseTextureImpl*) stateBlock->textures[i];
GLfloat* tex_dim = &np2fixup_constants[(idx >> 1) * 4];
const IWineD3DBaseTextureImpl *tex = stateBlock->state.textures[i];
GLfloat *tex_dim = &np2fixup_constants[(idx >> 1) * 4];
if (!tex)
{
@ -1050,6 +1050,8 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
for (i = 0; i < This->baseShader.limits.sampler; i++) {
if (reg_maps->sampler_type[i])
{
IWineD3DBaseTextureImpl *texture;
switch (reg_maps->sampler_type[i])
{
case WINED3DSTT_1D:
@ -1059,20 +1061,17 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
shader_addline(buffer, "uniform sampler1D %csampler%u;\n", prefix, i);
break;
case WINED3DSTT_2D:
texture = device->stateBlock->state.textures[i];
if (pshader && ps_args->shadow & (1 << i))
{
if (device->stateBlock->textures[i]
&& ((IWineD3DBaseTextureImpl *)device->stateBlock->textures[i])->baseTexture.target
== GL_TEXTURE_RECTANGLE_ARB)
if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
shader_addline(buffer, "uniform sampler2DRectShadow %csampler%u;\n", prefix, i);
else
shader_addline(buffer, "uniform sampler2DShadow %csampler%u;\n", prefix, i);
}
else
{
if (device->stateBlock->textures[i]
&& ((IWineD3DBaseTextureImpl *)device->stateBlock->textures[i])->baseTexture.target
== GL_TEXTURE_RECTANGLE_ARB)
if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
shader_addline(buffer, "uniform sampler2DRect %csampler%u;\n", prefix, i);
else
shader_addline(buffer, "uniform sampler2D %csampler%u;\n", prefix, i);
@ -3017,6 +3016,7 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
DWORD shader_version = WINED3D_SHADER_VERSION(ins->ctx->reg_maps->shader_version.major,
ins->ctx->reg_maps->shader_version.minor);
glsl_sample_function_t sample_function;
IWineD3DBaseTextureImpl *texture;
DWORD sample_flags = 0;
DWORD sampler_idx;
DWORD mask = 0, swizzle;
@ -3025,6 +3025,7 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
* 2.0+: Use provided sampler source. */
if (shader_version < WINED3D_SHADER_VERSION(2,0)) sampler_idx = ins->dst[0].reg.idx;
else sampler_idx = ins->src[1].reg.idx;
texture = deviceImpl->stateBlock->state.textures[sampler_idx];
if (shader_version < WINED3D_SHADER_VERSION(1,4))
{
@ -3063,12 +3064,8 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
}
}
if (deviceImpl->stateBlock->textures[sampler_idx]
&& ((IWineD3DBaseTextureImpl *)deviceImpl->stateBlock->textures[sampler_idx])->baseTexture.target
== GL_TEXTURE_RECTANGLE_ARB)
{
if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
sample_flags |= WINED3D_GLSL_SAMPLE_RECT;
}
shader_glsl_get_sample_function(ins->ctx, sampler_idx, sample_flags, &sample_function);
mask |= sample_function.coord_mask;
@ -3110,6 +3107,7 @@ static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins)
DWORD sample_flags = WINED3D_GLSL_SAMPLE_GRAD;
DWORD sampler_idx;
DWORD swizzle = ins->src[1].swizzle;
IWineD3DBaseTextureImpl *texture;
if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD] && !gl_info->supported[EXT_GPU_SHADER4])
{
@ -3119,9 +3117,8 @@ static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins)
}
sampler_idx = ins->src[1].reg.idx;
if (deviceImpl->stateBlock->textures[sampler_idx]
&& ((IWineD3DBaseTextureImpl *)deviceImpl->stateBlock->textures[sampler_idx])->baseTexture.target
== GL_TEXTURE_RECTANGLE_ARB)
texture = deviceImpl->stateBlock->state.textures[sampler_idx];
if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
sample_flags |= WINED3D_GLSL_SAMPLE_RECT;
shader_glsl_get_sample_function(ins->ctx, sampler_idx, sample_flags, &sample_function);
@ -3143,11 +3140,11 @@ static void shader_glsl_texldl(const struct wined3d_shader_instruction *ins)
DWORD sample_flags = WINED3D_GLSL_SAMPLE_LOD;
DWORD sampler_idx;
DWORD swizzle = ins->src[1].swizzle;
IWineD3DBaseTextureImpl *texture;
sampler_idx = ins->src[1].reg.idx;
if (deviceImpl->stateBlock->textures[sampler_idx]
&& ((IWineD3DBaseTextureImpl *)deviceImpl->stateBlock->textures[sampler_idx])->baseTexture.target
== GL_TEXTURE_RECTANGLE_ARB)
texture = deviceImpl->stateBlock->state.textures[sampler_idx];
if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
sample_flags |= WINED3D_GLSL_SAMPLE_RECT;
shader_glsl_get_sample_function(ins->ctx, sampler_idx, sample_flags, &sample_function);
@ -4131,6 +4128,7 @@ static GLhandleARB find_glsl_pshader(const struct wined3d_context *context,
struct wined3d_shader_buffer *buffer, IWineD3DPixelShaderImpl *shader,
const struct ps_compile_args *args, const struct ps_np2fixup_info **np2fixup_info)
{
struct wined3d_state *state = &((IWineD3DDeviceImpl *)shader->baseShader.device)->stateBlock->state;
UINT i;
DWORD new_size;
struct glsl_ps_compiled_shader *new_array;
@ -4187,8 +4185,7 @@ static GLhandleARB find_glsl_pshader(const struct wined3d_context *context,
memset(&shader_data->gl_shaders[shader_data->num_gl_shaders].np2fixup, 0, sizeof(struct ps_np2fixup_info));
if (args->np2_fixup) np2fixup = &shader_data->gl_shaders[shader_data->num_gl_shaders].np2fixup;
pixelshader_update_samplers(&shader->baseShader.reg_maps,
((IWineD3DDeviceImpl *)shader->baseShader.device)->stateBlock->textures);
pixelshader_update_samplers(&shader->baseShader.reg_maps, (IWineD3DBaseTexture **)state->textures);
shader_buffer_clear(buffer);
ret = shader_glsl_generate_pshader(context, buffer, shader, args, np2fixup);

View File

@ -43,9 +43,9 @@ static void nvts_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateb
context->texShaderBumpMap &= ~(1 << stage);
}
if (stateblock->textures[stage])
if (stateblock->state.textures[stage])
{
switch (((IWineD3DBaseTextureImpl *)stateblock->textures[stage])->baseTexture.target)
switch (stateblock->state.textures[stage]->baseTexture.target)
{
case GL_TEXTURE_2D:
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, bumpmap ? GL_OFFSET_TEXTURE_2D_NV : GL_TEXTURE_2D);

View File

@ -2086,7 +2086,7 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader,
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
{
if (!shader->baseShader.reg_maps.sampler_type[i]) continue;
texture = (IWineD3DBaseTextureImpl *)stateblock->textures[i];
texture = stateblock->state.textures[i];
if (!texture)
{
args->color_fixup[i] = COLOR_FIXUP_IDENTITY;

View File

@ -496,13 +496,13 @@ static void state_alpha(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
* used WINED3DRS_COLORKEYENABLE state(which is d3d <= 3 only). The texture function will call alpha
* in case it finds some texture+colorkeyenable combination which needs extra care.
*/
if (stateblock->textures[0])
if (stateblock->state.textures[0])
{
GLenum texture_dimensions = ((IWineD3DBaseTextureImpl *)stateblock->textures[0])->baseTexture.target;
IWineD3DBaseTextureImpl *texture = stateblock->state.textures[0];
GLenum texture_dimensions = texture->baseTexture.target;
if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB)
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)stateblock->textures[0];
IWineD3DSurfaceImpl *surf = (IWineD3DSurfaceImpl *)texture->baseTexture.sub_resources[0];
if (surf->CKeyFlags & WINEDDSD_CKSRCBLT)
@ -2111,7 +2111,7 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if
op = WINED3DTOP_SELECTARG1;
}
if (isAlpha && !This->stateBlock->textures[Stage] && arg1 == WINED3DTA_TEXTURE)
if (isAlpha && !This->stateBlock->state.textures[Stage] && arg1 == WINED3DTA_TEXTURE)
{
get_src_and_opr(WINED3DTA_DIFFUSE, isAlpha, &src1, &opr1);
} else {
@ -3184,9 +3184,9 @@ void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d
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])
if (stateblock->state.render_states[WINED3DRS_COLORKEYENABLE] && !stage && stateblock->state.textures[0])
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)stateblock->textures[0];
IWineD3DBaseTextureImpl *texture = stateblock->state.textures[0];
GLenum texture_dimensions = texture->baseTexture.target;
if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB)
@ -3292,7 +3292,7 @@ static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock, s
stateblock->device->frag_pipe->ffp_proj_control);
/* The sampler applying function calls us if this changes */
if ((context->lastWasPow2Texture & (1 << texUnit)) && stateblock->textures[texUnit])
if ((context->lastWasPow2Texture & (1 << texUnit)) && stateblock->state.textures[texUnit])
{
if(generated) {
FIXME("Non-power2 texture being used with generated texture coords\n");
@ -3301,7 +3301,7 @@ static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock, s
fixed-function-pipeline fixup via pow2Matrix when no PS is used. */
if (!use_ps(stateblock)) {
TRACE("Non power two matrix multiply fixup\n");
glMultMatrixf(((IWineD3DTextureImpl *) stateblock->textures[texUnit])->baseTexture.pow2Matrix);
glMultMatrixf(stateblock->state.textures[texUnit]->baseTexture.pow2Matrix);
}
}
}
@ -3579,7 +3579,7 @@ static void tex_bumpenvlscale(DWORD state, IWineD3DStateBlockImpl *stateblock, s
static void sampler_texmatrix(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
const DWORD sampler = state - STATE_SAMPLER(0);
IWineD3DBaseTexture *texture = stateblock->textures[sampler];
IWineD3DBaseTextureImpl *texture = stateblock->state.textures[sampler];
TRACE("state %#x, stateblock %p, context %p\n", state, stateblock, context);
@ -3592,7 +3592,7 @@ static void sampler_texmatrix(DWORD state, IWineD3DStateBlockImpl *stateblock, s
* misc pipeline
*/
if(sampler < MAX_TEXTURES) {
const BOOL texIsPow2 = !((IWineD3DBaseTextureImpl *)texture)->baseTexture.pow2Matrix_identity;
const BOOL texIsPow2 = !texture->baseTexture.pow2Matrix_identity;
if (texIsPow2 || (context->lastWasPow2Texture & (1 << sampler)))
{
@ -3632,12 +3632,13 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB");
if (stateblock->textures[sampler])
if (stateblock->state.textures[sampler])
{
IWineD3DBaseTexture *texture = (IWineD3DBaseTexture *)stateblock->state.textures[sampler];
BOOL srgb = stateblock->state.sampler_states[sampler][WINED3DSAMP_SRGBTEXTURE];
IWineD3DBaseTextureImpl *tex_impl = (IWineD3DBaseTextureImpl *) stateblock->textures[sampler];
IWineD3DBaseTexture_BindTexture(stateblock->textures[sampler], srgb);
basetexture_apply_state_changes(stateblock->textures[sampler],
IWineD3DBaseTexture_BindTexture(texture, srgb);
basetexture_apply_state_changes(texture,
stateblock->state.texture_states[sampler],
stateblock->state.sampler_states[sampler], gl_info);
@ -3662,7 +3663,7 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine
}
/* Trigger shader constant reloading (for NP2 texcoord fixup) */
if (!tex_impl->baseTexture.pow2Matrix_identity)
if (!stateblock->state.textures[sampler]->baseTexture.pow2Matrix_identity)
{
IWineD3DDeviceImpl *d3ddevice = stateblock->device;
d3ddevice->shader_backend->shader_load_np2fixup_constants(

View File

@ -496,7 +496,8 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
for (counter = 0; counter < MAX_COMBINED_SAMPLERS; counter++)
{
if (This->textures[counter]) IWineD3DBaseTexture_Release(This->textures[counter]);
if (This->state.textures[counter])
IWineD3DBaseTexture_Release((IWineD3DBaseTexture *)This->state.textures[counter]);
}
for (counter = 0; counter < MAX_STREAMS; ++counter)
@ -840,11 +841,14 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
{
if (!(map & 1)) continue;
TRACE("Updating texture %u to %p (was %p).\n", i, targetStateBlock->textures[i], This->textures[i]);
TRACE("Updating texture %u to %p (was %p).\n",
i, targetStateBlock->state.textures[i], This->state.textures[i]);
if (targetStateBlock->textures[i]) IWineD3DBaseTexture_AddRef(targetStateBlock->textures[i]);
if (This->textures[i]) IWineD3DBaseTexture_Release(This->textures[i]);
This->textures[i] = targetStateBlock->textures[i];
if (targetStateBlock->state.textures[i])
IWineD3DBaseTexture_AddRef((IWineD3DBaseTexture *)targetStateBlock->state.textures[i]);
if (This->state.textures[i])
IWineD3DBaseTexture_Release((IWineD3DBaseTexture *)This->state.textures[i]);
This->state.textures[i] = targetStateBlock->state.textures[i];
}
for (i = 0; i < This->num_contained_sampler_states; ++i)
@ -1029,7 +1033,7 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Apply(IWineD3DStateBlock *iface)
if (!(map & 1)) continue;
stage = i < MAX_FRAGMENT_SAMPLERS ? i : WINED3DVERTEXTEXTURESAMPLER0 + i - MAX_FRAGMENT_SAMPLERS;
IWineD3DDevice_SetTexture(device, stage, This->textures[i]);
IWineD3DDevice_SetTexture(device, stage, (IWineD3DBaseTexture *)This->state.textures[i]);
}
map = This->changed.clipplane;
@ -1280,7 +1284,7 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat
{
/* Note: This avoids calling SetTexture, so pretend it has been called */
This->changed.textures |= 1 << i;
This->textures[i] = NULL;
This->state.textures[i] = NULL;
}
/* check the return values, because the GetBackBuffer call isn't valid for ddraw */

View File

@ -2368,7 +2368,7 @@ GLenum CompareFunc(DWORD func) {
BOOL is_invalid_op(IWineD3DDeviceImpl *This, int stage, WINED3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3) {
if (op == WINED3DTOP_DISABLE) return FALSE;
if (This->stateBlock->textures[stage]) return FALSE;
if (This->stateBlock->state.textures[stage]) return FALSE;
if ((arg1 & WINED3DTA_SELECTMASK) == WINED3DTA_TEXTURE
&& op != WINED3DTOP_SELECTARG2) return TRUE;
@ -2745,8 +2745,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
break;
}
texture = (IWineD3DBaseTextureImpl *) stateblock->textures[i];
if (texture)
if ((texture = stateblock->state.textures[i]))
{
settings->op[i].color_fixup = texture->resource.format->color_fixup;
if (ignore_textype)
@ -2809,9 +2808,9 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
aarg0 = (args[aop] & ARG0) ? stateblock->state.texture_states[i][WINED3DTSS_ALPHAARG0] : ARG_UNUSED;
}
if (!i && stateblock->textures[0] && stateblock->state.render_states[WINED3DRS_COLORKEYENABLE])
if (!i && stateblock->state.textures[0] && stateblock->state.render_states[WINED3DRS_COLORKEYENABLE])
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)stateblock->textures[0];
IWineD3DBaseTextureImpl *texture = stateblock->state.textures[0];
GLenum texture_dimensions = texture->baseTexture.target;
if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB)
@ -2980,9 +2979,9 @@ void texture_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock
{
const struct wined3d_gl_info *gl_info = context->gl_info;
if (stateblock->textures[stage])
if (stateblock->state.textures[stage])
{
switch (((IWineD3DBaseTextureImpl *)stateblock->textures[stage])->baseTexture.target)
switch (stateblock->state.textures[stage]->baseTexture.target)
{
case GL_TEXTURE_2D:
glDisable(GL_TEXTURE_3D);

View File

@ -2349,7 +2349,7 @@ struct wined3d_stream_state
struct wined3d_state
{
/* Sampler States */
IWineD3DBaseTextureImpl *textures[MAX_COMBINED_SAMPLERS];
DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
DWORD texture_states[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
DWORD lowest_disabled_stage;
@ -2417,9 +2417,6 @@ struct IWineD3DStateBlockImpl
INT pixelShaderConstantI[MAX_CONST_I * 4];
float *pixelShaderConstantF;
/* Texture */
IWineD3DBaseTexture *textures[MAX_COMBINED_SAMPLERS];
/* Contained state management */
DWORD contained_render_states[WINEHIGHEST_RENDER_STATE + 1];
unsigned int num_contained_render_states;