[WINED3D|DDRAW|D3D8|D3D9]

Sync to Wine 1.3.21

svn path=/trunk/; revision=52009
This commit is contained in:
Kamil Hornicek 2011-05-30 15:27:19 +00:00
parent 6486187cdb
commit 4e0877c6fb
84 changed files with 22725 additions and 24676 deletions

View file

@ -51,7 +51,7 @@ static ULONG WINAPI d3d8_vertexbuffer_AddRef(IDirect3DVertexBuffer8 *iface)
{
IDirect3DDevice8_AddRef(buffer->parentDevice);
wined3d_mutex_lock();
IWineD3DBuffer_AddRef(buffer->wineD3DVertexBuffer);
wined3d_buffer_incref(buffer->wineD3DVertexBuffer);
wined3d_mutex_unlock();
}
@ -70,7 +70,7 @@ static ULONG WINAPI d3d8_vertexbuffer_Release(IDirect3DVertexBuffer8 *iface)
IDirect3DDevice8 *device = buffer->parentDevice;
wined3d_mutex_lock();
IWineD3DBuffer_Release(buffer->wineD3DVertexBuffer);
wined3d_buffer_decref(buffer->wineD3DVertexBuffer);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
@ -101,7 +101,7 @@ static HRESULT WINAPI d3d8_vertexbuffer_SetPrivateData(IDirect3DVertexBuffer8 *i
iface, debugstr_guid(guid), data, data_size, flags);
wined3d_mutex_lock();
hr = IWineD3DBuffer_SetPrivateData(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer,
hr = wined3d_buffer_set_private_data(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer,
guid, data, data_size, flags);
wined3d_mutex_unlock();
@ -117,7 +117,7 @@ static HRESULT WINAPI d3d8_vertexbuffer_GetPrivateData(IDirect3DVertexBuffer8 *i
iface, debugstr_guid(guid), data, data_size);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetPrivateData(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer,
hr = wined3d_buffer_get_private_data(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer,
guid, data, data_size);
wined3d_mutex_unlock();
@ -131,7 +131,7 @@ static HRESULT WINAPI d3d8_vertexbuffer_FreePrivateData(IDirect3DVertexBuffer8 *
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
wined3d_mutex_lock();
hr = IWineD3DBuffer_FreePrivateData(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer, guid);
hr = wined3d_buffer_free_private_data(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer, guid);
wined3d_mutex_unlock();
return hr;
@ -144,7 +144,7 @@ static DWORD WINAPI d3d8_vertexbuffer_SetPriority(IDirect3DVertexBuffer8 *iface,
TRACE("iface %p, priority %u.\n", iface, priority);
wined3d_mutex_lock();
previous = IWineD3DBuffer_SetPriority(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer, priority);
previous = wined3d_buffer_set_priority(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer, priority);
wined3d_mutex_unlock();
return previous;
@ -157,7 +157,7 @@ static DWORD WINAPI d3d8_vertexbuffer_GetPriority(IDirect3DVertexBuffer8 *iface)
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
priority = IWineD3DBuffer_GetPriority(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer);
priority = wined3d_buffer_get_priority(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer);
wined3d_mutex_unlock();
return priority;
@ -168,7 +168,7 @@ static void WINAPI d3d8_vertexbuffer_PreLoad(IDirect3DVertexBuffer8 *iface)
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
IWineD3DBuffer_PreLoad(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer);
wined3d_buffer_preload(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer);
wined3d_mutex_unlock();
}
@ -188,7 +188,7 @@ static HRESULT WINAPI d3d8_vertexbuffer_Lock(IDirect3DVertexBuffer8 *iface,
iface, offset, size, data, flags);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Map(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer,
hr = wined3d_buffer_map(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer,
offset, size, data, flags);
wined3d_mutex_unlock();
@ -197,32 +197,32 @@ static HRESULT WINAPI d3d8_vertexbuffer_Lock(IDirect3DVertexBuffer8 *iface,
static HRESULT WINAPI d3d8_vertexbuffer_Unlock(IDirect3DVertexBuffer8 *iface)
{
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Unmap(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer);
wined3d_buffer_unmap(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer);
wined3d_mutex_unlock();
return hr;
return D3D_OK;
}
static HRESULT WINAPI d3d8_vertexbuffer_GetDesc(IDirect3DVertexBuffer8 *iface, D3DVERTEXBUFFER_DESC *desc)
{
IDirect3DVertexBuffer8Impl *buffer = (IDirect3DVertexBuffer8Impl *)iface;
WINED3DBUFFER_DESC wined3d_desc;
struct wined3d_resource_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock();
IWineD3DBuffer_GetDesc(buffer->wineD3DVertexBuffer, &wined3d_desc);
wined3d_resource = wined3d_buffer_get_resource(buffer->wineD3DVertexBuffer);
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
wined3d_mutex_unlock();
desc->Type = D3DRTYPE_VERTEXBUFFER;
desc->Usage = wined3d_desc.Usage;
desc->Pool = wined3d_desc.Pool;
desc->Size = wined3d_desc.Size;
desc->Usage = wined3d_desc.usage;
desc->Pool = wined3d_desc.pool;
desc->Size = wined3d_desc.size;
desc->FVF = buffer->fvf;
desc->Format = D3DFMT_VERTEXDATA;
@ -270,7 +270,7 @@ HRESULT vertexbuffer_init(IDirect3DVertexBuffer8Impl *buffer, IDirect3DDevice8Im
buffer->fvf = fvf;
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateVertexBuffer(device->WineD3DDevice, size, usage & WINED3DUSAGE_MASK,
hr = wined3d_buffer_create_vb(device->wined3d_device, size, usage & WINED3DUSAGE_MASK,
(WINED3DPOOL)pool, buffer, &d3d8_vertexbuffer_wined3d_parent_ops, &buffer->wineD3DVertexBuffer);
wined3d_mutex_unlock();
if (FAILED(hr))
@ -279,7 +279,7 @@ HRESULT vertexbuffer_init(IDirect3DVertexBuffer8Impl *buffer, IDirect3DDevice8Im
return hr;
}
buffer->parentDevice = (IDirect3DDevice8 *)device;
buffer->parentDevice = &device->IDirect3DDevice8_iface;
IUnknown_AddRef(buffer->parentDevice);
return D3D_OK;
@ -315,7 +315,7 @@ static ULONG WINAPI d3d8_indexbuffer_AddRef(IDirect3DIndexBuffer8 *iface)
{
IDirect3DDevice8_AddRef(buffer->parentDevice);
wined3d_mutex_lock();
IWineD3DBuffer_AddRef(buffer->wineD3DIndexBuffer);
wined3d_buffer_incref(buffer->wineD3DIndexBuffer);
wined3d_mutex_unlock();
}
@ -334,7 +334,7 @@ static ULONG WINAPI d3d8_indexbuffer_Release(IDirect3DIndexBuffer8 *iface)
IDirect3DDevice8 *device = buffer->parentDevice;
wined3d_mutex_lock();
IWineD3DBuffer_Release(buffer->wineD3DIndexBuffer);
wined3d_buffer_decref(buffer->wineD3DIndexBuffer);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
@ -365,7 +365,7 @@ static HRESULT WINAPI d3d8_indexbuffer_SetPrivateData(IDirect3DIndexBuffer8 *ifa
iface, debugstr_guid(guid), data, data_size, flags);
wined3d_mutex_lock();
hr = IWineD3DBuffer_SetPrivateData(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer,
hr = wined3d_buffer_set_private_data(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer,
guid, data, data_size, flags);
wined3d_mutex_unlock();
@ -381,7 +381,7 @@ static HRESULT WINAPI d3d8_indexbuffer_GetPrivateData(IDirect3DIndexBuffer8 *ifa
iface, debugstr_guid(guid), data, data_size);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetPrivateData(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer,
hr = wined3d_buffer_get_private_data(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer,
guid, data, data_size);
wined3d_mutex_unlock();
@ -395,7 +395,7 @@ static HRESULT WINAPI d3d8_indexbuffer_FreePrivateData(IDirect3DIndexBuffer8 *if
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
wined3d_mutex_lock();
hr = IWineD3DBuffer_FreePrivateData(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer, guid);
hr = wined3d_buffer_free_private_data(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer, guid);
wined3d_mutex_unlock();
return hr;
@ -408,7 +408,7 @@ static DWORD WINAPI d3d8_indexbuffer_SetPriority(IDirect3DIndexBuffer8 *iface, D
TRACE("iface %p, priority %u.\n", iface, priority);
wined3d_mutex_lock();
previous = IWineD3DBuffer_SetPriority(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer, priority);
previous = wined3d_buffer_set_priority(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer, priority);
wined3d_mutex_unlock();
return previous;
@ -421,7 +421,7 @@ static DWORD WINAPI d3d8_indexbuffer_GetPriority(IDirect3DIndexBuffer8 *iface)
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
priority = IWineD3DBuffer_GetPriority(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer);
priority = wined3d_buffer_get_priority(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer);
wined3d_mutex_unlock();
return priority;
@ -432,7 +432,7 @@ static void WINAPI d3d8_indexbuffer_PreLoad(IDirect3DIndexBuffer8 *iface)
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
IWineD3DBuffer_PreLoad(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer);
wined3d_buffer_preload(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer);
wined3d_mutex_unlock();
}
@ -452,7 +452,7 @@ static HRESULT WINAPI d3d8_indexbuffer_Lock(IDirect3DIndexBuffer8 *iface,
iface, offset, size, data, flags);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Map(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer,
hr = wined3d_buffer_map(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer,
offset, size, data, flags);
wined3d_mutex_unlock();
@ -461,33 +461,33 @@ static HRESULT WINAPI d3d8_indexbuffer_Lock(IDirect3DIndexBuffer8 *iface,
static HRESULT WINAPI d3d8_indexbuffer_Unlock(IDirect3DIndexBuffer8 *iface)
{
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Unmap(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer);
wined3d_buffer_unmap(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer);
wined3d_mutex_unlock();
return hr;
return D3D_OK;
}
static HRESULT WINAPI d3d8_indexbuffer_GetDesc(IDirect3DIndexBuffer8 *iface, D3DINDEXBUFFER_DESC *desc)
{
IDirect3DIndexBuffer8Impl *buffer = (IDirect3DIndexBuffer8Impl *)iface;
WINED3DBUFFER_DESC wined3d_desc;
struct wined3d_resource_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock();
IWineD3DBuffer_GetDesc(buffer->wineD3DIndexBuffer, &wined3d_desc);
wined3d_resource = wined3d_buffer_get_resource(buffer->wineD3DIndexBuffer);
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
wined3d_mutex_unlock();
desc->Format = d3dformat_from_wined3dformat(buffer->format);
desc->Type = D3DRTYPE_INDEXBUFFER;
desc->Usage = wined3d_desc.Usage;
desc->Pool = wined3d_desc.Pool;
desc->Size = wined3d_desc.Size;
desc->Usage = wined3d_desc.usage;
desc->Pool = wined3d_desc.pool;
desc->Size = wined3d_desc.size;
return D3D_OK;
}
@ -533,7 +533,7 @@ HRESULT indexbuffer_init(IDirect3DIndexBuffer8Impl *buffer, IDirect3DDevice8Impl
buffer->format = wined3dformat_from_d3dformat(format);
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateIndexBuffer(device->WineD3DDevice, size, usage & WINED3DUSAGE_MASK,
hr = wined3d_buffer_create_ib(device->wined3d_device, size, usage & WINED3DUSAGE_MASK,
(WINED3DPOOL)pool, buffer, &d3d8_indexbuffer_wined3d_parent_ops, &buffer->wineD3DIndexBuffer);
wined3d_mutex_unlock();
if (FAILED(hr))
@ -542,7 +542,7 @@ HRESULT indexbuffer_init(IDirect3DIndexBuffer8Impl *buffer, IDirect3DDevice8Impl
return hr;
}
buffer->parentDevice = (IDirect3DDevice8 *)device;
buffer->parentDevice = &device->IDirect3DDevice8_iface;
IUnknown_AddRef(buffer->parentDevice);
return D3D_OK;

View file

@ -23,9 +23,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DCubeTexture8 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DCubeTexture8Impl_QueryInterface(LPDIRECT3DCUBETEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
static inline IDirect3DCubeTexture8Impl *impl_from_IDirect3DCubeTexture8(IDirect3DCubeTexture8 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DCubeTexture8Impl, IDirect3DCubeTexture8_iface);
}
static HRESULT WINAPI IDirect3DCubeTexture8Impl_QueryInterface(IDirect3DCubeTexture8 *iface,
REFIID riid, void **ppobj)
{
IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
@ -43,8 +49,9 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_QueryInterface(LPDIRECT3DCUBETEX
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DCubeTexture8Impl_AddRef(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
static ULONG WINAPI IDirect3DCubeTexture8Impl_AddRef(IDirect3DCubeTexture8 *iface)
{
IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", iface, ref);
@ -53,15 +60,16 @@ static ULONG WINAPI IDirect3DCubeTexture8Impl_AddRef(LPDIRECT3DCUBETEXTURE8 ifac
{
IUnknown_AddRef(This->parentDevice);
wined3d_mutex_lock();
IWineD3DCubeTexture_AddRef(This->wineD3DCubeTexture);
wined3d_texture_incref(This->wined3d_texture);
wined3d_mutex_unlock();
}
return ref;
}
static ULONG WINAPI IDirect3DCubeTexture8Impl_Release(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
static ULONG WINAPI IDirect3DCubeTexture8Impl_Release(IDirect3DCubeTexture8 *iface)
{
IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", iface, ref);
@ -69,10 +77,10 @@ static ULONG WINAPI IDirect3DCubeTexture8Impl_Release(LPDIRECT3DCUBETEXTURE8 ifa
if (ref == 0) {
IDirect3DDevice8 *parentDevice = This->parentDevice;
TRACE("Releasing child %p\n", This->wineD3DCubeTexture);
TRACE("Releasing child %p.\n", This->wined3d_texture);
wined3d_mutex_lock();
IWineD3DCubeTexture_Release(This->wineD3DCubeTexture);
wined3d_texture_decref(This->wined3d_texture);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
@ -82,9 +90,10 @@ static ULONG WINAPI IDirect3DCubeTexture8Impl_Release(LPDIRECT3DCUBETEXTURE8 ifa
}
/* IDirect3DCubeTexture8 IDirect3DResource8 Interface follow: */
static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetDevice(IDirect3DCubeTexture8 *iface, IDirect3DDevice8 **device)
static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetDevice(IDirect3DCubeTexture8 *iface,
IDirect3DDevice8 **device)
{
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface);
TRACE("iface %p, device %p.\n", iface, device);
@ -96,221 +105,275 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetDevice(IDirect3DCubeTexture8
return D3D_OK;
}
static HRESULT WINAPI IDirect3DCubeTexture8Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DCubeTexture8Impl_SetPrivateData(IDirect3DCubeTexture8 *iface,
REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags)
{
IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface);
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_SetPrivateData(This->wineD3DCubeTexture,refguid,pData,SizeOfData,Flags);
hr = wined3d_texture_set_private_data(This->wined3d_texture, refguid, pData, SizeOfData, Flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetPrivateData(IDirect3DCubeTexture8 *iface,
REFGUID refguid, void *pData, DWORD *pSizeOfData)
{
IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface);
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %p.\n",
iface, debugstr_guid(refguid), pData, pSizeOfData);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetPrivateData(This->wineD3DCubeTexture,refguid,pData,pSizeOfData);
hr = wined3d_texture_get_private_data(This->wined3d_texture, refguid, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DCubeTexture8Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DCubeTexture8Impl_FreePrivateData(IDirect3DCubeTexture8 *iface,
REFGUID refguid)
{
IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface);
HRESULT hr;
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_FreePrivateData(This->wineD3DCubeTexture,refguid);
hr = wined3d_texture_free_private_data(This->wined3d_texture, refguid);
wined3d_mutex_unlock();
return hr;
}
static DWORD WINAPI IDirect3DCubeTexture8Impl_SetPriority(LPDIRECT3DCUBETEXTURE8 iface, DWORD PriorityNew) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
static DWORD WINAPI IDirect3DCubeTexture8Impl_SetPriority(IDirect3DCubeTexture8 *iface,
DWORD PriorityNew)
{
IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface);
DWORD ret;
TRACE("iface %p, priority %u.\n", iface, PriorityNew);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_SetPriority(This->wineD3DCubeTexture, PriorityNew);
ret = wined3d_texture_set_priority(This->wined3d_texture, PriorityNew);
wined3d_mutex_unlock();
return ret;
}
static DWORD WINAPI IDirect3DCubeTexture8Impl_GetPriority(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
static DWORD WINAPI IDirect3DCubeTexture8Impl_GetPriority(IDirect3DCubeTexture8 *iface)
{
IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface);
DWORD ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_GetPriority(This->wineD3DCubeTexture);
ret = wined3d_texture_get_priority(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
static void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
static void WINAPI IDirect3DCubeTexture8Impl_PreLoad(IDirect3DCubeTexture8 *iface)
{
IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface);
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
IWineD3DCubeTexture_PreLoad(This->wineD3DCubeTexture);
wined3d_texture_preload(This->wined3d_texture);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture8Impl_GetType(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture8Impl_GetType(IDirect3DCubeTexture8 *iface)
{
IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface);
D3DRESOURCETYPE type;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
type = IWineD3DCubeTexture_GetType(This->wineD3DCubeTexture);
type = wined3d_texture_get_type(This->wined3d_texture);
wined3d_mutex_unlock();
return type;
}
/* IDirect3DCubeTexture8 IDirect3DBaseTexture8 Interface follow: */
static DWORD WINAPI IDirect3DCubeTexture8Impl_SetLOD(LPDIRECT3DCUBETEXTURE8 iface, DWORD LODNew) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
static DWORD WINAPI IDirect3DCubeTexture8Impl_SetLOD(IDirect3DCubeTexture8 *iface, DWORD LODNew)
{
IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface);
DWORD lod;
TRACE("iface %p, lod %u.\n", iface, LODNew);
wined3d_mutex_lock();
lod = IWineD3DCubeTexture_SetLOD(This->wineD3DCubeTexture, LODNew);
lod = wined3d_texture_set_lod(This->wined3d_texture, LODNew);
wined3d_mutex_unlock();
return lod;
}
static DWORD WINAPI IDirect3DCubeTexture8Impl_GetLOD(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
static DWORD WINAPI IDirect3DCubeTexture8Impl_GetLOD(IDirect3DCubeTexture8 *iface)
{
IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface);
DWORD lod;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
lod = IWineD3DCubeTexture_GetLOD((LPDIRECT3DBASETEXTURE8) This);
lod = wined3d_texture_get_lod(This->wined3d_texture);
wined3d_mutex_unlock();
return lod;
}
static DWORD WINAPI IDirect3DCubeTexture8Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE8 iface) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
static DWORD WINAPI IDirect3DCubeTexture8Impl_GetLevelCount(IDirect3DCubeTexture8 *iface)
{
IDirect3DCubeTexture8Impl *This = impl_from_IDirect3DCubeTexture8(iface);
DWORD cnt;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
cnt = IWineD3DCubeTexture_GetLevelCount(This->wineD3DCubeTexture);
cnt = wined3d_texture_get_level_count(This->wined3d_texture);
wined3d_mutex_unlock();
return cnt;
}
/* IDirect3DCubeTexture8 Interface follow: */
static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE8 iface, UINT Level, D3DSURFACE_DESC *pDesc) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
HRESULT hr;
WINED3DSURFACE_DESC wined3ddesc;
static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetLevelDesc(IDirect3DCubeTexture8 *iface,
UINT level, D3DSURFACE_DESC *desc)
{
IDirect3DCubeTexture8Impl *texture = impl_from_IDirect3DCubeTexture8(iface);
struct wined3d_resource *sub_resource;
HRESULT hr = D3D_OK;
TRACE("iface %p, level %u, desc %p.\n", iface, Level, pDesc);
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
hr = D3DERR_INVALIDCALL;
else
{
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
pDesc->Type = wined3ddesc.resource_type;
pDesc->Usage = wined3ddesc.usage;
pDesc->Pool = wined3ddesc.pool;
pDesc->Size = wined3ddesc.size;
pDesc->MultiSampleType = wined3ddesc.multisample_type;
pDesc->Width = wined3ddesc.width;
pDesc->Height = wined3ddesc.height;
struct wined3d_resource_desc wined3d_desc;
wined3d_resource_get_desc(sub_resource, &wined3d_desc);
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = wined3d_desc.resource_type;
desc->Usage = wined3d_desc.usage;
desc->Pool = wined3d_desc.pool;
desc->Size = wined3d_desc.size;
desc->MultiSampleType = wined3d_desc.multisample_type;
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
}
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetCubeMapSurface(IDirect3DCubeTexture8 *iface,
D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface8 **ppCubeMapSurface)
D3DCUBEMAP_FACES face, UINT level, IDirect3DSurface8 **surface)
{
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
IWineD3DSurface *mySurface = NULL;
HRESULT hr;
IDirect3DCubeTexture8Impl *texture = impl_from_IDirect3DCubeTexture8(iface);
struct wined3d_resource *sub_resource;
UINT sub_resource_idx;
TRACE("iface %p, face %#x, level %u, surface %p.\n", iface, FaceType, Level, ppCubeMapSurface);
TRACE("iface %p, face %#x, level %u, surface %p.\n", iface, face, level, surface);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture,
(WINED3DCUBEMAP_FACES) FaceType, Level, &mySurface);
if (SUCCEEDED(hr) && ppCubeMapSurface)
sub_resource_idx = wined3d_texture_get_level_count(texture->wined3d_texture) * face + level;
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx)))
{
*ppCubeMapSurface = IWineD3DCubeTexture_GetParent(mySurface);
IDirect3DSurface8_AddRef(*ppCubeMapSurface);
IWineD3DCubeTexture_Release(mySurface);
wined3d_mutex_unlock();
return D3DERR_INVALIDCALL;
}
*surface = wined3d_resource_get_parent(sub_resource);
IDirect3DSurface8_AddRef(*surface);
wined3d_mutex_unlock();
return hr;
return D3D_OK;
}
static HRESULT WINAPI IDirect3DCubeTexture8Impl_LockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT *pRect, DWORD Flags) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DCubeTexture8Impl_LockRect(IDirect3DCubeTexture8 *iface,
D3DCUBEMAP_FACES face, UINT level, D3DLOCKED_RECT *locked_rect, const RECT *rect,
DWORD flags)
{
IDirect3DCubeTexture8Impl *texture = impl_from_IDirect3DCubeTexture8(iface);
struct wined3d_resource *sub_resource;
UINT sub_resource_idx;
HRESULT hr;
TRACE("iface %p, face %#x, level %u, locked_rect %p, rect %p, flags %#x.\n",
iface, FaceType, Level, pLockedRect, pRect, Flags);
iface, face, level, locked_rect, rect, flags);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_LockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
sub_resource_idx = wined3d_texture_get_level_count(texture->wined3d_texture) * face + level;
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx)))
hr = D3DERR_INVALIDCALL;
else
hr = IDirect3DSurface8_LockRect((IDirect3DSurface8 *)wined3d_resource_get_parent(sub_resource),
locked_rect, rect, flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DCubeTexture8Impl_UnlockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DCubeTexture8Impl_UnlockRect(IDirect3DCubeTexture8 *iface,
D3DCUBEMAP_FACES face, UINT level)
{
IDirect3DCubeTexture8Impl *texture = impl_from_IDirect3DCubeTexture8(iface);
struct wined3d_resource *sub_resource;
UINT sub_resource_idx;
HRESULT hr;
TRACE("iface %p, face %#x, level %u.\n", iface, FaceType, Level);
TRACE("iface %p, face %#x, level %u.\n", iface, face, level);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_UnlockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level);
sub_resource_idx = wined3d_texture_get_level_count(texture->wined3d_texture) * face + level;
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx)))
hr = D3DERR_INVALIDCALL;
else
hr = IDirect3DSurface8_UnlockRect((IDirect3DSurface8 *)wined3d_resource_get_parent(sub_resource));
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, CONST RECT *pDirtyRect) {
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(IDirect3DCubeTexture8 *iface,
D3DCUBEMAP_FACES face, const RECT *dirty_rect)
{
IDirect3DCubeTexture8Impl *texture = impl_from_IDirect3DCubeTexture8(iface);
HRESULT hr;
TRACE("iface %p, face %#x, dirty_rect %p.\n", iface, FaceType, pDirtyRect);
TRACE("iface %p, face %#x, dirty_rect %s.\n",
iface, face, wine_dbgstr_rect(dirty_rect));
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect);
if (!dirty_rect)
hr = wined3d_texture_add_dirty_region(texture->wined3d_texture, face, NULL);
else
{
WINED3DBOX dirty_region;
dirty_region.Left = dirty_rect->left;
dirty_region.Top = dirty_rect->top;
dirty_region.Right = dirty_rect->right;
dirty_region.Bottom = dirty_rect->bottom;
dirty_region.Front = 0;
dirty_region.Back = 1;
hr = wined3d_texture_add_dirty_region(texture->wined3d_texture, face, &dirty_region);
}
wined3d_mutex_unlock();
return hr;
@ -358,13 +421,13 @@ HRESULT cubetexture_init(IDirect3DCubeTexture8Impl *texture, IDirect3DDevice8Imp
{
HRESULT hr;
texture->lpVtbl = &Direct3DCubeTexture8_Vtbl;
texture->IDirect3DCubeTexture8_iface.lpVtbl = &Direct3DCubeTexture8_Vtbl;
texture->ref = 1;
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateCubeTexture(device->WineD3DDevice, edge_length, levels,
hr = wined3d_texture_create_cube(device->wined3d_device, edge_length, levels,
usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool, texture,
&d3d8_cubetexture_wined3d_parent_ops, &texture->wineD3DCubeTexture);
&d3d8_cubetexture_wined3d_parent_ops, &texture->wined3d_texture);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@ -372,7 +435,7 @@ HRESULT cubetexture_init(IDirect3DCubeTexture8Impl *texture, IDirect3DDevice8Imp
return hr;
}
texture->parentDevice = (IDirect3DDevice8 *)device;
texture->parentDevice = &device->IDirect3DDevice8_iface;
IDirect3DDevice8_AddRef(texture->parentDevice);
return D3D_OK;

View file

@ -43,9 +43,9 @@ IDirect3D8* WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT SDKVersion) {
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D8Impl));
object->lpVtbl = &Direct3D8_Vtbl;
object->IDirect3D8_iface.lpVtbl = &Direct3D8_Vtbl;
object->ref = 1;
object->WineD3D = WineDirect3DCreate(8, (IUnknown *)object);
object->WineD3D = wined3d_create(8, &object->IDirect3D8_iface);
TRACE("Created Direct3D object @ %p, WineObj @ %p\n", object, object->WineD3D);
@ -56,7 +56,7 @@ IDirect3D8* WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT SDKVersion) {
HeapFree( GetProcessHeap(), 0, object );
object = NULL;
}
return (IDirect3D8*) object;
return &object->IDirect3D8_iface;
}
/* At process attach */

View file

@ -109,7 +109,6 @@ typedef struct IDirect3DCubeTexture8Impl IDirect3DCubeTexture8Impl;
typedef struct IDirect3DIndexBuffer8Impl IDirect3DIndexBuffer8Impl;
typedef struct IDirect3DSurface8Impl IDirect3DSurface8Impl;
typedef struct IDirect3DSwapChain8Impl IDirect3DSwapChain8Impl;
typedef struct IDirect3DResource8Impl IDirect3DResource8Impl;
typedef struct IDirect3DVolume8Impl IDirect3DVolume8Impl;
typedef struct IDirect3DVertexBuffer8Impl IDirect3DVertexBuffer8Impl;
typedef struct IDirect3DVertexShader8Impl IDirect3DVertexShader8Impl;
@ -132,12 +131,9 @@ extern const IDirect3D8Vtbl Direct3D8_Vtbl DECLSPEC_HIDDEN;
*/
struct IDirect3D8Impl
{
/* IUnknown fields */
const IDirect3D8Vtbl *lpVtbl;
LONG ref;
/* The WineD3D device */
IWineD3D *WineD3D;
IDirect3D8 IDirect3D8_iface;
LONG ref;
struct wined3d *WineD3D;
};
/*****************************************************************************
@ -178,22 +174,22 @@ struct FvfToDecl
struct IDirect3DDevice8Impl
{
/* IUnknown fields */
const IDirect3DDevice8Vtbl *lpVtbl;
const IWineD3DDeviceParentVtbl *device_parent_vtbl;
LONG ref;
/* But what about baseVertexIndex in state blocks? hmm... it may be a better idea to pass this to wined3d */
IWineD3DDevice *WineD3DDevice;
struct d3d8_handle_table handle_table;
IDirect3DDevice8 IDirect3DDevice8_iface;
struct wined3d_device_parent device_parent;
LONG ref;
struct wined3d_device *wined3d_device;
struct d3d8_handle_table handle_table;
/* FVF management */
struct FvfToDecl *decls;
UINT numConvertedDecls, declArraySize;
/* Avoids recursion with nested ReleaseRef to 0 */
BOOL inDestruction;
BOOL inDestruction;
BOOL lost;
};
HRESULT device_init(IDirect3DDevice8Impl *device, IWineD3D *wined3d, UINT adapter,
HRESULT device_init(IDirect3DDevice8Impl *device, struct wined3d *wined3d, UINT adapter,
D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters) DECLSPEC_HIDDEN;
/* ---------------- */
@ -205,18 +201,11 @@ HRESULT device_init(IDirect3DDevice8Impl *device, IWineD3D *wined3d, UINT adapte
*/
struct IDirect3DVolume8Impl
{
/* IUnknown fields */
const IDirect3DVolume8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DVolume8 fields */
IWineD3DVolume *wineD3DVolume;
/* The volume container */
IUnknown *container;
/* If set forward refcounting to this object */
IUnknown *forwardReference;
IDirect3DVolume8 IDirect3DVolume8_iface;
LONG ref;
struct wined3d_volume *wined3d_volume;
IUnknown *container;
IUnknown *forwardReference;
};
HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device, UINT width, UINT height,
@ -232,14 +221,10 @@ HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device,
struct IDirect3DSwapChain8Impl
{
/* IUnknown fields */
const IDirect3DSwapChain8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DSwapChain8 fields */
IWineD3DSwapChain *wineD3DSwapChain;
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
IDirect3DSwapChain8 IDirect3DSwapChain8_iface;
LONG ref;
struct wined3d_swapchain *wined3d_swapchain;
IDirect3DDevice8 *parentDevice;
};
HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, IDirect3DDevice8Impl *device,
@ -257,12 +242,8 @@ struct IDirect3DSurface8Impl
/* IUnknown fields */
const IDirect3DSurface8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DSurface8 fields */
IWineD3DSurface *wineD3DSurface;
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
struct wined3d_surface *wined3d_surface;
IDirect3DDevice8 *parentDevice;
/* The surface container */
IUnknown *container;
@ -275,16 +256,6 @@ HRESULT surface_init(IDirect3DSurface8Impl *surface, IDirect3DDevice8Impl *devic
UINT width, UINT height, D3DFORMAT format, BOOL lockable, BOOL discard, UINT level,
DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality) DECLSPEC_HIDDEN;
struct IDirect3DResource8Impl
{
/* IUnknown fields */
const IDirect3DResource8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource8 fields */
IWineD3DResource *wineD3DResource;
};
/* ---------------------- */
/* IDirect3DVertexBuffer8 */
/* ---------------------- */
@ -298,13 +269,9 @@ struct IDirect3DVertexBuffer8Impl
const IDirect3DVertexBuffer8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource8 fields */
IWineD3DBuffer *wineD3DVertexBuffer;
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
DWORD fvf;
struct wined3d_buffer *wineD3DVertexBuffer;
IDirect3DDevice8 *parentDevice;
DWORD fvf;
};
HRESULT vertexbuffer_init(IDirect3DVertexBuffer8Impl *buffer, IDirect3DDevice8Impl *device,
@ -323,12 +290,8 @@ struct IDirect3DIndexBuffer8Impl
const IDirect3DIndexBuffer8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource8 fields */
IWineD3DBuffer *wineD3DIndexBuffer;
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
struct wined3d_buffer *wineD3DIndexBuffer;
IDirect3DDevice8 *parentDevice;
enum wined3d_format_id format;
};
@ -347,9 +310,7 @@ struct IDirect3DBaseTexture8Impl
/* IUnknown fields */
const IDirect3DBaseTexture8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource8 fields */
IWineD3DBaseTexture *wineD3DBaseTexture;
struct wined3d_texture *wined3d_texture;
};
/* --------------------- */
@ -361,15 +322,10 @@ struct IDirect3DBaseTexture8Impl
*/
struct IDirect3DCubeTexture8Impl
{
/* IUnknown fields */
const IDirect3DCubeTexture8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource8 fields */
IWineD3DCubeTexture *wineD3DCubeTexture;
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
IDirect3DCubeTexture8 IDirect3DCubeTexture8_iface;
LONG ref;
struct wined3d_texture *wined3d_texture;
IDirect3DDevice8 *parentDevice;
};
HRESULT cubetexture_init(IDirect3DCubeTexture8Impl *texture, IDirect3DDevice8Impl *device,
@ -384,15 +340,10 @@ HRESULT cubetexture_init(IDirect3DCubeTexture8Impl *texture, IDirect3DDevice8Imp
*/
struct IDirect3DTexture8Impl
{
/* IUnknown fields */
const IDirect3DTexture8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResourc8 fields */
IWineD3DTexture *wineD3DTexture;
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
IDirect3DTexture8 IDirect3DTexture8_iface;
LONG ref;
struct wined3d_texture *wined3d_texture;
IDirect3DDevice8 *parentDevice;
};
HRESULT texture_init(IDirect3DTexture8Impl *texture, IDirect3DDevice8Impl *device,
@ -407,15 +358,10 @@ HRESULT texture_init(IDirect3DTexture8Impl *texture, IDirect3DDevice8Impl *devic
*/
struct IDirect3DVolumeTexture8Impl
{
/* IUnknown fields */
const IDirect3DVolumeTexture8Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource8 fields */
IWineD3DVolumeTexture *wineD3DVolumeTexture;
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
IDirect3DVolumeTexture8 IDirect3DVolumeTexture8_iface;
LONG ref;
struct wined3d_texture *wined3d_texture;
IDirect3DDevice8 *parentDevice;
};
HRESULT volumetexture_init(IDirect3DVolumeTexture8Impl *texture, IDirect3DDevice8Impl *device,
@ -455,7 +401,7 @@ typedef struct {
DWORD *elements;
DWORD elements_size; /* Size of elements, in bytes */
IWineD3DVertexDeclaration *wined3d_vertex_declaration;
struct wined3d_vertex_declaration *wined3d_vertex_declaration;
DWORD shader_handle;
} IDirect3DVertexDeclaration8Impl;
@ -509,11 +455,10 @@ DECLARE_INTERFACE_(IDirect3DPixelShader8,IUnknown)
*/
struct IDirect3DVertexShader8Impl {
const IDirect3DVertexShader8Vtbl *lpVtbl;
LONG ref;
IDirect3DVertexDeclaration8 *vertex_declaration;
IWineD3DVertexShader *wineD3DVertexShader;
IDirect3DVertexShader8 IDirect3DVertexShader8_iface;
LONG ref;
IDirect3DVertexDeclaration8 *vertex_declaration;
struct wined3d_shader *wined3d_shader;
};
HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Impl *device,
@ -525,11 +470,10 @@ HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Im
* IDirect3DPixelShader implementation structure
*/
typedef struct IDirect3DPixelShader8Impl {
const IDirect3DPixelShader8Vtbl *lpVtbl;
IDirect3DPixelShader8 IDirect3DPixelShader8_iface;
LONG ref;
DWORD handle;
IWineD3DPixelShader *wineD3DPixelShader;
DWORD handle;
struct wined3d_shader *wined3d_shader;
} IDirect3DPixelShader8Impl;
HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl *device,
@ -537,7 +481,7 @@ HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl
D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN;
enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN;
void load_local_constants(const DWORD *d3d8_elements, IWineD3DVertexShader *wined3d_vertex_shader) DECLSPEC_HIDDEN;
void load_local_constants(const DWORD *d3d8_elements, struct wined3d_shader *wined3d_vertex_shader) DECLSPEC_HIDDEN;
size_t parse_token(const DWORD *pToken) DECLSPEC_HIDDEN;
#endif /* __WINE_D3DX8_PRIVATE_H */

File diff suppressed because it is too large Load diff

View file

@ -37,10 +37,14 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3D IUnknown parts follow: */
static inline IDirect3D8Impl *impl_from_IDirect3D8(IDirect3D8 *iface)
{
return CONTAINING_RECORD(iface, IDirect3D8Impl, IDirect3D8_iface);
}
static HRESULT WINAPI IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface, REFIID riid,LPVOID *ppobj)
{
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
@ -56,8 +60,9 @@ static HRESULT WINAPI IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface, REFIID ri
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3D8Impl_AddRef(LPDIRECT3D8 iface) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
static ULONG WINAPI IDirect3D8Impl_AddRef(LPDIRECT3D8 iface)
{
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", iface, ref);
@ -65,8 +70,9 @@ static ULONG WINAPI IDirect3D8Impl_AddRef(LPDIRECT3D8 iface) {
return ref;
}
static ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
static ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface)
{
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", iface, ref);
@ -75,7 +81,7 @@ static ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface) {
TRACE("Releasing wined3d %p\n", This->WineD3D);
wined3d_mutex_lock();
IWineD3D_Release(This->WineD3D);
wined3d_decref(This->WineD3D);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
@ -84,37 +90,39 @@ static ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface) {
return ref;
}
/* IDirect3D8 Interface follow: */
static HRESULT WINAPI IDirect3D8Impl_RegisterSoftwareDevice (LPDIRECT3D8 iface, void* pInitializeFunction) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
static HRESULT WINAPI IDirect3D8Impl_RegisterSoftwareDevice(LPDIRECT3D8 iface,
void* pInitializeFunction)
{
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
HRESULT hr;
TRACE("iface %p, init_function %p.\n", iface, pInitializeFunction);
wined3d_mutex_lock();
hr = IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
hr = wined3d_register_software_device(This->WineD3D, pInitializeFunction);
wined3d_mutex_unlock();
return hr;
}
static UINT WINAPI IDirect3D8Impl_GetAdapterCount (LPDIRECT3D8 iface) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
static UINT WINAPI IDirect3D8Impl_GetAdapterCount(LPDIRECT3D8 iface)
{
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterCount(This->WineD3D);
hr = wined3d_get_adapter_count(This->WineD3D);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier(LPDIRECT3D8 iface,
UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER8 *pIdentifier)
static HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier(LPDIRECT3D8 iface, UINT Adapter,
DWORD Flags, D3DADAPTER_IDENTIFIER8 *pIdentifier)
{
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
WINED3DADAPTER_IDENTIFIER adapter_id;
HRESULT hr;
@ -129,7 +137,7 @@ static HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier(LPDIRECT3D8 iface,
adapter_id.device_name_size = 0; /* d3d9 only */
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
hr = wined3d_get_adapter_identifier(This->WineD3D, Adapter, Flags, &adapter_id);
wined3d_mutex_unlock();
pIdentifier->DriverVersion = adapter_id.driver_version;
@ -143,28 +151,31 @@ static HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier(LPDIRECT3D8 iface,
return hr;
}
static UINT WINAPI IDirect3D8Impl_GetAdapterModeCount (LPDIRECT3D8 iface,UINT Adapter) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
static UINT WINAPI IDirect3D8Impl_GetAdapterModeCount(LPDIRECT3D8 iface,UINT Adapter)
{
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
HRESULT hr;
TRACE("iface %p, adapter %u.\n", iface, Adapter);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, 0 /* format */);
hr = wined3d_get_adapter_mode_count(This->WineD3D, Adapter, 0);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface, UINT Adapter, UINT Mode, D3DDISPLAYMODE* pMode) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
static HRESULT WINAPI IDirect3D8Impl_EnumAdapterModes(LPDIRECT3D8 iface, UINT Adapter, UINT Mode,
D3DDISPLAYMODE* pMode)
{
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, mode_idx %u, mode %p.\n",
iface, Adapter, Mode, pMode);
wined3d_mutex_lock();
hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, WINED3DFMT_UNKNOWN, Mode, (WINED3DDISPLAYMODE *) pMode);
hr = wined3d_enum_adapter_modes(This->WineD3D, Adapter, WINED3DFMT_UNKNOWN, Mode, (WINED3DDISPLAYMODE *)pMode);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
@ -172,15 +183,17 @@ static HRESULT WINAPI IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface, UINT A
return hr;
}
static HRESULT WINAPI IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
static HRESULT WINAPI IDirect3D8Impl_GetAdapterDisplayMode(LPDIRECT3D8 iface, UINT Adapter,
D3DDISPLAYMODE* pMode)
{
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, mode %p.\n",
iface, Adapter, pMode);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
hr = wined3d_get_adapter_display_mode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *)pMode);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
@ -188,27 +201,28 @@ static HRESULT WINAPI IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface, U
return hr;
}
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceType (LPDIRECT3D8 iface,
UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
D3DFORMAT BackBufferFormat, BOOL Windowed) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceType(LPDIRECT3D8 iface, UINT Adapter,
D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed)
{
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, display_format %#x, backbuffer_format %#x, windowed %#x.\n",
iface, Adapter, CheckType, DisplayFormat, BackBufferFormat, Windowed);
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
hr = wined3d_check_device_type(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
wined3dformat_from_d3dformat(BackBufferFormat), Windowed);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat(LPDIRECT3D8 iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType,
D3DFORMAT CheckFormat)
{
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
HRESULT hr;
WINED3DRESOURCETYPE WineD3DRType;
@ -235,7 +249,7 @@ static HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 i
}
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
hr = wined3d_check_device_format(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
Usage, WineD3DRType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
wined3d_mutex_unlock();
@ -243,33 +257,35 @@ static HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 i
}
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceMultiSampleType(IDirect3D8 *iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType)
D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed,
D3DMULTISAMPLE_TYPE MultiSampleType)
{
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, format %#x, windowed %#x, multisample_type %#x.\n",
iface, Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType);
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(SurfaceFormat), Windowed, (WINED3DMULTISAMPLE_TYPE) MultiSampleType, NULL);
hr = wined3d_check_device_multisample_type(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(SurfaceFormat), Windowed, (WINED3DMULTISAMPLE_TYPE)MultiSampleType, NULL);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(IDirect3D8 *iface, UINT Adapter, D3DDEVTYPE DeviceType,
D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat)
static HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(IDirect3D8 *iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat,
D3DFORMAT DepthStencilFormat)
{
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, rt_format %#x, ds_format %#x.\n",
iface, Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
wined3d_mutex_lock();
hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType,
hr = wined3d_check_depth_stencil_match(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat),
wined3dformat_from_d3dformat(DepthStencilFormat));
wined3d_mutex_unlock();
@ -291,8 +307,10 @@ void fixup_caps(WINED3DCAPS *caps)
caps->StencilCaps &= ~WINED3DSTENCILCAPS_TWOSIDED;
}
static HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8* pCaps) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
static HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DCAPS8* pCaps)
{
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
HRESULT hrc = D3D_OK;
WINED3DCAPS *pWineCaps;
@ -307,7 +325,7 @@ static HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Ada
}
wined3d_mutex_lock();
hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
hrc = wined3d_get_device_caps(This->WineD3D, Adapter, DeviceType, pWineCaps);
wined3d_mutex_unlock();
fixup_caps(pWineCaps);
@ -318,23 +336,25 @@ static HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Ada
return hrc;
}
static HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
static HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter)
{
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
HMONITOR ret;
TRACE("iface %p, adapter %u.\n", iface, Adapter);
wined3d_mutex_lock();
ret = IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
ret = wined3d_get_adapter_monitor(This->WineD3D, Adapter);
wined3d_mutex_unlock();
return ret;
}
static HRESULT WINAPI IDirect3D8Impl_CreateDevice(IDirect3D8 *iface, UINT adapter, D3DDEVTYPE device_type,
HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters, IDirect3DDevice8 **device)
static HRESULT WINAPI IDirect3D8Impl_CreateDevice(IDirect3D8 *iface, UINT adapter,
D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters,
IDirect3DDevice8 **device)
{
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
IDirect3DDevice8Impl *object;
HRESULT hr;
@ -357,7 +377,7 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(IDirect3D8 *iface, UINT adapte
}
TRACE("Created device %p.\n", object);
*device = (IDirect3DDevice8 *)object;
*device = &object->IDirect3DDevice8_iface;
return D3D_OK;
}

View file

@ -22,6 +22,11 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
static inline IDirect3DVertexShader8Impl *impl_from_IDirect3DVertexShader8(IDirect3DVertexShader8 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DVertexShader8Impl, IDirect3DVertexShader8_iface);
}
static HRESULT WINAPI d3d8_vertexshader_QueryInterface(IDirect3DVertexShader8 *iface, REFIID riid, void **object)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
@ -42,15 +47,15 @@ static HRESULT WINAPI d3d8_vertexshader_QueryInterface(IDirect3DVertexShader8 *i
static ULONG WINAPI d3d8_vertexshader_AddRef(IDirect3DVertexShader8 *iface)
{
IDirect3DVertexShader8Impl *shader = (IDirect3DVertexShader8Impl *)iface;
IDirect3DVertexShader8Impl *shader = impl_from_IDirect3DVertexShader8(iface);
ULONG refcount = InterlockedIncrement(&shader->ref);
TRACE("%p increasing refcount to %u.\n", iface, refcount);
if (refcount == 1 && shader->wineD3DVertexShader)
if (refcount == 1 && shader->wined3d_shader)
{
wined3d_mutex_lock();
IWineD3DVertexShader_AddRef(shader->wineD3DVertexShader);
wined3d_shader_incref(shader->wined3d_shader);
wined3d_mutex_unlock();
}
@ -66,17 +71,17 @@ static void STDMETHODCALLTYPE d3d8_vertexshader_wined3d_object_destroyed(void *p
static ULONG WINAPI d3d8_vertexshader_Release(IDirect3DVertexShader8 *iface)
{
IDirect3DVertexShader8Impl *shader = (IDirect3DVertexShader8Impl *)iface;
IDirect3DVertexShader8Impl *shader = impl_from_IDirect3DVertexShader8(iface);
ULONG refcount = InterlockedDecrement(&shader->ref);
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
if (!refcount)
{
if (shader->wineD3DVertexShader)
if (shader->wined3d_shader)
{
wined3d_mutex_lock();
IWineD3DVertexShader_Release(shader->wineD3DVertexShader);
wined3d_shader_decref(shader->wined3d_shader);
wined3d_mutex_unlock();
}
else
@ -157,7 +162,7 @@ HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Im
}
shader->ref = 1;
shader->lpVtbl = &d3d8_vertexshader_vtbl;
shader->IDirect3DVertexShader8_iface.lpVtbl = &d3d8_vertexshader_vtbl;
hr = d3d8_vertexshader_create_vertexdeclaration(device, declaration, shader_handle, &shader->vertex_declaration);
if (FAILED(hr))
@ -171,8 +176,8 @@ HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Im
if (usage) FIXME("Usage %#x not implemented.\n", usage);
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateVertexShader(device->WineD3DDevice, byte_code, NULL /* output signature */,
shader, &d3d8_vertexshader_wined3d_parent_ops, &shader->wineD3DVertexShader);
hr = wined3d_shader_create_vs(device->wined3d_device, byte_code, NULL /* output signature */,
shader, &d3d8_vertexshader_wined3d_parent_ops, &shader->wined3d_shader);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@ -181,12 +186,17 @@ HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Im
return hr;
}
load_local_constants(declaration, shader->wineD3DVertexShader);
load_local_constants(declaration, shader->wined3d_shader);
}
return D3D_OK;
}
static inline IDirect3DPixelShader8Impl *impl_from_IDirect3DPixelShader8(IDirect3DPixelShader8 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DPixelShader8Impl, IDirect3DPixelShader8_iface);
}
static HRESULT WINAPI d3d8_pixelshader_QueryInterface(IDirect3DPixelShader8 *iface, REFIID riid, void **object)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
@ -207,7 +217,7 @@ static HRESULT WINAPI d3d8_pixelshader_QueryInterface(IDirect3DPixelShader8 *ifa
static ULONG WINAPI d3d8_pixelshader_AddRef(IDirect3DPixelShader8 *iface)
{
IDirect3DPixelShader8Impl *shader = (IDirect3DPixelShader8Impl *)iface;
IDirect3DPixelShader8Impl *shader = impl_from_IDirect3DPixelShader8(iface);
ULONG refcount = InterlockedIncrement(&shader->ref);
TRACE("%p increasing refcount to %u.\n", iface, refcount);
@ -215,7 +225,7 @@ static ULONG WINAPI d3d8_pixelshader_AddRef(IDirect3DPixelShader8 *iface)
if (refcount == 1)
{
wined3d_mutex_lock();
IWineD3DPixelShader_AddRef(shader->wineD3DPixelShader);
wined3d_shader_incref(shader->wined3d_shader);
wined3d_mutex_unlock();
}
@ -224,7 +234,7 @@ static ULONG WINAPI d3d8_pixelshader_AddRef(IDirect3DPixelShader8 *iface)
static ULONG WINAPI d3d8_pixelshader_Release(IDirect3DPixelShader8 *iface)
{
IDirect3DPixelShader8Impl *shader = (IDirect3DPixelShader8Impl *)iface;
IDirect3DPixelShader8Impl *shader = impl_from_IDirect3DPixelShader8(iface);
ULONG refcount = InterlockedDecrement(&shader->ref);
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
@ -232,7 +242,7 @@ static ULONG WINAPI d3d8_pixelshader_Release(IDirect3DPixelShader8 *iface)
if (!refcount)
{
wined3d_mutex_lock();
IWineD3DPixelShader_Release(shader->wineD3DPixelShader);
wined3d_shader_decref(shader->wined3d_shader);
wined3d_mutex_unlock();
}
@ -263,12 +273,12 @@ HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl
HRESULT hr;
shader->ref = 1;
shader->lpVtbl = &d3d8_pixelshader_vtbl;
shader->IDirect3DPixelShader8_iface.lpVtbl = &d3d8_pixelshader_vtbl;
shader->handle = shader_handle;
wined3d_mutex_lock();
hr = IWineD3DDevice_CreatePixelShader(device->WineD3DDevice, byte_code, NULL, shader,
&d3d8_pixelshader_wined3d_parent_ops, &shader->wineD3DPixelShader);
hr = wined3d_shader_create_ps(device->wined3d_device, byte_code, NULL, shader,
&d3d8_pixelshader_wined3d_parent_ops, &shader->wined3d_shader);
wined3d_mutex_unlock();
if (FAILED(hr))
{

View file

@ -61,7 +61,7 @@ static ULONG WINAPI IDirect3DSurface8Impl_AddRef(LPDIRECT3DSURFACE8 iface) {
{
if (This->parentDevice) IUnknown_AddRef(This->parentDevice);
wined3d_mutex_lock();
IUnknown_AddRef(This->wineD3DSurface);
wined3d_surface_incref(This->wined3d_surface);
wined3d_mutex_unlock();
}
@ -89,7 +89,7 @@ static ULONG WINAPI IDirect3DSurface8Impl_Release(LPDIRECT3DSURFACE8 iface) {
/* Implicit surfaces are destroyed with the device, not if refcount reaches 0. */
wined3d_mutex_lock();
IWineD3DSurface_Release(This->wineD3DSurface);
wined3d_surface_decref(This->wined3d_surface);
wined3d_mutex_unlock();
if (parentDevice) IDirect3DDevice8_Release(parentDevice);
@ -139,7 +139,7 @@ static HRESULT WINAPI IDirect3DSurface8Impl_SetPrivateData(LPDIRECT3DSURFACE8 if
iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
wined3d_mutex_lock();
hr = IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
hr = wined3d_surface_set_private_data(This->wined3d_surface, refguid, pData, SizeOfData, Flags);
wined3d_mutex_unlock();
return hr;
@ -153,7 +153,7 @@ static HRESULT WINAPI IDirect3DSurface8Impl_GetPrivateData(LPDIRECT3DSURFACE8 if
iface, debugstr_guid(refguid), pData, pSizeOfData);
wined3d_mutex_lock();
hr = IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
hr = wined3d_surface_get_private_data(This->wined3d_surface, refguid, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;
@ -166,7 +166,7 @@ static HRESULT WINAPI IDirect3DSurface8Impl_FreePrivateData(LPDIRECT3DSURFACE8 i
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
wined3d_mutex_lock();
hr = IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
hr = wined3d_surface_free_private_data(This->wined3d_surface, refguid);
wined3d_mutex_unlock();
return hr;
@ -187,24 +187,27 @@ static HRESULT WINAPI IDirect3DSurface8Impl_GetContainer(LPDIRECT3DSURFACE8 ifac
return res;
}
static HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(LPDIRECT3DSURFACE8 iface, D3DSURFACE_DESC *pDesc) {
static HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(IDirect3DSurface8 *iface, D3DSURFACE_DESC *desc)
{
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
struct wined3d_resource_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
TRACE("iface %p, desc %p.\n", iface, pDesc);
TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock();
IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
wined3d_resource = wined3d_surface_get_resource(This->wined3d_surface);
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
wined3d_mutex_unlock();
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
pDesc->Type = wined3ddesc.resource_type;
pDesc->Usage = wined3ddesc.usage;
pDesc->Pool = wined3ddesc.pool;
pDesc->Size = wined3ddesc.size;
pDesc->MultiSampleType = wined3ddesc.multisample_type;
pDesc->Width = wined3ddesc.width;
pDesc->Height = wined3ddesc.height;
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = wined3d_desc.resource_type;
desc->Usage = wined3d_desc.usage;
desc->Pool = wined3d_desc.pool;
desc->Size = wined3d_desc.size;
desc->MultiSampleType = wined3d_desc.multisample_type;
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
return D3D_OK;
}
@ -233,7 +236,7 @@ static HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D
}
}
hr = IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
hr = wined3d_surface_map(This->wined3d_surface, (WINED3DLOCKED_RECT *)pLockedRect, pRect, Flags);
wined3d_mutex_unlock();
return hr;
@ -246,7 +249,7 @@ static HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface)
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DSurface_UnlockRect(This->wineD3DSurface);
hr = wined3d_surface_unmap(This->wined3d_surface);
wined3d_mutex_unlock();
switch(hr)
@ -301,9 +304,9 @@ HRESULT surface_init(IDirect3DSurface8Impl *surface, IDirect3DDevice8Impl *devic
}
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateSurface(device->WineD3DDevice, width, height, wined3dformat_from_d3dformat(format),
hr = wined3d_surface_create(device->wined3d_device, width, height, wined3dformat_from_d3dformat(format),
lockable, discard, level, usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, multisample_type,
multisample_quality, SURFACE_OPENGL, surface, &d3d8_surface_wined3d_parent_ops, &surface->wineD3DSurface);
multisample_quality, SURFACE_OPENGL, surface, &d3d8_surface_wined3d_parent_ops, &surface->wined3d_surface);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@ -311,7 +314,7 @@ HRESULT surface_init(IDirect3DSurface8Impl *surface, IDirect3DDevice8Impl *devic
return hr;
}
surface->parentDevice = (IDirect3DDevice8 *)device;
surface->parentDevice = &device->IDirect3DDevice8_iface;
IUnknown_AddRef(surface->parentDevice);
return D3D_OK;

View file

@ -23,10 +23,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DSwapChain IUnknown parts follow: */
static HRESULT WINAPI IDirect3DSwapChain8Impl_QueryInterface(LPDIRECT3DSWAPCHAIN8 iface, REFIID riid, LPVOID* ppobj)
static inline IDirect3DSwapChain8Impl *impl_from_IDirect3DSwapChain8(IDirect3DSwapChain8 *iface)
{
IDirect3DSwapChain8Impl *This = (IDirect3DSwapChain8Impl *)iface;
return CONTAINING_RECORD(iface, IDirect3DSwapChain8Impl, IDirect3DSwapChain8_iface);
}
static HRESULT WINAPI IDirect3DSwapChain8Impl_QueryInterface(IDirect3DSwapChain8 *iface,
REFIID riid, void **ppobj)
{
IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
@ -42,42 +47,59 @@ static HRESULT WINAPI IDirect3DSwapChain8Impl_QueryInterface(LPDIRECT3DSWAPCHAIN
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DSwapChain8Impl_AddRef(LPDIRECT3DSWAPCHAIN8 iface) {
IDirect3DSwapChain8Impl *This = (IDirect3DSwapChain8Impl *)iface;
static ULONG WINAPI IDirect3DSwapChain8Impl_AddRef(IDirect3DSwapChain8 *iface)
{
IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", iface, ref);
if (ref == 1)
{
if (This->parentDevice)
IDirect3DDevice8_AddRef(This->parentDevice);
wined3d_mutex_lock();
wined3d_swapchain_incref(This->wined3d_swapchain);
wined3d_mutex_unlock();
}
return ref;
}
static ULONG WINAPI IDirect3DSwapChain8Impl_Release(LPDIRECT3DSWAPCHAIN8 iface) {
IDirect3DSwapChain8Impl *This = (IDirect3DSwapChain8Impl *)iface;
static ULONG WINAPI IDirect3DSwapChain8Impl_Release(IDirect3DSwapChain8 *iface)
{
IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", iface, ref);
if (ref == 0) {
if (!ref)
{
IDirect3DDevice8 *parentDevice = This->parentDevice;
wined3d_mutex_lock();
IWineD3DSwapChain_Destroy(This->wineD3DSwapChain);
wined3d_swapchain_decref(This->wined3d_swapchain);
wined3d_mutex_unlock();
if (This->parentDevice) IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
if (parentDevice)
IDirect3DDevice8_Release(parentDevice);
}
return ref;
}
/* IDirect3DSwapChain8 parts follow: */
static HRESULT WINAPI IDirect3DSwapChain8Impl_Present(LPDIRECT3DSWAPCHAIN8 iface, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion) {
IDirect3DSwapChain8Impl *This = (IDirect3DSwapChain8Impl *)iface;
static HRESULT WINAPI IDirect3DSwapChain8Impl_Present(IDirect3DSwapChain8 *iface,
const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride,
const RGNDATA *pDirtyRegion)
{
IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface);
HRESULT hr;
TRACE("iface %p, src_rect %p, dst_rect %p, dst_window_override %p, dirty_region %p.\n",
iface, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_Present(This->wineD3DSwapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, 0);
hr = wined3d_swapchain_present(This->wined3d_swapchain, pSourceRect,
pDestRect, hDestWindowOverride, pDirtyRegion, 0);
wined3d_mutex_unlock();
return hr;
@ -86,21 +108,21 @@ static HRESULT WINAPI IDirect3DSwapChain8Impl_Present(LPDIRECT3DSWAPCHAIN8 iface
static HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(IDirect3DSwapChain8 *iface,
UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8 **ppBackBuffer)
{
IDirect3DSwapChain8Impl *This = (IDirect3DSwapChain8Impl *)iface;
IWineD3DSurface *mySurface = NULL;
IDirect3DSwapChain8Impl *This = impl_from_IDirect3DSwapChain8(iface);
struct wined3d_surface *wined3d_surface = NULL;
HRESULT hr;
TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
iface, iBackBuffer, Type, ppBackBuffer);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer,
(WINED3DBACKBUFFER_TYPE)Type, &mySurface);
if (SUCCEEDED(hr) && mySurface)
hr = wined3d_swapchain_get_back_buffer(This->wined3d_swapchain,
iBackBuffer, (WINED3DBACKBUFFER_TYPE)Type, &wined3d_surface);
if (SUCCEEDED(hr) && wined3d_surface)
{
*ppBackBuffer = IWineD3DSurface_GetParent(mySurface);
*ppBackBuffer = wined3d_surface_get_parent(wined3d_surface);
IDirect3DSurface8_AddRef(*ppBackBuffer);
IWineD3DSurface_Release(mySurface);
wined3d_surface_decref(wined3d_surface);
}
wined3d_mutex_unlock();
@ -116,6 +138,16 @@ static const IDirect3DSwapChain8Vtbl Direct3DSwapChain8_Vtbl =
IDirect3DSwapChain8Impl_GetBackBuffer
};
static void STDMETHODCALLTYPE d3d8_swapchain_wined3d_object_released(void *parent)
{
HeapFree(GetProcessHeap(), 0, parent);
}
static const struct wined3d_parent_ops d3d8_swapchain_wined3d_parent_ops =
{
d3d8_swapchain_wined3d_object_released,
};
HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, IDirect3DDevice8Impl *device,
D3DPRESENT_PARAMETERS *present_parameters)
{
@ -123,7 +155,7 @@ HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, IDirect3DDevice8Impl
HRESULT hr;
swapchain->ref = 1;
swapchain->lpVtbl = &Direct3DSwapChain8_Vtbl;
swapchain->IDirect3DSwapChain8_iface.lpVtbl = &Direct3DSwapChain8_Vtbl;
wined3d_parameters.BackBufferWidth = present_parameters->BackBufferWidth;
wined3d_parameters.BackBufferHeight = present_parameters->BackBufferHeight;
@ -142,8 +174,9 @@ HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, IDirect3DDevice8Impl
wined3d_parameters.AutoRestoreDisplayMode = TRUE;
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateSwapChain(device->WineD3DDevice, &wined3d_parameters,
SURFACE_OPENGL, swapchain, &swapchain->wineD3DSwapChain);
hr = wined3d_swapchain_create(device->wined3d_device, &wined3d_parameters,
SURFACE_OPENGL, swapchain, &d3d8_swapchain_wined3d_parent_ops,
&swapchain->wined3d_swapchain);
wined3d_mutex_unlock();
present_parameters->BackBufferWidth = wined3d_parameters.BackBufferWidth;
@ -166,7 +199,7 @@ HRESULT swapchain_init(IDirect3DSwapChain8Impl *swapchain, IDirect3DDevice8Impl
return hr;
}
swapchain->parentDevice = (IDirect3DDevice8 *)device;
swapchain->parentDevice = &device->IDirect3DDevice8_iface;
IDirect3DDevice8_AddRef(swapchain->parentDevice);
return D3D_OK;

View file

@ -24,8 +24,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DTexture8 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
static inline IDirect3DTexture8Impl *impl_from_IDirect3DTexture8(IDirect3DTexture8 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DTexture8Impl, IDirect3DTexture8_iface);
}
static HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(IDirect3DTexture8 *iface, REFIID riid,
void **ppobj)
{
IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
@ -43,8 +50,9 @@ static HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 if
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DTexture8Impl_AddRef(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
static ULONG WINAPI IDirect3DTexture8Impl_AddRef(IDirect3DTexture8 *iface)
{
IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", iface, ref);
@ -53,15 +61,16 @@ static ULONG WINAPI IDirect3DTexture8Impl_AddRef(LPDIRECT3DTEXTURE8 iface) {
{
IDirect3DDevice8_AddRef(This->parentDevice);
wined3d_mutex_lock();
IWineD3DTexture_AddRef(This->wineD3DTexture);
wined3d_texture_incref(This->wined3d_texture);
wined3d_mutex_unlock();
}
return ref;
}
static ULONG WINAPI IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
static ULONG WINAPI IDirect3DTexture8Impl_Release(IDirect3DTexture8 *iface)
{
IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", iface, ref);
@ -70,7 +79,7 @@ static ULONG WINAPI IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface) {
IDirect3DDevice8 *parentDevice = This->parentDevice;
wined3d_mutex_lock();
IWineD3DTexture_Release(This->wineD3DTexture);
wined3d_texture_decref(This->wined3d_texture);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
@ -80,9 +89,10 @@ static ULONG WINAPI IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface) {
}
/* IDirect3DTexture8 IDirect3DResource8 Interface follow: */
static HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(IDirect3DTexture8 *iface, IDirect3DDevice8 **device)
static HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(IDirect3DTexture8 *iface,
IDirect3DDevice8 **device)
{
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface);
TRACE("iface %p, device %p.\n", iface, device);
@ -94,220 +104,264 @@ static HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(IDirect3DTexture8 *iface,
return D3D_OK;
}
static HRESULT WINAPI IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DTexture8Impl_SetPrivateData(IDirect3DTexture8 *iface,
REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags)
{
IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface);
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
wined3d_mutex_lock();
hr = IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags);
hr = wined3d_texture_set_private_data(This->wined3d_texture, refguid, pData, SizeOfData, Flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DTexture8Impl_GetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, void *pData, DWORD* pSizeOfData) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DTexture8Impl_GetPrivateData(IDirect3DTexture8 *iface,
REFGUID refguid, void *pData, DWORD *pSizeOfData)
{
IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface);
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %p.\n",
iface, debugstr_guid(refguid), pData, pSizeOfData);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData);
hr = wined3d_texture_get_private_data(This->wined3d_texture, refguid, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DTexture8Impl_FreePrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DTexture8Impl_FreePrivateData(IDirect3DTexture8 *iface,
REFGUID refguid)
{
IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface);
HRESULT hr;
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
wined3d_mutex_lock();
hr = IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid);
hr = wined3d_texture_free_private_data(This->wined3d_texture, refguid);
wined3d_mutex_unlock();
return hr;
}
static DWORD WINAPI IDirect3DTexture8Impl_SetPriority(LPDIRECT3DTEXTURE8 iface, DWORD PriorityNew) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
static DWORD WINAPI IDirect3DTexture8Impl_SetPriority(IDirect3DTexture8 *iface, DWORD PriorityNew)
{
IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface);
DWORD ret;
TRACE("iface %p, priority %u.\n", iface, PriorityNew);
wined3d_mutex_lock();
ret = IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew);
ret = wined3d_texture_set_priority(This->wined3d_texture, PriorityNew);
wined3d_mutex_unlock();
return ret;
}
static DWORD WINAPI IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
static DWORD WINAPI IDirect3DTexture8Impl_GetPriority(IDirect3DTexture8 *iface)
{
IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface);
DWORD ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetPriority(This->wineD3DTexture);
ret = wined3d_texture_get_priority(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
static void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
static void WINAPI IDirect3DTexture8Impl_PreLoad(IDirect3DTexture8 *iface)
{
IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface);
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
IWineD3DTexture_PreLoad(This->wineD3DTexture);
wined3d_texture_preload(This->wined3d_texture);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
static D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(IDirect3DTexture8 *iface)
{
IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface);
D3DRESOURCETYPE type;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
type = IWineD3DTexture_GetType(This->wineD3DTexture);
type = wined3d_texture_get_type(This->wined3d_texture);
wined3d_mutex_unlock();
return type;
}
/* IDirect3DTexture8 IDirect3DBaseTexture8 Interface follow: */
static DWORD WINAPI IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface, DWORD LODNew) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
static DWORD WINAPI IDirect3DTexture8Impl_SetLOD(IDirect3DTexture8 *iface, DWORD LODNew)
{
IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface);
DWORD ret;
TRACE("iface %p, lod %u.\n", iface, LODNew);
wined3d_mutex_lock();
ret = IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew);
ret = wined3d_texture_set_lod(This->wined3d_texture, LODNew);
wined3d_mutex_unlock();
return ret;
}
static DWORD WINAPI IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
static DWORD WINAPI IDirect3DTexture8Impl_GetLOD(IDirect3DTexture8 *iface)
{
IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface);
DWORD ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetLOD(This->wineD3DTexture);
ret = wined3d_texture_get_lod(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
static DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
static DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(IDirect3DTexture8 *iface)
{
IDirect3DTexture8Impl *This = impl_from_IDirect3DTexture8(iface);
DWORD ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetLevelCount(This->wineD3DTexture);
ret = wined3d_texture_get_level_count(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
/* IDirect3DTexture8 Interface follow: */
static HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DSURFACE_DESC *pDesc) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
HRESULT hr;
static HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(IDirect3DTexture8 *iface,
UINT level, D3DSURFACE_DESC *desc)
{
IDirect3DTexture8Impl *texture = impl_from_IDirect3DTexture8(iface);
struct wined3d_resource *sub_resource;
HRESULT hr = D3D_OK;
TRACE("iface %p, level %u, desc %p.\n", iface, Level, pDesc);
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetLevelDesc(This->wineD3DTexture, Level, &wined3ddesc);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
hr = D3DERR_INVALIDCALL;
else
{
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
pDesc->Type = wined3ddesc.resource_type;
pDesc->Usage = wined3ddesc.usage;
pDesc->Pool = wined3ddesc.pool;
pDesc->Size = wined3ddesc.size;
pDesc->MultiSampleType = wined3ddesc.multisample_type;
pDesc->Width = wined3ddesc.width;
pDesc->Height = wined3ddesc.height;
struct wined3d_resource_desc wined3d_desc;
wined3d_resource_get_desc(sub_resource, &wined3d_desc);
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = wined3d_desc.resource_type;
desc->Usage = wined3d_desc.usage;
desc->Pool = wined3d_desc.pool;
desc->Size = wined3d_desc.size;
desc->MultiSampleType = wined3d_desc.multisample_type;
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
}
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(IDirect3DTexture8 *iface,
UINT Level, IDirect3DSurface8 **ppSurfaceLevel)
UINT level, IDirect3DSurface8 **surface)
{
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
IWineD3DSurface *mySurface = NULL;
HRESULT hr;
IDirect3DTexture8Impl *texture = impl_from_IDirect3DTexture8(iface);
struct wined3d_resource *sub_resource;
TRACE("iface %p, level %u, surface %p.\n", iface, Level, ppSurfaceLevel);
TRACE("iface %p, level %u, surface %p.\n", iface, level, surface);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
if (SUCCEEDED(hr) && ppSurfaceLevel)
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
{
*ppSurfaceLevel = IWineD3DSurface_GetParent(mySurface);
IDirect3DSurface8_AddRef(*ppSurfaceLevel);
IWineD3DSurface_Release(mySurface);
wined3d_mutex_unlock();
return D3DERR_INVALIDCALL;
}
*surface = wined3d_resource_get_parent(sub_resource);
IDirect3DSurface8_AddRef(*surface);
wined3d_mutex_unlock();
return hr;
return D3D_OK;
}
static HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DLOCKED_RECT *pLockedRect, CONST RECT *pRect, DWORD Flags) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DTexture8Impl_LockRect(IDirect3DTexture8 *iface, UINT level,
D3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags)
{
IDirect3DTexture8Impl *texture = impl_from_IDirect3DTexture8(iface);
struct wined3d_resource *sub_resource;
HRESULT hr;
TRACE("iface %p, level %u, locked_rect %p, rect %p, flags %#x.\n",
iface, Level, pLockedRect, pRect, Flags);
iface, level, locked_rect, rect, flags);
wined3d_mutex_lock();
hr = IWineD3DTexture_LockRect(This->wineD3DTexture, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
hr = D3DERR_INVALIDCALL;
else
hr = IDirect3DSurface8_LockRect((IDirect3DSurface8 *)wined3d_resource_get_parent(sub_resource),
locked_rect, rect, flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface, UINT Level) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(IDirect3DTexture8 *iface, UINT level)
{
IDirect3DTexture8Impl *texture = impl_from_IDirect3DTexture8(iface);
struct wined3d_resource *sub_resource;
HRESULT hr;
TRACE("iface %p, level %u.\n", iface, Level);
TRACE("iface %p, level %u.\n", iface, level);
wined3d_mutex_lock();
hr = IWineD3DTexture_UnlockRect(This->wineD3DTexture, Level);
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
hr = D3DERR_INVALIDCALL;
else
hr = IDirect3DSurface8_UnlockRect((IDirect3DSurface8 *)wined3d_resource_get_parent(sub_resource));
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT *pDirtyRect) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(IDirect3DTexture8 *iface, const RECT *dirty_rect)
{
IDirect3DTexture8Impl *texture = impl_from_IDirect3DTexture8(iface);
HRESULT hr;
TRACE("iface %p, dirty_rect %p.\n", iface, pDirtyRect);
TRACE("iface %p, dirty_rect %s.\n",
iface, wine_dbgstr_rect(dirty_rect));
wined3d_mutex_lock();
hr = IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect);
if (!dirty_rect)
hr = wined3d_texture_add_dirty_region(texture->wined3d_texture, 0, NULL);
else
{
WINED3DBOX dirty_region;
dirty_region.Left = dirty_rect->left;
dirty_region.Top = dirty_rect->top;
dirty_region.Right = dirty_rect->right;
dirty_region.Bottom = dirty_rect->bottom;
dirty_region.Front = 0;
dirty_region.Back = 1;
hr = wined3d_texture_add_dirty_region(texture->wined3d_texture, 0, &dirty_region);
}
wined3d_mutex_unlock();
return hr;
@ -355,13 +409,13 @@ HRESULT texture_init(IDirect3DTexture8Impl *texture, IDirect3DDevice8Impl *devic
{
HRESULT hr;
texture->lpVtbl = &Direct3DTexture8_Vtbl;
texture->IDirect3DTexture8_iface.lpVtbl = &Direct3DTexture8_Vtbl;
texture->ref = 1;
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateTexture(device->WineD3DDevice, width, height, levels,
hr = wined3d_texture_create_2d(device->wined3d_device, width, height, levels,
usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool,
texture, &d3d8_texture_wined3d_parent_ops, &texture->wineD3DTexture);
texture, &d3d8_texture_wined3d_parent_ops, &texture->wined3d_texture);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@ -369,7 +423,7 @@ HRESULT texture_init(IDirect3DTexture8Impl *texture, IDirect3DDevice8Impl *devic
return hr;
}
texture->parentDevice = (IDirect3DDevice8 *)device;
texture->parentDevice = &device->IDirect3DDevice8_iface;
IDirect3DDevice8_AddRef(texture->parentDevice);
return D3D_OK;

View file

@ -53,7 +53,7 @@ static ULONG WINAPI IDirect3DVertexDeclaration8Impl_AddRef(IDirect3DVertexDeclar
if (ref_count == 1)
{
wined3d_mutex_lock();
IWineD3DVertexDeclaration_AddRef(This->wined3d_vertex_declaration);
wined3d_vertex_declaration_incref(This->wined3d_vertex_declaration);
wined3d_mutex_unlock();
}
@ -69,7 +69,7 @@ static ULONG WINAPI IDirect3DVertexDeclaration8Impl_Release(IDirect3DVertexDecla
if (!ref_count) {
wined3d_mutex_lock();
IWineD3DVertexDeclaration_Release(This->wined3d_vertex_declaration);
wined3d_vertex_declaration_decref(This->wined3d_vertex_declaration);
wined3d_mutex_unlock();
}
@ -199,7 +199,7 @@ size_t parse_token(const DWORD* pToken)
return tokenlen;
}
void load_local_constants(const DWORD *d3d8_elements, IWineD3DVertexShader *wined3d_vertex_shader)
void load_local_constants(const DWORD *d3d8_elements, struct wined3d_shader *wined3d_vertex_shader)
{
const DWORD *token = d3d8_elements;
@ -224,7 +224,8 @@ void load_local_constants(const DWORD *d3d8_elements, IWineD3DVertexShader *wine
*(const float *)(token + i * 4 + 4));
}
}
hr = IWineD3DVertexShader_SetLocalConstantsF(wined3d_vertex_shader, constant_idx, (const float *)token+1, count);
hr = wined3d_shader_set_local_constants_float(wined3d_vertex_shader,
constant_idx, (const float *)token + 1, count);
if (FAILED(hr)) ERR("Failed setting shader constants\n");
}
@ -308,7 +309,7 @@ static UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3
WINED3DVERTEXELEMENT *element;
D3DVSD_TOKENTYPE token_type;
unsigned int element_count = 0;
DWORD stream = 0;
WORD stream = 0;
int offset = 0;
TRACE("d3d8_elements %p, wined3d_elements %p\n", d3d8_elements, wined3d_elements);
@ -399,7 +400,7 @@ HRESULT vertexdeclaration_init(IDirect3DVertexDeclaration8Impl *declaration,
memcpy(declaration->elements, elements, declaration->elements_size);
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateVertexDeclaration(device->WineD3DDevice, wined3d_elements, wined3d_element_count,
hr = wined3d_vertex_declaration_create(device->wined3d_device, wined3d_elements, wined3d_element_count,
declaration, &d3d8_vertexdeclaration_wined3d_parent_ops, &declaration->wined3d_vertex_declaration);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, wined3d_elements);
@ -424,7 +425,7 @@ HRESULT vertexdeclaration_init_fvf(IDirect3DVertexDeclaration8Impl *declaration,
declaration->elements_size = 0;
declaration->shader_handle = fvf;
hr = IWineD3DDevice_CreateVertexDeclarationFromFVF(device->WineD3DDevice, fvf, declaration,
hr = wined3d_vertex_declaration_create_from_fvf(device->wined3d_device, fvf, declaration,
&d3d8_vertexdeclaration_wined3d_parent_ops, &declaration->wined3d_vertex_declaration);
if (FAILED(hr))
{

View file

@ -23,9 +23,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DVolume8 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(LPDIRECT3DVOLUME8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
static inline IDirect3DVolume8Impl *impl_from_IDirect3DVolume8(IDirect3DVolume8 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DVolume8Impl, IDirect3DVolume8_iface);
}
static HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(IDirect3DVolume8 *iface, REFIID riid,
void **ppobj)
{
IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
@ -41,8 +47,9 @@ static HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(LPDIRECT3DVOLUME8 ifac
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DVolume8Impl_AddRef(LPDIRECT3DVOLUME8 iface) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
static ULONG WINAPI IDirect3DVolume8Impl_AddRef(IDirect3DVolume8 *iface)
{
IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
TRACE("iface %p.\n", iface);
@ -59,7 +66,7 @@ static ULONG WINAPI IDirect3DVolume8Impl_AddRef(LPDIRECT3DVOLUME8 iface) {
if (ref == 1)
{
wined3d_mutex_lock();
IWineD3DVolume_AddRef(This->wineD3DVolume);
wined3d_volume_incref(This->wined3d_volume);
wined3d_mutex_unlock();
}
@ -67,8 +74,9 @@ static ULONG WINAPI IDirect3DVolume8Impl_AddRef(LPDIRECT3DVOLUME8 iface) {
}
}
static ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
static ULONG WINAPI IDirect3DVolume8Impl_Release(IDirect3DVolume8 *iface)
{
IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
TRACE("iface %p.\n", iface);
@ -85,7 +93,7 @@ static ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
if (ref == 0) {
wined3d_mutex_lock();
IWineD3DVolume_Release(This->wineD3DVolume);
wined3d_volume_decref(This->wined3d_volume);
wined3d_mutex_unlock();
}
@ -93,10 +101,10 @@ static ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
}
}
/* IDirect3DVolume8 Interface follow: */
static HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(IDirect3DVolume8 *iface, IDirect3DDevice8 **device)
static HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(IDirect3DVolume8 *iface,
IDirect3DDevice8 **device)
{
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
IDirect3DResource8 *resource;
HRESULT hr;
@ -114,49 +122,56 @@ static HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(IDirect3DVolume8 *iface, ID
return hr;
}
static HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
static HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(IDirect3DVolume8 *iface, REFGUID refguid,
const void *pData, DWORD SizeOfData, DWORD Flags)
{
IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
wined3d_mutex_lock();
hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
hr = wined3d_volume_set_private_data(This->wined3d_volume, refguid, pData, SizeOfData, Flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, void *pData, DWORD* pSizeOfData) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
static HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(IDirect3DVolume8 *iface, REFGUID refguid,
void *pData, DWORD *pSizeOfData)
{
IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %p.\n",
iface, debugstr_guid(refguid), pData, pSizeOfData);
wined3d_mutex_lock();
hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
hr = wined3d_volume_get_private_data(This->wined3d_volume, refguid, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
static HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(IDirect3DVolume8 *iface, REFGUID refguid)
{
IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
HRESULT hr;
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
wined3d_mutex_lock();
hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
hr = wined3d_volume_free_private_data(This->wined3d_volume, refguid);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void **ppContainer) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
static HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(IDirect3DVolume8 *iface, REFIID riid,
void **ppContainer)
{
IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
HRESULT res;
TRACE("iface %p, riid %s, container %p.\n",
@ -164,10 +179,6 @@ static HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface,
if (!This->container) return E_NOINTERFACE;
if (!ppContainer) {
ERR("Called without a valid ppContainer.\n");
}
res = IUnknown_QueryInterface(This->container, riid, ppContainer);
TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
@ -175,50 +186,57 @@ static HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface,
return res;
}
static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC *pDesc) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
WINED3DVOLUME_DESC wined3ddesc;
static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(IDirect3DVolume8 *iface, D3DVOLUME_DESC *desc)
{
IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
struct wined3d_resource_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
TRACE("iface %p, desc %p.\n", iface, pDesc);
TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock();
IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
wined3d_resource = wined3d_volume_get_resource(This->wined3d_volume);
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
wined3d_mutex_unlock();
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
pDesc->Type = wined3ddesc.Type;
pDesc->Usage = wined3ddesc.Usage;
pDesc->Pool = wined3ddesc.Pool;
pDesc->Size = wined3ddesc.Size;
pDesc->Width = wined3ddesc.Width;
pDesc->Height = wined3ddesc.Height;
pDesc->Depth = wined3ddesc.Depth;
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = wined3d_desc.resource_type;
desc->Usage = wined3d_desc.usage;
desc->Pool = wined3d_desc.pool;
desc->Size = wined3d_desc.size;
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
desc->Depth = wined3d_desc.depth;
return D3D_OK;
}
static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(IDirect3DVolume8 *iface,
D3DLOCKED_BOX *pLockedVolume, const D3DBOX *pBox, DWORD Flags)
{
IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
HRESULT hr;
TRACE("iface %p, locked_box %p, box %p, flags %#x.\n",
iface, pLockedVolume, pBox, Flags);
wined3d_mutex_lock();
hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
hr = wined3d_volume_map(This->wined3d_volume, (WINED3DLOCKED_BOX *)pLockedVolume,
(const WINED3DBOX *)pBox, Flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(IDirect3DVolume8 *iface)
{
IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface);
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume);
hr = wined3d_volume_unmap(This->wined3d_volume);
wined3d_mutex_unlock();
return hr;
@ -256,11 +274,11 @@ HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device,
{
HRESULT hr;
volume->lpVtbl = &Direct3DVolume8_Vtbl;
volume->IDirect3DVolume8_iface.lpVtbl = &Direct3DVolume8_Vtbl;
volume->ref = 1;
hr = IWineD3DDevice_CreateVolume(device->WineD3DDevice, width, height, depth, usage,
format, pool, volume, &d3d8_volume_wined3d_parent_ops, &volume->wineD3DVolume);
hr = wined3d_volume_create(device->wined3d_device, width, height, depth, usage,
format, pool, volume, &d3d8_volume_wined3d_parent_ops, &volume->wined3d_volume);
if (FAILED(hr))
{
WARN("Failed to create wined3d volume, hr %#x.\n", hr);

View file

@ -23,9 +23,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DVolumeTexture8 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
static inline IDirect3DVolumeTexture8Impl *impl_from_IDirect3DVolumeTexture8(IDirect3DVolumeTexture8 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DVolumeTexture8Impl, IDirect3DVolumeTexture8_iface);
}
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_QueryInterface(IDirect3DVolumeTexture8 *iface,
REFIID riid, void **ppobj)
{
IDirect3DVolumeTexture8Impl *This = impl_from_IDirect3DVolumeTexture8(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
@ -43,8 +49,9 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_QueryInterface(LPDIRECT3DVOLUM
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
static ULONG WINAPI IDirect3DVolumeTexture8Impl_AddRef(IDirect3DVolumeTexture8 *iface)
{
IDirect3DVolumeTexture8Impl *This = impl_from_IDirect3DVolumeTexture8(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", iface, ref);
@ -53,15 +60,16 @@ static ULONG WINAPI IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8
{
IDirect3DDevice8_AddRef(This->parentDevice);
wined3d_mutex_lock();
IWineD3DVolumeTexture_AddRef(This->wineD3DVolumeTexture);
wined3d_texture_incref(This->wined3d_texture);
wined3d_mutex_unlock();
}
return ref;
}
static ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
static ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(IDirect3DVolumeTexture8 *iface)
{
IDirect3DVolumeTexture8Impl *This = impl_from_IDirect3DVolumeTexture8(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", iface, ref);
@ -70,7 +78,7 @@ static ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8
IDirect3DDevice8 *parentDevice = This->parentDevice;
wined3d_mutex_lock();
IWineD3DVolumeTexture_Release(This->wineD3DVolumeTexture);
wined3d_texture_decref(This->wined3d_texture);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
@ -80,9 +88,10 @@ static ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8
}
/* IDirect3DVolumeTexture8 IDirect3DResource8 Interface follow: */
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetDevice(IDirect3DVolumeTexture8 *iface, IDirect3DDevice8 **device)
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetDevice(IDirect3DVolumeTexture8 *iface,
IDirect3DDevice8 **device)
{
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
IDirect3DVolumeTexture8Impl *This = impl_from_IDirect3DVolumeTexture8(iface);
TRACE("iface %p, device %p.\n", iface, device);
@ -94,220 +103,253 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetDevice(IDirect3DVolumeTextu
return D3D_OK;
}
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(IDirect3DVolumeTexture8 *iface,
REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags)
{
IDirect3DVolumeTexture8Impl *This = impl_from_IDirect3DVolumeTexture8(iface);
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
hr = wined3d_texture_set_private_data(This->wined3d_texture, refguid, pData, SizeOfData, Flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetPrivateData(IDirect3DVolumeTexture8 *iface,
REFGUID refguid, void *pData, DWORD *pSizeOfData)
{
IDirect3DVolumeTexture8Impl *This = impl_from_IDirect3DVolumeTexture8(iface);
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %p.\n",
iface, debugstr_guid(refguid), pData, pSizeOfData);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
hr = wined3d_texture_get_private_data(This->wined3d_texture, refguid, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_FreePrivateData(IDirect3DVolumeTexture8 *iface,
REFGUID refguid)
{
IDirect3DVolumeTexture8Impl *This = impl_from_IDirect3DVolumeTexture8(iface);
HRESULT hr;
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
hr = wined3d_texture_free_private_data(This->wined3d_texture, refguid);
wined3d_mutex_unlock();
return hr;
}
static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD PriorityNew) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetPriority(IDirect3DVolumeTexture8 *iface,
DWORD PriorityNew)
{
IDirect3DVolumeTexture8Impl *This = impl_from_IDirect3DVolumeTexture8(iface);
DWORD ret;
TRACE("iface %p, priority %u.\n", iface, PriorityNew);
wined3d_mutex_lock();
ret = IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
ret = wined3d_texture_set_priority(This->wined3d_texture, PriorityNew);
wined3d_mutex_unlock();
return ret;
}
static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetPriority(IDirect3DVolumeTexture8 *iface)
{
IDirect3DVolumeTexture8Impl *This = impl_from_IDirect3DVolumeTexture8(iface);
DWORD ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
ret = wined3d_texture_get_priority(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
static void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
static void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(IDirect3DVolumeTexture8 *iface)
{
IDirect3DVolumeTexture8Impl *This = impl_from_IDirect3DVolumeTexture8(iface);
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
wined3d_texture_preload(This->wined3d_texture);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(IDirect3DVolumeTexture8 *iface)
{
IDirect3DVolumeTexture8Impl *This = impl_from_IDirect3DVolumeTexture8(iface);
D3DRESOURCETYPE type;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
type = IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
type = wined3d_texture_get_type(This->wined3d_texture);
wined3d_mutex_unlock();
return type;
}
/* IDirect3DVolumeTexture8 IDirect3DBaseTexture8 Interface follow: */
static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD LODNew) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetLOD(IDirect3DVolumeTexture8 *iface, DWORD LODNew)
{
IDirect3DVolumeTexture8Impl *This = impl_from_IDirect3DVolumeTexture8(iface);
DWORD ret;
TRACE("iface %p, lod %u.\n", iface, LODNew);
wined3d_mutex_lock();
ret = IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
ret = wined3d_texture_set_lod(This->wined3d_texture, LODNew);
wined3d_mutex_unlock();
return ret;
}
static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLOD(IDirect3DVolumeTexture8 *iface)
{
IDirect3DVolumeTexture8Impl *This = impl_from_IDirect3DVolumeTexture8(iface);
DWORD ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
ret = wined3d_texture_get_lod(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE8 iface) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(IDirect3DVolumeTexture8 *iface)
{
IDirect3DVolumeTexture8Impl *This = impl_from_IDirect3DVolumeTexture8(iface);
DWORD ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
ret = wined3d_texture_get_level_count(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
/* IDirect3DVolumeTexture8 Interface follow: */
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
WINED3DVOLUME_DESC wined3ddesc;
HRESULT hr;
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(IDirect3DVolumeTexture8 *iface,
UINT level, D3DVOLUME_DESC *desc)
{
IDirect3DVolumeTexture8Impl *texture = impl_from_IDirect3DVolumeTexture8(iface);
struct wined3d_resource *sub_resource;
HRESULT hr = D3D_OK;
TRACE("iface %p, level %u, desc %p.\n", iface, Level, pDesc);
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
hr = D3DERR_INVALIDCALL;
else
{
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
pDesc->Type = wined3ddesc.Type;
pDesc->Usage = wined3ddesc.Usage;
pDesc->Pool = wined3ddesc.Pool;
pDesc->Size = wined3ddesc.Size;
pDesc->Width = wined3ddesc.Width;
pDesc->Height = wined3ddesc.Height;
pDesc->Depth = wined3ddesc.Depth;
struct wined3d_resource_desc wined3d_desc;
wined3d_resource_get_desc(sub_resource, &wined3d_desc);
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = wined3d_desc.resource_type;
desc->Usage = wined3d_desc.usage;
desc->Pool = wined3d_desc.pool;
desc->Size = wined3d_desc.size;
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
desc->Depth = wined3d_desc.depth;
}
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(IDirect3DVolumeTexture8 *iface,
UINT Level, IDirect3DVolume8 **ppVolumeLevel)
UINT level, IDirect3DVolume8 **volume)
{
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
IWineD3DVolume *myVolume = NULL;
HRESULT hr;
IDirect3DVolumeTexture8Impl *texture = impl_from_IDirect3DVolumeTexture8(iface);
struct wined3d_resource *sub_resource;
TRACE("iface %p, level %u, volume %p.\n", iface, Level, ppVolumeLevel);
TRACE("iface %p, level %u, volume %p.\n", iface, level, volume);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
if (SUCCEEDED(hr) && ppVolumeLevel)
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
{
*ppVolumeLevel = IWineD3DVolumeTexture_GetParent(myVolume);
IDirect3DVolume8_AddRef(*ppVolumeLevel);
IWineD3DVolumeTexture_Release(myVolume);
wined3d_mutex_unlock();
return D3DERR_INVALIDCALL;
}
*volume = wined3d_resource_get_parent(sub_resource);
IDirect3DVolume8_AddRef(*volume);
wined3d_mutex_unlock();
return hr;
return D3D_OK;
}
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(IDirect3DVolumeTexture8 *iface,
UINT level, D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags)
{
IDirect3DVolumeTexture8Impl *texture = impl_from_IDirect3DVolumeTexture8(iface);
struct wined3d_resource *sub_resource;
HRESULT hr;
TRACE("iface %p, level %u, locked_box %p, box %p, flags %#x.\n",
iface, Level, pLockedVolume, pBox, Flags);
iface, level, locked_box, box, flags);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
hr = D3DERR_INVALIDCALL;
else
hr = IDirect3DVolume8_LockBox((IDirect3DVolume8 *)wined3d_resource_get_parent(sub_resource),
locked_box, box, flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(IDirect3DVolumeTexture8 *iface,
UINT level)
{
IDirect3DVolumeTexture8Impl *texture = impl_from_IDirect3DVolumeTexture8(iface);
struct wined3d_resource *sub_resource;
HRESULT hr;
TRACE("iface %p, level %u.\n", iface, Level);
TRACE("iface %p, level %u.\n", iface, level);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
hr = D3DERR_INVALIDCALL;
else
hr = IDirect3DVolume8_UnlockBox((IDirect3DVolume8 *)wined3d_resource_get_parent(sub_resource));
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX *pDirtyBox) {
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(IDirect3DVolumeTexture8 *iface,
const D3DBOX *dirty_box)
{
IDirect3DVolumeTexture8Impl *texture = impl_from_IDirect3DVolumeTexture8(iface);
HRESULT hr;
TRACE("iface %p, dirty_box %p.\n", iface, pDirtyBox);
TRACE("iface %p, dirty_box %p.\n", iface, dirty_box);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *) pDirtyBox);
hr = wined3d_texture_add_dirty_region(texture->wined3d_texture, 0, (const WINED3DBOX *)dirty_box);
wined3d_mutex_unlock();
return hr;
@ -355,13 +397,13 @@ HRESULT volumetexture_init(IDirect3DVolumeTexture8Impl *texture, IDirect3DDevice
{
HRESULT hr;
texture->lpVtbl = &Direct3DVolumeTexture8_Vtbl;
texture->IDirect3DVolumeTexture8_iface.lpVtbl = &Direct3DVolumeTexture8_Vtbl;
texture->ref = 1;
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateVolumeTexture(device->WineD3DDevice, width, height, depth, levels,
hr = wined3d_texture_create_3d(device->wined3d_device, width, height, depth, levels,
usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool, texture,
&d3d8_volumetexture_wined3d_parent_ops, &texture->wineD3DVolumeTexture);
&d3d8_volumetexture_wined3d_parent_ops, &texture->wined3d_texture);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@ -369,7 +411,7 @@ HRESULT volumetexture_init(IDirect3DVolumeTexture8Impl *texture, IDirect3DDevice
return hr;
}
texture->parentDevice = (IDirect3DDevice8 *)device;
texture->parentDevice = &device->IDirect3DDevice8_iface;
IDirect3DDevice8_AddRef(texture->parentDevice);
return D3D_OK;

View file

@ -53,7 +53,7 @@ static ULONG WINAPI d3d9_vertexbuffer_AddRef(IDirect3DVertexBuffer9 *iface)
{
IDirect3DDevice9Ex_AddRef(buffer->parentDevice);
wined3d_mutex_lock();
IWineD3DBuffer_AddRef(buffer->wineD3DVertexBuffer);
wined3d_buffer_incref(buffer->wineD3DVertexBuffer);
wined3d_mutex_unlock();
}
@ -72,7 +72,7 @@ static ULONG WINAPI d3d9_vertexbuffer_Release(IDirect3DVertexBuffer9 *iface)
IDirect3DDevice9Ex *device = buffer->parentDevice;
wined3d_mutex_lock();
IWineD3DBuffer_Release(buffer->wineD3DVertexBuffer);
wined3d_buffer_decref(buffer->wineD3DVertexBuffer);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
@ -103,7 +103,7 @@ static HRESULT WINAPI d3d9_vertexbuffer_SetPrivateData(IDirect3DVertexBuffer9 *i
iface, debugstr_guid(guid), data, data_size, flags);
wined3d_mutex_lock();
hr = IWineD3DBuffer_SetPrivateData(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer,
hr = wined3d_buffer_set_private_data(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer,
guid, data, data_size, flags);
wined3d_mutex_unlock();
@ -119,7 +119,7 @@ static HRESULT WINAPI d3d9_vertexbuffer_GetPrivateData(IDirect3DVertexBuffer9 *i
iface, debugstr_guid(guid), data, data_size);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetPrivateData(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer,
hr = wined3d_buffer_get_private_data(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer,
guid, data, data_size);
wined3d_mutex_unlock();
@ -133,7 +133,7 @@ static HRESULT WINAPI d3d9_vertexbuffer_FreePrivateData(IDirect3DVertexBuffer9 *
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
wined3d_mutex_lock();
hr = IWineD3DBuffer_FreePrivateData(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer, guid);
hr = wined3d_buffer_free_private_data(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer, guid);
wined3d_mutex_unlock();
return hr;
@ -146,7 +146,7 @@ static DWORD WINAPI d3d9_vertexbuffer_SetPriority(IDirect3DVertexBuffer9 *iface,
TRACE("iface %p, priority %u.\n", iface, priority);
wined3d_mutex_lock();
previous = IWineD3DBuffer_SetPriority(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer, priority);
previous = wined3d_buffer_set_priority(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer, priority);
wined3d_mutex_unlock();
return previous;
@ -159,7 +159,7 @@ static DWORD WINAPI d3d9_vertexbuffer_GetPriority(IDirect3DVertexBuffer9 *iface)
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
priority = IWineD3DBuffer_GetPriority(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer);
priority = wined3d_buffer_get_priority(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer);
wined3d_mutex_unlock();
return priority;
@ -170,7 +170,7 @@ static void WINAPI d3d9_vertexbuffer_PreLoad(IDirect3DVertexBuffer9 *iface)
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
IWineD3DBuffer_PreLoad(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer);
wined3d_buffer_preload(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer);
wined3d_mutex_unlock();
}
@ -190,7 +190,7 @@ static HRESULT WINAPI d3d9_vertexbuffer_Lock(IDirect3DVertexBuffer9 *iface,
iface, offset, size, data, flags);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Map(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer,
hr = wined3d_buffer_map(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer,
offset, size, (BYTE **)data, flags);
wined3d_mutex_unlock();
@ -199,32 +199,32 @@ static HRESULT WINAPI d3d9_vertexbuffer_Lock(IDirect3DVertexBuffer9 *iface,
static HRESULT WINAPI d3d9_vertexbuffer_Unlock(IDirect3DVertexBuffer9 *iface)
{
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Unmap(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer);
wined3d_buffer_unmap(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer);
wined3d_mutex_unlock();
return hr;
return D3D_OK;
}
static HRESULT WINAPI d3d9_vertexbuffer_GetDesc(IDirect3DVertexBuffer9 *iface, D3DVERTEXBUFFER_DESC *desc)
{
IDirect3DVertexBuffer9Impl *buffer = (IDirect3DVertexBuffer9Impl *)iface;
WINED3DBUFFER_DESC wined3d_desc;
struct wined3d_resource_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock();
IWineD3DBuffer_GetDesc(buffer->wineD3DVertexBuffer, &wined3d_desc);
wined3d_resource = wined3d_buffer_get_resource(buffer->wineD3DVertexBuffer);
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
wined3d_mutex_unlock();
desc->Format = D3DFMT_VERTEXDATA;
desc->Usage = wined3d_desc.Usage;
desc->Pool = wined3d_desc.Pool;
desc->Size = wined3d_desc.Size;
desc->Usage = wined3d_desc.usage;
desc->Pool = wined3d_desc.pool;
desc->Size = wined3d_desc.size;
desc->Type = D3DRTYPE_VERTEXBUFFER;
desc->FVF = buffer->fvf;
@ -272,7 +272,7 @@ HRESULT vertexbuffer_init(IDirect3DVertexBuffer9Impl *buffer, IDirect3DDevice9Im
buffer->fvf = fvf;
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateVertexBuffer(device->WineD3DDevice, size, usage & WINED3DUSAGE_MASK,
hr = wined3d_buffer_create_vb(device->wined3d_device, size, usage & WINED3DUSAGE_MASK,
(WINED3DPOOL)pool, buffer, &d3d9_vertexbuffer_wined3d_parent_ops, &buffer->wineD3DVertexBuffer);
wined3d_mutex_unlock();
if (FAILED(hr))
@ -281,7 +281,7 @@ HRESULT vertexbuffer_init(IDirect3DVertexBuffer9Impl *buffer, IDirect3DDevice9Im
return hr;
}
buffer->parentDevice = (IDirect3DDevice9Ex *)device;
buffer->parentDevice = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(buffer->parentDevice);
return D3D_OK;
@ -317,7 +317,7 @@ static ULONG WINAPI d3d9_indexbuffer_AddRef(IDirect3DIndexBuffer9 *iface)
{
IDirect3DDevice9Ex_AddRef(buffer->parentDevice);
wined3d_mutex_lock();
IWineD3DBuffer_AddRef(buffer->wineD3DIndexBuffer);
wined3d_buffer_incref(buffer->wineD3DIndexBuffer);
wined3d_mutex_unlock();
}
@ -336,7 +336,7 @@ static ULONG WINAPI d3d9_indexbuffer_Release(IDirect3DIndexBuffer9 *iface)
IDirect3DDevice9Ex *device = buffer->parentDevice;
wined3d_mutex_lock();
IWineD3DBuffer_Release(buffer->wineD3DIndexBuffer);
wined3d_buffer_decref(buffer->wineD3DIndexBuffer);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
@ -367,7 +367,7 @@ static HRESULT WINAPI d3d9_indexbuffer_SetPrivateData(IDirect3DIndexBuffer9 *ifa
iface, debugstr_guid(guid), data, data_size, flags);
wined3d_mutex_lock();
hr = IWineD3DBuffer_SetPrivateData(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer,
hr = wined3d_buffer_set_private_data(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer,
guid, data, data_size, flags);
wined3d_mutex_unlock();
@ -383,7 +383,7 @@ static HRESULT WINAPI d3d9_indexbuffer_GetPrivateData(IDirect3DIndexBuffer9 *ifa
iface, debugstr_guid(guid), data, data_size);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetPrivateData(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer,
hr = wined3d_buffer_get_private_data(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer,
guid, data, data_size);
wined3d_mutex_unlock();
@ -397,7 +397,7 @@ static HRESULT WINAPI d3d9_indexbuffer_FreePrivateData(IDirect3DIndexBuffer9 *if
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
wined3d_mutex_lock();
hr = IWineD3DBuffer_FreePrivateData(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer, guid);
hr = wined3d_buffer_free_private_data(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer, guid);
wined3d_mutex_unlock();
return hr;
@ -410,7 +410,7 @@ static DWORD WINAPI d3d9_indexbuffer_SetPriority(IDirect3DIndexBuffer9 *iface, D
TRACE("iface %p, priority %u.\n", iface, priority);
wined3d_mutex_lock();
previous = IWineD3DBuffer_SetPriority(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer, priority);
previous = wined3d_buffer_set_priority(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer, priority);
wined3d_mutex_unlock();
return previous;
@ -423,7 +423,7 @@ static DWORD WINAPI d3d9_indexbuffer_GetPriority(IDirect3DIndexBuffer9 *iface)
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
priority = IWineD3DBuffer_GetPriority(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer);
priority = wined3d_buffer_get_priority(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer);
wined3d_mutex_unlock();
return priority;
@ -434,7 +434,7 @@ static void WINAPI d3d9_indexbuffer_PreLoad(IDirect3DIndexBuffer9 *iface)
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
IWineD3DBuffer_PreLoad(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer);
wined3d_buffer_preload(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer);
wined3d_mutex_unlock();
}
@ -454,7 +454,7 @@ static HRESULT WINAPI d3d9_indexbuffer_Lock(IDirect3DIndexBuffer9 *iface,
iface, offset, size, data, flags);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Map(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer,
hr = wined3d_buffer_map(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer,
offset, size, (BYTE **)data, flags);
wined3d_mutex_unlock();
@ -463,32 +463,32 @@ static HRESULT WINAPI d3d9_indexbuffer_Lock(IDirect3DIndexBuffer9 *iface,
static HRESULT WINAPI d3d9_indexbuffer_Unlock(IDirect3DIndexBuffer9 *iface)
{
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Unmap(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer);
wined3d_buffer_unmap(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer);
wined3d_mutex_unlock();
return hr;
return D3D_OK;
}
static HRESULT WINAPI d3d9_indexbuffer_GetDesc(IDirect3DIndexBuffer9 *iface, D3DINDEXBUFFER_DESC *desc)
{
IDirect3DIndexBuffer9Impl *buffer = (IDirect3DIndexBuffer9Impl *)iface;
WINED3DBUFFER_DESC wined3d_desc;
struct wined3d_resource_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock();
IWineD3DBuffer_GetDesc(buffer->wineD3DIndexBuffer, &wined3d_desc);
wined3d_resource = wined3d_buffer_get_resource(buffer->wineD3DIndexBuffer);
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
wined3d_mutex_unlock();
desc->Format = d3dformat_from_wined3dformat(buffer->format);
desc->Usage = wined3d_desc.Usage;
desc->Pool = wined3d_desc.Pool;
desc->Size = wined3d_desc.Size;
desc->Usage = wined3d_desc.usage;
desc->Pool = wined3d_desc.pool;
desc->Size = wined3d_desc.size;
desc->Type = D3DRTYPE_INDEXBUFFER;
return D3D_OK;
@ -535,7 +535,7 @@ HRESULT indexbuffer_init(IDirect3DIndexBuffer9Impl *buffer, IDirect3DDevice9Impl
buffer->format = wined3dformat_from_d3dformat(format);
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateIndexBuffer(device->WineD3DDevice, size, usage & WINED3DUSAGE_MASK,
hr = wined3d_buffer_create_ib(device->wined3d_device, size, usage & WINED3DUSAGE_MASK,
(WINED3DPOOL)pool, buffer, &d3d9_indexbuffer_wined3d_parent_ops, &buffer->wineD3DIndexBuffer);
wined3d_mutex_unlock();
if (FAILED(hr))
@ -544,7 +544,7 @@ HRESULT indexbuffer_init(IDirect3DIndexBuffer9Impl *buffer, IDirect3DDevice9Impl
return hr;
}
buffer->parentDevice = (IDirect3DDevice9Ex *)device;
buffer->parentDevice = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(buffer->parentDevice);
return D3D_OK;

View file

@ -26,9 +26,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DCubeTexture9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DCubeTexture9Impl_QueryInterface(LPDIRECT3DCUBETEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
static inline IDirect3DCubeTexture9Impl *impl_from_IDirect3DCubeTexture9(IDirect3DCubeTexture9 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DCubeTexture9Impl, IDirect3DCubeTexture9_iface);
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_QueryInterface(IDirect3DCubeTexture9 *iface,
REFIID riid, void **ppobj)
{
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
@ -46,8 +52,9 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_QueryInterface(LPDIRECT3DCUBETEX
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DCubeTexture9Impl_AddRef(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
static ULONG WINAPI IDirect3DCubeTexture9Impl_AddRef(IDirect3DCubeTexture9 *iface)
{
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", iface, ref);
@ -56,15 +63,16 @@ static ULONG WINAPI IDirect3DCubeTexture9Impl_AddRef(LPDIRECT3DCUBETEXTURE9 ifac
{
IDirect3DDevice9Ex_AddRef(This->parentDevice);
wined3d_mutex_lock();
IWineD3DCubeTexture_AddRef(This->wineD3DCubeTexture);
wined3d_texture_incref(This->wined3d_texture);
wined3d_mutex_unlock();
}
return ref;
}
static ULONG WINAPI IDirect3DCubeTexture9Impl_Release(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
static ULONG WINAPI IDirect3DCubeTexture9Impl_Release(IDirect3DCubeTexture9 *iface)
{
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", iface, ref);
@ -72,10 +80,10 @@ static ULONG WINAPI IDirect3DCubeTexture9Impl_Release(LPDIRECT3DCUBETEXTURE9 ifa
if (ref == 0) {
IDirect3DDevice9Ex *parentDevice = This->parentDevice;
TRACE("Releasing child %p\n", This->wineD3DCubeTexture);
TRACE("Releasing child %p.\n", This->wined3d_texture);
wined3d_mutex_lock();
IWineD3DCubeTexture_Release(This->wineD3DCubeTexture);
wined3d_texture_decref(This->wined3d_texture);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
@ -85,9 +93,10 @@ static ULONG WINAPI IDirect3DCubeTexture9Impl_Release(LPDIRECT3DCUBETEXTURE9 ifa
}
/* IDirect3DCubeTexture9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetDevice(IDirect3DCubeTexture9 *iface, IDirect3DDevice9 **device)
static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetDevice(IDirect3DCubeTexture9 *iface,
IDirect3DDevice9 **device)
{
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
TRACE("iface %p, device %p.\n", iface, device);
@ -99,263 +108,320 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetDevice(IDirect3DCubeTexture9
return D3D_OK;
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetPrivateData(IDirect3DCubeTexture9 *iface,
REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags)
{
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_SetPrivateData(This->wineD3DCubeTexture,refguid,pData,SizeOfData,Flags);
hr = wined3d_texture_set_private_data(This->wined3d_texture, refguid, pData, SizeOfData, Flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetPrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetPrivateData(IDirect3DCubeTexture9 *iface,
REFGUID refguid, void *pData, DWORD *pSizeOfData)
{
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %p.\n",
iface, debugstr_guid(refguid), pData, pSizeOfData);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetPrivateData(This->wineD3DCubeTexture,refguid,pData,pSizeOfData);
hr = wined3d_texture_get_private_data(This->wined3d_texture, refguid, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_FreePrivateData(LPDIRECT3DCUBETEXTURE9 iface, REFGUID refguid) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DCubeTexture9Impl_FreePrivateData(IDirect3DCubeTexture9 *iface,
REFGUID refguid)
{
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
HRESULT hr;
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_FreePrivateData(This->wineD3DCubeTexture,refguid);
hr = wined3d_texture_free_private_data(This->wined3d_texture, refguid);
wined3d_mutex_unlock();
return hr;
}
static DWORD WINAPI IDirect3DCubeTexture9Impl_SetPriority(LPDIRECT3DCUBETEXTURE9 iface, DWORD PriorityNew) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
static DWORD WINAPI IDirect3DCubeTexture9Impl_SetPriority(IDirect3DCubeTexture9 *iface,
DWORD PriorityNew)
{
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
DWORD ret;
TRACE("iface %p, priority %u.\n", iface, PriorityNew);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_SetPriority(This->wineD3DCubeTexture, PriorityNew);
ret = wined3d_texture_set_priority(This->wined3d_texture, PriorityNew);
wined3d_mutex_unlock();
return ret;
}
static DWORD WINAPI IDirect3DCubeTexture9Impl_GetPriority(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
static DWORD WINAPI IDirect3DCubeTexture9Impl_GetPriority(IDirect3DCubeTexture9 *iface)
{
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
DWORD ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_GetPriority(This->wineD3DCubeTexture);
ret = wined3d_texture_get_priority(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
static void WINAPI IDirect3DCubeTexture9Impl_PreLoad(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
static void WINAPI IDirect3DCubeTexture9Impl_PreLoad(IDirect3DCubeTexture9 *iface)
{
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
IWineD3DCubeTexture_PreLoad(This->wineD3DCubeTexture);
wined3d_texture_preload(This->wined3d_texture);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture9Impl_GetType(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture9Impl_GetType(IDirect3DCubeTexture9 *iface)
{
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
D3DRESOURCETYPE ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_GetType(This->wineD3DCubeTexture);
ret = wined3d_texture_get_type(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
/* IDirect3DCubeTexture9 IDirect3DBaseTexture9 Interface follow: */
static DWORD WINAPI IDirect3DCubeTexture9Impl_SetLOD(LPDIRECT3DCUBETEXTURE9 iface, DWORD LODNew) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
static DWORD WINAPI IDirect3DCubeTexture9Impl_SetLOD(IDirect3DCubeTexture9 *iface, DWORD LODNew)
{
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
DWORD ret;
TRACE("iface %p, lod %u.\n", iface, LODNew);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_SetLOD(This->wineD3DCubeTexture, LODNew);
ret = wined3d_texture_set_lod(This->wined3d_texture, LODNew);
wined3d_mutex_unlock();
return ret;
}
static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLOD(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLOD(IDirect3DCubeTexture9 *iface)
{
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
DWORD ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_GetLOD(This->wineD3DCubeTexture);
ret = wined3d_texture_get_lod(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLevelCount(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLevelCount(IDirect3DCubeTexture9 *iface)
{
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
DWORD ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_GetLevelCount(This->wineD3DCubeTexture);
ret = wined3d_texture_get_level_count(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetAutoGenFilterType(IDirect3DCubeTexture9 *iface,
D3DTEXTUREFILTERTYPE FilterType)
{
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
HRESULT hr;
TRACE("iface %p, filter_type %#x.\n", iface, FilterType);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_SetAutoGenFilterType(This->wineD3DCubeTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
hr = wined3d_texture_set_autogen_filter_type(This->wined3d_texture, (WINED3DTEXTUREFILTERTYPE)FilterType);
wined3d_mutex_unlock();
return hr;
}
static D3DTEXTUREFILTERTYPE WINAPI IDirect3DCubeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
static D3DTEXTUREFILTERTYPE WINAPI IDirect3DCubeTexture9Impl_GetAutoGenFilterType(IDirect3DCubeTexture9 *iface)
{
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
D3DTEXTUREFILTERTYPE ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = (D3DTEXTUREFILTERTYPE) IWineD3DCubeTexture_GetAutoGenFilterType(This->wineD3DCubeTexture);
ret = (D3DTEXTUREFILTERTYPE)wined3d_texture_get_autogen_filter_type(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
static void WINAPI IDirect3DCubeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DCUBETEXTURE9 iface) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
static void WINAPI IDirect3DCubeTexture9Impl_GenerateMipSubLevels(IDirect3DCubeTexture9 *iface)
{
IDirect3DCubeTexture9Impl *This = impl_from_IDirect3DCubeTexture9(iface);
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
IWineD3DCubeTexture_GenerateMipSubLevels(This->wineD3DCubeTexture);
wined3d_texture_generate_mipmaps(This->wined3d_texture);
wined3d_mutex_unlock();
}
/* IDirect3DCubeTexture9 Interface follow: */
static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE9 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
HRESULT hr;
static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(IDirect3DCubeTexture9 *iface,
UINT level, D3DSURFACE_DESC *desc)
{
IDirect3DCubeTexture9Impl *texture = impl_from_IDirect3DCubeTexture9(iface);
struct wined3d_resource *sub_resource;
HRESULT hr = D3D_OK;
TRACE("iface %p, level %u, desc %p.\n", iface, Level, pDesc);
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
hr = D3DERR_INVALIDCALL;
else
{
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
pDesc->Type = wined3ddesc.resource_type;
pDesc->Usage = wined3ddesc.usage;
pDesc->Pool = wined3ddesc.pool;
pDesc->MultiSampleType = wined3ddesc.multisample_type;
pDesc->MultiSampleQuality = wined3ddesc.multisample_quality;
pDesc->Width = wined3ddesc.width;
pDesc->Height = wined3ddesc.height;
struct wined3d_resource_desc wined3d_desc;
wined3d_resource_get_desc(sub_resource, &wined3d_desc);
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = wined3d_desc.resource_type;
desc->Usage = wined3d_desc.usage;
desc->Pool = wined3d_desc.pool;
desc->MultiSampleType = wined3d_desc.multisample_type;
desc->MultiSampleQuality = wined3d_desc.multisample_quality;
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
}
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetCubeMapSurface(IDirect3DCubeTexture9 *iface,
D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9 **ppCubeMapSurface)
D3DCUBEMAP_FACES face, UINT level, IDirect3DSurface9 **surface)
{
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
IWineD3DSurface *mySurface = NULL;
HRESULT hr;
IDirect3DCubeTexture9Impl *texture = impl_from_IDirect3DCubeTexture9(iface);
struct wined3d_resource *sub_resource;
UINT sub_resource_idx;
TRACE("iface %p, face %#x, level %u, surface %p.\n", iface, FaceType, Level, ppCubeMapSurface);
TRACE("iface %p, face %#x, level %u, surface %p.\n", iface, face, level, surface);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture,
(WINED3DCUBEMAP_FACES)FaceType, Level, &mySurface);
if (SUCCEEDED(hr) && ppCubeMapSurface)
sub_resource_idx = wined3d_texture_get_level_count(texture->wined3d_texture) * face + level;
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx)))
{
*ppCubeMapSurface = IWineD3DCubeTexture_GetParent(mySurface);
IDirect3DSurface9_AddRef(*ppCubeMapSurface);
IWineD3DCubeTexture_Release(mySurface);
wined3d_mutex_unlock();
return D3DERR_INVALIDCALL;
}
*surface = wined3d_resource_get_parent(sub_resource);
IDirect3DSurface9_AddRef(*surface);
wined3d_mutex_unlock();
return D3D_OK;
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_LockRect(IDirect3DCubeTexture9 *iface,
D3DCUBEMAP_FACES face, UINT level, D3DLOCKED_RECT *locked_rect, const RECT *rect,
DWORD flags)
{
IDirect3DCubeTexture9Impl *texture = impl_from_IDirect3DCubeTexture9(iface);
struct wined3d_resource *sub_resource;
UINT sub_resource_idx;
HRESULT hr;
TRACE("iface %p, face %#x, level %u, locked_rect %p, rect %p, flags %#x.\n",
iface, face, level, locked_rect, rect, flags);
wined3d_mutex_lock();
sub_resource_idx = wined3d_texture_get_level_count(texture->wined3d_texture) * face + level;
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx)))
hr = D3DERR_INVALIDCALL;
else
hr = IDirect3DSurface9_LockRect((IDirect3DSurface9 *)wined3d_resource_get_parent(sub_resource),
locked_rect, rect, flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_UnlockRect(IDirect3DCubeTexture9 *iface,
D3DCUBEMAP_FACES face, UINT level)
{
IDirect3DCubeTexture9Impl *texture = impl_from_IDirect3DCubeTexture9(iface);
struct wined3d_resource *sub_resource;
UINT sub_resource_idx;
HRESULT hr;
TRACE("iface %p, face %#x, level %u.\n", iface, face, level);
wined3d_mutex_lock();
sub_resource_idx = wined3d_texture_get_level_count(texture->wined3d_texture) * face + level;
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx)))
hr = D3DERR_INVALIDCALL;
else
hr = IDirect3DSurface9_UnlockRect((IDirect3DSurface9 *)wined3d_resource_get_parent(sub_resource));
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_AddDirtyRect(IDirect3DCubeTexture9 *iface,
D3DCUBEMAP_FACES face, const RECT *dirty_rect)
{
IDirect3DCubeTexture9Impl *texture = impl_from_IDirect3DCubeTexture9(iface);
HRESULT hr;
TRACE("iface %p, face %#x, dirty_rect %s.\n",
iface, face, wine_dbgstr_rect(dirty_rect));
wined3d_mutex_lock();
if (!dirty_rect)
hr = wined3d_texture_add_dirty_region(texture->wined3d_texture, face, NULL);
else
{
WINED3DBOX dirty_region;
dirty_region.Left = dirty_rect->left;
dirty_region.Top = dirty_rect->top;
dirty_region.Right = dirty_rect->right;
dirty_region.Bottom = dirty_rect->bottom;
dirty_region.Front = 0;
dirty_region.Back = 1;
hr = wined3d_texture_add_dirty_region(texture->wined3d_texture, face, &dirty_region);
}
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_LockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
HRESULT hr;
TRACE("iface %p, face %#x, level %u, locked_rect %p, rect %p, flags %#x.\n",
iface, FaceType, Level, pLockedRect, pRect, Flags);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_LockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_UnlockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
HRESULT hr;
TRACE("iface %p, face %#x, level %u.\n", iface, FaceType, Level);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_UnlockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) {
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
HRESULT hr;
TRACE("iface %p, face %#x, dirty_rect %p.\n", iface, FaceType, pDirtyRect);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect);
wined3d_mutex_unlock();
return hr;
}
static const IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl =
{
/* IUnknown */
@ -400,13 +466,13 @@ HRESULT cubetexture_init(IDirect3DCubeTexture9Impl *texture, IDirect3DDevice9Imp
{
HRESULT hr;
texture->lpVtbl = &Direct3DCubeTexture9_Vtbl;
texture->IDirect3DCubeTexture9_iface.lpVtbl = &Direct3DCubeTexture9_Vtbl;
texture->ref = 1;
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateCubeTexture(device->WineD3DDevice, edge_length,
hr = wined3d_texture_create_cube(device->wined3d_device, edge_length,
levels, usage, wined3dformat_from_d3dformat(format), pool, texture,
&d3d9_cubetexture_wined3d_parent_ops, &texture->wineD3DCubeTexture);
&d3d9_cubetexture_wined3d_parent_ops, &texture->wined3d_texture);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@ -414,7 +480,7 @@ HRESULT cubetexture_init(IDirect3DCubeTexture9Impl *texture, IDirect3DDevice9Imp
return hr;
}
texture->parentDevice = (IDirect3DDevice9Ex *)device;
texture->parentDevice = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(texture->parentDevice);
return D3D_OK;

View file

@ -36,11 +36,11 @@ void WINAPI DebugSetMute(void) {
IDirect3D9* WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT SDKVersion) {
IDirect3D9Impl* object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D9Impl));
object->lpVtbl = &Direct3D9_Vtbl;
object->IDirect3D9Ex_iface.lpVtbl = &Direct3D9_Vtbl;
object->ref = 1;
wined3d_mutex_lock();
object->WineD3D = WineDirect3DCreate(9, (IUnknown *)object);
object->WineD3D = wined3d_create(9, object);
wined3d_mutex_unlock();
TRACE("SDKVersion = %x, Created Direct3D object @ %p, WineObj @ %p\n", SDKVersion, object, object->WineD3D);
@ -66,7 +66,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex
object = (IDirect3D9Impl *) ret;
object->extended = TRUE; /* Enables QI for extended interfaces */
*direct3d9ex = (IDirect3D9Ex *) object;
*direct3d9ex = &object->IDirect3D9Ex_iface;
return D3D_OK;
}

View file

@ -146,11 +146,10 @@ extern const IDirect3D9ExVtbl Direct3D9_Vtbl DECLSPEC_HIDDEN;
typedef struct IDirect3D9Impl
{
/* IUnknown fields */
const IDirect3D9ExVtbl *lpVtbl;
IDirect3D9Ex IDirect3D9Ex_iface;
LONG ref;
/* The WineD3D device */
IWineD3D *WineD3D;
struct wined3d *WineD3D;
/* Created via Direct3DCreate9Ex? Can QI extended interfaces */
BOOL extended;
@ -163,14 +162,10 @@ void filter_caps(D3DCAPS9* pCaps) DECLSPEC_HIDDEN;
*/
typedef struct IDirect3DDevice9Impl
{
/* IUnknown fields */
const IDirect3DDevice9ExVtbl *lpVtbl;
const IWineD3DDeviceParentVtbl *device_parent_vtbl;
LONG ref;
/* IDirect3DDevice9 fields */
IWineD3DDevice *WineD3DDevice;
IDirect3DDevice9Ex IDirect3DDevice9Ex_iface;
struct wined3d_device_parent device_parent;
LONG ref;
struct wined3d_device *wined3d_device;
/* Avoids recursion with nested ReleaseRef to 0 */
BOOL inDestruction;
@ -180,8 +175,8 @@ typedef struct IDirect3DDevice9Impl
BOOL notreset;
} IDirect3DDevice9Impl;
HRESULT device_init(IDirect3DDevice9Impl *device, IWineD3D *wined3d, UINT adapter, D3DDEVTYPE device_type,
HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters) DECLSPEC_HIDDEN;
HRESULT device_init(IDirect3DDevice9Impl *device, struct wined3d *wined3d, UINT adapter, D3DDEVTYPE device_type,
HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode) DECLSPEC_HIDDEN;
/*****************************************************************************
* IDirect3DVolume9 implementation structure
@ -189,17 +184,11 @@ HRESULT device_init(IDirect3DDevice9Impl *device, IWineD3D *wined3d, UINT adapte
typedef struct IDirect3DVolume9Impl
{
/* IUnknown fields */
const IDirect3DVolume9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DVolume9 fields */
IWineD3DVolume *wineD3DVolume;
/* The volume container */
IUnknown *container;
/* If set forward refcounting to this object */
IUnknown *forwardReference;
IDirect3DVolume9 IDirect3DVolume9_iface;
LONG ref;
struct wined3d_volume *wined3d_volume;
IUnknown *container;
IUnknown *forwardReference;
} IDirect3DVolume9Impl;
HRESULT volume_init(IDirect3DVolume9Impl *volume, IDirect3DDevice9Impl *device, UINT width, UINT height,
@ -217,15 +206,8 @@ typedef struct IDirect3DSwapChain9Impl
/* IUnknown fields */
const IDirect3DSwapChain9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DSwapChain9 fields */
IWineD3DSwapChain *wineD3DSwapChain;
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;
/* Flags an implicit swap chain */
BOOL isImplicit;
struct wined3d_swapchain *wined3d_swapchain;
IDirect3DDevice9Ex *parentDevice;
} IDirect3DSwapChain9Impl;
HRESULT swapchain_init(IDirect3DSwapChain9Impl *swapchain, IDirect3DDevice9Impl *device,
@ -243,12 +225,8 @@ typedef struct IDirect3DSurface9Impl
/* IUnknown fields */
const IDirect3DSurface9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource9 fields */
IWineD3DSurface *wineD3DSurface;
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;
struct wined3d_surface *wined3d_surface;
IDirect3DDevice9Ex *parentDevice;
/* The surface container */
IUnknown *container;
@ -276,12 +254,8 @@ typedef struct IDirect3DVertexBuffer9Impl
const IDirect3DVertexBuffer9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource9 fields */
IWineD3DBuffer *wineD3DVertexBuffer;
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;
struct wined3d_buffer *wineD3DVertexBuffer;
IDirect3DDevice9Ex *parentDevice;
DWORD fvf;
} IDirect3DVertexBuffer9Impl;
@ -301,11 +275,8 @@ typedef struct IDirect3DIndexBuffer9Impl
const IDirect3DIndexBuffer9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource9 fields */
IWineD3DBuffer *wineD3DIndexBuffer;
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;
struct wined3d_buffer *wineD3DIndexBuffer;
IDirect3DDevice9Ex *parentDevice;
enum wined3d_format_id format;
} IDirect3DIndexBuffer9Impl;
@ -321,12 +292,9 @@ HRESULT indexbuffer_init(IDirect3DIndexBuffer9Impl *buffer, IDirect3DDevice9Impl
*/
typedef struct IDirect3DBaseTexture9Impl
{
/* IUnknown fields */
const IDirect3DBaseTexture9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource9 fields */
IWineD3DBaseTexture *wineD3DBaseTexture;
struct wined3d_texture *wined3d_texture;
} IDirect3DBaseTexture9Impl;
/* --------------------- */
@ -338,15 +306,10 @@ typedef struct IDirect3DBaseTexture9Impl
*/
typedef struct IDirect3DCubeTexture9Impl
{
/* IUnknown fields */
const IDirect3DCubeTexture9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource9 fields */
IWineD3DCubeTexture *wineD3DCubeTexture;
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;
IDirect3DCubeTexture9 IDirect3DCubeTexture9_iface;
LONG ref;
struct wined3d_texture *wined3d_texture;
IDirect3DDevice9Ex *parentDevice;
} IDirect3DCubeTexture9Impl;
HRESULT cubetexture_init(IDirect3DCubeTexture9Impl *texture, IDirect3DDevice9Impl *device,
@ -361,15 +324,10 @@ HRESULT cubetexture_init(IDirect3DCubeTexture9Impl *texture, IDirect3DDevice9Imp
*/
typedef struct IDirect3DTexture9Impl
{
/* IUnknown fields */
const IDirect3DTexture9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource9 fields */
IWineD3DTexture *wineD3DTexture;
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;
IDirect3DTexture9 IDirect3DTexture9_iface;
LONG ref;
struct wined3d_texture *wined3d_texture;
IDirect3DDevice9Ex *parentDevice;
} IDirect3DTexture9Impl;
HRESULT texture_init(IDirect3DTexture9Impl *texture, IDirect3DDevice9Impl *device,
@ -384,15 +342,10 @@ HRESULT texture_init(IDirect3DTexture9Impl *texture, IDirect3DDevice9Impl *devic
*/
typedef struct IDirect3DVolumeTexture9Impl
{
/* IUnknown fields */
const IDirect3DVolumeTexture9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DResource9 fields */
IWineD3DVolumeTexture *wineD3DVolumeTexture;
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;
IDirect3DVolumeTexture9 IDirect3DVolumeTexture9_iface;
LONG ref;
struct wined3d_texture *wined3d_texture;
IDirect3DDevice9Ex *parentDevice;
} IDirect3DVolumeTexture9Impl;
HRESULT volumetexture_init(IDirect3DVolumeTexture9Impl *texture, IDirect3DDevice9Impl *device,
@ -406,19 +359,18 @@ HRESULT volumetexture_init(IDirect3DVolumeTexture9Impl *texture, IDirect3DDevice
* IDirect3DStateBlock9 implementation structure
*/
typedef struct IDirect3DStateBlock9Impl {
/* IUnknown fields */
const IDirect3DStateBlock9Vtbl *lpVtbl;
IDirect3DStateBlock9 IDirect3DStateBlock9_iface;
LONG ref;
/* IDirect3DStateBlock9 fields */
IWineD3DStateBlock *wineD3DStateBlock;
struct wined3d_stateblock *wined3d_stateblock;
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;
IDirect3DDevice9Ex *parentDevice;
} IDirect3DStateBlock9Impl;
HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, IDirect3DDevice9Impl *device,
D3DSTATEBLOCKTYPE type, IWineD3DStateBlock *wined3d_stateblock) DECLSPEC_HIDDEN;
D3DSTATEBLOCKTYPE type, struct wined3d_stateblock *wined3d_stateblock) DECLSPEC_HIDDEN;
/* --------------------------- */
/* IDirect3DVertexDeclaration9 */
@ -436,7 +388,7 @@ typedef struct IDirect3DVertexDeclaration9Impl {
UINT element_count;
/* IDirect3DVertexDeclaration9 fields */
IWineD3DVertexDeclaration *wineD3DVertexDeclaration;
struct wined3d_vertex_declaration *wineD3DVertexDeclaration;
DWORD convFVF;
/* Parent reference */
@ -457,13 +409,9 @@ HRESULT vertexdeclaration_init(IDirect3DVertexDeclaration9Impl *declaration,
typedef struct IDirect3DVertexShader9Impl {
/* IUnknown fields */
const IDirect3DVertexShader9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DVertexShader9 fields */
IWineD3DVertexShader *wineD3DVertexShader;
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;
LONG ref;
struct wined3d_shader *wined3d_shader;
IDirect3DDevice9Ex *parentDevice;
} IDirect3DVertexShader9Impl;
HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader,
@ -483,12 +431,8 @@ typedef struct IDirect3DPixelShader9Impl {
/* IUnknown fields */
const IDirect3DPixelShader9Vtbl *lpVtbl;
LONG ref;
/* IDirect3DPixelShader9 fields */
IWineD3DPixelShader *wineD3DPixelShader;
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;
struct wined3d_shader *wined3d_shader;
IDirect3DDevice9Ex *parentDevice;
} IDirect3DPixelShader9Impl;
HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader,
@ -502,15 +446,14 @@ HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader,
* IDirect3DPixelShader implementation structure
*/
typedef struct IDirect3DQuery9Impl {
/* IUnknown fields */
const IDirect3DQuery9Vtbl *lpVtbl;
IDirect3DQuery9 IDirect3DQuery9_iface;
LONG ref;
/* IDirect3DQuery9 fields */
IWineD3DQuery *wineD3DQuery;
struct wined3d_query *wineD3DQuery;
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;
IDirect3DDevice9Ex *parentDevice;
} IDirect3DQuery9Impl;
HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device,

File diff suppressed because it is too large Load diff

View file

@ -24,10 +24,14 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3D9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9EX iface, REFIID riid, LPVOID* ppobj)
static inline IDirect3D9Impl *impl_from_IDirect3D9Ex(IDirect3D9Ex *iface)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
return CONTAINING_RECORD(iface, IDirect3D9Impl, IDirect3D9Ex_iface);
}
static HRESULT WINAPI IDirect3D9Impl_QueryInterface(IDirect3D9Ex *iface, REFIID riid, void **ppobj)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
@ -55,8 +59,9 @@ static HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9EX iface, REFIID
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9EX iface) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static ULONG WINAPI IDirect3D9Impl_AddRef(IDirect3D9Ex *iface)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", iface, ref);
@ -64,15 +69,16 @@ static ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9EX iface) {
return ref;
}
static ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9EX iface) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static ULONG WINAPI IDirect3D9Impl_Release(IDirect3D9Ex *iface)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", iface, ref);
if (ref == 0) {
wined3d_mutex_lock();
IWineD3D_Release(This->WineD3D);
wined3d_decref(This->WineD3D);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
@ -82,34 +88,39 @@ static ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9EX iface) {
}
/* IDirect3D9 Interface follow: */
static HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9EX iface, void* pInitializeFunction) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(IDirect3D9Ex *iface,
void *pInitializeFunction)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p, init_function %p.\n", iface, pInitializeFunction);
wined3d_mutex_lock();
hr = IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
hr = wined3d_register_software_device(This->WineD3D, pInitializeFunction);
wined3d_mutex_unlock();
return hr;
}
static UINT WINAPI IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9EX iface) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static UINT WINAPI IDirect3D9Impl_GetAdapterCount(IDirect3D9Ex *iface)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterCount(This->WineD3D);
hr = wined3d_get_adapter_count(This->WineD3D);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9EX iface, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(IDirect3D9Ex *iface, UINT Adapter,
DWORD Flags, D3DADAPTER_IDENTIFIER9 *pIdentifier)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
WINED3DADAPTER_IDENTIFIER adapter_id;
HRESULT hr;
@ -124,7 +135,7 @@ static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9EX iface, U
adapter_id.device_name_size = sizeof(pIdentifier->DeviceName);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
hr = wined3d_get_adapter_identifier(This->WineD3D, Adapter, Flags, &adapter_id);
wined3d_mutex_unlock();
pIdentifier->DriverVersion = adapter_id.driver_version;
@ -138,8 +149,10 @@ static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9EX iface, U
return hr;
}
static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9EX iface, UINT Adapter, D3DFORMAT Format) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(IDirect3D9Ex *iface, UINT Adapter,
D3DFORMAT Format)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, format %#x.\n", iface, Adapter, Format);
@ -150,14 +163,16 @@ static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9EX iface, UINT
}
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format));
hr = wined3d_get_adapter_mode_count(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format));
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9EX iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(IDirect3D9Ex *iface, UINT Adapter,
D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE *pMode)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, format %#x, mode_idx %u, mode %p.\n",
@ -169,7 +184,7 @@ static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9EX iface, UINT
return D3DERR_INVALIDCALL;
wined3d_mutex_lock();
hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format),
hr = wined3d_enum_adapter_modes(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format),
Mode, (WINED3DDISPLAYMODE *) pMode);
wined3d_mutex_unlock();
@ -178,14 +193,16 @@ static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9EX iface, UINT
return hr;
}
static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9EX iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(IDirect3D9Ex *iface, UINT Adapter,
D3DDISPLAYMODE *pMode)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, mode %p.\n", iface, Adapter, pMode);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
hr = wined3d_get_adapter_display_mode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *)pMode);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
@ -196,24 +213,25 @@ static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9EX iface,
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(IDirect3D9Ex *iface, UINT Adapter,
D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, display_format %#x, backbuffer_format %#x, windowed %#x.\n",
iface, Adapter, CheckType, DisplayFormat, BackBufferFormat, Windowed);
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
hr = wined3d_check_device_type(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
wined3dformat_from_d3dformat(BackBufferFormat), Windowed);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(IDirect3D9Ex *iface, UINT Adapter, D3DDEVTYPE DeviceType,
D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat)
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(IDirect3D9Ex *iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType,
D3DFORMAT CheckFormat)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
WINED3DRESOURCETYPE WineD3DRType;
@ -244,7 +262,7 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(IDirect3D9Ex *iface, UINT
}
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
hr = wined3d_check_device_format(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
Usage, WineD3DRType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
wined3d_mutex_unlock();
@ -252,17 +270,17 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(IDirect3D9Ex *iface, UINT
}
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(IDirect3D9Ex *iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType,
DWORD *pQualityLevels)
D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed,
D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, format %#x, windowed %#x, multisample_type %#x, levels %p.\n",
iface, Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType, pQualityLevels);
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType,
hr = wined3d_check_device_multisample_type(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(SurfaceFormat), Windowed, MultiSampleType, pQualityLevels);
wined3d_mutex_unlock();
@ -270,16 +288,17 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(IDirect3D9Ex *if
}
static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(IDirect3D9Ex *iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat)
D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat,
D3DFORMAT DepthStencilFormat)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, rt_format %#x, ds_format %#x.\n",
iface, Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
wined3d_mutex_lock();
hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType,
hr = wined3d_check_depth_stencil_match(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat),
wined3dformat_from_d3dformat(DepthStencilFormat));
wined3d_mutex_unlock();
@ -287,15 +306,17 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(IDirect3D9Ex *iface,
return hr;
}
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9EX iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(IDirect3D9Ex *iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, src_format %#x, dst_format %#x.\n",
iface, Adapter, DeviceType, SourceFormat, TargetFormat);
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceFormatConversion(This->WineD3D, Adapter, DeviceType,
hr = wined3d_check_device_format_conversion(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(SourceFormat), wined3dformat_from_d3dformat(TargetFormat));
wined3d_mutex_unlock();
@ -362,8 +383,10 @@ void filter_caps(D3DCAPS9* pCaps)
pCaps->NumSimultaneousRTs = min(D3D9_MAX_SIMULTANEOUS_RENDERTARGETS, pCaps->NumSimultaneousRTs);
}
static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9EX iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(IDirect3D9Ex *iface, UINT Adapter,
D3DDEVTYPE DeviceType, D3DCAPS9 *pCaps)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HRESULT hrc = D3D_OK;
WINED3DCAPS *pWineCaps;
@ -379,7 +402,7 @@ static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9EX iface, UINT Ada
memset(pCaps, 0, sizeof(*pCaps));
wined3d_mutex_lock();
hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
hrc = wined3d_get_device_caps(This->WineD3D, Adapter, DeviceType, pWineCaps);
wined3d_mutex_unlock();
WINECAPSTOD3D9CAPS(pCaps, pWineCaps)
@ -394,14 +417,15 @@ static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9EX iface, UINT Ada
return hrc;
}
static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9EX iface, UINT Adapter) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(IDirect3D9Ex *iface, UINT Adapter)
{
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
HMONITOR ret;
TRACE("iface %p, adapter %u.\n", iface, Adapter);
wined3d_mutex_lock();
ret = IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
ret = wined3d_get_adapter_monitor(This->WineD3D, Adapter);
wined3d_mutex_unlock();
return ret;
@ -411,7 +435,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3D9Impl_CreateDevice(IDirect3D9Ex
D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters,
IDirect3DDevice9 **device)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
IDirect3DDevice9Impl *object;
HRESULT hr;
@ -425,7 +449,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3D9Impl_CreateDevice(IDirect3D9Ex
return E_OUTOFMEMORY;
}
hr = device_init(object, This->WineD3D, adapter, device_type, focus_window, flags, parameters);
hr = device_init(object, This->WineD3D, adapter, device_type, focus_window, flags, parameters, NULL);
if (FAILED(hr))
{
WARN("Failed to initialize device, hr %#x.\n", hr);
@ -444,7 +468,7 @@ static UINT WINAPI IDirect3D9ExImpl_GetAdapterModeCountEx(IDirect3D9Ex *iface,
{
FIXME("iface %p, adapter %u, filter %p stub!\n", iface, adapter, filter);
return D3DERR_DRIVERINTERNALERROR;
return E_NOTIMPL;
}
static HRESULT WINAPI IDirect3D9ExImpl_EnumAdapterModesEx(IDirect3D9Ex *iface,
@ -453,7 +477,7 @@ static HRESULT WINAPI IDirect3D9ExImpl_EnumAdapterModesEx(IDirect3D9Ex *iface,
FIXME("iface %p, adapter %u, filter %p, mode_idx %u, mode %p stub!\n",
iface, adapter, filter, mode_idx, mode);
return D3DERR_DRIVERINTERNALERROR;
return E_NOTIMPL;
}
static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterDisplayModeEx(IDirect3D9Ex *iface,
@ -462,26 +486,44 @@ static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterDisplayModeEx(IDirect3D9Ex *ifa
FIXME("iface %p, adapter %u, mode %p, rotation %p stub!\n",
iface, adapter, mode, rotation);
return D3DERR_DRIVERINTERNALERROR;
return E_NOTIMPL;
}
static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3D9ExImpl_CreateDeviceEx(IDirect3D9Ex *iface,
UINT adapter, D3DDEVTYPE device_type, HWND focus_window, DWORD flags,
D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode, IDirect3DDevice9Ex **device)
{
FIXME("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x,\n"
"parameters %p, mode %p, device %p stub!\n",
iface, adapter, device_type, focus_window, flags,
parameters, mode, device);
IDirect3D9Impl *d3d9 = impl_from_IDirect3D9Ex(iface);
IDirect3DDevice9Impl *object;
HRESULT hr;
*device = NULL;
TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, mode %p, device %p.\n",
iface, adapter, device_type, focus_window, flags, parameters, mode, device);
return D3DERR_DRIVERINTERNALERROR;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
ERR("Failed to allocate device memory.\n");
return E_OUTOFMEMORY;
}
hr = device_init(object, d3d9->WineD3D, adapter, device_type, focus_window, flags, parameters, mode);
if (FAILED(hr))
{
WARN("Failed to initialize device, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created device %p.\n", object);
*device = &object->IDirect3DDevice9Ex_iface;
return D3D_OK;
}
static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterLUID(IDirect3D9Ex *iface, UINT adapter, LUID *luid)
{
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
WINED3DADAPTER_IDENTIFIER adapter_id;
HRESULT hr;
@ -492,7 +534,7 @@ static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterLUID(IDirect3D9Ex *iface, UINT
adapter_id.device_name_size = 0;
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, adapter, 0, &adapter_id);
hr = wined3d_get_adapter_identifier(This->WineD3D, adapter, 0, &adapter_id);
wined3d_mutex_unlock();
memcpy(luid, &adapter_id.adapter_luid, sizeof(*luid));

View file

@ -25,9 +25,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DQuery9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DQuery9Impl_QueryInterface(LPDIRECT3DQUERY9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
static inline IDirect3DQuery9Impl *impl_from_IDirect3DQuery9(IDirect3DQuery9 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DQuery9Impl, IDirect3DQuery9_iface);
}
static HRESULT WINAPI IDirect3DQuery9Impl_QueryInterface(IDirect3DQuery9 *iface, REFIID riid,
void **ppobj)
{
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
@ -43,8 +49,9 @@ static HRESULT WINAPI IDirect3DQuery9Impl_QueryInterface(LPDIRECT3DQUERY9 iface,
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DQuery9Impl_AddRef(LPDIRECT3DQUERY9 iface) {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
static ULONG WINAPI IDirect3DQuery9Impl_AddRef(IDirect3DQuery9 *iface)
{
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", iface, ref);
@ -52,15 +59,16 @@ static ULONG WINAPI IDirect3DQuery9Impl_AddRef(LPDIRECT3DQUERY9 iface) {
return ref;
}
static ULONG WINAPI IDirect3DQuery9Impl_Release(LPDIRECT3DQUERY9 iface) {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
static ULONG WINAPI IDirect3DQuery9Impl_Release(IDirect3DQuery9 *iface)
{
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", iface, ref);
if (ref == 0) {
wined3d_mutex_lock();
IWineD3DQuery_Release(This->wineD3DQuery);
wined3d_query_decref(This->wineD3DQuery);
wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(This->parentDevice);
@ -69,10 +77,10 @@ static ULONG WINAPI IDirect3DQuery9Impl_Release(LPDIRECT3DQUERY9 iface) {
return ref;
}
/* IDirect3DQuery9 Interface follow: */
static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(IDirect3DQuery9 *iface, IDirect3DDevice9 **device)
static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(IDirect3DQuery9 *iface,
IDirect3DDevice9 **device)
{
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface);
TRACE("iface %p, device %p.\n", iface, device);
@ -84,54 +92,59 @@ static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(IDirect3DQuery9 *iface, IDir
return D3D_OK;
}
static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(LPDIRECT3DQUERY9 iface) {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
HRESULT hr;
static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(IDirect3DQuery9 *iface)
{
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface);
D3DQUERYTYPE type;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DQuery_GetType(This->wineD3DQuery);
type = wined3d_query_get_type(This->wineD3DQuery);
wined3d_mutex_unlock();
return hr;
return type;
}
static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(LPDIRECT3DQUERY9 iface) {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(IDirect3DQuery9 *iface)
{
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface);
DWORD ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DQuery_GetDataSize(This->wineD3DQuery);
ret = wined3d_query_get_data_size(This->wineD3DQuery);
wined3d_mutex_unlock();
return ret;
}
static HRESULT WINAPI IDirect3DQuery9Impl_Issue(LPDIRECT3DQUERY9 iface, DWORD dwIssueFlags) {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
static HRESULT WINAPI IDirect3DQuery9Impl_Issue(IDirect3DQuery9 *iface, DWORD dwIssueFlags)
{
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface);
HRESULT hr;
TRACE("iface %p, flags %#x.\n", iface, dwIssueFlags);
wined3d_mutex_lock();
hr = IWineD3DQuery_Issue(This->wineD3DQuery, dwIssueFlags);
hr = wined3d_query_issue(This->wineD3DQuery, dwIssueFlags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DQuery9Impl_GetData(LPDIRECT3DQUERY9 iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
static HRESULT WINAPI IDirect3DQuery9Impl_GetData(IDirect3DQuery9 *iface, void *pData,
DWORD dwSize, DWORD dwGetDataFlags)
{
IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface);
HRESULT hr;
TRACE("iface %p, data %p, size %u, flags %#x.\n",
iface, pData, dwSize, dwGetDataFlags);
wined3d_mutex_lock();
hr = IWineD3DQuery_GetData(This->wineD3DQuery, pData, dwSize, dwGetDataFlags);
hr = wined3d_query_get_data(This->wineD3DQuery, pData, dwSize, dwGetDataFlags);
wined3d_mutex_unlock();
return hr;
@ -154,11 +167,11 @@ HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, D3D
{
HRESULT hr;
query->lpVtbl = &Direct3DQuery9_Vtbl;
query->IDirect3DQuery9_iface.lpVtbl = &Direct3DQuery9_Vtbl;
query->ref = 1;
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateQuery(device->WineD3DDevice, type, &query->wineD3DQuery);
hr = wined3d_query_create(device->wined3d_device, type, &query->wineD3DQuery);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@ -166,7 +179,7 @@ HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, D3D
return hr;
}
query->parentDevice = (IDirect3DDevice9Ex *)device;
query->parentDevice = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(query->parentDevice);
return D3D_OK;

View file

@ -51,7 +51,7 @@ static ULONG WINAPI d3d9_vertexshader_AddRef(IDirect3DVertexShader9 *iface)
{
IDirect3DDevice9Ex_AddRef(shader->parentDevice);
wined3d_mutex_lock();
IWineD3DVertexShader_AddRef(shader->wineD3DVertexShader);
wined3d_shader_incref(shader->wined3d_shader);
wined3d_mutex_unlock();
}
@ -70,7 +70,7 @@ static ULONG WINAPI d3d9_vertexshader_Release(IDirect3DVertexShader9 *iface)
IDirect3DDevice9Ex *device = shader->parentDevice;
wined3d_mutex_lock();
IWineD3DVertexShader_Release(shader->wineD3DVertexShader);
wined3d_shader_decref(shader->wined3d_shader);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
@ -100,7 +100,7 @@ static HRESULT WINAPI d3d9_vertexshader_GetFunction(IDirect3DVertexShader9 *ifac
TRACE("iface %p, data %p, data_size %p.\n", iface, data, data_size);
wined3d_mutex_lock();
hr = IWineD3DVertexShader_GetFunction(((IDirect3DVertexShader9Impl *)iface)->wineD3DVertexShader, data, data_size);
hr = wined3d_shader_get_byte_code(((IDirect3DVertexShader9Impl *)iface)->wined3d_shader, data, data_size);
wined3d_mutex_unlock();
return hr;
@ -135,8 +135,8 @@ HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader, IDirect3DDevice9Im
shader->lpVtbl = &d3d9_vertexshader_vtbl;
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateVertexShader(device->WineD3DDevice, byte_code, NULL,
shader, &d3d9_vertexshader_wined3d_parent_ops, &shader->wineD3DVertexShader);
hr = wined3d_shader_create_vs(device->wined3d_device, byte_code, NULL,
shader, &d3d9_vertexshader_wined3d_parent_ops, &shader->wined3d_shader);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@ -144,7 +144,7 @@ HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader, IDirect3DDevice9Im
return hr;
}
shader->parentDevice = (IDirect3DDevice9Ex *)device;
shader->parentDevice = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(shader->parentDevice);
return D3D_OK;
@ -179,7 +179,7 @@ static ULONG WINAPI d3d9_pixelshader_AddRef(IDirect3DPixelShader9 *iface)
{
IDirect3DDevice9Ex_AddRef(shader->parentDevice);
wined3d_mutex_lock();
IWineD3DPixelShader_AddRef(shader->wineD3DPixelShader);
wined3d_shader_incref(shader->wined3d_shader);
wined3d_mutex_unlock();
}
@ -198,7 +198,7 @@ static ULONG WINAPI d3d9_pixelshader_Release(IDirect3DPixelShader9 *iface)
IDirect3DDevice9Ex *device = shader->parentDevice;
wined3d_mutex_lock();
IWineD3DPixelShader_Release(shader->wineD3DPixelShader);
wined3d_shader_decref(shader->wined3d_shader);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
@ -227,7 +227,7 @@ static HRESULT WINAPI d3d9_pixelshader_GetFunction(IDirect3DPixelShader9 *iface,
TRACE("iface %p, data %p, data_size %p.\n", iface, data, data_size);
wined3d_mutex_lock();
hr = IWineD3DPixelShader_GetFunction(((IDirect3DPixelShader9Impl *)iface)->wineD3DPixelShader, data, data_size);
hr = wined3d_shader_get_byte_code(((IDirect3DPixelShader9Impl *)iface)->wined3d_shader, data, data_size);
wined3d_mutex_unlock();
return hr;
@ -262,8 +262,8 @@ HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, IDirect3DDevice9Impl
shader->lpVtbl = &d3d9_pixelshader_vtbl;
wined3d_mutex_lock();
hr = IWineD3DDevice_CreatePixelShader(device->WineD3DDevice, byte_code, NULL, shader,
&d3d9_pixelshader_wined3d_parent_ops, &shader->wineD3DPixelShader);
hr = wined3d_shader_create_ps(device->wined3d_device, byte_code, NULL, shader,
&d3d9_pixelshader_wined3d_parent_ops, &shader->wined3d_shader);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@ -271,7 +271,7 @@ HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, IDirect3DDevice9Impl
return hr;
}
shader->parentDevice = (IDirect3DDevice9Ex *)device;
shader->parentDevice = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(shader->parentDevice);
return D3D_OK;

View file

@ -25,9 +25,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DStateBlock9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DStateBlock9Impl_QueryInterface(LPDIRECT3DSTATEBLOCK9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
static inline IDirect3DStateBlock9Impl *impl_from_IDirect3DStateBlock9(IDirect3DStateBlock9 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DStateBlock9Impl, IDirect3DStateBlock9_iface);
}
static HRESULT WINAPI IDirect3DStateBlock9Impl_QueryInterface(IDirect3DStateBlock9 *iface,
REFIID riid, void **ppobj)
{
IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
@ -43,8 +49,9 @@ static HRESULT WINAPI IDirect3DStateBlock9Impl_QueryInterface(LPDIRECT3DSTATEBLO
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DStateBlock9Impl_AddRef(LPDIRECT3DSTATEBLOCK9 iface) {
IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
static ULONG WINAPI IDirect3DStateBlock9Impl_AddRef(IDirect3DStateBlock9 *iface)
{
IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", iface, ref);
@ -52,15 +59,16 @@ static ULONG WINAPI IDirect3DStateBlock9Impl_AddRef(LPDIRECT3DSTATEBLOCK9 iface)
return ref;
}
static ULONG WINAPI IDirect3DStateBlock9Impl_Release(LPDIRECT3DSTATEBLOCK9 iface) {
IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
static ULONG WINAPI IDirect3DStateBlock9Impl_Release(IDirect3DStateBlock9 *iface)
{
IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", iface, ref);
if (ref == 0) {
wined3d_mutex_lock();
IWineD3DStateBlock_Release(This->wineD3DStateBlock);
wined3d_stateblock_decref(This->wined3d_stateblock);
wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(This->parentDevice);
@ -70,9 +78,10 @@ static ULONG WINAPI IDirect3DStateBlock9Impl_Release(LPDIRECT3DSTATEBLOCK9 iface
}
/* IDirect3DStateBlock9 Interface follow: */
static HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(IDirect3DStateBlock9 *iface, IDirect3DDevice9 **device)
static HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(IDirect3DStateBlock9 *iface,
IDirect3DDevice9 **device)
{
IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface);
TRACE("iface %p, device %p.\n", iface, device);
@ -84,27 +93,29 @@ static HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(IDirect3DStateBlock9 *i
return D3D_OK;
}
static HRESULT WINAPI IDirect3DStateBlock9Impl_Capture(LPDIRECT3DSTATEBLOCK9 iface) {
IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
static HRESULT WINAPI IDirect3DStateBlock9Impl_Capture(IDirect3DStateBlock9 *iface)
{
IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface);
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DStateBlock_Capture(This->wineD3DStateBlock);
hr = wined3d_stateblock_capture(This->wined3d_stateblock);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DStateBlock9Impl_Apply(LPDIRECT3DSTATEBLOCK9 iface) {
IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface;
static HRESULT WINAPI IDirect3DStateBlock9Impl_Apply(IDirect3DStateBlock9 *iface)
{
IDirect3DStateBlock9Impl *This = impl_from_IDirect3DStateBlock9(iface);
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DStateBlock_Apply(This->wineD3DStateBlock);
hr = wined3d_stateblock_apply(This->wined3d_stateblock);
wined3d_mutex_unlock();
return hr;
@ -124,22 +135,22 @@ static const IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl =
};
HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, IDirect3DDevice9Impl *device,
D3DSTATEBLOCKTYPE type, IWineD3DStateBlock *wined3d_stateblock)
D3DSTATEBLOCKTYPE type, struct wined3d_stateblock *wined3d_stateblock)
{
HRESULT hr;
stateblock->lpVtbl = &Direct3DStateBlock9_Vtbl;
stateblock->IDirect3DStateBlock9_iface.lpVtbl = &Direct3DStateBlock9_Vtbl;
stateblock->ref = 1;
if (wined3d_stateblock)
{
stateblock->wineD3DStateBlock = wined3d_stateblock;
stateblock->wined3d_stateblock = wined3d_stateblock;
}
else
{
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateStateBlock(device->WineD3DDevice,
(WINED3DSTATEBLOCKTYPE)type, &stateblock->wineD3DStateBlock);
hr = wined3d_stateblock_create(device->wined3d_device,
(WINED3DSTATEBLOCKTYPE)type, &stateblock->wined3d_stateblock);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@ -148,7 +159,7 @@ HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, IDirect3DDevice9Im
}
}
stateblock->parentDevice = (IDirect3DDevice9Ex *)device;
stateblock->parentDevice = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(stateblock->parentDevice);
return D3D_OK;

View file

@ -62,7 +62,7 @@ static ULONG WINAPI IDirect3DSurface9Impl_AddRef(LPDIRECT3DSURFACE9 iface) {
{
if (This->parentDevice) IDirect3DDevice9Ex_AddRef(This->parentDevice);
wined3d_mutex_lock();
IWineD3DSurface_AddRef(This->wineD3DSurface);
wined3d_surface_incref(This->wined3d_surface);
wined3d_mutex_unlock();
}
@ -90,7 +90,7 @@ static ULONG WINAPI IDirect3DSurface9Impl_Release(LPDIRECT3DSURFACE9 iface) {
IDirect3DDevice9Ex *parentDevice = This->parentDevice;
wined3d_mutex_lock();
IWineD3DSurface_Release(This->wineD3DSurface);
wined3d_surface_decref(This->wined3d_surface);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
@ -141,7 +141,7 @@ static HRESULT WINAPI IDirect3DSurface9Impl_SetPrivateData(LPDIRECT3DSURFACE9 if
iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
wined3d_mutex_lock();
hr = IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
hr = wined3d_surface_set_private_data(This->wined3d_surface, refguid, pData, SizeOfData, Flags);
wined3d_mutex_unlock();
return hr;
@ -155,7 +155,7 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetPrivateData(LPDIRECT3DSURFACE9 if
iface, debugstr_guid(refguid), pData, pSizeOfData);
wined3d_mutex_lock();
hr = IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
hr = wined3d_surface_get_private_data(This->wined3d_surface, refguid, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;
@ -168,7 +168,7 @@ static HRESULT WINAPI IDirect3DSurface9Impl_FreePrivateData(LPDIRECT3DSURFACE9 i
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
wined3d_mutex_lock();
hr = IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
hr = wined3d_surface_free_private_data(This->wined3d_surface, refguid);
wined3d_mutex_unlock();
return hr;
@ -181,7 +181,7 @@ static DWORD WINAPI IDirect3DSurface9Impl_SetPriority(LPDIRECT3DSURFACE9 iface,
TRACE("iface %p, priority %u.\n", iface, PriorityNew);
wined3d_mutex_lock();
hr = IWineD3DSurface_SetPriority(This->wineD3DSurface, PriorityNew);
hr = wined3d_surface_set_priority(This->wined3d_surface, PriorityNew);
wined3d_mutex_unlock();
return hr;
@ -194,7 +194,7 @@ static DWORD WINAPI IDirect3DSurface9Impl_GetPriority(LPDIRECT3DSURFACE9 iface)
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DSurface_GetPriority(This->wineD3DSurface);
hr = wined3d_surface_get_priority(This->wined3d_surface);
wined3d_mutex_unlock();
return hr;
@ -206,21 +206,15 @@ static void WINAPI IDirect3DSurface9Impl_PreLoad(LPDIRECT3DSURFACE9 iface) {
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
IWineD3DSurface_PreLoad(This->wineD3DSurface);
wined3d_surface_preload(This->wined3d_surface);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DSurface9Impl_GetType(LPDIRECT3DSURFACE9 iface) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
D3DRESOURCETYPE ret;
static D3DRESOURCETYPE WINAPI IDirect3DSurface9Impl_GetType(IDirect3DSurface9 *iface)
{
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DSurface_GetType(This->wineD3DSurface);
wined3d_mutex_unlock();
return ret;
return D3DRTYPE_SURFACE;
}
/* IDirect3DSurface9 Interface follow: */
@ -232,10 +226,6 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetContainer(LPDIRECT3DSURFACE9 ifac
if (!This->container) return E_NOINTERFACE;
if (!ppContainer) {
ERR("Called without a valid ppContainer\n");
}
res = IUnknown_QueryInterface(This->container, riid, ppContainer);
TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
@ -243,24 +233,27 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetContainer(LPDIRECT3DSURFACE9 ifac
return res;
}
static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3DSURFACE_DESC* pDesc) {
static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(IDirect3DSurface9 *iface, D3DSURFACE_DESC *desc)
{
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
struct wined3d_resource_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
TRACE("iface %p, desc %p.\n", iface, pDesc);
TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock();
IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
wined3d_resource = wined3d_surface_get_resource(This->wined3d_surface);
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
wined3d_mutex_unlock();
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
pDesc->Type = wined3ddesc.resource_type;
pDesc->Usage = wined3ddesc.usage;
pDesc->Pool = wined3ddesc.pool;
pDesc->MultiSampleType = wined3ddesc.multisample_type;
pDesc->MultiSampleQuality = wined3ddesc.multisample_quality;
pDesc->Width = wined3ddesc.width;
pDesc->Height = wined3ddesc.height;
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = wined3d_desc.resource_type;
desc->Usage = wined3d_desc.usage;
desc->Pool = wined3d_desc.pool;
desc->MultiSampleType = wined3d_desc.multisample_type;
desc->MultiSampleQuality = wined3d_desc.multisample_quality;
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
return D3D_OK;
}
@ -272,7 +265,7 @@ static HRESULT WINAPI IDirect3DSurface9Impl_LockRect(LPDIRECT3DSURFACE9 iface, D
TRACE("iface %p, locked_rect %p, rect %p, flags %#x.\n", iface, pLockedRect, pRect, Flags);
wined3d_mutex_lock();
hr = IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
hr = wined3d_surface_map(This->wined3d_surface, (WINED3DLOCKED_RECT *)pLockedRect, pRect, Flags);
wined3d_mutex_unlock();
return hr;
@ -285,7 +278,7 @@ static HRESULT WINAPI IDirect3DSurface9Impl_UnlockRect(LPDIRECT3DSURFACE9 iface)
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DSurface_UnlockRect(This->wineD3DSurface);
hr = wined3d_surface_unmap(This->wined3d_surface);
wined3d_mutex_unlock();
switch(hr)
@ -309,7 +302,7 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetDC(LPDIRECT3DSURFACE9 iface, HDC*
}
wined3d_mutex_lock();
hr = IWineD3DSurface_GetDC(This->wineD3DSurface, phdc);
hr = wined3d_surface_getdc(This->wined3d_surface, phdc);
wined3d_mutex_unlock();
return hr;
@ -322,11 +315,12 @@ static HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(LPDIRECT3DSURFACE9 iface,
TRACE("iface %p, hdc %p.\n", iface, hdc);
wined3d_mutex_lock();
hr = IWineD3DSurface_ReleaseDC(This->wineD3DSurface, hdc);
hr = wined3d_surface_releasedc(This->wined3d_surface, hdc);
wined3d_mutex_unlock();
switch(hr) {
case WINEDDERR_NODC: return WINED3DERR_INVALIDCALL;
switch (hr)
{
case WINEDDERR_NODC: return D3DERR_INVALIDCALL;
default: return hr;
}
}
@ -398,9 +392,9 @@ HRESULT surface_init(IDirect3DSurface9Impl *surface, IDirect3DDevice9Impl *devic
}
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateSurface(device->WineD3DDevice, width, height, wined3dformat_from_d3dformat(format),
hr = wined3d_surface_create(device->wined3d_device, width, height, wined3dformat_from_d3dformat(format),
lockable, discard, level, usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, multisample_type,
multisample_quality, SURFACE_OPENGL, surface, &d3d9_surface_wined3d_parent_ops, &surface->wineD3DSurface);
multisample_quality, SURFACE_OPENGL, surface, &d3d9_surface_wined3d_parent_ops, &surface->wined3d_surface);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@ -408,7 +402,7 @@ HRESULT surface_init(IDirect3DSurface9Impl *surface, IDirect3DDevice9Impl *devic
return hr;
}
surface->parentDevice = (IDirect3DDevice9Ex *)device;
surface->parentDevice = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(surface->parentDevice);
return D3D_OK;

View file

@ -50,7 +50,15 @@ static ULONG WINAPI IDirect3DSwapChain9Impl_AddRef(LPDIRECT3DSWAPCHAIN9 iface) {
TRACE("%p increasing refcount to %u.\n", iface, ref);
if(ref == 1 && This->parentDevice) IDirect3DDevice9Ex_AddRef(This->parentDevice);
if (ref == 1)
{
if (This->parentDevice)
IDirect3DDevice9Ex_AddRef(This->parentDevice);
wined3d_mutex_lock();
wined3d_swapchain_incref(This->wined3d_swapchain);
wined3d_mutex_unlock();
}
return ref;
}
@ -64,13 +72,9 @@ static ULONG WINAPI IDirect3DSwapChain9Impl_Release(LPDIRECT3DSWAPCHAIN9 iface)
if (ref == 0) {
IDirect3DDevice9Ex *parentDevice = This->parentDevice;
if (!This->isImplicit) {
wined3d_mutex_lock();
IWineD3DSwapChain_Destroy(This->wineD3DSwapChain);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
wined3d_mutex_lock();
wined3d_swapchain_decref(This->wined3d_swapchain);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
if (parentDevice) IDirect3DDevice9Ex_Release(parentDevice);
@ -87,7 +91,8 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DSwapChain9Impl_Present(LPDIRECT
iface, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_Present(This->wineD3DSwapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
hr = wined3d_swapchain_present(This->wined3d_swapchain, pSourceRect,
pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
wined3d_mutex_unlock();
return hr;
@ -100,7 +105,8 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetFrontBufferData(LPDIRECT3DSWAPC
TRACE("iface %p, surface %p.\n", iface, pDestSurface);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetFrontBufferData(This->wineD3DSwapChain, ((IDirect3DSurface9Impl *)pDestSurface)->wineD3DSurface);
hr = wined3d_swapchain_get_front_buffer_data(This->wined3d_swapchain,
((IDirect3DSurface9Impl *)pDestSurface)->wined3d_surface);
wined3d_mutex_unlock();
return hr;
@ -110,20 +116,20 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetBackBuffer(IDirect3DSwapChain9
UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 **ppBackBuffer)
{
IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
IWineD3DSurface *mySurface = NULL;
struct wined3d_surface *wined3d_surface = NULL;
HRESULT hr;
TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
iface, iBackBuffer, Type, ppBackBuffer);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer,
(WINED3DBACKBUFFER_TYPE)Type, &mySurface);
if (SUCCEEDED(hr) && mySurface)
hr = wined3d_swapchain_get_back_buffer(This->wined3d_swapchain,
iBackBuffer, (WINED3DBACKBUFFER_TYPE)Type, &wined3d_surface);
if (SUCCEEDED(hr) && wined3d_surface)
{
*ppBackBuffer = IWineD3DSurface_GetParent(mySurface);
*ppBackBuffer = wined3d_surface_get_parent(wined3d_surface);
IDirect3DSurface9_AddRef(*ppBackBuffer);
IWineD3DSurface_Release(mySurface);
wined3d_surface_decref(wined3d_surface);
}
wined3d_mutex_unlock();
@ -138,7 +144,7 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetRasterStatus(LPDIRECT3DSWAPCHAI
TRACE("iface %p, raster_status %p.\n", iface, pRasterStatus);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetRasterStatus(This->wineD3DSwapChain, (WINED3DRASTER_STATUS *) pRasterStatus);
hr = wined3d_swapchain_get_raster_status(This->wined3d_swapchain, (WINED3DRASTER_STATUS *)pRasterStatus);
wined3d_mutex_unlock();
return hr;
@ -151,7 +157,7 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetDisplayMode(LPDIRECT3DSWAPCHAIN
TRACE("iface %p, mode %p.\n", iface, pMode);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetDisplayMode(This->wineD3DSwapChain, (WINED3DDISPLAYMODE *) pMode);
hr = wined3d_swapchain_get_display_mode(This->wined3d_swapchain, (WINED3DDISPLAYMODE *)pMode);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
@ -181,7 +187,7 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetPresentParameters(LPDIRECT3DSWA
TRACE("iface %p, parameters %p.\n", iface, pPresentationParameters);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetPresentParameters(This->wineD3DSwapChain, &winePresentParameters);
hr = wined3d_swapchain_get_present_parameters(This->wined3d_swapchain, &winePresentParameters);
wined3d_mutex_unlock();
pPresentationParameters->BackBufferWidth = winePresentParameters.BackBufferWidth;
@ -217,6 +223,16 @@ static const IDirect3DSwapChain9Vtbl Direct3DSwapChain9_Vtbl =
IDirect3DSwapChain9Impl_GetPresentParameters
};
static void STDMETHODCALLTYPE d3d9_swapchain_wined3d_object_released(void *parent)
{
HeapFree(GetProcessHeap(), 0, parent);
}
static const struct wined3d_parent_ops d3d9_swapchain_wined3d_parent_ops =
{
d3d9_swapchain_wined3d_object_released,
};
HRESULT swapchain_init(IDirect3DSwapChain9Impl *swapchain, IDirect3DDevice9Impl *device,
D3DPRESENT_PARAMETERS *present_parameters)
{
@ -243,8 +259,9 @@ HRESULT swapchain_init(IDirect3DSwapChain9Impl *swapchain, IDirect3DDevice9Impl
wined3d_parameters.AutoRestoreDisplayMode = TRUE;
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateSwapChain(device->WineD3DDevice, &wined3d_parameters,
SURFACE_OPENGL, swapchain, &swapchain->wineD3DSwapChain);
hr = wined3d_swapchain_create(device->wined3d_device, &wined3d_parameters,
SURFACE_OPENGL, swapchain, &d3d9_swapchain_wined3d_parent_ops,
&swapchain->wined3d_swapchain);
wined3d_mutex_unlock();
present_parameters->BackBufferWidth = wined3d_parameters.BackBufferWidth;
@ -268,7 +285,7 @@ HRESULT swapchain_init(IDirect3DSwapChain9Impl *swapchain, IDirect3DDevice9Impl
return hr;
}
swapchain->parentDevice = (IDirect3DDevice9Ex *)device;
swapchain->parentDevice = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(swapchain->parentDevice);
return D3D_OK;

View file

@ -25,9 +25,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DTexture9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DTexture9Impl_QueryInterface(LPDIRECT3DTEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static inline IDirect3DTexture9Impl *impl_from_IDirect3DTexture9(IDirect3DTexture9 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DTexture9Impl, IDirect3DTexture9_iface);
}
static HRESULT WINAPI IDirect3DTexture9Impl_QueryInterface(IDirect3DTexture9 *iface, REFIID riid,
void **ppobj)
{
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
@ -45,8 +51,9 @@ static HRESULT WINAPI IDirect3DTexture9Impl_QueryInterface(LPDIRECT3DTEXTURE9 if
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DTexture9Impl_AddRef(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static ULONG WINAPI IDirect3DTexture9Impl_AddRef(IDirect3DTexture9 *iface)
{
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", iface, ref);
@ -55,15 +62,16 @@ static ULONG WINAPI IDirect3DTexture9Impl_AddRef(LPDIRECT3DTEXTURE9 iface) {
{
IDirect3DDevice9Ex_AddRef(This->parentDevice);
wined3d_mutex_lock();
IWineD3DTexture_AddRef(This->wineD3DTexture);
wined3d_texture_incref(This->wined3d_texture);
wined3d_mutex_unlock();
}
return ref;
}
static ULONG WINAPI IDirect3DTexture9Impl_Release(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static ULONG WINAPI IDirect3DTexture9Impl_Release(IDirect3DTexture9 *iface)
{
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", iface, ref);
@ -72,7 +80,7 @@ static ULONG WINAPI IDirect3DTexture9Impl_Release(LPDIRECT3DTEXTURE9 iface) {
IDirect3DDevice9Ex *parentDevice = This->parentDevice;
wined3d_mutex_lock();
IWineD3DTexture_Release(This->wineD3DTexture);
wined3d_texture_decref(This->wined3d_texture);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
@ -81,10 +89,10 @@ static ULONG WINAPI IDirect3DTexture9Impl_Release(LPDIRECT3DTEXTURE9 iface) {
return ref;
}
/* IDirect3DTexture9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DTexture9Impl_GetDevice(IDirect3DTexture9 *iface, IDirect3DDevice9 **device)
static HRESULT WINAPI IDirect3DTexture9Impl_GetDevice(IDirect3DTexture9 *iface,
IDirect3DDevice9 **device)
{
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
TRACE("iface %p, device %p.\n", iface, device);
@ -96,256 +104,305 @@ static HRESULT WINAPI IDirect3DTexture9Impl_GetDevice(IDirect3DTexture9 *iface,
return D3D_OK;
}
static HRESULT WINAPI IDirect3DTexture9Impl_SetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DTexture9Impl_SetPrivateData(IDirect3DTexture9 *iface,
REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags)
{
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
wined3d_mutex_lock();
hr = IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags);
hr = wined3d_texture_set_private_data(This->wined3d_texture, refguid, pData, SizeOfData, Flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DTexture9Impl_GetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DTexture9Impl_GetPrivateData(IDirect3DTexture9 *iface,
REFGUID refguid, void *pData, DWORD *pSizeOfData)
{
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %p.\n",
iface, debugstr_guid(refguid), pData, pSizeOfData);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData);
hr = wined3d_texture_get_private_data(This->wined3d_texture, refguid, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DTexture9Impl_FreePrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DTexture9Impl_FreePrivateData(IDirect3DTexture9 *iface,
REFGUID refguid)
{
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
HRESULT hr;
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
wined3d_mutex_lock();
hr = IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid);
hr = wined3d_texture_free_private_data(This->wined3d_texture, refguid);
wined3d_mutex_unlock();
return hr;
}
static DWORD WINAPI IDirect3DTexture9Impl_SetPriority(LPDIRECT3DTEXTURE9 iface, DWORD PriorityNew) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static DWORD WINAPI IDirect3DTexture9Impl_SetPriority(IDirect3DTexture9 *iface, DWORD PriorityNew)
{
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
DWORD ret;
TRACE("iface %p, priority %u.\n", iface, PriorityNew);
wined3d_mutex_lock();
ret = IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew);
ret = wined3d_texture_set_priority(This->wined3d_texture, PriorityNew);
wined3d_mutex_unlock();
return ret;
}
static DWORD WINAPI IDirect3DTexture9Impl_GetPriority(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static DWORD WINAPI IDirect3DTexture9Impl_GetPriority(IDirect3DTexture9 *iface)
{
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
DWORD ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetPriority(This->wineD3DTexture);
ret = wined3d_texture_get_priority(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
static void WINAPI IDirect3DTexture9Impl_PreLoad(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static void WINAPI IDirect3DTexture9Impl_PreLoad(IDirect3DTexture9 *iface)
{
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
IWineD3DTexture_PreLoad(This->wineD3DTexture);
wined3d_texture_preload(This->wined3d_texture);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DTexture9Impl_GetType(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static D3DRESOURCETYPE WINAPI IDirect3DTexture9Impl_GetType(IDirect3DTexture9 *iface)
{
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
HRESULT ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetType(This->wineD3DTexture);
ret = wined3d_texture_get_type(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
/* IDirect3DTexture9 IDirect3DBaseTexture9 Interface follow: */
static DWORD WINAPI IDirect3DTexture9Impl_SetLOD(LPDIRECT3DTEXTURE9 iface, DWORD LODNew) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static DWORD WINAPI IDirect3DTexture9Impl_SetLOD(IDirect3DTexture9 *iface, DWORD LODNew)
{
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
DWORD ret;
TRACE("iface %p, lod %u.\n", iface, LODNew);
wined3d_mutex_lock();
ret = IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew);
ret = wined3d_texture_set_lod(This->wined3d_texture, LODNew);
wined3d_mutex_unlock();
return ret;
}
static DWORD WINAPI IDirect3DTexture9Impl_GetLOD(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static DWORD WINAPI IDirect3DTexture9Impl_GetLOD(IDirect3DTexture9 *iface)
{
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
DWORD ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetLOD(This->wineD3DTexture);
ret = wined3d_texture_get_lod(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
static DWORD WINAPI IDirect3DTexture9Impl_GetLevelCount(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static DWORD WINAPI IDirect3DTexture9Impl_GetLevelCount(IDirect3DTexture9 *iface)
{
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
DWORD ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetLevelCount(This->wineD3DTexture);
ret = wined3d_texture_get_level_count(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
static HRESULT WINAPI IDirect3DTexture9Impl_SetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DTexture9Impl_SetAutoGenFilterType(IDirect3DTexture9 *iface,
D3DTEXTUREFILTERTYPE FilterType)
{
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
HRESULT hr;
TRACE("iface %p, filter_type %#x.\n", iface, FilterType);
wined3d_mutex_lock();
hr = IWineD3DTexture_SetAutoGenFilterType(This->wineD3DTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
hr = wined3d_texture_set_autogen_filter_type(This->wined3d_texture, (WINED3DTEXTUREFILTERTYPE)FilterType);
wined3d_mutex_unlock();
return hr;
}
static D3DTEXTUREFILTERTYPE WINAPI IDirect3DTexture9Impl_GetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static D3DTEXTUREFILTERTYPE WINAPI IDirect3DTexture9Impl_GetAutoGenFilterType(IDirect3DTexture9 *iface)
{
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
D3DTEXTUREFILTERTYPE ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
ret = (D3DTEXTUREFILTERTYPE) IWineD3DTexture_GetAutoGenFilterType(This->wineD3DTexture);
ret = (D3DTEXTUREFILTERTYPE)wined3d_texture_get_autogen_filter_type(This->wined3d_texture);
wined3d_mutex_unlock();
return ret;
}
static void WINAPI IDirect3DTexture9Impl_GenerateMipSubLevels(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static void WINAPI IDirect3DTexture9Impl_GenerateMipSubLevels(IDirect3DTexture9 *iface)
{
IDirect3DTexture9Impl *This = impl_from_IDirect3DTexture9(iface);
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
IWineD3DTexture_GenerateMipSubLevels(This->wineD3DTexture);
wined3d_texture_generate_mipmaps(This->wined3d_texture);
wined3d_mutex_unlock();
}
/* IDirect3DTexture9 Interface follow: */
static HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DSURFACE_DESC* pDesc) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
HRESULT hr;
static HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(IDirect3DTexture9 *iface,
UINT level, D3DSURFACE_DESC *desc)
{
IDirect3DTexture9Impl *texture = impl_from_IDirect3DTexture9(iface);
struct wined3d_resource *sub_resource;
HRESULT hr = D3D_OK;
TRACE("iface %p, level %u, desc %p.\n", iface, Level, pDesc);
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetLevelDesc(This->wineD3DTexture, Level, &wined3ddesc);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
hr = D3DERR_INVALIDCALL;
else
{
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.format);
pDesc->Type = wined3ddesc.resource_type;
pDesc->Usage = wined3ddesc.usage;
pDesc->Pool = wined3ddesc.pool;
pDesc->MultiSampleType = wined3ddesc.multisample_type;
pDesc->MultiSampleQuality = wined3ddesc.multisample_quality;
pDesc->Width = wined3ddesc.width;
pDesc->Height = wined3ddesc.height;
struct wined3d_resource_desc wined3d_desc;
wined3d_resource_get_desc(sub_resource, &wined3d_desc);
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = wined3d_desc.resource_type;
desc->Usage = wined3d_desc.usage;
desc->Pool = wined3d_desc.pool;
desc->MultiSampleType = wined3d_desc.multisample_type;
desc->MultiSampleQuality = wined3d_desc.multisample_quality;
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
}
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DTexture9Impl_GetSurfaceLevel(IDirect3DTexture9 *iface,
UINT Level, IDirect3DSurface9 **ppSurfaceLevel)
UINT level, IDirect3DSurface9 **surface)
{
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
IWineD3DSurface *mySurface = NULL;
HRESULT hr;
IDirect3DTexture9Impl *texture = impl_from_IDirect3DTexture9(iface);
struct wined3d_resource *sub_resource;
TRACE("iface %p, level %u, surface %p.\n", iface, Level, ppSurfaceLevel);
TRACE("iface %p, level %u, surface %p.\n", iface, level, surface);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
if (SUCCEEDED(hr) && ppSurfaceLevel)
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
{
*ppSurfaceLevel = IWineD3DSurface_GetParent(mySurface);
IDirect3DSurface9_AddRef(*ppSurfaceLevel);
IWineD3DSurface_Release(mySurface);
wined3d_mutex_unlock();
return D3DERR_INVALIDCALL;
}
*surface = wined3d_resource_get_parent(sub_resource);
IDirect3DSurface9_AddRef(*surface);
wined3d_mutex_unlock();
return hr;
return D3D_OK;
}
static HRESULT WINAPI IDirect3DTexture9Impl_LockRect(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DTexture9Impl_LockRect(IDirect3DTexture9 *iface,
UINT level, D3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags)
{
IDirect3DTexture9Impl *texture = impl_from_IDirect3DTexture9(iface);
struct wined3d_resource *sub_resource;
HRESULT hr;
TRACE("iface %p, level %u, locked_rect %p, rect %p, flags %#x.\n",
iface, Level, pLockedRect, pRect, Flags);
iface, level, locked_rect, rect, flags);
wined3d_mutex_lock();
hr = IWineD3DTexture_LockRect(This->wineD3DTexture, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
hr = D3DERR_INVALIDCALL;
else
hr = IDirect3DSurface9_LockRect((IDirect3DSurface9 *)wined3d_resource_get_parent(sub_resource),
locked_rect, rect, flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DTexture9Impl_UnlockRect(LPDIRECT3DTEXTURE9 iface, UINT Level) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DTexture9Impl_UnlockRect(IDirect3DTexture9 *iface, UINT level)
{
IDirect3DTexture9Impl *texture = impl_from_IDirect3DTexture9(iface);
struct wined3d_resource *sub_resource;
HRESULT hr;
TRACE("iface %p, level %u.\n", iface, Level);
TRACE("iface %p, level %u.\n", iface, level);
wined3d_mutex_lock();
hr = IWineD3DTexture_UnlockRect(This->wineD3DTexture, Level);
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
hr = D3DERR_INVALIDCALL;
else
hr = IDirect3DSurface9_UnlockRect((IDirect3DSurface9 *)wined3d_resource_get_parent(sub_resource));
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DTexture9Impl_AddDirtyRect(LPDIRECT3DTEXTURE9 iface, CONST RECT* pDirtyRect) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DTexture9Impl_AddDirtyRect(IDirect3DTexture9 *iface,
const RECT *dirty_rect)
{
IDirect3DTexture9Impl *texture = impl_from_IDirect3DTexture9(iface);
HRESULT hr;
TRACE("iface %p, dirty_rect %p.\n", iface, pDirtyRect);
TRACE("iface %p, dirty_rect %s.\n",
iface, wine_dbgstr_rect(dirty_rect));
wined3d_mutex_lock();
hr = IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect);
if (!dirty_rect)
hr = wined3d_texture_add_dirty_region(texture->wined3d_texture, 0, NULL);
else
{
WINED3DBOX dirty_region;
dirty_region.Left = dirty_rect->left;
dirty_region.Top = dirty_rect->top;
dirty_region.Right = dirty_rect->right;
dirty_region.Bottom = dirty_rect->bottom;
dirty_region.Front = 0;
dirty_region.Back = 1;
hr = wined3d_texture_add_dirty_region(texture->wined3d_texture, 0, &dirty_region);
}
wined3d_mutex_unlock();
return hr;
@ -396,13 +453,13 @@ HRESULT texture_init(IDirect3DTexture9Impl *texture, IDirect3DDevice9Impl *devic
{
HRESULT hr;
texture->lpVtbl = &Direct3DTexture9_Vtbl;
texture->IDirect3DTexture9_iface.lpVtbl = &Direct3DTexture9_Vtbl;
texture->ref = 1;
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateTexture(device->WineD3DDevice, width, height, levels,
hr = wined3d_texture_create_2d(device->wined3d_device, width, height, levels,
usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool,
texture, &d3d9_texture_wined3d_parent_ops, &texture->wineD3DTexture);
texture, &d3d9_texture_wined3d_parent_ops, &texture->wined3d_texture);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@ -410,7 +467,7 @@ HRESULT texture_init(IDirect3DTexture9Impl *texture, IDirect3DDevice9Impl *devic
return hr;
}
texture->parentDevice = (IDirect3DDevice9Ex *)device;
texture->parentDevice = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(texture->parentDevice);
return D3D_OK;

View file

@ -222,7 +222,7 @@ static ULONG WINAPI IDirect3DVertexDeclaration9Impl_AddRef(LPDIRECT3DVERTEXDECLA
if (!This->convFVF)
{
wined3d_mutex_lock();
IWineD3DVertexDeclaration_AddRef(This->wineD3DVertexDeclaration);
wined3d_vertex_declaration_incref(This->wineD3DVertexDeclaration);
wined3d_mutex_unlock();
}
}
@ -239,7 +239,7 @@ void IDirect3DVertexDeclaration9Impl_Destroy(LPDIRECT3DVERTEXDECLARATION9 iface)
}
wined3d_mutex_lock();
IWineD3DVertexDeclaration_Release(This->wineD3DVertexDeclaration);
wined3d_vertex_declaration_decref(This->wineD3DVertexDeclaration);
wined3d_mutex_unlock();
}
@ -395,7 +395,7 @@ HRESULT vertexdeclaration_init(IDirect3DVertexDeclaration9Impl *declaration,
declaration->element_count = element_count;
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateVertexDeclaration(device->WineD3DDevice, wined3d_elements, wined3d_element_count,
hr = wined3d_vertex_declaration_create(device->wined3d_device, wined3d_elements, wined3d_element_count,
declaration, &d3d9_vertexdeclaration_wined3d_parent_ops, &declaration->wineD3DVertexDeclaration);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, wined3d_elements);
@ -406,7 +406,7 @@ HRESULT vertexdeclaration_init(IDirect3DVertexDeclaration9Impl *declaration,
return hr;
}
declaration->parentDevice = (IDirect3DDevice9Ex *)device;
declaration->parentDevice = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(declaration->parentDevice);
return D3D_OK;

View file

@ -24,9 +24,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DVolume9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DVolume9Impl_QueryInterface(LPDIRECT3DVOLUME9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
static inline IDirect3DVolume9Impl *impl_from_IDirect3DVolume9(IDirect3DVolume9 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DVolume9Impl, IDirect3DVolume9_iface);
}
static HRESULT WINAPI IDirect3DVolume9Impl_QueryInterface(IDirect3DVolume9 *iface, REFIID riid,
void **ppobj)
{
IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
@ -42,8 +48,9 @@ static HRESULT WINAPI IDirect3DVolume9Impl_QueryInterface(LPDIRECT3DVOLUME9 ifac
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DVolume9Impl_AddRef(LPDIRECT3DVOLUME9 iface) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
static ULONG WINAPI IDirect3DVolume9Impl_AddRef(IDirect3DVolume9 *iface)
{
IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface);
TRACE("iface %p.\n", iface);
@ -60,7 +67,7 @@ static ULONG WINAPI IDirect3DVolume9Impl_AddRef(LPDIRECT3DVOLUME9 iface) {
if (ref == 1)
{
wined3d_mutex_lock();
IWineD3DVolume_AddRef(This->wineD3DVolume);
wined3d_volume_incref(This->wined3d_volume);
wined3d_mutex_unlock();
}
@ -68,8 +75,9 @@ static ULONG WINAPI IDirect3DVolume9Impl_AddRef(LPDIRECT3DVOLUME9 iface) {
}
}
static ULONG WINAPI IDirect3DVolume9Impl_Release(LPDIRECT3DVOLUME9 iface) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
static ULONG WINAPI IDirect3DVolume9Impl_Release(IDirect3DVolume9 *iface)
{
IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface);
TRACE("iface %p.\n", iface);
@ -85,7 +93,7 @@ static ULONG WINAPI IDirect3DVolume9Impl_Release(LPDIRECT3DVOLUME9 iface) {
if (ref == 0) {
wined3d_mutex_lock();
IWineD3DVolume_Release(This->wineD3DVolume);
wined3d_volume_decref(This->wined3d_volume);
wined3d_mutex_unlock();
}
@ -93,10 +101,10 @@ static ULONG WINAPI IDirect3DVolume9Impl_Release(LPDIRECT3DVOLUME9 iface) {
}
}
/* IDirect3DVolume9 Interface follow: */
static HRESULT WINAPI IDirect3DVolume9Impl_GetDevice(IDirect3DVolume9 *iface, IDirect3DDevice9 **device)
static HRESULT WINAPI IDirect3DVolume9Impl_GetDevice(IDirect3DVolume9 *iface,
IDirect3DDevice9 **device)
{
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface);
IDirect3DResource9 *resource;
HRESULT hr;
@ -114,65 +122,62 @@ static HRESULT WINAPI IDirect3DVolume9Impl_GetDevice(IDirect3DVolume9 *iface, ID
return hr;
}
static HRESULT WINAPI IDirect3DVolume9Impl_SetPrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
static HRESULT WINAPI IDirect3DVolume9Impl_SetPrivateData(IDirect3DVolume9 *iface, REFGUID refguid,
const void *pData, DWORD SizeOfData, DWORD Flags)
{
IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface);
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
wined3d_mutex_lock();
hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
hr = wined3d_volume_set_private_data(This->wined3d_volume, refguid, pData, SizeOfData, Flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolume9Impl_GetPrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
static HRESULT WINAPI IDirect3DVolume9Impl_GetPrivateData(IDirect3DVolume9 *iface, REFGUID refguid,
void *pData, DWORD *pSizeOfData)
{
IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface);
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %p.\n",
iface, debugstr_guid(refguid), pData, pSizeOfData);
wined3d_mutex_lock();
hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
hr = wined3d_volume_get_private_data(This->wined3d_volume, refguid, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolume9Impl_FreePrivateData(LPDIRECT3DVOLUME9 iface, REFGUID refguid) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
static HRESULT WINAPI IDirect3DVolume9Impl_FreePrivateData(IDirect3DVolume9 *iface, REFGUID refguid)
{
IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface);
HRESULT hr;
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
wined3d_mutex_lock();
hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
hr = wined3d_volume_free_private_data(This->wined3d_volume, refguid);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolume9Impl_GetContainer(LPDIRECT3DVOLUME9 iface, REFIID riid, void** ppContainer) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
static HRESULT WINAPI IDirect3DVolume9Impl_GetContainer(IDirect3DVolume9 *iface, REFIID riid,
void **ppContainer)
{
IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface);
HRESULT res;
TRACE("iface %p, riid %s, container %p.\n", iface, debugstr_guid(riid), ppContainer);
if (!This->container) return E_NOINTERFACE;
if (!ppContainer) {
ERR("Called without a valid ppContainer.\n");
}
res = IUnknown_QueryInterface(This->container, riid, ppContainer);
TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
@ -180,56 +185,56 @@ static HRESULT WINAPI IDirect3DVolume9Impl_GetContainer(LPDIRECT3DVOLUME9 iface,
return res;
}
static HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(LPDIRECT3DVOLUME9 iface, D3DVOLUME_DESC* pDesc) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
WINED3DVOLUME_DESC wined3ddesc;
static HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(IDirect3DVolume9 *iface, D3DVOLUME_DESC *desc)
{
IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface);
struct wined3d_resource_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
TRACE("iface %p, desc %p.\n", iface, pDesc);
TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock();
IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
wined3d_resource = wined3d_volume_get_resource(This->wined3d_volume);
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
wined3d_mutex_unlock();
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
pDesc->Type = wined3ddesc.Type;
pDesc->Usage = wined3ddesc.Usage;
pDesc->Pool = wined3ddesc.Pool;
pDesc->Width = wined3ddesc.Width;
pDesc->Height = wined3ddesc.Height;
pDesc->Depth = wined3ddesc.Depth;
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = wined3d_desc.resource_type;
desc->Usage = wined3d_desc.usage;
desc->Pool = wined3d_desc.pool;
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
desc->Depth = wined3d_desc.depth;
return D3D_OK;
}
static HRESULT WINAPI IDirect3DVolume9Impl_LockBox(LPDIRECT3DVOLUME9 iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
static HRESULT WINAPI IDirect3DVolume9Impl_LockBox(IDirect3DVolume9 *iface,
D3DLOCKED_BOX *pLockedVolume, const D3DBOX *pBox, DWORD Flags)
{
IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface);
HRESULT hr;
TRACE("iface %p, locked_box %p, box %p, flags %#x.\n",
iface, pLockedVolume, pBox, Flags);
wined3d_mutex_lock();
hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *)pLockedVolume,
hr = wined3d_volume_map(This->wined3d_volume, (WINED3DLOCKED_BOX *)pLockedVolume,
(const WINED3DBOX *)pBox, Flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolume9Impl_UnlockBox(LPDIRECT3DVOLUME9 iface) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
static HRESULT WINAPI IDirect3DVolume9Impl_UnlockBox(IDirect3DVolume9 *iface)
{
IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface);
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume);
hr = wined3d_volume_unmap(This->wined3d_volume);
wined3d_mutex_unlock();
return hr;
@ -267,11 +272,11 @@ HRESULT volume_init(IDirect3DVolume9Impl *volume, IDirect3DDevice9Impl *device,
{
HRESULT hr;
volume->lpVtbl = &Direct3DVolume9_Vtbl;
volume->IDirect3DVolume9_iface.lpVtbl = &Direct3DVolume9_Vtbl;
volume->ref = 1;
hr = IWineD3DDevice_CreateVolume(device->WineD3DDevice, width, height, depth, usage & WINED3DUSAGE_MASK,
format, pool, volume, &d3d9_volume_wined3d_parent_ops, &volume->wineD3DVolume);
hr = wined3d_volume_create(device->wined3d_device, width, height, depth, usage & WINED3DUSAGE_MASK,
format, pool, volume, &d3d9_volume_wined3d_parent_ops, &volume->wined3d_volume);
if (FAILED(hr))
{
WARN("Failed to create wined3d volume, hr %#x.\n", hr);

View file

@ -24,9 +24,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
/* IDirect3DVolumeTexture9 IUnknown parts follow: */
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static inline IDirect3DVolumeTexture9Impl *impl_from_IDirect3DVolumeTexture9(IDirect3DVolumeTexture9 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DVolumeTexture9Impl, IDirect3DVolumeTexture9_iface);
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_QueryInterface(IDirect3DVolumeTexture9 *iface,
REFIID riid, void **ppobj)
{
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
@ -44,8 +50,9 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_QueryInterface(LPDIRECT3DVOLUM
return E_NOINTERFACE;
}
static ULONG WINAPI IDirect3DVolumeTexture9Impl_AddRef(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static ULONG WINAPI IDirect3DVolumeTexture9Impl_AddRef(IDirect3DVolumeTexture9 *iface)
{
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", iface, ref);
@ -54,15 +61,16 @@ static ULONG WINAPI IDirect3DVolumeTexture9Impl_AddRef(LPDIRECT3DVOLUMETEXTURE9
{
IDirect3DDevice9Ex_AddRef(This->parentDevice);
wined3d_mutex_lock();
IWineD3DVolumeTexture_AddRef(This->wineD3DVolumeTexture);
wined3d_texture_incref(This->wined3d_texture);
wined3d_mutex_unlock();
}
return ref;
}
static ULONG WINAPI IDirect3DVolumeTexture9Impl_Release(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static ULONG WINAPI IDirect3DVolumeTexture9Impl_Release(IDirect3DVolumeTexture9 *iface)
{
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", iface, ref);
@ -71,7 +79,7 @@ static ULONG WINAPI IDirect3DVolumeTexture9Impl_Release(LPDIRECT3DVOLUMETEXTURE9
IDirect3DDevice9Ex *parentDevice = This->parentDevice;
wined3d_mutex_lock();
IWineD3DVolumeTexture_Release(This->wineD3DVolumeTexture);
wined3d_texture_decref(This->wined3d_texture);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
@ -80,10 +88,10 @@ static ULONG WINAPI IDirect3DVolumeTexture9Impl_Release(LPDIRECT3DVOLUMETEXTURE9
return ref;
}
/* IDirect3DVolumeTexture9 IDirect3DResource9 Interface follow: */
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetDevice(IDirect3DVolumeTexture9 *iface, IDirect3DDevice9 **device)
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetDevice(IDirect3DVolumeTexture9 *iface,
IDirect3DDevice9 **device)
{
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
TRACE("iface %p, device %p.\n", iface, device);
@ -95,292 +103,291 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetDevice(IDirect3DVolumeTextu
return D3D_OK;
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetPrivateData(IDirect3DVolumeTexture9 *iface,
REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags)
{
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
hr = wined3d_texture_set_private_data(This->wined3d_texture, refguid, pData, SizeOfData, Flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetPrivateData(IDirect3DVolumeTexture9 *iface,
REFGUID refguid, void *pData, DWORD *pSizeOfData)
{
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %p.\n",
iface, debugstr_guid(refguid), pData, pSizeOfData);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
hr = wined3d_texture_get_private_data(This->wined3d_texture, refguid, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_FreePrivateData(IDirect3DVolumeTexture9 *iface,
REFGUID refguid)
{
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
HRESULT hr;
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
hr = wined3d_texture_free_private_data(This->wined3d_texture, refguid);
wined3d_mutex_unlock();
return hr;
}
static DWORD WINAPI IDirect3DVolumeTexture9Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE9 iface, DWORD PriorityNew) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static DWORD WINAPI IDirect3DVolumeTexture9Impl_SetPriority(IDirect3DVolumeTexture9 *iface,
DWORD PriorityNew)
{
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
DWORD priority;
TRACE("iface %p, priority %u.\n", iface, PriorityNew);
wined3d_mutex_lock();
priority = IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
priority = wined3d_texture_set_priority(This->wined3d_texture, PriorityNew);
wined3d_mutex_unlock();
return priority;
}
static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetPriority(IDirect3DVolumeTexture9 *iface)
{
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
DWORD priority;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
priority = IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
priority = wined3d_texture_get_priority(This->wined3d_texture);
wined3d_mutex_unlock();
return priority;
}
static void WINAPI IDirect3DVolumeTexture9Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static void WINAPI IDirect3DVolumeTexture9Impl_PreLoad(IDirect3DVolumeTexture9 *iface)
{
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
wined3d_texture_preload(This->wined3d_texture);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture9Impl_GetType(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture9Impl_GetType(IDirect3DVolumeTexture9 *iface)
{
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
D3DRESOURCETYPE type;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
type = IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
type = wined3d_texture_get_type(This->wined3d_texture);
wined3d_mutex_unlock();
return type;
}
/* IDirect3DVolumeTexture9 IDirect3DBaseTexture9 Interface follow: */
static DWORD WINAPI IDirect3DVolumeTexture9Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE9 iface, DWORD LODNew) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static DWORD WINAPI IDirect3DVolumeTexture9Impl_SetLOD(IDirect3DVolumeTexture9 *iface, DWORD LODNew)
{
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
DWORD lod;
TRACE("iface %p, lod %u.\n", iface, LODNew);
wined3d_mutex_lock();
lod = IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
lod = wined3d_texture_set_lod(This->wined3d_texture, LODNew);
wined3d_mutex_unlock();
return lod;
}
static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLOD(IDirect3DVolumeTexture9 *iface)
{
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
DWORD lod;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
lod = IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
lod = wined3d_texture_get_lod(This->wined3d_texture);
wined3d_mutex_unlock();
return lod;
}
static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLevelCount(IDirect3DVolumeTexture9 *iface)
{
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
DWORD level_count;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
level_count = IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
level_count = wined3d_texture_get_level_count(This->wined3d_texture);
wined3d_mutex_unlock();
return level_count;
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DVOLUMETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetAutoGenFilterType(IDirect3DVolumeTexture9 *iface,
D3DTEXTUREFILTERTYPE FilterType)
{
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
HRESULT hr;
TRACE("iface %p, filter_type %#x.\n", iface, FilterType);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_SetAutoGenFilterType(This->wineD3DVolumeTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
hr = wined3d_texture_set_autogen_filter_type(This->wined3d_texture, (WINED3DTEXTUREFILTERTYPE)FilterType);
wined3d_mutex_unlock();
return hr;
}
static D3DTEXTUREFILTERTYPE WINAPI IDirect3DVolumeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static D3DTEXTUREFILTERTYPE WINAPI IDirect3DVolumeTexture9Impl_GetAutoGenFilterType(IDirect3DVolumeTexture9 *iface)
{
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
D3DTEXTUREFILTERTYPE filter_type;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
filter_type = (D3DTEXTUREFILTERTYPE)IWineD3DVolumeTexture_GetAutoGenFilterType(This->wineD3DVolumeTexture);
filter_type = (D3DTEXTUREFILTERTYPE)wined3d_texture_get_autogen_filter_type(This->wined3d_texture);
wined3d_mutex_unlock();
return filter_type;
}
static void WINAPI IDirect3DVolumeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DVOLUMETEXTURE9 iface) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static void WINAPI IDirect3DVolumeTexture9Impl_GenerateMipSubLevels(IDirect3DVolumeTexture9 *iface)
{
IDirect3DVolumeTexture9Impl *This = impl_from_IDirect3DVolumeTexture9(iface);
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
IWineD3DVolumeTexture_GenerateMipSubLevels(This->wineD3DVolumeTexture);
wined3d_texture_generate_mipmaps(This->wined3d_texture);
wined3d_mutex_unlock();
}
/* IDirect3DVolumeTexture9 Interface follow: */
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
WINED3DVOLUME_DESC wined3ddesc;
HRESULT hr;
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(IDirect3DVolumeTexture9 *iface,
UINT level, D3DVOLUME_DESC *desc)
{
IDirect3DVolumeTexture9Impl *texture = impl_from_IDirect3DVolumeTexture9(iface);
struct wined3d_resource *sub_resource;
HRESULT hr = D3D_OK;
TRACE("iface %p, level %u, desc %p.\n", iface, Level, pDesc);
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
hr = D3DERR_INVALIDCALL;
else
{
pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
pDesc->Type = wined3ddesc.Type;
pDesc->Usage = wined3ddesc.Usage;
pDesc->Pool = wined3ddesc.Pool;
pDesc->Width = wined3ddesc.Width;
pDesc->Height = wined3ddesc.Height;
pDesc->Depth = wined3ddesc.Depth;
struct wined3d_resource_desc wined3d_desc;
wined3d_resource_get_desc(sub_resource, &wined3d_desc);
desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format);
desc->Type = wined3d_desc.resource_type;
desc->Usage = wined3d_desc.usage;
desc->Pool = wined3d_desc.pool;
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
desc->Depth = wined3d_desc.depth;
}
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(IDirect3DVolumeTexture9 *iface,
UINT Level, IDirect3DVolume9 **ppVolumeLevel)
UINT level, IDirect3DVolume9 **volume)
{
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
IWineD3DVolume *myVolume = NULL;
HRESULT hr;
IDirect3DVolumeTexture9Impl *texture = impl_from_IDirect3DVolumeTexture9(iface);
struct wined3d_resource *sub_resource;
TRACE("iface %p, level %u, volume %p.\n", iface, Level, ppVolumeLevel);
TRACE("iface %p, level %u, volume %p.\n", iface, level, volume);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
if (SUCCEEDED(hr) && ppVolumeLevel)
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
{
*ppVolumeLevel = IWineD3DVolumeTexture_GetParent(myVolume);
IDirect3DVolumeTexture9_AddRef(*ppVolumeLevel);
IWineD3DVolumeTexture_Release(myVolume);
wined3d_mutex_unlock();
return D3DERR_INVALIDCALL;
}
*volume = wined3d_resource_get_parent(sub_resource);
IDirect3DVolume9_AddRef(*volume);
wined3d_mutex_unlock();
return hr;
return D3D_OK;
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_LockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_LockBox(IDirect3DVolumeTexture9 *iface,
UINT level, D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags)
{
IDirect3DVolumeTexture9Impl *texture = impl_from_IDirect3DVolumeTexture9(iface);
struct wined3d_resource *sub_resource;
HRESULT hr;
TRACE("iface %p, level %u, locked_box %p, box %p, flags %#x.\n",
iface, Level, pLockedVolume, pBox, Flags);
iface, level, locked_box, box, flags);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *)pLockedVolume,
(const WINED3DBOX *)pBox, Flags);
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
hr = D3DERR_INVALIDCALL;
else
hr = IDirect3DVolume9_LockBox((IDirect3DVolume9 *)wined3d_resource_get_parent(sub_resource),
locked_box, box, flags);
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_UnlockBox(IDirect3DVolumeTexture9 *iface,
UINT level)
{
IDirect3DVolumeTexture9Impl *texture = impl_from_IDirect3DVolumeTexture9(iface);
struct wined3d_resource *sub_resource;
HRESULT hr;
TRACE("iface %p, level %u.\n", iface, Level);
TRACE("iface %p, level %u.\n", iface, level);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, level)))
hr = D3DERR_INVALIDCALL;
else
hr = IDirect3DVolume9_UnlockBox((IDirect3DVolume9 *)wined3d_resource_get_parent(sub_resource));
wined3d_mutex_unlock();
return hr;
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE9 iface, CONST D3DBOX* pDirtyBox) {
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_AddDirtyBox(IDirect3DVolumeTexture9 *iface,
const D3DBOX *dirty_box)
{
IDirect3DVolumeTexture9Impl *texture = impl_from_IDirect3DVolumeTexture9(iface);
HRESULT hr;
TRACE("iface %p, dirty_box %p.\n", iface, pDirtyBox);
TRACE("iface %p, dirty_box %p.\n", iface, dirty_box);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *)pDirtyBox);
hr = wined3d_texture_add_dirty_region(texture->wined3d_texture, 0, (const WINED3DBOX *)dirty_box);
wined3d_mutex_unlock();
return hr;
@ -432,13 +439,13 @@ HRESULT volumetexture_init(IDirect3DVolumeTexture9Impl *texture, IDirect3DDevice
{
HRESULT hr;
texture->lpVtbl = &Direct3DVolumeTexture9_Vtbl;
texture->IDirect3DVolumeTexture9_iface.lpVtbl = &Direct3DVolumeTexture9_Vtbl;
texture->ref = 1;
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateVolumeTexture(device->WineD3DDevice, width, height, depth, levels,
hr = wined3d_texture_create_3d(device->wined3d_device, width, height, depth, levels,
usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool, texture,
&d3d9_volumetexture_wined3d_parent_ops, &texture->wineD3DVolumeTexture);
&d3d9_volumetexture_wined3d_parent_ops, &texture->wined3d_texture);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@ -446,7 +453,7 @@ HRESULT volumetexture_init(IDirect3DVolumeTexture9Impl *texture, IDirect3DDevice
return hr;
}
texture->parentDevice = (IDirect3DDevice9Ex *)device;
texture->parentDevice = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(texture->parentDevice);
return D3D_OK;

View file

@ -22,7 +22,6 @@ list(APPEND SOURCE
main.c
material.c
palette.c
parent.c
regsvr.c
stubs.c
surface.c
@ -40,7 +39,6 @@ target_link_libraries(ddraw
wine
uuid
dxguid
wined3d_guid
${PSEH_LIB})
add_importlibs(ddraw

View file

@ -95,7 +95,7 @@ static ULONG WINAPI IDirectDrawClipperImpl_Release(IDirectDrawClipper *iface) {
if (ref == 0)
{
EnterCriticalSection(&ddraw_cs);
IWineD3DClipper_Release(This->wineD3DClipper);
wined3d_clipper_decref(This->wineD3DClipper);
HeapFree(GetProcessHeap(), 0, This);
LeaveCriticalSection(&ddraw_cs);
return 0;
@ -127,9 +127,7 @@ static HRESULT WINAPI IDirectDrawClipperImpl_SetHwnd(
TRACE("iface %p, flags %#x, window %p.\n", iface, dwFlags, hWnd);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DClipper_SetHWnd(This->wineD3DClipper,
dwFlags,
hWnd);
hr = wined3d_clipper_set_window(This->wineD3DClipper, dwFlags, hWnd);
LeaveCriticalSection(&ddraw_cs);
switch(hr)
{
@ -167,10 +165,7 @@ static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(
iface, wine_dbgstr_rect(lpRect), lpClipList, lpdwSize);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DClipper_GetClipList(This->wineD3DClipper,
lpRect,
lpClipList,
lpdwSize);
hr = wined3d_clipper_get_clip_list(This->wineD3DClipper, lpRect, lpClipList, lpdwSize);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@ -198,9 +193,7 @@ static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList(
TRACE("iface %p, clip_list %p, flags %#x.\n", iface, lprgn, dwFlag);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DClipper_SetClipList(This->wineD3DClipper,
lprgn,
dwFlag);
hr = wined3d_clipper_set_clip_list(This->wineD3DClipper, lprgn, dwFlag);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@ -225,8 +218,7 @@ static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(
TRACE("iface %p, window %p.\n", iface, hWndPtr);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DClipper_GetHWnd(This->wineD3DClipper,
hWndPtr);
hr = wined3d_clipper_get_window(This->wineD3DClipper, hWndPtr);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@ -307,7 +299,7 @@ HRESULT ddraw_clipper_init(IDirectDrawClipperImpl *clipper)
{
clipper->lpVtbl = &ddraw_clipper_vtbl;
clipper->ref = 1;
clipper->wineD3DClipper = pWineDirect3DCreateClipper();
clipper->wineD3DClipper = wined3d_clipper_create();
if (!clipper->wineD3DClipper)
{
WARN("Failed to create wined3d clipper.\n");

File diff suppressed because it is too large Load diff

View file

@ -27,7 +27,6 @@
<file>main.c</file>
<file>material.c</file>
<file>palette.c</file>
<file>parent.c</file>
<file>regsvr.c</file>
<file>stubs.c</file>
<file>surface.c</file>

View file

@ -38,32 +38,9 @@
#include "wine/wined3d.h"
#include "legacy.h"
extern const struct wined3d_parent_ops ddraw_surface_wined3d_parent_ops DECLSPEC_HIDDEN;
extern const struct wined3d_parent_ops ddraw_null_wined3d_parent_ops DECLSPEC_HIDDEN;
/*****************************************************************************
* IParent - a helper interface
*****************************************************************************/
DEFINE_GUID(IID_IParent, 0xc20e4c88, 0x74e7, 0x4940, 0xba, 0x9f, 0x2e, 0x32, 0x3f, 0x9d, 0xc9, 0x81);
typedef struct IParent *LPPARENT, *PPARENT;
#define INTERFACE IParent
DECLARE_INTERFACE_(IParent,IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
};
#undef INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IParent_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IParent_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IParent_Release(p) (p)->lpVtbl->Release(p)
#endif
/* Typdef the interfaces */
typedef struct IDirectDrawImpl IDirectDrawImpl;
typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl;
@ -75,10 +52,6 @@ typedef struct IDirect3DViewportImpl IDirect3DViewportImpl;
typedef struct IDirect3DMaterialImpl IDirect3DMaterialImpl;
typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl;
typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl;
typedef struct IParentImpl IParentImpl;
/* Callbacks for implicit object destruction */
extern ULONG WINAPI D3D7CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) DECLSPEC_HIDDEN;
/* Global critical section */
extern CRITICAL_SECTION ddraw_cs DECLSPEC_HIDDEN;
@ -91,29 +64,29 @@ extern DWORD force_refresh_rate DECLSPEC_HIDDEN;
struct FvfToDecl
{
DWORD fvf;
IWineD3DVertexDeclaration *decl;
struct wined3d_vertex_declaration *decl;
};
struct IDirectDrawImpl
{
/* IUnknown fields */
const IDirectDraw7Vtbl *lpVtbl;
const IDirectDraw4Vtbl *IDirectDraw4_vtbl;
const IDirectDraw3Vtbl *IDirectDraw3_vtbl;
const IDirectDraw2Vtbl *IDirectDraw2_vtbl;
const IDirectDrawVtbl *IDirectDraw_vtbl;
const IDirect3D7Vtbl *IDirect3D7_vtbl;
const IDirect3D3Vtbl *IDirect3D3_vtbl;
const IDirect3D2Vtbl *IDirect3D2_vtbl;
const IDirect3DVtbl *IDirect3D_vtbl;
const IWineD3DDeviceParentVtbl *device_parent_vtbl;
/* Interfaces */
IDirectDraw7 IDirectDraw7_iface;
IDirectDraw4 IDirectDraw4_iface;
IDirectDraw3 IDirectDraw3_iface;
IDirectDraw2 IDirectDraw2_iface;
IDirectDraw IDirectDraw_iface;
IDirect3D7 IDirect3D7_iface;
IDirect3D3 IDirect3D3_iface;
IDirect3D2 IDirect3D2_iface;
IDirect3D IDirect3D_iface;
struct wined3d_device_parent device_parent;
/* See comment in IDirectDraw::AddRef */
LONG ref7, ref4, ref2, ref3, ref1, numIfaces;
/* WineD3D linkage */
IWineD3D *wineD3D;
IWineD3DDevice *wineD3DDevice;
struct wined3d *wineD3D;
struct wined3d_device *wined3d_device;
BOOL d3d_initialized;
/* Misc ddraw fields */
@ -183,35 +156,11 @@ void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS *pIn, DDSCAPS2 *pOut) DECLSPEC_H
void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2 *pIn, DDDEVICEIDENTIFIER *pOut) DECLSPEC_HIDDEN;
HRESULT WINAPI ddraw_recreate_surfaces_cb(IDirectDrawSurface7 *surf,
DDSURFACEDESC2 *desc, void *Context) DECLSPEC_HIDDEN;
IWineD3DVertexDeclaration *ddraw_find_decl(IDirectDrawImpl *This, DWORD fvf) DECLSPEC_HIDDEN;
static inline IDirectDrawImpl *ddraw_from_d3d1(IDirect3D *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D_vtbl));
}
static inline IDirectDrawImpl *ddraw_from_d3d2(IDirect3D2 *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D2_vtbl));
}
static inline IDirectDrawImpl *ddraw_from_d3d3(IDirect3D3 *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D3_vtbl));
}
static inline IDirectDrawImpl *ddraw_from_d3d7(IDirect3D7 *iface)
{
return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D7_vtbl));
}
struct wined3d_vertex_declaration *ddraw_find_decl(IDirectDrawImpl *This, DWORD fvf) DECLSPEC_HIDDEN;
/* The default surface type */
extern WINED3DSURFTYPE DefaultSurfaceType DECLSPEC_HIDDEN;
extern typeof(WineDirect3DCreateClipper) *pWineDirect3DCreateClipper DECLSPEC_HIDDEN;
extern typeof(WineDirect3DCreate) *pWineDirect3DCreate DECLSPEC_HIDDEN;
/*****************************************************************************
* IDirectDrawSurface implementation structure
*****************************************************************************/
@ -232,9 +181,9 @@ struct IDirectDrawSurfaceImpl
/* Connections to other Objects */
IDirectDrawImpl *ddraw;
IWineD3DSurface *WineD3DSurface;
IWineD3DBaseTexture *wineD3DTexture;
IWineD3DSwapChain *wineD3DSwapChain;
struct wined3d_surface *wined3d_surface;
struct wined3d_texture *wined3d_texture;
struct wined3d_swapchain *wined3d_swapchain;
/* This implementation handles attaching surfaces to other surfaces */
IDirectDrawSurfaceImpl *next_attached;
@ -272,6 +221,7 @@ struct IDirectDrawSurfaceImpl
DWORD Handle;
};
HRESULT ddraw_surface_create_texture(IDirectDrawSurfaceImpl *surface) DECLSPEC_HIDDEN;
void ddraw_surface_destroy(IDirectDrawSurfaceImpl *surface) DECLSPEC_HIDDEN;
HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface, IDirectDrawImpl *ddraw,
DDSURFACEDESC2 *desc, UINT mip_level, WINED3DSURFTYPE surface_type) DECLSPEC_HIDDEN;
@ -295,26 +245,6 @@ static inline IDirectDrawSurfaceImpl *surface_from_surface3(IDirectDrawSurface3
#define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.dwRGBBitCount+7)/8))
#define GET_BPP(desc) PFGET_BPP(desc.ddpfPixelFormat)
/*****************************************************************************
* IParent Implementation
*****************************************************************************/
struct IParentImpl
{
/* IUnknown fields */
const IParentVtbl *lpVtbl;
LONG ref;
/* IParentImpl fields */
IUnknown *child;
};
void ddraw_parent_init(IParentImpl *parent) DECLSPEC_HIDDEN;
/*****************************************************************************
* IDirect3DDevice implementation
*****************************************************************************/
#define DDRAW_INVALID_HANDLE ~0U
enum ddraw_handle_type
@ -356,13 +286,13 @@ struct IDirect3DDeviceImpl
LONG ref;
/* Other object connections */
IWineD3DDevice *wineD3DDevice;
struct wined3d_device *wined3d_device;
IDirectDrawImpl *ddraw;
IWineD3DBuffer *indexbuffer;
struct wined3d_buffer *indexbuffer;
IDirectDrawSurfaceImpl *target;
/* Viewport management */
IDirect3DViewportImpl *viewport_list;
struct list viewport_list;
IDirect3DViewportImpl *current_viewport;
D3DVIEWPORT7 active_viewport;
@ -393,7 +323,8 @@ HRESULT d3d_device_init(IDirect3DDeviceImpl *device, IDirectDrawImpl *ddraw,
extern const GUID IID_D3DDEVICE_WineD3D DECLSPEC_HIDDEN;
/* Helper functions */
HRESULT IDirect3DImpl_GetCaps(IWineD3D *WineD3D, D3DDEVICEDESC *Desc123, D3DDEVICEDESC7 *Desc7) DECLSPEC_HIDDEN;
HRESULT IDirect3DImpl_GetCaps(const struct wined3d *wined3d,
D3DDEVICEDESC *Desc123, D3DDEVICEDESC7 *Desc7) DECLSPEC_HIDDEN;
WINED3DZBUFFERTYPE IDirect3DDeviceImpl_UpdateDepthStencil(IDirect3DDeviceImpl *This) DECLSPEC_HIDDEN;
static inline IDirect3DDeviceImpl *device_from_device1(IDirect3DDevice *iface)
@ -435,7 +366,7 @@ struct IDirectDrawClipperImpl
const IDirectDrawClipperVtbl *lpVtbl;
LONG ref;
IWineD3DClipper *wineD3DClipper;
struct wined3d_clipper *wineD3DClipper;
BOOL initialized;
};
@ -450,8 +381,7 @@ struct IDirectDrawPaletteImpl
const IDirectDrawPaletteVtbl *lpVtbl;
LONG ref;
/* WineD3D uplink */
IWineD3DPalette *wineD3DPalette;
struct wined3d_palette *wineD3DPalette;
/* IDirectDrawPalette fields */
IUnknown *ifaceToRelease;
@ -460,17 +390,6 @@ struct IDirectDrawPaletteImpl
HRESULT ddraw_palette_init(IDirectDrawPaletteImpl *palette,
IDirectDrawImpl *ddraw, DWORD flags, PALETTEENTRY *entries) DECLSPEC_HIDDEN;
/******************************************************************************
* DirectDraw ClassFactory implementation - incomplete
******************************************************************************/
typedef struct
{
const IClassFactoryVtbl *lpVtbl;
LONG ref;
HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID iid, LPVOID *ppObj);
} IClassFactoryImpl;
/* Helper structures */
struct object_creation_info
{
@ -498,8 +417,7 @@ struct IDirect3DLightImpl
DWORD dwLightIndex;
/* Chained list used for adding / removing from viewports */
IDirect3DLightImpl *next;
struct list entry;
};
/* Helper functions */
@ -554,11 +472,8 @@ struct IDirect3DViewportImpl
D3DVIEWPORT2 vp2;
} viewports;
/* Field used to chain viewports together */
IDirect3DViewportImpl *next;
/* Lights list */
IDirect3DLightImpl *lights;
struct list entry;
struct list light_list;
/* Background material */
IDirect3DMaterialImpl *background;
@ -599,8 +514,8 @@ HRESULT d3d_execute_buffer_init(IDirect3DExecuteBufferImpl *execute_buffer,
IDirect3DDeviceImpl *device, D3DEXECUTEBUFFERDESC *desc) DECLSPEC_HIDDEN;
/* The execute function */
void IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
IDirect3DDeviceImpl *Device, IDirect3DViewportImpl *ViewportImpl) DECLSPEC_HIDDEN;
HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *execute_buffer,
IDirect3DDeviceImpl *device, IDirect3DViewportImpl *viewport) DECLSPEC_HIDDEN;
/*****************************************************************************
* IDirect3DVertexBuffer
@ -613,8 +528,8 @@ struct IDirect3DVertexBufferImpl
LONG ref;
/*** WineD3D and ddraw links ***/
IWineD3DBuffer *wineD3DVertexBuffer;
IWineD3DVertexDeclaration *wineD3DVertexDeclaration;
struct wined3d_buffer *wineD3DVertexBuffer;
struct wined3d_vertex_declaration *wineD3DVertexDeclaration;
IDirectDrawImpl *ddraw;
/*** Storage for D3D7 specific things ***/
@ -654,11 +569,6 @@ void DDRAW_dump_cooperativelevel(DWORD cooplevel) DECLSPEC_HIDDEN;
* IDirect3DExecuteBuffer isn't in WineD3D */
void multiply_matrix(LPD3DMATRIX dest, const D3DMATRIX *src1, const D3DMATRIX *src2) DECLSPEC_HIDDEN;
void multiply_matrix_D3D_way(LPD3DMATRIX result, const D3DMATRIX *m1, const D3DMATRIX *m2) DECLSPEC_HIDDEN;
/* Helper function in main.c */
BOOL LoadWineD3D(void) DECLSPEC_HIDDEN;
/* Used for generic dumping */
typedef struct
{
@ -679,22 +589,30 @@ typedef struct
/* Structure copy */
#define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
#define DD_STRUCT_COPY_BYSIZE(to,from) \
do { \
DWORD __size = (to)->dwSize; \
DWORD __copysize = __size; \
DWORD __resetsize = __size; \
assert(to != from); \
if (__resetsize > sizeof(*to)) \
__resetsize = sizeof(*to); \
memset(to,0,__resetsize); \
if ((from)->dwSize < __size) \
__copysize = (from)->dwSize; \
memcpy(to,from,__copysize); \
(to)->dwSize = __size;/*restore size*/ \
} while (0)
#define DD_STRUCT_COPY_BYSIZE_(to,from,from_size) \
do { \
DWORD __size = (to)->dwSize; \
DWORD __copysize = min(__size, from_size); \
assert(to != from); \
memcpy(to, from, __copysize); \
memset((char*)(to) + __copysize, 0, __size - __copysize); \
(to)->dwSize = __size; /* restore size */ \
} while (0)
#define DD_STRUCT_COPY_BYSIZE(to,from) DD_STRUCT_COPY_BYSIZE_(to,from,(from)->dwSize)
#endif
#define SIZEOF_END_PADDING(type, last_field) \
(sizeof(type) - offsetof(type, last_field) - sizeof(((type *)0)->last_field))
static inline void copy_to_surfacedesc2(DDSURFACEDESC2 *to, DDSURFACEDESC2 *from)
{
DWORD from_size = from->dwSize;
if (from_size == sizeof(DDSURFACEDESC))
from_size -= SIZEOF_END_PADDING(DDSURFACEDESC, ddsCaps);
to->dwSize = sizeof(DDSURFACEDESC2); /* for struct copy */
DD_STRUCT_COPY_BYSIZE_(to, from, from_size);
}
HRESULT hr_ddraw_from_wined3d(HRESULT hr) DECLSPEC_HIDDEN;
#endif

File diff suppressed because it is too large Load diff

View file

@ -68,10 +68,8 @@ static void _dump_D3DEXECUTEBUFFERDESC(const D3DEXECUTEBUFFERDESC *lpDesc) {
* Viewport: Viewport for this operation
*
*****************************************************************************/
void
IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
IDirect3DDeviceImpl *lpDevice,
IDirect3DViewportImpl *lpViewport)
HRESULT d3d_execute_buffer_execute(IDirect3DExecuteBufferImpl *This,
IDirect3DDeviceImpl *lpDevice, IDirect3DViewportImpl *lpViewport)
{
/* DWORD bs = This->desc.dwBufferSize; */
DWORD vs = This->data.dwVertexOffset;
@ -81,10 +79,14 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
char *instr = (char *)This->desc.lpData + is;
/* Should check if the viewport was added or not to the device */
if (lpViewport->active_device != lpDevice)
{
WARN("Viewport %p active device is %p.\n",
lpViewport, lpViewport->active_device);
return DDERR_INVALIDPARAMS;
}
/* Activate the viewport */
lpViewport->active_device = lpDevice;
viewport_activate(lpViewport, FALSE);
TRACE("ExecuteData :\n");
@ -153,11 +155,8 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
}
/* IDirect3DDevices have color keying always enabled -
* enable it before drawing. This overwrites any ALPHA*
* render state
*/
IWineD3DDevice_SetRenderState(lpDevice->wineD3DDevice,
WINED3DRS_COLORKEYENABLE,
1);
* render state. */
wined3d_device_set_render_state(lpDevice->wined3d_device, WINED3DRS_COLORKEYENABLE, 1);
IDirect3DDevice7_DrawIndexedPrimitive((IDirect3DDevice7 *)lpDevice,
D3DPT_TRIANGLELIST, D3DFVF_TLVERTEX, tl_vx, 0, This->indices, count * 3, 0);
} break;
@ -316,18 +315,12 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
/* Get the transform and world matrix */
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
IWineD3DDevice_GetTransform(lpDevice->wineD3DDevice,
D3DTRANSFORMSTATE_VIEW,
(WINED3DMATRIX*) &view_mat);
IWineD3DDevice_GetTransform(lpDevice->wineD3DDevice,
D3DTRANSFORMSTATE_PROJECTION,
(WINED3DMATRIX*) &proj_mat);
IWineD3DDevice_GetTransform(lpDevice->wineD3DDevice,
WINED3DTS_WORLDMATRIX(0),
(WINED3DMATRIX*) &world_mat);
wined3d_device_get_transform(lpDevice->wined3d_device,
D3DTRANSFORMSTATE_VIEW, (WINED3DMATRIX *)&view_mat);
wined3d_device_get_transform(lpDevice->wined3d_device,
D3DTRANSFORMSTATE_PROJECTION, (WINED3DMATRIX *)&proj_mat);
wined3d_device_get_transform(lpDevice->wined3d_device,
WINED3DTS_WORLDMATRIX(0), (WINED3DMATRIX *)&world_mat);
for (i = 0; i < count; i++) {
LPD3DPROCESSVERTICES ci = (LPD3DPROCESSVERTICES) instr;
@ -551,7 +544,7 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
}
end_of_buffer:
;
return D3D_OK;
}
/*****************************************************************************

View file

@ -38,8 +38,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/* The configured default surface */
WINED3DSURFTYPE DefaultSurfaceType = SURFACE_UNKNOWN;
typeof(WineDirect3DCreateClipper) *pWineDirect3DCreateClipper DECLSPEC_HIDDEN;
typeof(WineDirect3DCreate) *pWineDirect3DCreate DECLSPEC_HIDDEN;
/* DDraw list and critical section */
static struct list global_ddraw_list = LIST_INIT(global_ddraw_list);
@ -167,31 +166,6 @@ void *ddraw_get_object(struct ddraw_handle_table *t, DWORD handle, enum ddraw_ha
return entry->object;
}
/*
* Helper Function for DDRAW_Create and DirectDrawCreateClipper for
* lazy loading of the Wine D3D driver.
*
* Returns
* TRUE on success
* FALSE on failure.
*/
BOOL LoadWineD3D(void)
{
static HMODULE hWineD3D = (HMODULE) -1;
if (hWineD3D == (HMODULE) -1)
{
hWineD3D = LoadLibraryA("wined3d");
if (hWineD3D)
{
pWineDirect3DCreate = (typeof(WineDirect3DCreate) *)GetProcAddress(hWineD3D, "WineDirect3DCreate");
pWineDirect3DCreateClipper = (typeof(WineDirect3DCreateClipper) *) GetProcAddress(hWineD3D, "WineDirect3DCreateClipper");
return TRUE;
}
}
return hWineD3D != NULL;
}
/***********************************************************************
*
* Helper function for DirectDrawCreate and friends
@ -270,8 +244,8 @@ DDRAW_Create(const GUID *guid,
return hr;
}
hr = IDirectDraw7_QueryInterface((IDirectDraw7 *)This, iid, DD);
IDirectDraw7_Release((IDirectDraw7 *)This);
hr = IDirectDraw7_QueryInterface(&This->IDirectDraw7_iface, iid, DD);
IDirectDraw7_Release(&This->IDirectDraw7_iface);
if (SUCCEEDED(hr)) list_add_head(&global_ddraw_list, &This->ddraw_list_entry);
else WARN("Failed to query interface %s from ddraw object %p.\n", debugstr_guid(iid), This);
@ -525,6 +499,23 @@ static const struct object_creation_info object_creation[] =
{ &CLSID_DirectDrawClipper, CF_CreateDirectDrawClipper }
};
/******************************************************************************
* DirectDraw ClassFactory implementation
******************************************************************************/
typedef struct
{
IClassFactory IClassFactory_iface;
LONG ref;
HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID iid, LPVOID *ppObj);
} IClassFactoryImpl;
static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
{
return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
}
/*******************************************************************************
* IDirectDrawClassFactory::QueryInterface
*
@ -539,12 +530,10 @@ static const struct object_creation_info object_creation[] =
* Failure: E_NOINTERFACE
*
*******************************************************************************/
static HRESULT WINAPI
IDirectDrawClassFactoryImpl_QueryInterface(IClassFactory *iface,
REFIID riid,
void **obj)
static HRESULT WINAPI IDirectDrawClassFactoryImpl_QueryInterface(IClassFactory *iface, REFIID riid,
void **obj)
{
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), obj);
@ -569,10 +558,9 @@ IDirectDrawClassFactoryImpl_QueryInterface(IClassFactory *iface,
* The new refcount
*
*******************************************************************************/
static ULONG WINAPI
IDirectDrawClassFactoryImpl_AddRef(IClassFactory *iface)
static ULONG WINAPI IDirectDrawClassFactoryImpl_AddRef(IClassFactory *iface)
{
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", This, ref);
@ -590,10 +578,9 @@ IDirectDrawClassFactoryImpl_AddRef(IClassFactory *iface)
* The new refcount
*
*******************************************************************************/
static ULONG WINAPI
IDirectDrawClassFactoryImpl_Release(IClassFactory *iface)
static ULONG WINAPI IDirectDrawClassFactoryImpl_Release(IClassFactory *iface)
{
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", This, ref);
@ -617,13 +604,10 @@ IDirectDrawClassFactoryImpl_Release(IClassFactory *iface)
* ???
*
*******************************************************************************/
static HRESULT WINAPI
IDirectDrawClassFactoryImpl_CreateInstance(IClassFactory *iface,
IUnknown *UnkOuter,
REFIID riid,
void **obj)
static HRESULT WINAPI IDirectDrawClassFactoryImpl_CreateInstance(IClassFactory *iface,
IUnknown *UnkOuter, REFIID riid, void **obj)
{
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
TRACE("iface %p, outer_unknown %p, riid %s, object %p.\n",
iface, UnkOuter, debugstr_guid(riid), obj);
@ -706,7 +690,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
factory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*factory));
if (factory == NULL) return E_OUTOFMEMORY;
factory->lpVtbl = &IClassFactory_Vtbl;
factory->IClassFactory_iface.lpVtbl = &IClassFactory_Vtbl;
factory->ref = 1;
factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
@ -916,11 +900,11 @@ DllMain(HINSTANCE hInstDLL,
WARN("DDraw %p has a refcount of %d\n", ddraw, ddraw->ref7 + ddraw->ref4 + ddraw->ref3 + ddraw->ref2 + ddraw->ref1);
/* Add references to each interface to avoid freeing them unexpectedly */
IDirectDraw_AddRef((IDirectDraw *)&ddraw->IDirectDraw_vtbl);
IDirectDraw2_AddRef((IDirectDraw2 *)&ddraw->IDirectDraw2_vtbl);
IDirectDraw3_AddRef((IDirectDraw3 *)&ddraw->IDirectDraw3_vtbl);
IDirectDraw4_AddRef((IDirectDraw4 *)&ddraw->IDirectDraw4_vtbl);
IDirectDraw7_AddRef((IDirectDraw7 *)ddraw);
IDirectDraw_AddRef(&ddraw->IDirectDraw_iface);
IDirectDraw2_AddRef(&ddraw->IDirectDraw2_iface);
IDirectDraw3_AddRef(&ddraw->IDirectDraw3_iface);
IDirectDraw4_AddRef(&ddraw->IDirectDraw4_iface);
IDirectDraw7_AddRef(&ddraw->IDirectDraw7_iface);
/* Does a D3D device exist? Destroy it
* TODO: Destroy all Vertex buffers, Lights, Materials
@ -939,8 +923,8 @@ DllMain(HINSTANCE hInstDLL,
desc.dwSize = sizeof(desc);
for(i = 0; i <= 1; i++)
{
hr = IDirectDraw7_EnumSurfaces((IDirectDraw7 *)ddraw,
DDENUMSURFACES_ALL, &desc, ddraw, DestroyCallback);
hr = IDirectDraw7_EnumSurfaces(&ddraw->IDirectDraw7_iface, DDENUMSURFACES_ALL,
&desc, ddraw, DestroyCallback);
if(hr != D3D_OK)
ERR("(%p) EnumSurfaces failed, prepare for trouble\n", ddraw);
}
@ -952,11 +936,11 @@ DllMain(HINSTANCE hInstDLL,
/* Release all hanging references to destroy the objects. This
* restores the screen mode too
*/
while(IDirectDraw_Release((IDirectDraw *)&ddraw->IDirectDraw_vtbl));
while(IDirectDraw2_Release((IDirectDraw2 *)&ddraw->IDirectDraw2_vtbl));
while(IDirectDraw3_Release((IDirectDraw3 *)&ddraw->IDirectDraw3_vtbl));
while(IDirectDraw4_Release((IDirectDraw4 *)&ddraw->IDirectDraw4_vtbl));
while(IDirectDraw7_Release((IDirectDraw7 *)ddraw));
while(IDirectDraw_Release(&ddraw->IDirectDraw_iface));
while(IDirectDraw2_Release(&ddraw->IDirectDraw2_iface));
while(IDirectDraw3_Release(&ddraw->IDirectDraw3_iface));
while(IDirectDraw4_Release(&ddraw->IDirectDraw4_iface));
while(IDirectDraw7_Release(&ddraw->IDirectDraw7_iface));
}
}

View file

@ -326,7 +326,7 @@ IDirect3DMaterialImpl_GetHandle(IDirect3DMaterial3 *iface,
return D3D_OK;
}
static HRESULT WINAPI Thunk_IDirect3DMaterialImpl_2_GetHandle(IDirect3DMaterial2 *iface,
static HRESULT WINAPI IDirect3DMaterialImpl_2_GetHandle(IDirect3DMaterial2 *iface,
IDirect3DDevice2 *lpDirect3DDevice2, D3DMATERIALHANDLE *lpHandle)
{
TRACE("iface %p, device %p, handle %p.\n", iface, lpDirect3DDevice2, lpHandle);
@ -335,7 +335,7 @@ static HRESULT WINAPI Thunk_IDirect3DMaterialImpl_2_GetHandle(IDirect3DMaterial2
(IDirect3DDevice3 *)&device_from_device2(lpDirect3DDevice2)->IDirect3DDevice3_vtbl : NULL, lpHandle);
}
static HRESULT WINAPI Thunk_IDirect3DMaterialImpl_1_GetHandle(IDirect3DMaterial *iface,
static HRESULT WINAPI IDirect3DMaterialImpl_1_GetHandle(IDirect3DMaterial *iface,
IDirect3DDevice *lpDirect3DDevice, D3DMATERIALHANDLE *lpHandle)
{
TRACE("iface %p, device %p, handle %p.\n", iface, lpDirect3DDevice, lpHandle);
@ -344,88 +344,76 @@ static HRESULT WINAPI Thunk_IDirect3DMaterialImpl_1_GetHandle(IDirect3DMaterial
(IDirect3DDevice3 *)&device_from_device1(lpDirect3DDevice)->IDirect3DDevice3_vtbl : NULL, lpHandle);
}
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_2_QueryInterface(LPDIRECT3DMATERIAL2 iface,
REFIID riid,
LPVOID* obp)
static HRESULT WINAPI IDirect3DMaterialImpl_2_QueryInterface(LPDIRECT3DMATERIAL2 iface, REFIID riid,
LPVOID* obp)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), obp);
return IDirect3DMaterial3_QueryInterface((IDirect3DMaterial3 *)material_from_material2(iface), riid, obp);
}
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_1_QueryInterface(LPDIRECT3DMATERIAL iface,
REFIID riid,
LPVOID* obp)
static HRESULT WINAPI IDirect3DMaterialImpl_1_QueryInterface(LPDIRECT3DMATERIAL iface, REFIID riid,
LPVOID* obp)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), obp);
return IDirect3DMaterial3_QueryInterface((IDirect3DMaterial3 *)material_from_material1(iface), riid, obp);
}
static ULONG WINAPI
Thunk_IDirect3DMaterialImpl_2_AddRef(LPDIRECT3DMATERIAL2 iface)
static ULONG WINAPI IDirect3DMaterialImpl_2_AddRef(LPDIRECT3DMATERIAL2 iface)
{
TRACE("iface %p.\n", iface);
return IDirect3DMaterial3_AddRef((IDirect3DMaterial3 *)material_from_material2(iface));
}
static ULONG WINAPI
Thunk_IDirect3DMaterialImpl_1_AddRef(LPDIRECT3DMATERIAL iface)
static ULONG WINAPI IDirect3DMaterialImpl_1_AddRef(LPDIRECT3DMATERIAL iface)
{
TRACE("iface %p.\n", iface);
return IDirect3DMaterial3_AddRef((IDirect3DMaterial3 *)material_from_material1(iface));
}
static ULONG WINAPI
Thunk_IDirect3DMaterialImpl_2_Release(LPDIRECT3DMATERIAL2 iface)
static ULONG WINAPI IDirect3DMaterialImpl_2_Release(LPDIRECT3DMATERIAL2 iface)
{
TRACE("iface %p.\n", iface);
return IDirect3DMaterial3_Release((IDirect3DMaterial3 *)material_from_material2(iface));
}
static ULONG WINAPI
Thunk_IDirect3DMaterialImpl_1_Release(LPDIRECT3DMATERIAL iface)
static ULONG WINAPI IDirect3DMaterialImpl_1_Release(LPDIRECT3DMATERIAL iface)
{
TRACE("iface %p.\n", iface);
return IDirect3DMaterial3_Release((IDirect3DMaterial3 *)material_from_material1(iface));
}
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_2_SetMaterial(LPDIRECT3DMATERIAL2 iface,
LPD3DMATERIAL lpMat)
static HRESULT WINAPI IDirect3DMaterialImpl_2_SetMaterial(LPDIRECT3DMATERIAL2 iface,
LPD3DMATERIAL lpMat)
{
TRACE("iface %p, material %p.\n", iface, lpMat);
return IDirect3DMaterial3_SetMaterial((IDirect3DMaterial3 *)material_from_material2(iface), lpMat);
}
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_1_SetMaterial(LPDIRECT3DMATERIAL iface,
LPD3DMATERIAL lpMat)
static HRESULT WINAPI IDirect3DMaterialImpl_1_SetMaterial(LPDIRECT3DMATERIAL iface,
LPD3DMATERIAL lpMat)
{
TRACE("iface %p, material %p.\n", iface, lpMat);
return IDirect3DMaterial3_SetMaterial((IDirect3DMaterial3 *)material_from_material1(iface), lpMat);
}
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_2_GetMaterial(LPDIRECT3DMATERIAL2 iface,
LPD3DMATERIAL lpMat)
static HRESULT WINAPI IDirect3DMaterialImpl_2_GetMaterial(LPDIRECT3DMATERIAL2 iface,
LPD3DMATERIAL lpMat)
{
TRACE("iface %p, material %p.\n", iface, lpMat);
return IDirect3DMaterial3_GetMaterial((IDirect3DMaterial3 *)material_from_material2(iface), lpMat);
}
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_1_GetMaterial(LPDIRECT3DMATERIAL iface,
LPD3DMATERIAL lpMat)
static HRESULT WINAPI IDirect3DMaterialImpl_1_GetMaterial(LPDIRECT3DMATERIAL iface,
LPD3DMATERIAL lpMat)
{
TRACE("iface %p, material %p.\n", iface, lpMat);
@ -471,26 +459,26 @@ static const struct IDirect3DMaterial3Vtbl d3d_material3_vtbl =
static const struct IDirect3DMaterial2Vtbl d3d_material2_vtbl =
{
/*** IUnknown Methods ***/
Thunk_IDirect3DMaterialImpl_2_QueryInterface,
Thunk_IDirect3DMaterialImpl_2_AddRef,
Thunk_IDirect3DMaterialImpl_2_Release,
IDirect3DMaterialImpl_2_QueryInterface,
IDirect3DMaterialImpl_2_AddRef,
IDirect3DMaterialImpl_2_Release,
/*** IDirect3DMaterial2 Methods ***/
Thunk_IDirect3DMaterialImpl_2_SetMaterial,
Thunk_IDirect3DMaterialImpl_2_GetMaterial,
Thunk_IDirect3DMaterialImpl_2_GetHandle,
IDirect3DMaterialImpl_2_SetMaterial,
IDirect3DMaterialImpl_2_GetMaterial,
IDirect3DMaterialImpl_2_GetHandle,
};
static const struct IDirect3DMaterialVtbl d3d_material1_vtbl =
{
/*** IUnknown Methods ***/
Thunk_IDirect3DMaterialImpl_1_QueryInterface,
Thunk_IDirect3DMaterialImpl_1_AddRef,
Thunk_IDirect3DMaterialImpl_1_Release,
IDirect3DMaterialImpl_1_QueryInterface,
IDirect3DMaterialImpl_1_AddRef,
IDirect3DMaterialImpl_1_Release,
/*** IDirect3DMaterial1 Methods ***/
IDirect3DMaterialImpl_Initialize,
Thunk_IDirect3DMaterialImpl_1_SetMaterial,
Thunk_IDirect3DMaterialImpl_1_GetMaterial,
Thunk_IDirect3DMaterialImpl_1_GetHandle,
IDirect3DMaterialImpl_1_SetMaterial,
IDirect3DMaterialImpl_1_GetMaterial,
IDirect3DMaterialImpl_1_GetHandle,
IDirect3DMaterialImpl_Reserve,
IDirect3DMaterialImpl_Unreserve
};

View file

@ -98,7 +98,7 @@ IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface)
if (ref == 0)
{
EnterCriticalSection(&ddraw_cs);
IWineD3DPalette_Release(This->wineD3DPalette);
wined3d_palette_decref(This->wineD3DPalette);
if(This->ifaceToRelease)
{
IUnknown_Release(This->ifaceToRelease);
@ -156,14 +156,14 @@ IDirectDrawPaletteImpl_GetCaps(IDirectDrawPalette *iface,
DWORD *Caps)
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
HRESULT hr;
TRACE("iface %p, caps %p.\n", iface, Caps);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DPalette_GetCaps(This->wineD3DPalette, Caps);
*Caps = wined3d_palette_get_flags(This->wineD3DPalette);
LeaveCriticalSection(&ddraw_cs);
return hr;
return D3D_OK;
}
/*****************************************************************************
@ -201,7 +201,7 @@ IDirectDrawPaletteImpl_SetEntries(IDirectDrawPalette *iface,
return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DPalette_SetEntries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
hr = wined3d_palette_set_entries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@ -240,7 +240,7 @@ IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette *iface,
return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DPalette_GetEntries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
hr = wined3d_palette_get_entries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@ -266,7 +266,7 @@ HRESULT ddraw_palette_init(IDirectDrawPaletteImpl *palette,
palette->lpVtbl = &ddraw_palette_vtbl;
palette->ref = 1;
hr = IWineD3DDevice_CreatePalette(ddraw->wineD3DDevice, flags,
hr = wined3d_palette_create(ddraw->wined3d_device, flags,
entries, palette, &palette->wineD3DPalette);
if (FAILED(hr))
{
@ -274,7 +274,7 @@ HRESULT ddraw_palette_init(IDirectDrawPaletteImpl *palette,
return hr;
}
palette->ifaceToRelease = (IUnknown *)ddraw;
palette->ifaceToRelease = (IUnknown *)&ddraw->IDirectDraw7_iface;
IUnknown_AddRef(palette->ifaceToRelease);
return DD_OK;

View file

@ -102,7 +102,8 @@ static HRESULT WINAPI ddraw_surface7_QueryInterface(IDirectDrawSurface7 *iface,
IDirect3DDevice7 *d3d;
/* Call into IDirect3D7 for creation */
IDirect3D7_CreateDevice((IDirect3D7 *)&This->ddraw->IDirect3D7_vtbl, riid, (IDirectDrawSurface7 *)This, &d3d);
IDirect3D7_CreateDevice(&This->ddraw->IDirect3D7_iface, riid, (IDirectDrawSurface7 *)This,
&d3d);
if (d3d)
{
@ -179,10 +180,13 @@ static ULONG WINAPI ddraw_surface7_AddRef(IDirectDrawSurface7 *iface)
TRACE("%p increasing refcount to %u.\n", This, refCount);
if (refCount == 1 && This->WineD3DSurface)
if (refCount == 1)
{
EnterCriticalSection(&ddraw_cs);
IWineD3DSurface_AddRef(This->WineD3DSurface);
if (This->wined3d_surface)
wined3d_surface_incref(This->wined3d_surface);
if (This->wined3d_texture)
wined3d_texture_incref(This->wined3d_texture);
LeaveCriticalSection(&ddraw_cs);
}
@ -243,53 +247,100 @@ void ddraw_surface_destroy(IDirectDrawSurfaceImpl *This)
WARN("(%p): Destroying surface with refount %d\n", This, This->ref);
}
/* Check for attached surfaces and detach them */
if(This->first_attached != This)
if (This->wined3d_surface)
wined3d_surface_decref(This->wined3d_surface);
}
static void ddraw_surface_cleanup(IDirectDrawSurfaceImpl *surface)
{
IDirectDrawSurfaceImpl *surf;
IUnknown *ifaceToRelease;
UINT i;
TRACE("surface %p.\n", surface);
if (surface->wined3d_swapchain)
{
/* Well, this shouldn't happen: The surface being attached is addref()ed
* in AddAttachedSurface, so it shouldn't be released until DeleteAttachedSurface
* is called, because the refcount is held. It looks like the app released()
* it often enough to force this
*/
IDirectDrawSurface7 *root = (IDirectDrawSurface7 *)This->first_attached;
IDirectDrawSurface7 *detach = (IDirectDrawSurface7 *)This;
IDirectDrawImpl *ddraw = surface->ddraw;
FIXME("(%p) Freeing a surface that is attached to surface %p\n", This, This->first_attached);
/* The refcount will drop to -1 here */
if(IDirectDrawSurface7_DeleteAttachedSurface(root, 0, detach) != DD_OK)
/* If it's the render target, destroy the D3D device. */
if (ddraw->d3d_initialized && surface == ddraw->d3d_target)
{
ERR("(%p) DeleteAttachedSurface failed!\n", This);
TRACE("Destroying the render target, uninitializing D3D.\n");
for (i = 0; i < ddraw->numConvertedDecls; ++i)
{
wined3d_vertex_declaration_decref(ddraw->decls[i].decl);
}
HeapFree(GetProcessHeap(), 0, ddraw->decls);
ddraw->numConvertedDecls = 0;
if (FAILED(wined3d_device_uninit_3d(ddraw->wined3d_device)))
{
ERR("Failed to uninit 3D.\n");
}
else
{
/* Free the d3d window if one was created. */
if (ddraw->d3d_window && ddraw->d3d_window != ddraw->dest_window)
{
TRACE("Destroying the hidden render window %p.\n", ddraw->d3d_window);
DestroyWindow(ddraw->d3d_window);
ddraw->d3d_window = 0;
}
}
ddraw->d3d_initialized = FALSE;
ddraw->d3d_target = NULL;
}
else
{
wined3d_device_uninit_gdi(ddraw->wined3d_device);
}
surface->wined3d_swapchain = NULL;
/* Reset to the default surface implementation type. This is needed
* if applications use non render target surfaces and expect blits to
* work after destroying the render target.
*
* TODO: Recreate existing offscreen surfaces. */
ddraw->ImplType = DefaultSurfaceType;
TRACE("D3D unloaded.\n");
}
/* The refcount test shows that the palette is detached when the surface
* is destroyed. */
IDirectDrawSurface7_SetPalette((IDirectDrawSurface7 *)surface, NULL);
/* Loop through all complex attached surfaces and destroy them.
*
* Yet again, only the root can have more than one complexly attached
* surface, all the others have a total of one. */
for (i = 0; i < MAX_COMPLEX_ATTACHED; ++i)
{
if (!surface->complex_array[i])
break;
surf = surface->complex_array[i];
surface->complex_array[i] = NULL;
while (surf)
{
IDirectDrawSurfaceImpl *destroy = surf;
surf = surf->complex_array[0]; /* Iterate through the "tree" */
ddraw_surface_destroy(destroy); /* Destroy it */
}
}
while(This->next_attached != NULL)
{
IDirectDrawSurface7 *root = (IDirectDrawSurface7 *)This;
IDirectDrawSurface7 *detach = (IDirectDrawSurface7 *)This->next_attached;
ifaceToRelease = surface->ifaceToRelease;
if(IDirectDrawSurface7_DeleteAttachedSurface(root, 0, detach) != DD_OK)
{
ERR("(%p) DeleteAttachedSurface failed!\n", This);
assert(0);
}
}
/* Destroy the root surface. */
ddraw_surface_destroy(surface);
/* Now destroy the surface. Wait: It could have been released if we are a texture */
if(This->WineD3DSurface)
IWineD3DSurface_Release(This->WineD3DSurface);
/* Having a texture handle set implies that the device still exists */
if(This->Handle)
{
ddraw_free_handle(&This->ddraw->d3ddevice->handle_table, This->Handle - 1, DDRAW_HANDLE_SURFACE);
}
/* Reduce the ddraw surface count */
InterlockedDecrement(&This->ddraw->surfaces);
list_remove(&This->surface_list_entry);
HeapFree(GetProcessHeap(), 0, This);
/* Reduce the ddraw refcount */
if (ifaceToRelease)
IUnknown_Release(ifaceToRelease);
}
/*****************************************************************************
@ -330,12 +381,6 @@ static ULONG WINAPI ddraw_surface7_Release(IDirectDrawSurface7 *iface)
if (ref == 0)
{
IDirectDrawSurfaceImpl *surf;
IDirectDrawImpl *ddraw;
IUnknown *ifaceToRelease = This->ifaceToRelease;
UINT i;
/* Complex attached surfaces are destroyed implicitly when the root is released */
EnterCriticalSection(&ddraw_cs);
if(!This->is_complex_root)
@ -344,101 +389,10 @@ static ULONG WINAPI ddraw_surface7_Release(IDirectDrawSurface7 *iface)
LeaveCriticalSection(&ddraw_cs);
return ref;
}
ddraw = This->ddraw;
/* If it's a texture, destroy the WineD3DTexture.
* WineD3D will destroy the IParent interfaces
* of the sublevels, which destroys the WineD3DSurfaces.
* Set the surfaces to NULL to avoid destroying them again later
*/
if(This->wineD3DTexture)
{
IWineD3DBaseTexture_Release(This->wineD3DTexture);
}
/* If it's the RenderTarget, destroy the d3ddevice */
else if(This->wineD3DSwapChain)
{
if((ddraw->d3d_initialized) && (This == ddraw->d3d_target)) {
TRACE("(%p) Destroying the render target, uninitializing D3D\n", This);
/* Unset any index buffer, just to be sure */
IWineD3DDevice_SetIndexBuffer(ddraw->wineD3DDevice, NULL, WINED3DFMT_UNKNOWN);
IWineD3DDevice_SetDepthStencilSurface(ddraw->wineD3DDevice, NULL);
IWineD3DDevice_SetVertexDeclaration(ddraw->wineD3DDevice, NULL);
for(i = 0; i < ddraw->numConvertedDecls; i++)
{
IWineD3DVertexDeclaration_Release(ddraw->decls[i].decl);
}
HeapFree(GetProcessHeap(), 0, ddraw->decls);
ddraw->numConvertedDecls = 0;
if (FAILED(IWineD3DDevice_Uninit3D(ddraw->wineD3DDevice, D3D7CB_DestroySwapChain)))
{
/* Not good */
ERR("(%p) Failed to uninit 3D\n", This);
}
else
{
/* Free the d3d window if one was created */
if(ddraw->d3d_window != 0 && ddraw->d3d_window != ddraw->dest_window)
{
TRACE(" (%p) Destroying the hidden render window %p\n", This, ddraw->d3d_window);
DestroyWindow(ddraw->d3d_window);
ddraw->d3d_window = 0;
}
/* Unset the pointers */
}
This->wineD3DSwapChain = NULL; /* Uninit3D releases the swapchain */
ddraw->d3d_initialized = FALSE;
ddraw->d3d_target = NULL;
} else {
IWineD3DDevice_UninitGDI(ddraw->wineD3DDevice, D3D7CB_DestroySwapChain);
This->wineD3DSwapChain = NULL;
}
/* Reset to the default surface implementation type. This is needed if apps use
* non render target surfaces and expect blits to work after destroying the render
* target.
*
* TODO: Recreate existing offscreen surfaces
*/
ddraw->ImplType = DefaultSurfaceType;
/* Write a trace because D3D unloading was the reason for many
* crashes during development.
*/
TRACE("(%p) D3D unloaded\n", This);
}
/* The refcount test shows that the palette is detached when the surface is destroyed */
IDirectDrawSurface7_SetPalette((IDirectDrawSurface7 *)This, NULL);
/* Loop through all complex attached surfaces,
* and destroy them.
*
* Yet again, only the root can have more than one complexly attached surface, all the others
* have a total of one;
*/
for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
{
if(!This->complex_array[i]) break;
surf = This->complex_array[i];
This->complex_array[i] = NULL;
while(surf)
{
IDirectDrawSurfaceImpl *destroy = surf;
surf = surf->complex_array[0]; /* Iterate through the "tree" */
ddraw_surface_destroy(destroy); /* Destroy it */
}
}
/* Destroy the root surface. */
ddraw_surface_destroy(This);
/* Reduce the ddraw refcount */
if(ifaceToRelease) IUnknown_Release(ifaceToRelease);
if (This->wined3d_texture) /* If it's a texture, destroy the wined3d texture. */
wined3d_texture_decref(This->wined3d_texture);
else
ddraw_surface_cleanup(This);
LeaveCriticalSection(&ddraw_cs);
}
@ -679,11 +633,8 @@ static HRESULT WINAPI ddraw_surface7_Lock(IDirectDrawSurface7 *iface,
}
}
hr = IWineD3DSurface_LockRect(This->WineD3DSurface,
&LockedRect,
Rect,
Flags);
if(hr != D3D_OK)
hr = wined3d_surface_map(This->wined3d_surface, &LockedRect, Rect, Flags);
if (FAILED(hr))
{
LeaveCriticalSection(&ddraw_cs);
switch(hr)
@ -744,8 +695,8 @@ static HRESULT WINAPI ddraw_surface7_Unlock(IDirectDrawSurface7 *iface, RECT *pR
TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(pRect));
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DSurface_UnlockRect(This->WineD3DSurface);
if(SUCCEEDED(hr))
hr = wined3d_surface_unmap(This->wined3d_surface);
if (SUCCEEDED(hr))
{
This->surface_desc.lpSurface = NULL;
}
@ -817,9 +768,7 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra
ddraw_surface7_Release(Override7);
}
hr = IWineD3DSurface_Flip(This->WineD3DSurface,
Override->WineD3DSurface,
Flags);
hr = wined3d_surface_flip(This->wined3d_surface, Override->wined3d_surface, Flags);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@ -856,7 +805,7 @@ static HRESULT WINAPI ddraw_surface7_Blt(IDirectDrawSurface7 *iface, RECT *DestR
IDirectDrawSurfaceImpl *Src = (IDirectDrawSurfaceImpl *)SrcSurface;
HRESULT hr;
TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %p, flags %#x, fx %p.\n",
TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n",
iface, wine_dbgstr_rect(DestRect), SrcSurface, wine_dbgstr_rect(SrcRect), Flags, DDBltFx);
/* Check for validity of the flags here. WineD3D Has the software-opengl selection path and would have
@ -903,17 +852,12 @@ static HRESULT WINAPI ddraw_surface7_Blt(IDirectDrawSurface7 *iface, RECT *DestR
return DDERR_INVALIDPARAMS;
}
/* TODO: Check if the DDBltFx contains any ddraw surface pointers. If it does, copy the struct,
* and replace the ddraw surfaces with the wined3d surfaces
* So far no blitting operations using surfaces in the bltfx struct are supported anyway.
*/
hr = IWineD3DSurface_Blt(This->WineD3DSurface,
DestRect,
Src ? Src->WineD3DSurface : NULL,
SrcRect,
Flags,
(WINEDDBLTFX *) DDBltFx,
WINED3DTEXF_POINT);
/* TODO: Check if the DDBltFx contains any ddraw surface pointers. If it
* does, copy the struct, and replace the ddraw surfaces with the wined3d
* surfaces. So far no blitting operations using surfaces in the bltfx
* struct are supported anyway. */
hr = wined3d_surface_blt(This->wined3d_surface, DestRect, Src ? Src->wined3d_surface : NULL,
SrcRect, Flags, (WINEDDBLTFX *)DDBltFx, WINED3DTEXF_LINEAR);
LeaveCriticalSection(&ddraw_cs);
switch(hr)
@ -927,7 +871,7 @@ static HRESULT WINAPI ddraw_surface7_Blt(IDirectDrawSurface7 *iface, RECT *DestR
static HRESULT WINAPI ddraw_surface3_Blt(IDirectDrawSurface3 *iface, RECT *dst_rect,
IDirectDrawSurface3 *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx)
{
TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %p, flags %#x, fx %p.\n",
TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n",
iface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect), flags, fx);
return ddraw_surface7_Blt((IDirectDrawSurface7 *)surface_from_surface3(iface), dst_rect,
@ -1199,8 +1143,7 @@ static HRESULT WINAPI ddraw_surface7_GetDC(IDirectDrawSurface7 *iface, HDC *hdc)
return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DSurface_GetDC(This->WineD3DSurface,
hdc);
hr = wined3d_surface_getdc(This->wined3d_surface, hdc);
LeaveCriticalSection(&ddraw_cs);
switch(hr)
{
@ -1243,7 +1186,7 @@ static HRESULT WINAPI ddraw_surface7_ReleaseDC(IDirectDrawSurface7 *iface, HDC h
TRACE("iface %p, dc %p.\n", iface, hdc);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DSurface_ReleaseDC(This->WineD3DSurface, hdc);
hr = wined3d_surface_releasedc(This->wined3d_surface, hdc);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@ -1316,7 +1259,7 @@ static HRESULT WINAPI ddraw_surface7_SetPriority(IDirectDrawSurface7 *iface, DWO
TRACE("iface %p, priority %u.\n", iface, Priority);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DSurface_SetPriority(This->WineD3DSurface, Priority);
hr = wined3d_surface_set_priority(This->wined3d_surface, Priority);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@ -1347,7 +1290,7 @@ static HRESULT WINAPI ddraw_surface7_GetPriority(IDirectDrawSurface7 *iface, DWO
}
EnterCriticalSection(&ddraw_cs);
*Priority = IWineD3DSurface_GetPriority(This->WineD3DSurface);
*Priority = wined3d_surface_get_priority(This->wined3d_surface);
LeaveCriticalSection(&ddraw_cs);
return DD_OK;
}
@ -1379,11 +1322,7 @@ static HRESULT WINAPI ddraw_surface7_SetPrivateData(IDirectDrawSurface7 *iface,
iface, debugstr_guid(tag), Data, Size, Flags);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DSurface_SetPrivateData(This->WineD3DSurface,
tag,
Data,
Size,
Flags);
hr = wined3d_surface_set_private_data(This->wined3d_surface, tag, Data, Size, Flags);
LeaveCriticalSection(&ddraw_cs);
switch(hr)
{
@ -1420,10 +1359,7 @@ static HRESULT WINAPI ddraw_surface7_GetPrivateData(IDirectDrawSurface7 *iface,
return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DSurface_GetPrivateData(This->WineD3DSurface,
tag,
Data,
Size);
hr = wined3d_surface_get_private_data(This->wined3d_surface, tag, Data, Size);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@ -1449,7 +1385,7 @@ static HRESULT WINAPI ddraw_surface7_FreePrivateData(IDirectDrawSurface7 *iface,
TRACE("iface %p, tag %s.\n", iface, debugstr_guid(tag));
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DSurface_FreePrivateData(This->WineD3DSurface, tag);
hr = wined3d_surface_free_private_data(This->wined3d_surface, tag);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@ -1680,7 +1616,7 @@ static HRESULT WINAPI ddraw_surface7_GetBltStatus(IDirectDrawSurface7 *iface, DW
TRACE("iface %p, flags %#x.\n", iface, Flags);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DSurface_GetBltStatus(This->WineD3DSurface, Flags);
hr = wined3d_surface_get_blt_status(This->wined3d_surface, Flags);
LeaveCriticalSection(&ddraw_cs);
switch(hr)
{
@ -1795,7 +1731,7 @@ static HRESULT WINAPI ddraw_surface7_GetFlipStatus(IDirectDrawSurface7 *iface, D
TRACE("iface %p, flags %#x.\n", iface, Flags);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DSurface_GetFlipStatus(This->WineD3DSurface, Flags);
hr = wined3d_surface_get_flip_status(This->wined3d_surface, Flags);
LeaveCriticalSection(&ddraw_cs);
switch(hr)
{
@ -1831,9 +1767,7 @@ static HRESULT WINAPI ddraw_surface7_GetOverlayPosition(IDirectDrawSurface7 *ifa
TRACE("iface %p, x %p, y %p.\n", iface, X, Y);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DSurface_GetOverlayPosition(This->WineD3DSurface,
X,
Y);
hr = wined3d_surface_get_overlay_position(This->wined3d_surface, X, Y);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@ -2029,7 +1963,7 @@ static HRESULT WINAPI ddraw_surface7_IsLost(IDirectDrawSurface7 *iface)
return DDERR_SURFACELOST;
}
hr = IWineD3DSurface_IsLost(This->WineD3DSurface);
hr = wined3d_surface_is_lost(This->wined3d_surface);
LeaveCriticalSection(&ddraw_cs);
switch(hr)
{
@ -2073,7 +2007,7 @@ static HRESULT WINAPI ddraw_surface7_Restore(IDirectDrawSurface7 *iface)
IDirectDrawSurface_AddRef(iface);
ddraw_recreate_surfaces_cb(iface, &This->surface_desc, NULL /* Not needed */);
}
hr = IWineD3DSurface_Restore(This->WineD3DSurface);
hr = wined3d_surface_restore(This->wined3d_surface);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@ -2105,9 +2039,7 @@ static HRESULT WINAPI ddraw_surface7_SetOverlayPosition(IDirectDrawSurface7 *ifa
TRACE("iface %p, x %d, y %d.\n", iface, X, Y);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DSurface_SetOverlayPosition(This->WineD3DSurface,
X,
Y);
hr = wined3d_surface_set_overlay_position(This->wined3d_surface, X, Y);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@ -2145,12 +2077,8 @@ static HRESULT WINAPI ddraw_surface7_UpdateOverlay(IDirectDrawSurface7 *iface, R
iface, wine_dbgstr_rect(SrcRect), DstSurface, wine_dbgstr_rect(DstRect), Flags, FX);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DSurface_UpdateOverlay(This->WineD3DSurface,
SrcRect,
Dst ? Dst->WineD3DSurface : NULL,
DstRect,
Flags,
(WINEDDOVERLAYFX *) FX);
hr = wined3d_surface_update_overlay(This->wined3d_surface, SrcRect,
Dst ? Dst->wined3d_surface : NULL, DstRect, Flags, (WINEDDOVERLAYFX *)FX);
LeaveCriticalSection(&ddraw_cs);
switch(hr) {
case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
@ -2219,9 +2147,8 @@ static HRESULT WINAPI ddraw_surface7_UpdateOverlayZOrder(IDirectDrawSurface7 *if
TRACE("iface %p, flags %#x, reference %p.\n", iface, Flags, DDSRef);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DSurface_UpdateOverlayZOrder(This->WineD3DSurface,
Flags,
Ref ? Ref->WineD3DSurface : NULL);
hr = wined3d_surface_update_overlay_z_order(This->wined3d_surface,
Flags, Ref ? Ref->wined3d_surface : NULL);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@ -2261,19 +2188,19 @@ static HRESULT WINAPI ddraw_surface7_GetDDInterface(IDirectDrawSurface7 *iface,
switch(This->version)
{
case 7:
*DD = This->ddraw;
*DD = &This->ddraw->IDirectDraw7_iface;
break;
case 4:
*DD = &This->ddraw->IDirectDraw4_vtbl;
*DD = &This->ddraw->IDirectDraw4_iface;
break;
case 2:
*DD = &This->ddraw->IDirectDraw2_vtbl;
*DD = &This->ddraw->IDirectDraw2_iface;
break;
case 1:
*DD = &This->ddraw->IDirectDraw_vtbl;
*DD = &This->ddraw->IDirectDraw_iface;
break;
}
@ -2359,15 +2286,14 @@ static HRESULT WINAPI ddraw_surface7_SetLOD(IDirectDrawSurface7 *iface, DWORD Ma
return DDERR_INVALIDOBJECT;
}
if(!This->wineD3DTexture)
if (!This->wined3d_texture)
{
ERR("(%p) The DirectDraw texture has no WineD3DTexture!\n", This);
LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDOBJECT;
}
hr = IWineD3DBaseTexture_SetLOD(This->wineD3DTexture,
MaxLOD);
hr = wined3d_texture_set_lod(This->wined3d_texture, MaxLOD);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@ -2402,7 +2328,7 @@ static HRESULT WINAPI ddraw_surface7_GetLOD(IDirectDrawSurface7 *iface, DWORD *M
return DDERR_INVALIDOBJECT;
}
*MaxLOD = IWineD3DBaseTexture_GetLOD(This->wineD3DTexture);
*MaxLOD = wined3d_texture_get_lod(This->wined3d_texture);
LeaveCriticalSection(&ddraw_cs);
return DD_OK;
}
@ -2468,11 +2394,8 @@ static HRESULT WINAPI ddraw_surface7_BltFast(IDirectDrawSurface7 *iface, DWORD d
}
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DSurface_BltFast(This->WineD3DSurface,
dstx, dsty,
src ? src->WineD3DSurface : NULL,
rsrc,
trans);
hr = wined3d_surface_bltfast(This->wined3d_surface, dstx, dsty,
src ? src->wined3d_surface : NULL, rsrc, trans);
LeaveCriticalSection(&ddraw_cs);
switch(hr)
{
@ -2574,21 +2497,20 @@ static HRESULT WINAPI ddraw_surface7_SetClipper(IDirectDrawSurface7 *iface, IDir
if(oldClipper)
IDirectDrawClipper_Release((IDirectDrawClipper *)oldClipper);
hr = IWineD3DSurface_SetClipper(This->WineD3DSurface, This->clipper ? This->clipper->wineD3DClipper : NULL);
hr = wined3d_surface_set_clipper(This->wined3d_surface,
This->clipper ? This->clipper->wineD3DClipper : NULL);
if(This->wineD3DSwapChain) {
if (This->wined3d_swapchain)
{
clipWindow = NULL;
if(Clipper) {
IDirectDrawClipper_GetHWnd(Clipper, &clipWindow);
}
if(clipWindow) {
IWineD3DSwapChain_SetDestWindowOverride(This->wineD3DSwapChain,
clipWindow);
} else {
IWineD3DSwapChain_SetDestWindowOverride(This->wineD3DSwapChain,
This->ddraw->d3d_window);
}
if (clipWindow)
wined3d_swapchain_set_window(This->wined3d_swapchain, clipWindow);
else
wined3d_swapchain_set_window(This->wined3d_swapchain, This->ddraw->d3d_window);
}
LeaveCriticalSection(&ddraw_cs);
@ -2642,9 +2564,8 @@ static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface,
}
if(newFormat != PixelFormat_DD2WineD3D(&This->surface_desc.u4.ddpfPixelFormat) )
{
hr = IWineD3DSurface_SetFormat(This->WineD3DSurface,
newFormat);
if(hr != DD_OK)
hr = wined3d_surface_set_format(This->wined3d_surface, newFormat);
if (FAILED(hr))
{
LeaveCriticalSection(&ddraw_cs);
return hr;
@ -2653,32 +2574,28 @@ static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface,
}
if (DDSD->dwFlags & DDSD_CKDESTOVERLAY)
{
IWineD3DSurface_SetColorKey(This->WineD3DSurface,
DDCKEY_DESTOVERLAY,
(WINEDDCOLORKEY *) &DDSD->u3.ddckCKDestOverlay);
wined3d_surface_set_color_key(This->wined3d_surface, DDCKEY_DESTOVERLAY,
(WINEDDCOLORKEY *)&DDSD->u3.ddckCKDestOverlay);
}
if (DDSD->dwFlags & DDSD_CKDESTBLT)
{
IWineD3DSurface_SetColorKey(This->WineD3DSurface,
DDCKEY_DESTBLT,
(WINEDDCOLORKEY *) &DDSD->ddckCKDestBlt);
wined3d_surface_set_color_key(This->wined3d_surface, DDCKEY_DESTBLT,
(WINEDDCOLORKEY *)&DDSD->ddckCKDestBlt);
}
if (DDSD->dwFlags & DDSD_CKSRCOVERLAY)
{
IWineD3DSurface_SetColorKey(This->WineD3DSurface,
DDCKEY_SRCOVERLAY,
(WINEDDCOLORKEY *) &DDSD->ddckCKSrcOverlay);
wined3d_surface_set_color_key(This->wined3d_surface, DDCKEY_SRCOVERLAY,
(WINEDDCOLORKEY *)&DDSD->ddckCKSrcOverlay);
}
if (DDSD->dwFlags & DDSD_CKSRCBLT)
{
IWineD3DSurface_SetColorKey(This->WineD3DSurface,
DDCKEY_SRCBLT,
(WINEDDCOLORKEY *) &DDSD->ddckCKSrcBlt);
wined3d_surface_set_color_key(This->wined3d_surface, DDCKEY_SRCBLT,
(WINEDDCOLORKEY *)&DDSD->ddckCKSrcBlt);
}
if (DDSD->dwFlags & DDSD_LPSURFACE && DDSD->lpSurface)
{
hr = IWineD3DSurface_SetMem(This->WineD3DSurface, DDSD->lpSurface);
if(hr != WINED3D_OK)
hr = wined3d_surface_set_mem(This->wined3d_surface, DDSD->lpSurface);
if (FAILED(hr))
{
/* No need for a trace here, wined3d does that for us */
switch(hr)
@ -2724,8 +2641,8 @@ static HRESULT WINAPI ddraw_surface3_SetSurfaceDesc(IDirectDrawSurface3 *iface,
static HRESULT WINAPI ddraw_surface7_GetPalette(IDirectDrawSurface7 *iface, IDirectDrawPalette **Pal)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IWineD3DPalette *wPal;
HRESULT hr;
struct wined3d_palette *wined3d_palette;
HRESULT hr = DD_OK;
TRACE("iface %p, palette %p.\n", iface, Pal);
@ -2733,16 +2650,10 @@ static HRESULT WINAPI ddraw_surface7_GetPalette(IDirectDrawSurface7 *iface, IDir
return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DSurface_GetPalette(This->WineD3DSurface, &wPal);
if(hr != DD_OK)
wined3d_palette = wined3d_surface_get_palette(This->wined3d_surface);
if (wined3d_palette)
{
LeaveCriticalSection(&ddraw_cs);
return hr;
}
if(wPal)
{
*Pal = IWineD3DPalette_GetParent(wPal);
*Pal = wined3d_palette_get_parent(wined3d_palette);
IDirectDrawPalette_AddRef(*Pal);
}
else
@ -2785,10 +2696,8 @@ SetColorKeyEnum(IDirectDrawSurface7 *surface,
struct SCKContext *ctx = context;
HRESULT hr;
hr = IWineD3DSurface_SetColorKey(This->WineD3DSurface,
ctx->Flags,
ctx->CKey);
if(hr != DD_OK)
hr = wined3d_surface_set_color_key(This->wined3d_surface, ctx->Flags, ctx->CKey);
if (FAILED(hr))
{
WARN("IWineD3DSurface_SetColorKey failed, hr = %08x\n", hr);
ctx->ret = hr;
@ -2884,7 +2793,7 @@ static HRESULT WINAPI ddraw_surface7_SetColorKey(IDirectDrawSurface7 *iface, DWO
return DDERR_INVALIDPARAMS;
}
}
ctx.ret = IWineD3DSurface_SetColorKey(This->WineD3DSurface, Flags, ctx.CKey);
ctx.ret = wined3d_surface_set_color_key(This->wined3d_surface, Flags, ctx.CKey);
ddraw_surface7_EnumAttachedSurfaces(iface, &ctx, SetColorKeyEnum);
LeaveCriticalSection(&ddraw_cs);
switch(ctx.ret)
@ -2939,8 +2848,7 @@ static HRESULT WINAPI ddraw_surface7_SetPalette(IDirectDrawSurface7 *iface, IDir
if(oldPal) IDirectDrawPalette_Release(oldPal); /* For the GetPalette */
/* Set the new Palette */
IWineD3DSurface_SetPalette(This->WineD3DSurface,
PalImpl ? PalImpl->wineD3DPalette : NULL);
wined3d_surface_set_palette(This->wined3d_surface, PalImpl ? PalImpl->wineD3DPalette : NULL);
/* AddRef the Palette */
if(Pal) IDirectDrawPalette_AddRef(Pal);
@ -3015,7 +2923,7 @@ static HRESULT WINAPI ddraw_gamma_control_GetGammaRamp(IDirectDrawGammaControl *
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
/* Note: DDGAMMARAMP is compatible with WINED3DGAMMARAMP. */
IWineD3DDevice_GetGammaRamp(surface->ddraw->wineD3DDevice, 0, (WINED3DGAMMARAMP *)gamma_ramp);
wined3d_device_get_gamma_ramp(surface->ddraw->wined3d_device, 0, (WINED3DGAMMARAMP *)gamma_ramp);
}
else
{
@ -3057,7 +2965,7 @@ static HRESULT WINAPI ddraw_gamma_control_SetGammaRamp(IDirectDrawGammaControl *
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
/* Note: DDGAMMARAMP is compatible with WINED3DGAMMARAMP */
IWineD3DDevice_SetGammaRamp(surface->ddraw->wineD3DDevice, 0, flags, (WINED3DGAMMARAMP *)gamma_ramp);
wined3d_device_set_gamma_ramp(surface->ddraw->wined3d_device, 0, flags, (WINED3DGAMMARAMP *)gamma_ramp);
}
else
{
@ -3234,7 +3142,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
for (;;)
{
IWineD3DPalette *wined3d_dst_pal, *wined3d_src_pal;
struct wined3d_palette *wined3d_dst_pal, *wined3d_src_pal;
IDirectDrawPalette *dst_pal = NULL, *src_pal = NULL;
DDSURFACEDESC *src_desc, *dst_desc;
@ -3245,23 +3153,13 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
dst_surface->surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_ALLOCONLOAD;
/* Get the palettes */
hr = IWineD3DSurface_GetPalette(dst_surface->WineD3DSurface, &wined3d_dst_pal);
if (FAILED(hr))
{
ERR("Failed to get destination palette, hr %#x.\n", hr);
LeaveCriticalSection(&ddraw_cs);
return D3DERR_TEXTURE_LOAD_FAILED;
}
if (wined3d_dst_pal) dst_pal = IWineD3DPalette_GetParent(wined3d_dst_pal);
wined3d_dst_pal = wined3d_surface_get_palette(dst_surface->wined3d_surface);
if (wined3d_dst_pal)
dst_pal = wined3d_palette_get_parent(wined3d_dst_pal);
hr = IWineD3DSurface_GetPalette(src_surface->WineD3DSurface, &wined3d_src_pal);
if (FAILED(hr))
{
ERR("Failed to get source palette, hr %#x.\n", hr);
LeaveCriticalSection(&ddraw_cs);
return D3DERR_TEXTURE_LOAD_FAILED;
}
if (wined3d_src_pal) src_pal = IWineD3DPalette_GetParent(wined3d_src_pal);
wined3d_src_pal = wined3d_surface_get_palette(src_surface->wined3d_surface);
if (wined3d_src_pal)
src_pal = wined3d_palette_get_parent(wined3d_src_pal);
if (src_pal)
{
@ -3302,7 +3200,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
/* Copy the main memory texture into the surface that corresponds
* to the OpenGL texture object. */
hr = IWineD3DSurface_LockRect(src_surface->WineD3DSurface, &src_rect, NULL, 0);
hr = wined3d_surface_map(src_surface->wined3d_surface, &src_rect, NULL, 0);
if (FAILED(hr))
{
ERR("Failed to lock source surface, hr %#x.\n", hr);
@ -3310,11 +3208,11 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
return D3DERR_TEXTURE_LOAD_FAILED;
}
hr = IWineD3DSurface_LockRect(dst_surface->WineD3DSurface, &dst_rect, NULL, 0);
hr = wined3d_surface_map(dst_surface->wined3d_surface, &dst_rect, NULL, 0);
if (FAILED(hr))
{
ERR("Failed to lock destination surface, hr %#x.\n", hr);
IWineD3DSurface_UnlockRect(src_surface->WineD3DSurface);
wined3d_surface_unmap(src_surface->wined3d_surface);
LeaveCriticalSection(&ddraw_cs);
return D3DERR_TEXTURE_LOAD_FAILED;
}
@ -3324,8 +3222,8 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
else
memcpy(dst_rect.pBits, src_rect.pBits, src_rect.Pitch * src_desc->dwHeight);
IWineD3DSurface_UnlockRect(src_surface->WineD3DSurface);
IWineD3DSurface_UnlockRect(dst_surface->WineD3DSurface);
wined3d_surface_unmap(src_surface->wined3d_surface);
wined3d_surface_unmap(dst_surface->wined3d_surface);
}
if (src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
@ -3501,11 +3399,103 @@ static const struct IDirect3DTextureVtbl d3d_texture1_vtbl =
d3d_texture1_Unload,
};
static void STDMETHODCALLTYPE ddraw_surface_wined3d_object_destroyed(void *parent)
{
IDirectDrawSurfaceImpl *surface = parent;
TRACE("surface %p.\n", surface);
/* Check for attached surfaces and detach them. */
if (surface->first_attached != surface)
{
IDirectDrawSurface7 *root = (IDirectDrawSurface7 *)surface->first_attached;
IDirectDrawSurface7 *detach = (IDirectDrawSurface7 *)surface;
/* Well, this shouldn't happen: The surface being attached is
* referenced in AddAttachedSurface(), so it shouldn't be released
* until DeleteAttachedSurface() is called, because the refcount is
* held. It looks like the application released it often enough to
* force this. */
WARN("Surface is still attached to surface %p.\n", surface->first_attached);
/* The refcount will drop to -1 here */
if (FAILED(IDirectDrawSurface7_DeleteAttachedSurface(root, 0, detach)))
ERR("DeleteAttachedSurface failed.\n");
}
while (surface->next_attached)
{
IDirectDrawSurface7 *root = (IDirectDrawSurface7 *)surface;
IDirectDrawSurface7 *detach = (IDirectDrawSurface7 *)surface->next_attached;
if (FAILED(IDirectDrawSurface7_DeleteAttachedSurface(root, 0, detach)))
ERR("DeleteAttachedSurface failed.\n");
}
/* Having a texture handle set implies that the device still exists. */
if (surface->Handle)
ddraw_free_handle(&surface->ddraw->d3ddevice->handle_table, surface->Handle - 1, DDRAW_HANDLE_SURFACE);
/* Reduce the ddraw surface count. */
InterlockedDecrement(&surface->ddraw->surfaces);
list_remove(&surface->surface_list_entry);
HeapFree(GetProcessHeap(), 0, surface);
}
const struct wined3d_parent_ops ddraw_surface_wined3d_parent_ops =
{
ddraw_surface_wined3d_object_destroyed,
};
static void STDMETHODCALLTYPE ddraw_texture_wined3d_object_destroyed(void *parent)
{
IDirectDrawSurfaceImpl *surface = parent;
TRACE("surface %p.\n", surface);
ddraw_surface_cleanup(surface);
}
static const struct wined3d_parent_ops ddraw_texture_wined3d_parent_ops =
{
ddraw_texture_wined3d_object_destroyed,
};
HRESULT ddraw_surface_create_texture(IDirectDrawSurfaceImpl *surface)
{
const DDSURFACEDESC2 *desc = &surface->surface_desc;
enum wined3d_format_id format;
WINED3DPOOL pool;
UINT levels;
if (desc->ddsCaps.dwCaps & DDSCAPS_MIPMAP)
levels = desc->u2.dwMipMapCount;
else
levels = 1;
/* DDSCAPS_SYSTEMMEMORY textures are in WINED3DPOOL_SYSTEMMEM.
* Should I forward the MANAGED cap to the managed pool? */
if (desc->ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY)
pool = WINED3DPOOL_SYSTEMMEM;
else
pool = WINED3DPOOL_DEFAULT;
format = PixelFormat_DD2WineD3D(&surface->surface_desc.u4.ddpfPixelFormat);
if (desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
return wined3d_texture_create_cube(surface->ddraw->wined3d_device, desc->dwWidth,
levels, 0, format, pool, surface, &ddraw_texture_wined3d_parent_ops, &surface->wined3d_texture);
else
return wined3d_texture_create_2d(surface->ddraw->wined3d_device, desc->dwWidth, desc->dwHeight,
levels, 0, format, pool, surface, &ddraw_texture_wined3d_parent_ops, &surface->wined3d_texture);
}
HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface, IDirectDrawImpl *ddraw,
DDSURFACEDESC2 *desc, UINT mip_level, WINED3DSURFTYPE surface_type)
{
struct wined3d_resource_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
WINED3DPOOL pool = WINED3DPOOL_DEFAULT;
WINED3DSURFACE_DESC wined3d_desc;
enum wined3d_format_id format;
DWORD usage = 0;
HRESULT hr;
@ -3519,12 +3509,17 @@ HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface, IDirectDrawImpl *ddr
desc->ddsCaps.dwCaps |= DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY;
}
if (desc->ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE))
if (desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
usage |= WINED3DUSAGE_RENDERTARGET;
desc->ddsCaps.dwCaps |= DDSCAPS_VISIBLE;
}
if ((desc->ddsCaps.dwCaps & DDSCAPS_3DDEVICE) && !(desc->ddsCaps.dwCaps & DDSCAPS_ZBUFFER))
{
usage |= WINED3DUSAGE_RENDERTARGET;
}
if (desc->ddsCaps.dwCaps & (DDSCAPS_OVERLAY))
{
usage |= WINED3DUSAGE_OVERLAY;
@ -3570,17 +3565,15 @@ HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface, IDirectDrawImpl *ddr
surface->version = 7;
surface->ddraw = ddraw;
surface->surface_desc.dwSize = sizeof(DDSURFACEDESC2);
surface->surface_desc.u4.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
DD_STRUCT_COPY_BYSIZE(&surface->surface_desc, desc);
copy_to_surfacedesc2(&surface->surface_desc, desc);
surface->first_attached = surface;
surface->ImplType = surface_type;
hr = IWineD3DDevice_CreateSurface(ddraw->wineD3DDevice, desc->dwWidth, desc->dwHeight, format,
hr = wined3d_surface_create(ddraw->wined3d_device, desc->dwWidth, desc->dwHeight, format,
TRUE /* Lockable */, FALSE /* Discard */, mip_level, usage, pool,
WINED3DMULTISAMPLE_NONE, 0 /* MultiSampleQuality */, surface_type, surface,
&ddraw_null_wined3d_parent_ops, &surface->WineD3DSurface);
&ddraw_surface_wined3d_parent_ops, &surface->wined3d_surface);
if (FAILED(hr))
{
WARN("Failed to create wined3d surface, hr %#x.\n", hr);
@ -3588,7 +3581,8 @@ HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface, IDirectDrawImpl *ddr
}
surface->surface_desc.dwFlags |= DDSD_PIXELFORMAT;
IWineD3DSurface_GetDesc(surface->WineD3DSurface, &wined3d_desc);
wined3d_resource = wined3d_surface_get_resource(surface->wined3d_surface);
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
format = wined3d_desc.format;
if (format == WINED3DFMT_UNKNOWN)
@ -3615,36 +3609,36 @@ HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface, IDirectDrawImpl *ddr
else
{
surface->surface_desc.dwFlags |= DDSD_PITCH;
surface->surface_desc.u1.lPitch = IWineD3DSurface_GetPitch(surface->WineD3DSurface);
surface->surface_desc.u1.lPitch = wined3d_surface_get_pitch(surface->wined3d_surface);
}
if (desc->dwFlags & DDSD_CKDESTOVERLAY)
{
IWineD3DSurface_SetColorKey(surface->WineD3DSurface,
DDCKEY_DESTOVERLAY, (WINEDDCOLORKEY *)&desc->u3.ddckCKDestOverlay);
wined3d_surface_set_color_key(surface->wined3d_surface, DDCKEY_DESTOVERLAY,
(WINEDDCOLORKEY *)&desc->u3.ddckCKDestOverlay);
}
if (desc->dwFlags & DDSD_CKDESTBLT)
{
IWineD3DSurface_SetColorKey(surface->WineD3DSurface,
DDCKEY_DESTBLT, (WINEDDCOLORKEY *)&desc->ddckCKDestBlt);
wined3d_surface_set_color_key(surface->wined3d_surface, DDCKEY_DESTBLT,
(WINEDDCOLORKEY *)&desc->ddckCKDestBlt);
}
if (desc->dwFlags & DDSD_CKSRCOVERLAY)
{
IWineD3DSurface_SetColorKey(surface->WineD3DSurface,
DDCKEY_SRCOVERLAY, (WINEDDCOLORKEY *)&desc->ddckCKSrcOverlay);
wined3d_surface_set_color_key(surface->wined3d_surface, DDCKEY_SRCOVERLAY,
(WINEDDCOLORKEY *)&desc->ddckCKSrcOverlay);
}
if (desc->dwFlags & DDSD_CKSRCBLT)
{
IWineD3DSurface_SetColorKey(surface->WineD3DSurface,
DDCKEY_SRCBLT, (WINEDDCOLORKEY *)&desc->ddckCKSrcBlt);
wined3d_surface_set_color_key(surface->wined3d_surface, DDCKEY_SRCBLT,
(WINEDDCOLORKEY *)&desc->ddckCKSrcBlt);
}
if (desc->dwFlags & DDSD_LPSURFACE)
{
hr = IWineD3DSurface_SetMem(surface->WineD3DSurface, desc->lpSurface);
hr = wined3d_surface_set_mem(surface->wined3d_surface, desc->lpSurface);
if (FAILED(hr))
{
ERR("Failed to set surface memory, hr %#x.\n", hr);
IWineD3DSurface_Release(surface->WineD3DSurface);
wined3d_surface_decref(surface->wined3d_surface);
return hr;
}
}

View file

@ -1172,30 +1172,6 @@ multiply_matrix(D3DMATRIX *dest,
memcpy(dest, &temp, 16 * sizeof(D3DVALUE));
}
void multiply_matrix_D3D_way(D3DMATRIX* result, const D3DMATRIX *m1, const D3DMATRIX *m2)
{
D3DMATRIX temp;
temp._11 = m1->_11 * m2->_11 + m1->_12 * m2->_21 + m1->_13 * m2->_31 + m1->_14 * m2->_41;
temp._12 = m1->_11 * m2->_12 + m1->_12 * m2->_22 + m1->_13 * m2->_32 + m1->_14 * m2->_42;
temp._13 = m1->_11 * m2->_13 + m1->_12 * m2->_23 + m1->_13 * m2->_33 + m1->_14 * m2->_43;
temp._14 = m1->_11 * m2->_14 + m1->_12 * m2->_24 + m1->_13 * m2->_34 + m1->_14 * m2->_44;
temp._21 = m1->_21 * m2->_11 + m1->_22 * m2->_21 + m1->_23 * m2->_31 + m1->_24 * m2->_41;
temp._22 = m1->_21 * m2->_12 + m1->_22 * m2->_22 + m1->_23 * m2->_32 + m1->_24 * m2->_42;
temp._23 = m1->_21 * m2->_13 + m1->_22 * m2->_23 + m1->_23 * m2->_33 + m1->_24 * m2->_43;
temp._24 = m1->_21 * m2->_14 + m1->_22 * m2->_24 + m1->_23 * m2->_34 + m1->_24 * m2->_44;
temp._31 = m1->_31 * m2->_11 + m1->_32 * m2->_21 + m1->_33 * m2->_31 + m1->_34 * m2->_41;
temp._32 = m1->_31 * m2->_12 + m1->_32 * m2->_22 + m1->_33 * m2->_32 + m1->_34 * m2->_42;
temp._33 = m1->_31 * m2->_13 + m1->_32 * m2->_23 + m1->_33 * m2->_33 + m1->_34 * m2->_43;
temp._34 = m1->_31 * m2->_14 + m1->_32 * m2->_24 + m1->_33 * m2->_34 + m1->_34 * m2->_44;
temp._41 = m1->_41 * m2->_11 + m1->_42 * m2->_21 + m1->_43 * m2->_31 + m1->_44 * m2->_41;
temp._42 = m1->_41 * m2->_12 + m1->_42 * m2->_22 + m1->_43 * m2->_32 + m1->_44 * m2->_42;
temp._43 = m1->_41 * m2->_13 + m1->_42 * m2->_23 + m1->_43 * m2->_33 + m1->_44 * m2->_43;
temp._44 = m1->_41 * m2->_14 + m1->_42 * m2->_24 + m1->_43 * m2->_34 + m1->_44 * m2->_44;
*result = temp;
}
HRESULT
hr_ddraw_from_wined3d(HRESULT hr)
{

View file

@ -82,10 +82,8 @@ IDirect3DVertexBufferImpl_QueryInterface(IDirect3DVertexBuffer7 *iface,
return E_NOINTERFACE;
}
static HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_QueryInterface(IDirect3DVertexBuffer *iface,
REFIID riid,
void **obj)
static HRESULT WINAPI IDirect3DVertexBufferImpl_1_QueryInterface(IDirect3DVertexBuffer *iface,
REFIID riid, void **obj)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), obj);
@ -112,8 +110,7 @@ IDirect3DVertexBufferImpl_AddRef(IDirect3DVertexBuffer7 *iface)
return ref;
}
static ULONG WINAPI
Thunk_IDirect3DVertexBufferImpl_1_AddRef(IDirect3DVertexBuffer *iface)
static ULONG WINAPI IDirect3DVertexBufferImpl_1_AddRef(IDirect3DVertexBuffer *iface)
{
TRACE("iface %p.\n", iface);
@ -140,34 +137,23 @@ IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface)
if (ref == 0)
{
IWineD3DBuffer *curVB = NULL;
struct wined3d_buffer *curVB = NULL;
UINT offset, stride;
EnterCriticalSection(&ddraw_cs);
/* D3D7 Vertex buffers don't stay bound in the device, they are passed as a parameter
* to drawPrimitiveVB. DrawPrimitiveVB sets them as the stream source in wined3d,
* and they should get unset there before they are destroyed
*/
IWineD3DDevice_GetStreamSource(This->ddraw->wineD3DDevice,
0 /* Stream number */,
&curVB,
&offset,
&stride);
if(curVB == This->wineD3DVertexBuffer)
{
IWineD3DDevice_SetStreamSource(This->ddraw->wineD3DDevice,
0 /* Steam number */,
NULL /* stream data */,
0 /* Offset */,
0 /* stride */);
}
if(curVB)
{
IWineD3DBuffer_Release(curVB); /* For the GetStreamSource */
}
/* D3D7 Vertex buffers don't stay bound in the device, they are passed
* as a parameter to drawPrimitiveVB. DrawPrimitiveVB sets them as the
* stream source in wined3d, and they should get unset there before
* they are destroyed. */
wined3d_device_get_stream_source(This->ddraw->wined3d_device,
0, &curVB, &offset, &stride);
if (curVB == This->wineD3DVertexBuffer)
wined3d_device_set_stream_source(This->ddraw->wined3d_device, 0, NULL, 0, 0);
if (curVB)
wined3d_buffer_decref(curVB); /* For the GetStreamSource */
IWineD3DVertexDeclaration_Release(This->wineD3DVertexDeclaration);
IWineD3DBuffer_Release(This->wineD3DVertexBuffer);
wined3d_vertex_declaration_decref(This->wineD3DVertexDeclaration);
wined3d_buffer_decref(This->wineD3DVertexBuffer);
LeaveCriticalSection(&ddraw_cs);
HeapFree(GetProcessHeap(), 0, This);
@ -176,8 +162,7 @@ IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface)
return ref;
}
static ULONG WINAPI
Thunk_IDirect3DVertexBufferImpl_1_Release(IDirect3DVertexBuffer *iface)
static ULONG WINAPI IDirect3DVertexBufferImpl_1_Release(IDirect3DVertexBuffer *iface)
{
TRACE("iface %p.\n", iface);
@ -214,7 +199,8 @@ IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface,
DWORD *Size)
{
IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
WINED3DBUFFER_DESC Desc;
struct wined3d_resource_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
HRESULT hr;
DWORD wined3d_flags = 0;
@ -232,21 +218,18 @@ IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface,
if(Size)
{
/* Get the size, for returning it, and for locking */
IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &Desc);
*Size = Desc.Size;
wined3d_resource = wined3d_buffer_get_resource(This->wineD3DVertexBuffer);
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
*Size = wined3d_desc.size;
}
hr = IWineD3DBuffer_Map(This->wineD3DVertexBuffer, 0 /* OffsetToLock */,
0 /* SizeToLock, 0 == Full lock */, (BYTE **)Data, wined3d_flags);
hr = wined3d_buffer_map(This->wineD3DVertexBuffer, 0, 0, (BYTE **)Data, wined3d_flags);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
static HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_Lock(IDirect3DVertexBuffer *iface,
DWORD Flags,
void **Data,
DWORD *Size)
static HRESULT WINAPI IDirect3DVertexBufferImpl_1_Lock(IDirect3DVertexBuffer *iface, DWORD Flags,
void **Data, DWORD *Size)
{
TRACE("iface %p, flags %#x, data %p, data_size %p.\n", iface, Flags, Data, Size);
@ -266,19 +249,17 @@ static HRESULT WINAPI
IDirect3DVertexBufferImpl_Unlock(IDirect3DVertexBuffer7 *iface)
{
IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
HRESULT hr;
TRACE("iface %p.\n", iface);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DBuffer_Unmap(This->wineD3DVertexBuffer);
wined3d_buffer_unmap(This->wineD3DVertexBuffer);
LeaveCriticalSection(&ddraw_cs);
return hr;
return D3D_OK;
}
static HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_Unlock(IDirect3DVertexBuffer *iface)
static HRESULT WINAPI IDirect3DVertexBufferImpl_1_Unlock(IDirect3DVertexBuffer *iface)
{
TRACE("iface %p.\n", iface);
@ -345,50 +326,26 @@ IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface,
* the vertex ops
*/
doClip = VertexOp & D3DVOP_CLIP ? TRUE : FALSE;
IWineD3DDevice_GetRenderState(D3D->wineD3DDevice,
WINED3DRS_CLIPPING,
(DWORD *) &oldClip);
if(doClip != oldClip)
{
IWineD3DDevice_SetRenderState(D3D->wineD3DDevice,
WINED3DRS_CLIPPING,
doClip);
}
wined3d_device_get_render_state(D3D->wined3d_device, WINED3DRS_CLIPPING, (DWORD *)&oldClip);
if (doClip != oldClip)
wined3d_device_set_render_state(D3D->wined3d_device, WINED3DRS_CLIPPING, doClip);
IWineD3DDevice_SetStreamSource(D3D->wineD3DDevice,
0, /* Stream No */
Src->wineD3DVertexBuffer,
0, /* Offset */
get_flexible_vertex_size(Src->fvf));
IWineD3DDevice_SetVertexDeclaration(D3D->wineD3DDevice,
Src->wineD3DVertexDeclaration);
hr = IWineD3DDevice_ProcessVertices(D3D->wineD3DDevice,
SrcIndex,
DestIndex,
Count,
This->wineD3DVertexBuffer,
NULL /* Output vdecl */,
Flags,
This->fvf);
wined3d_device_set_stream_source(D3D->wined3d_device,
0, Src->wineD3DVertexBuffer, 0, get_flexible_vertex_size(Src->fvf));
wined3d_device_set_vertex_declaration(D3D->wined3d_device, Src->wineD3DVertexDeclaration);
hr = wined3d_device_process_vertices(D3D->wined3d_device, SrcIndex, DestIndex,
Count, This->wineD3DVertexBuffer, NULL, Flags, This->fvf);
/* Restore the states if needed */
if(doClip != oldClip)
IWineD3DDevice_SetRenderState(D3D->wineD3DDevice,
WINED3DRS_CLIPPING,
oldClip);
if (doClip != oldClip)
wined3d_device_set_render_state(D3D->wined3d_device, WINED3DRS_CLIPPING, oldClip);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
static HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_ProcessVertices(IDirect3DVertexBuffer *iface,
DWORD VertexOp,
DWORD DestIndex,
DWORD Count,
IDirect3DVertexBuffer *SrcBuffer,
DWORD SrcIndex,
IDirect3DDevice3 *D3DDevice,
DWORD Flags)
static HRESULT WINAPI IDirect3DVertexBufferImpl_1_ProcessVertices(IDirect3DVertexBuffer *iface,
DWORD VertexOp, DWORD DestIndex, DWORD Count, IDirect3DVertexBuffer *SrcBuffer,
DWORD SrcIndex, IDirect3DDevice3 *D3DDevice, DWORD Flags)
{
IDirect3DVertexBufferImpl *Src = SrcBuffer ? vb_from_vb1(SrcBuffer) : NULL;
IDirect3DDeviceImpl *D3D = D3DDevice ? device_from_device3(D3DDevice) : NULL;
@ -418,27 +375,28 @@ IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface,
D3DVERTEXBUFFERDESC *Desc)
{
IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
WINED3DBUFFER_DESC WDesc;
struct wined3d_resource_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
TRACE("iface %p, desc %p.\n", iface, Desc);
if(!Desc) return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &WDesc);
wined3d_resource = wined3d_buffer_get_resource(This->wineD3DVertexBuffer);
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
LeaveCriticalSection(&ddraw_cs);
/* Now fill the Desc structure */
Desc->dwCaps = This->Caps;
Desc->dwFVF = This->fvf;
Desc->dwNumVertices = WDesc.Size / get_flexible_vertex_size(This->fvf);
Desc->dwNumVertices = wined3d_desc.size / get_flexible_vertex_size(This->fvf);
return D3D_OK;
}
static HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_GetVertexBufferDesc(IDirect3DVertexBuffer *iface,
D3DVERTEXBUFFERDESC *Desc)
static HRESULT WINAPI IDirect3DVertexBufferImpl_1_GetVertexBufferDesc(IDirect3DVertexBuffer *iface,
D3DVERTEXBUFFERDESC *Desc)
{
TRACE("iface %p, desc %p.\n", iface, Desc);
@ -485,10 +443,8 @@ IDirect3DVertexBufferImpl_Optimize(IDirect3DVertexBuffer7 *iface,
return DD_OK;
}
static HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_Optimize(IDirect3DVertexBuffer *iface,
IDirect3DDevice3 *D3DDevice,
DWORD Flags)
static HRESULT WINAPI IDirect3DVertexBufferImpl_1_Optimize(IDirect3DVertexBuffer *iface,
IDirect3DDevice3 *D3DDevice, DWORD Flags)
{
IDirect3DDeviceImpl *D3D = D3DDevice ? device_from_device3(D3DDevice) : NULL;
@ -559,15 +515,15 @@ static const struct IDirect3DVertexBuffer7Vtbl d3d_vertex_buffer7_vtbl =
static const struct IDirect3DVertexBufferVtbl d3d_vertex_buffer1_vtbl =
{
/*** IUnknown Methods ***/
Thunk_IDirect3DVertexBufferImpl_1_QueryInterface,
Thunk_IDirect3DVertexBufferImpl_1_AddRef,
Thunk_IDirect3DVertexBufferImpl_1_Release,
IDirect3DVertexBufferImpl_1_QueryInterface,
IDirect3DVertexBufferImpl_1_AddRef,
IDirect3DVertexBufferImpl_1_Release,
/*** IDirect3DVertexBuffer Methods ***/
Thunk_IDirect3DVertexBufferImpl_1_Lock,
Thunk_IDirect3DVertexBufferImpl_1_Unlock,
Thunk_IDirect3DVertexBufferImpl_1_ProcessVertices,
Thunk_IDirect3DVertexBufferImpl_1_GetVertexBufferDesc,
Thunk_IDirect3DVertexBufferImpl_1_Optimize
IDirect3DVertexBufferImpl_1_Lock,
IDirect3DVertexBufferImpl_1_Unlock,
IDirect3DVertexBufferImpl_1_ProcessVertices,
IDirect3DVertexBufferImpl_1_GetVertexBufferDesc,
IDirect3DVertexBufferImpl_1_Optimize
};
HRESULT d3d_vertex_buffer_init(IDirect3DVertexBufferImpl *buffer,
@ -589,7 +545,7 @@ HRESULT d3d_vertex_buffer_init(IDirect3DVertexBufferImpl *buffer,
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DDevice_CreateVertexBuffer(ddraw->wineD3DDevice,
hr = wined3d_buffer_create_vb(ddraw->wined3d_device,
get_flexible_vertex_size(desc->dwFVF) * desc->dwNumVertices,
usage, desc->dwCaps & D3DVBCAPS_SYSTEMMEMORY ? WINED3DPOOL_SYSTEMMEM : WINED3DPOOL_DEFAULT,
buffer, &ddraw_null_wined3d_parent_ops, &buffer->wineD3DVertexBuffer);
@ -608,12 +564,12 @@ HRESULT d3d_vertex_buffer_init(IDirect3DVertexBufferImpl *buffer,
if (!buffer->wineD3DVertexDeclaration)
{
ERR("Failed to find vertex declaration for fvf %#x.\n", desc->dwFVF);
IWineD3DBuffer_Release(buffer->wineD3DVertexBuffer);
wined3d_buffer_decref(buffer->wineD3DVertexBuffer);
LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDPARAMS;
}
IWineD3DVertexDeclaration_AddRef(buffer->wineD3DVertexDeclaration);
wined3d_vertex_declaration_incref(buffer->wineD3DVertexDeclaration);
LeaveCriticalSection(&ddraw_cs);

View file

@ -36,18 +36,18 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
* activates the viewport using IDirect3DDevice7::SetViewport
*
*****************************************************************************/
void viewport_activate(IDirect3DViewportImpl* This, BOOL ignore_lights) {
IDirect3DLightImpl* light;
void viewport_activate(IDirect3DViewportImpl *This, BOOL ignore_lights)
{
D3DVIEWPORT7 vp;
if (!ignore_lights) {
/* Activate all the lights associated with this context */
light = This->lights;
if (!ignore_lights)
{
IDirect3DLightImpl *light;
while (light)
/* Activate all the lights associated with this context */
LIST_FOR_EACH_ENTRY(light, &This->light_list, IDirect3DLightImpl, entry)
{
light_activate(light);
light = light->next;
}
}
@ -387,17 +387,12 @@ IDirect3DViewportImpl_TransformVertices(IDirect3DViewport3 *iface,
EnterCriticalSection(&ddraw_cs);
IWineD3DDevice_GetTransform(This->active_device->wineD3DDevice,
D3DTRANSFORMSTATE_VIEW,
(WINED3DMATRIX*) &view_mat);
IWineD3DDevice_GetTransform(This->active_device->wineD3DDevice,
D3DTRANSFORMSTATE_PROJECTION,
(WINED3DMATRIX*) &proj_mat);
IWineD3DDevice_GetTransform(This->active_device->wineD3DDevice,
WINED3DTS_WORLDMATRIX(0),
(WINED3DMATRIX*) &world_mat);
wined3d_device_get_transform(This->active_device->wined3d_device,
D3DTRANSFORMSTATE_VIEW, (WINED3DMATRIX *)&view_mat);
wined3d_device_get_transform(This->active_device->wined3d_device,
D3DTRANSFORMSTATE_PROJECTION, (WINED3DMATRIX *)&proj_mat);
wined3d_device_get_transform(This->active_device->wined3d_device,
WINED3DTS_WORLDMATRIX(0), (WINED3DMATRIX *)&world_mat);
multiply_matrix(&mat,&view_mat,&world_mat);
multiply_matrix(&mat,&proj_mat,&mat);
@ -749,8 +744,7 @@ IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface,
This->map_lights |= 1<<i;
/* Add the light in the 'linked' chain */
lpDirect3DLightImpl->next = This->lights;
This->lights = lpDirect3DLightImpl;
list_add_head(&This->light_list, &lpDirect3DLightImpl->entry);
IDirect3DLight_AddRef(lpDirect3DLight);
/* Attach the light to the viewport */
@ -782,33 +776,29 @@ IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3 *iface,
IDirect3DLight *lpDirect3DLight)
{
IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface;
IDirect3DLightImpl *lpDirect3DLightImpl = (IDirect3DLightImpl *)lpDirect3DLight;
IDirect3DLightImpl *cur_light, *prev_light = NULL;
IDirect3DLightImpl *l = (IDirect3DLightImpl *)lpDirect3DLight;
TRACE("iface %p, light %p.\n", iface, lpDirect3DLight);
EnterCriticalSection(&ddraw_cs);
cur_light = This->lights;
while (cur_light != NULL) {
if (cur_light == lpDirect3DLightImpl)
{
light_deactivate(lpDirect3DLightImpl);
if (!prev_light) This->lights = cur_light->next;
else prev_light->next = cur_light->next;
/* Detach the light from the viewport. */
cur_light->active_viewport = NULL;
IDirect3DLight_Release((IDirect3DLight *)cur_light);
--This->num_lights;
This->map_lights &= ~(1 << lpDirect3DLightImpl->dwLightIndex);
LeaveCriticalSection(&ddraw_cs);
return D3D_OK;
}
prev_light = cur_light;
cur_light = cur_light->next;
if (l->active_viewport != This)
{
WARN("Light %p active viewport is %p.\n", l, l->active_viewport);
LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDPARAMS;
}
light_deactivate(l);
list_remove(&l->entry);
l->active_viewport = NULL;
IDirect3DLight_Release(lpDirect3DLight);
--This->num_lights;
This->map_lights &= ~(1 << l->dwLightIndex);
LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDPARAMS;
return D3D_OK;
}
/*****************************************************************************
@ -831,7 +821,9 @@ IDirect3DViewportImpl_NextLight(IDirect3DViewport3 *iface,
DWORD dwFlags)
{
IDirect3DViewportImpl *This = (IDirect3DViewportImpl *)iface;
IDirect3DLightImpl *cur_light, *prev_light = NULL;
IDirect3DLightImpl *l = (IDirect3DLightImpl *)lpDirect3DLight;
struct list *entry;
HRESULT hr;
TRACE("iface %p, light %p, next_light %p, flags %#x.\n",
iface, lpDirect3DLight, lplpDirect3DLight, dwFlags);
@ -839,47 +831,50 @@ IDirect3DViewportImpl_NextLight(IDirect3DViewport3 *iface,
if (!lplpDirect3DLight)
return DDERR_INVALIDPARAMS;
*lplpDirect3DLight = NULL;
EnterCriticalSection(&ddraw_cs);
cur_light = This->lights;
switch (dwFlags) {
switch (dwFlags)
{
case D3DNEXT_NEXT:
if (!lpDirect3DLight) {
LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDPARAMS;
}
while (cur_light != NULL) {
if (cur_light == (IDirect3DLightImpl *)lpDirect3DLight) {
*lplpDirect3DLight = (IDirect3DLight*)cur_light->next;
break;
}
cur_light = cur_light->next;
if (!l || l->active_viewport != This)
{
if (l)
WARN("Light %p active viewport is %p.\n", l, l->active_viewport);
entry = NULL;
}
else
entry = list_next(&This->light_list, &l->entry);
break;
case D3DNEXT_HEAD:
*lplpDirect3DLight = (IDirect3DLight*)This->lights;
entry = list_head(&This->light_list);
break;
case D3DNEXT_TAIL:
while (cur_light != NULL) {
prev_light = cur_light;
cur_light = cur_light->next;
}
*lplpDirect3DLight = (IDirect3DLight*)prev_light;
entry = list_tail(&This->light_list);
break;
default:
ERR("Unknown flag %d\n", dwFlags);
entry = NULL;
WARN("Invalid flags %#x.\n", dwFlags);
break;
}
if (*lplpDirect3DLight)
if (entry)
{
*lplpDirect3DLight = (IDirect3DLight *)LIST_ENTRY(entry, IDirect3DLightImpl, entry);
IDirect3DLight_AddRef(*lplpDirect3DLight);
hr = D3D_OK;
}
else
{
*lplpDirect3DLight = NULL;
hr = DDERR_INVALIDPARAMS;
}
LeaveCriticalSection(&ddraw_cs);
return *lplpDirect3DLight ? D3D_OK : DDERR_INVALIDPARAMS;
return hr;
}
/*****************************************************************************
@ -1131,4 +1126,5 @@ void d3d_viewport_init(IDirect3DViewportImpl *viewport, IDirectDrawImpl *ddraw)
viewport->ref = 1;
viewport->ddraw = ddraw;
viewport->use_vp2 = 0xff;
list_init(&viewport->light_list);
}

View file

@ -18,11 +18,9 @@ spec2def(wined3d.dll wined3d.spec)
list(APPEND SOURCE
ati_fragment_shader.c
arb_program_shader.c
basetexture.c
buffer.c
clipper.c
context.c
cubetexture.c
device.c
directx.c
drawprim.c
@ -37,18 +35,13 @@ list(APPEND SOURCE
shader_sm4.c
state.c
stateblock.c
surface_base.c
surface.c
surface_gdi.c
swapchain.c
swapchain_base.c
swapchain_gdi.c
texture.c
utils.c
vertexdeclaration.c
view.c
volume.c
volumetexture.c
wined3d_main.c
version.rc
${CMAKE_CURRENT_BINARY_DIR}/wined3d.def)
@ -62,7 +55,7 @@ endif()
add_library(wined3d SHARED ${SOURCE})
set_module_type(wined3d win32dll)
target_link_libraries(wined3d wine uuid wined3d_guid)
target_link_libraries(wined3d wine uuid)
add_importlibs(wined3d
user32

File diff suppressed because it is too large Load diff

View file

@ -796,13 +796,13 @@ static GLuint gen_ati_shader(const struct texture_stage_op op[MAX_TEXTURES], con
return ret;
}
static void set_tex_op_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
static void set_tex_op_atifs(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
IWineD3DDeviceImpl *This = stateblock->device;
struct wined3d_device *device = stateblock->device;
const struct atifs_ffp_desc *desc;
struct ffp_frag_settings settings;
struct atifs_private_data *priv = This->fragment_priv;
struct ffp_frag_settings settings;
struct atifs_private_data *priv = device->fragment_priv;
DWORD mapped_stage;
unsigned int i;
@ -832,8 +832,9 @@ static void set_tex_op_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, st
/* GL_ATI_fragment_shader depends on the GL_TEXTURE_xD enable settings. Update the texture stages
* used by this shader
*/
for(i = 0; i < desc->num_textures_used; i++) {
mapped_stage = This->texUnitMap[i];
for (i = 0; i < desc->num_textures_used; ++i)
{
mapped_stage = device->texUnitMap[i];
if (mapped_stage != WINED3D_UNMAPPED_STAGE)
{
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
@ -845,7 +846,7 @@ static void set_tex_op_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, st
GL_EXTCALL(glBindFragmentShaderATI(desc->shader));
}
static void state_texfactor_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
static void state_texfactor_atifs(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
float col[4];
@ -855,7 +856,7 @@ static void state_texfactor_atifs(DWORD state, IWineD3DStateBlockImpl *statebloc
checkGLcall("glSetFragmentShaderConstantATI(ATI_FFP_CONST_TFACTOR, col)");
}
static void set_bumpmat(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
static void set_bumpmat(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
const struct wined3d_gl_info *gl_info = context->gl_info;
@ -880,17 +881,17 @@ static void set_bumpmat(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
checkGLcall("glSetFragmentShaderConstantATI(ATI_FFP_CONST_BUMPMAT(stage), mat)");
}
static void textransform(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
static void textransform(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if(!isStateDirty(context, STATE_PIXELSHADER)) {
if (!isStateDirty(context, STATE_PIXELSHADER))
set_tex_op_atifs(state, stateblock, context);
}
}
static void atifs_apply_pixelshader(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
static void atifs_apply_pixelshader(DWORD state_id,
struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_state *state = &stateblock->state;
IWineD3DDeviceImpl *device = stateblock->device;
struct wined3d_device *device = stateblock->device;
BOOL use_vshader = use_vs(state);
context->last_was_pshader = use_ps(state);
@ -913,7 +914,7 @@ static void atifs_apply_pixelshader(DWORD state_id, IWineD3DStateBlockImpl *stat
}
}
static void atifs_srgbwriteenable(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
static void atifs_srgbwriteenable(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_SRGBWRITEENABLE])
WARN("sRGB writes are not supported by this fragment pipe.\n");
@ -1053,9 +1054,9 @@ static const struct StateEntryTemplate atifs_fragmentstate_template[] = {
{0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE },
};
/* Context activation is done by the caller. */
static void atifs_enable(IWineD3DDevice *iface, BOOL enable) {
ENTER_GL();
/* Context activation and GL locking are done by the caller. */
static void atifs_enable(BOOL enable)
{
if(enable) {
glEnable(GL_FRAGMENT_SHADER_ATI);
checkGLcall("glEnable(GL_FRAGMENT_SHADER_ATI)");
@ -1063,7 +1064,6 @@ static void atifs_enable(IWineD3DDevice *iface, BOOL enable) {
glDisable(GL_FRAGMENT_SHADER_ATI);
checkGLcall("glDisable(GL_FRAGMENT_SHADER_ATI)");
}
LEAVE_GL();
}
static void atifs_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps)
@ -1113,20 +1113,21 @@ static void atifs_get_caps(const struct wined3d_gl_info *gl_info, struct fragmen
caps->MaxSimultaneousTextures = 6;
}
static HRESULT atifs_alloc(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
static HRESULT atifs_alloc(struct wined3d_device *device)
{
struct atifs_private_data *priv;
This->fragment_priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct atifs_private_data));
if(!This->fragment_priv) {
device->fragment_priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct atifs_private_data));
if (!device->fragment_priv)
{
ERR("Out of memory\n");
return E_OUTOFMEMORY;
}
priv = This->fragment_priv;
priv = device->fragment_priv;
if (wine_rb_init(&priv->fragment_shaders, &wined3d_ffp_frag_program_rb_functions) == -1)
{
ERR("Failed to initialize rbtree.\n");
HeapFree(GetProcessHeap(), 0, This->fragment_priv);
HeapFree(GetProcessHeap(), 0, device->fragment_priv);
return E_OUTOFMEMORY;
}
return WINED3D_OK;
@ -1135,8 +1136,8 @@ static HRESULT atifs_alloc(IWineD3DDevice *iface) {
/* Context activation is done by the caller. */
static void atifs_free_ffpshader(struct wine_rb_entry *entry, void *context)
{
IWineD3DDeviceImpl *This = context;
const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
struct wined3d_device *device = context;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct atifs_ffp_desc *entry_ati = WINE_RB_ENTRY_VALUE(entry, struct atifs_ffp_desc, parent.entry);
ENTER_GL();
@ -1147,14 +1148,14 @@ static void atifs_free_ffpshader(struct wine_rb_entry *entry, void *context)
}
/* Context activation is done by the caller. */
static void atifs_free(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
struct atifs_private_data *priv = This->fragment_priv;
static void atifs_free(struct wined3d_device *device)
{
struct atifs_private_data *priv = device->fragment_priv;
wine_rb_destroy(&priv->fragment_shaders, atifs_free_ffpshader, This);
wine_rb_destroy(&priv->fragment_shaders, atifs_free_ffpshader, device);
HeapFree(GetProcessHeap(), 0, priv);
This->fragment_priv = NULL;
device->fragment_priv = NULL;
}
static BOOL atifs_color_fixup_supported(struct color_fixup_desc fixup)

View file

@ -1,542 +0,0 @@
/*
* IWineD3DBaseTexture Implementation
*
* Copyright 2002-2004 Jason Edmeades
* Copyright 2002-2004 Raphael Junqueira
* Copyright 2005 Oliver Stieber
* Copyright 2007-2008 Stefan Dösinger for CodeWeavers
* Copyright 2009 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT layer_count, UINT level_count,
WINED3DRESOURCETYPE resource_type, IWineD3DDeviceImpl *device, UINT size, DWORD usage,
const struct wined3d_format *format, WINED3DPOOL pool, void *parent,
const struct wined3d_parent_ops *parent_ops)
{
HRESULT hr;
hr = resource_init((IWineD3DResource *)texture, resource_type, device,
size, usage, format, pool, parent, parent_ops);
if (FAILED(hr))
{
WARN("Failed to initialize resource, returning %#x\n", hr);
return hr;
}
texture->baseTexture.sub_resources = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
level_count * layer_count * sizeof(*texture->baseTexture.sub_resources));
if (!texture->baseTexture.sub_resources)
{
ERR("Failed to allocate sub-resource array.\n");
resource_cleanup((IWineD3DResource *)texture);
return E_OUTOFMEMORY;
}
texture->baseTexture.layer_count = layer_count;
texture->baseTexture.level_count = level_count;
texture->baseTexture.filterType = (usage & WINED3DUSAGE_AUTOGENMIPMAP) ? WINED3DTEXF_LINEAR : WINED3DTEXF_NONE;
texture->baseTexture.LOD = 0;
texture->baseTexture.texture_rgb.dirty = TRUE;
texture->baseTexture.texture_srgb.dirty = TRUE;
texture->baseTexture.is_srgb = FALSE;
texture->baseTexture.pow2Matrix_identity = TRUE;
if (texture->resource.format->Flags & WINED3DFMT_FLAG_FILTERING)
{
texture->baseTexture.minMipLookup = minMipLookup;
texture->baseTexture.magLookup = magLookup;
}
else
{
texture->baseTexture.minMipLookup = minMipLookup_noFilter;
texture->baseTexture.magLookup = magLookup_noFilter;
}
return WINED3D_OK;
}
void basetexture_cleanup(IWineD3DBaseTexture *iface)
{
basetexture_unload(iface);
HeapFree(GetProcessHeap(), 0, ((IWineD3DBaseTextureImpl *)iface)->baseTexture.sub_resources);
resource_cleanup((IWineD3DResource *)iface);
}
IWineD3DResourceImpl *basetexture_get_sub_resource(IWineD3DBaseTextureImpl *texture, UINT layer, UINT level)
{
if (layer >= texture->baseTexture.layer_count)
{
WARN("layer %u >= layer_count %u.\n", layer, texture->baseTexture.layer_count);
return NULL;
}
if (level >= texture->baseTexture.level_count)
{
WARN("level %u >= level_count %u.\n", level, texture->baseTexture.level_count);
return NULL;
}
return texture->baseTexture.sub_resources[layer * texture->baseTexture.level_count + level];
}
/* A GL context is provided by the caller */
static void gltexture_delete(struct gl_texture *tex)
{
ENTER_GL();
glDeleteTextures(1, &tex->name);
LEAVE_GL();
tex->name = 0;
}
void basetexture_unload(IWineD3DBaseTexture *iface)
{
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
IWineD3DDeviceImpl *device = This->resource.device;
struct wined3d_context *context = NULL;
if (This->baseTexture.texture_rgb.name || This->baseTexture.texture_srgb.name)
{
context = context_acquire(device, NULL);
}
if(This->baseTexture.texture_rgb.name) {
gltexture_delete(&This->baseTexture.texture_rgb);
}
if(This->baseTexture.texture_srgb.name) {
gltexture_delete(&This->baseTexture.texture_srgb);
}
if (context) context_release(context);
This->baseTexture.texture_rgb.dirty = TRUE;
This->baseTexture.texture_srgb.dirty = TRUE;
resource_unload((IWineD3DResourceImpl *)This);
}
DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD LODNew)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
DWORD old = This->baseTexture.LOD;
/* The d3d9:texture test shows that SetLOD is ignored on non-managed
* textures. The call always returns 0, and GetLOD always returns 0
*/
if (This->resource.pool != WINED3DPOOL_MANAGED) {
TRACE("Ignoring SetLOD on %s texture, returning 0\n", debug_d3dpool(This->resource.pool));
return 0;
}
if (LODNew >= This->baseTexture.level_count)
LODNew = This->baseTexture.level_count - 1;
if(This->baseTexture.LOD != LODNew) {
This->baseTexture.LOD = LODNew;
This->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAXMIPLEVEL] = ~0U;
This->baseTexture.texture_srgb.states[WINED3DTEXSTA_MAXMIPLEVEL] = ~0U;
if(This->baseTexture.bindCount) {
IWineD3DDeviceImpl_MarkStateDirty(This->resource.device, STATE_SAMPLER(This->baseTexture.sampler));
}
}
TRACE("(%p) : set LOD to %d\n", This, This->baseTexture.LOD);
return old;
}
DWORD basetexture_get_lod(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
TRACE("(%p) : returning %d\n", This, This->baseTexture.LOD);
return This->baseTexture.LOD;
}
DWORD basetexture_get_level_count(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
TRACE("iface %p, returning %u.\n", iface, This->baseTexture.level_count);
return This->baseTexture.level_count;
}
HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
IWineD3DDeviceImpl *device = This->resource.device;
GLenum textureDimensions = This->baseTexture.target;
if (!(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP)) {
TRACE("(%p) : returning invalid call\n", This);
return WINED3DERR_INVALIDCALL;
}
if(This->baseTexture.filterType != FilterType) {
/* What about multithreading? Do we want all the context overhead just to set this value?
* Or should we delay the applying until the texture is used for drawing? For now, apply
* immediately.
*/
struct wined3d_context *context = context_acquire(device, NULL);
ENTER_GL();
glBindTexture(textureDimensions, This->baseTexture.texture_rgb.name);
checkGLcall("glBindTexture");
switch(FilterType) {
case WINED3DTEXF_NONE:
case WINED3DTEXF_POINT:
glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST);
checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST)");
break;
case WINED3DTEXF_LINEAR:
glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST)");
break;
default:
WARN("Unexpected filter type %d, setting to GL_NICEST\n", FilterType);
glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST)");
}
LEAVE_GL();
context_release(context);
}
This->baseTexture.filterType = FilterType;
TRACE("(%p) :\n", This);
return WINED3D_OK;
}
WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
FIXME("(%p) : stub\n", This);
return This->baseTexture.filterType;
}
void basetexture_generate_mipmaps(IWineD3DBaseTexture *iface)
{
/* TODO: Implement filters using GL_SGI_generate_mipmaps. */
FIXME("iface %p stub!\n", iface);
}
BOOL basetexture_set_dirty(IWineD3DBaseTexture *iface, BOOL dirty)
{
BOOL old;
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
old = This->baseTexture.texture_rgb.dirty || This->baseTexture.texture_srgb.dirty;
This->baseTexture.texture_rgb.dirty = dirty;
This->baseTexture.texture_srgb.dirty = dirty;
return old;
}
BOOL basetexture_get_dirty(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
return This->baseTexture.texture_rgb.dirty || This->baseTexture.texture_srgb.dirty;
}
/* Context activation is done by the caller. */
HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surface_desc)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
HRESULT hr = WINED3D_OK;
GLenum textureDimensions;
BOOL isNewTexture = FALSE;
struct gl_texture *gl_tex;
TRACE("(%p) : About to bind texture\n", This);
This->baseTexture.is_srgb = srgb; /* SRGB mode cache for PreLoad calls outside drawprim */
if(srgb) {
gl_tex = &This->baseTexture.texture_srgb;
} else {
gl_tex = &This->baseTexture.texture_rgb;
}
textureDimensions = This->baseTexture.target;
ENTER_GL();
/* Generate a texture name if we don't already have one */
if (!gl_tex->name)
{
*set_surface_desc = TRUE;
glGenTextures(1, &gl_tex->name);
checkGLcall("glGenTextures");
TRACE("Generated texture %d\n", gl_tex->name);
if (This->resource.pool == WINED3DPOOL_DEFAULT) {
/* Tell opengl to try and keep this texture in video ram (well mostly) */
GLclampf tmp;
tmp = 0.9f;
glPrioritizeTextures(1, &gl_tex->name, &tmp);
}
/* Initialise the state of the texture object
to the openGL defaults, not the directx defaults */
gl_tex->states[WINED3DTEXSTA_ADDRESSU] = WINED3DTADDRESS_WRAP;
gl_tex->states[WINED3DTEXSTA_ADDRESSV] = WINED3DTADDRESS_WRAP;
gl_tex->states[WINED3DTEXSTA_ADDRESSW] = WINED3DTADDRESS_WRAP;
gl_tex->states[WINED3DTEXSTA_BORDERCOLOR] = 0;
gl_tex->states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_LINEAR;
gl_tex->states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT; /* GL_NEAREST_MIPMAP_LINEAR */
gl_tex->states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_LINEAR; /* GL_NEAREST_MIPMAP_LINEAR */
gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] = 0;
gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] = 1;
gl_tex->states[WINED3DTEXSTA_SRGBTEXTURE] = 0;
gl_tex->states[WINED3DTEXSTA_SHADOW] = FALSE;
IWineD3DBaseTexture_SetDirty(iface, TRUE);
isNewTexture = TRUE;
if(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP) {
/* This means double binding the texture at creation, but keeps the code simpler all
* in all, and the run-time path free from additional checks
*/
glBindTexture(textureDimensions, gl_tex->name);
checkGLcall("glBindTexture");
glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_SGIS, GL_TRUE)");
}
} else {
*set_surface_desc = FALSE;
}
/* Bind the texture */
if (gl_tex->name)
{
glBindTexture(textureDimensions, gl_tex->name);
checkGLcall("glBindTexture");
if (isNewTexture) {
/* For a new texture we have to set the textures levels after binding the texture.
* In theory this is all we should ever have to do, but because ATI's drivers are broken, we
* also need to set the texture dimensions before the texture is set
* Beware that texture rectangles do not support mipmapping, but set the maxmiplevel if we're
* relying on the partial GL_ARB_texture_non_power_of_two emulation with texture rectangles
* (ie, do not care for cond_np2 here, just look for GL_TEXTURE_RECTANGLE_ARB)
*/
if (textureDimensions != GL_TEXTURE_RECTANGLE_ARB)
{
TRACE("Setting GL_TEXTURE_MAX_LEVEL to %u.\n", This->baseTexture.level_count - 1);
glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.level_count - 1);
checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.level_count)");
}
if(textureDimensions==GL_TEXTURE_CUBE_MAP_ARB) {
/* Cubemaps are always set to clamp, regardless of the sampler state. */
glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
}
}
} else { /* this only happened if we've run out of openGL textures */
WARN("This texture doesn't have an openGL texture assigned to it\n");
hr = WINED3DERR_INVALIDCALL;
}
LEAVE_GL();
return hr;
}
/* GL locking is done by the caller */
static void apply_wrap(const struct wined3d_gl_info *gl_info, GLenum target,
WINED3DTEXTUREADDRESS d3d_wrap, GLenum param, BOOL cond_np2)
{
GLint gl_wrap;
if (d3d_wrap < WINED3DTADDRESS_WRAP || d3d_wrap > WINED3DTADDRESS_MIRRORONCE)
{
FIXME("Unrecognized or unsupported WINED3DTEXTUREADDRESS %#x.\n", d3d_wrap);
return;
}
if (target == GL_TEXTURE_CUBE_MAP_ARB
|| (cond_np2 && d3d_wrap == WINED3DTADDRESS_WRAP))
{
/* Cubemaps are always set to clamp, regardless of the sampler state. */
gl_wrap = GL_CLAMP_TO_EDGE;
}
else
{
gl_wrap = gl_info->wrap_lookup[d3d_wrap - WINED3DTADDRESS_WRAP];
}
TRACE("Setting param %#x to %#x for target %#x.\n", param, gl_wrap, target);
glTexParameteri(target, param, gl_wrap);
checkGLcall("glTexParameteri(target, param, gl_wrap)");
}
/* GL locking is done by the caller (state handler) */
void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1],
const struct wined3d_gl_info *gl_info)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
GLenum textureDimensions = This->baseTexture.target;
DWORD state;
BOOL cond_np2 = IWineD3DBaseTexture_IsCondNP2(iface);
DWORD aniso;
struct gl_texture *gl_tex;
TRACE("iface %p, textureStates %p, samplerStates %p\n", iface, textureStates, samplerStates);
if(This->baseTexture.is_srgb) {
gl_tex = &This->baseTexture.texture_srgb;
} else {
gl_tex = &This->baseTexture.texture_rgb;
}
/* This function relies on the correct texture being bound and loaded. */
if(samplerStates[WINED3DSAMP_ADDRESSU] != gl_tex->states[WINED3DTEXSTA_ADDRESSU]) {
state = samplerStates[WINED3DSAMP_ADDRESSU];
apply_wrap(gl_info, textureDimensions, state, GL_TEXTURE_WRAP_S, cond_np2);
gl_tex->states[WINED3DTEXSTA_ADDRESSU] = state;
}
if(samplerStates[WINED3DSAMP_ADDRESSV] != gl_tex->states[WINED3DTEXSTA_ADDRESSV]) {
state = samplerStates[WINED3DSAMP_ADDRESSV];
apply_wrap(gl_info, textureDimensions, state, GL_TEXTURE_WRAP_T, cond_np2);
gl_tex->states[WINED3DTEXSTA_ADDRESSV] = state;
}
if(samplerStates[WINED3DSAMP_ADDRESSW] != gl_tex->states[WINED3DTEXSTA_ADDRESSW]) {
state = samplerStates[WINED3DSAMP_ADDRESSW];
apply_wrap(gl_info, textureDimensions, state, GL_TEXTURE_WRAP_R, cond_np2);
gl_tex->states[WINED3DTEXSTA_ADDRESSW] = state;
}
if(samplerStates[WINED3DSAMP_BORDERCOLOR] != gl_tex->states[WINED3DTEXSTA_BORDERCOLOR]) {
float col[4];
state = samplerStates[WINED3DSAMP_BORDERCOLOR];
D3DCOLORTOGLFLOAT4(state, col);
TRACE("Setting border color for %u to %x\n", textureDimensions, state);
glTexParameterfv(textureDimensions, GL_TEXTURE_BORDER_COLOR, &col[0]);
checkGLcall("glTexParameteri(..., GL_TEXTURE_BORDER_COLOR, ...)");
gl_tex->states[WINED3DTEXSTA_BORDERCOLOR] = state;
}
if(samplerStates[WINED3DSAMP_MAGFILTER] != gl_tex->states[WINED3DTEXSTA_MAGFILTER]) {
GLint glValue;
state = samplerStates[WINED3DSAMP_MAGFILTER];
if (state > WINED3DTEXF_ANISOTROPIC) {
FIXME("Unrecognized or unsupported MAGFILTER* value %d\n", state);
}
glValue = wined3d_gl_mag_filter(This->baseTexture.magLookup,
min(max(state, WINED3DTEXF_POINT), WINED3DTEXF_LINEAR));
TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue);
glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue);
gl_tex->states[WINED3DTEXSTA_MAGFILTER] = state;
}
if((samplerStates[WINED3DSAMP_MINFILTER] != gl_tex->states[WINED3DTEXSTA_MINFILTER] ||
samplerStates[WINED3DSAMP_MIPFILTER] != gl_tex->states[WINED3DTEXSTA_MIPFILTER] ||
samplerStates[WINED3DSAMP_MAXMIPLEVEL] != gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL])) {
GLint glValue;
gl_tex->states[WINED3DTEXSTA_MIPFILTER] = samplerStates[WINED3DSAMP_MIPFILTER];
gl_tex->states[WINED3DTEXSTA_MINFILTER] = samplerStates[WINED3DSAMP_MINFILTER];
gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] = samplerStates[WINED3DSAMP_MAXMIPLEVEL];
if (gl_tex->states[WINED3DTEXSTA_MINFILTER] > WINED3DTEXF_ANISOTROPIC
|| gl_tex->states[WINED3DTEXSTA_MIPFILTER] > WINED3DTEXF_ANISOTROPIC)
{
FIXME("Unrecognized or unsupported D3DSAMP_MINFILTER value %d D3DSAMP_MIPFILTER value %d\n",
gl_tex->states[WINED3DTEXSTA_MINFILTER],
gl_tex->states[WINED3DTEXSTA_MIPFILTER]);
}
glValue = wined3d_gl_min_mip_filter(This->baseTexture.minMipLookup,
min(max(samplerStates[WINED3DSAMP_MINFILTER], WINED3DTEXF_POINT), WINED3DTEXF_LINEAR),
min(max(samplerStates[WINED3DSAMP_MIPFILTER], WINED3DTEXF_NONE), WINED3DTEXF_LINEAR));
TRACE("ValueMIN=%d, ValueMIP=%d, setting MINFILTER to %x\n",
samplerStates[WINED3DSAMP_MINFILTER],
samplerStates[WINED3DSAMP_MIPFILTER], glValue);
glTexParameteri(textureDimensions, GL_TEXTURE_MIN_FILTER, glValue);
checkGLcall("glTexParameter GL_TEXTURE_MIN_FILTER, ...");
if (!cond_np2)
{
if (gl_tex->states[WINED3DTEXSTA_MIPFILTER] == WINED3DTEXF_NONE)
glValue = This->baseTexture.LOD;
else if (gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] >= This->baseTexture.level_count)
glValue = This->baseTexture.level_count - 1;
else if (gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] < This->baseTexture.LOD)
/* baseTexture.LOD is already clamped in the setter */
glValue = This->baseTexture.LOD;
else
glValue = gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL];
/* Note that D3DSAMP_MAXMIPLEVEL specifies the biggest mipmap(default 0), while
* GL_TEXTURE_MAX_LEVEL specifies the smallest mimap used(default 1000).
* So D3DSAMP_MAXMIPLEVEL is the same as GL_TEXTURE_BASE_LEVEL.
*/
glTexParameteri(textureDimensions, GL_TEXTURE_BASE_LEVEL, glValue);
}
}
if ((gl_tex->states[WINED3DTEXSTA_MAGFILTER] != WINED3DTEXF_ANISOTROPIC
&& gl_tex->states[WINED3DTEXSTA_MINFILTER] != WINED3DTEXF_ANISOTROPIC
&& gl_tex->states[WINED3DTEXSTA_MIPFILTER] != WINED3DTEXF_ANISOTROPIC)
|| cond_np2)
{
aniso = 1;
}
else
{
aniso = samplerStates[WINED3DSAMP_MAXANISOTROPY];
}
if (gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] != aniso)
{
if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
{
glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso);
checkGLcall("glTexParameteri(GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso)");
}
else
{
WARN("Anisotropic filtering not supported.\n");
}
gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] = aniso;
}
if (!(This->resource.format->Flags & WINED3DFMT_FLAG_SHADOW)
!= !gl_tex->states[WINED3DTEXSTA_SHADOW])
{
if (This->resource.format->Flags & WINED3DFMT_FLAG_SHADOW)
{
glTexParameteri(textureDimensions, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE);
glTexParameteri(textureDimensions, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB)");
gl_tex->states[WINED3DTEXSTA_SHADOW] = TRUE;
}
else
{
glTexParameteri(textureDimensions, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE)");
gl_tex->states[WINED3DTEXSTA_SHADOW] = FALSE;
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -28,70 +28,51 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
static HRESULT WINAPI IWineD3DClipperImpl_QueryInterface(IWineD3DClipper *iface, REFIID riid, void **object)
ULONG CDECL wined3d_clipper_incref(struct wined3d_clipper *clipper)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
ULONG refcount = InterlockedIncrement(&clipper->ref);
if (IsEqualGUID(riid, &IID_IWineD3DClipper)
|| IsEqualGUID(riid, &IID_IUnknown))
TRACE("%p increasing refcount to %u.\n", clipper, refcount);
return refcount;
}
ULONG CDECL wined3d_clipper_decref(struct wined3d_clipper *clipper)
{
ULONG refcount = InterlockedDecrement(&clipper->ref);
TRACE("%p decreasing refcount to %u.\n", clipper, refcount);
if (!refcount)
HeapFree(GetProcessHeap(), 0, clipper);
return refcount;
}
HRESULT CDECL wined3d_clipper_set_window(struct wined3d_clipper *clipper, DWORD flags, HWND window)
{
TRACE("clipper %p, flags %#x, window %p.\n", clipper, flags, window);
if (flags)
{
IUnknown_AddRef(iface);
*object = iface;
return S_OK;
}
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
*object = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IWineD3DClipperImpl_AddRef(IWineD3DClipper *iface )
{
IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IWineD3DClipperImpl_Release(IWineD3DClipper *iface)
{
IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
if (!ref) HeapFree(GetProcessHeap(), 0, This);
return ref;
}
static HRESULT WINAPI IWineD3DClipperImpl_SetHwnd(IWineD3DClipper *iface, DWORD Flags, HWND hWnd)
{
IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
TRACE("(%p)->(0x%08x,%p)\n", This, Flags, hWnd);
if( Flags )
{
FIXME("Flags = 0x%08x, not supported.\n",Flags);
FIXME("flags %#x, not supported.\n", flags);
return WINED3DERR_INVALIDCALL;
}
This->hWnd = hWnd;
clipper->hWnd = window;
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DClipperImpl_GetClipList(IWineD3DClipper *iface, const RECT *Rect,
RGNDATA *ClipList, DWORD *Size)
HRESULT CDECL wined3d_clipper_get_clip_list(const struct wined3d_clipper *clipper, const RECT *rect,
RGNDATA *clip_list, DWORD *clip_list_size)
{
IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
TRACE("(%p,%p,%p,%p)\n", This, Rect, ClipList, Size);
TRACE("clipper %p, rect %s, clip_list %p, clip_list_size %p.\n",
clipper, wine_dbgstr_rect(rect), clip_list, clip_list_size);
if (This->hWnd)
if (clipper->hWnd)
{
HDC hDC = GetDCEx(This->hWnd, NULL, DCX_WINDOW);
HDC hDC = GetDCEx(clipper->hWnd, NULL, DCX_WINDOW);
if (hDC)
{
HRGN hRgn = CreateRectRgn(0,0,0,0);
@ -101,55 +82,60 @@ static HRESULT WINAPI IWineD3DClipperImpl_GetClipList(IWineD3DClipper *iface, co
{
/* map region to screen coordinates */
POINT org;
GetDCOrgEx( hDC, &org );
OffsetRgn( hRgn, org.x, org.y );
GetDCOrgEx(hDC, &org);
OffsetRgn(hRgn, org.x, org.y);
}
if (Rect)
if (rect)
{
HRGN hRgnClip = CreateRectRgn(Rect->left, Rect->top,
Rect->right, Rect->bottom);
HRGN hRgnClip = CreateRectRgn(rect->left, rect->top,
rect->right, rect->bottom);
CombineRgn(hRgn, hRgn, hRgnClip, RGN_AND);
DeleteObject(hRgnClip);
}
*Size = GetRegionData(hRgn, *Size, ClipList);
*clip_list_size = GetRegionData(hRgn, *clip_list_size, clip_list);
}
DeleteObject(hRgn);
ReleaseDC(This->hWnd, hDC);
ReleaseDC(clipper->hWnd, hDC);
}
return WINED3D_OK;
}
else
{
static int warned = 0;
if (warned++ < 10)
FIXME("(%p,%p,%p,%p),stub!\n",This,Rect,ClipList,Size);
if (Size) *Size=0;
static unsigned int once;
if (!once++)
FIXME("clipper %p, rect %s, clip_list %p, clip_list_size %p stub!\n",
clipper, wine_dbgstr_rect(rect), clip_list, clip_list_size);
if (clip_list_size)
*clip_list_size = 0;
return WINEDDERR_NOCLIPLIST;
}
}
static HRESULT WINAPI IWineD3DClipperImpl_SetClipList(IWineD3DClipper *iface, const RGNDATA *rgn, DWORD Flags)
HRESULT CDECL wined3d_clipper_set_clip_list(struct wined3d_clipper *clipper, const RGNDATA *region, DWORD flags)
{
static int warned = 0;
static unsigned int once;
if (warned++ < 10 || !rgn)
FIXME("iface %p, region %p, flags %#x stub!\n", iface, rgn, Flags);
if (!once++ || !region)
FIXME("clipper %p, region %p, flags %#x stub!\n", clipper, region, flags);
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DClipperImpl_GetHwnd(IWineD3DClipper *iface, HWND *hwnd)
HRESULT CDECL wined3d_clipper_get_window(const struct wined3d_clipper *clipper, HWND *window)
{
IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
TRACE("(%p)->(%p)\n", This, hwnd);
TRACE("clipper %p, window %p.\n", clipper, window);
*window = clipper->hWnd;
*hwnd = This->hWnd;
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DClipperImpl_IsClipListChanged(IWineD3DClipper *iface, BOOL *changed)
HRESULT CDECL wined3d_clipper_is_clip_list_changed(const struct wined3d_clipper *clipper, BOOL *changed)
{
FIXME("iface %p, changed %p stub!\n", iface, changed);
FIXME("clipper %p, changed %p stub!\n", clipper, changed);
/* XXX What is safest? */
*changed = FALSE;
@ -157,33 +143,20 @@ static HRESULT WINAPI IWineD3DClipperImpl_IsClipListChanged(IWineD3DClipper *ifa
return WINED3D_OK;
}
static const IWineD3DClipperVtbl IWineD3DClipper_Vtbl =
struct wined3d_clipper * CDECL wined3d_clipper_create(void)
{
IWineD3DClipperImpl_QueryInterface,
IWineD3DClipperImpl_AddRef,
IWineD3DClipperImpl_Release,
IWineD3DClipperImpl_GetClipList,
IWineD3DClipperImpl_GetHwnd,
IWineD3DClipperImpl_IsClipListChanged,
IWineD3DClipperImpl_SetClipList,
IWineD3DClipperImpl_SetHwnd
};
IWineD3DClipper * WINAPI WineDirect3DCreateClipper(void)
{
IWineD3DClipperImpl *obj;
struct wined3d_clipper *clipper;
TRACE("\n");
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*obj));
if(!obj)
clipper = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*clipper));
if (!clipper)
{
ERR("Out of memory when trying to allocate a WineD3D Clipper\n");
return NULL;
}
obj->lpVtbl = &IWineD3DClipper_Vtbl;
wined3d_clipper_incref(clipper);
IWineD3DClipper_AddRef((IWineD3DClipper *)obj);
return (IWineD3DClipper *) obj;
return clipper;
}

File diff suppressed because it is too large Load diff

View file

@ -1,573 +0,0 @@
/*
* IWineD3DCubeTexture implementation
*
* Copyright 2002-2005 Jason Edmeades
* Copyright 2002-2005 Raphael Junqueira
* Copyright 2005 Oliver Stieber
* Copyright 2007-2008 Stefan Dösinger for CodeWeavers
* Copyright 2009 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
/* Do not call while under the GL lock. */
static void cubetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb)
{
/* Override the IWineD3DResource Preload method. */
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
UINT sub_count = This->baseTexture.level_count * This->baseTexture.layer_count;
IWineD3DDeviceImpl *device = This->resource.device;
struct wined3d_context *context = NULL;
BOOL srgb_mode;
BOOL *dirty;
UINT i;
switch (srgb)
{
case SRGB_RGB:
srgb_mode = FALSE;
break;
case SRGB_BOTH:
cubetexture_internal_preload(iface, SRGB_RGB);
/* Fallthrough */
case SRGB_SRGB:
srgb_mode = TRUE;
break;
default:
srgb_mode = This->baseTexture.is_srgb;
break;
}
dirty = srgb_mode ? &This->baseTexture.texture_srgb.dirty : &This->baseTexture.texture_rgb.dirty;
TRACE("(%p) : About to load texture: dirtified(%u).\n", This, *dirty);
/* We only have to activate a context for gl when we're not drawing.
* In most cases PreLoad will be called during draw and a context was
* activated at the beginning of drawPrimitive. */
if (!device->isInDraw)
{
/* No danger of recursive calls, context_acquire() sets isInDraw to true
* when loading offscreen render targets into their texture. */
context = context_acquire(device, NULL);
}
if (This->resource.format->id == WINED3DFMT_P8_UINT
|| This->resource.format->id == WINED3DFMT_P8_UINT_A8_UNORM)
{
for (i = 0; i < sub_count; ++i)
{
IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)This->baseTexture.sub_resources[i];
if (palette9_changed(surface))
{
TRACE("Reloading surface %p because the d3d8/9 palette was changed.\n", surface);
/* TODO: This is not necessarily needed with hw palettized texture support. */
surface_load_location(surface, SFLAG_INSYSMEM, NULL);
/* Make sure the texture is reloaded because of the palette change,
* this kills performance though :( */
surface_modify_location(surface, SFLAG_INTEXTURE, FALSE);
}
}
}
/* If the texture is marked dirty or the srgb sampler setting has changed
* since the last load then reload the surfaces. */
if (*dirty)
{
for (i = 0; i < sub_count; ++i)
{
IWineD3DSurface_LoadTexture((IWineD3DSurface *)This->baseTexture.sub_resources[i], srgb_mode);
}
}
else
{
TRACE("(%p) Texture not dirty, nothing to do.\n" , iface);
}
/* No longer dirty. */
*dirty = FALSE;
if (context) context_release(context);
}
static void cubetexture_cleanup(IWineD3DCubeTextureImpl *This)
{
UINT sub_count = This->baseTexture.level_count * This->baseTexture.layer_count;
UINT i;
TRACE("(%p) : Cleaning up.\n", This);
for (i = 0; i < sub_count; ++i)
{
IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)This->baseTexture.sub_resources[i];
if (surface)
{
/* Clean out the texture name we gave to the surface so that the
* surface doesn't try and release it. */
surface_set_texture_name(surface, 0, TRUE);
surface_set_texture_name(surface, 0, FALSE);
surface_set_texture_target(surface, 0);
surface_set_container(surface, WINED3D_CONTAINER_NONE, NULL);
IWineD3DSurface_Release((IWineD3DSurface *)surface);
}
}
basetexture_cleanup((IWineD3DBaseTexture *)This);
}
/* *******************************************
IWineD3DCubeTexture IUnknown parts follow
******************************************* */
static HRESULT WINAPI IWineD3DCubeTextureImpl_QueryInterface(IWineD3DCubeTexture *iface, REFIID riid, LPVOID *ppobj)
{
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| IsEqualGUID(riid, &IID_IWineD3DResource)
|| IsEqualGUID(riid, &IID_IWineD3DBaseTexture)
|| IsEqualGUID(riid, &IID_IWineD3DCubeTexture)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IWineD3DCubeTextureImpl_AddRef(IWineD3DCubeTexture *iface) {
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
TRACE("(%p) : AddRef increasing from %d\n", This, This->resource.ref);
return InterlockedIncrement(&This->resource.ref);
}
/* Do not call while under the GL lock. */
static ULONG WINAPI IWineD3DCubeTextureImpl_Release(IWineD3DCubeTexture *iface) {
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
ULONG ref;
TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
ref = InterlockedDecrement(&This->resource.ref);
if (!ref)
{
cubetexture_cleanup(This);
This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* ****************************************************
IWineD3DCubeTexture IWineD3DResource parts follow
**************************************************** */
static HRESULT WINAPI IWineD3DCubeTextureImpl_SetPrivateData(IWineD3DCubeTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IWineD3DCubeTextureImpl_GetPrivateData(IWineD3DCubeTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IWineD3DCubeTextureImpl_FreePrivateData(IWineD3DCubeTexture *iface, REFGUID refguid) {
return resource_free_private_data((IWineD3DResource *)iface, refguid);
}
static DWORD WINAPI IWineD3DCubeTextureImpl_SetPriority(IWineD3DCubeTexture *iface, DWORD PriorityNew) {
return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
}
static DWORD WINAPI IWineD3DCubeTextureImpl_GetPriority(IWineD3DCubeTexture *iface) {
return resource_get_priority((IWineD3DResource *)iface);
}
/* Do not call while under the GL lock. */
static void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
cubetexture_internal_preload((IWineD3DBaseTexture *) iface, SRGB_ANY);
}
/* Do not call while under the GL lock. */
static void WINAPI IWineD3DCubeTextureImpl_UnLoad(IWineD3DCubeTexture *iface)
{
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
UINT sub_count = This->baseTexture.level_count * This->baseTexture.layer_count;
UINT i;
TRACE("iface %p.\n", iface);
/* Unload all the surfaces and reset the texture name. If UnLoad was called on the
* surface before, this one will be a NOP and vice versa. Unloading an unloaded
* surface is fine. */
for (i = 0; i < sub_count; ++i)
{
IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)This->baseTexture.sub_resources[i];
IWineD3DSurface_UnLoad((IWineD3DSurface *)surface);
surface_set_texture_name(surface, 0, TRUE);
surface_set_texture_name(surface, 0, FALSE);
}
basetexture_unload((IWineD3DBaseTexture *)iface);
}
static WINED3DRESOURCETYPE WINAPI IWineD3DCubeTextureImpl_GetType(IWineD3DCubeTexture *iface) {
return resource_get_type((IWineD3DResource *)iface);
}
static void * WINAPI IWineD3DCubeTextureImpl_GetParent(IWineD3DCubeTexture *iface)
{
TRACE("iface %p.\n", iface);
return ((IWineD3DCubeTextureImpl *)iface)->resource.parent;
}
/* ******************************************************
IWineD3DCubeTexture IWineD3DBaseTexture parts follow
****************************************************** */
static DWORD WINAPI IWineD3DCubeTextureImpl_SetLOD(IWineD3DCubeTexture *iface, DWORD LODNew) {
return basetexture_set_lod((IWineD3DBaseTexture *)iface, LODNew);
}
static DWORD WINAPI IWineD3DCubeTextureImpl_GetLOD(IWineD3DCubeTexture *iface) {
return basetexture_get_lod((IWineD3DBaseTexture *)iface);
}
static DWORD WINAPI IWineD3DCubeTextureImpl_GetLevelCount(IWineD3DCubeTexture *iface) {
return basetexture_get_level_count((IWineD3DBaseTexture *)iface);
}
static HRESULT WINAPI IWineD3DCubeTextureImpl_SetAutoGenFilterType(IWineD3DCubeTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
return basetexture_set_autogen_filter_type((IWineD3DBaseTexture *)iface, FilterType);
}
static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DCubeTextureImpl_GetAutoGenFilterType(IWineD3DCubeTexture *iface) {
return basetexture_get_autogen_filter_type((IWineD3DBaseTexture *)iface);
}
static void WINAPI IWineD3DCubeTextureImpl_GenerateMipSubLevels(IWineD3DCubeTexture *iface) {
basetexture_generate_mipmaps((IWineD3DBaseTexture *)iface);
}
/* Internal function, No d3d mapping */
static BOOL WINAPI IWineD3DCubeTextureImpl_SetDirty(IWineD3DCubeTexture *iface, BOOL dirty) {
return basetexture_set_dirty((IWineD3DBaseTexture *)iface, dirty);
}
/* Internal function, No d3d mapping */
static BOOL WINAPI IWineD3DCubeTextureImpl_GetDirty(IWineD3DCubeTexture *iface) {
return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
}
/* Context activation is done by the caller. */
static HRESULT WINAPI IWineD3DCubeTextureImpl_BindTexture(IWineD3DCubeTexture *iface, BOOL srgb) {
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
BOOL set_gl_texture_desc;
HRESULT hr;
TRACE("(%p) : relay to BaseTexture\n", This);
hr = basetexture_bind((IWineD3DBaseTexture *)iface, srgb, &set_gl_texture_desc);
if (set_gl_texture_desc && SUCCEEDED(hr))
{
UINT sub_count = This->baseTexture.level_count * This->baseTexture.layer_count;
UINT i;
for (i = 0; i < sub_count; ++i)
{
IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)This->baseTexture.sub_resources[i];
if (This->baseTexture.is_srgb)
surface_set_texture_name(surface, This->baseTexture.texture_srgb.name, TRUE);
else
surface_set_texture_name(surface, This->baseTexture.texture_rgb.name, FALSE);
}
}
return hr;
}
static BOOL WINAPI IWineD3DCubeTextureImpl_IsCondNP2(IWineD3DCubeTexture *iface)
{
TRACE("iface %p.\n", iface);
return FALSE;
}
/* *******************************************
IWineD3DCubeTexture IWineD3DCubeTexture parts follow
******************************************* */
static HRESULT WINAPI IWineD3DCubeTextureImpl_GetLevelDesc(IWineD3DCubeTexture *iface,
UINT level, WINED3DSURFACE_DESC *desc)
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
IWineD3DSurface *surface;
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
if (!(surface = (IWineD3DSurface *)basetexture_get_sub_resource(texture, 0, level)))
{
WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL;
}
IWineD3DSurface_GetDesc(surface, desc);
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DCubeTextureImpl_GetCubeMapSurface(IWineD3DCubeTexture *iface,
WINED3DCUBEMAP_FACES face, UINT level, IWineD3DSurface **surface)
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
IWineD3DSurface *s;
TRACE("iface %p, face %u, level %u, surface %p.\n",
iface, face, level, surface);
if (!(s = (IWineD3DSurface *)basetexture_get_sub_resource(texture, face, level)))
{
WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL;
}
IWineD3DSurface_AddRef(s);
*surface = s;
TRACE("Returning surface %p.\n", *surface);
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DCubeTextureImpl_LockRect(IWineD3DCubeTexture *iface,
WINED3DCUBEMAP_FACES face, UINT level, WINED3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags)
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
IWineD3DSurface *surface;
TRACE("iface %p, face %u, level %u, locked_rect %p, rect %s, flags %#x.\n",
iface, face, level, locked_rect, wine_dbgstr_rect(rect), flags);
if (!(surface = (IWineD3DSurface *)basetexture_get_sub_resource(texture, face, level)))
{
WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL;
}
return IWineD3DSurface_LockRect(surface, locked_rect, rect, flags);
}
static HRESULT WINAPI IWineD3DCubeTextureImpl_UnlockRect(IWineD3DCubeTexture *iface,
WINED3DCUBEMAP_FACES face, UINT level)
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
IWineD3DSurface *surface;
TRACE("iface %p, face %u, level %u.\n",
iface, face, level);
if (!(surface = (IWineD3DSurface *)basetexture_get_sub_resource(texture, face, level)))
{
WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL;
}
return IWineD3DSurface_UnlockRect(surface);
}
static HRESULT WINAPI IWineD3DCubeTextureImpl_AddDirtyRect(IWineD3DCubeTexture *iface,
WINED3DCUBEMAP_FACES face, const RECT *dirty_rect)
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
IWineD3DSurfaceImpl *surface;
TRACE("iface %p, face %u, dirty_rect %s.\n",
iface, face, wine_dbgstr_rect(dirty_rect));
if (!(surface = (IWineD3DSurfaceImpl *)basetexture_get_sub_resource(texture, face, 0)))
{
WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL;
}
texture->baseTexture.texture_rgb.dirty = TRUE;
texture->baseTexture.texture_srgb.dirty = TRUE;
surface_add_dirty_rect(surface, dirty_rect);
return WINED3D_OK;
}
static const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl =
{
/* IUnknown */
IWineD3DCubeTextureImpl_QueryInterface,
IWineD3DCubeTextureImpl_AddRef,
IWineD3DCubeTextureImpl_Release,
/* IWineD3DResource */
IWineD3DCubeTextureImpl_GetParent,
IWineD3DCubeTextureImpl_SetPrivateData,
IWineD3DCubeTextureImpl_GetPrivateData,
IWineD3DCubeTextureImpl_FreePrivateData,
IWineD3DCubeTextureImpl_SetPriority,
IWineD3DCubeTextureImpl_GetPriority,
IWineD3DCubeTextureImpl_PreLoad,
IWineD3DCubeTextureImpl_UnLoad,
IWineD3DCubeTextureImpl_GetType,
/* IWineD3DBaseTexture */
IWineD3DCubeTextureImpl_SetLOD,
IWineD3DCubeTextureImpl_GetLOD,
IWineD3DCubeTextureImpl_GetLevelCount,
IWineD3DCubeTextureImpl_SetAutoGenFilterType,
IWineD3DCubeTextureImpl_GetAutoGenFilterType,
IWineD3DCubeTextureImpl_GenerateMipSubLevels,
IWineD3DCubeTextureImpl_SetDirty,
IWineD3DCubeTextureImpl_GetDirty,
IWineD3DCubeTextureImpl_BindTexture,
IWineD3DCubeTextureImpl_IsCondNP2,
/* IWineD3DCubeTexture */
IWineD3DCubeTextureImpl_GetLevelDesc,
IWineD3DCubeTextureImpl_GetCubeMapSurface,
IWineD3DCubeTextureImpl_LockRect,
IWineD3DCubeTextureImpl_UnlockRect,
IWineD3DCubeTextureImpl_AddDirtyRect
};
HRESULT cubetexture_init(IWineD3DCubeTextureImpl *texture, UINT edge_length, UINT levels,
IWineD3DDeviceImpl *device, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool,
void *parent, const struct wined3d_parent_ops *parent_ops)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
UINT pow2_edge_length;
unsigned int i, j;
UINT tmp_w;
HRESULT hr;
/* TODO: It should only be possible to create textures for formats
* that are reported as supported. */
if (WINED3DFMT_UNKNOWN >= format_id)
{
WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
return WINED3DERR_INVALIDCALL;
}
if (!gl_info->supported[ARB_TEXTURE_CUBE_MAP] && pool != WINED3DPOOL_SCRATCH)
{
WARN("(%p) : Tried to create not supported cube texture.\n", texture);
return WINED3DERR_INVALIDCALL;
}
/* Calculate levels for mip mapping */
if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
{
if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
{
WARN("No mipmap generation support, returning D3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
if (levels > 1)
{
WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning D3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
levels = 1;
}
else if (!levels)
{
levels = wined3d_log2i(edge_length) + 1;
TRACE("Calculated levels = %u.\n", levels);
}
texture->lpVtbl = &IWineD3DCubeTexture_Vtbl;
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, 6, levels,
WINED3DRTYPE_CUBETEXTURE, device, 0, usage, format, pool, parent, parent_ops);
if (FAILED(hr))
{
WARN("Failed to initialize basetexture, returning %#x\n", hr);
return hr;
}
/* Find the nearest pow2 match. */
pow2_edge_length = 1;
while (pow2_edge_length < edge_length) pow2_edge_length <<= 1;
if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] || (edge_length == pow2_edge_length))
{
/* Precalculated scaling for 'faked' non power of two texture coords. */
texture->baseTexture.pow2Matrix[0] = 1.0f;
texture->baseTexture.pow2Matrix[5] = 1.0f;
texture->baseTexture.pow2Matrix[10] = 1.0f;
texture->baseTexture.pow2Matrix[15] = 1.0f;
}
else
{
/* Precalculated scaling for 'faked' non power of two texture coords. */
texture->baseTexture.pow2Matrix[0] = ((float)edge_length) / ((float)pow2_edge_length);
texture->baseTexture.pow2Matrix[5] = ((float)edge_length) / ((float)pow2_edge_length);
texture->baseTexture.pow2Matrix[10] = ((float)edge_length) / ((float)pow2_edge_length);
texture->baseTexture.pow2Matrix[15] = 1.0f;
texture->baseTexture.pow2Matrix_identity = FALSE;
}
texture->baseTexture.target = GL_TEXTURE_CUBE_MAP_ARB;
/* Generate all the surfaces. */
tmp_w = edge_length;
for (i = 0; i < texture->baseTexture.level_count; ++i)
{
/* Create the 6 faces. */
for (j = 0; j < 6; ++j)
{
static const GLenum cube_targets[6] =
{
GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
};
UINT idx = j * texture->baseTexture.level_count + i;
IWineD3DSurface *surface;
hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_w,
format_id, usage, pool, i /* Level */, j, &surface);
if (FAILED(hr))
{
FIXME("(%p) Failed to create surface, hr %#x.\n", texture, hr);
cubetexture_cleanup(texture);
return hr;
}
surface_set_container((IWineD3DSurfaceImpl *)surface, WINED3D_CONTAINER_TEXTURE, (IWineD3DBase *)texture);
surface_set_texture_target((IWineD3DSurfaceImpl *)surface, cube_targets[j]);
texture->baseTexture.sub_resources[idx] = (IWineD3DResourceImpl *)surface;
TRACE("Created surface level %u @ %p.\n", i, surface);
}
tmp_w = max(1, tmp_w >> 1);
}
texture->baseTexture.internal_preload = cubetexture_internal_preload;
return WINED3D_OK;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -55,7 +55,7 @@ static void drawStridedFast(GLenum primitive_type, UINT count, UINT idx_size, co
*/
/* GL locking is done by the caller */
static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context *context,
static void drawStridedSlow(struct wined3d_device *device, const struct wined3d_context *context,
const struct wined3d_stream_info *si, UINT NumVertexes, GLenum glPrimType,
const void *idxData, UINT idxSize, UINT startIdx)
{
@ -63,8 +63,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context
const WORD *pIdxBufS = NULL;
const DWORD *pIdxBufL = NULL;
UINT vx_index;
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
const struct wined3d_state *state = &This->stateBlock->state;
const struct wined3d_state *state = &device->stateBlock->state;
const struct wined3d_stream_state *streams = state->streams;
LONG SkipnStrides = startIdx + state->load_base_vertex_index;
BOOL pixelShader = use_ps(state);
@ -166,7 +165,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context
for (textureNo = 0; textureNo < texture_stages; ++textureNo)
{
int coordIdx = state->texture_states[textureNo][WINED3DTSS_TEXCOORDINDEX];
DWORD texture_idx = This->texUnitMap[textureNo];
DWORD texture_idx = device->texUnitMap[textureNo];
if (!gl_info->supported[ARB_MULTITEXTURE] && textureNo > 0)
{
@ -238,7 +237,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context
coord_idx = state->texture_states[texture][WINED3DTSS_TEXCOORDINDEX];
ptr = texCoords[coord_idx] + (SkipnStrides * si->elements[WINED3D_FFP_TEXCOORD0 + coord_idx].stride);
texture_idx = This->texUnitMap[texture];
texture_idx = device->texUnitMap[texture];
multi_texcoord_funcs[si->elements[WINED3D_FFP_TEXCOORD0 + coord_idx].format->emit_idx](
GL_TEXTURE0_ARB + texture_idx, ptr);
}
@ -275,7 +274,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context
if (specular_fog)
{
DWORD specularColor = *(const DWORD *)ptrToCoords;
GL_EXTCALL(glFogCoordfEXT(specularColor >> 24));
GL_EXTCALL(glFogCoordfEXT((float) (specularColor >> 24)));
}
}
@ -559,11 +558,9 @@ static void remove_vbos(const struct wined3d_gl_info *gl_info,
}
/* Routine common to the draw primitive and draw indexed primitive routines */
void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT idxSize, const void *idxData)
void drawPrimitive(struct wined3d_device *device, UINT index_count, UINT StartIdx, UINT idxSize, const void *idxData)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
const struct wined3d_state *state = &This->stateBlock->state;
const struct wined3d_state *state = &device->stateBlock->state;
struct wined3d_context *context;
unsigned int i;
@ -572,9 +569,9 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
if (state->render_states[WINED3DRS_COLORWRITEENABLE])
{
/* Invalidate the back buffer memory so LockRect will read it the next time */
for (i = 0; i < This->adapter->gl_info.limits.buffers; ++i)
for (i = 0; i < device->adapter->gl_info.limits.buffers; ++i)
{
IWineD3DSurfaceImpl *target = This->render_targets[i];
struct wined3d_surface *target = device->fb.render_targets[i];
if (target)
{
surface_load_location(target, SFLAG_INDRAWABLE, NULL);
@ -584,9 +581,9 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
}
/* Signals other modules that a drawing is in progress and the stateblock finalized */
This->isInDraw = TRUE;
device->isInDraw = TRUE;
context = context_acquire(This, This->render_targets[0]);
context = context_acquire(device, device->fb.render_targets[0]);
if (!context->valid)
{
context_release(context);
@ -594,42 +591,44 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
return;
}
context_apply_draw_state(context, This);
if (!context_apply_draw_state(context, device))
{
context_release(context);
WARN("Unable to apply draw state, skipping draw.\n");
return;
}
if (This->depth_stencil)
if (device->fb.depth_stencil)
{
/* Note that this depends on the context_acquire() call above to set
* This->render_offscreen properly. We don't currently take the
* context->render_offscreen properly. We don't currently take the
* Z-compare function into account, but we could skip loading the
* depthstencil for D3DCMP_NEVER and D3DCMP_ALWAYS as well. Also note
* that we never copy the stencil data.*/
DWORD location = context->render_offscreen ? SFLAG_DS_OFFSCREEN : SFLAG_DS_ONSCREEN;
if (state->render_states[WINED3DRS_ZWRITEENABLE] || state->render_states[WINED3DRS_ZENABLE])
{
struct wined3d_surface *ds = device->fb.depth_stencil;
RECT current_rect, draw_rect, r;
if (location == SFLAG_DS_ONSCREEN && This->depth_stencil != This->onscreen_depth_stencil)
device_switch_onscreen_ds(This, context, This->depth_stencil);
if (location == SFLAG_DS_ONSCREEN && ds != device->onscreen_depth_stencil)
device_switch_onscreen_ds(device, context, ds);
if (This->depth_stencil->Flags & location)
SetRect(&current_rect, 0, 0,
This->depth_stencil->ds_current_size.cx,
This->depth_stencil->ds_current_size.cy);
if (ds->flags & location)
SetRect(&current_rect, 0, 0, ds->ds_current_size.cx, ds->ds_current_size.cy);
else
SetRectEmpty(&current_rect);
device_get_draw_rect(This, &draw_rect);
device_get_draw_rect(device, &draw_rect);
IntersectRect(&r, &draw_rect, &current_rect);
if (!EqualRect(&r, &draw_rect))
surface_load_ds_location(This->depth_stencil, context, location);
surface_load_ds_location(ds, context, location);
if (state->render_states[WINED3DRS_ZWRITEENABLE])
{
surface_modify_ds_location(This->depth_stencil, location,
This->depth_stencil->ds_current_size.cx,
This->depth_stencil->ds_current_size.cy);
surface_modify_location(This->depth_stencil, SFLAG_INDRAWABLE, TRUE);
surface_modify_ds_location(ds, location, ds->ds_current_size.cx, ds->ds_current_size.cy);
surface_modify_location(ds, SFLAG_INDRAWABLE, TRUE);
}
}
}
@ -648,12 +647,12 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
{
GLenum glPrimType = state->gl_primitive_type;
BOOL emulation = FALSE;
const struct wined3d_stream_info *stream_info = &This->strided_streams;
const struct wined3d_stream_info *stream_info = &device->strided_streams;
struct wined3d_stream_info stridedlcl;
if (!use_vs(state))
{
if (!This->strided_streams.position_transformed && context->num_untracked_materials
if (!stream_info->position_transformed && context->num_untracked_materials
&& state->render_states[WINED3DRS_LIGHTING])
{
static BOOL warned;
@ -682,12 +681,12 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
if(emulation) {
stream_info = &stridedlcl;
memcpy(&stridedlcl, &This->strided_streams, sizeof(stridedlcl));
memcpy(&stridedlcl, &device->strided_streams, sizeof(stridedlcl));
remove_vbos(context->gl_info, state, &stridedlcl);
}
}
if (This->useDrawStridedSlow || emulation)
if (device->useDrawStridedSlow || emulation)
{
/* Immediate mode drawing */
if (use_vs(state))
@ -704,11 +703,11 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
}
else
{
drawStridedSlow(iface, context, stream_info, index_count,
drawStridedSlow(device, context, stream_info, index_count,
glPrimType, idxData, idxSize, StartIdx);
}
}
else if (This->instancedDraw)
else if (device->instancedDraw)
{
/* Instancing emulation with mixing immediate mode and arrays */
drawStridedInstanced(context->gl_info, state, stream_info,
@ -723,9 +722,9 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
/* Finished updating the screen, restore lock */
LEAVE_GL();
for(i = 0; i < This->num_buffer_queries; i++)
for(i = 0; i < device->num_buffer_queries; ++i)
{
wined3d_event_query_issue(This->buffer_queries[i], This);
wined3d_event_query_issue(device->buffer_queries[i], device);
}
if (wined3d_settings.strict_draw_ordering) wglFlush(); /* Flush to ensure ordering across contexts. */
@ -735,7 +734,7 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT
TRACE("Done all gl drawing\n");
/* Control goes back to the device, stateblock values may change again */
This->isInDraw = FALSE;
device->isInDraw = FALSE;
}
static void normalize_normal(float *n) {
@ -769,8 +768,8 @@ static void normalize_normal(float *n) {
* responsible of taking care that either the gl states are restored, or the context activated
* for drawing to reset the lastWasBlit flag.
*/
HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
struct WineD3DRectPatch *patch) {
HRESULT tesselate_rectpatch(struct wined3d_device *This, struct WineD3DRectPatch *patch)
{
unsigned int i, j, num_quads, out_vertex_size, buffer_size, d3d_out_vertex_size;
float max_x = 0.0f, max_y = 0.0f, max_z = 0.0f, neg_z = 0.0f;
struct wined3d_stream_info stream_info;
@ -842,7 +841,7 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
glMatrixMode(GL_PROJECTION);
checkGLcall("glMatrixMode(GL_PROJECTION)");
glLoadIdentity();
checkGLcall("glLoadIndentity()");
checkGLcall("glLoadIdentity()");
glScalef(1.0f / (max_x), 1.0f / (max_y), max_z == 0.0f ? 1.0f : 1.0f / (2.0f * max_z));
glTranslatef(0.0f, 0.0f, 0.5f);
checkGLcall("glScalef");

View file

@ -178,9 +178,9 @@ static void WINE_GLAPI wine_glFogi(GLenum pname, GLint param) {
}
} else {
if(pname == GL_FOG_START) {
ctx->fogstart = param;
ctx->fogstart = (float) param;
} else if(pname == GL_FOG_END) {
ctx->fogend = param;
ctx->fogend = (float) param;
}
old_fogcoord_glFogi(pname, param);
}
@ -199,9 +199,9 @@ static void WINE_GLAPI wine_glFogiv(GLenum pname, const GLint *param) {
}
} else {
if(pname == GL_FOG_START) {
ctx->fogstart = *param;
ctx->fogstart = (float) *param;
} else if(pname == GL_FOG_END) {
ctx->fogend = *param;
ctx->fogend = (float) *param;
}
old_fogcoord_glFogiv(pname, param);
}
@ -331,13 +331,13 @@ static void WINE_GLAPI wine_glFogCoordfEXT(GLfloat f) {
ctx->fog_coord_value = f;
}
static void WINE_GLAPI wine_glFogCoorddEXT(GLdouble f) {
wine_glFogCoordfEXT(f);
wine_glFogCoordfEXT((GLfloat) f);
}
static void WINE_GLAPI wine_glFogCoordfvEXT(const GLfloat *f) {
wine_glFogCoordfEXT(*f);
}
static void WINE_GLAPI wine_glFogCoorddvEXT(const GLdouble *f) {
wine_glFogCoordfEXT(*f);
wine_glFogCoordfEXT((GLfloat) *f);
}
/* End GL_EXT_fog_coord emulation */

File diff suppressed because it is too large Load diff

View file

@ -45,7 +45,7 @@ static void nvts_activate_dimensions(const struct wined3d_state *state, DWORD st
if (state->textures[stage])
{
switch (state->textures[stage]->baseTexture.target)
switch (state->textures[stage]->target)
{
case GL_TEXTURE_2D:
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, bumpmap ? GL_OFFSET_TEXTURE_2D_NV : GL_TEXTURE_2D);
@ -456,7 +456,7 @@ void set_tex_op_nvrc(const struct wined3d_gl_info *gl_info, const struct wined3d
}
static void nvrc_colorop(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
static void nvrc_colorop(DWORD state_id, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
DWORD stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
BOOL tex_used = stateblock->device->fixed_function_usage_map & (1 << stage);
@ -566,7 +566,7 @@ static void nvrc_colorop(DWORD state_id, IWineD3DStateBlockImpl *stateblock, str
}
}
static void nvts_texdim(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
static void nvts_texdim(DWORD state_id, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
DWORD sampler = state_id - STATE_SAMPLER(0);
DWORD mapped_stage = stateblock->device->texUnitMap[sampler];
@ -583,7 +583,7 @@ static void nvts_texdim(DWORD state_id, IWineD3DStateBlockImpl *stateblock, stru
nvts_activate_dimensions(state, sampler, context);
}
static void nvts_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
static void nvts_bumpenvmat(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
DWORD mapped_stage = stateblock->device->texUnitMap[stage + 1];
@ -612,7 +612,7 @@ static void nvts_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, str
}
}
static void nvrc_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
static void nvrc_texfactor(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
float col[4];
@ -621,11 +621,11 @@ static void nvrc_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, stru
}
/* Context activation is done by the caller. */
static void nvrc_enable(IWineD3DDevice *iface, BOOL enable) { }
static void nvrc_enable(BOOL enable) {}
/* Context activation is done by the caller. */
static void nvts_enable(IWineD3DDevice *iface, BOOL enable) {
ENTER_GL();
/* Context activation and GL locking are done by the caller. */
static void nvts_enable(BOOL enable)
{
if(enable) {
glEnable(GL_TEXTURE_SHADER_NV);
checkGLcall("glEnable(GL_TEXTURE_SHADER_NV)");
@ -633,68 +633,66 @@ static void nvts_enable(IWineD3DDevice *iface, BOOL enable) {
glDisable(GL_TEXTURE_SHADER_NV);
checkGLcall("glDisable(GL_TEXTURE_SHADER_NV)");
}
LEAVE_GL();
}
static void nvrc_fragment_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *pCaps)
static void nvrc_fragment_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps)
{
pCaps->PrimitiveMiscCaps = WINED3DPMISCCAPS_TSSARGTEMP;
caps->PrimitiveMiscCaps = WINED3DPMISCCAPS_TSSARGTEMP;
/* The caps below can be supported but aren't handled yet in utils.c
* 'd3dta_to_combiner_input', disable them until support is fixed */
#if 0
if (gl_info->supported[NV_REGISTER_COMBINERS2])
pCaps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_PERSTAGECONSTANT;
caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_PERSTAGECONSTANT;
#endif
pCaps->TextureOpCaps = WINED3DTEXOPCAPS_ADD |
WINED3DTEXOPCAPS_ADDSIGNED |
WINED3DTEXOPCAPS_ADDSIGNED2X |
WINED3DTEXOPCAPS_MODULATE |
WINED3DTEXOPCAPS_MODULATE2X |
WINED3DTEXOPCAPS_MODULATE4X |
WINED3DTEXOPCAPS_SELECTARG1 |
WINED3DTEXOPCAPS_SELECTARG2 |
WINED3DTEXOPCAPS_DISABLE |
WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA |
WINED3DTEXOPCAPS_BLENDTEXTUREALPHA |
WINED3DTEXOPCAPS_BLENDFACTORALPHA |
WINED3DTEXOPCAPS_BLENDCURRENTALPHA |
WINED3DTEXOPCAPS_LERP |
WINED3DTEXOPCAPS_SUBTRACT |
WINED3DTEXOPCAPS_ADDSMOOTH |
WINED3DTEXOPCAPS_MULTIPLYADD |
WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR |
WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA |
WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM |
WINED3DTEXOPCAPS_DOTPRODUCT3 |
WINED3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR |
WINED3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA;
caps->TextureOpCaps = WINED3DTEXOPCAPS_ADD
| WINED3DTEXOPCAPS_ADDSIGNED
| WINED3DTEXOPCAPS_ADDSIGNED2X
| WINED3DTEXOPCAPS_MODULATE
| WINED3DTEXOPCAPS_MODULATE2X
| WINED3DTEXOPCAPS_MODULATE4X
| WINED3DTEXOPCAPS_SELECTARG1
| WINED3DTEXOPCAPS_SELECTARG2
| WINED3DTEXOPCAPS_DISABLE
| WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA
| WINED3DTEXOPCAPS_BLENDTEXTUREALPHA
| WINED3DTEXOPCAPS_BLENDFACTORALPHA
| WINED3DTEXOPCAPS_BLENDCURRENTALPHA
| WINED3DTEXOPCAPS_LERP
| WINED3DTEXOPCAPS_SUBTRACT
| WINED3DTEXOPCAPS_ADDSMOOTH
| WINED3DTEXOPCAPS_MULTIPLYADD
| WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
| WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
| WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM
| WINED3DTEXOPCAPS_DOTPRODUCT3
| WINED3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR
| WINED3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA;
if (gl_info->supported[NV_TEXTURE_SHADER2])
{
/* Bump mapping is supported already in NV_TEXTURE_SHADER, but that extension does
* not support 3D textures. This asks for trouble if an app uses both bump mapping
* and 3D textures. It also allows us to keep the code simpler by having texture
* shaders constantly enabled.
*/
pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_BUMPENVMAP;
* shaders constantly enabled. */
caps->TextureOpCaps |= WINED3DTEXOPCAPS_BUMPENVMAP;
/* TODO: Luminance bump map? */
}
#if 0
/* FIXME: Add
pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_BUMPENVMAPLUMINANCE
caps->TextureOpCaps |= WINED3DTEXOPCAPS_BUMPENVMAPLUMINANCE
WINED3DTEXOPCAPS_PREMODULATE */
#endif
pCaps->MaxTextureBlendStages = min(MAX_TEXTURES, gl_info->limits.general_combiners);
pCaps->MaxSimultaneousTextures = gl_info->limits.textures;
caps->MaxTextureBlendStages = min(MAX_TEXTURES, gl_info->limits.general_combiners);
caps->MaxSimultaneousTextures = gl_info->limits.textures;
}
static HRESULT nvrc_fragment_alloc(IWineD3DDevice *iface) { return WINED3D_OK; }
static HRESULT nvrc_fragment_alloc(struct wined3d_device *device) { return WINED3D_OK; }
/* Context activation is done by the caller. */
static void nvrc_fragment_free(IWineD3DDevice *iface) {}
static void nvrc_fragment_free(struct wined3d_device *device) {}
/* Two fixed function pipeline implementations using GL_NV_register_combiners and
* GL_NV_texture_shader. The nvts_fragment_pipeline assumes that both extensions

View file

@ -30,183 +30,145 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define SIZE_BITS (WINEDDPCAPS_1BIT | WINEDDPCAPS_2BIT | WINEDDPCAPS_4BIT | WINEDDPCAPS_8BIT)
static HRESULT WINAPI IWineD3DPaletteImpl_QueryInterface(IWineD3DPalette *iface, REFIID riid, void **object)
ULONG CDECL wined3d_palette_incref(struct wined3d_palette *palette)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
ULONG refcount = InterlockedIncrement(&palette->ref);
if (IsEqualGUID(riid, &IID_IWineD3DPalette)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| IsEqualGUID(riid, &IID_IUnknown))
TRACE("%p increasing refcount to %u.\n", palette, refcount);
return refcount;
}
ULONG CDECL wined3d_palette_decref(struct wined3d_palette *palette)
{
ULONG refcount = InterlockedDecrement(&palette->ref);
TRACE("%p decreasing refcount to %u.\n", palette, refcount);
if (!refcount)
{
IUnknown_AddRef(iface);
*object = iface;
return S_OK;
DeleteObject(palette->hpal);
HeapFree(GetProcessHeap(), 0, palette);
}
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
*object = NULL;
return E_NOINTERFACE;
return refcount;
}
static ULONG WINAPI IWineD3DPaletteImpl_AddRef(IWineD3DPalette *iface) {
IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
return ref;
}
static ULONG WINAPI IWineD3DPaletteImpl_Release(IWineD3DPalette *iface) {
IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
if (!ref) {
DeleteObject(This->hpal);
HeapFree(GetProcessHeap(), 0, This);
return 0;
}
return ref;
}
/* Not called from the vtable */
static WORD IWineD3DPaletteImpl_Size(DWORD dwFlags)
static WORD wined3d_palette_size(DWORD flags)
{
switch (dwFlags & SIZE_BITS) {
switch (flags & SIZE_BITS)
{
case WINEDDPCAPS_1BIT: return 2;
case WINEDDPCAPS_2BIT: return 4;
case WINEDDPCAPS_4BIT: return 16;
case WINEDDPCAPS_8BIT: return 256;
default:
FIXME("Unhandled size bits %#x.\n", dwFlags & SIZE_BITS);
FIXME("Unhandled size bits %#x.\n", flags & SIZE_BITS);
return 256;
}
}
static HRESULT WINAPI IWineD3DPaletteImpl_GetEntries(IWineD3DPalette *iface, DWORD Flags, DWORD Start, DWORD Count, PALETTEENTRY *PalEnt) {
IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface;
HRESULT CDECL wined3d_palette_get_entries(const struct wined3d_palette *palette,
DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries)
{
TRACE("palette %p, flags %#x, start %u, count %u, entries %p.\n",
palette, flags, start, count, entries);
TRACE("(%p)->(%08x,%d,%d,%p)\n",This,Flags,Start,Count,PalEnt);
if (Flags) return WINED3DERR_INVALIDCALL; /* unchecked */
if (Start + Count > IWineD3DPaletteImpl_Size(This->Flags))
if (flags) return WINED3DERR_INVALIDCALL; /* unchecked */
if (start + count > wined3d_palette_size(palette->flags))
return WINED3DERR_INVALIDCALL;
if (This->Flags & WINEDDPCAPS_8BITENTRIES)
if (palette->flags & WINEDDPCAPS_8BITENTRIES)
{
BYTE *entry = (BYTE *)entries;
unsigned int i;
LPBYTE entry = (LPBYTE)PalEnt;
for (i=Start; i < Count+Start; i++)
*entry++ = This->palents[i].peRed;
for (i = start; i < count + start; ++i)
*entry++ = palette->palents[i].peRed;
}
else
memcpy(PalEnt, This->palents+Start, Count * sizeof(PALETTEENTRY));
memcpy(entries, palette->palents + start, count * sizeof(*entries));
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DPaletteImpl_SetEntries(IWineD3DPalette *iface,
DWORD Flags, DWORD Start, DWORD Count, const PALETTEENTRY *PalEnt)
HRESULT CDECL wined3d_palette_set_entries(struct wined3d_palette *palette,
DWORD flags, DWORD start, DWORD count, const PALETTEENTRY *entries)
{
IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface;
IWineD3DResourceImpl *res;
struct wined3d_resource *resource;
TRACE("(%p)->(%08x,%d,%d,%p)\n",This,Flags,Start,Count,PalEnt);
TRACE("Palette flags: %#x\n", This->Flags);
TRACE("palette %p, flags %#x, start %u, count %u, entries %p.\n",
palette, flags, start, count, entries);
TRACE("Palette flags: %#x.\n", palette->flags);
if (This->Flags & WINEDDPCAPS_8BITENTRIES) {
if (palette->flags & WINEDDPCAPS_8BITENTRIES)
{
const BYTE *entry = (const BYTE *)entries;
unsigned int i;
const BYTE* entry = (const BYTE*)PalEnt;
for (i=Start; i < Count+Start; i++)
This->palents[i].peRed = *entry++;
for (i = start; i < count + start; ++i)
palette->palents[i].peRed = *entry++;
}
else {
memcpy(This->palents+Start, PalEnt, Count * sizeof(PALETTEENTRY));
else
{
memcpy(palette->palents + start, entries, count * sizeof(*palette->palents));
/* When WINEDDCAPS_ALLOW256 isn't set we need to override entry 0 with black and 255 with white */
if(!(This->Flags & WINEDDPCAPS_ALLOW256))
if (!(palette->flags & WINEDDPCAPS_ALLOW256))
{
TRACE("WINEDDPCAPS_ALLOW256 set, overriding palette entry 0 with black and 255 with white\n");
This->palents[0].peRed = 0;
This->palents[0].peGreen = 0;
This->palents[0].peBlue = 0;
palette->palents[0].peRed = 0;
palette->palents[0].peGreen = 0;
palette->palents[0].peBlue = 0;
This->palents[255].peRed = 255;
This->palents[255].peGreen = 255;
This->palents[255].peBlue = 255;
palette->palents[255].peRed = 255;
palette->palents[255].peGreen = 255;
palette->palents[255].peBlue = 255;
}
if (This->hpal)
SetPaletteEntries(This->hpal, Start, Count, This->palents+Start);
if (palette->hpal)
SetPaletteEntries(palette->hpal, start, count, palette->palents + start);
}
#if 0
/* Now, if we are in 'depth conversion mode', update the screen palette */
/* FIXME: we need to update the image or we won't get palette fading. */
if (This->ddraw->d->palette_convert)
This->ddraw->d->palette_convert(palent,This->screen_palents,start,count);
#endif
/* If the palette is attached to the render target, update all render targets */
LIST_FOR_EACH_ENTRY(res, &This->device->resources, IWineD3DResourceImpl, resource.resource_list_entry)
LIST_FOR_EACH_ENTRY(resource, &palette->device->resources, struct wined3d_resource, resource_list_entry)
{
if(IWineD3DResource_GetType((IWineD3DResource *) res) == WINED3DRTYPE_SURFACE) {
IWineD3DSurfaceImpl *impl = (IWineD3DSurfaceImpl *) res;
if(impl->palette == This)
IWineD3DSurface_RealizePalette((IWineD3DSurface *) res);
if (resource->resourceType == WINED3DRTYPE_SURFACE)
{
struct wined3d_surface *surface = surface_from_resource(resource);
if (surface->palette == palette)
surface->surface_ops->surface_realize_palette(surface);
}
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DPaletteImpl_GetCaps(IWineD3DPalette *iface, DWORD *Caps) {
IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface;
TRACE("(%p)->(%p)\n", This, Caps);
DWORD CDECL wined3d_palette_get_flags(const struct wined3d_palette *palette)
{
TRACE("palette %p.\n", palette);
*Caps = This->Flags;
return WINED3D_OK;
return palette->flags;
}
static void * WINAPI IWineD3DPaletteImpl_GetParent(IWineD3DPalette *iface)
void * CDECL wined3d_palette_get_parent(const struct wined3d_palette *palette)
{
TRACE("iface %p.\n", iface);
TRACE("palette %p.\n", palette);
return ((IWineD3DPaletteImpl *)iface)->parent;
return palette->parent;
}
static const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl =
{
/*** IUnknown ***/
IWineD3DPaletteImpl_QueryInterface,
IWineD3DPaletteImpl_AddRef,
IWineD3DPaletteImpl_Release,
/*** IWineD3DPalette ***/
IWineD3DPaletteImpl_GetParent,
IWineD3DPaletteImpl_GetEntries,
IWineD3DPaletteImpl_GetCaps,
IWineD3DPaletteImpl_SetEntries
};
HRESULT wined3d_palette_init(IWineD3DPaletteImpl *palette, IWineD3DDeviceImpl *device,
static HRESULT wined3d_palette_init(struct wined3d_palette *palette, struct wined3d_device *device,
DWORD flags, const PALETTEENTRY *entries, void *parent)
{
HRESULT hr;
palette->lpVtbl = &IWineD3DPalette_Vtbl;
palette->ref = 1;
palette->parent = parent;
palette->device = device;
palette->Flags = flags;
palette->flags = flags;
palette->palNumEntries = IWineD3DPaletteImpl_Size(flags);
palette->palNumEntries = wined3d_palette_size(flags);
palette->hpal = CreatePalette((const LOGPALETTE *)&palette->palVersion);
if (!palette->hpal)
{
@ -214,7 +176,7 @@ HRESULT wined3d_palette_init(IWineD3DPaletteImpl *palette, IWineD3DDeviceImpl *d
return E_FAIL;
}
hr = IWineD3DPalette_SetEntries((IWineD3DPalette *)palette, 0, 0, IWineD3DPaletteImpl_Size(flags), entries);
hr = wined3d_palette_set_entries(palette, 0, 0, wined3d_palette_size(flags), entries);
if (FAILED(hr))
{
WARN("Failed to set palette entries, hr %#x.\n", hr);
@ -224,3 +186,33 @@ HRESULT wined3d_palette_init(IWineD3DPaletteImpl *palette, IWineD3DDeviceImpl *d
return WINED3D_OK;
}
HRESULT CDECL wined3d_palette_create(struct wined3d_device *device, DWORD flags,
const PALETTEENTRY *entries, void *parent, struct wined3d_palette **palette)
{
struct wined3d_palette *object;
HRESULT hr;
TRACE("device %p, flags %#x, entries %p, palette %p, parent %p.\n",
device, flags, entries, palette, parent);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
ERR("Failed to allocate palette memory.\n");
return E_OUTOFMEMORY;
}
hr = wined3d_palette_init(object, device, flags, entries, parent);
if (FAILED(hr))
{
WARN("Failed to initialize palette, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created palette %p.\n", object);
*palette = object;
return WINED3D_OK;
}

View file

@ -3,7 +3,7 @@
*
* Copyright 2005 Oliver Stieber
* Copyright 2007-2008 Stefan Dösinger for CodeWeavers
* Copyright 2009 Henri Verbeet for CodeWeavers.
* Copyright 2009-2010 Henri Verbeet for CodeWeavers.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -37,7 +37,8 @@ void wined3d_event_query_destroy(struct wined3d_event_query *query)
HeapFree(GetProcessHeap(), 0, query);
}
enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_query *query, IWineD3DDeviceImpl *device)
static enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_query *query,
struct wined3d_device *device)
{
struct wined3d_context *context;
const struct wined3d_gl_info *gl_info;
@ -111,7 +112,8 @@ enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_qu
return ret;
}
enum wined3d_event_query_result wined3d_event_query_finish(struct wined3d_event_query *query, IWineD3DDeviceImpl *device)
enum wined3d_event_query_result wined3d_event_query_finish(struct wined3d_event_query *query,
struct wined3d_device *device)
{
struct wined3d_context *context;
const struct wined3d_gl_info *gl_info;
@ -179,7 +181,7 @@ enum wined3d_event_query_result wined3d_event_query_finish(struct wined3d_event_
return ret;
}
void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDeviceImpl *device)
void wined3d_event_query_issue(struct wined3d_event_query *query, struct wined3d_device *device)
{
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
@ -230,64 +232,74 @@ void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDevice
context_release(context);
}
static HRESULT WINAPI IWineD3DQueryImpl_QueryInterface(IWineD3DQuery *iface, REFIID riid, void **object)
ULONG CDECL wined3d_query_incref(struct wined3d_query *query)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
ULONG refcount = InterlockedIncrement(&query->ref);
if (IsEqualGUID(riid, &IID_IWineD3DQuery)
|| IsEqualGUID(riid, &IID_IUnknown))
{
IUnknown_AddRef(iface);
*object = iface;
return S_OK;
}
TRACE("%p increasing refcount to %u.\n", query, refcount);
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
*object = NULL;
return E_NOINTERFACE;
return refcount;
}
static ULONG WINAPI IWineD3DQueryImpl_AddRef(IWineD3DQuery *iface) {
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
TRACE("(%p) : AddRef increasing from %d\n", This, This->ref);
return InterlockedIncrement(&This->ref);
}
ULONG CDECL wined3d_query_decref(struct wined3d_query *query)
{
ULONG refcount = InterlockedDecrement(&query->ref);
static ULONG WINAPI IWineD3DQueryImpl_Release(IWineD3DQuery *iface) {
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
ULONG ref;
TRACE("(%p) : Releasing from %d\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
TRACE("%p decreasing refcount to %u.\n", query, refcount);
if (!ref)
if (!refcount)
{
/* Queries are specific to the GL context that created them. Not
* deleting the query will obviously leak it, but that's still better
* than potentially deleting a different query with the same id in this
* context, and (still) leaking the actual query. */
if (This->type == WINED3DQUERYTYPE_EVENT)
if (query->type == WINED3DQUERYTYPE_EVENT)
{
struct wined3d_event_query *query = This->extendedData;
if (query) wined3d_event_query_destroy(query);
struct wined3d_event_query *event_query = query->extendedData;
if (event_query) wined3d_event_query_destroy(event_query);
}
else if (This->type == WINED3DQUERYTYPE_OCCLUSION)
else if (query->type == WINED3DQUERYTYPE_OCCLUSION)
{
struct wined3d_occlusion_query *query = This->extendedData;
struct wined3d_occlusion_query *oq = query->extendedData;
if (query->context) context_free_occlusion_query(query);
HeapFree(GetProcessHeap(), 0, This->extendedData);
if (oq->context) context_free_occlusion_query(oq);
HeapFree(GetProcessHeap(), 0, query->extendedData);
}
HeapFree(GetProcessHeap(), 0, This);
HeapFree(GetProcessHeap(), 0, query);
}
return ref;
return refcount;
}
static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface;
struct wined3d_occlusion_query *query = This->extendedData;
IWineD3DDeviceImpl *device = This->device;
HRESULT CDECL wined3d_query_get_data(struct wined3d_query *query,
void *data, UINT data_size, DWORD flags)
{
TRACE("query %p, data %p, data_size %u, flags %#x.\n",
query, data, data_size, flags);
return query->query_ops->query_get_data(query, data, data_size, flags);
}
UINT CDECL wined3d_query_get_data_size(const struct wined3d_query *query)
{
TRACE("query %p.\n", query);
return query->data_size;
}
HRESULT CDECL wined3d_query_issue(struct wined3d_query *query, DWORD flags)
{
TRACE("query %p, flags %#x.\n", query, flags);
return query->query_ops->query_issue(query, flags);
}
static HRESULT wined3d_occlusion_query_ops_get_data(struct wined3d_query *query,
void *pData, DWORD dwSize, DWORD flags)
{
struct wined3d_occlusion_query *oq = query->extendedData;
struct wined3d_device *device = query->device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct wined3d_context *context;
DWORD* data = pData;
@ -295,11 +307,12 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface,
GLuint samples;
HRESULT res;
TRACE("(%p) : type D3DQUERY_OCCLUSION, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, pData, dwSize, dwGetDataFlags);
TRACE("(%p) : type D3DQUERY_OCCLUSION, pData %p, dwSize %#x, flags %#x.\n", query, pData, dwSize, flags);
if (!query->context) This->state = QUERY_CREATED;
if (!oq->context)
query->state = QUERY_CREATED;
if (This->state == QUERY_CREATED)
if (query->state == QUERY_CREATED)
{
/* D3D allows GetData on a new query, OpenGL doesn't. So just invent the data ourselves */
TRACE("Query wasn't yet started, returning S_OK\n");
@ -307,7 +320,7 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface,
return S_OK;
}
if (This->state == QUERY_BUILDING)
if (query->state == QUERY_BUILDING)
{
/* Msdn says this returns an error, but our tests show that S_FALSE is returned */
TRACE("Query is building, returning S_FALSE\n");
@ -316,33 +329,33 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface,
if (!gl_info->supported[ARB_OCCLUSION_QUERY])
{
WARN("(%p) : Occlusion queries not supported. Returning 1.\n", This);
WARN("%p Occlusion queries not supported. Returning 1.\n", query);
*data = 1;
return S_OK;
}
if (query->context->tid != GetCurrentThreadId())
if (oq->context->tid != GetCurrentThreadId())
{
FIXME("%p Wrong thread, returning 1.\n", This);
FIXME("%p Wrong thread, returning 1.\n", query);
*data = 1;
return S_OK;
}
context = context_acquire(This->device, query->context->current_rt);
context = context_acquire(query->device, oq->context->current_rt);
ENTER_GL();
GL_EXTCALL(glGetQueryObjectuivARB(query->id, GL_QUERY_RESULT_AVAILABLE_ARB, &available));
GL_EXTCALL(glGetQueryObjectuivARB(oq->id, GL_QUERY_RESULT_AVAILABLE_ARB, &available));
checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT_AVAILABLE)");
TRACE("(%p) : available %d.\n", This, available);
TRACE("available %#x.\n", available);
if (available)
{
if (data)
{
GL_EXTCALL(glGetQueryObjectuivARB(query->id, GL_QUERY_RESULT_ARB, &samples));
GL_EXTCALL(glGetQueryObjectuivARB(oq->id, GL_QUERY_RESULT_ARB, &samples));
checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT)");
TRACE("(%p) : Returning %d samples.\n", This, samples);
TRACE("Returning %d samples.\n", samples);
*data = samples;
}
res = S_OK;
@ -359,23 +372,24 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface,
return res;
}
static HRESULT WINAPI IWineD3DEventQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface;
struct wined3d_event_query *query = This->extendedData;
static HRESULT wined3d_event_query_ops_get_data(struct wined3d_query *query,
void *pData, DWORD dwSize, DWORD flags)
{
struct wined3d_event_query *event_query = query->extendedData;
BOOL *data = pData;
enum wined3d_event_query_result ret;
TRACE("(%p) : type D3DQUERY_EVENT, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, pData, dwSize, dwGetDataFlags);
TRACE("query %p, pData %p, dwSize %#x, flags %#x.\n", query, pData, dwSize, flags);
if (!pData || !dwSize) return S_OK;
if (!query)
if (!event_query)
{
WARN("(%p): Event query not supported by GL, reporting GPU idle\n", This);
WARN("Event query not supported by GL, reporting GPU idle.\n");
*data = TRUE;
return S_OK;
}
ret = wined3d_event_query_test(query, This->device);
ret = wined3d_event_query_test(event_query, query->device);
switch(ret)
{
case WINED3D_EVENT_QUERY_OK:
@ -388,7 +402,7 @@ static HRESULT WINAPI IWineD3DEventQueryImpl_GetData(IWineD3DQuery* iface, void
break;
case WINED3D_EVENT_QUERY_WRONG_THREAD:
FIXME("(%p) Wrong thread, reporting GPU idle.\n", This);
FIXME("(%p) Wrong thread, reporting GPU idle.\n", query);
*data = TRUE;
break;
@ -400,77 +414,69 @@ static HRESULT WINAPI IWineD3DEventQueryImpl_GetData(IWineD3DQuery* iface, void
return S_OK;
}
static DWORD WINAPI IWineD3DEventQueryImpl_GetDataSize(IWineD3DQuery* iface){
TRACE("(%p) : type D3DQUERY_EVENT\n", iface);
WINED3DQUERYTYPE CDECL wined3d_query_get_type(const struct wined3d_query *query)
{
TRACE("query %p.\n", query);
return sizeof(BOOL);
return query->type;
}
static DWORD WINAPI IWineD3DOcclusionQueryImpl_GetDataSize(IWineD3DQuery* iface){
TRACE("(%p) : type D3DQUERY_OCCLUSION\n", iface);
static HRESULT wined3d_event_query_ops_issue(struct wined3d_query *query, DWORD flags)
{
TRACE("query %p, flags %#x.\n", query, flags);
return sizeof(DWORD);
}
static WINED3DQUERYTYPE WINAPI IWineD3DQueryImpl_GetType(IWineD3DQuery* iface){
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
return This->type;
}
static HRESULT WINAPI IWineD3DEventQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIssueFlags) {
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
TRACE("(%p) : dwIssueFlags %#x, type D3DQUERY_EVENT\n", This, dwIssueFlags);
if (dwIssueFlags & WINED3DISSUE_END)
TRACE("(%p) : flags %#x, type D3DQUERY_EVENT\n", query, flags);
if (flags & WINED3DISSUE_END)
{
struct wined3d_event_query *query = This->extendedData;
struct wined3d_event_query *event_query = query->extendedData;
/* Faked event query support */
if (!query) return WINED3D_OK;
if (!event_query) return WINED3D_OK;
wined3d_event_query_issue(query, This->device);
wined3d_event_query_issue(event_query, query->device);
}
else if(dwIssueFlags & WINED3DISSUE_BEGIN)
else if (flags & WINED3DISSUE_BEGIN)
{
/* Started implicitly at device creation */
ERR("Event query issued with START flag - what to do?\n");
}
if(dwIssueFlags & WINED3DISSUE_BEGIN) {
This->state = QUERY_BUILDING;
} else {
This->state = QUERY_SIGNALLED;
}
if (flags & WINED3DISSUE_BEGIN)
query->state = QUERY_BUILDING;
else
query->state = QUERY_SIGNALLED;
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIssueFlags) {
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
IWineD3DDeviceImpl *device = This->device;
static HRESULT wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DWORD flags)
{
struct wined3d_device *device = query->device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
TRACE("query %p, flags %#x.\n", query, flags);
if (gl_info->supported[ARB_OCCLUSION_QUERY])
{
struct wined3d_occlusion_query *query = This->extendedData;
struct wined3d_occlusion_query *oq = query->extendedData;
struct wined3d_context *context;
/* This is allowed according to msdn and our tests. Reset the query and restart */
if (dwIssueFlags & WINED3DISSUE_BEGIN)
if (flags & WINED3DISSUE_BEGIN)
{
if (This->state == QUERY_BUILDING)
if (query->state == QUERY_BUILDING)
{
if (query->context->tid != GetCurrentThreadId())
if (oq->context->tid != GetCurrentThreadId())
{
FIXME("Wrong thread, can't restart query.\n");
context_free_occlusion_query(query);
context = context_acquire(This->device, NULL);
context_alloc_occlusion_query(context, query);
context_free_occlusion_query(oq);
context = context_acquire(query->device, NULL);
context_alloc_occlusion_query(context, oq);
}
else
{
context = context_acquire(This->device, query->context->current_rt);
context = context_acquire(query->device, oq->context->current_rt);
ENTER_GL();
GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
@ -480,32 +486,33 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, D
}
else
{
if (query->context) context_free_occlusion_query(query);
context = context_acquire(This->device, NULL);
context_alloc_occlusion_query(context, query);
if (oq->context) context_free_occlusion_query(oq);
context = context_acquire(query->device, NULL);
context_alloc_occlusion_query(context, oq);
}
ENTER_GL();
GL_EXTCALL(glBeginQueryARB(GL_SAMPLES_PASSED_ARB, query->id));
GL_EXTCALL(glBeginQueryARB(GL_SAMPLES_PASSED_ARB, oq->id));
checkGLcall("glBeginQuery()");
LEAVE_GL();
context_release(context);
}
if (dwIssueFlags & WINED3DISSUE_END) {
if (flags & WINED3DISSUE_END)
{
/* Msdn says _END on a non-building occlusion query returns an error, but
* our tests show that it returns OK. But OpenGL doesn't like it, so avoid
* generating an error
*/
if (This->state == QUERY_BUILDING)
if (query->state == QUERY_BUILDING)
{
if (query->context->tid != GetCurrentThreadId())
if (oq->context->tid != GetCurrentThreadId())
{
FIXME("Wrong thread, can't end query.\n");
}
else
{
context = context_acquire(This->device, query->context->current_rt);
context = context_acquire(query->device, oq->context->current_rt);
ENTER_GL();
GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
@ -516,45 +523,33 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, D
}
}
}
} else {
FIXME("(%p) : Occlusion queries not supported\n", This);
}
else
{
FIXME("%p Occlusion queries not supported.\n", query);
}
if(dwIssueFlags & WINED3DISSUE_BEGIN) {
This->state = QUERY_BUILDING;
} else {
This->state = QUERY_SIGNALLED;
}
if (flags & WINED3DISSUE_BEGIN)
query->state = QUERY_BUILDING;
else
query->state = QUERY_SIGNALLED;
return WINED3D_OK; /* can be WINED3DERR_INVALIDCALL. */
}
static const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl =
static const struct wined3d_query_ops event_query_ops =
{
/*** IUnknown methods ***/
IWineD3DQueryImpl_QueryInterface,
IWineD3DQueryImpl_AddRef,
IWineD3DQueryImpl_Release,
/*** IWineD3Dquery methods ***/
IWineD3DEventQueryImpl_GetData,
IWineD3DEventQueryImpl_GetDataSize,
IWineD3DQueryImpl_GetType,
IWineD3DEventQueryImpl_Issue
wined3d_event_query_ops_get_data,
wined3d_event_query_ops_issue,
};
static const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl =
static const struct wined3d_query_ops occlusion_query_ops =
{
/*** IUnknown methods ***/
IWineD3DQueryImpl_QueryInterface,
IWineD3DQueryImpl_AddRef,
IWineD3DQueryImpl_Release,
/*** IWineD3Dquery methods ***/
IWineD3DOcclusionQueryImpl_GetData,
IWineD3DOcclusionQueryImpl_GetDataSize,
IWineD3DQueryImpl_GetType,
IWineD3DOcclusionQueryImpl_Issue
wined3d_occlusion_query_ops_get_data,
wined3d_occlusion_query_ops_issue,
};
HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device, WINED3DQUERYTYPE type)
static HRESULT query_init(struct wined3d_query *query, struct wined3d_device *device, WINED3DQUERYTYPE type)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
@ -567,7 +562,8 @@ HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device, WINED3D
WARN("Unsupported in local OpenGL implementation: ARB_OCCLUSION_QUERY.\n");
return WINED3DERR_NOTAVAILABLE;
}
query->lpVtbl = &IWineD3DOcclusionQuery_Vtbl;
query->query_ops = &occlusion_query_ops;
query->data_size = sizeof(DWORD);
query->extendedData = HeapAlloc(GetProcessHeap(), 0, sizeof(struct wined3d_occlusion_query));
if (!query->extendedData)
{
@ -587,7 +583,8 @@ HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device, WINED3D
* lowering performance. */
FIXME("Event query: Unimplemented, but pretending to be supported.\n");
}
query->lpVtbl = &IWineD3DEventQuery_Vtbl;
query->query_ops = &event_query_ops;
query->data_size = sizeof(BOOL);
query->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct wined3d_event_query));
if (!query->extendedData)
{
@ -620,3 +617,32 @@ HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device, WINED3D
return WINED3D_OK;
}
HRESULT CDECL wined3d_query_create(struct wined3d_device *device,
WINED3DQUERYTYPE type, struct wined3d_query **query)
{
struct wined3d_query *object;
HRESULT hr;
TRACE("device %p, type %#x, query %p.\n", device, type, query);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
ERR("Failed to allocate query memory.\n");
return E_OUTOFMEMORY;
}
hr = query_init(object, device, type);
if (FAILED(hr))
{
WARN("Failed to initialize query, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created query %p.\n", object);
*query = object;
return WINED3D_OK;
}

View file

@ -5,7 +5,7 @@
* Copyright 2003-2004 Raphael Junqueira
* Copyright 2004 Christian Costa
* Copyright 2005 Oliver Stieber
* Copyright 2009 Henri Verbeet for CodeWeavers
* Copyright 2009-2010 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -27,24 +27,87 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
HRESULT resource_init(IWineD3DResource *iface, WINED3DRESOURCETYPE resource_type,
IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct wined3d_format *format,
WINED3DPOOL pool, void *parent, const struct wined3d_parent_ops *parent_ops)
struct private_data
{
struct IWineD3DResourceClass *resource = &((IWineD3DResourceImpl *)iface)->resource;
struct list entry;
GUID tag;
DWORD flags; /* DDSPD_* */
union
{
void *data;
IUnknown *object;
} ptr;
DWORD size;
};
static DWORD resource_access_from_pool(WINED3DPOOL pool)
{
switch (pool)
{
case WINED3DPOOL_DEFAULT:
return WINED3D_RESOURCE_ACCESS_GPU;
case WINED3DPOOL_MANAGED:
return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU;
case WINED3DPOOL_SYSTEMMEM:
return WINED3D_RESOURCE_ACCESS_CPU;
case WINED3DPOOL_SCRATCH:
return WINED3D_RESOURCE_ACCESS_SCRATCH;
default:
FIXME("Unhandled pool %#x.\n", pool);
return 0;
}
}
static void resource_check_usage(DWORD usage)
{
static const DWORD handled = WINED3DUSAGE_RENDERTARGET
| WINED3DUSAGE_DEPTHSTENCIL
| WINED3DUSAGE_DYNAMIC
| WINED3DUSAGE_AUTOGENMIPMAP
| WINED3DUSAGE_STATICDECL
| WINED3DUSAGE_OVERLAY;
if (usage & ~handled)
FIXME("Unhandled usage flags %#x.\n", usage & ~handled);
}
HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *device,
WINED3DRESOURCETYPE resource_type, const struct wined3d_format *format,
WINED3DMULTISAMPLE_TYPE multisample_type, UINT multisample_quality,
DWORD usage, WINED3DPOOL pool, UINT width, UINT height, UINT depth, UINT size,
void *parent, const struct wined3d_parent_ops *parent_ops,
const struct wined3d_resource_ops *resource_ops)
{
resource->ref = 1;
resource->device = device;
resource->resourceType = resource_type;
resource->ref = 1;
resource->pool = pool;
resource->format = format;
resource->multisample_type = multisample_type;
resource->multisample_quality = multisample_quality;
resource->usage = usage;
resource->pool = pool;
resource->access_flags = resource_access_from_pool(pool);
if (usage & WINED3DUSAGE_DYNAMIC)
resource->access_flags |= WINED3D_RESOURCE_ACCESS_CPU;
resource->width = width;
resource->height = height;
resource->depth = depth;
resource->size = size;
resource->priority = 0;
resource->parent = parent;
resource->parent_ops = parent_ops;
resource->resource_ops = resource_ops;
list_init(&resource->privateData);
resource_check_usage(usage);
if (size)
{
resource->heapMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size + RESOURCE_ALIGNMENT);
@ -58,12 +121,13 @@ HRESULT resource_init(IWineD3DResource *iface, WINED3DRESOURCETYPE resource_type
{
resource->heapMemory = NULL;
}
resource->allocatedMemory = (BYTE *)(((ULONG_PTR)resource->heapMemory + (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
resource->allocatedMemory = (BYTE *)(((ULONG_PTR)resource->heapMemory
+ (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
/* Check that we have enough video ram left */
if (pool == WINED3DPOOL_DEFAULT)
{
if (size > IWineD3DDevice_GetAvailableTextureMem((IWineD3DDevice *)device))
if (size > wined3d_device_get_available_texture_mem(device))
{
ERR("Out of adapter memory\n");
HeapFree(GetProcessHeap(), 0, resource->heapMemory);
@ -72,54 +136,56 @@ HRESULT resource_init(IWineD3DResource *iface, WINED3DRESOURCETYPE resource_type
WineD3DAdapterChangeGLRam(device, size);
}
device_resource_add(device, iface);
device_resource_add(device, resource);
return WINED3D_OK;
}
void resource_cleanup(IWineD3DResource *iface)
void resource_cleanup(struct wined3d_resource *resource)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
struct private_data *data;
struct list *e1, *e2;
PrivateData *data;
HRESULT hr;
TRACE("(%p) Cleaning up resource\n", This);
if (This->resource.pool == WINED3DPOOL_DEFAULT) {
TRACE("Decrementing device memory pool by %u\n", This->resource.size);
WineD3DAdapterChangeGLRam(This->resource.device, -This->resource.size);
TRACE("Cleaning up resource %p.\n", resource);
if (resource->pool == WINED3DPOOL_DEFAULT)
{
TRACE("Decrementing device memory pool by %u.\n", resource->size);
WineD3DAdapterChangeGLRam(resource->device, 0 - resource->size);
}
LIST_FOR_EACH_SAFE(e1, e2, &This->resource.privateData) {
data = LIST_ENTRY(e1, PrivateData, entry);
hr = resource_free_private_data(iface, &data->tag);
if(hr != WINED3D_OK) {
ERR("Failed to free private data when destroying resource %p, hr = %08x\n", This, hr);
}
LIST_FOR_EACH_SAFE(e1, e2, &resource->privateData)
{
data = LIST_ENTRY(e1, struct private_data, entry);
hr = resource_free_private_data(resource, &data->tag);
if (FAILED(hr))
ERR("Failed to free private data when destroying resource %p, hr = %#x.\n", resource, hr);
}
HeapFree(GetProcessHeap(), 0, This->resource.heapMemory);
This->resource.allocatedMemory = 0;
This->resource.heapMemory = 0;
HeapFree(GetProcessHeap(), 0, resource->heapMemory);
resource->allocatedMemory = 0;
resource->heapMemory = 0;
if (This->resource.device) device_resource_released(This->resource.device, iface);
if (resource->device)
device_resource_released(resource->device, resource);
}
void resource_unload(IWineD3DResourceImpl *resource)
void resource_unload(struct wined3d_resource *resource)
{
context_resource_unloaded(resource->resource.device, (IWineD3DResource *)resource,
resource->resource.resourceType);
context_resource_unloaded(resource->device,
resource, resource->resourceType);
}
static PrivateData* resource_find_private_data(IWineD3DResourceImpl *This, REFGUID tag)
static struct private_data *resource_find_private_data(const struct wined3d_resource *resource, REFGUID tag)
{
PrivateData *data;
struct private_data *data;
struct list *entry;
TRACE("Searching for private data %s\n", debugstr_guid(tag));
LIST_FOR_EACH(entry, &This->resource.privateData)
LIST_FOR_EACH(entry, &resource->privateData)
{
data = LIST_ENTRY(entry, PrivateData, entry);
data = LIST_ENTRY(entry, struct private_data, entry);
if (IsEqualGUID(&data->tag, tag)) {
TRACE("Found %p\n", data);
return data;
@ -129,85 +195,91 @@ static PrivateData* resource_find_private_data(IWineD3DResourceImpl *This, REFGU
return NULL;
}
HRESULT resource_set_private_data(IWineD3DResource *iface, REFGUID refguid,
const void *pData, DWORD SizeOfData, DWORD Flags)
HRESULT resource_set_private_data(struct wined3d_resource *resource, REFGUID guid,
const void *data, DWORD data_size, DWORD flags)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
PrivateData *data;
struct private_data *d;
TRACE("(%p) : %s %p %d %d\n", This, debugstr_guid(refguid), pData, SizeOfData, Flags);
resource_free_private_data(iface, refguid);
TRACE("resource %p, riid %s, data %p, data_size %u, flags %#x.\n",
resource, debugstr_guid(guid), data, data_size, flags);
data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data));
if (!data) return E_OUTOFMEMORY;
resource_free_private_data(resource, guid);
data->tag = *refguid;
data->flags = Flags;
d = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d));
if (!d) return E_OUTOFMEMORY;
if (Flags & WINED3DSPD_IUNKNOWN) {
if(SizeOfData != sizeof(IUnknown *)) {
WARN("IUnknown data with size %d, returning WINED3DERR_INVALIDCALL\n", SizeOfData);
HeapFree(GetProcessHeap(), 0, data);
d->tag = *guid;
d->flags = flags;
if (flags & WINED3DSPD_IUNKNOWN)
{
if (data_size != sizeof(IUnknown *))
{
WARN("IUnknown data with size %u, returning WINED3DERR_INVALIDCALL.\n", data_size);
HeapFree(GetProcessHeap(), 0, d);
return WINED3DERR_INVALIDCALL;
}
data->ptr.object = (LPUNKNOWN)pData;
data->size = sizeof(LPUNKNOWN);
IUnknown_AddRef(data->ptr.object);
d->ptr.object = (IUnknown *)data;
d->size = sizeof(IUnknown *);
IUnknown_AddRef(d->ptr.object);
}
else
{
data->ptr.data = HeapAlloc(GetProcessHeap(), 0, SizeOfData);
if (!data->ptr.data)
d->ptr.data = HeapAlloc(GetProcessHeap(), 0, data_size);
if (!d->ptr.data)
{
HeapFree(GetProcessHeap(), 0, data);
HeapFree(GetProcessHeap(), 0, d);
return E_OUTOFMEMORY;
}
data->size = SizeOfData;
memcpy(data->ptr.data, pData, SizeOfData);
d->size = data_size;
memcpy(d->ptr.data, data, data_size);
}
list_add_tail(&This->resource.privateData, &data->entry);
list_add_tail(&resource->privateData, &d->entry);
return WINED3D_OK;
}
HRESULT resource_get_private_data(IWineD3DResource *iface, REFGUID refguid, void *pData, DWORD *pSizeOfData)
HRESULT resource_get_private_data(const struct wined3d_resource *resource, REFGUID guid, void *data, DWORD *data_size)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
PrivateData *data;
const struct private_data *d;
TRACE("(%p) : %p %p %p\n", This, refguid, pData, pSizeOfData);
data = resource_find_private_data(This, refguid);
if (!data) return WINED3DERR_NOTFOUND;
TRACE("resource %p, guid %s, data %p, data_size %p.\n",
resource, debugstr_guid(guid), data, data_size);
if (*pSizeOfData < data->size) {
*pSizeOfData = data->size;
d = resource_find_private_data(resource, guid);
if (!d) return WINED3DERR_NOTFOUND;
if (*data_size < d->size)
{
*data_size = d->size;
return WINED3DERR_MOREDATA;
}
if (data->flags & WINED3DSPD_IUNKNOWN) {
*(LPUNKNOWN *)pData = data->ptr.object;
if (((IWineD3DImpl *)This->resource.device->wined3d)->dxVersion != 7)
if (d->flags & WINED3DSPD_IUNKNOWN)
{
*(IUnknown **)data = d->ptr.object;
if (resource->device->wined3d->dxVersion != 7)
{
/* D3D8 and D3D9 addref the private data, DDraw does not. This can't be handled in
* ddraw because it doesn't know if the pointer returned is an IUnknown * or just a
* Blob
*/
IUnknown_AddRef(data->ptr.object);
/* D3D8 and D3D9 addref the private data, DDraw does not. This
* can't be handled in ddraw because it doesn't know if the
* pointer returned is an IUnknown * or just a blob. */
IUnknown_AddRef(d->ptr.object);
}
}
else {
memcpy(pData, data->ptr.data, data->size);
else
{
memcpy(data, d->ptr.data, d->size);
}
return WINED3D_OK;
}
HRESULT resource_free_private_data(IWineD3DResource *iface, REFGUID refguid)
HRESULT resource_free_private_data(struct wined3d_resource *resource, REFGUID guid)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
PrivateData *data;
struct private_data *data;
TRACE("(%p) : %s\n", This, debugstr_guid(refguid));
data = resource_find_private_data(This, refguid);
TRACE("resource %p, guid %s.\n", resource, debugstr_guid(guid));
data = resource_find_private_data(resource, guid);
if (!data) return WINED3DERR_NOTFOUND;
if (data->flags & WINED3DSPD_IUNKNOWN)
@ -226,25 +298,35 @@ HRESULT resource_free_private_data(IWineD3DResource *iface, REFGUID refguid)
return WINED3D_OK;
}
DWORD resource_set_priority(IWineD3DResource *iface, DWORD PriorityNew)
DWORD resource_set_priority(struct wined3d_resource *resource, DWORD priority)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
DWORD PriorityOld = This->resource.priority;
This->resource.priority = PriorityNew;
TRACE("(%p) : new priority %d, returning old priority %d\n", This, PriorityNew, PriorityOld );
return PriorityOld;
DWORD prev = resource->priority;
resource->priority = priority;
TRACE("resource %p, new priority %u, returning old priority %u.\n", resource, priority, prev);
return prev;
}
DWORD resource_get_priority(IWineD3DResource *iface)
DWORD resource_get_priority(const struct wined3d_resource *resource)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
TRACE("(%p) : returning %d\n", This, This->resource.priority );
return This->resource.priority;
TRACE("resource %p, returning %u.\n", resource, resource->priority);
return resource->priority;
}
WINED3DRESOURCETYPE resource_get_type(IWineD3DResource *iface)
void * CDECL wined3d_resource_get_parent(const struct wined3d_resource *resource)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
TRACE("(%p) : returning %d\n", This, This->resource.resourceType);
return This->resource.resourceType;
return resource->parent;
}
void CDECL wined3d_resource_get_desc(const struct wined3d_resource *resource, struct wined3d_resource_desc *desc)
{
desc->resource_type = resource->resourceType;
desc->format = resource->format->id;
desc->multisample_type = resource->multisample_type;
desc->multisample_quality = resource->multisample_quality;
desc->usage = resource->usage;
desc->pool = resource->pool;
desc->width = resource->width;
desc->height = resource->height;
desc->depth = resource->depth;
desc->size = resource->size;
}

File diff suppressed because it is too large Load diff

View file

@ -23,11 +23,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
#define WINED3D_SM4_INSTRUCTION_MODIFIER (1 << 31)
#define WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT 24
#define WINED3D_SM4_INSTRUCTION_LENGTH_MASK (0xf << WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT)
#define WINED3D_SM4_OPCODE_MASK 0xff
#define WINED3D_SM4_REGISTER_MODIFIER (1 << 31)
#define WINED3D_SM4_REGISTER_ORDER_SHIFT 20
#define WINED3D_SM4_REGISTER_ORDER_MASK (0x3 << WINED3D_SM4_REGISTER_ORDER_SHIFT)
@ -48,34 +52,44 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
enum wined3d_sm4_opcode
{
WINED3D_SM4_OP_ADD = 0x00,
WINED3D_SM4_OP_AND = 0x01,
WINED3D_SM4_OP_BREAK = 0x02,
WINED3D_SM4_OP_BREAKC = 0x03,
WINED3D_SM4_OP_CUT = 0x09,
WINED3D_SM4_OP_DP3 = 0x10,
WINED3D_SM4_OP_DP4 = 0x11,
WINED3D_SM4_OP_EMIT = 0x13,
WINED3D_SM4_OP_ENDIF = 0x15,
WINED3D_SM4_OP_ENDLOOP = 0x16,
WINED3D_SM4_OP_EXP = 0x19,
WINED3D_SM4_OP_FRC = 0x1a,
WINED3D_SM4_OP_IADD = 0x1e,
WINED3D_SM4_OP_IF = 0x1f,
WINED3D_SM4_OP_IGE = 0x21,
WINED3D_SM4_OP_IMUL = 0x26,
WINED3D_SM4_OP_LOG = 0x2f,
WINED3D_SM4_OP_LOOP = 0x30,
WINED3D_SM4_OP_LT = 0x31,
WINED3D_SM4_OP_MAD = 0x32,
WINED3D_SM4_OP_MIN = 0x33,
WINED3D_SM4_OP_MAX = 0x34,
WINED3D_SM4_OP_MOV = 0x36,
WINED3D_SM4_OP_MOVC = 0x37,
WINED3D_SM4_OP_MUL = 0x38,
WINED3D_SM4_OP_RET = 0x3e,
WINED3D_SM4_OP_RSQ = 0x44,
WINED3D_SM4_OP_SINCOS = 0x4d,
WINED3D_SM4_OP_ADD = 0x00,
WINED3D_SM4_OP_AND = 0x01,
WINED3D_SM4_OP_BREAK = 0x02,
WINED3D_SM4_OP_BREAKC = 0x03,
WINED3D_SM4_OP_CUT = 0x09,
WINED3D_SM4_OP_DIV = 0x0e,
WINED3D_SM4_OP_DP3 = 0x10,
WINED3D_SM4_OP_DP4 = 0x11,
WINED3D_SM4_OP_EMIT = 0x13,
WINED3D_SM4_OP_ENDIF = 0x15,
WINED3D_SM4_OP_ENDLOOP = 0x16,
WINED3D_SM4_OP_EXP = 0x19,
WINED3D_SM4_OP_FRC = 0x1a,
WINED3D_SM4_OP_FTOI = 0x1b,
WINED3D_SM4_OP_IADD = 0x1e,
WINED3D_SM4_OP_IF = 0x1f,
WINED3D_SM4_OP_IEQ = 0x20,
WINED3D_SM4_OP_IGE = 0x21,
WINED3D_SM4_OP_IMUL = 0x26,
WINED3D_SM4_OP_ITOF = 0x2b,
WINED3D_SM4_OP_LD = 0x2d,
WINED3D_SM4_OP_LOG = 0x2f,
WINED3D_SM4_OP_LOOP = 0x30,
WINED3D_SM4_OP_LT = 0x31,
WINED3D_SM4_OP_MAD = 0x32,
WINED3D_SM4_OP_MIN = 0x33,
WINED3D_SM4_OP_MAX = 0x34,
WINED3D_SM4_OP_MOV = 0x36,
WINED3D_SM4_OP_MOVC = 0x37,
WINED3D_SM4_OP_MUL = 0x38,
WINED3D_SM4_OP_RET = 0x3e,
WINED3D_SM4_OP_RSQ = 0x44,
WINED3D_SM4_OP_SAMPLE = 0x45,
WINED3D_SM4_OP_SAMPLE_LOD = 0x48,
WINED3D_SM4_OP_SAMPLE_GRAD = 0x49,
WINED3D_SM4_OP_SQRT = 0x4b,
WINED3D_SM4_OP_SINCOS = 0x4d,
WINED3D_SM4_OP_UTOF = 0x56,
};
enum wined3d_sm4_register_type
@ -84,6 +98,7 @@ enum wined3d_sm4_register_type
WINED3D_SM4_RT_INPUT = 0x1,
WINED3D_SM4_RT_OUTPUT = 0x2,
WINED3D_SM4_RT_IMMCONST = 0x4,
WINED3D_SM4_RT_SAMPLER = 0x6,
WINED3D_SM4_RT_CONSTBUFFER = 0x8,
WINED3D_SM4_RT_NULL = 0xd,
};
@ -118,34 +133,44 @@ struct sysval_map
static const struct wined3d_sm4_opcode_info opcode_table[] =
{
{WINED3D_SM4_OP_ADD, WINED3DSIH_ADD, 1, 2},
{WINED3D_SM4_OP_AND, WINED3DSIH_AND, 1, 2},
{WINED3D_SM4_OP_BREAK, WINED3DSIH_BREAK, 0, 0},
{WINED3D_SM4_OP_BREAKC, WINED3DSIH_BREAKP, 0, 1},
{WINED3D_SM4_OP_CUT, WINED3DSIH_CUT, 0, 0},
{WINED3D_SM4_OP_DP3, WINED3DSIH_DP3, 1, 2},
{WINED3D_SM4_OP_DP4, WINED3DSIH_DP4, 1, 2},
{WINED3D_SM4_OP_EMIT, WINED3DSIH_EMIT, 0, 0},
{WINED3D_SM4_OP_ENDIF, WINED3DSIH_ENDIF, 0, 0},
{WINED3D_SM4_OP_ENDLOOP,WINED3DSIH_ENDLOOP, 0, 0},
{WINED3D_SM4_OP_EXP, WINED3DSIH_EXP, 1, 1},
{WINED3D_SM4_OP_FRC, WINED3DSIH_FRC, 1, 1},
{WINED3D_SM4_OP_IADD, WINED3DSIH_IADD, 1, 2},
{WINED3D_SM4_OP_IF, WINED3DSIH_IF, 0, 1},
{WINED3D_SM4_OP_IGE, WINED3DSIH_IGE, 1, 2},
{WINED3D_SM4_OP_IMUL, WINED3DSIH_IMUL, 2, 2},
{WINED3D_SM4_OP_LOG, WINED3DSIH_LOG, 1, 1},
{WINED3D_SM4_OP_LOOP, WINED3DSIH_LOOP, 0, 0},
{WINED3D_SM4_OP_LT, WINED3DSIH_LT, 1, 2},
{WINED3D_SM4_OP_MAD, WINED3DSIH_MAD, 1, 3},
{WINED3D_SM4_OP_MIN, WINED3DSIH_MIN, 1, 2},
{WINED3D_SM4_OP_MAX, WINED3DSIH_MAX, 1, 2},
{WINED3D_SM4_OP_MOV, WINED3DSIH_MOV, 1, 1},
{WINED3D_SM4_OP_MOVC, WINED3DSIH_MOVC, 1, 3},
{WINED3D_SM4_OP_MUL, WINED3DSIH_MUL, 1, 2},
{WINED3D_SM4_OP_RET, WINED3DSIH_RET, 0, 0},
{WINED3D_SM4_OP_RSQ, WINED3DSIH_RSQ, 1, 1},
{WINED3D_SM4_OP_SINCOS, WINED3DSIH_SINCOS, 2, 1},
{WINED3D_SM4_OP_ADD, WINED3DSIH_ADD, 1, 2},
{WINED3D_SM4_OP_AND, WINED3DSIH_AND, 1, 2},
{WINED3D_SM4_OP_BREAK, WINED3DSIH_BREAK, 0, 0},
{WINED3D_SM4_OP_BREAKC, WINED3DSIH_BREAKP, 0, 1},
{WINED3D_SM4_OP_CUT, WINED3DSIH_CUT, 0, 0},
{WINED3D_SM4_OP_DIV, WINED3DSIH_DIV, 1, 2},
{WINED3D_SM4_OP_DP3, WINED3DSIH_DP3, 1, 2},
{WINED3D_SM4_OP_DP4, WINED3DSIH_DP4, 1, 2},
{WINED3D_SM4_OP_EMIT, WINED3DSIH_EMIT, 0, 0},
{WINED3D_SM4_OP_ENDIF, WINED3DSIH_ENDIF, 0, 0},
{WINED3D_SM4_OP_ENDLOOP, WINED3DSIH_ENDLOOP, 0, 0},
{WINED3D_SM4_OP_EXP, WINED3DSIH_EXP, 1, 1},
{WINED3D_SM4_OP_FRC, WINED3DSIH_FRC, 1, 1},
{WINED3D_SM4_OP_FTOI, WINED3DSIH_FTOI, 1, 1},
{WINED3D_SM4_OP_IADD, WINED3DSIH_IADD, 1, 2},
{WINED3D_SM4_OP_IF, WINED3DSIH_IF, 0, 1},
{WINED3D_SM4_OP_IEQ, WINED3DSIH_IEQ, 1, 2},
{WINED3D_SM4_OP_IGE, WINED3DSIH_IGE, 1, 2},
{WINED3D_SM4_OP_IMUL, WINED3DSIH_IMUL, 2, 2},
{WINED3D_SM4_OP_ITOF, WINED3DSIH_ITOF, 1, 1},
{WINED3D_SM4_OP_LD, WINED3DSIH_LD, 1, 2},
{WINED3D_SM4_OP_LOG, WINED3DSIH_LOG, 1, 1},
{WINED3D_SM4_OP_LOOP, WINED3DSIH_LOOP, 0, 0},
{WINED3D_SM4_OP_LT, WINED3DSIH_LT, 1, 2},
{WINED3D_SM4_OP_MAD, WINED3DSIH_MAD, 1, 3},
{WINED3D_SM4_OP_MIN, WINED3DSIH_MIN, 1, 2},
{WINED3D_SM4_OP_MAX, WINED3DSIH_MAX, 1, 2},
{WINED3D_SM4_OP_MOV, WINED3DSIH_MOV, 1, 1},
{WINED3D_SM4_OP_MOVC, WINED3DSIH_MOVC, 1, 3},
{WINED3D_SM4_OP_MUL, WINED3DSIH_MUL, 1, 2},
{WINED3D_SM4_OP_RET, WINED3DSIH_RET, 0, 0},
{WINED3D_SM4_OP_RSQ, WINED3DSIH_RSQ, 1, 1},
{WINED3D_SM4_OP_SAMPLE, WINED3DSIH_SAMPLE, 1, 3},
{WINED3D_SM4_OP_SAMPLE_LOD, WINED3DSIH_SAMPLE_LOD, 1, 4},
{WINED3D_SM4_OP_SAMPLE_GRAD,WINED3DSIH_SAMPLE_GRAD, 1, 5},
{WINED3D_SM4_OP_SQRT, WINED3DSIH_SQRT, 1, 1},
{WINED3D_SM4_OP_SINCOS, WINED3DSIH_SINCOS, 2, 1},
{WINED3D_SM4_OP_UTOF, WINED3DSIH_UTOF, 1, 1},
};
static const WINED3DSHADER_PARAM_REGISTER_TYPE register_type_table[] =
@ -156,8 +181,8 @@ static const WINED3DSHADER_PARAM_REGISTER_TYPE register_type_table[] =
/* UNKNOWN */ 0,
/* WINED3D_SM4_RT_IMMCONST */ WINED3DSPR_IMMCONST,
/* UNKNOWN */ 0,
/* UNKNOWN */ 0,
/* UNKNOWN */ 0,
/* WINED3D_SM4_RT_SAMPLER */ WINED3DSPR_SAMPLER,
/* WINED3D_SM4_RT_RESOURCE */ WINED3DSPR_RESOURCE,
/* WINED3D_SM4_RT_CONSTBUFFER */ WINED3DSPR_CONSTBUFFER,
/* UNKNOWN */ 0,
/* UNKNOWN */ 0,
@ -315,6 +340,12 @@ static void shader_sm4_read_opcode(void *data, const DWORD **ptr, struct wined3d
ins->predicate = 0;
ins->dst_count = opcode_info->dst_count;
ins->src_count = opcode_info->src_count;
if (token & WINED3D_SM4_INSTRUCTION_MODIFIER)
{
DWORD modifier = *(*ptr)++;
FIXME("Skipping modifier 0x%08x.\n", modifier);
}
}
static void shader_sm4_read_src_param(void *data, const DWORD **ptr, struct wined3d_shader_src_param *src_param,
@ -336,6 +367,34 @@ static void shader_sm4_read_src_param(void *data, const DWORD **ptr, struct wine
src_param->reg.type = register_type_table[register_type];
}
if (token & WINED3D_SM4_REGISTER_MODIFIER)
{
DWORD modifier = *(*ptr)++;
/* FIXME: This will probably break down at some point. The SM4
* modifiers look like flags, while wined3d currently has an enum
* with possible combinations, e.g. WINED3DSPSM_ABSNEG. */
switch (modifier)
{
case 0x41:
src_param->modifiers = WINED3DSPSM_NEG;
break;
case 0x81:
src_param->modifiers = WINED3DSPSM_ABS;
break;
default:
FIXME("Skipping modifier 0x%08x.\n", modifier);
src_param->modifiers = WINED3DSPSM_NONE;
break;
}
}
else
{
src_param->modifiers = WINED3DSPSM_NONE;
}
order = (token & WINED3D_SM4_REGISTER_ORDER_MASK) >> WINED3D_SM4_REGISTER_ORDER_SHIFT;
if (order < 1) src_param->reg.idx = ~0U;
@ -376,7 +435,6 @@ static void shader_sm4_read_src_param(void *data, const DWORD **ptr, struct wine
src_param->swizzle = (token & WINED3D_SM4_SWIZZLE_MASK) >> WINED3D_SM4_SWIZZLE_SHIFT;
}
src_param->modifiers = 0;
src_param->reg.rel_addr = NULL;
map_register(priv, &src_param->reg);

File diff suppressed because it is too large Load diff

View file

@ -191,9 +191,9 @@ static const DWORD vertex_states_sampler[] =
/* Allocates the correct amount of space for pixel and vertex shader constants,
* along with their set/changed flags on the given stateblock object
*/
static HRESULT stateblock_allocate_shader_constants(IWineD3DStateBlockImpl *object)
static HRESULT stateblock_allocate_shader_constants(struct wined3d_stateblock *object)
{
IWineD3DDeviceImpl *device = object->device;
struct wined3d_device *device = object->device;
/* Allocate space for floating point constants */
object->state.ps_consts_f = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
@ -327,9 +327,9 @@ static void stateblock_savedstates_set_vertex(SAVEDSTATES *states, const DWORD n
memset(states->vertexShaderConstantsF, TRUE, sizeof(BOOL) * num_constants);
}
void stateblock_init_contained_states(IWineD3DStateBlockImpl *stateblock)
void stateblock_init_contained_states(struct wined3d_stateblock *stateblock)
{
IWineD3DDeviceImpl *device = stateblock->device;
struct wined3d_device *device = stateblock->device;
unsigned int i, j;
for (i = 0; i <= WINEHIGHEST_RENDER_STATE >> 5; ++i)
@ -439,7 +439,7 @@ void stateblock_init_contained_states(IWineD3DStateBlockImpl *stateblock)
}
}
static void stateblock_init_lights(IWineD3DStateBlockImpl *stateblock, struct list *light_map)
static void stateblock_init_lights(struct wined3d_stateblock *stateblock, struct list *light_map)
{
unsigned int i;
@ -457,68 +457,68 @@ static void stateblock_init_lights(IWineD3DStateBlockImpl *stateblock, struct li
}
}
/**********************************************************
* IWineD3DStateBlockImpl IUnknown parts follows
**********************************************************/
static HRESULT WINAPI IWineD3DStateBlockImpl_QueryInterface(IWineD3DStateBlock *iface,REFIID riid,LPVOID *ppobj)
ULONG CDECL wined3d_stateblock_incref(struct wined3d_stateblock *stateblock)
{
IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IWineD3DStateBlock))
ULONG refcount = InterlockedIncrement(&stateblock->ref);
TRACE("%p increasing refcount to %u.\n", stateblock, refcount);
return refcount;
}
ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
{
ULONG refcount = InterlockedDecrement(&stateblock->ref);
TRACE("%p decreasing refcount to %u\n", stateblock, refcount);
if (!refcount)
{
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IWineD3DStateBlockImpl_AddRef(IWineD3DStateBlock *iface) {
IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef increasing from %d\n", This, refCount - 1);
return refCount;
}
static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p) : Releasing from %d\n", This, refCount + 1);
if (!refCount) {
struct wined3d_buffer *buffer;
int counter;
if (This->state.vertex_declaration)
IWineD3DVertexDeclaration_Release((IWineD3DVertexDeclaration *)This->state.vertex_declaration);
if (stateblock->state.vertex_declaration)
wined3d_vertex_declaration_decref(stateblock->state.vertex_declaration);
for (counter = 0; counter < MAX_COMBINED_SAMPLERS; counter++)
{
if (This->state.textures[counter])
IWineD3DBaseTexture_Release((IWineD3DBaseTexture *)This->state.textures[counter]);
struct wined3d_texture *texture = stateblock->state.textures[counter];
if (texture)
{
stateblock->state.textures[counter] = NULL;
wined3d_texture_decref(texture);
}
}
for (counter = 0; counter < MAX_STREAMS; ++counter)
{
struct wined3d_buffer *buffer = This->state.streams[counter].buffer;
buffer = stateblock->state.streams[counter].buffer;
if (buffer)
{
if (IWineD3DBuffer_Release((IWineD3DBuffer *)buffer))
stateblock->state.streams[counter].buffer = NULL;
if (wined3d_buffer_decref(buffer))
{
WARN("Buffer %p still referenced by stateblock, stream %u.\n", buffer, counter);
}
}
}
if (This->state.index_buffer) IWineD3DBuffer_Release((IWineD3DBuffer *)This->state.index_buffer);
if (This->state.vertex_shader) IWineD3DVertexShader_Release((IWineD3DVertexShader *)This->state.vertex_shader);
if (This->state.pixel_shader) IWineD3DPixelShader_Release((IWineD3DPixelShader *)This->state.pixel_shader);
for(counter = 0; counter < LIGHTMAP_SIZE; counter++) {
buffer = stateblock->state.index_buffer;
if (buffer)
{
stateblock->state.index_buffer = NULL;
wined3d_buffer_decref(buffer);
}
if (stateblock->state.vertex_shader)
wined3d_shader_decref(stateblock->state.vertex_shader);
if (stateblock->state.pixel_shader)
wined3d_shader_decref(stateblock->state.pixel_shader);
for (counter = 0; counter < LIGHTMAP_SIZE; ++counter)
{
struct list *e1, *e2;
LIST_FOR_EACH_SAFE(e1, e2, &This->state.light_map[counter])
LIST_FOR_EACH_SAFE(e1, e2, &stateblock->state.light_map[counter])
{
struct wined3d_light_info *light = LIST_ENTRY(e1, struct wined3d_light_info, entry);
list_remove(&light->entry);
@ -526,15 +526,16 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
}
}
HeapFree(GetProcessHeap(), 0, This->state.vs_consts_f);
HeapFree(GetProcessHeap(), 0, This->changed.vertexShaderConstantsF);
HeapFree(GetProcessHeap(), 0, This->state.ps_consts_f);
HeapFree(GetProcessHeap(), 0, This->changed.pixelShaderConstantsF);
HeapFree(GetProcessHeap(), 0, This->contained_vs_consts_f);
HeapFree(GetProcessHeap(), 0, This->contained_ps_consts_f);
HeapFree(GetProcessHeap(), 0, This);
HeapFree(GetProcessHeap(), 0, stateblock->state.vs_consts_f);
HeapFree(GetProcessHeap(), 0, stateblock->changed.vertexShaderConstantsF);
HeapFree(GetProcessHeap(), 0, stateblock->state.ps_consts_f);
HeapFree(GetProcessHeap(), 0, stateblock->changed.pixelShaderConstantsF);
HeapFree(GetProcessHeap(), 0, stateblock->contained_vs_consts_f);
HeapFree(GetProcessHeap(), 0, stateblock->contained_ps_consts_f);
HeapFree(GetProcessHeap(), 0, stateblock);
}
return refCount;
return refcount;
}
static void wined3d_state_record_lights(struct wined3d_state *dst_state, const struct wined3d_state *src_state)
@ -594,33 +595,32 @@ static void wined3d_state_record_lights(struct wined3d_state *dst_state, const s
}
}
static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
HRESULT CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
{
IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
const struct wined3d_state *src_state = &This->device->stateBlock->state;
const struct wined3d_state *src_state = &stateblock->device->stateBlock->state;
unsigned int i;
DWORD map;
TRACE("iface %p.\n", iface);
TRACE("stateblock %p.\n", stateblock);
TRACE("Capturing state %p.\n", src_state);
if (This->changed.vertexShader && This->state.vertex_shader != src_state->vertex_shader)
if (stateblock->changed.vertexShader && stateblock->state.vertex_shader != src_state->vertex_shader)
{
TRACE("Updating vertex shader from %p to %p\n",
This->state.vertex_shader, src_state->vertex_shader);
stateblock->state.vertex_shader, src_state->vertex_shader);
if (src_state->vertex_shader)
IWineD3DVertexShader_AddRef((IWineD3DVertexShader *)src_state->vertex_shader);
if (This->state.vertex_shader)
IWineD3DVertexShader_Release((IWineD3DVertexShader *)This->state.vertex_shader);
This->state.vertex_shader = src_state->vertex_shader;
wined3d_shader_incref(src_state->vertex_shader);
if (stateblock->state.vertex_shader)
wined3d_shader_decref(stateblock->state.vertex_shader);
stateblock->state.vertex_shader = src_state->vertex_shader;
}
/* Vertex Shader Float Constants */
for (i = 0; i < This->num_contained_vs_consts_f; ++i)
/* Vertex shader float constants. */
for (i = 0; i < stateblock->num_contained_vs_consts_f; ++i)
{
unsigned int idx = This->contained_vs_consts_f[i];
unsigned int idx = stateblock->contained_vs_consts_f[i];
TRACE("Setting vs_consts_f[%u] to {%.8e, %.8e, %.8e, %.8e}.\n", idx,
src_state->vs_consts_f[idx * 4 + 0],
@ -628,16 +628,16 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
src_state->vs_consts_f[idx * 4 + 2],
src_state->vs_consts_f[idx * 4 + 3]);
This->state.vs_consts_f[idx * 4 + 0] = src_state->vs_consts_f[idx * 4 + 0];
This->state.vs_consts_f[idx * 4 + 1] = src_state->vs_consts_f[idx * 4 + 1];
This->state.vs_consts_f[idx * 4 + 2] = src_state->vs_consts_f[idx * 4 + 2];
This->state.vs_consts_f[idx * 4 + 3] = src_state->vs_consts_f[idx * 4 + 3];
stateblock->state.vs_consts_f[idx * 4 + 0] = src_state->vs_consts_f[idx * 4 + 0];
stateblock->state.vs_consts_f[idx * 4 + 1] = src_state->vs_consts_f[idx * 4 + 1];
stateblock->state.vs_consts_f[idx * 4 + 2] = src_state->vs_consts_f[idx * 4 + 2];
stateblock->state.vs_consts_f[idx * 4 + 3] = src_state->vs_consts_f[idx * 4 + 3];
}
/* Vertex Shader Integer Constants */
for (i = 0; i < This->num_contained_vs_consts_i; ++i)
/* Vertex shader integer constants. */
for (i = 0; i < stateblock->num_contained_vs_consts_i; ++i)
{
unsigned int idx = This->contained_vs_consts_i[i];
unsigned int idx = stateblock->contained_vs_consts_i[i];
TRACE("Setting vs_consts[%u] to {%d, %d, %d, %d}.\n", idx,
src_state->vs_consts_i[idx * 4 + 0],
@ -645,27 +645,27 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
src_state->vs_consts_i[idx * 4 + 2],
src_state->vs_consts_i[idx * 4 + 3]);
This->state.vs_consts_i[idx * 4 + 0] = src_state->vs_consts_i[idx * 4 + 0];
This->state.vs_consts_i[idx * 4 + 1] = src_state->vs_consts_i[idx * 4 + 1];
This->state.vs_consts_i[idx * 4 + 2] = src_state->vs_consts_i[idx * 4 + 2];
This->state.vs_consts_i[idx * 4 + 3] = src_state->vs_consts_i[idx * 4 + 3];
stateblock->state.vs_consts_i[idx * 4 + 0] = src_state->vs_consts_i[idx * 4 + 0];
stateblock->state.vs_consts_i[idx * 4 + 1] = src_state->vs_consts_i[idx * 4 + 1];
stateblock->state.vs_consts_i[idx * 4 + 2] = src_state->vs_consts_i[idx * 4 + 2];
stateblock->state.vs_consts_i[idx * 4 + 3] = src_state->vs_consts_i[idx * 4 + 3];
}
/* Vertex Shader Boolean Constants */
for (i = 0; i < This->num_contained_vs_consts_b; ++i)
/* Vertex shader boolean constants. */
for (i = 0; i < stateblock->num_contained_vs_consts_b; ++i)
{
unsigned int idx = This->contained_vs_consts_b[i];
unsigned int idx = stateblock->contained_vs_consts_b[i];
TRACE("Setting vs_consts_b[%u] to %s.\n",
idx, src_state->vs_consts_b[idx] ? "TRUE" : "FALSE");
This->state.vs_consts_b[idx] = src_state->vs_consts_b[idx];
stateblock->state.vs_consts_b[idx] = src_state->vs_consts_b[idx];
}
/* Pixel Shader Float Constants */
for (i = 0; i < This->num_contained_ps_consts_f; ++i)
/* Pixel shader float constants. */
for (i = 0; i < stateblock->num_contained_ps_consts_f; ++i)
{
unsigned int idx = This->contained_ps_consts_f[i];
unsigned int idx = stateblock->contained_ps_consts_f[i];
TRACE("Setting ps_consts_f[%u] to {%.8e, %.8e, %.8e, %.8e}.\n", idx,
src_state->ps_consts_f[idx * 4 + 0],
@ -673,217 +673,219 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
src_state->ps_consts_f[idx * 4 + 2],
src_state->ps_consts_f[idx * 4 + 3]);
This->state.ps_consts_f[idx * 4 + 0] = src_state->ps_consts_f[idx * 4 + 0];
This->state.ps_consts_f[idx * 4 + 1] = src_state->ps_consts_f[idx * 4 + 1];
This->state.ps_consts_f[idx * 4 + 2] = src_state->ps_consts_f[idx * 4 + 2];
This->state.ps_consts_f[idx * 4 + 3] = src_state->ps_consts_f[idx * 4 + 3];
stateblock->state.ps_consts_f[idx * 4 + 0] = src_state->ps_consts_f[idx * 4 + 0];
stateblock->state.ps_consts_f[idx * 4 + 1] = src_state->ps_consts_f[idx * 4 + 1];
stateblock->state.ps_consts_f[idx * 4 + 2] = src_state->ps_consts_f[idx * 4 + 2];
stateblock->state.ps_consts_f[idx * 4 + 3] = src_state->ps_consts_f[idx * 4 + 3];
}
/* Pixel Shader Integer Constants */
for (i = 0; i < This->num_contained_ps_consts_i; ++i)
/* Pixel shader integer constants. */
for (i = 0; i < stateblock->num_contained_ps_consts_i; ++i)
{
unsigned int idx = This->contained_ps_consts_i[i];
unsigned int idx = stateblock->contained_ps_consts_i[i];
TRACE("Setting ps_consts_i[%u] to {%d, %d, %d, %d}.\n", idx,
src_state->ps_consts_i[idx * 4 + 0],
src_state->ps_consts_i[idx * 4 + 1],
src_state->ps_consts_i[idx * 4 + 2],
src_state->ps_consts_i[idx * 4 + 3]);
This->state.ps_consts_i[idx * 4 + 0] = src_state->ps_consts_i[idx * 4 + 0];
This->state.ps_consts_i[idx * 4 + 1] = src_state->ps_consts_i[idx * 4 + 1];
This->state.ps_consts_i[idx * 4 + 2] = src_state->ps_consts_i[idx * 4 + 2];
This->state.ps_consts_i[idx * 4 + 3] = src_state->ps_consts_i[idx * 4 + 3];
stateblock->state.ps_consts_i[idx * 4 + 0] = src_state->ps_consts_i[idx * 4 + 0];
stateblock->state.ps_consts_i[idx * 4 + 1] = src_state->ps_consts_i[idx * 4 + 1];
stateblock->state.ps_consts_i[idx * 4 + 2] = src_state->ps_consts_i[idx * 4 + 2];
stateblock->state.ps_consts_i[idx * 4 + 3] = src_state->ps_consts_i[idx * 4 + 3];
}
/* Pixel Shader Boolean Constants */
for (i = 0; i < This->num_contained_ps_consts_b; ++i)
/* Pixel shader boolean constants. */
for (i = 0; i < stateblock->num_contained_ps_consts_b; ++i)
{
unsigned int idx = This->contained_ps_consts_b[i];
unsigned int idx = stateblock->contained_ps_consts_b[i];
TRACE("Setting ps_consts_b[%u] to %s.\n",
idx, src_state->ps_consts_b[idx] ? "TRUE" : "FALSE");
This->state.ps_consts_b[idx] = src_state->ps_consts_b[idx];
stateblock->state.ps_consts_b[idx] = src_state->ps_consts_b[idx];
}
/* Others + Render & Texture */
for (i = 0; i < This->num_contained_transform_states; ++i)
for (i = 0; i < stateblock->num_contained_transform_states; ++i)
{
WINED3DTRANSFORMSTATETYPE transform = This->contained_transform_states[i];
WINED3DTRANSFORMSTATETYPE transform = stateblock->contained_transform_states[i];
TRACE("Updating transform %#x.\n", transform);
This->state.transforms[transform] = src_state->transforms[transform];
stateblock->state.transforms[transform] = src_state->transforms[transform];
}
if (This->changed.primitive_type)
This->state.gl_primitive_type = src_state->gl_primitive_type;
if (stateblock->changed.primitive_type)
stateblock->state.gl_primitive_type = src_state->gl_primitive_type;
if (This->changed.indices
&& ((This->state.index_buffer != src_state->index_buffer)
|| (This->state.base_vertex_index != src_state->base_vertex_index)
|| (This->state.index_format != src_state->index_format)))
if (stateblock->changed.indices
&& ((stateblock->state.index_buffer != src_state->index_buffer)
|| (stateblock->state.base_vertex_index != src_state->base_vertex_index)
|| (stateblock->state.index_format != src_state->index_format)))
{
TRACE("Updating index buffer to %p, base vertex index to %d.\n",
src_state->index_buffer, src_state->base_vertex_index);
if (src_state->index_buffer)
IWineD3DBuffer_AddRef((IWineD3DBuffer *)src_state->index_buffer);
if (This->state.index_buffer)
IWineD3DBuffer_Release((IWineD3DBuffer *)This->state.index_buffer);
This->state.index_buffer = src_state->index_buffer;
This->state.base_vertex_index = src_state->base_vertex_index;
This->state.index_format = src_state->index_format;
wined3d_buffer_incref(src_state->index_buffer);
if (stateblock->state.index_buffer)
wined3d_buffer_decref(stateblock->state.index_buffer);
stateblock->state.index_buffer = src_state->index_buffer;
stateblock->state.base_vertex_index = src_state->base_vertex_index;
stateblock->state.index_format = src_state->index_format;
}
if (This->changed.vertexDecl && This->state.vertex_declaration != src_state->vertex_declaration)
if (stateblock->changed.vertexDecl && stateblock->state.vertex_declaration != src_state->vertex_declaration)
{
TRACE("Updating vertex declaration from %p to %p.\n",
This->state.vertex_declaration, src_state->vertex_declaration);
stateblock->state.vertex_declaration, src_state->vertex_declaration);
if (src_state->vertex_declaration)
IWineD3DVertexDeclaration_AddRef((IWineD3DVertexDeclaration *)src_state->vertex_declaration);
if (This->state.vertex_declaration)
IWineD3DVertexDeclaration_Release((IWineD3DVertexDeclaration *)This->state.vertex_declaration);
This->state.vertex_declaration = src_state->vertex_declaration;
wined3d_vertex_declaration_incref(src_state->vertex_declaration);
if (stateblock->state.vertex_declaration)
wined3d_vertex_declaration_decref(stateblock->state.vertex_declaration);
stateblock->state.vertex_declaration = src_state->vertex_declaration;
}
if (This->changed.material && memcmp(&src_state->material, &This->state.material, sizeof(This->state.material)))
if (stateblock->changed.material
&& memcmp(&src_state->material, &stateblock->state.material, sizeof(stateblock->state.material)))
{
TRACE("Updating material.\n");
This->state.material = src_state->material;
stateblock->state.material = src_state->material;
}
if (This->changed.viewport && memcmp(&src_state->viewport, &This->state.viewport, sizeof(This->state.viewport)))
if (stateblock->changed.viewport
&& memcmp(&src_state->viewport, &stateblock->state.viewport, sizeof(stateblock->state.viewport)))
{
TRACE("Updating viewport.\n");
This->state.viewport = src_state->viewport;
stateblock->state.viewport = src_state->viewport;
}
if (This->changed.scissorRect && memcmp(&src_state->scissor_rect,
&This->state.scissor_rect, sizeof(This->state.scissor_rect)))
if (stateblock->changed.scissorRect && memcmp(&src_state->scissor_rect,
&stateblock->state.scissor_rect, sizeof(stateblock->state.scissor_rect)))
{
TRACE("Updating scissor rect.\n");
This->state.scissor_rect = src_state->scissor_rect;
stateblock->state.scissor_rect = src_state->scissor_rect;
}
map = This->changed.streamSource;
map = stateblock->changed.streamSource;
for (i = 0; map; map >>= 1, ++i)
{
if (!(map & 1)) continue;
if (This->state.streams[i].stride != src_state->streams[i].stride
|| This->state.streams[i].buffer != src_state->streams[i].buffer)
if (stateblock->state.streams[i].stride != src_state->streams[i].stride
|| stateblock->state.streams[i].buffer != src_state->streams[i].buffer)
{
TRACE("Updating stream source %u to %p, stride to %u.\n",
i, src_state->streams[i].buffer,
src_state->streams[i].stride);
This->state.streams[i].stride = src_state->streams[i].stride;
stateblock->state.streams[i].stride = src_state->streams[i].stride;
if (src_state->streams[i].buffer)
IWineD3DBuffer_AddRef((IWineD3DBuffer *)src_state->streams[i].buffer);
if (This->state.streams[i].buffer)
IWineD3DBuffer_Release((IWineD3DBuffer *)This->state.streams[i].buffer);
This->state.streams[i].buffer = src_state->streams[i].buffer;
wined3d_buffer_incref(src_state->streams[i].buffer);
if (stateblock->state.streams[i].buffer)
wined3d_buffer_decref(stateblock->state.streams[i].buffer);
stateblock->state.streams[i].buffer = src_state->streams[i].buffer;
}
}
map = This->changed.streamFreq;
map = stateblock->changed.streamFreq;
for (i = 0; map; map >>= 1, ++i)
{
if (!(map & 1)) continue;
if (This->state.streams[i].frequency != src_state->streams[i].frequency
|| This->state.streams[i].flags != src_state->streams[i].flags)
if (stateblock->state.streams[i].frequency != src_state->streams[i].frequency
|| stateblock->state.streams[i].flags != src_state->streams[i].flags)
{
TRACE("Updating stream frequency %u to %u flags to %#x.\n",
i, src_state->streams[i].frequency, src_state->streams[i].flags);
This->state.streams[i].frequency = src_state->streams[i].frequency;
This->state.streams[i].flags = src_state->streams[i].flags;
stateblock->state.streams[i].frequency = src_state->streams[i].frequency;
stateblock->state.streams[i].flags = src_state->streams[i].flags;
}
}
map = This->changed.clipplane;
map = stateblock->changed.clipplane;
for (i = 0; map; map >>= 1, ++i)
{
if (!(map & 1)) continue;
if (memcmp(src_state->clip_planes[i], This->state.clip_planes[i], sizeof(*This->state.clip_planes)))
if (memcmp(src_state->clip_planes[i], stateblock->state.clip_planes[i], sizeof(*stateblock->state.clip_planes)))
{
TRACE("Updating clipplane %u.\n", i);
memcpy(This->state.clip_planes[i], src_state->clip_planes[i], sizeof(*This->state.clip_planes));
memcpy(stateblock->state.clip_planes[i], src_state->clip_planes[i], sizeof(*stateblock->state.clip_planes));
}
}
/* Render */
for (i = 0; i < This->num_contained_render_states; ++i)
for (i = 0; i < stateblock->num_contained_render_states; ++i)
{
WINED3DRENDERSTATETYPE rs = This->contained_render_states[i];
WINED3DRENDERSTATETYPE rs = stateblock->contained_render_states[i];
TRACE("Updating render state %#x to %u.\n", rs, src_state->render_states[rs]);
This->state.render_states[rs] = src_state->render_states[rs];
stateblock->state.render_states[rs] = src_state->render_states[rs];
}
/* Texture states */
for (i = 0; i < This->num_contained_tss_states; ++i)
for (i = 0; i < stateblock->num_contained_tss_states; ++i)
{
DWORD stage = This->contained_tss_states[i].stage;
DWORD state = This->contained_tss_states[i].state;
DWORD stage = stateblock->contained_tss_states[i].stage;
DWORD state = stateblock->contained_tss_states[i].state;
TRACE("Updating texturestage state %u, %u to %#x (was %#x).\n", stage, state,
src_state->texture_states[stage][state], This->state.texture_states[stage][state]);
src_state->texture_states[stage][state], stateblock->state.texture_states[stage][state]);
This->state.texture_states[stage][state] = src_state->texture_states[stage][state];
stateblock->state.texture_states[stage][state] = src_state->texture_states[stage][state];
}
/* Samplers */
map = This->changed.textures;
map = stateblock->changed.textures;
for (i = 0; map; map >>= 1, ++i)
{
if (!(map & 1)) continue;
TRACE("Updating texture %u to %p (was %p).\n",
i, src_state->textures[i], This->state.textures[i]);
i, src_state->textures[i], stateblock->state.textures[i]);
if (src_state->textures[i])
IWineD3DBaseTexture_AddRef((IWineD3DBaseTexture *)src_state->textures[i]);
if (This->state.textures[i])
IWineD3DBaseTexture_Release((IWineD3DBaseTexture *)This->state.textures[i]);
This->state.textures[i] = src_state->textures[i];
wined3d_texture_incref(src_state->textures[i]);
if (stateblock->state.textures[i])
wined3d_texture_decref(stateblock->state.textures[i]);
stateblock->state.textures[i] = src_state->textures[i];
}
for (i = 0; i < This->num_contained_sampler_states; ++i)
for (i = 0; i < stateblock->num_contained_sampler_states; ++i)
{
DWORD stage = This->contained_sampler_states[i].stage;
DWORD state = This->contained_sampler_states[i].state;
DWORD stage = stateblock->contained_sampler_states[i].stage;
DWORD state = stateblock->contained_sampler_states[i].state;
TRACE("Updating sampler state %u, %u to %#x (was %#x).\n", stage, state,
src_state->sampler_states[stage][state], This->state.sampler_states[stage][state]);
src_state->sampler_states[stage][state], stateblock->state.sampler_states[stage][state]);
This->state.sampler_states[stage][state] = src_state->sampler_states[stage][state];
stateblock->state.sampler_states[stage][state] = src_state->sampler_states[stage][state];
}
if (This->changed.pixelShader && This->state.pixel_shader != src_state->pixel_shader)
if (stateblock->changed.pixelShader && stateblock->state.pixel_shader != src_state->pixel_shader)
{
if (src_state->pixel_shader)
IWineD3DPixelShader_AddRef((IWineD3DPixelShader *)src_state->pixel_shader);
if (This->state.pixel_shader)
IWineD3DPixelShader_Release((IWineD3DPixelShader *)This->state.pixel_shader);
This->state.pixel_shader = src_state->pixel_shader;
wined3d_shader_incref(src_state->pixel_shader);
if (stateblock->state.pixel_shader)
wined3d_shader_decref(stateblock->state.pixel_shader);
stateblock->state.pixel_shader = src_state->pixel_shader;
}
wined3d_state_record_lights(&This->state, src_state);
wined3d_state_record_lights(&stateblock->state, src_state);
TRACE("Captue done.\n");
return WINED3D_OK;
}
static void apply_lights(IWineD3DDevice *device, const struct wined3d_state *state)
static void apply_lights(struct wined3d_device *device, const struct wined3d_state *state)
{
UINT i;
@ -895,148 +897,139 @@ static void apply_lights(IWineD3DDevice *device, const struct wined3d_state *sta
{
const struct wined3d_light_info *light = LIST_ENTRY(e, struct wined3d_light_info, entry);
IWineD3DDevice_SetLight(device, light->OriginalIndex, &light->OriginalParms);
IWineD3DDevice_SetLightEnable(device, light->OriginalIndex, light->glIndex != -1);
wined3d_device_set_light(device, light->OriginalIndex, &light->OriginalParms);
wined3d_device_set_light_enable(device, light->OriginalIndex, light->glIndex != -1);
}
}
}
static HRESULT WINAPI IWineD3DStateBlockImpl_Apply(IWineD3DStateBlock *iface)
HRESULT CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
{
IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
IWineD3DDevice *device = (IWineD3DDevice *)This->device;
struct wined3d_device *device = stateblock->device;
unsigned int i;
DWORD map;
TRACE("(%p) : Applying state block %p ------------------v\n", This, device);
TRACE("Applying stateblock %p to device %p.\n", stateblock, device);
TRACE("Blocktype: %#x.\n", stateblock->blockType);
TRACE("Blocktype: %d\n", This->blockType);
if (stateblock->changed.vertexShader)
wined3d_device_set_vertex_shader(device, stateblock->state.vertex_shader);
if (This->changed.vertexShader)
IWineD3DDevice_SetVertexShader(device, (IWineD3DVertexShader *)This->state.vertex_shader);
/* Vertex Shader Constants */
for (i = 0; i < This->num_contained_vs_consts_f; ++i)
/* Vertex Shader Constants. */
for (i = 0; i < stateblock->num_contained_vs_consts_f; ++i)
{
IWineD3DDevice_SetVertexShaderConstantF(device, This->contained_vs_consts_f[i],
This->state.vs_consts_f + This->contained_vs_consts_f[i] * 4, 1);
wined3d_device_set_vs_consts_f(device, stateblock->contained_vs_consts_f[i],
stateblock->state.vs_consts_f + stateblock->contained_vs_consts_f[i] * 4, 1);
}
for (i = 0; i < This->num_contained_vs_consts_i; ++i)
for (i = 0; i < stateblock->num_contained_vs_consts_i; ++i)
{
IWineD3DDevice_SetVertexShaderConstantI(device, This->contained_vs_consts_i[i],
This->state.vs_consts_i + This->contained_vs_consts_i[i] * 4, 1);
wined3d_device_set_vs_consts_i(device, stateblock->contained_vs_consts_i[i],
stateblock->state.vs_consts_i + stateblock->contained_vs_consts_i[i] * 4, 1);
}
for (i = 0; i < This->num_contained_vs_consts_b; ++i)
for (i = 0; i < stateblock->num_contained_vs_consts_b; ++i)
{
IWineD3DDevice_SetVertexShaderConstantB(device, This->contained_vs_consts_b[i],
This->state.vs_consts_b + This->contained_vs_consts_b[i], 1);
wined3d_device_set_vs_consts_b(device, stateblock->contained_vs_consts_b[i],
stateblock->state.vs_consts_b + stateblock->contained_vs_consts_b[i], 1);
}
apply_lights(device, &This->state);
apply_lights(device, &stateblock->state);
if (This->changed.pixelShader)
IWineD3DDevice_SetPixelShader(device, (IWineD3DPixelShader *)This->state.pixel_shader);
if (stateblock->changed.pixelShader)
wined3d_device_set_pixel_shader(device, stateblock->state.pixel_shader);
/* Pixel Shader Constants */
for (i = 0; i < This->num_contained_ps_consts_f; ++i)
/* Pixel Shader Constants. */
for (i = 0; i < stateblock->num_contained_ps_consts_f; ++i)
{
IWineD3DDevice_SetPixelShaderConstantF(device, This->contained_ps_consts_f[i],
This->state.ps_consts_f + This->contained_ps_consts_f[i] * 4, 1);
wined3d_device_set_ps_consts_f(device, stateblock->contained_ps_consts_f[i],
stateblock->state.ps_consts_f + stateblock->contained_ps_consts_f[i] * 4, 1);
}
for (i = 0; i < This->num_contained_ps_consts_i; ++i)
for (i = 0; i < stateblock->num_contained_ps_consts_i; ++i)
{
IWineD3DDevice_SetPixelShaderConstantI(device, This->contained_ps_consts_i[i],
This->state.ps_consts_i + This->contained_ps_consts_i[i] * 4, 1);
wined3d_device_set_ps_consts_i(device, stateblock->contained_ps_consts_i[i],
stateblock->state.ps_consts_i + stateblock->contained_ps_consts_i[i] * 4, 1);
}
for (i = 0; i < This->num_contained_ps_consts_b; ++i)
for (i = 0; i < stateblock->num_contained_ps_consts_b; ++i)
{
IWineD3DDevice_SetPixelShaderConstantB(device, This->contained_ps_consts_b[i],
This->state.ps_consts_b + This->contained_ps_consts_b[i], 1);
wined3d_device_set_ps_consts_b(device, stateblock->contained_ps_consts_b[i],
stateblock->state.ps_consts_b + stateblock->contained_ps_consts_b[i], 1);
}
/* Render */
for (i = 0; i < This->num_contained_render_states; ++i)
/* Render states. */
for (i = 0; i < stateblock->num_contained_render_states; ++i)
{
IWineD3DDevice_SetRenderState(device, This->contained_render_states[i],
This->state.render_states[This->contained_render_states[i]]);
wined3d_device_set_render_state(device, stateblock->contained_render_states[i],
stateblock->state.render_states[stateblock->contained_render_states[i]]);
}
/* Texture states */
for (i = 0; i < This->num_contained_tss_states; ++i)
/* Texture states. */
for (i = 0; i < stateblock->num_contained_tss_states; ++i)
{
DWORD stage = This->contained_tss_states[i].stage;
DWORD state = This->contained_tss_states[i].state;
DWORD stage = stateblock->contained_tss_states[i].stage;
DWORD state = stateblock->contained_tss_states[i].state;
IWineD3DDevice_SetTextureStageState(device, stage, state, This->state.texture_states[stage][state]);
wined3d_device_set_texture_stage_state(device, stage, state, stateblock->state.texture_states[stage][state]);
}
/* Sampler states */
for (i = 0; i < This->num_contained_sampler_states; ++i)
/* Sampler states. */
for (i = 0; i < stateblock->num_contained_sampler_states; ++i)
{
DWORD stage = This->contained_sampler_states[i].stage;
DWORD state = This->contained_sampler_states[i].state;
DWORD value = This->state.sampler_states[stage][state];
DWORD stage = stateblock->contained_sampler_states[i].stage;
DWORD state = stateblock->contained_sampler_states[i].state;
DWORD value = stateblock->state.sampler_states[stage][state];
if (stage >= MAX_FRAGMENT_SAMPLERS) stage += WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS;
IWineD3DDevice_SetSamplerState(device, stage, state, value);
wined3d_device_set_sampler_state(device, stage, state, value);
}
for (i = 0; i < This->num_contained_transform_states; ++i)
/* Transform states. */
for (i = 0; i < stateblock->num_contained_transform_states; ++i)
{
IWineD3DDevice_SetTransform(device, This->contained_transform_states[i],
&This->state.transforms[This->contained_transform_states[i]]);
wined3d_device_set_transform(device, stateblock->contained_transform_states[i],
&stateblock->state.transforms[stateblock->contained_transform_states[i]]);
}
if (This->changed.primitive_type)
if (stateblock->changed.primitive_type)
{
This->device->updateStateBlock->changed.primitive_type = TRUE;
This->device->updateStateBlock->state.gl_primitive_type = This->state.gl_primitive_type;
stateblock->device->updateStateBlock->changed.primitive_type = TRUE;
stateblock->device->updateStateBlock->state.gl_primitive_type = stateblock->state.gl_primitive_type;
}
if (This->changed.indices)
if (stateblock->changed.indices)
{
IWineD3DDevice_SetIndexBuffer(device, (IWineD3DBuffer *)This->state.index_buffer, This->state.index_format);
IWineD3DDevice_SetBaseVertexIndex(device, This->state.base_vertex_index);
wined3d_device_set_index_buffer(device, stateblock->state.index_buffer, stateblock->state.index_format);
wined3d_device_set_base_vertex_index(device, stateblock->state.base_vertex_index);
}
if (This->changed.vertexDecl && This->state.vertex_declaration)
{
IWineD3DDevice_SetVertexDeclaration(device, (IWineD3DVertexDeclaration *)This->state.vertex_declaration);
}
if (stateblock->changed.vertexDecl && stateblock->state.vertex_declaration)
wined3d_device_set_vertex_declaration(device, stateblock->state.vertex_declaration);
if (This->changed.material)
{
IWineD3DDevice_SetMaterial(device, &This->state.material);
}
if (stateblock->changed.material)
wined3d_device_set_material(device, &stateblock->state.material);
if (This->changed.viewport)
{
IWineD3DDevice_SetViewport(device, &This->state.viewport);
}
if (stateblock->changed.viewport)
wined3d_device_set_viewport(device, &stateblock->state.viewport);
if (This->changed.scissorRect)
{
IWineD3DDevice_SetScissorRect(device, &This->state.scissor_rect);
}
if (stateblock->changed.scissorRect)
wined3d_device_set_scissor_rect(device, &stateblock->state.scissor_rect);
map = This->changed.streamSource;
map = stateblock->changed.streamSource;
for (i = 0; map; map >>= 1, ++i)
{
if (map & 1)
IWineD3DDevice_SetStreamSource(device, i,
(IWineD3DBuffer *)This->state.streams[i].buffer,
0, This->state.streams[i].stride);
wined3d_device_set_stream_source(device, i,
stateblock->state.streams[i].buffer,
0, stateblock->state.streams[i].stride);
}
map = This->changed.streamFreq;
map = stateblock->changed.streamFreq;
for (i = 0; map; map >>= 1, ++i)
{
if (map & 1)
IWineD3DDevice_SetStreamSourceFreq(device, i,
This->state.streams[i].frequency | This->state.streams[i].flags);
wined3d_device_set_stream_source_freq(device, i,
stateblock->state.streams[i].frequency | stateblock->state.streams[i].flags);
}
map = This->changed.textures;
map = stateblock->changed.textures;
for (i = 0; map; map >>= 1, ++i)
{
DWORD stage;
@ -1044,40 +1037,41 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Apply(IWineD3DStateBlock *iface)
if (!(map & 1)) continue;
stage = i < MAX_FRAGMENT_SAMPLERS ? i : WINED3DVERTEXTEXTURESAMPLER0 + i - MAX_FRAGMENT_SAMPLERS;
IWineD3DDevice_SetTexture(device, stage, (IWineD3DBaseTexture *)This->state.textures[i]);
wined3d_device_set_texture(device, stage, stateblock->state.textures[i]);
}
map = This->changed.clipplane;
map = stateblock->changed.clipplane;
for (i = 0; map; map >>= 1, ++i)
{
float clip[4];
if (!(map & 1)) continue;
clip[0] = This->state.clip_planes[i][0];
clip[1] = This->state.clip_planes[i][1];
clip[2] = This->state.clip_planes[i][2];
clip[3] = This->state.clip_planes[i][3];
IWineD3DDevice_SetClipPlane(device, i, clip);
clip[0] = (float) stateblock->state.clip_planes[i][0];
clip[1] = (float) stateblock->state.clip_planes[i][1];
clip[2] = (float) stateblock->state.clip_planes[i][2];
clip[3] = (float) stateblock->state.clip_planes[i][3];
wined3d_device_set_clip_plane(device, i, clip);
}
This->device->stateBlock->state.lowest_disabled_stage = MAX_TEXTURES - 1;
stateblock->device->stateBlock->state.lowest_disabled_stage = MAX_TEXTURES - 1;
for (i = 0; i < MAX_TEXTURES - 1; ++i)
{
if (This->device->stateBlock->state.texture_states[i][WINED3DTSS_COLOROP] == WINED3DTOP_DISABLE)
if (stateblock->device->stateBlock->state.texture_states[i][WINED3DTSS_COLOROP] == WINED3DTOP_DISABLE)
{
This->device->stateBlock->state.lowest_disabled_stage = i;
stateblock->device->stateBlock->state.lowest_disabled_stage = i;
break;
}
}
TRACE("(%p) : Applied state block %p ------------------^\n", This, device);
TRACE("Applied stateblock %p.\n", stateblock);
return WINED3D_OK;
}
void stateblock_init_default_state(IWineD3DStateBlockImpl *stateblock)
void stateblock_init_default_state(struct wined3d_stateblock *stateblock)
{
IWineD3DDeviceImpl *device = stateblock->device;
struct wined3d_device *device = stateblock->device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct wined3d_state *state = &stateblock->state;
union {
@ -1089,8 +1083,8 @@ void stateblock_init_default_state(IWineD3DStateBlockImpl *stateblock)
DWORD d;
} tmpfloat;
unsigned int i;
IWineD3DSwapChain *swapchain;
IWineD3DSurface *backbuffer;
struct wined3d_swapchain *swapchain;
struct wined3d_surface *backbuffer;
HRESULT hr;
TRACE("stateblock %p.\n", stateblock);
@ -1139,7 +1133,6 @@ void stateblock_init_default_state(IWineD3DStateBlockImpl *stateblock)
tmpfloat.f = 1.0f;
state->render_states[WINED3DRS_FOGDENSITY] = tmpfloat.d;
state->render_states[WINED3DRS_EDGEANTIALIAS] = FALSE;
state->render_states[WINED3DRS_ZBIAS] = 0;
state->render_states[WINED3DRS_RANGEFOGENABLE] = FALSE;
state->render_states[WINED3DRS_STENCILENABLE] = FALSE;
state->render_states[WINED3DRS_STENCILFAIL] = WINED3DSTENCILOP_KEEP;
@ -1294,16 +1287,16 @@ void stateblock_init_default_state(IWineD3DStateBlockImpl *stateblock)
}
/* check the return values, because the GetBackBuffer call isn't valid for ddraw */
hr = IWineD3DDevice_GetSwapChain((IWineD3DDevice *)device, 0, &swapchain);
hr = wined3d_device_get_swapchain(device, 0, &swapchain);
if (SUCCEEDED(hr) && swapchain)
{
hr = IWineD3DSwapChain_GetBackBuffer(swapchain, 0, WINED3DBACKBUFFER_TYPE_MONO, &backbuffer);
hr = wined3d_swapchain_get_back_buffer(swapchain, 0, WINED3DBACKBUFFER_TYPE_MONO, &backbuffer);
if (SUCCEEDED(hr) && backbuffer)
{
WINED3DSURFACE_DESC desc;
struct wined3d_resource_desc desc;
IWineD3DSurface_GetDesc(backbuffer, &desc);
IWineD3DSurface_Release(backbuffer);
wined3d_resource_get_desc(&backbuffer->resource, &desc);
wined3d_surface_decref(backbuffer);
/* Set the default scissor rect values */
state->scissor_rect.left = 0;
@ -1315,38 +1308,23 @@ void stateblock_init_default_state(IWineD3DStateBlockImpl *stateblock)
/* Set the default viewport */
state->viewport.X = 0;
state->viewport.Y = 0;
state->viewport.Width = ((IWineD3DSwapChainImpl *)swapchain)->presentParms.BackBufferWidth;
state->viewport.Height = ((IWineD3DSwapChainImpl *)swapchain)->presentParms.BackBufferHeight;
state->viewport.Width = swapchain->presentParms.BackBufferWidth;
state->viewport.Height = swapchain->presentParms.BackBufferHeight;
state->viewport.MinZ = 0.0f;
state->viewport.MaxZ = 1.0f;
IWineD3DSwapChain_Release(swapchain);
wined3d_swapchain_decref(swapchain);
}
TRACE("Done.\n");
}
/**********************************************************
* IWineD3DStateBlock VTbl follows
**********************************************************/
static const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl =
{
/* IUnknown */
IWineD3DStateBlockImpl_QueryInterface,
IWineD3DStateBlockImpl_AddRef,
IWineD3DStateBlockImpl_Release,
/* IWineD3DStateBlock */
IWineD3DStateBlockImpl_Capture,
IWineD3DStateBlockImpl_Apply,
};
HRESULT stateblock_init(IWineD3DStateBlockImpl *stateblock, IWineD3DDeviceImpl *device, WINED3DSTATEBLOCKTYPE type)
static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
struct wined3d_device *device, WINED3DSTATEBLOCKTYPE type)
{
unsigned int i;
HRESULT hr;
stateblock->lpVtbl = &IWineD3DStateBlock_Vtbl;
stateblock->ref = 1;
stateblock->device = device;
stateblock->blockType = type;
@ -1389,7 +1367,37 @@ HRESULT stateblock_init(IWineD3DStateBlockImpl *stateblock, IWineD3DDeviceImpl *
}
stateblock_init_contained_states(stateblock);
IWineD3DStateBlockImpl_Capture((IWineD3DStateBlock *)stateblock);
wined3d_stateblock_capture(stateblock);
return WINED3D_OK;
}
HRESULT CDECL wined3d_stateblock_create(struct wined3d_device *device,
WINED3DSTATEBLOCKTYPE type, struct wined3d_stateblock **stateblock)
{
struct wined3d_stateblock *object;
HRESULT hr;
TRACE("device %p, type %#x, stateblock %p.\n",
device, type, stateblock);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
ERR("Failed to allocate stateblock memory.\n");
return E_OUTOFMEMORY;
}
hr = stateblock_init(object, device, type);
if (FAILED(hr))
{
WARN("Failed to initialize stateblock, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created stateblock %p.\n", object);
*stateblock = object;
return WINED3D_OK;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,538 +0,0 @@
/*
* 2D Surface implementation without OpenGL
*
* Copyright 1997-2000 Marcus Meissner
* Copyright 1998-2000 Lionel Ulmer
* Copyright 2000-2001 TransGaming Technologies Inc.
* Copyright 2002-2005 Jason Edmeades
* Copyright 2002-2003 Raphael Junqueira
* Copyright 2004 Christian Costa
* Copyright 2005 Oliver Stieber
* Copyright 2006-2008 Stefan Dösinger
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include "wined3d_private.h"
#include <stdio.h>
/* Use the d3d_surface debug channel to have one channel for all surfaces */
WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
void surface_gdi_cleanup(IWineD3DSurfaceImpl *This)
{
TRACE("(%p) : Cleaning up.\n", This);
if (This->Flags & SFLAG_DIBSECTION)
{
/* Release the DC. */
SelectObject(This->hDC, This->dib.holdbitmap);
DeleteDC(This->hDC);
/* Release the DIB section. */
DeleteObject(This->dib.DIBsection);
This->dib.bitmap_data = NULL;
This->resource.allocatedMemory = NULL;
}
if (This->Flags & SFLAG_USERPTR) IWineD3DSurface_SetMem((IWineD3DSurface *)This, NULL);
if (This->overlay_dest) list_remove(&This->overlay_entry);
HeapFree(GetProcessHeap(), 0, This->palette9);
resource_cleanup((IWineD3DResource *)This);
}
/*****************************************************************************
* IWineD3DSurface::Release, GDI version
*
* In general a normal COM Release method, but the GDI version doesn't have
* to destroy all the GL things.
*
*****************************************************************************/
static ULONG WINAPI IWineGDISurfaceImpl_Release(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
ULONG ref = InterlockedDecrement(&This->resource.ref);
TRACE("(%p) : Releasing from %d\n", This, ref + 1);
if (!ref)
{
surface_gdi_cleanup(This);
TRACE("(%p) Released.\n", This);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/*****************************************************************************
* IWineD3DSurface::PreLoad, GDI version
*
* This call is unsupported on GDI surfaces, if it's called something went
* wrong in the parent library. Write an informative warning
*
*****************************************************************************/
static void WINAPI
IWineGDISurfaceImpl_PreLoad(IWineD3DSurface *iface)
{
ERR("(%p): PreLoad is not supported on X11 surfaces!\n", iface);
ERR("(%p): Most likely the parent library did something wrong.\n", iface);
ERR("(%p): Please report to wine-devel\n", iface);
}
/*****************************************************************************
* IWineD3DSurface::UnLoad, GDI version
*
* This call is unsupported on GDI surfaces, if it's called something went
* wrong in the parent library. Write an informative warning.
*
*****************************************************************************/
static void WINAPI IWineGDISurfaceImpl_UnLoad(IWineD3DSurface *iface)
{
ERR("(%p): UnLoad is not supported on X11 surfaces!\n", iface);
ERR("(%p): Most likely the parent library did something wrong.\n", iface);
ERR("(%p): Please report to wine-devel\n", iface);
}
/*****************************************************************************
* IWineD3DSurface::LockRect, GDI version
*
* Locks the surface and returns a pointer to the surface memory
*
* Params:
* pLockedRect: Address to return the locking info at
* pRect: Rectangle to lock
* Flags: Some flags
*
* Returns:
* WINED3D_OK on success
* WINED3DERR_INVALIDCALL on errors
*
*****************************************************************************/
static HRESULT WINAPI
IWineGDISurfaceImpl_LockRect(IWineD3DSurface *iface,
WINED3DLOCKED_RECT* pLockedRect,
CONST RECT* pRect,
DWORD Flags)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
/* Already locked? */
if(This->Flags & SFLAG_LOCKED)
{
WARN("(%p) Surface already locked\n", This);
/* What should I return here? */
return WINED3DERR_INVALIDCALL;
}
This->Flags |= SFLAG_LOCKED;
if(!This->resource.allocatedMemory) {
/* This happens on gdi surfaces if the application set a user pointer and resets it.
* Recreate the DIB section
*/
IWineD3DBaseSurfaceImpl_CreateDIBSection(iface);
This->resource.allocatedMemory = This->dib.bitmap_data;
}
return IWineD3DBaseSurfaceImpl_LockRect(iface, pLockedRect, pRect, Flags);
}
/*****************************************************************************
* IWineD3DSurface::UnlockRect, GDI version
*
* Unlocks a surface. This implementation doesn't do much, except updating
* the window if the front buffer is unlocked
*
* Returns:
* WINED3D_OK on success
* WINED3DERR_INVALIDCALL on failure
*
*****************************************************************************/
static HRESULT WINAPI
IWineGDISurfaceImpl_UnlockRect(IWineD3DSurface *iface)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("(%p)\n", This);
if (!(This->Flags & SFLAG_LOCKED))
{
WARN("trying to Unlock an unlocked surf@%p\n", This);
return WINEDDERR_NOTLOCKED;
}
/* Tell the swapchain to update the screen */
if (This->container.type == WINED3D_CONTAINER_SWAPCHAIN)
{
IWineD3DSwapChainImpl *swapchain = This->container.u.swapchain;
if (This == swapchain->front_buffer)
{
x11_copy_to_screen(swapchain, &This->lockedRect);
}
}
This->Flags &= ~SFLAG_LOCKED;
memset(&This->lockedRect, 0, sizeof(RECT));
return WINED3D_OK;
}
/*****************************************************************************
* IWineD3DSurface::Flip, GDI version
*
* Flips 2 flipping enabled surfaces. Determining the 2 targets is done by
* the parent library. This implementation changes the data pointers of the
* surfaces and copies the new front buffer content to the screen
*
* Params:
* override: Flipping target(e.g. back buffer)
*
* Returns:
* WINED3D_OK on success
*
*****************************************************************************/
static HRESULT WINAPI
IWineGDISurfaceImpl_Flip(IWineD3DSurface *iface,
IWineD3DSurface *override,
DWORD Flags)
{
IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)iface;
IWineD3DSwapChainImpl *swapchain;
HRESULT hr;
if (surface->container.type != WINED3D_CONTAINER_SWAPCHAIN)
{
ERR("Flipped surface is not on a swapchain\n");
return WINEDDERR_NOTFLIPPABLE;
}
swapchain = surface->container.u.swapchain;
hr = IWineD3DSwapChain_Present((IWineD3DSwapChain *)swapchain,
NULL, NULL, swapchain->win_handle, NULL, 0);
return hr;
}
/*****************************************************************************
* IWineD3DSurface::LoadTexture, GDI version
*
* This is mutually unsupported by GDI surfaces
*
* Returns:
* D3DERR_INVALIDCALL
*
*****************************************************************************/
static HRESULT WINAPI
IWineGDISurfaceImpl_LoadTexture(IWineD3DSurface *iface, BOOL srgb_mode)
{
ERR("Unsupported on X11 surfaces\n");
return WINED3DERR_INVALIDCALL;
}
static void WINAPI IWineGDISurfaceImpl_BindTexture(IWineD3DSurface *iface, BOOL srgb)
{
ERR("Not supported.\n");
}
static HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
WINED3DLOCKED_RECT lock;
HRESULT hr;
RGBQUAD col[256];
TRACE("(%p)->(%p)\n",This,pHDC);
if(!(This->Flags & SFLAG_DIBSECTION))
{
WARN("DC not supported on this surface\n");
return WINED3DERR_INVALIDCALL;
}
if(This->Flags & SFLAG_USERPTR) {
ERR("Not supported on surfaces with an application-provided surfaces\n");
return WINEDDERR_NODC;
}
/* Give more detailed info for ddraw */
if (This->Flags & SFLAG_DCINUSE)
return WINEDDERR_DCALREADYCREATED;
/* Can't GetDC if the surface is locked */
if (This->Flags & SFLAG_LOCKED)
return WINED3DERR_INVALIDCALL;
memset(&lock, 0, sizeof(lock)); /* To be sure */
/* Should have a DIB section already */
/* Lock the surface */
hr = IWineD3DSurface_LockRect(iface,
&lock,
NULL,
0);
if(FAILED(hr)) {
ERR("IWineD3DSurface_LockRect failed with hr = %08x\n", hr);
/* keep the dib section */
return hr;
}
if (This->resource.format->id == WINED3DFMT_P8_UINT
|| This->resource.format->id == WINED3DFMT_P8_UINT_A8_UNORM)
{
unsigned int n;
const PALETTEENTRY *pal = NULL;
if(This->palette) {
pal = This->palette->palents;
} else {
IWineD3DSurfaceImpl *dds_primary;
IWineD3DSwapChainImpl *swapchain;
swapchain = (IWineD3DSwapChainImpl *)This->resource.device->swapchains[0];
dds_primary = swapchain->front_buffer;
if (dds_primary && dds_primary->palette)
pal = dds_primary->palette->palents;
}
if (pal) {
for (n=0; n<256; n++) {
col[n].rgbRed = pal[n].peRed;
col[n].rgbGreen = pal[n].peGreen;
col[n].rgbBlue = pal[n].peBlue;
col[n].rgbReserved = 0;
}
SetDIBColorTable(This->hDC, 0, 256, col);
}
}
*pHDC = This->hDC;
TRACE("returning %p\n",*pHDC);
This->Flags |= SFLAG_DCINUSE;
return WINED3D_OK;
}
static HRESULT WINAPI IWineGDISurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("(%p)->(%p)\n",This,hDC);
if (!(This->Flags & SFLAG_DCINUSE))
return WINEDDERR_NODC;
if (This->hDC !=hDC) {
WARN("Application tries to release an invalid DC(%p), surface dc is %p\n", hDC, This->hDC);
return WINEDDERR_NODC;
}
/* we locked first, so unlock now */
IWineD3DSurface_UnlockRect(iface);
This->Flags &= ~SFLAG_DCINUSE;
return WINED3D_OK;
}
static HRESULT WINAPI IWineGDISurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
RGBQUAD col[256];
IWineD3DPaletteImpl *pal = This->palette;
unsigned int n;
TRACE("(%p)\n", This);
if (!pal) return WINED3D_OK;
if(This->Flags & SFLAG_DIBSECTION) {
TRACE("(%p): Updating the hdc's palette\n", This);
for (n=0; n<256; n++) {
col[n].rgbRed = pal->palents[n].peRed;
col[n].rgbGreen = pal->palents[n].peGreen;
col[n].rgbBlue = pal->palents[n].peBlue;
col[n].rgbReserved = 0;
}
SetDIBColorTable(This->hDC, 0, 256, col);
}
/* Update the image because of the palette change. Some games like e.g Red Alert
call SetEntries a lot to implement fading. */
/* Tell the swapchain to update the screen */
if (This->container.type == WINED3D_CONTAINER_SWAPCHAIN)
{
IWineD3DSwapChainImpl *swapchain = This->container.u.swapchain;
if (This == swapchain->front_buffer)
{
x11_copy_to_screen(swapchain, NULL);
}
}
return WINED3D_OK;
}
/*****************************************************************************
* IWineD3DSurface::PrivateSetup, GDI version
*
* Initializes the GDI surface, aka creates the DIB section we render to
* The DIB section creation is done by calling GetDC, which will create the
* section and releasing the dc to allow the app to use it. The dib section
* will stay until the surface is released
*
* GDI surfaces do not need to be a power of 2 in size, so the pow2 sizes
* are set to the real sizes to save memory. The NONPOW2 flag is unset to
* avoid confusion in the shared surface code.
*
* Returns:
* WINED3D_OK on success
* The return values of called methods on failure
*
*****************************************************************************/
static HRESULT WINAPI
IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
HRESULT hr;
if(This->resource.usage & WINED3DUSAGE_OVERLAY)
{
ERR("(%p) Overlays not yet supported by GDI surfaces\n", This);
return WINED3DERR_INVALIDCALL;
}
/* Sysmem textures have memory already allocated -
* release it, this avoids an unnecessary memcpy
*/
hr = IWineD3DBaseSurfaceImpl_CreateDIBSection(iface);
if(SUCCEEDED(hr))
{
HeapFree(GetProcessHeap(), 0, This->resource.heapMemory);
This->resource.heapMemory = NULL;
This->resource.allocatedMemory = This->dib.bitmap_data;
}
/* We don't mind the nonpow2 stuff in GDI */
This->pow2Width = This->currentDesc.Width;
This->pow2Height = This->currentDesc.Height;
return WINED3D_OK;
}
static HRESULT WINAPI IWineGDISurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
/* Render targets depend on their hdc, and we can't create an hdc on a user pointer */
if(This->resource.usage & WINED3DUSAGE_RENDERTARGET) {
ERR("Not supported on render targets\n");
return WINED3DERR_INVALIDCALL;
}
if(This->Flags & (SFLAG_LOCKED | SFLAG_DCINUSE)) {
WARN("Surface is locked or the HDC is in use\n");
return WINED3DERR_INVALIDCALL;
}
if(Mem && Mem != This->resource.allocatedMemory) {
void *release = NULL;
/* Do I have to copy the old surface content? */
if(This->Flags & SFLAG_DIBSECTION) {
/* Release the DC. No need to hold the critical section for the update
* Thread because this thread runs only on front buffers, but this method
* fails for render targets in the check above.
*/
SelectObject(This->hDC, This->dib.holdbitmap);
DeleteDC(This->hDC);
/* Release the DIB section */
DeleteObject(This->dib.DIBsection);
This->dib.bitmap_data = NULL;
This->resource.allocatedMemory = NULL;
This->hDC = NULL;
This->Flags &= ~SFLAG_DIBSECTION;
} else if(!(This->Flags & SFLAG_USERPTR)) {
release = This->resource.allocatedMemory;
}
This->resource.allocatedMemory = Mem;
This->Flags |= SFLAG_USERPTR | SFLAG_INSYSMEM;
/* Now free the old memory if any */
HeapFree(GetProcessHeap(), 0, release);
} else if(This->Flags & SFLAG_USERPTR) {
/* LockRect and GetDC will re-create the dib section and allocated memory */
This->resource.allocatedMemory = NULL;
This->Flags &= ~SFLAG_USERPTR;
}
return WINED3D_OK;
}
static WINED3DSURFTYPE WINAPI IWineGDISurfaceImpl_GetImplType(IWineD3DSurface *iface) {
return SURFACE_GDI;
}
static HRESULT WINAPI IWineGDISurfaceImpl_DrawOverlay(IWineD3DSurface *iface) {
FIXME("GDI surfaces can't draw overlays yet\n");
return E_FAIL;
}
/* FIXME: This vtable should not use any IWineD3DSurface* implementation functions,
* only IWineD3DBaseSurface and IWineGDISurface ones.
*/
const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl =
{
/* IUnknown */
IWineD3DBaseSurfaceImpl_QueryInterface,
IWineD3DBaseSurfaceImpl_AddRef,
IWineGDISurfaceImpl_Release,
/* IWineD3DResource */
IWineD3DBaseSurfaceImpl_GetParent,
IWineD3DBaseSurfaceImpl_SetPrivateData,
IWineD3DBaseSurfaceImpl_GetPrivateData,
IWineD3DBaseSurfaceImpl_FreePrivateData,
IWineD3DBaseSurfaceImpl_SetPriority,
IWineD3DBaseSurfaceImpl_GetPriority,
IWineGDISurfaceImpl_PreLoad,
IWineGDISurfaceImpl_UnLoad,
IWineD3DBaseSurfaceImpl_GetType,
/* IWineD3DSurface */
IWineD3DBaseSurfaceImpl_GetDesc,
IWineGDISurfaceImpl_LockRect,
IWineGDISurfaceImpl_UnlockRect,
IWineGDISurfaceImpl_GetDC,
IWineGDISurfaceImpl_ReleaseDC,
IWineGDISurfaceImpl_Flip,
IWineD3DBaseSurfaceImpl_Blt,
IWineD3DBaseSurfaceImpl_GetBltStatus,
IWineD3DBaseSurfaceImpl_GetFlipStatus,
IWineD3DBaseSurfaceImpl_IsLost,
IWineD3DBaseSurfaceImpl_Restore,
IWineD3DBaseSurfaceImpl_BltFast,
IWineD3DBaseSurfaceImpl_GetPalette,
IWineD3DBaseSurfaceImpl_SetPalette,
IWineGDISurfaceImpl_RealizePalette,
IWineD3DBaseSurfaceImpl_SetColorKey,
IWineD3DBaseSurfaceImpl_GetPitch,
IWineGDISurfaceImpl_SetMem,
IWineD3DBaseSurfaceImpl_SetOverlayPosition,
IWineD3DBaseSurfaceImpl_GetOverlayPosition,
IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder,
IWineD3DBaseSurfaceImpl_UpdateOverlay,
IWineD3DBaseSurfaceImpl_SetClipper,
IWineD3DBaseSurfaceImpl_GetClipper,
/* Internal use: */
IWineGDISurfaceImpl_LoadTexture,
IWineGDISurfaceImpl_BindTexture,
IWineD3DBaseSurfaceImpl_GetData,
IWineD3DBaseSurfaceImpl_SetFormat,
IWineGDISurfaceImpl_PrivateSetup,
IWineGDISurfaceImpl_GetImplType,
IWineGDISurfaceImpl_DrawOverlay
};

File diff suppressed because it is too large Load diff

View file

@ -1,194 +0,0 @@
/*
*IDirect3DSwapChain9 implementation
*
*Copyright 2002-2003 Jason Edmeades
*Copyright 2002-2003 Raphael Junqueira
*Copyright 2005 Oliver Stieber
*Copyright 2007-2008 Stefan Dösinger for CodeWeavers
*
*This library is free software; you can redistribute it and/or
*modify it under the terms of the GNU Lesser General Public
*License as published by the Free Software Foundation; either
*version 2.1 of the License, or (at your option) any later version.
*
*This library is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
*Lesser General Public License for more details.
*
*You should have received a copy of the GNU Lesser General Public
*License along with this library; if not, write to the Free Software
*Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
/* IDirect3DSwapChain IUnknown parts follow: */
HRESULT WINAPI IWineD3DBaseSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface, REFIID riid, void **object)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
if (IsEqualGUID(riid, &IID_IWineD3DSwapChain)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| IsEqualGUID(riid, &IID_IUnknown))
{
IUnknown_AddRef(iface);
*object = iface;
return S_OK;
}
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
*object = NULL;
return E_NOINTERFACE;
}
ULONG WINAPI IWineD3DBaseSwapChainImpl_AddRef(IWineD3DSwapChain *iface) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
DWORD refCount = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef increasing from %d\n", This, refCount - 1);
return refCount;
}
/* Do not call while under the GL lock. */
ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface)
{
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
DWORD refCount;
refCount = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %d\n", This, refCount);
if (!refCount) IWineD3DSwapChain_Destroy(iface);
return refCount;
}
void * WINAPI IWineD3DBaseSwapChainImpl_GetParent(IWineD3DSwapChain *iface)
{
TRACE("iface %p.\n", iface);
return ((IWineD3DSwapChainImpl *)iface)->parent;
}
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface, IWineD3DSurface *dst_surface)
{
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
POINT start;
TRACE("iface %p, dst_surface %p.\n", iface, dst_surface);
start.x = 0;
start.y = 0;
if (This->presentParms.Windowed) {
MapWindowPoints(This->win_handle, NULL, &start, 1);
}
IWineD3DSurface_BltFast(dst_surface, start.x, start.y, (IWineD3DSurface *)This->front_buffer, NULL, 0);
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface,
UINT back_buffer_idx, WINED3DBACKBUFFER_TYPE type, IWineD3DSurface **back_buffer)
{
IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)iface;
TRACE("iface %p, back_buffer_idx %u, type %#x, back_buffer %p.\n",
iface, back_buffer_idx, type, back_buffer);
/* Return invalid if there is no backbuffer array, otherwise it will
* crash when ddraw is used (there swapchain->back_buffers is always NULL).
* We need this because this function is called from
* IWineD3DStateBlockImpl_InitStartupStateBlock() to get the default
* scissorrect dimensions. */
if (!swapchain->back_buffers || back_buffer_idx >= swapchain->presentParms.BackBufferCount)
{
WARN("Invalid back buffer index.\n");
/* Native d3d9 doesn't set NULL here, just as wine's d3d9. But set it
* here in wined3d to avoid problems in other libs. */
*back_buffer = NULL;
return WINED3DERR_INVALIDCALL;
}
*back_buffer = (IWineD3DSurface *)swapchain->back_buffers[back_buffer_idx];
if (*back_buffer) IWineD3DSurface_AddRef(*back_buffer);
TRACE("Returning back buffer %p.\n", *back_buffer);
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface, WINED3DRASTER_STATUS *pRasterStatus) {
static BOOL warned;
/* No OpenGL equivalent */
if (!warned)
{
FIXME("iface %p, raster_status %p stub!\n", iface, pRasterStatus);
warned = TRUE;
}
/* Obtaining the raster status is a widely implemented but optional feature.
* When this method returns OK then the application Starcraft 2 expects that
* the pRasterStatus->InVBlank value differs over time. To prevent Starcraft 2
* from running in an infinite loop at startup this method returns INVALIDCALL.
*/
return WINED3DERR_INVALIDCALL;
}
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, WINED3DDISPLAYMODE*pMode) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
HRESULT hr;
TRACE("(%p)->(%p): Calling GetAdapterDisplayMode\n", This, pMode);
hr = IWineD3D_GetAdapterDisplayMode(This->device->wined3d, This->device->adapter->ordinal, pMode);
TRACE("(%p) : returning w(%d) h(%d) rr(%d) fmt(%u,%s)\n", This, pMode->Width, pMode->Height, pMode->RefreshRate,
pMode->Format, debug_d3dformat(pMode->Format));
return hr;
}
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDevice(IWineD3DSwapChain *iface, IWineD3DDevice **device)
{
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
*device = (IWineD3DDevice *)This->device;
IWineD3DDevice_AddRef(*device);
TRACE("(%p) : returning %p\n", This, *device);
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface, WINED3DPRESENT_PARAMETERS *pPresentationParameters) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
TRACE("(%p)\n", This);
*pPresentationParameters = This->presentParms;
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DBaseSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface, DWORD Flags, CONST WINED3DGAMMARAMP *pRamp){
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
HDC hDC;
TRACE("(%p) : pRamp@%p flags(%d)\n", This, pRamp, Flags);
hDC = GetDC(This->device_window);
SetDeviceGammaRamp(hDC, (LPVOID)pRamp);
ReleaseDC(This->device_window, hDC);
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface, WINED3DGAMMARAMP *pRamp){
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
HDC hDC;
TRACE("(%p) : pRamp@%p\n", This, pRamp);
hDC = GetDC(This->device_window);
GetDeviceGammaRamp(hDC, pRamp);
ReleaseDC(This->device_window, hDC);
return WINED3D_OK;
}

View file

@ -1,270 +0,0 @@
/*
*IDirect3DSwapChain9 implementation
*
*Copyright 2002-2003 Jason Edmeades
*Copyright 2002-2003 Raphael Junqueira
*Copyright 2005 Oliver Stieber
*Copyright 2007-2008 Stefan Dösinger for CodeWeavers
*
*This library is free software; you can redistribute it and/or
*modify it under the terms of the GNU Lesser General Public
*License as published by the Free Software Foundation; either
*version 2.1 of the License, or (at your option) any later version.
*
*This library is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
*Lesser General Public License for more details.
*
*You should have received a copy of the GNU Lesser General Public
*License along with this library; if not, write to the Free Software
*Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DECLARE_DEBUG_CHANNEL(fps);
static void WINAPI IWineGDISwapChainImpl_Destroy(IWineD3DSwapChain *iface)
{
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
WINED3DDISPLAYMODE mode;
TRACE("Destroying swapchain %p\n", iface);
IWineD3DSwapChain_SetGammaRamp(iface, 0, &This->orig_gamma);
/* release the ref to the front and back buffer parents */
if (This->front_buffer)
{
surface_set_container(This->front_buffer, WINED3D_CONTAINER_NONE, NULL);
if (IWineD3DSurface_Release((IWineD3DSurface *)This->front_buffer) > 0)
{
WARN("(%p) Something's still holding the front buffer\n",This);
}
}
if (This->back_buffers)
{
UINT i;
for (i = 0; i < This->presentParms.BackBufferCount; ++i)
{
surface_set_container(This->back_buffers[i], WINED3D_CONTAINER_NONE, NULL);
if (IWineD3DSurface_Release((IWineD3DSurface *)This->back_buffers[i]))
{
WARN("(%p) Something's still holding the back buffer\n",This);
}
}
HeapFree(GetProcessHeap(), 0, This->back_buffers);
}
/* Restore the screen resolution if we rendered in fullscreen
* This will restore the screen resolution to what it was before creating the swapchain. In case of d3d8 and d3d9
* this will be the original desktop resolution. In case of d3d7 this will be a NOP because ddraw sets the resolution
* before starting up Direct3D, thus orig_width and orig_height will be equal to the modes in the presentation params
*/
if (!This->presentParms.Windowed && This->presentParms.AutoRestoreDisplayMode)
{
mode.Width = This->orig_width;
mode.Height = This->orig_height;
mode.RefreshRate = 0;
mode.Format = This->orig_fmt;
IWineD3DDevice_SetDisplayMode((IWineD3DDevice *)This->device, 0, &mode);
}
HeapFree(GetProcessHeap(), 0, This->context);
HeapFree(GetProcessHeap(), 0, This);
}
/*****************************************************************************
* x11_copy_to_screen
*
* Helper function that blts the front buffer contents to the target window
*
* Params:
* This: Surface to copy from
* rc: Rectangle to copy
*
*****************************************************************************/
void x11_copy_to_screen(IWineD3DSwapChainImpl *This, const RECT *rc)
{
IWineD3DSurfaceImpl *front = This->front_buffer;
if(front->resource.usage & WINED3DUSAGE_RENDERTARGET) {
POINT offset = {0,0};
HWND hDisplayWnd;
HDC hDisplayDC;
HDC hSurfaceDC = 0;
RECT drawrect;
TRACE("(%p)->(%p): Copying to screen\n", front, rc);
hSurfaceDC = front->hDC;
hDisplayWnd = This->win_handle;
hDisplayDC = GetDCEx(hDisplayWnd, 0, DCX_CLIPSIBLINGS|DCX_CACHE);
if(rc) {
TRACE(" copying rect (%d,%d)->(%d,%d), offset (%d,%d)\n",
rc->left, rc->top, rc->right, rc->bottom, offset.x, offset.y);
}
/* Front buffer coordinates are screen coordinates. Map them to the destination
* window if not fullscreened
*/
if(This->presentParms.Windowed) {
ClientToScreen(hDisplayWnd, &offset);
}
#if 0
/* FIXME: This doesn't work... if users really want to run
* X in 8bpp, then we need to call directly into display.drv
* (or Wine's equivalent), and force a private colormap
* without default entries. */
if (front->palette) {
SelectPalette(hDisplayDC, front->palette->hpal, FALSE);
RealizePalette(hDisplayDC); /* sends messages => deadlocks */
}
#endif
drawrect.left = 0;
drawrect.right = front->currentDesc.Width;
drawrect.top = 0;
drawrect.bottom = front->currentDesc.Height;
#if 0
/* TODO: Support clippers */
if (front->clipper)
{
RECT xrc;
HWND hwnd = ((IWineD3DClipperImpl *) front->clipper)->hWnd;
if (hwnd && GetClientRect(hwnd,&xrc))
{
OffsetRect(&xrc,offset.x,offset.y);
IntersectRect(&drawrect,&drawrect,&xrc);
}
}
#endif
if (rc) {
IntersectRect(&drawrect,&drawrect,rc);
}
else {
/* Only use this if the caller did not pass a rectangle, since
* due to double locking this could be the wrong one ...
*/
if (front->lockedRect.left != front->lockedRect.right) {
IntersectRect(&drawrect,&drawrect,&front->lockedRect);
}
}
BitBlt(hDisplayDC,
drawrect.left-offset.x, drawrect.top-offset.y,
drawrect.right-drawrect.left, drawrect.bottom-drawrect.top,
hSurfaceDC,
drawrect.left, drawrect.top,
SRCCOPY);
ReleaseDC(hDisplayWnd, hDisplayDC);
}
}
static HRESULT WINAPI IWineGDISwapChainImpl_SetDestWindowOverride(IWineD3DSwapChain *iface, HWND window) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
This->win_handle = window;
return WINED3D_OK;
}
static HRESULT WINAPI IWineGDISwapChainImpl_Present(IWineD3DSwapChain *iface, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion, DWORD dwFlags) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *) iface;
IWineD3DSurfaceImpl *front, *back;
if (!This->back_buffers)
{
WARN("Swapchain doesn't have a backbuffer, returning WINED3DERR_INVALIDCALL\n");
return WINED3DERR_INVALIDCALL;
}
front = This->front_buffer;
back = This->back_buffers[0];
/* Flip the DC */
{
HDC tmp;
tmp = front->hDC;
front->hDC = back->hDC;
back->hDC = tmp;
}
/* Flip the DIBsection */
{
HBITMAP tmp;
tmp = front->dib.DIBsection;
front->dib.DIBsection = back->dib.DIBsection;
back->dib.DIBsection = tmp;
}
/* Flip the surface data */
{
void* tmp;
tmp = front->dib.bitmap_data;
front->dib.bitmap_data = back->dib.bitmap_data;
back->dib.bitmap_data = tmp;
tmp = front->resource.allocatedMemory;
front->resource.allocatedMemory = back->resource.allocatedMemory;
back->resource.allocatedMemory = tmp;
if(front->resource.heapMemory) {
ERR("GDI Surface %p has heap memory allocated\n", front);
}
if(back->resource.heapMemory) {
ERR("GDI Surface %p has heap memory allocated\n", back);
}
}
/* client_memory should not be different, but just in case */
{
BOOL tmp;
tmp = front->dib.client_memory;
front->dib.client_memory = back->dib.client_memory;
back->dib.client_memory = tmp;
}
/* FPS support */
if (TRACE_ON(fps))
{
static LONG prev_time, frames;
DWORD time = GetTickCount();
frames++;
/* every 1.5 seconds */
if (time - prev_time > 1500) {
TRACE_(fps)("@ approx %.2ffps\n", 1000.0*frames/(time - prev_time));
prev_time = time;
frames = 0;
}
}
x11_copy_to_screen(This, NULL);
return WINED3D_OK;
}
const IWineD3DSwapChainVtbl IWineGDISwapChain_Vtbl =
{
/* IUnknown */
IWineD3DBaseSwapChainImpl_QueryInterface,
IWineD3DBaseSwapChainImpl_AddRef,
IWineD3DBaseSwapChainImpl_Release,
/* IWineD3DSwapChain */
IWineD3DBaseSwapChainImpl_GetParent,
IWineGDISwapChainImpl_Destroy,
IWineD3DBaseSwapChainImpl_GetDevice,
IWineGDISwapChainImpl_Present,
IWineGDISwapChainImpl_SetDestWindowOverride,
IWineD3DBaseSwapChainImpl_GetFrontBufferData,
IWineD3DBaseSwapChainImpl_GetBackBuffer,
IWineD3DBaseSwapChainImpl_GetRasterStatus,
IWineD3DBaseSwapChainImpl_GetDisplayMode,
IWineD3DBaseSwapChainImpl_GetPresentParameters,
IWineD3DBaseSwapChainImpl_SetGammaRamp,
IWineD3DBaseSwapChainImpl_GetGammaRamp
};

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,7 @@
* Copyright 2005 Oliver Stieber
* Copyright 2006-2008 Henri Verbeet
* Copyright 2007-2008 Stefan Dösinger for CodeWeavers
* Copyright 2009 Henri Verbeet for CodeWeavers
* Copyright 2009-2010 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -34,7 +34,7 @@ struct StaticPixelFormatDesc
enum wined3d_format_id id;
DWORD alphaMask, redMask, greenMask, blueMask;
UINT bpp;
short depthSize, stencilSize;
BYTE depthSize, stencilSize;
};
/*****************************************************************************
@ -130,8 +130,10 @@ static const struct StaticPixelFormatDesc formats[] =
/* Vendor-specific formats */
{WINED3DFMT_ATI2N, 0x0, 0x0, 0x0, 0x0, 1, 0, 0},
{WINED3DFMT_NVDB, 0x0, 0x0, 0x0, 0x0, 0, 0, 0},
{WINED3DFMT_INTZ, 0x0, 0x0, 0x0, 0x0, 4, 24, 8},
{WINED3DFMT_NVHU, 0x0, 0x0, 0x0, 0x0, 2, 0, 0},
{WINED3DFMT_NVHS, 0x0, 0x0, 0x0, 0x0, 2, 0, 0},
{WINED3DFMT_NULL, 0xff000000, 0x000000ff, 0x0000ff00, 0x00ff0000, 4, 0, 0},
};
struct wined3d_format_base_flags
@ -156,6 +158,8 @@ static const struct wined3d_format_base_flags format_base_flags[] =
{WINED3DFMT_MULTI2_ARGB8, WINED3DFMT_FLAG_FOURCC},
{WINED3DFMT_G8R8_G8B8, WINED3DFMT_FLAG_FOURCC},
{WINED3DFMT_R8G8_B8G8, WINED3DFMT_FLAG_FOURCC},
{WINED3DFMT_INTZ, WINED3DFMT_FLAG_FOURCC},
{WINED3DFMT_NULL, WINED3DFMT_FLAG_FOURCC},
{WINED3DFMT_P8_UINT, WINED3DFMT_FLAG_GETDC},
{WINED3DFMT_B8G8R8_UNORM, WINED3DFMT_FLAG_GETDC},
{WINED3DFMT_B8G8R8A8_UNORM, WINED3DFMT_FLAG_GETDC},
@ -342,10 +346,10 @@ static void convert_r8g8_snorm(const BYTE *src, BYTE *dst, UINT pitch, UINT widt
Dest = dst + y * outpitch;
for (x = 0; x < width; x++ )
{
LONG color = (*Source++);
const short color = (*Source++);
/* B */ Dest[0] = 0xff;
/* G */ Dest[1] = (color >> 8) + 128; /* V */
/* R */ Dest[2] = (color) + 128; /* U */
/* R */ Dest[2] = (color & 0xff) + 128; /* U */
Dest += 3;
}
}
@ -436,10 +440,10 @@ static void convert_r16g16_snorm(const BYTE *src, BYTE *dst, UINT pitch, UINT wi
Dest = (unsigned short *) (dst + y * outpitch);
for (x = 0; x < width; x++ )
{
DWORD color = (*Source++);
const DWORD color = (*Source++);
/* B */ Dest[0] = 0xffff;
/* G */ Dest[1] = (color >> 16) + 32768; /* V */
/* R */ Dest[2] = (color ) + 32768; /* U */
/* R */ Dest[2] = (color & 0xffff) + 32768; /* U */
Dest += 3;
}
}
@ -856,6 +860,20 @@ static const struct wined3d_format_texture_info format_texture_info[] =
GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 0,
WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
ARB_TEXTURE_COMPRESSION_RGTC, NULL},
{WINED3DFMT_INTZ, GL_DEPTH24_STENCIL8_EXT, GL_DEPTH24_STENCIL8_EXT, 0,
GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, 0,
WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL,
EXT_PACKED_DEPTH_STENCIL, NULL},
{WINED3DFMT_INTZ, GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, 0,
GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 0,
WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL,
ARB_FRAMEBUFFER_OBJECT, NULL},
{WINED3DFMT_NULL, GL_RGBA8, GL_RGBA8, 0,
GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 0,
WINED3DFMT_FLAG_RENDERTARGET,
ARB_FRAMEBUFFER_OBJECT, NULL},
};
static inline int getFmtIdx(enum wined3d_format_id format_id)
@ -916,7 +934,7 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
return FALSE;
}
gl_info->formats[fmt_idx].Flags |= format_base_flags[i].flags;
gl_info->formats[fmt_idx].flags |= format_base_flags[i].flags;
}
return TRUE;
@ -942,7 +960,7 @@ static BOOL init_format_compression_info(struct wined3d_gl_info *gl_info)
format->block_width = format_compression_info[i].block_width;
format->block_height = format_compression_info[i].block_height;
format->block_byte_count = format_compression_info[i].block_byte_count;
format->Flags |= WINED3DFMT_FLAG_COMPRESSED;
format->flags |= WINED3DFMT_FLAG_COMPRESSED;
}
return TRUE;
@ -978,18 +996,18 @@ static void check_fbo_compat(const struct wined3d_gl_info *gl_info, struct wined
if (status == GL_FRAMEBUFFER_COMPLETE)
{
TRACE("Format %s is supported as FBO color attachment.\n", debug_d3dformat(format->id));
format->Flags |= WINED3DFMT_FLAG_FBO_ATTACHABLE;
format->flags |= WINED3DFMT_FLAG_FBO_ATTACHABLE;
format->rtInternal = format->glInternal;
}
else
{
if (!format->rtInternal)
{
if (format->Flags & WINED3DFMT_FLAG_RENDERTARGET)
if (format->flags & WINED3DFMT_FLAG_RENDERTARGET)
{
FIXME("Format %s with rendertarget flag is not supported as FBO color attachment,"
" and no fallback specified.\n", debug_d3dformat(format->id));
format->Flags &= ~WINED3DFMT_FLAG_RENDERTARGET;
format->flags &= ~WINED3DFMT_FLAG_RENDERTARGET;
}
else
{
@ -1024,12 +1042,12 @@ static void check_fbo_compat(const struct wined3d_gl_info *gl_info, struct wined
{
FIXME("Format %s rtInternal format is not supported as FBO color attachment.\n",
debug_d3dformat(format->id));
format->Flags &= ~WINED3DFMT_FLAG_RENDERTARGET;
format->flags &= ~WINED3DFMT_FLAG_RENDERTARGET;
}
}
}
if (status == GL_FRAMEBUFFER_COMPLETE && format->Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING)
if (status == GL_FRAMEBUFFER_COMPLETE && format->flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING)
{
GLuint rb;
@ -1050,7 +1068,7 @@ static void check_fbo_compat(const struct wined3d_gl_info *gl_info, struct wined
{
while(glGetError());
TRACE("Format doesn't support post-pixelshader blending.\n");
format->Flags &= ~WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
format->flags &= ~WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
}
if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT]
@ -1074,7 +1092,7 @@ static void check_fbo_compat(const struct wined3d_gl_info *gl_info, struct wined
if (status == GL_FRAMEBUFFER_COMPLETE)
{
TRACE("Format %s's sRGB format is FBO attachable.\n", debug_d3dformat(format->id));
format->Flags |= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB;
format->flags |= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB;
}
else
{
@ -1109,14 +1127,14 @@ static void init_format_fbo_compat_info(struct wined3d_gl_info *gl_info)
if (!format->glInternal) continue;
if (format->Flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
if (format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
{
TRACE("Skipping format %s because it's a depth/stencil format.\n",
debug_d3dformat(format->id));
continue;
}
if (format->Flags & WINED3DFMT_FLAG_COMPRESSED)
if (format->flags & WINED3DFMT_FLAG_COMPRESSED)
{
TRACE("Skipping format %s because it's a compressed format.\n",
debug_d3dformat(format->id));
@ -1163,15 +1181,36 @@ static BOOL init_format_texture_info(struct wined3d_gl_info *gl_info)
if (!gl_info->supported[format_texture_info[i].extension]) continue;
format = &gl_info->formats[fmt_idx];
/* ARB_texture_rg defines floating point formats, but only if
* ARB_texture_float is also supported. */
if (!gl_info->supported[ARB_TEXTURE_FLOAT]
&& (format->flags & WINED3DFMT_FLAG_FLOAT))
continue;
format->glInternal = format_texture_info[i].gl_internal;
format->glGammaInternal = format_texture_info[i].gl_srgb_internal;
format->rtInternal = format_texture_info[i].gl_rt_internal;
format->glFormat = format_texture_info[i].gl_format;
format->glType = format_texture_info[i].gl_type;
format->color_fixup = COLOR_FIXUP_IDENTITY;
format->Flags |= format_texture_info[i].flags;
format->flags |= format_texture_info[i].flags;
format->heightscale = 1.0f;
if (format->glGammaInternal != format->glInternal)
{
/* Filter sRGB capabilities if EXT_texture_sRGB is not supported. */
if (!gl_info->supported[EXT_TEXTURE_SRGB])
{
format->glGammaInternal = format->glInternal;
format->flags &= ~(WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE);
}
else if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
{
format->glInternal = format->glGammaInternal;
}
}
/* Texture conversion stuff */
format->convert = format_texture_info[i].convert;
format->conv_byte_count = format_texture_info[i].conv_byte_count;
@ -1326,7 +1365,7 @@ static void init_format_filter_info(struct wined3d_gl_info *gl_info, enum wined3
for(i = 0; i < (sizeof(fmts16) / sizeof(*fmts16)); i++)
{
fmt_idx = getFmtIdx(fmts16[i]);
gl_info->formats[fmt_idx].Flags |= WINED3DFMT_FLAG_FILTERING;
gl_info->formats[fmt_idx].flags |= WINED3DFMT_FLAG_FILTERING;
}
}
return;
@ -1342,7 +1381,7 @@ static void init_format_filter_info(struct wined3d_gl_info *gl_info, enum wined3
if(filtered)
{
TRACE("Format %s supports filtering\n", debug_d3dformat(fmts16[i]));
format->Flags |= WINED3DFMT_FLAG_FILTERING;
format->flags |= WINED3DFMT_FLAG_FILTERING;
}
else
{
@ -1565,7 +1604,7 @@ UINT wined3d_format_calculate_size(const struct wined3d_format *format, UINT ali
{
size = 0;
}
else if (format->Flags & WINED3DFMT_FLAG_COMPRESSED)
else if (format->flags & WINED3DFMT_FLAG_COMPRESSED)
{
UINT row_block_count = (width + format->block_width - 1) / format->block_width;
UINT row_count = (height + format->block_height - 1) / format->block_height;
@ -1576,7 +1615,11 @@ UINT wined3d_format_calculate_size(const struct wined3d_format *format, UINT ali
size = height * (((width * format->byte_count) + alignment - 1) & ~(alignment - 1));
}
if (format->heightscale != 0.0f) size *= format->heightscale;
if (format->heightscale != 0.0f)
{
/* The D3D format requirements make sure that the resulting format is an integer again */
size = (UINT) (size * format->heightscale);
}
return size;
}
@ -1720,6 +1763,8 @@ const char *debug_d3dformat(enum wined3d_format_id format_id)
FMT_TO_STR(WINED3DFMT_B5G5R5A1_UNORM);
FMT_TO_STR(WINED3DFMT_B8G8R8A8_UNORM);
FMT_TO_STR(WINED3DFMT_B8G8R8X8_UNORM);
FMT_TO_STR(WINED3DFMT_INTZ);
FMT_TO_STR(WINED3DFMT_NULL);
#undef FMT_TO_STR
default:
{
@ -1921,7 +1966,6 @@ const char *debug_d3drenderstate(WINED3DRENDERSTATETYPE state)
D3DSTATE_TO_STR(WINED3DRS_EDGEANTIALIAS);
D3DSTATE_TO_STR(WINED3DRS_COLORKEYENABLE);
D3DSTATE_TO_STR(WINED3DRS_MIPMAPLODBIAS);
D3DSTATE_TO_STR(WINED3DRS_ZBIAS);
D3DSTATE_TO_STR(WINED3DRS_RANGEFOGENABLE);
D3DSTATE_TO_STR(WINED3DRS_ANISOTROPY);
D3DSTATE_TO_STR(WINED3DRS_FLUSHBATCH);
@ -2193,6 +2237,8 @@ const char *debug_d3dstate(DWORD state)
return "STATE_MATERIAL";
if (STATE_IS_FRONTFACE(state))
return "STATE_FRONTFACE";
if (STATE_IS_POINTSPRITECOORDORIGIN(state))
return "STATE_POINTSPRITECOORDORIGIN";
return wine_dbg_sprintf("UNKNOWN_STATE(%#x)", state);
}
@ -2493,17 +2539,18 @@ unsigned int count_bits(unsigned int mask)
/* Helper function for retrieving color info for ChoosePixelFormat and wglChoosePixelFormatARB.
* The later function requires individual color components. */
BOOL getColorBits(const struct wined3d_format *format,
short *redSize, short *greenSize, short *blueSize, short *alphaSize, short *totalSize)
BYTE *redSize, BYTE *greenSize, BYTE *blueSize, BYTE *alphaSize, BYTE *totalSize)
{
TRACE("format %s.\n", debug_d3dformat(format->id));
switch (format->id)
{
case WINED3DFMT_B10G10R10A2_UNORM:
case WINED3DFMT_R10G10B10A2_UNORM:
case WINED3DFMT_B8G8R8X8_UNORM:
case WINED3DFMT_B8G8R8_UNORM:
case WINED3DFMT_B8G8R8A8_UNORM:
case WINED3DFMT_R8G8B8A8_UNORM:
case WINED3DFMT_B10G10R10A2_UNORM:
case WINED3DFMT_B5G5R5X1_UNORM:
case WINED3DFMT_B5G5R5A1_UNORM:
case WINED3DFMT_B5G6R5_UNORM:
@ -2530,7 +2577,7 @@ BOOL getColorBits(const struct wined3d_format *format,
}
/* Helper function for retrieving depth/stencil info for ChoosePixelFormat and wglChoosePixelFormatARB */
BOOL getDepthStencilBits(const struct wined3d_format *format, short *depthSize, short *stencilSize)
BOOL getDepthStencilBits(const struct wined3d_format *format, BYTE *depthSize, BYTE *stencilSize)
{
TRACE("format %s.\n", debug_d3dformat(format->id));
@ -2545,6 +2592,7 @@ BOOL getDepthStencilBits(const struct wined3d_format *format, short *depthSize,
case WINED3DFMT_S8_UINT_D24_FLOAT:
case WINED3DFMT_D32_UNORM:
case WINED3DFMT_D32_FLOAT:
case WINED3DFMT_INTZ:
break;
default:
FIXME("Unsupported depth/stencil format %s.\n", debug_d3dformat(format->id));
@ -2689,7 +2737,8 @@ DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) {
return size;
}
void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_settings *settings, BOOL ignore_textype) {
void gen_ffp_frag_op(struct wined3d_stateblock *stateblock, struct ffp_frag_settings *settings, BOOL ignore_textype)
{
#define ARG1 0x01
#define ARG2 0x02
#define ARG0 0x04
@ -2725,13 +2774,14 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
unsigned int i;
DWORD ttff;
DWORD cop, aop, carg0, carg1, carg2, aarg0, aarg1, aarg2;
IWineD3DDeviceImpl *device = stateblock->device;
IWineD3DSurfaceImpl *rt = device->render_targets[0];
struct wined3d_device *device = stateblock->device;
struct wined3d_surface *rt = device->fb.render_targets[0];
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
for (i = 0; i < gl_info->limits.texture_stages; ++i)
{
IWineD3DBaseTextureImpl *texture;
const struct wined3d_texture *texture;
settings->op[i].padding = 0;
if (stateblock->state.texture_states[i][WINED3DTSS_COLOROP] == WINED3DTOP_DISABLE)
{
@ -2756,7 +2806,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
}
else
{
switch (texture->baseTexture.target)
switch (texture->target)
{
case GL_TEXTURE_1D:
settings->op[i].tex_type = tex_1d;
@ -2813,12 +2863,14 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
if (!i && stateblock->state.textures[0] && stateblock->state.render_states[WINED3DRS_COLORKEYENABLE])
{
IWineD3DBaseTextureImpl *texture = stateblock->state.textures[0];
GLenum texture_dimensions = texture->baseTexture.target;
GLenum texture_dimensions;
texture = stateblock->state.textures[0];
texture_dimensions = texture->target;
if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB)
{
IWineD3DSurfaceImpl *surf = (IWineD3DSurfaceImpl *)texture->baseTexture.sub_resources[0];
struct wined3d_surface *surf = surface_from_resource(texture->sub_resources[0]);
if (surf->CKeyFlags & WINEDDSD_CKSRCBLT && !surf->resource.format->alpha_mask)
{
@ -2938,7 +2990,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
}
}
if (stateblock->state.render_states[WINED3DRS_SRGBWRITEENABLE]
&& rt->resource.format->Flags & WINED3DFMT_FLAG_SRGB_WRITE)
&& rt->resource.format->flags & WINED3DFMT_FLAG_SRGB_WRITE)
{
settings->sRGB_write = 1;
} else {
@ -2979,11 +3031,11 @@ void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *des
* Requires the caller to activate the correct unit before
*/
/* GL locking is done by the caller (state handler) */
void texture_activate_dimensions(IWineD3DBaseTextureImpl *texture, const struct wined3d_gl_info *gl_info)
void texture_activate_dimensions(const struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info)
{
if (texture)
{
switch (texture->baseTexture.target)
switch (texture->target)
{
case GL_TEXTURE_2D:
glDisable(GL_TEXTURE_3D);
@ -3064,7 +3116,7 @@ void texture_activate_dimensions(IWineD3DBaseTextureImpl *texture, const struct
}
/* GL locking is done by the caller (state handler) */
void sampler_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
void sampler_texdim(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
DWORD sampler = state - STATE_SAMPLER(0);
DWORD mapped_stage = stateblock->device->texUnitMap[sampler];
@ -3162,7 +3214,7 @@ void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected,
else *ps_selected = SHADER_NONE;
}
const struct blit_shader *wined3d_select_blitter(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
const struct blit_shader *wined3d_select_blitter(const struct wined3d_gl_info *gl_info, enum wined3d_blit_op blit_op,
const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool, const struct wined3d_format *src_format,
const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool, const struct wined3d_format *dst_format)
{

View file

@ -37,53 +37,36 @@ static void dump_wined3dvertexelement(const WINED3DVERTEXELEMENT *element) {
TRACE(" usage_idx: %u\n", element->usage_idx);
}
/* *******************************************
IWineD3DVertexDeclaration IUnknown parts follow
******************************************* */
static HRESULT WINAPI IWineD3DVertexDeclarationImpl_QueryInterface(IWineD3DVertexDeclaration *iface, REFIID riid, LPVOID *ppobj)
ULONG CDECL wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration)
{
IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface;
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| IsEqualGUID(riid, &IID_IWineD3DVertexDeclaration)){
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
*ppobj = NULL;
return E_NOINTERFACE;
ULONG refcount = InterlockedIncrement(&declaration->ref);
TRACE("%p increasing refcount to %u.\n", declaration, refcount);
return refcount;
}
static ULONG WINAPI IWineD3DVertexDeclarationImpl_AddRef(IWineD3DVertexDeclaration *iface) {
IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface;
TRACE("(%p) : AddRef increasing from %d\n", This, This->ref);
return InterlockedIncrement(&This->ref);
}
ULONG CDECL wined3d_vertex_declaration_decref(struct wined3d_vertex_declaration *declaration)
{
ULONG refcount = InterlockedDecrement(&declaration->ref);
static ULONG WINAPI IWineD3DVertexDeclarationImpl_Release(IWineD3DVertexDeclaration *iface) {
IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface;
ULONG ref;
TRACE("(%p) : Releasing from %d\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
if (!ref)
TRACE("%p decreasing refcount to %u.\n", declaration, refcount);
if (!refcount)
{
HeapFree(GetProcessHeap(), 0, This->elements);
This->parent_ops->wined3d_object_destroyed(This->parent);
HeapFree(GetProcessHeap(), 0, This);
HeapFree(GetProcessHeap(), 0, declaration->elements);
declaration->parent_ops->wined3d_object_destroyed(declaration->parent);
HeapFree(GetProcessHeap(), 0, declaration);
}
return ref;
return refcount;
}
/* *******************************************
IWineD3DVertexDeclaration parts follow
******************************************* */
static void * WINAPI IWineD3DVertexDeclarationImpl_GetParent(IWineD3DVertexDeclaration *iface)
void * CDECL wined3d_vertex_declaration_get_parent(const struct wined3d_vertex_declaration *declaration)
{
TRACE("iface %p.\n", iface);
TRACE("declaration %p.\n", declaration);
return ((IWineD3DVertexDeclarationImpl *)iface)->parent;
return declaration->parent;
}
static BOOL declaration_element_valid_ffp(const WINED3DVERTEXELEMENT *element)
@ -174,18 +157,8 @@ static BOOL declaration_element_valid_ffp(const WINED3DVERTEXELEMENT *element)
}
}
static const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl =
{
/* IUnknown */
IWineD3DVertexDeclarationImpl_QueryInterface,
IWineD3DVertexDeclarationImpl_AddRef,
IWineD3DVertexDeclarationImpl_Release,
/* IWineD3DVertexDeclaration */
IWineD3DVertexDeclarationImpl_GetParent,
};
HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *declaration, IWineD3DDeviceImpl *device,
const WINED3DVERTEXELEMENT *elements, UINT element_count,
static HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declaration,
struct wined3d_device *device, const WINED3DVERTEXELEMENT *elements, UINT element_count,
void *parent, const struct wined3d_parent_ops *parent_ops)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
@ -200,7 +173,6 @@ HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *declaration, IWine
}
}
declaration->lpVtbl = &IWineD3DVertexDeclaration_Vtbl;
declaration->ref = 1;
declaration->parent = parent;
declaration->parent_ops = parent_ops;
@ -264,3 +236,189 @@ HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *declaration, IWine
return WINED3D_OK;
}
HRESULT CDECL wined3d_vertex_declaration_create(struct wined3d_device *device,
const WINED3DVERTEXELEMENT *elements, UINT element_count, void *parent,
const struct wined3d_parent_ops *parent_ops, struct wined3d_vertex_declaration **declaration)
{
struct wined3d_vertex_declaration *object;
HRESULT hr;
TRACE("device %p, elements %p, element_count %u, parent %p, parent_ops %p, declaration %p.\n",
device, elements, element_count, parent, parent_ops, declaration);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if(!object)
{
ERR("Failed to allocate vertex declaration memory.\n");
return E_OUTOFMEMORY;
}
hr = vertexdeclaration_init(object, device, elements, element_count, parent, parent_ops);
if (FAILED(hr))
{
WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created vertex declaration %p.\n", object);
*declaration = object;
return WINED3D_OK;
}
struct wined3d_fvf_convert_state
{
const struct wined3d_gl_info *gl_info;
WINED3DVERTEXELEMENT *elements;
UINT offset;
UINT idx;
};
static void append_decl_element(struct wined3d_fvf_convert_state *state,
enum wined3d_format_id format_id, WINED3DDECLUSAGE usage, UINT usage_idx)
{
WINED3DVERTEXELEMENT *elements = state->elements;
const struct wined3d_format *format;
UINT offset = state->offset;
UINT idx = state->idx;
elements[idx].format = format_id;
elements[idx].input_slot = 0;
elements[idx].offset = offset;
elements[idx].output_slot = 0;
elements[idx].method = WINED3DDECLMETHOD_DEFAULT;
elements[idx].usage = usage;
elements[idx].usage_idx = usage_idx;
format = wined3d_get_format(state->gl_info, format_id);
state->offset += format->component_count * format->component_size;
++state->idx;
}
static unsigned int convert_fvf_to_declaration(const struct wined3d_gl_info *gl_info,
DWORD fvf, WINED3DVERTEXELEMENT **elements)
{
BOOL has_pos = !!(fvf & WINED3DFVF_POSITION_MASK);
BOOL has_blend = (fvf & WINED3DFVF_XYZB5) > WINED3DFVF_XYZRHW;
BOOL has_blend_idx = has_blend &&
(((fvf & WINED3DFVF_XYZB5) == WINED3DFVF_XYZB5) ||
(fvf & WINED3DFVF_LASTBETA_D3DCOLOR) ||
(fvf & WINED3DFVF_LASTBETA_UBYTE4));
BOOL has_normal = !!(fvf & WINED3DFVF_NORMAL);
BOOL has_psize = !!(fvf & WINED3DFVF_PSIZE);
BOOL has_diffuse = !!(fvf & WINED3DFVF_DIFFUSE);
BOOL has_specular = !!(fvf & WINED3DFVF_SPECULAR);
DWORD num_textures = (fvf & WINED3DFVF_TEXCOUNT_MASK) >> WINED3DFVF_TEXCOUNT_SHIFT;
DWORD texcoords = (fvf & 0xFFFF0000) >> 16;
struct wined3d_fvf_convert_state state;
unsigned int size;
unsigned int idx;
DWORD num_blends = 1 + (((fvf & WINED3DFVF_XYZB5) - WINED3DFVF_XYZB1) >> 1);
if (has_blend_idx) num_blends--;
/* Compute declaration size */
size = has_pos + (has_blend && num_blends > 0) + has_blend_idx + has_normal +
has_psize + has_diffuse + has_specular + num_textures;
state.gl_info = gl_info;
state.elements = HeapAlloc(GetProcessHeap(), 0, size * sizeof(*state.elements));
if (!state.elements) return ~0U;
state.offset = 0;
state.idx = 0;
if (has_pos)
{
if (!has_blend && (fvf & WINED3DFVF_XYZRHW))
append_decl_element(&state, WINED3DFMT_R32G32B32A32_FLOAT, WINED3DDECLUSAGE_POSITIONT, 0);
else if ((fvf & WINED3DFVF_XYZW) == WINED3DFVF_XYZW)
append_decl_element(&state, WINED3DFMT_R32G32B32A32_FLOAT, WINED3DDECLUSAGE_POSITION, 0);
else
append_decl_element(&state, WINED3DFMT_R32G32B32_FLOAT, WINED3DDECLUSAGE_POSITION, 0);
}
if (has_blend && (num_blends > 0))
{
if ((fvf & WINED3DFVF_XYZB5) == WINED3DFVF_XYZB2 && (fvf & WINED3DFVF_LASTBETA_D3DCOLOR))
append_decl_element(&state, WINED3DFMT_B8G8R8A8_UNORM, WINED3DDECLUSAGE_BLENDWEIGHT, 0);
else
{
switch (num_blends)
{
case 1:
append_decl_element(&state, WINED3DFMT_R32_FLOAT, WINED3DDECLUSAGE_BLENDWEIGHT, 0);
break;
case 2:
append_decl_element(&state, WINED3DFMT_R32G32_FLOAT, WINED3DDECLUSAGE_BLENDWEIGHT, 0);
break;
case 3:
append_decl_element(&state, WINED3DFMT_R32G32B32_FLOAT, WINED3DDECLUSAGE_BLENDWEIGHT, 0);
break;
case 4:
append_decl_element(&state, WINED3DFMT_R32G32B32A32_FLOAT, WINED3DDECLUSAGE_BLENDWEIGHT, 0);
break;
default:
ERR("Unexpected amount of blend values: %u\n", num_blends);
}
}
}
if (has_blend_idx)
{
if ((fvf & WINED3DFVF_LASTBETA_UBYTE4)
|| ((fvf & WINED3DFVF_XYZB5) == WINED3DFVF_XYZB2 && (fvf & WINED3DFVF_LASTBETA_D3DCOLOR)))
append_decl_element(&state, WINED3DFMT_R8G8B8A8_UINT, WINED3DDECLUSAGE_BLENDINDICES, 0);
else if (fvf & WINED3DFVF_LASTBETA_D3DCOLOR)
append_decl_element(&state, WINED3DFMT_B8G8R8A8_UNORM, WINED3DDECLUSAGE_BLENDINDICES, 0);
else
append_decl_element(&state, WINED3DFMT_R32_FLOAT, WINED3DDECLUSAGE_BLENDINDICES, 0);
}
if (has_normal) append_decl_element(&state, WINED3DFMT_R32G32B32_FLOAT, WINED3DDECLUSAGE_NORMAL, 0);
if (has_psize) append_decl_element(&state, WINED3DFMT_R32_FLOAT, WINED3DDECLUSAGE_PSIZE, 0);
if (has_diffuse) append_decl_element(&state, WINED3DFMT_B8G8R8A8_UNORM, WINED3DDECLUSAGE_COLOR, 0);
if (has_specular) append_decl_element(&state, WINED3DFMT_B8G8R8A8_UNORM, WINED3DDECLUSAGE_COLOR, 1);
for (idx = 0; idx < num_textures; ++idx)
{
switch ((texcoords >> (idx * 2)) & 0x03)
{
case WINED3DFVF_TEXTUREFORMAT1:
append_decl_element(&state, WINED3DFMT_R32_FLOAT, WINED3DDECLUSAGE_TEXCOORD, idx);
break;
case WINED3DFVF_TEXTUREFORMAT2:
append_decl_element(&state, WINED3DFMT_R32G32_FLOAT, WINED3DDECLUSAGE_TEXCOORD, idx);
break;
case WINED3DFVF_TEXTUREFORMAT3:
append_decl_element(&state, WINED3DFMT_R32G32B32_FLOAT, WINED3DDECLUSAGE_TEXCOORD, idx);
break;
case WINED3DFVF_TEXTUREFORMAT4:
append_decl_element(&state, WINED3DFMT_R32G32B32A32_FLOAT, WINED3DDECLUSAGE_TEXCOORD, idx);
break;
}
}
*elements = state.elements;
return size;
}
HRESULT CDECL wined3d_vertex_declaration_create_from_fvf(struct wined3d_device *device,
DWORD fvf, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_vertex_declaration **declaration)
{
WINED3DVERTEXELEMENT *elements;
unsigned int size;
DWORD hr;
TRACE("device %p, fvf %#x, parent %p, parent_ops %p, declaration %p.\n",
device, fvf, parent, parent_ops, declaration);
size = convert_fvf_to_declaration(&device->adapter->gl_info, fvf, &elements);
if (size == ~0U) return E_OUTOFMEMORY;
hr = wined3d_vertex_declaration_create(device, elements, size, parent, parent_ops, declaration);
HeapFree(GetProcessHeap(), 0, elements);
return hr;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright 2009 Henri Verbeet for CodeWeavers
* Copyright 2009, 2011 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -24,94 +24,68 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
/* IUnknown methods */
static HRESULT STDMETHODCALLTYPE rendertarget_view_QueryInterface(IWineD3DRendertargetView *iface,
REFIID riid, void **object)
ULONG CDECL wined3d_rendertarget_view_incref(struct wined3d_rendertarget_view *view)
{
TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
ULONG refcount = InterlockedIncrement(&view->refcount);
if (IsEqualGUID(riid, &IID_IWineD3DRendertargetView)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| IsEqualGUID(riid, &IID_IUnknown))
{
IUnknown_AddRef(iface);
*object = iface;
return S_OK;
}
WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
*object = NULL;
return E_NOINTERFACE;
}
static ULONG STDMETHODCALLTYPE rendertarget_view_AddRef(IWineD3DRendertargetView *iface)
{
struct wined3d_rendertarget_view *This = (struct wined3d_rendertarget_view *)iface;
ULONG refcount = InterlockedIncrement(&This->refcount);
TRACE("%p increasing refcount to %u\n", This, refcount);
TRACE("%p increasing refcount to %u.\n", view, refcount);
return refcount;
}
static ULONG STDMETHODCALLTYPE rendertarget_view_Release(IWineD3DRendertargetView *iface)
ULONG CDECL wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *view)
{
struct wined3d_rendertarget_view *This = (struct wined3d_rendertarget_view *)iface;
ULONG refcount = InterlockedDecrement(&This->refcount);
ULONG refcount = InterlockedDecrement(&view->refcount);
TRACE("%p decreasing refcount to %u\n", This, refcount);
TRACE("%p decreasing refcount to %u.\n", view, refcount);
if (!refcount)
{
IWineD3DResource_Release(This->resource);
HeapFree(GetProcessHeap(), 0, This);
}
HeapFree(GetProcessHeap(), 0, view);
return refcount;
}
/* IWineD3DBase methods */
static void * STDMETHODCALLTYPE rendertarget_view_GetParent(IWineD3DRendertargetView *iface)
void * CDECL wined3d_rendertarget_view_get_parent(const struct wined3d_rendertarget_view *view)
{
TRACE("iface %p.\n", iface);
TRACE("view %p.\n", view);
return ((struct wined3d_rendertarget_view *)iface)->parent;
return view->parent;
}
/* IWineD3DRendertargetView methods */
static HRESULT STDMETHODCALLTYPE rendertarget_view_GetResource(IWineD3DRendertargetView *iface,
IWineD3DResource **resource)
struct wined3d_resource * CDECL wined3d_rendertarget_view_get_resource(const struct wined3d_rendertarget_view *view)
{
struct wined3d_rendertarget_view *This = (struct wined3d_rendertarget_view *)iface;
TRACE("view %p.\n", view);
IWineD3DResource_AddRef(This->resource);
*resource = This->resource;
return WINED3D_OK;
return view->resource;
}
static const struct IWineD3DRendertargetViewVtbl wined3d_rendertarget_view_vtbl =
static void wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *view,
struct wined3d_resource *resource, void *parent)
{
/* IUnknown methods */
rendertarget_view_QueryInterface,
rendertarget_view_AddRef,
rendertarget_view_Release,
/* IWineD3DBase methods */
rendertarget_view_GetParent,
/* IWineD3DRendertargetView methods */
rendertarget_view_GetResource,
};
void wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *view,
IWineD3DResource *resource, void *parent)
{
view->vtbl = &wined3d_rendertarget_view_vtbl;
view->refcount = 1;
IWineD3DResource_AddRef(resource);
view->resource = resource;
view->parent = parent;
}
HRESULT CDECL wined3d_rendertarget_view_create(struct wined3d_resource *resource,
void *parent, struct wined3d_rendertarget_view **rendertarget_view)
{
struct wined3d_rendertarget_view *object;
TRACE("resource %p, parent %p, rendertarget_view %p.\n",
resource, parent, rendertarget_view);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
ERR("Failed to allocate memory\n");
return E_OUTOFMEMORY;
}
wined3d_rendertarget_view_init(object, resource, parent);
TRACE("Created render target view %p.\n", object);
*rendertarget_view = object;
return WINED3D_OK;
}

View file

@ -1,10 +1,8 @@
/*
* IWineD3DVolume implementation
*
* Copyright 2002-2005 Jason Edmeades
* Copyright 2002-2005 Raphael Junqueira
* Copyright 2005 Oliver Stieber
* Copyright 2009 Henri Verbeet for CodeWeavers
* Copyright 2009-2011 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -27,9 +25,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
/* Context activation is done by the caller. */
static void volume_bind_and_dirtify(IWineD3DVolume *iface) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
const struct wined3d_gl_info *gl_info = &This->resource.device->adapter->gl_info;
static void volume_bind_and_dirtify(struct wined3d_volume *volume, const struct wined3d_gl_info *gl_info)
{
struct wined3d_texture *container = volume->container;
DWORD active_sampler;
/* We don't need a specific texture unit, but after binding the texture the current unit is dirty.
@ -49,285 +47,256 @@ static void volume_bind_and_dirtify(IWineD3DVolume *iface) {
ENTER_GL();
glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
LEAVE_GL();
active_sampler = This->resource.device->rev_tex_unit_map[active_texture - GL_TEXTURE0_ARB];
active_sampler = volume->resource.device->rev_tex_unit_map[active_texture - GL_TEXTURE0_ARB];
} else {
active_sampler = 0;
}
if (active_sampler != WINED3D_UNMAPPED_STAGE)
{
IWineD3DDeviceImpl_MarkStateDirty(This->resource.device, STATE_SAMPLER(active_sampler));
IWineD3DDeviceImpl_MarkStateDirty(volume->resource.device, STATE_SAMPLER(active_sampler));
}
IWineD3DVolumeTexture_BindTexture((IWineD3DVolumeTexture *)This->container, FALSE);
container->texture_ops->texture_bind(container, gl_info, FALSE);
}
void volume_add_dirty_box(IWineD3DVolume *iface, const WINED3DBOX *dirty_box)
void volume_add_dirty_box(struct wined3d_volume *volume, const WINED3DBOX *dirty_box)
{
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
This->dirty = TRUE;
volume->dirty = TRUE;
if (dirty_box)
{
This->lockedBox.Left = min(This->lockedBox.Left, dirty_box->Left);
This->lockedBox.Top = min(This->lockedBox.Top, dirty_box->Top);
This->lockedBox.Front = min(This->lockedBox.Front, dirty_box->Front);
This->lockedBox.Right = max(This->lockedBox.Right, dirty_box->Right);
This->lockedBox.Bottom = max(This->lockedBox.Bottom, dirty_box->Bottom);
This->lockedBox.Back = max(This->lockedBox.Back, dirty_box->Back);
volume->lockedBox.Left = min(volume->lockedBox.Left, dirty_box->Left);
volume->lockedBox.Top = min(volume->lockedBox.Top, dirty_box->Top);
volume->lockedBox.Front = min(volume->lockedBox.Front, dirty_box->Front);
volume->lockedBox.Right = max(volume->lockedBox.Right, dirty_box->Right);
volume->lockedBox.Bottom = max(volume->lockedBox.Bottom, dirty_box->Bottom);
volume->lockedBox.Back = max(volume->lockedBox.Back, dirty_box->Back);
}
else
{
This->lockedBox.Left = 0;
This->lockedBox.Top = 0;
This->lockedBox.Front = 0;
This->lockedBox.Right = This->currentDesc.Width;
This->lockedBox.Bottom = This->currentDesc.Height;
This->lockedBox.Back = This->currentDesc.Depth;
volume->lockedBox.Left = 0;
volume->lockedBox.Top = 0;
volume->lockedBox.Front = 0;
volume->lockedBox.Right = volume->resource.width;
volume->lockedBox.Bottom = volume->resource.height;
volume->lockedBox.Back = volume->resource.depth;
}
}
void volume_set_container(IWineD3DVolumeImpl *volume, struct IWineD3DVolumeTextureImpl *container)
void volume_set_container(struct wined3d_volume *volume, struct wined3d_texture *container)
{
TRACE("volume %p, container %p.\n", volume, container);
volume->container = container;
}
/* *******************************************
IWineD3DVolume IUnknown parts follow
******************************************* */
static HRESULT WINAPI IWineD3DVolumeImpl_QueryInterface(IWineD3DVolume *iface, REFIID riid, void **object)
/* Context activation is done by the caller. */
void volume_load(struct wined3d_volume *volume, UINT level, BOOL srgb_mode)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
const struct wined3d_gl_info *gl_info = &volume->resource.device->adapter->gl_info;
const struct wined3d_format *format = volume->resource.format;
if (IsEqualGUID(riid, &IID_IWineD3DVolume)
|| IsEqualGUID(riid, &IID_IWineD3DResource)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| IsEqualGUID(riid, &IID_IUnknown))
{
IUnknown_AddRef(iface);
*object = iface;
return S_OK;
}
TRACE("volume %p, level %u, srgb %#x, format %s (%#x).\n",
volume, level, srgb_mode, debug_d3dformat(format->id), format->id);
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
volume_bind_and_dirtify(volume, gl_info);
*object = NULL;
return E_NOINTERFACE;
}
ENTER_GL();
GL_EXTCALL(glTexImage3DEXT(GL_TEXTURE_3D, level, format->glInternal,
volume->resource.width, volume->resource.height, volume->resource.depth,
0, format->glFormat, format->glType, volume->resource.allocatedMemory));
checkGLcall("glTexImage3D");
LEAVE_GL();
static ULONG WINAPI IWineD3DVolumeImpl_AddRef(IWineD3DVolume *iface) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
TRACE("(%p) : AddRef increasing from %d\n", This, This->resource.ref);
return InterlockedIncrement(&This->resource.ref);
/* When adding code releasing volume->resource.allocatedMemory to save
* data keep in mind that GL_UNPACK_CLIENT_STORAGE_APPLE is enabled by
* default if supported(GL_APPLE_client_storage). Thus do not release
* volume->resource.allocatedMemory if GL_APPLE_client_storage is
* supported. */
}
/* Do not call while under the GL lock. */
static ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
ULONG ref;
TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
ref = InterlockedDecrement(&This->resource.ref);
if (!ref)
{
resource_cleanup((IWineD3DResource *)iface);
This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* ****************************************************
IWineD3DVolume IWineD3DResource parts follow
**************************************************** */
static void * WINAPI IWineD3DVolumeImpl_GetParent(IWineD3DVolume *iface)
static void volume_unload(struct wined3d_resource *resource)
{
TRACE("iface %p.\n", iface);
return ((IWineD3DVolumeImpl *)iface)->resource.parent;
}
static HRESULT WINAPI IWineD3DVolumeImpl_SetPrivateData(IWineD3DVolume *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IWineD3DVolumeImpl_GetPrivateData(IWineD3DVolume *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IWineD3DVolumeImpl_FreePrivateData(IWineD3DVolume *iface, REFGUID refguid) {
return resource_free_private_data((IWineD3DResource *)iface, refguid);
}
static DWORD WINAPI IWineD3DVolumeImpl_SetPriority(IWineD3DVolume *iface, DWORD PriorityNew) {
return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
}
static DWORD WINAPI IWineD3DVolumeImpl_GetPriority(IWineD3DVolume *iface) {
return resource_get_priority((IWineD3DResource *)iface);
}
/* Do not call while under the GL lock. */
static void WINAPI IWineD3DVolumeImpl_PreLoad(IWineD3DVolume *iface) {
FIXME("iface %p stub!\n", iface);
}
/* Do not call while under the GL lock. */
static void WINAPI IWineD3DVolumeImpl_UnLoad(IWineD3DVolume *iface)
{
TRACE("iface %p.\n", iface);
TRACE("texture %p.\n", resource);
/* The whole content is shadowed on This->resource.allocatedMemory, and
* the texture name is managed by the VolumeTexture container. */
resource_unload((IWineD3DResourceImpl *)iface);
resource_unload(resource);
}
static WINED3DRESOURCETYPE WINAPI IWineD3DVolumeImpl_GetType(IWineD3DVolume *iface) {
return resource_get_type((IWineD3DResource *)iface);
}
static void WINAPI IWineD3DVolumeImpl_GetDesc(IWineD3DVolume *iface, WINED3DVOLUME_DESC *desc)
ULONG CDECL wined3d_volume_incref(struct wined3d_volume *volume)
{
IWineD3DVolumeImpl *volume = (IWineD3DVolumeImpl *)iface;
ULONG refcount;
TRACE("iface %p, desc %p.\n", iface, desc);
if (volume->container)
{
TRACE("Forwarding to container %p.\n", volume->container);
return wined3d_texture_incref(volume->container);
}
desc->Format = volume->resource.format->id;
desc->Type = volume->resource.resourceType;
desc->Usage = volume->resource.usage;
desc->Pool = volume->resource.pool;
desc->Size = volume->resource.size; /* dx8 only */
desc->Width = volume->currentDesc.Width;
desc->Height = volume->currentDesc.Height;
desc->Depth = volume->currentDesc.Depth;
refcount = InterlockedIncrement(&volume->resource.ref);
TRACE("%p increasing refcount to %u.\n", volume, refcount);
return refcount;
}
static HRESULT WINAPI IWineD3DVolumeImpl_LockBox(IWineD3DVolume *iface, WINED3DLOCKED_BOX* pLockedVolume, CONST WINED3DBOX* pBox, DWORD Flags) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
FIXME("(%p) : pBox=%p stub\n", This, pBox);
/* Do not call while under the GL lock. */
ULONG CDECL wined3d_volume_decref(struct wined3d_volume *volume)
{
ULONG refcount;
if(!This->resource.allocatedMemory) {
This->resource.allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->resource.size);
if (volume->container)
{
TRACE("Forwarding to container %p.\n", volume->container);
return wined3d_texture_decref(volume->container);
}
/* fixme: should we really lock as such? */
TRACE("(%p) : box=%p, output pbox=%p, allMem=%p\n", This, pBox, pLockedVolume, This->resource.allocatedMemory);
refcount = InterlockedDecrement(&volume->resource.ref);
pLockedVolume->RowPitch = This->resource.format->byte_count * This->currentDesc.Width; /* Bytes / row */
pLockedVolume->SlicePitch = This->resource.format->byte_count
* This->currentDesc.Width * This->currentDesc.Height; /* Bytes / slice */
if (!pBox) {
TRACE("%p decreasing refcount to %u.\n", volume, refcount);
if (!refcount)
{
resource_cleanup(&volume->resource);
volume->resource.parent_ops->wined3d_object_destroyed(volume->resource.parent);
HeapFree(GetProcessHeap(), 0, volume);
}
return refcount;
}
void * CDECL wined3d_volume_get_parent(const struct wined3d_volume *volume)
{
TRACE("volume %p.\n", volume);
return volume->resource.parent;
}
HRESULT CDECL wined3d_volume_set_private_data(struct wined3d_volume *volume,
REFGUID guid, const void *data, DWORD data_size, DWORD flags)
{
return resource_set_private_data(&volume->resource, guid, data, data_size, flags);
}
HRESULT CDECL wined3d_volume_get_private_data(const struct wined3d_volume *volume,
REFGUID guid, void *data, DWORD *data_size)
{
return resource_get_private_data(&volume->resource, guid, data, data_size);
}
HRESULT CDECL wined3d_volume_free_private_data(struct wined3d_volume *volume, REFGUID guid)
{
return resource_free_private_data(&volume->resource, guid);
}
DWORD CDECL wined3d_volume_set_priority(struct wined3d_volume *volume, DWORD priority)
{
return resource_set_priority(&volume->resource, priority);
}
DWORD CDECL wined3d_volume_get_priority(const struct wined3d_volume *volume)
{
return resource_get_priority(&volume->resource);
}
/* Do not call while under the GL lock. */
void CDECL wined3d_volume_preload(struct wined3d_volume *volume)
{
FIXME("volume %p stub!\n", volume);
}
struct wined3d_resource * CDECL wined3d_volume_get_resource(struct wined3d_volume *volume)
{
TRACE("volume %p.\n", volume);
return &volume->resource;
}
HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume,
WINED3DLOCKED_BOX *locked_box, const WINED3DBOX *box, DWORD flags)
{
TRACE("volume %p, locked_box %p, box %p, flags %#x.\n",
volume, locked_box, box, flags);
if (!volume->resource.allocatedMemory)
volume->resource.allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, volume->resource.size);
TRACE("allocatedMemory %p.\n", volume->resource.allocatedMemory);
locked_box->RowPitch = volume->resource.format->byte_count * volume->resource.width; /* Bytes / row */
locked_box->SlicePitch = volume->resource.format->byte_count
* volume->resource.width * volume->resource.height; /* Bytes / slice */
if (!box)
{
TRACE("No box supplied - all is ok\n");
pLockedVolume->pBits = This->resource.allocatedMemory;
This->lockedBox.Left = 0;
This->lockedBox.Top = 0;
This->lockedBox.Front = 0;
This->lockedBox.Right = This->currentDesc.Width;
This->lockedBox.Bottom = This->currentDesc.Height;
This->lockedBox.Back = This->currentDesc.Depth;
} else {
TRACE("Lock Box (%p) = l %d, t %d, r %d, b %d, fr %d, ba %d\n", pBox, pBox->Left, pBox->Top, pBox->Right, pBox->Bottom, pBox->Front, pBox->Back);
pLockedVolume->pBits = This->resource.allocatedMemory
+ (pLockedVolume->SlicePitch * pBox->Front) /* FIXME: is front < back or vica versa? */
+ (pLockedVolume->RowPitch * pBox->Top)
+ (pBox->Left * This->resource.format->byte_count);
This->lockedBox.Left = pBox->Left;
This->lockedBox.Top = pBox->Top;
This->lockedBox.Front = pBox->Front;
This->lockedBox.Right = pBox->Right;
This->lockedBox.Bottom = pBox->Bottom;
This->lockedBox.Back = pBox->Back;
}
if (Flags & (WINED3DLOCK_NO_DIRTY_UPDATE | WINED3DLOCK_READONLY)) {
/* Don't dirtify */
locked_box->pBits = volume->resource.allocatedMemory;
volume->lockedBox.Left = 0;
volume->lockedBox.Top = 0;
volume->lockedBox.Front = 0;
volume->lockedBox.Right = volume->resource.width;
volume->lockedBox.Bottom = volume->resource.height;
volume->lockedBox.Back = volume->resource.depth;
}
else
{
volume_add_dirty_box(iface, &This->lockedBox);
This->container->baseTexture.texture_rgb.dirty = TRUE;
This->container->baseTexture.texture_srgb.dirty = TRUE;
TRACE("Lock Box (%p) = l %d, t %d, r %d, b %d, fr %d, ba %d\n",
box, box->Left, box->Top, box->Right, box->Bottom, box->Front, box->Back);
locked_box->pBits = volume->resource.allocatedMemory
+ (locked_box->SlicePitch * box->Front) /* FIXME: is front < back or vica versa? */
+ (locked_box->RowPitch * box->Top)
+ (box->Left * volume->resource.format->byte_count);
volume->lockedBox.Left = box->Left;
volume->lockedBox.Top = box->Top;
volume->lockedBox.Front = box->Front;
volume->lockedBox.Right = box->Right;
volume->lockedBox.Bottom = box->Bottom;
volume->lockedBox.Back = box->Back;
}
This->locked = TRUE;
TRACE("returning memory@%p rpitch(%d) spitch(%d)\n", pLockedVolume->pBits, pLockedVolume->RowPitch, pLockedVolume->SlicePitch);
if (!(flags & (WINED3DLOCK_NO_DIRTY_UPDATE | WINED3DLOCK_READONLY)))
{
volume_add_dirty_box(volume, &volume->lockedBox);
wined3d_texture_set_dirty(volume->container, TRUE);
}
volume->locked = TRUE;
TRACE("Returning memory %p, row pitch %d, slice pitch %d.\n",
locked_box->pBits, locked_box->RowPitch, locked_box->SlicePitch);
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DVolumeImpl_UnlockBox(IWineD3DVolume *iface) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
if (!This->locked)
struct wined3d_volume * CDECL wined3d_volume_from_resource(struct wined3d_resource *resource)
{
return volume_from_resource(resource);
}
HRESULT CDECL wined3d_volume_unmap(struct wined3d_volume *volume)
{
TRACE("volume %p.\n", volume);
if (!volume->locked)
{
WARN("Trying to unlock unlocked volume %p.\n", iface);
WARN("Trying to unlock unlocked volume %p.\n", volume);
return WINED3DERR_INVALIDCALL;
}
TRACE("(%p) : unlocking volume\n", This);
This->locked = FALSE;
memset(&This->lockedBox, 0, sizeof(RECT));
volume->locked = FALSE;
memset(&volume->lockedBox, 0, sizeof(volume->lockedBox));
return WINED3D_OK;
}
/* Internal use functions follow : */
/* Context activation is done by the caller. */
static HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, int gl_level, BOOL srgb_mode)
static const struct wined3d_resource_ops volume_resource_ops =
{
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
const struct wined3d_gl_info *gl_info = &This->resource.device->adapter->gl_info;
const struct wined3d_format *format = This->resource.format;
TRACE("iface %p, level %u, srgb %#x, format %s (%#x).\n",
iface, gl_level, srgb_mode, debug_d3dformat(format->id), format->id);
volume_bind_and_dirtify(iface);
TRACE("Calling glTexImage3D %x level=%d, intfmt=%x, w=%d, h=%d,d=%d, 0=%d, glFmt=%x, glType=%x, Mem=%p\n",
GL_TEXTURE_3D, gl_level, format->glInternal, This->currentDesc.Width, This->currentDesc.Height,
This->currentDesc.Depth, 0, format->glFormat, format->glType, This->resource.allocatedMemory);
ENTER_GL();
GL_EXTCALL(glTexImage3DEXT(GL_TEXTURE_3D, gl_level, format->glInternal,
This->currentDesc.Width, This->currentDesc.Height, This->currentDesc.Depth,
0, format->glFormat, format->glType, This->resource.allocatedMemory));
checkGLcall("glTexImage3D");
LEAVE_GL();
/* When adding code releasing This->resource.allocatedMemory to save data keep in mind that
* GL_UNPACK_CLIENT_STORAGE_APPLE is enabled by default if supported(GL_APPLE_client_storage).
* Thus do not release This->resource.allocatedMemory if GL_APPLE_client_storage is supported.
*/
return WINED3D_OK;
}
static const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl =
{
/* IUnknown */
IWineD3DVolumeImpl_QueryInterface,
IWineD3DVolumeImpl_AddRef,
IWineD3DVolumeImpl_Release,
/* IWineD3DResource */
IWineD3DVolumeImpl_GetParent,
IWineD3DVolumeImpl_SetPrivateData,
IWineD3DVolumeImpl_GetPrivateData,
IWineD3DVolumeImpl_FreePrivateData,
IWineD3DVolumeImpl_SetPriority,
IWineD3DVolumeImpl_GetPriority,
IWineD3DVolumeImpl_PreLoad,
IWineD3DVolumeImpl_UnLoad,
IWineD3DVolumeImpl_GetType,
/* IWineD3DVolume */
IWineD3DVolumeImpl_GetDesc,
IWineD3DVolumeImpl_LockBox,
IWineD3DVolumeImpl_UnlockBox,
/* Internal interface */
IWineD3DVolumeImpl_LoadTexture,
volume_unload,
};
HRESULT volume_init(IWineD3DVolumeImpl *volume, IWineD3DDeviceImpl *device, UINT width,
static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_device *device, UINT width,
UINT height, UINT depth, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool,
void *parent, const struct wined3d_parent_ops *parent_ops)
{
@ -341,25 +310,55 @@ HRESULT volume_init(IWineD3DVolumeImpl *volume, IWineD3DDeviceImpl *device, UINT
return WINED3DERR_INVALIDCALL;
}
volume->lpVtbl = &IWineD3DVolume_Vtbl;
hr = resource_init((IWineD3DResource *)volume, WINED3DRTYPE_VOLUME, device,
width * height * depth * format->byte_count, usage, format, pool, parent, parent_ops);
hr = resource_init(&volume->resource, device, WINED3DRTYPE_VOLUME, format,
WINED3DMULTISAMPLE_NONE, 0, usage, pool, width, height, depth,
width * height * depth * format->byte_count, parent, parent_ops,
&volume_resource_ops);
if (FAILED(hr))
{
WARN("Failed to initialize resource, returning %#x.\n", hr);
return hr;
}
volume->currentDesc.Width = width;
volume->currentDesc.Height = height;
volume->currentDesc.Depth = depth;
volume->lockable = TRUE;
volume->locked = FALSE;
memset(&volume->lockedBox, 0, sizeof(volume->lockedBox));
volume->dirty = TRUE;
volume_add_dirty_box((IWineD3DVolume *)volume, NULL);
volume_add_dirty_box(volume, NULL);
return WINED3D_OK;
}
HRESULT CDECL wined3d_volume_create(struct wined3d_device *device, UINT width, UINT height,
UINT depth, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool, void *parent,
const struct wined3d_parent_ops *parent_ops, struct wined3d_volume **volume)
{
struct wined3d_volume *object;
HRESULT hr;
TRACE("device %p, width %u, height %u, depth %u, usage %#x, format %s, pool %s\n",
device, width, height, depth, usage, debug_d3dformat(format_id), debug_d3dpool(pool));
TRACE("parent %p, parent_ops %p, volume %p.\n", parent, parent_ops, volume);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
ERR("Out of memory\n");
*volume = NULL;
return WINED3DERR_OUTOFVIDEOMEMORY;
}
hr = volume_init(object, device, width, height, depth, usage, format_id, pool, parent, parent_ops);
if (FAILED(hr))
{
WARN("Failed to initialize volume, returning %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created volume %p.\n", object);
*volume = object;
return WINED3D_OK;
}

View file

@ -1,481 +0,0 @@
/*
* IWineD3DVolumeTexture implementation
*
* Copyright 2002-2005 Jason Edmeades
* Copyright 2002-2005 Raphael Junqueira
* Copyright 2005 Oliver Stieber
* Copyright 2009 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
/* Do not call while under the GL lock. */
static void volumetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb)
{
/* Override the IWineD3DResource Preload method. */
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
IWineD3DDeviceImpl *device = This->resource.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct wined3d_context *context = NULL;
BOOL srgb_mode = This->baseTexture.is_srgb;
BOOL srgb_was_toggled = FALSE;
unsigned int i;
TRACE("(%p) : About to load texture.\n", This);
if (!device->isInDraw) context = context_acquire(device, NULL);
else if (gl_info->supported[EXT_TEXTURE_SRGB] && This->baseTexture.bindCount > 0)
{
srgb_mode = device->stateBlock->state.sampler_states[This->baseTexture.sampler][WINED3DSAMP_SRGBTEXTURE];
srgb_was_toggled = This->baseTexture.is_srgb != srgb_mode;
This->baseTexture.is_srgb = srgb_mode;
}
/* If the texture is marked dirty or the srgb sampler setting has changed
* since the last load then reload the volumes. */
if (This->baseTexture.texture_rgb.dirty)
{
for (i = 0; i < This->baseTexture.level_count; ++i)
{
IWineD3DVolume *volume = (IWineD3DVolume *)This->baseTexture.sub_resources[i];
IWineD3DVolume_LoadTexture(volume, i, srgb_mode);
}
}
else if (srgb_was_toggled)
{
for (i = 0; i < This->baseTexture.level_count; ++i)
{
IWineD3DVolume *volume = (IWineD3DVolume *)This->baseTexture.sub_resources[i];
volume_add_dirty_box(volume, NULL);
IWineD3DVolume_LoadTexture(volume, i, srgb_mode);
}
}
else
{
TRACE("(%p) Texture not dirty, nothing to do.\n", iface);
}
if (context) context_release(context);
/* No longer dirty */
This->baseTexture.texture_rgb.dirty = FALSE;
}
static void volumetexture_cleanup(IWineD3DVolumeTextureImpl *This)
{
unsigned int i;
TRACE("(%p) : Cleaning up.\n", This);
for (i = 0; i < This->baseTexture.level_count; ++i)
{
IWineD3DVolumeImpl *volume = (IWineD3DVolumeImpl *)This->baseTexture.sub_resources[i];
if (volume)
{
/* Cleanup the container. */
volume_set_container(volume, NULL);
IWineD3DVolume_Release((IWineD3DVolume *)volume);
}
}
basetexture_cleanup((IWineD3DBaseTexture *)This);
}
/* *******************************************
IWineD3DTexture IUnknown parts follow
******************************************* */
static HRESULT WINAPI IWineD3DVolumeTextureImpl_QueryInterface(IWineD3DVolumeTexture *iface, REFIID riid, LPVOID *ppobj)
{
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| IsEqualGUID(riid, &IID_IWineD3DResource)
|| IsEqualGUID(riid, &IID_IWineD3DBaseTexture)
|| IsEqualGUID(riid, &IID_IWineD3DVolumeTexture)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IWineD3DVolumeTextureImpl_AddRef(IWineD3DVolumeTexture *iface) {
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
TRACE("(%p) : AddRef increasing from %d\n", This, This->resource.ref);
return InterlockedIncrement(&This->resource.ref);
}
/* Do not call while under the GL lock. */
static ULONG WINAPI IWineD3DVolumeTextureImpl_Release(IWineD3DVolumeTexture *iface) {
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
ULONG ref;
TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
ref = InterlockedDecrement(&This->resource.ref);
if (!ref)
{
volumetexture_cleanup(This);
This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* ****************************************************
IWineD3DVolumeTexture IWineD3DResource parts follow
**************************************************** */
static HRESULT WINAPI IWineD3DVolumeTextureImpl_SetPrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetPrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IWineD3DVolumeTextureImpl_FreePrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid) {
return resource_free_private_data((IWineD3DResource *)iface, refguid);
}
static DWORD WINAPI IWineD3DVolumeTextureImpl_SetPriority(IWineD3DVolumeTexture *iface, DWORD PriorityNew) {
return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
}
static DWORD WINAPI IWineD3DVolumeTextureImpl_GetPriority(IWineD3DVolumeTexture *iface) {
return resource_get_priority((IWineD3DResource *)iface);
}
static void WINAPI IWineD3DVolumeTextureImpl_PreLoad(IWineD3DVolumeTexture *iface) {
volumetexture_internal_preload((IWineD3DBaseTexture *) iface, SRGB_ANY);
}
/* Do not call while under the GL lock. */
static void WINAPI IWineD3DVolumeTextureImpl_UnLoad(IWineD3DVolumeTexture *iface) {
unsigned int i;
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
TRACE("(%p)\n", This);
/* Unload all the surfaces and reset the texture name. If UnLoad was called on the
* surface before, this one will be a NOP and vice versa. Unloading an unloaded
* surface is fine
*/
for (i = 0; i < This->baseTexture.level_count; ++i)
{
IWineD3DVolume_UnLoad((IWineD3DVolume *)This->baseTexture.sub_resources[i]);
}
basetexture_unload((IWineD3DBaseTexture *)iface);
}
static WINED3DRESOURCETYPE WINAPI IWineD3DVolumeTextureImpl_GetType(IWineD3DVolumeTexture *iface) {
return resource_get_type((IWineD3DResource *)iface);
}
static void * WINAPI IWineD3DVolumeTextureImpl_GetParent(IWineD3DVolumeTexture *iface)
{
TRACE("iface %p\n", iface);
return ((IWineD3DVolumeTextureImpl *)iface)->resource.parent;
}
/* ******************************************************
IWineD3DVolumeTexture IWineD3DBaseTexture parts follow
****************************************************** */
static DWORD WINAPI IWineD3DVolumeTextureImpl_SetLOD(IWineD3DVolumeTexture *iface, DWORD LODNew) {
return basetexture_set_lod((IWineD3DBaseTexture *)iface, LODNew);
}
static DWORD WINAPI IWineD3DVolumeTextureImpl_GetLOD(IWineD3DVolumeTexture *iface) {
return basetexture_get_lod((IWineD3DBaseTexture *)iface);
}
static DWORD WINAPI IWineD3DVolumeTextureImpl_GetLevelCount(IWineD3DVolumeTexture *iface) {
return basetexture_get_level_count((IWineD3DBaseTexture *)iface);
}
static HRESULT WINAPI IWineD3DVolumeTextureImpl_SetAutoGenFilterType(IWineD3DVolumeTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
return basetexture_set_autogen_filter_type((IWineD3DBaseTexture *)iface, FilterType);
}
static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DVolumeTextureImpl_GetAutoGenFilterType(IWineD3DVolumeTexture *iface) {
return basetexture_get_autogen_filter_type((IWineD3DBaseTexture *)iface);
}
static void WINAPI IWineD3DVolumeTextureImpl_GenerateMipSubLevels(IWineD3DVolumeTexture *iface) {
basetexture_generate_mipmaps((IWineD3DBaseTexture *)iface);
}
/* Internal function, No d3d mapping */
static BOOL WINAPI IWineD3DVolumeTextureImpl_SetDirty(IWineD3DVolumeTexture *iface, BOOL dirty) {
return basetexture_set_dirty((IWineD3DBaseTexture *)iface, dirty);
}
static BOOL WINAPI IWineD3DVolumeTextureImpl_GetDirty(IWineD3DVolumeTexture *iface) {
return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
}
/* Context activation is done by the caller. */
static HRESULT WINAPI IWineD3DVolumeTextureImpl_BindTexture(IWineD3DVolumeTexture *iface, BOOL srgb)
{
BOOL dummy;
TRACE("iface %p, srgb %#x.\n", iface, srgb);
return basetexture_bind((IWineD3DBaseTexture *)iface, srgb, &dummy);
}
static BOOL WINAPI IWineD3DVolumeTextureImpl_IsCondNP2(IWineD3DVolumeTexture *iface)
{
TRACE("iface %p.\n", iface);
return FALSE;
}
/* *******************************************
IWineD3DVolumeTexture IWineD3DVolumeTexture parts follow
******************************************* */
static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetLevelDesc(IWineD3DVolumeTexture *iface,
UINT level, WINED3DVOLUME_DESC *desc)
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
IWineD3DVolume *volume;
TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
if (!(volume = (IWineD3DVolume *)basetexture_get_sub_resource(texture, 0, level)))
{
WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL;
}
IWineD3DVolume_GetDesc(volume, desc);
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetVolumeLevel(IWineD3DVolumeTexture *iface,
UINT level, IWineD3DVolume **volume)
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
IWineD3DVolume *v;
TRACE("iface %p, level %u, volume %p.\n", iface, level, volume);
if (!(v = (IWineD3DVolume *)basetexture_get_sub_resource(texture, 0, level)))
{
WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL;
}
IWineD3DVolume_AddRef(v);
*volume = v;
TRACE("Returning volume %p.\n", *volume);
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DVolumeTextureImpl_LockBox(IWineD3DVolumeTexture *iface,
UINT level, WINED3DLOCKED_BOX *locked_box, const WINED3DBOX *box, DWORD flags)
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
IWineD3DVolume *volume;
TRACE("iface %p, level %u, locked_box %p, box %p, flags %#x.\n",
iface, level, locked_box, box, flags);
if (!(volume = (IWineD3DVolume *)basetexture_get_sub_resource(texture, 0, level)))
{
WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL;
}
return IWineD3DVolume_LockBox(volume, locked_box, box, flags);
}
static HRESULT WINAPI IWineD3DVolumeTextureImpl_UnlockBox(IWineD3DVolumeTexture *iface, UINT level)
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
IWineD3DVolume *volume;
TRACE("iface %p, level %u.\n", iface, level);
if (!(volume = (IWineD3DVolume *)basetexture_get_sub_resource(texture, 0, level)))
{
WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL;
}
return IWineD3DVolume_UnlockBox(volume);
}
static HRESULT WINAPI IWineD3DVolumeTextureImpl_AddDirtyBox(IWineD3DVolumeTexture *iface, const WINED3DBOX *dirty_box)
{
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
IWineD3DVolume *volume;
TRACE("iface %p, dirty_box %p.\n", iface, dirty_box);
if (!(volume = (IWineD3DVolume *)basetexture_get_sub_resource(texture, 0, 0)))
{
WARN("Failed to get sub-resource.\n");
return WINED3DERR_INVALIDCALL;
}
texture->baseTexture.texture_rgb.dirty = TRUE;
texture->baseTexture.texture_srgb.dirty = TRUE;
volume_add_dirty_box(volume, dirty_box);
return WINED3D_OK;
}
static const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl =
{
/* IUnknown */
IWineD3DVolumeTextureImpl_QueryInterface,
IWineD3DVolumeTextureImpl_AddRef,
IWineD3DVolumeTextureImpl_Release,
/* resource */
IWineD3DVolumeTextureImpl_GetParent,
IWineD3DVolumeTextureImpl_SetPrivateData,
IWineD3DVolumeTextureImpl_GetPrivateData,
IWineD3DVolumeTextureImpl_FreePrivateData,
IWineD3DVolumeTextureImpl_SetPriority,
IWineD3DVolumeTextureImpl_GetPriority,
IWineD3DVolumeTextureImpl_PreLoad,
IWineD3DVolumeTextureImpl_UnLoad,
IWineD3DVolumeTextureImpl_GetType,
/* BaseTexture */
IWineD3DVolumeTextureImpl_SetLOD,
IWineD3DVolumeTextureImpl_GetLOD,
IWineD3DVolumeTextureImpl_GetLevelCount,
IWineD3DVolumeTextureImpl_SetAutoGenFilterType,
IWineD3DVolumeTextureImpl_GetAutoGenFilterType,
IWineD3DVolumeTextureImpl_GenerateMipSubLevels,
IWineD3DVolumeTextureImpl_SetDirty,
IWineD3DVolumeTextureImpl_GetDirty,
/* not in d3d */
IWineD3DVolumeTextureImpl_BindTexture,
IWineD3DVolumeTextureImpl_IsCondNP2,
/* volume texture */
IWineD3DVolumeTextureImpl_GetLevelDesc,
IWineD3DVolumeTextureImpl_GetVolumeLevel,
IWineD3DVolumeTextureImpl_LockBox,
IWineD3DVolumeTextureImpl_UnlockBox,
IWineD3DVolumeTextureImpl_AddDirtyBox
};
HRESULT volumetexture_init(IWineD3DVolumeTextureImpl *texture, UINT width, UINT height,
UINT depth, UINT levels, IWineD3DDeviceImpl *device, DWORD usage, enum wined3d_format_id format_id,
WINED3DPOOL pool, void *parent, const struct wined3d_parent_ops *parent_ops)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
UINT tmp_w, tmp_h, tmp_d;
unsigned int i;
HRESULT hr;
/* TODO: It should only be possible to create textures for formats
* that are reported as supported. */
if (WINED3DFMT_UNKNOWN >= format_id)
{
WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
return WINED3DERR_INVALIDCALL;
}
if (!gl_info->supported[EXT_TEXTURE3D])
{
WARN("(%p) : Texture cannot be created - no volume texture support.\n", texture);
return WINED3DERR_INVALIDCALL;
}
/* Calculate levels for mip mapping. */
if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
{
if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
{
WARN("No mipmap generation support, returning D3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
if (levels > 1)
{
WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning D3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
levels = 1;
}
else if (!levels)
{
levels = wined3d_log2i(max(max(width, height), depth)) + 1;
TRACE("Calculated levels = %u.\n", levels);
}
texture->lpVtbl = &IWineD3DVolumeTexture_Vtbl;
hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, 1, levels,
WINED3DRTYPE_VOLUMETEXTURE, device, 0, usage, format, pool, parent, parent_ops);
if (FAILED(hr))
{
WARN("Failed to initialize basetexture, returning %#x.\n", hr);
return hr;
}
/* Is NP2 support for volumes needed? */
texture->baseTexture.pow2Matrix[0] = 1.0f;
texture->baseTexture.pow2Matrix[5] = 1.0f;
texture->baseTexture.pow2Matrix[10] = 1.0f;
texture->baseTexture.pow2Matrix[15] = 1.0f;
texture->baseTexture.target = GL_TEXTURE_3D;
/* Generate all the surfaces. */
tmp_w = width;
tmp_h = height;
tmp_d = depth;
for (i = 0; i < texture->baseTexture.level_count; ++i)
{
IWineD3DVolume *volume;
/* Create the volume. */
hr = IWineD3DDeviceParent_CreateVolume(device->device_parent, parent,
tmp_w, tmp_h, tmp_d, format_id, pool, usage, &volume);
if (FAILED(hr))
{
ERR("Creating a volume for the volume texture failed, hr %#x.\n", hr);
volumetexture_cleanup(texture);
return hr;
}
/* Set its container to this texture. */
volume_set_container((IWineD3DVolumeImpl *)volume, texture);
texture->baseTexture.sub_resources[i] = (IWineD3DResourceImpl *)volume;
/* Calculate the next mipmap level. */
tmp_w = max(1, tmp_w >> 1);
tmp_h = max(1, tmp_h >> 1);
tmp_d = max(1, tmp_d >> 1);
}
texture->baseTexture.internal_preload = volumetexture_internal_preload;
return WINED3D_OK;
}

View file

@ -17,11 +17,9 @@
<file>ati_fragment_shader.c</file>
<file>arb_program_shader.c</file>
<file>basetexture.c</file>
<file>buffer.c</file>
<file>clipper.c</file>
<file>context.c</file>
<file>cubetexture.c</file>
<file>device.c</file>
<file>directx.c</file>
<file>drawprim.c</file>
@ -36,18 +34,13 @@
<file>shader_sm4.c</file>
<file>state.c</file>
<file>stateblock.c</file>
<file>surface_base.c</file>
<file>surface.c</file>
<file>surface_gdi.c </file>
<file>swapchain.c</file>
<file>swapchain_base.c</file>
<file>swapchain_gdi.c</file>
<file>texture.c</file>
<file>utils.c</file>
<file>vertexdeclaration.c</file>
<file>view.c</file>
<file>volume.c</file>
<file>volumetexture.c</file>
<file>wined3d_main.c</file>
<file>version.rc</file>
<if property="ARCH" value="amd64">

View file

@ -1,4 +1,298 @@
@ stdcall WineDirect3DCreate(long ptr)
@ stdcall WineDirect3DCreateClipper()
@ stdcall wined3d_mutex_lock()
@ stdcall wined3d_mutex_unlock()
@ cdecl wined3d_check_depth_stencil_match(ptr long long long long long)
@ cdecl wined3d_check_device_format(ptr long long long long long long long)
@ cdecl wined3d_check_device_format_conversion(ptr long long long long)
@ cdecl wined3d_check_device_multisample_type(ptr long long long long long ptr)
@ cdecl wined3d_check_device_type(ptr long long long long long)
@ cdecl wined3d_create(long ptr)
@ cdecl wined3d_decref(ptr)
@ cdecl wined3d_enum_adapter_modes(ptr long long long ptr)
@ cdecl wined3d_get_adapter_count(ptr)
@ cdecl wined3d_get_adapter_display_mode(ptr long ptr)
@ cdecl wined3d_get_adapter_identifier(ptr long long ptr)
@ cdecl wined3d_get_adapter_mode_count(ptr long long)
@ cdecl wined3d_get_adapter_monitor(ptr long)
@ cdecl wined3d_get_device_caps(ptr long long ptr)
@ cdecl wined3d_get_parent(ptr)
@ cdecl wined3d_incref(ptr)
@ cdecl wined3d_register_software_device(ptr ptr)
@ cdecl wined3d_buffer_create(ptr ptr ptr ptr ptr ptr)
@ cdecl wined3d_buffer_create_ib(ptr long long long ptr ptr ptr)
@ cdecl wined3d_buffer_create_vb(ptr long long long ptr ptr ptr)
@ cdecl wined3d_buffer_decref(ptr)
@ cdecl wined3d_buffer_free_private_data(ptr ptr)
@ cdecl wined3d_buffer_get_parent(ptr)
@ cdecl wined3d_buffer_get_priority(ptr)
@ cdecl wined3d_buffer_get_private_data(ptr ptr ptr ptr)
@ cdecl wined3d_buffer_get_resource(ptr)
@ cdecl wined3d_buffer_incref(ptr)
@ cdecl wined3d_buffer_map(ptr long long ptr long)
@ cdecl wined3d_buffer_preload(ptr)
@ cdecl wined3d_buffer_set_priority(ptr long)
@ cdecl wined3d_buffer_set_private_data(ptr ptr ptr long long)
@ cdecl wined3d_buffer_unmap(ptr)
@ cdecl wined3d_clipper_create()
@ cdecl wined3d_clipper_decref(ptr)
@ cdecl wined3d_clipper_get_clip_list(ptr ptr ptr ptr)
@ cdecl wined3d_clipper_get_window(ptr ptr)
@ cdecl wined3d_clipper_incref(ptr)
@ cdecl wined3d_clipper_is_clip_list_changed(ptr ptr)
@ cdecl wined3d_clipper_set_clip_list(ptr ptr long)
@ cdecl wined3d_clipper_set_window(ptr long ptr)
@ cdecl wined3d_device_acquire_focus_window(ptr ptr)
@ cdecl wined3d_device_begin_scene(ptr)
@ cdecl wined3d_device_begin_stateblock(ptr)
@ cdecl wined3d_device_clear(ptr long ptr long long long long)
@ cdecl wined3d_device_clear_rendertarget_view(ptr ptr ptr)
@ cdecl wined3d_device_color_fill(ptr ptr ptr ptr)
@ cdecl wined3d_device_create(ptr long long ptr long ptr ptr)
@ cdecl wined3d_device_decref(ptr)
@ cdecl wined3d_device_delete_patch(ptr long)
@ cdecl wined3d_device_draw_indexed_primitive(ptr long long)
@ cdecl wined3d_device_draw_indexed_primitive_strided(ptr long ptr long ptr long)
@ cdecl wined3d_device_draw_indexed_primitive_up(ptr long ptr long ptr long)
@ cdecl wined3d_device_draw_primitive(ptr long long)
@ cdecl wined3d_device_draw_primitive_strided(ptr long ptr)
@ cdecl wined3d_device_draw_primitive_up(ptr long ptr long)
@ cdecl wined3d_device_draw_rect_patch(ptr long ptr ptr)
@ cdecl wined3d_device_draw_tri_patch(ptr long ptr ptr)
@ cdecl wined3d_device_end_scene(ptr)
@ cdecl wined3d_device_end_stateblock(ptr ptr)
@ cdecl wined3d_device_enum_resources(ptr ptr ptr)
@ cdecl wined3d_device_evict_managed_resources(ptr)
@ cdecl wined3d_device_get_available_texture_mem(ptr)
@ cdecl wined3d_device_get_back_buffer(ptr long long long ptr)
@ cdecl wined3d_device_get_base_vertex_index(ptr)
@ cdecl wined3d_device_get_clip_plane(ptr long ptr)
@ cdecl wined3d_device_get_clip_status(ptr ptr)
@ cdecl wined3d_device_get_creation_parameters(ptr ptr)
@ cdecl wined3d_device_get_current_texture_palette(ptr ptr)
@ cdecl wined3d_device_get_depth_stencil(ptr ptr)
@ cdecl wined3d_device_get_device_caps(ptr ptr)
@ cdecl wined3d_device_get_display_mode(ptr long ptr)
@ cdecl wined3d_device_get_front_buffer_data(ptr long ptr)
@ cdecl wined3d_device_get_gamma_ramp(ptr long ptr)
@ cdecl wined3d_device_get_index_buffer(ptr ptr)
@ cdecl wined3d_device_get_light(ptr long ptr)
@ cdecl wined3d_device_get_light_enable(ptr long ptr)
@ cdecl wined3d_device_get_material(ptr ptr)
@ cdecl wined3d_device_get_npatch_mode(ptr)
@ cdecl wined3d_device_get_palette_entries(ptr long ptr)
@ cdecl wined3d_device_get_pixel_shader(ptr)
@ cdecl wined3d_device_get_primitive_type(ptr ptr)
@ cdecl wined3d_device_get_ps_consts_b(ptr long ptr long)
@ cdecl wined3d_device_get_ps_consts_f(ptr long ptr long)
@ cdecl wined3d_device_get_ps_consts_i(ptr long ptr long)
@ cdecl wined3d_device_get_raster_status(ptr long ptr)
@ cdecl wined3d_device_get_render_state(ptr long ptr)
@ cdecl wined3d_device_get_render_target(ptr long ptr)
@ cdecl wined3d_device_get_sampler_state(ptr long long ptr)
@ cdecl wined3d_device_get_scissor_rect(ptr ptr)
@ cdecl wined3d_device_get_software_vertex_processing(ptr)
@ cdecl wined3d_device_get_stream_source(ptr long ptr ptr ptr)
@ cdecl wined3d_device_get_stream_source_freq(ptr long ptr)
@ cdecl wined3d_device_get_surface_from_dc(ptr ptr ptr)
@ cdecl wined3d_device_get_swapchain(ptr long ptr)
@ cdecl wined3d_device_get_swapchain_count(ptr)
@ cdecl wined3d_device_get_texture(ptr long ptr)
@ cdecl wined3d_device_get_texture_stage_state(ptr long long ptr)
@ cdecl wined3d_device_get_transform(ptr long ptr)
@ cdecl wined3d_device_get_vertex_declaration(ptr ptr)
@ cdecl wined3d_device_get_vertex_shader(ptr)
@ cdecl wined3d_device_get_viewport(ptr ptr)
@ cdecl wined3d_device_get_vs_consts_b(ptr long ptr long)
@ cdecl wined3d_device_get_vs_consts_f(ptr long ptr long)
@ cdecl wined3d_device_get_vs_consts_i(ptr long ptr long)
@ cdecl wined3d_device_get_wined3d(ptr ptr)
@ cdecl wined3d_device_incref(ptr)
@ cdecl wined3d_device_init_3d(ptr ptr)
@ cdecl wined3d_device_init_gdi(ptr ptr)
@ cdecl wined3d_device_multiply_transform(ptr long ptr)
@ cdecl wined3d_device_present(ptr ptr ptr ptr ptr)
@ cdecl wined3d_device_process_vertices(ptr long long long ptr ptr long long)
@ cdecl wined3d_device_release_focus_window(ptr)
@ cdecl wined3d_device_reset(ptr ptr)
@ cdecl wined3d_device_restore_fullscreen_window(ptr ptr)
@ cdecl wined3d_device_set_base_vertex_index(ptr long)
@ cdecl wined3d_device_set_clip_plane(ptr long ptr)
@ cdecl wined3d_device_set_clip_status(ptr ptr)
@ cdecl wined3d_device_set_current_texture_palette(ptr long)
@ cdecl wined3d_device_set_cursor_position(ptr long long long)
@ cdecl wined3d_device_set_cursor_properties(ptr long long ptr)
@ cdecl wined3d_device_set_depth_stencil(ptr ptr)
@ cdecl wined3d_device_set_dialog_box_mode(ptr long)
@ cdecl wined3d_device_set_display_mode(ptr long ptr)
@ cdecl wined3d_device_set_gamma_ramp(ptr long long ptr)
@ cdecl wined3d_device_set_index_buffer(ptr ptr long)
@ cdecl wined3d_device_set_light(ptr long ptr)
@ cdecl wined3d_device_set_light_enable(ptr long long)
@ cdecl wined3d_device_set_material(ptr ptr)
@ cdecl wined3d_device_set_multithreaded(ptr)
@ cdecl wined3d_device_set_npatch_mode(ptr long)
@ cdecl wined3d_device_set_palette_entries(ptr long ptr)
@ cdecl wined3d_device_set_pixel_shader(ptr ptr)
@ cdecl wined3d_device_set_primitive_type(ptr long)
@ cdecl wined3d_device_set_ps_consts_b(ptr long ptr long)
@ cdecl wined3d_device_set_ps_consts_f(ptr long ptr long)
@ cdecl wined3d_device_set_ps_consts_i(ptr long ptr long)
@ cdecl wined3d_device_set_render_state(ptr long long)
@ cdecl wined3d_device_set_render_target(ptr long ptr long)
@ cdecl wined3d_device_set_sampler_state(ptr long long long)
@ cdecl wined3d_device_set_scissor_rect(ptr ptr)
@ cdecl wined3d_device_set_software_vertex_processing(ptr long)
@ cdecl wined3d_device_set_stream_source(ptr long ptr long long)
@ cdecl wined3d_device_set_stream_source_freq(ptr long long)
@ cdecl wined3d_device_set_texture(ptr long ptr)
@ cdecl wined3d_device_set_texture_stage_state(ptr long long long)
@ cdecl wined3d_device_set_transform(ptr long ptr)
@ cdecl wined3d_device_set_vertex_declaration(ptr ptr)
@ cdecl wined3d_device_set_vertex_shader(ptr ptr)
@ cdecl wined3d_device_set_viewport(ptr ptr)
@ cdecl wined3d_device_set_vs_consts_b(ptr long ptr long)
@ cdecl wined3d_device_set_vs_consts_f(ptr long ptr long)
@ cdecl wined3d_device_set_vs_consts_i(ptr long ptr long)
@ cdecl wined3d_device_setup_fullscreen_window(ptr ptr long long)
@ cdecl wined3d_device_show_cursor(ptr long)
@ cdecl wined3d_device_uninit_3d(ptr)
@ cdecl wined3d_device_uninit_gdi(ptr)
@ cdecl wined3d_device_update_surface(ptr ptr ptr ptr ptr)
@ cdecl wined3d_device_update_texture(ptr ptr ptr)
@ cdecl wined3d_device_validate_device(ptr ptr)
@ cdecl wined3d_palette_create(ptr long ptr ptr ptr)
@ cdecl wined3d_palette_decref(ptr)
@ cdecl wined3d_palette_get_entries(ptr long long long ptr)
@ cdecl wined3d_palette_get_flags(ptr)
@ cdecl wined3d_palette_get_parent(ptr)
@ cdecl wined3d_palette_incref(ptr)
@ cdecl wined3d_palette_set_entries(ptr long long long ptr)
@ cdecl wined3d_query_create(ptr long ptr)
@ cdecl wined3d_query_decref(ptr)
@ cdecl wined3d_query_get_data(ptr ptr long long)
@ cdecl wined3d_query_get_data_size(ptr)
@ cdecl wined3d_query_get_type(ptr)
@ cdecl wined3d_query_incref(ptr)
@ cdecl wined3d_query_issue(ptr long)
@ cdecl wined3d_resource_get_desc(ptr ptr)
@ cdecl wined3d_resource_get_parent(ptr)
@ cdecl wined3d_rendertarget_view_create(ptr ptr ptr)
@ cdecl wined3d_rendertarget_view_decref(ptr)
@ cdecl wined3d_rendertarget_view_get_parent(ptr)
@ cdecl wined3d_rendertarget_view_get_resource(ptr)
@ cdecl wined3d_rendertarget_view_incref(ptr)
@ cdecl wined3d_shader_create_gs(ptr ptr ptr ptr ptr ptr)
@ cdecl wined3d_shader_create_ps(ptr ptr ptr ptr ptr ptr)
@ cdecl wined3d_shader_create_vs(ptr ptr ptr ptr ptr ptr)
@ cdecl wined3d_shader_decref(ptr)
@ cdecl wined3d_shader_get_byte_code(ptr ptr ptr)
@ cdecl wined3d_shader_get_parent(ptr)
@ cdecl wined3d_shader_incref(ptr)
@ cdecl wined3d_shader_set_local_constants_float(ptr long ptr long)
@ cdecl wined3d_stateblock_apply(ptr)
@ cdecl wined3d_stateblock_capture(ptr)
@ cdecl wined3d_stateblock_create(ptr long ptr)
@ cdecl wined3d_stateblock_decref(ptr)
@ cdecl wined3d_stateblock_incref(ptr)
@ cdecl wined3d_surface_blt(ptr ptr ptr ptr long ptr long)
@ cdecl wined3d_surface_bltfast(ptr long long ptr ptr long)
@ cdecl wined3d_surface_create(ptr long long long long long long long long long long long ptr ptr ptr)
@ cdecl wined3d_surface_decref(ptr)
@ cdecl wined3d_surface_flip(ptr ptr long)
@ cdecl wined3d_surface_free_private_data(ptr ptr)
@ cdecl wined3d_surface_get_blt_status(ptr long)
@ cdecl wined3d_surface_get_clipper(ptr)
@ cdecl wined3d_surface_get_flip_status(ptr long)
@ cdecl wined3d_surface_get_overlay_position(ptr ptr ptr)
@ cdecl wined3d_surface_get_palette(ptr)
@ cdecl wined3d_surface_get_parent(ptr)
@ cdecl wined3d_surface_get_pitch(ptr)
@ cdecl wined3d_surface_get_priority(ptr)
@ cdecl wined3d_surface_get_private_data(ptr ptr ptr ptr)
@ cdecl wined3d_surface_get_resource(ptr)
@ cdecl wined3d_surface_getdc(ptr ptr)
@ cdecl wined3d_surface_incref(ptr)
@ cdecl wined3d_surface_is_lost(ptr)
@ cdecl wined3d_surface_map(ptr ptr ptr long)
@ cdecl wined3d_surface_preload(ptr)
@ cdecl wined3d_surface_releasedc(ptr ptr)
@ cdecl wined3d_surface_restore(ptr)
@ cdecl wined3d_surface_set_clipper(ptr ptr)
@ cdecl wined3d_surface_set_color_key(ptr long ptr)
@ cdecl wined3d_surface_set_format(ptr long)
@ cdecl wined3d_surface_set_mem(ptr ptr)
@ cdecl wined3d_surface_set_overlay_position(ptr long long)
@ cdecl wined3d_surface_set_palette(ptr ptr)
@ cdecl wined3d_surface_set_priority(ptr long)
@ cdecl wined3d_surface_set_private_data(ptr ptr ptr long long)
@ cdecl wined3d_surface_unmap(ptr)
@ cdecl wined3d_surface_update_overlay(ptr ptr ptr ptr long ptr)
@ cdecl wined3d_surface_update_overlay_z_order(ptr long ptr)
@ cdecl wined3d_swapchain_create(ptr ptr long ptr ptr ptr)
@ cdecl wined3d_swapchain_decref(ptr)
@ cdecl wined3d_swapchain_get_back_buffer(ptr long long ptr)
@ cdecl wined3d_swapchain_get_device(ptr)
@ cdecl wined3d_swapchain_get_display_mode(ptr ptr)
@ cdecl wined3d_swapchain_get_front_buffer_data(ptr ptr)
@ cdecl wined3d_swapchain_get_gamma_ramp(ptr ptr)
@ cdecl wined3d_swapchain_get_parent(ptr)
@ cdecl wined3d_swapchain_get_present_parameters(ptr ptr)
@ cdecl wined3d_swapchain_get_raster_status(ptr ptr)
@ cdecl wined3d_swapchain_incref(ptr)
@ cdecl wined3d_swapchain_present(ptr ptr ptr ptr ptr long)
@ cdecl wined3d_swapchain_set_gamma_ramp(ptr long ptr)
@ cdecl wined3d_swapchain_set_window(ptr ptr)
@ cdecl wined3d_texture_add_dirty_region(ptr long ptr)
@ cdecl wined3d_texture_create_2d(ptr long long long long long long ptr ptr ptr)
@ cdecl wined3d_texture_create_3d(ptr long long long long long long long ptr ptr ptr)
@ cdecl wined3d_texture_create_cube(ptr long long long long long ptr ptr ptr)
@ cdecl wined3d_texture_decref(ptr)
@ cdecl wined3d_texture_free_private_data(ptr ptr)
@ cdecl wined3d_texture_generate_mipmaps(ptr)
@ cdecl wined3d_texture_get_autogen_filter_type(ptr)
@ cdecl wined3d_texture_get_level_count(ptr)
@ cdecl wined3d_texture_get_lod(ptr)
@ cdecl wined3d_texture_get_parent(ptr)
@ cdecl wined3d_texture_get_priority(ptr)
@ cdecl wined3d_texture_get_private_data(ptr ptr ptr ptr)
@ cdecl wined3d_texture_get_sub_resource(ptr long)
@ cdecl wined3d_texture_get_type(ptr)
@ cdecl wined3d_texture_incref(ptr)
@ cdecl wined3d_texture_preload(ptr)
@ cdecl wined3d_texture_set_autogen_filter_type(ptr long)
@ cdecl wined3d_texture_set_lod(ptr long)
@ cdecl wined3d_texture_set_priority(ptr long)
@ cdecl wined3d_texture_set_private_data(ptr ptr ptr long long)
@ cdecl wined3d_vertex_declaration_create(ptr ptr long ptr ptr ptr)
@ cdecl wined3d_vertex_declaration_create_from_fvf(ptr long ptr ptr ptr)
@ cdecl wined3d_vertex_declaration_decref(ptr)
@ cdecl wined3d_vertex_declaration_get_parent(ptr)
@ cdecl wined3d_vertex_declaration_incref(ptr)
@ cdecl wined3d_volume_create(ptr long long long long long long ptr ptr ptr)
@ cdecl wined3d_volume_decref(ptr)
@ cdecl wined3d_volume_free_private_data(ptr ptr)
@ cdecl wined3d_volume_from_resource(ptr)
@ cdecl wined3d_volume_get_parent(ptr)
@ cdecl wined3d_volume_get_priority(ptr)
@ cdecl wined3d_volume_get_private_data(ptr ptr ptr ptr)
@ cdecl wined3d_volume_get_resource(ptr)
@ cdecl wined3d_volume_incref(ptr)
@ cdecl wined3d_volume_map(ptr ptr ptr long)
@ cdecl wined3d_volume_preload(ptr)
@ cdecl wined3d_volume_set_priority(ptr long)
@ cdecl wined3d_volume_set_private_data(ptr ptr ptr long long)
@ cdecl wined3d_volume_unmap(ptr)

View file

@ -1744,7 +1744,6 @@ typedef enum wined3d_gl_extension
ARB_GEOMETRY_SHADER4,
ARB_HALF_FLOAT_PIXEL,
ARB_HALF_FLOAT_VERTEX,
ARB_IMAGING,
ARB_MAP_BUFFER_RANGE,
ARB_MULTISAMPLE,
ARB_MULTITEXTURE,
@ -1786,6 +1785,7 @@ typedef enum wined3d_gl_extension
EXT_BLEND_EQUATION_SEPARATE,
EXT_BLEND_FUNC_SEPARATE,
EXT_BLEND_MINMAX,
EXT_BLEND_SUBTRACT,
EXT_DRAW_BUFFERS2,
EXT_DEPTH_BOUNDS_TEST,
EXT_FOG_COORD,
@ -1810,6 +1810,7 @@ typedef enum wined3d_gl_extension
EXT_TEXTURE_FILTER_ANISOTROPIC,
EXT_TEXTURE_LOD_BIAS,
EXT_TEXTURE_SRGB,
EXT_TEXTURE_SRGB_DECODE,
EXT_VERTEX_ARRAY_BGRA,
/* NVIDIA */
NV_DEPTH_CLAMP,
@ -1834,9 +1835,9 @@ typedef enum wined3d_gl_extension
NV_VERTEX_PROGRAM3,
/* SGI */
SGIS_GENERATE_MIPMAP,
SGI_VIDEO_SYNC,
/* WGL extensions */
WGL_ARB_PIXEL_FORMAT,
WGL_EXT_SWAP_CONTROL,
WGL_WINE_PIXEL_FORMAT_PASSTHROUGH,
/* Internally used */
WINED3D_GL_NORMALIZED_TEXRECT,
@ -2146,88 +2147,6 @@ typedef void (WINE_GLAPI *PGLFNFRAMEBUFFERTEXTUREFACEARBPROC)(GLenum target, GLe
#define GL_HALF_FLOAT 0x140b
#endif
/* GL_ARB_imaging */
#ifndef GL_ARB_imaging
#define GL_ARB_imaging 1
#define GL_CONSTANT_COLOR 0x8001
#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
#define GL_CONSTANT_ALPHA 0x8003
#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
#define GL_BLEND_COLOR 0x8005
#define GL_FUNC_ADD 0x8006
#define GL_MIN 0x8007
#define GL_MAX 0x8008
#define GL_BLEND_EQUATION 0x8009
#define GL_FUNC_SUBTRACT 0x800a
#define GL_FUNC_REVERSE_SUBTRACT 0x800b
#define GL_CONVOLUTION_1D 0x8010
#define GL_CONVOLUTION_2D 0x8011
#define GL_SEPARABLE_2D 0x8012
#define GL_CONVOLUTION_BORDER_MODE 0x8013
#define GL_CONVOLUTION_FILTER_SCALE 0x8014
#define GL_CONVOLUTION_FILTER_BIAS 0x8015
#define GL_REDUCE 0x8016
#define GL_CONVOLUTION_FORMAT 0x8017
#define GL_CONVOLUTION_WIDTH 0x8018
#define GL_CONVOLUTION_HEIGHT 0x8019
#define GL_MAX_CONVOLUTION_WIDTH 0x801a
#define GL_MAX_CONVOLUTION_HEIGHT 0x801b
#define GL_POST_CONVOLUTION_RED_SCALE 0x801d
#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801f
#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801e
#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801f
#define GL_POST_CONVOLUTION_RED_BIAS 0x8020
#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021
#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022
#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023
#define GL_HISTOGRAM 0x8024
#define GL_PROXY_HISTOGRAM 0x8025
#define GL_HISTOGRAM_WIDTH 0x8026
#define GL_HISTOGRAM_FORMAT 0x8027
#define GL_HISTOGRAM_RED_SIZE 0x8028
#define GL_HISTOGRAM_GREEN_SIZE 0x8029
#define GL_HISTOGRAM_BLUE_SIZE 0x802a
#define GL_HISTOGRAM_ALPHA_SIZE 0x802b
#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802c
#define GL_HISTOGRAM_SINK 0x802d
#define GL_MINMAX 0x802e
#define GL_MINMAX_FORMAT 0x802f
#define GL_MINMAX_SINK 0x8030
#define GL_TABLE_TOO_LARGE 0x8031
#define GL_COLOR_MATRIX 0x80b1
#define GL_COLOR_MATRIX_STACK_DEPTH 0x80b2
#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80b3
#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80b4
#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80b5
#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80b6
#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80b7
#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80b8
#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80b9
#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80ba
#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80bb
#define GL_COLOR_TABLE 0x80d0
#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80d1
#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80d2
#define GL_PROXY_COLOR_TABLE 0x80d3
#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80d4
#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80d5
#define GL_COLOR_TABLE_SCALE 0x80d6
#define GL_COLOR_TABLE_BIAS 0x80d7
#define GL_COLOR_TABLE_FORMAT 0x80d8
#define GL_COLOR_TABLE_WIDTH 0x80d9
#define GL_COLOR_TABLE_RED_SIZE 0x80da
#define GL_COLOR_TABLE_GREEN_SIZE 0x80db
#define GL_COLOR_TABLE_BLUE_SIZE 0x80dc
#define GL_COLOR_TABLE_ALPHA_SIZE 0x80dd
#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80de
#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80df
#define GL_CONSTANT_BORDER 0x8151
#define GL_REPLICATE_BORDER 0x8153
#define GL_CONVOLUTION_BORDER_COLOR 0x8154
#endif
typedef void (WINE_GLAPI *PGLFNBLENDCOLORPROC)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONPROC)(GLenum mode);
/* GL_ARB_map_buffer_range */
#ifndef GL_ARB_map_buffer_range
#define GL_ARB_map_buffer_range 1
@ -2969,6 +2888,18 @@ typedef void (WINE_GLAPI *PGLFNSTENCILFUNCSEPARATEATIPROC)(GLenum, GLenum, GLint
#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743
#endif
/* GL_EXT_blend_color */
#ifndef GL_EXT_blend_color
#define GL_EXT_blend_color 1
#define GL_CONSTANT_COLOR_EXT 0x8001
#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002
#define GL_CONSTANT_ALPHA_EXT 0x8003
#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004
#define GL_BLEND_COLOR_EXT 0x8005
#endif
typedef GLvoid (WINE_GLAPI *PGLFNBLENDCOLOREXTPROC)(GLclampf red,
GLclampf green, GLclampf blue, GLclampf alpha);
/* GL_EXT_blend_equation_separate */
typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONSEPARATEEXTPROC)(GLenum modeRGB, GLenum modeAlpha);
@ -2983,6 +2914,23 @@ typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONSEPARATEEXTPROC)(GLenum modeRGB, GLe
typedef void (WINE_GLAPI *PGLFNBLENDFUNCSEPARATEEXTPROC)(GLenum sfactorRGB, GLenum dfactorRGB,
GLenum sfactorAlpha, GLenum dfactorAlpha);
/* GL_EXT_blend_minmax */
#ifndef GL_EXT_blend_minmax
#define GL_EXT_blend_minmax 1
#define GL_FUNC_ADD_EXT 0x8006
#define GL_MIN_EXT 0x8007
#define GL_MAX_EXT 0x8008
#define GL_BLEND_EQUATION_EXT 0x8009
#endif
typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONEXTPROC)(GLenum mode);
/* GL_EXT_blend_subtract */
#ifndef GL_EXT_blend_subtract
#define GL_EXT_blend_subtract 1
#define GL_FUNC_SUBTRACT_EXT 0x800a
#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800b
#endif
/* GL_EXT_depth_bounds_test */
#ifndef GL_EXT_depth_bounds_test
#define GL_EXT_depth_bounds_test 1
@ -3412,6 +3360,14 @@ typedef void (WINE_GLAPI *PGLFNGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint l
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8c4f
#endif
/* GL_EXT_texture_sRGB_decode */
#ifndef GL_EXT_texture_sRGB_decode
#define GL_EXT_texture_sRGB_decode 1
#define GL_TEXTURE_SRGB_DECODE_EXT 0x8a48
#define GL_DECODE_EXT 0x8a49
#define GL_SKIP_DECODE_EXT 0x8a4a
#endif
/* GL_NV_depth_clamp */
#ifndef GL_NV_depth_clamp
#define GL_NV_depth_clamp 1
@ -3711,16 +3667,12 @@ typedef void (WINE_GLAPI *PGLFNGETCOMBINERSTAGEPARAMETERFVNVPROC)(GLenum stage,
#endif
/* GL_SGIS_generate_mipmap */
#ifndef GLX_SGIS_generate_mipmap
#define GLX_SGIS_generate_mipmap 1
#ifndef GL_SGIS_generate_mipmap
#define GL_SGIS_generate_mipmap 1
#define GL_GENERATE_MIPMAP_SGIS 0x8191
#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192
#endif
/* GLX_SGI_video_sync */
typedef int (WINE_GLAPI *PGLXFNGETVIDEOSYNCSGIPROC)(unsigned int *);
typedef int (WINE_GLAPI *PGLXFNWAITVIDEOSYNCSGIPROC)(int, int, unsigned int *);
/* WGL_ARB_extensions_string */
typedef const char *(WINAPI *WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC hdc);
@ -3801,6 +3753,8 @@ typedef BOOL (WINAPI *WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC)(HDC hdc, const int
typedef BOOL (WINAPI *WINED3D_PFNWGLSETPIXELFORMATWINE)(HDC hdc, int iPixelFormat,
const PIXELFORMATDESCRIPTOR *ppfd);
typedef BOOL (WINAPI *WINED3D_PFNWGLSWAPINTERVALEXTPROC)(int interval);
#define GL_EXT_FUNCS_GEN \
/* GL_APPLE_fence */ \
USE_GL_FUNC(PGLFNGENFENCESAPPLEPROC, \
@ -3885,11 +3839,6 @@ typedef BOOL (WINAPI *WINED3D_PFNWGLSETPIXELFORMATWINE)(HDC hdc, int iPixelForma
glFramebufferTextureLayerARB, ARB_GEOMETRY_SHADER4, NULL) \
USE_GL_FUNC(PGLFNFRAMEBUFFERTEXTUREFACEARBPROC, \
glFramebufferTextureFaceARB, ARB_GEOMETRY_SHADER4, NULL) \
/* GL_ARB_imaging, GL_EXT_blend_minmax */ \
USE_GL_FUNC(PGLFNBLENDCOLORPROC, \
glBlendColorEXT, EXT_BLEND_COLOR, NULL) \
USE_GL_FUNC(PGLFNBLENDEQUATIONPROC, \
glBlendEquationEXT, EXT_BLEND_MINMAX, NULL) \
/* GL_ARB_map_buffer_range */ \
USE_GL_FUNC(PGLFNMAPBUFFERRANGEPROC, \
glMapBufferRange, ARB_MAP_BUFFER_RANGE, NULL) \
@ -4224,12 +4173,18 @@ typedef BOOL (WINAPI *WINED3D_PFNWGLSETPIXELFORMATWINE)(HDC hdc, int iPixelForma
glStencilOpSeparateATI, ATI_SEPARATE_STENCIL, NULL) \
USE_GL_FUNC(PGLFNSTENCILFUNCSEPARATEATIPROC, \
glStencilFuncSeparateATI, ATI_SEPARATE_STENCIL, NULL) \
/* GL_EXT_blend_color */ \
USE_GL_FUNC(PGLFNBLENDCOLOREXTPROC, \
glBlendColorEXT, EXT_BLEND_COLOR, NULL) \
/* GL_EXT_blend_equation_separate */ \
USE_GL_FUNC(PGLFNBLENDFUNCSEPARATEEXTPROC, \
glBlendFuncSeparateEXT, EXT_BLEND_FUNC_SEPARATE, NULL) \
/* GL_EXT_blend_func_separate */ \
USE_GL_FUNC(PGLFNBLENDEQUATIONSEPARATEEXTPROC, \
glBlendEquationSeparateEXT, EXT_BLEND_EQUATION_SEPARATE, NULL) \
/* GL_EXT_blend_minmax */ \
USE_GL_FUNC(PGLFNBLENDEQUATIONEXTPROC, \
glBlendEquationEXT, EXT_BLEND_MINMAX, NULL) \
/* GL_EXT_depth_bounds_test */ \
USE_GL_FUNC(PGLFNDEPTHBOUNDSEXTPROC, \
glDepthBoundsEXT, EXT_DEPTH_BOUNDS_TEST, NULL) \
@ -4530,17 +4485,13 @@ typedef BOOL (WINAPI *WINED3D_PFNWGLSETPIXELFORMATWINE)(HDC hdc, int iPixelForma
glCombinerParameterivNV, NV_REGISTER_COMBINERS, NULL) \
USE_GL_FUNC(PGLFNFINALCOMBINERINPUTNVPROC, \
glFinalCombinerInputNV, NV_REGISTER_COMBINERS, NULL) \
/* GLX_SGI_video_sync */ \
USE_GL_FUNC(PGLXFNGETVIDEOSYNCSGIPROC, \
glXGetVideoSyncSGI, SGI_VIDEO_SYNC, NULL) \
USE_GL_FUNC(PGLXFNWAITVIDEOSYNCSGIPROC, \
glXWaitVideoSyncSGI, SGI_VIDEO_SYNC, NULL)
#define WGL_EXT_FUNCS_GEN \
USE_GL_FUNC(WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC, wglGetExtensionsStringARB, 0, NULL) \
USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBIVARBPROC, wglGetPixelFormatAttribivARB, 0, NULL) \
USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBFVARBPROC, wglGetPixelFormatAttribfvARB, 0, NULL) \
USE_GL_FUNC(WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC, wglChoosePixelFormatARB, 0, NULL) \
USE_GL_FUNC(WINED3D_PFNWGLSETPIXELFORMATWINE, wglSetPixelFormatWINE, 0, NULL)
USE_GL_FUNC(WINED3D_PFNWGLSETPIXELFORMATWINE, wglSetPixelFormatWINE, 0, NULL) \
USE_GL_FUNC(WINED3D_PFNWGLSWAPINTERVALEXTPROC, wglSwapIntervalEXT, 0, NULL)
#endif /* __WINE_WINED3D_GL */

View file

@ -32,8 +32,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d);
struct wined3d_wndproc
{
HWND window;
BOOL unicode;
WNDPROC proc;
IWineD3DDeviceImpl *device;
struct wined3d_device *device;
};
struct wined3d_wndproc_table
@ -61,7 +62,7 @@ static CRITICAL_SECTION wined3d_cs = {&wined3d_cs_debug, -1, 0, 0, 0, 0};
/* When updating default value here, make sure to update winecfg as well,
* where appropriate. */
wined3d_settings_t wined3d_settings =
struct wined3d_settings wined3d_settings =
{
VS_HW, /* Hardware by default */
PS_HW, /* Hardware by default */
@ -77,9 +78,9 @@ wined3d_settings_t wined3d_settings =
};
/* Do not call while under the GL lock. */
IWineD3D * WINAPI WineDirect3DCreate(UINT version, void *parent)
struct wined3d * CDECL wined3d_create(UINT version, void *parent)
{
IWineD3DImpl *object;
struct wined3d *object;
HRESULT hr;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
@ -99,7 +100,7 @@ IWineD3D * WINAPI WineDirect3DCreate(UINT version, void *parent)
TRACE("Created wined3d object %p for d3d%d support.\n", object, version);
return (IWineD3D *)object;
return object;
}
static DWORD get_config_key(HKEY defkey, HKEY appkey, const char *name, char *buffer, DWORD size)
@ -354,8 +355,13 @@ static BOOL wined3d_dll_destroy(HINSTANCE hInstDLL)
for (i = 0; i < wndproc_table.count; ++i)
{
struct wined3d_wndproc *entry = &wndproc_table.entries[i];
SetWindowLongPtrW(entry->window, GWLP_WNDPROC, (LONG_PTR)entry->proc);
/* Trying to unregister these would be futile. These entries can only
* exist if either we skipped them in wined3d_unregister_window() due
* to the application replacing the wndproc after the entry was
* registered, or if the application still has an active wined3d
* device. In the latter case the application has bigger problems than
* these entries. */
WARN("Leftover wndproc table entry %p.\n", &wndproc_table.entries[i]);
}
HeapFree(GetProcessHeap(), 0, wndproc_table.entries);
@ -393,7 +399,8 @@ static struct wined3d_wndproc *wined3d_find_wndproc(HWND window)
static LRESULT CALLBACK wined3d_wndproc(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
{
struct wined3d_wndproc *entry;
IWineD3DDeviceImpl *device;
struct wined3d_device *device;
BOOL unicode;
WNDPROC proc;
wined3d_mutex_lock();
@ -407,18 +414,26 @@ static LRESULT CALLBACK wined3d_wndproc(HWND window, UINT message, WPARAM wparam
}
device = entry->device;
unicode = entry->unicode;
proc = entry->proc;
wined3d_mutex_unlock();
return device_process_message(device, window, message, wparam, lparam, proc);
return device_process_message(device, window, unicode, message, wparam, lparam, proc);
}
BOOL wined3d_register_window(HWND window, IWineD3DDeviceImpl *device)
BOOL wined3d_register_window(HWND window, struct wined3d_device *device)
{
struct wined3d_wndproc *entry;
wined3d_mutex_lock();
if (wined3d_find_wndproc(window))
{
wined3d_mutex_unlock();
WARN("Window %p is already registered with wined3d.\n", window);
return TRUE;
}
if (wndproc_table.size == wndproc_table.count)
{
unsigned int new_size = max(1, wndproc_table.size * 2);
@ -440,7 +455,14 @@ BOOL wined3d_register_window(HWND window, IWineD3DDeviceImpl *device)
entry = &wndproc_table.entries[wndproc_table.count++];
entry->window = window;
entry->proc = (WNDPROC)SetWindowLongPtrW(window, GWLP_WNDPROC, (LONG_PTR)wined3d_wndproc);
entry->unicode = IsWindowUnicode(window);
/* Set a window proc that matches the window. Some applications (e.g. NoX)
* replace the window proc after we've set ours, and expect to be able to
* call the previous one (ours) directly, without using CallWindowProc(). */
if (entry->unicode)
entry->proc = (WNDPROC)SetWindowLongPtrW(window, GWLP_WNDPROC, (LONG_PTR)wined3d_wndproc);
else
entry->proc = (WNDPROC)SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)wined3d_wndproc);
entry->device = device;
wined3d_mutex_unlock();
@ -450,27 +472,49 @@ BOOL wined3d_register_window(HWND window, IWineD3DDeviceImpl *device)
void wined3d_unregister_window(HWND window)
{
unsigned int i;
struct wined3d_wndproc *entry, *last;
LONG_PTR proc;
wined3d_mutex_lock();
for (i = 0; i < wndproc_table.count; ++i)
if (!(entry = wined3d_find_wndproc(window)))
{
if (wndproc_table.entries[i].window == window)
wined3d_mutex_unlock();
ERR("Window %p is not registered with wined3d.\n", window);
return;
}
if (entry->unicode)
{
proc = GetWindowLongPtrW(window, GWLP_WNDPROC);
if (proc != (LONG_PTR)wined3d_wndproc)
{
struct wined3d_wndproc *entry = &wndproc_table.entries[i];
struct wined3d_wndproc *last = &wndproc_table.entries[--wndproc_table.count];
if (GetWindowLongPtrW(window, GWLP_WNDPROC) == (LONG_PTR)wined3d_wndproc)
SetWindowLongPtrW(window, GWLP_WNDPROC, (LONG_PTR)entry->proc);
if (entry != last) *entry = *last;
wined3d_mutex_unlock();
WARN("Not unregistering window %p, window proc %#lx doesn't match wined3d window proc %p.\n",
window, proc, wined3d_wndproc);
return;
}
}
wined3d_mutex_unlock();
ERR("Window %p is not registered with wined3d.\n", window);
SetWindowLongPtrW(window, GWLP_WNDPROC, (LONG_PTR)entry->proc);
}
else
{
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
if (proc != (LONG_PTR)wined3d_wndproc)
{
wined3d_mutex_unlock();
WARN("Not unregistering window %p, window proc %#lx doesn't match wined3d window proc %p.\n",
window, proc, wined3d_wndproc);
return;
}
SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)entry->proc);
}
last = &wndproc_table.entries[--wndproc_table.count];
if (entry != last) *entry = *last;
wined3d_mutex_unlock();
}
/* At process attach */

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,8 @@
add_idl_headers(wineheaders itss.idl wined3d.idl)
add_idl_headers(wineheaders itss.idl)
add_idl_headers(winesdk epm.idl irot.idl)
add_rpc_library(epmrpc epm.idl)
add_rpc_library(irotrpc irot.idl)
add_iid_library(wined3d_guid wined3d.idl)
add_iid_library(itss_guid itss.idl)

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -2,5 +2,4 @@
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
<module name="wineheaders" type="idlheader">
<file>itss.idl</file>
<file>wined3d.idl</file>
</module>