diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 814f06074d6..54f37af00b4 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -459,7 +459,7 @@ static void device_preload_texture(IWineD3DStateBlockImpl *stateblock, unsigned enum WINED3DSRGB srgb; if (!(texture = (IWineD3DBaseTextureImpl *)stateblock->textures[idx])) return; - srgb = stateblock->samplerState[idx][WINED3DSAMP_SRGBTEXTURE] ? SRGB_SRGB : SRGB_RGB; + srgb = stateblock->state.sampler_states[idx][WINED3DSAMP_SRGBTEXTURE] ? SRGB_SRGB : SRGB_RGB; texture->baseTexture.internal_preload((IWineD3DBaseTexture *)texture, srgb); } @@ -3086,27 +3086,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetSamplerState(IWineD3DDevice *iface, Sampler -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS); } - if (Sampler >= sizeof(This->stateBlock->samplerState)/sizeof(This->stateBlock->samplerState[0])) { + if (Sampler >= sizeof(This->stateBlock->state.sampler_states) / sizeof(*This->stateBlock->state.sampler_states)) + { ERR("Current Sampler overflows sampleState0 array (sampler %d)\n", Sampler); return WINED3D_OK; /* Windows accepts overflowing this array ... we do not. */ } - /** - * SetSampler is designed to allow for more than the standard up to 8 textures - * and Geforce has stopped supporting more than 6 standard textures in openGL. - * So I have to use ARB for Gforce. (maybe if the sampler > 4 then use ARB?) - * - * http://developer.nvidia.com/object/General_FAQ.html#t6 - * - * There are two new settings for GForce - * the sampler one: - * GL_MAX_TEXTURE_IMAGE_UNITS_ARB - * and the texture one: - * GL_MAX_TEXTURE_COORDS_ARB. - * Ok GForce say it's ok to use glTexParameter/glGetTexParameter(...). - ******************/ - oldValue = This->stateBlock->samplerState[Sampler][Type]; - This->updateStateBlock->samplerState[Sampler][Type] = Value; + oldValue = This->stateBlock->state.sampler_states[Sampler][Type]; + This->updateStateBlock->state.sampler_states[Sampler][Type] = Value; This->updateStateBlock->changed.samplerState[Sampler] |= 1 << Type; /* Handle recording of state blocks */ @@ -3135,11 +3122,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetSamplerState(IWineD3DDevice *iface, Sampler -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS); } - if (Sampler >= sizeof(This->stateBlock->samplerState)/sizeof(This->stateBlock->samplerState[0])) { + if (Sampler >= sizeof(This->stateBlock->state.sampler_states) / sizeof(*This->stateBlock->state.sampler_states)) + { ERR("Current Sampler overflows sampleState0 array (sampler %d)\n", Sampler); return WINED3D_OK; /* Windows accepts overflowing this array ... we do not. */ } - *Value = This->stateBlock->samplerState[Sampler][Type]; + *Value = This->stateBlock->state.sampler_states[Sampler][Type]; TRACE("(%p) : Returning %#x\n", This, *Value); return WINED3D_OK; @@ -5069,12 +5057,15 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ValidateDevice(IWineD3DDevice *iface, TRACE("(%p) : %p\n", This, pNumPasses); - for(i = 0; i < MAX_COMBINED_SAMPLERS; i++) { - if(This->stateBlock->samplerState[i][WINED3DSAMP_MINFILTER] == WINED3DTEXF_NONE) { + for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) + { + if (This->stateBlock->state.sampler_states[i][WINED3DSAMP_MINFILTER] == WINED3DTEXF_NONE) + { WARN("Sampler state %u has minfilter D3DTEXF_NONE, returning D3DERR_UNSUPPORTEDTEXTUREFILTER\n", i); return WINED3DERR_UNSUPPORTEDTEXTUREFILTER; } - if(This->stateBlock->samplerState[i][WINED3DSAMP_MAGFILTER] == WINED3DTEXF_NONE) { + if (This->stateBlock->state.sampler_states[i][WINED3DSAMP_MAGFILTER] == WINED3DTEXF_NONE) + { WARN("Sampler state %u has magfilter D3DTEXF_NONE, returning D3DERR_UNSUPPORTEDTEXTUREFILTER\n", i); return WINED3DERR_UNSUPPORTEDTEXTUREFILTER; } @@ -5082,16 +5073,19 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ValidateDevice(IWineD3DDevice *iface, texture = (IWineD3DBaseTextureImpl *) This->stateBlock->textures[i]; if (!texture || texture->resource.format->Flags & WINED3DFMT_FLAG_FILTERING) continue; - if(This->stateBlock->samplerState[i][WINED3DSAMP_MAGFILTER] != WINED3DTEXF_POINT) { + if (This->stateBlock->state.sampler_states[i][WINED3DSAMP_MAGFILTER] != WINED3DTEXF_POINT) + { WARN("Non-filterable texture and mag filter enabled on samper %u, returning E_FAIL\n", i); return E_FAIL; } - if(This->stateBlock->samplerState[i][WINED3DSAMP_MINFILTER] != WINED3DTEXF_POINT) { + if (This->stateBlock->state.sampler_states[i][WINED3DSAMP_MINFILTER] != WINED3DTEXF_POINT) + { WARN("Non-filterable texture and min filter enabled on samper %u, returning E_FAIL\n", i); return E_FAIL; } - if(This->stateBlock->samplerState[i][WINED3DSAMP_MIPFILTER] != WINED3DTEXF_NONE && - This->stateBlock->samplerState[i][WINED3DSAMP_MIPFILTER] != WINED3DTEXF_POINT /* sic! */) { + if (This->stateBlock->state.sampler_states[i][WINED3DSAMP_MIPFILTER] != WINED3DTEXF_NONE + && This->stateBlock->state.sampler_states[i][WINED3DSAMP_MIPFILTER] != WINED3DTEXF_POINT) + { WARN("Non-filterable texture and mip filter enabled on samper %u, returning E_FAIL\n", i); return E_FAIL; } diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 36e605dae64..5d0d1dfac34 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -3596,16 +3596,18 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage)); checkGLcall("glActiveTextureARB"); - if(stateblock->textures[sampler]) { - BOOL srgb = stateblock->samplerState[sampler][WINED3DSAMP_SRGBTEXTURE]; + if (stateblock->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], - stateblock->state.texture_states[sampler], stateblock->samplerState[sampler], gl_info); + stateblock->state.texture_states[sampler], + stateblock->state.sampler_states[sampler], gl_info); if (gl_info->supported[EXT_TEXTURE_LOD_BIAS]) { - tmpvalue.d = stateblock->samplerState[sampler][WINED3DSAMP_MIPMAPLODBIAS]; + tmpvalue.d = stateblock->state.sampler_states[sampler][WINED3DSAMP_MIPMAPLODBIAS]; glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, tmpvalue.f); diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index c952697158d..41fca5a5b82 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -852,10 +852,11 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface) DWORD stage = This->contained_sampler_states[i].stage; DWORD state = This->contained_sampler_states[i].state; - TRACE("Updating sampler state %u, %u to %u (was %u).\n", stage, state, - targetStateBlock->samplerState[stage][state], This->samplerState[stage][state]); + TRACE("Updating sampler state %u, %u to %#x (was %#x).\n", stage, state, + targetStateBlock->state.sampler_states[stage][state], + This->state.sampler_states[stage][state]); - This->samplerState[stage][state] = targetStateBlock->samplerState[stage][state]; + This->state.sampler_states[stage][state] = targetStateBlock->state.sampler_states[stage][state]; } if (This->changed.pixelShader && This->pixelShader != targetStateBlock->pixelShader) @@ -960,7 +961,7 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Apply(IWineD3DStateBlock *iface) { DWORD stage = This->contained_sampler_states[i].stage; DWORD state = This->contained_sampler_states[i].state; - DWORD value = This->samplerState[stage][state]; + DWORD value = This->state.sampler_states[stage][state]; if (stage >= MAX_FRAGMENT_SAMPLERS) stage += WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS; IWineD3DDevice_SetSamplerState(device, stage, state, value); @@ -1255,21 +1256,24 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat This->state.lowest_disabled_stage = 1; /* Sampler states*/ - for (i = 0 ; i < MAX_COMBINED_SAMPLERS; i++) { - TRACE("Setting up default samplers states for sampler %d\n", i); - This->samplerState[i][WINED3DSAMP_ADDRESSU ] = WINED3DTADDRESS_WRAP; - This->samplerState[i][WINED3DSAMP_ADDRESSV ] = WINED3DTADDRESS_WRAP; - This->samplerState[i][WINED3DSAMP_ADDRESSW ] = WINED3DTADDRESS_WRAP; - This->samplerState[i][WINED3DSAMP_BORDERCOLOR ] = 0x00; - This->samplerState[i][WINED3DSAMP_MAGFILTER ] = WINED3DTEXF_POINT; - This->samplerState[i][WINED3DSAMP_MINFILTER ] = WINED3DTEXF_POINT; - This->samplerState[i][WINED3DSAMP_MIPFILTER ] = WINED3DTEXF_NONE; - This->samplerState[i][WINED3DSAMP_MIPMAPLODBIAS ] = 0; - This->samplerState[i][WINED3DSAMP_MAXMIPLEVEL ] = 0; - This->samplerState[i][WINED3DSAMP_MAXANISOTROPY ] = 1; - This->samplerState[i][WINED3DSAMP_SRGBTEXTURE ] = 0; - This->samplerState[i][WINED3DSAMP_ELEMENTINDEX ] = 0; /* TODO: Indicates which element of a multielement texture to use */ - This->samplerState[i][WINED3DSAMP_DMAPOFFSET ] = 0; /* TODO: Vertex offset in the presampled displacement map */ + for (i = 0 ; i < MAX_COMBINED_SAMPLERS; ++i) + { + TRACE("Setting up default samplers states for sampler %u.\n", i); + This->state.sampler_states[i][WINED3DSAMP_ADDRESSU] = WINED3DTADDRESS_WRAP; + This->state.sampler_states[i][WINED3DSAMP_ADDRESSV] = WINED3DTADDRESS_WRAP; + This->state.sampler_states[i][WINED3DSAMP_ADDRESSW] = WINED3DTADDRESS_WRAP; + This->state.sampler_states[i][WINED3DSAMP_BORDERCOLOR] = 0; + This->state.sampler_states[i][WINED3DSAMP_MAGFILTER] = WINED3DTEXF_POINT; + This->state.sampler_states[i][WINED3DSAMP_MINFILTER] = WINED3DTEXF_POINT; + This->state.sampler_states[i][WINED3DSAMP_MIPFILTER] = WINED3DTEXF_NONE; + This->state.sampler_states[i][WINED3DSAMP_MIPMAPLODBIAS] = 0; + This->state.sampler_states[i][WINED3DSAMP_MAXMIPLEVEL] = 0; + This->state.sampler_states[i][WINED3DSAMP_MAXANISOTROPY] = 1; + This->state.sampler_states[i][WINED3DSAMP_SRGBTEXTURE] = 0; + /* TODO: Indicates which element of a multielement texture to use. */ + This->state.sampler_states[i][WINED3DSAMP_ELEMENTINDEX] = 0; + /* TODO: Vertex offset in the presampled displacement map. */ + This->state.sampler_states[i][WINED3DSAMP_DMAPOFFSET] = 0; } for (i = 0; i < gl_info->limits.textures; ++i) diff --git a/dlls/wined3d/volumetexture.c b/dlls/wined3d/volumetexture.c index 2e9fec9c819..a69ff68cff5 100644 --- a/dlls/wined3d/volumetexture.c +++ b/dlls/wined3d/volumetexture.c @@ -43,7 +43,7 @@ static void volumetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINE if (!device->isInDraw) context = context_acquire(device, NULL); else if (gl_info->supported[EXT_TEXTURE_SRGB] && This->baseTexture.bindCount > 0) { - srgb_mode = device->stateBlock->samplerState[This->baseTexture.sampler][WINED3DSAMP_SRGBTEXTURE]; + srgb_mode = device->stateBlock->state.sampler_states[This->baseTexture.sampler][WINED3DSAMP_SRGBTEXTURE]; srgb_was_toggled = This->baseTexture.is_srgb != srgb_mode; This->baseTexture.is_srgb = srgb_mode; } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 61c46535d2d..90082ba2a70 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2349,6 +2349,8 @@ struct wined3d_stream_state struct wined3d_state { + /* Sampler States */ + 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; @@ -2418,9 +2420,6 @@ struct IWineD3DStateBlockImpl /* Texture */ IWineD3DBaseTexture *textures[MAX_COMBINED_SAMPLERS]; - /* Sampler States */ - DWORD samplerState[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1]; - /* Contained state management */ DWORD contained_render_states[WINEHIGHEST_RENDER_STATE + 1]; unsigned int num_contained_render_states;