From 030b92a2f6206fb7586f031c750fe6c263fb7a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Mon, 4 Jun 2007 14:16:32 +0200 Subject: [PATCH] wined3d: Remove the FVF codepath from drawprim. --- dlls/wined3d/device.c | 6 +- dlls/wined3d/drawprim.c | 164 --------------------------------- dlls/wined3d/state.c | 15 +-- dlls/wined3d/wined3d_private.h | 9 -- 4 files changed, 3 insertions(+), 191 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 9dc7f287e26..a8eade29e3e 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3861,11 +3861,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ProcessVertices(IWineD3DDevice *iface, */ This->stateBlock->streamIsUP = FALSE; memset(&strided, 0, sizeof(strided)); - if(This->stateBlock->vertexDecl) { - primitiveDeclarationConvertToStridedData(iface, FALSE, &strided, &vbo); - } else { - primitiveConvertToStridedData(iface, &strided, &vbo); - } + primitiveDeclarationConvertToStridedData(iface, FALSE, &strided, &vbo); This->stateBlock->streamIsUP = streamWasUP; if(vbo || SrcStartIndex) { diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index 16504d5ef42..1cde3a9074b 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -244,170 +244,6 @@ void primitiveDeclarationConvertToStridedData( } } -void primitiveConvertFVFtoOffset(DWORD thisFVF, DWORD stride, BYTE *data, WineDirect3DVertexStridedData *strided, GLint streamVBO, UINT streamNo) { - int numBlends; - int numTextures; - int textureNo; - int coordIdxInfo = 0x00; /* Information on number of coords supplied */ - int numCoords[8]; /* Holding place for WINED3DFVF_TEXTUREFORMATx */ - - /* Either 3 or 4 floats depending on the FVF */ - /* FIXME: Can blending data be in a different stream to the position data? - and if so using the fixed pipeline how do we handle it */ - if (thisFVF & WINED3DFVF_POSITION_MASK) { - strided->u.s.position.lpData = data; - strided->u.s.position.dwType = WINED3DDECLTYPE_FLOAT3; - strided->u.s.position.dwStride = stride; - strided->u.s.position.VBO = streamVBO; - strided->u.s.position.streamNo = streamNo; - data += 3 * sizeof(float); - if ((thisFVF & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZRHW) { - strided->u.s.position.dwType = WINED3DDECLTYPE_FLOAT4; - strided->u.s.position_transformed = TRUE; - data += sizeof(float); - } else - strided->u.s.position_transformed = FALSE; - } - - /* Blending is numBlends * FLOATs followed by a DWORD for UBYTE4 */ - /** do we have to Check This->stateBlock->renderState[D3DRS_INDEXEDVERTEXBLENDENABLE] ? */ - numBlends = 1 + (((thisFVF & WINED3DFVF_XYZB5) - WINED3DFVF_XYZB1) >> 1); - if(thisFVF & WINED3DFVF_LASTBETA_UBYTE4) numBlends--; - - if ((thisFVF & WINED3DFVF_POSITION_MASK ) > WINED3DFVF_XYZRHW) { - TRACE("Setting blend Weights to %p\n", data); - strided->u.s.blendWeights.lpData = data; - strided->u.s.blendWeights.dwType = WINED3DDECLTYPE_FLOAT1 + numBlends - 1; - strided->u.s.blendWeights.dwStride = stride; - strided->u.s.blendWeights.VBO = streamVBO; - strided->u.s.blendWeights.streamNo = streamNo; - data += numBlends * sizeof(FLOAT); - - if (thisFVF & WINED3DFVF_LASTBETA_UBYTE4) { - strided->u.s.blendMatrixIndices.lpData = data; - strided->u.s.blendMatrixIndices.dwType = WINED3DDECLTYPE_UBYTE4; - strided->u.s.blendMatrixIndices.dwStride= stride; - strided->u.s.blendMatrixIndices.VBO = streamVBO; - strided->u.s.blendMatrixIndices.streamNo= streamNo; - data += sizeof(DWORD); - } - } - - /* Normal is always 3 floats */ - if (thisFVF & WINED3DFVF_NORMAL) { - strided->u.s.normal.lpData = data; - strided->u.s.normal.dwType = WINED3DDECLTYPE_FLOAT3; - strided->u.s.normal.dwStride = stride; - strided->u.s.normal.VBO = streamVBO; - strided->u.s.normal.streamNo = streamNo; - data += 3 * sizeof(FLOAT); - } - - /* Pointsize is a single float */ - if (thisFVF & WINED3DFVF_PSIZE) { - strided->u.s.pSize.lpData = data; - strided->u.s.pSize.dwType = WINED3DDECLTYPE_FLOAT1; - strided->u.s.pSize.dwStride = stride; - strided->u.s.pSize.VBO = streamVBO; - strided->u.s.pSize.streamNo = streamNo; - data += sizeof(FLOAT); - } - - /* Diffuse is 4 unsigned bytes */ - if (thisFVF & WINED3DFVF_DIFFUSE) { - strided->u.s.diffuse.lpData = data; - strided->u.s.diffuse.dwType = WINED3DDECLTYPE_SHORT4; - strided->u.s.diffuse.dwStride = stride; - strided->u.s.diffuse.VBO = streamVBO; - strided->u.s.diffuse.streamNo = streamNo; - data += sizeof(DWORD); - } - - /* Specular is 4 unsigned bytes */ - if (thisFVF & WINED3DFVF_SPECULAR) { - strided->u.s.specular.lpData = data; - strided->u.s.specular.dwType = WINED3DDECLTYPE_SHORT4; - strided->u.s.specular.dwStride = stride; - strided->u.s.specular.VBO = streamVBO; - strided->u.s.specular.streamNo = streamNo; - data += sizeof(DWORD); - } - - /* Texture coords */ - numTextures = (thisFVF & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT; - coordIdxInfo = (thisFVF & 0x00FF0000) >> 16; /* 16 is from definition of WINED3DFVF_TEXCOORDSIZE1, and is 8 (0-7 stages) * 2bits long */ - - /* numTextures indicates the number of texture coordinates supplied */ - /* However, the first set may not be for stage 0 texture - it all */ - /* depends on WINED3DTSS_TEXCOORDINDEX. */ - /* The number of bytes for each coordinate set is based off */ - /* WINED3DFVF_TEXCOORDSIZEn, which are the bottom 2 bits */ - - /* So, for each supplied texture extract the coords */ - for (textureNo = 0; textureNo < numTextures; ++textureNo) { - - strided->u.s.texCoords[textureNo].lpData = data; - strided->u.s.texCoords[textureNo].dwType = WINED3DDECLTYPE_FLOAT1; - strided->u.s.texCoords[textureNo].dwStride = stride; - strided->u.s.texCoords[textureNo].VBO = streamVBO; - strided->u.s.texCoords[textureNo].streamNo = streamNo; - numCoords[textureNo] = coordIdxInfo & 0x03; - - /* Always one set */ - data += sizeof(float); - if (numCoords[textureNo] != WINED3DFVF_TEXTUREFORMAT1) { - strided->u.s.texCoords[textureNo].dwType = WINED3DDECLTYPE_FLOAT2; - data += sizeof(float); - if (numCoords[textureNo] != WINED3DFVF_TEXTUREFORMAT2) { - strided->u.s.texCoords[textureNo].dwType = WINED3DDECLTYPE_FLOAT3; - data += sizeof(float); - if (numCoords[textureNo] != WINED3DFVF_TEXTUREFORMAT3) { - strided->u.s.texCoords[textureNo].dwType = WINED3DDECLTYPE_FLOAT4; - data += sizeof(float); - } - } - } - coordIdxInfo = coordIdxInfo >> 2; /* Drop bottom two bits */ - } -} - -void primitiveConvertToStridedData(IWineD3DDevice *iface, WineDirect3DVertexStridedData *strided, BOOL *fixup) { - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; - GLint streamVBO = 0; - DWORD stride = This->stateBlock->streamStride[0]; - BYTE *data = NULL; - DWORD thisFVF = 0; - - /* Retrieve appropriate FVF */ - thisFVF = This->stateBlock->fvf; - /* Handle memory passed directly as well as vertex buffers */ - if (This->stateBlock->streamIsUP) { - streamVBO = 0; - data = (BYTE *)This->stateBlock->streamSource[0]; - } else { - /* The for loop should iterate through here only once per stream, so we don't need magic to prevent double loading - * buffers - */ - data = IWineD3DVertexBufferImpl_GetMemory(This->stateBlock->streamSource[0], 0, &streamVBO); - if(fixup) { - if(streamVBO != 0 ) *fixup = TRUE; - } - } - VTRACE(("FVF for stream 0 is %lx\n", thisFVF)); - - /* Now convert the stream into pointers */ - primitiveConvertFVFtoOffset(thisFVF, stride, data, strided, streamVBO, 0); - - /* Now call PreLoad on the vertex buffer. In the very rare case - * that the buffers stopps converting PreLoad will dirtify the VDECL again. - * The vertex buffer can now use the strided structure in the device instead of finding its - * own again. - */ - if(!This->stateBlock->streamIsUP) { - IWineD3DVertexBuffer_PreLoad(This->stateBlock->streamSource[0]); - } -} - static void drawStridedFast(IWineD3DDevice *iface,UINT numberOfVertices, GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, ULONG startVertex) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index a244d3a9ae9..d6522f24b24 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -3067,7 +3067,7 @@ static inline void handleStreams(IWineD3DStateBlockImpl *stateblock, BOOL useVer if(TRACE_ON(d3d)) { drawPrimitiveTraceDataLocations(dataLocations); } - } else if (stateblock->vertexDecl) { + } else { /* 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 @@ -3077,18 +3077,7 @@ static inline void handleStreams(IWineD3DStateBlockImpl *stateblock, BOOL useVer memset(dataLocations, 0, sizeof(*dataLocations)); primitiveDeclarationConvertToStridedData((IWineD3DDevice *) device, useVertexShaderFunction, dataLocations, &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(dataLocations, 0, sizeof(*dataLocations)); - primitiveConvertToStridedData((IWineD3DDevice *) device, dataLocations, &fixup); - if(TRACE_ON(d3d)) { - drawPrimitiveTraceDataLocations(dataLocations); - } - } + } if (dataLocations->u.s.position_transformed) { useVertexShaderFunction = FALSE; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 8549232de60..1c35ea471d2 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -410,21 +410,12 @@ void drawPrimitive(IWineD3DDevice *iface, const void *idxData, int minIndex); -void primitiveConvertToStridedData(IWineD3DDevice *iface, WineDirect3DVertexStridedData *strided, BOOL *fixup); - void primitiveDeclarationConvertToStridedData( IWineD3DDevice *iface, BOOL useVertexShaderFunction, WineDirect3DVertexStridedData *strided, BOOL *fixup); -void primitiveConvertFVFtoOffset(DWORD thisFVF, - DWORD stride, - BYTE *data, - WineDirect3DVertexStridedData *strided, - GLint streamVBO, - UINT streamNo); - DWORD get_flexible_vertex_size(DWORD d3dvtVertexType); void blt_to_drawable(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *surface);