From 438c17284138776edbbe9196364ae620bbf01adb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20D=C3=B6singer?= Date: Tue, 2 Jan 2007 21:31:08 +0100 Subject: [PATCH] wined3d: Move decoding the vertex declaration to the vertexshader state handler. --- dlls/wined3d/drawprim.c | 41 ++------------------------------------ dlls/wined3d/state.c | 45 ++++++++++++++++++++++++++++++++++++++++-- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 46 insertions(+), 41 deletions(-) diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index 5dfc15ba07a..6bd2854d560 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -1943,7 +1943,7 @@ void drawPrimitive(IWineD3DDevice *iface, BOOL usePixelShaderFunction = FALSE; IWineD3DSwapChainImpl *swapchain; int i; - BOOL fixup = FALSE; + BOOL fixup; DWORD dirtyState, idx; BYTE shift; @@ -1980,6 +1980,7 @@ void drawPrimitive(IWineD3DDevice *iface, StateTable[dirtyState].apply(dirtyState, This->stateBlock); } This->numDirtyEntries = 0; /* This makes the whole list clean */ + fixup = This->streamFixedUp; if (TRACE_ON(d3d_draw) && wined3d_settings.offscreen_rendering_mode == ORM_FBO) { check_fbo_status(iface); @@ -1990,44 +1991,6 @@ void drawPrimitive(IWineD3DDevice *iface, } This->depth_copy_state = WINED3D_DCS_INITIAL; - if(This->up_strided) { - - /* Note: this is a ddraw fixed-function code path */ - - TRACE("================ Strided Input ===================\n"); - memcpy(&This->strided_streams, This->up_strided, sizeof(This->strided_streams)); - drawPrimitiveTraceDataLocations(&This->strided_streams); - fixup = FALSE; - } - - else if (This->stateBlock->vertexDecl || This->stateBlock->vertexShader) { - - /* Note: This is a fixed function or shader codepath. - * This means it must handle both types of strided data. - * Shaders must go through here to zero the strided data, even if they - * don't set any declaration at all */ - - TRACE("================ Vertex Declaration ===================\n"); - memset(&This->strided_streams, 0, sizeof(This->strided_streams)); - - if (This->stateBlock->vertexDecl != NULL || - ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->vertexDeclaration != NULL) - - primitiveDeclarationConvertToStridedData(iface, useVertexShaderFunction, - &This->strided_streams, &fixup); - - } else { - - /* Note: This codepath is not reachable from d3d9 (see fvf->decl9 conversion) - * It is reachable through d3d8, but only for fixed-function. - * It will not work properly for shaders. */ - - TRACE("================ FVF ===================\n"); - memset(&This->strided_streams, 0, sizeof(This->strided_streams)); - primitiveConvertToStridedData(iface, &This->strided_streams, &fixup); - drawPrimitiveTraceDataLocations(&This->strided_streams); - } - /* Setup transform matrices and sort out */ primitiveInitState(iface, &This->strided_streams, useVertexShaderFunction, &lighting_changed, &lighting_original); diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index a8419a701ea..f68546b0995 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -1857,8 +1857,49 @@ static void transform_worldex(DWORD state, IWineD3DStateBlockImpl *stateBlock) { WARN("World matrix 1 - 255 not supported yet\n"); } -static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateBlock) { - TRACE("To be filled later\n"); +static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock) { + BOOL useVertexShaderFunction = FALSE; + stateblock->wineD3DDevice->streamFixedUp = FALSE; + + /* Shaders can be implemented using ARB_PROGRAM, GLSL, or software - + * here simply check whether a shader was set, or the user disabled shaders + */ + if (stateblock->wineD3DDevice->vs_selected_mode != SHADER_NONE && stateblock->vertexShader && + ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->baseShader.function != NULL) + useVertexShaderFunction = TRUE; + + if(stateblock->wineD3DDevice->up_strided) { + + /* Note: this is a ddraw fixed-function code path */ + TRACE("================ Strided Input ===================\n"); + memcpy(&stateblock->wineD3DDevice->strided_streams, stateblock->wineD3DDevice->up_strided, sizeof(stateblock->wineD3DDevice->strided_streams)); + stateblock->wineD3DDevice->streamFixedUp = FALSE; + } + else if (stateblock->vertexDecl || stateblock->vertexShader) { + /* Note: This is a fixed function or shader codepath. + * This means it must handle both types of strided data. + * Shaders must go through here to zero the strided data, even if they + * don't set any declaration at all + */ + TRACE("================ Vertex Declaration ===================\n"); + memset(&stateblock->wineD3DDevice->strided_streams, 0, sizeof(stateblock->wineD3DDevice->strided_streams)); + + if (stateblock->vertexDecl != NULL || + ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->vertexDeclaration != NULL) { + + primitiveDeclarationConvertToStridedData((IWineD3DDevice *) stateblock->wineD3DDevice, useVertexShaderFunction, + &stateblock->wineD3DDevice->strided_streams, &stateblock->wineD3DDevice->streamFixedUp); + } + } else { + /* Note: This codepath is not reachable from d3d9 (see fvf->decl9 conversion) + * It is reachable through d3d8, but only for fixed-function. + * It will not work properly for shaders. + */ + TRACE("================ FVF ===================\n"); + memset(&stateblock->wineD3DDevice->strided_streams, 0, sizeof(stateblock->wineD3DDevice->strided_streams)); + primitiveConvertToStridedData((IWineD3DDevice *) stateblock->wineD3DDevice, &stateblock->wineD3DDevice->strided_streams, + &stateblock->wineD3DDevice->streamFixedUp); + } } const struct StateEntry StateTable[] = diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 9ca13c1ac87..15958f3ee59 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -669,6 +669,7 @@ typedef struct IWineD3DDeviceImpl /* Stream source management */ WineDirect3DVertexStridedData strided_streams; WineDirect3DVertexStridedData *up_strided; + BOOL streamFixedUp; } IWineD3DDeviceImpl; -- 2.11.4.GIT