d3d: Remove the format from index buffers.
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h
index 01a475e..c9afe17 100644
--- a/dlls/d3d8/d3d8_private.h
+++ b/dlls/d3d8/d3d8_private.h
@@ -353,6 +353,8 @@
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
+
+ WINED3DFORMAT format;
};
/* --------------------- */
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 057d895..985557c 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -773,10 +773,11 @@
object->lpVtbl = &Direct3DIndexBuffer8_Vtbl;
object->ref = 1;
+ object->format = wined3dformat_from_d3dformat(Format);
TRACE("Calling wined3d create index buffer\n");
EnterCriticalSection(&d3d8_cs);
hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage & WINED3DUSAGE_MASK,
- wined3dformat_from_d3dformat(Format), (WINED3DPOOL) Pool, &object->wineD3DIndexBuffer,
+ (WINED3DPOOL) Pool, &object->wineD3DIndexBuffer,
NULL, (IUnknown *)object);
LeaveCriticalSection(&d3d8_cs);
@@ -2085,6 +2086,7 @@
static HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8* pIndexData, UINT baseVertexIndex) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
HRESULT hr;
+ IDirect3DIndexBuffer8Impl *ib = (IDirect3DIndexBuffer8Impl *)pIndexData;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
@@ -2096,7 +2098,8 @@
*/
IWineD3DDevice_SetBaseVertexIndex(This->WineD3DDevice, baseVertexIndex);
hr = IWineD3DDevice_SetIndices(This->WineD3DDevice,
- pIndexData ? ((IDirect3DIndexBuffer8Impl *)pIndexData)->wineD3DIndexBuffer : NULL);
+ ib ? ib->wineD3DIndexBuffer : NULL,
+ ib ? ib->format : WINED3DFMT_UNKNOWN);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
diff --git a/dlls/d3d8/indexbuffer.c b/dlls/d3d8/indexbuffer.c
index d8f7b66..a0de5c5 100644
--- a/dlls/d3d8/indexbuffer.c
+++ b/dlls/d3d8/indexbuffer.c
@@ -188,7 +188,7 @@
LeaveCriticalSection(&d3d8_cs);
if (SUCCEEDED(hr)) {
- pDesc->Format = d3dformat_from_wined3dformat(desc.Format);
+ pDesc->Format = d3dformat_from_wined3dformat(This->format);
pDesc->Type = D3DRTYPE_INDEXBUFFER;
pDesc->Usage = desc.Usage;
pDesc->Pool = desc.Pool;
diff --git a/dlls/d3d8/vertexbuffer.c b/dlls/d3d8/vertexbuffer.c
index 569efa2..a282cda 100644
--- a/dlls/d3d8/vertexbuffer.c
+++ b/dlls/d3d8/vertexbuffer.c
@@ -195,7 +195,7 @@
pDesc->Pool = desc.Pool;
pDesc->Size = desc.Size;
pDesc->FVF = This->fvf;
- pDesc->Format = d3dformat_from_wined3dformat(desc.Format);
+ pDesc->Format = D3DFMT_VERTEXDATA;
}
return hr;
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
index 9338f97..25b6ae2 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -351,6 +351,7 @@
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;
+ WINED3DFORMAT format;
} IDirect3DIndexBuffer9Impl;
/* --------------------- */
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index bfbfe97..8d88e52 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -516,8 +516,7 @@
* below fails, the device is considered "lost", and _Reset and _Release are the only allowed calls
*/
EnterCriticalSection(&d3d9_cs);
-
- IWineD3DDevice_SetIndices(This->WineD3DDevice, NULL);
+ IWineD3DDevice_SetIndices(This->WineD3DDevice, NULL, WINED3DFMT_UNKNOWN);
for(i = 0; i < 16; i++) {
IWineD3DDevice_SetStreamSource(This->WineD3DDevice, i, NULL, 0, 0);
}
@@ -1639,11 +1638,13 @@
static HRESULT WINAPI IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9EX iface, IDirect3DIndexBuffer9* pIndexData) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr;
+ IDirect3DIndexBuffer9Impl *ib = (IDirect3DIndexBuffer9Impl *) pIndexData;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d9_cs);
hr = IWineD3DDevice_SetIndices(This->WineD3DDevice,
- pIndexData ? ((IDirect3DIndexBuffer9Impl *)pIndexData)->wineD3DIndexBuffer : NULL);
+ ib ? ib->wineD3DIndexBuffer : NULL,
+ ib ? ib->format : WINED3DFMT_UNKNOWN);
LeaveCriticalSection(&d3d9_cs);
return hr;
}
diff --git a/dlls/d3d9/indexbuffer.c b/dlls/d3d9/indexbuffer.c
index 23a374c..161ff64 100644
--- a/dlls/d3d9/indexbuffer.c
+++ b/dlls/d3d9/indexbuffer.c
@@ -189,7 +189,7 @@
LeaveCriticalSection(&d3d9_cs);
if (SUCCEEDED(hr)) {
- pDesc->Format = d3dformat_from_wined3dformat(desc.Format);
+ pDesc->Format = d3dformat_from_wined3dformat(This->format);
pDesc->Usage = desc.Usage;
pDesc->Pool = desc.Pool;
pDesc->Size = desc.Size;
@@ -241,10 +241,11 @@
object->lpVtbl = &Direct3DIndexBuffer9_Vtbl;
object->ref = 1;
+ object->format = wined3dformat_from_d3dformat(Format);
TRACE("Calling wined3d create index buffer\n");
EnterCriticalSection(&d3d9_cs);
hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage & WINED3DUSAGE_MASK,
- wined3dformat_from_d3dformat(Format), (WINED3DPOOL)Pool, &object->wineD3DIndexBuffer,
+ (WINED3DPOOL)Pool, &object->wineD3DIndexBuffer,
pSharedHandle, (IUnknown *)object);
LeaveCriticalSection(&d3d9_cs);
if (hrc != D3D_OK) {
diff --git a/dlls/d3d9/vertexbuffer.c b/dlls/d3d9/vertexbuffer.c
index 71a9ca7..8c65a88 100644
--- a/dlls/d3d9/vertexbuffer.c
+++ b/dlls/d3d9/vertexbuffer.c
@@ -193,7 +193,7 @@
LeaveCriticalSection(&d3d9_cs);
if (SUCCEEDED(hr)) {
- pDesc->Format = d3dformat_from_wined3dformat(desc.Format);
+ pDesc->Format = D3DFMT_VERTEXDATA;
pDesc->Usage = desc.Usage;
pDesc->Pool = desc.Pool;
pDesc->Size = desc.Size;
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 37bb1ff..4fe6532 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -316,7 +316,7 @@
EnterCriticalSection(&ddraw_cs);
/* Free the index buffer. */
- IWineD3DDevice_SetIndices(This->wineD3DDevice, NULL);
+ IWineD3DDevice_SetIndices(This->wineD3DDevice, NULL, WINED3DFMT_UNKNOWN);
IWineD3DBuffer_GetParent(This->indexbuffer,
(IUnknown **) &IndexBufferParent);
IParent_Release(IndexBufferParent); /* Once for the getParent */
@@ -4272,7 +4272,8 @@
/* Set the index stream */
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 */
hr = IWineD3DDevice_SetStreamSource(This->wineD3DDevice,
diff --git a/dlls/ddraw/direct3d.c b/dlls/ddraw/direct3d.c
index 438b6ad..aeba55b 100644
--- a/dlls/ddraw/direct3d.c
+++ b/dlls/ddraw/direct3d.c
@@ -824,7 +824,7 @@
* takes the pointer and avoids the memcpy
*/
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);
if(FAILED(hr))
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index 1312c22..bde2234 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -310,7 +310,7 @@
TRACE("(%p) Destroying the render target, uninitializing D3D\n", This);
/* 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_SetVertexDeclaration(ddraw->wineD3DDevice, NULL);
for(i = 0; i < ddraw->numConvertedDecls; i++)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 0c53c23..0e29de0 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -937,7 +937,6 @@
TRACE("(%p)\n", This);
- desc->Format = This->resource.format_desc->format;
desc->Type = This->resource.resourceType;
desc->Usage = This->resource.usage;
desc->Pool = This->resource.pool;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index fc968db..879008c 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -583,10 +583,10 @@
}
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) {
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;
HRESULT hr;
@@ -620,8 +620,8 @@
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,
- debug_d3dformat(Format), Pool, object, object->resource.allocatedMemory);
+ TRACE("(%p) : Len=%d, Use=%x, Pool=%d - Memory@%p, Iface@%p\n", This, Length, Usage,
+ Pool, object, object->resource.allocatedMemory);
*ppIndexBuffer = (IWineD3DBuffer *) object;
return WINED3D_OK;
@@ -3637,7 +3637,7 @@
/*****
* 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;
IWineD3DBuffer *oldIdxs;
@@ -3646,6 +3646,7 @@
This->updateStateBlock->changed.indices = TRUE;
This->updateStateBlock->pIndexData = pIndexData;
+ This->updateStateBlock->IndexFmt = fmt;
/* Handle recording of state blocks */
if (This->isRecordingState) {
@@ -5639,7 +5640,6 @@
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
UINT idxStride = 2;
IWineD3DBuffer *pIB;
- WINED3DBUFFER_DESC IdxBufDsc;
GLuint vbo;
pIB = This->stateBlock->pIndexData;
@@ -5666,8 +5666,7 @@
TRACE("(%p) : min %u, vertex count %u, startIdx %u, index count %u\n",
This, minIndex, NumVertices, startIndex, index_count);
- IWineD3DBuffer_GetDesc(pIB, &IdxBufDsc);
- if (IdxBufDsc.Format == WINED3DFMT_R16_UINT) {
+ if (This->stateBlock->IndexFmt == WINED3DFMT_R16_UINT) {
idxStride = 2;
} else {
idxStride = 4;
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index bda4c6b..1c9b5a8 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -195,6 +195,7 @@
Dest->vertexShader = This->vertexShader;
Dest->streamIsUP = This->streamIsUP;
Dest->pIndexData = This->pIndexData;
+ Dest->IndexFmt = This->IndexFmt;
Dest->baseVertexIndex = This->baseVertexIndex;
/* Dest->lights = This->lights; */
Dest->clip_status = This->clip_status;
@@ -506,13 +507,15 @@
if (This->changed.primitive_type) This->gl_primitive_type = targetStateBlock->gl_primitive_type;
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",
targetStateBlock->pIndexData, targetStateBlock->baseVertexIndex);
if(targetStateBlock->pIndexData) IWineD3DBuffer_AddRef(targetStateBlock->pIndexData);
if(This->pIndexData) IWineD3DBuffer_Release(This->pIndexData);
This->pIndexData = targetStateBlock->pIndexData;
This->baseVertexIndex = targetStateBlock->baseVertexIndex;
+ This->IndexFmt = targetStateBlock->IndexFmt;
}
if(This->changed.vertexDecl && This->vertexDecl != targetStateBlock->vertexDecl){
@@ -655,10 +658,12 @@
memcpy(This->samplerState, targetStateBlock->samplerState, sizeof(This->samplerState));
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 (This->pIndexData) IWineD3DBuffer_Release(This->pIndexData);
This->pIndexData = targetStateBlock->pIndexData;
+ This->IndexFmt = targetStateBlock->IndexFmt;
}
for(i = 0; i < MAX_STREAMS; i++) {
if(targetStateBlock->streamSource[i] != This->streamSource[i]) {
@@ -841,7 +846,7 @@
}
if (This->changed.indices) {
- IWineD3DDevice_SetIndices(pDevice, This->pIndexData);
+ IWineD3DDevice_SetIndices(pDevice, This->pIndexData, This->IndexFmt);
IWineD3DDevice_SetBaseVertexIndex(pDevice, This->baseVertexIndex);
}
@@ -1023,7 +1028,7 @@
IWineD3DDevice_SetTransform(pDevice, i, &This->transforms[i]);
}
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_SetVertexDeclaration(pDevice, This->vertexDecl);
IWineD3DDevice_SetMaterial(pDevice, &This->material);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 4076912..200bf22 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1932,6 +1932,7 @@
/* Indices */
IWineD3DBuffer* pIndexData;
+ WINED3DFORMAT IndexFmt;
INT baseVertexIndex;
INT loadBaseVertexIndex; /* non-indexed drawing needs 0 here, indexed baseVertexIndex */
diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl
index f6e5ef5..b8691a7 100644
--- a/include/wine/wined3d.idl
+++ b/include/wine/wined3d.idl
@@ -1864,7 +1864,6 @@
typedef struct _WINED3DBUFFER_DESC
{
- WINED3DFORMAT Format;
WINED3DRESOURCETYPE Type;
DWORD Usage;
WINED3DPOOL Pool;
@@ -2893,7 +2892,6 @@
HRESULT CreateIndexBuffer(
[in] UINT length,
[in] DWORD usage,
- [in] WINED3DFORMAT format,
[in] WINED3DPOOL pool,
[out] IWineD3DBuffer **index_buffer,
[in] HANDLE *shared_handle,
@@ -3118,7 +3116,8 @@
[out] WINED3DGAMMARAMP *ramp
);
HRESULT SetIndices(
- [in] IWineD3DBuffer *index_buffer
+ [in] IWineD3DBuffer *index_buffer,
+ [in] WINED3DFORMAT format
);
HRESULT GetIndices(
[out] IWineD3DBuffer **index_buffer