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

ddraw: Store the fvf in the ddraw buffer.

WineD3D buffer FVFs will go away soon.
parent 825354af
......@@ -687,6 +687,7 @@ struct IDirect3DVertexBufferImpl
/*** Storage for D3D7 specific things ***/
DWORD Caps;
DWORD fvf;
};
/* The Vtables */
......
......@@ -4104,7 +4104,6 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
IDirect3DVertexBufferImpl *vb = (IDirect3DVertexBufferImpl *)D3DVertexBuf;
HRESULT hr;
DWORD stride;
WINED3DBUFFER_DESC Desc;
TRACE("(%p)->(%08x,%p,%08x,%08x,%08x)\n", This, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Flags);
......@@ -4114,18 +4113,9 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
ERR("(%p) No Vertex buffer specified\n", This);
return DDERR_INVALIDPARAMS;
}
stride = get_flexible_vertex_size(vb->fvf);
/* Get the FVF of the vertex buffer, and its stride */
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DBuffer_GetDesc(vb->wineD3DVertexBuffer, &Desc);
if(hr != D3D_OK)
{
ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr = %08x\n", This, hr);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
stride = get_flexible_vertex_size(Desc.FVF);
hr = IWineD3DDevice_SetVertexDeclaration(This->wineD3DDevice,
vb->wineD3DVertexDeclaration);
if(FAILED(hr))
......@@ -4229,32 +4219,20 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IDirect3DVertexBufferImpl *vb = (IDirect3DVertexBufferImpl *)D3DVertexBuf;
DWORD stride;
DWORD stride = get_flexible_vertex_size(vb->fvf);
WORD *LockedIndices;
HRESULT hr;
WINED3DBUFFER_DESC Desc;
TRACE("(%p)->(%08x,%p,%d,%d,%p,%d,%08x)\n", This, PrimitiveType, vb, StartVertex, NumVertices, Indices, IndexCount, Flags);
/* Steps:
* 1) Calculate some things: stride, ...
* 2) Upload the Indices to the index buffer
* 3) Set the index source
* 4) Set the Vertex Buffer as the Stream source
* 5) Call IWineD3DDevice::DrawIndexedPrimitive
* 1) Upload the Indices to the index buffer
* 2) Set the index source
* 3) Set the Vertex Buffer as the Stream source
* 4) Call IWineD3DDevice::DrawIndexedPrimitive
*/
EnterCriticalSection(&ddraw_cs);
/* Get the FVF of the vertex buffer, and its stride */
hr = IWineD3DBuffer_GetDesc(vb->wineD3DVertexBuffer, &Desc);
if(hr != D3D_OK)
{
ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr = %08x\n", This, hr);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
stride = get_flexible_vertex_size(Desc.FVF);
TRACE("Vertex buffer FVF = %08x, stride=%d\n", Desc.FVF, stride);
hr = IWineD3DDevice_SetVertexDeclaration(This->wineD3DDevice,
vb->wineD3DVertexDeclaration);
......
......@@ -1017,6 +1017,7 @@ IDirect3DImpl_7_CreateVertexBuffer(IDirect3D7 *iface,
object->Caps = Desc->dwCaps;
object->ddraw = This;
object->fvf = Desc->dwFVF;
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DDevice_CreateVertexBuffer(This->wineD3DDevice,
......
......@@ -340,7 +340,6 @@ IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface,
IDirect3DDeviceImpl *D3D = (IDirect3DDeviceImpl *)D3DDevice;
BOOL oldClip, doClip;
HRESULT hr;
WINED3DBUFFER_DESC Desc;
TRACE("(%p)->(%08x,%d,%d,%p,%d,%p,%08x)\n", This, VertexOp, DestIndex, Count, Src, SrcIndex, D3D, Flags);
......@@ -372,12 +371,11 @@ IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface,
doClip);
}
IWineD3DBuffer_GetDesc(Src->wineD3DVertexBuffer, &Desc);
IWineD3DDevice_SetStreamSource(D3D->wineD3DDevice,
0, /* Stream No */
Src->wineD3DVertexBuffer,
0, /* Offset */
get_flexible_vertex_size(Desc.FVF));
get_flexible_vertex_size(Src->fvf));
IWineD3DDevice_SetVertexDeclaration(D3D->wineD3DDevice,
Src->wineD3DVertexDeclaration);
hr = IWineD3DDevice_ProcessVertices(D3D->wineD3DDevice,
......@@ -452,8 +450,8 @@ IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface,
/* Now fill the Desc structure */
Desc->dwCaps = This->Caps;
Desc->dwFVF = WDesc.FVF;
Desc->dwNumVertices = WDesc.Size / get_flexible_vertex_size(WDesc.FVF);
Desc->dwFVF = This->fvf;
Desc->dwNumVertices = WDesc.Size / get_flexible_vertex_size(This->fvf);
LeaveCriticalSection(&ddraw_cs);
return D3D_OK;
......
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