d3d8, d3d9: Don't rely on the wined3d buffer type.
This commit is contained in:
parent
55fc90220f
commit
bc07ad0579
|
@ -188,11 +188,23 @@ static HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 i
|
|||
DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
|
||||
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
||||
HRESULT hr;
|
||||
WINED3DRESOURCETYPE WineD3DRType;
|
||||
TRACE("(%p)->(%d, %d, %d, %08x, %d, %d)\n", This, Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat);
|
||||
|
||||
switch(RType) {
|
||||
case D3DRTYPE_VERTEXBUFFER:
|
||||
case D3DRTYPE_INDEXBUFFER:
|
||||
WineD3DRType = WINED3DRTYPE_BUFFER;
|
||||
break;
|
||||
|
||||
default:
|
||||
WineD3DRType = RType;
|
||||
break;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&d3d8_cs);
|
||||
hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
|
||||
Usage, RType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
|
||||
Usage, WineD3DRType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
|
||||
LeaveCriticalSection(&d3d8_cs);
|
||||
return hr;
|
||||
}
|
||||
|
|
|
@ -149,13 +149,9 @@ static void WINAPI IDirect3DIndexBuffer8Impl_PreLoad(LPDIRECT3DINDEXBUFFER8 ifac
|
|||
|
||||
static D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer8Impl_GetType(LPDIRECT3DINDEXBUFFER8 iface) {
|
||||
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
|
||||
D3DRESOURCETYPE type;
|
||||
TRACE("(%p) Relay\n", This);
|
||||
TRACE("(%p)\n", This);
|
||||
|
||||
EnterCriticalSection(&d3d8_cs);
|
||||
type = IWineD3DIndexBuffer_GetType(This->wineD3DIndexBuffer);
|
||||
LeaveCriticalSection(&d3d8_cs);
|
||||
return type;
|
||||
return D3DRTYPE_INDEXBUFFER;
|
||||
}
|
||||
|
||||
/* IDirect3DIndexBuffer8 Interface follow: */
|
||||
|
@ -190,7 +186,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 i
|
|||
hr = IWineD3DIndexBuffer_GetDesc(This->wineD3DIndexBuffer, (WINED3DINDEXBUFFER_DESC *) pDesc);
|
||||
LeaveCriticalSection(&d3d8_cs);
|
||||
|
||||
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(pDesc->Format);
|
||||
if (SUCCEEDED(hr)) {
|
||||
pDesc->Format = d3dformat_from_wined3dformat(pDesc->Format);
|
||||
pDesc->Type = D3DRTYPE_INDEXBUFFER;
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
|
|
@ -151,13 +151,9 @@ static void WINAPI IDirect3DVertexBuffer8Impl_PreLoad(LPDIRECT3DVERTEXBUFFER8 if
|
|||
|
||||
static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer8Impl_GetType(LPDIRECT3DVERTEXBUFFER8 iface) {
|
||||
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
|
||||
D3DRESOURCETYPE type;
|
||||
TRACE("(%p) Relay\n", This);
|
||||
TRACE("(%p)\n", This);
|
||||
|
||||
EnterCriticalSection(&d3d8_cs);
|
||||
type = IWineD3DBuffer_GetType(This->wineD3DVertexBuffer);
|
||||
LeaveCriticalSection(&d3d8_cs);
|
||||
return type;
|
||||
return D3DRTYPE_VERTEXBUFFER;
|
||||
}
|
||||
|
||||
/* IDirect3DVertexBuffer8 Interface follow: */
|
||||
|
@ -192,7 +188,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8
|
|||
hr = IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, (WINED3DVERTEXBUFFER_DESC *)pDesc);
|
||||
LeaveCriticalSection(&d3d8_cs);
|
||||
|
||||
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(pDesc->Format);
|
||||
if (SUCCEEDED(hr)) {
|
||||
pDesc->Type = D3DRTYPE_VERTEXBUFFER;
|
||||
pDesc->Format = d3dformat_from_wined3dformat(pDesc->Format);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
|
|
@ -428,17 +428,18 @@ static HRESULT WINAPI reset_enum_callback(IWineD3DResource *resource, void *data
|
|||
HRESULT ret = S_OK;
|
||||
WINED3DSURFACE_DESC surface_desc;
|
||||
WINED3DVOLUME_DESC volume_desc;
|
||||
WINED3DINDEXBUFFER_DESC index_desc;
|
||||
WINED3DVERTEXBUFFER_DESC vertex_desc;
|
||||
D3DINDEXBUFFER_DESC index_desc;
|
||||
D3DVERTEXBUFFER_DESC vertex_desc;
|
||||
WINED3DFORMAT dummy_format;
|
||||
WINED3DMULTISAMPLE_TYPE dummy_multisampletype;
|
||||
DWORD dummy_dword;
|
||||
WINED3DPOOL pool = WINED3DPOOL_SCRATCH; /* a harmless pool */
|
||||
IUnknown *parent;
|
||||
IDirect3DResource9 *parent;
|
||||
|
||||
type = IWineD3DResource_GetType(resource);
|
||||
IWineD3DResource_GetParent(resource, (IUnknown **) &parent);
|
||||
type = IDirect3DResource9_GetType(parent);
|
||||
switch(type) {
|
||||
case WINED3DRTYPE_SURFACE:
|
||||
case D3DRTYPE_SURFACE:
|
||||
surface_desc.Format = &dummy_format;
|
||||
surface_desc.Type = &type;
|
||||
surface_desc.Usage = &dummy_dword;
|
||||
|
@ -452,7 +453,7 @@ static HRESULT WINAPI reset_enum_callback(IWineD3DResource *resource, void *data
|
|||
IWineD3DSurface_GetDesc((IWineD3DSurface *) resource, &surface_desc);
|
||||
break;
|
||||
|
||||
case WINED3DRTYPE_VOLUME:
|
||||
case D3DRTYPE_VOLUME:
|
||||
volume_desc.Format = &dummy_format;
|
||||
volume_desc.Type = &type;
|
||||
volume_desc.Usage = &dummy_dword;
|
||||
|
@ -464,13 +465,13 @@ static HRESULT WINAPI reset_enum_callback(IWineD3DResource *resource, void *data
|
|||
IWineD3DVolume_GetDesc((IWineD3DVolume *) resource, &volume_desc);
|
||||
break;
|
||||
|
||||
case WINED3DRTYPE_INDEXBUFFER:
|
||||
IWineD3DIndexBuffer_GetDesc((IWineD3DIndexBuffer *) resource, &index_desc);
|
||||
case D3DRTYPE_INDEXBUFFER:
|
||||
IDirect3DIndexBuffer9_GetDesc((IDirect3DIndexBuffer9 *) parent, &index_desc);
|
||||
pool = index_desc.Pool;
|
||||
break;
|
||||
|
||||
case WINED3DRTYPE_VERTEXBUFFER:
|
||||
IWineD3DBuffer_GetDesc((IWineD3DBuffer *)resource, &vertex_desc);
|
||||
case D3DRTYPE_VERTEXBUFFER:
|
||||
IDirect3DVertexBuffer9_GetDesc((IDirect3DVertexBuffer9 *)parent, &vertex_desc);
|
||||
pool = vertex_desc.Pool;
|
||||
break;
|
||||
|
||||
|
@ -482,7 +483,6 @@ static HRESULT WINAPI reset_enum_callback(IWineD3DResource *resource, void *data
|
|||
}
|
||||
|
||||
if(pool == WINED3DPOOL_DEFAULT) {
|
||||
IWineD3DResource_GetParent(resource, &parent);
|
||||
if(IUnknown_Release(parent) == 0) {
|
||||
TRACE("Parent %p is an implicit resource with ref 0\n", parent);
|
||||
} else {
|
||||
|
@ -490,6 +490,8 @@ static HRESULT WINAPI reset_enum_callback(IWineD3DResource *resource, void *data
|
|||
ret = S_FALSE;
|
||||
*resources_ok = FALSE;
|
||||
}
|
||||
} else {
|
||||
IUnknown_Release(parent);
|
||||
}
|
||||
IWineD3DResource_Release(resource);
|
||||
|
||||
|
|
|
@ -194,11 +194,23 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(LPDIRECT3D9EX iface,
|
|||
DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
|
||||
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
|
||||
HRESULT hr;
|
||||
WINED3DRESOURCETYPE WineD3DRType;
|
||||
TRACE("%p\n", This);
|
||||
|
||||
switch(RType) {
|
||||
case D3DRTYPE_VERTEXBUFFER:
|
||||
case D3DRTYPE_INDEXBUFFER:
|
||||
WineD3DRType = WINED3DRTYPE_BUFFER;
|
||||
break;
|
||||
|
||||
default:
|
||||
WineD3DRType = RType;
|
||||
break;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&d3d9_cs);
|
||||
hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
|
||||
Usage, RType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
|
||||
Usage, WineD3DRType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
|
||||
LeaveCriticalSection(&d3d9_cs);
|
||||
return hr;
|
||||
}
|
||||
|
|
|
@ -154,13 +154,9 @@ static void WINAPI IDirect3DVertexBuffer9Impl_PreLoad(LPDIRECT3DVERTEXBUFFER9 if
|
|||
|
||||
static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer9Impl_GetType(LPDIRECT3DVERTEXBUFFER9 iface) {
|
||||
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
|
||||
D3DRESOURCETYPE ret;
|
||||
TRACE("(%p) Relay\n", This);
|
||||
TRACE("(%p)\n", This);
|
||||
|
||||
EnterCriticalSection(&d3d9_cs);
|
||||
ret = IWineD3DBuffer_GetType(This->wineD3DVertexBuffer);
|
||||
LeaveCriticalSection(&d3d9_cs);
|
||||
return ret;
|
||||
return D3DRTYPE_VERTEXBUFFER;
|
||||
}
|
||||
|
||||
/* IDirect3DVertexBuffer9 Interface follow: */
|
||||
|
@ -195,7 +191,11 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDesc(LPDIRECT3DVERTEXBUFFER9
|
|||
hr = IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, (WINED3DVERTEXBUFFER_DESC *)pDesc);
|
||||
LeaveCriticalSection(&d3d9_cs);
|
||||
|
||||
if (SUCCEEDED(hr)) pDesc->Format = d3dformat_from_wined3dformat(pDesc->Format);
|
||||
if (SUCCEEDED(hr)) {
|
||||
pDesc->Format = d3dformat_from_wined3dformat(pDesc->Format);
|
||||
pDesc->Type = D3DRTYPE_VERTEXBUFFER;
|
||||
}
|
||||
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
|
|
@ -532,7 +532,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *ifac
|
|||
}
|
||||
|
||||
object->vtbl = &wined3d_buffer_vtbl;
|
||||
hr = resource_init(&object->resource, WINED3DRTYPE_VERTEXBUFFER, This, Size, Usage, format_desc, Pool, parent);
|
||||
hr = resource_init(&object->resource, WINED3DRTYPE_BUFFER, This, Size, Usage, format_desc, Pool, parent);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to initialize resource, returning %#x\n", hr);
|
||||
|
@ -650,7 +650,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface
|
|||
}
|
||||
|
||||
object->lpVtbl = &IWineD3DIndexBuffer_Vtbl;
|
||||
hr = resource_init(&object->resource, WINED3DRTYPE_INDEXBUFFER, This, Length, Usage, format_desc, Pool, parent);
|
||||
hr = resource_init(&object->resource, WINED3DRTYPE_BUFFER, This, Length, Usage, format_desc, Pool, parent);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to initialize resource, returning %#x\n", hr);
|
||||
|
@ -7905,7 +7905,7 @@ static void WINAPI IWineD3DDeviceImpl_ResourceReleased(IWineD3DDevice *iface, IW
|
|||
case WINED3DRTYPE_VOLUME:
|
||||
/* TODO: nothing really? */
|
||||
break;
|
||||
case WINED3DRTYPE_VERTEXBUFFER:
|
||||
case WINED3DRTYPE_BUFFER:
|
||||
{
|
||||
int streamNumber;
|
||||
TRACE("Cleaning up stream pointers\n");
|
||||
|
@ -7928,9 +7928,7 @@ static void WINAPI IWineD3DDeviceImpl_ResourceReleased(IWineD3DDevice *iface, IW
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WINED3DRTYPE_INDEXBUFFER:
|
||||
|
||||
if (This->updateStateBlock != NULL ) { /* ==NULL when device is being destroyed */
|
||||
if (This->updateStateBlock->pIndexData == (IWineD3DIndexBuffer *)resource) {
|
||||
This->updateStateBlock->pIndexData = NULL;
|
||||
|
@ -7941,10 +7939,7 @@ static void WINAPI IWineD3DDeviceImpl_ResourceReleased(IWineD3DDevice *iface, IW
|
|||
This->stateBlock->pIndexData = NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WINED3DRTYPE_BUFFER:
|
||||
/* Nothing to do, yet.*/
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -3047,7 +3047,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
|
|||
/* Do nothing, continue with checking the format below */
|
||||
break;
|
||||
}
|
||||
} else if((RType == WINED3DRTYPE_INDEXBUFFER) || (RType == WINED3DRTYPE_VERTEXBUFFER)){
|
||||
} else if(RType == WINED3DRTYPE_BUFFER){
|
||||
/* For instance vertexbuffer/indexbuffer aren't supported yet because no Windows drivers seem to offer it */
|
||||
TRACE_(d3d_caps)("Unhandled resource type D3DRTYPE_INDEXBUFFER / D3DRTYPE_VERTEXBUFFER\n");
|
||||
return WINED3DERR_NOTAVAILABLE;
|
||||
|
|
|
@ -996,8 +996,6 @@ const char* debug_d3dresourcetype(WINED3DRESOURCETYPE res) {
|
|||
RES_TO_STR(WINED3DRTYPE_TEXTURE);
|
||||
RES_TO_STR(WINED3DRTYPE_VOLUMETEXTURE);
|
||||
RES_TO_STR(WINED3DRTYPE_CUBETEXTURE);
|
||||
RES_TO_STR(WINED3DRTYPE_VERTEXBUFFER);
|
||||
RES_TO_STR(WINED3DRTYPE_INDEXBUFFER);
|
||||
RES_TO_STR(WINED3DRTYPE_BUFFER);
|
||||
#undef RES_TO_STR
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue