wined3d: Determine used streams at vdecl creation.
This commit is contained in:
parent
ca0d92f3bc
commit
06e51c21e1
|
@ -156,10 +156,8 @@ void primitiveDeclarationConvertToStridedData(
|
||||||
WINED3DVERTEXELEMENT *element;
|
WINED3DVERTEXELEMENT *element;
|
||||||
DWORD stride;
|
DWORD stride;
|
||||||
int reg;
|
int reg;
|
||||||
char isPreLoaded[MAX_STREAMS];
|
DWORD numPreloadStreams = This->stateBlock->streamIsUP ? 0 : vertexDeclaration->num_streams;
|
||||||
DWORD preLoadStreams[MAX_STREAMS], numPreloadStreams = 0;
|
DWORD *streams = vertexDeclaration->streams;
|
||||||
|
|
||||||
memset(isPreLoaded, 0, sizeof(isPreLoaded));
|
|
||||||
|
|
||||||
/* Check for transformed vertices, disable vertex shader if present */
|
/* Check for transformed vertices, disable vertex shader if present */
|
||||||
strided->u.s.position_transformed = FALSE;
|
strided->u.s.position_transformed = FALSE;
|
||||||
|
@ -191,11 +189,6 @@ void primitiveDeclarationConvertToStridedData(
|
||||||
data = (BYTE *)This->stateBlock->streamSource[element->Stream];
|
data = (BYTE *)This->stateBlock->streamSource[element->Stream];
|
||||||
} else {
|
} else {
|
||||||
TRACE("Stream isn't up %d, %p\n", element->Stream, This->stateBlock->streamSource[element->Stream]);
|
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);
|
data = IWineD3DVertexBufferImpl_GetMemory(This->stateBlock->streamSource[element->Stream], 0, &streamVBO);
|
||||||
if(fixup) {
|
if(fixup) {
|
||||||
if( streamVBO != 0) *fixup = TRUE;
|
if( streamVBO != 0) *fixup = TRUE;
|
||||||
|
@ -242,7 +235,7 @@ void primitiveDeclarationConvertToStridedData(
|
||||||
* once in there.
|
* once in there.
|
||||||
*/
|
*/
|
||||||
for(i=0; i < numPreloadStreams; i++) {
|
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) {
|
const WINED3DVERTEXELEMENT *elements, size_t element_count) {
|
||||||
IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface;
|
IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface;
|
||||||
HRESULT hr = WINED3D_OK;
|
HRESULT hr = WINED3D_OK;
|
||||||
|
int i;
|
||||||
|
char isPreLoaded[MAX_STREAMS];
|
||||||
|
|
||||||
TRACE("(%p) : d3d version %d\n", This, ((IWineD3DImpl *)This->wineD3DDevice->wineD3D)->dxVersion);
|
TRACE("(%p) : d3d version %d\n", This, ((IWineD3DImpl *)This->wineD3DDevice->wineD3D)->dxVersion);
|
||||||
|
memset(isPreLoaded, 0, sizeof(isPreLoaded));
|
||||||
|
|
||||||
if (TRACE_ON(d3d_decl)) {
|
if (TRACE_ON(d3d_decl)) {
|
||||||
int i;
|
|
||||||
for (i = 0; i < element_count; ++i) {
|
for (i = 0; i < element_count; ++i) {
|
||||||
dump_wined3dvertexelement(elements+i);
|
dump_wined3dvertexelement(elements+i);
|
||||||
}
|
}
|
||||||
|
@ -139,6 +141,25 @@ static HRESULT WINAPI IWineD3DVertexDeclarationImpl_SetDeclaration(IWineD3DVerte
|
||||||
CopyMemory(This->pDeclarationWine, elements, sizeof(WINED3DVERTEXELEMENT) * element_count);
|
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");
|
TRACE("Returning\n");
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1225,6 +1225,9 @@ typedef struct IWineD3DVertexDeclarationImpl {
|
||||||
|
|
||||||
WINED3DVERTEXELEMENT *pDeclarationWine;
|
WINED3DVERTEXELEMENT *pDeclarationWine;
|
||||||
UINT declarationWNumElements;
|
UINT declarationWNumElements;
|
||||||
|
|
||||||
|
DWORD streams[MAX_STREAMS];
|
||||||
|
UINT num_streams;
|
||||||
} IWineD3DVertexDeclarationImpl;
|
} IWineD3DVertexDeclarationImpl;
|
||||||
|
|
||||||
extern const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl;
|
extern const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl;
|
||||||
|
|
Loading…
Reference in New Issue