Commit 06e51c21 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Determine used streams at vdecl creation.

parent ca0d92f3
......@@ -156,10 +156,8 @@ void primitiveDeclarationConvertToStridedData(
WINED3DVERTEXELEMENT *element;
DWORD stride;
int reg;
char isPreLoaded[MAX_STREAMS];
DWORD preLoadStreams[MAX_STREAMS], numPreloadStreams = 0;
memset(isPreLoaded, 0, sizeof(isPreLoaded));
DWORD numPreloadStreams = This->stateBlock->streamIsUP ? 0 : vertexDeclaration->num_streams;
DWORD *streams = vertexDeclaration->streams;
/* Check for transformed vertices, disable vertex shader if present */
strided->u.s.position_transformed = FALSE;
......@@ -191,11 +189,6 @@ void primitiveDeclarationConvertToStridedData(
data = (BYTE *)This->stateBlock->streamSource[element->Stream];
} else {
TRACE("Stream isn't up %d, %p\n", element->Stream, This->stateBlock->streamSource[element->Stream]);
if(!isPreLoaded[element->Stream]) {
preLoadStreams[numPreloadStreams] = element->Stream;
numPreloadStreams++;
isPreLoaded[element->Stream] = 1;
}
data = IWineD3DVertexBufferImpl_GetMemory(This->stateBlock->streamSource[element->Stream], 0, &streamVBO);
if(fixup) {
if( streamVBO != 0) *fixup = TRUE;
......@@ -242,7 +235,7 @@ void primitiveDeclarationConvertToStridedData(
* once in there.
*/
for(i=0; i < numPreloadStreams; i++) {
IWineD3DVertexBuffer_PreLoad(This->stateBlock->streamSource[preLoadStreams[i]]);
IWineD3DVertexBuffer_PreLoad(This->stateBlock->streamSource[streams[i]]);
}
}
......
......@@ -120,11 +120,13 @@ static HRESULT WINAPI IWineD3DVertexDeclarationImpl_SetDeclaration(IWineD3DVerte
const WINED3DVERTEXELEMENT *elements, size_t element_count) {
IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface;
HRESULT hr = WINED3D_OK;
int i;
char isPreLoaded[MAX_STREAMS];
TRACE("(%p) : d3d version %d\n", This, ((IWineD3DImpl *)This->wineD3DDevice->wineD3D)->dxVersion);
memset(isPreLoaded, 0, sizeof(isPreLoaded));
if (TRACE_ON(d3d_decl)) {
int i;
for (i = 0; i < element_count; ++i) {
dump_wined3dvertexelement(elements+i);
}
......@@ -139,6 +141,25 @@ static HRESULT WINAPI IWineD3DVertexDeclarationImpl_SetDeclaration(IWineD3DVerte
CopyMemory(This->pDeclarationWine, elements, sizeof(WINED3DVERTEXELEMENT) * element_count);
}
/* Do some static analysis on the elements to make reading the declaration more comfortable
* for the drawing code
*
* First, find the Streams used in the declaration. The vertex buffers have to be loaded
* when drawing.
*/
This->num_streams = 0;
for (i = 0; i < element_count; ++i) {
/* Filter tesselation pseudo streams*/
if(This->pDeclarationWine[i].Stream >= MAX_STREAMS) continue;
if(!isPreLoaded[This->pDeclarationWine[i].Stream]) {
This->streams[This->num_streams] = This->pDeclarationWine[i].Stream;
This->num_streams++;
isPreLoaded[This->pDeclarationWine[i].Stream] = 1;
}
}
TRACE("Returning\n");
return hr;
}
......
......@@ -1225,6 +1225,9 @@ typedef struct IWineD3DVertexDeclarationImpl {
WINED3DVERTEXELEMENT *pDeclarationWine;
UINT declarationWNumElements;
DWORD streams[MAX_STREAMS];
UINT num_streams;
} IWineD3DVertexDeclarationImpl;
extern const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment