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

d3d: Remove the format from index buffers.

parent f0efa974
...@@ -353,6 +353,8 @@ struct IDirect3DIndexBuffer8Impl ...@@ -353,6 +353,8 @@ struct IDirect3DIndexBuffer8Impl
/* Parent reference */ /* Parent reference */
LPDIRECT3DDEVICE8 parentDevice; LPDIRECT3DDEVICE8 parentDevice;
WINED3DFORMAT format;
}; };
/* --------------------- */ /* --------------------- */
......
...@@ -773,10 +773,11 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(LPDIRECT3DDEVICE8 i ...@@ -773,10 +773,11 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(LPDIRECT3DDEVICE8 i
object->lpVtbl = &Direct3DIndexBuffer8_Vtbl; object->lpVtbl = &Direct3DIndexBuffer8_Vtbl;
object->ref = 1; object->ref = 1;
object->format = wined3dformat_from_d3dformat(Format);
TRACE("Calling wined3d create index buffer\n"); TRACE("Calling wined3d create index buffer\n");
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage & WINED3DUSAGE_MASK, hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage & WINED3DUSAGE_MASK,
wined3dformat_from_d3dformat(Format), (WINED3DPOOL) Pool, &object->wineD3DIndexBuffer, (WINED3DPOOL) Pool, &object->wineD3DIndexBuffer,
NULL, (IUnknown *)object); NULL, (IUnknown *)object);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
...@@ -2085,6 +2086,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(LPDIRECT3DDEV ...@@ -2085,6 +2086,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(LPDIRECT3DDEV
static HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8* pIndexData, UINT baseVertexIndex) { static HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8* pIndexData, UINT baseVertexIndex) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hr; HRESULT hr;
IDirect3DIndexBuffer8Impl *ib = (IDirect3DIndexBuffer8Impl *)pIndexData;
TRACE("(%p) Relay\n", This); TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
...@@ -2096,7 +2098,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, I ...@@ -2096,7 +2098,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, I
*/ */
IWineD3DDevice_SetBaseVertexIndex(This->WineD3DDevice, baseVertexIndex); IWineD3DDevice_SetBaseVertexIndex(This->WineD3DDevice, baseVertexIndex);
hr = IWineD3DDevice_SetIndices(This->WineD3DDevice, hr = IWineD3DDevice_SetIndices(This->WineD3DDevice,
pIndexData ? ((IDirect3DIndexBuffer8Impl *)pIndexData)->wineD3DIndexBuffer : NULL); ib ? ib->wineD3DIndexBuffer : NULL,
ib ? ib->format : WINED3DFMT_UNKNOWN);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
......
...@@ -188,7 +188,7 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 i ...@@ -188,7 +188,7 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 i
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
pDesc->Format = d3dformat_from_wined3dformat(desc.Format); pDesc->Format = d3dformat_from_wined3dformat(This->format);
pDesc->Type = D3DRTYPE_INDEXBUFFER; pDesc->Type = D3DRTYPE_INDEXBUFFER;
pDesc->Usage = desc.Usage; pDesc->Usage = desc.Usage;
pDesc->Pool = desc.Pool; pDesc->Pool = desc.Pool;
......
...@@ -195,7 +195,7 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8 ...@@ -195,7 +195,7 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8
pDesc->Pool = desc.Pool; pDesc->Pool = desc.Pool;
pDesc->Size = desc.Size; pDesc->Size = desc.Size;
pDesc->FVF = This->fvf; pDesc->FVF = This->fvf;
pDesc->Format = d3dformat_from_wined3dformat(desc.Format); pDesc->Format = D3DFMT_VERTEXDATA;
} }
return hr; return hr;
......
...@@ -351,6 +351,7 @@ typedef struct IDirect3DIndexBuffer9Impl ...@@ -351,6 +351,7 @@ typedef struct IDirect3DIndexBuffer9Impl
/* Parent reference */ /* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice; LPDIRECT3DDEVICE9EX parentDevice;
WINED3DFORMAT format;
} IDirect3DIndexBuffer9Impl; } IDirect3DIndexBuffer9Impl;
/* --------------------- */ /* --------------------- */
......
...@@ -516,8 +516,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3 ...@@ -516,8 +516,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3
* below fails, the device is considered "lost", and _Reset and _Release are the only allowed calls * below fails, the device is considered "lost", and _Reset and _Release are the only allowed calls
*/ */
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
IWineD3DDevice_SetIndices(This->WineD3DDevice, NULL, WINED3DFMT_UNKNOWN);
IWineD3DDevice_SetIndices(This->WineD3DDevice, NULL);
for(i = 0; i < 16; i++) { for(i = 0; i < 16; i++) {
IWineD3DDevice_SetStreamSource(This->WineD3DDevice, i, NULL, 0, 0); IWineD3DDevice_SetStreamSource(This->WineD3DDevice, i, NULL, 0, 0);
} }
...@@ -1639,11 +1638,13 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVIC ...@@ -1639,11 +1638,13 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVIC
static HRESULT WINAPI IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9EX iface, IDirect3DIndexBuffer9* pIndexData) { static HRESULT WINAPI IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9EX iface, IDirect3DIndexBuffer9* pIndexData) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr; HRESULT hr;
IDirect3DIndexBuffer9Impl *ib = (IDirect3DIndexBuffer9Impl *) pIndexData;
TRACE("(%p) Relay\n", This); TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
hr = IWineD3DDevice_SetIndices(This->WineD3DDevice, hr = IWineD3DDevice_SetIndices(This->WineD3DDevice,
pIndexData ? ((IDirect3DIndexBuffer9Impl *)pIndexData)->wineD3DIndexBuffer : NULL); ib ? ib->wineD3DIndexBuffer : NULL,
ib ? ib->format : WINED3DFMT_UNKNOWN);
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
return hr; return hr;
} }
......
...@@ -189,7 +189,7 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDesc(LPDIRECT3DINDEXB ...@@ -189,7 +189,7 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDesc(LPDIRECT3DINDEXB
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
pDesc->Format = d3dformat_from_wined3dformat(desc.Format); pDesc->Format = d3dformat_from_wined3dformat(This->format);
pDesc->Usage = desc.Usage; pDesc->Usage = desc.Usage;
pDesc->Pool = desc.Pool; pDesc->Pool = desc.Pool;
pDesc->Size = desc.Size; pDesc->Size = desc.Size;
...@@ -241,10 +241,11 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9EX iface, ...@@ -241,10 +241,11 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9EX iface,
object->lpVtbl = &Direct3DIndexBuffer9_Vtbl; object->lpVtbl = &Direct3DIndexBuffer9_Vtbl;
object->ref = 1; object->ref = 1;
object->format = wined3dformat_from_d3dformat(Format);
TRACE("Calling wined3d create index buffer\n"); TRACE("Calling wined3d create index buffer\n");
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage & WINED3DUSAGE_MASK, hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage & WINED3DUSAGE_MASK,
wined3dformat_from_d3dformat(Format), (WINED3DPOOL)Pool, &object->wineD3DIndexBuffer, (WINED3DPOOL)Pool, &object->wineD3DIndexBuffer,
pSharedHandle, (IUnknown *)object); pSharedHandle, (IUnknown *)object);
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
if (hrc != D3D_OK) { if (hrc != D3D_OK) {
......
...@@ -193,7 +193,7 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDesc(LPDIRECT3DVERTEXBUFFER9 ...@@ -193,7 +193,7 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDesc(LPDIRECT3DVERTEXBUFFER9
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
pDesc->Format = d3dformat_from_wined3dformat(desc.Format); pDesc->Format = D3DFMT_VERTEXDATA;
pDesc->Usage = desc.Usage; pDesc->Usage = desc.Usage;
pDesc->Pool = desc.Pool; pDesc->Pool = desc.Pool;
pDesc->Size = desc.Size; pDesc->Size = desc.Size;
......
...@@ -316,7 +316,7 @@ IDirect3DDeviceImpl_7_Release(IDirect3DDevice7 *iface) ...@@ -316,7 +316,7 @@ IDirect3DDeviceImpl_7_Release(IDirect3DDevice7 *iface)
EnterCriticalSection(&ddraw_cs); EnterCriticalSection(&ddraw_cs);
/* Free the index buffer. */ /* Free the index buffer. */
IWineD3DDevice_SetIndices(This->wineD3DDevice, NULL); IWineD3DDevice_SetIndices(This->wineD3DDevice, NULL, WINED3DFMT_UNKNOWN);
IWineD3DBuffer_GetParent(This->indexbuffer, IWineD3DBuffer_GetParent(This->indexbuffer,
(IUnknown **) &IndexBufferParent); (IUnknown **) &IndexBufferParent);
IParent_Release(IndexBufferParent); /* Once for the getParent */ IParent_Release(IndexBufferParent); /* Once for the getParent */
...@@ -4272,7 +4272,8 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface, ...@@ -4272,7 +4272,8 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
/* Set the index stream */ /* Set the index stream */
IWineD3DDevice_SetBaseVertexIndex(This->wineD3DDevice, StartVertex); IWineD3DDevice_SetBaseVertexIndex(This->wineD3DDevice, StartVertex);
hr = IWineD3DDevice_SetIndices(This->wineD3DDevice, This->indexbuffer); hr = IWineD3DDevice_SetIndices(This->wineD3DDevice, This->indexbuffer,
WINED3DFMT_R16_UINT);
/* Set the vertex stream source */ /* Set the vertex stream source */
hr = IWineD3DDevice_SetStreamSource(This->wineD3DDevice, hr = IWineD3DDevice_SetStreamSource(This->wineD3DDevice,
......
...@@ -824,7 +824,7 @@ IDirect3DImpl_7_CreateDevice(IDirect3D7 *iface, ...@@ -824,7 +824,7 @@ IDirect3DImpl_7_CreateDevice(IDirect3D7 *iface,
* takes the pointer and avoids the memcpy * takes the pointer and avoids the memcpy
*/ */
hr = IWineD3DDevice_CreateIndexBuffer(This->wineD3DDevice, 0x40000 /* Length. Don't know how long it should be */, hr = IWineD3DDevice_CreateIndexBuffer(This->wineD3DDevice, 0x40000 /* Length. Don't know how long it should be */,
WINED3DUSAGE_DYNAMIC /* Usage */, WINED3DFMT_R16_UINT /* Format. D3D7 uses WORDS */, WINED3DPOOL_DEFAULT, WINED3DUSAGE_DYNAMIC /* Usage */, WINED3DPOOL_DEFAULT,
&object->indexbuffer, 0 /* Handle */, (IUnknown *)IndexBufferParent); &object->indexbuffer, 0 /* Handle */, (IUnknown *)IndexBufferParent);
if(FAILED(hr)) if(FAILED(hr))
......
...@@ -310,7 +310,7 @@ IDirectDrawSurfaceImpl_Release(IDirectDrawSurface7 *iface) ...@@ -310,7 +310,7 @@ IDirectDrawSurfaceImpl_Release(IDirectDrawSurface7 *iface)
TRACE("(%p) Destroying the render target, uninitializing D3D\n", This); TRACE("(%p) Destroying the render target, uninitializing D3D\n", This);
/* Unset any index buffer, just to be sure */ /* Unset any index buffer, just to be sure */
IWineD3DDevice_SetIndices(ddraw->wineD3DDevice, NULL); IWineD3DDevice_SetIndices(ddraw->wineD3DDevice, NULL, WINED3DFMT_UNKNOWN);
IWineD3DDevice_SetDepthStencilSurface(ddraw->wineD3DDevice, NULL); IWineD3DDevice_SetDepthStencilSurface(ddraw->wineD3DDevice, NULL);
IWineD3DDevice_SetVertexDeclaration(ddraw->wineD3DDevice, NULL); IWineD3DDevice_SetVertexDeclaration(ddraw->wineD3DDevice, NULL);
for(i = 0; i < ddraw->numConvertedDecls; i++) for(i = 0; i < ddraw->numConvertedDecls; i++)
......
...@@ -937,7 +937,6 @@ static HRESULT STDMETHODCALLTYPE buffer_GetDesc(IWineD3DBuffer *iface, WINED3DBU ...@@ -937,7 +937,6 @@ static HRESULT STDMETHODCALLTYPE buffer_GetDesc(IWineD3DBuffer *iface, WINED3DBU
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
desc->Format = This->resource.format_desc->format;
desc->Type = This->resource.resourceType; desc->Type = This->resource.resourceType;
desc->Usage = This->resource.usage; desc->Usage = This->resource.usage;
desc->Pool = This->resource.pool; desc->Pool = This->resource.pool;
......
...@@ -583,10 +583,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *ifac ...@@ -583,10 +583,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *ifac
} }
static HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface, UINT Length, DWORD Usage, static HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface, UINT Length, DWORD Usage,
WINED3DFORMAT Format, WINED3DPOOL Pool, IWineD3DBuffer** ppIndexBuffer, WINED3DPOOL Pool, IWineD3DBuffer** ppIndexBuffer,
HANDLE *sharedHandle, IUnknown *parent) { HANDLE *sharedHandle, IUnknown *parent) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(Format, &This->adapter->gl_info); const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(WINED3DFMT_UNKNOWN, &This->adapter->gl_info);
struct wined3d_buffer *object; struct wined3d_buffer *object;
HRESULT hr; HRESULT hr;
...@@ -620,8 +620,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface ...@@ -620,8 +620,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface
object->flags |= WINED3D_BUFFER_CREATEBO; object->flags |= WINED3D_BUFFER_CREATEBO;
} }
TRACE("(%p) : Len=%d, Use=%x, Format=(%u,%s), Pool=%d - Memory@%p, Iface@%p\n", This, Length, Usage, Format, TRACE("(%p) : Len=%d, Use=%x, Pool=%d - Memory@%p, Iface@%p\n", This, Length, Usage,
debug_d3dformat(Format), Pool, object, object->resource.allocatedMemory); Pool, object, object->resource.allocatedMemory);
*ppIndexBuffer = (IWineD3DBuffer *) object; *ppIndexBuffer = (IWineD3DBuffer *) object;
return WINED3D_OK; return WINED3D_OK;
...@@ -3637,7 +3637,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetMaterial(IWineD3DDevice *iface, WINE ...@@ -3637,7 +3637,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetMaterial(IWineD3DDevice *iface, WINE
/***** /*****
* Get / Set Indices * Get / Set Indices
*****/ *****/
static HRESULT WINAPI IWineD3DDeviceImpl_SetIndices(IWineD3DDevice *iface, IWineD3DBuffer* pIndexData) { static HRESULT WINAPI IWineD3DDeviceImpl_SetIndices(IWineD3DDevice *iface, IWineD3DBuffer* pIndexData, WINED3DFORMAT fmt) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DBuffer *oldIdxs; IWineD3DBuffer *oldIdxs;
...@@ -3646,6 +3646,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetIndices(IWineD3DDevice *iface, IWine ...@@ -3646,6 +3646,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetIndices(IWineD3DDevice *iface, IWine
This->updateStateBlock->changed.indices = TRUE; This->updateStateBlock->changed.indices = TRUE;
This->updateStateBlock->pIndexData = pIndexData; This->updateStateBlock->pIndexData = pIndexData;
This->updateStateBlock->IndexFmt = fmt;
/* Handle recording of state blocks */ /* Handle recording of state blocks */
if (This->isRecordingState) { if (This->isRecordingState) {
...@@ -5639,7 +5640,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *if ...@@ -5639,7 +5640,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *if
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
UINT idxStride = 2; UINT idxStride = 2;
IWineD3DBuffer *pIB; IWineD3DBuffer *pIB;
WINED3DBUFFER_DESC IdxBufDsc;
GLuint vbo; GLuint vbo;
pIB = This->stateBlock->pIndexData; pIB = This->stateBlock->pIndexData;
...@@ -5666,8 +5666,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *if ...@@ -5666,8 +5666,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *if
TRACE("(%p) : min %u, vertex count %u, startIdx %u, index count %u\n", TRACE("(%p) : min %u, vertex count %u, startIdx %u, index count %u\n",
This, minIndex, NumVertices, startIndex, index_count); This, minIndex, NumVertices, startIndex, index_count);
IWineD3DBuffer_GetDesc(pIB, &IdxBufDsc); if (This->stateBlock->IndexFmt == WINED3DFMT_R16_UINT) {
if (IdxBufDsc.Format == WINED3DFMT_R16_UINT) {
idxStride = 2; idxStride = 2;
} else { } else {
idxStride = 4; idxStride = 4;
......
...@@ -195,6 +195,7 @@ void stateblock_copy( ...@@ -195,6 +195,7 @@ void stateblock_copy(
Dest->vertexShader = This->vertexShader; Dest->vertexShader = This->vertexShader;
Dest->streamIsUP = This->streamIsUP; Dest->streamIsUP = This->streamIsUP;
Dest->pIndexData = This->pIndexData; Dest->pIndexData = This->pIndexData;
Dest->IndexFmt = This->IndexFmt;
Dest->baseVertexIndex = This->baseVertexIndex; Dest->baseVertexIndex = This->baseVertexIndex;
/* Dest->lights = This->lights; */ /* Dest->lights = This->lights; */
Dest->clip_status = This->clip_status; Dest->clip_status = This->clip_status;
...@@ -506,13 +507,15 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface) ...@@ -506,13 +507,15 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
if (This->changed.primitive_type) This->gl_primitive_type = targetStateBlock->gl_primitive_type; if (This->changed.primitive_type) This->gl_primitive_type = targetStateBlock->gl_primitive_type;
if (This->changed.indices && ((This->pIndexData != targetStateBlock->pIndexData) if (This->changed.indices && ((This->pIndexData != targetStateBlock->pIndexData)
|| (This->baseVertexIndex != targetStateBlock->baseVertexIndex))) { || (This->baseVertexIndex != targetStateBlock->baseVertexIndex)
|| (This->IndexFmt != targetStateBlock->IndexFmt))) {
TRACE("Updating pIndexData to %p, baseVertexIndex to %d\n", TRACE("Updating pIndexData to %p, baseVertexIndex to %d\n",
targetStateBlock->pIndexData, targetStateBlock->baseVertexIndex); targetStateBlock->pIndexData, targetStateBlock->baseVertexIndex);
if(targetStateBlock->pIndexData) IWineD3DBuffer_AddRef(targetStateBlock->pIndexData); if(targetStateBlock->pIndexData) IWineD3DBuffer_AddRef(targetStateBlock->pIndexData);
if(This->pIndexData) IWineD3DBuffer_Release(This->pIndexData); if(This->pIndexData) IWineD3DBuffer_Release(This->pIndexData);
This->pIndexData = targetStateBlock->pIndexData; This->pIndexData = targetStateBlock->pIndexData;
This->baseVertexIndex = targetStateBlock->baseVertexIndex; This->baseVertexIndex = targetStateBlock->baseVertexIndex;
This->IndexFmt = targetStateBlock->IndexFmt;
} }
if(This->changed.vertexDecl && This->vertexDecl != targetStateBlock->vertexDecl){ if(This->changed.vertexDecl && This->vertexDecl != targetStateBlock->vertexDecl){
...@@ -655,10 +658,12 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface) ...@@ -655,10 +658,12 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
memcpy(This->samplerState, targetStateBlock->samplerState, sizeof(This->samplerState)); memcpy(This->samplerState, targetStateBlock->samplerState, sizeof(This->samplerState));
This->scissorRect = targetStateBlock->scissorRect; This->scissorRect = targetStateBlock->scissorRect;
if(targetStateBlock->pIndexData != This->pIndexData) { if(targetStateBlock->pIndexData != This->pIndexData ||
targetStateBlock->IndexFmt != This->IndexFmt) {
if (targetStateBlock->pIndexData) IWineD3DBuffer_AddRef(targetStateBlock->pIndexData); if (targetStateBlock->pIndexData) IWineD3DBuffer_AddRef(targetStateBlock->pIndexData);
if (This->pIndexData) IWineD3DBuffer_Release(This->pIndexData); if (This->pIndexData) IWineD3DBuffer_Release(This->pIndexData);
This->pIndexData = targetStateBlock->pIndexData; This->pIndexData = targetStateBlock->pIndexData;
This->IndexFmt = targetStateBlock->IndexFmt;
} }
for(i = 0; i < MAX_STREAMS; i++) { for(i = 0; i < MAX_STREAMS; i++) {
if(targetStateBlock->streamSource[i] != This->streamSource[i]) { if(targetStateBlock->streamSource[i] != This->streamSource[i]) {
...@@ -841,7 +846,7 @@ should really perform a delta so that only the changes get updated*/ ...@@ -841,7 +846,7 @@ should really perform a delta so that only the changes get updated*/
} }
if (This->changed.indices) { if (This->changed.indices) {
IWineD3DDevice_SetIndices(pDevice, This->pIndexData); IWineD3DDevice_SetIndices(pDevice, This->pIndexData, This->IndexFmt);
IWineD3DDevice_SetBaseVertexIndex(pDevice, This->baseVertexIndex); IWineD3DDevice_SetBaseVertexIndex(pDevice, This->baseVertexIndex);
} }
...@@ -1023,7 +1028,7 @@ should really perform a delta so that only the changes get updated*/ ...@@ -1023,7 +1028,7 @@ should really perform a delta so that only the changes get updated*/
IWineD3DDevice_SetTransform(pDevice, i, &This->transforms[i]); IWineD3DDevice_SetTransform(pDevice, i, &This->transforms[i]);
} }
This->wineD3DDevice->updateStateBlock->gl_primitive_type = This->gl_primitive_type; This->wineD3DDevice->updateStateBlock->gl_primitive_type = This->gl_primitive_type;
IWineD3DDevice_SetIndices(pDevice, This->pIndexData); IWineD3DDevice_SetIndices(pDevice, This->pIndexData, This->IndexFmt);
IWineD3DDevice_SetBaseVertexIndex(pDevice, This->baseVertexIndex); IWineD3DDevice_SetBaseVertexIndex(pDevice, This->baseVertexIndex);
IWineD3DDevice_SetVertexDeclaration(pDevice, This->vertexDecl); IWineD3DDevice_SetVertexDeclaration(pDevice, This->vertexDecl);
IWineD3DDevice_SetMaterial(pDevice, &This->material); IWineD3DDevice_SetMaterial(pDevice, &This->material);
......
...@@ -1932,6 +1932,7 @@ struct IWineD3DStateBlockImpl ...@@ -1932,6 +1932,7 @@ struct IWineD3DStateBlockImpl
/* Indices */ /* Indices */
IWineD3DBuffer* pIndexData; IWineD3DBuffer* pIndexData;
WINED3DFORMAT IndexFmt;
INT baseVertexIndex; INT baseVertexIndex;
INT loadBaseVertexIndex; /* non-indexed drawing needs 0 here, indexed baseVertexIndex */ INT loadBaseVertexIndex; /* non-indexed drawing needs 0 here, indexed baseVertexIndex */
......
...@@ -1864,7 +1864,6 @@ typedef struct WINED3DDEVINFO_VCACHE ...@@ -1864,7 +1864,6 @@ typedef struct WINED3DDEVINFO_VCACHE
typedef struct _WINED3DBUFFER_DESC typedef struct _WINED3DBUFFER_DESC
{ {
WINED3DFORMAT Format;
WINED3DRESOURCETYPE Type; WINED3DRESOURCETYPE Type;
DWORD Usage; DWORD Usage;
WINED3DPOOL Pool; WINED3DPOOL Pool;
...@@ -2893,7 +2892,6 @@ interface IWineD3DDevice : IWineD3DBase ...@@ -2893,7 +2892,6 @@ interface IWineD3DDevice : IWineD3DBase
HRESULT CreateIndexBuffer( HRESULT CreateIndexBuffer(
[in] UINT length, [in] UINT length,
[in] DWORD usage, [in] DWORD usage,
[in] WINED3DFORMAT format,
[in] WINED3DPOOL pool, [in] WINED3DPOOL pool,
[out] IWineD3DBuffer **index_buffer, [out] IWineD3DBuffer **index_buffer,
[in] HANDLE *shared_handle, [in] HANDLE *shared_handle,
...@@ -3118,7 +3116,8 @@ interface IWineD3DDevice : IWineD3DBase ...@@ -3118,7 +3116,8 @@ interface IWineD3DDevice : IWineD3DBase
[out] WINED3DGAMMARAMP *ramp [out] WINED3DGAMMARAMP *ramp
); );
HRESULT SetIndices( HRESULT SetIndices(
[in] IWineD3DBuffer *index_buffer [in] IWineD3DBuffer *index_buffer,
[in] WINED3DFORMAT format
); );
HRESULT GetIndices( HRESULT GetIndices(
[out] IWineD3DBuffer **index_buffer [out] IWineD3DBuffer **index_buffer
......
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