From 197ec1c179b4367ae25783cb08a1b2a616562e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Tue, 2 Jan 2007 00:07:55 +0100 Subject: [PATCH] wined3d: Remove IWineD3DDevice_ApplyStateChanges. --- dlls/wined3d/device.c | 82 +------------------------------- dlls/wined3d/state.c | 27 +++++++---- dlls/wined3d/stateblock.c | 4 -- include/wine/wined3d_interface.h | 3 -- 4 files changed, 18 insertions(+), 98 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index b68c4a22f07..38afc4f20a4 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -315,84 +315,6 @@ static void delete_glsl_shader_list(IWineD3DDevice* iface) { } } - -/* Apply the current values to the specified texture stage */ -static void WINAPI IWineD3DDeviceImpl_SetupTextureStates(IWineD3DDevice *iface, DWORD Sampler, DWORD texture_idx, DWORD Flags) { - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - float col[4]; - - union { - float f; - DWORD d; - } tmpvalue; - - /* In addition, IDirect3DDevice9::SetSamplerState will now be used for filtering, tiling, - clamping, MIPLOD, etc. This will work for up to 16 samplers. - */ - - if (Sampler >= GL_LIMITS(sampler_stages)) { - FIXME("Trying to set the state of more samplers %d than are supported %d by this openGL implementation\n", Sampler, GL_LIMITS(sampler_stages)); - return; - } - VTRACE(("Activating appropriate texture state %d\n", Sampler)); - if (GL_SUPPORT(ARB_MULTITEXTURE)) { - ENTER_GL(); - GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + texture_idx)); - checkGLcall("glActiveTextureARB"); - LEAVE_GL(); - /* Could we use bindTexture and then apply the states instead of GLACTIVETEXTURE */ - } else if (Sampler > 0) { - FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n"); - return; - } - - /* TODO: change this to a lookup table - LOOKUP_TEXTURE_STATES lists all texture states that should be applied. - LOOKUP_CONTEXT_SATES list all context applicable states that can be applied - etc.... it's a lot cleaner, quicker and possibly easier to maintain than running a switch and setting a skip flag... - especially when there are a number of groups of states. */ - - TRACE("-----------------------> Updating the texture at Sampler %d to have new texture state information\n", Sampler); - - /* apply any sampler states that always need applying */ - if (GL_SUPPORT(EXT_TEXTURE_LOD_BIAS)) { - tmpvalue.d = This->stateBlock->samplerState[Sampler][WINED3DSAMP_MIPMAPLODBIAS]; - glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, - GL_TEXTURE_LOD_BIAS_EXT, - tmpvalue.f); - checkGLcall("glTexEnvi GL_TEXTURE_LOD_BIAS_EXT ..."); - } - - D3DCOLORTOGLFLOAT4(This->stateBlock->renderState[WINED3DRS_TEXTUREFACTOR], col); - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]); - checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);"); - - /* TODO: NV_POINT_SPRITE */ - if (GL_SUPPORT(ARB_POINT_SPRITE)) { - if (This->stateBlock->renderState[WINED3DRS_POINTSPRITEENABLE]) { - /* Doesn't work with GL_POINT_SMOOTH on on my ATI 9600, but then ATI drivers are buggered! */ - glDisable(GL_POINT_SMOOTH); - - /* Centre the texture on the vertex */ - VTRACE(("glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE)\n")); - glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE); - - VTRACE(("glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE)\n")); - glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE); - checkGLcall("glTexEnvf(...)"); - VTRACE(("glEnable( GL_POINT_SPRITE_ARB )\n")); - glEnable( GL_POINT_SPRITE_ARB ); - checkGLcall("glEnable(...)"); - } else { - VTRACE(("glDisable( GL_POINT_SPRITE_ARB )\n")); - glDisable( GL_POINT_SPRITE_ARB ); - checkGLcall("glEnable(...)"); - } - } - - TRACE("-----------------------> Updated the texture at Sampler %d to have new texture state information\n", Sampler); -} - /********************************************************** * IUnknown parts follows **********************************************************/ @@ -3249,7 +3171,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetSamplerState(IWineD3DDevice *iface, * GL_MAX_TEXTURE_COORDS_ARB. * Ok GForce say it's ok to use glTexParameter/glGetTexParameter(...). ******************/ - /** NOTE: States are appled in IWineD3DBaseTextre ApplyStateChanges and IWineD3DDevice SetupTextureStates**/ + /** NOTE: States are applied in IWineD3DBaseTextre ApplyStateChanges the sampler state handler**/ if(Sampler > GL_LIMITS(sampler_stages) || Sampler < 0 || Type > WINED3D_HIGHEST_SAMPLER_STATE || Type < 0) { FIXME("sampler %d type %s(%u) is out of range [max_samplers=%d, highest_state=%d]\n", Sampler, debug_d3dsamplerstate(Type), Type, GL_LIMITS(sampler_stages), WINED3D_HIGHEST_SAMPLER_STATE); @@ -6864,8 +6786,6 @@ const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl = IWineD3DDeviceImpl_StretchRect, IWineD3DDeviceImpl_GetRenderTargetData, IWineD3DDeviceImpl_GetFrontBufferData, - /*** Internal use IWineD3DDevice methods ***/ - IWineD3DDeviceImpl_SetupTextureStates, /*** object tracking ***/ IWineD3DDeviceImpl_ResourceReleased }; diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 5402fbf9e92..5a79d22d03c 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -1044,18 +1044,14 @@ static void state_pointsprite(DWORD state, IWineD3DStateBlockImpl *stateblock) { return; } - /* - * Point sprites are always enabled. Value controls texture coordinate - * replacement mode. Must be set true for point sprites to use - * textures. - */ - glEnable(GL_POINT_SPRITE_ARB); - checkGLcall("glEnable(GL_POINT_SPRITE_ARB)"); - if (stateblock->renderState[WINED3DRS_POINTSPRITEENABLE]) { + glEnable(GL_POINT_SPRITE_ARB); + checkGLcall("glEnable(GL_POINT_SPRITE_ARB)"); glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, TRUE); checkGLcall("glTexEnvf(GL_POINT_SPRITE, GL_COORD_REPLACE, TRUE)"); } else { + glDisable(GL_POINT_SPRITE_ARB); + checkGLcall("glDisable(GL_POINT_SPRITE_ARB)"); glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, FALSE); checkGLcall("glTexEnvf(GL_POINT_SPRITE, GL_COORD_REPLACE, FALSE)"); } @@ -1679,6 +1675,10 @@ static void tex_resultarg(DWORD state, IWineD3DStateBlockImpl *stateblock) { static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock) { DWORD sampler = state - STATE_SAMPLER(0); + union { + float f; + DWORD d; + } tmpvalue; TRACE("Sampler: %d\n", sampler); /* Enabling and disabling texture dimensions is done by texture stage state / pixel shader setup, this function @@ -1700,7 +1700,7 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock) { if(stateblock->textures[sampler]) { /* NP2 textures need the texture matrix set properly for the stage */ - if(wined3d_settings.nonpower2_mode == NP2_NATIVE && + if(wined3d_settings.nonpower2_mode == NP2_NATIVE && sampler < MAX_TEXTURES - 1 && stateblock->textureDimensions[sampler] == GL_TEXTURE_2D && (((IWineD3DTextureImpl *) stateblock->textures[sampler])->pow2scalingFactorX != 1.0 || ((IWineD3DTextureImpl *) stateblock->textures[sampler])->pow2scalingFactorY != 1.0 ) ) { @@ -1708,9 +1708,16 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock) { } IWineD3DBaseTexture_PreLoad((IWineD3DBaseTexture *) stateblock->textures[sampler]); - IWineD3DDevice_SetupTextureStates((IWineD3DDevice *)stateblock->wineD3DDevice, sampler, stateblock->wineD3DDevice->texUnitMap[sampler], REAPPLY_ALPHAOP); IWineD3DBaseTexture_ApplyStateChanges(stateblock->textures[sampler], stateblock->textureState[sampler], stateblock->samplerState[sampler]); + if (GL_SUPPORT(EXT_TEXTURE_LOD_BIAS)) { + tmpvalue.d = stateblock->samplerState[sampler][WINED3DSAMP_MIPMAPLODBIAS]; + glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, + GL_TEXTURE_LOD_BIAS_EXT, + tmpvalue.f); + checkGLcall("glTexEnvi GL_TEXTURE_LOD_BIAS_EXT ..."); + } + if (stateblock->wineD3DDevice->ps_selected_mode != SHADER_NONE && stateblock->pixelShader && ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function) { /* Using a pixel shader? Verify the sampler types */ diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index afc582d821c..33d42ad0784 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1069,10 +1069,6 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat glTexImage1D(GL_TEXTURE_1D, 0, GL_LUMINANCE, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, &white); checkGLcall("glTexImage1D"); -#if 1 /* TODO: move the setting texture states off to basetexture */ - /* Reapply all the texture state information to this texture */ - IWineD3DDevice_SetupTextureStates(device, i, i, REAPPLY_ALL); -#endif } LEAVE_GL(); diff --git a/include/wine/wined3d_interface.h b/include/wine/wined3d_interface.h index 56d93f46fd2..4a5a0511662 100644 --- a/include/wine/wined3d_interface.h +++ b/include/wine/wined3d_interface.h @@ -471,8 +471,6 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD3DBase) STDMETHOD(StretchRect)(THIS_ struct IWineD3DSurface* pSourceSurface, CONST RECT* pSourceRect, struct IWineD3DSurface* pDestinationSurface, CONST RECT* pDestRect, WINED3DTEXTUREFILTERTYPE Filter) PURE; STDMETHOD(GetRenderTargetData)(THIS_ struct IWineD3DSurface* pRenderTarget, struct IWineD3DSurface* pSurface) PURE; STDMETHOD(GetFrontBufferData)(THIS_ UINT iSwapChain,struct IWineD3DSurface* pSurface) PURE; - /*** Internal use IWineD3Device methods ***/ - STDMETHOD_(void, SetupTextureStates)(THIS_ DWORD Stage, DWORD texture_idx, DWORD Flags); /*** object tracking ***/ STDMETHOD_(void, ResourceReleased)(THIS_ struct IWineD3DResource *resource); }; @@ -611,7 +609,6 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD3DBase) #define IWineD3DDevice_StretchRect(p,a,b,c,d,e) (p)->lpVtbl->StretchRect(p,a,b,c,d,e) #define IWineD3DDevice_GetRenderTargetData(p,a,b) (p)->lpVtbl->GetRenderTargetData(p,a,b) #define IWineD3DDevice_GetFrontBufferData(p,a,b) (p)->lpVtbl->GetFrontBufferData(p,a,b) -#define IWineD3DDevice_SetupTextureStates(p,a,b,c) (p)->lpVtbl->SetupTextureStates(p,a,b,c) #define IWineD3DDevice_ResourceReleased(p,a) (p)->lpVtbl->ResourceReleased(p,a) #endif