Commit 602bb1f5 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Pass the vertex count rather than the primitive count to wined3d draw methods.

parent 6eccf2a3
...@@ -136,6 +136,32 @@ WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format) ...@@ -136,6 +136,32 @@ WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format)
} }
} }
static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, UINT primitive_count)
{
switch(primitive_type)
{
case D3DPT_POINTLIST:
return primitive_count;
case D3DPT_LINELIST:
return primitive_count * 2;
case D3DPT_LINESTRIP:
return primitive_count + 1;
case D3DPT_TRIANGLELIST:
return primitive_count * 3;
case D3DPT_TRIANGLESTRIP:
case D3DPT_TRIANGLEFAN:
return primitive_count + 2;
default:
FIXME("Unhandled primitive type %#x\n", primitive_type);
return 0;
}
}
/* Shader handle functions */ /* Shader handle functions */
static shader_handle *alloc_shader_handle(IDirect3DDevice8Impl *This) { static shader_handle *alloc_shader_handle(IDirect3DDevice8Impl *This) {
if (This->free_shader_handles) { if (This->free_shader_handles) {
...@@ -1512,7 +1538,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitive(LPDIRECT3DDEVICE8 iface ...@@ -1512,7 +1538,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitive(LPDIRECT3DDEVICE8 iface
TRACE("(%p) Relay\n" , This); TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, PrimitiveType, StartVertex, PrimitiveCount); hr = IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, PrimitiveType, StartVertex,
vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount));
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
...@@ -1524,7 +1551,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE ...@@ -1524,7 +1551,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE
TRACE("(%p) Relay\n" , This); TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, PrimitiveType, MinVertexIndex, NumVertices, startIndex, primCount); hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, PrimitiveType, MinVertexIndex, NumVertices,
startIndex, vertex_count_from_primitive_count(PrimitiveType, primCount));
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
...@@ -1535,7 +1563,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE8 ifa ...@@ -1535,7 +1563,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE8 ifa
TRACE("(%p) Relay\n" , This); TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride); hr = IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice, PrimitiveType,
vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount),
pVertexStreamZeroData, VertexStreamZeroStride);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
...@@ -1550,8 +1580,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVI ...@@ -1550,8 +1580,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVI
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, PrimitiveType, MinVertexIndex, hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, PrimitiveType, MinVertexIndex,
NumVertexIndices, PrimitiveCount, pIndexData, wined3dformat_from_d3dformat(IndexDataFormat), NumVertexIndices, vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount), pIndexData,
pVertexStreamZeroData, VertexStreamZeroStride); wined3dformat_from_d3dformat(IndexDataFormat), pVertexStreamZeroData, VertexStreamZeroStride);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
......
...@@ -155,6 +155,32 @@ WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format) ...@@ -155,6 +155,32 @@ WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format)
} }
} }
static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, UINT primitive_count)
{
switch(primitive_type)
{
case D3DPT_POINTLIST:
return primitive_count;
case D3DPT_LINELIST:
return primitive_count * 2;
case D3DPT_LINESTRIP:
return primitive_count + 1;
case D3DPT_TRIANGLELIST:
return primitive_count * 3;
case D3DPT_TRIANGLESTRIP:
case D3DPT_TRIANGLEFAN:
return primitive_count + 2;
default:
FIXME("Unhandled primitive type %#x\n", primitive_type);
return 0;
}
}
/* IDirect3D IUnknown parts follow: */ /* IDirect3D IUnknown parts follow: */
static HRESULT WINAPI IDirect3DDevice9Impl_QueryInterface(LPDIRECT3DDEVICE9EX iface, REFIID riid, LPVOID* ppobj) { static HRESULT WINAPI IDirect3DDevice9Impl_QueryInterface(LPDIRECT3DDEVICE9EX iface, REFIID riid, LPVOID* ppobj) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
...@@ -1357,7 +1383,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitive(LPDIRECT3DDEVICE9EX ifa ...@@ -1357,7 +1383,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitive(LPDIRECT3DDEVICE9EX ifa
TRACE("(%p) Relay\n" , This); TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
hr = IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, PrimitiveType, StartVertex, PrimitiveCount); hr = IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, PrimitiveType, StartVertex,
vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount));
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
return hr; return hr;
} }
...@@ -1371,7 +1398,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVI ...@@ -1371,7 +1398,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVI
/* D3D8 passes the baseVertexIndex in SetIndices, and due to the stateblock functions wined3d has to work that way */ /* D3D8 passes the baseVertexIndex in SetIndices, and due to the stateblock functions wined3d has to work that way */
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
IWineD3DDevice_SetBaseVertexIndex(This->WineD3DDevice, BaseVertexIndex); IWineD3DDevice_SetBaseVertexIndex(This->WineD3DDevice, BaseVertexIndex);
hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, PrimitiveType, MinVertexIndex, NumVertices, startIndex, primCount); hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, PrimitiveType, MinVertexIndex, NumVertices,
startIndex, vertex_count_from_primitive_count(PrimitiveType, primCount));
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
return hr; return hr;
} }
...@@ -1382,7 +1410,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE9EX ...@@ -1382,7 +1410,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE9EX
TRACE("(%p) Relay\n" , This); TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
hr = IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride); hr = IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice, PrimitiveType,
vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount),
pVertexStreamZeroData, VertexStreamZeroStride);
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
return hr; return hr;
} }
...@@ -1396,8 +1426,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDE ...@@ -1396,8 +1426,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDE
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, PrimitiveType, MinVertexIndex, hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, PrimitiveType, MinVertexIndex,
NumVertexIndices, PrimitiveCount, pIndexData, wined3dformat_from_d3dformat(IndexDataFormat), NumVertexIndices, vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount), pIndexData,
pVertexStreamZeroData, VertexStreamZeroStride); wined3dformat_from_d3dformat(IndexDataFormat), pVertexStreamZeroData, VertexStreamZeroStride);
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
return hr; return hr;
} }
......
...@@ -3463,44 +3463,13 @@ IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7 *iface, ...@@ -3463,44 +3463,13 @@ IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7 *iface,
DWORD Flags) DWORD Flags)
{ {
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface; IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
UINT PrimitiveCount, stride; UINT stride;
HRESULT hr; HRESULT hr;
TRACE("(%p)->(%08x,%08x,%p,%08x,%08x): Relay!\n", This, PrimitiveType, VertexType, Vertices, VertexCount, Flags); TRACE("(%p)->(%08x,%08x,%p,%08x,%08x): Relay!\n", This, PrimitiveType, VertexType, Vertices, VertexCount, Flags);
if(!Vertices) if(!Vertices)
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
/* Get the vertex count */
switch(PrimitiveType)
{
case D3DPT_POINTLIST:
PrimitiveCount = VertexCount;
break;
case D3DPT_LINELIST:
PrimitiveCount = VertexCount / 2;
break;
case D3DPT_LINESTRIP:
PrimitiveCount = VertexCount - 1;
break;
case D3DPT_TRIANGLELIST:
PrimitiveCount = VertexCount / 3;
break;
case D3DPT_TRIANGLESTRIP:
PrimitiveCount = VertexCount - 2;
break;
case D3DPT_TRIANGLEFAN:
PrimitiveCount = VertexCount - 2;
break;
default:
return DDERR_INVALIDPARAMS;
}
/* Get the stride */ /* Get the stride */
stride = get_flexible_vertex_size(VertexType); stride = get_flexible_vertex_size(VertexType);
...@@ -3517,7 +3486,7 @@ IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7 *iface, ...@@ -3517,7 +3486,7 @@ IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7 *iface,
/* This method translates to the user pointer draw of WineD3D */ /* This method translates to the user pointer draw of WineD3D */
hr = IWineD3DDevice_DrawPrimitiveUP(This->wineD3DDevice, hr = IWineD3DDevice_DrawPrimitiveUP(This->wineD3DDevice,
PrimitiveType, PrimitiveType,
PrimitiveCount, VertexCount,
Vertices, Vertices,
stride); stride);
LeaveCriticalSection(&ddraw_cs); LeaveCriticalSection(&ddraw_cs);
...@@ -3627,41 +3596,9 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7 *iface, ...@@ -3627,41 +3596,9 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
DWORD Flags) DWORD Flags)
{ {
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface; IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
UINT PrimitiveCount = 0;
HRESULT hr; HRESULT hr;
TRACE("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x): Relay!\n", This, PrimitiveType, VertexType, Vertices, VertexCount, Indices, IndexCount, Flags); TRACE("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x): Relay!\n", This, PrimitiveType, VertexType, Vertices, VertexCount, Indices, IndexCount, Flags);
/* Get the primitive number */
switch(PrimitiveType)
{
case D3DPT_POINTLIST:
PrimitiveCount = IndexCount;
break;
case D3DPT_LINELIST:
PrimitiveCount = IndexCount / 2;
break;
case D3DPT_LINESTRIP:
PrimitiveCount = IndexCount - 1;
break;
case D3DPT_TRIANGLELIST:
PrimitiveCount = IndexCount / 3;
break;
case D3DPT_TRIANGLESTRIP:
PrimitiveCount = IndexCount - 2;
break;
case D3DPT_TRIANGLEFAN:
PrimitiveCount = IndexCount - 2;
break;
default:
return DDERR_INVALIDPARAMS;
}
/* Set the D3DDevice's FVF */ /* Set the D3DDevice's FVF */
EnterCriticalSection(&ddraw_cs); EnterCriticalSection(&ddraw_cs);
hr = IWineD3DDevice_SetVertexDeclaration(This->wineD3DDevice, hr = IWineD3DDevice_SetVertexDeclaration(This->wineD3DDevice,
...@@ -3674,7 +3611,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7 *iface, ...@@ -3674,7 +3611,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
} }
hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->wineD3DDevice, PrimitiveType, 0 /* MinVertexIndex */, hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->wineD3DDevice, PrimitiveType, 0 /* MinVertexIndex */,
VertexCount /* UINT NumVertexIndex */, PrimitiveCount, Indices, WINED3DFMT_R16_UINT, Vertices, VertexCount /* UINT NumVertexIndex */, IndexCount, Indices, WINED3DFMT_R16_UINT, Vertices,
get_flexible_vertex_size(VertexType)); get_flexible_vertex_size(VertexType));
LeaveCriticalSection(&ddraw_cs); LeaveCriticalSection(&ddraw_cs);
return hr; return hr;
...@@ -3879,7 +3816,6 @@ IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7 *iface, ...@@ -3879,7 +3816,6 @@ IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7 *iface,
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface; IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
WineDirect3DVertexStridedData WineD3DStrided; WineDirect3DVertexStridedData WineD3DStrided;
DWORD i; DWORD i;
UINT PrimitiveCount;
HRESULT hr; HRESULT hr;
TRACE("(%p)->(%08x,%08x,%p,%08x,%08x): stub!\n", This, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags); TRACE("(%p)->(%08x,%08x,%p,%08x,%08x): stub!\n", This, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
...@@ -3940,41 +3876,11 @@ IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7 *iface, ...@@ -3940,41 +3876,11 @@ IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7 *iface,
} }
} }
/* Get the primitive count */
switch(PrimitiveType)
{
case D3DPT_POINTLIST:
PrimitiveCount = VertexCount;
break;
case D3DPT_LINELIST:
PrimitiveCount = VertexCount / 2;
break;
case D3DPT_LINESTRIP:
PrimitiveCount = VertexCount - 1;
break;
case D3DPT_TRIANGLELIST:
PrimitiveCount = VertexCount / 3;
break;
case D3DPT_TRIANGLESTRIP:
PrimitiveCount = VertexCount - 2;
break;
case D3DPT_TRIANGLEFAN:
PrimitiveCount = VertexCount - 2;
break;
default: return DDERR_INVALIDPARAMS;
}
/* WineD3D doesn't need the FVF here */ /* WineD3D doesn't need the FVF here */
EnterCriticalSection(&ddraw_cs); EnterCriticalSection(&ddraw_cs);
hr = IWineD3DDevice_DrawPrimitiveStrided(This->wineD3DDevice, hr = IWineD3DDevice_DrawPrimitiveStrided(This->wineD3DDevice,
PrimitiveType, PrimitiveType,
PrimitiveCount, VertexCount,
&WineD3DStrided); &WineD3DStrided);
LeaveCriticalSection(&ddraw_cs); LeaveCriticalSection(&ddraw_cs);
return hr; return hr;
...@@ -4053,7 +3959,6 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface, ...@@ -4053,7 +3959,6 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface,
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface; IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
WineDirect3DVertexStridedData WineD3DStrided; WineDirect3DVertexStridedData WineD3DStrided;
DWORD i; DWORD i;
UINT PrimitiveCount;
HRESULT hr; HRESULT hr;
TRACE("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x)\n", This, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags); TRACE("(%p)->(%08x,%08x,%p,%08x,%p,%08x,%08x)\n", This, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
...@@ -4114,40 +4019,10 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface, ...@@ -4114,40 +4019,10 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface,
} }
} }
/* Get the primitive count */
switch(PrimitiveType)
{
case D3DPT_POINTLIST:
PrimitiveCount = IndexCount;
break;
case D3DPT_LINELIST:
PrimitiveCount = IndexCount / 2;
break;
case D3DPT_LINESTRIP:
PrimitiveCount = IndexCount - 1;
break;
case D3DPT_TRIANGLELIST:
PrimitiveCount = IndexCount / 3;
break;
case D3DPT_TRIANGLESTRIP:
PrimitiveCount = IndexCount - 2;
break;
case D3DPT_TRIANGLEFAN:
PrimitiveCount = IndexCount - 2;
break;
default: return DDERR_INVALIDPARAMS;
}
/* WineD3D doesn't need the FVF here */ /* WineD3D doesn't need the FVF here */
EnterCriticalSection(&ddraw_cs); EnterCriticalSection(&ddraw_cs);
hr = IWineD3DDevice_DrawIndexedPrimitiveStrided(This->wineD3DDevice, PrimitiveType, hr = IWineD3DDevice_DrawIndexedPrimitiveStrided(This->wineD3DDevice, PrimitiveType,
PrimitiveCount, &WineD3DStrided, VertexCount, Indices, WINED3DFMT_R16_UINT); IndexCount, &WineD3DStrided, VertexCount, Indices, WINED3DFMT_R16_UINT);
LeaveCriticalSection(&ddraw_cs); LeaveCriticalSection(&ddraw_cs);
return hr; return hr;
} }
...@@ -4230,7 +4105,6 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface, ...@@ -4230,7 +4105,6 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
{ {
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface; IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IDirect3DVertexBufferImpl *vb = (IDirect3DVertexBufferImpl *)D3DVertexBuf; IDirect3DVertexBufferImpl *vb = (IDirect3DVertexBufferImpl *)D3DVertexBuf;
UINT PrimitiveCount;
HRESULT hr; HRESULT hr;
DWORD stride; DWORD stride;
WINED3DVERTEXBUFFER_DESC Desc; WINED3DVERTEXBUFFER_DESC Desc;
...@@ -4244,37 +4118,6 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface, ...@@ -4244,37 +4118,6 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }
/* Get the primitive count */
switch(PrimitiveType)
{
case D3DPT_POINTLIST:
PrimitiveCount = NumVertices;
break;
case D3DPT_LINELIST:
PrimitiveCount = NumVertices / 2;
break;
case D3DPT_LINESTRIP:
PrimitiveCount = NumVertices - 1;
break;
case D3DPT_TRIANGLELIST:
PrimitiveCount = NumVertices / 3;
break;
case D3DPT_TRIANGLESTRIP:
PrimitiveCount = NumVertices - 2;
break;
case D3DPT_TRIANGLEFAN:
PrimitiveCount = NumVertices - 2;
break;
default:
return DDERR_INVALIDPARAMS;
}
/* Get the FVF of the vertex buffer, and its stride */ /* Get the FVF of the vertex buffer, and its stride */
EnterCriticalSection(&ddraw_cs); EnterCriticalSection(&ddraw_cs);
hr = IWineD3DVertexBuffer_GetDesc(vb->wineD3DVertexBuffer, hr = IWineD3DVertexBuffer_GetDesc(vb->wineD3DVertexBuffer,
...@@ -4313,7 +4156,7 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface, ...@@ -4313,7 +4156,7 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
hr = IWineD3DDevice_DrawPrimitive(This->wineD3DDevice, hr = IWineD3DDevice_DrawPrimitive(This->wineD3DDevice,
PrimitiveType, PrimitiveType,
StartVertex, StartVertex,
PrimitiveCount); NumVertices);
LeaveCriticalSection(&ddraw_cs); LeaveCriticalSection(&ddraw_cs);
return hr; return hr;
} }
...@@ -4393,7 +4236,6 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface, ...@@ -4393,7 +4236,6 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface; IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IDirect3DVertexBufferImpl *vb = (IDirect3DVertexBufferImpl *)D3DVertexBuf; IDirect3DVertexBufferImpl *vb = (IDirect3DVertexBufferImpl *)D3DVertexBuf;
DWORD stride; DWORD stride;
UINT PrimitiveCount;
WORD *LockedIndices; WORD *LockedIndices;
HRESULT hr; HRESULT hr;
WINED3DVERTEXBUFFER_DESC Desc; WINED3DVERTEXBUFFER_DESC Desc;
...@@ -4401,43 +4243,13 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface, ...@@ -4401,43 +4243,13 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
TRACE("(%p)->(%08x,%p,%d,%d,%p,%d,%08x)\n", This, PrimitiveType, vb, StartVertex, NumVertices, Indices, IndexCount, Flags); TRACE("(%p)->(%08x,%p,%d,%d,%p,%d,%08x)\n", This, PrimitiveType, vb, StartVertex, NumVertices, Indices, IndexCount, Flags);
/* Steps: /* Steps:
* 1) Calculate some things: Vertex count -> Primitive count, stride, ... * 1) Calculate some things: stride, ...
* 2) Upload the Indices to the index buffer * 2) Upload the Indices to the index buffer
* 3) Set the index source * 3) Set the index source
* 4) Set the Vertex Buffer as the Stream source * 4) Set the Vertex Buffer as the Stream source
* 5) Call IWineD3DDevice::DrawIndexedPrimitive * 5) Call IWineD3DDevice::DrawIndexedPrimitive
*/ */
/* Get the primitive count */
switch(PrimitiveType)
{
case D3DPT_POINTLIST:
PrimitiveCount = IndexCount;
break;
case D3DPT_LINELIST:
PrimitiveCount = IndexCount / 2;
break;
case D3DPT_LINESTRIP:
PrimitiveCount = IndexCount - 1;
break;
case D3DPT_TRIANGLELIST:
PrimitiveCount = IndexCount / 3;
break;
case D3DPT_TRIANGLESTRIP:
PrimitiveCount = IndexCount - 2;
break;
case D3DPT_TRIANGLEFAN:
PrimitiveCount = IndexCount - 2;
break;
default: return DDERR_INVALIDPARAMS;
}
EnterCriticalSection(&ddraw_cs); EnterCriticalSection(&ddraw_cs);
/* Get the FVF of the vertex buffer, and its stride */ /* Get the FVF of the vertex buffer, and its stride */
hr = IWineD3DVertexBuffer_GetDesc(vb->wineD3DVertexBuffer, hr = IWineD3DVertexBuffer_GetDesc(vb->wineD3DVertexBuffer,
...@@ -4510,7 +4322,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface, ...@@ -4510,7 +4322,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
0 /* minIndex */, 0 /* minIndex */,
NumVertices, NumVertices,
0 /* StartIndex */, 0 /* StartIndex */,
PrimitiveCount); IndexCount);
LeaveCriticalSection(&ddraw_cs); LeaveCriticalSection(&ddraw_cs);
return hr; return hr;
......
...@@ -5301,14 +5301,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Coun ...@@ -5301,14 +5301,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Coun
/***** /*****
* Drawing functions * Drawing functions
*****/ *****/
static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, WINED3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface,
UINT PrimitiveCount) { WINED3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT vertex_count)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
TRACE("(%p) : Type=(%d,%s), Start=%d, Count=%d\n", This, PrimitiveType, TRACE("(%p) : type %u (%s), start %u, count %u\n", This, PrimitiveType,
debug_d3dprimitivetype(PrimitiveType), debug_d3dprimitivetype(PrimitiveType), StartVertex, vertex_count);
StartVertex, PrimitiveCount);
if(!This->stateBlock->vertexDecl) { if(!This->stateBlock->vertexDecl) {
WARN("(%p) : Called without a valid vertex declaration set\n", This); WARN("(%p) : Called without a valid vertex declaration set\n", This);
...@@ -5326,16 +5325,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, WI ...@@ -5326,16 +5325,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, WI
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
} }
/* Account for the loading offset due to index buffers. Instead of reloading all sources correct it with the startvertex parameter */ /* Account for the loading offset due to index buffers. Instead of reloading all sources correct it with the startvertex parameter */
drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0/* NumVertices */, StartVertex /* start_idx */, drawPrimitive(iface, PrimitiveType, vertex_count, 0/* NumVertices */, StartVertex /* start_idx */,
0 /* indxSize */, NULL /* indxData */, 0 /* minIndex */); 0 /* indxSize */, NULL /* indxData */, 0 /* minIndex */);
return WINED3D_OK; return WINED3D_OK;
} }
/* TODO: baseVIndex needs to be provided from This->stateBlock->baseVertexIndex when called from d3d8 */ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *iface,
static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *iface, WINED3DPRIMITIVETYPE PrimitiveType, UINT minIndex, UINT NumVertices, UINT startIndex, UINT index_count)
WINED3DPRIMITIVETYPE PrimitiveType, {
UINT minIndex, UINT NumVertices, UINT startIndex, UINT primCount) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
UINT idxStride = 2; UINT idxStride = 2;
IWineD3DIndexBuffer *pIB; IWineD3DIndexBuffer *pIB;
...@@ -5363,9 +5360,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice * ...@@ -5363,9 +5360,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *
} }
vbo = ((IWineD3DIndexBufferImpl *) pIB)->vbo; vbo = ((IWineD3DIndexBufferImpl *) pIB)->vbo;
TRACE("(%p) : Type=(%d,%s), min=%d, CountV=%d, startIdx=%d, countP=%d\n", This, TRACE("(%p) : type %u (%s), min %u, vertex count %u, startIdx %u, index count %u\n", This,
PrimitiveType, debug_d3dprimitivetype(PrimitiveType), PrimitiveType, debug_d3dprimitivetype(PrimitiveType), minIndex, NumVertices, startIndex, index_count);
minIndex, NumVertices, startIndex, primCount);
IWineD3DIndexBuffer_GetDesc(pIB, &IdxBufDsc); IWineD3DIndexBuffer_GetDesc(pIB, &IdxBufDsc);
if (IdxBufDsc.Format == WINED3DFMT_R16_UINT) { if (IdxBufDsc.Format == WINED3DFMT_R16_UINT) {
...@@ -5379,21 +5375,20 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice * ...@@ -5379,21 +5375,20 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
} }
drawPrimitive(iface, PrimitiveType, primCount, NumVertices, startIndex, drawPrimitive(iface, PrimitiveType, index_count, NumVertices, startIndex,
idxStride, vbo ? NULL : ((IWineD3DIndexBufferImpl *) pIB)->resource.allocatedMemory, minIndex); idxStride, vbo ? NULL : ((IWineD3DIndexBufferImpl *) pIB)->resource.allocatedMemory, minIndex);
return WINED3D_OK; return WINED3D_OK;
} }
static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface, WINED3DPRIMITIVETYPE PrimitiveType, static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface, WINED3DPRIMITIVETYPE PrimitiveType,
UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT vertex_count, const void *pVertexStreamZeroData, UINT VertexStreamZeroStride)
UINT VertexStreamZeroStride) { {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DVertexBuffer *vb; IWineD3DVertexBuffer *vb;
TRACE("(%p) : Type=(%d,%s), pCount=%d, pVtxData=%p, Stride=%d\n", This, PrimitiveType, TRACE("(%p) : type %u (%s), vertex count %u, pVtxData %p, stride %u\n", This, PrimitiveType,
debug_d3dprimitivetype(PrimitiveType), debug_d3dprimitivetype(PrimitiveType), vertex_count, pVertexStreamZeroData, VertexStreamZeroStride);
PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
if(!This->stateBlock->vertexDecl) { if(!This->stateBlock->vertexDecl) {
WARN("(%p) : Called without a valid vertex declaration set\n", This); WARN("(%p) : Called without a valid vertex declaration set\n", This);
...@@ -5412,8 +5407,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface, ...@@ -5412,8 +5407,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface,
/* TODO: Only mark dirty if drawing from a different UP address */ /* TODO: Only mark dirty if drawing from a different UP address */
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0 /* NumVertices */, drawPrimitive(iface, PrimitiveType, vertex_count, 0 /* NumVertices */,
0 /* start_idx */, 0 /* indxSize*/, NULL /* indxData */, 0 /* indxMin */); 0 /* start_idx */, 0 /* indxSize*/, NULL /* indxData */, 0 /* indxMin */);
/* MSDN specifies stream zero settings must be set to NULL */ /* MSDN specifies stream zero settings must be set to NULL */
This->stateBlock->streamStride[0] = 0; This->stateBlock->streamStride[0] = 0;
...@@ -5425,20 +5420,19 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface, ...@@ -5425,20 +5420,19 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface,
return WINED3D_OK; return WINED3D_OK;
} }
static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *iface, WINED3DPRIMITIVETYPE PrimitiveType, static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *iface,
UINT MinVertexIndex, UINT NumVertices, WINED3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices,
UINT PrimitiveCount, CONST void* pIndexData, UINT index_count, const void *pIndexData, WINED3DFORMAT IndexDataFormat,
WINED3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData, const void *pVertexStreamZeroData, UINT VertexStreamZeroStride)
UINT VertexStreamZeroStride) { {
int idxStride; int idxStride;
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DVertexBuffer *vb; IWineD3DVertexBuffer *vb;
IWineD3DIndexBuffer *ib; IWineD3DIndexBuffer *ib;
TRACE("(%p) : Type=(%d,%s), MinVtxIdx=%d, NumVIdx=%d, PCount=%d, pidxdata=%p, IdxFmt=%d, pVtxdata=%p, stride=%d\n", TRACE("(%p) : type %u (%s), MinVtxIdx %u, NumVIdx %u, index count %u, pidxdata %p, IdxFmt %u, pVtxdata %p, stride=%u\n",
This, PrimitiveType, debug_d3dprimitivetype(PrimitiveType), This, PrimitiveType, debug_d3dprimitivetype(PrimitiveType), MinVertexIndex, NumVertices, index_count,
MinVertexIndex, NumVertices, PrimitiveCount, pIndexData, pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
if(!This->stateBlock->vertexDecl) { if(!This->stateBlock->vertexDecl) {
WARN("(%p) : Called without a valid vertex declaration set\n", This); WARN("(%p) : Called without a valid vertex declaration set\n", This);
...@@ -5466,7 +5460,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice * ...@@ -5466,7 +5460,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
drawPrimitive(iface, PrimitiveType, PrimitiveCount, NumVertices, 0 /* start_idx */, idxStride, pIndexData, MinVertexIndex); drawPrimitive(iface, PrimitiveType, index_count, NumVertices,
0 /* start_idx */, idxStride, pIndexData, MinVertexIndex);
/* MSDN specifies stream zero settings and index buffer must be set to NULL */ /* MSDN specifies stream zero settings and index buffer must be set to NULL */
This->stateBlock->streamSource[0] = NULL; This->stateBlock->streamSource[0] = NULL;
...@@ -5484,8 +5479,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice * ...@@ -5484,8 +5479,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *
} }
static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided(IWineD3DDevice *iface, static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided(IWineD3DDevice *iface,
WINED3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, WINED3DPRIMITIVETYPE PrimitiveType, UINT vertex_count, const WineDirect3DVertexStridedData *DrawPrimStrideData)
const WineDirect3DVertexStridedData *DrawPrimStrideData)
{ {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
...@@ -5497,15 +5491,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided(IWineD3DDevice *if ...@@ -5497,15 +5491,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided(IWineD3DDevice *if
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
This->stateBlock->baseVertexIndex = 0; This->stateBlock->baseVertexIndex = 0;
This->up_strided = DrawPrimStrideData; This->up_strided = DrawPrimStrideData;
drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0, 0, 0, NULL, 0); drawPrimitive(iface, PrimitiveType, vertex_count, 0, 0, 0, NULL, 0);
This->up_strided = NULL; This->up_strided = NULL;
return WINED3D_OK; return WINED3D_OK;
} }
static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveStrided(IWineD3DDevice *iface, static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveStrided(IWineD3DDevice *iface,
WINED3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, WINED3DPRIMITIVETYPE PrimitiveType, UINT vertex_count, const WineDirect3DVertexStridedData *DrawPrimStrideData,
const WineDirect3DVertexStridedData *DrawPrimStrideData, UINT NumVertices, const void *pIndexData, UINT NumVertices, const void *pIndexData, WINED3DFORMAT IndexDataFormat)
WINED3DFORMAT IndexDataFormat)
{ {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
DWORD idxSize = (IndexDataFormat == WINED3DFMT_R32_UINT ? 4 : 2); DWORD idxSize = (IndexDataFormat == WINED3DFMT_R32_UINT ? 4 : 2);
...@@ -5519,7 +5512,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveStrided(IWineD3DDev ...@@ -5519,7 +5512,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveStrided(IWineD3DDev
This->stateBlock->streamIsUP = TRUE; This->stateBlock->streamIsUP = TRUE;
This->stateBlock->baseVertexIndex = 0; This->stateBlock->baseVertexIndex = 0;
This->up_strided = DrawPrimStrideData; This->up_strided = DrawPrimStrideData;
drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0 /* numindices */, 0 /* start_idx */, idxSize, pIndexData, 0 /* minindex */); drawPrimitive(iface, PrimitiveType, vertex_count, 0 /* numindices */,
0 /* start_idx */, idxSize, pIndexData, 0 /* minindex */);
This->up_strided = NULL; This->up_strided = NULL;
return WINED3D_OK; return WINED3D_OK;
} }
......
...@@ -32,56 +32,34 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_draw); ...@@ -32,56 +32,34 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_draw);
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
/* Issues the glBegin call for gl given the primitive type and count */ /* Note that except for WINED3DPT_POINTLIST and WINED3DPT_LINELIST these
static DWORD primitiveToGl(WINED3DPRIMITIVETYPE PrimitiveType, * actually have the same values in GL and D3D. */
DWORD NumPrimitives, static GLenum primitive_to_gl(WINED3DPRIMITIVETYPE primitive_type)
GLenum *primType)
{ {
DWORD NumVertexes = NumPrimitives; switch(primitive_type)
{
switch (PrimitiveType) { case WINED3DPT_POINTLIST:
case WINED3DPT_POINTLIST: return GL_POINTS;
TRACE("POINTS\n");
*primType = GL_POINTS; case WINED3DPT_LINELIST:
NumVertexes = NumPrimitives; return GL_LINES;
break;
case WINED3DPT_LINESTRIP:
case WINED3DPT_LINELIST: return GL_LINE_STRIP;
TRACE("LINES\n");
*primType = GL_LINES; case WINED3DPT_TRIANGLELIST:
NumVertexes = NumPrimitives * 2; return GL_TRIANGLES;
break;
case WINED3DPT_TRIANGLESTRIP:
case WINED3DPT_LINESTRIP: return GL_TRIANGLE_STRIP;
TRACE("LINE_STRIP\n");
*primType = GL_LINE_STRIP; case WINED3DPT_TRIANGLEFAN:
NumVertexes = NumPrimitives + 1; return GL_TRIANGLE_FAN;
break;
default:
case WINED3DPT_TRIANGLELIST: FIXME("Unhandled primitive type %s\n", debug_d3dprimitivetype(primitive_type));
TRACE("TRIANGLES\n"); return GL_NONE;
*primType = GL_TRIANGLES;
NumVertexes = NumPrimitives * 3;
break;
case WINED3DPT_TRIANGLESTRIP:
TRACE("TRIANGLE_STRIP\n");
*primType = GL_TRIANGLE_STRIP;
NumVertexes = NumPrimitives + 2;
break;
case WINED3DPT_TRIANGLEFAN:
TRACE("TRIANGLE_FAN\n");
*primType = GL_TRIANGLE_FAN;
NumVertexes = NumPrimitives + 2;
break;
default:
FIXME("Unhandled primitive\n");
*primType = GL_POINTS;
break;
} }
return NumVertexes;
} }
static BOOL fixed_get_input( static BOOL fixed_get_input(
...@@ -829,7 +807,7 @@ static inline void remove_vbos(IWineD3DDeviceImpl *This, WineDirect3DVertexStrid ...@@ -829,7 +807,7 @@ static inline void remove_vbos(IWineD3DDeviceImpl *This, WineDirect3DVertexStrid
} }
/* Routine common to the draw primitive and draw indexed primitive routines */ /* Routine common to the draw primitive and draw indexed primitive routines */
void drawPrimitive(IWineD3DDevice *iface, int PrimitiveType, long NumPrimitives, void drawPrimitive(IWineD3DDevice *iface, WINED3DPRIMITIVETYPE PrimitiveType, UINT index_count,
UINT numberOfVertices, long StartIdx, short idxSize, const void *idxData, int minIndex) UINT numberOfVertices, long StartIdx, short idxSize, const void *idxData, int minIndex)
{ {
...@@ -837,7 +815,7 @@ void drawPrimitive(IWineD3DDevice *iface, int PrimitiveType, long NumPrimitives, ...@@ -837,7 +815,7 @@ void drawPrimitive(IWineD3DDevice *iface, int PrimitiveType, long NumPrimitives,
IWineD3DSurfaceImpl *target; IWineD3DSurfaceImpl *target;
unsigned int i; unsigned int i;
if (NumPrimitives == 0) return; if (!index_count) return;
/* Invalidate the back buffer memory so LockRect will read it the next time */ /* Invalidate the back buffer memory so LockRect will read it the next time */
for(i = 0; i < GL_LIMITS(buffers); i++) { for(i = 0; i < GL_LIMITS(buffers); i++) {
...@@ -870,9 +848,9 @@ void drawPrimitive(IWineD3DDevice *iface, int PrimitiveType, long NumPrimitives, ...@@ -870,9 +848,9 @@ void drawPrimitive(IWineD3DDevice *iface, int PrimitiveType, long NumPrimitives,
WineDirect3DVertexStridedData stridedlcl; WineDirect3DVertexStridedData stridedlcl;
/* Ok, Work out which primitive is requested and how many vertexes that /* Ok, Work out which primitive is requested and how many vertexes that
will be */ will be */
UINT calculatedNumberOfindices = primitiveToGl(PrimitiveType, NumPrimitives, &glPrimType); glPrimType = primitive_to_gl(PrimitiveType);
if (numberOfVertices == 0 )
numberOfVertices = calculatedNumberOfindices; if (!numberOfVertices) numberOfVertices = index_count;
if (!use_vs(This->stateBlock)) if (!use_vs(This->stateBlock))
{ {
...@@ -920,19 +898,17 @@ void drawPrimitive(IWineD3DDevice *iface, int PrimitiveType, long NumPrimitives, ...@@ -920,19 +898,17 @@ void drawPrimitive(IWineD3DDevice *iface, int PrimitiveType, long NumPrimitives,
} else { } else {
TRACE("Using immediate mode with vertex shaders for half float emulation\n"); TRACE("Using immediate mode with vertex shaders for half float emulation\n");
} }
drawStridedSlowVs(iface, strided, calculatedNumberOfindices, drawStridedSlowVs(iface, strided, index_count, glPrimType, idxData, idxSize, minIndex, StartIdx);
glPrimType, idxData, idxSize, minIndex, StartIdx);
} else { } else {
drawStridedSlow(iface, strided, calculatedNumberOfindices, drawStridedSlow(iface, strided, index_count, glPrimType, idxData, idxSize, minIndex, StartIdx);
glPrimType, idxData, idxSize, minIndex, StartIdx);
} }
} else if(This->instancedDraw) { } else if(This->instancedDraw) {
/* Instancing emulation with mixing immediate mode and arrays */ /* Instancing emulation with mixing immediate mode and arrays */
drawStridedInstanced(iface, &This->strided_streams, calculatedNumberOfindices, glPrimType, drawStridedInstanced(iface, &This->strided_streams, index_count,
idxData, idxSize, minIndex, StartIdx); glPrimType, idxData, idxSize, minIndex, StartIdx);
} else { } else {
drawStridedFast(iface, glPrimType, minIndex, minIndex + numberOfVertices - 1, drawStridedFast(iface, glPrimType, minIndex, minIndex + numberOfVertices - 1,
calculatedNumberOfindices, idxSize, idxData, StartIdx); index_count, idxSize, idxData, StartIdx);
} }
} }
......
...@@ -653,7 +653,7 @@ extern LONG primCounter; ...@@ -653,7 +653,7 @@ extern LONG primCounter;
*/ */
/* Routine common to the draw primitive and draw indexed primitive routines */ /* Routine common to the draw primitive and draw indexed primitive routines */
void drawPrimitive(IWineD3DDevice *iface, int PrimitiveType, long NumPrimitives, void drawPrimitive(IWineD3DDevice *iface, WINED3DPRIMITIVETYPE PrimitiveType, UINT index_count,
UINT numberOfVertices, long start_idx, short idxBytes, const void *idxData, int minIndex); UINT numberOfVertices, long start_idx, short idxBytes, const void *idxData, int minIndex);
void primitiveDeclarationConvertToStridedData( void primitiveDeclarationConvertToStridedData(
......
...@@ -3483,18 +3483,18 @@ interface IWineD3DDevice : IWineD3DBase ...@@ -3483,18 +3483,18 @@ interface IWineD3DDevice : IWineD3DBase
HRESULT DrawPrimitive( HRESULT DrawPrimitive(
[in] WINED3DPRIMITIVETYPE primitive_type, [in] WINED3DPRIMITIVETYPE primitive_type,
[in] UINT start_vertex, [in] UINT start_vertex,
[in] UINT primitive_count [in] UINT vertex_count
); );
HRESULT DrawIndexedPrimitive( HRESULT DrawIndexedPrimitive(
[in] WINED3DPRIMITIVETYPE primitive_type, [in] WINED3DPRIMITIVETYPE primitive_type,
[in] UINT min_vertex_idx, [in] UINT min_vertex_idx,
[in] UINT vertex_count, [in] UINT vertex_count,
[in] UINT start_idx, [in] UINT start_idx,
[in] UINT primitive_count [in] UINT index_count
); );
HRESULT DrawPrimitiveUP( HRESULT DrawPrimitiveUP(
[in] WINED3DPRIMITIVETYPE primitive_type, [in] WINED3DPRIMITIVETYPE primitive_type,
[in] UINT primitive_count, [in] UINT vertex_count,
[in] const void *stream_data, [in] const void *stream_data,
[in] UINT stream_stride [in] UINT stream_stride
); );
...@@ -3502,7 +3502,7 @@ interface IWineD3DDevice : IWineD3DBase ...@@ -3502,7 +3502,7 @@ interface IWineD3DDevice : IWineD3DBase
[in] WINED3DPRIMITIVETYPE primitive_type, [in] WINED3DPRIMITIVETYPE primitive_type,
[in] UINT min_vertex_idx, [in] UINT min_vertex_idx,
[in] UINT vertex_count, [in] UINT vertex_count,
[in] UINT primitive_count, [in] UINT index_count,
[in] const void *index_data, [in] const void *index_data,
[in] WINED3DFORMAT index_data_format, [in] WINED3DFORMAT index_data_format,
[in] const void *stream_data, [in] const void *stream_data,
...@@ -3510,12 +3510,12 @@ interface IWineD3DDevice : IWineD3DBase ...@@ -3510,12 +3510,12 @@ interface IWineD3DDevice : IWineD3DBase
); );
HRESULT DrawPrimitiveStrided( HRESULT DrawPrimitiveStrided(
[in] WINED3DPRIMITIVETYPE primitive_type, [in] WINED3DPRIMITIVETYPE primitive_type,
[in] UINT primitive_count, [in] UINT vertex_count,
[in] const WineDirect3DVertexStridedData *strided_data [in] const WineDirect3DVertexStridedData *strided_data
); );
HRESULT DrawIndexedPrimitiveStrided( HRESULT DrawIndexedPrimitiveStrided(
[in] WINED3DPRIMITIVETYPE primitive_type, [in] WINED3DPRIMITIVETYPE primitive_type,
[in] UINT primitive_count, [in] UINT index_count,
[in] const WineDirect3DVertexStridedData *strided_data, [in] const WineDirect3DVertexStridedData *strided_data,
[in] UINT vertex_count, [in] UINT vertex_count,
[in] const void *index_data, [in] const void *index_data,
......
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