Module: wine Branch: master Commit: 9b4920996e7eed4ab50077eb958d67e85e82f9e7 URL: http://source.winehq.org/git/wine.git/?a=commit;h=9b4920996e7eed4ab50077eb95...
Author: Stefan Dösinger stefan@codeweavers.com Date: Wed Jan 10 11:26:12 2007 +0100
wined3d: Move material applying to the state table.
---
dlls/wined3d/drawprim.c | 34 ---------------------------------- dlls/wined3d/state.c | 35 ++++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 45 deletions(-)
diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index 2e4a694..b46192e 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -90,37 +90,6 @@ static DWORD primitiveToGl(WINED3DPRIMIT return NumVertexes; }
-/* Ensure the appropriate material states are set up - only change - state if really required */ -static void init_materials(IWineD3DDevice *iface, BOOL isDiffuseSupplied) { - - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - - if (This->tracking_color == NEEDS_TRACKING && isDiffuseSupplied) { - /* If we have not set up the material color tracking, do it now as required */ - glDisable(GL_COLOR_MATERIAL); /* Note: Man pages state must enable AFTER calling glColorMaterial! Required?*/ - checkGLcall("glDisable GL_COLOR_MATERIAL"); - TRACE("glColorMaterial Parm=%x\n", This->tracking_parm); - glColorMaterial(GL_FRONT_AND_BACK, This->tracking_parm); - checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)"); - glEnable(GL_COLOR_MATERIAL); - checkGLcall("glEnable GL_COLOR_MATERIAL"); - This->tracking_color = IS_TRACKING; - } else if ((This->tracking_color == IS_TRACKING && !isDiffuseSupplied) || - (This->tracking_color == NEEDS_TRACKING && !isDiffuseSupplied)) { - /* If we are tracking the current color but one isn't supplied, don't! */ - glDisable(GL_COLOR_MATERIAL); - checkGLcall("glDisable GL_COLOR_MATERIAL"); - This->tracking_color = NEEDS_TRACKING; - } else if (This->tracking_color == IS_TRACKING && isDiffuseSupplied) { - /* No need to reset material colors since no change to gl_color_material */ - } else if (This->tracking_color == NEEDS_DISABLE) { - glDisable(GL_COLOR_MATERIAL); - checkGLcall("glDisable GL_COLOR_MATERIAL"); - This->tracking_color = DISABLED_TRACKING; - } -} - static BOOL fixed_get_input( BYTE usage, BYTE usage_idx, unsigned int* regnum) { @@ -1248,9 +1217,6 @@ void drawPrimitive(IWineD3DDevice *iface } This->depth_copy_state = WINED3D_DCS_INITIAL;
- /* Now initialize the materials state */ - init_materials(iface, (This->strided_streams.u.s.diffuse.lpData != NULL || This->strided_streams.u.s.diffuse.VBO != 0)); - { GLenum glPrimType; /* Ok, Work out which primitive is requested and how many vertexes that diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 8cdd758..f62db54 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -806,7 +806,18 @@ static void state_fogdensity(DWORD state
/* TODO: Merge with primitive type + init_materials()!! */ static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock) { - GLenum Parm = GL_AMBIENT_AND_DIFFUSE; + GLenum Parm = -1; + WineDirect3DStridedData *diffuse = &stateblock->wineD3DDevice->strided_streams.u.s.diffuse; + BOOL isDiffuseSupplied; + + /* Depends on the decoded vertex declaration to read the existance of diffuse data. + * The vertex declaration will call this function if the fixed function pipeline is used. + */ + if(isStateDirty(stateblock->wineD3DDevice, STATE_VDECL)) { + return; + } + + isDiffuseSupplied = diffuse->lpData || diffuse->VBO;
if (stateblock->renderState[WINED3DRS_COLORVERTEX]) { TRACE("diff %d, amb %d, emis %d, spec %d\n", @@ -827,19 +838,17 @@ static void state_colormat(DWORD state, Parm = GL_EMISSION; } else if (stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE] == D3DMCS_COLOR1) { Parm = GL_SPECULAR; - } else { - Parm = -1; - } - - if (Parm == -1) { - if (stateblock->wineD3DDevice->tracking_color != DISABLED_TRACKING) stateblock->wineD3DDevice->tracking_color = NEEDS_DISABLE; - } else { - stateblock->wineD3DDevice->tracking_color = NEEDS_TRACKING; - stateblock->wineD3DDevice->tracking_parm = Parm; } + }
+ if(Parm == -1 || !isDiffuseSupplied) { + glDisable(GL_COLOR_MATERIAL); + checkGLcall("glDisable GL_COLOR_MATERIAL"); } else { - if (stateblock->wineD3DDevice->tracking_color != DISABLED_TRACKING) stateblock->wineD3DDevice->tracking_color = NEEDS_DISABLE; + glColorMaterial(GL_FRONT_AND_BACK, Parm); + checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)"); + glEnable(GL_COLOR_MATERIAL); + checkGLcall("glEnable(GL_COLOR_MATERIAL)"); } }
@@ -2678,6 +2687,10 @@ static void vertexdeclaration(DWORD stat !isStateDirty(stateblock->wineD3DDevice, STATE_TRANSFORM(WINED3DTS_VIEW))) { transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock); } + + if(!isStateDirty(stateblock->wineD3DDevice, STATE_RENDER(WINED3DRS_COLORVERTEX))) { + state_colormat(STATE_RENDER(WINED3DRS_COLORVERTEX), stateblock); + } } else { /* We compile the shader here because we need the vertex declaration * in order to determine if we need to do any swizzling for D3DCOLOR