diff --git a/reactos/dll/directx/wine/d3d8/buffer.c b/reactos/dll/directx/wine/d3d8/buffer.c
index f7dc12d8f60..8cf55311ba9 100644
--- a/reactos/dll/directx/wine/d3d8/buffer.c
+++ b/reactos/dll/directx/wine/d3d8/buffer.c
@@ -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;
diff --git a/reactos/dll/directx/wine/d3d8/cubetexture.c b/reactos/dll/directx/wine/d3d8/cubetexture.c
index b9b411a1156..5915c54e730 100644
--- a/reactos/dll/directx/wine/d3d8/cubetexture.c
+++ b/reactos/dll/directx/wine/d3d8/cubetexture.c
@@ -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;
diff --git a/reactos/dll/directx/wine/d3d8/d3d8_main.c b/reactos/dll/directx/wine/d3d8/d3d8_main.c
index 6cefe574d19..7a25a93c928 100644
--- a/reactos/dll/directx/wine/d3d8/d3d8_main.c
+++ b/reactos/dll/directx/wine/d3d8/d3d8_main.c
@@ -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 */
diff --git a/reactos/dll/directx/wine/d3d8/d3d8_private.h b/reactos/dll/directx/wine/d3d8/d3d8_private.h
index 7e896671922..914dec58357 100644
--- a/reactos/dll/directx/wine/d3d8/d3d8_private.h
+++ b/reactos/dll/directx/wine/d3d8/d3d8_private.h
@@ -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 */
diff --git a/reactos/dll/directx/wine/d3d8/device.c b/reactos/dll/directx/wine/d3d8/device.c
index f54f043e006..aa85c61c398 100644
--- a/reactos/dll/directx/wine/d3d8/device.c
+++ b/reactos/dll/directx/wine/d3d8/device.c
@@ -254,20 +254,15 @@ static void *d3d8_get_object(struct d3d8_handle_table *t, DWORD handle, enum d3d
return entry->object;
}
-static ULONG WINAPI D3D8CB_DestroySwapChain(IWineD3DSwapChain *swapchain)
+static inline IDirect3DDevice8Impl *impl_from_IDirect3DDevice8(IDirect3DDevice8 *iface)
{
- IUnknown *parent;
-
- TRACE("swapchain %p.\n", swapchain);
-
- parent = IWineD3DSwapChain_GetParent(swapchain);
- return IUnknown_Release(parent);
+ return CONTAINING_RECORD(iface, IDirect3DDevice8Impl, IDirect3DDevice8_iface);
}
-/* IDirect3D IUnknown parts follow: */
-static HRESULT WINAPI IDirect3DDevice8Impl_QueryInterface(LPDIRECT3DDEVICE8 iface,REFIID riid,LPVOID *ppobj)
+static HRESULT WINAPI IDirect3DDevice8Impl_QueryInterface(IDirect3DDevice8 *iface, REFIID riid,
+ void **ppobj)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
TRACE("iface %p, riid %s, object %p.\n",
iface, debugstr_guid(riid), ppobj);
@@ -279,20 +274,14 @@ static HRESULT WINAPI IDirect3DDevice8Impl_QueryInterface(LPDIRECT3DDEVICE8 ifac
return S_OK;
}
- if (IsEqualGUID(riid, &IID_IWineD3DDeviceParent))
- {
- IUnknown_AddRef((IUnknown *)&This->device_parent_vtbl);
- *ppobj = &This->device_parent_vtbl;
- return S_OK;
- }
-
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
-static ULONG WINAPI IDirect3DDevice8Impl_AddRef(LPDIRECT3DDEVICE8 iface) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static ULONG WINAPI IDirect3DDevice8Impl_AddRef(IDirect3DDevice8 *iface)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", iface, ref);
@@ -300,8 +289,9 @@ static ULONG WINAPI IDirect3DDevice8Impl_AddRef(LPDIRECT3DDEVICE8 iface) {
return ref;
}
-static ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static ULONG WINAPI IDirect3DDevice8Impl_Release(IDirect3DDevice8 *iface)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
ULONG ref;
if (This->inDestruction) return 0;
@@ -312,7 +302,7 @@ static ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface) {
if (ref == 0) {
unsigned i;
- TRACE("Releasing wined3d device %p\n", This->WineD3DDevice);
+ TRACE("Releasing wined3d device %p.\n", This->wined3d_device);
wined3d_mutex_lock();
@@ -323,9 +313,9 @@ static ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface) {
}
HeapFree(GetProcessHeap(), 0, This->decls);
- IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D8CB_DestroySwapChain);
- IWineD3DDevice_ReleaseFocusWindow(This->WineD3DDevice);
- IWineD3DDevice_Release(This->WineD3DDevice);
+ wined3d_device_uninit_3d(This->wined3d_device);
+ wined3d_device_release_focus_window(This->wined3d_device);
+ wined3d_device_decref(This->wined3d_device);
HeapFree(GetProcessHeap(), 0, This->handle_table.entries);
HeapFree(GetProcessHeap(), 0, This);
@@ -337,33 +327,44 @@ static ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface) {
/* IDirect3DDevice Interface follow: */
static HRESULT WINAPI IDirect3DDevice8Impl_TestCooperativeLevel(IDirect3DDevice8 *iface)
{
+ IDirect3DDevice8Impl *device = impl_from_IDirect3DDevice8(iface);
+
TRACE("iface %p.\n", iface);
+ if (device->lost)
+ {
+ TRACE("Device is lost.\n");
+ return D3DERR_DEVICENOTRESET;
+ }
+
return D3D_OK;
}
-static UINT WINAPI IDirect3DDevice8Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE8 iface) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static UINT WINAPI IDirect3DDevice8Impl_GetAvailableTextureMem(IDirect3DDevice8 *iface)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetAvailableTextureMem(This->WineD3DDevice);
+ hr = wined3d_device_get_available_texture_mem(This->wined3d_device);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_ResourceManagerDiscardBytes(LPDIRECT3DDEVICE8 iface, DWORD Bytes) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_ResourceManagerDiscardBytes(IDirect3DDevice8 *iface,
+ DWORD Bytes)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, byte_count %u.\n", iface, Bytes);
FIXME("Byte count ignored.\n");
wined3d_mutex_lock();
- hr = IWineD3DDevice_EvictManagedResources(This->WineD3DDevice);
+ hr = wined3d_device_evict_managed_resources(This->wined3d_device);
wined3d_mutex_unlock();
return hr;
@@ -371,8 +372,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_ResourceManagerDiscardBytes(LPDIRECT3
static HRESULT WINAPI IDirect3DDevice8Impl_GetDirect3D(IDirect3DDevice8 *iface, IDirect3D8 **ppD3D8)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- IWineD3D *pWineD3D;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+ struct wined3d *wined3d;
HRESULT hr;
TRACE("iface %p, d3d8 %p.\n", iface, ppD3D8);
@@ -382,12 +383,12 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetDirect3D(IDirect3DDevice8 *iface,
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &pWineD3D);
- if (SUCCEEDED(hr) && pWineD3D)
+ hr = wined3d_device_get_wined3d(This->wined3d_device, &wined3d);
+ if (SUCCEEDED(hr) && wined3d)
{
- *ppD3D8 = IWineD3D_GetParent(pWineD3D);
+ *ppD3D8 = wined3d_get_parent(wined3d);
IDirect3D8_AddRef(*ppD3D8);
- IWineD3D_Release(pWineD3D);
+ wined3d_decref(wined3d);
}
else
{
@@ -401,8 +402,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetDirect3D(IDirect3DDevice8 *iface,
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetDeviceCaps(LPDIRECT3DDEVICE8 iface, D3DCAPS8* pCaps) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetDeviceCaps(IDirect3DDevice8 *iface, D3DCAPS8 *pCaps)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hrc = D3D_OK;
WINED3DCAPS *pWineCaps;
@@ -417,7 +419,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetDeviceCaps(LPDIRECT3DDEVICE8 iface
}
wined3d_mutex_lock();
- hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps);
+ hrc = wined3d_device_get_device_caps(This->wined3d_device, pWineCaps);
wined3d_mutex_unlock();
fixup_caps(pWineCaps);
@@ -428,14 +430,16 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetDeviceCaps(LPDIRECT3DDEVICE8 iface
return hrc;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetDisplayMode(LPDIRECT3DDEVICE8 iface, D3DDISPLAYMODE* pMode) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetDisplayMode(IDirect3DDevice8 *iface,
+ D3DDISPLAYMODE *pMode)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, mode %p.\n", iface, pMode);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, 0, (WINED3DDISPLAYMODE *) pMode);
+ hr = wined3d_device_get_display_mode(This->wined3d_device, 0, (WINED3DDISPLAYMODE *)pMode);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
@@ -443,58 +447,67 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetDisplayMode(LPDIRECT3DDEVICE8 ifac
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetCreationParameters(LPDIRECT3DDEVICE8 iface, D3DDEVICE_CREATION_PARAMETERS *pParameters) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetCreationParameters(IDirect3DDevice8 *iface,
+ D3DDEVICE_CREATION_PARAMETERS *pParameters)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, parameters %p.\n", iface, pParameters);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetCreationParameters(This->WineD3DDevice, (WINED3DDEVICE_CREATION_PARAMETERS *) pParameters);
+ hr = wined3d_device_get_creation_parameters(This->wined3d_device,
+ (WINED3DDEVICE_CREATION_PARAMETERS *)pParameters);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetCursorProperties(LPDIRECT3DDEVICE8 iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface8* pCursorBitmap) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetCursorProperties(IDirect3DDevice8 *iface,
+ UINT XHotSpot, UINT YHotSpot, IDirect3DSurface8 *pCursorBitmap)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DSurface8Impl *pSurface = (IDirect3DSurface8Impl*)pCursorBitmap;
HRESULT hr;
TRACE("iface %p, hotspot_x %u, hotspot_y %u, bitmap %p.\n",
iface, XHotSpot, YHotSpot, pCursorBitmap);
- if(!pCursorBitmap) {
- WARN("No cursor bitmap, returning WINED3DERR_INVALIDCALL\n");
- return WINED3DERR_INVALIDCALL;
+ if (!pCursorBitmap)
+ {
+ WARN("No cursor bitmap, returning D3DERR_INVALIDCALL.\n");
+ return D3DERR_INVALIDCALL;
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetCursorProperties(This->WineD3DDevice,XHotSpot,YHotSpot,pSurface->wineD3DSurface);
+ hr = wined3d_device_set_cursor_properties(This->wined3d_device, XHotSpot, YHotSpot, pSurface->wined3d_surface);
wined3d_mutex_unlock();
return hr;
}
-static void WINAPI IDirect3DDevice8Impl_SetCursorPosition(LPDIRECT3DDEVICE8 iface, UINT XScreenSpace, UINT YScreenSpace, DWORD Flags) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static void WINAPI IDirect3DDevice8Impl_SetCursorPosition(IDirect3DDevice8 *iface,
+ UINT XScreenSpace, UINT YScreenSpace, DWORD Flags)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
TRACE("iface %p, x %u, y %u, flags %#x.\n",
iface, XScreenSpace, YScreenSpace, Flags);
wined3d_mutex_lock();
- IWineD3DDevice_SetCursorPosition(This->WineD3DDevice, XScreenSpace, YScreenSpace, Flags);
+ wined3d_device_set_cursor_position(This->wined3d_device, XScreenSpace, YScreenSpace, Flags);
wined3d_mutex_unlock();
}
-static BOOL WINAPI IDirect3DDevice8Impl_ShowCursor(LPDIRECT3DDEVICE8 iface, BOOL bShow) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static BOOL WINAPI IDirect3DDevice8Impl_ShowCursor(IDirect3DDevice8 *iface, BOOL bShow)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
BOOL ret;
TRACE("iface %p, show %#x.\n", iface, bShow);
wined3d_mutex_lock();
- ret = IWineD3DDevice_ShowCursor(This->WineD3DDevice, bShow);
+ ret = wined3d_device_show_cursor(This->wined3d_device, bShow);
wined3d_mutex_unlock();
return ret;
@@ -503,7 +516,7 @@ static BOOL WINAPI IDirect3DDevice8Impl_ShowCursor(LPDIRECT3DDEVICE8 iface, BOOL
static HRESULT WINAPI IDirect3DDevice8Impl_CreateAdditionalSwapChain(IDirect3DDevice8 *iface,
D3DPRESENT_PARAMETERS *present_parameters, IDirect3DSwapChain8 **swapchain)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DSwapChain8Impl *object;
HRESULT hr;
@@ -526,18 +539,76 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateAdditionalSwapChain(IDirect3DDe
}
TRACE("Created swapchain %p.\n", object);
- *swapchain = (IDirect3DSwapChain8 *)object;
+ *swapchain = &object->IDirect3DSwapChain8_iface;
return D3D_OK;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_Reset(LPDIRECT3DDEVICE8 iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI reset_enum_callback(struct wined3d_resource *resource, void *data)
+{
+ struct wined3d_resource_desc desc;
+ BOOL *resources_ok = data;
+
+ wined3d_resource_get_desc(resource, &desc);
+ if (desc.pool == WINED3DPOOL_DEFAULT)
+ {
+ IDirect3DSurface8 *surface;
+
+ if (desc.resource_type != WINED3DRTYPE_SURFACE)
+ {
+ WARN("Resource %p in pool D3DPOOL_DEFAULT blocks the Reset call.\n", resource);
+ *resources_ok = FALSE;
+ return S_FALSE;
+ }
+
+ surface = wined3d_resource_get_parent(resource);
+
+ IDirect3DSurface8_AddRef(surface);
+ if (IDirect3DSurface8_Release(surface))
+ {
+ WARN("Surface %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", surface, resource);
+ *resources_ok = FALSE;
+ return S_FALSE;
+ }
+
+ WARN("Surface %p (resource %p) is an implicit resource with ref 0.\n", surface, resource);
+ }
+
+ return S_OK;
+}
+
+static HRESULT WINAPI IDirect3DDevice8Impl_Reset(IDirect3DDevice8 *iface,
+ D3DPRESENT_PARAMETERS *pPresentationParameters)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
WINED3DPRESENT_PARAMETERS localParameters;
+ BOOL resources_ok = TRUE;
HRESULT hr;
+ UINT i;
TRACE("iface %p, present_parameters %p.\n", iface, pPresentationParameters);
+ wined3d_mutex_lock();
+ wined3d_device_set_index_buffer(This->wined3d_device, NULL, WINED3DFMT_UNKNOWN);
+ for (i = 0; i < 16; ++i)
+ {
+ wined3d_device_set_stream_source(This->wined3d_device, i, NULL, 0, 0);
+ }
+ for (i = 0; i < 16; ++i)
+ {
+ wined3d_device_set_texture(This->wined3d_device, i, NULL);
+ }
+
+ wined3d_device_enum_resources(This->wined3d_device, reset_enum_callback, &resources_ok);
+ if (!resources_ok)
+ {
+ WARN("The application is holding D3DPOOL_DEFAULT resources, rejecting reset.\n");
+ This->lost = TRUE;
+ wined3d_mutex_unlock();
+
+ return D3DERR_DEVICELOST;
+ }
+
localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
localParameters.BackBufferFormat = wined3dformat_from_d3dformat(pPresentationParameters->BackBufferFormat);
@@ -554,10 +625,15 @@ static HRESULT WINAPI IDirect3DDevice8Impl_Reset(LPDIRECT3DDEVICE8 iface, D3DPRE
localParameters.PresentationInterval = pPresentationParameters->FullScreen_PresentationInterval;
localParameters.AutoRestoreDisplayMode = TRUE;
- wined3d_mutex_lock();
- hr = IWineD3DDevice_Reset(This->WineD3DDevice, &localParameters);
- if(SUCCEEDED(hr)) {
- hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, WINED3DRS_POINTSIZE_MIN, 0);
+ hr = wined3d_device_reset(This->wined3d_device, &localParameters);
+ if (SUCCEEDED(hr))
+ {
+ hr = wined3d_device_set_render_state(This->wined3d_device, WINED3DRS_POINTSIZE_MIN, 0);
+ This->lost = FALSE;
+ }
+ else
+ {
+ This->lost = TRUE;
}
wined3d_mutex_unlock();
@@ -578,15 +654,17 @@ static HRESULT WINAPI IDirect3DDevice8Impl_Reset(LPDIRECT3DDEVICE8 iface, D3DPRE
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_Present(LPDIRECT3DDEVICE8 iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_Present(IDirect3DDevice8 *iface, const RECT *pSourceRect,
+ const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(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 = IWineD3DDevice_Present(This->WineD3DDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
+ hr = wined3d_device_present(This->wined3d_device, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
wined3d_mutex_unlock();
return hr;
@@ -595,58 +673,64 @@ static HRESULT WINAPI IDirect3DDevice8Impl_Present(LPDIRECT3DDEVICE8 iface, CONS
static HRESULT WINAPI IDirect3DDevice8Impl_GetBackBuffer(IDirect3DDevice8 *iface,
UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8 **ppBackBuffer)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- IWineD3DSurface *retSurface = NULL;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+ struct wined3d_surface *wined3d_surface = NULL;
HRESULT hr;
TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
iface, BackBuffer, Type, ppBackBuffer);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, 0, BackBuffer, (WINED3DBACKBUFFER_TYPE)Type, &retSurface);
- if (SUCCEEDED(hr) && retSurface && ppBackBuffer)
+ hr = wined3d_device_get_back_buffer(This->wined3d_device, 0,
+ BackBuffer, (WINED3DBACKBUFFER_TYPE)Type, &wined3d_surface);
+ if (SUCCEEDED(hr) && wined3d_surface && ppBackBuffer)
{
- *ppBackBuffer = IWineD3DSurface_GetParent(retSurface);
+ *ppBackBuffer = wined3d_surface_get_parent(wined3d_surface);
IDirect3DSurface8_AddRef(*ppBackBuffer);
- IWineD3DSurface_Release(retSurface);
+ wined3d_surface_decref(wined3d_surface);
}
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetRasterStatus(LPDIRECT3DDEVICE8 iface, D3DRASTER_STATUS* pRasterStatus) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetRasterStatus(IDirect3DDevice8 *iface,
+ D3DRASTER_STATUS *pRasterStatus)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, raster_status %p.\n", iface, pRasterStatus);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetRasterStatus(This->WineD3DDevice, 0, (WINED3DRASTER_STATUS *) pRasterStatus);
+ hr = wined3d_device_get_raster_status(This->wined3d_device, 0, (WINED3DRASTER_STATUS *)pRasterStatus);
wined3d_mutex_unlock();
return hr;
}
-static void WINAPI IDirect3DDevice8Impl_SetGammaRamp(LPDIRECT3DDEVICE8 iface, DWORD Flags, CONST D3DGAMMARAMP* pRamp) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static void WINAPI IDirect3DDevice8Impl_SetGammaRamp(IDirect3DDevice8 *iface, DWORD Flags,
+ const D3DGAMMARAMP *pRamp)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
TRACE("iface %p, flags %#x, ramp %p.\n", iface, Flags, pRamp);
/* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
wined3d_mutex_lock();
- IWineD3DDevice_SetGammaRamp(This->WineD3DDevice, 0, Flags, (CONST WINED3DGAMMARAMP *) pRamp);
+ wined3d_device_set_gamma_ramp(This->wined3d_device, 0, Flags, (const WINED3DGAMMARAMP *)pRamp);
wined3d_mutex_unlock();
}
-static void WINAPI IDirect3DDevice8Impl_GetGammaRamp(LPDIRECT3DDEVICE8 iface, D3DGAMMARAMP* pRamp) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static void WINAPI IDirect3DDevice8Impl_GetGammaRamp(IDirect3DDevice8 *iface, D3DGAMMARAMP *pRamp)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
TRACE("iface %p, ramp %p.\n", iface, pRamp);
/* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
wined3d_mutex_lock();
- IWineD3DDevice_GetGammaRamp(This->WineD3DDevice, 0, (WINED3DGAMMARAMP *) pRamp);
+ wined3d_device_get_gamma_ramp(This->wined3d_device, 0, (WINED3DGAMMARAMP *)pRamp);
wined3d_mutex_unlock();
}
@@ -654,7 +738,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateTexture(IDirect3DDevice8 *iface
UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format,
D3DPOOL pool, IDirect3DTexture8 **texture)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DTexture8Impl *object;
HRESULT hr;
@@ -677,7 +761,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateTexture(IDirect3DDevice8 *iface
}
TRACE("Created texture %p.\n", object);
- *texture = (IDirect3DTexture8 *)object;
+ *texture = &object->IDirect3DTexture8_iface;
return D3D_OK;
}
@@ -686,7 +770,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(IDirect3DDevice8
UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format,
D3DPOOL pool, IDirect3DVolumeTexture8 **texture)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DVolumeTexture8Impl *object;
HRESULT hr;
@@ -709,7 +793,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(IDirect3DDevice8
}
TRACE("Created volume texture %p.\n", object);
- *texture = (IDirect3DVolumeTexture8 *)object;
+ *texture = &object->IDirect3DVolumeTexture8_iface;
return D3D_OK;
}
@@ -717,7 +801,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(IDirect3DDevice8
static HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(IDirect3DDevice8 *iface, UINT edge_length,
UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, IDirect3DCubeTexture8 **texture)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DCubeTexture8Impl *object;
HRESULT hr;
@@ -740,15 +824,15 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(IDirect3DDevice8 *i
}
TRACE("Created cube texture %p.\n", object);
- *texture = (IDirect3DCubeTexture8 *)object;
+ *texture = &object->IDirect3DCubeTexture8_iface;
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(IDirect3DDevice8 *iface, UINT size, DWORD usage,
- DWORD fvf, D3DPOOL pool, IDirect3DVertexBuffer8 **buffer)
+static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(IDirect3DDevice8 *iface, UINT size,
+ DWORD usage, DWORD fvf, D3DPOOL pool, IDirect3DVertexBuffer8 **buffer)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DVertexBuffer8Impl *object;
HRESULT hr;
@@ -776,10 +860,10 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(IDirect3DDevice8 *
return D3D_OK;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(IDirect3DDevice8 *iface, UINT size, DWORD usage,
- D3DFORMAT format, D3DPOOL pool, IDirect3DIndexBuffer8 **buffer)
+static HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(IDirect3DDevice8 *iface, UINT size,
+ DWORD usage, D3DFORMAT format, D3DPOOL pool, IDirect3DIndexBuffer8 **buffer)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DIndexBuffer8Impl *object;
HRESULT hr;
@@ -807,17 +891,17 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(IDirect3DDevice8 *i
return D3D_OK;
}
-static HRESULT IDirect3DDevice8Impl_CreateSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height,
- D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface8 **ppSurface,
- UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality)
+static HRESULT IDirect3DDevice8Impl_CreateSurface(IDirect3DDevice8Impl *device, UINT Width,
+ UINT Height, D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level,
+ IDirect3DSurface8 **ppSurface, UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample,
+ DWORD MultisampleQuality)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
IDirect3DSurface8Impl *object;
HRESULT hr;
- TRACE("iface %p, width %u, height %u, format %#x, lockable %#x, discard %#x, level %u, surface %p,\n"
+ TRACE("device %p, width %u, height %u, format %#x, lockable %#x, discard %#x, level %u, surface %p,\n"
"\tusage %#x, pool %#x, multisample_type %#x, multisample_quality %u.\n",
- iface, Width, Height, Format, Lockable, Discard, Level, ppSurface,
+ device, Width, Height, Format, Lockable, Discard, Level, ppSurface,
Usage, Pool, MultiSample, MultisampleQuality);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface8Impl));
@@ -827,8 +911,8 @@ static HRESULT IDirect3DDevice8Impl_CreateSurface(LPDIRECT3DDEVICE8 iface, UINT
return D3DERR_OUTOFVIDEOMEMORY;
}
- hr = surface_init(object, This, Width, Height, Format, Lockable, Discard,
- Level, Usage, Pool, MultiSample, MultisampleQuality);
+ hr = surface_init(object, device, Width, Height, Format, Lockable, Discard, Level, Usage,
+ Pool, MultiSample, MultisampleQuality);
if (FAILED(hr))
{
WARN("Failed to initialize surface, hr %#x.\n", hr);
@@ -842,52 +926,66 @@ static HRESULT IDirect3DDevice8Impl_CreateSurface(LPDIRECT3DDEVICE8 iface, UINT
return D3D_OK;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable, IDirect3DSurface8** ppSurface) {
+static HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(IDirect3DDevice8 *iface, UINT Width,
+ UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable,
+ IDirect3DSurface8 **ppSurface)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, lockable %#x, surface %p.\n",
iface, Width, Height, Format, MultiSample, Lockable, ppSurface);
- hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, Lockable, FALSE /* Discard */,
- 0 /* Level */, ppSurface, D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT, MultiSample, 0);
+ hr = IDirect3DDevice8Impl_CreateSurface(This, Width, Height, Format, Lockable,
+ FALSE /* Discard */, 0 /* Level */, ppSurface, D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT,
+ MultiSample, 0);
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, IDirect3DSurface8** ppSurface) {
+static HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(IDirect3DDevice8 *iface,
+ UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
+ IDirect3DSurface8 **ppSurface)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, surface %p.\n",
iface, Width, Height, Format, MultiSample, ppSurface);
/* TODO: Verify that Discard is false */
- hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Lockable */, FALSE,
+ hr = IDirect3DDevice8Impl_CreateSurface(This, Width, Height, Format, TRUE /* Lockable */, FALSE,
0 /* Level */, ppSurface, D3DUSAGE_DEPTHSTENCIL, D3DPOOL_DEFAULT, MultiSample, 0);
return hr;
}
/* IDirect3DDevice8Impl::CreateImageSurface returns surface with pool type SYSTEMMEM */
-static HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, IDirect3DSurface8** ppSurface) {
+static HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(IDirect3DDevice8 *iface, UINT Width,
+ UINT Height, D3DFORMAT Format, IDirect3DSurface8 **ppSurface)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, width %u, height %u, format %#x, surface %p.\n",
iface, Width, Height, Format, ppSurface);
- hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Lockable */, FALSE /* Discard */,
- 0 /* Level */, ppSurface, 0 /* Usage (undefined/none) */, D3DPOOL_SYSTEMMEM, D3DMULTISAMPLE_NONE,
- 0 /* MultisampleQuality */);
+ hr = IDirect3DDevice8Impl_CreateSurface(This, Width, Height, Format, TRUE /* Lockable */,
+ FALSE /* Discard */, 0 /* Level */, ppSurface, 0 /* Usage (undefined/none) */,
+ D3DPOOL_SYSTEMMEM, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8 *pSourceSurface, CONST RECT *pSourceRects, UINT cRects, IDirect3DSurface8 *pDestinationSurface, CONST POINT *pDestPoints) {
+static HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(IDirect3DDevice8 *iface,
+ IDirect3DSurface8 *pSourceSurface, const RECT *pSourceRects, UINT cRects,
+ IDirect3DSurface8 *pDestinationSurface, const POINT *pDestPoints)
+{
IDirect3DSurface8Impl *Source = (IDirect3DSurface8Impl *) pSourceSurface;
IDirect3DSurface8Impl *Dest = (IDirect3DSurface8Impl *) pDestinationSurface;
-
- HRESULT hr = WINED3D_OK;
enum wined3d_format_id srcFormat, destFormat;
- WINED3DSURFACE_DESC winedesc;
+ struct wined3d_resource_desc wined3d_desc;
+ struct wined3d_resource *wined3d_resource;
TRACE("iface %p, src_surface %p, src_rects %p, rect_count %u, dst_surface %p, dst_points %p.\n",
iface, pSourceSurface, pSourceRects, cRects, pDestinationSurface, pDestPoints);
@@ -896,58 +994,81 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, ID
* destination texture is in WINED3DPOOL_DEFAULT. */
wined3d_mutex_lock();
- IWineD3DSurface_GetDesc(Source->wineD3DSurface, &winedesc);
- srcFormat = winedesc.format;
+ wined3d_resource = wined3d_surface_get_resource(Source->wined3d_surface);
+ wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
+ srcFormat = wined3d_desc.format;
- IWineD3DSurface_GetDesc(Dest->wineD3DSurface, &winedesc);
- destFormat = winedesc.format;
+ wined3d_resource = wined3d_surface_get_resource(Dest->wined3d_surface);
+ wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
+ destFormat = wined3d_desc.format;
/* Check that the source and destination formats match */
- if (srcFormat != destFormat && WINED3DFMT_UNKNOWN != destFormat) {
- WARN("(%p) source %p format must match the dest %p format, returning WINED3DERR_INVALIDCALL\n", iface, pSourceSurface, pDestinationSurface);
+ if (srcFormat != destFormat && WINED3DFMT_UNKNOWN != destFormat)
+ {
+ WARN("Source %p format must match the dest %p format, returning D3DERR_INVALIDCALL.\n",
+ pSourceSurface, pDestinationSurface);
wined3d_mutex_unlock();
- return WINED3DERR_INVALIDCALL;
- } else if (WINED3DFMT_UNKNOWN == destFormat) {
+ return D3DERR_INVALIDCALL;
+ }
+ else if (WINED3DFMT_UNKNOWN == destFormat)
+ {
TRACE("(%p) : Converting destination surface from WINED3DFMT_UNKNOWN to the source format\n", iface);
- IWineD3DSurface_SetFormat(Dest->wineD3DSurface, srcFormat);
+ wined3d_surface_set_format(Dest->wined3d_surface, srcFormat);
}
/* Quick if complete copy ... */
- if (cRects == 0 && pSourceRects == NULL && pDestPoints == NULL) {
- IWineD3DSurface_BltFast(Dest->wineD3DSurface, 0, 0, Source->wineD3DSurface, NULL, WINEDDBLTFAST_NOCOLORKEY);
- } else {
+ if (!cRects && !pSourceRects && !pDestPoints)
+ {
+ wined3d_surface_bltfast(Dest->wined3d_surface, 0, 0,
+ Source->wined3d_surface, NULL, WINEDDBLTFAST_NOCOLORKEY);
+ }
+ else
+ {
unsigned int i;
/* Copy rect by rect */
- if (NULL != pSourceRects && NULL != pDestPoints) {
- for (i = 0; i < cRects; ++i) {
- IWineD3DSurface_BltFast(Dest->wineD3DSurface, pDestPoints[i].x, pDestPoints[i].y, Source->wineD3DSurface, &pSourceRects[i], WINEDDBLTFAST_NOCOLORKEY);
+ if (pSourceRects && pDestPoints)
+ {
+ for (i = 0; i < cRects; ++i)
+ {
+ wined3d_surface_bltfast(Dest->wined3d_surface, pDestPoints[i].x, pDestPoints[i].y,
+ Source->wined3d_surface, &pSourceRects[i], WINEDDBLTFAST_NOCOLORKEY);
}
- } else {
- for (i = 0; i < cRects; ++i) {
- IWineD3DSurface_BltFast(Dest->wineD3DSurface, 0, 0, Source->wineD3DSurface, &pSourceRects[i], WINEDDBLTFAST_NOCOLORKEY);
+ }
+ else
+ {
+ for (i = 0; i < cRects; ++i)
+ {
+ wined3d_surface_bltfast(Dest->wined3d_surface, 0, 0,
+ Source->wined3d_surface, &pSourceRects[i], WINEDDBLTFAST_NOCOLORKEY);
}
}
}
wined3d_mutex_unlock();
- return hr;
+ return WINED3D_OK;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(LPDIRECT3DDEVICE8 iface, IDirect3DBaseTexture8* pSourceTexture, IDirect3DBaseTexture8* pDestinationTexture) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(IDirect3DDevice8 *iface,
+ IDirect3DBaseTexture8 *src_texture, IDirect3DBaseTexture8 *dst_texture)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
- TRACE("iface %p, src_texture %p, dst_texture %p.\n", iface, pSourceTexture, pDestinationTexture);
+ TRACE("iface %p, src_texture %p, dst_texture %p.\n", iface, src_texture, dst_texture);
wined3d_mutex_lock();
- hr = IWineD3DDevice_UpdateTexture(This->WineD3DDevice, ((IDirect3DBaseTexture8Impl *)pSourceTexture)->wineD3DBaseTexture, ((IDirect3DBaseTexture8Impl *)pDestinationTexture)->wineD3DBaseTexture);
+ hr = wined3d_device_update_texture(This->wined3d_device,
+ ((IDirect3DBaseTexture8Impl *)src_texture)->wined3d_texture,
+ ((IDirect3DBaseTexture8Impl *)dst_texture)->wined3d_texture);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetFrontBuffer(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pDestSurface) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetFrontBuffer(IDirect3DDevice8 *iface,
+ IDirect3DSurface8 *pDestSurface)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DSurface8Impl *destSurface = (IDirect3DSurface8Impl *)pDestSurface;
HRESULT hr;
@@ -959,32 +1080,70 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetFrontBuffer(LPDIRECT3DDEVICE8 ifac
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetFrontBufferData(This->WineD3DDevice, 0, destSurface->wineD3DSurface);
+ hr = wined3d_device_get_front_buffer_data(This->wined3d_device, 0, destSurface->wined3d_surface);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pRenderTarget, IDirect3DSurface8* pNewZStencil) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderTarget(IDirect3DDevice8 *iface,
+ IDirect3DSurface8 *pRenderTarget, IDirect3DSurface8 *pNewZStencil)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DSurface8Impl *pSurface = (IDirect3DSurface8Impl *)pRenderTarget;
IDirect3DSurface8Impl *pZSurface = (IDirect3DSurface8Impl *)pNewZStencil;
- IWineD3DSurface *original_ds = NULL;
+ struct wined3d_surface *original_ds = NULL;
HRESULT hr;
TRACE("iface %p, render_target %p, depth_stencil %p.\n", iface, pRenderTarget, pNewZStencil);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice, &original_ds);
+ if (pZSurface)
+ {
+ struct wined3d_resource_desc ds_desc, rt_desc;
+ struct wined3d_resource *wined3d_resource;
+ IDirect3DSurface8 *orig_rt = NULL;
+
+ /* If no render target is passed in check the size against the current RT */
+ if (!pRenderTarget)
+ {
+ hr = IDirect3DDevice8_GetRenderTarget(iface, &orig_rt);
+ if (FAILED(hr))
+ {
+ wined3d_mutex_unlock();
+ return hr;
+ }
+ pSurface = (IDirect3DSurface8Impl *)orig_rt;
+ }
+
+ wined3d_resource = wined3d_surface_get_resource(pZSurface->wined3d_surface);
+ wined3d_resource_get_desc(wined3d_resource, &ds_desc);
+ wined3d_resource = wined3d_surface_get_resource(pSurface->wined3d_surface);
+ wined3d_resource_get_desc(wined3d_resource, &rt_desc);
+ if (orig_rt) IDirect3DSurface8_Release(orig_rt);
+
+ if (ds_desc.width < rt_desc.width || ds_desc.height < rt_desc.height)
+ {
+ WARN("Depth stencil is smaller than the render target, returning D3DERR_INVALIDCALL\n");
+ wined3d_mutex_unlock();
+ return D3DERR_INVALIDCALL;
+ }
+ }
+
+ hr = wined3d_device_get_depth_stencil(This->wined3d_device, &original_ds);
if (hr == WINED3D_OK || hr == WINED3DERR_NOTFOUND)
{
- hr = IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, pZSurface ? pZSurface->wineD3DSurface : NULL);
- if (SUCCEEDED(hr) && pSurface)
- hr = IWineD3DDevice_SetRenderTarget(This->WineD3DDevice, 0, pSurface->wineD3DSurface, TRUE);
- if (FAILED(hr)) IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, original_ds);
+ hr = wined3d_device_set_depth_stencil(This->wined3d_device, pZSurface ? pZSurface->wined3d_surface : NULL);
+ if (SUCCEEDED(hr) && pRenderTarget)
+ {
+ hr = wined3d_device_set_render_target(This->wined3d_device, 0, pSurface->wined3d_surface, TRUE);
+ if (FAILED(hr))
+ wined3d_device_set_depth_stencil(This->wined3d_device, original_ds);
+ }
}
- if (original_ds) IWineD3DSurface_Release(original_ds);
+ if (original_ds)
+ wined3d_surface_decref(original_ds);
wined3d_mutex_unlock();
@@ -994,8 +1153,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderTarget(LPDIRECT3DDEVICE8 ifa
static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderTarget(IDirect3DDevice8 *iface,
IDirect3DSurface8 **ppRenderTarget)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- IWineD3DSurface *pRenderTarget;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+ struct wined3d_surface *wined3d_surface;
HRESULT hr;
TRACE("iface %p, render_target %p.\n", iface, ppRenderTarget);
@@ -1005,12 +1164,12 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderTarget(IDirect3DDevice8 *ifa
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetRenderTarget(This->WineD3DDevice, 0, &pRenderTarget);
- if (SUCCEEDED(hr) && pRenderTarget)
+ hr = wined3d_device_get_render_target(This->wined3d_device, 0, &wined3d_surface);
+ if (SUCCEEDED(hr) && wined3d_surface)
{
- *ppRenderTarget = IWineD3DSurface_GetParent(pRenderTarget);
+ *ppRenderTarget = wined3d_surface_get_parent(wined3d_surface);
IDirect3DSurface8_AddRef(*ppRenderTarget);
- IWineD3DSurface_Release(pRenderTarget);
+ wined3d_surface_decref(wined3d_surface);
}
else
{
@@ -1025,8 +1184,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderTarget(IDirect3DDevice8 *ifa
static HRESULT WINAPI IDirect3DDevice8Impl_GetDepthStencilSurface(IDirect3DDevice8 *iface,
IDirect3DSurface8 **ppZStencilSurface)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- IWineD3DSurface *pZStencilSurface;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+ struct wined3d_surface *wined3d_surface;
HRESULT hr;
TRACE("iface %p, depth_stencil %p.\n", iface, ppZStencilSurface);
@@ -1036,12 +1195,12 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetDepthStencilSurface(IDirect3DDevic
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice, &pZStencilSurface);
+ hr = wined3d_device_get_depth_stencil(This->wined3d_device, &wined3d_surface);
if (SUCCEEDED(hr))
{
- *ppZStencilSurface = IWineD3DSurface_GetParent(pZStencilSurface);
+ *ppZStencilSurface = wined3d_surface_get_parent(wined3d_surface);
IDirect3DSurface8_AddRef(*ppZStencilSurface);
- IWineD3DSurface_Release(pZStencilSurface);
+ wined3d_surface_decref(wined3d_surface);
}
else
{
@@ -1054,266 +1213,336 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetDepthStencilSurface(IDirect3DDevic
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_BeginScene(LPDIRECT3DDEVICE8 iface) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_BeginScene(IDirect3DDevice8 *iface)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
- hr = IWineD3DDevice_BeginScene(This->WineD3DDevice);
+ hr = wined3d_device_begin_scene(This->wined3d_device);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice8Impl_EndScene(LPDIRECT3DDEVICE8 iface) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice8Impl_EndScene(IDirect3DDevice8 *iface)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
- hr = IWineD3DDevice_EndScene(This->WineD3DDevice);
+ hr = wined3d_device_end_scene(This->wined3d_device);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_Clear(LPDIRECT3DDEVICE8 iface, DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_Clear(IDirect3DDevice8 *iface, DWORD Count,
+ const D3DRECT *pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, rect_count %u, rects %p, flags %#x, color 0x%08x, z %.8e, stencil %u.\n",
iface, Count, pRects, Flags, Color, Z, Stencil);
wined3d_mutex_lock();
- hr = IWineD3DDevice_Clear(This->WineD3DDevice, Count, (const RECT *)pRects, Flags, Color, Z, Stencil);
+ hr = wined3d_device_clear(This->wined3d_device, Count, (const RECT *)pRects, Flags, Color, Z, Stencil);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* lpMatrix) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetTransform(IDirect3DDevice8 *iface,
+ D3DTRANSFORMSTATETYPE State, const D3DMATRIX *lpMatrix)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, state %#x, matrix %p.\n", iface, State, lpMatrix);
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) lpMatrix);
+ hr = wined3d_device_set_transform(This->wined3d_device, State, (const WINED3DMATRIX *)lpMatrix);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetTransform(IDirect3DDevice8 *iface,
+ D3DTRANSFORMSTATETYPE State, D3DMATRIX *pMatrix)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, state %#x, matrix %p.\n", iface, State, pMatrix);
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetTransform(This->WineD3DDevice, State, (WINED3DMATRIX*) pMatrix);
+ hr = wined3d_device_get_transform(This->wined3d_device, State, (WINED3DMATRIX *)pMatrix);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_MultiplyTransform(LPDIRECT3DDEVICE8 iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_MultiplyTransform(IDirect3DDevice8 *iface,
+ D3DTRANSFORMSTATETYPE State, const D3DMATRIX *pMatrix)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, state %#x, matrix %p.\n", iface, State, pMatrix);
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
wined3d_mutex_lock();
- hr = IWineD3DDevice_MultiplyTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) pMatrix);
+ hr = wined3d_device_multiply_transform(This->wined3d_device, State, (const WINED3DMATRIX *)pMatrix);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetViewport(LPDIRECT3DDEVICE8 iface, CONST D3DVIEWPORT8* pViewport) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetViewport(IDirect3DDevice8 *iface,
+ const D3DVIEWPORT8 *pViewport)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, viewport %p.\n", iface, pViewport);
/* Note: D3DVIEWPORT8 is compatible with WINED3DVIEWPORT */
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetViewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport);
+ hr = wined3d_device_set_viewport(This->wined3d_device, (const WINED3DVIEWPORT *)pViewport);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetViewport(LPDIRECT3DDEVICE8 iface, D3DVIEWPORT8* pViewport) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetViewport(IDirect3DDevice8 *iface,
+ D3DVIEWPORT8 *pViewport)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, viewport %p.\n", iface, pViewport);
/* Note: D3DVIEWPORT8 is compatible with WINED3DVIEWPORT */
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetViewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport);
+ hr = wined3d_device_get_viewport(This->wined3d_device, (WINED3DVIEWPORT *)pViewport);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetMaterial(LPDIRECT3DDEVICE8 iface, CONST D3DMATERIAL8* pMaterial) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetMaterial(IDirect3DDevice8 *iface,
+ const D3DMATERIAL8 *pMaterial)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, material %p.\n", iface, pMaterial);
/* Note: D3DMATERIAL8 is compatible with WINED3DMATERIAL */
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial);
+ hr = wined3d_device_set_material(This->wined3d_device, (const WINED3DMATERIAL *)pMaterial);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetMaterial(LPDIRECT3DDEVICE8 iface, D3DMATERIAL8* pMaterial) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetMaterial(IDirect3DDevice8 *iface,
+ D3DMATERIAL8 *pMaterial)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, material %p.\n", iface, pMaterial);
/* Note: D3DMATERIAL8 is compatible with WINED3DMATERIAL */
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial);
+ hr = wined3d_device_get_material(This->wined3d_device, (WINED3DMATERIAL *)pMaterial);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetLight(LPDIRECT3DDEVICE8 iface, DWORD Index, CONST D3DLIGHT8* pLight) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetLight(IDirect3DDevice8 *iface, DWORD Index,
+ const D3DLIGHT8 *pLight)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, index %u, light %p.\n", iface, Index, pLight);
/* Note: D3DLIGHT8 is compatible with WINED3DLIGHT */
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight);
+ hr = wined3d_device_set_light(This->wined3d_device, Index, (const WINED3DLIGHT *)pLight);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetLight(LPDIRECT3DDEVICE8 iface, DWORD Index,D3DLIGHT8* pLight) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetLight(IDirect3DDevice8 *iface, DWORD Index,
+ D3DLIGHT8 *pLight)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, index %u, light %p.\n", iface, Index, pLight);
/* Note: D3DLIGHT8 is compatible with WINED3DLIGHT */
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight);
+ hr = wined3d_device_get_light(This->wined3d_device, Index, (WINED3DLIGHT *)pLight);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_LightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index,BOOL Enable) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_LightEnable(IDirect3DDevice8 *iface, DWORD Index,
+ BOOL Enable)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, index %u, enable %#x.\n", iface, Index, Enable);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetLightEnable(This->WineD3DDevice, Index, Enable);
+ hr = wined3d_device_set_light_enable(This->wined3d_device, Index, Enable);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetLightEnable(LPDIRECT3DDEVICE8 iface, DWORD Index,BOOL* pEnable) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetLightEnable(IDirect3DDevice8 *iface, DWORD Index,
+ BOOL *pEnable)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, index %u, enable %p.\n", iface, Index, pEnable);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetLightEnable(This->WineD3DDevice, Index, pEnable);
+ hr = wined3d_device_get_light_enable(This->wined3d_device, Index, pEnable);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index,CONST float* pPlane) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetClipPlane(IDirect3DDevice8 *iface, DWORD Index,
+ const float *pPlane)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, index %u, plane %p.\n", iface, Index, pPlane);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetClipPlane(This->WineD3DDevice, Index, pPlane);
+ hr = wined3d_device_set_clip_plane(This->wined3d_device, Index, pPlane);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetClipPlane(LPDIRECT3DDEVICE8 iface, DWORD Index,float* pPlane) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetClipPlane(IDirect3DDevice8 *iface, DWORD Index,
+ float *pPlane)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, index %u, plane %p.\n", iface, Index, pPlane);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetClipPlane(This->WineD3DDevice, Index, pPlane);
+ hr = wined3d_device_get_clip_plane(This->wined3d_device, Index, pPlane);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD Value) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+/* This factor is the result of a trial-and-error search. Both ZBIAS and DEPTHBIAS require
+ * guesswork by design. d3d9 apps usually use a DEPTHBIAS of -0.00002(Mass Effect 2, WoW).
+ * d3d8 apps(Final Fantasy XI) set ZBIAS to 15 and still expect the depth test to sort
+ * objects properly. */
+static const float zbias_factor = -0.000005f;
+
+static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(IDirect3DDevice8 *iface,
+ D3DRENDERSTATETYPE State, DWORD Value)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
+ union
+ {
+ DWORD d;
+ float f;
+ } wined3d_value;
TRACE("iface %p, state %#x, value %#x.\n", iface, State, Value);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, State, Value);
+ switch (State)
+ {
+ case D3DRS_ZBIAS:
+ wined3d_value.f = Value * zbias_factor;
+ hr = wined3d_device_set_render_state(This->wined3d_device, WINED3DRS_DEPTHBIAS, wined3d_value.d);
+ break;
+
+ default:
+ hr = wined3d_device_set_render_state(This->wined3d_device, State, Value);
+ }
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD* pValue) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderState(IDirect3DDevice8 *iface,
+ D3DRENDERSTATETYPE State, DWORD *pValue)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
+ union
+ {
+ DWORD d;
+ float f;
+ } wined3d_value;
TRACE("iface %p, state %#x, value %p.\n", iface, State, pValue);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetRenderState(This->WineD3DDevice, State, pValue);
+ switch (State)
+ {
+ case D3DRS_ZBIAS:
+ hr = wined3d_device_get_render_state(This->wined3d_device, WINED3DRS_DEPTHBIAS, &wined3d_value.d);
+ if (SUCCEEDED(hr)) *pValue = (DWORD)(wined3d_value.f / zbias_factor);
+ break;
+
+ default:
+ hr = wined3d_device_get_render_state(This->wined3d_device, State, pValue);
+ }
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_BeginStateBlock(LPDIRECT3DDEVICE8 iface) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_BeginStateBlock(IDirect3DDevice8 *iface)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
- hr = IWineD3DDevice_BeginStateBlock(This->WineD3DDevice);
+ hr = wined3d_device_begin_stateblock(This->wined3d_device);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_EndStateBlock(LPDIRECT3DDEVICE8 iface, DWORD* pToken) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- IWineD3DStateBlock *stateblock;
+static HRESULT WINAPI IDirect3DDevice8Impl_EndStateBlock(IDirect3DDevice8 *iface, DWORD *pToken)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+ struct wined3d_stateblock *stateblock;
HRESULT hr;
TRACE("iface %p, token %p.\n", iface, pToken);
@@ -1322,8 +1551,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_EndStateBlock(LPDIRECT3DDEVICE8 iface
* of memory later and cause locking problems)
*/
wined3d_mutex_lock();
- hr = IWineD3DDevice_EndStateBlock(This->WineD3DDevice , &stateblock);
- if (hr != D3D_OK) {
+ hr = wined3d_device_end_stateblock(This->wined3d_device, &stateblock);
+ if (FAILED(hr))
+ {
WARN("IWineD3DDevice_EndStateBlock returned an error\n");
wined3d_mutex_unlock();
return hr;
@@ -1336,7 +1566,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_EndStateBlock(LPDIRECT3DDEVICE8 iface
{
ERR("Failed to create a handle\n");
wined3d_mutex_lock();
- IWineD3DStateBlock_Release(stateblock);
+ wined3d_stateblock_decref(stateblock);
wined3d_mutex_unlock();
return E_FAIL;
}
@@ -1347,9 +1577,34 @@ static HRESULT WINAPI IDirect3DDevice8Impl_EndStateBlock(LPDIRECT3DDEVICE8 iface
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_ApplyStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- IWineD3DStateBlock *stateblock;
+static HRESULT WINAPI IDirect3DDevice8Impl_ApplyStateBlock(IDirect3DDevice8 *iface, DWORD Token)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+ struct wined3d_stateblock *stateblock;
+ HRESULT hr;
+
+ TRACE("iface %p, token %#x.\n", iface, Token);
+
+ if (!Token) return D3D_OK;
+
+ wined3d_mutex_lock();
+ stateblock = d3d8_get_object(&This->handle_table, Token - 1, D3D8_HANDLE_SB);
+ if (!stateblock)
+ {
+ WARN("Invalid handle (%#x) passed.\n", Token);
+ wined3d_mutex_unlock();
+ return D3DERR_INVALIDCALL;
+ }
+ hr = wined3d_stateblock_apply(stateblock);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice8Impl_CaptureStateBlock(IDirect3DDevice8 *iface, DWORD Token)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+ struct wined3d_stateblock *stateblock;
HRESULT hr;
TRACE("iface %p, token %#x.\n", iface, Token);
@@ -1362,36 +1617,16 @@ static HRESULT WINAPI IDirect3DDevice8Impl_ApplyStateBlock(LPDIRECT3DDEVICE8 ifa
wined3d_mutex_unlock();
return D3DERR_INVALIDCALL;
}
- hr = IWineD3DStateBlock_Apply(stateblock);
+ hr = wined3d_stateblock_capture(stateblock);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_CaptureStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- IWineD3DStateBlock *stateblock;
- HRESULT hr;
-
- TRACE("iface %p, token %#x.\n", iface, Token);
-
- wined3d_mutex_lock();
- stateblock = d3d8_get_object(&This->handle_table, Token - 1, D3D8_HANDLE_SB);
- if (!stateblock)
- {
- WARN("Invalid handle (%#x) passed.\n", Token);
- wined3d_mutex_unlock();
- return D3DERR_INVALIDCALL;
- }
- hr = IWineD3DStateBlock_Capture(stateblock);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DDevice8Impl_DeleteStateBlock(LPDIRECT3DDEVICE8 iface, DWORD Token) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- IWineD3DStateBlock *stateblock;
+static HRESULT WINAPI IDirect3DDevice8Impl_DeleteStateBlock(IDirect3DDevice8 *iface, DWORD Token)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+ struct wined3d_stateblock *stateblock;
TRACE("iface %p, token %#x.\n", iface, Token);
@@ -1405,7 +1640,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeleteStateBlock(LPDIRECT3DDEVICE8 if
return D3DERR_INVALIDCALL;
}
- if (IWineD3DStateBlock_Release((IUnknown *)stateblock))
+ if (wined3d_stateblock_decref(stateblock))
{
ERR("Stateblock %p has references left, this shouldn't happen.\n", stateblock);
}
@@ -1417,8 +1652,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeleteStateBlock(LPDIRECT3DDEVICE8 if
static HRESULT WINAPI IDirect3DDevice8Impl_CreateStateBlock(IDirect3DDevice8 *iface,
D3DSTATEBLOCKTYPE Type, DWORD *handle)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- IWineD3DStateBlock *stateblock;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+ struct wined3d_stateblock *stateblock;
HRESULT hr;
TRACE("iface %p, type %#x, handle %p.\n", iface, Type, handle);
@@ -1432,7 +1667,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateStateBlock(IDirect3DDevice8 *if
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_CreateStateBlock(This->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)Type, &stateblock);
+ hr = wined3d_stateblock_create(This->wined3d_device, (WINED3DSTATEBLOCKTYPE)Type, &stateblock);
if (FAILED(hr))
{
wined3d_mutex_unlock();
@@ -1447,7 +1682,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateStateBlock(IDirect3DDevice8 *if
{
ERR("Failed to allocate a handle.\n");
wined3d_mutex_lock();
- IWineD3DStateBlock_Release(stateblock);
+ wined3d_stateblock_decref(stateblock);
wined3d_mutex_unlock();
return E_FAIL;
}
@@ -1458,28 +1693,32 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateStateBlock(IDirect3DDevice8 *if
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetClipStatus(LPDIRECT3DDEVICE8 iface, CONST D3DCLIPSTATUS8* pClipStatus) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetClipStatus(IDirect3DDevice8 *iface,
+ const D3DCLIPSTATUS8 *pClipStatus)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, clip_status %p.\n", iface, pClipStatus);
/* FIXME: Verify that D3DCLIPSTATUS8 ~= WINED3DCLIPSTATUS */
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus);
+ hr = wined3d_device_set_clip_status(This->wined3d_device, (const WINED3DCLIPSTATUS *)pClipStatus);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetClipStatus(LPDIRECT3DDEVICE8 iface, D3DCLIPSTATUS8* pClipStatus) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetClipStatus(IDirect3DDevice8 *iface,
+ D3DCLIPSTATUS8 *pClipStatus)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, clip_status %p.\n", iface, pClipStatus);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetClipStatus(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus);
+ hr = wined3d_device_get_clip_status(This->wined3d_device, (WINED3DCLIPSTATUS *)pClipStatus);
wined3d_mutex_unlock();
return hr;
@@ -1488,8 +1727,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetClipStatus(LPDIRECT3DDEVICE8 iface
static HRESULT WINAPI IDirect3DDevice8Impl_GetTexture(IDirect3DDevice8 *iface,
DWORD Stage, IDirect3DBaseTexture8 **ppTexture)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- IWineD3DBaseTexture *retTexture;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+ struct wined3d_texture *wined3d_texture;
HRESULT hr;
TRACE("iface %p, stage %u, texture %p.\n", iface, Stage, ppTexture);
@@ -1499,7 +1738,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetTexture(IDirect3DDevice8 *iface,
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, &retTexture);
+ hr = wined3d_device_get_texture(This->wined3d_device, Stage, &wined3d_texture);
if (FAILED(hr))
{
WARN("Failed to get texture for stage %u, hr %#x.\n", Stage, hr);
@@ -1508,11 +1747,11 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetTexture(IDirect3DDevice8 *iface,
return hr;
}
- if (retTexture)
+ if (wined3d_texture)
{
- *ppTexture = IWineD3DBaseTexture_GetParent(retTexture);
+ *ppTexture = wined3d_texture_get_parent(wined3d_texture);
IDirect3DBaseTexture8_AddRef(*ppTexture);
- IWineD3DBaseTexture_Release(retTexture);
+ wined3d_texture_decref(wined3d_texture);
}
else
{
@@ -1523,15 +1762,17 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetTexture(IDirect3DDevice8 *iface,
return D3D_OK;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage, IDirect3DBaseTexture8* pTexture) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(IDirect3DDevice8 *iface, DWORD Stage,
+ IDirect3DBaseTexture8 *pTexture)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, stage %u, texture %p.\n", iface, Stage, pTexture);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetTexture(This->WineD3DDevice, Stage,
- pTexture==NULL ? NULL : ((IDirect3DBaseTexture8Impl *)pTexture)->wineD3DBaseTexture);
+ hr = wined3d_device_set_texture(This->wined3d_device, Stage,
+ pTexture ? ((IDirect3DBaseTexture8Impl *)pTexture)->wined3d_texture : NULL);
wined3d_mutex_unlock();
return hr;
@@ -1575,9 +1816,10 @@ tss_lookup[] =
{FALSE, WINED3DTSS_RESULTARG}, /* 28, D3DTSS_RESULTARG */
};
-static HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD *pValue)
+static HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(IDirect3DDevice8 *iface,
+ DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD *pValue)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
const struct tss_lookup *l;
HRESULT hr;
@@ -1592,16 +1834,19 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVI
l = &tss_lookup[Type];
wined3d_mutex_lock();
- if (l->sampler_state) hr = IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Stage, l->state, pValue);
- else hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, l->state, pValue);
+ if (l->sampler_state)
+ hr = wined3d_device_get_sampler_state(This->wined3d_device, Stage, l->state, pValue);
+ else
+ hr = wined3d_device_get_texture_stage_state(This->wined3d_device, Stage, l->state, pValue);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value)
+static HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(IDirect3DDevice8 *iface,
+ DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
const struct tss_lookup *l;
HRESULT hr;
@@ -1616,21 +1861,25 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE
l = &tss_lookup[Type];
wined3d_mutex_lock();
- if (l->sampler_state) hr = IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Stage, l->state, Value);
- else hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, l->state, Value);
+ if (l->sampler_state)
+ hr = wined3d_device_set_sampler_state(This->wined3d_device, Stage, l->state, Value);
+ else
+ hr = wined3d_device_set_texture_stage_state(This->wined3d_device, Stage, l->state, Value);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_ValidateDevice(LPDIRECT3DDEVICE8 iface, DWORD* pNumPasses) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_ValidateDevice(IDirect3DDevice8 *iface,
+ DWORD *pNumPasses)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, pass_count %p.\n", iface, pNumPasses);
wined3d_mutex_lock();
- hr = IWineD3DDevice_ValidateDevice(This->WineD3DDevice, pNumPasses);
+ hr = wined3d_device_validate_device(This->wined3d_device, pNumPasses);
wined3d_mutex_unlock();
return hr;
@@ -1644,103 +1893,116 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetInfo(IDirect3DDevice8 *iface,
return D3D_OK;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetPaletteEntries(IDirect3DDevice8 *iface,
+ UINT PaletteNumber, const PALETTEENTRY *pEntries)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, palette_idx %u, entries %p.\n", iface, PaletteNumber, pEntries);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
+ hr = wined3d_device_set_palette_entries(This->wined3d_device, PaletteNumber, pEntries);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetPaletteEntries(IDirect3DDevice8 *iface,
+ UINT PaletteNumber, PALETTEENTRY *pEntries)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, palette_idx %u, entries %p.\n", iface, PaletteNumber, pEntries);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
+ hr = wined3d_device_get_palette_entries(This->wined3d_device, PaletteNumber, pEntries);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetCurrentTexturePalette(IDirect3DDevice8 *iface,
+ UINT PaletteNumber)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, palette_idx %u.\n", iface, PaletteNumber);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
+ hr = wined3d_device_set_current_texture_palette(This->wined3d_device, PaletteNumber);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE8 iface, UINT *PaletteNumber) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetCurrentTexturePalette(IDirect3DDevice8 *iface,
+ UINT *PaletteNumber)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, palette_idx %p.\n", iface, PaletteNumber);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
+ hr = wined3d_device_get_current_texture_palette(This->wined3d_device, PaletteNumber);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitive(IDirect3DDevice8 *iface, D3DPRIMITIVETYPE PrimitiveType,
- UINT StartVertex, UINT PrimitiveCount)
+static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitive(IDirect3DDevice8 *iface,
+ D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, primitive_type %#x, start_vertex %u, primitive_count %u.\n",
iface, PrimitiveType, StartVertex, PrimitiveCount);
wined3d_mutex_lock();
- IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
- hr = IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, StartVertex,
+ wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+ hr = wined3d_device_draw_primitive(This->wined3d_device, StartVertex,
vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount));
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,
- UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitive(IDirect3DDevice8 *iface,
+ D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT startIndex,
+ UINT primCount)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, primitive_type %#x, min_vertex_idx %u, vertex_count %u, start_idx %u, primitive_count %u.\n",
iface, PrimitiveType, MinVertexIndex, NumVertices, startIndex, primCount);
wined3d_mutex_lock();
- IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
- hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, startIndex,
+ wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+ hr = wined3d_device_draw_indexed_primitive(This->wined3d_device, startIndex,
vertex_count_from_primitive_count(PrimitiveType, primCount));
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitiveUP(IDirect3DDevice8 *iface,
+ D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, const void *pVertexStreamZeroData,
+ UINT VertexStreamZeroStride)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, primitive_type %#x, primitive_count %u, data %p, stride %u.\n",
iface, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
wined3d_mutex_lock();
- IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
- hr = IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice,
+ wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+ hr = wined3d_device_draw_primitive_up(This->wined3d_device,
vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount),
pVertexStreamZeroData, VertexStreamZeroStride);
wined3d_mutex_unlock();
@@ -1748,11 +2010,12 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE8 ifa
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE8 iface, D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,
- UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,
- D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,
- UINT VertexStreamZeroStride) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitiveUP(IDirect3DDevice8 *iface,
+ D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertexIndices,
+ UINT PrimitiveCount, const void *pIndexData, D3DFORMAT IndexDataFormat,
+ const void *pVertexStreamZeroData, UINT VertexStreamZeroStride)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, primitive_type %#x, min_vertex_idx %u, index_count %u, primitive_count %u,\n"
@@ -1761,8 +2024,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVI
pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
wined3d_mutex_lock();
- IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
- hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice,
+ wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+ hr = wined3d_device_draw_indexed_primitive_up(This->wined3d_device,
vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount), pIndexData,
wined3dformat_from_d3dformat(IndexDataFormat), pVertexStreamZeroData, VertexStreamZeroStride);
wined3d_mutex_unlock();
@@ -1770,8 +2033,11 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVI
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_ProcessVertices(LPDIRECT3DDEVICE8 iface, UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8* pDestBuffer,DWORD Flags) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_ProcessVertices(IDirect3DDevice8 *iface,
+ UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer8 *pDestBuffer,
+ DWORD Flags)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
IDirect3DVertexBuffer8Impl *dest = (IDirect3DVertexBuffer8Impl *) pDestBuffer;
@@ -1779,7 +2045,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_ProcessVertices(LPDIRECT3DDEVICE8 ifa
iface, SrcStartIndex, DestIndex, VertexCount, pDestBuffer, Flags);
wined3d_mutex_lock();
- hr = IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, dest->wineD3DVertexBuffer, NULL, Flags, dest->fvf);
+ hr = wined3d_device_process_vertices(This->wined3d_device, SrcStartIndex, DestIndex,
+ VertexCount, dest->wineD3DVertexBuffer, NULL, Flags, dest->fvf);
wined3d_mutex_unlock();
return hr;
@@ -1788,7 +2055,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_ProcessVertices(LPDIRECT3DDEVICE8 ifa
static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(IDirect3DDevice8 *iface,
const DWORD *declaration, const DWORD *byte_code, DWORD *shader, DWORD usage)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DVertexShader8Impl *object;
DWORD shader_handle;
DWORD handle;
@@ -1898,8 +2165,9 @@ static IDirect3DVertexDeclaration8Impl *IDirect3DDevice8Impl_FindDecl(IDirect3DD
return d3d8_declaration;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(IDirect3DDevice8 *iface, DWORD pShader)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DVertexShader8Impl *shader;
HRESULT hr;
@@ -1909,9 +2177,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 ifa
TRACE("Setting FVF, %#x\n", pShader);
wined3d_mutex_lock();
- IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice,
+ wined3d_device_set_vertex_declaration(This->wined3d_device,
IDirect3DDevice8Impl_FindDecl(This, pShader)->wined3d_vertex_declaration);
- IWineD3DDevice_SetVertexShader(This->WineD3DDevice, NULL);
+ wined3d_device_set_vertex_shader(This->wined3d_device, NULL);
wined3d_mutex_unlock();
return D3D_OK;
@@ -1929,9 +2197,10 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 ifa
return D3DERR_INVALIDCALL;
}
- hr = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice,
+ hr = wined3d_device_set_vertex_declaration(This->wined3d_device,
((IDirect3DVertexDeclaration8Impl *)shader->vertex_declaration)->wined3d_vertex_declaration);
- if (SUCCEEDED(hr)) hr = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, shader->wineD3DVertexShader);
+ if (SUCCEEDED(hr))
+ hr = wined3d_device_set_vertex_shader(This->wined3d_device, shader->wined3d_shader);
wined3d_mutex_unlock();
TRACE("Returning hr %#x\n", hr);
@@ -1941,20 +2210,20 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 ifa
static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(IDirect3DDevice8 *iface, DWORD *ppShader)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- IWineD3DVertexDeclaration *wined3d_declaration;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+ struct wined3d_vertex_declaration *wined3d_declaration;
IDirect3DVertexDeclaration8 *d3d8_declaration;
HRESULT hr;
TRACE("iface %p, shader %p.\n", iface, ppShader);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &wined3d_declaration);
+ hr = wined3d_device_get_vertex_declaration(This->wined3d_device, &wined3d_declaration);
if (FAILED(hr))
{
wined3d_mutex_unlock();
WARN("(%p) : Call to IWineD3DDevice_GetVertexDeclaration failed %#x (device %p)\n",
- This, hr, This->WineD3DDevice);
+ This, hr, This->wined3d_device);
return hr;
}
@@ -1965,8 +2234,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(IDirect3DDevice8 *ifa
return D3D_OK;
}
- d3d8_declaration = IWineD3DVertexDeclaration_GetParent(wined3d_declaration);
- IWineD3DVertexDeclaration_Release(wined3d_declaration);
+ d3d8_declaration = wined3d_vertex_declaration_get_parent(wined3d_declaration);
+ wined3d_vertex_declaration_decref(wined3d_declaration);
wined3d_mutex_unlock();
*ppShader = ((IDirect3DVertexDeclaration8Impl *)d3d8_declaration)->shader_handle;
@@ -1975,10 +2244,11 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(IDirect3DDevice8 *ifa
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(IDirect3DDevice8 *iface, DWORD pShader)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DVertexShader8Impl *shader;
- IWineD3DVertexShader *cur;
+ struct wined3d_shader *cur;
TRACE("iface %p, shader %#x.\n", iface, pShader);
@@ -1992,16 +2262,17 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(LPDIRECT3DDEVICE
return D3DERR_INVALIDCALL;
}
- cur = IWineD3DDevice_GetVertexShader(This->WineD3DDevice);
+ cur = wined3d_device_get_vertex_shader(This->wined3d_device);
if (cur)
{
- if (cur == shader->wineD3DVertexShader) IDirect3DDevice8_SetVertexShader(iface, 0);
- IWineD3DVertexShader_Release(cur);
+ if (cur == shader->wined3d_shader)
+ IDirect3DDevice8_SetVertexShader(iface, 0);
+ wined3d_shader_decref(cur);
}
wined3d_mutex_unlock();
- if (IUnknown_Release((IUnknown *)shader))
+ if (IDirect3DVertexShader8_Release(&shader->IDirect3DVertexShader8_iface))
{
ERR("Shader %p has references left, this shouldn't happen.\n", shader);
}
@@ -2009,8 +2280,10 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(LPDIRECT3DDEVICE
return D3D_OK;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, CONST void* pConstantData, DWORD ConstantCount) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShaderConstant(IDirect3DDevice8 *iface,
+ DWORD Register, const void *pConstantData, DWORD ConstantCount)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, register %u, data %p, count %u.\n",
@@ -2023,14 +2296,16 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShaderConstant(LPDIRECT3DDEV
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount);
+ hr = wined3d_device_set_vs_consts_f(This->wined3d_device, Register, pConstantData, ConstantCount);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, void* pConstantData, DWORD ConstantCount) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderConstant(IDirect3DDevice8 *iface,
+ DWORD Register, void *pConstantData, DWORD ConstantCount)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, register %u, data %p, count %u.\n",
@@ -2043,14 +2318,16 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderConstant(LPDIRECT3DDEV
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount);
+ hr = wined3d_device_get_vs_consts_f(This->wined3d_device, Register, pConstantData, ConstantCount);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderDeclaration(LPDIRECT3DDEVICE8 iface, DWORD pVertexShader, void* pData, DWORD* pSizeOfData) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderDeclaration(IDirect3DDevice8 *iface,
+ DWORD pVertexShader, void *pData, DWORD *pSizeOfData)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DVertexDeclaration8Impl *declaration;
IDirect3DVertexShader8Impl *shader;
@@ -2086,8 +2363,10 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderDeclaration(LPDIRECT3D
return D3D_OK;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(LPDIRECT3DDEVICE8 iface, DWORD pVertexShader, void* pData, DWORD* pSizeOfData) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(IDirect3DDevice8 *iface,
+ DWORD pVertexShader, void *pData, DWORD *pSizeOfData)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DVertexShader8Impl *shader = NULL;
HRESULT hr;
@@ -2104,21 +2383,23 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(LPDIRECT3DDEV
return D3DERR_INVALIDCALL;
}
- if (!shader->wineD3DVertexShader)
+ if (!shader->wined3d_shader)
{
wined3d_mutex_unlock();
*pSizeOfData = 0;
return D3D_OK;
}
- hr = IWineD3DVertexShader_GetFunction(shader->wineD3DVertexShader, pData, pSizeOfData);
+ hr = wined3d_shader_get_byte_code(shader->wined3d_shader, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8* pIndexData, UINT baseVertexIndex) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(IDirect3DDevice8 *iface,
+ IDirect3DIndexBuffer8 *pIndexData, UINT baseVertexIndex)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
IDirect3DIndexBuffer8Impl *ib = (IDirect3DIndexBuffer8Impl *)pIndexData;
@@ -2131,8 +2412,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, I
* problem)
*/
wined3d_mutex_lock();
- IWineD3DDevice_SetBaseVertexIndex(This->WineD3DDevice, baseVertexIndex);
- hr = IWineD3DDevice_SetIndexBuffer(This->WineD3DDevice,
+ wined3d_device_set_base_vertex_index(This->wined3d_device, baseVertexIndex);
+ hr = wined3d_device_set_index_buffer(This->wined3d_device,
ib ? ib->wineD3DIndexBuffer : NULL,
ib ? ib->format : WINED3DFMT_UNKNOWN);
wined3d_mutex_unlock();
@@ -2143,8 +2424,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetIndices(LPDIRECT3DDEVICE8 iface, I
static HRESULT WINAPI IDirect3DDevice8Impl_GetIndices(IDirect3DDevice8 *iface,
IDirect3DIndexBuffer8 **ppIndexData, UINT *pBaseVertexIndex)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- IWineD3DBuffer *retIndexData = NULL;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+ struct wined3d_buffer *retIndexData = NULL;
HRESULT hr;
TRACE("iface %p, buffer %p, base_vertex_index %p.\n", iface, ppIndexData, pBaseVertexIndex);
@@ -2155,13 +2436,13 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetIndices(IDirect3DDevice8 *iface,
/* The case from UINT to INT is safe because d3d8 will never set negative values */
wined3d_mutex_lock();
- IWineD3DDevice_GetBaseVertexIndex(This->WineD3DDevice, (INT *) pBaseVertexIndex);
- hr = IWineD3DDevice_GetIndexBuffer(This->WineD3DDevice, &retIndexData);
+ *pBaseVertexIndex = wined3d_device_get_base_vertex_index(This->wined3d_device);
+ hr = wined3d_device_get_index_buffer(This->wined3d_device, &retIndexData);
if (SUCCEEDED(hr) && retIndexData)
{
- *ppIndexData = IWineD3DBuffer_GetParent(retIndexData);
+ *ppIndexData = wined3d_buffer_get_parent(retIndexData);
IDirect3DIndexBuffer8_AddRef(*ppIndexData);
- IWineD3DBuffer_Release(retIndexData);
+ wined3d_buffer_decref(retIndexData);
} else {
if (FAILED(hr)) FIXME("Call to GetIndices failed\n");
*ppIndexData = NULL;
@@ -2174,7 +2455,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetIndices(IDirect3DDevice8 *iface,
static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(IDirect3DDevice8 *iface,
const DWORD *byte_code, DWORD *shader)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DPixelShader8Impl *object;
DWORD shader_handle;
DWORD handle;
@@ -2225,8 +2506,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(IDirect3DDevice8 *i
return D3D_OK;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(IDirect3DDevice8 *iface, DWORD pShader)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DPixelShader8Impl *shader;
HRESULT hr;
@@ -2236,7 +2518,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(LPDIRECT3DDEVICE8 ifac
if (!pShader)
{
- hr = IWineD3DDevice_SetPixelShader(This->WineD3DDevice, NULL);
+ hr = wined3d_device_set_pixel_shader(This->wined3d_device, NULL);
wined3d_mutex_unlock();
return hr;
}
@@ -2250,7 +2532,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(LPDIRECT3DDEVICE8 ifac
}
TRACE("(%p) : Setting shader %p\n", This, shader);
- hr = IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader->wineD3DPixelShader);
+ hr = wined3d_device_set_pixel_shader(This->wined3d_device, shader->wined3d_shader);
wined3d_mutex_unlock();
return hr;
@@ -2258,8 +2540,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShader(LPDIRECT3DDEVICE8 ifac
static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(IDirect3DDevice8 *iface, DWORD *ppShader)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- IWineD3DPixelShader *object;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+ struct wined3d_shader *object;
TRACE("iface %p, shader %p.\n", iface, ppShader);
@@ -2269,12 +2551,12 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(IDirect3DDevice8 *ifac
}
wined3d_mutex_lock();
- object = IWineD3DDevice_GetPixelShader(This->WineD3DDevice);
+ object = wined3d_device_get_pixel_shader(This->wined3d_device);
if (object)
{
IDirect3DPixelShader8Impl *d3d8_shader;
- d3d8_shader = IWineD3DPixelShader_GetParent(object);
- IWineD3DPixelShader_Release(object);
+ d3d8_shader = wined3d_shader_get_parent(object);
+ wined3d_shader_decref(object);
*ppShader = d3d8_shader->handle;
}
else
@@ -2288,10 +2570,11 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(IDirect3DDevice8 *ifac
return D3D_OK;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(IDirect3DDevice8 *iface, DWORD pShader)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DPixelShader8Impl *shader;
- IWineD3DPixelShader *cur;
+ struct wined3d_shader *cur;
TRACE("iface %p, shader %#x.\n", iface, pShader);
@@ -2305,16 +2588,17 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(LPDIRECT3DDEVICE8 i
return D3DERR_INVALIDCALL;
}
- cur = IWineD3DDevice_GetPixelShader(This->WineD3DDevice);
+ cur = wined3d_device_get_pixel_shader(This->wined3d_device);
if (cur)
{
- if (cur == shader->wineD3DPixelShader) IDirect3DDevice8_SetPixelShader(iface, 0);
- IWineD3DPixelShader_Release(cur);
+ if (cur == shader->wined3d_shader)
+ IDirect3DDevice8_SetPixelShader(iface, 0);
+ wined3d_shader_decref(cur);
}
wined3d_mutex_unlock();
- if (IUnknown_Release((IUnknown *)shader))
+ if (IDirect3DPixelShader8_Release(&shader->IDirect3DPixelShader8_iface))
{
ERR("Shader %p has references left, this shouldn't happen.\n", shader);
}
@@ -2322,36 +2606,42 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(LPDIRECT3DDEVICE8 i
return D3D_OK;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, CONST void* pConstantData, DWORD ConstantCount) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShaderConstant(IDirect3DDevice8 *iface,
+ DWORD Register, const void *pConstantData, DWORD ConstantCount)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, register %u, data %p, count %u.\n",
iface, Register, pConstantData, ConstantCount);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount);
+ hr = wined3d_device_set_ps_consts_f(This->wined3d_device, Register, pConstantData, ConstantCount);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, void* pConstantData, DWORD ConstantCount) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderConstant(IDirect3DDevice8 *iface,
+ DWORD Register, void *pConstantData, DWORD ConstantCount)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, register %u, data %p, count %u.\n",
iface, Register, pConstantData, ConstantCount);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount);
+ hr = wined3d_device_get_ps_consts_f(This->wined3d_device, Register, pConstantData, ConstantCount);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderFunction(LPDIRECT3DDEVICE8 iface, DWORD pPixelShader, void* pData, DWORD* pSizeOfData) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderFunction(IDirect3DDevice8 *iface,
+ DWORD pPixelShader, void *pData, DWORD *pSizeOfData)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IDirect3DPixelShader8Impl *shader = NULL;
HRESULT hr;
@@ -2368,64 +2658,73 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderFunction(LPDIRECT3DDEVI
return D3DERR_INVALIDCALL;
}
- hr = IWineD3DPixelShader_GetFunction(shader->wineD3DPixelShader, pData, pSizeOfData);
+ hr = wined3d_shader_get_byte_code(shader->wined3d_shader, pData, pSizeOfData);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_DrawRectPatch(LPDIRECT3DDEVICE8 iface, UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_DrawRectPatch(IDirect3DDevice8 *iface, UINT Handle,
+ const float *pNumSegs, const D3DRECTPATCH_INFO *pRectPatchInfo)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, handle %#x, segment_count %p, patch_info %p.\n",
iface, Handle, pNumSegs, pRectPatchInfo);
wined3d_mutex_lock();
- hr = IWineD3DDevice_DrawRectPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DRECTPATCH_INFO *)pRectPatchInfo);
+ hr = wined3d_device_draw_rect_patch(This->wined3d_device, Handle,
+ pNumSegs, (const WINED3DRECTPATCH_INFO *)pRectPatchInfo);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_DrawTriPatch(LPDIRECT3DDEVICE8 iface, UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_DrawTriPatch(IDirect3DDevice8 *iface, UINT Handle,
+ const float *pNumSegs, const D3DTRIPATCH_INFO *pTriPatchInfo)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, handle %#x, segment_count %p, patch_info %p.\n",
iface, Handle, pNumSegs, pTriPatchInfo);
wined3d_mutex_lock();
- hr = IWineD3DDevice_DrawTriPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DTRIPATCH_INFO *)pTriPatchInfo);
+ hr = wined3d_device_draw_tri_patch(This->wined3d_device, Handle,
+ pNumSegs, (const WINED3DTRIPATCH_INFO *)pTriPatchInfo);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_DeletePatch(LPDIRECT3DDEVICE8 iface, UINT Handle) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_DeletePatch(IDirect3DDevice8 *iface, UINT Handle)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, handle %#x.\n", iface, Handle);
wined3d_mutex_lock();
- hr = IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle);
+ hr = wined3d_device_delete_patch(This->wined3d_device, Handle);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetStreamSource(LPDIRECT3DDEVICE8 iface, UINT StreamNumber,IDirect3DVertexBuffer8* pStreamData,UINT Stride) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice8Impl_SetStreamSource(IDirect3DDevice8 *iface,
+ UINT StreamNumber, IDirect3DVertexBuffer8 *pStreamData, UINT Stride)
+{
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, stream_idx %u, buffer %p, stride %u.\n",
iface, StreamNumber, pStreamData, Stride);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetStreamSource(This->WineD3DDevice, StreamNumber,
- NULL == pStreamData ? NULL : ((IDirect3DVertexBuffer8Impl *)pStreamData)->wineD3DVertexBuffer,
- 0/* Offset in bytes */, Stride);
+ hr = wined3d_device_set_stream_source(This->wined3d_device, StreamNumber,
+ pStreamData ? ((IDirect3DVertexBuffer8Impl *)pStreamData)->wineD3DVertexBuffer : NULL,
+ 0/* Offset in bytes */, Stride);
wined3d_mutex_unlock();
return hr;
@@ -2434,8 +2733,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetStreamSource(LPDIRECT3DDEVICE8 ifa
static HRESULT WINAPI IDirect3DDevice8Impl_GetStreamSource(IDirect3DDevice8 *iface,
UINT StreamNumber, IDirect3DVertexBuffer8 **pStream, UINT *pStride)
{
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- IWineD3DBuffer *retStream = NULL;
+ IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
+ struct wined3d_buffer *retStream = NULL;
HRESULT hr;
TRACE("iface %p, stream_idx %u, buffer %p, stride %p.\n",
@@ -2446,13 +2745,13 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetStreamSource(IDirect3DDevice8 *ifa
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber,
+ hr = wined3d_device_get_stream_source(This->wined3d_device, StreamNumber,
&retStream, 0 /* Offset in bytes */, pStride);
if (SUCCEEDED(hr) && retStream)
{
- *pStream = IWineD3DBuffer_GetParent(retStream);
+ *pStream = wined3d_buffer_get_parent(retStream);
IDirect3DVertexBuffer8_AddRef(*pStream);
- IWineD3DBuffer_Release(retStream);
+ wined3d_buffer_decref(retStream);
}
else
{
@@ -2565,148 +2864,129 @@ static const IDirect3DDevice8Vtbl Direct3DDevice8_Vtbl =
IDirect3DDevice8Impl_DeletePatch
};
-/* IWineD3DDeviceParent IUnknown methods */
-
-static inline struct IDirect3DDevice8Impl *device_from_device_parent(IWineD3DDeviceParent *iface)
+static inline IDirect3DDevice8Impl *device_from_device_parent(struct wined3d_device_parent *device_parent)
{
- return (struct IDirect3DDevice8Impl *)((char*)iface
- - FIELD_OFFSET(struct IDirect3DDevice8Impl, device_parent_vtbl));
+ return CONTAINING_RECORD(device_parent, IDirect3DDevice8Impl, device_parent);
}
-static HRESULT STDMETHODCALLTYPE device_parent_QueryInterface(IWineD3DDeviceParent *iface, REFIID riid, void **object)
+static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
+ struct wined3d_device *device)
{
- struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
- return IDirect3DDevice8Impl_QueryInterface((IDirect3DDevice8 *)This, riid, object);
+ TRACE("device_parent %p, device %p\n", device_parent, device);
}
-static ULONG STDMETHODCALLTYPE device_parent_AddRef(IWineD3DDeviceParent *iface)
+static HRESULT CDECL device_parent_create_surface(struct wined3d_device_parent *device_parent,
+ void *container_parent, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
+ WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, struct wined3d_surface **surface)
{
- struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
- return IDirect3DDevice8Impl_AddRef((IDirect3DDevice8 *)This);
-}
-
-static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface)
-{
- struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
- return IDirect3DDevice8Impl_Release((IDirect3DDevice8 *)This);
-}
-
-/* IWineD3DDeviceParent methods */
-
-static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
-{
- TRACE("iface %p, device %p\n", iface, device);
-}
-
-static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
- WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
-{
- struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
+ IDirect3DDevice8Impl *device = device_from_device_parent(device_parent);
IDirect3DSurface8Impl *d3d_surface;
BOOL lockable = TRUE;
HRESULT hr;
- TRACE("iface %p, superior %p, width %u, height %u, format %#x, usage %#x,\n"
- "\tpool %#x, level %u, face %u, surface %p\n",
- iface, superior, width, height, format, usage, pool, level, face, surface);
+ TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n"
+ "\tpool %#x, level %u, face %u, surface %p.\n",
+ device_parent, container_parent, width, height, format, usage, pool, level, face, surface);
if (pool == WINED3DPOOL_DEFAULT && !(usage & WINED3DUSAGE_DYNAMIC)) lockable = FALSE;
- hr = IDirect3DDevice8Impl_CreateSurface((IDirect3DDevice8 *)This, width, height,
+ hr = IDirect3DDevice8Impl_CreateSurface(device, width, height,
d3dformat_from_wined3dformat(format), lockable, FALSE /* Discard */, level,
(IDirect3DSurface8 **)&d3d_surface, usage, pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
if (FAILED(hr))
{
- ERR("(%p) CreateSurface failed, returning %#x\n", iface, hr);
+ WARN("Failed to create surface, hr %#x.\n", hr);
return hr;
}
- *surface = d3d_surface->wineD3DSurface;
- IWineD3DSurface_AddRef(*surface);
+ *surface = d3d_surface->wined3d_surface;
+ wined3d_surface_incref(*surface);
- d3d_surface->container = superior;
+ d3d_surface->container = container_parent;
IUnknown_Release(d3d_surface->parentDevice);
d3d_surface->parentDevice = NULL;
IDirect3DSurface8_Release((IDirect3DSurface8 *)d3d_surface);
- d3d_surface->forwardReference = superior;
+ d3d_surface->forwardReference = container_parent;
return hr;
}
-static HRESULT STDMETHODCALLTYPE device_parent_CreateRenderTarget(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, enum wined3d_format_id format,
+static HRESULT CDECL device_parent_create_rendertarget(struct wined3d_device_parent *device_parent,
+ void *container_parent, UINT width, UINT height, enum wined3d_format_id format,
WINED3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality, BOOL lockable,
- IWineD3DSurface **surface)
+ struct wined3d_surface **surface)
{
- struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
+ IDirect3DDevice8Impl *device = device_from_device_parent(device_parent);
IDirect3DSurface8Impl *d3d_surface;
HRESULT hr;
- TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
- "\tmultisample_quality %u, lockable %u, surface %p\n",
- iface, superior, width, height, format, multisample_type, multisample_quality, lockable, surface);
+ TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, multisample_type %#x,\n"
+ "\tmultisample_quality %u, lockable %u, surface %p.\n",
+ device_parent, container_parent, width, height, format,
+ multisample_type, multisample_quality, lockable, surface);
- hr = IDirect3DDevice8_CreateRenderTarget((IDirect3DDevice8 *)This, width, height,
+ hr = IDirect3DDevice8_CreateRenderTarget(&device->IDirect3DDevice8_iface, width, height,
d3dformat_from_wined3dformat(format), multisample_type, lockable, (IDirect3DSurface8 **)&d3d_surface);
if (FAILED(hr))
{
- ERR("(%p) CreateRenderTarget failed, returning %#x\n", iface, hr);
+ WARN("Failed to create rendertarget, hr %#x.\n", hr);
return hr;
}
- *surface = d3d_surface->wineD3DSurface;
- IWineD3DSurface_AddRef(*surface);
+ *surface = d3d_surface->wined3d_surface;
+ wined3d_surface_incref(*surface);
- d3d_surface->container = (IUnknown *)This;
+ d3d_surface->container = (IUnknown *)&device->IDirect3DDevice8_iface;
/* Implicit surfaces are created with an refcount of 0 */
IUnknown_Release((IUnknown *)d3d_surface);
return hr;
}
-static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent *iface,
+static HRESULT CDECL device_parent_create_depth_stencil(struct wined3d_device_parent *device_parent,
UINT width, UINT height, enum wined3d_format_id format, WINED3DMULTISAMPLE_TYPE multisample_type,
- DWORD multisample_quality, BOOL discard, IWineD3DSurface **surface)
+ DWORD multisample_quality, BOOL discard, struct wined3d_surface **surface)
{
- struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
+ IDirect3DDevice8Impl *device = device_from_device_parent(device_parent);
IDirect3DSurface8Impl *d3d_surface;
HRESULT hr;
- TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x,\n"
- "\tmultisample_quality %u, discard %u, surface %p\n",
- iface, width, height, format, multisample_type, multisample_quality, discard, surface);
+ TRACE("device_parent %p, width %u, height %u, format %#x, multisample_type %#x,\n"
+ "\tmultisample_quality %u, discard %u, surface %p.\n",
+ device_parent, width, height, format, multisample_type, multisample_quality, discard, surface);
- hr = IDirect3DDevice8_CreateDepthStencilSurface((IDirect3DDevice8 *)This, width, height,
+ hr = IDirect3DDevice8_CreateDepthStencilSurface(&device->IDirect3DDevice8_iface, width, height,
d3dformat_from_wined3dformat(format), multisample_type, (IDirect3DSurface8 **)&d3d_surface);
if (FAILED(hr))
{
- ERR("(%p) CreateDepthStencilSurface failed, returning %#x\n", iface, hr);
+ WARN("Failed to create depth/stencil surface, hr %#x.\n", hr);
return hr;
}
- *surface = d3d_surface->wineD3DSurface;
- IWineD3DSurface_AddRef(*surface);
+ *surface = d3d_surface->wined3d_surface;
+ wined3d_surface_incref(*surface);
- d3d_surface->container = (IUnknown *)This;
+ d3d_surface->container = (IUnknown *)&device->IDirect3DDevice8_iface;
/* Implicit surfaces are created with an refcount of 0 */
IUnknown_Release((IUnknown *)d3d_surface);
return hr;
}
-static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
- WINED3DPOOL pool, DWORD usage, IWineD3DVolume **volume)
+static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *device_parent,
+ void *container_parent, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
+ WINED3DPOOL pool, DWORD usage, struct wined3d_volume **volume)
{
- struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
+ IDirect3DDevice8Impl *device = device_from_device_parent(device_parent);
IDirect3DVolume8Impl *object;
HRESULT hr;
- TRACE("iface %p, superior %p, width %u, height %u, depth %u, format %#x, pool %#x, usage %#x, volume %p\n",
- iface, superior, width, height, depth, format, pool, usage, volume);
+ TRACE("device_parent %p, container_parent %p, width %u, height %u, depth %u, "
+ "format %#x, pool %#x, usage %#x, volume %p.\n",
+ device_parent, container_parent, width, height, depth,
+ format, pool, usage, volume);
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
@@ -2717,7 +2997,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent
return D3DERR_OUTOFVIDEOMEMORY;
}
- hr = volume_init(object, This, width, height, depth, usage, format, pool);
+ hr = volume_init(object, device, width, height, depth, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize volume, hr %#x.\n", hr);
@@ -2725,27 +3005,27 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent
return hr;
}
- *volume = object->wineD3DVolume;
- IWineD3DVolume_AddRef(*volume);
- IDirect3DVolume8_Release((IDirect3DVolume8 *)object);
+ *volume = object->wined3d_volume;
+ wined3d_volume_incref(*volume);
+ IDirect3DVolume8_Release(&object->IDirect3DVolume8_iface);
- object->container = superior;
- object->forwardReference = superior;
+ object->container = container_parent;
+ object->forwardReference = container_parent;
- TRACE("(%p) Created volume %p\n", iface, object);
+ TRACE("Created volume %p.\n", object);
return hr;
}
-static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDeviceParent *iface,
- WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
+static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
+ WINED3DPRESENT_PARAMETERS *present_parameters, struct wined3d_swapchain **swapchain)
{
- struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
- IDirect3DSwapChain8Impl *d3d_swapchain;
+ IDirect3DDevice8Impl *device = device_from_device_parent(device_parent);
D3DPRESENT_PARAMETERS local_parameters;
+ IDirect3DSwapChain8 *d3d_swapchain;
HRESULT hr;
- TRACE("iface %p, present_parameters %p, swapchain %p\n", iface, present_parameters, swapchain);
+ TRACE("device_parent %p, present_parameters %p, swapchain %p.\n", device_parent, present_parameters, swapchain);
/* Copy the presentation parameters */
local_parameters.BackBufferWidth = present_parameters->BackBufferWidth;
@@ -2762,18 +3042,18 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
local_parameters.FullScreen_RefreshRateInHz = present_parameters->FullScreen_RefreshRateInHz;
local_parameters.FullScreen_PresentationInterval = present_parameters->PresentationInterval;
- hr = IDirect3DDevice8_CreateAdditionalSwapChain((IDirect3DDevice8 *)This,
- &local_parameters, (IDirect3DSwapChain8 **)&d3d_swapchain);
+ hr = IDirect3DDevice8_CreateAdditionalSwapChain(&device->IDirect3DDevice8_iface,
+ &local_parameters, &d3d_swapchain);
if (FAILED(hr))
{
- ERR("(%p) CreateAdditionalSwapChain failed, returning %#x\n", iface, hr);
+ WARN("Failed to create swapchain, hr %#x.\n", hr);
*swapchain = NULL;
return hr;
}
- *swapchain = d3d_swapchain->wineD3DSwapChain;
- IUnknown_Release(d3d_swapchain->parentDevice);
- d3d_swapchain->parentDevice = NULL;
+ *swapchain = ((IDirect3DSwapChain8Impl *)d3d_swapchain)->wined3d_swapchain;
+ wined3d_swapchain_incref(*swapchain);
+ IDirect3DSwapChain8_Release(d3d_swapchain);
/* Copy back the presentation parameters */
present_parameters->BackBufferWidth = local_parameters.BackBufferWidth;
@@ -2793,19 +3073,14 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
return hr;
}
-static const IWineD3DDeviceParentVtbl d3d8_wined3d_device_parent_vtbl =
+static const struct wined3d_device_parent_ops d3d8_wined3d_device_parent_ops =
{
- /* IUnknown methods */
- device_parent_QueryInterface,
- device_parent_AddRef,
- device_parent_Release,
- /* IWineD3DDeviceParent methods */
- device_parent_WineD3DDeviceCreated,
- device_parent_CreateSurface,
- device_parent_CreateRenderTarget,
- device_parent_CreateDepthStencilSurface,
- device_parent_CreateVolume,
- device_parent_CreateSwapChain,
+ device_parent_wined3d_device_created,
+ device_parent_create_surface,
+ device_parent_create_rendertarget,
+ device_parent_create_depth_stencil,
+ device_parent_create_volume,
+ device_parent_create_swapchain,
};
static void setup_fpu(void)
@@ -2820,14 +3095,14 @@ static void setup_fpu(void)
#endif
}
-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)
{
WINED3DPRESENT_PARAMETERS wined3d_parameters;
HRESULT hr;
- device->lpVtbl = &Direct3DDevice8_Vtbl;
- device->device_parent_vtbl = &d3d8_wined3d_device_parent_vtbl;
+ device->IDirect3DDevice8_iface.lpVtbl = &Direct3DDevice8_Vtbl;
+ device->device_parent.ops = &d3d8_wined3d_device_parent_ops;
device->ref = 1;
device->handle_table.entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
D3D8_INITIAL_HANDLE_TABLE_SIZE * sizeof(*device->handle_table.entries));
@@ -2841,8 +3116,8 @@ HRESULT device_init(IDirect3DDevice8Impl *device, IWineD3D *wined3d, UINT adapte
if (!(flags & D3DCREATE_FPU_PRESERVE)) setup_fpu();
wined3d_mutex_lock();
- hr = IWineD3D_CreateDevice(wined3d, adapter, device_type, focus_window, flags,
- (IWineD3DDeviceParent *)&device->device_parent_vtbl, &device->WineD3DDevice);
+ hr = wined3d_device_create(wined3d, adapter, device_type, focus_window, flags,
+ &device->device_parent, &device->wined3d_device);
if (FAILED(hr))
{
WARN("Failed to create wined3d device, hr %#x.\n", hr);
@@ -2853,18 +3128,28 @@ HRESULT device_init(IDirect3DDevice8Impl *device, IWineD3D *wined3d, UINT adapte
if (!parameters->Windowed)
{
- if (!focus_window) focus_window = parameters->hDeviceWindow;
- if (FAILED(hr = IWineD3DDevice_AcquireFocusWindow(device->WineD3DDevice, focus_window)))
+ HWND device_window = parameters->hDeviceWindow;
+
+ if (!focus_window)
+ focus_window = device_window;
+ if (FAILED(hr = wined3d_device_acquire_focus_window(device->wined3d_device, focus_window)))
{
ERR("Failed to acquire focus window, hr %#x.\n", hr);
- IWineD3DDevice_Release(device->WineD3DDevice);
+ wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
return hr;
}
+
+ if (!device_window)
+ device_window = focus_window;
+ wined3d_device_setup_fullscreen_window(device->wined3d_device, device_window,
+ parameters->BackBufferWidth,
+ parameters->BackBufferHeight);
}
- if (flags & D3DCREATE_MULTITHREADED) IWineD3DDevice_SetMultithreaded(device->WineD3DDevice);
+ if (flags & D3DCREATE_MULTITHREADED)
+ wined3d_device_set_multithreaded(device->wined3d_device);
wined3d_parameters.BackBufferWidth = parameters->BackBufferWidth;
wined3d_parameters.BackBufferHeight = parameters->BackBufferHeight;
@@ -2882,18 +3167,18 @@ HRESULT device_init(IDirect3DDevice8Impl *device, IWineD3D *wined3d, UINT adapte
wined3d_parameters.PresentationInterval = parameters->FullScreen_PresentationInterval;
wined3d_parameters.AutoRestoreDisplayMode = TRUE;
- hr = IWineD3DDevice_Init3D(device->WineD3DDevice, &wined3d_parameters);
+ hr = wined3d_device_init_3d(device->wined3d_device, &wined3d_parameters);
if (FAILED(hr))
{
WARN("Failed to initialize 3D, hr %#x.\n", hr);
- IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
- IWineD3DDevice_Release(device->WineD3DDevice);
+ wined3d_device_release_focus_window(device->wined3d_device);
+ wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
return hr;
}
- hr = IWineD3DDevice_SetRenderState(device->WineD3DDevice, WINED3DRS_POINTSIZE_MIN, 0);
+ hr = wined3d_device_set_render_state(device->wined3d_device, WINED3DRS_POINTSIZE_MIN, 0);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@@ -2928,9 +3213,9 @@ HRESULT device_init(IDirect3DDevice8Impl *device, IWineD3D *wined3d, UINT adapte
err:
wined3d_mutex_lock();
- IWineD3DDevice_Uninit3D(device->WineD3DDevice, D3D8CB_DestroySwapChain);
- IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
- IWineD3DDevice_Release(device->WineD3DDevice);
+ wined3d_device_uninit_3d(device->wined3d_device);
+ wined3d_device_release_focus_window(device->wined3d_device);
+ wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, device->handle_table.entries);
return hr;
diff --git a/reactos/dll/directx/wine/d3d8/directx.c b/reactos/dll/directx/wine/d3d8/directx.c
index 8bcd5abf9c9..249399e8452 100644
--- a/reactos/dll/directx/wine/d3d8/directx.c
+++ b/reactos/dll/directx/wine/d3d8/directx.c
@@ -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;
}
diff --git a/reactos/dll/directx/wine/d3d8/shader.c b/reactos/dll/directx/wine/d3d8/shader.c
index a59f10b57b4..e04c2a2960f 100644
--- a/reactos/dll/directx/wine/d3d8/shader.c
+++ b/reactos/dll/directx/wine/d3d8/shader.c
@@ -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))
{
diff --git a/reactos/dll/directx/wine/d3d8/surface.c b/reactos/dll/directx/wine/d3d8/surface.c
index 6e59bd65f75..8a07244e604 100644
--- a/reactos/dll/directx/wine/d3d8/surface.c
+++ b/reactos/dll/directx/wine/d3d8/surface.c
@@ -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;
diff --git a/reactos/dll/directx/wine/d3d8/swapchain.c b/reactos/dll/directx/wine/d3d8/swapchain.c
index 1c2a5357824..866335fcdc8 100644
--- a/reactos/dll/directx/wine/d3d8/swapchain.c
+++ b/reactos/dll/directx/wine/d3d8/swapchain.c
@@ -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;
diff --git a/reactos/dll/directx/wine/d3d8/texture.c b/reactos/dll/directx/wine/d3d8/texture.c
index a8421604862..1b9db9d2303 100644
--- a/reactos/dll/directx/wine/d3d8/texture.c
+++ b/reactos/dll/directx/wine/d3d8/texture.c
@@ -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;
diff --git a/reactos/dll/directx/wine/d3d8/vertexdeclaration.c b/reactos/dll/directx/wine/d3d8/vertexdeclaration.c
index 58573a50f84..78a59d11ad5 100644
--- a/reactos/dll/directx/wine/d3d8/vertexdeclaration.c
+++ b/reactos/dll/directx/wine/d3d8/vertexdeclaration.c
@@ -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))
{
diff --git a/reactos/dll/directx/wine/d3d8/volume.c b/reactos/dll/directx/wine/d3d8/volume.c
index 1705822cf5d..2726880aa83 100644
--- a/reactos/dll/directx/wine/d3d8/volume.c
+++ b/reactos/dll/directx/wine/d3d8/volume.c
@@ -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);
diff --git a/reactos/dll/directx/wine/d3d8/volumetexture.c b/reactos/dll/directx/wine/d3d8/volumetexture.c
index bd72d68e916..08e36807bba 100644
--- a/reactos/dll/directx/wine/d3d8/volumetexture.c
+++ b/reactos/dll/directx/wine/d3d8/volumetexture.c
@@ -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;
diff --git a/reactos/dll/directx/wine/d3d9/buffer.c b/reactos/dll/directx/wine/d3d9/buffer.c
index ac8c2443e33..d9a5564d577 100644
--- a/reactos/dll/directx/wine/d3d9/buffer.c
+++ b/reactos/dll/directx/wine/d3d9/buffer.c
@@ -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;
diff --git a/reactos/dll/directx/wine/d3d9/cubetexture.c b/reactos/dll/directx/wine/d3d9/cubetexture.c
index 508784f8958..1f5e27b8033 100644
--- a/reactos/dll/directx/wine/d3d9/cubetexture.c
+++ b/reactos/dll/directx/wine/d3d9/cubetexture.c
@@ -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;
diff --git a/reactos/dll/directx/wine/d3d9/d3d9_main.c b/reactos/dll/directx/wine/d3d9/d3d9_main.c
index c405a5747d7..0d3ecec99d4 100644
--- a/reactos/dll/directx/wine/d3d9/d3d9_main.c
+++ b/reactos/dll/directx/wine/d3d9/d3d9_main.c
@@ -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;
}
diff --git a/reactos/dll/directx/wine/d3d9/d3d9_private.h b/reactos/dll/directx/wine/d3d9/d3d9_private.h
index f1bc1a0e23d..23e7f00353e 100644
--- a/reactos/dll/directx/wine/d3d9/d3d9_private.h
+++ b/reactos/dll/directx/wine/d3d9/d3d9_private.h
@@ -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,
diff --git a/reactos/dll/directx/wine/d3d9/device.c b/reactos/dll/directx/wine/d3d9/device.c
index c788b987c8a..2af2c82460a 100644
--- a/reactos/dll/directx/wine/d3d9/device.c
+++ b/reactos/dll/directx/wine/d3d9/device.c
@@ -181,21 +181,15 @@ static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, U
}
}
-static ULONG WINAPI D3D9CB_DestroySwapChain(IWineD3DSwapChain *swapchain)
+static inline IDirect3DDevice9Impl *impl_from_IDirect3DDevice9Ex(IDirect3DDevice9Ex *iface)
{
- IDirect3DSwapChain9Impl *parent;
-
- TRACE("swapchain %p.\n", swapchain);
-
- parent = IWineD3DSwapChain_GetParent(swapchain);
- parent->isImplicit = FALSE;
- IDirect3DSwapChain9_AddRef((IDirect3DSwapChain9 *)parent);
- return IDirect3DSwapChain9_Release((IDirect3DSwapChain9 *)parent);
+ return CONTAINING_RECORD(iface, IDirect3DDevice9Impl, IDirect3DDevice9Ex_iface);
}
-/* IDirect3D IUnknown parts follow: */
-static HRESULT WINAPI IDirect3DDevice9Impl_QueryInterface(LPDIRECT3DDEVICE9EX iface, REFIID riid, LPVOID* ppobj) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_QueryInterface(IDirect3DDevice9Ex *iface, REFIID riid,
+ void **ppobj)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3D9 *d3d;
IDirect3D9Impl *d3dimpl;
@@ -228,20 +222,14 @@ static HRESULT WINAPI IDirect3DDevice9Impl_QueryInterface(LPDIRECT3DDEVICE9EX if
}
}
- if (IsEqualGUID(riid, &IID_IWineD3DDeviceParent))
- {
- IUnknown_AddRef((IUnknown *)&This->device_parent_vtbl);
- *ppobj = &This->device_parent_vtbl;
- return S_OK;
- }
-
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL;
return E_NOINTERFACE;
}
-static ULONG WINAPI IDirect3DDevice9Impl_AddRef(LPDIRECT3DDEVICE9EX iface) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static ULONG WINAPI IDirect3DDevice9Impl_AddRef(IDirect3DDevice9Ex *iface)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("%p increasing refcount to %u.\n", iface, ref);
@@ -249,8 +237,9 @@ static ULONG WINAPI IDirect3DDevice9Impl_AddRef(LPDIRECT3DDEVICE9EX iface) {
return ref;
}
-static ULONG WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9EX iface) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static ULONG WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Release(IDirect3DDevice9Ex *iface)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
ULONG ref;
if (This->inDestruction) return 0;
@@ -271,9 +260,9 @@ static ULONG WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Release(LPDIRECT3DDEV
}
HeapFree(GetProcessHeap(), 0, This->convertedDecls);
- IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D9CB_DestroySwapChain);
- IWineD3DDevice_ReleaseFocusWindow(This->WineD3DDevice);
- IWineD3DDevice_Release(This->WineD3DDevice);
+ wined3d_device_uninit_3d(This->wined3d_device);
+ wined3d_device_release_focus_window(This->wined3d_device);
+ wined3d_device_decref(This->wined3d_device);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
@@ -281,10 +270,9 @@ static ULONG WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Release(LPDIRECT3DDEV
return ref;
}
-/* IDirect3DDevice Interface follow: */
static HRESULT WINAPI IDirect3DDevice9Impl_TestCooperativeLevel(IDirect3DDevice9Ex *iface)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
TRACE("iface %p.\n", iface);
@@ -297,36 +285,40 @@ static HRESULT WINAPI IDirect3DDevice9Impl_TestCooperativeLevel(IDirect3DDevice9
return D3D_OK;
}
-static UINT WINAPI IDirect3DDevice9Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE9EX iface) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static UINT WINAPI IDirect3DDevice9Impl_GetAvailableTextureMem(IDirect3DDevice9Ex *iface)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetAvailableTextureMem(This->WineD3DDevice);
+ hr = wined3d_device_get_available_texture_mem(This->wined3d_device);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_EvictManagedResources(LPDIRECT3DDEVICE9EX iface) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_EvictManagedResources(IDirect3DDevice9Ex *iface)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
- hr = IWineD3DDevice_EvictManagedResources(This->WineD3DDevice);
+ hr = wined3d_device_evict_managed_resources(This->wined3d_device);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9EX iface, IDirect3D9** ppD3D9) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(IDirect3DDevice9Ex *iface,
+ IDirect3D9 **ppD3D9)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
+ struct wined3d *wined3d;
HRESULT hr = D3D_OK;
- IWineD3D* pWineD3D;
TRACE("iface %p, d3d9 %p.\n", iface, ppD3D9);
@@ -335,13 +327,15 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9EX iface
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &pWineD3D);
- if (hr == D3D_OK && pWineD3D != NULL)
+ hr = wined3d_device_get_wined3d(This->wined3d_device, &wined3d);
+ if (hr == D3D_OK && wined3d)
{
- *ppD3D9 = IWineD3D_GetParent(pWineD3D);
+ *ppD3D9 = wined3d_get_parent(wined3d);
IDirect3D9_AddRef(*ppD3D9);
- IWineD3D_Release(pWineD3D);
- } else {
+ wined3d_decref(wined3d);
+ }
+ else
+ {
FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
*ppD3D9 = NULL;
}
@@ -351,8 +345,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9EX iface
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9EX iface, D3DCAPS9* pCaps) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetDeviceCaps(IDirect3DDevice9Ex *iface, D3DCAPS9 *pCaps)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hrc = D3D_OK;
WINED3DCAPS *pWineCaps;
@@ -369,7 +364,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9EX i
memset(pCaps, 0, sizeof(*pCaps));
wined3d_mutex_lock();
- hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps);
+ hrc = wined3d_device_get_device_caps(This->wined3d_device, pWineCaps);
wined3d_mutex_unlock();
WINECAPSTOD3D9CAPS(pCaps, pWineCaps)
@@ -384,14 +379,16 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9EX i
return hrc;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, D3DDISPLAYMODE* pMode) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetDisplayMode(IDirect3DDevice9Ex *iface,
+ UINT iSwapChain, D3DDISPLAYMODE *pMode)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, swapchain %u, mode %p.\n", iface, iSwapChain, pMode);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, iSwapChain, (WINED3DDISPLAYMODE *) pMode);
+ hr = wined3d_device_get_display_mode(This->wined3d_device, iSwapChain, (WINED3DDISPLAYMODE *)pMode);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
@@ -399,57 +396,66 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9EX
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetCreationParameters(LPDIRECT3DDEVICE9EX iface, D3DDEVICE_CREATION_PARAMETERS *pParameters) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetCreationParameters(IDirect3DDevice9Ex *iface,
+ D3DDEVICE_CREATION_PARAMETERS *pParameters)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, parameters %p.\n", iface, pParameters);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetCreationParameters(This->WineD3DDevice, (WINED3DDEVICE_CREATION_PARAMETERS *) pParameters);
+ hr = wined3d_device_get_creation_parameters(This->wined3d_device,
+ (WINED3DDEVICE_CREATION_PARAMETERS *)pParameters);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVICE9EX iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetCursorProperties(IDirect3DDevice9Ex *iface,
+ UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9 *pCursorBitmap)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *pSurface = (IDirect3DSurface9Impl*)pCursorBitmap;
HRESULT hr;
TRACE("iface %p, hotspot_x %u, hotspot_y %u, bitmap %p.\n",
iface, XHotSpot, YHotSpot, pCursorBitmap);
- if(!pCursorBitmap) {
- WARN("No cursor bitmap, returning WINED3DERR_INVALIDCALL\n");
- return WINED3DERR_INVALIDCALL;
+ if (!pCursorBitmap)
+ {
+ WARN("No cursor bitmap, returning D3DERR_INVALIDCALL.\n");
+ return D3DERR_INVALIDCALL;
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetCursorProperties(This->WineD3DDevice, XHotSpot, YHotSpot, pSurface->wineD3DSurface);
+ hr = wined3d_device_set_cursor_properties(This->wined3d_device, XHotSpot, YHotSpot, pSurface->wined3d_surface);
wined3d_mutex_unlock();
return hr;
}
-static void WINAPI IDirect3DDevice9Impl_SetCursorPosition(LPDIRECT3DDEVICE9EX iface, int XScreenSpace, int YScreenSpace, DWORD Flags) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static void WINAPI IDirect3DDevice9Impl_SetCursorPosition(IDirect3DDevice9Ex *iface,
+ int XScreenSpace, int YScreenSpace, DWORD Flags)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
TRACE("iface %p, x %u, y %u, flags %#x.\n", iface, XScreenSpace, YScreenSpace, Flags);
wined3d_mutex_lock();
- IWineD3DDevice_SetCursorPosition(This->WineD3DDevice, XScreenSpace, YScreenSpace, Flags);
+ wined3d_device_set_cursor_position(This->wined3d_device, XScreenSpace, YScreenSpace, Flags);
wined3d_mutex_unlock();
}
-static BOOL WINAPI IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9EX iface, BOOL bShow) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static BOOL WINAPI IDirect3DDevice9Impl_ShowCursor(IDirect3DDevice9Ex *iface, BOOL bShow)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
BOOL ret;
TRACE("iface %p, show %#x.\n", iface, bShow);
wined3d_mutex_lock();
- ret = IWineD3DDevice_ShowCursor(This->WineD3DDevice, bShow);
+ ret = wined3d_device_show_cursor(This->wined3d_device, bShow);
wined3d_mutex_unlock();
return ret;
@@ -458,7 +464,7 @@ static BOOL WINAPI IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9EX ifac
static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_CreateAdditionalSwapChain(IDirect3DDevice9Ex *iface,
D3DPRESENT_PARAMETERS *present_parameters, IDirect3DSwapChain9 **swapchain)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSwapChain9Impl *object;
HRESULT hr;
@@ -489,19 +495,19 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_CreateAdditionalSwa
static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_GetSwapChain(IDirect3DDevice9Ex *iface,
UINT swapchain_idx, IDirect3DSwapChain9 **swapchain)
{
- IWineD3DSwapChain *wined3d_swapchain = NULL;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
+ struct wined3d_swapchain *wined3d_swapchain = NULL;
HRESULT hr;
TRACE("iface %p, swapchain_idx %u, swapchain %p.\n", iface, swapchain_idx, swapchain);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetSwapChain(((IDirect3DDevice9Impl *)iface)->WineD3DDevice,
- swapchain_idx, &wined3d_swapchain);
- if (SUCCEEDED(hr) && swapchain)
+ hr = wined3d_device_get_swapchain(This->wined3d_device, swapchain_idx, &wined3d_swapchain);
+ if (SUCCEEDED(hr) && wined3d_swapchain)
{
- *swapchain = IWineD3DSwapChain_GetParent(wined3d_swapchain);
+ *swapchain = wined3d_swapchain_get_parent(wined3d_swapchain);
IDirect3DSwapChain9_AddRef(*swapchain);
- IWineD3DSwapChain_Release(wined3d_swapchain);
+ wined3d_swapchain_decref(wined3d_swapchain);
}
else
{
@@ -514,78 +520,55 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_GetSwapChain(IDirec
static UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(IDirect3DDevice9Ex *iface)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
UINT count;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
- count = IWineD3DDevice_GetNumberOfSwapChains(((IDirect3DDevice9Impl *)iface)->WineD3DDevice);
+ count = wined3d_device_get_swapchain_count(This->wined3d_device);
wined3d_mutex_unlock();
return count;
}
-static HRESULT WINAPI reset_enum_callback(IWineD3DResource *resource, void *data) {
+static HRESULT WINAPI reset_enum_callback(struct wined3d_resource *resource, void *data)
+{
+ struct wined3d_resource_desc desc;
BOOL *resources_ok = data;
- D3DRESOURCETYPE type;
- HRESULT ret = S_OK;
- WINED3DSURFACE_DESC surface_desc;
- WINED3DVOLUME_DESC volume_desc;
- D3DINDEXBUFFER_DESC index_desc;
- D3DVERTEXBUFFER_DESC vertex_desc;
- WINED3DPOOL pool;
- IDirect3DResource9 *parent;
- parent = IWineD3DResource_GetParent(resource);
- type = IDirect3DResource9_GetType(parent);
- switch(type) {
- case D3DRTYPE_SURFACE:
- IWineD3DSurface_GetDesc((IWineD3DSurface *) resource, &surface_desc);
- pool = surface_desc.pool;
- break;
-
- case D3DRTYPE_VOLUME:
- IWineD3DVolume_GetDesc((IWineD3DVolume *) resource, &volume_desc);
- pool = volume_desc.Pool;
- break;
-
- case D3DRTYPE_INDEXBUFFER:
- IDirect3DIndexBuffer9_GetDesc((IDirect3DIndexBuffer9 *) parent, &index_desc);
- pool = index_desc.Pool;
- break;
-
- case D3DRTYPE_VERTEXBUFFER:
- IDirect3DVertexBuffer9_GetDesc((IDirect3DVertexBuffer9 *)parent, &vertex_desc);
- pool = vertex_desc.Pool;
- break;
-
- /* No need to check for textures. If there is a D3DPOOL_DEFAULT texture, there
- * is a D3DPOOL_DEFAULT surface or volume as well
- */
- default:
- pool = WINED3DPOOL_SCRATCH; /* a harmless pool */
- break;
- }
-
- if (pool == WINED3DPOOL_DEFAULT)
+ wined3d_resource_get_desc(resource, &desc);
+ if (desc.pool == WINED3DPOOL_DEFAULT)
{
- IDirect3DResource9_AddRef(parent);
- if (IUnknown_Release(parent) == 0)
- {
- TRACE("Parent %p is an implicit resource with ref 0\n", parent);
- } else {
- WARN("Resource %p(wineD3D %p) with pool D3DPOOL_DEFAULT blocks the Reset call\n", parent, resource);
- ret = S_FALSE;
- *resources_ok = FALSE;
- }
- }
- IWineD3DResource_Release(resource);
+ IDirect3DSurface9 *surface;
- return ret;
+ if (desc.resource_type != WINED3DRTYPE_SURFACE)
+ {
+ WARN("Resource %p in pool D3DPOOL_DEFAULT blocks the Reset call.\n", resource);
+ *resources_ok = FALSE;
+ return S_FALSE;
+ }
+
+ surface = wined3d_resource_get_parent(resource);
+
+ IDirect3DSurface9_AddRef(surface);
+ if (IDirect3DSurface9_Release(surface))
+ {
+ WARN("Surface %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", surface, resource);
+ *resources_ok = FALSE;
+ return S_FALSE;
+ }
+
+ WARN("Surface %p (resource %p) is an implicit resource with ref 0.\n", surface, resource);
+ }
+
+ return S_OK;
}
-static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Reset(IDirect3DDevice9Ex *iface,
+ D3DPRESENT_PARAMETERS *pPresentationParameters)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
WINED3DPRESENT_PARAMETERS localParameters;
HRESULT hr;
BOOL resources_ok = TRUE;
@@ -602,21 +585,24 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Reset(LPDIRECT3DDE
* below fails, the device is considered "lost", and _Reset and _Release are the only allowed calls
*/
wined3d_mutex_lock();
- IWineD3DDevice_SetIndexBuffer(This->WineD3DDevice, NULL, WINED3DFMT_UNKNOWN);
- for(i = 0; i < 16; i++) {
- IWineD3DDevice_SetStreamSource(This->WineD3DDevice, i, NULL, 0, 0);
+ wined3d_device_set_index_buffer(This->wined3d_device, NULL, WINED3DFMT_UNKNOWN);
+ for (i = 0; i < 16; ++i)
+ {
+ wined3d_device_set_stream_source(This->wined3d_device, i, NULL, 0, 0);
}
- for(i = 0; i < 16; i++) {
- IWineD3DDevice_SetTexture(This->WineD3DDevice, i, NULL);
+ for (i = 0; i < 16; ++i)
+ {
+ wined3d_device_set_texture(This->wined3d_device, i, NULL);
}
- IWineD3DDevice_EnumResources(This->WineD3DDevice, reset_enum_callback, &resources_ok);
- if(!resources_ok) {
+ wined3d_device_enum_resources(This->wined3d_device, reset_enum_callback, &resources_ok);
+ if (!resources_ok)
+ {
WARN("The application is holding D3DPOOL_DEFAULT resources, rejecting reset\n");
This->notreset = TRUE;
wined3d_mutex_unlock();
- return WINED3DERR_INVALIDCALL;
+ return D3DERR_INVALIDCALL;
}
localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
@@ -635,7 +621,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Reset(LPDIRECT3DDE
localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
localParameters.AutoRestoreDisplayMode = TRUE;
- hr = IWineD3DDevice_Reset(This->WineD3DDevice, &localParameters);
+ hr = wined3d_device_reset(This->wined3d_device, &localParameters);
if(FAILED(hr)) {
This->notreset = TRUE;
@@ -662,16 +648,18 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Reset(LPDIRECT3DDE
return hr;
}
-static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9EX iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA*
- pDirtyRegion) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Present(IDirect3DDevice9Ex *iface,
+ const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride,
+ const RGNDATA *pDirtyRegion)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(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 = IWineD3DDevice_Present(This->WineD3DDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
+ hr = wined3d_device_present(This->wined3d_device, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
wined3d_mutex_unlock();
return hr;
@@ -680,47 +668,51 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_Present(LPDIRECT3D
static HRESULT WINAPI IDirect3DDevice9Impl_GetBackBuffer(IDirect3DDevice9Ex *iface,
UINT iSwapChain, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 **ppBackBuffer)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- IWineD3DSurface *retSurface = NULL;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
+ struct wined3d_surface *wined3d_surface = NULL;
HRESULT hr;
TRACE("iface %p, swapchain %u, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
iface, iSwapChain, BackBuffer, Type, ppBackBuffer);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, iSwapChain,
- BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &retSurface);
- if (SUCCEEDED(hr) && retSurface && ppBackBuffer)
+ hr = wined3d_device_get_back_buffer(This->wined3d_device, iSwapChain,
+ BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &wined3d_surface);
+ if (SUCCEEDED(hr) && wined3d_surface && ppBackBuffer)
{
- *ppBackBuffer = IWineD3DSurface_GetParent(retSurface);
+ *ppBackBuffer = wined3d_surface_get_parent(wined3d_surface);
IDirect3DSurface9_AddRef(*ppBackBuffer);
- IWineD3DSurface_Release(retSurface);
+ wined3d_surface_decref(wined3d_surface);
}
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetRasterStatus(IDirect3DDevice9Ex *iface,
+ UINT iSwapChain, D3DRASTER_STATUS *pRasterStatus)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, swapchain %u, raster_status %p.\n", iface, iSwapChain, pRasterStatus);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetRasterStatus(This->WineD3DDevice, iSwapChain, (WINED3DRASTER_STATUS *) pRasterStatus);
+ hr = wined3d_device_get_raster_status(This->wined3d_device, iSwapChain, (WINED3DRASTER_STATUS *)pRasterStatus);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetDialogBoxMode(LPDIRECT3DDEVICE9EX iface, BOOL bEnableDialogs) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetDialogBoxMode(IDirect3DDevice9Ex *iface,
+ BOOL bEnableDialogs)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, enable %#x.\n", iface, bEnableDialogs);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetDialogBoxMode(This->WineD3DDevice, bEnableDialogs);
+ hr = wined3d_device_set_dialog_box_mode(This->wined3d_device, bEnableDialogs);
wined3d_mutex_unlock();
return hr;
@@ -729,24 +721,26 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetDialogBoxMode(LPDIRECT3DDEVICE9EX
static void WINAPI IDirect3DDevice9Impl_SetGammaRamp(IDirect3DDevice9Ex *iface, UINT iSwapChain,
DWORD Flags, const D3DGAMMARAMP *pRamp)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
TRACE("iface %p, swapchain %u, flags %#x, ramp %p.\n", iface, iSwapChain, Flags, pRamp);
/* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
wined3d_mutex_lock();
- IWineD3DDevice_SetGammaRamp(This->WineD3DDevice, iSwapChain, Flags, (CONST WINED3DGAMMARAMP *)pRamp);
+ wined3d_device_set_gamma_ramp(This->wined3d_device, iSwapChain, Flags, (const WINED3DGAMMARAMP *)pRamp);
wined3d_mutex_unlock();
}
-static void WINAPI IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, D3DGAMMARAMP* pRamp) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static void WINAPI IDirect3DDevice9Impl_GetGammaRamp(IDirect3DDevice9Ex *iface, UINT iSwapChain,
+ D3DGAMMARAMP *pRamp)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
TRACE("iface %p, swapchain %u, ramp %p.\n", iface, iSwapChain, pRamp);
/* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
wined3d_mutex_lock();
- IWineD3DDevice_GetGammaRamp(This->WineD3DDevice, iSwapChain, (WINED3DGAMMARAMP *) pRamp);
+ wined3d_device_get_gamma_ramp(This->wined3d_device, iSwapChain, (WINED3DGAMMARAMP *)pRamp);
wined3d_mutex_unlock();
}
@@ -754,7 +748,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(IDirect3DDevice9Ex *ifa
UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format,
D3DPOOL pool, IDirect3DTexture9 **texture, HANDLE *shared_handle)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DTexture9Impl *object;
HRESULT hr;
@@ -777,7 +771,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(IDirect3DDevice9Ex *ifa
}
TRACE("Created texture %p.\n", object);
- *texture = (IDirect3DTexture9 *)object;
+ *texture = &object->IDirect3DTexture9_iface;
return D3D_OK;
}
@@ -786,7 +780,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(IDirect3DDevice9E
UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format,
D3DPOOL pool, IDirect3DVolumeTexture9 **texture, HANDLE *shared_handle)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DVolumeTexture9Impl *object;
HRESULT hr;
@@ -811,7 +805,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(IDirect3DDevice9E
}
TRACE("Created volume texture %p.\n", object);
- *texture = (IDirect3DVolumeTexture9 *)object;
+ *texture = &object->IDirect3DVolumeTexture9_iface;
return D3D_OK;
}
@@ -820,7 +814,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(IDirect3DDevice9Ex
UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool,
IDirect3DCubeTexture9 **texture, HANDLE *shared_handle)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DCubeTexture9Impl *object;
HRESULT hr;
@@ -843,15 +837,16 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(IDirect3DDevice9Ex
}
TRACE("Created cube texture %p.\n", object);
- *texture = (IDirect3DCubeTexture9 *)object;
+ *texture = &object->IDirect3DCubeTexture9_iface;
return D3D_OK;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(IDirect3DDevice9Ex *iface, UINT size, DWORD usage,
- DWORD fvf, D3DPOOL pool, IDirect3DVertexBuffer9 **buffer, HANDLE *shared_handle)
+static HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(IDirect3DDevice9Ex *iface, UINT size,
+ DWORD usage, DWORD fvf, D3DPOOL pool, IDirect3DVertexBuffer9 **buffer,
+ HANDLE *shared_handle)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DVertexBuffer9Impl *object;
HRESULT hr;
@@ -879,10 +874,11 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(IDirect3DDevice9Ex
return D3D_OK;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(IDirect3DDevice9Ex *iface, UINT size, DWORD usage,
- D3DFORMAT format, D3DPOOL pool, IDirect3DIndexBuffer9 **buffer, HANDLE *shared_handle)
+static HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(IDirect3DDevice9Ex *iface, UINT size,
+ DWORD usage, D3DFORMAT format, D3DPOOL pool, IDirect3DIndexBuffer9 **buffer,
+ HANDLE *shared_handle)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DIndexBuffer9Impl *object;
HRESULT hr;
@@ -910,18 +906,18 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(IDirect3DDevice9Ex
return D3D_OK;
}
-static HRESULT IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height,
- D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface9 **ppSurface,
- UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality)
+static HRESULT IDirect3DDevice9Impl_CreateSurface(IDirect3DDevice9Impl *device, UINT Width,
+ UINT Height, D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level,
+ IDirect3DSurface9 **ppSurface, UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample,
+ DWORD MultisampleQuality)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DSurface9Impl *object;
HRESULT hr;
- TRACE("iface %p, width %u, height %u, format %#x, lockable %#x, discard %#x, level %u, surface %p.\n"
+ TRACE("device %p, width %u, height %u, format %#x, lockable %#x, discard %#x, level %u, surface %p.\n"
"usage %#x, pool %#x, multisample_type %#x, multisample_quality %u.\n",
- iface, Width, Height, Format, Lockable, Discard, Level, ppSurface,
- Usage, Pool, MultiSample, MultisampleQuality);
+ device, Width, Height, Format, Lockable, Discard, Level, ppSurface, Usage, Pool,
+ MultiSample, MultisampleQuality);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface9Impl));
if (!object)
@@ -930,8 +926,8 @@ static HRESULT IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface, UIN
return D3DERR_OUTOFVIDEOMEMORY;
}
- hr = surface_init(object, This, Width, Height, Format, Lockable, Discard,
- Level, Usage, Pool, MultiSample, MultisampleQuality);
+ hr = surface_init(object, device, Width, Height, Format, Lockable, Discard, Level, Usage, Pool,
+ MultiSample, MultisampleQuality);
if (FAILED(hr))
{
WARN("Failed to initialize surface, hr %#x.\n", hr);
@@ -945,10 +941,11 @@ static HRESULT IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface, UIN
return D3D_OK;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_CreateRenderTarget(IDirect3DDevice9Ex *iface, UINT Width, UINT Height,
- D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable,
- IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle)
+static HRESULT WINAPI IDirect3DDevice9Impl_CreateRenderTarget(IDirect3DDevice9Ex *iface, UINT Width,
+ UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality,
+ BOOL Lockable, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u.\n"
@@ -956,16 +953,19 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateRenderTarget(IDirect3DDevice9Ex
iface, Width, Height, Format, MultiSample, MultisampleQuality,
Lockable, ppSurface, pSharedHandle);
- hr = IDirect3DDevice9Impl_CreateSurface(iface, Width, Height, Format, Lockable, FALSE /* Discard */,
- 0 /* Level */, ppSurface, D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT, MultiSample, MultisampleQuality);
+ hr = IDirect3DDevice9Impl_CreateSurface(This, Width, Height, Format, Lockable,
+ FALSE /* Discard */, 0 /* Level */, ppSurface, D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT,
+ MultiSample, MultisampleQuality);
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height,
- D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
- DWORD MultisampleQuality, BOOL Discard,
- IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
+static HRESULT WINAPI IDirect3DDevice9Impl_CreateDepthStencilSurface(IDirect3DDevice9Ex *iface,
+ UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample,
+ DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9 **ppSurface,
+ HANDLE *pSharedHandle)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u.\n"
@@ -973,35 +973,45 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateDepthStencilSurface(LPDIRECT3
iface, Width, Height, Format, MultiSample, MultisampleQuality,
Discard, ppSurface, pSharedHandle);
- hr = IDirect3DDevice9Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Lockable */, Discard,
- 0 /* Level */, ppSurface, D3DUSAGE_DEPTHSTENCIL, D3DPOOL_DEFAULT, MultiSample, MultisampleQuality);
+ hr = IDirect3DDevice9Impl_CreateSurface(This, Width, Height, Format, TRUE /* Lockable */,
+ Discard, 0 /* Level */, ppSurface, D3DUSAGE_DEPTHSTENCIL, D3DPOOL_DEFAULT, MultiSample,
+ MultisampleQuality);
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_UpdateSurface(LPDIRECT3DDEVICE9EX iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_UpdateSurface(IDirect3DDevice9Ex *iface,
+ IDirect3DSurface9 *pSourceSurface, const RECT *pSourceRect,
+ IDirect3DSurface9 *pDestinationSurface, const POINT *pDestPoint)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, src_surface %p, src_rect %p, dst_surface %p, dst_point %p.\n",
iface, pSourceSurface, pSourceRect, pDestinationSurface, pDestPoint);
wined3d_mutex_lock();
- hr = IWineD3DDevice_UpdateSurface(This->WineD3DDevice, ((IDirect3DSurface9Impl *)pSourceSurface)->wineD3DSurface, pSourceRect, ((IDirect3DSurface9Impl *)pDestinationSurface)->wineD3DSurface, pDestPoint);
+ hr = wined3d_device_update_surface(This->wined3d_device,
+ ((IDirect3DSurface9Impl *)pSourceSurface)->wined3d_surface, pSourceRect,
+ ((IDirect3DSurface9Impl *)pDestinationSurface)->wined3d_surface, pDestPoint);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_UpdateTexture(LPDIRECT3DDEVICE9EX iface, IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_UpdateTexture(IDirect3DDevice9Ex *iface,
+ IDirect3DBaseTexture9 *src_texture, IDirect3DBaseTexture9 *dst_texture)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
- TRACE("iface %p, src_texture %p, dst_texture %p.\n", iface, pSourceTexture, pDestinationTexture);
+ TRACE("iface %p, src_texture %p, dst_texture %p.\n", iface, src_texture, dst_texture);
wined3d_mutex_lock();
- hr = IWineD3DDevice_UpdateTexture(This->WineD3DDevice, ((IDirect3DBaseTexture9Impl *)pSourceTexture)->wineD3DBaseTexture, ((IDirect3DBaseTexture9Impl *)pDestinationTexture)->wineD3DBaseTexture);
+ hr = wined3d_device_update_texture(This->wined3d_device,
+ ((IDirect3DBaseTexture9Impl *)src_texture)->wined3d_texture,
+ ((IDirect3DBaseTexture9Impl *)dst_texture)->wined3d_texture);
wined3d_mutex_unlock();
return hr;
@@ -1017,21 +1027,24 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTargetData(IDirect3DDevice9E
TRACE("iface %p, render_target %p, dst_surface %p.\n", iface, pRenderTarget, pDestSurface);
wined3d_mutex_lock();
- hr = IWineD3DSurface_BltFast(destSurface->wineD3DSurface, 0, 0, renderTarget->wineD3DSurface, NULL, WINEDDBLTFAST_NOCOLORKEY);
+ hr = wined3d_surface_bltfast(destSurface->wined3d_surface, 0, 0,
+ renderTarget->wined3d_surface, NULL, WINEDDBLTFAST_NOCOLORKEY);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBufferData(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, IDirect3DSurface9* pDestSurface) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBufferData(IDirect3DDevice9Ex *iface,
+ UINT iSwapChain, IDirect3DSurface9 *pDestSurface)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *destSurface = (IDirect3DSurface9Impl *)pDestSurface;
HRESULT hr;
TRACE("iface %p, swapchain %u, dst_surface %p.\n", iface, iSwapChain, pDestSurface);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetFrontBufferData(This->WineD3DDevice, iSwapChain, destSurface->wineD3DSurface);
+ hr = wined3d_device_get_front_buffer_data(This->wined3d_device, iSwapChain, destSurface->wined3d_surface);
wined3d_mutex_unlock();
return hr;
@@ -1048,7 +1061,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_StretchRect(IDirect3DDevice9Ex *iface
iface, pSourceSurface, pSourceRect, pDestSurface, pDestRect, Filter);
wined3d_mutex_lock();
- hr = IWineD3DSurface_Blt(dst->wineD3DSurface, pDestRect, src->wineD3DSurface, pSourceRect, 0, NULL, Filter);
+ hr = wined3d_surface_blt(dst->wined3d_surface, pDestRect, src->wined3d_surface, pSourceRect, 0, NULL, Filter);
wined3d_mutex_unlock();
return hr;
@@ -1064,41 +1077,41 @@ static HRESULT WINAPI IDirect3DDevice9Impl_ColorFill(IDirect3DDevice9Ex *iface,
(color & 0xff) / 255.0f,
((color >> 24) & 0xff) / 255.0f,
};
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *surface = (IDirect3DSurface9Impl *)pSurface;
- WINED3DPOOL pool;
- WINED3DRESOURCETYPE restype;
- DWORD usage;
- WINED3DSURFACE_DESC desc;
+ struct wined3d_resource *wined3d_resource;
+ struct wined3d_resource_desc desc;
HRESULT hr;
TRACE("iface %p, surface %p, rect %p, color 0x%08x.\n", iface, pSurface, pRect, color);
wined3d_mutex_lock();
- IWineD3DSurface_GetDesc(surface->wineD3DSurface, &desc);
- usage = desc.usage;
- pool = desc.pool;
- restype = desc.resource_type;
+ wined3d_resource = wined3d_surface_get_resource(surface->wined3d_surface);
+ wined3d_resource_get_desc(wined3d_resource, &desc);
- /* This method is only allowed with surfaces that are render targets, or offscreen plain surfaces
- * in D3DPOOL_DEFAULT
- */
- if(!(usage & WINED3DUSAGE_RENDERTARGET) && (pool != WINED3DPOOL_DEFAULT || restype != WINED3DRTYPE_SURFACE)) {
+ /* This method is only allowed with surfaces that are render targets, or
+ * offscreen plain surfaces in D3DPOOL_DEFAULT. */
+ if (!(desc.usage & WINED3DUSAGE_RENDERTARGET) && desc.pool != WINED3DPOOL_DEFAULT)
+ {
wined3d_mutex_unlock();
WARN("Surface is not a render target, or not a stand-alone D3DPOOL_DEFAULT surface\n");
return D3DERR_INVALIDCALL;
}
/* Colorfill can only be used on rendertarget surfaces, or offscreen plain surfaces in D3DPOOL_DEFAULT */
- hr = IWineD3DDevice_ColorFill(This->WineD3DDevice, surface->wineD3DSurface, pRect, &c);
+ hr = wined3d_device_color_fill(This->wined3d_device, surface->wined3d_surface, pRect, &c);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE* pSharedHandle) {
+static HRESULT WINAPI IDirect3DDevice9Impl_CreateOffscreenPlainSurface(IDirect3DDevice9Ex *iface,
+ UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface,
+ HANDLE *pSharedHandle)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, width %u, height %u, format %#x, pool %#x, surface %p, shared_handle %p.\n",
@@ -1115,16 +1128,18 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIREC
Why, their always lockable?
should I change the usage to dynamic?
*/
- hr = IDirect3DDevice9Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Lockable */, FALSE /* Discard */,
- 0 /* Level */, ppSurface, 0 /* Usage (undefined/none) */, (WINED3DPOOL)Pool, D3DMULTISAMPLE_NONE,
- 0 /* MultisampleQuality */);
+ hr = IDirect3DDevice9Impl_CreateSurface(This, Width, Height, Format, TRUE /* Lockable */,
+ FALSE /* Discard */, 0 /* Level */, ppSurface, 0 /* Usage (undefined/none) */,
+ (WINED3DPOOL)Pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
return hr;
}
/* TODO: move to wineD3D */
-static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9EX iface, DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(IDirect3DDevice9Ex *iface,
+ DWORD RenderTargetIndex, IDirect3DSurface9 *pRenderTarget)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *pSurface = (IDirect3DSurface9Impl*)pRenderTarget;
HRESULT hr;
@@ -1137,7 +1152,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9EX
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetRenderTarget(This->WineD3DDevice, RenderTargetIndex, pSurface ? pSurface->wineD3DSurface : NULL, TRUE);
+ hr = wined3d_device_set_render_target(This->wined3d_device, RenderTargetIndex,
+ pSurface ? pSurface->wined3d_surface : NULL, TRUE);
wined3d_mutex_unlock();
return hr;
@@ -1146,8 +1162,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9EX
static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(IDirect3DDevice9Ex *iface,
DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- IWineD3DSurface *pRenderTarget;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
+ struct wined3d_surface *wined3d_surface;
HRESULT hr;
TRACE("iface %p, idx %u, surface %p.\n", iface, RenderTargetIndex, ppRenderTarget);
@@ -1164,21 +1180,21 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(IDirect3DDevice9Ex *i
wined3d_mutex_lock();
- hr=IWineD3DDevice_GetRenderTarget(This->WineD3DDevice,RenderTargetIndex,&pRenderTarget);
+ hr = wined3d_device_get_render_target(This->wined3d_device, RenderTargetIndex, &wined3d_surface);
if (FAILED(hr))
{
FIXME("Call to IWineD3DDevice_GetRenderTarget failed, hr %#x\n", hr);
}
- else if (!pRenderTarget)
+ else if (!wined3d_surface)
{
*ppRenderTarget = NULL;
}
else
{
- *ppRenderTarget = IWineD3DSurface_GetParent(pRenderTarget);
+ *ppRenderTarget = wined3d_surface_get_parent(wined3d_surface);
IDirect3DSurface9_AddRef(*ppRenderTarget);
- IWineD3DSurface_Release(pRenderTarget);
+ wined3d_surface_decref(wined3d_surface);
}
wined3d_mutex_unlock();
@@ -1186,8 +1202,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(IDirect3DDevice9Ex *i
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9EX iface, IDirect3DSurface9* pZStencilSurface) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(IDirect3DDevice9Ex *iface,
+ IDirect3DSurface9 *pZStencilSurface)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *pSurface;
HRESULT hr;
@@ -1196,7 +1214,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDE
pSurface = (IDirect3DSurface9Impl*)pZStencilSurface;
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, NULL==pSurface ? NULL : pSurface->wineD3DSurface);
+ hr = wined3d_device_set_depth_stencil(This->wined3d_device, pSurface ? pSurface->wined3d_surface : NULL);
wined3d_mutex_unlock();
return hr;
@@ -1205,8 +1223,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDE
static HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(IDirect3DDevice9Ex *iface,
IDirect3DSurface9 **ppZStencilSurface)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- IWineD3DSurface *pZStencilSurface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
+ struct wined3d_surface *wined3d_surface;
HRESULT hr;
TRACE("iface %p, depth_stencil %p.\n", iface, ppZStencilSurface);
@@ -1216,12 +1234,12 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(IDirect3DDevic
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface);
+ hr = wined3d_device_get_depth_stencil(This->wined3d_device, &wined3d_surface);
if (SUCCEEDED(hr))
{
- *ppZStencilSurface = IWineD3DSurface_GetParent(pZStencilSurface);
+ *ppZStencilSurface = wined3d_surface_get_parent(wined3d_surface);
IDirect3DSurface9_AddRef(*ppZStencilSurface);
- IWineD3DSurface_Release(pZStencilSurface);
+ wined3d_surface_decref(wined3d_surface);
}
else
{
@@ -1234,34 +1252,38 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(IDirect3DDevic
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9EX iface) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_BeginScene(IDirect3DDevice9Ex *iface)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
- hr = IWineD3DDevice_BeginScene(This->WineD3DDevice);
+ hr = wined3d_device_begin_scene(This->wined3d_device);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9EX iface) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_EndScene(IDirect3DDevice9Ex *iface)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
- hr = IWineD3DDevice_EndScene(This->WineD3DDevice);
+ hr = wined3d_device_end_scene(This->wined3d_device);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_Clear(LPDIRECT3DDEVICE9EX iface, DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_Clear(IDirect3DDevice9Ex *iface, DWORD Count,
+ const D3DRECT *pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, rect_count %u, rects %p, flags %#x, color 0x%08x, z %.8e, stencil %u.\n",
@@ -1269,211 +1291,241 @@ static HRESULT WINAPI IDirect3DDevice9Impl_Clear(LPDIRECT3DDEVICE9EX iface, DW
/* Note: D3DRECT is compatible with WINED3DRECT */
wined3d_mutex_lock();
- hr = IWineD3DDevice_Clear(This->WineD3DDevice, Count, (const RECT *)pRects, Flags, Color, Z, Stencil);
+ hr = wined3d_device_clear(This->wined3d_device, Count, (const RECT *)pRects, Flags, Color, Z, Stencil);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetTransform(LPDIRECT3DDEVICE9EX iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* lpMatrix) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetTransform(IDirect3DDevice9Ex *iface,
+ D3DTRANSFORMSTATETYPE State, const D3DMATRIX *lpMatrix)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, state %#x, matrix %p.\n", iface, State, lpMatrix);
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) lpMatrix);
+ hr = wined3d_device_set_transform(This->wined3d_device, State, (const WINED3DMATRIX *)lpMatrix);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetTransform(LPDIRECT3DDEVICE9EX iface, D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetTransform(IDirect3DDevice9Ex *iface,
+ D3DTRANSFORMSTATETYPE State, D3DMATRIX *pMatrix)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, state %#x, matrix %p.\n", iface, State, pMatrix);
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetTransform(This->WineD3DDevice, State, (WINED3DMATRIX*) pMatrix);
+ hr = wined3d_device_get_transform(This->wined3d_device, State, (WINED3DMATRIX *)pMatrix);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_MultiplyTransform(LPDIRECT3DDEVICE9EX iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_MultiplyTransform(IDirect3DDevice9Ex *iface,
+ D3DTRANSFORMSTATETYPE State, const D3DMATRIX *pMatrix)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, state %#x, matrix %p.\n", iface, State, pMatrix);
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
wined3d_mutex_lock();
- hr = IWineD3DDevice_MultiplyTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) pMatrix);
+ hr = wined3d_device_multiply_transform(This->wined3d_device, State, (const WINED3DMATRIX *)pMatrix);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9EX iface, CONST D3DVIEWPORT9* pViewport) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetViewport(IDirect3DDevice9Ex *iface,
+ const D3DVIEWPORT9 *pViewport)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, viewport %p.\n", iface, pViewport);
/* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetViewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport);
+ hr = wined3d_device_set_viewport(This->wined3d_device, (const WINED3DVIEWPORT *)pViewport);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9EX iface, D3DVIEWPORT9* pViewport) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetViewport(IDirect3DDevice9Ex *iface,
+ D3DVIEWPORT9 *pViewport)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, viewport %p.\n", iface, pViewport);
/* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetViewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport);
+ hr = wined3d_device_get_viewport(This->wined3d_device, (WINED3DVIEWPORT *)pViewport);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9EX iface, CONST D3DMATERIAL9* pMaterial) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetMaterial(IDirect3DDevice9Ex *iface,
+ const D3DMATERIAL9 *pMaterial)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, material %p.\n", iface, pMaterial);
/* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial);
+ hr = wined3d_device_set_material(This->wined3d_device, (const WINED3DMATERIAL *)pMaterial);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9EX iface, D3DMATERIAL9* pMaterial) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetMaterial(IDirect3DDevice9Ex *iface,
+ D3DMATERIAL9 *pMaterial)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, material %p.\n", iface, pMaterial);
/* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial);
+ hr = wined3d_device_get_material(This->wined3d_device, (WINED3DMATERIAL *)pMaterial);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9EX iface, DWORD Index, CONST D3DLIGHT9* pLight) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetLight(IDirect3DDevice9Ex *iface, DWORD Index,
+ const D3DLIGHT9 *pLight)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, index %u, light %p.\n", iface, Index, pLight);
/* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight);
+ hr = wined3d_device_set_light(This->wined3d_device, Index, (const WINED3DLIGHT *)pLight);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9EX iface, DWORD Index, D3DLIGHT9* pLight) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetLight(IDirect3DDevice9Ex *iface, DWORD Index,
+ D3DLIGHT9 *pLight)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, index %u, light %p.\n", iface, Index, pLight);
/* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight);
+ hr = wined3d_device_get_light(This->wined3d_device, Index, (WINED3DLIGHT *)pLight);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_LightEnable(LPDIRECT3DDEVICE9EX iface, DWORD Index, BOOL Enable) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_LightEnable(IDirect3DDevice9Ex *iface, DWORD Index,
+ BOOL Enable)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, index %u, enable %#x.\n", iface, Index, Enable);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetLightEnable(This->WineD3DDevice, Index, Enable);
+ hr = wined3d_device_set_light_enable(This->wined3d_device, Index, Enable);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetLightEnable(LPDIRECT3DDEVICE9EX iface, DWORD Index, BOOL* pEnable) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetLightEnable(IDirect3DDevice9Ex *iface, DWORD Index,
+ BOOL *pEnable)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, index %u, enable %p.\n", iface, Index, pEnable);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetLightEnable(This->WineD3DDevice, Index, pEnable);
+ hr = wined3d_device_get_light_enable(This->wined3d_device, Index, pEnable);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetClipPlane(LPDIRECT3DDEVICE9EX iface, DWORD Index, CONST float* pPlane) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetClipPlane(IDirect3DDevice9Ex *iface, DWORD Index,
+ const float *pPlane)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, index %u, plane %p.\n", iface, Index, pPlane);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetClipPlane(This->WineD3DDevice, Index, pPlane);
+ hr = wined3d_device_set_clip_plane(This->wined3d_device, Index, pPlane);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9EX iface, DWORD Index, float* pPlane) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetClipPlane(IDirect3DDevice9Ex *iface, DWORD Index,
+ float *pPlane)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, index %u, plane %p.\n", iface, Index, pPlane);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetClipPlane(This->WineD3DDevice, Index, pPlane);
+ hr = wined3d_device_get_clip_plane(This->wined3d_device, Index, pPlane);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9EX iface, D3DRENDERSTATETYPE State, DWORD Value) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_SetRenderState(IDirect3DDevice9Ex *iface,
+ D3DRENDERSTATETYPE State, DWORD Value)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, state %#x, value %#x.\n", iface, State, Value);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, State, Value);
+ hr = wined3d_device_set_render_state(This->wined3d_device, State, Value);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9EX iface, D3DRENDERSTATETYPE State, DWORD* pValue) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderState(IDirect3DDevice9Ex *iface,
+ D3DRENDERSTATETYPE State, DWORD *pValue)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, state %#x, value %p.\n", iface, State, pValue);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetRenderState(This->WineD3DDevice, State, pValue);
+ hr = wined3d_device_get_render_state(This->wined3d_device, State, pValue);
wined3d_mutex_unlock();
return hr;
@@ -1482,7 +1534,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9EX
static HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(IDirect3DDevice9Ex *iface,
D3DSTATEBLOCKTYPE type, IDirect3DStateBlock9 **stateblock)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DStateBlock9Impl *object;
HRESULT hr;
@@ -1510,36 +1562,37 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(IDirect3DDevice9Ex *
}
TRACE("Created stateblock %p.\n", object);
- *stateblock = (IDirect3DStateBlock9 *)object;
+ *stateblock = &object->IDirect3DStateBlock9_iface;
return D3D_OK;
}
static HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(IDirect3DDevice9Ex *iface)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
- hr = IWineD3DDevice_BeginStateBlock(This->WineD3DDevice);
+ hr = wined3d_device_begin_stateblock(This->wined3d_device);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *iface, IDirect3DStateBlock9 **stateblock)
+static HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *iface,
+ IDirect3DStateBlock9 **stateblock)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- IWineD3DStateBlock *wined3d_stateblock;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
+ struct wined3d_stateblock *wined3d_stateblock;
IDirect3DStateBlock9Impl *object;
HRESULT hr;
TRACE("iface %p, stateblock %p.\n", iface, stateblock);
wined3d_mutex_lock();
- hr = IWineD3DDevice_EndStateBlock(This->WineD3DDevice, &wined3d_stateblock);
+ hr = wined3d_device_end_stateblock(This->wined3d_device, &wined3d_stateblock);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@@ -1551,7 +1604,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *ifa
if (!object)
{
ERR("Failed to allocate stateblock memory.\n");
- IWineD3DStateBlock_Release(wined3d_stateblock);
+ wined3d_mutex_lock();
+ wined3d_stateblock_decref(wined3d_stateblock);
+ wined3d_mutex_unlock();
return E_OUTOFMEMORY;
}
@@ -1559,48 +1614,54 @@ static HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *ifa
if (FAILED(hr))
{
WARN("Failed to initialize stateblock, hr %#x.\n", hr);
- IWineD3DStateBlock_Release(wined3d_stateblock);
+ wined3d_mutex_lock();
+ wined3d_stateblock_decref(wined3d_stateblock);
+ wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created stateblock %p.\n", object);
- *stateblock = (IDirect3DStateBlock9 *)object;
+ *stateblock = &object->IDirect3DStateBlock9_iface;
return D3D_OK;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9EX iface, CONST D3DCLIPSTATUS9* pClipStatus) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, clip_status %p.\n", iface, pClipStatus);
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9EX iface, D3DCLIPSTATUS9* pClipStatus) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, clip_status %p.\n", iface, pClipStatus);
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_GetClipStatus(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DDevice9Impl_GetTexture(IDirect3DDevice9Ex *iface,
- DWORD Stage, IDirect3DBaseTexture9 **ppTexture)
+static HRESULT WINAPI IDirect3DDevice9Impl_SetClipStatus(IDirect3DDevice9Ex *iface,
+ const D3DCLIPSTATUS9 *pClipStatus)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- IWineD3DBaseTexture *retTexture = NULL;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
+ HRESULT hr;
+
+ TRACE("iface %p, clip_status %p.\n", iface, pClipStatus);
+
+ wined3d_mutex_lock();
+ hr = wined3d_device_set_clip_status(This->wined3d_device, (const WINED3DCLIPSTATUS *)pClipStatus);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetClipStatus(IDirect3DDevice9Ex *iface,
+ D3DCLIPSTATUS9 *pClipStatus)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
+ HRESULT hr;
+
+ TRACE("iface %p, clip_status %p.\n", iface, pClipStatus);
+
+ wined3d_mutex_lock();
+ hr = wined3d_device_get_clip_status(This->wined3d_device, (WINED3DCLIPSTATUS *)pClipStatus);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetTexture(IDirect3DDevice9Ex *iface, DWORD Stage,
+ IDirect3DBaseTexture9 **ppTexture)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
+ struct wined3d_texture *wined3d_texture = NULL;
HRESULT hr;
TRACE("iface %p, stage %u, texture %p.\n", iface, Stage, ppTexture);
@@ -1610,18 +1671,18 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetTexture(IDirect3DDevice9Ex *iface,
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, &retTexture);
- if (SUCCEEDED(hr) && retTexture)
+ hr = wined3d_device_get_texture(This->wined3d_device, Stage, &wined3d_texture);
+ if (SUCCEEDED(hr) && wined3d_texture)
{
- *ppTexture = IWineD3DBaseTexture_GetParent(retTexture);
- IWineD3DBaseTexture_AddRef(*ppTexture);
- IWineD3DBaseTexture_Release(retTexture);
+ *ppTexture = wined3d_texture_get_parent(wined3d_texture);
+ IDirect3DBaseTexture9_AddRef(*ppTexture);
+ wined3d_texture_decref(wined3d_texture);
}
else
{
if (FAILED(hr))
{
- WARN("Call to get texture (%d) failed (%p)\n", Stage, retTexture);
+ WARN("Call to get texture (%u) failed (%p).\n", Stage, wined3d_texture);
}
*ppTexture = NULL;
}
@@ -1630,15 +1691,17 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetTexture(IDirect3DDevice9Ex *iface,
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9EX iface, DWORD Stage, IDirect3DBaseTexture9* pTexture) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetTexture(IDirect3DDevice9Ex *iface, DWORD stage,
+ IDirect3DBaseTexture9 *texture)
+{
+ IDirect3DDevice9Impl *device = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
- TRACE("iface %p, stage %u, texture %p.\n", iface, Stage, pTexture);
+ TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetTexture(This->WineD3DDevice, Stage,
- pTexture==NULL ? NULL:((IDirect3DBaseTexture9Impl *)pTexture)->wineD3DBaseTexture);
+ hr = wined3d_device_set_texture(device->wined3d_device, stage,
+ texture ? ((IDirect3DBaseTexture9Impl *)texture)->wined3d_texture : NULL);
wined3d_mutex_unlock();
return hr;
@@ -1681,9 +1744,10 @@ static const WINED3DTEXTURESTAGESTATETYPE tss_lookup[] =
WINED3DTSS_CONSTANT, /* 32, D3DTSS_CONSTANT */
};
-static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9EX iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD *pValue)
+static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(IDirect3DDevice9Ex *iface,
+ DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD *pValue)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, stage %u, state %#x, value %p.\n", iface, Stage, Type, pValue);
@@ -1695,15 +1759,16 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVI
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, tss_lookup[Type], pValue);
+ hr = wined3d_device_get_texture_stage_state(This->wined3d_device, Stage, tss_lookup[Type], pValue);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9EX iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value)
+static HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(IDirect3DDevice9Ex *iface,
+ DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, stage %u, state %#x, value %#x.\n", iface, Stage, Type, Value);
@@ -1715,7 +1780,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVI
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, tss_lookup[Type], Value);
+ hr = wined3d_device_set_texture_stage_state(This->wined3d_device, Stage, tss_lookup[Type], Value);
wined3d_mutex_unlock();
return hr;
@@ -1724,197 +1789,217 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVI
static HRESULT WINAPI IDirect3DDevice9Impl_GetSamplerState(IDirect3DDevice9Ex *iface, DWORD Sampler,
D3DSAMPLERSTATETYPE Type, DWORD *pValue)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, sampler %u, state %#x, value %p.\n", iface, Sampler, Type, pValue);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Sampler, Type, pValue);
+ hr = wined3d_device_get_sampler_state(This->wined3d_device, Sampler, Type, pValue);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9EX iface, DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_SetSamplerState(IDirect3DDevice9Ex *iface,
+ DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, sampler %u, state %#x, value %#x.\n", iface, Sampler, Type, Value);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Sampler, Type, Value);
+ hr = wined3d_device_set_sampler_state(This->wined3d_device, Sampler, Type, Value);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_ValidateDevice(LPDIRECT3DDEVICE9EX iface, DWORD* pNumPasses) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_ValidateDevice(IDirect3DDevice9Ex *iface,
+ DWORD *pNumPasses)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, pass_count %p.\n", iface, pNumPasses);
wined3d_mutex_lock();
- hr = IWineD3DDevice_ValidateDevice(This->WineD3DDevice, pNumPasses);
+ hr = wined3d_device_validate_device(This->wined3d_device, pNumPasses);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetPaletteEntries(IDirect3DDevice9Ex *iface, UINT PaletteNumber,
- const PALETTEENTRY *pEntries)
+static HRESULT WINAPI IDirect3DDevice9Impl_SetPaletteEntries(IDirect3DDevice9Ex *iface,
+ UINT PaletteNumber, const PALETTEENTRY *pEntries)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, palette_idx %u, entries %p.\n", iface, PaletteNumber, pEntries);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
+ hr = wined3d_device_set_palette_entries(This->wined3d_device, PaletteNumber, pEntries);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetPaletteEntries(LPDIRECT3DDEVICE9EX iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetPaletteEntries(IDirect3DDevice9Ex *iface,
+ UINT PaletteNumber, PALETTEENTRY *pEntries)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, palette_idx %u, entries %p.\n", iface, PaletteNumber, pEntries);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
+ hr = wined3d_device_get_palette_entries(This->wined3d_device, PaletteNumber, pEntries);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE9EX iface, UINT PaletteNumber) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetCurrentTexturePalette(IDirect3DDevice9Ex *iface,
+ UINT PaletteNumber)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, palette_idx %u.\n", iface, PaletteNumber);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
+ hr = wined3d_device_set_current_texture_palette(This->wined3d_device, PaletteNumber);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetCurrentTexturePalette(LPDIRECT3DDEVICE9EX iface, UINT* PaletteNumber) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetCurrentTexturePalette(IDirect3DDevice9Ex *iface,
+ UINT *PaletteNumber)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, palette_idx %p.\n", iface, PaletteNumber);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
+ hr = wined3d_device_get_current_texture_palette(This->wined3d_device, PaletteNumber);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetScissorRect(LPDIRECT3DDEVICE9EX iface, CONST RECT* pRect) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetScissorRect(IDirect3DDevice9Ex *iface,
+ const RECT *pRect)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, rect %p.\n", iface, pRect);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetScissorRect(This->WineD3DDevice, pRect);
+ hr = wined3d_device_set_scissor_rect(This->wined3d_device, pRect);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetScissorRect(LPDIRECT3DDEVICE9EX iface, RECT* pRect) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetScissorRect(IDirect3DDevice9Ex *iface, RECT *pRect)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, rect %p.\n", iface, pRect);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetScissorRect(This->WineD3DDevice, pRect);
+ hr = wined3d_device_get_scissor_rect(This->wined3d_device, pRect);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetSoftwareVertexProcessing(LPDIRECT3DDEVICE9EX iface, BOOL bSoftware) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetSoftwareVertexProcessing(IDirect3DDevice9Ex *iface,
+ BOOL bSoftware)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, software %#x.\n", iface, bSoftware);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetSoftwareVertexProcessing(This->WineD3DDevice, bSoftware);
+ hr = wined3d_device_set_software_vertex_processing(This->wined3d_device, bSoftware);
wined3d_mutex_unlock();
return hr;
}
-static BOOL WINAPI IDirect3DDevice9Impl_GetSoftwareVertexProcessing(LPDIRECT3DDEVICE9EX iface) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static BOOL WINAPI IDirect3DDevice9Impl_GetSoftwareVertexProcessing(IDirect3DDevice9Ex *iface)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
BOOL ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
- ret = IWineD3DDevice_GetSoftwareVertexProcessing(This->WineD3DDevice);
+ ret = wined3d_device_get_software_vertex_processing(This->wined3d_device);
wined3d_mutex_unlock();
return ret;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetNPatchMode(LPDIRECT3DDEVICE9EX iface, float nSegments) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetNPatchMode(IDirect3DDevice9Ex *iface, float nSegments)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, segment_count %.8e.\n", iface, nSegments);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetNPatchMode(This->WineD3DDevice, nSegments);
+ hr = wined3d_device_set_npatch_mode(This->wined3d_device, nSegments);
wined3d_mutex_unlock();
return hr;
}
-static float WINAPI IDirect3DDevice9Impl_GetNPatchMode(LPDIRECT3DDEVICE9EX iface) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static float WINAPI IDirect3DDevice9Impl_GetNPatchMode(IDirect3DDevice9Ex *iface)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
float ret;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
- ret = IWineD3DDevice_GetNPatchMode(This->WineD3DDevice);
+ ret = wined3d_device_get_npatch_mode(This->wined3d_device);
wined3d_mutex_unlock();
return ret;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitive(IDirect3DDevice9Ex *iface, D3DPRIMITIVETYPE PrimitiveType,
- UINT StartVertex, UINT PrimitiveCount)
+static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitive(IDirect3DDevice9Ex *iface,
+ D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, primitive_type %#x, start_vertex %u, primitive_count %u.\n",
iface, PrimitiveType, StartVertex, PrimitiveCount);
wined3d_mutex_lock();
- IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
- hr = IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, StartVertex,
+ wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+ hr = wined3d_device_draw_primitive(This->wined3d_device, StartVertex,
vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount));
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVICE9EX iface, D3DPRIMITIVETYPE PrimitiveType,
- INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitive(IDirect3DDevice9Ex *iface,
+ D3DPRIMITIVETYPE PrimitiveType, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices,
+ UINT startIndex, UINT primCount)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, primitive_type %#x, base_vertex_idx %u, min_vertex_idx %u,\n"
@@ -1923,27 +2008,28 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVI
NumVertices, startIndex, primCount);
wined3d_mutex_lock();
- IWineD3DDevice_SetBaseVertexIndex(This->WineD3DDevice, BaseVertexIndex);
- IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
- hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, startIndex,
+ wined3d_device_set_base_vertex_index(This->wined3d_device, BaseVertexIndex);
+ wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+ hr = wined3d_device_draw_indexed_primitive(This->wined3d_device, startIndex,
vertex_count_from_primitive_count(PrimitiveType, primCount));
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitiveUP(IDirect3DDevice9Ex *iface, D3DPRIMITIVETYPE PrimitiveType,
- UINT PrimitiveCount, const void *pVertexStreamZeroData, UINT VertexStreamZeroStride)
+static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitiveUP(IDirect3DDevice9Ex *iface,
+ D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, const void *pVertexStreamZeroData,
+ UINT VertexStreamZeroStride)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, primitive_type %#x, primitive_count %u, data %p, stride %u.\n",
iface, PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
wined3d_mutex_lock();
- IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
- hr = IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice,
+ wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+ hr = wined3d_device_draw_primitive_up(This->wined3d_device,
vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount),
pVertexStreamZeroData, VertexStreamZeroStride);
wined3d_mutex_unlock();
@@ -1951,10 +2037,12 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitiveUP(IDirect3DDevice9Ex *i
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDEVICE9EX iface, D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex,
- UINT NumVertexIndices, UINT PrimitiveCount, CONST void* pIndexData,
- D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *iface,
+ D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertexIndices,
+ UINT PrimitiveCount, const void *pIndexData, D3DFORMAT IndexDataFormat,
+ const void *pVertexStreamZeroData, UINT VertexStreamZeroStride)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, primitive_type %#x, min_vertex_idx %u, index_count %u, primitive_count %u,\n"
@@ -1963,8 +2051,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDE
pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
wined3d_mutex_lock();
- IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
- hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice,
+ wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+ hr = wined3d_device_draw_indexed_primitive_up(This->wined3d_device,
vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount), pIndexData,
wined3dformat_from_d3dformat(IndexDataFormat), pVertexStreamZeroData, VertexStreamZeroStride);
wined3d_mutex_unlock();
@@ -1972,8 +2060,11 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDE
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9EX iface, UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_ProcessVertices(IDirect3DDevice9Ex *iface,
+ UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9 *pDestBuffer,
+ IDirect3DVertexDeclaration9 *pVertexDecl, DWORD Flags)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DVertexDeclaration9Impl *Decl = (IDirect3DVertexDeclaration9Impl *) pVertexDecl;
HRESULT hr;
IDirect3DVertexBuffer9Impl *dest = (IDirect3DVertexBuffer9Impl *) pDestBuffer;
@@ -1982,7 +2073,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9EX
iface, SrcStartIndex, DestIndex, VertexCount, pDestBuffer, pVertexDecl, Flags);
wined3d_mutex_lock();
- hr = IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, dest->wineD3DVertexBuffer, Decl ? Decl->wineD3DVertexDeclaration : NULL, Flags, dest->fvf);
+ hr = wined3d_device_process_vertices(This->wined3d_device, SrcStartIndex, DestIndex, VertexCount,
+ dest->wineD3DVertexBuffer, Decl ? Decl->wineD3DVertexDeclaration : NULL, Flags, dest->fvf);
wined3d_mutex_unlock();
return hr;
@@ -1991,7 +2083,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9EX
static HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(IDirect3DDevice9Ex *iface,
const D3DVERTEXELEMENT9 *elements, IDirect3DVertexDeclaration9 **declaration)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DVertexDeclaration9Impl *object;
HRESULT hr;
@@ -2027,12 +2119,13 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(IDirect3DDevi
static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(IDirect3DDevice9Ex *iface,
IDirect3DVertexDeclaration9 *declaration)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, declaration %p.\n", iface, declaration);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetVertexDeclaration(((IDirect3DDevice9Impl *)iface)->WineD3DDevice,
+ hr = wined3d_device_set_vertex_declaration(This->wined3d_device,
declaration ? ((IDirect3DVertexDeclaration9Impl *)declaration)->wineD3DVertexDeclaration : NULL);
wined3d_mutex_unlock();
@@ -2042,7 +2135,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(IDirect3DDevice9
static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(IDirect3DDevice9Ex *iface,
IDirect3DVertexDeclaration9 **declaration)
{
- IWineD3DVertexDeclaration *wined3d_declaration = NULL;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
+ struct wined3d_vertex_declaration *wined3d_declaration = NULL;
HRESULT hr;
TRACE("iface %p, declaration %p.\n", iface, declaration);
@@ -2050,12 +2144,12 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(IDirect3DDevice9
if (!declaration) return D3DERR_INVALIDCALL;
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetVertexDeclaration(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, &wined3d_declaration);
+ hr = wined3d_device_get_vertex_declaration(This->wined3d_device, &wined3d_declaration);
if (SUCCEEDED(hr) && wined3d_declaration)
{
- *declaration = IWineD3DVertexDeclaration_GetParent(wined3d_declaration);
+ *declaration = wined3d_vertex_declaration_get_parent(wined3d_declaration);
IDirect3DVertexDeclaration9_AddRef(*declaration);
- IWineD3DVertexDeclaration_Release(wined3d_declaration);
+ wined3d_vertex_declaration_decref(wined3d_declaration);
}
else
{
@@ -2095,7 +2189,8 @@ static IDirect3DVertexDeclaration9 *getConvertedDecl(IDirect3DDevice9Impl *This,
hr = vdecl_convert_fvf(fvf, &elements);
if (hr != S_OK) return NULL;
- hr = IDirect3DDevice9Impl_CreateVertexDeclaration((IDirect3DDevice9Ex *) This, elements, &pDecl);
+ hr = IDirect3DDevice9Impl_CreateVertexDeclaration(&This->IDirect3DDevice9Ex_iface, elements,
+ &pDecl);
HeapFree(GetProcessHeap(), 0, elements); /* CreateVertexDeclaration makes a copy */
if (hr != S_OK) return NULL;
@@ -2124,8 +2219,9 @@ static IDirect3DVertexDeclaration9 *getConvertedDecl(IDirect3DDevice9Impl *This,
return pDecl;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9EX iface, DWORD FVF) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetFVF(IDirect3DDevice9Ex *iface, DWORD FVF)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DVertexDeclaration9 *decl;
HRESULT hr;
@@ -2187,7 +2283,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetFVF(IDirect3DDevice9Ex *iface, DWO
static HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(IDirect3DDevice9Ex *iface,
const DWORD *byte_code, IDirect3DVertexShader9 **shader)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DVertexShader9Impl *object;
HRESULT hr;
@@ -2217,13 +2313,14 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(IDirect3DDevice9Ex
static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(IDirect3DDevice9Ex *iface,
IDirect3DVertexShader9 *shader)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, shader %p.\n", iface, shader);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetVertexShader(((IDirect3DDevice9Impl *)iface)->WineD3DDevice,
- shader ? ((IDirect3DVertexShader9Impl *)shader)->wineD3DVertexShader : NULL);
+ hr = wined3d_device_set_vertex_shader(This->wined3d_device,
+ shader ? ((IDirect3DVertexShader9Impl *)shader)->wined3d_shader : NULL);
wined3d_mutex_unlock();
return hr;
@@ -2232,17 +2329,18 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(IDirect3DDevice9Ex *i
static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(IDirect3DDevice9Ex *iface,
IDirect3DVertexShader9 **shader)
{
- IWineD3DVertexShader *wined3d_shader;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
+ struct wined3d_shader *wined3d_shader;
TRACE("iface %p, shader %p.\n", iface, shader);
wined3d_mutex_lock();
- wined3d_shader = IWineD3DDevice_GetVertexShader(((IDirect3DDevice9Impl *)iface)->WineD3DDevice);
+ wined3d_shader = wined3d_device_get_vertex_shader(This->wined3d_device);
if (wined3d_shader)
{
- *shader = IWineD3DVertexShader_GetParent(wined3d_shader);
+ *shader = wined3d_shader_get_parent(wined3d_shader);
IDirect3DVertexShader9_AddRef(*shader);
- IWineD3DVertexShader_Release(wined3d_shader);
+ wined3d_shader_decref(wined3d_shader);
}
else
{
@@ -2258,6 +2356,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(IDirect3DDevice9Ex *i
static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(IDirect3DDevice9Ex *iface,
UINT reg_idx, const float *data, UINT count)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
@@ -2270,7 +2369,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(IDirect3DDev
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetVertexShaderConstantF(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, reg_idx, data, count);
+ hr = wined3d_device_set_vs_consts_f(This->wined3d_device, reg_idx, data, count);
wined3d_mutex_unlock();
return hr;
@@ -2279,6 +2378,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(IDirect3DDev
static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(IDirect3DDevice9Ex *iface,
UINT reg_idx, float *data, UINT count)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
@@ -2291,7 +2391,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(IDirect3DDev
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetVertexShaderConstantF(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, reg_idx, data, count);
+ hr = wined3d_device_get_vs_consts_f(This->wined3d_device, reg_idx, data, count);
wined3d_mutex_unlock();
return hr;
@@ -2300,12 +2400,13 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(IDirect3DDev
static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(IDirect3DDevice9Ex *iface,
UINT reg_idx, const int *data, UINT count)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetVertexShaderConstantI(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, reg_idx, data, count);
+ hr = wined3d_device_set_vs_consts_i(This->wined3d_device, reg_idx, data, count);
wined3d_mutex_unlock();
return hr;
@@ -2314,12 +2415,13 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(IDirect3DDev
static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(IDirect3DDevice9Ex *iface,
UINT reg_idx, int *data, UINT count)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetVertexShaderConstantI(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, reg_idx, data, count);
+ hr = wined3d_device_get_vs_consts_i(This->wined3d_device, reg_idx, data, count);
wined3d_mutex_unlock();
return hr;
@@ -2328,12 +2430,13 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(IDirect3DDev
static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(IDirect3DDevice9Ex *iface,
UINT reg_idx, const BOOL *data, UINT count)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetVertexShaderConstantB(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, reg_idx, data, count);
+ hr = wined3d_device_set_vs_consts_b(This->wined3d_device, reg_idx, data, count);
wined3d_mutex_unlock();
return hr;
@@ -2342,26 +2445,29 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(IDirect3DDev
static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(IDirect3DDevice9Ex *iface,
UINT reg_idx, BOOL *data, UINT count)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetVertexShaderConstantB(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, reg_idx, data, count);
+ hr = wined3d_device_get_vs_consts_b(This->wined3d_device, reg_idx, data, count);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9EX iface, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(IDirect3DDevice9Ex *iface,
+ UINT StreamNumber, IDirect3DVertexBuffer9 *pStreamData, UINT OffsetInBytes, UINT Stride)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, stream_idx %u, buffer %p, offset %u, stride %u.\n",
iface, StreamNumber, pStreamData, OffsetInBytes, Stride);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetStreamSource(This->WineD3DDevice, StreamNumber,
+ hr = wined3d_device_set_stream_source(This->wined3d_device, StreamNumber,
pStreamData ? ((IDirect3DVertexBuffer9Impl *)pStreamData)->wineD3DVertexBuffer : NULL,
OffsetInBytes, Stride);
wined3d_mutex_unlock();
@@ -2370,10 +2476,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9EX i
}
static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(IDirect3DDevice9Ex *iface,
- UINT StreamNumber, IDirect3DVertexBuffer9 **pStream, UINT* OffsetInBytes, UINT* pStride)
+ UINT StreamNumber, IDirect3DVertexBuffer9 **pStream, UINT *OffsetInBytes, UINT *pStride)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- IWineD3DBuffer *retStream = NULL;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
+ struct wined3d_buffer *retStream = NULL;
HRESULT hr;
TRACE("iface %p, stream_idx %u, buffer %p, offset %p, stride %p.\n",
@@ -2384,12 +2490,12 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(IDirect3DDevice9Ex *i
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, &retStream, OffsetInBytes, pStride);
+ hr = wined3d_device_get_stream_source(This->wined3d_device, StreamNumber, &retStream, OffsetInBytes, pStride);
if (SUCCEEDED(hr) && retStream)
{
- *pStream = IWineD3DBuffer_GetParent(retStream);
+ *pStream = wined3d_buffer_get_parent(retStream);
IDirect3DVertexBuffer9_AddRef(*pStream);
- IWineD3DBuffer_Release(retStream);
+ wined3d_buffer_decref(retStream);
}
else
{
@@ -2404,43 +2510,47 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(IDirect3DDevice9Ex *i
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSourceFreq(IDirect3DDevice9Ex *iface, UINT StreamNumber,
- UINT Divider)
+static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSourceFreq(IDirect3DDevice9Ex *iface,
+ UINT StreamNumber, UINT Divider)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, stream_idx %u, freq %u.\n", iface, StreamNumber, Divider);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetStreamSourceFreq(This->WineD3DDevice, StreamNumber, Divider);
+ hr = wined3d_device_set_stream_source_freq(This->wined3d_device, StreamNumber, Divider);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVICE9EX iface, UINT StreamNumber, UINT* Divider) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSourceFreq(IDirect3DDevice9Ex *iface,
+ UINT StreamNumber, UINT *Divider)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, stream_idx %u, freq %p.\n", iface, StreamNumber, Divider);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetStreamSourceFreq(This->WineD3DDevice, StreamNumber, Divider);
+ hr = wined3d_device_get_stream_source_freq(This->wined3d_device, StreamNumber, Divider);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9EX iface, IDirect3DIndexBuffer9* pIndexData) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_SetIndices(IDirect3DDevice9Ex *iface,
+ IDirect3DIndexBuffer9 *pIndexData)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
IDirect3DIndexBuffer9Impl *ib = (IDirect3DIndexBuffer9Impl *) pIndexData;
TRACE("iface %p, buffer %p.\n", iface, pIndexData);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetIndexBuffer(This->WineD3DDevice,
+ hr = wined3d_device_set_index_buffer(This->wined3d_device,
ib ? ib->wineD3DIndexBuffer : NULL,
ib ? ib->format : WINED3DFMT_UNKNOWN);
wined3d_mutex_unlock();
@@ -2448,10 +2558,11 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9EX ifac
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(IDirect3DDevice9Ex *iface, IDirect3DIndexBuffer9 **ppIndexData)
+static HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(IDirect3DDevice9Ex *iface,
+ IDirect3DIndexBuffer9 **ppIndexData)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- IWineD3DBuffer *retIndexData = NULL;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
+ struct wined3d_buffer *retIndexData = NULL;
HRESULT hr;
TRACE("iface %p, buffer %p.\n", iface, ppIndexData);
@@ -2461,12 +2572,12 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(IDirect3DDevice9Ex *iface,
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetIndexBuffer(This->WineD3DDevice, &retIndexData);
+ hr = wined3d_device_get_index_buffer(This->wined3d_device, &retIndexData);
if (SUCCEEDED(hr) && retIndexData)
{
- *ppIndexData = IWineD3DBuffer_GetParent(retIndexData);
+ *ppIndexData = wined3d_buffer_get_parent(retIndexData);
IDirect3DIndexBuffer9_AddRef(*ppIndexData);
- IWineD3DBuffer_Release(retIndexData);
+ wined3d_buffer_decref(retIndexData);
}
else
{
@@ -2481,7 +2592,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(IDirect3DDevice9Ex *iface,
static HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(IDirect3DDevice9Ex *iface,
const DWORD *byte_code, IDirect3DPixelShader9 **shader)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DPixelShader9Impl *object;
HRESULT hr;
@@ -2511,13 +2622,14 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(IDirect3DDevice9Ex
static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(IDirect3DDevice9Ex *iface,
IDirect3DPixelShader9 *shader)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, shader %p.\n", iface, shader);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetPixelShader(((IDirect3DDevice9Impl *)iface)->WineD3DDevice,
- shader ? ((IDirect3DPixelShader9Impl *)shader)->wineD3DPixelShader : NULL);
+ hr = wined3d_device_set_pixel_shader(This->wined3d_device,
+ shader ? ((IDirect3DPixelShader9Impl *)shader)->wined3d_shader : NULL);
wined3d_mutex_unlock();
return hr;
@@ -2526,19 +2638,20 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(IDirect3DDevice9Ex *if
static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(IDirect3DDevice9Ex *iface,
IDirect3DPixelShader9 **shader)
{
- IWineD3DPixelShader *wined3d_shader;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
+ struct wined3d_shader *wined3d_shader;
TRACE("iface %p, shader %p.\n", iface, shader);
if (!shader) return D3DERR_INVALIDCALL;
wined3d_mutex_lock();
- wined3d_shader = IWineD3DDevice_GetPixelShader(((IDirect3DDevice9Impl *)iface)->WineD3DDevice);
+ wined3d_shader = wined3d_device_get_pixel_shader(This->wined3d_device);
if (wined3d_shader)
{
- *shader = IWineD3DPixelShader_GetParent(wined3d_shader);
+ *shader = wined3d_shader_get_parent(wined3d_shader);
IDirect3DPixelShader9_AddRef(*shader);
- IWineD3DPixelShader_Release(wined3d_shader);
+ wined3d_shader_decref(wined3d_shader);
}
else
{
@@ -2554,12 +2667,13 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(IDirect3DDevice9Ex *if
static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(IDirect3DDevice9Ex *iface,
UINT reg_idx, const float *data, UINT count)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetPixelShaderConstantF(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, reg_idx, data, count);
+ hr = wined3d_device_set_ps_consts_f(This->wined3d_device, reg_idx, data, count);
wined3d_mutex_unlock();
return hr;
@@ -2568,12 +2682,13 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(IDirect3DDevi
static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(IDirect3DDevice9Ex *iface,
UINT reg_idx, float *data, UINT count)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetPixelShaderConstantF(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, reg_idx, data, count);
+ hr = wined3d_device_get_ps_consts_f(This->wined3d_device, reg_idx, data, count);
wined3d_mutex_unlock();
return hr;
@@ -2582,12 +2697,13 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(IDirect3DDevi
static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(IDirect3DDevice9Ex *iface,
UINT reg_idx, const int *data, UINT count)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetPixelShaderConstantI(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, reg_idx, data, count);
+ hr = wined3d_device_set_ps_consts_i(This->wined3d_device, reg_idx, data, count);
wined3d_mutex_unlock();
return hr;
@@ -2596,12 +2712,13 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(IDirect3DDevi
static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(IDirect3DDevice9Ex *iface,
UINT reg_idx, int *data, UINT count)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetPixelShaderConstantI(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, reg_idx, data, count);
+ hr = wined3d_device_get_ps_consts_i(This->wined3d_device, reg_idx, data, count);
wined3d_mutex_unlock();
return hr;
@@ -2610,12 +2727,13 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(IDirect3DDevi
static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(IDirect3DDevice9Ex *iface,
UINT reg_idx, const BOOL *data, UINT count)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
wined3d_mutex_lock();
- hr = IWineD3DDevice_SetPixelShaderConstantB(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, reg_idx, data, count);
+ hr = wined3d_device_set_ps_consts_b(This->wined3d_device, reg_idx, data, count);
wined3d_mutex_unlock();
return hr;
@@ -2624,62 +2742,70 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(IDirect3DDevi
static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(IDirect3DDevice9Ex *iface,
UINT reg_idx, BOOL *data, UINT count)
{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
wined3d_mutex_lock();
- hr = IWineD3DDevice_GetPixelShaderConstantB(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, reg_idx, data, count);
+ hr = wined3d_device_get_ps_consts_b(This->wined3d_device, reg_idx, data, count);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_DrawRectPatch(LPDIRECT3DDEVICE9EX iface, UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_DrawRectPatch(IDirect3DDevice9Ex *iface, UINT Handle,
+ const float *pNumSegs, const D3DRECTPATCH_INFO *pRectPatchInfo)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, handle %#x, segment_count %p, patch_info %p.\n",
iface, Handle, pNumSegs, pRectPatchInfo);
wined3d_mutex_lock();
- hr = IWineD3DDevice_DrawRectPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DRECTPATCH_INFO *)pRectPatchInfo);
+ hr = wined3d_device_draw_rect_patch(This->wined3d_device, Handle,
+ pNumSegs, (const WINED3DRECTPATCH_INFO *)pRectPatchInfo);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_DrawTriPatch(LPDIRECT3DDEVICE9EX iface, UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_DrawTriPatch(IDirect3DDevice9Ex *iface, UINT Handle,
+ const float *pNumSegs, const D3DTRIPATCH_INFO *pTriPatchInfo)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, handle %#x, segment_count %p, patch_info %p.\n",
iface, Handle, pNumSegs, pTriPatchInfo);
wined3d_mutex_lock();
- hr = IWineD3DDevice_DrawTriPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DTRIPATCH_INFO *)pTriPatchInfo);
+ hr = wined3d_device_draw_tri_patch(This->wined3d_device, Handle,
+ pNumSegs, (const WINED3DTRIPATCH_INFO *)pTriPatchInfo);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9EX iface, UINT Handle) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+static HRESULT WINAPI IDirect3DDevice9Impl_DeletePatch(IDirect3DDevice9Ex *iface, UINT Handle)
+{
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, handle %#x.\n", iface, Handle);
wined3d_mutex_lock();
- hr = IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle);
+ hr = wined3d_device_delete_patch(This->wined3d_device, Handle);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(IDirect3DDevice9Ex *iface,
- D3DQUERYTYPE type, IDirect3DQuery9 **query)
+static HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(IDirect3DDevice9Ex *iface, D3DQUERYTYPE type,
+ IDirect3DQuery9 **query)
{
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DQuery9Impl *object;
HRESULT hr;
@@ -2701,8 +2827,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(IDirect3DDevice9Ex *iface
}
TRACE("Created query %p.\n", object);
- if (query) *query = (IDirect3DQuery9 *)object;
- else IDirect3DQuery9_Release((IDirect3DQuery9 *)object);
+ if (query) *query = &object->IDirect3DQuery9_iface;
+ else IDirect3DQuery9_Release(&object->IDirect3DQuery9_iface);
return D3D_OK;
}
@@ -2713,7 +2839,7 @@ static HRESULT WINAPI IDirect3DDevice9ExImpl_SetConvolutionMonoKernel(IDirect3DD
FIXME("iface %p, width %u, height %u, rows %p, columns %p stub!\n",
iface, width, height, rows, columns);
- return WINED3DERR_INVALIDCALL;
+ return E_NOTIMPL;
}
static HRESULT WINAPI IDirect3DDevice9ExImpl_ComposeRects(IDirect3DDevice9Ex *iface,
@@ -2725,7 +2851,7 @@ static HRESULT WINAPI IDirect3DDevice9ExImpl_ComposeRects(IDirect3DDevice9Ex *if
iface, src_surface, dst_surface, src_descs, rect_count,
dst_descs, operation, offset_x, offset_y);
- return WINED3DERR_INVALIDCALL;
+ return E_NOTIMPL;
}
static HRESULT WINAPI IDirect3DDevice9ExImpl_PresentEx(IDirect3DDevice9Ex *iface,
@@ -2735,28 +2861,28 @@ static HRESULT WINAPI IDirect3DDevice9ExImpl_PresentEx(IDirect3DDevice9Ex *iface
FIXME("iface %p, src_rect %p, dst_rect %p, dst_window_override %p, dirty_region %p, flags %#x stub!\n",
iface, src_rect, dst_rect, dst_window_override, dirty_region, flags);
- return WINED3DERR_INVALIDCALL;
+ return E_NOTIMPL;
}
static HRESULT WINAPI IDirect3DDevice9ExImpl_GetGPUThreadPriority(IDirect3DDevice9Ex *iface, INT *priority)
{
FIXME("iface %p, priority %p stub!\n", iface, priority);
- return WINED3DERR_INVALIDCALL;
+ return E_NOTIMPL;
}
static HRESULT WINAPI IDirect3DDevice9ExImpl_SetGPUThreadPriority(IDirect3DDevice9Ex *iface, INT priority)
{
FIXME("iface %p, priority %d stub!\n", iface, priority);
- return WINED3DERR_INVALIDCALL;
+ return E_NOTIMPL;
}
static HRESULT WINAPI IDirect3DDevice9ExImpl_WaitForVBlank(IDirect3DDevice9Ex *iface, UINT swapchain_idx)
{
FIXME("iface %p, swapchain_idx %u stub!\n", iface, swapchain_idx);
- return WINED3DERR_INVALIDCALL;
+ return E_NOTIMPL;
}
static HRESULT WINAPI IDirect3DDevice9ExImpl_CheckResourceResidency(IDirect3DDevice9Ex *iface,
@@ -2765,14 +2891,14 @@ static HRESULT WINAPI IDirect3DDevice9ExImpl_CheckResourceResidency(IDirect3DDev
FIXME("iface %p, resources %p, resource_count %u stub!\n",
iface, resources, resource_count);
- return WINED3DERR_INVALIDCALL;
+ return E_NOTIMPL;
}
static HRESULT WINAPI IDirect3DDevice9ExImpl_SetMaximumFrameLatency(IDirect3DDevice9Ex *iface, UINT max_latency)
{
FIXME("iface %p, max_latency %u stub!\n", iface, max_latency);
- return WINED3DERR_INVALIDCALL;
+ return E_NOTIMPL;
}
static HRESULT WINAPI IDirect3DDevice9ExImpl_GetMaximumFrameLatency(IDirect3DDevice9Ex *iface, UINT *max_latency)
@@ -2781,14 +2907,19 @@ static HRESULT WINAPI IDirect3DDevice9ExImpl_GetMaximumFrameLatency(IDirect3DDev
*max_latency = 2;
- return WINED3DERR_INVALIDCALL;
+ return E_NOTIMPL;
}
static HRESULT WINAPI IDirect3DDevice9ExImpl_CheckDeviceState(IDirect3DDevice9Ex *iface, HWND dst_window)
{
- FIXME("iface %p, dst_window %p stub!\n", iface, dst_window);
+ static int i;
- return WINED3DERR_INVALIDCALL;
+ TRACE("iface %p, dst_window %p stub!\n", iface, dst_window);
+
+ if (!i++)
+ FIXME("iface %p, dst_window %p stub!\n", iface, dst_window);
+
+ return D3D_OK;
}
static HRESULT WINAPI IDirect3DDevice9ExImpl_CreateRenderTargetEx(IDirect3DDevice9Ex *iface,
@@ -2800,7 +2931,7 @@ static HRESULT WINAPI IDirect3DDevice9ExImpl_CreateRenderTargetEx(IDirect3DDevic
iface, width, height, format, multisample_type, multisample_quality,
lockable, surface, shared_handle, usage);
- return WINED3DERR_INVALIDCALL;
+ return E_NOTIMPL;
}
static HRESULT WINAPI IDirect3DDevice9ExImpl_CreateOffscreenPlainSurfaceEx(IDirect3DDevice9Ex *iface,
@@ -2810,7 +2941,7 @@ static HRESULT WINAPI IDirect3DDevice9ExImpl_CreateOffscreenPlainSurfaceEx(IDire
FIXME("iface %p, width %u, height %u, format %#x, pool %#x, surface %p, shared_handle %p, usage %#x stub!\n",
iface, width, height, format, pool, surface, shared_handle, usage);
- return WINED3DERR_INVALIDCALL;
+ return E_NOTIMPL;
}
static HRESULT WINAPI IDirect3DDevice9ExImpl_CreateDepthStencilSurfaceEx(IDirect3DDevice9Ex *iface,
@@ -2822,7 +2953,7 @@ static HRESULT WINAPI IDirect3DDevice9ExImpl_CreateDepthStencilSurfaceEx(IDirect
iface, width, height, format, multisample_type, multisample_quality,
discard, surface, shared_handle, usage);
- return WINED3DERR_INVALIDCALL;
+ return E_NOTIMPL;
}
static HRESULT WINAPI IDirect3DDevice9ExImpl_ResetEx(IDirect3DDevice9Ex *iface,
@@ -2830,7 +2961,7 @@ static HRESULT WINAPI IDirect3DDevice9ExImpl_ResetEx(IDirect3DDevice9Ex *iface,
{
FIXME("iface %p, present_parameters %p, mode %p stub!\n", iface, present_parameters, mode);
- return WINED3DERR_INVALIDCALL;
+ return E_NOTIMPL;
}
static HRESULT WINAPI IDirect3DDevice9ExImpl_GetDisplayModeEx(IDirect3DDevice9Ex *iface,
@@ -2838,7 +2969,7 @@ static HRESULT WINAPI IDirect3DDevice9ExImpl_GetDisplayModeEx(IDirect3DDevice9
{
FIXME("iface %p, swapchain_idx %u, mode %p, rotation %p stub!\n", iface, swapchain_idx, mode, rotation);
- return WINED3DERR_INVALIDCALL;
+ return E_NOTIMPL;
}
static const IDirect3DDevice9ExVtbl Direct3DDevice9_Vtbl =
@@ -2982,149 +3113,130 @@ static const IDirect3DDevice9ExVtbl Direct3DDevice9_Vtbl =
IDirect3DDevice9ExImpl_GetDisplayModeEx
};
-/* IWineD3DDeviceParent IUnknown methods */
-
-static inline struct IDirect3DDevice9Impl *device_from_device_parent(IWineD3DDeviceParent *iface)
+static inline struct IDirect3DDevice9Impl *device_from_device_parent(struct wined3d_device_parent *device_parent)
{
- return (struct IDirect3DDevice9Impl *)((char*)iface
- - FIELD_OFFSET(struct IDirect3DDevice9Impl, device_parent_vtbl));
+ return CONTAINING_RECORD(device_parent, struct IDirect3DDevice9Impl, device_parent);
}
-static HRESULT STDMETHODCALLTYPE device_parent_QueryInterface(IWineD3DDeviceParent *iface, REFIID riid, void **object)
+static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
+ struct wined3d_device *device)
{
- struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
- return IDirect3DDevice9Impl_QueryInterface((IDirect3DDevice9Ex *)This, riid, object);
+ TRACE("device_parent %p, device %p.\n", device_parent, device);
}
-static ULONG STDMETHODCALLTYPE device_parent_AddRef(IWineD3DDeviceParent *iface)
+static HRESULT CDECL device_parent_create_surface(struct wined3d_device_parent *device_parent,
+ void *container_parent, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
+ WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, struct wined3d_surface **surface)
{
- struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
- return IDirect3DDevice9Impl_AddRef((IDirect3DDevice9Ex *)This);
-}
-
-static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface)
-{
- struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
- return IDirect3DDevice9Impl_Release((IDirect3DDevice9Ex *)This);
-}
-
-/* IWineD3DDeviceParent methods */
-
-static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
-{
- TRACE("iface %p, device %p\n", iface, device);
-}
-
-static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
- WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
-{
- struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
+ struct IDirect3DDevice9Impl *device = device_from_device_parent(device_parent);
IDirect3DSurface9Impl *d3d_surface;
BOOL lockable = TRUE;
HRESULT hr;
- TRACE("iface %p, superior %p, width %u, height %u, format %#x, usage %#x,\n"
- "\tpool %#x, level %u, face %u, surface %p\n",
- iface, superior, width, height, format, usage, pool, level, face, surface);
+ TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n"
+ "\tpool %#x, level %u, face %u, surface %p.\n",
+ device_parent, container_parent, width, height, format, usage, pool, level, face, surface);
if (pool == WINED3DPOOL_DEFAULT && !(usage & D3DUSAGE_DYNAMIC))
lockable = FALSE;
- hr = IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9Ex *)This, width, height,
+ hr = IDirect3DDevice9Impl_CreateSurface(device, width, height,
d3dformat_from_wined3dformat(format), lockable, FALSE /* Discard */, level,
(IDirect3DSurface9 **)&d3d_surface, usage, pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
if (FAILED(hr))
{
- ERR("(%p) CreateSurface failed, returning %#x\n", iface, hr);
+ WARN("Failed to create surface, hr %#x.\n", hr);
return hr;
}
- *surface = d3d_surface->wineD3DSurface;
- IWineD3DSurface_AddRef(*surface);
+ *surface = d3d_surface->wined3d_surface;
+ wined3d_surface_incref(*surface);
- d3d_surface->container = superior;
+ d3d_surface->container = container_parent;
IDirect3DDevice9Ex_Release(d3d_surface->parentDevice);
d3d_surface->parentDevice = NULL;
IDirect3DSurface9_Release((IDirect3DSurface9 *)d3d_surface);
- d3d_surface->forwardReference = superior;
+ d3d_surface->forwardReference = container_parent;
return hr;
}
-static HRESULT STDMETHODCALLTYPE device_parent_CreateRenderTarget(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, enum wined3d_format_id format,
+static HRESULT CDECL device_parent_create_rendertarget(struct wined3d_device_parent *device_parent,
+ void *container_parent, UINT width, UINT height, enum wined3d_format_id format,
WINED3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality, BOOL lockable,
- IWineD3DSurface **surface)
+ struct wined3d_surface **surface)
{
- struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
+ struct IDirect3DDevice9Impl *device = device_from_device_parent(device_parent);
IDirect3DSurface9Impl *d3d_surface;
HRESULT hr;
- TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
- "\tmultisample_quality %u, lockable %u, surface %p\n",
- iface, superior, width, height, format, multisample_type, multisample_quality, lockable, surface);
+ TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, multisample_type %#x,\n"
+ "\tmultisample_quality %u, lockable %u, surface %p.\n",
+ device_parent, container_parent, width, height, format, multisample_type,
+ multisample_quality, lockable, surface);
- hr = IDirect3DDevice9Impl_CreateRenderTarget((IDirect3DDevice9Ex *)This, width, height,
+ hr = IDirect3DDevice9Impl_CreateRenderTarget(&device->IDirect3DDevice9Ex_iface, width, height,
d3dformat_from_wined3dformat(format), multisample_type, multisample_quality, lockable,
(IDirect3DSurface9 **)&d3d_surface, NULL);
if (FAILED(hr))
{
- ERR("(%p) CreateRenderTarget failed, returning %#x\n", iface, hr);
+ WARN("Failed to create rendertarget, hr %#x.\n", hr);
return hr;
}
- *surface = d3d_surface->wineD3DSurface;
- IWineD3DSurface_AddRef(*surface);
+ *surface = d3d_surface->wined3d_surface;
+ wined3d_surface_incref(*surface);
- d3d_surface->container = superior;
+ d3d_surface->container = container_parent;
/* Implicit surfaces are created with an refcount of 0 */
IDirect3DSurface9_Release((IDirect3DSurface9 *)d3d_surface);
return hr;
}
-static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent *iface,
+static HRESULT CDECL device_parent_create_depth_stencil(struct wined3d_device_parent *device_parent,
UINT width, UINT height, enum wined3d_format_id format, WINED3DMULTISAMPLE_TYPE multisample_type,
- DWORD multisample_quality, BOOL discard, IWineD3DSurface **surface)
+ DWORD multisample_quality, BOOL discard, struct wined3d_surface **surface)
{
- struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
+ struct IDirect3DDevice9Impl *device = device_from_device_parent(device_parent);
IDirect3DSurface9Impl *d3d_surface;
HRESULT hr;
- TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x,\n"
- "\tmultisample_quality %u, discard %u, surface %p\n",
- iface, width, height, format, multisample_type, multisample_quality, discard, surface);
+ TRACE("device_parent %p, width %u, height %u, format %#x, multisample_type %#x,\n"
+ "\tmultisample_quality %u, discard %u, surface %p.\n",
+ device_parent, width, height, format, multisample_type, multisample_quality, discard, surface);
- hr = IDirect3DDevice9Impl_CreateDepthStencilSurface((IDirect3DDevice9Ex *)This, width, height,
- d3dformat_from_wined3dformat(format), multisample_type, multisample_quality, discard,
- (IDirect3DSurface9 **)&d3d_surface, NULL);
+ hr = IDirect3DDevice9Impl_CreateDepthStencilSurface(&device->IDirect3DDevice9Ex_iface, width,
+ height, d3dformat_from_wined3dformat(format), multisample_type, multisample_quality,
+ discard, (IDirect3DSurface9 **)&d3d_surface, NULL);
if (FAILED(hr))
{
- ERR("(%p) CreateDepthStencilSurface failed, returning %#x\n", iface, hr);
+ WARN("Failed to create depth/stencil surface, hr %#x.\n", hr);
return hr;
}
- *surface = d3d_surface->wineD3DSurface;
- IWineD3DSurface_AddRef(*surface);
- d3d_surface->container = (IUnknown *)This;
+ *surface = d3d_surface->wined3d_surface;
+ wined3d_surface_incref(*surface);
+ d3d_surface->container = (IUnknown *)&device->IDirect3DDevice9Ex_iface;
/* Implicit surfaces are created with an refcount of 0 */
IDirect3DSurface9_Release((IDirect3DSurface9 *)d3d_surface);
return hr;
}
-static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
- WINED3DPOOL pool, DWORD usage, IWineD3DVolume **volume)
+static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *device_parent,
+ void *container_parent, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
+ WINED3DPOOL pool, DWORD usage, struct wined3d_volume **volume)
{
- struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
+ struct IDirect3DDevice9Impl *device = device_from_device_parent(device_parent);
IDirect3DVolume9Impl *object;
HRESULT hr;
- TRACE("iface %p, superior %p, width %u, height %u, depth %u, format %#x, pool %#x, usage %#x, volume %p\n",
- iface, superior, width, height, depth, format, pool, usage, volume);
+ TRACE("device_parent %p, container_parent %p, width %u, height %u, depth %u, "
+ "format %#x, pool %#x, usage %#x, volume %p\n",
+ device_parent, container_parent, width, height, depth,
+ format, pool, usage, volume);
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
@@ -3135,7 +3247,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent
return D3DERR_OUTOFVIDEOMEMORY;
}
- hr = volume_init(object, This, width, height, depth, usage, format, pool);
+ hr = volume_init(object, device, width, height, depth, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize volume, hr %#x.\n", hr);
@@ -3143,27 +3255,27 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent
return hr;
}
- *volume = object->wineD3DVolume;
- IWineD3DVolume_AddRef(*volume);
- IDirect3DVolume9_Release((IDirect3DVolume9 *)object);
+ *volume = object->wined3d_volume;
+ wined3d_volume_incref(*volume);
+ IDirect3DVolume9_Release(&object->IDirect3DVolume9_iface);
- object->container = superior;
- object->forwardReference = superior;
+ object->container = container_parent;
+ object->forwardReference = container_parent;
- TRACE("(%p) Created volume %p\n", iface, object);
+ TRACE("Created volume %p.\n", object);
return hr;
}
-static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDeviceParent *iface,
- WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
+static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
+ WINED3DPRESENT_PARAMETERS *present_parameters, struct wined3d_swapchain **swapchain)
{
- struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
- IDirect3DSwapChain9Impl *d3d_swapchain;
+ struct IDirect3DDevice9Impl *device = device_from_device_parent(device_parent);
D3DPRESENT_PARAMETERS local_parameters;
+ IDirect3DSwapChain9 *d3d_swapchain;
HRESULT hr;
- TRACE("iface %p, present_parameters %p, swapchain %p\n", iface, present_parameters, swapchain);
+ TRACE("device_parent %p, present_parameters %p, swapchain %p\n", device_parent, present_parameters, swapchain);
/* Copy the presentation parameters */
local_parameters.BackBufferWidth = present_parameters->BackBufferWidth;
@@ -3181,18 +3293,17 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
local_parameters.FullScreen_RefreshRateInHz = present_parameters->FullScreen_RefreshRateInHz;
local_parameters.PresentationInterval = present_parameters->PresentationInterval;
- hr = IDirect3DDevice9Impl_CreateAdditionalSwapChain((IDirect3DDevice9Ex *)This,
- &local_parameters, (IDirect3DSwapChain9 **)&d3d_swapchain);
+ hr = IDirect3DDevice9Impl_CreateAdditionalSwapChain(&device->IDirect3DDevice9Ex_iface,
+ &local_parameters, &d3d_swapchain);
if (FAILED(hr))
{
- ERR("(%p) CreateAdditionalSwapChain failed, returning %#x\n", iface, hr);
+ WARN("Failed to create swapchain, hr %#x.\n", hr);
*swapchain = NULL;
return hr;
}
- *swapchain = d3d_swapchain->wineD3DSwapChain;
- d3d_swapchain->isImplicit = TRUE;
- /* Implicit swap chains are created with an refcount of 0 */
+ *swapchain = ((IDirect3DSwapChain9Impl *)d3d_swapchain)->wined3d_swapchain;
+ wined3d_swapchain_incref(*swapchain);
IDirect3DSwapChain9_Release((IDirect3DSwapChain9 *)d3d_swapchain);
/* Copy back the presentation parameters */
@@ -3214,19 +3325,14 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDevicePar
return hr;
}
-static const IWineD3DDeviceParentVtbl d3d9_wined3d_device_parent_vtbl =
+static const struct wined3d_device_parent_ops d3d9_wined3d_device_parent_ops =
{
- /* IUnknown methods */
- device_parent_QueryInterface,
- device_parent_AddRef,
- device_parent_Release,
- /* IWineD3DDeviceParent methods */
- device_parent_WineD3DDeviceCreated,
- device_parent_CreateSurface,
- device_parent_CreateRenderTarget,
- device_parent_CreateDepthStencilSurface,
- device_parent_CreateVolume,
- device_parent_CreateSwapChain,
+ device_parent_wined3d_device_created,
+ device_parent_create_surface,
+ device_parent_create_rendertarget,
+ device_parent_create_depth_stencil,
+ device_parent_create_volume,
+ device_parent_create_swapchain,
};
static void setup_fpu(void)
@@ -3241,22 +3347,25 @@ static void setup_fpu(void)
#endif
}
-HRESULT device_init(IDirect3DDevice9Impl *device, IWineD3D *wined3d, UINT adapter, D3DDEVTYPE device_type,
- HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters)
+HRESULT device_init(IDirect3DDevice9Impl *device, struct wined3d *wined3d, UINT adapter, D3DDEVTYPE device_type,
+ HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode)
{
WINED3DPRESENT_PARAMETERS *wined3d_parameters;
UINT i, count = 1;
HRESULT hr;
- device->lpVtbl = &Direct3DDevice9_Vtbl;
- device->device_parent_vtbl = &d3d9_wined3d_device_parent_vtbl;
+ if (mode)
+ FIXME("Ignoring display mode.\n");
+
+ device->IDirect3DDevice9Ex_iface.lpVtbl = &Direct3DDevice9_Vtbl;
+ device->device_parent.ops = &d3d9_wined3d_device_parent_ops;
device->ref = 1;
if (!(flags & D3DCREATE_FPU_PRESERVE)) setup_fpu();
wined3d_mutex_lock();
- hr = IWineD3D_CreateDevice(wined3d, adapter, device_type, focus_window, flags,
- (IWineD3DDeviceParent *)&device->device_parent_vtbl, &device->WineD3DDevice);
+ hr = wined3d_device_create(wined3d, adapter, device_type, focus_window, flags,
+ &device->device_parent, &device->wined3d_device);
if (FAILED(hr))
{
WARN("Failed to create wined3d device, hr %#x.\n", hr);
@@ -3264,33 +3373,45 @@ HRESULT device_init(IDirect3DDevice9Impl *device, IWineD3D *wined3d, UINT adapte
return hr;
}
- if (!parameters->Windowed)
- {
- if (!focus_window) focus_window = parameters->hDeviceWindow;
- if (FAILED(hr = IWineD3DDevice_AcquireFocusWindow(device->WineD3DDevice, focus_window)))
- {
- ERR("Failed to acquire focus window, hr %#x.\n", hr);
- IWineD3DDevice_Release(device->WineD3DDevice);
- wined3d_mutex_unlock();
- return hr;
- }
- }
-
if (flags & D3DCREATE_ADAPTERGROUP_DEVICE)
{
WINED3DCAPS caps;
- IWineD3D_GetDeviceCaps(wined3d, adapter, device_type, &caps);
+ wined3d_get_device_caps(wined3d, adapter, device_type, &caps);
count = caps.NumberOfAdaptersInGroup;
}
- if (flags & D3DCREATE_MULTITHREADED) IWineD3DDevice_SetMultithreaded(device->WineD3DDevice);
+ if (flags & D3DCREATE_MULTITHREADED)
+ wined3d_device_set_multithreaded(device->wined3d_device);
+
+ if (!parameters->Windowed)
+ {
+ if (!focus_window)
+ focus_window = parameters->hDeviceWindow;
+ if (FAILED(hr = wined3d_device_acquire_focus_window(device->wined3d_device, focus_window)))
+ {
+ ERR("Failed to acquire focus window, hr %#x.\n", hr);
+ wined3d_device_decref(device->wined3d_device);
+ wined3d_mutex_unlock();
+ return hr;
+ }
+
+ for (i = 0; i < count; ++i)
+ {
+ HWND device_window = parameters[i].hDeviceWindow;
+
+ if (!device_window) device_window = focus_window;
+ wined3d_device_setup_fullscreen_window(device->wined3d_device, device_window,
+ parameters[i].BackBufferWidth,
+ parameters[i].BackBufferHeight);
+ }
+ }
wined3d_parameters = HeapAlloc(GetProcessHeap(), 0, sizeof(*wined3d_parameters) * count);
if (!wined3d_parameters)
{
ERR("Failed to allocate wined3d parameters.\n");
- IWineD3DDevice_Release(device->WineD3DDevice);
+ wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
return E_OUTOFMEMORY;
}
@@ -3315,13 +3436,13 @@ HRESULT device_init(IDirect3DDevice9Impl *device, IWineD3D *wined3d, UINT adapte
wined3d_parameters[i].AutoRestoreDisplayMode = TRUE;
}
- hr = IWineD3DDevice_Init3D(device->WineD3DDevice, wined3d_parameters);
+ hr = wined3d_device_init_3d(device->wined3d_device, wined3d_parameters);
if (FAILED(hr))
{
WARN("Failed to initialize 3D, hr %#x.\n", hr);
- IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
+ wined3d_device_release_focus_window(device->wined3d_device);
HeapFree(GetProcessHeap(), 0, wined3d_parameters);
- IWineD3DDevice_Release(device->WineD3DDevice);
+ wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
return hr;
}
@@ -3355,9 +3476,9 @@ HRESULT device_init(IDirect3DDevice9Impl *device, IWineD3D *wined3d, UINT adapte
{
ERR("Failed to allocate FVF vertex declaration map memory.\n");
wined3d_mutex_lock();
- IWineD3DDevice_Uninit3D(device->WineD3DDevice, D3D9CB_DestroySwapChain);
- IWineD3DDevice_ReleaseFocusWindow(device->WineD3DDevice);
- IWineD3DDevice_Release(device->WineD3DDevice);
+ wined3d_device_uninit_3d(device->wined3d_device);
+ wined3d_device_release_focus_window(device->wined3d_device);
+ wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock();
return E_OUTOFMEMORY;
}
diff --git a/reactos/dll/directx/wine/d3d9/directx.c b/reactos/dll/directx/wine/d3d9/directx.c
index 1fcc8c47fcf..7a22c30223d 100644
--- a/reactos/dll/directx/wine/d3d9/directx.c
+++ b/reactos/dll/directx/wine/d3d9/directx.c
@@ -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));
diff --git a/reactos/dll/directx/wine/d3d9/query.c b/reactos/dll/directx/wine/d3d9/query.c
index 4a5869696fb..42523320f33 100644
--- a/reactos/dll/directx/wine/d3d9/query.c
+++ b/reactos/dll/directx/wine/d3d9/query.c
@@ -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;
diff --git a/reactos/dll/directx/wine/d3d9/shader.c b/reactos/dll/directx/wine/d3d9/shader.c
index c6656e524c3..c36600dcd60 100644
--- a/reactos/dll/directx/wine/d3d9/shader.c
+++ b/reactos/dll/directx/wine/d3d9/shader.c
@@ -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;
diff --git a/reactos/dll/directx/wine/d3d9/stateblock.c b/reactos/dll/directx/wine/d3d9/stateblock.c
index 01a882eea54..06f8aedba75 100644
--- a/reactos/dll/directx/wine/d3d9/stateblock.c
+++ b/reactos/dll/directx/wine/d3d9/stateblock.c
@@ -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;
diff --git a/reactos/dll/directx/wine/d3d9/surface.c b/reactos/dll/directx/wine/d3d9/surface.c
index de3fb779e0d..1d66bde2d90 100644
--- a/reactos/dll/directx/wine/d3d9/surface.c
+++ b/reactos/dll/directx/wine/d3d9/surface.c
@@ -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;
diff --git a/reactos/dll/directx/wine/d3d9/swapchain.c b/reactos/dll/directx/wine/d3d9/swapchain.c
index 0d523914f92..26437079970 100644
--- a/reactos/dll/directx/wine/d3d9/swapchain.c
+++ b/reactos/dll/directx/wine/d3d9/swapchain.c
@@ -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;
diff --git a/reactos/dll/directx/wine/d3d9/texture.c b/reactos/dll/directx/wine/d3d9/texture.c
index dbe9798ab64..d1df0f5ee7b 100644
--- a/reactos/dll/directx/wine/d3d9/texture.c
+++ b/reactos/dll/directx/wine/d3d9/texture.c
@@ -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;
diff --git a/reactos/dll/directx/wine/d3d9/vertexdeclaration.c b/reactos/dll/directx/wine/d3d9/vertexdeclaration.c
index 88f912f1dba..62246147d3c 100644
--- a/reactos/dll/directx/wine/d3d9/vertexdeclaration.c
+++ b/reactos/dll/directx/wine/d3d9/vertexdeclaration.c
@@ -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;
diff --git a/reactos/dll/directx/wine/d3d9/volume.c b/reactos/dll/directx/wine/d3d9/volume.c
index 1ecd2b27d29..ba495b644d0 100644
--- a/reactos/dll/directx/wine/d3d9/volume.c
+++ b/reactos/dll/directx/wine/d3d9/volume.c
@@ -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);
diff --git a/reactos/dll/directx/wine/d3d9/volumetexture.c b/reactos/dll/directx/wine/d3d9/volumetexture.c
index 7ce46237cc3..9528e9b8dd5 100644
--- a/reactos/dll/directx/wine/d3d9/volumetexture.c
+++ b/reactos/dll/directx/wine/d3d9/volumetexture.c
@@ -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;
diff --git a/reactos/dll/directx/wine/ddraw/CMakeLists.txt b/reactos/dll/directx/wine/ddraw/CMakeLists.txt
index 81732d6678b..b05d1a50343 100644
--- a/reactos/dll/directx/wine/ddraw/CMakeLists.txt
+++ b/reactos/dll/directx/wine/ddraw/CMakeLists.txt
@@ -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
diff --git a/reactos/dll/directx/wine/ddraw/clipper.c b/reactos/dll/directx/wine/ddraw/clipper.c
index b4c493c4bad..c9290c85a50 100644
--- a/reactos/dll/directx/wine/ddraw/clipper.c
+++ b/reactos/dll/directx/wine/ddraw/clipper.c
@@ -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");
diff --git a/reactos/dll/directx/wine/ddraw/ddraw.c b/reactos/dll/directx/wine/ddraw/ddraw.c
index bef9cf0f8a6..0c6ba3c2656 100644
--- a/reactos/dll/directx/wine/ddraw/ddraw.c
+++ b/reactos/dll/directx/wine/ddraw/ddraw.c
@@ -46,24 +46,49 @@ const struct wined3d_parent_ops ddraw_null_wined3d_parent_ops =
ddraw_null_wined3d_object_destroyed,
};
-static inline IDirectDrawImpl *ddraw_from_ddraw1(IDirectDraw *iface)
+static inline IDirectDrawImpl *impl_from_IDirectDraw(IDirectDraw *iface)
{
- return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw_vtbl));
+ return CONTAINING_RECORD(iface, IDirectDrawImpl, IDirectDraw_iface);
}
-static inline IDirectDrawImpl *ddraw_from_ddraw2(IDirectDraw2 *iface)
+static inline IDirectDrawImpl *impl_from_IDirectDraw2(IDirectDraw2 *iface)
{
- return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw2_vtbl));
+ return CONTAINING_RECORD(iface, IDirectDrawImpl, IDirectDraw2_iface);
}
-static inline IDirectDrawImpl *ddraw_from_ddraw3(IDirectDraw3 *iface)
+static inline IDirectDrawImpl *impl_from_IDirectDraw3(IDirectDraw3 *iface)
{
- return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw3_vtbl));
+ return CONTAINING_RECORD(iface, IDirectDrawImpl, IDirectDraw3_iface);
}
-static inline IDirectDrawImpl *ddraw_from_ddraw4(IDirectDraw4 *iface)
+static inline IDirectDrawImpl *impl_from_IDirectDraw4(IDirectDraw4 *iface)
{
- return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw4_vtbl));
+ return CONTAINING_RECORD(iface, IDirectDrawImpl, IDirectDraw4_iface);
+}
+
+static inline IDirectDrawImpl *impl_from_IDirectDraw7(IDirectDraw7 *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectDrawImpl, IDirectDraw7_iface);
+}
+
+static inline IDirectDrawImpl *impl_from_IDirect3D(IDirect3D *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectDrawImpl, IDirect3D_iface);
+}
+
+static inline IDirectDrawImpl *impl_from_IDirect3D2(IDirect3D2 *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectDrawImpl, IDirect3D2_iface);
+}
+
+static inline IDirectDrawImpl *impl_from_IDirect3D3(IDirect3D3 *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectDrawImpl, IDirect3D3_iface);
+}
+
+static inline IDirectDrawImpl *impl_from_IDirect3D7(IDirect3D7 *iface)
+{
+ return CONTAINING_RECORD(iface, IDirectDrawImpl, IDirect3D7_iface);
}
/*****************************************************************************
@@ -92,7 +117,7 @@ static inline IDirectDrawImpl *ddraw_from_ddraw4(IDirectDraw4 *iface)
*****************************************************************************/
static HRESULT WINAPI ddraw7_QueryInterface(IDirectDraw7 *iface, REFIID refiid, void **obj)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(refiid), obj);
@@ -117,7 +142,7 @@ static HRESULT WINAPI ddraw7_QueryInterface(IDirectDraw7 *iface, REFIID refiid,
}
else if ( IsEqualGUID( &IID_IDirectDraw4, refiid ) )
{
- *obj = &This->IDirectDraw4_vtbl;
+ *obj = &This->IDirectDraw4_iface;
TRACE("(%p) Returning IDirectDraw4 interface at %p\n", This, *obj);
}
else if ( IsEqualGUID( &IID_IDirectDraw3, refiid ) )
@@ -130,12 +155,12 @@ static HRESULT WINAPI ddraw7_QueryInterface(IDirectDraw7 *iface, REFIID refiid,
}
else if ( IsEqualGUID( &IID_IDirectDraw2, refiid ) )
{
- *obj = &This->IDirectDraw2_vtbl;
+ *obj = &This->IDirectDraw2_iface;
TRACE("(%p) Returning IDirectDraw2 interface at %p\n", This, *obj);
}
else if ( IsEqualGUID( &IID_IDirectDraw, refiid ) )
{
- *obj = &This->IDirectDraw_vtbl;
+ *obj = &This->IDirectDraw_iface;
TRACE("(%p) Returning IDirectDraw interface at %p\n", This, *obj);
}
@@ -174,33 +199,28 @@ static HRESULT WINAPI ddraw7_QueryInterface(IDirectDraw7 *iface, REFIID refiid,
if ( IsEqualGUID( &IID_IDirect3D , refiid ) )
{
This->d3dversion = 1;
- *obj = &This->IDirect3D_vtbl;
+ *obj = &This->IDirect3D_iface;
TRACE(" returning Direct3D interface at %p.\n", *obj);
}
else if ( IsEqualGUID( &IID_IDirect3D2 , refiid ) )
{
This->d3dversion = 2;
- *obj = &This->IDirect3D2_vtbl;
+ *obj = &This->IDirect3D2_iface;
TRACE(" returning Direct3D2 interface at %p.\n", *obj);
}
else if ( IsEqualGUID( &IID_IDirect3D3 , refiid ) )
{
This->d3dversion = 3;
- *obj = &This->IDirect3D3_vtbl;
+ *obj = &This->IDirect3D3_iface;
TRACE(" returning Direct3D3 interface at %p.\n", *obj);
}
else if(IsEqualGUID( &IID_IDirect3D7 , refiid ))
{
This->d3dversion = 7;
- *obj = &This->IDirect3D7_vtbl;
+ *obj = &This->IDirect3D7_iface;
TRACE(" returning Direct3D7 interface at %p.\n", *obj);
}
}
- else if (IsEqualGUID(refiid, &IID_IWineD3DDeviceParent))
- {
- *obj = &This->device_parent_vtbl;
- }
-
/* Unknown interface */
else
{
@@ -216,58 +236,74 @@ static HRESULT WINAPI ddraw7_QueryInterface(IDirectDraw7 *iface, REFIID refiid,
static HRESULT WINAPI ddraw4_QueryInterface(IDirectDraw4 *iface, REFIID riid, void **object)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
- return ddraw7_QueryInterface((IDirectDraw7 *)ddraw_from_ddraw4(iface), riid, object);
+ return ddraw7_QueryInterface(&This->IDirectDraw7_iface, riid, object);
}
static HRESULT WINAPI ddraw3_QueryInterface(IDirectDraw3 *iface, REFIID riid, void **object)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
- return ddraw7_QueryInterface((IDirectDraw7 *)ddraw_from_ddraw3(iface), riid, object);
+ return ddraw7_QueryInterface(&This->IDirectDraw7_iface, riid, object);
}
static HRESULT WINAPI ddraw2_QueryInterface(IDirectDraw2 *iface, REFIID riid, void **object)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
- return ddraw7_QueryInterface((IDirectDraw7 *)ddraw_from_ddraw2(iface), riid, object);
+ return ddraw7_QueryInterface(&This->IDirectDraw7_iface, riid, object);
}
static HRESULT WINAPI ddraw1_QueryInterface(IDirectDraw *iface, REFIID riid, void **object)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
- return ddraw7_QueryInterface((IDirectDraw7 *)ddraw_from_ddraw1(iface), riid, object);
+ return ddraw7_QueryInterface(&This->IDirectDraw7_iface, riid, object);
}
static HRESULT WINAPI d3d7_QueryInterface(IDirect3D7 *iface, REFIID riid, void **object)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D7(iface);
+
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
- return ddraw7_QueryInterface((IDirectDraw7 *)ddraw_from_d3d7(iface), riid, object);
+ return ddraw7_QueryInterface(&This->IDirectDraw7_iface, riid, object);
}
static HRESULT WINAPI d3d3_QueryInterface(IDirect3D3 *iface, REFIID riid, void **object)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D3(iface);
+
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
- return ddraw7_QueryInterface((IDirectDraw7 *)ddraw_from_d3d3(iface), riid, object);
+ return ddraw7_QueryInterface(&This->IDirectDraw7_iface, riid, object);
}
static HRESULT WINAPI d3d2_QueryInterface(IDirect3D2 *iface, REFIID riid, void **object)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D2(iface);
+
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
- return ddraw7_QueryInterface((IDirectDraw7 *)ddraw_from_d3d2(iface), riid, object);
+ return ddraw7_QueryInterface(&This->IDirectDraw7_iface, riid, object);
}
static HRESULT WINAPI d3d1_QueryInterface(IDirect3D *iface, REFIID riid, void **object)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D(iface);
+
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
- return ddraw7_QueryInterface((IDirectDraw7 *)ddraw_from_d3d1(iface), riid, object);
+ return ddraw7_QueryInterface(&This->IDirectDraw7_iface, riid, object);
}
/*****************************************************************************
@@ -290,7 +326,7 @@ static HRESULT WINAPI d3d1_QueryInterface(IDirect3D *iface, REFIID riid, void **
*****************************************************************************/
static ULONG WINAPI ddraw7_AddRef(IDirectDraw7 *iface)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
ULONG ref = InterlockedIncrement(&This->ref7);
TRACE("%p increasing refcount to %u.\n", This, ref);
@@ -302,78 +338,86 @@ static ULONG WINAPI ddraw7_AddRef(IDirectDraw7 *iface)
static ULONG WINAPI ddraw4_AddRef(IDirectDraw4 *iface)
{
- IDirectDrawImpl *ddraw = ddraw_from_ddraw4(iface);
- ULONG ref = InterlockedIncrement(&ddraw->ref4);
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+ ULONG ref = InterlockedIncrement(&This->ref4);
- TRACE("%p increasing refcount to %u.\n", ddraw, ref);
+ TRACE("%p increasing refcount to %u.\n", This, ref);
- if (ref == 1) InterlockedIncrement(&ddraw->numIfaces);
+ if (ref == 1) InterlockedIncrement(&This->numIfaces);
return ref;
}
static ULONG WINAPI ddraw3_AddRef(IDirectDraw3 *iface)
{
- IDirectDrawImpl *ddraw = ddraw_from_ddraw3(iface);
- ULONG ref = InterlockedIncrement(&ddraw->ref3);
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+ ULONG ref = InterlockedIncrement(&This->ref3);
- TRACE("%p increasing refcount to %u.\n", ddraw, ref);
+ TRACE("%p increasing refcount to %u.\n", This, ref);
- if (ref == 1) InterlockedIncrement(&ddraw->numIfaces);
+ if (ref == 1) InterlockedIncrement(&This->numIfaces);
return ref;
}
static ULONG WINAPI ddraw2_AddRef(IDirectDraw2 *iface)
{
- IDirectDrawImpl *ddraw = ddraw_from_ddraw2(iface);
- ULONG ref = InterlockedIncrement(&ddraw->ref2);
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+ ULONG ref = InterlockedIncrement(&This->ref2);
- TRACE("%p increasing refcount to %u.\n", ddraw, ref);
+ TRACE("%p increasing refcount to %u.\n", This, ref);
- if (ref == 1) InterlockedIncrement(&ddraw->numIfaces);
+ if (ref == 1) InterlockedIncrement(&This->numIfaces);
return ref;
}
static ULONG WINAPI ddraw1_AddRef(IDirectDraw *iface)
{
- IDirectDrawImpl *ddraw = ddraw_from_ddraw1(iface);
- ULONG ref = InterlockedIncrement(&ddraw->ref1);
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+ ULONG ref = InterlockedIncrement(&This->ref1);
- TRACE("%p increasing refcount to %u.\n", ddraw, ref);
+ TRACE("%p increasing refcount to %u.\n", This, ref);
- if (ref == 1) InterlockedIncrement(&ddraw->numIfaces);
+ if (ref == 1) InterlockedIncrement(&This->numIfaces);
return ref;
}
static ULONG WINAPI d3d7_AddRef(IDirect3D7 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D7(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw7_AddRef((IDirectDraw7 *)ddraw_from_d3d7(iface));
+ return ddraw7_AddRef(&This->IDirectDraw7_iface);
}
static ULONG WINAPI d3d3_AddRef(IDirect3D3 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D3(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw1_AddRef((IDirectDraw *)&ddraw_from_d3d3(iface)->IDirectDraw_vtbl);
+ return ddraw1_AddRef(&This->IDirectDraw_iface);
}
static ULONG WINAPI d3d2_AddRef(IDirect3D2 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D2(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw1_AddRef((IDirectDraw *)&ddraw_from_d3d2(iface)->IDirectDraw_vtbl);
+ return ddraw1_AddRef(&This->IDirectDraw_iface);
}
static ULONG WINAPI d3d1_AddRef(IDirect3D *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw1_AddRef((IDirectDraw *)&ddraw_from_d3d1(iface)->IDirectDraw_vtbl);
+ return ddraw1_AddRef(&This->IDirectDraw_iface);
}
/*****************************************************************************
@@ -388,8 +432,8 @@ static ULONG WINAPI d3d1_AddRef(IDirect3D *iface)
*****************************************************************************/
static void ddraw_destroy(IDirectDrawImpl *This)
{
- IDirectDraw7_SetCooperativeLevel((IDirectDraw7 *)This, NULL, DDSCL_NORMAL);
- IDirectDraw7_RestoreDisplayMode((IDirectDraw7 *)This);
+ IDirectDraw7_SetCooperativeLevel(&This->IDirectDraw7_iface, NULL, DDSCL_NORMAL);
+ IDirectDraw7_RestoreDisplayMode(&This->IDirectDraw7_iface);
/* Destroy the device window if we created one */
if(This->devicewindow != 0)
@@ -404,8 +448,8 @@ static void ddraw_destroy(IDirectDrawImpl *This)
LeaveCriticalSection(&ddraw_cs);
/* Release the attached WineD3D stuff */
- IWineD3DDevice_Release(This->wineD3DDevice);
- IWineD3D_Release(This->wineD3D);
+ wined3d_device_decref(This->wined3d_device);
+ wined3d_decref(This->wineD3D);
/* Now free the object */
HeapFree(GetProcessHeap(), 0, This);
@@ -420,7 +464,7 @@ static void ddraw_destroy(IDirectDrawImpl *This)
*****************************************************************************/
static ULONG WINAPI ddraw7_Release(IDirectDraw7 *iface)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
ULONG ref = InterlockedDecrement(&This->ref7);
TRACE("%p decreasing refcount to %u.\n", This, ref);
@@ -433,82 +477,90 @@ static ULONG WINAPI ddraw7_Release(IDirectDraw7 *iface)
static ULONG WINAPI ddraw4_Release(IDirectDraw4 *iface)
{
- IDirectDrawImpl *ddraw = ddraw_from_ddraw4(iface);
- ULONG ref = InterlockedDecrement(&ddraw->ref4);
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+ ULONG ref = InterlockedDecrement(&This->ref4);
- TRACE("%p decreasing refcount to %u.\n", ddraw, ref);
+ TRACE("%p decreasing refcount to %u.\n", This, ref);
- if (!ref && !InterlockedDecrement(&ddraw->numIfaces))
- ddraw_destroy(ddraw);
+ if (!ref && !InterlockedDecrement(&This->numIfaces))
+ ddraw_destroy(This);
return ref;
}
static ULONG WINAPI ddraw3_Release(IDirectDraw3 *iface)
{
- IDirectDrawImpl *ddraw = ddraw_from_ddraw3(iface);
- ULONG ref = InterlockedDecrement(&ddraw->ref3);
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+ ULONG ref = InterlockedDecrement(&This->ref3);
- TRACE("%p decreasing refcount to %u.\n", ddraw, ref);
+ TRACE("%p decreasing refcount to %u.\n", This, ref);
- if (!ref && !InterlockedDecrement(&ddraw->numIfaces))
- ddraw_destroy(ddraw);
+ if (!ref && !InterlockedDecrement(&This->numIfaces))
+ ddraw_destroy(This);
return ref;
}
static ULONG WINAPI ddraw2_Release(IDirectDraw2 *iface)
{
- IDirectDrawImpl *ddraw = ddraw_from_ddraw2(iface);
- ULONG ref = InterlockedDecrement(&ddraw->ref2);
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+ ULONG ref = InterlockedDecrement(&This->ref2);
- TRACE("%p decreasing refcount to %u.\n", ddraw, ref);
+ TRACE("%p decreasing refcount to %u.\n", This, ref);
- if (!ref && !InterlockedDecrement(&ddraw->numIfaces))
- ddraw_destroy(ddraw);
+ if (!ref && !InterlockedDecrement(&This->numIfaces))
+ ddraw_destroy(This);
return ref;
}
static ULONG WINAPI ddraw1_Release(IDirectDraw *iface)
{
- IDirectDrawImpl *ddraw = ddraw_from_ddraw1(iface);
- ULONG ref = InterlockedDecrement(&ddraw->ref1);
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+ ULONG ref = InterlockedDecrement(&This->ref1);
- TRACE("%p decreasing refcount to %u.\n", ddraw, ref);
+ TRACE("%p decreasing refcount to %u.\n", This, ref);
- if (!ref && !InterlockedDecrement(&ddraw->numIfaces))
- ddraw_destroy(ddraw);
+ if (!ref && !InterlockedDecrement(&This->numIfaces))
+ ddraw_destroy(This);
return ref;
}
static ULONG WINAPI d3d7_Release(IDirect3D7 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D7(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw7_Release((IDirectDraw7 *)ddraw_from_d3d7(iface));
+ return ddraw7_Release(&This->IDirectDraw7_iface);
}
static ULONG WINAPI d3d3_Release(IDirect3D3 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D3(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw1_Release((IDirectDraw *)&ddraw_from_d3d3(iface)->IDirectDraw_vtbl);
+ return ddraw1_Release(&This->IDirectDraw_iface);
}
static ULONG WINAPI d3d2_Release(IDirect3D2 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D2(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw1_Release((IDirectDraw *)&ddraw_from_d3d2(iface)->IDirectDraw_vtbl);
+ return ddraw1_Release(&This->IDirectDraw_iface);
}
static ULONG WINAPI d3d1_Release(IDirect3D *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw1_Release((IDirectDraw *)&ddraw_from_d3d1(iface)->IDirectDraw_vtbl);
+ return ddraw1_Release(&This->IDirectDraw_iface);
}
/*****************************************************************************
@@ -561,7 +613,7 @@ static ULONG WINAPI d3d1_Release(IDirect3D *iface)
*****************************************************************************/
static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd, DWORD cooplevel)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
HWND window;
TRACE("iface %p, window %p, flags %#x.\n", iface, hwnd, cooplevel);
@@ -586,21 +638,23 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
if(cooplevel & DDSCL_SETFOCUSWINDOW)
{
/* This isn't compatible with a lot of flags */
- if(cooplevel & ( DDSCL_MULTITHREADED |
- DDSCL_FPUSETUP |
- DDSCL_FPUPRESERVE |
- DDSCL_ALLOWREBOOT |
- DDSCL_ALLOWMODEX |
- DDSCL_SETDEVICEWINDOW |
- DDSCL_NORMAL |
- DDSCL_EXCLUSIVE |
- DDSCL_FULLSCREEN ) )
+ if(cooplevel & ( DDSCL_MULTITHREADED |
+ DDSCL_CREATEDEVICEWINDOW |
+ DDSCL_FPUSETUP |
+ DDSCL_FPUPRESERVE |
+ DDSCL_ALLOWREBOOT |
+ DDSCL_ALLOWMODEX |
+ DDSCL_SETDEVICEWINDOW |
+ DDSCL_NORMAL |
+ DDSCL_EXCLUSIVE |
+ DDSCL_FULLSCREEN ) )
{
TRACE("Called with incompatible flags, returning DDERR_INVALIDPARAMS\n");
LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDPARAMS;
}
- else if( (This->cooperative_level & DDSCL_FULLSCREEN) && window)
+
+ if( (This->cooperative_level & DDSCL_EXCLUSIVE) && window )
{
TRACE("Setting DDSCL_SETFOCUSWINDOW with an already set window, returning DDERR_HWNDALREADYSET\n");
LeaveCriticalSection(&ddraw_cs);
@@ -620,79 +674,62 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
DestroyWindow(This->devicewindow);
This->devicewindow = NULL;
}
+
+ LeaveCriticalSection(&ddraw_cs);
+ return DD_OK;
}
- /* DDSCL_NORMAL or DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE */
- if(cooplevel & DDSCL_NORMAL)
+
+ if(cooplevel & DDSCL_EXCLUSIVE)
{
- /* Can't coexist with fullscreen or exclusive */
- if(cooplevel & (DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE) )
+ if( !(cooplevel & DDSCL_FULLSCREEN) || !hwnd )
{
- TRACE("(%p) DDSCL_NORMAL is not compative with DDSCL_FULLSCREEN or DDSCL_EXCLUSIVE\n", This);
+ TRACE("(%p) DDSCL_EXCLUSIVE needs DDSCL_FULLSCREEN and a window\n", This);
LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDPARAMS;
}
-
- /* Switching from fullscreen? */
- if(This->cooperative_level & DDSCL_FULLSCREEN)
- {
- This->cooperative_level &= ~DDSCL_FULLSCREEN;
- This->cooperative_level &= ~DDSCL_EXCLUSIVE;
- This->cooperative_level &= ~DDSCL_ALLOWMODEX;
-
- IWineD3DDevice_ReleaseFocusWindow(This->wineD3DDevice);
- }
-
- /* Don't override focus windows or private device windows */
- if( hwnd &&
- !(This->focuswindow) &&
- !(This->devicewindow) &&
- (hwnd != window) )
- {
- This->dest_window = hwnd;
- }
}
- else if(cooplevel & DDSCL_FULLSCREEN)
+ else if( !(cooplevel & DDSCL_NORMAL) )
{
- /* Needs DDSCL_EXCLUSIVE */
- if(!(cooplevel & DDSCL_EXCLUSIVE) )
- {
- TRACE("(%p) DDSCL_FULLSCREEN needs DDSCL_EXCLUSIVE\n", This);
- LeaveCriticalSection(&ddraw_cs);
- return DDERR_INVALIDPARAMS;
- }
- /* Need a HWND
- if(hwnd == 0)
- {
- TRACE("(%p) DDSCL_FULLSCREEN needs a HWND\n", This);
- return DDERR_INVALIDPARAMS;
- }
- */
-
- This->cooperative_level &= ~DDSCL_NORMAL;
-
- /* Don't override focus windows or private device windows */
- if( hwnd &&
- !(This->focuswindow) &&
- !(This->devicewindow) &&
- (hwnd != window) )
- {
- HRESULT hr = IWineD3DDevice_AcquireFocusWindow(This->wineD3DDevice, hwnd);
- if (FAILED(hr))
- {
- ERR("Failed to acquire focus window, hr %#x.\n", hr);
- LeaveCriticalSection(&ddraw_cs);
- return hr;
- }
- This->dest_window = hwnd;
- }
- }
- else if(cooplevel & DDSCL_EXCLUSIVE)
- {
- TRACE("(%p) DDSCL_EXCLUSIVE needs DDSCL_FULLSCREEN\n", This);
+ TRACE("(%p) SetCooperativeLevel needs at least SetFocusWindow or Exclusive or Normal mode\n", This);
LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDPARAMS;
}
+ if ((This->cooperative_level & DDSCL_EXCLUSIVE)
+ && (hwnd != window || !(cooplevel & DDSCL_EXCLUSIVE)))
+ wined3d_device_release_focus_window(This->wined3d_device);
+
+ if ((cooplevel & DDSCL_FULLSCREEN) != (This->cooperative_level & DDSCL_FULLSCREEN) || hwnd != window)
+ {
+ if (This->cooperative_level & DDSCL_FULLSCREEN)
+ wined3d_device_restore_fullscreen_window(This->wined3d_device, window);
+
+ if (cooplevel & DDSCL_FULLSCREEN)
+ {
+ WINED3DDISPLAYMODE display_mode;
+
+ wined3d_get_adapter_display_mode(This->wineD3D, WINED3DADAPTER_DEFAULT, &display_mode);
+ wined3d_device_setup_fullscreen_window(This->wined3d_device, hwnd,
+ display_mode.Width, display_mode.Height);
+ }
+ }
+
+ if ((cooplevel & DDSCL_EXCLUSIVE)
+ && (hwnd != window || !(This->cooperative_level & DDSCL_EXCLUSIVE)))
+ {
+ HRESULT hr = wined3d_device_acquire_focus_window(This->wined3d_device, hwnd);
+ if (FAILED(hr))
+ {
+ ERR("Failed to acquire focus window, hr %#x.\n", hr);
+ LeaveCriticalSection(&ddraw_cs);
+ return hr;
+ }
+ }
+
+ /* Don't override focus windows or private device windows */
+ if (hwnd && !This->focuswindow && !This->devicewindow && (hwnd != window))
+ This->dest_window = hwnd;
+
if(cooplevel & DDSCL_CREATEDEVICEWINDOW)
{
/* Don't create a device window if a focus window is set */
@@ -716,11 +753,8 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
}
}
- if(cooplevel & DDSCL_MULTITHREADED && !(This->cooperative_level & DDSCL_MULTITHREADED))
- {
- /* Enable thread safety in wined3d */
- IWineD3DDevice_SetMultithreaded(This->wineD3DDevice);
- }
+ if (cooplevel & DDSCL_MULTITHREADED && !(This->cooperative_level & DDSCL_MULTITHREADED))
+ wined3d_device_set_multithreaded(This->wined3d_device);
/* Unhandled flags */
if(cooplevel & DDSCL_ALLOWREBOOT)
@@ -731,7 +765,7 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
WARN("(%p) Unhandled flag DDSCL_FPUSETUP, harmless\n", This);
/* Store the cooperative_level */
- This->cooperative_level |= cooplevel;
+ This->cooperative_level = cooplevel;
TRACE("SetCooperativeLevel retuning DD_OK\n");
LeaveCriticalSection(&ddraw_cs);
return DD_OK;
@@ -739,30 +773,38 @@ static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd,
static HRESULT WINAPI ddraw4_SetCooperativeLevel(IDirectDraw4 *iface, HWND window, DWORD flags)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, window %p, flags %#x.\n", iface, window, flags);
- return ddraw7_SetCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw4(iface), window, flags);
+ return ddraw7_SetCooperativeLevel(&This->IDirectDraw7_iface, window, flags);
}
static HRESULT WINAPI ddraw3_SetCooperativeLevel(IDirectDraw3 *iface, HWND window, DWORD flags)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+
TRACE("iface %p, window %p, flags %#x.\n", iface, window, flags);
- return ddraw7_SetCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw3(iface), window, flags);
+ return ddraw7_SetCooperativeLevel(&This->IDirectDraw7_iface, window, flags);
}
static HRESULT WINAPI ddraw2_SetCooperativeLevel(IDirectDraw2 *iface, HWND window, DWORD flags)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+
TRACE("iface %p, window %p, flags %#x.\n", iface, window, flags);
- return ddraw7_SetCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw2(iface), window, flags);
+ return ddraw7_SetCooperativeLevel(&This->IDirectDraw7_iface, window, flags);
}
static HRESULT WINAPI ddraw1_SetCooperativeLevel(IDirectDraw *iface, HWND window, DWORD flags)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+
TRACE("iface %p, window %p, flags %#x.\n", iface, window, flags);
- return ddraw7_SetCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw1(iface), window, flags);
+ return ddraw7_SetCooperativeLevel(&This->IDirectDraw7_iface, window, flags);
}
/*****************************************************************************
@@ -777,15 +819,15 @@ static HRESULT WINAPI ddraw1_SetCooperativeLevel(IDirectDraw *iface, HWND window
* ddraw7_SetDisplayMode.
*
*****************************************************************************/
-static HRESULT ddraw_set_display_mode(IDirectDraw7 *iface, DWORD Width, DWORD Height,
+static HRESULT ddraw_set_display_mode(IDirectDrawImpl *ddraw, DWORD Width, DWORD Height,
DWORD BPP, DWORD RefreshRate, DWORD Flags)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
+ enum wined3d_format_id format;
WINED3DDISPLAYMODE Mode;
HRESULT hr;
- TRACE("iface %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n",
- iface, Width, Height, BPP, RefreshRate, Flags);
+ TRACE("ddraw %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n", ddraw, Width,
+ Height, BPP, RefreshRate, Flags);
EnterCriticalSection(&ddraw_cs);
if( !Width || !Height )
@@ -796,8 +838,32 @@ static HRESULT ddraw_set_display_mode(IDirectDraw7 *iface, DWORD Width, DWORD He
return DD_OK;
}
+ switch(BPP)
+ {
+ case 8: format = WINED3DFMT_P8_UINT; break;
+ case 15: format = WINED3DFMT_B5G5R5X1_UNORM; break;
+ case 16: format = WINED3DFMT_B5G6R5_UNORM; break;
+ case 24: format = WINED3DFMT_B8G8R8_UNORM; break;
+ case 32: format = WINED3DFMT_B8G8R8X8_UNORM; break;
+ default: format = WINED3DFMT_UNKNOWN; break;
+ }
+
+ if (FAILED(hr = wined3d_device_get_display_mode(ddraw->wined3d_device, 0, &Mode)))
+ {
+ ERR("Failed to get current display mode, hr %#x.\n", hr);
+ }
+ else if (Mode.Width == Width
+ && Mode.Height == Height
+ && Mode.Format == format
+ && Mode.RefreshRate == RefreshRate)
+ {
+ TRACE("Skipping redundant mode setting call.\n");
+ LeaveCriticalSection(&ddraw_cs);
+ return DD_OK;
+ }
+
/* Check the exclusive mode
- if(!(This->cooperative_level & DDSCL_EXCLUSIVE))
+ if(!(ddraw->cooperative_level & DDSCL_EXCLUSIVE))
return DDERR_NOEXCLUSIVEMODE;
* This is WRONG. Don't know if the SDK is completely
* wrong and if there are any conditions when DDERR_NOEXCLUSIVE
@@ -808,14 +874,7 @@ static HRESULT ddraw_set_display_mode(IDirectDraw7 *iface, DWORD Width, DWORD He
Mode.Width = Width;
Mode.Height = Height;
Mode.RefreshRate = RefreshRate;
- switch(BPP)
- {
- case 8: Mode.Format = WINED3DFMT_P8_UINT; break;
- case 15: Mode.Format = WINED3DFMT_B5G5R5X1_UNORM; break;
- case 16: Mode.Format = WINED3DFMT_B5G6R5_UNORM; break;
- case 24: Mode.Format = WINED3DFMT_B8G8R8_UNORM; break;
- case 32: Mode.Format = WINED3DFMT_B8G8R8X8_UNORM; break;
- }
+ Mode.Format = format;
/* TODO: The possible return values from msdn suggest that
* the screen mode can't be changed if a surface is locked
@@ -823,9 +882,14 @@ static HRESULT ddraw_set_display_mode(IDirectDraw7 *iface, DWORD Width, DWORD He
*/
/* TODO: Lose the primary surface */
- hr = IWineD3DDevice_SetDisplayMode(This->wineD3DDevice,
- 0, /* First swapchain */
- &Mode);
+ hr = wined3d_device_set_display_mode(ddraw->wined3d_device, 0, &Mode);
+
+ if (ddraw->cooperative_level & DDSCL_EXCLUSIVE)
+ {
+ wined3d_device_restore_fullscreen_window(ddraw->wined3d_device, ddraw->dest_window);
+ wined3d_device_setup_fullscreen_window(ddraw->wined3d_device, ddraw->dest_window, Width, Height);
+ }
+
LeaveCriticalSection(&ddraw_cs);
switch(hr)
{
@@ -859,6 +923,8 @@ static HRESULT ddraw_set_display_mode(IDirectDraw7 *iface, DWORD Width, DWORD He
static HRESULT WINAPI ddraw7_SetDisplayMode(IDirectDraw7 *iface, DWORD Width, DWORD Height,
DWORD BPP, DWORD RefreshRate, DWORD Flags)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
+
TRACE("iface %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n",
iface, Width, Height, BPP, RefreshRate, Flags);
@@ -869,44 +935,49 @@ static HRESULT WINAPI ddraw7_SetDisplayMode(IDirectDraw7 *iface, DWORD Width, DW
RefreshRate = force_refresh_rate;
}
- return ddraw_set_display_mode(iface, Width, Height, BPP, RefreshRate, Flags);
+ return ddraw_set_display_mode(This, Width, Height, BPP, RefreshRate, Flags);
}
-static HRESULT WINAPI ddraw4_SetDisplayMode(IDirectDraw4 *iface,
- DWORD width, DWORD height, DWORD bpp, DWORD refresh_rate, DWORD flags)
+static HRESULT WINAPI ddraw4_SetDisplayMode(IDirectDraw4 *iface, DWORD width, DWORD height,
+ DWORD bpp, DWORD refresh_rate, DWORD flags)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n",
iface, width, height, bpp, refresh_rate, flags);
- return ddraw7_SetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw4(iface),
- width, height, bpp, refresh_rate, flags);
+ return ddraw7_SetDisplayMode(&This->IDirectDraw7_iface, width, height, bpp, refresh_rate, flags);
}
-static HRESULT WINAPI ddraw3_SetDisplayMode(IDirectDraw3 *iface,
- DWORD width, DWORD height, DWORD bpp, DWORD refresh_rate, DWORD flags)
+static HRESULT WINAPI ddraw3_SetDisplayMode(IDirectDraw3 *iface, DWORD width, DWORD height,
+ DWORD bpp, DWORD refresh_rate, DWORD flags)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+
TRACE("iface %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n",
iface, width, height, bpp, refresh_rate, flags);
- return ddraw7_SetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw3(iface),
- width, height, bpp, refresh_rate, flags);
+ return ddraw7_SetDisplayMode(&This->IDirectDraw7_iface, width, height, bpp, refresh_rate, flags);
}
static HRESULT WINAPI ddraw2_SetDisplayMode(IDirectDraw2 *iface,
DWORD width, DWORD height, DWORD bpp, DWORD refresh_rate, DWORD flags)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+
TRACE("iface %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n",
iface, width, height, bpp, refresh_rate, flags);
- return ddraw7_SetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw2(iface),
- width, height, bpp, refresh_rate, flags);
+ return ddraw7_SetDisplayMode(&This->IDirectDraw7_iface, width, height, bpp, refresh_rate, flags);
}
static HRESULT WINAPI ddraw1_SetDisplayMode(IDirectDraw *iface, DWORD width, DWORD height, DWORD bpp)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+
TRACE("iface %p, width %u, height %u, bpp %u.\n", iface, width, height, bpp);
- return ddraw7_SetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw1(iface), width, height, bpp, 0, 0);
+ return ddraw7_SetDisplayMode(&This->IDirectDraw7_iface, width, height, bpp, 0, 0);
}
/*****************************************************************************
@@ -932,39 +1003,47 @@ static HRESULT WINAPI ddraw1_SetDisplayMode(IDirectDraw *iface, DWORD width, DWO
*****************************************************************************/
static HRESULT WINAPI ddraw7_RestoreDisplayMode(IDirectDraw7 *iface)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
TRACE("iface %p.\n", iface);
- return ddraw_set_display_mode(iface, This->orig_width, This->orig_height, This->orig_bpp, 0, 0);
+ return ddraw_set_display_mode(This, This->orig_width, This->orig_height, This->orig_bpp, 0, 0);
}
static HRESULT WINAPI ddraw4_RestoreDisplayMode(IDirectDraw4 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw7_RestoreDisplayMode((IDirectDraw7 *)ddraw_from_ddraw4(iface));
+ return ddraw7_RestoreDisplayMode(&This->IDirectDraw7_iface);
}
static HRESULT WINAPI ddraw3_RestoreDisplayMode(IDirectDraw3 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw7_RestoreDisplayMode((IDirectDraw7 *)ddraw_from_ddraw3(iface));
+ return ddraw7_RestoreDisplayMode(&This->IDirectDraw7_iface);
}
static HRESULT WINAPI ddraw2_RestoreDisplayMode(IDirectDraw2 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw7_RestoreDisplayMode((IDirectDraw7 *)ddraw_from_ddraw2(iface));
+ return ddraw7_RestoreDisplayMode(&This->IDirectDraw7_iface);
}
static HRESULT WINAPI ddraw1_RestoreDisplayMode(IDirectDraw *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw7_RestoreDisplayMode((IDirectDraw7 *)ddraw_from_ddraw1(iface));
+ return ddraw7_RestoreDisplayMode(&This->IDirectDraw7_iface);
}
/*****************************************************************************
@@ -984,12 +1063,11 @@ static HRESULT WINAPI ddraw1_RestoreDisplayMode(IDirectDraw *iface)
*****************************************************************************/
static HRESULT WINAPI ddraw7_GetCaps(IDirectDraw7 *iface, DDCAPS *DriverCaps, DDCAPS *HELCaps)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
DDCAPS caps;
WINED3DCAPS winecaps;
HRESULT hr;
DDSCAPS2 ddscaps = {0, 0, 0, {0}};
- TRACE("(%p)->(%p,%p)\n", This, DriverCaps, HELCaps);
TRACE("iface %p, driver_caps %p, hel_caps %p.\n", iface, DriverCaps, HELCaps);
@@ -1004,8 +1082,9 @@ static HRESULT WINAPI ddraw7_GetCaps(IDirectDraw7 *iface, DDCAPS *DriverCaps, DD
memset(&winecaps, 0, sizeof(winecaps));
caps.dwSize = sizeof(caps);
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_GetDeviceCaps(This->wineD3DDevice, &winecaps);
- if(FAILED(hr)) {
+ hr = wined3d_device_get_device_caps(This->wined3d_device, &winecaps);
+ if (FAILED(hr))
+ {
WARN("IWineD3DDevice::GetDeviceCaps failed\n");
LeaveCriticalSection(&ddraw_cs);
return hr;
@@ -1071,30 +1150,38 @@ static HRESULT WINAPI ddraw7_GetCaps(IDirectDraw7 *iface, DDCAPS *DriverCaps, DD
static HRESULT WINAPI ddraw4_GetCaps(IDirectDraw4 *iface, DDCAPS *driver_caps, DDCAPS *hel_caps)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, driver_caps %p, hel_caps %p.\n", iface, driver_caps, hel_caps);
- return ddraw7_GetCaps((IDirectDraw7 *)ddraw_from_ddraw4(iface), driver_caps, hel_caps);
+ return ddraw7_GetCaps(&This->IDirectDraw7_iface, driver_caps, hel_caps);
}
static HRESULT WINAPI ddraw3_GetCaps(IDirectDraw3 *iface, DDCAPS *driver_caps, DDCAPS *hel_caps)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+
TRACE("iface %p, driver_caps %p, hel_caps %p.\n", iface, driver_caps, hel_caps);
- return ddraw7_GetCaps((IDirectDraw7 *)ddraw_from_ddraw3(iface), driver_caps, hel_caps);
+ return ddraw7_GetCaps(&This->IDirectDraw7_iface, driver_caps, hel_caps);
}
static HRESULT WINAPI ddraw2_GetCaps(IDirectDraw2 *iface, DDCAPS *driver_caps, DDCAPS *hel_caps)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+
TRACE("iface %p, driver_caps %p, hel_caps %p.\n", iface, driver_caps, hel_caps);
- return ddraw7_GetCaps((IDirectDraw7 *)ddraw_from_ddraw2(iface), driver_caps, hel_caps);
+ return ddraw7_GetCaps(&This->IDirectDraw7_iface, driver_caps, hel_caps);
}
static HRESULT WINAPI ddraw1_GetCaps(IDirectDraw *iface, DDCAPS *driver_caps, DDCAPS *hel_caps)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+
TRACE("iface %p, driver_caps %p, hel_caps %p.\n", iface, driver_caps, hel_caps);
- return ddraw7_GetCaps((IDirectDraw7 *)ddraw_from_ddraw1(iface), driver_caps, hel_caps);
+ return ddraw7_GetCaps(&This->IDirectDraw7_iface, driver_caps, hel_caps);
}
/*****************************************************************************
@@ -1115,30 +1202,38 @@ static HRESULT WINAPI ddraw7_Compact(IDirectDraw7 *iface)
static HRESULT WINAPI ddraw4_Compact(IDirectDraw4 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw7_Compact((IDirectDraw7 *)ddraw_from_ddraw4(iface));
+ return ddraw7_Compact(&This->IDirectDraw7_iface);
}
static HRESULT WINAPI ddraw3_Compact(IDirectDraw3 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw7_Compact((IDirectDraw7 *)ddraw_from_ddraw3(iface));
+ return ddraw7_Compact(&This->IDirectDraw7_iface);
}
static HRESULT WINAPI ddraw2_Compact(IDirectDraw2 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw7_Compact((IDirectDraw7 *)ddraw_from_ddraw2(iface));
+ return ddraw7_Compact(&This->IDirectDraw7_iface);
}
static HRESULT WINAPI ddraw1_Compact(IDirectDraw *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw7_Compact((IDirectDraw7 *)ddraw_from_ddraw1(iface));
+ return ddraw7_Compact(&This->IDirectDraw7_iface);
}
/*****************************************************************************
@@ -1157,7 +1252,7 @@ static HRESULT WINAPI ddraw1_Compact(IDirectDraw *iface)
*****************************************************************************/
static HRESULT WINAPI ddraw7_GetDisplayMode(IDirectDraw7 *iface, DDSURFACEDESC2 *DDSD)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
HRESULT hr;
WINED3DDISPLAYMODE Mode;
DWORD Size;
@@ -1173,12 +1268,9 @@ static HRESULT WINAPI ddraw7_GetDisplayMode(IDirectDraw7 *iface, DDSURFACEDESC2
}
/* The necessary members of LPDDSURFACEDESC and LPDDSURFACEDESC2 are equal,
- * so one method can be used for all versions (Hopefully)
- */
- hr = IWineD3DDevice_GetDisplayMode(This->wineD3DDevice,
- 0 /* swapchain 0 */,
- &Mode);
- if( hr != D3D_OK )
+ * so one method can be used for all versions (Hopefully) */
+ hr = wined3d_device_get_display_mode(This->wined3d_device, 0, &Mode);
+ if (FAILED(hr))
{
ERR(" (%p) IWineD3DDevice::GetDisplayMode returned %08x\n", This, hr);
LeaveCriticalSection(&ddraw_cs);
@@ -1210,30 +1302,38 @@ static HRESULT WINAPI ddraw7_GetDisplayMode(IDirectDraw7 *iface, DDSURFACEDESC2
static HRESULT WINAPI ddraw4_GetDisplayMode(IDirectDraw4 *iface, DDSURFACEDESC2 *surface_desc)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, surface_desc %p.\n", iface, surface_desc);
- return ddraw7_GetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw4(iface), surface_desc);
+ return ddraw7_GetDisplayMode(&This->IDirectDraw7_iface, surface_desc);
}
static HRESULT WINAPI ddraw3_GetDisplayMode(IDirectDraw3 *iface, DDSURFACEDESC *surface_desc)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+
TRACE("iface %p, surface_desc %p.\n", iface, surface_desc);
- return ddraw7_GetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw3(iface), (DDSURFACEDESC2 *)surface_desc);
+ return ddraw7_GetDisplayMode(&This->IDirectDraw7_iface, (DDSURFACEDESC2 *)surface_desc);
}
static HRESULT WINAPI ddraw2_GetDisplayMode(IDirectDraw2 *iface, DDSURFACEDESC *surface_desc)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+
TRACE("iface %p, surface_desc %p.\n", iface, surface_desc);
- return ddraw7_GetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw2(iface), (DDSURFACEDESC2 *)surface_desc);
+ return ddraw7_GetDisplayMode(&This->IDirectDraw7_iface, (DDSURFACEDESC2 *)surface_desc);
}
static HRESULT WINAPI ddraw1_GetDisplayMode(IDirectDraw *iface, DDSURFACEDESC *surface_desc)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+
TRACE("iface %p, surface_desc %p.\n", iface, surface_desc);
- return ddraw7_GetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw1(iface), (DDSURFACEDESC2 *)surface_desc);
+ return ddraw7_GetDisplayMode(&This->IDirectDraw7_iface, (DDSURFACEDESC2 *)surface_desc);
}
/*****************************************************************************
@@ -1255,7 +1355,7 @@ static HRESULT WINAPI ddraw1_GetDisplayMode(IDirectDraw *iface, DDSURFACEDESC *s
*****************************************************************************/
static HRESULT WINAPI ddraw7_GetFourCCCodes(IDirectDraw7 *iface, DWORD *NumCodes, DWORD *Codes)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
static const enum wined3d_format_id formats[] =
{
WINED3DFMT_YUY2, WINED3DFMT_UYVY, WINED3DFMT_YV12,
@@ -1269,28 +1369,21 @@ static HRESULT WINAPI ddraw7_GetFourCCCodes(IDirectDraw7 *iface, DWORD *NumCodes
TRACE("iface %p, codes_count %p, codes %p.\n", iface, NumCodes, Codes);
- IWineD3DDevice_GetDisplayMode(This->wineD3DDevice,
- 0 /* swapchain 0 */,
- &d3ddm);
+ wined3d_device_get_display_mode(This->wined3d_device, 0, &d3ddm);
outsize = NumCodes && Codes ? *NumCodes : 0;
if(type == SURFACE_UNKNOWN) type = SURFACE_GDI;
- for(i = 0; i < (sizeof(formats) / sizeof(formats[0])); i++) {
- hr = IWineD3D_CheckDeviceFormat(This->wineD3D,
- WINED3DADAPTER_DEFAULT,
- WINED3DDEVTYPE_HAL,
- d3ddm.Format /* AdapterFormat */,
- 0 /* usage */,
- WINED3DRTYPE_SURFACE,
- formats[i],
- type);
- if(SUCCEEDED(hr)) {
- if(count < outsize) {
+ for (i = 0; i < (sizeof(formats) / sizeof(formats[0])); ++i)
+ {
+ hr = wined3d_check_device_format(This->wineD3D, WINED3DADAPTER_DEFAULT, WINED3DDEVTYPE_HAL,
+ d3ddm.Format, 0, WINED3DRTYPE_SURFACE, formats[i], type);
+ if (SUCCEEDED(hr))
+ {
+ if (count < outsize)
Codes[count] = formats[i];
- }
- count++;
+ ++count;
}
}
if(NumCodes) {
@@ -1303,30 +1396,38 @@ static HRESULT WINAPI ddraw7_GetFourCCCodes(IDirectDraw7 *iface, DWORD *NumCodes
static HRESULT WINAPI ddraw4_GetFourCCCodes(IDirectDraw4 *iface, DWORD *codes_count, DWORD *codes)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
- return ddraw7_GetFourCCCodes((IDirectDraw7 *)ddraw_from_ddraw4(iface), codes_count, codes);
+ return ddraw7_GetFourCCCodes(&This->IDirectDraw7_iface, codes_count, codes);
}
static HRESULT WINAPI ddraw3_GetFourCCCodes(IDirectDraw3 *iface, DWORD *codes_count, DWORD *codes)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+
TRACE("iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
- return ddraw7_GetFourCCCodes((IDirectDraw7 *)ddraw_from_ddraw3(iface), codes_count, codes);
+ return ddraw7_GetFourCCCodes(&This->IDirectDraw7_iface, codes_count, codes);
}
static HRESULT WINAPI ddraw2_GetFourCCCodes(IDirectDraw2 *iface, DWORD *codes_count, DWORD *codes)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+
TRACE("iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
- return ddraw7_GetFourCCCodes((IDirectDraw7 *)ddraw_from_ddraw2(iface), codes_count, codes);
+ return ddraw7_GetFourCCCodes(&This->IDirectDraw7_iface, codes_count, codes);
}
static HRESULT WINAPI ddraw1_GetFourCCCodes(IDirectDraw *iface, DWORD *codes_count, DWORD *codes)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+
TRACE("iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
- return ddraw7_GetFourCCCodes((IDirectDraw7 *)ddraw_from_ddraw1(iface), codes_count, codes);
+ return ddraw7_GetFourCCCodes(&This->IDirectDraw7_iface, codes_count, codes);
}
/*****************************************************************************
@@ -1356,30 +1457,38 @@ static HRESULT WINAPI ddraw7_GetMonitorFrequency(IDirectDraw7 *iface, DWORD *Fre
static HRESULT WINAPI ddraw4_GetMonitorFrequency(IDirectDraw4 *iface, DWORD *frequency)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, frequency %p.\n", iface, frequency);
- return ddraw7_GetMonitorFrequency((IDirectDraw7 *)ddraw_from_ddraw4(iface), frequency);
+ return ddraw7_GetMonitorFrequency(&This->IDirectDraw7_iface, frequency);
}
static HRESULT WINAPI ddraw3_GetMonitorFrequency(IDirectDraw3 *iface, DWORD *frequency)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+
TRACE("iface %p, frequency %p.\n", iface, frequency);
- return ddraw7_GetMonitorFrequency((IDirectDraw7 *)ddraw_from_ddraw3(iface), frequency);
+ return ddraw7_GetMonitorFrequency(&This->IDirectDraw7_iface, frequency);
}
static HRESULT WINAPI ddraw2_GetMonitorFrequency(IDirectDraw2 *iface, DWORD *frequency)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+
TRACE("iface %p, frequency %p.\n", iface, frequency);
- return ddraw7_GetMonitorFrequency((IDirectDraw7 *)ddraw_from_ddraw2(iface), frequency);
+ return ddraw7_GetMonitorFrequency(&This->IDirectDraw7_iface, frequency);
}
static HRESULT WINAPI ddraw1_GetMonitorFrequency(IDirectDraw *iface, DWORD *frequency)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+
TRACE("iface %p, frequency %p.\n", iface, frequency);
- return ddraw7_GetMonitorFrequency((IDirectDraw7 *)ddraw_from_ddraw1(iface), frequency);
+ return ddraw7_GetMonitorFrequency(&This->IDirectDraw7_iface, frequency);
}
/*****************************************************************************
@@ -1398,7 +1507,7 @@ static HRESULT WINAPI ddraw1_GetMonitorFrequency(IDirectDraw *iface, DWORD *freq
*****************************************************************************/
static HRESULT WINAPI ddraw7_GetVerticalBlankStatus(IDirectDraw7 *iface, BOOL *status)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
TRACE("iface %p, status %p.\n", iface, status);
@@ -1418,30 +1527,38 @@ static HRESULT WINAPI ddraw7_GetVerticalBlankStatus(IDirectDraw7 *iface, BOOL *s
static HRESULT WINAPI ddraw4_GetVerticalBlankStatus(IDirectDraw4 *iface, BOOL *status)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, status %p.\n", iface, status);
- return ddraw7_GetVerticalBlankStatus((IDirectDraw7 *)ddraw_from_ddraw4(iface), status);
+ return ddraw7_GetVerticalBlankStatus(&This->IDirectDraw7_iface, status);
}
static HRESULT WINAPI ddraw3_GetVerticalBlankStatus(IDirectDraw3 *iface, BOOL *status)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+
TRACE("iface %p, status %p.\n", iface, status);
- return ddraw7_GetVerticalBlankStatus((IDirectDraw7 *)ddraw_from_ddraw3(iface), status);
+ return ddraw7_GetVerticalBlankStatus(&This->IDirectDraw7_iface, status);
}
static HRESULT WINAPI ddraw2_GetVerticalBlankStatus(IDirectDraw2 *iface, BOOL *status)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+
TRACE("iface %p, status %p.\n", iface, status);
- return ddraw7_GetVerticalBlankStatus((IDirectDraw7 *)ddraw_from_ddraw2(iface), status);
+ return ddraw7_GetVerticalBlankStatus(&This->IDirectDraw7_iface, status);
}
static HRESULT WINAPI ddraw1_GetVerticalBlankStatus(IDirectDraw *iface, BOOL *status)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+
TRACE("iface %p, status %p.\n", iface, status);
- return ddraw7_GetVerticalBlankStatus((IDirectDraw7 *)ddraw_from_ddraw1(iface), status);
+ return ddraw7_GetVerticalBlankStatus(&This->IDirectDraw7_iface, status);
}
/*****************************************************************************
@@ -1459,9 +1576,10 @@ static HRESULT WINAPI ddraw1_GetVerticalBlankStatus(IDirectDraw *iface, BOOL *st
* DDERR_INVALIDPARAMS of free and total are NULL
*
*****************************************************************************/
-static HRESULT WINAPI ddraw7_GetAvailableVidMem(IDirectDraw7 *iface, DDSCAPS2 *Caps, DWORD *total, DWORD *free)
+static HRESULT WINAPI ddraw7_GetAvailableVidMem(IDirectDraw7 *iface, DDSCAPS2 *Caps, DWORD *total,
+ DWORD *free)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
TRACE("iface %p, caps %p, total %p, free %p.\n", iface, Caps, total, free);
@@ -1483,8 +1601,10 @@ static HRESULT WINAPI ddraw7_GetAvailableVidMem(IDirectDraw7 *iface, DDSCAPS2 *C
return DDERR_INVALIDPARAMS;
}
- if(total) *total = This->total_vidmem;
- if(free) *free = IWineD3DDevice_GetAvailableTextureMem(This->wineD3DDevice);
+ if (total)
+ *total = This->total_vidmem;
+ if (free)
+ *free = wined3d_device_get_available_texture_mem(This->wined3d_device);
LeaveCriticalSection(&ddraw_cs);
return DD_OK;
@@ -1493,31 +1613,35 @@ static HRESULT WINAPI ddraw7_GetAvailableVidMem(IDirectDraw7 *iface, DDSCAPS2 *C
static HRESULT WINAPI ddraw4_GetAvailableVidMem(IDirectDraw4 *iface,
DDSCAPS2 *caps, DWORD *total, DWORD *free)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, caps %p, total %p, free %p.\n", iface, caps, total, free);
- return ddraw7_GetAvailableVidMem((IDirectDraw7 *)ddraw_from_ddraw4(iface), caps, total, free);
+ return ddraw7_GetAvailableVidMem(&This->IDirectDraw7_iface, caps, total, free);
}
-static HRESULT WINAPI ddraw3_GetAvailableVidMem(IDirectDraw3 *iface,
- DDSCAPS *caps, DWORD *total, DWORD *free)
+static HRESULT WINAPI ddraw3_GetAvailableVidMem(IDirectDraw3 *iface, DDSCAPS *caps, DWORD *total,
+ DWORD *free)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
DDSCAPS2 caps2;
TRACE("iface %p, caps %p, total %p, free %p.\n", iface, caps, total, free);
DDRAW_Convert_DDSCAPS_1_To_2(caps, &caps2);
- return ddraw7_GetAvailableVidMem((IDirectDraw7 *)ddraw_from_ddraw3(iface), &caps2, total, free);
+ return ddraw7_GetAvailableVidMem(&This->IDirectDraw7_iface, &caps2, total, free);
}
static HRESULT WINAPI ddraw2_GetAvailableVidMem(IDirectDraw2 *iface,
DDSCAPS *caps, DWORD *total, DWORD *free)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
DDSCAPS2 caps2;
TRACE("iface %p, caps %p, total %p, free %p.\n", iface, caps, total, free);
DDRAW_Convert_DDSCAPS_1_To_2(caps, &caps2);
- return ddraw7_GetAvailableVidMem((IDirectDraw7 *)ddraw_from_ddraw2(iface), &caps2, total, free);
+ return ddraw7_GetAvailableVidMem(&This->IDirectDraw7_iface, &caps2, total, free);
}
/*****************************************************************************
@@ -1536,7 +1660,7 @@ static HRESULT WINAPI ddraw2_GetAvailableVidMem(IDirectDraw2 *iface,
*****************************************************************************/
static HRESULT WINAPI ddraw7_Initialize(IDirectDraw7 *iface, GUID *Guid)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(Guid));
@@ -1552,30 +1676,38 @@ static HRESULT WINAPI ddraw7_Initialize(IDirectDraw7 *iface, GUID *Guid)
static HRESULT WINAPI ddraw4_Initialize(IDirectDraw4 *iface, GUID *guid)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
- return ddraw7_Initialize((IDirectDraw7 *)ddraw_from_ddraw4(iface), guid);
+ return ddraw7_Initialize(&This->IDirectDraw7_iface, guid);
}
static HRESULT WINAPI ddraw3_Initialize(IDirectDraw3 *iface, GUID *guid)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
- return ddraw7_Initialize((IDirectDraw7 *)ddraw_from_ddraw3(iface), guid);
+ return ddraw7_Initialize(&This->IDirectDraw7_iface, guid);
}
static HRESULT WINAPI ddraw2_Initialize(IDirectDraw2 *iface, GUID *guid)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
- return ddraw7_Initialize((IDirectDraw7 *)ddraw_from_ddraw2(iface), guid);
+ return ddraw7_Initialize(&This->IDirectDraw7_iface, guid);
}
static HRESULT WINAPI ddraw1_Initialize(IDirectDraw *iface, GUID *guid)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
- return ddraw7_Initialize((IDirectDraw7 *)ddraw_from_ddraw1(iface), guid);
+ return ddraw7_Initialize(&This->IDirectDraw7_iface, guid);
}
static HRESULT WINAPI d3d1_Initialize(IDirect3D *iface, REFIID riid)
@@ -1607,30 +1739,38 @@ static HRESULT WINAPI ddraw7_FlipToGDISurface(IDirectDraw7 *iface)
static HRESULT WINAPI ddraw4_FlipToGDISurface(IDirectDraw4 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw7_FlipToGDISurface((IDirectDraw7 *)ddraw_from_ddraw4(iface));
+ return ddraw7_FlipToGDISurface(&This->IDirectDraw7_iface);
}
static HRESULT WINAPI ddraw3_FlipToGDISurface(IDirectDraw3 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw7_FlipToGDISurface((IDirectDraw7 *)ddraw_from_ddraw3(iface));
+ return ddraw7_FlipToGDISurface(&This->IDirectDraw7_iface);
}
static HRESULT WINAPI ddraw2_FlipToGDISurface(IDirectDraw2 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw7_FlipToGDISurface((IDirectDraw7 *)ddraw_from_ddraw2(iface));
+ return ddraw7_FlipToGDISurface(&This->IDirectDraw7_iface);
}
static HRESULT WINAPI ddraw1_FlipToGDISurface(IDirectDraw *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw7_FlipToGDISurface((IDirectDraw7 *)ddraw_from_ddraw1(iface));
+ return ddraw7_FlipToGDISurface(&This->IDirectDraw7_iface);
}
/*****************************************************************************
@@ -1672,30 +1812,38 @@ static HRESULT WINAPI ddraw7_WaitForVerticalBlank(IDirectDraw7 *iface, DWORD Fla
static HRESULT WINAPI ddraw4_WaitForVerticalBlank(IDirectDraw4 *iface, DWORD flags, HANDLE event)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, flags %#x, event %p.\n", iface, flags, event);
- return ddraw7_WaitForVerticalBlank((IDirectDraw7 *)ddraw_from_ddraw4(iface), flags, event);
+ return ddraw7_WaitForVerticalBlank(&This->IDirectDraw7_iface, flags, event);
}
static HRESULT WINAPI ddraw3_WaitForVerticalBlank(IDirectDraw3 *iface, DWORD flags, HANDLE event)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+
TRACE("iface %p, flags %#x, event %p.\n", iface, flags, event);
- return ddraw7_WaitForVerticalBlank((IDirectDraw7 *)ddraw_from_ddraw3(iface), flags, event);
+ return ddraw7_WaitForVerticalBlank(&This->IDirectDraw7_iface, flags, event);
}
static HRESULT WINAPI ddraw2_WaitForVerticalBlank(IDirectDraw2 *iface, DWORD flags, HANDLE event)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+
TRACE("iface %p, flags %#x, event %p.\n", iface, flags, event);
- return ddraw7_WaitForVerticalBlank((IDirectDraw7 *)ddraw_from_ddraw2(iface), flags, event);
+ return ddraw7_WaitForVerticalBlank(&This->IDirectDraw7_iface, flags, event);
}
static HRESULT WINAPI ddraw1_WaitForVerticalBlank(IDirectDraw *iface, DWORD flags, HANDLE event)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+
TRACE("iface %p, flags %#x, event %p.\n", iface, flags, event);
- return ddraw7_WaitForVerticalBlank((IDirectDraw7 *)ddraw_from_ddraw1(iface), flags, event);
+ return ddraw7_WaitForVerticalBlank(&This->IDirectDraw7_iface, flags, event);
}
/*****************************************************************************
@@ -1712,7 +1860,7 @@ static HRESULT WINAPI ddraw1_WaitForVerticalBlank(IDirectDraw *iface, DWORD flag
*****************************************************************************/
static HRESULT WINAPI ddraw7_GetScanLine(IDirectDraw7 *iface, DWORD *Scanline)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
static BOOL hide = FALSE;
WINED3DDISPLAYMODE Mode;
@@ -1726,9 +1874,7 @@ static HRESULT WINAPI ddraw7_GetScanLine(IDirectDraw7 *iface, DWORD *Scanline)
hide = TRUE;
}
- IWineD3DDevice_GetDisplayMode(This->wineD3DDevice,
- 0,
- &Mode);
+ wined3d_device_get_display_mode(This->wined3d_device, 0, &Mode);
/* Fake the line sweeping of the monitor */
/* FIXME: We should synchronize with a source to keep the refresh rate */
@@ -1743,30 +1889,38 @@ static HRESULT WINAPI ddraw7_GetScanLine(IDirectDraw7 *iface, DWORD *Scanline)
static HRESULT WINAPI ddraw4_GetScanLine(IDirectDraw4 *iface, DWORD *line)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, line %p.\n", iface, line);
- return ddraw7_GetScanLine((IDirectDraw7 *)ddraw_from_ddraw4(iface), line);
+ return ddraw7_GetScanLine(&This->IDirectDraw7_iface, line);
}
static HRESULT WINAPI ddraw3_GetScanLine(IDirectDraw3 *iface, DWORD *line)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+
TRACE("iface %p, line %p.\n", iface, line);
- return ddraw7_GetScanLine((IDirectDraw7 *)ddraw_from_ddraw3(iface), line);
+ return ddraw7_GetScanLine(&This->IDirectDraw7_iface, line);
}
static HRESULT WINAPI ddraw2_GetScanLine(IDirectDraw2 *iface, DWORD *line)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+
TRACE("iface %p, line %p.\n", iface, line);
- return ddraw7_GetScanLine((IDirectDraw7 *)ddraw_from_ddraw2(iface), line);
+ return ddraw7_GetScanLine(&This->IDirectDraw7_iface, line);
}
static HRESULT WINAPI ddraw1_GetScanLine(IDirectDraw *iface, DWORD *line)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+
TRACE("iface %p, line %p.\n", iface, line);
- return ddraw7_GetScanLine((IDirectDraw7 *)ddraw_from_ddraw1(iface), line);
+ return ddraw7_GetScanLine(&This->IDirectDraw7_iface, line);
}
/*****************************************************************************
@@ -1790,9 +1944,11 @@ static HRESULT WINAPI ddraw7_TestCooperativeLevel(IDirectDraw7 *iface)
static HRESULT WINAPI ddraw4_TestCooperativeLevel(IDirectDraw4 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw7_TestCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw4(iface));
+ return ddraw7_TestCooperativeLevel(&This->IDirectDraw7_iface);
}
/*****************************************************************************
@@ -1811,8 +1967,8 @@ static HRESULT WINAPI ddraw4_TestCooperativeLevel(IDirectDraw4 *iface)
*****************************************************************************/
static HRESULT WINAPI ddraw7_GetGDISurface(IDirectDraw7 *iface, IDirectDrawSurface7 **GDISurface)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
- IWineD3DSurface *Surf;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
+ struct wined3d_surface *wined3d_surface;
IDirectDrawSurface7 *ddsurf;
HRESULT hr;
DDSCAPS2 ddsCaps;
@@ -1820,25 +1976,19 @@ static HRESULT WINAPI ddraw7_GetGDISurface(IDirectDraw7 *iface, IDirectDrawSurfa
TRACE("iface %p, surface %p.\n", iface, GDISurface);
/* Get the back buffer from the wineD3DDevice and search its
- * attached surfaces for the front buffer
- */
+ * attached surfaces for the front buffer. */
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_GetBackBuffer(This->wineD3DDevice,
- 0, /* SwapChain */
- 0, /* first back buffer*/
- WINED3DBACKBUFFER_TYPE_MONO,
- &Surf);
-
- if( (hr != D3D_OK) ||
- (!Surf) )
+ hr = wined3d_device_get_back_buffer(This->wined3d_device,
+ 0, 0, WINED3DBACKBUFFER_TYPE_MONO, &wined3d_surface);
+ if (FAILED(hr) || !wined3d_surface)
{
ERR("IWineD3DDevice::GetBackBuffer failed\n");
LeaveCriticalSection(&ddraw_cs);
return DDERR_NOTFOUND;
}
- ddsurf = IWineD3DSurface_GetParent(Surf);
- IWineD3DSurface_Release(Surf);
+ ddsurf = wined3d_surface_get_parent(wined3d_surface);
+ wined3d_surface_decref(wined3d_surface);
/* Find the front buffer */
ddsCaps.dwCaps = DDSCAPS_FRONTBUFFER;
@@ -1857,19 +2007,22 @@ static HRESULT WINAPI ddraw7_GetGDISurface(IDirectDraw7 *iface, IDirectDrawSurfa
static HRESULT WINAPI ddraw4_GetGDISurface(IDirectDraw4 *iface, IDirectDrawSurface4 **surface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, surface %p.\n", iface, surface);
- return ddraw7_GetGDISurface((IDirectDraw7 *)ddraw_from_ddraw4(iface), (IDirectDrawSurface7 **)surface);
+ return ddraw7_GetGDISurface(&This->IDirectDraw7_iface, (IDirectDrawSurface7 **)surface);
}
static HRESULT WINAPI ddraw3_GetGDISurface(IDirectDraw3 *iface, IDirectDrawSurface **surface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
IDirectDrawSurface7 *surface7;
HRESULT hr;
TRACE("iface %p, surface %p.\n", iface, surface);
- hr = ddraw7_GetGDISurface((IDirectDraw7 *)ddraw_from_ddraw3(iface), &surface7);
+ hr = ddraw7_GetGDISurface(&This->IDirectDraw7_iface, &surface7);
*surface = surface7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)surface7)->IDirectDrawSurface3_vtbl : NULL;
return hr;
@@ -1877,12 +2030,13 @@ static HRESULT WINAPI ddraw3_GetGDISurface(IDirectDraw3 *iface, IDirectDrawSurfa
static HRESULT WINAPI ddraw2_GetGDISurface(IDirectDraw2 *iface, IDirectDrawSurface **surface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
IDirectDrawSurface7 *surface7;
HRESULT hr;
TRACE("iface %p, surface %p.\n", iface, surface);
- hr = ddraw7_GetGDISurface((IDirectDraw7 *)ddraw_from_ddraw2(iface), &surface7);
+ hr = ddraw7_GetGDISurface(&This->IDirectDraw7_iface, &surface7);
*surface = surface7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)surface7)->IDirectDrawSurface3_vtbl : NULL;
return hr;
@@ -1890,12 +2044,13 @@ static HRESULT WINAPI ddraw2_GetGDISurface(IDirectDraw2 *iface, IDirectDrawSurfa
static HRESULT WINAPI ddraw1_GetGDISurface(IDirectDraw *iface, IDirectDrawSurface **surface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
IDirectDrawSurface7 *surface7;
HRESULT hr;
TRACE("iface %p, surface %p.\n", iface, surface);
- hr = ddraw7_GetGDISurface((IDirectDraw7 *)ddraw_from_ddraw1(iface), &surface7);
+ hr = ddraw7_GetGDISurface(&This->IDirectDraw7_iface, &surface7);
*surface = surface7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)surface7)->IDirectDrawSurface3_vtbl : NULL;
return hr;
@@ -1925,7 +2080,8 @@ static HRESULT CALLBACK EnumDisplayModesCallbackThunk(DDSURFACEDESC2 *surface_de
* the DDSD parameter.
*
* Params:
- * Flags: can be DDEDM_REFRESHRATES and DDEDM_STANDARDVGAMODES
+ * Flags: can be DDEDM_REFRESHRATES and DDEDM_STANDARDVGAMODES. For old ddraw
+ * versions (3 and older?) this is reserved and must be 0.
* DDSD: Surface description to filter the modes
* Context: Pointer passed back to the callback function
* cb: Application-provided callback function
@@ -1938,13 +2094,13 @@ static HRESULT CALLBACK EnumDisplayModesCallbackThunk(DDSURFACEDESC2 *surface_de
static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags,
DDSURFACEDESC2 *DDSD, void *Context, LPDDENUMMODESCALLBACK2 cb)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
unsigned int modenum, fmt;
- enum wined3d_format_id pixelformat = WINED3DFMT_UNKNOWN;
WINED3DDISPLAYMODE mode;
DDSURFACEDESC2 callback_sd;
WINED3DDISPLAYMODE *enum_modes = NULL;
unsigned enum_mode_count = 0, enum_mode_array_size = 0;
+ DDPIXELFORMAT pixelformat;
static const enum wined3d_format_id checkFormatList[] =
{
@@ -1964,12 +2120,6 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags,
return DDERR_INVALIDPARAMS;
}
- if(DDSD)
- {
- if ((DDSD->dwFlags & DDSD_PIXELFORMAT) && (DDSD->u4.ddpfPixelFormat.dwFlags & DDPF_RGB) )
- pixelformat = PixelFormat_DD2WineD3D(&DDSD->u4.ddpfPixelFormat);
- }
-
if(!(Flags & DDEDM_REFRESHRATES))
{
enum_mode_array_size = 16;
@@ -1982,24 +2132,21 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags,
}
}
+ pixelformat.dwSize = sizeof(pixelformat);
for(fmt = 0; fmt < (sizeof(checkFormatList) / sizeof(checkFormatList[0])); fmt++)
{
- if(pixelformat != WINED3DFMT_UNKNOWN && checkFormatList[fmt] != pixelformat)
- {
- continue;
- }
-
modenum = 0;
- while(IWineD3D_EnumAdapterModes(This->wineD3D,
- WINED3DADAPTER_DEFAULT,
- checkFormatList[fmt],
- modenum++,
- &mode) == WINED3D_OK)
+ while (wined3d_enum_adapter_modes(This->wineD3D, WINED3DADAPTER_DEFAULT,
+ checkFormatList[fmt], modenum++, &mode) == WINED3D_OK)
{
+ PixelFormat_WineD3DtoDD(&pixelformat, mode.Format);
if(DDSD)
{
if(DDSD->dwFlags & DDSD_WIDTH && mode.Width != DDSD->dwWidth) continue;
if(DDSD->dwFlags & DDSD_HEIGHT && mode.Height != DDSD->dwHeight) continue;
+ if(DDSD->dwFlags & DDSD_REFRESHRATE && mode.RefreshRate != DDSD->u2.dwRefreshRate) continue;
+ if (DDSD->dwFlags & DDSD_PIXELFORMAT &&
+ pixelformat.u1.dwRGBBitCount != DDSD->u4.ddpfPixelFormat.u1.dwRGBBitCount) continue;
}
if(!(Flags & DDEDM_REFRESHRATES))
@@ -2028,17 +2175,16 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags,
callback_sd.dwSize = sizeof(callback_sd);
callback_sd.u4.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
- callback_sd.dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH;
+ callback_sd.dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH|DDSD_REFRESHRATE;
if(Flags & DDEDM_REFRESHRATES)
{
- callback_sd.dwFlags |= DDSD_REFRESHRATE;
callback_sd.u2.dwRefreshRate = mode.RefreshRate;
}
callback_sd.dwWidth = mode.Width;
callback_sd.dwHeight = mode.Height;
- PixelFormat_WineD3DtoDD(&callback_sd.u4.ddpfPixelFormat, mode.Format);
+ callback_sd.u4.ddpfPixelFormat=pixelformat;
/* Calc pitch and DWORD align like MSDN says */
callback_sd.u1.lPitch = (callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount / 8) * mode.Width;
@@ -2089,16 +2235,18 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags,
static HRESULT WINAPI ddraw4_EnumDisplayModes(IDirectDraw4 *iface, DWORD flags,
DDSURFACEDESC2 *surface_desc, void *context, LPDDENUMMODESCALLBACK2 callback)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
iface, flags, surface_desc, context, callback);
- return ddraw7_EnumDisplayModes((IDirectDraw7 *)ddraw_from_ddraw4(iface), flags,
- surface_desc, context, callback);
+ return ddraw7_EnumDisplayModes(&This->IDirectDraw7_iface, flags, surface_desc, context, callback);
}
static HRESULT WINAPI ddraw3_EnumDisplayModes(IDirectDraw3 *iface, DWORD flags,
DDSURFACEDESC *surface_desc, void *context, LPDDENUMMODESCALLBACK callback)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
struct displaymodescallback_context cbcontext;
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
@@ -2107,13 +2255,14 @@ static HRESULT WINAPI ddraw3_EnumDisplayModes(IDirectDraw3 *iface, DWORD flags,
cbcontext.func = callback;
cbcontext.context = context;
- return ddraw7_EnumDisplayModes((IDirectDraw7 *)ddraw_from_ddraw3(iface), flags,
- (DDSURFACEDESC2 *)surface_desc, &cbcontext, EnumDisplayModesCallbackThunk);
+ return ddraw7_EnumDisplayModes(&This->IDirectDraw7_iface, flags, (DDSURFACEDESC2 *)surface_desc,
+ &cbcontext, EnumDisplayModesCallbackThunk);
}
static HRESULT WINAPI ddraw2_EnumDisplayModes(IDirectDraw2 *iface, DWORD flags,
DDSURFACEDESC *surface_desc, void *context, LPDDENUMMODESCALLBACK callback)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
struct displaymodescallback_context cbcontext;
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
@@ -2122,13 +2271,14 @@ static HRESULT WINAPI ddraw2_EnumDisplayModes(IDirectDraw2 *iface, DWORD flags,
cbcontext.func = callback;
cbcontext.context = context;
- return ddraw7_EnumDisplayModes((IDirectDraw7 *)ddraw_from_ddraw2(iface), flags,
- (DDSURFACEDESC2 *)surface_desc, &cbcontext, EnumDisplayModesCallbackThunk);
+ return ddraw7_EnumDisplayModes(&This->IDirectDraw7_iface, flags, (DDSURFACEDESC2 *)surface_desc,
+ &cbcontext, EnumDisplayModesCallbackThunk);
}
static HRESULT WINAPI ddraw1_EnumDisplayModes(IDirectDraw *iface, DWORD flags,
DDSURFACEDESC *surface_desc, void *context, LPDDENUMMODESCALLBACK callback)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
struct displaymodescallback_context cbcontext;
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
@@ -2137,8 +2287,8 @@ static HRESULT WINAPI ddraw1_EnumDisplayModes(IDirectDraw *iface, DWORD flags,
cbcontext.func = callback;
cbcontext.context = context;
- return ddraw7_EnumDisplayModes((IDirectDraw7 *)ddraw_from_ddraw1(iface), flags,
- (DDSURFACEDESC2 *)surface_desc, &cbcontext, EnumDisplayModesCallbackThunk);
+ return ddraw7_EnumDisplayModes(&This->IDirectDraw7_iface, flags, (DDSURFACEDESC2 *)surface_desc,
+ &cbcontext, EnumDisplayModesCallbackThunk);
}
/*****************************************************************************
@@ -2203,12 +2353,13 @@ static HRESULT WINAPI ddraw7_GetDeviceIdentifier(IDirectDraw7 *iface,
static HRESULT WINAPI ddraw4_GetDeviceIdentifier(IDirectDraw4 *iface,
DDDEVICEIDENTIFIER *identifier, DWORD flags)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
DDDEVICEIDENTIFIER2 identifier2;
HRESULT hr;
TRACE("iface %p, identifier %p, flags %#x.\n", iface, identifier, flags);
- hr = ddraw7_GetDeviceIdentifier((IDirectDraw7 *)ddraw_from_ddraw4(iface), &identifier2, flags);
+ hr = ddraw7_GetDeviceIdentifier(&This->IDirectDraw7_iface, &identifier2, flags);
DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(&identifier2, identifier);
return hr;
@@ -2228,17 +2379,18 @@ static HRESULT WINAPI ddraw4_GetDeviceIdentifier(IDirectDraw4 *iface,
* Always returns DD_OK because it's a stub
*
*****************************************************************************/
-static HRESULT WINAPI ddraw7_GetSurfaceFromDC(IDirectDraw7 *iface, HDC hdc, IDirectDrawSurface7 **Surface)
+static HRESULT WINAPI ddraw7_GetSurfaceFromDC(IDirectDraw7 *iface, HDC hdc,
+ IDirectDrawSurface7 **Surface)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
- IWineD3DSurface *wined3d_surface;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
+ struct wined3d_surface *wined3d_surface;
HRESULT hr;
TRACE("iface %p, dc %p, surface %p.\n", iface, hdc, Surface);
if (!Surface) return E_INVALIDARG;
- hr = IWineD3DDevice_GetSurfaceFromDC(This->wineD3DDevice, hdc, &wined3d_surface);
+ hr = wined3d_device_get_surface_from_dc(This->wined3d_device, hdc, &wined3d_surface);
if (FAILED(hr))
{
TRACE("No surface found for dc %p.\n", hdc);
@@ -2246,14 +2398,16 @@ static HRESULT WINAPI ddraw7_GetSurfaceFromDC(IDirectDraw7 *iface, HDC hdc, IDir
return DDERR_NOTFOUND;
}
- *Surface = IWineD3DSurface_GetParent(wined3d_surface);
+ *Surface = wined3d_surface_get_parent(wined3d_surface);
IDirectDrawSurface7_AddRef(*Surface);
TRACE("Returning surface %p.\n", Surface);
return DD_OK;
}
-static HRESULT WINAPI ddraw4_GetSurfaceFromDC(IDirectDraw4 *iface, HDC dc, IDirectDrawSurface4 **surface)
+static HRESULT WINAPI ddraw4_GetSurfaceFromDC(IDirectDraw4 *iface, HDC dc,
+ IDirectDrawSurface4 **surface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
IDirectDrawSurface7 *surface7;
HRESULT hr;
@@ -2261,18 +2415,20 @@ static HRESULT WINAPI ddraw4_GetSurfaceFromDC(IDirectDraw4 *iface, HDC dc, IDire
if (!surface) return E_INVALIDARG;
- hr = ddraw7_GetSurfaceFromDC((IDirectDraw7 *)ddraw_from_ddraw4(iface), dc, &surface7);
+ hr = ddraw7_GetSurfaceFromDC(&This->IDirectDraw7_iface, dc, &surface7);
*surface = surface7 ? (IDirectDrawSurface4 *)&((IDirectDrawSurfaceImpl *)surface7)->IDirectDrawSurface3_vtbl : NULL;
return hr;
}
-static HRESULT WINAPI ddraw3_GetSurfaceFromDC(IDirectDraw3 *iface, HDC dc, IDirectDrawSurface **surface)
+static HRESULT WINAPI ddraw3_GetSurfaceFromDC(IDirectDraw3 *iface, HDC dc,
+ IDirectDrawSurface **surface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+
TRACE("iface %p, dc %p, surface %p.\n", iface, dc, surface);
- return ddraw7_GetSurfaceFromDC((IDirectDraw7 *)ddraw_from_ddraw3(iface),
- dc, (IDirectDrawSurface7 **)surface);
+ return ddraw7_GetSurfaceFromDC(&This->IDirectDraw7_iface, dc, (IDirectDrawSurface7 **)surface);
}
/*****************************************************************************
@@ -2300,9 +2456,11 @@ static HRESULT WINAPI ddraw7_RestoreAllSurfaces(IDirectDraw7 *iface)
static HRESULT WINAPI ddraw4_RestoreAllSurfaces(IDirectDraw4 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p.\n", iface);
- return ddraw7_RestoreAllSurfaces((IDirectDraw7 *)ddraw_from_ddraw4(iface));
+ return ddraw7_RestoreAllSurfaces(&This->IDirectDraw7_iface);
}
/*****************************************************************************
@@ -2356,22 +2514,14 @@ static HRESULT WINAPI ddraw7_StartModeTest(IDirectDraw7 *iface, SIZE *Modes, DWO
HRESULT WINAPI ddraw_recreate_surfaces_cb(IDirectDrawSurface7 *surf, DDSURFACEDESC2 *desc, void *Context)
{
IDirectDrawSurfaceImpl *surfImpl = (IDirectDrawSurfaceImpl *)surf;
+ struct wined3d_resource_desc wined3d_desc;
+ struct wined3d_resource *wined3d_resource;
IDirectDrawImpl *This = surfImpl->ddraw;
- IWineD3DSurface *wineD3DSurface;
- IWineD3DSwapChain *swapchain;
+ struct wined3d_surface *wined3d_surface;
+ struct wined3d_swapchain *swapchain;
+ struct wined3d_clipper *clipper;
void *parent;
HRESULT hr;
- IWineD3DClipper *clipper = NULL;
-
- WINED3DSURFACE_DESC Desc;
- enum wined3d_format_id Format;
- DWORD Usage;
- WINED3DPOOL Pool;
-
- WINED3DMULTISAMPLE_TYPE MultiSampleType;
- DWORD MultiSampleQuality;
- UINT Width;
- UINT Height;
TRACE("surface %p, surface_desc %p, context %p.\n",
surf, desc, Context);
@@ -2382,51 +2532,46 @@ HRESULT WINAPI ddraw_recreate_surfaces_cb(IDirectDrawSurface7 *surf, DDSURFACEDE
if(surfImpl->ImplType == This->ImplType) return DDENUMRET_OK; /* Continue */
/* Get the objects */
- swapchain = surfImpl->wineD3DSwapChain;
- surfImpl->wineD3DSwapChain = NULL;
- wineD3DSurface = surfImpl->WineD3DSurface;
+ swapchain = surfImpl->wined3d_swapchain;
+ surfImpl->wined3d_swapchain = NULL;
+ wined3d_surface = surfImpl->wined3d_surface;
/* get the clipper */
- IWineD3DSurface_GetClipper(wineD3DSurface, &clipper);
+ clipper = wined3d_surface_get_clipper(wined3d_surface);
/* Get the surface properties */
- IWineD3DSurface_GetDesc(wineD3DSurface, &Desc);
+ wined3d_resource = wined3d_surface_get_resource(wined3d_surface);
+ wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
- Format = Desc.format;
- Usage = Desc.usage;
- Pool = Desc.pool;
- MultiSampleType = Desc.multisample_type;
- MultiSampleQuality = Desc.multisample_quality;
- Width = Desc.width;
- Height = Desc.height;
-
- parent = IWineD3DSurface_GetParent(wineD3DSurface);
- hr = IWineD3DDevice_CreateSurface(This->wineD3DDevice, Width, Height, Format, TRUE /* Lockable */,
- FALSE /* Discard */, surfImpl->mipmap_level, Usage, Pool, MultiSampleType, MultiSampleQuality,
- This->ImplType, parent, &ddraw_null_wined3d_parent_ops, &surfImpl->WineD3DSurface);
+ parent = wined3d_surface_get_parent(wined3d_surface);
+ hr = wined3d_surface_create(This->wined3d_device, wined3d_desc.width, wined3d_desc.height,
+ wined3d_desc.format, TRUE, FALSE, surfImpl->mipmap_level, wined3d_desc.usage, wined3d_desc.pool,
+ wined3d_desc.multisample_type, wined3d_desc.multisample_quality, This->ImplType,
+ parent, &ddraw_surface_wined3d_parent_ops, &surfImpl->wined3d_surface);
if (FAILED(hr))
{
- surfImpl->WineD3DSurface = wineD3DSurface;
+ surfImpl->wined3d_surface = wined3d_surface;
return hr;
}
- IWineD3DSurface_SetClipper(surfImpl->WineD3DSurface, clipper);
+ wined3d_surface_set_clipper(surfImpl->wined3d_surface, clipper);
/* TODO: Copy the surface content, except for render targets */
/* If there's a swapchain, it owns the wined3d surfaces. So Destroy
* the swapchain
*/
- if(swapchain) {
+ if (swapchain)
+ {
/* The backbuffers have the swapchain set as well, but the primary
- * owns it and destroys it
- */
- if(surfImpl->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) {
- IWineD3DDevice_UninitGDI(This->wineD3DDevice, D3D7CB_DestroySwapChain);
- }
+ * owns it and destroys it. */
+ if (surfImpl->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
+ wined3d_device_uninit_gdi(This->wined3d_device);
surfImpl->isRenderTarget = FALSE;
- } else {
- if(IWineD3DSurface_Release(wineD3DSurface) == 0)
+ }
+ else
+ {
+ if (!wined3d_surface_decref(wined3d_surface))
TRACE("Surface released successful, next surface\n");
else
ERR("Something's still holding the old WineD3DSurface\n");
@@ -2434,10 +2579,6 @@ HRESULT WINAPI ddraw_recreate_surfaces_cb(IDirectDrawSurface7 *surf, DDSURFACEDE
surfImpl->ImplType = This->ImplType;
- if(clipper)
- {
- IWineD3DClipper_Release(clipper);
- }
return DDENUMRET_OK;
}
@@ -2459,24 +2600,15 @@ static HRESULT ddraw_recreate_surfaces(IDirectDrawImpl *This)
/* Should happen almost never */
FIXME("(%p) Switching to non-opengl surfaces with d3d started. Is this a bug?\n", This);
/* Shutdown d3d */
- IWineD3DDevice_Uninit3D(This->wineD3DDevice, D3D7CB_DestroySwapChain);
+ wined3d_device_uninit_3d(This->wined3d_device);
}
/* Contrary: D3D starting is handled by the caller, because it knows the render target */
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
- return IDirectDraw7_EnumSurfaces((IDirectDraw7 *)This, 0, &desc, This, ddraw_recreate_surfaces_cb);
-}
-
-ULONG WINAPI D3D7CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain)
-{
- IUnknown *swapChainParent;
-
- TRACE("swapchain %p.\n", pSwapChain);
-
- swapChainParent = IWineD3DSwapChain_GetParent(pSwapChain);
- return IUnknown_Release(swapChainParent);
+ return IDirectDraw7_EnumSurfaces(&This->IDirectDraw7_iface, 0, &desc, This,
+ ddraw_recreate_surfaces_cb);
}
/*****************************************************************************
@@ -2737,11 +2869,12 @@ static HRESULT ddraw_attach_d3d_device(IDirectDrawImpl *ddraw, IDirectDrawSurfac
localParameters.Flags = 0;
localParameters.FullScreen_RefreshRateInHz = WINED3DPRESENT_RATE_DEFAULT;
localParameters.PresentationInterval = WINED3DPRESENT_INTERVAL_DEFAULT;
+ localParameters.AutoRestoreDisplayMode = FALSE;
/* Set this NOW, otherwise creating the depth stencil surface will cause a
* recursive loop until ram or emulated video memory is full. */
ddraw->d3d_initialized = TRUE;
- hr = IWineD3DDevice_Init3D(ddraw->wineD3DDevice, &localParameters);
+ hr = wined3d_device_init_3d(ddraw->wined3d_device, &localParameters);
if (FAILED(hr))
{
ddraw->d3d_target = NULL;
@@ -2755,7 +2888,7 @@ static HRESULT ddraw_attach_d3d_device(IDirectDrawImpl *ddraw, IDirectDrawSurfac
{
ERR("Error allocating an array for the converted vertex decls.\n");
ddraw->declArraySize = 0;
- hr = IWineD3DDevice_Uninit3D(ddraw->wineD3DDevice, D3D7CB_DestroySwapChain);
+ hr = wined3d_device_uninit_3d(ddraw->wined3d_device);
return E_OUTOFMEMORY;
}
@@ -2791,14 +2924,15 @@ static HRESULT ddraw_create_gdi_swapchain(IDirectDrawImpl *ddraw, IDirectDrawSur
presentation_parameters.Flags = 0;
presentation_parameters.FullScreen_RefreshRateInHz = WINED3DPRESENT_RATE_DEFAULT;
presentation_parameters.PresentationInterval = WINED3DPRESENT_INTERVAL_DEFAULT;
+ presentation_parameters.AutoRestoreDisplayMode = FALSE;
ddraw->d3d_target = primary;
- hr = IWineD3DDevice_InitGDI(ddraw->wineD3DDevice, &presentation_parameters);
+ hr = wined3d_device_init_gdi(ddraw->wined3d_device, &presentation_parameters);
ddraw->d3d_target = NULL;
if (FAILED(hr))
{
WARN("Failed to initialize GDI ddraw implementation, hr %#x.\n", hr);
- primary->wineD3DSwapChain = NULL;
+ primary->wined3d_swapchain = NULL;
}
return hr;
@@ -2881,10 +3015,9 @@ static HRESULT ddraw_create_gdi_swapchain(IDirectDrawImpl *ddraw, IDirectDrawSur
* DDERR_* if an error occurs
*
*****************************************************************************/
-static HRESULT CreateSurface(IDirectDraw7 *iface,
- DDSURFACEDESC2 *DDSD, IDirectDrawSurface7 **Surf, IUnknown *UnkOuter)
+static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
+ IDirectDrawSurface7 **Surf, IUnknown *UnkOuter)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
IDirectDrawSurfaceImpl *object = NULL;
HRESULT hr;
LONG extra_surfaces = 0;
@@ -2892,27 +3025,26 @@ static HRESULT CreateSurface(IDirectDraw7 *iface,
WINED3DDISPLAYMODE Mode;
const DWORD sysvidmem = DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
- TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
- iface, DDSD, Surf, UnkOuter);
+ TRACE("ddraw %p, surface_desc %p, surface %p, outer_unknown %p.\n", ddraw, DDSD, Surf, UnkOuter);
/* Some checks before we start */
if (TRACE_ON(ddraw))
{
- TRACE(" (%p) Requesting surface desc :\n", This);
+ TRACE(" (%p) Requesting surface desc :\n", ddraw);
DDRAW_dump_surface_desc(DDSD);
}
EnterCriticalSection(&ddraw_cs);
if (UnkOuter != NULL)
{
- FIXME("(%p) : outer != NULL?\n", This);
+ FIXME("(%p) : outer != NULL?\n", ddraw);
LeaveCriticalSection(&ddraw_cs);
return CLASS_E_NOAGGREGATION; /* unchecked */
}
if (Surf == NULL)
{
- FIXME("(%p) You want to get back a surface? Don't give NULL ptrs!\n", This);
+ FIXME("(%p) You want to get back a surface? Don't give NULL ptrs!\n", ddraw);
LeaveCriticalSection(&ddraw_cs);
return E_POINTER; /* unchecked */
}
@@ -2932,14 +3064,15 @@ static HRESULT CreateSurface(IDirectDraw7 *iface,
if ((DDSD->dwFlags & DDSD_LPSURFACE) && (DDSD->lpSurface == NULL))
{
/* Frank Herbert's Dune specifies a null pointer for the surface, ignore the LPSURFACE field */
- WARN("(%p) Null surface pointer specified, ignore it!\n", This);
+ WARN("(%p) Null surface pointer specified, ignore it!\n", ddraw);
DDSD->dwFlags &= ~DDSD_LPSURFACE;
}
if((DDSD->ddsCaps.dwCaps & (DDSCAPS_FLIP | DDSCAPS_PRIMARYSURFACE)) == (DDSCAPS_FLIP | DDSCAPS_PRIMARYSURFACE) &&
- !(This->cooperative_level & DDSCL_EXCLUSIVE))
+ !(ddraw->cooperative_level & DDSCL_EXCLUSIVE))
{
- TRACE("(%p): Attempt to create a flipable primary surface without DDSCL_EXCLUSIVE set\n", This);
+ TRACE("(%p): Attempt to create a flipable primary surface without DDSCL_EXCLUSIVE set\n",
+ ddraw);
*Surf = NULL;
LeaveCriticalSection(&ddraw_cs);
return DDERR_NOEXCLUSIVEMODE;
@@ -2992,20 +3125,15 @@ static HRESULT CreateSurface(IDirectDraw7 *iface,
DDSD->ddsCaps.dwCaps2 &= ~DDSCAPS2_MIPMAPSUBLEVEL;
/* Modify some flags */
- memset(&desc2, 0, sizeof(desc2));
- desc2.dwSize = sizeof(desc2); /* For the struct copy */
- DD_STRUCT_COPY_BYSIZE(&desc2, DDSD);
- desc2.dwSize = sizeof(desc2); /* To override a possibly smaller size */
+ copy_to_surfacedesc2(&desc2, DDSD);
desc2.u4.ddpfPixelFormat.dwSize=sizeof(DDPIXELFORMAT); /* Just to be sure */
/* Get the video mode from WineD3D - we will need it */
- hr = IWineD3DDevice_GetDisplayMode(This->wineD3DDevice,
- 0, /* Swapchain 0 */
- &Mode);
- if(FAILED(hr))
+ hr = wined3d_device_get_display_mode(ddraw->wined3d_device, 0, &Mode);
+ if (FAILED(hr))
{
ERR("Failed to read display mode from wined3d\n");
- switch(This->orig_bpp)
+ switch(ddraw->orig_bpp)
{
case 8:
Mode.Format = WINED3DFMT_P8_UINT;
@@ -3027,8 +3155,8 @@ static HRESULT CreateSurface(IDirectDraw7 *iface,
Mode.Format = WINED3DFMT_B8G8R8X8_UNORM;
break;
}
- Mode.Width = This->orig_width;
- Mode.Height = This->orig_height;
+ Mode.Width = ddraw->orig_width;
+ Mode.Height = ddraw->orig_height;
}
/* No pixelformat given? Use the current screen format */
@@ -3083,6 +3211,12 @@ static HRESULT CreateSurface(IDirectDraw7 *iface,
desc2.dwHeight = Mode.Height;
}
+ if (!desc2.dwWidth || !desc2.dwHeight)
+ {
+ LeaveCriticalSection(&ddraw_cs);
+ return DDERR_INVALIDPARAMS;
+ }
+
/* Mipmap count fixes */
if(desc2.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
{
@@ -3138,7 +3272,7 @@ static HRESULT CreateSurface(IDirectDraw7 *iface,
}
/* Create the first surface */
- hr = ddraw_create_surface(This, &desc2, &object, 0);
+ hr = ddraw_create_surface(ddraw, &desc2, &object, 0);
if (FAILED(hr))
{
WARN("ddraw_create_surface failed, hr %#x.\n", hr);
@@ -3167,24 +3301,24 @@ static HRESULT CreateSurface(IDirectDraw7 *iface,
{
desc2.ddsCaps.dwCaps2 &= ~DDSCAPS2_CUBEMAP_ALLFACES;
desc2.ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_NEGATIVEZ;
- hr |= CreateAdditionalSurfaces(This, object, extra_surfaces + 1, desc2, TRUE);
+ hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces + 1, desc2, TRUE);
desc2.ddsCaps.dwCaps2 &= ~DDSCAPS2_CUBEMAP_NEGATIVEZ;
desc2.ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_POSITIVEZ;
- hr |= CreateAdditionalSurfaces(This, object, extra_surfaces + 1, desc2, TRUE);
+ hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces + 1, desc2, TRUE);
desc2.ddsCaps.dwCaps2 &= ~DDSCAPS2_CUBEMAP_POSITIVEZ;
desc2.ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_NEGATIVEY;
- hr |= CreateAdditionalSurfaces(This, object, extra_surfaces + 1, desc2, TRUE);
+ hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces + 1, desc2, TRUE);
desc2.ddsCaps.dwCaps2 &= ~DDSCAPS2_CUBEMAP_NEGATIVEY;
desc2.ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_POSITIVEY;
- hr |= CreateAdditionalSurfaces(This, object, extra_surfaces + 1, desc2, TRUE);
+ hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces + 1, desc2, TRUE);
desc2.ddsCaps.dwCaps2 &= ~DDSCAPS2_CUBEMAP_POSITIVEY;
desc2.ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_NEGATIVEX;
- hr |= CreateAdditionalSurfaces(This, object, extra_surfaces + 1, desc2, TRUE);
+ hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces + 1, desc2, TRUE);
desc2.ddsCaps.dwCaps2 &= ~DDSCAPS2_CUBEMAP_NEGATIVEX;
desc2.ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_POSITIVEX;
}
- hr |= CreateAdditionalSurfaces(This, object, extra_surfaces, desc2, FALSE);
+ hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces, desc2, FALSE);
if(hr != DD_OK)
{
/* This destroys and possibly created surfaces too */
@@ -3201,14 +3335,14 @@ static HRESULT CreateSurface(IDirectDraw7 *iface,
* the render target as first surface. In this case the render target creation
* will cause the 3D init.
*/
- if( (This->ImplType == SURFACE_OPENGL) && !(This->d3d_initialized) &&
+ if( (ddraw->ImplType == SURFACE_OPENGL) && !(ddraw->d3d_initialized) &&
desc2.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE) )
{
IDirectDrawSurfaceImpl *target = object, *surface;
struct list *entry;
/* Search for the primary to use as render target */
- LIST_FOR_EACH(entry, &This->surface_list)
+ LIST_FOR_EACH(entry, &ddraw->surface_list)
{
surface = LIST_ENTRY(entry, IDirectDrawSurfaceImpl, surface_list_entry);
if((surface->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER)) ==
@@ -3221,8 +3355,8 @@ static HRESULT CreateSurface(IDirectDraw7 *iface,
}
}
- TRACE("(%p) Attaching a D3DDevice, rendertarget = %p\n", This, target);
- hr = ddraw_attach_d3d_device(This, target);
+ TRACE("(%p) Attaching a D3DDevice, rendertarget = %p\n", ddraw, target);
+ hr = ddraw_attach_d3d_device(ddraw, target);
if (hr != D3D_OK)
{
IDirectDrawSurfaceImpl *release_surf;
@@ -3246,70 +3380,32 @@ static HRESULT CreateSurface(IDirectDraw7 *iface,
return hr;
}
}
- else if(!(This->d3d_initialized) && desc2.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
+ else if(!(ddraw->d3d_initialized) && desc2.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
- ddraw_create_gdi_swapchain(This, object);
+ ddraw_create_gdi_swapchain(ddraw, object);
}
/* Addref the ddraw interface to keep an reference for each surface */
- IDirectDraw7_AddRef(iface);
- object->ifaceToRelease = (IUnknown *) iface;
+ IDirectDraw7_AddRef(&ddraw->IDirectDraw7_iface);
+ object->ifaceToRelease = (IUnknown *)&ddraw->IDirectDraw7_iface;
/* Create a WineD3DTexture if a texture was requested */
- if(desc2.ddsCaps.dwCaps & DDSCAPS_TEXTURE)
+ if (desc2.ddsCaps.dwCaps & DDSCAPS_TEXTURE)
{
- enum wined3d_format_id Format;
- UINT levels;
- WINED3DPOOL Pool = WINED3DPOOL_DEFAULT;
-
- This->tex_root = object;
-
- if(desc2.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
- {
- /* a mipmap is created, create enough levels */
- levels = desc2.u2.dwMipMapCount;
- }
- else
- {
- /* No mipmap is created, create one level */
- levels = 1;
- }
-
- /* DDSCAPS_SYSTEMMEMORY textures are in WINED3DPOOL_SYSTEMMEM */
- if(DDSD->ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY)
- {
- Pool = WINED3DPOOL_SYSTEMMEM;
- }
- /* Should I forward the MANAGED cap to the managed pool ? */
-
- /* Get the format. It's set already by CreateNewSurface */
- Format = PixelFormat_DD2WineD3D(&object->surface_desc.u4.ddpfPixelFormat);
-
- /* The surfaces are already created, the callback only
- * passes the IWineD3DSurface to WineD3D
- */
- if(desc2.ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
- {
- hr = IWineD3DDevice_CreateCubeTexture(This->wineD3DDevice, DDSD->dwWidth /* Edgelength */, levels,
- 0 /* usage */, Format, Pool, object, &ddraw_null_wined3d_parent_ops,
- (IWineD3DCubeTexture **)&object->wineD3DTexture);
- }
- else
- {
- hr = IWineD3DDevice_CreateTexture(This->wineD3DDevice, DDSD->dwWidth, DDSD->dwHeight, levels,
- 0 /* usage */, Format, Pool, object, &ddraw_null_wined3d_parent_ops,
- (IWineD3DTexture **)&object->wineD3DTexture);
- }
- This->tex_root = NULL;
+ ddraw->tex_root = object;
+ ddraw_surface_create_texture(object);
+ ddraw->tex_root = NULL;
}
LeaveCriticalSection(&ddraw_cs);
return hr;
}
-static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface,
- DDSURFACEDESC2 *surface_desc, IDirectDrawSurface7 **surface, IUnknown *outer_unknown)
+static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface, DDSURFACEDESC2 *surface_desc,
+ IDirectDrawSurface7 **surface, IUnknown *outer_unknown)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
+
TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
iface, surface_desc, surface, outer_unknown);
@@ -3331,13 +3427,13 @@ static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface,
return DDERR_INVALIDCAPS;
}
- return CreateSurface(iface, surface_desc, surface, outer_unknown);
+ return CreateSurface(This, surface_desc, surface, outer_unknown);
}
static HRESULT WINAPI ddraw4_CreateSurface(IDirectDraw4 *iface,
DDSURFACEDESC2 *surface_desc, IDirectDrawSurface4 **surface, IUnknown *outer_unknown)
{
- IDirectDrawImpl *ddraw = ddraw_from_ddraw4(iface);
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
IDirectDrawSurfaceImpl *impl;
HRESULT hr;
@@ -3362,12 +3458,12 @@ static HRESULT WINAPI ddraw4_CreateSurface(IDirectDraw4 *iface,
return DDERR_INVALIDCAPS;
}
- hr = CreateSurface((IDirectDraw7 *)ddraw, surface_desc, (IDirectDrawSurface7 **)surface, outer_unknown);
+ hr = CreateSurface(This, surface_desc, (IDirectDrawSurface7 **)surface, outer_unknown);
impl = (IDirectDrawSurfaceImpl *)*surface;
if (SUCCEEDED(hr) && impl)
{
ddraw_set_surface_version(impl, 4);
- IDirectDraw7_Release((IDirectDraw7 *)ddraw);
+ IDirectDraw7_Release(&This->IDirectDraw7_iface);
IDirectDraw4_AddRef(iface);
impl->ifaceToRelease = (IUnknown *)iface;
}
@@ -3375,10 +3471,10 @@ static HRESULT WINAPI ddraw4_CreateSurface(IDirectDraw4 *iface,
return hr;
}
-static HRESULT WINAPI ddraw3_CreateSurface(IDirectDraw3 *iface,
- DDSURFACEDESC *surface_desc, IDirectDrawSurface **surface, IUnknown *outer_unknown)
+static HRESULT WINAPI ddraw3_CreateSurface(IDirectDraw3 *iface, DDSURFACEDESC *surface_desc,
+ IDirectDrawSurface **surface, IUnknown *outer_unknown)
{
- IDirectDrawImpl *ddraw = ddraw_from_ddraw3(iface);
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
IDirectDrawSurface7 *surface7;
IDirectDrawSurfaceImpl *impl;
HRESULT hr;
@@ -3404,7 +3500,7 @@ static HRESULT WINAPI ddraw3_CreateSurface(IDirectDraw3 *iface,
return DDERR_INVALIDCAPS;
}
- hr = CreateSurface((IDirectDraw7 *)ddraw, (DDSURFACEDESC2 *)surface_desc, &surface7, outer_unknown);
+ hr = CreateSurface(This, (DDSURFACEDESC2 *)surface_desc, &surface7, outer_unknown);
if (FAILED(hr))
{
*surface = NULL;
@@ -3414,7 +3510,7 @@ static HRESULT WINAPI ddraw3_CreateSurface(IDirectDraw3 *iface,
impl = (IDirectDrawSurfaceImpl *)surface7;
*surface = (IDirectDrawSurface *)&impl->IDirectDrawSurface3_vtbl;
ddraw_set_surface_version(impl, 3);
- IDirectDraw7_Release((IDirectDraw7 *)ddraw);
+ IDirectDraw7_Release(&This->IDirectDraw7_iface);
IDirectDraw3_AddRef(iface);
impl->ifaceToRelease = (IUnknown *)iface;
@@ -3424,7 +3520,7 @@ static HRESULT WINAPI ddraw3_CreateSurface(IDirectDraw3 *iface,
static HRESULT WINAPI ddraw2_CreateSurface(IDirectDraw2 *iface,
DDSURFACEDESC *surface_desc, IDirectDrawSurface **surface, IUnknown *outer_unknown)
{
- IDirectDrawImpl *ddraw = ddraw_from_ddraw2(iface);
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
IDirectDrawSurface7 *surface7;
IDirectDrawSurfaceImpl *impl;
HRESULT hr;
@@ -3450,7 +3546,7 @@ static HRESULT WINAPI ddraw2_CreateSurface(IDirectDraw2 *iface,
return DDERR_INVALIDCAPS;
}
- hr = CreateSurface((IDirectDraw7 *)ddraw, (DDSURFACEDESC2 *)surface_desc, &surface7, outer_unknown);
+ hr = CreateSurface(This, (DDSURFACEDESC2 *)surface_desc, &surface7, outer_unknown);
if (FAILED(hr))
{
*surface = NULL;
@@ -3460,7 +3556,7 @@ static HRESULT WINAPI ddraw2_CreateSurface(IDirectDraw2 *iface,
impl = (IDirectDrawSurfaceImpl *)surface7;
*surface = (IDirectDrawSurface *)&impl->IDirectDrawSurface3_vtbl;
ddraw_set_surface_version(impl, 2);
- IDirectDraw7_Release((IDirectDraw7 *)ddraw);
+ IDirectDraw7_Release(&This->IDirectDraw7_iface);
impl->ifaceToRelease = NULL;
return hr;
@@ -3469,7 +3565,7 @@ static HRESULT WINAPI ddraw2_CreateSurface(IDirectDraw2 *iface,
static HRESULT WINAPI ddraw1_CreateSurface(IDirectDraw *iface,
DDSURFACEDESC *surface_desc, IDirectDrawSurface **surface, IUnknown *outer_unknown)
{
- IDirectDrawImpl *ddraw = ddraw_from_ddraw1(iface);
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
IDirectDrawSurface7 *surface7;
IDirectDrawSurfaceImpl *impl;
HRESULT hr;
@@ -3486,7 +3582,7 @@ static HRESULT WINAPI ddraw1_CreateSurface(IDirectDraw *iface,
/* Remove front buffer flag, this causes failure in v7, and its added to normal
* primaries anyway. */
surface_desc->ddsCaps.dwCaps &= ~DDSCAPS_FRONTBUFFER;
- hr = CreateSurface((IDirectDraw7 *)ddraw, (DDSURFACEDESC2 *)surface_desc, &surface7, outer_unknown);
+ hr = CreateSurface(This, (DDSURFACEDESC2 *)surface_desc, &surface7, outer_unknown);
if (FAILED(hr))
{
*surface = NULL;
@@ -3496,7 +3592,7 @@ static HRESULT WINAPI ddraw1_CreateSurface(IDirectDraw *iface,
impl = (IDirectDrawSurfaceImpl *)surface7;
*surface = (IDirectDrawSurface *)&impl->IDirectDrawSurface3_vtbl;
ddraw_set_surface_version(impl, 1);
- IDirectDraw7_Release((IDirectDraw7 *)ddraw);
+ IDirectDraw7_Release(&This->IDirectDraw7_iface);
impl->ifaceToRelease = NULL;
return hr;
@@ -3657,7 +3753,7 @@ static HRESULT WINAPI ddraw7_EnumSurfaces(IDirectDraw7 *iface, DWORD Flags,
* because WineDDraw doesn't handle ddraw-like surface
* caps structures
*/
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
IDirectDrawSurfaceImpl *surf;
BOOL all, nomatch;
DDSURFACEDESC2 desc;
@@ -3699,16 +3795,19 @@ static HRESULT WINAPI ddraw7_EnumSurfaces(IDirectDraw7 *iface, DWORD Flags,
static HRESULT WINAPI ddraw4_EnumSurfaces(IDirectDraw4 *iface, DWORD flags,
DDSURFACEDESC2 *surface_desc, void *context, LPDDENUMSURFACESCALLBACK2 callback)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
iface, flags, surface_desc, context, callback);
- return ddraw7_EnumSurfaces((IDirectDraw7 *)ddraw_from_ddraw4(iface),
- flags, surface_desc, context, (LPDDENUMSURFACESCALLBACK7)callback);
+ return ddraw7_EnumSurfaces(&This->IDirectDraw7_iface, flags, surface_desc, context,
+ (LPDDENUMSURFACESCALLBACK7)callback);
}
static HRESULT WINAPI ddraw3_EnumSurfaces(IDirectDraw3 *iface, DWORD flags,
DDSURFACEDESC *surface_desc, void *context, LPDDENUMSURFACESCALLBACK callback)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
struct surfacescallback_context cbcontext;
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
@@ -3717,13 +3816,14 @@ static HRESULT WINAPI ddraw3_EnumSurfaces(IDirectDraw3 *iface, DWORD flags,
cbcontext.func = callback;
cbcontext.context = context;
- return ddraw7_EnumSurfaces((IDirectDraw7 *)ddraw_from_ddraw3(iface), flags,
- (DDSURFACEDESC2 *)surface_desc, &cbcontext, EnumSurfacesCallbackThunk);
+ return ddraw7_EnumSurfaces(&This->IDirectDraw7_iface, flags, (DDSURFACEDESC2 *)surface_desc,
+ &cbcontext, EnumSurfacesCallbackThunk);
}
static HRESULT WINAPI ddraw2_EnumSurfaces(IDirectDraw2 *iface, DWORD flags,
DDSURFACEDESC *surface_desc, void *context, LPDDENUMSURFACESCALLBACK callback)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
struct surfacescallback_context cbcontext;
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
@@ -3732,13 +3832,14 @@ static HRESULT WINAPI ddraw2_EnumSurfaces(IDirectDraw2 *iface, DWORD flags,
cbcontext.func = callback;
cbcontext.context = context;
- return ddraw7_EnumSurfaces((IDirectDraw7 *)ddraw_from_ddraw2(iface), flags,
- (DDSURFACEDESC2 *)surface_desc, &cbcontext, EnumSurfacesCallbackThunk);
+ return ddraw7_EnumSurfaces(&This->IDirectDraw7_iface, flags, (DDSURFACEDESC2 *)surface_desc,
+ &cbcontext, EnumSurfacesCallbackThunk);
}
static HRESULT WINAPI ddraw1_EnumSurfaces(IDirectDraw *iface, DWORD flags,
DDSURFACEDESC *surface_desc, void *context, LPDDENUMSURFACESCALLBACK callback)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
struct surfacescallback_context cbcontext;
TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
@@ -3747,8 +3848,8 @@ static HRESULT WINAPI ddraw1_EnumSurfaces(IDirectDraw *iface, DWORD flags,
cbcontext.func = callback;
cbcontext.context = context;
- return ddraw7_EnumSurfaces((IDirectDraw7 *)ddraw_from_ddraw1(iface), flags,
- (DDSURFACEDESC2 *)surface_desc, &cbcontext, EnumSurfacesCallbackThunk);
+ return ddraw7_EnumSurfaces(&This->IDirectDraw7_iface, flags, (DDSURFACEDESC2 *)surface_desc,
+ &cbcontext, EnumSurfacesCallbackThunk);
}
/*****************************************************************************
@@ -3784,12 +3885,6 @@ DirectDrawCreateClipper(DWORD Flags,
return CLASS_E_NOAGGREGATION;
}
- if (!LoadWineD3D())
- {
- LeaveCriticalSection(&ddraw_cs);
- return DDERR_NODIRECTDRAWSUPPORT;
- }
-
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(IDirectDrawClipperImpl));
if (object == NULL)
@@ -3828,40 +3923,48 @@ static HRESULT WINAPI ddraw7_CreateClipper(IDirectDraw7 *iface, DWORD Flags,
return DirectDrawCreateClipper(Flags, Clipper, UnkOuter);
}
-static HRESULT WINAPI ddraw4_CreateClipper(IDirectDraw4 *iface,
- DWORD flags, IDirectDrawClipper **clipper, IUnknown *outer_unknown)
+static HRESULT WINAPI ddraw4_CreateClipper(IDirectDraw4 *iface, DWORD flags,
+ IDirectDrawClipper **clipper, IUnknown *outer_unknown)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
iface, flags, clipper, outer_unknown);
- return ddraw7_CreateClipper((IDirectDraw7 *)ddraw_from_ddraw4(iface), flags, clipper, outer_unknown);
+ return ddraw7_CreateClipper(&This->IDirectDraw7_iface, flags, clipper, outer_unknown);
}
-static HRESULT WINAPI ddraw3_CreateClipper(IDirectDraw3 *iface,
- DWORD flags, IDirectDrawClipper **clipper, IUnknown *outer_unknown)
+static HRESULT WINAPI ddraw3_CreateClipper(IDirectDraw3 *iface, DWORD flags,
+ IDirectDrawClipper **clipper, IUnknown *outer_unknown)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
+
TRACE("iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
iface, flags, clipper, outer_unknown);
- return ddraw7_CreateClipper((IDirectDraw7 *)ddraw_from_ddraw3(iface), flags, clipper, outer_unknown);
+ return ddraw7_CreateClipper(&This->IDirectDraw7_iface, flags, clipper, outer_unknown);
}
static HRESULT WINAPI ddraw2_CreateClipper(IDirectDraw2 *iface,
DWORD flags, IDirectDrawClipper **clipper, IUnknown *outer_unknown)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
+
TRACE("iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
iface, flags, clipper, outer_unknown);
- return ddraw7_CreateClipper((IDirectDraw7 *)ddraw_from_ddraw2(iface), flags, clipper, outer_unknown);
+ return ddraw7_CreateClipper(&This->IDirectDraw7_iface, flags, clipper, outer_unknown);
}
static HRESULT WINAPI ddraw1_CreateClipper(IDirectDraw *iface,
DWORD flags, IDirectDrawClipper **clipper, IUnknown *outer_unknown)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
+
TRACE("iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
iface, flags, clipper, outer_unknown);
- return ddraw7_CreateClipper((IDirectDraw7 *)ddraw_from_ddraw1(iface), flags, clipper, outer_unknown);
+ return ddraw7_CreateClipper(&This->IDirectDraw7_iface, flags, clipper, outer_unknown);
}
/*****************************************************************************
@@ -3884,7 +3987,7 @@ static HRESULT WINAPI ddraw1_CreateClipper(IDirectDraw *iface,
static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface, DWORD Flags,
PALETTEENTRY *ColorTable, IDirectDrawPalette **Palette, IUnknown *pUnkOuter)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
+ IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
IDirectDrawPaletteImpl *object;
HRESULT hr;
@@ -3930,20 +4033,20 @@ static HRESULT WINAPI ddraw7_CreatePalette(IDirectDraw7 *iface, DWORD Flags,
return DD_OK;
}
-static HRESULT WINAPI ddraw4_CreatePalette(IDirectDraw4 *iface, DWORD flags,
- PALETTEENTRY *entries, IDirectDrawPalette **palette, IUnknown *outer_unknown)
+static HRESULT WINAPI ddraw4_CreatePalette(IDirectDraw4 *iface, DWORD flags, PALETTEENTRY *entries,
+ IDirectDrawPalette **palette, IUnknown *outer_unknown)
{
- IDirectDrawImpl *ddraw = ddraw_from_ddraw4(iface);
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
HRESULT hr;
TRACE("iface %p, flags %#x, entries %p, palette %p, outer_unknown %p.\n",
iface, flags, entries, palette, outer_unknown);
- hr = ddraw7_CreatePalette((IDirectDraw7 *)ddraw, flags, entries, palette, outer_unknown);
+ hr = ddraw7_CreatePalette(&This->IDirectDraw7_iface, flags, entries, palette, outer_unknown);
if (SUCCEEDED(hr) && *palette)
{
IDirectDrawPaletteImpl *impl = (IDirectDrawPaletteImpl *)*palette;
- IDirectDraw7_Release((IDirectDraw7 *)ddraw);
+ IDirectDraw7_Release(&This->IDirectDraw7_iface);
IDirectDraw4_AddRef(iface);
impl->ifaceToRelease = (IUnknown *)iface;
}
@@ -3953,17 +4056,17 @@ static HRESULT WINAPI ddraw4_CreatePalette(IDirectDraw4 *iface, DWORD flags,
static HRESULT WINAPI ddraw3_CreatePalette(IDirectDraw3 *iface, DWORD flags,
PALETTEENTRY *entries, IDirectDrawPalette **palette, IUnknown *outer_unknown)
{
- IDirectDrawImpl *ddraw = ddraw_from_ddraw3(iface);
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
HRESULT hr;
TRACE("iface %p, flags %#x, entries %p, palette %p, outer_unknown %p.\n",
iface, flags, entries, palette, outer_unknown);
- hr = ddraw7_CreatePalette((IDirectDraw7 *)ddraw, flags, entries, palette, outer_unknown);
+ hr = ddraw7_CreatePalette(&This->IDirectDraw7_iface, flags, entries, palette, outer_unknown);
if (SUCCEEDED(hr) && *palette)
{
IDirectDrawPaletteImpl *impl = (IDirectDrawPaletteImpl *)*palette;
- IDirectDraw7_Release((IDirectDraw7 *)ddraw);
+ IDirectDraw7_Release(&This->IDirectDraw7_iface);
IDirectDraw4_AddRef(iface);
impl->ifaceToRelease = (IUnknown *)iface;
}
@@ -3974,17 +4077,17 @@ static HRESULT WINAPI ddraw3_CreatePalette(IDirectDraw3 *iface, DWORD flags,
static HRESULT WINAPI ddraw2_CreatePalette(IDirectDraw2 *iface, DWORD flags,
PALETTEENTRY *entries, IDirectDrawPalette **palette, IUnknown *outer_unknown)
{
- IDirectDrawImpl *ddraw = ddraw_from_ddraw2(iface);
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
HRESULT hr;
TRACE("iface %p, flags %#x, entries %p, palette %p, outer_unknown %p.\n",
iface, flags, entries, palette, outer_unknown);
- hr = ddraw7_CreatePalette((IDirectDraw7 *)ddraw, flags, entries, palette, outer_unknown);
+ hr = ddraw7_CreatePalette(&This->IDirectDraw7_iface, flags, entries, palette, outer_unknown);
if (SUCCEEDED(hr) && *palette)
{
IDirectDrawPaletteImpl *impl = (IDirectDrawPaletteImpl *)*palette;
- IDirectDraw7_Release((IDirectDraw7 *)ddraw);
+ IDirectDraw7_Release(&This->IDirectDraw7_iface);
impl->ifaceToRelease = NULL;
}
@@ -3994,17 +4097,17 @@ static HRESULT WINAPI ddraw2_CreatePalette(IDirectDraw2 *iface, DWORD flags,
static HRESULT WINAPI ddraw1_CreatePalette(IDirectDraw *iface, DWORD flags,
PALETTEENTRY *entries, IDirectDrawPalette **palette, IUnknown *outer_unknown)
{
- IDirectDrawImpl *ddraw = ddraw_from_ddraw1(iface);
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
HRESULT hr;
TRACE("iface %p, flags %#x, entries %p, palette %p, outer_unknown %p.\n",
iface, flags, entries, palette, outer_unknown);
- hr = ddraw7_CreatePalette((IDirectDraw7 *)ddraw, flags, entries, palette, outer_unknown);
+ hr = ddraw7_CreatePalette(&This->IDirectDraw7_iface, flags, entries, palette, outer_unknown);
if (SUCCEEDED(hr) && *palette)
{
IDirectDrawPaletteImpl *impl = (IDirectDrawPaletteImpl *)*palette;
- IDirectDraw7_Release((IDirectDraw7 *)ddraw);
+ IDirectDraw7_Release(&This->IDirectDraw7_iface);
impl->ifaceToRelease = NULL;
}
@@ -4042,24 +4145,27 @@ static HRESULT WINAPI ddraw7_DuplicateSurface(IDirectDraw7 *iface,
NULL);
}
-static HRESULT WINAPI ddraw4_DuplicateSurface(IDirectDraw4 *iface,
- IDirectDrawSurface4 *src, IDirectDrawSurface4 **dst)
+static HRESULT WINAPI ddraw4_DuplicateSurface(IDirectDraw4 *iface, IDirectDrawSurface4 *src,
+ IDirectDrawSurface4 **dst)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw4(iface);
+
TRACE("iface %p, src %p, dst %p.\n", iface, src, dst);
- return ddraw7_DuplicateSurface((IDirectDraw7 *)ddraw_from_ddraw4(iface),
- (IDirectDrawSurface7 *)src, (IDirectDrawSurface7 **)dst);
+ return ddraw7_DuplicateSurface(&This->IDirectDraw7_iface, (IDirectDrawSurface7 *)src,
+ (IDirectDrawSurface7 **)dst);
}
-static HRESULT WINAPI ddraw3_DuplicateSurface(IDirectDraw3 *iface,
- IDirectDrawSurface *src, IDirectDrawSurface **dst)
+static HRESULT WINAPI ddraw3_DuplicateSurface(IDirectDraw3 *iface, IDirectDrawSurface *src,
+ IDirectDrawSurface **dst)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw3(iface);
IDirectDrawSurface7 *src7, *dst7;
HRESULT hr;
TRACE("iface %p, src %p, dst %p.\n", iface, src, dst);
src7 = (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)src);
- hr = ddraw7_DuplicateSurface((IDirectDraw7 *)ddraw_from_ddraw3(iface), src7, &dst7);
+ hr = ddraw7_DuplicateSurface(&This->IDirectDraw7_iface, src7, &dst7);
if (FAILED(hr))
return hr;
*dst = (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)dst7)->IDirectDrawSurface3_vtbl;
@@ -4069,27 +4175,29 @@ static HRESULT WINAPI ddraw3_DuplicateSurface(IDirectDraw3 *iface,
static HRESULT WINAPI ddraw2_DuplicateSurface(IDirectDraw2 *iface,
IDirectDrawSurface *src, IDirectDrawSurface **dst)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw2(iface);
IDirectDrawSurface7 *src7, *dst7;
HRESULT hr;
TRACE("iface %p, src %p, dst %p.\n", iface, src, dst);
src7 = (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)src);
- hr = ddraw7_DuplicateSurface((IDirectDraw7 *)ddraw_from_ddraw2(iface), src7, &dst7);
+ hr = ddraw7_DuplicateSurface(&This->IDirectDraw7_iface, src7, &dst7);
if (FAILED(hr))
return hr;
*dst = (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)dst7)->IDirectDrawSurface3_vtbl;
return hr;
}
-static HRESULT WINAPI ddraw1_DuplicateSurface(IDirectDraw *iface,
- IDirectDrawSurface *src, IDirectDrawSurface **dst)
+static HRESULT WINAPI ddraw1_DuplicateSurface(IDirectDraw *iface, IDirectDrawSurface *src,
+ IDirectDrawSurface **dst)
{
+ IDirectDrawImpl *This = impl_from_IDirectDraw(iface);
IDirectDrawSurface7 *src7, *dst7;
HRESULT hr;
TRACE("iface %p, src %p, dst %p.\n", iface, src, dst);
src7 = (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)src);
- hr = ddraw7_DuplicateSurface((IDirectDraw7 *)ddraw_from_ddraw1(iface), src7, &dst7);
+ hr = ddraw7_DuplicateSurface(&This->IDirectDraw7_iface, src7, &dst7);
if (FAILED(hr))
return hr;
*dst = (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)dst7)->IDirectDrawSurface3_vtbl;
@@ -4119,7 +4227,7 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBA
char interface_name_rgb[] = "WINE Direct3D7 RGB Software Emulation using WineD3D";
char device_name_rgb[] = "Wine D3D7 RGB";
- IDirectDrawImpl *ddraw = ddraw_from_d3d7(iface);
+ IDirectDrawImpl *This = impl_from_IDirect3D7(iface);
D3DDEVICEDESC7 device_desc7;
D3DDEVICEDESC device_desc1;
HRESULT hr;
@@ -4128,7 +4236,7 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBA
EnterCriticalSection(&ddraw_cs);
- hr = IDirect3DImpl_GetCaps(ddraw->wineD3D, &device_desc1, &device_desc7);
+ hr = IDirect3DImpl_GetCaps(This->wineD3D, &device_desc1, &device_desc7);
if (hr != D3D_OK)
{
LeaveCriticalSection(&ddraw_cs);
@@ -4170,7 +4278,7 @@ static HRESULT WINAPI d3d3_EnumDevices(IDirect3D3 *iface, LPD3DENUMDEVICESCALLBA
{
static CHAR wined3d_description[] = "Wine D3DDevice using WineD3D and OpenGL";
- IDirectDrawImpl *ddraw = ddraw_from_d3d3(iface);
+ IDirectDrawImpl *This = impl_from_IDirect3D3(iface);
D3DDEVICEDESC device_desc1, hal_desc, hel_desc;
D3DDEVICEDESC7 device_desc7;
HRESULT hr;
@@ -4185,7 +4293,7 @@ static HRESULT WINAPI d3d3_EnumDevices(IDirect3D3 *iface, LPD3DENUMDEVICESCALLBA
EnterCriticalSection(&ddraw_cs);
- hr = IDirect3DImpl_GetCaps(ddraw->wineD3D, &device_desc1, &device_desc7);
+ hr = IDirect3DImpl_GetCaps(This->wineD3D, &device_desc1, &device_desc7);
if (hr != D3D_OK)
{
LeaveCriticalSection(&ddraw_cs);
@@ -4211,7 +4319,7 @@ static HRESULT WINAPI d3d3_EnumDevices(IDirect3D3 *iface, LPD3DENUMDEVICESCALLBA
* limitation flag), and it refuses all devices that have the perspective
* flag set. This way it refuses the emulation device, and HAL devices
* never have POW2 unset in d3d7 on windows. */
- if (ddraw->d3dversion != 1)
+ if (This->d3dversion != 1)
{
static CHAR reference_description[] = "RGB Direct3D emulation";
@@ -4260,16 +4368,20 @@ static HRESULT WINAPI d3d3_EnumDevices(IDirect3D3 *iface, LPD3DENUMDEVICESCALLBA
static HRESULT WINAPI d3d2_EnumDevices(IDirect3D2 *iface, LPD3DENUMDEVICESCALLBACK callback, void *context)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D2(iface);
+
TRACE("iface %p, callback %p, context %p.\n", iface, callback, context);
- return d3d3_EnumDevices((IDirect3D3 *)&ddraw_from_d3d2(iface)->IDirect3D3_vtbl, callback, context);
+ return d3d3_EnumDevices(&This->IDirect3D3_iface, callback, context);
}
static HRESULT WINAPI d3d1_EnumDevices(IDirect3D *iface, LPD3DENUMDEVICESCALLBACK callback, void *context)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D(iface);
+
TRACE("iface %p, callback %p, context %p.\n", iface, callback, context);
- return d3d3_EnumDevices((IDirect3D3 *)&ddraw_from_d3d1(iface)->IDirect3D3_vtbl, callback, context);
+ return d3d3_EnumDevices(&This->IDirect3D3_iface, callback, context);
}
/*****************************************************************************
@@ -4293,8 +4405,10 @@ static HRESULT WINAPI d3d1_EnumDevices(IDirect3D *iface, LPD3DENUMDEVICESCALLBAC
* CLASS_E_NOAGGREGATION if outer_unknown != NULL
*
*****************************************************************************/
-static HRESULT WINAPI d3d3_CreateLight(IDirect3D3 *iface, IDirect3DLight **light, IUnknown *outer_unknown)
+static HRESULT WINAPI d3d3_CreateLight(IDirect3D3 *iface, IDirect3DLight **light,
+ IUnknown *outer_unknown)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D3(iface);
IDirect3DLightImpl *object;
TRACE("iface %p, light %p, outer_unknown %p.\n", iface, light, outer_unknown);
@@ -4308,7 +4422,7 @@ static HRESULT WINAPI d3d3_CreateLight(IDirect3D3 *iface, IDirect3DLight **light
return DDERR_OUTOFMEMORY;
}
- d3d_light_init(object, ddraw_from_d3d3(iface));
+ d3d_light_init(object, This);
TRACE("Created light %p.\n", object);
*light = (IDirect3DLight *)object;
@@ -4318,16 +4432,20 @@ static HRESULT WINAPI d3d3_CreateLight(IDirect3D3 *iface, IDirect3DLight **light
static HRESULT WINAPI d3d2_CreateLight(IDirect3D2 *iface, IDirect3DLight **light, IUnknown *outer_unknown)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D2(iface);
+
TRACE("iface %p, light %p, outer_unknown %p.\n", iface, light, outer_unknown);
- return d3d3_CreateLight((IDirect3D3 *)&ddraw_from_d3d2(iface)->IDirect3D3_vtbl, light, outer_unknown);
+ return d3d3_CreateLight(&This->IDirect3D3_iface, light, outer_unknown);
}
static HRESULT WINAPI d3d1_CreateLight(IDirect3D *iface, IDirect3DLight **light, IUnknown *outer_unknown)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D(iface);
+
TRACE("iface %p, light %p, outer_unknown %p.\n", iface, light, outer_unknown);
- return d3d3_CreateLight((IDirect3D3 *)&ddraw_from_d3d1(iface)->IDirect3D3_vtbl, light, outer_unknown);
+ return d3d3_CreateLight(&This->IDirect3D3_iface, light, outer_unknown);
}
/*****************************************************************************
@@ -4350,8 +4468,10 @@ static HRESULT WINAPI d3d1_CreateLight(IDirect3D *iface, IDirect3DLight **light,
* CLASS_E_NOAGGREGATION if outer_unknown != NULL
*
*****************************************************************************/
-static HRESULT WINAPI d3d3_CreateMaterial(IDirect3D3 *iface, IDirect3DMaterial3 **material, IUnknown *outer_unknown)
+static HRESULT WINAPI d3d3_CreateMaterial(IDirect3D3 *iface, IDirect3DMaterial3 **material,
+ IUnknown *outer_unknown)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D3(iface);
IDirect3DMaterialImpl *object;
TRACE("iface %p, material %p, outer_unknown %p.\n", iface, material, outer_unknown);
@@ -4365,7 +4485,7 @@ static HRESULT WINAPI d3d3_CreateMaterial(IDirect3D3 *iface, IDirect3DMaterial3
return DDERR_OUTOFMEMORY;
}
- d3d_material_init(object, ddraw_from_d3d3(iface));
+ d3d_material_init(object, This);
TRACE("Created material %p.\n", object);
*material = (IDirect3DMaterial3 *)object;
@@ -4375,12 +4495,13 @@ static HRESULT WINAPI d3d3_CreateMaterial(IDirect3D3 *iface, IDirect3DMaterial3
static HRESULT WINAPI d3d2_CreateMaterial(IDirect3D2 *iface, IDirect3DMaterial2 **material, IUnknown *outer_unknown)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D2(iface);
IDirect3DMaterial3 *material3;
HRESULT hr;
TRACE("iface %p, material %p, outer_unknown %p.\n", iface, material, outer_unknown);
- hr = d3d3_CreateMaterial((IDirect3D3 *)&ddraw_from_d3d2(iface)->IDirect3D3_vtbl, &material3, outer_unknown);
+ hr = d3d3_CreateMaterial(&This->IDirect3D3_iface, &material3, outer_unknown);
*material = material3 ? (IDirect3DMaterial2 *)&((IDirect3DMaterialImpl *)material3)->IDirect3DMaterial2_vtbl : NULL;
TRACE("Returning material %p.\n", *material);
@@ -4393,9 +4514,11 @@ static HRESULT WINAPI d3d1_CreateMaterial(IDirect3D *iface, IDirect3DMaterial **
IDirect3DMaterial3 *material3;
HRESULT hr;
+ IDirectDrawImpl *This = impl_from_IDirect3D(iface);
+
TRACE("iface %p, material %p, outer_unknown %p.\n", iface, material, outer_unknown);
- hr = d3d3_CreateMaterial((IDirect3D3 *)&ddraw_from_d3d1(iface)->IDirect3D3_vtbl, &material3, outer_unknown);
+ hr = d3d3_CreateMaterial(&This->IDirect3D3_iface, &material3, outer_unknown);
*material = material3 ? (IDirect3DMaterial *)&((IDirect3DMaterialImpl *)material3)->IDirect3DMaterial_vtbl : NULL;
TRACE("Returning material %p.\n", *material);
@@ -4423,8 +4546,10 @@ static HRESULT WINAPI d3d1_CreateMaterial(IDirect3D *iface, IDirect3DMaterial **
* CLASS_E_NOAGGREGATION if outer_unknown != NULL
*
*****************************************************************************/
-static HRESULT WINAPI d3d3_CreateViewport(IDirect3D3 *iface, IDirect3DViewport3 **viewport, IUnknown *outer_unknown)
+static HRESULT WINAPI d3d3_CreateViewport(IDirect3D3 *iface, IDirect3DViewport3 **viewport,
+ IUnknown *outer_unknown)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D3(iface);
IDirect3DViewportImpl *object;
TRACE("iface %p, viewport %p, outer_unknown %p.\n", iface, viewport, outer_unknown);
@@ -4438,7 +4563,7 @@ static HRESULT WINAPI d3d3_CreateViewport(IDirect3D3 *iface, IDirect3DViewport3
return DDERR_OUTOFMEMORY;
}
- d3d_viewport_init(object, ddraw_from_d3d3(iface));
+ d3d_viewport_init(object, This);
TRACE("Created viewport %p.\n", object);
*viewport = (IDirect3DViewport3 *)object;
@@ -4448,18 +4573,22 @@ static HRESULT WINAPI d3d3_CreateViewport(IDirect3D3 *iface, IDirect3DViewport3
static HRESULT WINAPI d3d2_CreateViewport(IDirect3D2 *iface, IDirect3DViewport2 **viewport, IUnknown *outer_unknown)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D2(iface);
+
TRACE("iface %p, viewport %p, outer_unknown %p.\n", iface, viewport, outer_unknown);
- return d3d3_CreateViewport((IDirect3D3 *)&ddraw_from_d3d2(iface)->IDirect3D3_vtbl,
- (IDirect3DViewport3 **)viewport, outer_unknown);
+ return d3d3_CreateViewport(&This->IDirect3D3_iface, (IDirect3DViewport3 **)viewport,
+ outer_unknown);
}
static HRESULT WINAPI d3d1_CreateViewport(IDirect3D *iface, IDirect3DViewport **viewport, IUnknown *outer_unknown)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D(iface);
+
TRACE("iface %p, viewport %p, outer_unknown %p.\n", iface, viewport, outer_unknown);
- return d3d3_CreateViewport((IDirect3D3 *)&ddraw_from_d3d1(iface)->IDirect3D3_vtbl,
- (IDirect3DViewport3 **)viewport, outer_unknown);
+ return d3d3_CreateViewport(&This->IDirect3D3_iface, (IDirect3DViewport3 **)viewport,
+ outer_unknown);
}
/*****************************************************************************
@@ -4480,7 +4609,7 @@ static HRESULT WINAPI d3d1_CreateViewport(IDirect3D *iface, IDirect3DViewport **
*****************************************************************************/
static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fds, D3DFINDDEVICERESULT *fdr)
{
- IDirectDrawImpl *ddraw = ddraw_from_d3d3(iface);
+ IDirectDrawImpl *This = impl_from_IDirect3D3(iface);
D3DDEVICEDESC7 desc7;
D3DDEVICEDESC desc1;
HRESULT hr;
@@ -4513,7 +4642,7 @@ static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fd
}
/* Get the caps */
- hr = IDirect3DImpl_GetCaps(ddraw->wineD3D, &desc1, &desc7);
+ hr = IDirect3DImpl_GetCaps(This->wineD3D, &desc1, &desc7);
if (hr != D3D_OK) return hr;
/* Now return our own GUID */
@@ -4528,16 +4657,20 @@ static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fd
static HRESULT WINAPI d3d2_FindDevice(IDirect3D2 *iface, D3DFINDDEVICESEARCH *fds, D3DFINDDEVICERESULT *fdr)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D2(iface);
+
TRACE("iface %p, fds %p, fdr %p.\n", iface, fds, fdr);
- return d3d3_FindDevice((IDirect3D3 *)&ddraw_from_d3d2(iface)->IDirect3D3_vtbl, fds, fdr);
+ return d3d3_FindDevice(&This->IDirect3D3_iface, fds, fdr);
}
static HRESULT WINAPI d3d1_FindDevice(IDirect3D *iface, D3DFINDDEVICESEARCH *fds, D3DFINDDEVICERESULT *fdr)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D(iface);
+
TRACE("iface %p, fds %p, fdr %p.\n", iface, fds, fdr);
- return d3d3_FindDevice((IDirect3D3 *)&ddraw_from_d3d1(iface)->IDirect3D3_vtbl, fds, fdr);
+ return d3d3_FindDevice(&This->IDirect3D3_iface, fds, fdr);
}
/*****************************************************************************
@@ -4565,7 +4698,7 @@ static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid,
IDirectDrawSurface7 *surface, IDirect3DDevice7 **device)
{
IDirectDrawSurfaceImpl *target = (IDirectDrawSurfaceImpl *)surface;
- IDirectDrawImpl *ddraw = ddraw_from_d3d7(iface);
+ IDirectDrawImpl *This = impl_from_IDirect3D7(iface);
IDirect3DDeviceImpl *object;
HRESULT hr;
@@ -4575,7 +4708,7 @@ static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid,
*device = NULL;
/* Fail device creation if non-opengl surfaces are used. */
- if (ddraw->ImplType != SURFACE_OPENGL)
+ if (This->ImplType != SURFACE_OPENGL)
{
ERR("The application wants to create a Direct3D device, but non-opengl surfaces are set in the registry.\n");
ERR("Please set the surface implementation to opengl or autodetection to allow 3D rendering.\n");
@@ -4586,7 +4719,7 @@ static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid,
return DDERR_NO3D;
}
- if (ddraw->d3ddevice)
+ if (This->d3ddevice)
{
FIXME("Only one Direct3D device per DirectDraw object supported.\n");
LeaveCriticalSection(&ddraw_cs);
@@ -4601,7 +4734,7 @@ static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid,
return DDERR_OUTOFMEMORY;
}
- hr = d3d_device_init(object, ddraw, target);
+ hr = d3d_device_init(object, This, target);
if (FAILED(hr))
{
WARN("Failed to initialize device, hr %#x.\n", hr);
@@ -4620,6 +4753,7 @@ static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid,
static HRESULT WINAPI d3d3_CreateDevice(IDirect3D3 *iface, REFCLSID riid,
IDirectDrawSurface4 *surface, IDirect3DDevice3 **device, IUnknown *outer_unknown)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D3(iface);
HRESULT hr;
TRACE("iface %p, riid %s, surface %p, device %p, outer_unknown %p.\n",
@@ -4627,8 +4761,8 @@ static HRESULT WINAPI d3d3_CreateDevice(IDirect3D3 *iface, REFCLSID riid,
if (outer_unknown) return CLASS_E_NOAGGREGATION;
- hr = d3d7_CreateDevice((IDirect3D7 *)&ddraw_from_d3d3(iface)->IDirect3D7_vtbl, riid,
- (IDirectDrawSurface7 *)surface, (IDirect3DDevice7 **)device);
+ hr = d3d7_CreateDevice(&This->IDirect3D7_iface, riid, (IDirectDrawSurface7 *)surface,
+ (IDirect3DDevice7 **)device);
if (*device) *device = (IDirect3DDevice3 *)&((IDirect3DDeviceImpl *)*device)->IDirect3DDevice3_vtbl;
return hr;
@@ -4637,12 +4771,13 @@ static HRESULT WINAPI d3d3_CreateDevice(IDirect3D3 *iface, REFCLSID riid,
static HRESULT WINAPI d3d2_CreateDevice(IDirect3D2 *iface, REFCLSID riid,
IDirectDrawSurface *surface, IDirect3DDevice2 **device)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D2(iface);
HRESULT hr;
TRACE("iface %p, riid %s, surface %p, device %p.\n",
iface, debugstr_guid(riid), surface, device);
- hr = d3d7_CreateDevice((IDirect3D7 *)&ddraw_from_d3d2(iface)->IDirect3D7_vtbl, riid,
+ hr = d3d7_CreateDevice(&This->IDirect3D7_iface, riid,
surface ? (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)surface) : NULL,
(IDirect3DDevice7 **)device);
if (*device) *device = (IDirect3DDevice2 *)&((IDirect3DDeviceImpl *)*device)->IDirect3DDevice2_vtbl;
@@ -4673,6 +4808,7 @@ static HRESULT WINAPI d3d2_CreateDevice(IDirect3D2 *iface, REFCLSID riid,
static HRESULT WINAPI d3d7_CreateVertexBuffer(IDirect3D7 *iface, D3DVERTEXBUFFERDESC *desc,
IDirect3DVertexBuffer7 **vertex_buffer, DWORD flags)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D7(iface);
IDirect3DVertexBufferImpl *object;
HRESULT hr;
@@ -4695,7 +4831,7 @@ static HRESULT WINAPI d3d7_CreateVertexBuffer(IDirect3D7 *iface, D3DVERTEXBUFFER
return DDERR_OUTOFMEMORY;
}
- hr = d3d_vertex_buffer_init(object, ddraw_from_d3d7(iface), desc);
+ hr = d3d_vertex_buffer_init(object, This, desc);
if (FAILED(hr))
{
WARN("Failed to initialize vertex buffer, hr %#x.\n", hr);
@@ -4712,7 +4848,7 @@ static HRESULT WINAPI d3d7_CreateVertexBuffer(IDirect3D7 *iface, D3DVERTEXBUFFER
static HRESULT WINAPI d3d3_CreateVertexBuffer(IDirect3D3 *iface, D3DVERTEXBUFFERDESC *desc,
IDirect3DVertexBuffer **vertex_buffer, DWORD flags, IUnknown *outer_unknown)
{
- IDirectDrawImpl *This = ddraw_from_d3d3(iface);
+ IDirectDrawImpl *This = impl_from_IDirect3D3(iface);
HRESULT hr;
TRACE("iface %p, desc %p, vertex_buffer %p, flags %#x, outer_unknown %p.\n",
@@ -4720,8 +4856,8 @@ static HRESULT WINAPI d3d3_CreateVertexBuffer(IDirect3D3 *iface, D3DVERTEXBUFFER
if (outer_unknown) return CLASS_E_NOAGGREGATION;
- hr = d3d7_CreateVertexBuffer((IDirect3D7 *)&This->IDirect3D7_vtbl,
- desc, (IDirect3DVertexBuffer7 **)vertex_buffer, flags);
+ hr = d3d7_CreateVertexBuffer(&This->IDirect3D7_iface, desc,
+ (IDirect3DVertexBuffer7 **)vertex_buffer, flags);
if (*vertex_buffer)
*vertex_buffer = (IDirect3DVertexBuffer *)&((IDirect3DVertexBufferImpl *)*vertex_buffer)->IDirect3DVertexBuffer_vtbl;
@@ -4749,7 +4885,7 @@ static HRESULT WINAPI d3d3_CreateVertexBuffer(IDirect3D3 *iface, D3DVERTEXBUFFER
static HRESULT WINAPI d3d7_EnumZBufferFormats(IDirect3D7 *iface, REFCLSID device_iid,
LPD3DENUMPIXELFORMATSCALLBACK callback, void *context)
{
- IDirectDrawImpl *ddraw = ddraw_from_d3d7(iface);
+ IDirectDrawImpl *This = impl_from_IDirect3D7(iface);
WINED3DDISPLAYMODE d3ddm;
WINED3DDEVTYPE type;
unsigned int i;
@@ -4808,11 +4944,11 @@ static HRESULT WINAPI d3d7_EnumZBufferFormats(IDirect3D7 *iface, REFCLSID device
* not like that we'll have to find some workaround, like iterating over
* all imaginable formats and collecting all the depth stencil formats we
* can get. */
- hr = IWineD3DDevice_GetDisplayMode(ddraw->wineD3DDevice, 0, &d3ddm);
+ hr = wined3d_device_get_display_mode(This->wined3d_device, 0, &d3ddm);
for (i = 0; i < (sizeof(formats) / sizeof(*formats)); ++i)
{
- hr = IWineD3D_CheckDeviceFormat(ddraw->wineD3D, WINED3DADAPTER_DEFAULT, type, d3ddm.Format,
+ hr = wined3d_check_device_format(This->wineD3D, WINED3DADAPTER_DEFAULT, type, d3ddm.Format,
WINED3DUSAGE_DEPTHSTENCIL, WINED3DRTYPE_SURFACE, formats[i], SURFACE_OPENGL);
if (SUCCEEDED(hr))
{
@@ -4841,11 +4977,12 @@ static HRESULT WINAPI d3d7_EnumZBufferFormats(IDirect3D7 *iface, REFCLSID device
static HRESULT WINAPI d3d3_EnumZBufferFormats(IDirect3D3 *iface, REFCLSID device_iid,
LPD3DENUMPIXELFORMATSCALLBACK callback, void *context)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D3(iface);
+
TRACE("iface %p, device_iid %s, callback %p, context %p.\n",
iface, debugstr_guid(device_iid), callback, context);
- return d3d7_EnumZBufferFormats((IDirect3D7 *)&ddraw_from_d3d3(iface)->IDirect3D7_vtbl,
- device_iid, callback, context);
+ return d3d7_EnumZBufferFormats(&This->IDirect3D7_iface, device_iid, callback, context);
}
/*****************************************************************************
@@ -4872,9 +5009,11 @@ static HRESULT WINAPI d3d7_EvictManagedTextures(IDirect3D7 *iface)
static HRESULT WINAPI d3d3_EvictManagedTextures(IDirect3D3 *iface)
{
+ IDirectDrawImpl *This = impl_from_IDirect3D3(iface);
+
TRACE("iface %p.\n", iface);
- return d3d7_EvictManagedTextures((IDirect3D7 *)&ddraw_from_d3d3(iface)->IDirect3D7_vtbl);
+ return d3d7_EvictManagedTextures(&This->IDirect3D7_iface);
}
/*****************************************************************************
@@ -4893,7 +5032,7 @@ static HRESULT WINAPI d3d3_EvictManagedTextures(IDirect3D3 *iface)
* D3D_OK on success, or the return value of IWineD3D::GetCaps
*
*****************************************************************************/
-HRESULT IDirect3DImpl_GetCaps(IWineD3D *wined3d, D3DDEVICEDESC *desc1, D3DDEVICEDESC7 *desc7)
+HRESULT IDirect3DImpl_GetCaps(const struct wined3d *wined3d, D3DDEVICEDESC *desc1, D3DDEVICEDESC7 *desc7)
{
WINED3DCAPS wined3d_caps;
HRESULT hr;
@@ -4903,7 +5042,7 @@ HRESULT IDirect3DImpl_GetCaps(IWineD3D *wined3d, D3DDEVICEDESC *desc1, D3DDEVICE
memset(&wined3d_caps, 0, sizeof(wined3d_caps));
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3D_GetDeviceCaps(wined3d, 0, WINED3DDEVTYPE_HAL, &wined3d_caps);
+ hr = wined3d_get_device_caps(wined3d, 0, WINED3DDEVTYPE_HAL, &wined3d_caps);
LeaveCriticalSection(&ddraw_cs);
if (FAILED(hr))
{
@@ -5428,14 +5567,13 @@ static const struct IDirect3DVtbl d3d1_vtbl =
* fvf: Fvf to find the decl for
*
* Returns:
- * NULL in case of an error, the IWineD3DVertexDeclaration interface for the
- * fvf otherwise.
+ * NULL in case of an error, the vertex declaration for the FVF otherwise.
*
*****************************************************************************/
-IWineD3DVertexDeclaration *ddraw_find_decl(IDirectDrawImpl *This, DWORD fvf)
+struct wined3d_vertex_declaration *ddraw_find_decl(IDirectDrawImpl *This, DWORD fvf)
{
+ struct wined3d_vertex_declaration *pDecl = NULL;
HRESULT hr;
- IWineD3DVertexDeclaration* pDecl = NULL;
int p, low, high; /* deliberately signed */
struct FvfToDecl *convertedDecls = This->decls;
@@ -5457,7 +5595,7 @@ IWineD3DVertexDeclaration *ddraw_find_decl(IDirectDrawImpl *This, DWORD fvf)
}
TRACE("not found. Creating and inserting at position %d.\n", low);
- hr = IWineD3DDevice_CreateVertexDeclarationFromFVF(This->wineD3DDevice,
+ hr = wined3d_vertex_declaration_create_from_fvf(This->wined3d_device,
fvf, This, &ddraw_null_wined3d_parent_ops, &pDecl);
if (hr != S_OK) return NULL;
@@ -5465,9 +5603,9 @@ IWineD3DVertexDeclaration *ddraw_find_decl(IDirectDrawImpl *This, DWORD fvf)
int grow = max(This->declArraySize / 2, 8);
convertedDecls = HeapReAlloc(GetProcessHeap(), 0, convertedDecls,
sizeof(convertedDecls[0]) * (This->numConvertedDecls + grow));
- if(!convertedDecls) {
- /* This will destroy it */
- IWineD3DVertexDeclaration_Release(pDecl);
+ if (!convertedDecls)
+ {
+ wined3d_vertex_declaration_decref(pDecl);
return NULL;
}
This->decls = convertedDecls;
@@ -5483,50 +5621,29 @@ IWineD3DVertexDeclaration *ddraw_find_decl(IDirectDrawImpl *This, DWORD fvf)
return pDecl;
}
-/* IWineD3DDeviceParent IUnknown methods */
-
-static inline struct IDirectDrawImpl *ddraw_from_device_parent(IWineD3DDeviceParent *iface)
+static inline struct IDirectDrawImpl *ddraw_from_device_parent(struct wined3d_device_parent *device_parent)
{
- return (struct IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(struct IDirectDrawImpl, device_parent_vtbl));
+ return CONTAINING_RECORD(device_parent, struct IDirectDrawImpl, device_parent);
}
-static HRESULT STDMETHODCALLTYPE device_parent_QueryInterface(IWineD3DDeviceParent *iface, REFIID riid, void **object)
+static void CDECL device_parent_wined3d_device_created(struct wined3d_device_parent *device_parent,
+ struct wined3d_device *device)
{
- struct IDirectDrawImpl *This = ddraw_from_device_parent(iface);
- return ddraw7_QueryInterface((IDirectDraw7 *)This, riid, object);
+ TRACE("device_parent %p, device %p.\n", device_parent, device);
}
-static ULONG STDMETHODCALLTYPE device_parent_AddRef(IWineD3DDeviceParent *iface)
+static HRESULT CDECL device_parent_create_surface(struct wined3d_device_parent *device_parent,
+ void *container_parent, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
+ WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, struct wined3d_surface **surface)
{
- struct IDirectDrawImpl *This = ddraw_from_device_parent(iface);
- return ddraw7_AddRef((IDirectDraw7 *)This);
-}
-
-static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface)
-{
- struct IDirectDrawImpl *This = ddraw_from_device_parent(iface);
- return ddraw7_Release((IDirectDraw7 *)This);
-}
-
-/* IWineD3DDeviceParent methods */
-
-static void STDMETHODCALLTYPE device_parent_WineD3DDeviceCreated(IWineD3DDeviceParent *iface, IWineD3DDevice *device)
-{
- TRACE("iface %p, device %p\n", iface, device);
-}
-
-static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
- WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
-{
- struct IDirectDrawImpl *This = ddraw_from_device_parent(iface);
+ struct IDirectDrawImpl *ddraw = ddraw_from_device_parent(device_parent);
IDirectDrawSurfaceImpl *surf = NULL;
UINT i = 0;
- DDSCAPS2 searchcaps = This->tex_root->surface_desc.ddsCaps;
+ DDSCAPS2 searchcaps = ddraw->tex_root->surface_desc.ddsCaps;
- TRACE("iface %p, superior %p, width %u, height %u, format %#x, usage %#x,\n"
- "\tpool %#x, level %u, face %u, surface %p\n",
- iface, superior, width, height, format, usage, pool, level, face, surface);
+ TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n"
+ "\tpool %#x, level %u, face %u, surface %p.\n",
+ device_parent, container_parent, width, height, format, usage, pool, level, face, surface);
searchcaps.dwCaps2 &= ~DDSCAPS2_CUBEMAP_ALLFACES;
switch(face)
@@ -5537,7 +5654,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParen
{
searchcaps.dwCaps2 |= DDSCAPS2_CUBEMAP_POSITIVEX;
}
- surf = This->tex_root; break;
+ surf = ddraw->tex_root; break;
case WINED3DCUBEMAP_FACE_NEGATIVE_X:
TRACE("Asked for negative x\n");
searchcaps.dwCaps2 |= DDSCAPS2_CUBEMAP_NEGATIVEX; break;
@@ -5559,7 +5676,7 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParen
if (!surf)
{
IDirectDrawSurface7 *attached;
- IDirectDrawSurface7_GetAttachedSurface((IDirectDrawSurface7 *)This->tex_root, &searchcaps, &attached);
+ IDirectDrawSurface7_GetAttachedSurface((IDirectDrawSurface7 *)ddraw->tex_root, &searchcaps, &attached);
surf = (IDirectDrawSurfaceImpl *)attached;
IDirectDrawSurface7_Release(attached);
}
@@ -5577,8 +5694,8 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParen
}
/* Return the surface */
- *surface = surf->WineD3DSurface;
- IWineD3DSurface_AddRef(*surface);
+ *surface = surf->wined3d_surface;
+ wined3d_surface_incref(*surface);
TRACE("Returning wineD3DSurface %p, it belongs to surface %p\n", *surface, surf);
@@ -5606,18 +5723,19 @@ static HRESULT WINAPI findRenderTarget(IDirectDrawSurface7 *surface, DDSURFACEDE
return DDENUMRET_OK;
}
-static HRESULT STDMETHODCALLTYPE device_parent_CreateRenderTarget(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, enum wined3d_format_id format,
+static HRESULT CDECL device_parent_create_rendertarget(struct wined3d_device_parent *device_parent,
+ void *container_parent, UINT width, UINT height, enum wined3d_format_id format,
WINED3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality, BOOL lockable,
- IWineD3DSurface **surface)
+ struct wined3d_surface **surface)
{
- struct IDirectDrawImpl *This = ddraw_from_device_parent(iface);
- IDirectDrawSurfaceImpl *d3d_surface = This->d3d_target;
+ struct IDirectDrawImpl *ddraw = ddraw_from_device_parent(device_parent);
+ IDirectDrawSurfaceImpl *d3d_surface = ddraw->d3d_target;
IDirectDrawSurfaceImpl *target = NULL;
- TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
- "\tmultisample_quality %u, lockable %u, surface %p\n",
- iface, superior, width, height, format, multisample_type, multisample_quality, lockable, surface);
+ TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, multisample_type %#x,\n"
+ "\tmultisample_quality %u, lockable %u, surface %p.\n",
+ device_parent, container_parent, width, height, format, multisample_type,
+ multisample_quality, lockable, surface);
if (d3d_surface->isRenderTarget)
{
@@ -5630,14 +5748,14 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateRenderTarget(IWineD3DDevice
if (!target)
{
- target = This->d3d_target;
- ERR(" (%p) : No DirectDrawSurface found to create the back buffer. Using the front buffer as back buffer. Uncertain consequences\n", This);
+ target = ddraw->d3d_target;
+ ERR(" (%p) : No DirectDrawSurface found to create the back buffer. Using the front buffer as back buffer. Uncertain consequences\n", ddraw);
}
/* TODO: Return failure if the dimensions do not match, but this shouldn't happen */
- *surface = target->WineD3DSurface;
- IWineD3DSurface_AddRef(*surface);
+ *surface = target->wined3d_surface;
+ wined3d_surface_incref(*surface);
target->isRenderTarget = TRUE;
TRACE("Returning wineD3DSurface %p, it belongs to surface %p\n", *surface, d3d_surface);
@@ -5645,18 +5763,18 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateRenderTarget(IWineD3DDevice
return D3D_OK;
}
-static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent *iface,
+static HRESULT CDECL device_parent_create_depth_stencil(struct wined3d_device_parent *device_parent,
UINT width, UINT height, enum wined3d_format_id format, WINED3DMULTISAMPLE_TYPE multisample_type,
- DWORD multisample_quality, BOOL discard, IWineD3DSurface **surface)
+ DWORD multisample_quality, BOOL discard, struct wined3d_surface **surface)
{
- struct IDirectDrawImpl *This = ddraw_from_device_parent(iface);
+ struct IDirectDrawImpl *ddraw = ddraw_from_device_parent(device_parent);
IDirectDrawSurfaceImpl *ddraw_surface;
DDSURFACEDESC2 ddsd;
HRESULT hr;
- TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x,\n"
- "\tmultisample_quality %u, discard %u, surface %p\n",
- iface, width, height, format, multisample_type, multisample_quality, discard, surface);
+ TRACE("device_parent %p, width %u, height %u, format %#x, multisample_type %#x,\n"
+ "\tmultisample_quality %u, discard %u, surface %p.\n",
+ device_parent, width, height, format, multisample_type, multisample_quality, discard, surface);
*surface = NULL;
@@ -5677,89 +5795,74 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3
ddsd.dwFlags ^= DDSD_PIXELFORMAT;
}
- This->depthstencil = TRUE;
- hr = IDirectDraw7_CreateSurface((IDirectDraw7 *)This, &ddsd, (IDirectDrawSurface7 **)&ddraw_surface, NULL);
- This->depthstencil = FALSE;
- if(FAILED(hr))
+ ddraw->depthstencil = TRUE;
+ hr = IDirectDraw7_CreateSurface(&ddraw->IDirectDraw7_iface, &ddsd,
+ (IDirectDrawSurface7 **)&ddraw_surface, NULL);
+ ddraw->depthstencil = FALSE;
+ if (FAILED(hr))
{
- ERR(" (%p) Creating a DepthStencil Surface failed, result = %x\n", This, hr);
+ WARN("Failed to create depth/stencil surface, hr %#x.\n", hr);
return hr;
}
- *surface = ddraw_surface->WineD3DSurface;
- IWineD3DSurface_AddRef(*surface);
+ *surface = ddraw_surface->wined3d_surface;
+ wined3d_surface_incref(*surface);
IDirectDrawSurface7_Release((IDirectDrawSurface7 *)ddraw_surface);
return D3D_OK;
}
-static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
- WINED3DPOOL pool, DWORD usage, IWineD3DVolume **volume)
+static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *device_parent,
+ void *container_parent, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
+ WINED3DPOOL pool, DWORD usage, struct wined3d_volume **volume)
{
- TRACE("iface %p, superior %p, width %u, height %u, depth %u, format %#x, pool %#x, usage %#x, volume %p\n",
- iface, superior, width, height, depth, format, pool, usage, volume);
+ TRACE("device_parent %p, container_parent %p, width %u, height %u, depth %u, "
+ "format %#x, pool %#x, usage %#x, volume %p.\n",
+ device_parent, container_parent, width, height, depth,
+ format, pool, usage, volume);
ERR("Not implemented!\n");
return E_NOTIMPL;
}
-static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDeviceParent *iface,
- WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
+static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent,
+ WINED3DPRESENT_PARAMETERS *present_parameters, struct wined3d_swapchain **swapchain)
{
- struct IDirectDrawImpl *This = ddraw_from_device_parent(iface);
+ struct IDirectDrawImpl *ddraw = ddraw_from_device_parent(device_parent);
IDirectDrawSurfaceImpl *iterator;
- IParentImpl *object;
HRESULT hr;
- TRACE("iface %p, present_parameters %p, swapchain %p\n", iface, present_parameters, swapchain);
+ TRACE("device_parent %p, present_parameters %p, swapchain %p.\n", device_parent, present_parameters, swapchain);
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IParentImpl));
- if (!object)
- {
- FIXME("Allocation of memory failed\n");
- *swapchain = NULL;
- return DDERR_OUTOFVIDEOMEMORY;
- }
-
- ddraw_parent_init(object);
-
- hr = IWineD3DDevice_CreateSwapChain(This->wineD3DDevice, present_parameters,
- This->ImplType, object, swapchain);
+ hr = wined3d_swapchain_create(ddraw->wined3d_device, present_parameters,
+ ddraw->ImplType, NULL, &ddraw_null_wined3d_parent_ops, swapchain);
if (FAILED(hr))
{
- FIXME("(%p) CreateSwapChain failed, returning %#x\n", iface, hr);
- HeapFree(GetProcessHeap(), 0 , object);
+ WARN("Failed to create swapchain, hr %#x.\n", hr);
*swapchain = NULL;
return hr;
}
- object->child = (IUnknown *)*swapchain;
- This->d3d_target->wineD3DSwapChain = *swapchain;
- iterator = This->d3d_target->complex_array[0];
+ ddraw->d3d_target->wined3d_swapchain = *swapchain;
+ iterator = ddraw->d3d_target->complex_array[0];
while (iterator)
{
- iterator->wineD3DSwapChain = *swapchain;
+ iterator->wined3d_swapchain = *swapchain;
iterator = iterator->complex_array[0];
}
return hr;
}
-static const IWineD3DDeviceParentVtbl ddraw_wined3d_device_parent_vtbl =
+static const struct wined3d_device_parent_ops ddraw_wined3d_device_parent_ops =
{
- /* IUnknown methods */
- device_parent_QueryInterface,
- device_parent_AddRef,
- device_parent_Release,
- /* IWineD3DDeviceParent methods */
- device_parent_WineD3DDeviceCreated,
- device_parent_CreateSurface,
- device_parent_CreateRenderTarget,
- device_parent_CreateDepthStencilSurface,
- device_parent_CreateVolume,
- device_parent_CreateSwapChain,
+ device_parent_wined3d_device_created,
+ device_parent_create_surface,
+ device_parent_create_rendertarget,
+ device_parent_create_depth_stencil,
+ device_parent_create_volume,
+ device_parent_create_swapchain,
};
HRESULT ddraw_init(IDirectDrawImpl *ddraw, WINED3DDEVTYPE device_type)
@@ -5767,16 +5870,16 @@ HRESULT ddraw_init(IDirectDrawImpl *ddraw, WINED3DDEVTYPE device_type)
HRESULT hr;
HDC hDC;
- ddraw->lpVtbl = &ddraw7_vtbl;
- ddraw->IDirectDraw_vtbl = &ddraw1_vtbl;
- ddraw->IDirectDraw2_vtbl = &ddraw2_vtbl;
- ddraw->IDirectDraw3_vtbl = &ddraw3_vtbl;
- ddraw->IDirectDraw4_vtbl = &ddraw4_vtbl;
- ddraw->IDirect3D_vtbl = &d3d1_vtbl;
- ddraw->IDirect3D2_vtbl = &d3d2_vtbl;
- ddraw->IDirect3D3_vtbl = &d3d3_vtbl;
- ddraw->IDirect3D7_vtbl = &d3d7_vtbl;
- ddraw->device_parent_vtbl = &ddraw_wined3d_device_parent_vtbl;
+ ddraw->IDirectDraw7_iface.lpVtbl = &ddraw7_vtbl;
+ ddraw->IDirectDraw_iface.lpVtbl = &ddraw1_vtbl;
+ ddraw->IDirectDraw2_iface.lpVtbl = &ddraw2_vtbl;
+ ddraw->IDirectDraw3_iface.lpVtbl = &ddraw3_vtbl;
+ ddraw->IDirectDraw4_iface.lpVtbl = &ddraw4_vtbl;
+ ddraw->IDirect3D_iface.lpVtbl = &d3d1_vtbl;
+ ddraw->IDirect3D2_iface.lpVtbl = &d3d2_vtbl;
+ ddraw->IDirect3D3_iface.lpVtbl = &d3d3_vtbl;
+ ddraw->IDirect3D7_iface.lpVtbl = &d3d7_vtbl;
+ ddraw->device_parent.ops = &ddraw_wined3d_device_parent_ops;
ddraw->numIfaces = 1;
ddraw->ref7 = 1;
@@ -5791,30 +5894,24 @@ HRESULT ddraw_init(IDirectDrawImpl *ddraw, WINED3DDEVTYPE device_type)
ddraw->orig_width = GetSystemMetrics(SM_CXSCREEN);
ddraw->orig_height = GetSystemMetrics(SM_CYSCREEN);
- if (!LoadWineD3D())
- {
- ERR("Failed to load wined3d - broken OpenGL setup?\n");
- return DDERR_NODIRECTDRAWSUPPORT;
- }
-
- ddraw->wineD3D = pWineDirect3DCreate(7, (IUnknown *)ddraw);
+ ddraw->wineD3D = wined3d_create(7, &ddraw->IDirectDraw7_iface);
if (!ddraw->wineD3D)
{
WARN("Failed to create a wined3d object.\n");
return E_OUTOFMEMORY;
}
- hr = IWineD3D_CreateDevice(ddraw->wineD3D, WINED3DADAPTER_DEFAULT, device_type, NULL, 0,
- (IWineD3DDeviceParent *)&ddraw->device_parent_vtbl, &ddraw->wineD3DDevice);
+ hr = wined3d_device_create(ddraw->wineD3D, WINED3DADAPTER_DEFAULT, device_type,
+ NULL, 0, &ddraw->device_parent, &ddraw->wined3d_device);
if (FAILED(hr))
{
WARN("Failed to create a wined3d device, hr %#x.\n", hr);
- IWineD3D_Release(ddraw->wineD3D);
+ wined3d_decref(ddraw->wineD3D);
return hr;
}
/* Get the amount of video memory */
- ddraw->total_vidmem = IWineD3DDevice_GetAvailableTextureMem(ddraw->wineD3DDevice);
+ ddraw->total_vidmem = wined3d_device_get_available_texture_mem(ddraw->wined3d_device);
list_init(&ddraw->surface_list);
diff --git a/reactos/dll/directx/wine/ddraw/ddraw.rbuild b/reactos/dll/directx/wine/ddraw/ddraw.rbuild
index d221726dfac..fa6bba2c88d 100644
--- a/reactos/dll/directx/wine/ddraw/ddraw.rbuild
+++ b/reactos/dll/directx/wine/ddraw/ddraw.rbuild
@@ -27,7 +27,6 @@
main.c
material.c
palette.c
- parent.c
regsvr.c
stubs.c
surface.c
diff --git a/reactos/dll/directx/wine/ddraw/ddraw_private.h b/reactos/dll/directx/wine/ddraw/ddraw_private.h
index 91662fe3003..78e69b77aad 100644
--- a/reactos/dll/directx/wine/ddraw/ddraw_private.h
+++ b/reactos/dll/directx/wine/ddraw/ddraw_private.h
@@ -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
diff --git a/reactos/dll/directx/wine/ddraw/device.c b/reactos/dll/directx/wine/ddraw/device.c
index 9f0f631724c..ad5edfe9019 100644
--- a/reactos/dll/directx/wine/ddraw/device.c
+++ b/reactos/dll/directx/wine/ddraw/device.c
@@ -116,47 +116,47 @@ IDirect3DDeviceImpl_7_QueryInterface(IDirect3DDevice7 *iface,
*obj = iface;
}
- /* Check DirectDraw Interfacs */
+ /* Check DirectDraw Interfaces. */
else if( IsEqualGUID( &IID_IDirectDraw7, refiid ) )
{
- *obj = This->ddraw;
+ *obj = &This->ddraw->IDirectDraw7_iface;
TRACE("(%p) Returning IDirectDraw7 interface at %p\n", This, *obj);
}
else if ( IsEqualGUID( &IID_IDirectDraw4, refiid ) )
{
- *obj = &This->ddraw->IDirectDraw4_vtbl;
+ *obj = &This->ddraw->IDirectDraw4_iface;
TRACE("(%p) Returning IDirectDraw4 interface at %p\n", This, *obj);
}
else if ( IsEqualGUID( &IID_IDirectDraw2, refiid ) )
{
- *obj = &This->ddraw->IDirectDraw2_vtbl;
+ *obj = &This->ddraw->IDirectDraw2_iface;
TRACE("(%p) Returning IDirectDraw2 interface at %p\n", This, *obj);
}
else if( IsEqualGUID( &IID_IDirectDraw, refiid ) )
{
- *obj = &This->ddraw->IDirectDraw_vtbl;
+ *obj = &This->ddraw->IDirectDraw_iface;
TRACE("(%p) Returning IDirectDraw interface at %p\n", This, *obj);
}
/* Direct3D */
else if ( IsEqualGUID( &IID_IDirect3D , refiid ) )
{
- *obj = &This->ddraw->IDirect3D_vtbl;
+ *obj = &This->ddraw->IDirect3D_iface;
TRACE("(%p) Returning IDirect3D interface at %p\n", This, *obj);
}
else if ( IsEqualGUID( &IID_IDirect3D2 , refiid ) )
{
- *obj = &This->ddraw->IDirect3D2_vtbl;
+ *obj = &This->ddraw->IDirect3D2_iface;
TRACE("(%p) Returning IDirect3D2 interface at %p\n", This, *obj);
}
else if ( IsEqualGUID( &IID_IDirect3D3 , refiid ) )
{
- *obj = &This->ddraw->IDirect3D3_vtbl;
+ *obj = &This->ddraw->IDirect3D3_iface;
TRACE("(%p) Returning IDirect3D3 interface at %p\n", This, *obj);
}
else if ( IsEqualGUID( &IID_IDirect3D7 , refiid ) )
{
- *obj = &This->ddraw->IDirect3D7_vtbl;
+ *obj = &This->ddraw->IDirect3D7_iface;
TRACE("(%p) Returning IDirect3D7 interface at %p\n", This, *obj);
}
@@ -191,30 +191,24 @@ IDirect3DDeviceImpl_7_QueryInterface(IDirect3DDevice7 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_QueryInterface(IDirect3DDevice3 *iface,
- REFIID riid,
- void **obj)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_QueryInterface(IDirect3DDevice3 *iface, REFIID riid,
+ void **obj)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), obj);
return IDirect3DDevice7_QueryInterface((IDirect3DDevice7 *)device_from_device3(iface), riid, obj);
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_QueryInterface(IDirect3DDevice2 *iface,
- REFIID riid,
- void **obj)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_QueryInterface(IDirect3DDevice2 *iface, REFIID riid,
+ void **obj)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), obj);
return IDirect3DDevice7_QueryInterface((IDirect3DDevice7 *)device_from_device2(iface), riid, obj);
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_1_QueryInterface(IDirect3DDevice *iface,
- REFIID riid,
- void **obp)
+static HRESULT WINAPI IDirect3DDeviceImpl_1_QueryInterface(IDirect3DDevice *iface, REFIID riid,
+ void **obp)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), obp);
@@ -244,24 +238,21 @@ IDirect3DDeviceImpl_7_AddRef(IDirect3DDevice7 *iface)
return ref;
}
-static ULONG WINAPI
-Thunk_IDirect3DDeviceImpl_3_AddRef(IDirect3DDevice3 *iface)
+static ULONG WINAPI IDirect3DDeviceImpl_3_AddRef(IDirect3DDevice3 *iface)
{
TRACE("iface %p.\n", iface);
return IDirect3DDevice7_AddRef((IDirect3DDevice7 *)device_from_device3(iface));
}
-static ULONG WINAPI
-Thunk_IDirect3DDeviceImpl_2_AddRef(IDirect3DDevice2 *iface)
+static ULONG WINAPI IDirect3DDeviceImpl_2_AddRef(IDirect3DDevice2 *iface)
{
TRACE("iface %p.\n", iface);
return IDirect3DDevice7_AddRef((IDirect3DDevice7 *)device_from_device2(iface));
}
-static ULONG WINAPI
-Thunk_IDirect3DDeviceImpl_1_AddRef(IDirect3DDevice *iface)
+static ULONG WINAPI IDirect3DDeviceImpl_1_AddRef(IDirect3DDevice *iface)
{
TRACE("iface %p.\n", iface);
@@ -294,33 +285,24 @@ IDirect3DDeviceImpl_7_Release(IDirect3DDevice7 *iface)
*/
if (ref == 0)
{
- IParent *IndexBufferParent;
DWORD i;
EnterCriticalSection(&ddraw_cs);
- /* Free the index buffer. */
- IWineD3DDevice_SetIndexBuffer(This->wineD3DDevice, NULL, WINED3DFMT_UNKNOWN);
- IndexBufferParent = IWineD3DBuffer_GetParent(This->indexbuffer);
- if (IParent_Release(IndexBufferParent))
- {
- ERR(" (%p) Something is still holding the index buffer parent %p\n", This, IndexBufferParent);
- }
- /* There is no need to unset the vertex buffer here, IWineD3DDevice_Uninit3D will do that when
- * destroying the primary stateblock. If a vertex buffer is destroyed while it is bound
- * IDirect3DVertexBuffer::Release will unset it.
- */
+ /* There is no need to unset any resources here, wined3d will take
+ * care of that on Uninit3D(). */
+
+ /* Free the index buffer. */
+ wined3d_buffer_decref(This->indexbuffer);
/* Set the device up to render to the front buffer since the back
* buffer will vanish soon. */
- IWineD3DDevice_SetRenderTarget(This->wineD3DDevice, 0,
- This->ddraw->d3d_target->WineD3DSurface, TRUE);
+ wined3d_device_set_render_target(This->wined3d_device, 0,
+ This->ddraw->d3d_target->wined3d_surface, TRUE);
- /* Release the WineD3DDevice. This won't destroy it */
- if(IWineD3DDevice_Release(This->wineD3DDevice) <= 0)
- {
- ERR(" (%p) The wineD3D device %p was destroyed unexpectedly. Prepare for trouble\n", This, This->wineD3DDevice);
- }
+ /* Release the WineD3DDevice. This won't destroy it. */
+ if (!wined3d_device_decref(This->wined3d_device))
+ ERR("The wined3d device (%p) was destroyed unexpectedly.\n", This->wined3d_device);
/* The texture handles should be unset by now, but there might be some bits
* missing in our reference counting(needs test). Do a sanity check. */
@@ -392,24 +374,21 @@ IDirect3DDeviceImpl_7_Release(IDirect3DDevice7 *iface)
return ref;
}
-static ULONG WINAPI
-Thunk_IDirect3DDeviceImpl_3_Release(IDirect3DDevice3 *iface)
+static ULONG WINAPI IDirect3DDeviceImpl_3_Release(IDirect3DDevice3 *iface)
{
TRACE("iface %p.\n", iface);
return IDirect3DDevice7_Release((IDirect3DDevice7 *)device_from_device3(iface));
}
-static ULONG WINAPI
-Thunk_IDirect3DDeviceImpl_2_Release(IDirect3DDevice2 *iface)
+static ULONG WINAPI IDirect3DDeviceImpl_2_Release(IDirect3DDevice2 *iface)
{
TRACE("iface %p.\n", iface);
return IDirect3DDevice7_Release((IDirect3DDevice7 *)device_from_device2(iface));
}
-static ULONG WINAPI
-Thunk_IDirect3DDeviceImpl_1_Release(IDirect3DDevice *iface)
+static ULONG WINAPI IDirect3DDeviceImpl_1_Release(IDirect3DDevice *iface)
{
TRACE("iface %p.\n", iface);
@@ -531,20 +510,16 @@ IDirect3DDeviceImpl_3_GetCaps(IDirect3DDevice3 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_GetCaps(IDirect3DDevice2 *iface,
- D3DDEVICEDESC *D3DHWDevDesc,
- D3DDEVICEDESC *D3DHELDevDesc)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_GetCaps(IDirect3DDevice2 *iface,
+ D3DDEVICEDESC *D3DHWDevDesc, D3DDEVICEDESC *D3DHELDevDesc)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
TRACE("iface %p, hw_desc %p, hel_desc %p.\n", iface, D3DHWDevDesc, D3DHELDevDesc);
return IDirect3DDevice3_GetCaps((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, D3DHWDevDesc, D3DHELDevDesc);
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_1_GetCaps(IDirect3DDevice *iface,
- D3DDEVICEDESC *D3DHWDevDesc,
- D3DDEVICEDESC *D3DHELDevDesc)
+static HRESULT WINAPI IDirect3DDeviceImpl_1_GetCaps(IDirect3DDevice *iface,
+ D3DDEVICEDESC *D3DHWDevDesc, D3DDEVICEDESC *D3DHELDevDesc)
{
IDirect3DDeviceImpl *This = device_from_device1(iface);
TRACE("iface %p, hw_desc %p, hel_desc %p.\n", iface, D3DHWDevDesc, D3DHELDevDesc);
@@ -589,10 +564,8 @@ IDirect3DDeviceImpl_2_SwapTextureHandles(IDirect3DDevice2 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles(IDirect3DDevice *iface,
- IDirect3DTexture *D3DTex1,
- IDirect3DTexture *D3DTex2)
+static HRESULT WINAPI IDirect3DDeviceImpl_1_SwapTextureHandles(IDirect3DDevice *iface,
+ IDirect3DTexture *D3DTex1, IDirect3DTexture *D3DTex2)
{
IDirect3DDeviceImpl *This = device_from_device1(iface);
IDirectDrawSurfaceImpl *surf1 = surface_from_texture1(D3DTex1);
@@ -642,9 +615,7 @@ IDirect3DDeviceImpl_3_GetStats(IDirect3DDevice3 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_GetStats(IDirect3DDevice2 *iface,
- D3DSTATS *Stats)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_GetStats(IDirect3DDevice2 *iface, D3DSTATS *Stats)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
@@ -653,9 +624,7 @@ Thunk_IDirect3DDeviceImpl_2_GetStats(IDirect3DDevice2 *iface,
return IDirect3DDevice3_GetStats((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, Stats);
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_1_GetStats(IDirect3DDevice *iface,
- D3DSTATS *Stats)
+static HRESULT WINAPI IDirect3DDeviceImpl_1_GetStats(IDirect3DDevice *iface, D3DSTATS *Stats)
{
IDirect3DDeviceImpl *This = device_from_device1(iface);
@@ -747,6 +716,7 @@ IDirect3DDeviceImpl_1_Execute(IDirect3DDevice *iface,
IDirect3DDeviceImpl *This = device_from_device1(iface);
IDirect3DExecuteBufferImpl *Direct3DExecuteBufferImpl = (IDirect3DExecuteBufferImpl *)ExecuteBuffer;
IDirect3DViewportImpl *Direct3DViewportImpl = (IDirect3DViewportImpl *)Viewport;
+ HRESULT hr;
TRACE("iface %p, buffer %p, viewport %p, flags %#x.\n", iface, ExecuteBuffer, Viewport, Flags);
@@ -755,10 +725,10 @@ IDirect3DDeviceImpl_1_Execute(IDirect3DDevice *iface,
/* Execute... */
EnterCriticalSection(&ddraw_cs);
- IDirect3DExecuteBufferImpl_Execute(Direct3DExecuteBufferImpl, This, Direct3DViewportImpl);
+ hr = d3d_execute_buffer_execute(Direct3DExecuteBufferImpl, This, Direct3DViewportImpl);
LeaveCriticalSection(&ddraw_cs);
- return D3D_OK;
+ return hr;
}
/*****************************************************************************
@@ -792,8 +762,7 @@ IDirect3DDeviceImpl_3_AddViewport(IDirect3DDevice3 *iface,
return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
- vp->next = This->viewport_list;
- This->viewport_list = vp;
+ list_add_head(&This->viewport_list, &vp->entry);
vp->active_device = This; /* Viewport must be usable for Clear() after AddViewport,
so set active_device here. */
LeaveCriticalSection(&ddraw_cs);
@@ -801,9 +770,8 @@ IDirect3DDeviceImpl_3_AddViewport(IDirect3DDevice3 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_AddViewport(IDirect3DDevice2 *iface,
- IDirect3DViewport2 *Direct3DViewport2)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_AddViewport(IDirect3DDevice2 *iface,
+ IDirect3DViewport2 *Direct3DViewport2)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport2;
@@ -813,9 +781,8 @@ Thunk_IDirect3DDeviceImpl_2_AddViewport(IDirect3DDevice2 *iface,
return IDirect3DDevice3_AddViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, (IDirect3DViewport3 *)vp);
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_1_AddViewport(IDirect3DDevice *iface,
- IDirect3DViewport *Direct3DViewport)
+static HRESULT WINAPI IDirect3DDeviceImpl_1_AddViewport(IDirect3DDevice *iface,
+ IDirect3DViewport *Direct3DViewport)
{
IDirect3DDeviceImpl *This = device_from_device1(iface);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport;
@@ -841,39 +808,31 @@ Thunk_IDirect3DDeviceImpl_1_AddViewport(IDirect3DDevice *iface,
* DDERR_INVALIDPARAMS if the viewport wasn't found in the list
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirect3DDeviceImpl_3_DeleteViewport(IDirect3DDevice3 *iface,
- IDirect3DViewport3 *Viewport)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_DeleteViewport(IDirect3DDevice3 *iface, IDirect3DViewport3 *viewport)
{
- IDirect3DDeviceImpl *This = device_from_device3(iface);
- IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *) Viewport;
- IDirect3DViewportImpl *cur_viewport, *prev_viewport = NULL;
+ IDirect3DDeviceImpl *device = device_from_device3(iface);
+ IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)viewport;
- TRACE("iface %p, viewport %p.\n", iface, Viewport);
+ TRACE("iface %p, viewport %p.\n", iface, viewport);
EnterCriticalSection(&ddraw_cs);
- cur_viewport = This->viewport_list;
- while (cur_viewport != NULL)
+
+ if (vp->active_device != device)
{
- if (cur_viewport == vp)
- {
- if (prev_viewport == NULL) This->viewport_list = cur_viewport->next;
- else prev_viewport->next = cur_viewport->next;
- /* TODO : add desactivate of the viewport and all associated lights... */
- LeaveCriticalSection(&ddraw_cs);
- return D3D_OK;
- }
- prev_viewport = cur_viewport;
- cur_viewport = cur_viewport->next;
+ WARN("Viewport %p active device is %p.\n", vp, vp->active_device);
+ LeaveCriticalSection(&ddraw_cs);
+ return DDERR_INVALIDPARAMS;
}
+ vp->active_device = NULL;
+ list_remove(&vp->entry);
+
LeaveCriticalSection(&ddraw_cs);
- return DDERR_INVALIDPARAMS;
+ return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_DeleteViewport(IDirect3DDevice2 *iface,
- IDirect3DViewport2 *Direct3DViewport2)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_DeleteViewport(IDirect3DDevice2 *iface,
+ IDirect3DViewport2 *Direct3DViewport2)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport2;
@@ -883,9 +842,8 @@ Thunk_IDirect3DDeviceImpl_2_DeleteViewport(IDirect3DDevice2 *iface,
return IDirect3DDevice3_DeleteViewport((IDirect3DDevice3 *)&This->IDirect3DDevice3_vtbl, (IDirect3DViewport3 *)vp);
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_1_DeleteViewport(IDirect3DDevice *iface,
- IDirect3DViewport *Direct3DViewport)
+static HRESULT WINAPI IDirect3DDeviceImpl_1_DeleteViewport(IDirect3DDevice *iface,
+ IDirect3DViewport *Direct3DViewport)
{
IDirect3DDeviceImpl *This = device_from_device1(iface);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport;
@@ -921,7 +879,7 @@ IDirect3DDeviceImpl_3_NextViewport(IDirect3DDevice3 *iface,
{
IDirect3DDeviceImpl *This = device_from_device3(iface);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Viewport3;
- IDirect3DViewportImpl *res = NULL;
+ struct list *entry;
TRACE("iface %p, viewport %p, next %p, flags %#x.\n",
iface, Viewport3, lplpDirect3DViewport3, Flags);
@@ -937,41 +895,35 @@ IDirect3DDeviceImpl_3_NextViewport(IDirect3DDevice3 *iface,
switch (Flags)
{
case D3DNEXT_NEXT:
- {
- res = vp->next;
- }
- break;
+ entry = list_next(&This->viewport_list, &vp->entry);
+ break;
+
case D3DNEXT_HEAD:
- {
- res = This->viewport_list;
- }
- break;
+ entry = list_head(&This->viewport_list);
+ break;
+
case D3DNEXT_TAIL:
- {
- IDirect3DViewportImpl *cur_viewport = This->viewport_list;
- if (cur_viewport != NULL)
- {
- while (cur_viewport->next != NULL) cur_viewport = cur_viewport->next;
- }
- res = cur_viewport;
- }
- break;
+ entry = list_tail(&This->viewport_list);
+ break;
+
default:
+ WARN("Invalid flags %#x.\n", Flags);
*lplpDirect3DViewport3 = NULL;
LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDPARAMS;
}
- *lplpDirect3DViewport3 = (IDirect3DViewport3 *)res;
+ if (entry)
+ *lplpDirect3DViewport3 = (IDirect3DViewport3 *)LIST_ENTRY(entry, IDirect3DViewportImpl, entry);
+ else
+ *lplpDirect3DViewport3 = NULL;
+
LeaveCriticalSection(&ddraw_cs);
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_NextViewport(IDirect3DDevice2 *iface,
- IDirect3DViewport2 *Viewport2,
- IDirect3DViewport2 **lplpDirect3DViewport2,
- DWORD Flags)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_NextViewport(IDirect3DDevice2 *iface,
+ IDirect3DViewport2 *Viewport2, IDirect3DViewport2 **lplpDirect3DViewport2, DWORD Flags)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Viewport2;
@@ -987,11 +939,8 @@ Thunk_IDirect3DDeviceImpl_2_NextViewport(IDirect3DDevice2 *iface,
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_1_NextViewport(IDirect3DDevice *iface,
- IDirect3DViewport *Viewport,
- IDirect3DViewport **lplpDirect3DViewport,
- DWORD Flags)
+static HRESULT WINAPI IDirect3DDeviceImpl_1_NextViewport(IDirect3DDevice *iface,
+ IDirect3DViewport *Viewport, IDirect3DViewport **lplpDirect3DViewport, DWORD Flags)
{
IDirect3DDeviceImpl *This = device_from_device1(iface);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Viewport;
@@ -1135,10 +1084,9 @@ IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7 *iface,
EnterCriticalSection(&ddraw_cs);
memset(&mode, 0, sizeof(mode));
- hr = IWineD3DDevice_GetDisplayMode(This->ddraw->wineD3DDevice,
- 0,
- &mode);
- if(FAILED(hr)) {
+ hr = wined3d_device_get_display_mode(This->ddraw->wined3d_device, 0, &mode);
+ if (FAILED(hr))
+ {
LeaveCriticalSection(&ddraw_cs);
WARN("Cannot get the current adapter format\n");
return hr;
@@ -1146,15 +1094,9 @@ IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7 *iface,
for (i = 0; i < sizeof(FormatList) / sizeof(*FormatList); ++i)
{
- hr = IWineD3D_CheckDeviceFormat(This->ddraw->wineD3D,
- WINED3DADAPTER_DEFAULT,
- WINED3DDEVTYPE_HAL,
- mode.Format,
- 0 /* Usage */,
- WINED3DRTYPE_TEXTURE,
- FormatList[i],
- SURFACE_OPENGL);
- if(hr == D3D_OK)
+ hr = wined3d_check_device_format(This->ddraw->wineD3D, WINED3DADAPTER_DEFAULT, WINED3DDEVTYPE_HAL,
+ mode.Format, 0, WINED3DRTYPE_TEXTURE, FormatList[i], SURFACE_OPENGL);
+ if (hr == D3D_OK)
{
DDPIXELFORMAT pformat;
@@ -1175,15 +1117,10 @@ IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7 *iface,
for (i = 0; i < sizeof(BumpFormatList) / sizeof(*BumpFormatList); ++i)
{
- hr = IWineD3D_CheckDeviceFormat(This->ddraw->wineD3D,
- WINED3DADAPTER_DEFAULT,
- WINED3DDEVTYPE_HAL,
- mode.Format,
- WINED3DUSAGE_QUERY_LEGACYBUMPMAP,
- WINED3DRTYPE_TEXTURE,
- BumpFormatList[i],
- SURFACE_OPENGL);
- if(hr == D3D_OK)
+ hr = wined3d_check_device_format(This->ddraw->wineD3D, WINED3DADAPTER_DEFAULT,
+ WINED3DDEVTYPE_HAL, mode.Format, WINED3DUSAGE_QUERY_LEGACYBUMPMAP,
+ WINED3DRTYPE_TEXTURE, BumpFormatList[i], SURFACE_OPENGL);
+ if (hr == D3D_OK)
{
DDPIXELFORMAT pformat;
@@ -1229,10 +1166,8 @@ IDirect3DDeviceImpl_7_EnumTextureFormats_FPUPreserve(IDirect3DDevice7 *iface,
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats(IDirect3DDevice3 *iface,
- LPD3DENUMPIXELFORMATSCALLBACK Callback,
- void *Arg)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_EnumTextureFormats(IDirect3DDevice3 *iface,
+ LPD3DENUMPIXELFORMATSCALLBACK Callback, void *Arg)
{
IDirect3DDeviceImpl *This = device_from_device3(iface);
@@ -1287,10 +1222,9 @@ IDirect3DDeviceImpl_2_EnumTextureFormats(IDirect3DDevice2 *iface,
EnterCriticalSection(&ddraw_cs);
memset(&mode, 0, sizeof(mode));
- hr = IWineD3DDevice_GetDisplayMode(This->ddraw->wineD3DDevice,
- 0,
- &mode);
- if(FAILED(hr)) {
+ hr = wined3d_device_get_display_mode(This->ddraw->wined3d_device, 0, &mode);
+ if (FAILED(hr))
+ {
LeaveCriticalSection(&ddraw_cs);
WARN("Cannot get the current adapter format\n");
return hr;
@@ -1298,15 +1232,9 @@ IDirect3DDeviceImpl_2_EnumTextureFormats(IDirect3DDevice2 *iface,
for (i = 0; i < sizeof(FormatList) / sizeof(*FormatList); ++i)
{
- hr = IWineD3D_CheckDeviceFormat(This->ddraw->wineD3D,
- 0 /* Adapter */,
- WINED3DDEVTYPE_HAL,
- mode.Format,
- 0 /* Usage */,
- WINED3DRTYPE_TEXTURE,
- FormatList[i],
- SURFACE_OPENGL);
- if(hr == D3D_OK)
+ hr = wined3d_check_device_format(This->ddraw->wineD3D, 0, WINED3DDEVTYPE_HAL,
+ mode.Format, 0, WINED3DRTYPE_TEXTURE, FormatList[i], SURFACE_OPENGL);
+ if (hr == D3D_OK)
{
DDSURFACEDESC sdesc;
@@ -1332,10 +1260,8 @@ IDirect3DDeviceImpl_2_EnumTextureFormats(IDirect3DDevice2 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats(IDirect3DDevice *iface,
- LPD3DENUMTEXTUREFORMATSCALLBACK Callback,
- void *Arg)
+static HRESULT WINAPI IDirect3DDeviceImpl_1_EnumTextureFormats(IDirect3DDevice *iface,
+ LPD3DENUMTEXTUREFORMATSCALLBACK Callback, void *Arg)
{
IDirect3DDeviceImpl *This = device_from_device1(iface);
@@ -1443,24 +1369,14 @@ IDirect3DDeviceImpl_1_SetMatrix(IDirect3DDevice *iface,
*m = *D3DMatrix;
- if(This->world == D3DMatHandle)
- {
- IWineD3DDevice_SetTransform(This->wineD3DDevice,
- WINED3DTS_WORLDMATRIX(0),
- (WINED3DMATRIX *) D3DMatrix);
- }
- if(This->view == D3DMatHandle)
- {
- IWineD3DDevice_SetTransform(This->wineD3DDevice,
- WINED3DTS_VIEW,
- (WINED3DMATRIX *) D3DMatrix);
- }
- if(This->proj == D3DMatHandle)
- {
- IWineD3DDevice_SetTransform(This->wineD3DDevice,
- WINED3DTS_PROJECTION,
- (WINED3DMATRIX *) D3DMatrix);
- }
+ if (D3DMatHandle == This->world)
+ wined3d_device_set_transform(This->wined3d_device, WINED3DTS_WORLDMATRIX(0), (WINED3DMATRIX *)D3DMatrix);
+
+ if (D3DMatHandle == This->view)
+ wined3d_device_set_transform(This->wined3d_device, WINED3DTS_VIEW, (WINED3DMATRIX *)D3DMatrix);
+
+ if (D3DMatHandle == This->proj)
+ wined3d_device_set_transform(This->wined3d_device, WINED3DTS_PROJECTION, (WINED3DMATRIX *)D3DMatrix);
LeaveCriticalSection(&ddraw_cs);
return D3D_OK;
@@ -1574,7 +1490,7 @@ IDirect3DDeviceImpl_7_BeginScene(IDirect3DDevice7 *iface)
TRACE("iface %p.\n", iface);
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_BeginScene(This->wineD3DDevice);
+ hr = wined3d_device_begin_scene(This->wined3d_device);
LeaveCriticalSection(&ddraw_cs);
if(hr == WINED3D_OK) return D3D_OK;
else return D3DERR_SCENE_IN_SCENE; /* TODO: Other possible causes of failure */
@@ -1599,24 +1515,21 @@ IDirect3DDeviceImpl_7_BeginScene_FPUPreserve(IDirect3DDevice7 *iface)
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_BeginScene(IDirect3DDevice3 *iface)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_BeginScene(IDirect3DDevice3 *iface)
{
TRACE("iface %p.\n", iface);
return IDirect3DDevice7_BeginScene((IDirect3DDevice7 *)device_from_device3(iface));
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_BeginScene(IDirect3DDevice2 *iface)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_BeginScene(IDirect3DDevice2 *iface)
{
TRACE("iface %p.\n", iface);
return IDirect3DDevice7_BeginScene((IDirect3DDevice7 *)device_from_device2(iface));
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_1_BeginScene(IDirect3DDevice *iface)
+static HRESULT WINAPI IDirect3DDeviceImpl_1_BeginScene(IDirect3DDevice *iface)
{
TRACE("iface %p.\n", iface);
@@ -1646,7 +1559,7 @@ IDirect3DDeviceImpl_7_EndScene(IDirect3DDevice7 *iface)
TRACE("iface %p.\n", iface);
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_EndScene(This->wineD3DDevice);
+ hr = wined3d_device_end_scene(This->wined3d_device);
LeaveCriticalSection(&ddraw_cs);
if(hr == WINED3D_OK) return D3D_OK;
else return D3DERR_SCENE_NOT_IN_SCENE;
@@ -1671,24 +1584,21 @@ IDirect3DDeviceImpl_7_EndScene_FPUPreserve(IDirect3DDevice7 *iface)
return hr;
}
-static HRESULT WINAPI DECLSPEC_HOTPATCH
-Thunk_IDirect3DDeviceImpl_3_EndScene(IDirect3DDevice3 *iface)
+static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDeviceImpl_3_EndScene(IDirect3DDevice3 *iface)
{
TRACE("iface %p.\n", iface);
return IDirect3DDevice7_EndScene((IDirect3DDevice7 *)device_from_device3(iface));
}
-static HRESULT WINAPI DECLSPEC_HOTPATCH
-Thunk_IDirect3DDeviceImpl_2_EndScene(IDirect3DDevice2 *iface)
+static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDeviceImpl_2_EndScene(IDirect3DDevice2 *iface)
{
TRACE("iface %p.\n", iface);
return IDirect3DDevice7_EndScene((IDirect3DDevice7 *)device_from_device2(iface));
}
-static HRESULT WINAPI DECLSPEC_HOTPATCH
-Thunk_IDirect3DDeviceImpl_1_EndScene(IDirect3DDevice *iface)
+static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDeviceImpl_1_EndScene(IDirect3DDevice *iface)
{
TRACE("iface %p.\n", iface);
@@ -1720,63 +1630,57 @@ IDirect3DDeviceImpl_7_GetDirect3D(IDirect3DDevice7 *iface,
if(!Direct3D7)
return DDERR_INVALIDPARAMS;
- *Direct3D7 = (IDirect3D7 *)&This->ddraw->IDirect3D7_vtbl;
+ *Direct3D7 = &This->ddraw->IDirect3D7_iface;
IDirect3D7_AddRef(*Direct3D7);
TRACE(" returning interface %p\n", *Direct3D7);
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_GetDirect3D(IDirect3DDevice3 *iface,
- IDirect3D3 **Direct3D3)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_GetDirect3D(IDirect3DDevice3 *iface,
+ IDirect3D3 **Direct3D3)
{
IDirect3DDeviceImpl *This = device_from_device3(iface);
- HRESULT ret;
- IDirect3D7 *ret_ptr;
TRACE("iface %p, d3d %p.\n", iface, Direct3D3);
- ret = IDirect3DDevice7_GetDirect3D((IDirect3DDevice7 *)This, &ret_ptr);
- if(ret != D3D_OK)
- return ret;
- *Direct3D3 = ret_ptr ? (IDirect3D3 *)&ddraw_from_d3d7(ret_ptr)->IDirect3D3_vtbl : NULL;
+ if(!Direct3D3)
+ return DDERR_INVALIDPARAMS;
+
+ IDirect3D3_AddRef(&This->ddraw->IDirect3D3_iface);
+ *Direct3D3 = &This->ddraw->IDirect3D3_iface;
TRACE(" returning interface %p\n", *Direct3D3);
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_GetDirect3D(IDirect3DDevice2 *iface,
- IDirect3D2 **Direct3D2)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_GetDirect3D(IDirect3DDevice2 *iface,
+ IDirect3D2 **Direct3D2)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
- HRESULT ret;
- IDirect3D7 *ret_ptr;
TRACE("iface %p, d3d %p.\n", iface, Direct3D2);
- ret = IDirect3DDevice7_GetDirect3D((IDirect3DDevice7 *)This, &ret_ptr);
- if(ret != D3D_OK)
- return ret;
- *Direct3D2 = ret_ptr ? (IDirect3D2 *)&ddraw_from_d3d7(ret_ptr)->IDirect3D2_vtbl : NULL;
+ if(!Direct3D2)
+ return DDERR_INVALIDPARAMS;
+
+ IDirect3D2_AddRef(&This->ddraw->IDirect3D2_iface);
+ *Direct3D2 = &This->ddraw->IDirect3D2_iface;
TRACE(" returning interface %p\n", *Direct3D2);
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_1_GetDirect3D(IDirect3DDevice *iface,
- IDirect3D **Direct3D)
+static HRESULT WINAPI IDirect3DDeviceImpl_1_GetDirect3D(IDirect3DDevice *iface,
+ IDirect3D **Direct3D)
{
IDirect3DDeviceImpl *This = device_from_device1(iface);
- HRESULT ret;
- IDirect3D7 *ret_ptr;
TRACE("iface %p, d3d %p.\n", iface, Direct3D);
- ret = IDirect3DDevice7_GetDirect3D((IDirect3DDevice7 *)This, &ret_ptr);
- if(ret != D3D_OK)
- return ret;
- *Direct3D = ret_ptr ? (IDirect3D *)&ddraw_from_d3d7(ret_ptr)->IDirect3D_vtbl : NULL;
+ if(!Direct3D)
+ return DDERR_INVALIDPARAMS;
+
+ IDirect3D_AddRef(&This->ddraw->IDirect3D_iface);
+ *Direct3D = &This->ddraw->IDirect3D_iface;
TRACE(" returning interface %p\n", *Direct3D);
return D3D_OK;
}
@@ -1814,7 +1718,12 @@ IDirect3DDeviceImpl_3_SetCurrentViewport(IDirect3DDevice3 *iface,
return D3D_OK;
}
- /* Should check if the viewport was added or not */
+ if (vp->active_device != This)
+ {
+ WARN("Viewport %p active device is %p.\n", vp, vp->active_device);
+ LeaveCriticalSection(&ddraw_cs);
+ return DDERR_INVALIDPARAMS;
+ }
/* Release previous viewport and AddRef the new one */
if (This->current_viewport)
@@ -1829,16 +1738,14 @@ IDirect3DDeviceImpl_3_SetCurrentViewport(IDirect3DDevice3 *iface,
This->current_viewport = vp;
/* Activate this viewport */
- This->current_viewport->active_device = This;
viewport_activate(This->current_viewport, FALSE);
LeaveCriticalSection(&ddraw_cs);
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport(IDirect3DDevice2 *iface,
- IDirect3DViewport2 *Direct3DViewport2)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_SetCurrentViewport(IDirect3DDevice2 *iface,
+ IDirect3DViewport2 *Direct3DViewport2)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Direct3DViewport2;
@@ -1887,9 +1794,8 @@ IDirect3DDeviceImpl_3_GetCurrentViewport(IDirect3DDevice3 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport(IDirect3DDevice2 *iface,
- IDirect3DViewport2 **Direct3DViewport2)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_GetCurrentViewport(IDirect3DDevice2 *iface,
+ IDirect3DViewport2 **Direct3DViewport2)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
HRESULT hr;
@@ -1941,10 +1847,8 @@ IDirect3DDeviceImpl_7_SetRenderTarget(IDirect3DDevice7 *iface,
return D3D_OK;
}
- hr = IWineD3DDevice_SetRenderTarget(This->wineD3DDevice,
- 0,
- Target ? Target->WineD3DSurface : NULL,
- FALSE);
+ hr = wined3d_device_set_render_target(This->wined3d_device, 0,
+ Target ? Target->wined3d_surface : NULL, FALSE);
if(hr != D3D_OK)
{
LeaveCriticalSection(&ddraw_cs);
@@ -1981,10 +1885,8 @@ IDirect3DDeviceImpl_7_SetRenderTarget_FPUPreserve(IDirect3DDevice7 *iface,
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_SetRenderTarget(IDirect3DDevice3 *iface,
- IDirectDrawSurface4 *NewRenderTarget,
- DWORD Flags)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_SetRenderTarget(IDirect3DDevice3 *iface,
+ IDirectDrawSurface4 *NewRenderTarget, DWORD Flags)
{
IDirect3DDeviceImpl *This = device_from_device3(iface);
IDirectDrawSurfaceImpl *Target = (IDirectDrawSurfaceImpl *)NewRenderTarget;
@@ -1994,10 +1896,8 @@ Thunk_IDirect3DDeviceImpl_3_SetRenderTarget(IDirect3DDevice3 *iface,
return IDirect3DDevice7_SetRenderTarget((IDirect3DDevice7 *)This, (IDirectDrawSurface7 *)Target, Flags);
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_SetRenderTarget(IDirect3DDevice2 *iface,
- IDirectDrawSurface *NewRenderTarget,
- DWORD Flags)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_SetRenderTarget(IDirect3DDevice2 *iface,
+ IDirectDrawSurface *NewRenderTarget, DWORD Flags)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
IDirectDrawSurfaceImpl *Target = (IDirectDrawSurfaceImpl *)NewRenderTarget;
@@ -2043,9 +1943,8 @@ IDirect3DDeviceImpl_7_GetRenderTarget(IDirect3DDevice7 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_GetRenderTarget(IDirect3DDevice3 *iface,
- IDirectDrawSurface4 **RenderTarget)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_GetRenderTarget(IDirect3DDevice3 *iface,
+ IDirectDrawSurface4 **RenderTarget)
{
IDirect3DDeviceImpl *This = device_from_device3(iface);
HRESULT hr;
@@ -2057,9 +1956,8 @@ Thunk_IDirect3DDeviceImpl_3_GetRenderTarget(IDirect3DDevice3 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_GetRenderTarget(IDirect3DDevice2 *iface,
- IDirectDrawSurface **RenderTarget)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_GetRenderTarget(IDirect3DDevice2 *iface,
+ IDirectDrawSurface **RenderTarget)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
HRESULT hr;
@@ -2113,11 +2011,8 @@ IDirect3DDeviceImpl_3_Begin(IDirect3DDevice3 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_Begin(IDirect3DDevice2 *iface,
- D3DPRIMITIVETYPE d3dpt,
- D3DVERTEXTYPE dwVertexTypeDesc,
- DWORD dwFlags)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_Begin(IDirect3DDevice2 *iface, D3DPRIMITIVETYPE d3dpt,
+ D3DVERTEXTYPE dwVertexTypeDesc, DWORD dwFlags)
{
DWORD FVF;
IDirect3DDeviceImpl *This = device_from_device2(iface);
@@ -2172,13 +2067,9 @@ IDirect3DDeviceImpl_3_BeginIndexed(IDirect3DDevice3 *iface,
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_BeginIndexed(IDirect3DDevice2 *iface,
- D3DPRIMITIVETYPE d3dptPrimitiveType,
- D3DVERTEXTYPE d3dvtVertexType,
- void *lpvVertices,
- DWORD dwNumVertices,
- DWORD dwFlags)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_BeginIndexed(IDirect3DDevice2 *iface,
+ D3DPRIMITIVETYPE d3dptPrimitiveType, D3DVERTEXTYPE d3dvtVertexType,
+ void *lpvVertices, DWORD dwNumVertices, DWORD dwFlags)
{
DWORD FVF;
IDirect3DDeviceImpl *This = device_from_device2(iface);
@@ -2248,9 +2139,7 @@ IDirect3DDeviceImpl_3_Vertex(IDirect3DDevice3 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_Vertex(IDirect3DDevice2 *iface,
- void *lpVertexType)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_Vertex(IDirect3DDevice2 *iface, void *lpVertexType)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
@@ -2281,9 +2170,7 @@ IDirect3DDeviceImpl_3_Index(IDirect3DDevice3 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_Index(IDirect3DDevice2 *iface,
- WORD wVertexIndex)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_Index(IDirect3DDevice2 *iface, WORD wVertexIndex)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
@@ -2322,9 +2209,7 @@ IDirect3DDeviceImpl_3_End(IDirect3DDevice3 *iface,
This->vertex_type, This->vertex_buffer, This->nb_vertices, This->render_flags);
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_End(IDirect3DDevice2 *iface,
- DWORD dwFlags)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_End(IDirect3DDevice2 *iface, DWORD dwFlags)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
@@ -2350,6 +2235,8 @@ Thunk_IDirect3DDeviceImpl_2_End(IDirect3DDevice2 *iface,
* DDERR_INVALIDPARAMS if Value == NULL
*
*****************************************************************************/
+static const float zbias_factor = -0.000005f;
+
static HRESULT
IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
D3DRENDERSTATETYPE RenderStateType,
@@ -2370,9 +2257,7 @@ IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
{
WINED3DTEXTUREFILTERTYPE tex_mag;
- hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
- 0, WINED3DSAMP_MAGFILTER,
- &tex_mag);
+ hr = wined3d_device_get_sampler_state(This->wined3d_device, 0, WINED3DSAMP_MAGFILTER, &tex_mag);
switch (tex_mag)
{
@@ -2394,14 +2279,14 @@ IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
WINED3DTEXTUREFILTERTYPE tex_min;
WINED3DTEXTUREFILTERTYPE tex_mip;
- hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
+ hr = wined3d_device_get_sampler_state(This->wined3d_device,
0, WINED3DSAMP_MINFILTER, &tex_min);
if (FAILED(hr))
{
LeaveCriticalSection(&ddraw_cs);
return hr;
}
- hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
+ hr = wined3d_device_get_sampler_state(This->wined3d_device,
0, WINED3DSAMP_MIPFILTER, &tex_mip);
switch (tex_min)
@@ -2452,14 +2337,12 @@ IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
case D3DRENDERSTATE_TEXTUREADDRESS:
case D3DRENDERSTATE_TEXTUREADDRESSU:
- hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
- 0, WINED3DSAMP_ADDRESSU,
- Value);
+ hr = wined3d_device_get_sampler_state(This->wined3d_device,
+ 0, WINED3DSAMP_ADDRESSU, Value);
break;
case D3DRENDERSTATE_TEXTUREADDRESSV:
- hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice,
- 0, WINED3DSAMP_ADDRESSV,
- Value);
+ hr = wined3d_device_get_sampler_state(This->wined3d_device,
+ 0, WINED3DSAMP_ADDRESSV, Value);
break;
case D3DRENDERSTATE_BORDERCOLOR:
@@ -2473,6 +2356,20 @@ IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
hr = DDERR_INVALIDPARAMS;
break;
+ case D3DRENDERSTATE_ZBIAS:
+ {
+ union
+ {
+ DWORD d;
+ float f;
+ } wined3d_value;
+
+ hr = wined3d_device_get_render_state(This->wined3d_device, WINED3DRS_DEPTHBIAS, &wined3d_value.d);
+ if (SUCCEEDED(hr))
+ *Value = wined3d_value.f / zbias_factor;
+ break;
+ }
+
default:
if (RenderStateType >= D3DRENDERSTATE_STIPPLEPATTERN00
&& RenderStateType <= D3DRENDERSTATE_STIPPLEPATTERN31)
@@ -2482,9 +2379,7 @@ IDirect3DDeviceImpl_7_GetRenderState(IDirect3DDevice7 *iface,
hr = E_NOTIMPL;
break;
}
- hr = IWineD3DDevice_GetRenderState(This->wineD3DDevice,
- RenderStateType,
- Value);
+ hr = wined3d_device_get_render_state(This->wined3d_device, RenderStateType, Value);
}
LeaveCriticalSection(&ddraw_cs);
return hr;
@@ -2528,21 +2423,20 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
case D3DRENDERSTATE_TEXTUREHANDLE:
{
/* This state is wrapped to SetTexture in SetRenderState, so
- * it has to be wrapped to GetTexture here
- */
- IWineD3DBaseTexture *tex = NULL;
+ * it has to be wrapped to GetTexture here. */
+ struct wined3d_texture *tex = NULL;
*lpdwRenderState = 0;
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_GetTexture(This->wineD3DDevice, 0, &tex);
+ hr = wined3d_device_get_texture(This->wined3d_device, 0, &tex);
if (SUCCEEDED(hr) && tex)
{
/* The parent of the texture is the IDirectDrawSurface7
* interface of the ddraw surface. */
- IDirectDrawSurfaceImpl *parent = IWineD3DBaseTexture_GetParent(tex);
+ IDirectDrawSurfaceImpl *parent = wined3d_texture_get_parent(tex);
if (parent) *lpdwRenderState = parent->Handle;
- IWineD3DBaseTexture_Release(tex);
+ wined3d_texture_decref(tex);
}
LeaveCriticalSection(&ddraw_cs);
@@ -2561,12 +2455,12 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
This->legacyTextureBlending = TRUE;
- IWineD3DDevice_GetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, &colorop);
- IWineD3DDevice_GetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, &colorarg1);
- IWineD3DDevice_GetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG2, &colorarg2);
- IWineD3DDevice_GetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, &alphaop);
- IWineD3DDevice_GetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, &alphaarg1);
- IWineD3DDevice_GetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG2, &alphaarg2);
+ wined3d_device_get_texture_stage_state(This->wined3d_device, 0, WINED3DTSS_COLOROP, &colorop);
+ wined3d_device_get_texture_stage_state(This->wined3d_device, 0, WINED3DTSS_COLORARG1, &colorarg1);
+ wined3d_device_get_texture_stage_state(This->wined3d_device, 0, WINED3DTSS_COLORARG2, &colorarg2);
+ wined3d_device_get_texture_stage_state(This->wined3d_device, 0, WINED3DTSS_ALPHAOP, &alphaop);
+ wined3d_device_get_texture_stage_state(This->wined3d_device, 0, WINED3DTSS_ALPHAARG1, &alphaarg1);
+ wined3d_device_get_texture_stage_state(This->wined3d_device, 0, WINED3DTSS_ALPHAARG2, &alphaarg2);
if (colorop == WINED3DTOP_SELECTARG1 && colorarg1 == WINED3DTA_TEXTURE &&
alphaop == WINED3DTOP_SELECTARG1 && alphaarg1 == WINED3DTA_TEXTURE)
@@ -2585,27 +2479,28 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
}
else
{
+ struct wined3d_texture *tex = NULL;
HRESULT hr;
BOOL tex_alpha = FALSE;
- IWineD3DBaseTexture *tex = NULL;
- WINED3DSURFACE_DESC desc;
DDPIXELFORMAT ddfmt;
- hr = IWineD3DDevice_GetTexture(This->wineD3DDevice,
- 0,
- &tex);
+ hr = wined3d_device_get_texture(This->wined3d_device, 0, &tex);
if(hr == WINED3D_OK && tex)
{
- hr = IWineD3DTexture_GetLevelDesc((IWineD3DTexture*) tex, 0, &desc);
- if (SUCCEEDED(hr))
+ struct wined3d_resource *sub_resource;
+
+ if ((sub_resource = wined3d_texture_get_sub_resource(tex, 0)))
{
+ struct wined3d_resource_desc desc;
+
+ wined3d_resource_get_desc(sub_resource, &desc);
ddfmt.dwSize = sizeof(ddfmt);
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
}
- IWineD3DBaseTexture_Release(tex);
+ wined3d_texture_decref(tex);
}
if (!(colorop == WINED3DTOP_MODULATE && colorarg1 == WINED3DTA_TEXTURE && colorarg2 == WINED3DTA_CURRENT &&
@@ -2628,10 +2523,8 @@ IDirect3DDeviceImpl_3_GetRenderState(IDirect3DDevice3 *iface,
}
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_GetRenderState(IDirect3DDevice2 *iface,
- D3DRENDERSTATETYPE dwRenderStateType,
- DWORD *lpdwRenderState)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_GetRenderState(IDirect3DDevice2 *iface,
+ D3DRENDERSTATETYPE dwRenderStateType, DWORD *lpdwRenderState)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
@@ -2707,9 +2600,7 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
break;
}
- hr = IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
- 0, WINED3DSAMP_MAGFILTER,
- tex_mag);
+ hr = wined3d_device_set_sampler_state(This->wined3d_device, 0, WINED3DSAMP_MAGFILTER, tex_mag);
break;
}
@@ -2752,28 +2643,24 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
break;
}
- IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
+ wined3d_device_set_sampler_state(This->wined3d_device,
0, WINED3DSAMP_MIPFILTER, tex_mip);
- hr = IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
- 0, WINED3DSAMP_MINFILTER,
- tex_min);
+ hr = wined3d_device_set_sampler_state(This->wined3d_device,
+ 0, WINED3DSAMP_MINFILTER, tex_min);
break;
}
case D3DRENDERSTATE_TEXTUREADDRESS:
- IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
- 0, WINED3DSAMP_ADDRESSV,
- Value);
+ wined3d_device_set_sampler_state(This->wined3d_device,
+ 0, WINED3DSAMP_ADDRESSV, Value);
/* Drop through */
case D3DRENDERSTATE_TEXTUREADDRESSU:
- hr = IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
- 0, WINED3DSAMP_ADDRESSU,
- Value);
+ hr = wined3d_device_set_sampler_state(This->wined3d_device,
+ 0, WINED3DSAMP_ADDRESSU, Value);
break;
case D3DRENDERSTATE_TEXTUREADDRESSV:
- hr = IWineD3DDevice_SetSamplerState(This->wineD3DDevice,
- 0, WINED3DSAMP_ADDRESSV,
- Value);
+ hr = wined3d_device_set_sampler_state(This->wined3d_device,
+ 0, WINED3DSAMP_ADDRESSV, Value);
break;
case D3DRENDERSTATE_BORDERCOLOR:
@@ -2789,6 +2676,18 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
hr = DDERR_INVALIDPARAMS;
break;
+ case D3DRENDERSTATE_ZBIAS:
+ {
+ union
+ {
+ DWORD d;
+ float f;
+ } wined3d_value;
+ wined3d_value.f = Value * zbias_factor;
+ hr = wined3d_device_set_render_state(This->wined3d_device, WINED3DRS_DEPTHBIAS, wined3d_value.d);
+ break;
+ }
+
default:
if (RenderStateType >= D3DRENDERSTATE_STIPPLEPATTERN00
&& RenderStateType <= D3DRENDERSTATE_STIPPLEPATTERN31)
@@ -2799,9 +2698,7 @@ IDirect3DDeviceImpl_7_SetRenderState(IDirect3DDevice7 *iface,
break;
}
- hr = IWineD3DDevice_SetRenderState(This->wineD3DDevice,
- RenderStateType,
- Value);
+ hr = wined3d_device_set_render_state(This->wined3d_device, RenderStateType, Value);
break;
}
LeaveCriticalSection(&ddraw_cs);
@@ -2870,9 +2767,7 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface,
if(Value == 0)
{
- hr = IWineD3DDevice_SetTexture(This->wineD3DDevice,
- 0,
- NULL);
+ hr = wined3d_device_set_texture(This->wined3d_device, 0, NULL);
break;
}
@@ -2896,73 +2791,99 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface,
{
case D3DTBLEND_MODULATE:
{
+ struct wined3d_texture *tex = NULL;
BOOL tex_alpha = FALSE;
- IWineD3DBaseTexture *tex = NULL;
- WINED3DSURFACE_DESC desc;
DDPIXELFORMAT ddfmt;
- hr = IWineD3DDevice_GetTexture(This->wineD3DDevice,
- 0,
- &tex);
+ hr = wined3d_device_get_texture(This->wined3d_device, 0, &tex);
if(hr == WINED3D_OK && tex)
{
- memset(&desc, 0, sizeof(desc));
- hr = IWineD3DTexture_GetLevelDesc((IWineD3DTexture*) tex, 0, &desc);
- if (SUCCEEDED(hr))
+ struct wined3d_resource *sub_resource;
+
+ if ((sub_resource = wined3d_texture_get_sub_resource(tex, 0)))
{
+ struct wined3d_resource_desc desc;
+
+ wined3d_resource_get_desc(sub_resource, &desc);
ddfmt.dwSize = sizeof(ddfmt);
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
}
- IWineD3DBaseTexture_Release(tex);
+ wined3d_texture_decref(tex);
}
if (tex_alpha)
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1);
else
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, WINED3DTOP_MODULATE);
-
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_COLOROP, WINED3DTOP_MODULATE);
break;
}
case D3DTBLEND_ADD:
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, WINED3DTOP_ADD);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_COLOROP, WINED3DTOP_ADD);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
break;
case D3DTBLEND_MODULATEALPHA:
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, WINED3DTOP_MODULATE);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_MODULATE);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_COLOROP, WINED3DTOP_MODULATE);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_ALPHAOP, WINED3DTOP_MODULATE);
break;
case D3DTBLEND_COPY:
case D3DTBLEND_DECAL:
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, WINED3DTOP_SELECTARG1);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_ALPHAARG1, WINED3DTA_TEXTURE);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_COLOROP, WINED3DTOP_SELECTARG1);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1);
break;
case D3DTBLEND_DECALALPHA:
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLOROP, WINED3DTOP_BLENDTEXTUREALPHA);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_COLOROP, WINED3DTOP_BLENDTEXTUREALPHA);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_COLORARG1, WINED3DTA_TEXTURE);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_COLORARG2, WINED3DTA_CURRENT);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
+ wined3d_device_set_texture_stage_state(This->wined3d_device,
+ 0, WINED3DTSS_ALPHAARG2, WINED3DTA_CURRENT);
break;
default:
@@ -2983,10 +2904,8 @@ IDirect3DDeviceImpl_3_SetRenderState(IDirect3DDevice3 *iface,
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_SetRenderState(IDirect3DDevice2 *iface,
- D3DRENDERSTATETYPE RenderStateType,
- DWORD Value)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_SetRenderState(IDirect3DDevice2 *iface,
+ D3DRENDERSTATETYPE RenderStateType, DWORD Value)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
@@ -3100,10 +3019,8 @@ IDirect3DDeviceImpl_3_SetLightState(IDirect3DDevice3 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_SetLightState(IDirect3DDevice2 *iface,
- D3DLIGHTSTATETYPE LightStateType,
- DWORD Value)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_SetLightState(IDirect3DDevice2 *iface,
+ D3DLIGHTSTATETYPE LightStateType, DWORD Value)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
@@ -3196,10 +3113,8 @@ IDirect3DDeviceImpl_3_GetLightState(IDirect3DDevice3 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_GetLightState(IDirect3DDevice2 *iface,
- D3DLIGHTSTATETYPE LightStateType,
- DWORD *Value)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_GetLightState(IDirect3DDevice2 *iface,
+ D3DLIGHTSTATETYPE LightStateType, DWORD *Value)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
@@ -3249,14 +3164,12 @@ IDirect3DDeviceImpl_7_SetTransform(IDirect3DDevice7 *iface,
default: type = TransformStateType;
}
- if(!Matrix)
- return DDERR_INVALIDPARAMS;
+ if (!Matrix)
+ return DDERR_INVALIDPARAMS;
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_SetTransform(This->wineD3DDevice,
- type,
- (WINED3DMATRIX*) Matrix);
+ hr = wined3d_device_set_transform(This->wined3d_device, type, (WINED3DMATRIX *)Matrix);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@@ -3284,10 +3197,8 @@ IDirect3DDeviceImpl_7_SetTransform_FPUPreserve(IDirect3DDevice7 *iface,
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_SetTransform(IDirect3DDevice3 *iface,
- D3DTRANSFORMSTATETYPE TransformStateType,
- D3DMATRIX *D3DMatrix)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_SetTransform(IDirect3DDevice3 *iface,
+ D3DTRANSFORMSTATETYPE TransformStateType, D3DMATRIX *D3DMatrix)
{
IDirect3DDeviceImpl *This = device_from_device3(iface);
@@ -3296,10 +3207,8 @@ Thunk_IDirect3DDeviceImpl_3_SetTransform(IDirect3DDevice3 *iface,
return IDirect3DDevice7_SetTransform((IDirect3DDevice7 *)This, TransformStateType, D3DMatrix);
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_SetTransform(IDirect3DDevice2 *iface,
- D3DTRANSFORMSTATETYPE TransformStateType,
- D3DMATRIX *D3DMatrix)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_SetTransform(IDirect3DDevice2 *iface,
+ D3DTRANSFORMSTATETYPE TransformStateType, D3DMATRIX *D3DMatrix)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
@@ -3350,7 +3259,7 @@ IDirect3DDeviceImpl_7_GetTransform(IDirect3DDevice7 *iface,
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_GetTransform(This->wineD3DDevice, type, (WINED3DMATRIX*) Matrix);
+ hr = wined3d_device_get_transform(This->wined3d_device, type, (WINED3DMATRIX *)Matrix);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@@ -3378,10 +3287,8 @@ IDirect3DDeviceImpl_7_GetTransform_FPUPreserve(IDirect3DDevice7 *iface,
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_GetTransform(IDirect3DDevice3 *iface,
- D3DTRANSFORMSTATETYPE TransformStateType,
- D3DMATRIX *D3DMatrix)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_GetTransform(IDirect3DDevice3 *iface,
+ D3DTRANSFORMSTATETYPE TransformStateType, D3DMATRIX *D3DMatrix)
{
IDirect3DDeviceImpl *This = device_from_device3(iface);
@@ -3390,10 +3297,8 @@ Thunk_IDirect3DDeviceImpl_3_GetTransform(IDirect3DDevice3 *iface,
return IDirect3DDevice7_GetTransform((IDirect3DDevice7 *)This, TransformStateType, D3DMatrix);
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_GetTransform(IDirect3DDevice2 *iface,
- D3DTRANSFORMSTATETYPE TransformStateType,
- D3DMATRIX *D3DMatrix)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_GetTransform(IDirect3DDevice2 *iface,
+ D3DTRANSFORMSTATETYPE TransformStateType, D3DMATRIX *D3DMatrix)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
@@ -3442,9 +3347,8 @@ IDirect3DDeviceImpl_7_MultiplyTransform(IDirect3DDevice7 *iface,
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_MultiplyTransform(This->wineD3DDevice,
- type,
- (WINED3DMATRIX*) D3DMatrix);
+ hr = wined3d_device_multiply_transform(This->wined3d_device,
+ type, (WINED3DMATRIX *)D3DMatrix);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@@ -3472,10 +3376,8 @@ IDirect3DDeviceImpl_7_MultiplyTransform_FPUPreserve(IDirect3DDevice7 *iface,
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_MultiplyTransform(IDirect3DDevice3 *iface,
- D3DTRANSFORMSTATETYPE TransformStateType,
- D3DMATRIX *D3DMatrix)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_MultiplyTransform(IDirect3DDevice3 *iface,
+ D3DTRANSFORMSTATETYPE TransformStateType, D3DMATRIX *D3DMatrix)
{
IDirect3DDeviceImpl *This = device_from_device3(iface);
@@ -3484,10 +3386,8 @@ Thunk_IDirect3DDeviceImpl_3_MultiplyTransform(IDirect3DDevice3 *iface,
return IDirect3DDevice7_MultiplyTransform((IDirect3DDevice7 *)This, TransformStateType, D3DMatrix);
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_MultiplyTransform(IDirect3DDevice2 *iface,
- D3DTRANSFORMSTATETYPE TransformStateType,
- D3DMATRIX *D3DMatrix)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_MultiplyTransform(IDirect3DDevice2 *iface,
+ D3DTRANSFORMSTATETYPE TransformStateType, D3DMATRIX *D3DMatrix)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
@@ -3540,7 +3440,7 @@ IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7 *iface,
/* Set the FVF */
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_SetVertexDeclaration(This->wineD3DDevice, ddraw_find_decl(This->ddraw, VertexType));
+ hr = wined3d_device_set_vertex_declaration(This->wined3d_device, ddraw_find_decl(This->ddraw, VertexType));
if(hr != D3D_OK)
{
LeaveCriticalSection(&ddraw_cs);
@@ -3548,8 +3448,8 @@ IDirect3DDeviceImpl_7_DrawPrimitive(IDirect3DDevice7 *iface,
}
/* This method translates to the user pointer draw of WineD3D */
- IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
- hr = IWineD3DDevice_DrawPrimitiveUP(This->wineD3DDevice, VertexCount, Vertices, stride);
+ wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+ hr = wined3d_device_draw_primitive_up(This->wined3d_device, VertexCount, Vertices, stride);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@@ -3583,13 +3483,9 @@ IDirect3DDeviceImpl_7_DrawPrimitive_FPUPreserve(IDirect3DDevice7 *iface,
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_DrawPrimitive(IDirect3DDevice3 *iface,
- D3DPRIMITIVETYPE PrimitiveType,
- DWORD VertexType,
- void *Vertices,
- DWORD VertexCount,
- DWORD Flags)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_DrawPrimitive(IDirect3DDevice3 *iface,
+ D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType, void *Vertices, DWORD VertexCount,
+ DWORD Flags)
{
TRACE("iface %p, primitive_type %#x, FVF %#x, vertices %p, vertex_count %u, flags %#x.\n",
iface, PrimitiveType, VertexType, Vertices, VertexCount, Flags);
@@ -3598,13 +3494,9 @@ Thunk_IDirect3DDeviceImpl_3_DrawPrimitive(IDirect3DDevice3 *iface,
PrimitiveType, VertexType, Vertices, VertexCount, Flags);
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_DrawPrimitive(IDirect3DDevice2 *iface,
- D3DPRIMITIVETYPE PrimitiveType,
- D3DVERTEXTYPE VertexType,
- void *Vertices,
- DWORD VertexCount,
- DWORD Flags)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_DrawPrimitive(IDirect3DDevice2 *iface,
+ D3DPRIMITIVETYPE PrimitiveType, D3DVERTEXTYPE VertexType, void *Vertices,
+ DWORD VertexCount, DWORD Flags)
{
DWORD FVF;
@@ -3667,7 +3559,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
/* Set the D3DDevice's FVF */
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_SetVertexDeclaration(This->wineD3DDevice, ddraw_find_decl(This->ddraw, VertexType));
+ hr = wined3d_device_set_vertex_declaration(This->wined3d_device, ddraw_find_decl(This->ddraw, VertexType));
if(FAILED(hr))
{
ERR(" (%p) Setting the FVF failed, hr = %x!\n", This, hr);
@@ -3675,8 +3567,8 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
return hr;
}
- IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
- hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->wineD3DDevice, IndexCount, Indices,
+ wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+ hr = wined3d_device_draw_indexed_primitive_up(This->wined3d_device, IndexCount, Indices,
WINED3DFMT_R16_UINT, Vertices, get_flexible_vertex_size(VertexType));
LeaveCriticalSection(&ddraw_cs);
return hr;
@@ -3715,15 +3607,9 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitive_FPUPreserve(IDirect3DDevice7 *iface,
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive(IDirect3DDevice3 *iface,
- D3DPRIMITIVETYPE PrimitiveType,
- DWORD VertexType,
- void *Vertices,
- DWORD VertexCount,
- WORD *Indices,
- DWORD IndexCount,
- DWORD Flags)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_DrawIndexedPrimitive(IDirect3DDevice3 *iface,
+ D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType, void *Vertices, DWORD VertexCount,
+ WORD *Indices, DWORD IndexCount, DWORD Flags)
{
TRACE("iface %p, primitive_type %#x, FVF %#x, vertices %p, vertex_count %u, indices %p, index_count %u, flags %#x.\n",
iface, PrimitiveType, VertexType, Vertices, VertexCount, Indices, IndexCount, Flags);
@@ -3732,15 +3618,9 @@ Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive(IDirect3DDevice3 *iface,
PrimitiveType, VertexType, Vertices, VertexCount, Indices, IndexCount, Flags);
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_DrawIndexedPrimitive(IDirect3DDevice2 *iface,
- D3DPRIMITIVETYPE PrimitiveType,
- D3DVERTEXTYPE VertexType,
- void *Vertices,
- DWORD VertexCount,
- WORD *Indices,
- DWORD IndexCount,
- DWORD Flags)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_DrawIndexedPrimitive(IDirect3DDevice2 *iface,
+ D3DPRIMITIVETYPE PrimitiveType, D3DVERTEXTYPE VertexType, void *Vertices,
+ DWORD VertexCount, WORD *Indices, DWORD IndexCount, DWORD Flags)
{
DWORD FVF;
@@ -3790,18 +3670,16 @@ IDirect3DDeviceImpl_7_SetClipStatus(IDirect3DDevice7 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_SetClipStatus(IDirect3DDevice3 *iface,
- D3DCLIPSTATUS *ClipStatus)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_SetClipStatus(IDirect3DDevice3 *iface,
+ D3DCLIPSTATUS *ClipStatus)
{
TRACE("iface %p, clip_status %p.\n", iface, ClipStatus);
return IDirect3DDevice7_SetClipStatus((IDirect3DDevice7 *)device_from_device3(iface), ClipStatus);
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_SetClipStatus(IDirect3DDevice2 *iface,
- D3DCLIPSTATUS *ClipStatus)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_SetClipStatus(IDirect3DDevice2 *iface,
+ D3DCLIPSTATUS *ClipStatus)
{
TRACE("iface %p, clip_status %p.\n", iface, ClipStatus);
@@ -3831,18 +3709,16 @@ IDirect3DDeviceImpl_7_GetClipStatus(IDirect3DDevice7 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_GetClipStatus(IDirect3DDevice3 *iface,
- D3DCLIPSTATUS *ClipStatus)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_GetClipStatus(IDirect3DDevice3 *iface,
+ D3DCLIPSTATUS *ClipStatus)
{
TRACE("iface %p, clip_status %p.\n", iface, ClipStatus);
return IDirect3DDevice7_GetClipStatus((IDirect3DDevice7 *)device_from_device3(iface), ClipStatus);
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_2_GetClipStatus(IDirect3DDevice2 *iface,
- D3DCLIPSTATUS *ClipStatus)
+static HRESULT WINAPI IDirect3DDeviceImpl_2_GetClipStatus(IDirect3DDevice2 *iface,
+ D3DCLIPSTATUS *ClipStatus)
{
TRACE("iface %p, clip_status %p.\n", iface, ClipStatus);
@@ -3944,8 +3820,8 @@ IDirect3DDeviceImpl_7_DrawPrimitiveStrided(IDirect3DDevice7 *iface,
/* WineD3D doesn't need the FVF here */
EnterCriticalSection(&ddraw_cs);
- IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
- hr = IWineD3DDevice_DrawPrimitiveStrided(This->wineD3DDevice, VertexCount, &WineD3DStrided);
+ wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+ hr = wined3d_device_draw_primitive_strided(This->wined3d_device, VertexCount, &WineD3DStrided);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@@ -3979,13 +3855,9 @@ IDirect3DDeviceImpl_7_DrawPrimitiveStrided_FPUPreserve(IDirect3DDevice7 *iface,
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided(IDirect3DDevice3 *iface,
- D3DPRIMITIVETYPE PrimitiveType,
- DWORD VertexType,
- D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData,
- DWORD VertexCount,
- DWORD Flags)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_DrawPrimitiveStrided(IDirect3DDevice3 *iface,
+ D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType,
+ D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData, DWORD VertexCount, DWORD Flags)
{
TRACE("iface %p, primitive_type %#x, FVF %#x, strided_data %p, vertex_count %u, flags %#x.\n",
iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
@@ -4087,8 +3959,8 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface,
/* WineD3D doesn't need the FVF here */
EnterCriticalSection(&ddraw_cs);
- IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
- hr = IWineD3DDevice_DrawIndexedPrimitiveStrided(This->wineD3DDevice,
+ wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+ hr = wined3d_device_draw_indexed_primitive_strided(This->wined3d_device,
IndexCount, &WineD3DStrided, VertexCount, Indices, WINED3DFMT_R16_UINT);
LeaveCriticalSection(&ddraw_cs);
return hr;
@@ -4127,15 +3999,10 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveStrided_FPUPreserve(IDirect3DDevice7 *
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided(IDirect3DDevice3 *iface,
- D3DPRIMITIVETYPE PrimitiveType,
- DWORD VertexType,
- D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData,
- DWORD VertexCount,
- WORD *Indices,
- DWORD IndexCount,
- DWORD Flags)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided(IDirect3DDevice3 *iface,
+ D3DPRIMITIVETYPE PrimitiveType, DWORD VertexType,
+ D3DDRAWPRIMITIVESTRIDEDDATA *D3DDrawPrimStrideData, DWORD VertexCount, WORD *Indices,
+ DWORD IndexCount, DWORD Flags)
{
TRACE("iface %p, primitive_type %#x, FVF %#x, strided_data %p, vertex_count %u, indices %p, index_count %u, flags %#x.\n",
iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
@@ -4188,9 +4055,8 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
stride = get_flexible_vertex_size(vb->fvf);
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_SetVertexDeclaration(This->wineD3DDevice,
- vb->wineD3DVertexDeclaration);
- if(FAILED(hr))
+ hr = wined3d_device_set_vertex_declaration(This->wined3d_device, vb->wineD3DVertexDeclaration);
+ if (FAILED(hr))
{
ERR(" (%p) Setting the FVF failed, hr = %x!\n", This, hr);
LeaveCriticalSection(&ddraw_cs);
@@ -4198,11 +4064,7 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
}
/* Set the vertex stream source */
- hr = IWineD3DDevice_SetStreamSource(This->wineD3DDevice,
- 0 /* StreamNumber */,
- vb->wineD3DVertexBuffer,
- 0 /* StartVertex - we pass this to DrawPrimitive */,
- stride);
+ hr = wined3d_device_set_stream_source(This->wined3d_device, 0, vb->wineD3DVertexBuffer, 0, stride);
if(hr != D3D_OK)
{
ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x\n", This, hr);
@@ -4211,8 +4073,8 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB(IDirect3DDevice7 *iface,
}
/* Now draw the primitives */
- IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
- hr = IWineD3DDevice_DrawPrimitive(This->wineD3DDevice, StartVertex, NumVertices);
+ wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+ hr = wined3d_device_draw_primitive(This->wined3d_device, StartVertex, NumVertices);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@@ -4246,13 +4108,9 @@ IDirect3DDeviceImpl_7_DrawPrimitiveVB_FPUPreserve(IDirect3DDevice7 *iface,
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB(IDirect3DDevice3 *iface,
- D3DPRIMITIVETYPE PrimitiveType,
- IDirect3DVertexBuffer *D3DVertexBuf,
- DWORD StartVertex,
- DWORD NumVertices,
- DWORD Flags)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_DrawPrimitiveVB(IDirect3DDevice3 *iface,
+ D3DPRIMITIVETYPE PrimitiveType, IDirect3DVertexBuffer *D3DVertexBuf, DWORD StartVertex,
+ DWORD NumVertices, DWORD Flags)
{
IDirect3DVertexBufferImpl *vb = D3DVertexBuf ? vb_from_vb1(D3DVertexBuf) : NULL;
@@ -4294,9 +4152,10 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IDirect3DVertexBufferImpl *vb = (IDirect3DVertexBufferImpl *)D3DVertexBuf;
DWORD stride = get_flexible_vertex_size(vb->fvf);
+ struct wined3d_resource *wined3d_resource;
+ struct wined3d_resource_desc desc;
WORD *LockedIndices;
HRESULT hr;
- WINED3DBUFFER_DESC desc;
TRACE("iface %p, primitive_type %#x, vb %p, start_vertex %u, vertex_count %u, indices %p, index_count %u, flags %#x.\n",
iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Indices, IndexCount, Flags);
@@ -4310,9 +4169,8 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_SetVertexDeclaration(This->wineD3DDevice,
- vb->wineD3DVertexDeclaration);
- if(FAILED(hr))
+ hr = wined3d_device_set_vertex_declaration(This->wined3d_device, vb->wineD3DVertexDeclaration);
+ if (FAILED(hr))
{
ERR(" (%p) Setting the FVF failed, hr = %x!\n", This, hr);
LeaveCriticalSection(&ddraw_cs);
@@ -4321,18 +4179,17 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
/* check that the buffer is large enough to hold the indices,
* reallocate if necessary. */
- IWineD3DBuffer_GetDesc(This->indexbuffer, &desc);
- if (desc.Size < IndexCount * sizeof(WORD))
+ wined3d_resource = wined3d_buffer_get_resource(This->indexbuffer);
+ wined3d_resource_get_desc(wined3d_resource, &desc);
+ if (desc.size < IndexCount * sizeof(WORD))
{
- UINT size = max(desc.Size * 2, IndexCount * sizeof(WORD));
- IWineD3DBuffer *buffer;
- IParentImpl *parent;
+ UINT size = max(desc.size * 2, IndexCount * sizeof(WORD));
+ struct wined3d_buffer *buffer;
TRACE("Growing index buffer to %u bytes\n", size);
- parent = IWineD3DBuffer_GetParent(This->indexbuffer);
- hr = IWineD3DDevice_CreateIndexBuffer(This->wineD3DDevice, size, WINED3DUSAGE_DYNAMIC /* Usage */,
- WINED3DPOOL_DEFAULT, parent, &ddraw_null_wined3d_parent_ops, &buffer);
+ hr = wined3d_buffer_create_ib(This->wined3d_device, size, WINED3DUSAGE_DYNAMIC /* Usage */,
+ WINED3DPOOL_DEFAULT, NULL, &ddraw_null_wined3d_parent_ops, &buffer);
if (FAILED(hr))
{
ERR("(%p) IWineD3DDevice::CreateIndexBuffer failed with hr = %08x\n", This, hr);
@@ -4340,50 +4197,32 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
return hr;
}
- IWineD3DBuffer_Release(This->indexbuffer);
+ wined3d_buffer_decref(This->indexbuffer);
This->indexbuffer = buffer;
-
- parent->child = (IUnknown *)buffer;
}
- /* copy the index stream into the index buffer.
- * A new IWineD3DDevice method could be created
- * which takes an user pointer containing the indices
- * or a SetData-Method for the index buffer, which
- * overrides the index buffer data with our pointer.
- */
- hr = IWineD3DBuffer_Map(This->indexbuffer,
- 0 /* OffSetToLock */,
- IndexCount * sizeof(WORD),
- (BYTE **) &LockedIndices,
- 0 /* Flags */);
- if(hr != D3D_OK)
+ /* Copy the index stream into the index buffer. A new IWineD3DDevice
+ * method could be created which takes an user pointer containing the
+ * indices or a SetData-Method for the index buffer, which overrides the
+ * index buffer data with our pointer. */
+ hr = wined3d_buffer_map(This->indexbuffer, 0, IndexCount * sizeof(WORD),
+ (BYTE **)&LockedIndices, 0);
+ if (FAILED(hr))
{
- ERR("(%p) IWineD3DBuffer::Map failed with hr = %08x\n", This, hr);
+ ERR("Failed to map buffer, hr %#x.\n", hr);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
memcpy(LockedIndices, Indices, IndexCount * sizeof(WORD));
- hr = IWineD3DBuffer_Unmap(This->indexbuffer);
- if(hr != D3D_OK)
- {
- ERR("(%p) IWineD3DBuffer::Unmap failed with hr = %08x\n", This, hr);
- LeaveCriticalSection(&ddraw_cs);
- return hr;
- }
+ wined3d_buffer_unmap(This->indexbuffer);
/* Set the index stream */
- IWineD3DDevice_SetBaseVertexIndex(This->wineD3DDevice, StartVertex);
- hr = IWineD3DDevice_SetIndexBuffer(This->wineD3DDevice, This->indexbuffer,
- WINED3DFMT_R16_UINT);
+ wined3d_device_set_base_vertex_index(This->wined3d_device, StartVertex);
+ hr = wined3d_device_set_index_buffer(This->wined3d_device, This->indexbuffer, WINED3DFMT_R16_UINT);
/* Set the vertex stream source */
- hr = IWineD3DDevice_SetStreamSource(This->wineD3DDevice,
- 0 /* StreamNumber */,
- vb->wineD3DVertexBuffer,
- 0 /* offset, we pass this to DrawIndexedPrimitive */,
- stride);
- if(hr != D3D_OK)
+ hr = wined3d_device_set_stream_source(This->wined3d_device, 0, vb->wineD3DVertexBuffer, 0, stride);
+ if (FAILED(hr))
{
ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x\n", This, hr);
LeaveCriticalSection(&ddraw_cs);
@@ -4391,8 +4230,8 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
}
- IWineD3DDevice_SetPrimitiveType(This->wineD3DDevice, PrimitiveType);
- hr = IWineD3DDevice_DrawIndexedPrimitive(This->wineD3DDevice, 0 /* StartIndex */, IndexCount);
+ wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
+ hr = wined3d_device_draw_indexed_primitive(This->wined3d_device, 0, IndexCount);
LeaveCriticalSection(&ddraw_cs);
return hr;
@@ -4431,13 +4270,9 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB_FPUPreserve(IDirect3DDevice7 *iface
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB(IDirect3DDevice3 *iface,
- D3DPRIMITIVETYPE PrimitiveType,
- IDirect3DVertexBuffer *D3DVertexBuf,
- WORD *Indices,
- DWORD IndexCount,
- DWORD Flags)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB(IDirect3DDevice3 *iface,
+ D3DPRIMITIVETYPE PrimitiveType, IDirect3DVertexBuffer *D3DVertexBuf, WORD *Indices,
+ DWORD IndexCount, DWORD Flags)
{
IDirect3DVertexBufferImpl *VB = vb_from_vb1(D3DVertexBuf);
@@ -4508,11 +4343,11 @@ IDirect3DDeviceImpl_7_ComputeSphereVisibility(IDirect3DDevice7 *iface,
if ( hr != DD_OK ) return DDERR_INVALIDPARAMS;
hr = IDirect3DDeviceImpl_7_GetTransform(iface, D3DTRANSFORMSTATE_VIEW, &temp);
if ( hr != DD_OK ) return DDERR_INVALIDPARAMS;
- multiply_matrix_D3D_way(&m, &m, &temp);
+ multiply_matrix(&m, &temp, &m);
hr = IDirect3DDeviceImpl_7_GetTransform(iface, D3DTRANSFORMSTATE_PROJECTION, &temp);
if ( hr != DD_OK ) return DDERR_INVALIDPARAMS;
- multiply_matrix_D3D_way(&m, &m, &temp);
+ multiply_matrix(&m, &temp, &m);
/* Left plane */
vec[0].u1.x = m._14 + m._11;
@@ -4559,13 +4394,8 @@ IDirect3DDeviceImpl_7_ComputeSphereVisibility(IDirect3DDevice7 *iface,
return D3D_OK;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility(IDirect3DDevice3 *iface,
- D3DVECTOR *Centers,
- D3DVALUE *Radii,
- DWORD NumSpheres,
- DWORD Flags,
- DWORD *ReturnValues)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_ComputeSphereVisibility(IDirect3DDevice3 *iface,
+ D3DVECTOR *Centers, D3DVALUE *Radii, DWORD NumSpheres, DWORD Flags, DWORD *ReturnValues)
{
TRACE("iface %p, centers %p, radii %p, sphere_count %u, flags %#x, return_values %p.\n",
iface, Centers, Radii, NumSpheres, Flags, ReturnValues);
@@ -4599,7 +4429,7 @@ IDirect3DDeviceImpl_7_GetTexture(IDirect3DDevice7 *iface,
IDirectDrawSurface7 **Texture)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
- IWineD3DBaseTexture *Surf;
+ struct wined3d_texture *wined3d_texture;
HRESULT hr;
TRACE("iface %p, stage %u, texture %p.\n", iface, Stage, Texture);
@@ -4611,15 +4441,15 @@ IDirect3DDeviceImpl_7_GetTexture(IDirect3DDevice7 *iface,
}
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_GetTexture(This->wineD3DDevice, Stage, &Surf);
- if( (hr != D3D_OK) || (!Surf) )
+ hr = wined3d_device_get_texture(This->wined3d_device, Stage, &wined3d_texture);
+ if (FAILED(hr) || !wined3d_texture)
{
*Texture = NULL;
LeaveCriticalSection(&ddraw_cs);
return hr;
}
- *Texture = IWineD3DBaseTexture_GetParent(Surf);
+ *Texture = wined3d_texture_get_parent(wined3d_texture);
IDirectDrawSurface7_AddRef(*Texture);
LeaveCriticalSection(&ddraw_cs);
return hr;
@@ -4648,10 +4478,8 @@ IDirect3DDeviceImpl_7_GetTexture_FPUPreserve(IDirect3DDevice7 *iface,
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_GetTexture(IDirect3DDevice3 *iface,
- DWORD Stage,
- IDirect3DTexture2 **Texture2)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_GetTexture(IDirect3DDevice3 *iface, DWORD Stage,
+ IDirect3DTexture2 **Texture2)
{
HRESULT ret;
IDirectDrawSurface7 *ret_val;
@@ -4696,9 +4524,8 @@ IDirect3DDeviceImpl_7_SetTexture(IDirect3DDevice7 *iface,
/* Texture may be NULL here */
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_SetTexture(This->wineD3DDevice,
- Stage,
- surf ? surf->wineD3DTexture : NULL);
+ hr = wined3d_device_set_texture(This->wined3d_device,
+ Stage, surf ? surf->wined3d_texture : NULL);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@@ -4749,35 +4576,34 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface,
{
/* This fixup is required by the way D3DTBLEND_MODULATE maps to texture stage states.
See IDirect3DDeviceImpl_3_SetRenderState for details. */
+ struct wined3d_texture *tex = NULL;
BOOL tex_alpha = FALSE;
- IWineD3DBaseTexture *tex = NULL;
- WINED3DSURFACE_DESC desc;
DDPIXELFORMAT ddfmt;
HRESULT result;
- result = IWineD3DDevice_GetTexture(This->wineD3DDevice,
- 0,
- &tex);
-
- if(result == WINED3D_OK && tex)
+ result = wined3d_device_get_texture(This->wined3d_device, 0, &tex);
+ if (result == WINED3D_OK && tex)
{
- memset(&desc, 0, sizeof(desc));
- result = IWineD3DTexture_GetLevelDesc((IWineD3DTexture*) tex, 0, &desc);
- if (SUCCEEDED(result))
+ struct wined3d_resource *sub_resource;
+
+ if ((sub_resource = wined3d_texture_get_sub_resource(tex, 0)))
{
+ struct wined3d_resource_desc desc;
+
+ wined3d_resource_get_desc(sub_resource, &desc);
ddfmt.dwSize = sizeof(ddfmt);
PixelFormat_WineD3DtoDD(&ddfmt, desc.format);
if (ddfmt.u5.dwRGBAlphaBitMask) tex_alpha = TRUE;
}
- IWineD3DBaseTexture_Release(tex);
+ wined3d_texture_decref(tex);
}
/* Arg 1/2 are already set to WINED3DTA_TEXTURE/WINED3DTA_CURRENT in case of D3DTBLEND_MODULATE */
if (tex_alpha)
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1);
+ wined3d_device_set_texture_stage_state(This->wined3d_device, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG1);
else
- IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
+ wined3d_device_set_texture_stage_state(This->wined3d_device, 0, WINED3DTSS_ALPHAOP, WINED3DTOP_SELECTARG2);
}
LeaveCriticalSection(&ddraw_cs);
@@ -4865,7 +4691,7 @@ IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7 *iface,
if (l->sampler_state)
{
- hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice, Stage, l->state, State);
+ hr = wined3d_device_get_sampler_state(This->wined3d_device, Stage, l->state, State);
switch(TexStageStateType)
{
@@ -4909,7 +4735,7 @@ IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7 *iface,
}
else
{
- hr = IWineD3DDevice_GetTextureStageState(This->wineD3DDevice, Stage, l->state, State);
+ hr = wined3d_device_get_texture_stage_state(This->wined3d_device, Stage, l->state, State);
}
LeaveCriticalSection(&ddraw_cs);
@@ -4941,11 +4767,8 @@ IDirect3DDeviceImpl_7_GetTextureStageState_FPUPreserve(IDirect3DDevice7 *iface,
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_GetTextureStageState(IDirect3DDevice3 *iface,
- DWORD Stage,
- D3DTEXTURESTAGESTATETYPE TexStageStateType,
- DWORD *State)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_GetTextureStageState(IDirect3DDevice3 *iface,
+ DWORD Stage, D3DTEXTURESTAGESTATETYPE TexStageStateType, DWORD *State)
{
TRACE("iface %p, stage %u, state %#x, value %p.\n",
iface, Stage, TexStageStateType, State);
@@ -5035,18 +4858,18 @@ IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7 *iface,
}
case D3DTSS_ADDRESS:
- IWineD3DDevice_SetSamplerState(This->wineD3DDevice, Stage, WINED3DSAMP_ADDRESSV, State);
+ wined3d_device_set_sampler_state(This->wined3d_device, Stage, WINED3DSAMP_ADDRESSV, State);
break;
default:
break;
}
- hr = IWineD3DDevice_SetSamplerState(This->wineD3DDevice, Stage, l->state, State);
+ hr = wined3d_device_set_sampler_state(This->wined3d_device, Stage, l->state, State);
}
else
{
- hr = IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, Stage, l->state, State);
+ hr = wined3d_device_set_texture_stage_state(This->wined3d_device, Stage, l->state, State);
}
LeaveCriticalSection(&ddraw_cs);
@@ -5078,11 +4901,8 @@ IDirect3DDeviceImpl_7_SetTextureStageState_FPUPreserve(IDirect3DDevice7 *iface,
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_SetTextureStageState(IDirect3DDevice3 *iface,
- DWORD Stage,
- D3DTEXTURESTAGESTATETYPE TexStageStateType,
- DWORD State)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_SetTextureStageState(IDirect3DDevice3 *iface,
+ DWORD Stage, D3DTEXTURESTAGESTATETYPE TexStageStateType, DWORD State)
{
TRACE("iface %p, stage %u, state %#x, value %#x.\n",
iface, Stage, TexStageStateType, State);
@@ -5119,7 +4939,7 @@ IDirect3DDeviceImpl_7_ValidateDevice(IDirect3DDevice7 *iface,
TRACE("iface %p, pass_count %p.\n", iface, NumPasses);
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_ValidateDevice(This->wineD3DDevice, NumPasses);
+ hr = wined3d_device_validate_device(This->wined3d_device, NumPasses);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@@ -5145,9 +4965,7 @@ IDirect3DDeviceImpl_7_ValidateDevice_FPUPreserve(IDirect3DDevice7 *iface,
return hr;
}
-static HRESULT WINAPI
-Thunk_IDirect3DDeviceImpl_3_ValidateDevice(IDirect3DDevice3 *iface,
- DWORD *Passes)
+static HRESULT WINAPI IDirect3DDeviceImpl_3_ValidateDevice(IDirect3DDevice3 *iface, DWORD *Passes)
{
TRACE("iface %p, pass_count %p.\n", iface, Passes);
@@ -5191,7 +5009,7 @@ IDirect3DDeviceImpl_7_Clear(IDirect3DDevice7 *iface,
iface, Count, Rects, Flags, Color, Z, Stencil);
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_Clear(This->wineD3DDevice, Count, (RECT *)Rects, Flags, Color, Z, Stencil);
+ hr = wined3d_device_clear(This->wined3d_device, Count, (RECT *)Rects, Flags, Color, Z, Stencil);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@@ -5258,8 +5076,7 @@ IDirect3DDeviceImpl_7_SetViewport(IDirect3DDevice7 *iface,
/* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_SetViewport(This->wineD3DDevice,
- (WINED3DVIEWPORT*) Data);
+ hr = wined3d_device_set_viewport(This->wined3d_device, (WINED3DVIEWPORT *)Data);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@@ -5315,8 +5132,7 @@ IDirect3DDeviceImpl_7_GetViewport(IDirect3DDevice7 *iface,
/* Note: D3DVIEWPORT7 is compatible with WINED3DVIEWPORT */
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_GetViewport(This->wineD3DDevice,
- (WINED3DVIEWPORT*) Data);
+ hr = wined3d_device_get_viewport(This->wined3d_device, (WINED3DVIEWPORT *)Data);
LeaveCriticalSection(&ddraw_cs);
return hr_ddraw_from_wined3d(hr);
@@ -5371,8 +5187,7 @@ IDirect3DDeviceImpl_7_SetMaterial(IDirect3DDevice7 *iface,
if (!Mat) return DDERR_INVALIDPARAMS;
/* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_SetMaterial(This->wineD3DDevice,
- (WINED3DMATERIAL*) Mat);
+ hr = wined3d_device_set_material(This->wined3d_device, (WINED3DMATERIAL *)Mat);
LeaveCriticalSection(&ddraw_cs);
return hr_ddraw_from_wined3d(hr);
}
@@ -5425,8 +5240,7 @@ IDirect3DDeviceImpl_7_GetMaterial(IDirect3DDevice7 *iface,
EnterCriticalSection(&ddraw_cs);
/* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */
- hr = IWineD3DDevice_GetMaterial(This->wineD3DDevice,
- (WINED3DMATERIAL*) Mat);
+ hr = wined3d_device_get_material(This->wined3d_device, (WINED3DMATERIAL *)Mat);
LeaveCriticalSection(&ddraw_cs);
return hr_ddraw_from_wined3d(hr);
}
@@ -5480,9 +5294,7 @@ IDirect3DDeviceImpl_7_SetLight(IDirect3DDevice7 *iface,
EnterCriticalSection(&ddraw_cs);
/* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
- hr = IWineD3DDevice_SetLight(This->wineD3DDevice,
- LightIndex,
- (WINED3DLIGHT*) Light);
+ hr = wined3d_device_set_light(This->wined3d_device, LightIndex, (WINED3DLIGHT *)Light);
LeaveCriticalSection(&ddraw_cs);
return hr_ddraw_from_wined3d(hr);
}
@@ -5536,9 +5348,7 @@ IDirect3DDeviceImpl_7_GetLight(IDirect3DDevice7 *iface,
EnterCriticalSection(&ddraw_cs);
/* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
- rc = IWineD3DDevice_GetLight(This->wineD3DDevice,
- LightIndex,
- (WINED3DLIGHT*) Light);
+ rc = wined3d_device_get_light(This->wined3d_device, LightIndex, (WINED3DLIGHT *)Light);
/* Translate the result. WineD3D returns other values than D3D7 */
LeaveCriticalSection(&ddraw_cs);
@@ -5589,7 +5399,7 @@ IDirect3DDeviceImpl_7_BeginStateBlock(IDirect3DDevice7 *iface)
TRACE("iface %p.\n", iface);
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_BeginStateBlock(This->wineD3DDevice);
+ hr = wined3d_device_begin_stateblock(This->wined3d_device);
LeaveCriticalSection(&ddraw_cs);
return hr_ddraw_from_wined3d(hr);
}
@@ -5635,7 +5445,7 @@ IDirect3DDeviceImpl_7_EndStateBlock(IDirect3DDevice7 *iface,
DWORD *BlockHandle)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
- IWineD3DStateBlock *wined3d_sb;
+ struct wined3d_stateblock *wined3d_sb;
HRESULT hr;
DWORD h;
@@ -5649,7 +5459,7 @@ IDirect3DDeviceImpl_7_EndStateBlock(IDirect3DDevice7 *iface,
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_EndStateBlock(This->wineD3DDevice, &wined3d_sb);
+ hr = wined3d_device_end_stateblock(This->wined3d_device, &wined3d_sb);
if (FAILED(hr))
{
WARN("Failed to end stateblock, hr %#x.\n", hr);
@@ -5662,7 +5472,7 @@ IDirect3DDeviceImpl_7_EndStateBlock(IDirect3DDevice7 *iface,
if (h == DDRAW_INVALID_HANDLE)
{
ERR("Failed to allocate a stateblock handle.\n");
- IWineD3DStateBlock_Release(wined3d_sb);
+ wined3d_stateblock_decref(wined3d_sb);
LeaveCriticalSection(&ddraw_cs);
*BlockHandle = 0;
return DDERR_OUTOFMEMORY;
@@ -5724,7 +5534,7 @@ IDirect3DDeviceImpl_7_PreLoad(IDirect3DDevice7 *iface,
return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
- IWineD3DSurface_PreLoad(surf->WineD3DSurface);
+ wined3d_surface_preload(surf->wined3d_surface);
LeaveCriticalSection(&ddraw_cs);
return D3D_OK;
}
@@ -5768,7 +5578,7 @@ IDirect3DDeviceImpl_7_ApplyStateBlock(IDirect3DDevice7 *iface,
DWORD BlockHandle)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
- IWineD3DStateBlock *wined3d_sb;
+ struct wined3d_stateblock *wined3d_sb;
HRESULT hr;
TRACE("iface %p, stateblock %#x.\n", iface, BlockHandle);
@@ -5783,7 +5593,7 @@ IDirect3DDeviceImpl_7_ApplyStateBlock(IDirect3DDevice7 *iface,
return D3DERR_INVALIDSTATEBLOCK;
}
- hr = IWineD3DStateBlock_Apply(wined3d_sb);
+ hr = wined3d_stateblock_apply(wined3d_sb);
LeaveCriticalSection(&ddraw_cs);
return hr_ddraw_from_wined3d(hr);
@@ -5831,7 +5641,7 @@ IDirect3DDeviceImpl_7_CaptureStateBlock(IDirect3DDevice7 *iface,
DWORD BlockHandle)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
- IWineD3DStateBlock *wined3d_sb;
+ struct wined3d_stateblock *wined3d_sb;
HRESULT hr;
TRACE("iface %p, stateblock %#x.\n", iface, BlockHandle);
@@ -5846,7 +5656,7 @@ IDirect3DDeviceImpl_7_CaptureStateBlock(IDirect3DDevice7 *iface,
return D3DERR_INVALIDSTATEBLOCK;
}
- hr = IWineD3DStateBlock_Capture(wined3d_sb);
+ hr = wined3d_stateblock_capture(wined3d_sb);
LeaveCriticalSection(&ddraw_cs);
return hr_ddraw_from_wined3d(hr);
}
@@ -5892,7 +5702,7 @@ IDirect3DDeviceImpl_7_DeleteStateBlock(IDirect3DDevice7 *iface,
DWORD BlockHandle)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
- IWineD3DStateBlock *wined3d_sb;
+ struct wined3d_stateblock *wined3d_sb;
ULONG ref;
TRACE("iface %p, stateblock %#x.\n", iface, BlockHandle);
@@ -5907,7 +5717,7 @@ IDirect3DDeviceImpl_7_DeleteStateBlock(IDirect3DDevice7 *iface,
return D3DERR_INVALIDSTATEBLOCK;
}
- if ((ref = IWineD3DStateBlock_Release(wined3d_sb)))
+ if ((ref = wined3d_stateblock_decref(wined3d_sb)))
{
ERR("Something is still holding stateblock %p (refcount %u).\n", wined3d_sb, ref);
}
@@ -5959,7 +5769,7 @@ IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7 *iface,
DWORD *BlockHandle)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
- IWineD3DStateBlock *wined3d_sb;
+ struct wined3d_stateblock *wined3d_sb;
HRESULT hr;
DWORD h;
@@ -5979,7 +5789,7 @@ IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7 *iface,
EnterCriticalSection(&ddraw_cs);
/* The D3DSTATEBLOCKTYPE enum is fine here. */
- hr = IWineD3DDevice_CreateStateBlock(This->wineD3DDevice, Type, &wined3d_sb);
+ hr = wined3d_stateblock_create(This->wined3d_device, Type, &wined3d_sb);
if (FAILED(hr))
{
WARN("Failed to create stateblock, hr %#x.\n", hr);
@@ -5991,7 +5801,7 @@ IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7 *iface,
if (h == DDRAW_INVALID_HANDLE)
{
ERR("Failed to allocate stateblock handle.\n");
- IWineD3DStateBlock_Release(wined3d_sb);
+ wined3d_stateblock_decref(wined3d_sb);
LeaveCriticalSection(&ddraw_cs);
return DDERR_OUTOFMEMORY;
}
@@ -6135,19 +5945,20 @@ static void copy_mipmap_chain(IDirect3DDeviceImpl *device,
if (src_level->surface_desc.dwWidth == dest_level->surface_desc.dwWidth &&
src_level->surface_desc.dwHeight == dest_level->surface_desc.dwHeight)
{
- /* Try UpdateSurface that may perform a more direct opengl loading. But skip this if destination is paletted texture and has no palette.
- * Some games like Sacrifice set palette after Load, and it is a waste of effort to try to load texture without palette and generates
- * warnings in wined3d. */
+ /* Try UpdateSurface that may perform a more direct OpenGL
+ * loading. But skip this if destination is paletted texture and
+ * has no palette. Some games like Sacrifice set palette after
+ * Load, and it is a waste of effort to try to load texture
+ * without palette and generates warnings in wined3d. */
if (!palette_missing)
- hr = IWineD3DDevice_UpdateSurface(device->wineD3DDevice, src_level->WineD3DSurface, &rect, dest_level->WineD3DSurface,
- &point);
+ hr = wined3d_device_update_surface(device->wined3d_device, src_level->wined3d_surface,
+ &rect, dest_level->wined3d_surface, &point);
if (palette_missing || FAILED(hr))
{
/* UpdateSurface may fail e.g. if dest is in system memory. Fall back to BltFast that is less strict. */
- IWineD3DSurface_BltFast(dest_level->WineD3DSurface,
- point.x, point.y,
- src_level->WineD3DSurface, &rect, 0);
+ wined3d_surface_bltfast(dest_level->wined3d_surface, point.x, point.y,
+ src_level->wined3d_surface, &rect, 0);
}
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
@@ -6434,7 +6245,7 @@ IDirect3DDeviceImpl_7_LightEnable(IDirect3DDevice7 *iface,
TRACE("iface %p, light_idx %u, enabled %#x.\n", iface, LightIndex, Enable);
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_SetLightEnable(This->wineD3DDevice, LightIndex, Enable);
+ hr = wined3d_device_set_light_enable(This->wined3d_device, LightIndex, Enable);
LeaveCriticalSection(&ddraw_cs);
return hr_ddraw_from_wined3d(hr);
}
@@ -6493,7 +6304,7 @@ IDirect3DDeviceImpl_7_GetLightEnable(IDirect3DDevice7 *iface,
return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_GetLightEnable(This->wineD3DDevice, LightIndex, Enable);
+ hr = wined3d_device_get_light_enable(This->wined3d_device, LightIndex, Enable);
LeaveCriticalSection(&ddraw_cs);
return hr_ddraw_from_wined3d(hr);
}
@@ -6552,7 +6363,7 @@ IDirect3DDeviceImpl_7_SetClipPlane(IDirect3DDevice7 *iface,
return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_SetClipPlane(This->wineD3DDevice, Index, PlaneEquation);
+ hr = wined3d_device_set_clip_plane(This->wined3d_device, Index, PlaneEquation);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@@ -6609,7 +6420,7 @@ IDirect3DDeviceImpl_7_GetClipPlane(IDirect3DDevice7 *iface,
return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
- hr = IWineD3DDevice_GetClipPlane(This->wineD3DDevice, Index, PlaneEquation);
+ hr = wined3d_device_get_clip_plane(This->wined3d_device, Index, PlaneEquation);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
@@ -6800,23 +6611,23 @@ static const struct IDirect3DDevice7Vtbl d3d_device7_fpu_preserve_vtbl =
static const struct IDirect3DDevice3Vtbl d3d_device3_vtbl =
{
/*** IUnknown Methods ***/
- Thunk_IDirect3DDeviceImpl_3_QueryInterface,
- Thunk_IDirect3DDeviceImpl_3_AddRef,
- Thunk_IDirect3DDeviceImpl_3_Release,
+ IDirect3DDeviceImpl_3_QueryInterface,
+ IDirect3DDeviceImpl_3_AddRef,
+ IDirect3DDeviceImpl_3_Release,
/*** IDirect3DDevice3 ***/
IDirect3DDeviceImpl_3_GetCaps,
IDirect3DDeviceImpl_3_GetStats,
IDirect3DDeviceImpl_3_AddViewport,
IDirect3DDeviceImpl_3_DeleteViewport,
IDirect3DDeviceImpl_3_NextViewport,
- Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats,
- Thunk_IDirect3DDeviceImpl_3_BeginScene,
- Thunk_IDirect3DDeviceImpl_3_EndScene,
- Thunk_IDirect3DDeviceImpl_3_GetDirect3D,
+ IDirect3DDeviceImpl_3_EnumTextureFormats,
+ IDirect3DDeviceImpl_3_BeginScene,
+ IDirect3DDeviceImpl_3_EndScene,
+ IDirect3DDeviceImpl_3_GetDirect3D,
IDirect3DDeviceImpl_3_SetCurrentViewport,
IDirect3DDeviceImpl_3_GetCurrentViewport,
- Thunk_IDirect3DDeviceImpl_3_SetRenderTarget,
- Thunk_IDirect3DDeviceImpl_3_GetRenderTarget,
+ IDirect3DDeviceImpl_3_SetRenderTarget,
+ IDirect3DDeviceImpl_3_GetRenderTarget,
IDirect3DDeviceImpl_3_Begin,
IDirect3DDeviceImpl_3_BeginIndexed,
IDirect3DDeviceImpl_3_Vertex,
@@ -6826,90 +6637,90 @@ static const struct IDirect3DDevice3Vtbl d3d_device3_vtbl =
IDirect3DDeviceImpl_3_SetRenderState,
IDirect3DDeviceImpl_3_GetLightState,
IDirect3DDeviceImpl_3_SetLightState,
- Thunk_IDirect3DDeviceImpl_3_SetTransform,
- Thunk_IDirect3DDeviceImpl_3_GetTransform,
- Thunk_IDirect3DDeviceImpl_3_MultiplyTransform,
- Thunk_IDirect3DDeviceImpl_3_DrawPrimitive,
- Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive,
- Thunk_IDirect3DDeviceImpl_3_SetClipStatus,
- Thunk_IDirect3DDeviceImpl_3_GetClipStatus,
- Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided,
- Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided,
- Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB,
- Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB,
- Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility,
- Thunk_IDirect3DDeviceImpl_3_GetTexture,
+ IDirect3DDeviceImpl_3_SetTransform,
+ IDirect3DDeviceImpl_3_GetTransform,
+ IDirect3DDeviceImpl_3_MultiplyTransform,
+ IDirect3DDeviceImpl_3_DrawPrimitive,
+ IDirect3DDeviceImpl_3_DrawIndexedPrimitive,
+ IDirect3DDeviceImpl_3_SetClipStatus,
+ IDirect3DDeviceImpl_3_GetClipStatus,
+ IDirect3DDeviceImpl_3_DrawPrimitiveStrided,
+ IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided,
+ IDirect3DDeviceImpl_3_DrawPrimitiveVB,
+ IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB,
+ IDirect3DDeviceImpl_3_ComputeSphereVisibility,
+ IDirect3DDeviceImpl_3_GetTexture,
IDirect3DDeviceImpl_3_SetTexture,
- Thunk_IDirect3DDeviceImpl_3_GetTextureStageState,
- Thunk_IDirect3DDeviceImpl_3_SetTextureStageState,
- Thunk_IDirect3DDeviceImpl_3_ValidateDevice
+ IDirect3DDeviceImpl_3_GetTextureStageState,
+ IDirect3DDeviceImpl_3_SetTextureStageState,
+ IDirect3DDeviceImpl_3_ValidateDevice
};
static const struct IDirect3DDevice2Vtbl d3d_device2_vtbl =
{
/*** IUnknown Methods ***/
- Thunk_IDirect3DDeviceImpl_2_QueryInterface,
- Thunk_IDirect3DDeviceImpl_2_AddRef,
- Thunk_IDirect3DDeviceImpl_2_Release,
+ IDirect3DDeviceImpl_2_QueryInterface,
+ IDirect3DDeviceImpl_2_AddRef,
+ IDirect3DDeviceImpl_2_Release,
/*** IDirect3DDevice2 ***/
- Thunk_IDirect3DDeviceImpl_2_GetCaps,
+ IDirect3DDeviceImpl_2_GetCaps,
IDirect3DDeviceImpl_2_SwapTextureHandles,
- Thunk_IDirect3DDeviceImpl_2_GetStats,
- Thunk_IDirect3DDeviceImpl_2_AddViewport,
- Thunk_IDirect3DDeviceImpl_2_DeleteViewport,
- Thunk_IDirect3DDeviceImpl_2_NextViewport,
+ IDirect3DDeviceImpl_2_GetStats,
+ IDirect3DDeviceImpl_2_AddViewport,
+ IDirect3DDeviceImpl_2_DeleteViewport,
+ IDirect3DDeviceImpl_2_NextViewport,
IDirect3DDeviceImpl_2_EnumTextureFormats,
- Thunk_IDirect3DDeviceImpl_2_BeginScene,
- Thunk_IDirect3DDeviceImpl_2_EndScene,
- Thunk_IDirect3DDeviceImpl_2_GetDirect3D,
- Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport,
- Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport,
- Thunk_IDirect3DDeviceImpl_2_SetRenderTarget,
- Thunk_IDirect3DDeviceImpl_2_GetRenderTarget,
- Thunk_IDirect3DDeviceImpl_2_Begin,
- Thunk_IDirect3DDeviceImpl_2_BeginIndexed,
- Thunk_IDirect3DDeviceImpl_2_Vertex,
- Thunk_IDirect3DDeviceImpl_2_Index,
- Thunk_IDirect3DDeviceImpl_2_End,
- Thunk_IDirect3DDeviceImpl_2_GetRenderState,
- Thunk_IDirect3DDeviceImpl_2_SetRenderState,
- Thunk_IDirect3DDeviceImpl_2_GetLightState,
- Thunk_IDirect3DDeviceImpl_2_SetLightState,
- Thunk_IDirect3DDeviceImpl_2_SetTransform,
- Thunk_IDirect3DDeviceImpl_2_GetTransform,
- Thunk_IDirect3DDeviceImpl_2_MultiplyTransform,
- Thunk_IDirect3DDeviceImpl_2_DrawPrimitive,
- Thunk_IDirect3DDeviceImpl_2_DrawIndexedPrimitive,
- Thunk_IDirect3DDeviceImpl_2_SetClipStatus,
- Thunk_IDirect3DDeviceImpl_2_GetClipStatus
+ IDirect3DDeviceImpl_2_BeginScene,
+ IDirect3DDeviceImpl_2_EndScene,
+ IDirect3DDeviceImpl_2_GetDirect3D,
+ IDirect3DDeviceImpl_2_SetCurrentViewport,
+ IDirect3DDeviceImpl_2_GetCurrentViewport,
+ IDirect3DDeviceImpl_2_SetRenderTarget,
+ IDirect3DDeviceImpl_2_GetRenderTarget,
+ IDirect3DDeviceImpl_2_Begin,
+ IDirect3DDeviceImpl_2_BeginIndexed,
+ IDirect3DDeviceImpl_2_Vertex,
+ IDirect3DDeviceImpl_2_Index,
+ IDirect3DDeviceImpl_2_End,
+ IDirect3DDeviceImpl_2_GetRenderState,
+ IDirect3DDeviceImpl_2_SetRenderState,
+ IDirect3DDeviceImpl_2_GetLightState,
+ IDirect3DDeviceImpl_2_SetLightState,
+ IDirect3DDeviceImpl_2_SetTransform,
+ IDirect3DDeviceImpl_2_GetTransform,
+ IDirect3DDeviceImpl_2_MultiplyTransform,
+ IDirect3DDeviceImpl_2_DrawPrimitive,
+ IDirect3DDeviceImpl_2_DrawIndexedPrimitive,
+ IDirect3DDeviceImpl_2_SetClipStatus,
+ IDirect3DDeviceImpl_2_GetClipStatus
};
static const struct IDirect3DDeviceVtbl d3d_device1_vtbl =
{
/*** IUnknown Methods ***/
- Thunk_IDirect3DDeviceImpl_1_QueryInterface,
- Thunk_IDirect3DDeviceImpl_1_AddRef,
- Thunk_IDirect3DDeviceImpl_1_Release,
+ IDirect3DDeviceImpl_1_QueryInterface,
+ IDirect3DDeviceImpl_1_AddRef,
+ IDirect3DDeviceImpl_1_Release,
/*** IDirect3DDevice1 ***/
IDirect3DDeviceImpl_1_Initialize,
- Thunk_IDirect3DDeviceImpl_1_GetCaps,
- Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles,
+ IDirect3DDeviceImpl_1_GetCaps,
+ IDirect3DDeviceImpl_1_SwapTextureHandles,
IDirect3DDeviceImpl_1_CreateExecuteBuffer,
- Thunk_IDirect3DDeviceImpl_1_GetStats,
+ IDirect3DDeviceImpl_1_GetStats,
IDirect3DDeviceImpl_1_Execute,
- Thunk_IDirect3DDeviceImpl_1_AddViewport,
- Thunk_IDirect3DDeviceImpl_1_DeleteViewport,
- Thunk_IDirect3DDeviceImpl_1_NextViewport,
+ IDirect3DDeviceImpl_1_AddViewport,
+ IDirect3DDeviceImpl_1_DeleteViewport,
+ IDirect3DDeviceImpl_1_NextViewport,
IDirect3DDeviceImpl_1_Pick,
IDirect3DDeviceImpl_1_GetPickRecords,
- Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats,
+ IDirect3DDeviceImpl_1_EnumTextureFormats,
IDirect3DDeviceImpl_1_CreateMatrix,
IDirect3DDeviceImpl_1_SetMatrix,
IDirect3DDeviceImpl_1_GetMatrix,
IDirect3DDeviceImpl_1_DeleteMatrix,
- Thunk_IDirect3DDeviceImpl_1_BeginScene,
- Thunk_IDirect3DDeviceImpl_1_EndScene,
- Thunk_IDirect3DDeviceImpl_1_GetDirect3D
+ IDirect3DDeviceImpl_1_BeginScene,
+ IDirect3DDeviceImpl_1_EndScene,
+ IDirect3DDeviceImpl_1_GetDirect3D
};
/*****************************************************************************
@@ -6933,15 +6744,13 @@ IDirect3DDeviceImpl_UpdateDepthStencil(IDirect3DDeviceImpl *This)
if(!depthStencil)
{
TRACE("Setting wined3d depth stencil to NULL\n");
- IWineD3DDevice_SetDepthStencilSurface(This->wineD3DDevice,
- NULL);
+ wined3d_device_set_depth_stencil(This->wined3d_device, NULL);
return WINED3DZB_FALSE;
}
dsi = (IDirectDrawSurfaceImpl *)depthStencil;
- TRACE("Setting wined3d depth stencil to %p (wined3d %p)\n", dsi, dsi->WineD3DSurface);
- IWineD3DDevice_SetDepthStencilSurface(This->wineD3DDevice,
- dsi->WineD3DSurface);
+ TRACE("Setting wined3d depth stencil to %p (wined3d %p)\n", dsi, dsi->wined3d_surface);
+ wined3d_device_set_depth_stencil(This->wined3d_device, dsi->wined3d_surface);
IDirectDrawSurface7_Release(depthStencil);
return WINED3DZB_TRUE;
@@ -6949,7 +6758,6 @@ IDirect3DDeviceImpl_UpdateDepthStencil(IDirect3DDeviceImpl *This)
HRESULT d3d_device_init(IDirect3DDeviceImpl *device, IDirectDrawImpl *ddraw, IDirectDrawSurfaceImpl *target)
{
- IParentImpl *index_buffer_parent;
HRESULT hr;
if (ddraw->cooperative_level & DDSCL_FPUPRESERVE)
@@ -6963,6 +6771,7 @@ HRESULT d3d_device_init(IDirect3DDeviceImpl *device, IDirectDrawImpl *ddraw, IDi
device->ref = 1;
device->ddraw = ddraw;
device->target = target;
+ list_init(&device->viewport_list);
if (!ddraw_handle_table_init(&device->handle_table, 64))
{
@@ -6973,38 +6782,26 @@ HRESULT d3d_device_init(IDirect3DDeviceImpl *device, IDirectDrawImpl *ddraw, IDi
device->legacyTextureBlending = FALSE;
/* Create an index buffer, it's needed for indexed drawing */
- index_buffer_parent = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*index_buffer_parent));
- if (!index_buffer_parent)
- {
- ERR("Failed to allocate index buffer parent memory.\n");
- ddraw_handle_table_destroy(&device->handle_table);
- return DDERR_OUTOFMEMORY;
- }
-
- ddraw_parent_init(index_buffer_parent);
-
- hr = IWineD3DDevice_CreateIndexBuffer(ddraw->wineD3DDevice, 0x40000 /* Length. Don't know how long it should be */,
- WINED3DUSAGE_DYNAMIC /* Usage */, WINED3DPOOL_DEFAULT, index_buffer_parent,
+ hr = wined3d_buffer_create_ib(ddraw->wined3d_device, 0x40000 /* Length. Don't know how long it should be */,
+ WINED3DUSAGE_DYNAMIC /* Usage */, WINED3DPOOL_DEFAULT, NULL,
&ddraw_null_wined3d_parent_ops, &device->indexbuffer);
if (FAILED(hr))
{
ERR("Failed to create an index buffer, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, index_buffer_parent);
ddraw_handle_table_destroy(&device->handle_table);
return hr;
}
- index_buffer_parent->child = (IUnknown *)device->indexbuffer;
/* This is for convenience. */
- device->wineD3DDevice = ddraw->wineD3DDevice;
- IWineD3DDevice_AddRef(ddraw->wineD3DDevice);
+ device->wined3d_device = ddraw->wined3d_device;
+ wined3d_device_incref(ddraw->wined3d_device);
/* Render to the back buffer */
- hr = IWineD3DDevice_SetRenderTarget(ddraw->wineD3DDevice, 0, target->WineD3DSurface, TRUE);
+ hr = wined3d_device_set_render_target(ddraw->wined3d_device, 0, target->wined3d_surface, TRUE);
if (FAILED(hr))
{
ERR("Failed to set render target, hr %#x.\n", hr);
- IParent_Release((IParent *)index_buffer_parent);
+ wined3d_buffer_decref(device->indexbuffer);
ddraw_handle_table_destroy(&device->handle_table);
return hr;
}
@@ -7023,7 +6820,7 @@ HRESULT d3d_device_init(IDirect3DDeviceImpl *device, IDirectDrawImpl *ddraw, IDi
ddraw->d3ddevice = device;
- IWineD3DDevice_SetRenderState(ddraw->wineD3DDevice, WINED3DRS_ZENABLE,
+ wined3d_device_set_render_state(ddraw->wined3d_device, WINED3DRS_ZENABLE,
IDirect3DDeviceImpl_UpdateDepthStencil(device));
return D3D_OK;
diff --git a/reactos/dll/directx/wine/ddraw/executebuffer.c b/reactos/dll/directx/wine/ddraw/executebuffer.c
index d4d2dd0b72f..86a3aa9e581 100644
--- a/reactos/dll/directx/wine/ddraw/executebuffer.c
+++ b/reactos/dll/directx/wine/ddraw/executebuffer.c
@@ -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;
}
/*****************************************************************************
diff --git a/reactos/dll/directx/wine/ddraw/main.c b/reactos/dll/directx/wine/ddraw/main.c
index 217a2cbcff8..875e1947f8d 100644
--- a/reactos/dll/directx/wine/ddraw/main.c
+++ b/reactos/dll/directx/wine/ddraw/main.c
@@ -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));
}
}
diff --git a/reactos/dll/directx/wine/ddraw/material.c b/reactos/dll/directx/wine/ddraw/material.c
index 42d5edcbce5..e137bfcbed5 100644
--- a/reactos/dll/directx/wine/ddraw/material.c
+++ b/reactos/dll/directx/wine/ddraw/material.c
@@ -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
};
diff --git a/reactos/dll/directx/wine/ddraw/palette.c b/reactos/dll/directx/wine/ddraw/palette.c
index 7064ba02790..b68cf82d4f0 100644
--- a/reactos/dll/directx/wine/ddraw/palette.c
+++ b/reactos/dll/directx/wine/ddraw/palette.c
@@ -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;
diff --git a/reactos/dll/directx/wine/ddraw/surface.c b/reactos/dll/directx/wine/ddraw/surface.c
index cff2f95aab4..ee30d8666d3 100644
--- a/reactos/dll/directx/wine/ddraw/surface.c
+++ b/reactos/dll/directx/wine/ddraw/surface.c
@@ -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;
}
}
diff --git a/reactos/dll/directx/wine/ddraw/utils.c b/reactos/dll/directx/wine/ddraw/utils.c
index 039a3a05776..62e4b43ba90 100644
--- a/reactos/dll/directx/wine/ddraw/utils.c
+++ b/reactos/dll/directx/wine/ddraw/utils.c
@@ -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)
{
diff --git a/reactos/dll/directx/wine/ddraw/vertexbuffer.c b/reactos/dll/directx/wine/ddraw/vertexbuffer.c
index 36087f280f7..af4e8bcab84 100644
--- a/reactos/dll/directx/wine/ddraw/vertexbuffer.c
+++ b/reactos/dll/directx/wine/ddraw/vertexbuffer.c
@@ -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);
diff --git a/reactos/dll/directx/wine/ddraw/viewport.c b/reactos/dll/directx/wine/ddraw/viewport.c
index 6e0725e604e..08af7e2380f 100644
--- a/reactos/dll/directx/wine/ddraw/viewport.c
+++ b/reactos/dll/directx/wine/ddraw/viewport.c
@@ -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<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);
}
diff --git a/reactos/dll/directx/wine/wined3d/CMakeLists.txt b/reactos/dll/directx/wine/wined3d/CMakeLists.txt
index 4a45c3b7b58..bd8268f0fe3 100644
--- a/reactos/dll/directx/wine/wined3d/CMakeLists.txt
+++ b/reactos/dll/directx/wine/wined3d/CMakeLists.txt
@@ -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
diff --git a/reactos/dll/directx/wine/wined3d/arb_program_shader.c b/reactos/dll/directx/wine/wined3d/arb_program_shader.c
index c053e7faf10..ee5bf86d88a 100644
--- a/reactos/dll/directx/wine/wined3d/arb_program_shader.c
+++ b/reactos/dll/directx/wine/wined3d/arb_program_shader.c
@@ -78,47 +78,6 @@ static void shader_arb_dump_program_source(const char *source)
HeapFree(GetProcessHeap(), 0, tmp);
}
-/* GL locking for state handlers is done by the caller. */
-static BOOL need_rel_addr_const(IWineD3DBaseShaderImpl *shader, const struct wined3d_gl_info *gl_info)
-{
- if (shader->baseShader.reg_maps.shader_version.type == WINED3D_SHADER_TYPE_VERTEX)
- {
- if (((IWineD3DVertexShaderImpl *)shader)->rel_offset) return TRUE;
- }
- if (!shader->baseShader.reg_maps.usesmova) return FALSE;
- return !gl_info->supported[NV_VERTEX_PROGRAM2_OPTION];
-}
-
-/* Returns TRUE if result.clip from GL_NV_vertex_program2 should be used and FALSE otherwise */
-static inline BOOL use_nv_clip(const struct wined3d_gl_info *gl_info)
-{
- return gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]
- && !(gl_info->quirks & WINED3D_QUIRK_NV_CLIP_BROKEN);
-}
-
-static BOOL need_helper_const(IWineD3DBaseShaderImpl *shader, const struct wined3d_gl_info *gl_info)
-{
- if (need_rel_addr_const(shader, gl_info)) return TRUE;
- if (!gl_info->supported[NV_VERTEX_PROGRAM]) return TRUE; /* Need to init colors. */
- if (gl_info->quirks & WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT) return TRUE; /* Load the immval offset. */
- if (gl_info->quirks & WINED3D_QUIRK_SET_TEXCOORD_W) return TRUE; /* Have to init texcoords. */
- if (!use_nv_clip(gl_info)) return TRUE; /* Init the clip texcoord */
- if (shader->baseShader.reg_maps.usesnrm) return TRUE; /* 0.0 */
- if (shader->baseShader.reg_maps.usesrcp) return TRUE; /* EPS */
- return FALSE;
-}
-
-static unsigned int reserved_vs_const(IWineD3DBaseShaderImpl *shader, const struct wined3d_gl_info *gl_info)
-{
- unsigned int ret = 1;
- /* We use one PARAM for the pos fixup, and in some cases one to load
- * some immediate values into the shader
- */
- if(need_helper_const(shader, gl_info)) ret++;
- if(need_rel_addr_const(shader, gl_info)) ret++;
- return ret;
-}
-
enum arb_helper_value
{
ARB_ZERO,
@@ -145,7 +104,7 @@ static const char *arb_get_helper_value(enum wined3d_shader_type shader, enum ar
case ARB_ZERO: return "ps_helper_const.x";
case ARB_ONE: return "ps_helper_const.y";
case ARB_TWO: return "coefmul.x";
- case ARB_0001: return "helper_const.xxxy";
+ case ARB_0001: return "ps_helper_const.xxxy";
case ARB_EPS: return "ps_helper_const.z";
default: break;
}
@@ -335,6 +294,7 @@ struct arb_pshader_private {
struct arb_vshader_private {
struct arb_vs_compiled_shader *gl_shaders;
UINT num_gl_shaders, shader_array_size;
+ UINT rel_offset;
};
struct shader_arb_priv
@@ -355,9 +315,45 @@ struct shader_arb_priv
DWORD ps_sig_number;
};
-/********************************************************
- * ARB_[vertex/fragment]_program helper functions follow
- ********************************************************/
+/* GL locking for state handlers is done by the caller. */
+static BOOL need_rel_addr_const(const struct arb_vshader_private *shader_data,
+ const struct wined3d_shader_reg_maps *reg_maps, const struct wined3d_gl_info *gl_info)
+{
+ if (shader_data->rel_offset) return TRUE;
+ if (!reg_maps->usesmova) return FALSE;
+ return !gl_info->supported[NV_VERTEX_PROGRAM2_OPTION];
+}
+
+/* Returns TRUE if result.clip from GL_NV_vertex_program2 should be used and FALSE otherwise */
+static inline BOOL use_nv_clip(const struct wined3d_gl_info *gl_info)
+{
+ return gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]
+ && !(gl_info->quirks & WINED3D_QUIRK_NV_CLIP_BROKEN);
+}
+
+static BOOL need_helper_const(const struct arb_vshader_private *shader_data,
+ const struct wined3d_shader_reg_maps *reg_maps, const struct wined3d_gl_info *gl_info)
+{
+ if (need_rel_addr_const(shader_data, reg_maps, gl_info)) return TRUE;
+ if (!gl_info->supported[NV_VERTEX_PROGRAM]) return TRUE; /* Need to init colors. */
+ if (gl_info->quirks & WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT) return TRUE; /* Load the immval offset. */
+ if (gl_info->quirks & WINED3D_QUIRK_SET_TEXCOORD_W) return TRUE; /* Have to init texcoords. */
+ if (!use_nv_clip(gl_info)) return TRUE; /* Init the clip texcoord */
+ if (reg_maps->usesnrm) return TRUE; /* 0.0 */
+ if (reg_maps->usespow) return TRUE; /* EPS, 0.0 and 1.0 */
+ return FALSE;
+}
+
+static unsigned int reserved_vs_const(const struct arb_vshader_private *shader_data,
+ const struct wined3d_shader_reg_maps *reg_maps, const struct wined3d_gl_info *gl_info)
+{
+ unsigned int ret = 1;
+ /* We use one PARAM for the pos fixup, and in some cases one to load
+ * some immediate values into the shader. */
+ if (need_helper_const(shader_data, reg_maps, gl_info)) ++ret;
+ if (need_rel_addr_const(shader_data, reg_maps, gl_info)) ++ret;
+ return ret;
+}
/* Loads floating point constants into the currently set ARB_vertex/fragment_program.
* When constant_list == NULL, it will load all the constants.
@@ -366,7 +362,7 @@ struct shader_arb_priv
* or GL_FRAGMENT_PROGRAM_ARB (for pixel shaders)
*/
/* GL locking is done by the caller */
-static unsigned int shader_arb_load_constantsF(IWineD3DBaseShaderImpl *This, const struct wined3d_gl_info *gl_info,
+static unsigned int shader_arb_load_constantsF(struct wined3d_shader *shader, const struct wined3d_gl_info *gl_info,
GLuint target_type, unsigned int max_constants, const float *constants, char *dirty_consts)
{
local_constant* lconst;
@@ -386,7 +382,7 @@ static unsigned int shader_arb_load_constantsF(IWineD3DBaseShaderImpl *This, con
i = 0;
/* In 1.X pixel shaders constants are implicitly clamped in the range [-1;1] */
- if (target_type == GL_FRAGMENT_PROGRAM_ARB && This->baseShader.reg_maps.shader_version.major == 1)
+ if (target_type == GL_FRAGMENT_PROGRAM_ARB && shader->reg_maps.shader_version.major == 1)
{
float lcl_const[4];
/* ps 1.x supports only 8 constants, clamp only those. When switching between 1.x and higher
@@ -455,9 +451,12 @@ static unsigned int shader_arb_load_constantsF(IWineD3DBaseShaderImpl *This, con
checkGLcall("glProgramEnvParameter4fvARB()");
/* Load immediate constants */
- if(This->baseShader.load_local_constsF) {
- if (TRACE_ON(d3d_shader)) {
- LIST_FOR_EACH_ENTRY(lconst, &This->baseShader.constantsF, local_constant, entry) {
+ if (shader->load_local_constsF)
+ {
+ if (TRACE_ON(d3d_shader))
+ {
+ LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, local_constant, entry)
+ {
GLfloat* values = (GLfloat*)lconst->value;
TRACE_(d3d_constants)("Loading local constants %i: %f, %f, %f, %f\n", lconst->idx,
values[0], values[1], values[2], values[3]);
@@ -465,7 +464,8 @@ static unsigned int shader_arb_load_constantsF(IWineD3DBaseShaderImpl *This, con
}
/* Immediate constants are clamped for 1.X shaders at loading times */
ret = 0;
- LIST_FOR_EACH_ENTRY(lconst, &This->baseShader.constantsF, local_constant, entry) {
+ LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, local_constant, entry)
+ {
dirty_consts[lconst->idx] = 1; /* Dirtify so the non-immediate constant overwrites it next time */
ret = max(ret, lconst->idx + 1);
GL_EXTCALL(glProgramEnvParameter4fvARB(target_type, lconst->idx, (GLfloat*)lconst->value));
@@ -480,20 +480,13 @@ static unsigned int shader_arb_load_constantsF(IWineD3DBaseShaderImpl *This, con
/**
* Loads the texture dimensions for NP2 fixup into the currently set ARB_[vertex/fragment]_programs.
*/
-static void shader_arb_load_np2fixup_constants(
- IWineD3DDevice* device,
- char usePixelShader,
- char useVertexShader) {
+static void shader_arb_load_np2fixup_constants(void *shader_priv,
+ const struct wined3d_gl_info *gl_info, const struct wined3d_state *state)
+{
+ const struct shader_arb_priv * priv = shader_priv;
- IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl *) device;
- const struct shader_arb_priv* const priv = (const struct shader_arb_priv *) deviceImpl->shader_priv;
- IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock;
- const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info;
-
- if (!usePixelShader) {
- /* NP2 texcoord fixup is (currently) only done for pixelshaders. */
- return;
- }
+ /* NP2 texcoord fixup is (currently) only done for pixelshaders. */
+ if (!use_ps(state)) return;
if (priv->compiled_fprog && priv->compiled_fprog->np2fixup_info.super.active) {
const struct arb_ps_np2fixup_info* const fixup = &priv->compiled_fprog->np2fixup_info;
@@ -501,9 +494,10 @@ static void shader_arb_load_np2fixup_constants(
WORD active = fixup->super.active;
GLfloat np2fixup_constants[4 * MAX_FRAGMENT_SAMPLERS];
- for (i = 0; active; active >>= 1, ++i) {
+ for (i = 0; active; active >>= 1, ++i)
+ {
+ const struct wined3d_texture *tex = state->textures[i];
const unsigned char idx = fixup->super.idx[i];
- const IWineD3DBaseTextureImpl *tex = stateBlock->state.textures[i];
GLfloat *tex_dim = &np2fixup_constants[(idx >> 1) * 4];
if (!(active & 1)) continue;
@@ -513,10 +507,15 @@ static void shader_arb_load_np2fixup_constants(
continue;
}
- if (idx % 2) {
- tex_dim[2] = tex->baseTexture.pow2Matrix[0]; tex_dim[3] = tex->baseTexture.pow2Matrix[5];
- } else {
- tex_dim[0] = tex->baseTexture.pow2Matrix[0]; tex_dim[1] = tex->baseTexture.pow2Matrix[5];
+ if (idx % 2)
+ {
+ tex_dim[2] = tex->pow2_matrix[0];
+ tex_dim[3] = tex->pow2_matrix[5];
+ }
+ else
+ {
+ tex_dim[0] = tex->pow2_matrix[0];
+ tex_dim[1] = tex->pow2_matrix[5];
}
}
@@ -528,21 +527,18 @@ static void shader_arb_load_np2fixup_constants(
}
/* GL locking is done by the caller. */
-static inline void shader_arb_ps_local_constants(IWineD3DDeviceImpl* deviceImpl)
+static void shader_arb_ps_local_constants(const struct arb_ps_compiled_shader *gl_shader,
+ const struct wined3d_context *context, const struct wined3d_state *state, UINT rt_height)
{
- const struct wined3d_context *context = context_get_current();
- IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock;
const struct wined3d_gl_info *gl_info = context->gl_info;
unsigned char i;
- struct shader_arb_priv *priv = deviceImpl->shader_priv;
- const struct arb_ps_compiled_shader *gl_shader = priv->compiled_fprog;
for(i = 0; i < gl_shader->numbumpenvmatconsts; i++)
{
int texunit = gl_shader->bumpenvmatconst[i].texunit;
/* The state manager takes care that this function is always called if the bump env matrix changes */
- const float *data = (const float *)&stateBlock->state.texture_states[texunit][WINED3DTSS_BUMPENVMAT00];
+ const float *data = (const float *)&state->texture_states[texunit][WINED3DTSS_BUMPENVMAT00];
GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB,
gl_shader->bumpenvmatconst[i].const_num, data));
@@ -553,7 +549,7 @@ static inline void shader_arb_ps_local_constants(IWineD3DDeviceImpl* deviceImpl)
* don't care about them. The pointers are valid for sure because the stateblock is bigger.
* (they're WINED3DTSS_TEXTURETRANSFORMFLAGS and WINED3DTSS_ADDRESSW, so most likely 0 or NaN
*/
- const float *scale = (const float *)&stateBlock->state.texture_states[texunit][WINED3DTSS_BUMPENVLSCALE];
+ const float *scale = (const float *)&state->texture_states[texunit][WINED3DTSS_BUMPENVLSCALE];
GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB,
gl_shader->luminanceconst[i].const_num, scale));
}
@@ -568,8 +564,7 @@ static inline void shader_arb_ps_local_constants(IWineD3DDeviceImpl* deviceImpl)
* ycorrection.w: 0.0
*/
float val[4];
- val[0] = context->render_offscreen ? 0.0f
- : deviceImpl->render_targets[0]->currentDesc.Height;
+ val[0] = context->render_offscreen ? 0.0f : (float) rt_height;
val[1] = context->render_offscreen ? 1.0f : -1.0f;
val[2] = 1.0f;
val[3] = 0.0f;
@@ -584,9 +579,9 @@ static inline void shader_arb_ps_local_constants(IWineD3DDeviceImpl* deviceImpl)
if(gl_shader->int_consts[i] != WINED3D_CONST_NUM_UNUSED)
{
float val[4];
- val[0] = (float)stateBlock->state.ps_consts_i[4 * i];
- val[1] = (float)stateBlock->state.ps_consts_i[4 * i + 1];
- val[2] = (float)stateBlock->state.ps_consts_i[4 * i + 2];
+ val[0] = (float)state->ps_consts_i[4 * i];
+ val[1] = (float)state->ps_consts_i[4 * i + 1];
+ val[2] = (float)state->ps_consts_i[4 * i + 2];
val[3] = -1.0f;
GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, gl_shader->int_consts[i], val));
@@ -596,29 +591,27 @@ static inline void shader_arb_ps_local_constants(IWineD3DDeviceImpl* deviceImpl)
}
/* GL locking is done by the caller. */
-static inline void shader_arb_vs_local_constants(IWineD3DDeviceImpl* deviceImpl)
+static void shader_arb_vs_local_constants(const struct arb_vs_compiled_shader *gl_shader,
+ const struct wined3d_context *context, const struct wined3d_state *state)
{
- IWineD3DStateBlockImpl* stateBlock;
- const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info;
+ const struct wined3d_gl_info *gl_info = context->gl_info;
+ float position_fixup[4];
unsigned char i;
- struct shader_arb_priv *priv = deviceImpl->shader_priv;
- const struct arb_vs_compiled_shader *gl_shader = priv->compiled_vprog;
/* Upload the position fixup */
- GL_EXTCALL(glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, gl_shader->pos_fixup, deviceImpl->posFixup));
+ shader_get_position_fixup(context, state, position_fixup);
+ GL_EXTCALL(glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, gl_shader->pos_fixup, position_fixup));
if (!gl_shader->num_int_consts) return;
- stateBlock = deviceImpl->stateBlock;
-
for(i = 0; i < MAX_CONST_I; i++)
{
if(gl_shader->int_consts[i] != WINED3D_CONST_NUM_UNUSED)
{
float val[4];
- val[0] = (float)stateBlock->state.vs_consts_i[4 * i];
- val[1] = (float)stateBlock->state.vs_consts_i[4 * i + 1];
- val[2] = (float)stateBlock->state.vs_consts_i[4 * i + 2];
+ val[0] = (float)state->vs_consts_i[4 * i];
+ val[1] = (float)state->vs_consts_i[4 * i + 1];
+ val[2] = (float)state->vs_consts_i[4 * i + 2];
val[3] = -1.0f;
GL_EXTCALL(glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, gl_shader->int_consts[i], val));
@@ -636,83 +629,88 @@ static inline void shader_arb_vs_local_constants(IWineD3DDeviceImpl* deviceImpl)
/* GL locking is done by the caller (state handler) */
static void shader_arb_load_constants(const struct wined3d_context *context, char usePixelShader, char useVertexShader)
{
- IWineD3DDeviceImpl *device = context->swapchain->device;
- IWineD3DStateBlockImpl* stateBlock = device->stateBlock;
+ struct wined3d_device *device = context->swapchain->device;
+ struct wined3d_stateblock *stateBlock = device->stateBlock;
const struct wined3d_gl_info *gl_info = context->gl_info;
+ struct shader_arb_priv *priv = device->shader_priv;
if (useVertexShader)
{
- IWineD3DBaseShaderImpl *vshader = (IWineD3DBaseShaderImpl *)stateBlock->state.vertex_shader;
+ struct wined3d_shader *vshader = stateBlock->state.vertex_shader;
+ const struct arb_vs_compiled_shader *gl_shader = priv->compiled_vprog;
/* Load DirectX 9 float constants for vertex shader */
device->highest_dirty_vs_const = shader_arb_load_constantsF(vshader, gl_info, GL_VERTEX_PROGRAM_ARB,
device->highest_dirty_vs_const, stateBlock->state.vs_consts_f, context->vshader_const_dirty);
- shader_arb_vs_local_constants(device);
+ shader_arb_vs_local_constants(gl_shader, context, &stateBlock->state);
}
if (usePixelShader)
{
- IWineD3DBaseShaderImpl *pshader = (IWineD3DBaseShaderImpl *)stateBlock->state.pixel_shader;
+ struct wined3d_shader *pshader = stateBlock->state.pixel_shader;
+ const struct arb_ps_compiled_shader *gl_shader = priv->compiled_fprog;
+ UINT rt_height = device->fb.render_targets[0]->resource.height;
/* Load DirectX 9 float constants for pixel shader */
device->highest_dirty_ps_const = shader_arb_load_constantsF(pshader, gl_info, GL_FRAGMENT_PROGRAM_ARB,
device->highest_dirty_ps_const, stateBlock->state.ps_consts_f, context->pshader_const_dirty);
- shader_arb_ps_local_constants(device);
+ shader_arb_ps_local_constants(gl_shader, context, &stateBlock->state, rt_height);
}
}
-static void shader_arb_update_float_vertex_constants(IWineD3DDevice *iface, UINT start, UINT count)
+static void shader_arb_update_float_vertex_constants(struct wined3d_device *device, UINT start, UINT count)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
struct wined3d_context *context = context_get_current();
/* We don't want shader constant dirtification to be an O(contexts), so just dirtify the active
* context. On a context switch the old context will be fully dirtified */
- if (!context || context->swapchain->device != This) return;
+ if (!context || context->swapchain->device != device) return;
memset(context->vshader_const_dirty + start, 1, sizeof(*context->vshader_const_dirty) * count);
- This->highest_dirty_vs_const = max(This->highest_dirty_vs_const, start + count);
+ device->highest_dirty_vs_const = max(device->highest_dirty_vs_const, start + count);
}
-static void shader_arb_update_float_pixel_constants(IWineD3DDevice *iface, UINT start, UINT count)
+static void shader_arb_update_float_pixel_constants(struct wined3d_device *device, UINT start, UINT count)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
struct wined3d_context *context = context_get_current();
/* We don't want shader constant dirtification to be an O(contexts), so just dirtify the active
* context. On a context switch the old context will be fully dirtified */
- if (!context || context->swapchain->device != This) return;
+ if (!context || context->swapchain->device != device) return;
memset(context->pshader_const_dirty + start, 1, sizeof(*context->pshader_const_dirty) * count);
- This->highest_dirty_ps_const = max(This->highest_dirty_ps_const, start + count);
+ device->highest_dirty_ps_const = max(device->highest_dirty_ps_const, start + count);
}
-static DWORD *local_const_mapping(IWineD3DBaseShaderImpl *This)
+static DWORD *local_const_mapping(const struct wined3d_shader *shader)
{
DWORD *ret;
DWORD idx = 0;
const local_constant *lconst;
- if(This->baseShader.load_local_constsF || list_empty(&This->baseShader.constantsF)) return NULL;
+ if (shader->load_local_constsF || list_empty(&shader->constantsF))
+ return NULL;
- ret = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * This->baseShader.limits.constant_float);
- if(!ret) {
+ ret = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * shader->limits.constant_float);
+ if (!ret)
+ {
ERR("Out of memory\n");
return NULL;
}
- LIST_FOR_EACH_ENTRY(lconst, &This->baseShader.constantsF, local_constant, entry) {
+ LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, local_constant, entry)
+ {
ret[lconst->idx] = idx++;
}
return ret;
}
/* Generate the variable & register declarations for the ARB_vertex_program output target */
-static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const shader_reg_maps *reg_maps,
- struct wined3d_shader_buffer *buffer, const struct wined3d_gl_info *gl_info, DWORD *lconst_map,
+static DWORD shader_generate_arb_declarations(struct wined3d_shader *shader,
+ const struct wined3d_shader_reg_maps *reg_maps, struct wined3d_shader_buffer *buffer,
+ const struct wined3d_gl_info *gl_info, DWORD *lconst_map,
DWORD *num_clipplanes, struct shader_arb_ctx_priv *ctx)
{
- IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
DWORD i, next_local = 0;
char pshader = shader_is_pshader_version(reg_maps->shader_version.type);
unsigned max_constantsF;
@@ -738,6 +736,7 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s
}
else
{
+ const struct arb_vshader_private *shader_data = shader->backend_data;
max_constantsF = gl_info->limits.arb_vs_native_constants;
/* 96 is the minimum MAX_PROGRAM_ENV_PARAMETERS_ARB value.
* Also prevents max_constantsF from becoming less than 0 and
@@ -745,13 +744,14 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s
if (max_constantsF < 96)
max_constantsF = gl_info->limits.arb_vs_float_constants;
- if(This->baseShader.reg_maps.usesrelconstF) {
+ if (reg_maps->usesrelconstF)
+ {
DWORD highest_constf = 0, clip_limit;
- max_constantsF -= reserved_vs_const(This, gl_info);
- max_constantsF -= count_bits(This->baseShader.reg_maps.integer_constants);
+ max_constantsF -= reserved_vs_const(shader_data, reg_maps, gl_info);
+ max_constantsF -= count_bits(reg_maps->integer_constants);
- for(i = 0; i < This->baseShader.limits.constant_float; i++)
+ for (i = 0; i < shader->limits.constant_float; ++i)
{
DWORD idx = i >> 5;
DWORD shift = i & 0x1f;
@@ -805,8 +805,10 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s
/* Load local constants using the program-local space,
* this avoids reloading them each time the shader is used
*/
- if(lconst_map) {
- LIST_FOR_EACH_ENTRY(lconst, &This->baseShader.constantsF, local_constant, entry) {
+ if (lconst_map)
+ {
+ LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, local_constant, entry)
+ {
shader_addline(buffer, "PARAM C%u = program.local[%u];\n", lconst->idx,
lconst_map[lconst->idx]);
next_local = max(next_local, lconst_map[lconst->idx] + 1);
@@ -826,7 +828,7 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s
}
/* Avoid declaring more constants than needed */
- max_constantsF = min(max_constantsF, This->baseShader.limits.constant_float);
+ max_constantsF = min(max_constantsF, shader->limits.constant_float);
/* we use the array-based constants array if the local constants are marked for loading,
* because then we use indirect addressing, or when the local constant list is empty,
@@ -834,7 +836,8 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s
* local constants do not declare the loaded constants as an array because ARB compilers usually
* do not optimize unused constants away
*/
- if(This->baseShader.reg_maps.usesrelconstF) {
+ if (reg_maps->usesrelconstF)
+ {
/* Need to PARAM the environment parameters (constants) so we can use relative addressing */
shader_addline(buffer, "PARAM C[%d] = { program.env[0..%d] };\n",
max_constantsF, max_constantsF - 1);
@@ -843,7 +846,8 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s
DWORD idx, mask;
idx = i >> 5;
mask = 1 << (i & 0x1f);
- if(!shader_constant_is_local(This, i) && (This->baseShader.reg_maps.constf[idx] & mask)) {
+ if (!shader_constant_is_local(shader, i) && (reg_maps->constf[idx] & mask))
+ {
shader_addline(buffer, "PARAM C%d = program.env[%d];\n",i, i);
}
}
@@ -940,8 +944,9 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
{
/* oPos, oFog and oPts in D3D */
static const char * const rastout_reg_names[] = {"TMP_OUT", "result.fogcoord", "result.pointsize"};
- IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
- BOOL pshader = shader_is_pshader_version(This->baseShader.reg_maps.shader_version.type);
+ struct wined3d_shader *shader = ins->ctx->shader;
+ const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
+ BOOL pshader = shader_is_pshader_version(reg_maps->shader_version.type);
struct shader_arb_ctx_priv *ctx = ins->ctx->backend_data;
*is_color = FALSE;
@@ -955,7 +960,7 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
case WINED3DSPR_INPUT:
if (pshader)
{
- if(This->baseShader.reg_maps.shader_version.major < 3)
+ if (reg_maps->shader_version.major < 3)
{
if (!reg->idx) strcpy(register_name, "fragment.color.primary");
else strcpy(register_name, "fragment.color.secondary");
@@ -980,7 +985,7 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
sprintf(register_name, "out_of_bounds_%u", idx);
}
}
- else if(This->baseShader.reg_maps.input_registers & 0x0300)
+ else if (reg_maps->input_registers & 0x0300)
{
/* There are two ways basically:
*
@@ -1041,10 +1046,12 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
case WINED3DSPR_CONST:
if (!pshader && reg->rel_addr)
{
+ const struct arb_vshader_private *shader_data = shader->backend_data;
+ UINT rel_offset = shader_data->rel_offset;
BOOL aL = FALSE;
char rel_reg[50];
- UINT rel_offset = ((IWineD3DVertexShaderImpl *)This)->rel_offset;
- if(This->baseShader.reg_maps.shader_version.major < 2) {
+ if (reg_maps->shader_version.major < 2)
+ {
sprintf(rel_reg, "A0.x");
} else {
shader_arb_get_src_param(ins, reg->rel_addr, 0, rel_reg);
@@ -1067,7 +1074,7 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
}
else
{
- if (This->baseShader.reg_maps.usesrelconstF)
+ if (reg_maps->usesrelconstF)
sprintf(register_name, "C[%u]", reg->idx);
else
sprintf(register_name, "C%u", reg->idx);
@@ -1075,9 +1082,11 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
break;
case WINED3DSPR_TEXTURE: /* case WINED3DSPR_ADDR: */
- if (pshader) {
- if(This->baseShader.reg_maps.shader_version.major == 1 &&
- This->baseShader.reg_maps.shader_version.minor <= 3) {
+ if (pshader)
+ {
+ if (reg_maps->shader_version.major == 1
+ && reg_maps->shader_version.minor <= 3)
+ {
/* In ps <= 1.3, Tx is a temporary register as destination to all instructions,
* and as source to most instructions. For some instructions it is the texcoord
* input. Those instructions know about the special use
@@ -1090,7 +1099,7 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
}
else
{
- if(This->baseShader.reg_maps.shader_version.major == 1 || ctx->target_version >= NV2)
+ if (reg_maps->shader_version.major == 1 || ctx->target_version >= NV2)
{
sprintf(register_name, "A%u", reg->idx);
}
@@ -1109,7 +1118,7 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
else
{
if(ctx->cur_ps_args->super.srgb_correction) FIXME("sRGB correction on higher render targets\n");
- if(This->baseShader.reg_maps.highest_render_target > 0)
+ if (reg_maps->rt_mask > 1)
{
sprintf(register_name, "result.color[%u]", reg->idx);
}
@@ -1142,7 +1151,7 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction
}
else
{
- if(This->baseShader.reg_maps.shader_version.major < 3)
+ if (reg_maps->shader_version.major < 3)
{
strcpy(register_name, ctx->texcrd_output[reg->idx]);
}
@@ -1328,11 +1337,11 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
{
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
DWORD sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx];
- IWineD3DBaseTextureImpl *texture;
+ const struct wined3d_texture *texture;
const char *tex_type;
BOOL np2_fixup = FALSE;
- IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device;
+ struct wined3d_shader *shader = ins->ctx->shader;
+ struct wined3d_device *device = shader->device;
struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
const char *mod;
BOOL pshader = shader_is_pshader_version(ins->ctx->reg_maps->shader_version.type);
@@ -1347,7 +1356,7 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
case WINED3DSTT_2D:
texture = device->stateBlock->state.textures[sampler_idx];
- if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
+ if (texture && texture->target == GL_TEXTURE_RECTANGLE_ARB)
{
tex_type = "RECT";
} else {
@@ -1476,7 +1485,7 @@ static void shader_arb_get_src_param(const struct wined3d_shader_instruction *in
shader_addline(buffer, "MAD T%c, %s, %s, -%s;\n", 'A' + tmpreg, regstr, two, one);
break;
case WINED3DSPSM_SIGNNEG:
- shader_addline(buffer, "MAD T%c, %s, %s, %s;\n", 'A' + tmpreg, regstr, two, one);
+ shader_addline(buffer, "MAD T%c, %s, -%s, %s;\n", 'A' + tmpreg, regstr, two, one);
break;
case WINED3DSPSM_COMP:
shader_addline(buffer, "SUB T%c, %s, %s;\n", 'A' + tmpreg, one, regstr);
@@ -1579,7 +1588,6 @@ static void pshader_hw_cnd(const struct wined3d_shader_instruction *ins)
char src_name[3][50];
DWORD shader_version = WINED3D_SHADER_VERSION(ins->ctx->reg_maps->shader_version.major,
ins->ctx->reg_maps->shader_version.minor);
- BOOL is_color;
shader_arb_get_dst_param(ins, dst, dst_name);
shader_arb_get_src_param(ins, &ins->src[1], 1, src_name[1]);
@@ -1588,7 +1596,9 @@ static void pshader_hw_cnd(const struct wined3d_shader_instruction *ins)
if (shader_version <= WINED3D_SHADER_VERSION(1, 3) && ins->coissue)
{
shader_addline(buffer, "MOV%s %s, %s;\n", shader_arb_get_modifier(ins), dst_name, src_name[1]);
- } else {
+ }
+ else
+ {
struct wined3d_shader_src_param src0_copy = ins->src[0];
char extra_neg;
@@ -1598,15 +1608,8 @@ static void pshader_hw_cnd(const struct wined3d_shader_instruction *ins)
shader_arb_get_src_param(ins, &src0_copy, 0, src_name[0]);
shader_arb_get_src_param(ins, &ins->src[2], 2, src_name[2]);
shader_addline(buffer, "ADD TA, %c%s, coefdiv.x;\n", extra_neg, src_name[0]);
- /* No modifiers supported on CMP */
- shader_addline(buffer, "CMP %s, TA, %s, %s;\n", dst_name, src_name[1], src_name[2]);
-
- /* _SAT on CMP doesn't make much sense, but it is not a pure NOP */
- if(ins->dst[0].modifiers & WINED3DSPDM_SATURATE)
- {
- shader_arb_get_register_name(ins, &dst->reg, src_name[0], &is_color);
- shader_addline(buffer, "MOV_SAT %s, %s;\n", dst_name, dst_name);
- }
+ shader_addline(buffer, "CMP%s %s, TA, %s, %s;\n", shader_arb_get_modifier(ins),
+ dst_name, src_name[1], src_name[2]);
}
}
@@ -1616,7 +1619,6 @@ static void pshader_hw_cmp(const struct wined3d_shader_instruction *ins)
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
char dst_name[50];
char src_name[3][50];
- BOOL is_color;
shader_arb_get_dst_param(ins, dst, dst_name);
@@ -1625,15 +1627,8 @@ static void pshader_hw_cmp(const struct wined3d_shader_instruction *ins)
shader_arb_get_src_param(ins, &ins->src[1], 1, src_name[1]);
shader_arb_get_src_param(ins, &ins->src[2], 2, src_name[2]);
- /* No modifiers are supported on CMP */
- shader_addline(buffer, "CMP %s, %s, %s, %s;\n", dst_name,
- src_name[0], src_name[2], src_name[1]);
-
- if(ins->dst[0].modifiers & WINED3DSPDM_SATURATE)
- {
- shader_arb_get_register_name(ins, &dst->reg, src_name[0], &is_color);
- shader_addline(buffer, "MOV_SAT %s, %s;\n", dst_name, src_name[0]);
- }
+ shader_addline(buffer, "CMP%s %s, %s, %s, %s;\n", shader_arb_get_modifier(ins),
+ dst_name, src_name[0], src_name[2], src_name[1]);
}
/** Process the WINED3DSIO_DP2ADD instruction in ARB.
@@ -1747,17 +1742,20 @@ static void shader_hw_nop(const struct wined3d_shader_instruction *ins)
static void shader_hw_mov(const struct wined3d_shader_instruction *ins)
{
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
- BOOL pshader = shader_is_pshader_version(shader->baseShader.reg_maps.shader_version.type);
+ struct wined3d_shader *shader = ins->ctx->shader;
+ const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
+ BOOL pshader = shader_is_pshader_version(reg_maps->shader_version.type);
struct shader_arb_ctx_priv *ctx = ins->ctx->backend_data;
- const char *zero = arb_get_helper_value(shader->baseShader.reg_maps.shader_version.type, ARB_ZERO);
- const char *one = arb_get_helper_value(shader->baseShader.reg_maps.shader_version.type, ARB_ONE);
- const char *two = arb_get_helper_value(shader->baseShader.reg_maps.shader_version.type, ARB_TWO);
+ const char *zero = arb_get_helper_value(reg_maps->shader_version.type, ARB_ZERO);
+ const char *one = arb_get_helper_value(reg_maps->shader_version.type, ARB_ONE);
+ const char *two = arb_get_helper_value(reg_maps->shader_version.type, ARB_TWO);
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
char src0_param[256];
- if(ins->handler_idx == WINED3DSIH_MOVA) {
+ if (ins->handler_idx == WINED3DSIH_MOVA)
+ {
+ const struct arb_vshader_private *shader_data = shader->backend_data;
char write_mask[6];
const char *offset = arb_get_helper_value(WINED3D_SHADER_TYPE_VERTEX, ARB_VS_REL_OFFSET);
@@ -1784,19 +1782,22 @@ static void shader_hw_mov(const struct wined3d_shader_instruction *ins)
shader_addline(buffer, "ABS TA%s, %s;\n", write_mask, src0_param);
shader_addline(buffer, "ADD TA%s, TA, rel_addr_const.x;\n", write_mask);
shader_addline(buffer, "FLR TA%s, TA;\n", write_mask);
- if (((IWineD3DVertexShaderImpl *)shader)->rel_offset)
+ if (shader_data->rel_offset)
{
shader_addline(buffer, "ADD TA%s, TA, %s;\n", write_mask, offset);
}
shader_addline(buffer, "MUL A0_SHADOW%s, TA, A0_SHADOW;\n", write_mask);
((struct shader_arb_ctx_priv *)ins->ctx->backend_data)->addr_reg[0] = '\0';
- } else if (ins->ctx->reg_maps->shader_version.major == 1
- && !shader_is_pshader_version(ins->ctx->reg_maps->shader_version.type)
+ }
+ else if (reg_maps->shader_version.major == 1
+ && !shader_is_pshader_version(reg_maps->shader_version.type)
&& ins->dst[0].reg.type == WINED3DSPR_ADDR)
{
+ const struct arb_vshader_private *shader_data = shader->backend_data;
src0_param[0] = '\0';
- if (((IWineD3DVertexShaderImpl *)shader)->rel_offset)
+
+ if (shader_data->rel_offset)
{
const char *offset = arb_get_helper_value(WINED3D_SHADER_TYPE_VERTEX, ARB_VS_REL_OFFSET);
shader_arb_get_src_param(ins, &ins->src[0], 0, src0_param);
@@ -1816,8 +1817,7 @@ static void shader_hw_mov(const struct wined3d_shader_instruction *ins)
}
else if (ins->dst[0].reg.type == WINED3DSPR_COLOROUT && !ins->dst[0].reg.idx && pshader)
{
- IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) shader;
- if(ctx->cur_ps_args->super.srgb_correction && ps->color0_mov)
+ if (ctx->cur_ps_args->super.srgb_correction && shader->u.ps.color0_mov)
{
shader_addline(buffer, "#mov handled in srgb write code\n");
return;
@@ -2098,8 +2098,7 @@ static void pshader_hw_texm3x2pad(const struct wined3d_shader_instruction *ins)
static void pshader_hw_texm3x2tex(const struct wined3d_shader_instruction *ins)
{
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
- IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device;
+ struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
DWORD flags;
DWORD reg = ins->dst[0].reg.idx;
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
@@ -2114,14 +2113,13 @@ static void pshader_hw_texm3x2tex(const struct wined3d_shader_instruction *ins)
shader_arb_get_dst_param(ins, &ins->dst[0], dst_str);
shader_arb_get_src_param(ins, &ins->src[0], 0, src0_name);
shader_addline(buffer, "DP3 %s.y, fragment.texcoord[%u], %s;\n", dst_reg, reg, src0_name);
- flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->state.texture_states[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0;
+ flags = reg < MAX_TEXTURES ? priv->cur_ps_args->super.tex_transform >> reg * WINED3D_PSARGS_TEXTRANSFORM_SHIFT : 0;
shader_hw_sample(ins, reg, dst_str, dst_reg, flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0, NULL, NULL);
}
static void pshader_hw_texm3x3pad(const struct wined3d_shader_instruction *ins)
{
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
- SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state;
+ struct wined3d_shader_tex_mx *tex_mx = ins->ctx->tex_mx;
DWORD reg = ins->dst[0].reg.idx;
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
char src0_name[50], dst_name[50];
@@ -2132,20 +2130,19 @@ static void pshader_hw_texm3x3pad(const struct wined3d_shader_instruction *ins)
* incrementing ins->dst[0].register_idx numbers. So the pad instruction already knows the final destination
* register, and this register is uninitialized(otherwise the assembler complains that it is 'redeclared')
*/
- tmp_reg.idx = reg + 2 - current_state->current_row;
+ tmp_reg.idx = reg + 2 - tex_mx->current_row;
shader_arb_get_register_name(ins, &tmp_reg, dst_name, &is_color);
shader_arb_get_src_param(ins, &ins->src[0], 0, src0_name);
shader_addline(buffer, "DP3 %s.%c, fragment.texcoord[%u], %s;\n",
- dst_name, 'x' + current_state->current_row, reg, src0_name);
- current_state->texcoord_w[current_state->current_row++] = reg;
+ dst_name, 'x' + tex_mx->current_row, reg, src0_name);
+ tex_mx->texcoord_w[tex_mx->current_row++] = reg;
}
static void pshader_hw_texm3x3tex(const struct wined3d_shader_instruction *ins)
{
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
- IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device;
- SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state;
+ struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
+ struct wined3d_shader_tex_mx *tex_mx = ins->ctx->tex_mx;
DWORD flags;
DWORD reg = ins->dst[0].reg.idx;
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
@@ -2159,16 +2156,15 @@ static void pshader_hw_texm3x3tex(const struct wined3d_shader_instruction *ins)
/* Sample the texture using the calculated coordinates */
shader_arb_get_dst_param(ins, &ins->dst[0], dst_str);
- flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->state.texture_states[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0;
+ flags = reg < MAX_TEXTURES ? priv->cur_ps_args->super.tex_transform >> reg * WINED3D_PSARGS_TEXTRANSFORM_SHIFT : 0;
shader_hw_sample(ins, reg, dst_str, dst_name, flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0, NULL, NULL);
- current_state->current_row = 0;
+ tex_mx->current_row = 0;
}
static void pshader_hw_texm3x3vspec(const struct wined3d_shader_instruction *ins)
{
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
- IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device;
- SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state;
+ struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
+ struct wined3d_shader_tex_mx *tex_mx = ins->ctx->tex_mx;
DWORD flags;
DWORD reg = ins->dst[0].reg.idx;
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
@@ -2185,8 +2181,8 @@ static void pshader_hw_texm3x3vspec(const struct wined3d_shader_instruction *ins
shader_addline(buffer, "DP3 %s.z, fragment.texcoord[%u], %s;\n", dst_reg, reg, src0_name);
/* Construct the eye-ray vector from w coordinates */
- shader_addline(buffer, "MOV TB.x, fragment.texcoord[%u].w;\n", current_state->texcoord_w[0]);
- shader_addline(buffer, "MOV TB.y, fragment.texcoord[%u].w;\n", current_state->texcoord_w[1]);
+ shader_addline(buffer, "MOV TB.x, fragment.texcoord[%u].w;\n", tex_mx->texcoord_w[0]);
+ shader_addline(buffer, "MOV TB.y, fragment.texcoord[%u].w;\n", tex_mx->texcoord_w[1]);
shader_addline(buffer, "MOV TB.z, fragment.texcoord[%u].w;\n", reg);
/* Calculate reflection vector
@@ -2201,16 +2197,15 @@ static void pshader_hw_texm3x3vspec(const struct wined3d_shader_instruction *ins
/* Sample the texture using the calculated coordinates */
shader_arb_get_dst_param(ins, &ins->dst[0], dst_str);
- flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->state.texture_states[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0;
+ flags = reg < MAX_TEXTURES ? priv->cur_ps_args->super.tex_transform >> reg * WINED3D_PSARGS_TEXTRANSFORM_SHIFT : 0;
shader_hw_sample(ins, reg, dst_str, dst_reg, flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0, NULL, NULL);
- current_state->current_row = 0;
+ tex_mx->current_row = 0;
}
static void pshader_hw_texm3x3spec(const struct wined3d_shader_instruction *ins)
{
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
- IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device;
- SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state;
+ struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
+ struct wined3d_shader_tex_mx *tex_mx = ins->ctx->tex_mx;
DWORD flags;
DWORD reg = ins->dst[0].reg.idx;
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
@@ -2243,9 +2238,9 @@ static void pshader_hw_texm3x3spec(const struct wined3d_shader_instruction *ins)
/* Sample the texture using the calculated coordinates */
shader_arb_get_dst_param(ins, &ins->dst[0], dst_str);
- flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->state.texture_states[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0;
+ flags = reg < MAX_TEXTURES ? priv->cur_ps_args->super.tex_transform >> reg * WINED3D_PSARGS_TEXTRANSFORM_SHIFT : 0;
shader_hw_sample(ins, reg, dst_str, dst_reg, flags & WINED3DTTFF_PROJECTED ? TEX_PROJ : 0, NULL, NULL);
- current_state->current_row = 0;
+ tex_mx->current_row = 0;
}
static void pshader_hw_texdepth(const struct wined3d_shader_instruction *ins)
@@ -2415,8 +2410,6 @@ static void shader_hw_mnxn(const struct wined3d_shader_instruction *ins)
static void shader_hw_rcp(const struct wined3d_shader_instruction *ins)
{
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
- struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
- const char *flt_eps = arb_get_helper_value(ins->ctx->reg_maps->shader_version.type, ARB_EPS);
char dst[50];
char src[50];
@@ -2431,23 +2424,7 @@ static void shader_hw_rcp(const struct wined3d_shader_instruction *ins)
strcat(src, ".w");
}
- /* TODO: If the destination is readable, and not the same as the source, the destination
- * can be used instead of TA
- */
- if (priv->target_version >= NV2)
- {
- shader_addline(buffer, "MOVC TA.x, %s;\n", src);
- shader_addline(buffer, "MOV TA.x (EQ.x), %s;\n", flt_eps);
- shader_addline(buffer, "RCP%s %s, TA.x;\n", shader_arb_get_modifier(ins), dst);
- }
- else
- {
- const char *zero = arb_get_helper_value(ins->ctx->reg_maps->shader_version.type, ARB_ZERO);
- shader_addline(buffer, "ABS TA.x, %s;\n", src);
- shader_addline(buffer, "SGE TA.y, -TA.x, %s;\n", zero);
- shader_addline(buffer, "MAD TA.x, TA.y, %s, %s;\n", flt_eps, src);
- shader_addline(buffer, "RCP%s %s, TA.x;\n", shader_arb_get_modifier(ins), dst);
- }
+ shader_addline(buffer, "RCP%s %s, %s;\n", shader_arb_get_modifier(ins), dst, src);
}
static void shader_hw_scalar_op(const struct wined3d_shader_instruction *ins)
@@ -2743,47 +2720,33 @@ static DWORD abs_modifier(DWORD mod, BOOL *need_abs)
return mod;
}
-static void shader_hw_log_pow(const struct wined3d_shader_instruction *ins)
+static void shader_hw_log(const struct wined3d_shader_instruction *ins)
{
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
- char src0[50], src1[50], dst[50];
+ char src0[50], dst[50];
struct wined3d_shader_src_param src0_copy = ins->src[0];
BOOL need_abs = FALSE;
const char *instr;
- BOOL arg2 = FALSE;
switch(ins->handler_idx)
{
case WINED3DSIH_LOG: instr = "LG2"; break;
case WINED3DSIH_LOGP: instr = "LOG"; break;
- case WINED3DSIH_POW: instr = "POW"; arg2 = TRUE; break;
default:
ERR("Unexpected instruction %d\n", ins->handler_idx);
return;
}
- /* LOG, LOGP and POW operate on the absolute value of the input */
+ /* LOG and LOGP operate on the absolute value of the input */
src0_copy.modifiers = abs_modifier(src0_copy.modifiers, &need_abs);
shader_arb_get_dst_param(ins, &ins->dst[0], dst);
shader_arb_get_src_param(ins, &src0_copy, 0, src0);
- if(arg2) shader_arb_get_src_param(ins, &ins->src[1], 1, src1);
if(need_abs)
{
shader_addline(buffer, "ABS TA, %s;\n", src0);
- if(arg2)
- {
- shader_addline(buffer, "%s%s %s, TA, %s;\n", instr, shader_arb_get_modifier(ins), dst, src1);
- }
- else
- {
- shader_addline(buffer, "%s%s %s, TA;\n", instr, shader_arb_get_modifier(ins), dst);
- }
- }
- else if(arg2)
- {
- shader_addline(buffer, "%s%s %s, %s, %s;\n", instr, shader_arb_get_modifier(ins), dst, src0, src1);
+ shader_addline(buffer, "%s%s %s, TA;\n", instr, shader_arb_get_modifier(ins), dst);
}
else
{
@@ -2791,6 +2754,48 @@ static void shader_hw_log_pow(const struct wined3d_shader_instruction *ins)
}
}
+static void shader_hw_pow(const struct wined3d_shader_instruction *ins)
+{
+ struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
+ char src0[50], src1[50], dst[50];
+ struct wined3d_shader_src_param src0_copy = ins->src[0];
+ BOOL need_abs = FALSE;
+ struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
+ const char *one = arb_get_helper_value(ins->ctx->reg_maps->shader_version.type, ARB_ONE);
+
+ /* POW operates on the absolute value of the input */
+ src0_copy.modifiers = abs_modifier(src0_copy.modifiers, &need_abs);
+
+ shader_arb_get_dst_param(ins, &ins->dst[0], dst);
+ shader_arb_get_src_param(ins, &src0_copy, 0, src0);
+ shader_arb_get_src_param(ins, &ins->src[1], 1, src1);
+
+ if (need_abs)
+ shader_addline(buffer, "ABS TA.x, %s;\n", src0);
+ else
+ shader_addline(buffer, "MOV TA.x, %s;\n", src0);
+
+ if (priv->target_version >= NV2)
+ {
+ shader_addline(buffer, "MOVC TA.y, %s;\n", src1);
+ shader_addline(buffer, "POW%s %s, TA.x, TA.y;\n", shader_arb_get_modifier(ins), dst);
+ shader_addline(buffer, "MOV %s (EQ.y), %s;\n", dst, one);
+ }
+ else
+ {
+ const char *zero = arb_get_helper_value(ins->ctx->reg_maps->shader_version.type, ARB_ZERO);
+ const char *flt_eps = arb_get_helper_value(ins->ctx->reg_maps->shader_version.type, ARB_EPS);
+
+ shader_addline(buffer, "ABS TA.y, %s;\n", src1);
+ shader_addline(buffer, "SGE TA.y, -TA.y, %s;\n", zero);
+ /* Possibly add flt_eps to avoid getting float special values */
+ shader_addline(buffer, "MAD TA.z, TA.y, %s, %s;\n", flt_eps, src1);
+ shader_addline(buffer, "POW%s TA.x, TA.x, TA.z;\n", shader_arb_get_modifier(ins));
+ shader_addline(buffer, "MAD TA.x, -TA.x, TA.y, TA.x;\n");
+ shader_addline(buffer, "MAD %s, TA.y, %s, TA.x;\n", dst, one);
+ }
+}
+
static void shader_hw_loop(const struct wined3d_shader_instruction *ins)
{
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
@@ -3101,12 +3106,11 @@ static void shader_hw_label(const struct wined3d_shader_instruction *ins)
shader_addline(buffer, "l%u:\n", ins->src[0].reg.idx);
}
-static void vshader_add_footer(IWineD3DVertexShaderImpl *This, struct wined3d_shader_buffer *buffer,
- const struct arb_vs_compile_args *args, struct shader_arb_ctx_priv *priv_ctx)
+static void vshader_add_footer(struct shader_arb_ctx_priv *priv_ctx,
+ const struct arb_vshader_private *shader_data, const struct arb_vs_compile_args *args,
+ const struct wined3d_shader_reg_maps *reg_maps, const struct wined3d_gl_info *gl_info,
+ struct wined3d_shader_buffer *buffer)
{
- const shader_reg_maps *reg_maps = &This->baseShader.reg_maps;
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)This->baseShader.device;
- const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
unsigned int i;
/* The D3DRS_FOGTABLEMODE render state defines if the shader-generated fog coord is used
@@ -3114,35 +3118,24 @@ static void vshader_add_footer(IWineD3DVertexShaderImpl *This, struct wined3d_sh
* the fog frag coord is thrown away. If the fog frag coord is used, but not written by
* the shader, it is set to 0.0(fully fogged, since start = 1.0, end = 0.0)
*/
- if(args->super.fog_src == VS_FOG_Z) {
+ if (args->super.fog_src == VS_FOG_Z)
shader_addline(buffer, "MOV result.fogcoord, TMP_OUT.z;\n");
- } else if (!reg_maps->fog) {
- /* posFixup.x is always 1.0, so we can savely use it */
+ else if (!reg_maps->fog)
+ /* posFixup.x is always 1.0, so we can safely use it */
shader_addline(buffer, "ADD result.fogcoord, posFixup.x, -posFixup.x;\n");
- }
- /* Write the final position.
- *
- * OpenGL coordinates specify the center of the pixel while d3d coords specify
- * the corner. The offsets are stored in z and w in posFixup. posFixup.y contains
- * 1.0 or -1.0 to turn the rendering upside down for offscreen rendering. PosFixup.x
- * contains 1.0 to allow a mad, but arb vs swizzles are too restricted for that.
- */
- shader_addline(buffer, "MUL TA, posFixup, TMP_OUT.w;\n");
- shader_addline(buffer, "ADD TMP_OUT.x, TMP_OUT.x, TA.z;\n");
- shader_addline(buffer, "MAD TMP_OUT.y, TMP_OUT.y, posFixup.y, TA.w;\n");
-
- if(use_nv_clip(gl_info) && priv_ctx->target_version >= NV2)
+ /* Clipplanes are always stored without y inversion */
+ if (use_nv_clip(gl_info) && priv_ctx->target_version >= NV2)
{
- if(args->super.clip_enabled)
+ if (args->super.clip_enabled)
{
- for(i = 0; i < priv_ctx->vs_clipplanes; i++)
+ for (i = 0; i < priv_ctx->vs_clipplanes; i++)
{
shader_addline(buffer, "DP4 result.clip[%u].x, TMP_OUT, state.clip[%u].plane;\n", i, i);
}
}
}
- else if(args->clip.boolclip.clip_texcoord)
+ else if (args->clip.boolclip.clip_texcoord)
{
unsigned int cur_clip = 0;
char component[4] = {'x', 'y', 'z', 'w'};
@@ -3150,13 +3143,13 @@ static void vshader_add_footer(IWineD3DVertexShaderImpl *This, struct wined3d_sh
for (i = 0; i < gl_info->limits.clipplanes; ++i)
{
- if(args->clip.boolclip.clipplane_mask & (1 << i))
+ if (args->clip.boolclip.clipplane_mask & (1 << i))
{
shader_addline(buffer, "DP4 TA.%c, TMP_OUT, state.clip[%u].plane;\n",
component[cur_clip++], i);
}
}
- switch(cur_clip)
+ switch (cur_clip)
{
case 0:
shader_addline(buffer, "MOV TA, %s;\n", zero);
@@ -3175,13 +3168,27 @@ static void vshader_add_footer(IWineD3DVertexShaderImpl *This, struct wined3d_sh
args->clip.boolclip.clip_texcoord - 1);
}
+ /* Write the final position.
+ *
+ * OpenGL coordinates specify the center of the pixel while d3d coords specify
+ * the corner. The offsets are stored in z and w in posFixup. posFixup.y contains
+ * 1.0 or -1.0 to turn the rendering upside down for offscreen rendering. PosFixup.x
+ * contains 1.0 to allow a mad, but arb vs swizzles are too restricted for that.
+ */
+ shader_addline(buffer, "MUL TA, posFixup, TMP_OUT.w;\n");
+ shader_addline(buffer, "ADD TMP_OUT.x, TMP_OUT.x, TA.z;\n");
+ shader_addline(buffer, "MAD TMP_OUT.y, TMP_OUT.y, posFixup.y, TA.w;\n");
+
/* Z coord [0;1]->[-1;1] mapping, see comment in transform_projection in state.c
* and the glsl equivalent
*/
- if(need_helper_const((IWineD3DBaseShaderImpl *) This, gl_info)) {
+ if (need_helper_const(shader_data, reg_maps, gl_info))
+ {
const char *two = arb_get_helper_value(WINED3D_SHADER_TYPE_VERTEX, ARB_TWO);
shader_addline(buffer, "MAD TMP_OUT.z, TMP_OUT.z, %s, -TMP_OUT.w;\n", two);
- } else {
+ }
+ else
+ {
shader_addline(buffer, "ADD TMP_OUT.z, TMP_OUT.z, TMP_OUT.z;\n");
shader_addline(buffer, "ADD TMP_OUT.z, TMP_OUT.z, -TMP_OUT.w;\n");
}
@@ -3195,14 +3202,15 @@ static void shader_hw_ret(const struct wined3d_shader_instruction *ins)
{
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *) ins->ctx->shader;
+ struct wined3d_shader *shader = ins->ctx->shader;
BOOL vshader = shader_is_vshader_version(ins->ctx->reg_maps->shader_version.type);
if(priv->target_version == ARB) return;
if(vshader)
{
- if(priv->in_main_func) vshader_add_footer((IWineD3DVertexShaderImpl *) shader, buffer, priv->cur_vs_args, priv);
+ if (priv->in_main_func) vshader_add_footer(priv, shader->backend_data,
+ priv->cur_vs_args, ins->ctx->reg_maps, ins->ctx->gl_info, buffer);
}
shader_addline(buffer, "RET;\n");
@@ -3401,11 +3409,11 @@ static void arbfp_add_sRGB_correction(struct wined3d_shader_buffer *buffer, cons
/* [0.0;1.0] clamping. Not needed, this is done implicitly */
}
-static const DWORD *find_loop_control_values(IWineD3DBaseShaderImpl *This, DWORD idx)
+static const DWORD *find_loop_control_values(const struct wined3d_shader *shader, DWORD idx)
{
const local_constant *constant;
- LIST_FOR_EACH_ENTRY(constant, &This->baseShader.constantsI, local_constant, entry)
+ LIST_FOR_EACH_ENTRY(constant, &shader->constantsI, local_constant, entry)
{
if (constant->idx == idx)
{
@@ -3415,8 +3423,8 @@ static const DWORD *find_loop_control_values(IWineD3DBaseShaderImpl *This, DWORD
return NULL;
}
-static void init_ps_input(const IWineD3DPixelShaderImpl *This, const struct arb_ps_compile_args *args,
- struct shader_arb_ctx_priv *priv)
+static void init_ps_input(const struct wined3d_shader *shader,
+ const struct arb_ps_compile_args *args, struct shader_arb_ctx_priv *priv)
{
static const char * const texcoords[8] =
{
@@ -3424,7 +3432,7 @@ static void init_ps_input(const IWineD3DPixelShaderImpl *This, const struct arb_
"fragment.texcoord[4]", "fragment.texcoord[5]", "fragment.texcoord[6]", "fragment.texcoord[7]"
};
unsigned int i;
- const struct wined3d_shader_signature_element *sig = This->baseShader.input_signature;
+ const struct wined3d_shader_signature_element *sig = shader->input_signature;
const char *semantic_name;
DWORD semantic_idx;
@@ -3490,20 +3498,20 @@ static void init_ps_input(const IWineD3DPixelShaderImpl *This, const struct arb_
}
/* GL locking is done by the caller */
-static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct wined3d_shader_buffer *buffer,
+static GLuint shader_arb_generate_pshader(struct wined3d_shader *shader,
+ const struct wined3d_gl_info *gl_info, struct wined3d_shader_buffer *buffer,
const struct arb_ps_compile_args *args, struct arb_ps_compiled_shader *compiled)
{
- const shader_reg_maps* reg_maps = &This->baseShader.reg_maps;
- CONST DWORD *function = This->baseShader.function;
- const struct wined3d_gl_info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info;
+ const struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
+ const DWORD *function = shader->function;
const local_constant *lconst;
GLuint retval;
char fragcolor[16];
- DWORD *lconst_map = local_const_mapping((IWineD3DBaseShaderImpl *) This), next_local, cur;
+ DWORD *lconst_map = local_const_mapping(shader), next_local;
struct shader_arb_ctx_priv priv_ctx;
BOOL dcl_td = FALSE;
BOOL want_nv_prog = FALSE;
- struct arb_pshader_private *shader_priv = This->baseShader.backend_data;
+ struct arb_pshader_private *shader_priv = shader->backend_data;
GLint errPos;
DWORD map;
@@ -3513,7 +3521,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct
for (i = 0, map = reg_maps->temporary; map; map >>= 1, ++i)
{
if (!(map & 1)
- || (This->color0_mov && i == This->color0_reg)
+ || (shader->u.ps.color0_mov && i == shader->u.ps.color0_reg)
|| (reg_maps->shader_version.major < 2 && !i))
continue;
@@ -3551,7 +3559,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct
priv_ctx.cur_ps_args = args;
priv_ctx.compiled_fprog = compiled;
priv_ctx.cur_np2fixup_info = &compiled->np2fixup_info;
- init_ps_input(This, args, &priv_ctx);
+ init_ps_input(shader, args, &priv_ctx);
list_init(&priv_ctx.control_frames);
/* Avoid enabling NV_fragment_program* if we do not need it.
@@ -3593,7 +3601,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct
priv_ctx.target_version = ARB;
}
- if(This->baseShader.reg_maps.highest_render_target > 0)
+ if (reg_maps->rt_mask > 1)
{
shader_addline(buffer, "OPTION ARB_draw_buffers;\n");
}
@@ -3630,11 +3638,17 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct
if (reg_maps->shader_version.major < 2)
{
strcpy(fragcolor, "R0");
- } else {
- if(args->super.srgb_correction) {
- if(This->color0_mov) {
- sprintf(fragcolor, "R%u", This->color0_reg);
- } else {
+ }
+ else
+ {
+ if (args->super.srgb_correction)
+ {
+ if (shader->u.ps.color0_mov)
+ {
+ sprintf(fragcolor, "R%u", shader->u.ps.color0_reg);
+ }
+ else
+ {
shader_addline(buffer, "TEMP TMP_COLOR;\n");
strcpy(fragcolor, "TMP_COLOR");
}
@@ -3651,18 +3665,20 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct
}
/* Base Declarations */
- next_local = shader_generate_arb_declarations((IWineD3DBaseShader *)This,
- reg_maps, buffer, gl_info, lconst_map, NULL, &priv_ctx);
+ next_local = shader_generate_arb_declarations(shader, reg_maps,
+ buffer, gl_info, lconst_map, NULL, &priv_ctx);
for (i = 0, map = reg_maps->bumpmat; map; map >>= 1, ++i)
{
+ unsigned char bump_const;
+
if (!(map & 1)) continue;
- cur = compiled->numbumpenvmatconsts;
- compiled->bumpenvmatconst[cur].const_num = WINED3D_CONST_NUM_UNUSED;
- compiled->bumpenvmatconst[cur].texunit = i;
- compiled->luminanceconst[cur].const_num = WINED3D_CONST_NUM_UNUSED;
- compiled->luminanceconst[cur].texunit = i;
+ bump_const = compiled->numbumpenvmatconsts;
+ compiled->bumpenvmatconst[bump_const].const_num = WINED3D_CONST_NUM_UNUSED;
+ compiled->bumpenvmatconst[bump_const].texunit = i;
+ compiled->luminanceconst[bump_const].const_num = WINED3D_CONST_NUM_UNUSED;
+ compiled->luminanceconst[bump_const].texunit = i;
/* We can fit the constants into the constant limit for sure because texbem, texbeml, bem and beml are only supported
* in 1.x shaders, and GL_ARB_fragment_program has a constant limit of 24 constants. So in the worst case we're loading
@@ -3673,16 +3689,16 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct
* shaders in newer shader models. Since the bump env parameters have to share their space with NP2 fixup constants,
* their location is shader dependent anyway and they cannot be loaded globally.
*/
- compiled->bumpenvmatconst[cur].const_num = next_local++;
+ compiled->bumpenvmatconst[bump_const].const_num = next_local++;
shader_addline(buffer, "PARAM bumpenvmat%d = program.local[%d];\n",
- i, compiled->bumpenvmatconst[cur].const_num);
- compiled->numbumpenvmatconsts = cur + 1;
+ i, compiled->bumpenvmatconst[bump_const].const_num);
+ compiled->numbumpenvmatconsts = bump_const + 1;
if (!(reg_maps->luminanceparams & (1 << i))) continue;
- compiled->luminanceconst[cur].const_num = next_local++;
+ compiled->luminanceconst[bump_const].const_num = next_local++;
shader_addline(buffer, "PARAM luminance%d = program.local[%d];\n",
- i, compiled->luminanceconst[cur].const_num);
+ i, compiled->luminanceconst[bump_const].const_num);
}
for(i = 0; i < MAX_CONST_I; i++)
@@ -3690,7 +3706,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct
compiled->int_consts[i] = WINED3D_CONST_NUM_UNUSED;
if (reg_maps->integer_constants & (1 << i) && priv_ctx.target_version >= NV2)
{
- const DWORD *control_values = find_loop_control_values((IWineD3DBaseShaderImpl *) This, i);
+ const DWORD *control_values = find_loop_control_values(shader, i);
if(control_values)
{
@@ -3735,6 +3751,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct
* applied / activated. This will probably result in wrong rendering of the texture, but will save us from
* shader compilation errors and the subsequent errors when drawing with this shader. */
if (priv_ctx.cur_ps_args->super.np2_fixup) {
+ unsigned char cur_fixup_sampler = 0;
struct arb_ps_np2fixup_info* const fixup = priv_ctx.cur_np2fixup_info;
const WORD map = priv_ctx.cur_ps_args->super.np2_fixup;
@@ -3743,13 +3760,12 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct
fixup->offset = next_local;
fixup->super.active = 0;
- cur = 0;
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i) {
if (!(map & (1 << i))) continue;
- if (fixup->offset + (cur >> 1) < max_lconsts) {
+ if (fixup->offset + (cur_fixup_sampler >> 1) < max_lconsts) {
fixup->super.active |= (1 << i);
- fixup->super.idx[i] = cur++;
+ fixup->super.idx[i] = cur_fixup_sampler++;
} else {
FIXME("No free constant found to load NP2 fixup data into shader. "
"Sampling from this texture will probably look wrong.\n");
@@ -3757,7 +3773,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct
}
}
- fixup->super.num_consts = (cur + 1) >> 1;
+ fixup->super.num_consts = (cur_fixup_sampler + 1) >> 1;
if (fixup->super.num_consts) {
shader_addline(buffer, "PARAM np2fixup[%u] = { program.env[%u..%u] };\n",
fixup->super.num_consts, fixup->offset, fixup->super.num_consts + fixup->offset - 1);
@@ -3772,7 +3788,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct
}
/* Base Shader Body */
- shader_generate_main((IWineD3DBaseShader *)This, buffer, reg_maps, function, &priv_ctx);
+ shader_generate_main(shader, buffer, reg_maps, function, &priv_ctx);
if(args->super.srgb_correction) {
arbfp_add_sRGB_correction(buffer, fragcolor, srgbtmp[0], srgbtmp[1], srgbtmp[2], srgbtmp[3],
@@ -3814,8 +3830,10 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct
}
/* Load immediate constants */
- if(lconst_map) {
- LIST_FOR_EACH_ENTRY(lconst, &This->baseShader.constantsF, local_constant, entry) {
+ if (lconst_map)
+ {
+ LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, local_constant, entry)
+ {
const float *value = (const float *)lconst->value;
GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, lconst_map[lconst->idx], value));
checkGLcall("glProgramLocalParameter4fvARB");
@@ -3843,7 +3861,7 @@ static int compare_sig(const struct wined3d_shader_signature_element *sig1, cons
if ((ret = strcmp(sig1[i].semantic_name, sig2[i].semantic_name))) return ret;
if(sig1[i].semantic_idx != sig2[i].semantic_idx) return sig1[i].semantic_idx < sig2[i].semantic_idx ? -1 : 1;
if(sig1[i].sysval_semantic != sig2[i].sysval_semantic) return sig1[i].sysval_semantic < sig2[i].sysval_semantic ? -1 : 1;
- if(sig1[i].component_type != sig2[i].component_type) return sig1[i].sysval_semantic < sig2[i].component_type ? -1 : 1;
+ if(sig1[i].component_type != sig2[i].component_type) return sig1[i].component_type < sig2[i].component_type ? -1 : 1;
if(sig1[i].register_idx != sig2[i].register_idx) return sig1[i].register_idx < sig2[i].register_idx ? -1 : 1;
if(sig1[i].mask != sig2->mask) return sig1[i].mask < sig2[i].mask ? -1 : 1;
}
@@ -3892,8 +3910,8 @@ static DWORD find_input_signature(struct shader_arb_priv *priv, const struct win
return found_sig->idx;
}
-static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_num, struct shader_arb_ctx_priv *priv_ctx,
- struct arb_vs_compiled_shader *compiled)
+static void init_output_registers(struct wined3d_shader *shader, DWORD sig_num,
+ struct shader_arb_ctx_priv *priv_ctx, struct arb_vs_compiled_shader *compiled)
{
unsigned int i, j;
static const char * const texcoords[8] =
@@ -3901,8 +3919,7 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
"result.texcoord[0]", "result.texcoord[1]", "result.texcoord[2]", "result.texcoord[3]",
"result.texcoord[4]", "result.texcoord[5]", "result.texcoord[6]", "result.texcoord[7]"
};
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) shader->baseShader.device;
- IWineD3DBaseShaderClass *baseshader = &shader->baseShader;
+ struct wined3d_device *device = shader->device;
const struct wined3d_shader_signature_element *sig;
const char *semantic_name;
DWORD semantic_idx, reg_idx;
@@ -3930,42 +3947,42 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
priv_ctx->fog_output = "result.fogcoord";
/* Map declared regs to builtins. Use "TA" to /dev/null unread output */
- for (i = 0; i < (sizeof(baseshader->output_signature) / sizeof(*baseshader->output_signature)); ++i)
+ for (i = 0; i < (sizeof(shader->output_signature) / sizeof(*shader->output_signature)); ++i)
{
- semantic_name = baseshader->output_signature[i].semantic_name;
+ semantic_name = shader->output_signature[i].semantic_name;
if (!semantic_name) continue;
if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION))
{
TRACE("o%u is TMP_OUT\n", i);
- if (!baseshader->output_signature[i].semantic_idx) priv_ctx->vs_output[i] = "TMP_OUT";
+ if (!shader->output_signature[i].semantic_idx) priv_ctx->vs_output[i] = "TMP_OUT";
else priv_ctx->vs_output[i] = "TA";
}
else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE))
{
TRACE("o%u is result.pointsize\n", i);
- if (!baseshader->output_signature[i].semantic_idx) priv_ctx->vs_output[i] = "result.pointsize";
+ if (!shader->output_signature[i].semantic_idx) priv_ctx->vs_output[i] = "result.pointsize";
else priv_ctx->vs_output[i] = "TA";
}
else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_COLOR))
{
- TRACE("o%u is result.color.?, idx %u\n", i, baseshader->output_signature[i].semantic_idx);
- if (!baseshader->output_signature[i].semantic_idx)
+ TRACE("o%u is result.color.?, idx %u\n", i, shader->output_signature[i].semantic_idx);
+ if (!shader->output_signature[i].semantic_idx)
priv_ctx->vs_output[i] = "result.color.primary";
- else if (baseshader->output_signature[i].semantic_idx == 1)
+ else if (shader->output_signature[i].semantic_idx == 1)
priv_ctx->vs_output[i] = "result.color.secondary";
else priv_ctx->vs_output[i] = "TA";
}
else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_TEXCOORD))
{
- TRACE("o%u is %s\n", i, texcoords[baseshader->output_signature[i].semantic_idx]);
- if (baseshader->output_signature[i].semantic_idx >= 8) priv_ctx->vs_output[i] = "TA";
- else priv_ctx->vs_output[i] = texcoords[baseshader->output_signature[i].semantic_idx];
+ TRACE("o%u is %s\n", i, texcoords[shader->output_signature[i].semantic_idx]);
+ if (shader->output_signature[i].semantic_idx >= 8) priv_ctx->vs_output[i] = "TA";
+ else priv_ctx->vs_output[i] = texcoords[shader->output_signature[i].semantic_idx];
}
else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_FOG))
{
TRACE("o%u is result.fogcoord\n", i);
- if (baseshader->output_signature[i].semantic_idx > 0) priv_ctx->vs_output[i] = "TA";
+ if (shader->output_signature[i].semantic_idx > 0) priv_ctx->vs_output[i] = "TA";
else priv_ctx->vs_output[i] = "result.fogcoord";
}
else
@@ -3979,7 +3996,7 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
/* Instead of searching for the signature in the signature list, read the one from the current pixel shader.
* Its maybe not the shader where the signature came from, but it is the same signature and faster to find
*/
- sig = device->stateBlock->state.pixel_shader->baseShader.input_signature;
+ sig = device->stateBlock->state.pixel_shader->input_signature;
TRACE("Pixel shader uses declared varyings\n");
/* Map builtin to declared. /dev/null the results by default to the TA temp reg */
@@ -4029,21 +4046,21 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
}
/* Map declared to declared */
- for (i = 0; i < (sizeof(baseshader->output_signature) / sizeof(*baseshader->output_signature)); ++i)
+ for (i = 0; i < (sizeof(shader->output_signature) / sizeof(*shader->output_signature)); ++i)
{
/* Write unread output to TA to throw them away */
priv_ctx->vs_output[i] = "TA";
- semantic_name = baseshader->output_signature[i].semantic_name;
+ semantic_name = shader->output_signature[i].semantic_name;
if (!semantic_name) continue;
if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION)
- && !baseshader->output_signature[i].semantic_idx)
+ && !shader->output_signature[i].semantic_idx)
{
priv_ctx->vs_output[i] = "TMP_OUT";
continue;
}
else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE)
- && !baseshader->output_signature[i].semantic_idx)
+ && !shader->output_signature[i].semantic_idx)
{
priv_ctx->vs_output[i] = "result.pointsize";
continue;
@@ -4054,7 +4071,7 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
if (!sig[j].semantic_name) continue;
if (!strcmp(sig[j].semantic_name, semantic_name)
- && sig[j].semantic_idx == baseshader->output_signature[i].semantic_idx)
+ && sig[j].semantic_idx == shader->output_signature[i].semantic_idx)
{
priv_ctx->vs_output[i] = decl_idx_to_string[sig[j].register_idx];
@@ -4069,16 +4086,16 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
}
/* GL locking is done by the caller */
-static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, struct wined3d_shader_buffer *buffer,
+static GLuint shader_arb_generate_vshader(struct wined3d_shader *shader,
+ const struct wined3d_gl_info *gl_info, struct wined3d_shader_buffer *buffer,
const struct arb_vs_compile_args *args, struct arb_vs_compiled_shader *compiled)
{
- const shader_reg_maps *reg_maps = &This->baseShader.reg_maps;
- CONST DWORD *function = This->baseShader.function;
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)This->baseShader.device;
- const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+ const struct arb_vshader_private *shader_data = shader->backend_data;
+ const struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
+ const DWORD *function = shader->function;
const local_constant *lconst;
GLuint ret;
- DWORD next_local, *lconst_map = local_const_mapping((IWineD3DBaseShaderImpl *) This);
+ DWORD next_local, *lconst_map = local_const_mapping(shader);
struct shader_arb_ctx_priv priv_ctx;
unsigned int i;
GLint errPos;
@@ -4086,7 +4103,7 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, struct
memset(&priv_ctx, 0, sizeof(priv_ctx));
priv_ctx.cur_vs_args = args;
list_init(&priv_ctx.control_frames);
- init_output_registers(This, args->ps_signature, &priv_ctx, compiled);
+ init_output_registers(shader, args->ps_signature, &priv_ctx, compiled);
/* Create the hw ARB shader */
shader_addline(buffer, "!!ARBvp1.0\n");
@@ -4110,26 +4127,29 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, struct
}
shader_addline(buffer, "TEMP TMP_OUT;\n");
- if(need_helper_const((IWineD3DBaseShaderImpl *) This, gl_info)) {
+ if (need_helper_const(shader_data, reg_maps, gl_info))
+ {
shader_addline(buffer, "PARAM helper_const = { 0.0, 1.0, 2.0, %1.10f};\n", eps);
}
- if(need_rel_addr_const((IWineD3DBaseShaderImpl *) This, gl_info)) {
- shader_addline(buffer, "PARAM rel_addr_const = { 0.5, %d.0, 0.0, 0.0 };\n", This->rel_offset);
+ if (need_rel_addr_const(shader_data, reg_maps, gl_info))
+ {
+ shader_addline(buffer, "PARAM rel_addr_const = { 0.5, %d.0, 0.0, 0.0 };\n", shader_data->rel_offset);
shader_addline(buffer, "TEMP A0_SHADOW;\n");
}
shader_addline(buffer, "TEMP TA;\n");
+ shader_addline(buffer, "TEMP TB;\n");
/* Base Declarations */
- next_local = shader_generate_arb_declarations((IWineD3DBaseShader *)This,
- reg_maps, buffer, gl_info, lconst_map, &priv_ctx.vs_clipplanes, &priv_ctx);
+ next_local = shader_generate_arb_declarations(shader, reg_maps, buffer,
+ gl_info, lconst_map, &priv_ctx.vs_clipplanes, &priv_ctx);
for(i = 0; i < MAX_CONST_I; i++)
{
compiled->int_consts[i] = WINED3D_CONST_NUM_UNUSED;
if(reg_maps->integer_constants & (1 << i) && priv_ctx.target_version >= NV2)
{
- const DWORD *control_values = find_loop_control_values((IWineD3DBaseShaderImpl *) This, i);
+ const DWORD *control_values = find_loop_control_values(shader, i);
if(control_values)
{
@@ -4162,6 +4182,7 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, struct
*/
if (!gl_info->supported[NV_VERTEX_PROGRAM])
{
+ struct wined3d_device *device = shader->device;
const char *color_init = arb_get_helper_value(WINED3D_SHADER_TYPE_VERTEX, ARB_0001);
shader_addline(buffer, "MOV result.color.secondary, %s;\n", color_init);
@@ -4171,8 +4192,7 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, struct
const char *one = arb_get_helper_value(WINED3D_SHADER_TYPE_VERTEX, ARB_ONE);
for(i = 0; i < min(8, MAX_REG_TEXCRD); i++)
{
- if (This->baseShader.reg_maps.texcoord_mask[i]
- && This->baseShader.reg_maps.texcoord_mask[i] != WINED3DSP_WRITEMASK_ALL)
+ if (reg_maps->texcoord_mask[i] && reg_maps->texcoord_mask[i] != WINED3DSP_WRITEMASK_ALL)
shader_addline(buffer, "MOV result.texcoord[%u].w, %s\n", i, one);
}
}
@@ -4181,9 +4201,10 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, struct
/* The shader starts with the main function */
priv_ctx.in_main_func = TRUE;
/* Base Shader Body */
- shader_generate_main((IWineD3DBaseShader *)This, buffer, reg_maps, function, &priv_ctx);
+ shader_generate_main(shader, buffer, reg_maps, function, &priv_ctx);
- if(!priv_ctx.footer_written) vshader_add_footer(This, buffer, args, &priv_ctx);
+ if (!priv_ctx.footer_written) vshader_add_footer(&priv_ctx,
+ shader_data, args, reg_maps, gl_info, buffer);
shader_addline(buffer, "END\n");
@@ -4216,8 +4237,10 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, struct
if (!native) WARN("Program exceeds native resource limits.\n");
/* Load immediate constants */
- if(lconst_map) {
- LIST_FOR_EACH_ENTRY(lconst, &This->baseShader.constantsF, local_constant, entry) {
+ if (lconst_map)
+ {
+ LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, local_constant, entry)
+ {
const float *value = (const float *)lconst->value;
GL_EXTCALL(glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, lconst_map[lconst->idx], value));
}
@@ -4229,9 +4252,11 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, struct
}
/* GL locking is done by the caller */
-static struct arb_ps_compiled_shader *find_arb_pshader(IWineD3DPixelShaderImpl *shader, const struct arb_ps_compile_args *args)
+static struct arb_ps_compiled_shader *find_arb_pshader(struct wined3d_shader *shader,
+ const struct arb_ps_compile_args *args)
{
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)shader->baseShader.device;
+ struct wined3d_device *device = shader->device;
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
UINT i;
DWORD new_size;
struct arb_ps_compiled_shader *new_array;
@@ -4239,28 +4264,29 @@ static struct arb_ps_compiled_shader *find_arb_pshader(IWineD3DPixelShaderImpl *
struct arb_pshader_private *shader_data;
GLuint ret;
- if (!shader->baseShader.backend_data)
+ if (!shader->backend_data)
{
- const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct shader_arb_priv *priv = device->shader_priv;
- shader->baseShader.backend_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
- shader_data = shader->baseShader.backend_data;
- shader_data->clamp_consts = shader->baseShader.reg_maps.shader_version.major == 1;
+ shader->backend_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
+ shader_data = shader->backend_data;
+ shader_data->clamp_consts = shader->reg_maps.shader_version.major == 1;
- if(shader->baseShader.reg_maps.shader_version.major < 3) shader_data->input_signature_idx = ~0;
- else shader_data->input_signature_idx = find_input_signature(priv, shader->baseShader.input_signature);
+ if (shader->reg_maps.shader_version.major < 3)
+ shader_data->input_signature_idx = ~0;
+ else
+ shader_data->input_signature_idx = find_input_signature(priv, shader->input_signature);
shader_data->has_signature_idx = TRUE;
TRACE("Shader got assigned input signature index %u\n", shader_data->input_signature_idx);
if (!device->vs_clipping)
- shader_data->clipplane_emulation = shader_find_free_input_register(&shader->baseShader.reg_maps,
+ shader_data->clipplane_emulation = shader_find_free_input_register(&shader->reg_maps,
gl_info->limits.texture_stages - 1);
else
shader_data->clipplane_emulation = ~0U;
}
- shader_data = shader->baseShader.backend_data;
+ shader_data = shader->backend_data;
/* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
* so a linear search is more performant than a hashmap or a binary search
@@ -4294,8 +4320,7 @@ static struct arb_ps_compiled_shader *find_arb_pshader(IWineD3DPixelShaderImpl *
shader_data->gl_shaders[shader_data->num_gl_shaders].args = *args;
- pixelshader_update_samplers(&shader->baseShader.reg_maps,
- (IWineD3DBaseTexture **)device->stateBlock->state.textures);
+ pixelshader_update_samplers(&shader->reg_maps, device->stateBlock->state.textures);
if (!shader_buffer_init(&buffer))
{
@@ -4303,8 +4328,8 @@ static struct arb_ps_compiled_shader *find_arb_pshader(IWineD3DPixelShaderImpl *
return 0;
}
- ret = shader_arb_generate_pshader(shader, &buffer, args,
- &shader_data->gl_shaders[shader_data->num_gl_shaders]);
+ ret = shader_arb_generate_pshader(shader, gl_info, &buffer, args,
+ &shader_data->gl_shaders[shader_data->num_gl_shaders]);
shader_buffer_free(&buffer);
shader_data->gl_shaders[shader_data->num_gl_shaders].prgId = ret;
@@ -4324,22 +4349,42 @@ static inline BOOL vs_args_equal(const struct arb_vs_compile_args *stored, const
return !memcmp(stored->loop_ctrl, new->loop_ctrl, sizeof(stored->loop_ctrl));
}
-static struct arb_vs_compiled_shader *find_arb_vshader(IWineD3DVertexShaderImpl *shader, const struct arb_vs_compile_args *args)
+static struct arb_vs_compiled_shader *find_arb_vshader(struct wined3d_shader *shader,
+ const struct arb_vs_compile_args *args)
{
+ struct wined3d_device *device = shader->device;
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+ DWORD use_map = device->strided_streams.use_map;
UINT i;
DWORD new_size;
struct arb_vs_compiled_shader *new_array;
- DWORD use_map = ((IWineD3DDeviceImpl *)shader->baseShader.device)->strided_streams.use_map;
struct wined3d_shader_buffer buffer;
struct arb_vshader_private *shader_data;
GLuint ret;
- const struct wined3d_gl_info *gl_info = &((IWineD3DDeviceImpl *)shader->baseShader.device)->adapter->gl_info;
- if (!shader->baseShader.backend_data)
+ if (!shader->backend_data)
{
- shader->baseShader.backend_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
+ const struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
+
+ shader->backend_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
+ shader_data = shader->backend_data;
+
+ if ((gl_info->quirks & WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT)
+ && reg_maps->min_rel_offset <= reg_maps->max_rel_offset)
+ {
+ if (reg_maps->max_rel_offset - reg_maps->min_rel_offset > 127)
+ {
+ FIXME("The difference between the minimum and maximum relative offset is > 127.\n");
+ FIXME("Which this OpenGL implementation does not support. Try using GLSL.\n");
+ FIXME("Min: %u, Max: %u.\n", reg_maps->min_rel_offset, reg_maps->max_rel_offset);
+ }
+ else if (reg_maps->max_rel_offset - reg_maps->min_rel_offset > 63)
+ shader_data->rel_offset = reg_maps->min_rel_offset + 63;
+ else if (reg_maps->max_rel_offset > 63)
+ shader_data->rel_offset = reg_maps->min_rel_offset;
+ }
}
- shader_data = shader->baseShader.backend_data;
+ shader_data = shader->backend_data;
/* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
* so a linear search is more performant than a hashmap or a binary search
@@ -4382,7 +4427,7 @@ static struct arb_vs_compiled_shader *find_arb_vshader(IWineD3DVertexShaderImpl
return 0;
}
- ret = shader_arb_generate_vshader(shader, &buffer, args,
+ ret = shader_arb_generate_vshader(shader, gl_info, &buffer, args,
&shader_data->gl_shaders[shader_data->num_gl_shaders]);
shader_buffer_free(&buffer);
shader_data->gl_shaders[shader_data->num_gl_shaders].prgId = ret;
@@ -4391,16 +4436,17 @@ static struct arb_vs_compiled_shader *find_arb_vshader(IWineD3DVertexShaderImpl
}
static void find_arb_ps_compile_args(const struct wined3d_state *state,
- IWineD3DPixelShaderImpl *shader, struct arb_ps_compile_args *args)
+ const struct wined3d_shader *shader, struct arb_ps_compile_args *args)
{
+ struct wined3d_device *device = shader->device;
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
int i;
WORD int_skip;
- const struct wined3d_gl_info *gl_info = &((IWineD3DDeviceImpl *)shader->baseShader.device)->adapter->gl_info;
find_ps_compile_args(state, shader, &args->super);
/* This forces all local boolean constants to 1 to make them stateblock independent */
- args->bools = shader->baseShader.reg_maps.local_bool_consts;
+ args->bools = shader->reg_maps.local_bool_consts;
for(i = 0; i < MAX_CONST_B; i++)
{
@@ -4412,7 +4458,7 @@ static void find_arb_ps_compile_args(const struct wined3d_state *state,
* is quite expensive because it forces the driver to disable early Z discards. It is cheaper to
* duplicate the shader than have a no-op KIL instruction in every shader
*/
- if ((!((IWineD3DDeviceImpl *)shader->baseShader.device)->vs_clipping) && use_vs(state)
+ if (!device->vs_clipping && use_vs(state)
&& state->render_states[WINED3DRS_CLIPPING]
&& state->render_states[WINED3DRS_CLIPPLANEENABLE])
args->clip = 1;
@@ -4420,7 +4466,7 @@ static void find_arb_ps_compile_args(const struct wined3d_state *state,
args->clip = 0;
/* Skip if unused or local, or supported natively */
- int_skip = ~shader->baseShader.reg_maps.integer_constants | shader->baseShader.reg_maps.local_int_consts;
+ int_skip = ~shader->reg_maps.integer_constants | shader->reg_maps.local_int_consts;
if (int_skip == 0xffff || gl_info->supported[NV_FRAGMENT_PROGRAM_OPTION])
{
memset(&args->loop_ctrl, 0, sizeof(args->loop_ctrl));
@@ -4445,20 +4491,20 @@ static void find_arb_ps_compile_args(const struct wined3d_state *state,
}
static void find_arb_vs_compile_args(const struct wined3d_state *state,
- IWineD3DVertexShaderImpl *shader, struct arb_vs_compile_args *args)
+ const struct wined3d_shader *shader, struct arb_vs_compile_args *args)
{
+ struct wined3d_device *device = shader->device;
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
int i;
WORD int_skip;
- IWineD3DDeviceImpl *dev = (IWineD3DDeviceImpl *)shader->baseShader.device;
- const struct wined3d_gl_info *gl_info = &dev->adapter->gl_info;
find_vs_compile_args(state, shader, &args->super);
args->clip.boolclip_compare = 0;
if (use_ps(state))
{
- IWineD3DPixelShaderImpl *ps = state->pixel_shader;
- struct arb_pshader_private *shader_priv = ps->baseShader.backend_data;
+ const struct wined3d_shader *ps = state->pixel_shader;
+ const struct arb_pshader_private *shader_priv = ps->backend_data;
args->ps_signature = shader_priv->input_signature_idx;
args->clip.boolclip.clip_texcoord = shader_priv->clipplane_emulation + 1;
@@ -4466,7 +4512,7 @@ static void find_arb_vs_compile_args(const struct wined3d_state *state,
else
{
args->ps_signature = ~0;
- if(!dev->vs_clipping)
+ if (!device->vs_clipping)
{
args->clip.boolclip.clip_texcoord = ffp_clip_emul(state) ? gl_info->limits.texture_stages : 0;
}
@@ -4481,7 +4527,7 @@ static void find_arb_vs_compile_args(const struct wined3d_state *state,
}
/* This forces all local boolean constants to 1 to make them stateblock independent */
- args->clip.boolclip.bools = shader->baseShader.reg_maps.local_bool_consts;
+ args->clip.boolclip.bools = shader->reg_maps.local_bool_consts;
/* TODO: Figure out if it would be better to store bool constants as bitmasks in the stateblock */
for(i = 0; i < MAX_CONST_B; i++)
{
@@ -4489,13 +4535,13 @@ static void find_arb_vs_compile_args(const struct wined3d_state *state,
args->clip.boolclip.bools |= ( 1 << i);
}
- args->vertex.samplers[0] = dev->texUnitMap[MAX_FRAGMENT_SAMPLERS + 0];
- args->vertex.samplers[1] = dev->texUnitMap[MAX_FRAGMENT_SAMPLERS + 1];
- args->vertex.samplers[2] = dev->texUnitMap[MAX_FRAGMENT_SAMPLERS + 2];
+ args->vertex.samplers[0] = device->texUnitMap[MAX_FRAGMENT_SAMPLERS + 0];
+ args->vertex.samplers[1] = device->texUnitMap[MAX_FRAGMENT_SAMPLERS + 1];
+ args->vertex.samplers[2] = device->texUnitMap[MAX_FRAGMENT_SAMPLERS + 2];
args->vertex.samplers[3] = 0;
/* Skip if unused or local */
- int_skip = ~shader->baseShader.reg_maps.integer_constants | shader->baseShader.reg_maps.local_int_consts;
+ int_skip = ~shader->reg_maps.integer_constants | shader->reg_maps.local_int_consts;
/* This is about flow control, not clipping. */
if (int_skip == 0xffff || gl_info->supported[NV_VERTEX_PROGRAM2_OPTION])
{
@@ -4523,16 +4569,16 @@ static void find_arb_vs_compile_args(const struct wined3d_state *state,
/* GL locking is done by the caller */
static void shader_arb_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS)
{
- IWineD3DDeviceImpl *This = context->swapchain->device;
- struct shader_arb_priv *priv = This->shader_priv;
+ struct wined3d_device *device = context->swapchain->device;
+ struct shader_arb_priv *priv = device->shader_priv;
const struct wined3d_gl_info *gl_info = context->gl_info;
- const struct wined3d_state *state = &This->stateBlock->state;
+ const struct wined3d_state *state = &device->stateBlock->state;
int i;
/* Deal with pixel shaders first so the vertex shader arg function has the input signature ready */
if (usePS)
{
- IWineD3DPixelShaderImpl *ps = state->pixel_shader;
+ struct wined3d_shader *ps = state->pixel_shader;
struct arb_ps_compile_args compile_args;
struct arb_ps_compiled_shader *compiled;
@@ -4551,15 +4597,16 @@ static void shader_arb_select(const struct wined3d_context *context, BOOL usePS,
glEnable(GL_FRAGMENT_PROGRAM_ARB);
checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB);");
}
- TRACE("(%p) : Bound fragment program %u and enabled GL_FRAGMENT_PROGRAM_ARB\n", This, priv->current_fprogram_id);
+ TRACE("(%p) : Bound fragment program %u and enabled GL_FRAGMENT_PROGRAM_ARB\n",
+ device, priv->current_fprogram_id);
/* Pixel Shader 1.x constants are clamped to [-1;1], Pixel Shader 2.0 constants are not. If switching between
* a 1.x and newer shader, reload the first 8 constants
*/
- if(priv->last_ps_const_clamped != ((struct arb_pshader_private *)ps->baseShader.backend_data)->clamp_consts)
+ if (priv->last_ps_const_clamped != ((struct arb_pshader_private *)ps->backend_data)->clamp_consts)
{
- priv->last_ps_const_clamped = ((struct arb_pshader_private *)ps->baseShader.backend_data)->clamp_consts;
- This->highest_dirty_ps_const = max(This->highest_dirty_ps_const, 8);
+ priv->last_ps_const_clamped = ((struct arb_pshader_private *)ps->backend_data)->clamp_consts;
+ device->highest_dirty_ps_const = max(device->highest_dirty_ps_const, 8);
for(i = 0; i < 8; i++)
{
context->pshader_const_dirty[i] = 1;
@@ -4569,12 +4616,13 @@ static void shader_arb_select(const struct wined3d_context *context, BOOL usePS,
}
else
{
- shader_arb_ps_local_constants(This);
+ UINT rt_height = device->fb.render_targets[0]->resource.height;
+ shader_arb_ps_local_constants(compiled, context, state, rt_height);
}
/* Force constant reloading for the NP2 fixup (see comment in shader_glsl_select for more info) */
if (compiled->np2fixup_info.super.active)
- shader_arb_load_np2fixup_constants((IWineD3DDevice *)This, usePS, useVS);
+ shader_arb_load_np2fixup_constants(priv, gl_info, state);
}
else if (gl_info->supported[ARB_FRAGMENT_PROGRAM] && !priv->use_arbfp_fixed_func)
{
@@ -4589,7 +4637,7 @@ static void shader_arb_select(const struct wined3d_context *context, BOOL usePS,
if (useVS)
{
- IWineD3DVertexShaderImpl *vs = state->vertex_shader;
+ struct wined3d_shader *vs = state->vertex_shader;
struct arb_vs_compile_args compile_args;
struct arb_vs_compiled_shader *compiled;
@@ -4606,8 +4654,8 @@ static void shader_arb_select(const struct wined3d_context *context, BOOL usePS,
/* Enable OpenGL vertex programs */
glEnable(GL_VERTEX_PROGRAM_ARB);
checkGLcall("glEnable(GL_VERTEX_PROGRAM_ARB);");
- TRACE("(%p) : Bound vertex program %u and enabled GL_VERTEX_PROGRAM_ARB\n", This, priv->current_vprogram_id);
- shader_arb_vs_local_constants(This);
+ TRACE("(%p) : Bound vertex program %u and enabled GL_VERTEX_PROGRAM_ARB\n", device, priv->current_vprogram_id);
+ shader_arb_vs_local_constants(compiled, context, state);
if(priv->last_vs_color_unclamp != compiled->need_color_unclamp) {
priv->last_vs_color_unclamp = compiled->need_color_unclamp;
@@ -4630,13 +4678,12 @@ static void shader_arb_select(const struct wined3d_context *context, BOOL usePS,
}
/* GL locking is done by the caller */
-static void shader_arb_select_depth_blt(IWineD3DDevice *iface, enum tex_types tex_type, const SIZE *ds_mask_size)
+static void shader_arb_select_depth_blt(void *shader_priv, const struct wined3d_gl_info *gl_info,
+ enum tex_types tex_type, const SIZE *ds_mask_size)
{
const float mask[] = {0.0f, 0.0f, (float)ds_mask_size->cx, (float)ds_mask_size->cy};
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
BOOL masked = ds_mask_size->cx && ds_mask_size->cy;
- struct shader_arb_priv *priv = This->shader_priv;
- const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
+ struct shader_arb_priv *priv = shader_priv;
GLuint *blt_fprogram;
if (!priv->depth_blt_vprogram_id) priv->depth_blt_vprogram_id = create_arb_blt_vertex_program(gl_info);
@@ -4651,17 +4698,18 @@ static void shader_arb_select_depth_blt(IWineD3DDevice *iface, enum tex_types te
}
/* GL locking is done by the caller */
-static void shader_arb_deselect_depth_blt(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- struct shader_arb_priv *priv = This->shader_priv;
- const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
+static void shader_arb_deselect_depth_blt(void *shader_priv, const struct wined3d_gl_info *gl_info)
+{
+ struct shader_arb_priv *priv = shader_priv;
if (priv->current_vprogram_id) {
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, priv->current_vprogram_id));
checkGLcall("glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vertexShader->prgId);");
- TRACE("(%p) : Bound vertex program %u and enabled GL_VERTEX_PROGRAM_ARB\n", This, priv->current_vprogram_id);
- } else {
+ TRACE("Bound vertex program %u and enabled GL_VERTEX_PROGRAM_ARB.\n", priv->current_vprogram_id);
+ }
+ else
+ {
glDisable(GL_VERTEX_PROGRAM_ARB);
checkGLcall("glDisable(GL_VERTEX_PROGRAM_ARB)");
}
@@ -4670,21 +4718,23 @@ static void shader_arb_deselect_depth_blt(IWineD3DDevice *iface) {
GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, priv->current_fprogram_id));
checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, pixelShader->prgId);");
- TRACE("(%p) : Bound fragment program %u and enabled GL_FRAGMENT_PROGRAM_ARB\n", This, priv->current_fprogram_id);
- } else if(!priv->use_arbfp_fixed_func) {
+ TRACE("Bound fragment program %u and enabled GL_FRAGMENT_PROGRAM_ARB.\n", priv->current_fprogram_id);
+ }
+ else if(!priv->use_arbfp_fixed_func)
+ {
glDisable(GL_FRAGMENT_PROGRAM_ARB);
checkGLcall("glDisable(GL_FRAGMENT_PROGRAM_ARB)");
}
}
-static void shader_arb_destroy(IWineD3DBaseShader *iface) {
- IWineD3DBaseShaderImpl *baseShader = (IWineD3DBaseShaderImpl *) iface;
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)baseShader->baseShader.device;
+static void shader_arb_destroy(struct wined3d_shader *shader)
+{
+ struct wined3d_device *device = shader->device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
- if (shader_is_pshader_version(baseShader->baseShader.reg_maps.shader_version.type))
+ if (shader_is_pshader_version(shader->reg_maps.shader_version.type))
{
- struct arb_pshader_private *shader_data = baseShader->baseShader.backend_data;
+ struct arb_pshader_private *shader_data = shader->backend_data;
UINT i;
if(!shader_data) return; /* This can happen if a shader was never compiled */
@@ -4706,11 +4756,11 @@ static void shader_arb_destroy(IWineD3DBaseShader *iface) {
HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders);
HeapFree(GetProcessHeap(), 0, shader_data);
- baseShader->baseShader.backend_data = NULL;
+ shader->backend_data = NULL;
}
else
{
- struct arb_vshader_private *shader_data = baseShader->baseShader.backend_data;
+ struct arb_vshader_private *shader_data = shader->backend_data;
UINT i;
if(!shader_data) return; /* This can happen if a shader was never compiled */
@@ -4732,7 +4782,7 @@ static void shader_arb_destroy(IWineD3DBaseShader *iface) {
HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders);
HeapFree(GetProcessHeap(), 0, shader_data);
- baseShader->baseShader.backend_data = NULL;
+ shader->backend_data = NULL;
}
}
@@ -4750,8 +4800,8 @@ static const struct wine_rb_functions sig_tree_functions =
sig_tree_compare
};
-static HRESULT shader_arb_alloc(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+static HRESULT shader_arb_alloc(struct wined3d_device *device)
+{
struct shader_arb_priv *priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*priv));
if(wine_rb_init(&priv->signature_tree, &sig_tree_functions) == -1)
{
@@ -4759,7 +4809,7 @@ static HRESULT shader_arb_alloc(IWineD3DDevice *iface) {
HeapFree(GetProcessHeap(), 0, priv);
return E_OUTOFMEMORY;
}
- This->shader_priv = priv;
+ device->shader_priv = priv;
return WINED3D_OK;
}
@@ -4776,10 +4826,10 @@ static void release_signature(struct wine_rb_entry *entry, void *context)
}
/* Context activation is done by the caller. */
-static void shader_arb_free(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
- struct shader_arb_priv *priv = This->shader_priv;
+static void shader_arb_free(struct wined3d_device *device)
+{
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+ struct shader_arb_priv *priv = device->shader_priv;
int i;
ENTER_GL();
@@ -4800,14 +4850,15 @@ static void shader_arb_free(IWineD3DDevice *iface) {
LEAVE_GL();
wine_rb_destroy(&priv->signature_tree, release_signature, NULL);
- HeapFree(GetProcessHeap(), 0, This->shader_priv);
+ HeapFree(GetProcessHeap(), 0, device->shader_priv);
}
-static BOOL shader_arb_dirty_const(IWineD3DDevice *iface) {
+static BOOL shader_arb_dirty_const(void)
+{
return TRUE;
}
-static void shader_arb_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps)
+static void shader_arb_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *caps)
{
if (gl_info->supported[ARB_VERTEX_PROGRAM])
{
@@ -4824,26 +4875,26 @@ static void shader_arb_get_caps(const struct wined3d_gl_info *gl_info, struct sh
if (gl_info->supported[NV_VERTEX_PROGRAM3])
{
- pCaps->VertexShaderVersion = WINED3DVS_VERSION(3,0);
+ caps->VertexShaderVersion = WINED3DVS_VERSION(3,0);
TRACE_(d3d_caps)("Hardware vertex shader version 3.0 enabled (NV_VERTEX_PROGRAM3)\n");
}
else if (vs_consts >= 256)
{
/* Shader Model 2.0 requires at least 256 vertex shader constants */
- pCaps->VertexShaderVersion = WINED3DVS_VERSION(2,0);
+ caps->VertexShaderVersion = WINED3DVS_VERSION(2,0);
TRACE_(d3d_caps)("Hardware vertex shader version 2.0 enabled (ARB_PROGRAM)\n");
}
else
{
- pCaps->VertexShaderVersion = WINED3DVS_VERSION(1,1);
+ caps->VertexShaderVersion = WINED3DVS_VERSION(1,1);
TRACE_(d3d_caps)("Hardware vertex shader version 1.1 enabled (ARB_PROGRAM)\n");
}
- pCaps->MaxVertexShaderConst = vs_consts;
+ caps->MaxVertexShaderConst = vs_consts;
}
else
{
- pCaps->VertexShaderVersion = 0;
- pCaps->MaxVertexShaderConst = 0;
+ caps->VertexShaderVersion = 0;
+ caps->MaxVertexShaderConst = 0;
}
if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
@@ -4859,31 +4910,31 @@ static void shader_arb_get_caps(const struct wined3d_gl_info *gl_info, struct sh
if (gl_info->supported[NV_FRAGMENT_PROGRAM2])
{
- pCaps->PixelShaderVersion = WINED3DPS_VERSION(3,0);
+ caps->PixelShaderVersion = WINED3DPS_VERSION(3,0);
TRACE_(d3d_caps)("Hardware pixel shader version 3.0 enabled (NV_FRAGMENT_PROGRAM2)\n");
}
else if (ps_consts >= 32)
{
/* Shader Model 2.0 requires at least 32 pixel shader constants */
- pCaps->PixelShaderVersion = WINED3DPS_VERSION(2,0);
+ caps->PixelShaderVersion = WINED3DPS_VERSION(2,0);
TRACE_(d3d_caps)("Hardware pixel shader version 2.0 enabled (ARB_PROGRAM)\n");
}
else
{
- pCaps->PixelShaderVersion = WINED3DPS_VERSION(1,4);
+ caps->PixelShaderVersion = WINED3DPS_VERSION(1,4);
TRACE_(d3d_caps)("Hardware pixel shader version 1.4 enabled (ARB_PROGRAM)\n");
}
- pCaps->PixelShader1xMaxValue = 8.0f;
- pCaps->MaxPixelShaderConst = ps_consts;
+ caps->PixelShader1xMaxValue = 8.0f;
+ caps->MaxPixelShaderConst = ps_consts;
}
else
{
- pCaps->PixelShaderVersion = 0;
- pCaps->PixelShader1xMaxValue = 0.0f;
- pCaps->MaxPixelShaderConst = 0;
+ caps->PixelShaderVersion = 0;
+ caps->PixelShader1xMaxValue = 0.0f;
+ caps->MaxPixelShaderConst = 0;
}
- pCaps->VSClipping = use_nv_clip(gl_info);
+ caps->VSClipping = use_nv_clip(gl_info);
}
static BOOL shader_arb_color_fixup_supported(struct color_fixup_desc fixup)
@@ -4948,6 +4999,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL
/* WINED3DSIH_DEF */ NULL,
/* WINED3DSIH_DEFB */ NULL,
/* WINED3DSIH_DEFI */ NULL,
+ /* WINED3DSIH_DIV */ NULL,
/* WINED3DSIH_DP2ADD */ pshader_hw_dp2add,
/* WINED3DSIH_DP3 */ shader_hw_map2gl,
/* WINED3DSIH_DP4 */ shader_hw_map2gl,
@@ -4962,15 +5014,19 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL
/* WINED3DSIH_EXP */ shader_hw_scalar_op,
/* WINED3DSIH_EXPP */ shader_hw_scalar_op,
/* WINED3DSIH_FRC */ shader_hw_map2gl,
+ /* WINED3DSIH_FTOI */ NULL,
/* WINED3DSIH_IADD */ NULL,
+ /* WINED3DSIH_IEQ */ NULL,
/* WINED3DSIH_IF */ NULL /* Hardcoded into the shader */,
/* WINED3DSIH_IFC */ shader_hw_ifc,
/* WINED3DSIH_IGE */ NULL,
/* WINED3DSIH_IMUL */ NULL,
+ /* WINED3DSIH_ITOF */ NULL,
/* WINED3DSIH_LABEL */ shader_hw_label,
+ /* WINED3DSIH_LD */ NULL,
/* WINED3DSIH_LIT */ shader_hw_map2gl,
- /* WINED3DSIH_LOG */ shader_hw_log_pow,
- /* WINED3DSIH_LOGP */ shader_hw_log_pow,
+ /* WINED3DSIH_LOG */ shader_hw_log,
+ /* WINED3DSIH_LOGP */ shader_hw_log,
/* WINED3DSIH_LOOP */ shader_hw_loop,
/* WINED3DSIH_LRP */ shader_hw_lrp,
/* WINED3DSIH_LT */ NULL,
@@ -4989,16 +5045,20 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL
/* WINED3DSIH_NOP */ shader_hw_nop,
/* WINED3DSIH_NRM */ shader_hw_nrm,
/* WINED3DSIH_PHASE */ NULL,
- /* WINED3DSIH_POW */ shader_hw_log_pow,
+ /* WINED3DSIH_POW */ shader_hw_pow,
/* WINED3DSIH_RCP */ shader_hw_rcp,
/* WINED3DSIH_REP */ shader_hw_rep,
/* WINED3DSIH_RET */ shader_hw_ret,
/* WINED3DSIH_RSQ */ shader_hw_scalar_op,
+ /* WINED3DSIH_SAMPLE */ NULL,
+ /* WINED3DSIH_SAMPLE_GRAD */ NULL,
+ /* WINED3DSIH_SAMPLE_LOD */ NULL,
/* WINED3DSIH_SETP */ NULL,
/* WINED3DSIH_SGE */ shader_hw_map2gl,
/* WINED3DSIH_SGN */ shader_hw_sgn,
/* WINED3DSIH_SINCOS */ shader_hw_sincos,
/* WINED3DSIH_SLT */ shader_hw_map2gl,
+ /* WINED3DSIH_SQRT */ NULL,
/* WINED3DSIH_SUB */ shader_hw_map2gl,
/* WINED3DSIH_TEX */ pshader_hw_tex,
/* WINED3DSIH_TEXBEM */ pshader_hw_texbem,
@@ -5022,20 +5082,23 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL
/* WINED3DSIH_TEXREG2AR */ pshader_hw_texreg2ar,
/* WINED3DSIH_TEXREG2GB */ pshader_hw_texreg2gb,
/* WINED3DSIH_TEXREG2RGB */ pshader_hw_texreg2rgb,
+ /* WINED3DSIH_UTOF */ NULL,
};
-static inline BOOL get_bool_const(const struct wined3d_shader_instruction *ins, IWineD3DBaseShaderImpl *This, DWORD idx)
+static BOOL get_bool_const(const struct wined3d_shader_instruction *ins,
+ const struct wined3d_shader *shader, DWORD idx)
{
- BOOL vshader = shader_is_vshader_version(This->baseShader.reg_maps.shader_version.type);
+ const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
+ BOOL vshader = shader_is_vshader_version(reg_maps->shader_version.type);
WORD bools = 0;
WORD flag = (1 << idx);
const local_constant *constant;
struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
- if(This->baseShader.reg_maps.local_bool_consts & flag)
+ if (reg_maps->local_bool_consts & flag)
{
/* What good is a if(bool) with a hardcoded local constant? I don't know, but handle it */
- LIST_FOR_EACH_ENTRY(constant, &This->baseShader.constantsB, local_constant, entry)
+ LIST_FOR_EACH_ENTRY(constant, &shader->constantsB, local_constant, entry)
{
if (constant->idx == idx)
{
@@ -5054,17 +5117,18 @@ static inline BOOL get_bool_const(const struct wined3d_shader_instruction *ins,
}
static void get_loop_control_const(const struct wined3d_shader_instruction *ins,
- IWineD3DBaseShaderImpl *This, UINT idx, struct wined3d_shader_loop_control *loop_control)
+ const struct wined3d_shader *shader, UINT idx, struct wined3d_shader_loop_control *loop_control)
{
+ const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
/* Integer constants can either be a local constant, or they can be stored in the shader
* type specific compile args. */
- if (This->baseShader.reg_maps.local_int_consts & (1 << idx))
+ if (reg_maps->local_int_consts & (1 << idx))
{
const local_constant *constant;
- LIST_FOR_EACH_ENTRY(constant, &This->baseShader.constantsI, local_constant, entry)
+ LIST_FOR_EACH_ENTRY(constant, &shader->constantsI, local_constant, entry)
{
if (constant->idx == idx)
{
@@ -5083,7 +5147,7 @@ static void get_loop_control_const(const struct wined3d_shader_instruction *ins,
return;
}
- switch (This->baseShader.reg_maps.shader_version.type)
+ switch (reg_maps->shader_version.type)
{
case WINED3D_SHADER_TYPE_VERTEX:
/* Count and aL start value are unsigned */
@@ -5100,7 +5164,7 @@ static void get_loop_control_const(const struct wined3d_shader_instruction *ins,
break;
default:
- FIXME("Unhandled shader type %#x.\n", This->baseShader.reg_maps.shader_version.type);
+ FIXME("Unhandled shader type %#x.\n", reg_maps->shader_version.type);
break;
}
}
@@ -5193,7 +5257,7 @@ static void free_recorded_instruction(struct list *list)
static void shader_arb_handle_instruction(const struct wined3d_shader_instruction *ins) {
SHADER_HANDLER hw_fct;
struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
- IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+ struct wined3d_shader *shader = ins->ctx->shader;
struct control_frame *control_frame;
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
BOOL bool_const;
@@ -5224,7 +5288,7 @@ static void shader_arb_handle_instruction(const struct wined3d_shader_instructio
list_init(&priv->record);
priv->recording = TRUE;
control_frame->outer_loop = TRUE;
- get_loop_control_const(ins, This, ins->src[0].reg.idx, &control_frame->loop_control);
+ get_loop_control_const(ins, shader, ins->src[0].reg.idx, &control_frame->loop_control);
return; /* Instruction is handled */
}
/* Record this loop in the outer loop's recording */
@@ -5321,7 +5385,7 @@ static void shader_arb_handle_instruction(const struct wined3d_shader_instructio
list_add_head(&priv->control_frames, &control_frame->entry);
control_frame->type = IF;
- bool_const = get_bool_const(ins, This, ins->src[0].reg.idx);
+ bool_const = get_bool_const(ins, shader, ins->src[0].reg.idx);
if(ins->src[0].modifiers == WINED3DSPSM_NOT) bool_const = !bool_const;
if (!priv->muted && !bool_const)
{
@@ -5408,7 +5472,8 @@ static void shader_arb_handle_instruction(const struct wined3d_shader_instructio
shader_arb_add_instruction_modifiers(ins);
}
-const shader_backend_t arb_program_shader_backend = {
+const struct wined3d_shader_backend_ops arb_program_shader_backend =
+{
shader_arb_handle_instruction,
shader_arb_select,
shader_arb_select_depth_blt,
@@ -5439,9 +5504,9 @@ struct arbfp_ffp_desc
unsigned int num_textures_used;
};
-/* Context activation is done by the caller. */
-static void arbfp_enable(IWineD3DDevice *iface, BOOL enable) {
- ENTER_GL();
+/* Context activation and GL locking are done by the caller. */
+static void arbfp_enable(BOOL enable)
+{
if(enable) {
glEnable(GL_FRAGMENT_PROGRAM_ARB);
checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB)");
@@ -5449,27 +5514,29 @@ static void arbfp_enable(IWineD3DDevice *iface, BOOL enable) {
glDisable(GL_FRAGMENT_PROGRAM_ARB);
checkGLcall("glDisable(GL_FRAGMENT_PROGRAM_ARB)");
}
- LEAVE_GL();
}
-static HRESULT arbfp_alloc(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
+static HRESULT arbfp_alloc(struct wined3d_device *device)
+{
struct shader_arb_priv *priv;
/* Share private data between the shader backend and the pipeline replacement, if both
* are the arb implementation. This is needed to figure out whether ARBfp should be disabled
* if no pixel shader is bound or not
*/
- if(This->shader_backend == &arb_program_shader_backend) {
- This->fragment_priv = This->shader_priv;
- } else {
- This->fragment_priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct shader_arb_priv));
- if(!This->fragment_priv) return E_OUTOFMEMORY;
+ if (device->shader_backend == &arb_program_shader_backend)
+ {
+ device->fragment_priv = device->shader_priv;
}
- priv = This->fragment_priv;
+ else
+ {
+ device->fragment_priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct shader_arb_priv));
+ if (!device->fragment_priv) return E_OUTOFMEMORY;
+ }
+ 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;
}
priv->use_arbfp_fixed_func = TRUE;
@@ -5490,15 +5557,16 @@ static void arbfp_free_ffpshader(struct wine_rb_entry *entry, void *context)
}
/* Context activation is done by the caller. */
-static void arbfp_free(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
- struct shader_arb_priv *priv = This->fragment_priv;
+static void arbfp_free(struct wined3d_device *device)
+{
+ struct shader_arb_priv *priv = device->fragment_priv;
- wine_rb_destroy(&priv->fragment_shaders, arbfp_free_ffpshader, &This->adapter->gl_info);
+ wine_rb_destroy(&priv->fragment_shaders, arbfp_free_ffpshader, &device->adapter->gl_info);
priv->use_arbfp_fixed_func = FALSE;
- if(This->shader_backend != &arb_program_shader_backend) {
- HeapFree(GetProcessHeap(), 0, This->fragment_priv);
+ if (device->shader_backend != &arb_program_shader_backend)
+ {
+ HeapFree(GetProcessHeap(), 0, device->fragment_priv);
}
}
@@ -5537,11 +5605,12 @@ static void arbfp_get_caps(const struct wined3d_gl_info *gl_info, struct fragmen
caps->MaxSimultaneousTextures = min(gl_info->limits.fragment_samplers, 8);
}
-static void state_texfactor_arbfp(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_texfactor_arbfp(DWORD state_id,
+ struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_state *state = &stateblock->state;
- IWineD3DDeviceImpl *device = stateblock->device;
+ struct wined3d_device *device = stateblock->device;
float col[4];
/* Don't load the parameter if we're using an arbfp pixel shader, otherwise we'll overwrite
@@ -5562,11 +5631,11 @@ static void state_texfactor_arbfp(DWORD state_id, IWineD3DStateBlockImpl *stateb
}
static void state_arb_specularenable(DWORD state_id,
- IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+ struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_state *state = &stateblock->state;
- IWineD3DDeviceImpl *device = stateblock->device;
+ struct wined3d_device *device = stateblock->device;
float col[4];
/* Don't load the parameter if we're using an arbfp pixel shader, otherwise we'll overwrite
@@ -5593,18 +5662,17 @@ static void state_arb_specularenable(DWORD state_id,
checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_SPECULAR_ENABLE, col)");
}
-static void set_bumpmat_arbfp(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void set_bumpmat_arbfp(DWORD state_id, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
DWORD stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_state *state = &stateblock->state;
- IWineD3DDeviceImpl *device = stateblock->device;
+ struct wined3d_device *device = stateblock->device;
float mat[2][2];
if (use_ps(state))
{
- IWineD3DPixelShaderImpl *ps = state->pixel_shader;
- if (stage && (ps->baseShader.reg_maps.bumpmat & (1 << stage)))
+ if (stage && (state->pixel_shader->reg_maps.bumpmat & (1 << stage)))
{
/* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled
* anyway
@@ -5631,18 +5699,18 @@ static void set_bumpmat_arbfp(DWORD state_id, IWineD3DStateBlockImpl *stateblock
checkGLcall("glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, ARB_FFP_CONST_BUMPMAT(stage), &mat[0][0])");
}
-static void tex_bumpenvlum_arbfp(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void tex_bumpenvlum_arbfp(DWORD state_id,
+ struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
DWORD stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_state *state = &stateblock->state;
- IWineD3DDeviceImpl *device = stateblock->device;
+ struct wined3d_device *device = stateblock->device;
float param[4];
if (use_ps(state))
{
- IWineD3DPixelShaderImpl *ps = state->pixel_shader;
- if (stage && (ps->baseShader.reg_maps.luminanceparams & (1 << stage)))
+ if (stage && (state->pixel_shader->reg_maps.luminanceparams & (1 << stage)))
{
/* The pixel shader has to know the luminance offset. Do a constants update if it
* isn't scheduled anyway
@@ -5766,12 +5834,14 @@ static void gen_ffp_instr(struct wined3d_shader_buffer *buffer, unsigned int sta
case WINED3DTOP_SELECTARG2:
arg1 = arg2;
+ /* FALLTHROUGH */
case WINED3DTOP_SELECTARG1:
shader_addline(buffer, "MOV %s%s, %s;\n", dstreg, dstmask, arg1);
break;
case WINED3DTOP_MODULATE4X:
mul = 2;
+ /* FALLTHROUGH */
case WINED3DTOP_MODULATE2X:
mul *= 2;
if (!strcmp(dstreg, "result.color"))
@@ -5779,6 +5849,7 @@ static void gen_ffp_instr(struct wined3d_shader_buffer *buffer, unsigned int sta
dstreg = "ret";
mul_final_dest = TRUE;
}
+ /* FALLTHROUGH */
case WINED3DTOP_MODULATE:
shader_addline(buffer, "MUL %s%s, %s, %s;\n", dstreg, dstmask, arg1, arg2);
break;
@@ -5790,9 +5861,11 @@ static void gen_ffp_instr(struct wined3d_shader_buffer *buffer, unsigned int sta
dstreg = "ret";
mul_final_dest = TRUE;
}
+ /* FALLTHROUGH */
case WINED3DTOP_ADDSIGNED:
shader_addline(buffer, "SUB arg2, %s, const.w;\n", arg2);
arg2 = "arg2";
+ /* FALLTHROUGH */
case WINED3DTOP_ADD:
shader_addline(buffer, "ADD_SAT %s%s, %s, %s;\n", dstreg, dstmask, arg1, arg2);
break;
@@ -5883,7 +5956,7 @@ static void gen_ffp_instr(struct wined3d_shader_buffer *buffer, unsigned int sta
}
}
-static GLuint gen_arbfp_ffp_shader(const struct ffp_frag_settings *settings, IWineD3DStateBlockImpl *stateblock)
+static GLuint gen_arbfp_ffp_shader(const struct ffp_frag_settings *settings, struct wined3d_stateblock *stateblock)
{
const struct wined3d_gl_info *gl_info = &stateblock->device->adapter->gl_info;
unsigned int stage;
@@ -6160,11 +6233,11 @@ static GLuint gen_arbfp_ffp_shader(const struct ffp_frag_settings *settings, IWi
return ret;
}
-static void fragment_prog_arbfp(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void fragment_prog_arbfp(DWORD state_id, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_state *state = &stateblock->state;
- IWineD3DDeviceImpl *device = stateblock->device;
+ struct wined3d_device *device = stateblock->device;
struct shader_arb_priv *priv = device->fragment_priv;
BOOL use_vshader = use_vs(state);
BOOL use_pshader = use_ps(state);
@@ -6258,7 +6331,7 @@ static void fragment_prog_arbfp(DWORD state_id, IWineD3DStateBlockImpl *stateblo
* is that changing the fog start and fog end(which links to FOGENABLE in vertex) results in the
* fragment_prog_arbfp function being called because FOGENABLE is dirty, which calls this function here
*/
-static void state_arbfp_fog(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_arbfp_fog(DWORD state_id, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_state *state = &stateblock->state;
enum fogsource new_source;
@@ -6293,11 +6366,10 @@ static void state_arbfp_fog(DWORD state_id, IWineD3DStateBlockImpl *stateblock,
}
}
-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))
fragment_prog_arbfp(state, stateblock, context);
- }
}
static const struct StateEntryTemplate arbfp_fragmentstate_template[] = {
@@ -6422,14 +6494,6 @@ static const struct StateEntryTemplate arbfp_fragmentstate_template[] = {
{STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), NULL }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlum_arbfp }, WINED3D_GL_EXT_NONE },
{STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLOFFSET), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE), NULL }, WINED3D_GL_EXT_NONE },
- {STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim }, WINED3D_GL_EXT_NONE },
- {STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim }, WINED3D_GL_EXT_NONE },
- {STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim }, WINED3D_GL_EXT_NONE },
- {STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim }, WINED3D_GL_EXT_NONE },
- {STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim }, WINED3D_GL_EXT_NONE },
- {STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim }, WINED3D_GL_EXT_NONE },
- {STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim }, WINED3D_GL_EXT_NONE },
- {STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim }, WINED3D_GL_EXT_NONE },
{STATE_PIXELSHADER, { STATE_PIXELSHADER, fragment_prog_arbfp }, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3DRS_FOGENABLE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_arbfp_fog }, WINED3D_GL_EXT_NONE },
{STATE_RENDER(WINED3DRS_FOGTABLEMODE), { STATE_RENDER(WINED3DRS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE },
@@ -6469,8 +6533,8 @@ struct arbfp_blit_priv {
GLuint palette_texture;
};
-static HRESULT arbfp_blit_alloc(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) iface;
+static HRESULT arbfp_blit_alloc(struct wined3d_device *device)
+{
device->blit_priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct arbfp_blit_priv));
if(!device->blit_priv) {
ERR("Out of memory\n");
@@ -6480,8 +6544,8 @@ static HRESULT arbfp_blit_alloc(IWineD3DDevice *iface) {
}
/* Context activation is done by the caller. */
-static void arbfp_blit_free(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) iface;
+static void arbfp_blit_free(struct wined3d_device *device)
+{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct arbfp_blit_priv *priv = device->blit_priv;
@@ -6737,12 +6801,11 @@ static BOOL gen_yv12_read(struct wined3d_shader_buffer *buffer, GLenum textype,
return TRUE;
}
-static GLuint gen_p8_shader(IWineD3DDeviceImpl *device, GLenum textype)
+static GLuint gen_p8_shader(struct arbfp_blit_priv *priv,
+ const struct wined3d_gl_info *gl_info, GLenum textype)
{
- const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
GLenum shader;
struct wined3d_shader_buffer buffer;
- struct arbfp_blit_priv *priv = device->blit_priv;
GLint pos;
/* Shader header */
@@ -6805,10 +6868,10 @@ static GLuint gen_p8_shader(IWineD3DDeviceImpl *device, GLenum textype)
}
/* Context activation is done by the caller. */
-static void upload_palette(IWineD3DSurfaceImpl *surface)
+static void upload_palette(struct wined3d_surface *surface)
{
BYTE table[256][4];
- IWineD3DDeviceImpl *device = surface->resource.device;
+ struct wined3d_device *device = surface->resource.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct arbfp_blit_priv *priv = device->blit_priv;
BOOL colorkey = (surface->CKeyFlags & WINEDDSD_CKSRCBLT) ? TRUE : FALSE;
@@ -6838,13 +6901,12 @@ static void upload_palette(IWineD3DSurfaceImpl *surface)
}
/* Context activation is done by the caller. */
-static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum complex_fixup yuv_fixup, GLenum textype)
+static GLuint gen_yuv_shader(struct arbfp_blit_priv *priv, const struct wined3d_gl_info *gl_info,
+ enum complex_fixup yuv_fixup, GLenum textype)
{
- const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
GLenum shader;
struct wined3d_shader_buffer buffer;
char luminance_component;
- struct arbfp_blit_priv *priv = device->blit_priv;
GLint pos;
/* Shader header */
@@ -6995,13 +7057,11 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum complex_fixup yuv_
}
/* Context activation is done by the caller. */
-static HRESULT arbfp_blit_set(IWineD3DDevice *iface, IWineD3DSurfaceImpl *surface)
+static HRESULT arbfp_blit_set(void *blit_priv, const struct wined3d_gl_info *gl_info, struct wined3d_surface *surface)
{
GLenum shader;
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) iface;
- const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
float size[4] = {(float) surface->pow2Width, (float) surface->pow2Height, 1.0f, 1.0f};
- struct arbfp_blit_priv *priv = device->blit_priv;
+ struct arbfp_blit_priv *priv = blit_priv;
enum complex_fixup fixup;
GLenum textype = surface->texture_target;
@@ -7035,7 +7095,7 @@ static HRESULT arbfp_blit_set(IWineD3DDevice *iface, IWineD3DSurfaceImpl *surfac
case COMPLEX_FIXUP_P8:
shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->p8_rect_shader : priv->p8_2d_shader;
- if (!shader) shader = gen_p8_shader(device, textype);
+ if (!shader) shader = gen_p8_shader(priv, gl_info, textype);
upload_palette(surface);
break;
@@ -7049,7 +7109,7 @@ static HRESULT arbfp_blit_set(IWineD3DDevice *iface, IWineD3DSurfaceImpl *surfac
return E_NOTIMPL;
}
- if (!shader) shader = gen_yuv_shader(device, fixup, textype);
+ if (!shader) shader = gen_yuv_shader(priv, gl_info, fixup, textype);
ENTER_GL();
glEnable(GL_FRAGMENT_PROGRAM_ARB);
@@ -7064,10 +7124,8 @@ static HRESULT arbfp_blit_set(IWineD3DDevice *iface, IWineD3DSurfaceImpl *surfac
}
/* Context activation is done by the caller. */
-static void arbfp_blit_unset(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) iface;
- const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
-
+static void arbfp_blit_unset(const struct wined3d_gl_info *gl_info)
+{
ENTER_GL();
glDisable(GL_FRAGMENT_PROGRAM_ARB);
checkGLcall("glDisable(GL_FRAGMENT_PROGRAM_ARB)");
@@ -7086,13 +7144,16 @@ static void arbfp_blit_unset(IWineD3DDevice *iface) {
LEAVE_GL();
}
-static BOOL arbfp_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
+static BOOL arbfp_blit_supported(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)
{
enum complex_fixup src_fixup;
- if (blit_op != BLIT_OP_BLIT)
+ if (!gl_info->supported[ARB_FRAGMENT_PROGRAM])
+ return FALSE;
+
+ if (blit_op != WINED3D_BLIT_OP_COLOR_BLIT)
{
TRACE("Unsupported blit_op=%d\n", blit_op);
return FALSE;
@@ -7140,11 +7201,9 @@ static BOOL arbfp_blit_supported(const struct wined3d_gl_info *gl_info, enum bli
}
}
-HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_surface, const RECT *src_rect,
- IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect_in, enum blit_operation blit_op,
- DWORD Filter)
+HRESULT arbfp_blit_surface(struct wined3d_device *device, struct wined3d_surface *src_surface, const RECT *src_rect,
+ struct wined3d_surface *dst_surface, const RECT *dst_rect_in, enum wined3d_blit_op blit_op, DWORD Filter)
{
- IWineD3DSwapChainImpl *dst_swapchain;
struct wined3d_context *context;
RECT dst_rect = *dst_rect_in;
@@ -7155,17 +7214,10 @@ HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_
context = context_acquire(device, dst_surface);
context_apply_blit_state(context, device);
- /* The coordinates of the ddraw front buffer are always fullscreen ('screen coordinates',
- * while OpenGL coordinates are window relative.
- * Also beware of the origin difference(top left vs bottom left).
- * Also beware that the front buffer's surface size is screen width x screen height,
- * whereas the real gl drawable size is the size of the window. */
- dst_swapchain = dst_surface->container.type == WINED3D_CONTAINER_SWAPCHAIN
- ? dst_surface->container.u.swapchain : NULL;
- if (dst_swapchain && dst_surface == dst_swapchain->front_buffer)
- surface_translate_frontbuffer_coords(dst_surface, context->win_handle, &dst_rect);
+ if (!surface_is_offscreen(dst_surface))
+ surface_translate_drawable_coords(dst_surface, context->win_handle, &dst_rect);
- arbfp_blit_set((IWineD3DDevice *)device, src_surface);
+ arbfp_blit_set(device->blit_priv, context->gl_info, src_surface);
ENTER_GL();
@@ -7175,11 +7227,11 @@ HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_
LEAVE_GL();
/* Leave the opengl state valid for blitting */
- arbfp_blit_unset((IWineD3DDevice *)device);
+ arbfp_blit_unset(context->gl_info);
- if (wined3d_settings.strict_draw_ordering || (dst_swapchain
- && (dst_surface == dst_swapchain->front_buffer
- || dst_swapchain->num_contexts > 1)))
+ if (wined3d_settings.strict_draw_ordering
+ || (dst_surface->container.type == WINED3D_CONTAINER_SWAPCHAIN
+ && (dst_surface->container.u.swapchain->front_buffer == dst_surface)))
wglFlush(); /* Flush to ensure ordering across contexts. */
context_release(context);
@@ -7189,18 +7241,27 @@ HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_
}
/* Do not call while under the GL lock. */
-static HRESULT arbfp_blit_color_fill(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface,
+static HRESULT arbfp_blit_color_fill(struct wined3d_device *device, struct wined3d_surface *dst_surface,
const RECT *dst_rect, const WINED3DCOLORVALUE *color)
{
FIXME("Color filling not implemented by arbfp_blit\n");
return WINED3DERR_INVALIDCALL;
}
+/* Do not call while under the GL lock. */
+static HRESULT arbfp_blit_depth_fill(struct wined3d_device *device,
+ struct wined3d_surface *surface, const RECT *rect, float depth)
+{
+ FIXME("Depth filling not implemented by arbfp_blit.\n");
+ return WINED3DERR_INVALIDCALL;
+}
+
const struct blit_shader arbfp_blit = {
arbfp_blit_alloc,
arbfp_blit_free,
arbfp_blit_set,
arbfp_blit_unset,
arbfp_blit_supported,
- arbfp_blit_color_fill
+ arbfp_blit_color_fill,
+ arbfp_blit_depth_fill,
};
diff --git a/reactos/dll/directx/wine/wined3d/ati_fragment_shader.c b/reactos/dll/directx/wine/wined3d/ati_fragment_shader.c
index 35838e18d73..02817573cb8 100644
--- a/reactos/dll/directx/wine/wined3d/ati_fragment_shader.c
+++ b/reactos/dll/directx/wine/wined3d/ati_fragment_shader.c
@@ -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)
diff --git a/reactos/dll/directx/wine/wined3d/basetexture.c b/reactos/dll/directx/wine/wined3d/basetexture.c
deleted file mode 100644
index bf3b4d4ff70..00000000000
--- a/reactos/dll/directx/wine/wined3d/basetexture.c
+++ /dev/null
@@ -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;
- }
- }
-}
diff --git a/reactos/dll/directx/wine/wined3d/buffer.c b/reactos/dll/directx/wine/wined3d/buffer.c
index 23b4a4ad67c..f2f806ec3e5 100644
--- a/reactos/dll/directx/wine/wined3d/buffer.c
+++ b/reactos/dll/directx/wine/wined3d/buffer.c
@@ -4,7 +4,7 @@
* Copyright 2004 Christian Costa
* Copyright 2005 Oliver Stieber
* Copyright 2007-2010 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
@@ -287,11 +287,9 @@ static BOOL buffer_process_converted_attribute(struct wined3d_buffer *This,
static BOOL buffer_check_attribute(struct wined3d_buffer *This, const struct wined3d_stream_info *si,
UINT attrib_idx, const BOOL check_d3dcolor, const BOOL is_ffp_position, const BOOL is_ffp_color,
- DWORD *stride_this_run, BOOL *float16_used)
+ DWORD *stride_this_run)
{
const struct wined3d_stream_info_element *attrib = &si->elements[attrib_idx];
- IWineD3DDeviceImpl *device = This->resource.device;
- const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
enum wined3d_format_id format;
BOOL ret = FALSE;
@@ -304,16 +302,7 @@ static BOOL buffer_check_attribute(struct wined3d_buffer *This, const struct win
format = attrib->format->id;
/* Look for newly appeared conversion */
- if (!gl_info->supported[ARB_HALF_FLOAT_VERTEX]
- && (format == WINED3DFMT_R16G16_FLOAT || format == WINED3DFMT_R16G16B16A16_FLOAT))
- {
- ret = buffer_process_converted_attribute(This, CONV_FLOAT16_2, attrib, stride_this_run);
-
- if (is_ffp_position) FIXME("Test FLOAT16 fixed function processing positions\n");
- else if (is_ffp_color) FIXME("test FLOAT16 fixed function processing colors\n");
- *float16_used = TRUE;
- }
- else if (check_d3dcolor && format == WINED3DFMT_B8G8R8A8_UNORM)
+ if (check_d3dcolor && format == WINED3DFMT_B8G8R8A8_UNORM)
{
ret = buffer_process_converted_attribute(This, CONV_D3DCOLOR, attrib, stride_this_run);
@@ -331,81 +320,15 @@ static BOOL buffer_check_attribute(struct wined3d_buffer *This, const struct win
return ret;
}
-static UINT *find_conversion_shift(struct wined3d_buffer *This,
- const struct wined3d_stream_info *strided, UINT stride)
-{
- UINT *ret, i, j, shift, orig_type_size;
-
- if (!stride)
- {
- TRACE("No shift\n");
- return NULL;
- }
-
- This->conversion_stride = stride;
- ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DWORD) * stride);
- for (i = 0; i < MAX_ATTRIBS; ++i)
- {
- enum wined3d_format_id format;
-
- if (!(strided->use_map & (1 << i)) || strided->elements[i].buffer_object != This->buffer_object) continue;
-
- format = strided->elements[i].format->id;
- if (format == WINED3DFMT_R16G16_FLOAT)
- {
- shift = 4;
- }
- else if (format == WINED3DFMT_R16G16B16A16_FLOAT)
- {
- shift = 8;
- /* Pre-shift the last 4 bytes in the FLOAT16_4 by 4 bytes - this makes FLOAT16_2 and FLOAT16_4 conversions
- * compatible
- */
- for (j = 4; j < 8; ++j)
- {
- ret[(DWORD_PTR)strided->elements[i].data + j] += 4;
- }
- }
- else
- {
- shift = 0;
- }
- This->conversion_stride += shift;
-
- if (shift)
- {
- orig_type_size = strided->elements[i].format->component_count
- * strided->elements[i].format->component_size;
- for (j = (DWORD_PTR)strided->elements[i].data + orig_type_size; j < stride; ++j)
- {
- ret[j] += shift;
- }
- }
- }
-
- if (TRACE_ON(d3d))
- {
- TRACE("Dumping conversion shift:\n");
- for (i = 0; i < stride; ++i)
- {
- TRACE("[%d]", ret[i]);
- }
- TRACE("\n");
- }
-
- return ret;
-}
-
static BOOL buffer_find_decl(struct wined3d_buffer *This)
{
- IWineD3DDeviceImpl *device = This->resource.device;
+ struct wined3d_device *device = This->resource.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_stream_info *si = &device->strided_streams;
const struct wined3d_state *state = &device->stateBlock->state;
UINT stride_this_run = 0;
- BOOL float16_used = FALSE;
BOOL ret = FALSE;
- unsigned int i;
+ BOOL support_d3dcolor = gl_info->supported[ARB_VERTEX_ARRAY_BGRA];
/* In d3d7 the vertex buffer declaration NEVER changes because it is stored in the d3d7 vertex buffer.
* Once we have our declaration there is no need to look it up again. Index buffers also never need
@@ -416,6 +339,20 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This)
if(This->resource.usage & WINED3DUSAGE_STATICDECL) return FALSE;
}
+ if (use_vs(state))
+ {
+ TRACE("Vertex shaders used, no VBO conversion is needed\n");
+ if(This->conversion_map)
+ {
+ HeapFree(GetProcessHeap(), 0, This->conversion_map);
+ This->conversion_map = NULL;
+ This->stride = 0;
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
TRACE("Finding vertex buffer conversion information\n");
/* Certain declaration types need some fixups before we can pass them to
* opengl. This means D3DCOLOR attributes with fixed function vertex
@@ -461,79 +398,31 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This)
* conversion types depend on the semantic as well, for example a FLOAT4
* texcoord needs no conversion while a FLOAT4 positiont needs one
*/
- if (use_vs(state))
- {
- TRACE("vshader\n");
- /* If the current vertex declaration is marked for no half float conversion don't bother to
- * analyse the strided streams in depth, just set them up for no conversion. Return decl changed
- * if we used conversion before
- */
- if (!state->vertex_declaration->half_float_conv_needed)
- {
- if (This->conversion_map)
- {
- TRACE("Now using shaders without conversion, but conversion used before\n");
- HeapFree(GetProcessHeap(), 0, This->conversion_map);
- HeapFree(GetProcessHeap(), 0, This->conversion_shift);
- This->conversion_map = NULL;
- This->stride = 0;
- This->conversion_shift = NULL;
- This->conversion_stride = 0;
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- for (i = 0; i < MAX_ATTRIBS; ++i)
- {
- ret = buffer_check_attribute(This, si, i, FALSE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
- }
- /* Recalculate the conversion shift map if the declaration has changed,
- * and we're using float16 conversion or used it on the last run
- */
- if (ret && (float16_used || This->conversion_map))
- {
- HeapFree(GetProcessHeap(), 0, This->conversion_shift);
- This->conversion_shift = find_conversion_shift(This, si, This->stride);
- }
- }
- else
- {
- /* Fixed function is a bit trickier. We have to take care for D3DCOLOR types, FLOAT4 positions and of course
- * FLOAT16s if not supported. Also, we can't iterate over the array, so use macros to generate code for all
- * the attributes that our current fixed function pipeline implementation cares for.
- */
- BOOL support_d3dcolor = gl_info->supported[ARB_VERTEX_ARRAY_BGRA];
- ret = buffer_check_attribute(This, si, WINED3D_FFP_POSITION,
- TRUE, TRUE, FALSE, &stride_this_run, &float16_used) || ret;
- ret = buffer_check_attribute(This, si, WINED3D_FFP_NORMAL,
- TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
- ret = buffer_check_attribute(This, si, WINED3D_FFP_DIFFUSE,
- !support_d3dcolor, FALSE, TRUE, &stride_this_run, &float16_used) || ret;
- ret = buffer_check_attribute(This, si, WINED3D_FFP_SPECULAR,
- !support_d3dcolor, FALSE, TRUE, &stride_this_run, &float16_used) || ret;
- ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD0,
- TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
- ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD1,
- TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
- ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD2,
- TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
- ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD3,
- TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
- ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD4,
- TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
- ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD5,
- TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
- ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD6,
- TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
- ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD7,
- TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
-
- if (float16_used) FIXME("Float16 conversion used with fixed function vertex processing\n");
- }
+ ret = buffer_check_attribute(This, si, WINED3D_FFP_POSITION,
+ TRUE, TRUE, FALSE, &stride_this_run) || ret;
+ ret = buffer_check_attribute(This, si, WINED3D_FFP_NORMAL,
+ TRUE, FALSE, FALSE, &stride_this_run) || ret;
+ ret = buffer_check_attribute(This, si, WINED3D_FFP_DIFFUSE,
+ !support_d3dcolor, FALSE, TRUE, &stride_this_run) || ret;
+ ret = buffer_check_attribute(This, si, WINED3D_FFP_SPECULAR,
+ !support_d3dcolor, FALSE, TRUE, &stride_this_run) || ret;
+ ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD0,
+ TRUE, FALSE, FALSE, &stride_this_run) || ret;
+ ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD1,
+ TRUE, FALSE, FALSE, &stride_this_run) || ret;
+ ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD2,
+ TRUE, FALSE, FALSE, &stride_this_run) || ret;
+ ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD3,
+ TRUE, FALSE, FALSE, &stride_this_run) || ret;
+ ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD4,
+ TRUE, FALSE, FALSE, &stride_this_run) || ret;
+ ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD5,
+ TRUE, FALSE, FALSE, &stride_this_run) || ret;
+ ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD6,
+ TRUE, FALSE, FALSE, &stride_this_run) || ret;
+ ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD7,
+ TRUE, FALSE, FALSE, &stride_this_run) || ret;
if (!stride_this_run && This->conversion_map)
{
@@ -549,36 +438,6 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This)
return ret;
}
-/* Context activation is done by the caller. */
-static void buffer_check_buffer_object_size(struct wined3d_buffer *This, const struct wined3d_gl_info *gl_info)
-{
- UINT size = This->conversion_stride ?
- This->conversion_stride * (This->resource.size / This->stride) : This->resource.size;
- if (This->buffer_object_size != size)
- {
- TRACE("Old size %u, creating new size %u\n", This->buffer_object_size, size);
-
- if(This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
- {
- IWineD3DDeviceImpl_MarkStateDirty(This->resource.device, STATE_INDEXBUFFER);
- }
-
- /* Rescue the data before resizing the buffer object if we do not have our backup copy */
- if(!(This->flags & WINED3D_BUFFER_DOUBLEBUFFER))
- {
- buffer_get_sysmem(This, gl_info);
- }
-
- ENTER_GL();
- GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
- checkGLcall("glBindBufferARB");
- GL_EXTCALL(glBufferDataARB(This->buffer_type_hint, size, NULL, This->buffer_object_usage));
- This->buffer_object_size = size;
- checkGLcall("glBufferDataARB");
- LEAVE_GL();
- }
-}
-
static inline void fixup_d3dcolor(DWORD *dst_color)
{
DWORD src_color = *dst_color;
@@ -611,24 +470,23 @@ static inline void fixup_transformed_pos(float *p)
}
/* Context activation is done by the caller. */
-const BYTE *buffer_get_memory(IWineD3DBuffer *iface, const struct wined3d_gl_info *gl_info, GLuint *buffer_object)
+const BYTE *buffer_get_memory(struct wined3d_buffer *buffer,
+ const struct wined3d_gl_info *gl_info, GLuint *buffer_object)
{
- struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
-
- *buffer_object = This->buffer_object;
- if (!This->buffer_object)
+ *buffer_object = buffer->buffer_object;
+ if (!buffer->buffer_object)
{
- if (This->flags & WINED3D_BUFFER_CREATEBO)
+ if (buffer->flags & WINED3D_BUFFER_CREATEBO)
{
- buffer_create_buffer_object(This, gl_info);
- This->flags &= ~WINED3D_BUFFER_CREATEBO;
- if (This->buffer_object)
+ buffer_create_buffer_object(buffer, gl_info);
+ buffer->flags &= ~WINED3D_BUFFER_CREATEBO;
+ if (buffer->buffer_object)
{
- *buffer_object = This->buffer_object;
+ *buffer_object = buffer->buffer_object;
return NULL;
}
}
- return This->resource.allocatedMemory;
+ return buffer->resource.allocatedMemory;
}
else
{
@@ -636,36 +494,11 @@ const BYTE *buffer_get_memory(IWineD3DBuffer *iface, const struct wined3d_gl_inf
}
}
-/* IUnknown methods */
-
-static HRESULT STDMETHODCALLTYPE buffer_QueryInterface(IWineD3DBuffer *iface,
- REFIID riid, void **object)
+ULONG CDECL wined3d_buffer_incref(struct wined3d_buffer *buffer)
{
- TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
+ ULONG refcount = InterlockedIncrement(&buffer->resource.ref);
- if (IsEqualGUID(riid, &IID_IWineD3DBuffer)
- || IsEqualGUID(riid, &IID_IWineD3DResource)
- || 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 buffer_AddRef(IWineD3DBuffer *iface)
-{
- struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
- ULONG refcount = InterlockedIncrement(&This->resource.ref);
-
- TRACE("%p increasing refcount to %u\n", This, refcount);
+ TRACE("%p increasing refcount to %u.\n", buffer, refcount);
return refcount;
}
@@ -678,6 +511,12 @@ BYTE *buffer_get_sysmem(struct wined3d_buffer *This, const struct wined3d_gl_inf
This->resource.heapMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->resource.size + RESOURCE_ALIGNMENT);
This->resource.allocatedMemory = (BYTE *)(((ULONG_PTR)This->resource.heapMemory + (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
+
+ if (This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
+ {
+ IWineD3DDeviceImpl_MarkStateDirty(This->resource.device, STATE_INDEXBUFFER);
+ }
+
ENTER_GL();
GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
GL_EXTCALL(glGetBufferSubDataARB(This->buffer_type_hint, 0, This->resource.size, This->resource.allocatedMemory));
@@ -688,99 +527,93 @@ BYTE *buffer_get_sysmem(struct wined3d_buffer *This, const struct wined3d_gl_inf
}
/* Do not call while under the GL lock. */
-static void STDMETHODCALLTYPE buffer_UnLoad(IWineD3DBuffer *iface)
+static void buffer_unload(struct wined3d_resource *resource)
{
- struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
+ struct wined3d_buffer *buffer = buffer_from_resource(resource);
- TRACE("iface %p\n", iface);
+ TRACE("buffer %p.\n", buffer);
- if (This->buffer_object)
+ if (buffer->buffer_object)
{
- IWineD3DDeviceImpl *device = This->resource.device;
+ struct wined3d_device *device = resource->device;
struct wined3d_context *context;
context = context_acquire(device, NULL);
/* Download the buffer, but don't permanently enable double buffering */
- if(!(This->flags & WINED3D_BUFFER_DOUBLEBUFFER))
+ if (!(buffer->flags & WINED3D_BUFFER_DOUBLEBUFFER))
{
- buffer_get_sysmem(This, context->gl_info);
- This->flags &= ~WINED3D_BUFFER_DOUBLEBUFFER;
+ buffer_get_sysmem(buffer, context->gl_info);
+ buffer->flags &= ~WINED3D_BUFFER_DOUBLEBUFFER;
}
- delete_gl_buffer(This, context->gl_info);
- This->flags |= WINED3D_BUFFER_CREATEBO; /* Recreate the buffer object next load */
- buffer_clear_dirty_areas(This);
+ delete_gl_buffer(buffer, context->gl_info);
+ buffer->flags |= WINED3D_BUFFER_CREATEBO; /* Recreate the buffer object next load */
+ buffer_clear_dirty_areas(buffer);
context_release(context);
- HeapFree(GetProcessHeap(), 0, This->conversion_shift);
- This->conversion_shift = NULL;
- HeapFree(GetProcessHeap(), 0, This->conversion_map);
- This->conversion_map = NULL;
- This->stride = 0;
- This->conversion_stride = 0;
- This->flags &= ~WINED3D_BUFFER_HASDESC;
+ HeapFree(GetProcessHeap(), 0, buffer->conversion_map);
+ buffer->conversion_map = NULL;
+ buffer->stride = 0;
+ buffer->conversion_stride = 0;
+ buffer->flags &= ~WINED3D_BUFFER_HASDESC;
}
- resource_unload((IWineD3DResourceImpl *)This);
+ resource_unload(resource);
}
/* Do not call while under the GL lock. */
-static ULONG STDMETHODCALLTYPE buffer_Release(IWineD3DBuffer *iface)
+ULONG CDECL wined3d_buffer_decref(struct wined3d_buffer *buffer)
{
- struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
- ULONG refcount = InterlockedDecrement(&This->resource.ref);
+ ULONG refcount = InterlockedDecrement(&buffer->resource.ref);
- TRACE("%p decreasing refcount to %u\n", This, refcount);
+ TRACE("%p decreasing refcount to %u.\n", buffer, refcount);
if (!refcount)
{
- buffer_UnLoad(iface);
- resource_cleanup((IWineD3DResource *)iface);
- This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
- HeapFree(GetProcessHeap(), 0, This->maps);
- HeapFree(GetProcessHeap(), 0, This);
+ buffer_unload(&buffer->resource);
+ resource_cleanup(&buffer->resource);
+ buffer->resource.parent_ops->wined3d_object_destroyed(buffer->resource.parent);
+ HeapFree(GetProcessHeap(), 0, buffer->maps);
+ HeapFree(GetProcessHeap(), 0, buffer);
}
return refcount;
}
-/* IWineD3DBase methods */
-static void * STDMETHODCALLTYPE buffer_GetParent(IWineD3DBuffer *iface)
+void * CDECL wined3d_buffer_get_parent(const struct wined3d_buffer *buffer)
{
- TRACE("iface %p.\n", iface);
+ TRACE("buffer %p.\n", buffer);
- return ((struct wined3d_buffer *)iface)->resource.parent;
+ return buffer->resource.parent;
}
-/* IWineD3DResource methods */
-
-static HRESULT STDMETHODCALLTYPE buffer_SetPrivateData(IWineD3DBuffer *iface,
+HRESULT CDECL wined3d_buffer_set_private_data(struct wined3d_buffer *buffer,
REFGUID guid, const void *data, DWORD data_size, DWORD flags)
{
- return resource_set_private_data((IWineD3DResource *)iface, guid, data, data_size, flags);
+ return resource_set_private_data(&buffer->resource, guid, data, data_size, flags);
}
-static HRESULT STDMETHODCALLTYPE buffer_GetPrivateData(IWineD3DBuffer *iface,
+HRESULT CDECL wined3d_buffer_get_private_data(const struct wined3d_buffer *buffer,
REFGUID guid, void *data, DWORD *data_size)
{
- return resource_get_private_data((IWineD3DResource *)iface, guid, data, data_size);
+ return resource_get_private_data(&buffer->resource, guid, data, data_size);
}
-static HRESULT STDMETHODCALLTYPE buffer_FreePrivateData(IWineD3DBuffer *iface, REFGUID guid)
+HRESULT CDECL wined3d_buffer_free_private_data(struct wined3d_buffer *buffer, REFGUID guid)
{
- return resource_free_private_data((IWineD3DResource *)iface, guid);
+ return resource_free_private_data(&buffer->resource, guid);
}
-static DWORD STDMETHODCALLTYPE buffer_SetPriority(IWineD3DBuffer *iface, DWORD priority)
+DWORD CDECL wined3d_buffer_set_priority(struct wined3d_buffer *buffer, DWORD priority)
{
- return resource_set_priority((IWineD3DResource *)iface, priority);
+ return resource_set_priority(&buffer->resource, priority);
}
-static DWORD STDMETHODCALLTYPE buffer_GetPriority(IWineD3DBuffer *iface)
+DWORD CDECL wined3d_buffer_get_priority(const struct wined3d_buffer *buffer)
{
- return resource_get_priority((IWineD3DResource *)iface);
+ return resource_get_priority(&buffer->resource);
}
/* The caller provides a context and binds the buffer */
@@ -857,120 +690,124 @@ drop_query:
/* The caller provides a GL context */
static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined3d_gl_info *gl_info, DWORD flags)
{
- BYTE *map;
- UINT start = 0, len = 0;
+ BYTE *map;
+ UINT start = 0, len = 0;
+
+ ENTER_GL();
+
+ /* This potentially invalidates the element array buffer binding, but the
+ * caller always takes care of this. */
+ GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
+ checkGLcall("glBindBufferARB");
+ if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
+ {
+ GLbitfield mapflags;
+ mapflags = GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT;
+ if (flags & WINED3D_BUFFER_DISCARD)
+ {
+ mapflags |= GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_INVALIDATE_BUFFER_BIT;
+ }
+ else if (flags & WINED3D_BUFFER_NOSYNC)
+ {
+ mapflags |= GL_MAP_UNSYNCHRONIZED_BIT;
+ }
+ map = GL_EXTCALL(glMapBufferRange(This->buffer_type_hint, 0,
+ This->resource.size, mapflags));
+ checkGLcall("glMapBufferRange");
+ }
+ else
+ {
+ if (This->flags & WINED3D_BUFFER_APPLESYNC)
+ {
+ DWORD syncflags = 0;
+ if (flags & WINED3D_BUFFER_DISCARD) syncflags |= WINED3DLOCK_DISCARD;
+ if (flags & WINED3D_BUFFER_NOSYNC) syncflags |= WINED3DLOCK_NOOVERWRITE;
+ LEAVE_GL();
+ buffer_sync_apple(This, syncflags, gl_info);
+ ENTER_GL();
+ }
+ map = GL_EXTCALL(glMapBufferARB(This->buffer_type_hint, GL_WRITE_ONLY_ARB));
+ checkGLcall("glMapBufferARB");
+ }
+ if (!map)
+ {
+ LEAVE_GL();
+ ERR("Failed to map opengl buffer\n");
+ return;
+ }
+
+ while (This->modified_areas)
+ {
+ This->modified_areas--;
+ start = This->maps[This->modified_areas].offset;
+ len = This->maps[This->modified_areas].size;
+
+ memcpy(map + start, This->resource.allocatedMemory + start, len);
- ENTER_GL();
- GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
- checkGLcall("glBindBufferARB");
if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
{
- GLbitfield mapflags;
- mapflags = GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT;
- if (flags & WINED3D_BUFFER_DISCARD)
- {
- mapflags |= GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_INVALIDATE_BUFFER_BIT;
- }
- else if (flags & WINED3D_BUFFER_NOSYNC)
- {
- mapflags |= GL_MAP_UNSYNCHRONIZED_BIT;
- }
- map = GL_EXTCALL(glMapBufferRange(This->buffer_type_hint, 0,
- This->resource.size, mapflags));
- checkGLcall("glMapBufferRange");
+ GL_EXTCALL(glFlushMappedBufferRange(This->buffer_type_hint, start, len));
+ checkGLcall("glFlushMappedBufferRange");
}
- else
+ else if (This->flags & WINED3D_BUFFER_FLUSH)
{
- if (This->flags & WINED3D_BUFFER_APPLESYNC)
- {
- DWORD syncflags = 0;
- if (flags & WINED3D_BUFFER_DISCARD) syncflags |= WINED3DLOCK_DISCARD;
- if (flags & WINED3D_BUFFER_NOSYNC) syncflags |= WINED3DLOCK_NOOVERWRITE;
- LEAVE_GL();
- buffer_sync_apple(This, syncflags, gl_info);
- ENTER_GL();
- }
- map = GL_EXTCALL(glMapBufferARB(This->buffer_type_hint, GL_WRITE_ONLY_ARB));
- checkGLcall("glMapBufferARB");
- }
- if (!map)
- {
- LEAVE_GL();
- ERR("Failed to map opengl buffer\n");
- return;
+ GL_EXTCALL(glFlushMappedBufferRangeAPPLE(This->buffer_type_hint, start, len));
+ checkGLcall("glFlushMappedBufferRangeAPPLE");
}
+ }
+ GL_EXTCALL(glUnmapBufferARB(This->buffer_type_hint));
+ checkGLcall("glUnmapBufferARB");
- while(This->modified_areas)
- {
- This->modified_areas--;
- start = This->maps[This->modified_areas].offset;
- len = This->maps[This->modified_areas].size;
-
- memcpy(map + start, This->resource.allocatedMemory + start, len);
-
- if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
- {
- GL_EXTCALL(glFlushMappedBufferRange(This->buffer_type_hint, start, len));
- checkGLcall("glFlushMappedBufferRange");
- }
- else if (This->flags & WINED3D_BUFFER_FLUSH)
- {
- GL_EXTCALL(glFlushMappedBufferRangeAPPLE(This->buffer_type_hint, start, len));
- checkGLcall("glFlushMappedBufferRangeAPPLE");
- }
- }
- GL_EXTCALL(glUnmapBufferARB(This->buffer_type_hint));
- checkGLcall("glUnmapBufferARB");
- LEAVE_GL();
+ LEAVE_GL();
}
/* Do not call while under the GL lock. */
-static void STDMETHODCALLTYPE buffer_PreLoad(IWineD3DBuffer *iface)
+void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
{
- struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
- IWineD3DDeviceImpl *device = This->resource.device;
+ DWORD flags = buffer->flags & (WINED3D_BUFFER_NOSYNC | WINED3D_BUFFER_DISCARD);
+ struct wined3d_device *device = buffer->resource.device;
UINT start = 0, end = 0, len = 0, vertices;
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
BOOL decl_changed = FALSE;
unsigned int i, j;
BYTE *data;
- DWORD flags = This->flags & (WINED3D_BUFFER_NOSYNC | WINED3D_BUFFER_DISCARD);
- TRACE("iface %p\n", iface);
- This->flags &= ~(WINED3D_BUFFER_NOSYNC | WINED3D_BUFFER_DISCARD);
+ TRACE("buffer %p.\n", buffer);
- context = context_acquire(device, NULL);
- gl_info = context->gl_info;
+ buffer->flags &= ~(WINED3D_BUFFER_NOSYNC | WINED3D_BUFFER_DISCARD);
- if (!This->buffer_object)
+ if (!buffer->buffer_object)
{
/* TODO: Make converting independent from VBOs */
- if (This->flags & WINED3D_BUFFER_CREATEBO)
+ if (buffer->flags & WINED3D_BUFFER_CREATEBO)
{
- buffer_create_buffer_object(This, gl_info);
- This->flags &= ~WINED3D_BUFFER_CREATEBO;
+ context = context_acquire(device, NULL);
+ buffer_create_buffer_object(buffer, context->gl_info);
+ context_release(context);
+ buffer->flags &= ~WINED3D_BUFFER_CREATEBO;
}
else
{
/* Not doing any conversion */
- goto end;
+ return;
}
}
/* Reading the declaration makes only sense if the stateblock is finalized and the buffer bound to a stream */
- if (device->isInDraw && This->bind_count > 0)
+ if (device->isInDraw && buffer->bind_count > 0)
{
- decl_changed = buffer_find_decl(This);
- This->flags |= WINED3D_BUFFER_HASDESC;
+ decl_changed = buffer_find_decl(buffer);
+ buffer->flags |= WINED3D_BUFFER_HASDESC;
}
- if (!decl_changed && !(This->flags & WINED3D_BUFFER_HASDESC && buffer_is_dirty(This)))
+ if (!decl_changed && !(buffer->flags & WINED3D_BUFFER_HASDESC && buffer_is_dirty(buffer)))
{
- context_release(context);
- ++This->draw_count;
- if (This->draw_count > VB_RESETDECLCHANGE) This->decl_change_count = 0;
- if (This->draw_count > VB_RESETFULLCONVS) This->full_conversion_count = 0;
+ ++buffer->draw_count;
+ if (buffer->draw_count > VB_RESETDECLCHANGE)
+ buffer->decl_change_count = 0;
+ if (buffer->draw_count > VB_RESETFULLCONVS)
+ buffer->full_conversion_count = 0;
return;
}
@@ -980,34 +817,33 @@ static void STDMETHODCALLTYPE buffer_PreLoad(IWineD3DBuffer *iface)
*/
if (decl_changed)
{
- ++This->decl_change_count;
- This->draw_count = 0;
+ ++buffer->decl_change_count;
+ buffer->draw_count = 0;
- if (This->decl_change_count > VB_MAXDECLCHANGES ||
- (This->conversion_map && (This->resource.usage & WINED3DUSAGE_DYNAMIC)))
+ if (buffer->decl_change_count > VB_MAXDECLCHANGES
+ || (buffer->conversion_map && (buffer->resource.usage & WINED3DUSAGE_DYNAMIC)))
{
FIXME("Too many declaration changes or converting dynamic buffer, stopping converting\n");
- IWineD3DBuffer_UnLoad(iface);
- This->flags &= ~WINED3D_BUFFER_CREATEBO;
+ buffer_unload(&buffer->resource);
+ buffer->flags &= ~WINED3D_BUFFER_CREATEBO;
- /* The stream source state handler might have read the memory of the vertex buffer already
- * and got the memory in the vbo which is not valid any longer. Dirtify the stream source
- * to force a reload. This happens only once per changed vertexbuffer and should occur rather
- * rarely
- */
+ /* The stream source state handler might have read the memory of
+ * the vertex buffer already and got the memory in the vbo which
+ * is not valid any longer. Dirtify the stream source to force a
+ * reload. This happens only once per changed vertexbuffer and
+ * should occur rather rarely. */
IWineD3DDeviceImpl_MarkStateDirty(device, STATE_STREAMSRC);
- goto end;
+ return;
}
- buffer_check_buffer_object_size(This, gl_info);
/* The declaration changed, reload the whole buffer */
WARN("Reloading buffer because of decl change\n");
- buffer_clear_dirty_areas(This);
- if(!buffer_add_dirty_area(This, 0, 0))
+ buffer_clear_dirty_areas(buffer);
+ if (!buffer_add_dirty_area(buffer, 0, 0))
{
ERR("buffer_add_dirty_area failed, this is not expected\n");
- goto end;
+ return;
}
/* Avoid unfenced updates, we might overwrite more areas of the buffer than the application
* cleared for unsynchronized updates
@@ -1020,172 +856,111 @@ static void STDMETHODCALLTYPE buffer_PreLoad(IWineD3DBuffer *iface)
* changes it every minute drop the VBO after VB_MAX_DECL_CHANGES minutes. So count draws without
* decl changes and reset the decl change count after a specific number of them
*/
- if(buffer_is_fully_dirty(This))
+ if (buffer->conversion_map && buffer_is_fully_dirty(buffer))
{
- ++This->full_conversion_count;
- if(This->full_conversion_count > VB_MAXFULLCONVERSIONS)
+ ++buffer->full_conversion_count;
+ if (buffer->full_conversion_count > VB_MAXFULLCONVERSIONS)
{
- FIXME("Too many full buffer conversions, stopping converting\n");
- IWineD3DBuffer_UnLoad(iface);
- This->flags &= ~WINED3D_BUFFER_CREATEBO;
+ FIXME("Too many full buffer conversions, stopping converting.\n");
+ buffer_unload(&buffer->resource);
+ buffer->flags &= ~WINED3D_BUFFER_CREATEBO;
IWineD3DDeviceImpl_MarkStateDirty(device, STATE_STREAMSRC);
- goto end;
+ return;
}
}
else
{
- ++This->draw_count;
- if (This->draw_count > VB_RESETDECLCHANGE) This->decl_change_count = 0;
- if (This->draw_count > VB_RESETFULLCONVS) This->full_conversion_count = 0;
+ ++buffer->draw_count;
+ if (buffer->draw_count > VB_RESETDECLCHANGE)
+ buffer->decl_change_count = 0;
+ if (buffer->draw_count > VB_RESETFULLCONVS)
+ buffer->full_conversion_count = 0;
}
}
- if(This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
- {
- IWineD3DDeviceImpl_MarkStateDirty(This->resource.device, STATE_INDEXBUFFER);
- }
+ if (buffer->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_INDEXBUFFER);
- if (!This->conversion_map)
+ if (!buffer->conversion_map)
{
- /* That means that there is nothing to fixup. Just upload from This->resource.allocatedMemory
- * directly into the vbo. Do not free the system memory copy because drawPrimitive may need it if
- * the stride is 0, for instancing emulation, vertex blending emulation or shader emulation.
- */
- TRACE("No conversion needed\n");
+ /* That means that there is nothing to fixup. Just upload from
+ * buffer->resource.allocatedMemory directly into the vbo. Do not
+ * free the system memory copy because drawPrimitive may need it if
+ * the stride is 0, for instancing emulation, vertex blending
+ * emulation or shader emulation. */
+ TRACE("No conversion needed.\n");
/* Nothing to do because we locked directly into the vbo */
- if (!(This->flags & WINED3D_BUFFER_DOUBLEBUFFER))
+ if (!(buffer->flags & WINED3D_BUFFER_DOUBLEBUFFER))
{
- context_release(context);
return;
}
- buffer_direct_upload(This, context->gl_info, flags);
+ context = context_acquire(device, NULL);
+ buffer_direct_upload(buffer, context->gl_info, flags);
context_release(context);
return;
}
- if(!(This->flags & WINED3D_BUFFER_DOUBLEBUFFER))
+ context = context_acquire(device, NULL);
+ gl_info = context->gl_info;
+
+ if(!(buffer->flags & WINED3D_BUFFER_DOUBLEBUFFER))
{
- buffer_get_sysmem(This, gl_info);
+ buffer_get_sysmem(buffer, gl_info);
}
/* Now for each vertex in the buffer that needs conversion */
- vertices = This->resource.size / This->stride;
+ vertices = buffer->resource.size / buffer->stride;
- if (This->conversion_shift)
+ data = HeapAlloc(GetProcessHeap(), 0, buffer->resource.size);
+
+ while(buffer->modified_areas)
{
- TRACE("Shifted conversion\n");
- data = HeapAlloc(GetProcessHeap(), 0, vertices * This->conversion_stride);
-
- start = 0;
- len = This->resource.size;
+ buffer->modified_areas--;
+ start = buffer->maps[buffer->modified_areas].offset;
+ len = buffer->maps[buffer->modified_areas].size;
end = start + len;
- if (This->maps[0].offset || This->maps[0].size != This->resource.size)
+ memcpy(data + start, buffer->resource.allocatedMemory + start, end - start);
+ for (i = start / buffer->stride; i < min((end / buffer->stride) + 1, vertices); ++i)
{
- FIXME("Implement partial buffer load with shifted conversion\n");
- }
-
- for (i = start / This->stride; i < min((end / This->stride) + 1, vertices); ++i)
- {
- for (j = 0; j < This->stride; ++j)
+ for (j = 0; j < buffer->stride; ++j)
{
- switch(This->conversion_map[j])
+ switch (buffer->conversion_map[j])
{
case CONV_NONE:
- data[This->conversion_stride * i + j + This->conversion_shift[j]]
- = This->resource.allocatedMemory[This->stride * i + j];
+ /* Done already */
+ j += 3;
+ break;
+ case CONV_D3DCOLOR:
+ fixup_d3dcolor((DWORD *) (data + i * buffer->stride + j));
+ j += 3;
break;
- case CONV_FLOAT16_2:
- {
- float *out = (float *)(&data[This->conversion_stride * i + j + This->conversion_shift[j]]);
- const WORD *in = (WORD *)(&This->resource.allocatedMemory[i * This->stride + j]);
-
- out[1] = float_16_to_32(in + 1);
- out[0] = float_16_to_32(in + 0);
- j += 3; /* Skip 3 additional bytes,as a FLOAT16_2 has 4 bytes */
+ case CONV_POSITIONT:
+ fixup_transformed_pos((float *) (data + i * buffer->stride + j));
+ j += 15;
break;
- }
-
default:
- FIXME("Unimplemented conversion %d in shifted conversion\n", This->conversion_map[j]);
- break;
+ FIXME("Unimplemented conversion %d in shifted conversion\n", buffer->conversion_map[j]);
}
}
}
ENTER_GL();
- GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
+ GL_EXTCALL(glBindBufferARB(buffer->buffer_type_hint, buffer->buffer_object));
checkGLcall("glBindBufferARB");
- GL_EXTCALL(glBufferSubDataARB(This->buffer_type_hint, 0, vertices * This->conversion_stride, data));
+ GL_EXTCALL(glBufferSubDataARB(buffer->buffer_type_hint, start, len, data + start));
checkGLcall("glBufferSubDataARB");
LEAVE_GL();
}
- else
- {
- data = HeapAlloc(GetProcessHeap(), 0, This->resource.size);
-
- while(This->modified_areas)
- {
- This->modified_areas--;
- start = This->maps[This->modified_areas].offset;
- len = This->maps[This->modified_areas].size;
- end = start + len;
-
- memcpy(data + start, This->resource.allocatedMemory + start, end - start);
- for (i = start / This->stride; i < min((end / This->stride) + 1, vertices); ++i)
- {
- for (j = 0; j < This->stride; ++j)
- {
- switch(This->conversion_map[j])
- {
- case CONV_NONE:
- /* Done already */
- j += 3;
- break;
- case CONV_D3DCOLOR:
- fixup_d3dcolor((DWORD *) (data + i * This->stride + j));
- j += 3;
- break;
-
- case CONV_POSITIONT:
- fixup_transformed_pos((float *) (data + i * This->stride + j));
- j += 15;
- break;
-
- case CONV_FLOAT16_2:
- ERR("Did not expect FLOAT16 conversion in unshifted conversion\n");
- default:
- FIXME("Unimplemented conversion %d in shifted conversion\n", This->conversion_map[j]);
- }
- }
- }
-
- ENTER_GL();
- GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
- checkGLcall("glBindBufferARB");
- GL_EXTCALL(glBufferSubDataARB(This->buffer_type_hint, start, len, data + start));
- checkGLcall("glBufferSubDataARB");
- LEAVE_GL();
- }
- }
HeapFree(GetProcessHeap(), 0, data);
-
-end:
context_release(context);
}
-static WINED3DRESOURCETYPE STDMETHODCALLTYPE buffer_GetType(IWineD3DBuffer *iface)
-{
- return resource_get_type((IWineD3DResource *)iface);
-}
-
-/* IWineD3DBuffer methods */
-
static DWORD buffer_sanitize_flags(struct wined3d_buffer *buffer, DWORD flags)
{
/* Not all flags make sense together, but Windows never returns an error. Catch the
@@ -1236,75 +1011,80 @@ static GLbitfield buffer_gl_map_flags(DWORD d3d_flags)
return ret;
}
-static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset, UINT size, BYTE **data, DWORD flags)
+struct wined3d_resource * CDECL wined3d_buffer_get_resource(struct wined3d_buffer *buffer)
{
- struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
+ TRACE("buffer %p.\n", buffer);
+
+ return &buffer->resource;
+}
+
+HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UINT size, BYTE **data, DWORD flags)
+{
+ BOOL dirty = buffer_is_dirty(buffer);
LONG count;
- BOOL dirty = buffer_is_dirty(This);
- TRACE("iface %p, offset %u, size %u, data %p, flags %#x\n", iface, offset, size, data, flags);
+ TRACE("buffer %p, offset %u, size %u, data %p, flags %#x\n", buffer, offset, size, data, flags);
- flags = buffer_sanitize_flags(This, flags);
+ flags = buffer_sanitize_flags(buffer, flags);
if (!(flags & WINED3DLOCK_READONLY))
{
- if (!buffer_add_dirty_area(This, offset, size)) return E_OUTOFMEMORY;
+ if (!buffer_add_dirty_area(buffer, offset, size)) return E_OUTOFMEMORY;
}
- count = InterlockedIncrement(&This->lock_count);
+ count = InterlockedIncrement(&buffer->lock_count);
- if (This->buffer_object)
+ if (buffer->buffer_object)
{
- if(!(This->flags & WINED3D_BUFFER_DOUBLEBUFFER))
+ if (!(buffer->flags & WINED3D_BUFFER_DOUBLEBUFFER))
{
- if(count == 1)
+ if (count == 1)
{
- IWineD3DDeviceImpl *device = This->resource.device;
+ struct wined3d_device *device = buffer->resource.device;
struct wined3d_context *context;
const struct wined3d_gl_info *gl_info;
- if(This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
- {
- IWineD3DDeviceImpl_MarkStateDirty(This->resource.device, STATE_INDEXBUFFER);
- }
+ if (buffer->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_INDEXBUFFER);
context = context_acquire(device, NULL);
gl_info = context->gl_info;
ENTER_GL();
- GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
+ GL_EXTCALL(glBindBufferARB(buffer->buffer_type_hint, buffer->buffer_object));
if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
{
GLbitfield mapflags = buffer_gl_map_flags(flags);
- This->resource.allocatedMemory = GL_EXTCALL(glMapBufferRange(This->buffer_type_hint, 0,
- This->resource.size, mapflags));
+ buffer->resource.allocatedMemory = GL_EXTCALL(glMapBufferRange(buffer->buffer_type_hint,
+ 0, buffer->resource.size, mapflags));
checkGLcall("glMapBufferRange");
}
else
{
- if(This->flags & WINED3D_BUFFER_APPLESYNC)
+ if (buffer->flags & WINED3D_BUFFER_APPLESYNC)
{
LEAVE_GL();
- buffer_sync_apple(This, flags, gl_info);
+ buffer_sync_apple(buffer, flags, gl_info);
ENTER_GL();
}
- This->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(This->buffer_type_hint, GL_READ_WRITE_ARB));
+ buffer->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(buffer->buffer_type_hint,
+ GL_READ_WRITE_ARB));
checkGLcall("glMapBufferARB");
}
LEAVE_GL();
- if (((DWORD_PTR) This->resource.allocatedMemory) & (RESOURCE_ALIGNMENT - 1))
+ if (((DWORD_PTR)buffer->resource.allocatedMemory) & (RESOURCE_ALIGNMENT - 1))
{
- WARN("Pointer %p is not %u byte aligned, falling back to double buffered operation\n",
- This->resource.allocatedMemory, RESOURCE_ALIGNMENT);
+ WARN("Pointer %p is not %u byte aligned, falling back to double buffered operation.\n",
+ buffer->resource.allocatedMemory, RESOURCE_ALIGNMENT);
ENTER_GL();
- GL_EXTCALL(glUnmapBufferARB(This->buffer_type_hint));
+ GL_EXTCALL(glUnmapBufferARB(buffer->buffer_type_hint));
checkGLcall("glUnmapBufferARB");
LEAVE_GL();
- This->resource.allocatedMemory = NULL;
+ buffer->resource.allocatedMemory = NULL;
- buffer_get_sysmem(This, gl_info);
- TRACE("New pointer is %p\n", This->resource.allocatedMemory);
+ buffer_get_sysmem(buffer, gl_info);
+ TRACE("New pointer is %p.\n", buffer->resource.allocatedMemory);
}
context_release(context);
}
@@ -1313,143 +1093,108 @@ static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset,
{
if (dirty)
{
- if (This->flags & WINED3D_BUFFER_NOSYNC && !(flags & WINED3DLOCK_NOOVERWRITE))
+ if (buffer->flags & WINED3D_BUFFER_NOSYNC && !(flags & WINED3DLOCK_NOOVERWRITE))
{
- This->flags &= ~WINED3D_BUFFER_NOSYNC;
+ buffer->flags &= ~WINED3D_BUFFER_NOSYNC;
}
}
else if(flags & WINED3DLOCK_NOOVERWRITE)
{
- This->flags |= WINED3D_BUFFER_NOSYNC;
+ buffer->flags |= WINED3D_BUFFER_NOSYNC;
}
if (flags & WINED3DLOCK_DISCARD)
{
- This->flags |= WINED3D_BUFFER_DISCARD;
+ buffer->flags |= WINED3D_BUFFER_DISCARD;
}
}
}
- *data = This->resource.allocatedMemory + offset;
+ *data = buffer->resource.allocatedMemory + offset;
- TRACE("Returning memory at %p (base %p, offset %u)\n", *data, This->resource.allocatedMemory, offset);
- /* TODO: check Flags compatibility with This->currentDesc.Usage (see MSDN) */
+ TRACE("Returning memory at %p (base %p, offset %u).\n", *data, buffer->resource.allocatedMemory, offset);
+ /* TODO: check Flags compatibility with buffer->currentDesc.Usage (see MSDN) */
return WINED3D_OK;
}
-static HRESULT STDMETHODCALLTYPE buffer_Unmap(IWineD3DBuffer *iface)
+void CDECL wined3d_buffer_unmap(struct wined3d_buffer *buffer)
{
- struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
ULONG i;
- TRACE("(%p)\n", This);
+ TRACE("buffer %p.\n", buffer);
/* In the case that the number of Unmap calls > the
* number of Map calls, d3d returns always D3D_OK.
* This is also needed to prevent Map from returning garbage on
* the next call (this will happen if the lock_count is < 0). */
- if (!This->lock_count)
+ if (!buffer->lock_count)
{
- TRACE("Unmap called without a previous Map call!\n");
- return WINED3D_OK;
+ WARN("Unmap called without a previous map call.\n");
+ return;
}
- if (InterlockedDecrement(&This->lock_count))
+ if (InterlockedDecrement(&buffer->lock_count))
{
/* Delay loading the buffer until everything is unlocked */
- TRACE("Ignoring unlock\n");
- return WINED3D_OK;
+ TRACE("Ignoring unmap.\n");
+ return;
}
- if(!(This->flags & WINED3D_BUFFER_DOUBLEBUFFER) && This->buffer_object)
+ if (!(buffer->flags & WINED3D_BUFFER_DOUBLEBUFFER) && buffer->buffer_object)
{
- IWineD3DDeviceImpl *device = This->resource.device;
+ struct wined3d_device *device = buffer->resource.device;
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
- if(This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
+ if (buffer->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
{
- IWineD3DDeviceImpl_MarkStateDirty(This->resource.device, STATE_INDEXBUFFER);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_INDEXBUFFER);
}
context = context_acquire(device, NULL);
gl_info = context->gl_info;
ENTER_GL();
- GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
+ GL_EXTCALL(glBindBufferARB(buffer->buffer_type_hint, buffer->buffer_object));
if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
{
- for(i = 0; i < This->modified_areas; i++)
+ for (i = 0; i < buffer->modified_areas; ++i)
{
- GL_EXTCALL(glFlushMappedBufferRange(This->buffer_type_hint,
- This->maps[i].offset,
- This->maps[i].size));
+ GL_EXTCALL(glFlushMappedBufferRange(buffer->buffer_type_hint,
+ buffer->maps[i].offset, buffer->maps[i].size));
checkGLcall("glFlushMappedBufferRange");
}
}
- else if (This->flags & WINED3D_BUFFER_FLUSH)
+ else if (buffer->flags & WINED3D_BUFFER_FLUSH)
{
- for(i = 0; i < This->modified_areas; i++)
+ for (i = 0; i < buffer->modified_areas; ++i)
{
- GL_EXTCALL(glFlushMappedBufferRangeAPPLE(This->buffer_type_hint,
- This->maps[i].offset,
- This->maps[i].size));
+ GL_EXTCALL(glFlushMappedBufferRangeAPPLE(buffer->buffer_type_hint,
+ buffer->maps[i].offset, buffer->maps[i].size));
checkGLcall("glFlushMappedBufferRangeAPPLE");
}
}
- GL_EXTCALL(glUnmapBufferARB(This->buffer_type_hint));
+ GL_EXTCALL(glUnmapBufferARB(buffer->buffer_type_hint));
LEAVE_GL();
context_release(context);
- This->resource.allocatedMemory = NULL;
- buffer_clear_dirty_areas(This);
+ buffer->resource.allocatedMemory = NULL;
+ buffer_clear_dirty_areas(buffer);
}
- else if (This->flags & WINED3D_BUFFER_HASDESC)
+ else if (buffer->flags & WINED3D_BUFFER_HASDESC)
{
- buffer_PreLoad(iface);
+ wined3d_buffer_preload(buffer);
}
-
- return WINED3D_OK;
}
-static void STDMETHODCALLTYPE buffer_GetDesc(IWineD3DBuffer *iface, WINED3DBUFFER_DESC *desc)
+static const struct wined3d_resource_ops buffer_resource_ops =
{
- struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
-
- TRACE("(%p)\n", This);
-
- desc->Type = This->resource.resourceType;
- desc->Usage = This->resource.usage;
- desc->Pool = This->resource.pool;
- desc->Size = This->resource.size;
-}
-
-static const struct IWineD3DBufferVtbl wined3d_buffer_vtbl =
-{
- /* IUnknown methods */
- buffer_QueryInterface,
- buffer_AddRef,
- buffer_Release,
- /* IWineD3DBase methods */
- buffer_GetParent,
- /* IWineD3DResource methods */
- buffer_SetPrivateData,
- buffer_GetPrivateData,
- buffer_FreePrivateData,
- buffer_SetPriority,
- buffer_GetPriority,
- buffer_PreLoad,
- buffer_UnLoad,
- buffer_GetType,
- /* IWineD3DBuffer methods */
- buffer_Map,
- buffer_Unmap,
- buffer_GetDesc,
+ buffer_unload,
};
-HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device,
+static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device *device,
UINT size, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool, GLenum bind_hint,
const char *data, void *parent, const struct wined3d_parent_ops *parent_ops)
{
@@ -1464,10 +1209,9 @@ HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device,
return WINED3DERR_INVALIDCALL;
}
- buffer->vtbl = &wined3d_buffer_vtbl;
-
- hr = resource_init((IWineD3DResource *)buffer, WINED3DRTYPE_BUFFER,
- device, size, usage, format, pool, parent, parent_ops);
+ hr = resource_init(&buffer->resource, device, WINED3DRTYPE_BUFFER, format,
+ WINED3DMULTISAMPLE_NONE, 0, usage, pool, size, 1, 1, size,
+ parent, parent_ops, &buffer_resource_ops);
if (FAILED(hr))
{
WARN("Failed to initialize resource, hr %#x\n", hr);
@@ -1509,36 +1253,137 @@ HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device,
{
BYTE *ptr;
- hr = IWineD3DBuffer_Map((IWineD3DBuffer *)buffer, 0, size, &ptr, 0);
+ hr = wined3d_buffer_map(buffer, 0, size, &ptr, 0);
if (FAILED(hr))
{
ERR("Failed to map buffer, hr %#x\n", hr);
- buffer_UnLoad((IWineD3DBuffer *)buffer);
- resource_cleanup((IWineD3DResource *)buffer);
+ buffer_unload(&buffer->resource);
+ resource_cleanup(&buffer->resource);
return hr;
}
memcpy(ptr, data, size);
- hr = IWineD3DBuffer_Unmap((IWineD3DBuffer *)buffer);
- if (FAILED(hr))
- {
- ERR("Failed to unmap buffer, hr %#x\n", hr);
- buffer_UnLoad((IWineD3DBuffer *)buffer);
- resource_cleanup((IWineD3DResource *)buffer);
- return hr;
- }
+ wined3d_buffer_unmap(buffer);
}
buffer->maps = HeapAlloc(GetProcessHeap(), 0, sizeof(*buffer->maps));
if (!buffer->maps)
{
ERR("Out of memory\n");
- buffer_UnLoad((IWineD3DBuffer *)buffer);
- resource_cleanup((IWineD3DResource *)buffer);
+ buffer_unload(&buffer->resource);
+ resource_cleanup(&buffer->resource);
return E_OUTOFMEMORY;
}
buffer->maps_size = 1;
return WINED3D_OK;
}
+
+HRESULT CDECL wined3d_buffer_create(struct wined3d_device *device, struct wined3d_buffer_desc *desc, const void *data,
+ void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer)
+{
+ struct wined3d_buffer *object;
+ HRESULT hr;
+
+ TRACE("device %p, desc %p, data %p, parent %p, buffer %p\n", device, desc, data, parent, buffer);
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (!object)
+ {
+ ERR("Failed to allocate memory\n");
+ return E_OUTOFMEMORY;
+ }
+
+ FIXME("Ignoring access flags (pool)\n");
+
+ hr = buffer_init(object, device, desc->byte_width, desc->usage, WINED3DFMT_UNKNOWN,
+ WINED3DPOOL_MANAGED, GL_ARRAY_BUFFER_ARB, data, parent, parent_ops);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize buffer, hr %#x.\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ return hr;
+ }
+ object->desc = *desc;
+
+ TRACE("Created buffer %p.\n", object);
+
+ *buffer = object;
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_buffer_create_vb(struct wined3d_device *device, UINT size, DWORD usage, WINED3DPOOL pool,
+ void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer)
+{
+ struct wined3d_buffer *object;
+ HRESULT hr;
+
+ TRACE("device %p, size %u, usage %#x, pool %#x, parent %p, parent_ops %p, buffer %p.\n",
+ device, size, usage, pool, parent, parent_ops, buffer);
+
+ if (pool == WINED3DPOOL_SCRATCH)
+ {
+ /* The d3d9 tests shows that this is not allowed. It doesn't make much
+ * sense anyway, SCRATCH buffers wouldn't be usable anywhere. */
+ WARN("Vertex buffer in WINED3DPOOL_SCRATCH requested, returning WINED3DERR_INVALIDCALL.\n");
+ *buffer = NULL;
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (!object)
+ {
+ ERR("Out of memory\n");
+ *buffer = NULL;
+ return WINED3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ hr = buffer_init(object, device, size, usage, WINED3DFMT_VERTEXDATA,
+ pool, GL_ARRAY_BUFFER_ARB, NULL, parent, parent_ops);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize buffer, hr %#x.\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ return hr;
+ }
+
+ TRACE("Created buffer %p.\n", object);
+ *buffer = object;
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_buffer_create_ib(struct wined3d_device *device, UINT size, DWORD usage, WINED3DPOOL pool,
+ void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer)
+{
+ struct wined3d_buffer *object;
+ HRESULT hr;
+
+ TRACE("device %p, size %u, usage %#x, pool %#x, parent %p, parent_ops %p, buffer %p.\n",
+ device, size, usage, pool, parent, parent_ops, buffer);
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (!object)
+ {
+ ERR("Out of memory\n");
+ *buffer = NULL;
+ return WINED3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ hr = buffer_init(object, device, size, usage | WINED3DUSAGE_STATICDECL,
+ WINED3DFMT_UNKNOWN, pool, GL_ELEMENT_ARRAY_BUFFER_ARB, NULL,
+ parent, parent_ops);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize buffer, hr %#x\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ return hr;
+ }
+
+ TRACE("Created buffer %p.\n", object);
+ *buffer = object;
+
+ return WINED3D_OK;
+}
diff --git a/reactos/dll/directx/wine/wined3d/clipper.c b/reactos/dll/directx/wine/wined3d/clipper.c
index 48ce06f76d4..e5131d7f749 100644
--- a/reactos/dll/directx/wine/wined3d/clipper.c
+++ b/reactos/dll/directx/wine/wined3d/clipper.c
@@ -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;
}
diff --git a/reactos/dll/directx/wine/wined3d/context.c b/reactos/dll/directx/wine/wined3d/context.c
index 6f9d9d7ce22..04942527e07 100644
--- a/reactos/dll/directx/wine/wined3d/context.c
+++ b/reactos/dll/directx/wine/wined3d/context.c
@@ -2,7 +2,7 @@
* Context and render target management in wined3d
*
* Copyright 2007-2008 Stefan Dösinger for CodeWeavers
- * 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
@@ -112,13 +112,14 @@ static void context_destroy_fbo(struct wined3d_context *context, GLuint *fbo)
}
/* GL locking is done by the caller */
-static void context_apply_attachment_filter_states(IWineD3DSurfaceImpl *surface, DWORD location)
+static void context_apply_attachment_filter_states(const struct wined3d_context *context,
+ struct wined3d_surface *surface, DWORD location)
{
/* Update base texture states array */
if (surface->container.type == WINED3D_CONTAINER_TEXTURE)
{
- IWineD3DBaseTextureImpl *texture_impl = surface->container.u.texture;
- IWineD3DDeviceImpl *device = surface->resource.device;
+ struct wined3d_texture *texture = surface->container.u.texture;
+ struct wined3d_device *device = surface->resource.device;
BOOL update_minfilter = FALSE;
BOOL update_magfilter = FALSE;
struct gl_texture *gl_tex;
@@ -126,16 +127,13 @@ static void context_apply_attachment_filter_states(IWineD3DSurfaceImpl *surface,
switch (location)
{
case SFLAG_INTEXTURE:
- gl_tex = &texture_impl->baseTexture.texture_rgb;
- break;
-
case SFLAG_INSRGBTEX:
- gl_tex = &texture_impl->baseTexture.texture_srgb;
+ gl_tex = wined3d_texture_get_gl_texture(texture,
+ context->gl_info, location == SFLAG_INSRGBTEX);
break;
default:
ERR("Unsupported location %s (%#x).\n", debug_surflocation(location), location);
- IWineD3DBaseTexture_Release((IWineD3DBaseTexture *)texture_impl);
return;
}
@@ -153,10 +151,10 @@ static void context_apply_attachment_filter_states(IWineD3DSurfaceImpl *surface,
update_magfilter = TRUE;
}
- if (texture_impl->baseTexture.bindCount)
+ if (texture->bind_count)
{
WARN("Render targets should not be bound to a sampler\n");
- IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(texture_impl->baseTexture.sampler));
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(texture->sampler));
}
if (update_minfilter || update_magfilter)
@@ -193,7 +191,7 @@ static void context_apply_attachment_filter_states(IWineD3DSurfaceImpl *surface,
/* GL locking is done by the caller */
void context_attach_depth_stencil_fbo(struct wined3d_context *context,
- GLenum fbo_target, IWineD3DSurfaceImpl *depth_stencil, BOOL use_render_buffer)
+ GLenum fbo_target, struct wined3d_surface *depth_stencil, BOOL use_render_buffer)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
@@ -201,7 +199,7 @@ void context_attach_depth_stencil_fbo(struct wined3d_context *context,
if (depth_stencil)
{
- DWORD format_flags = depth_stencil->resource.format->Flags;
+ DWORD format_flags = depth_stencil->resource.format->flags;
if (use_render_buffer && depth_stencil->current_renderbuffer)
{
@@ -222,7 +220,7 @@ void context_attach_depth_stencil_fbo(struct wined3d_context *context,
else
{
surface_prepare_texture(depth_stencil, gl_info, FALSE);
- context_apply_attachment_filter_states(depth_stencil, SFLAG_INTEXTURE);
+ context_apply_attachment_filter_states(context, depth_stencil, SFLAG_INTEXTURE);
if (format_flags & WINED3DFMT_FLAG_DEPTH)
{
@@ -265,28 +263,26 @@ void context_attach_depth_stencil_fbo(struct wined3d_context *context,
/* GL locking is done by the caller */
static void context_attach_surface_fbo(const struct wined3d_context *context,
- GLenum fbo_target, DWORD idx, IWineD3DSurfaceImpl *surface, DWORD location)
+ GLenum fbo_target, DWORD idx, struct wined3d_surface *surface, DWORD location)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
TRACE("Attach surface %p to %u\n", surface, idx);
- if (surface)
+ if (surface && surface->resource.format->id != WINED3DFMT_NULL)
{
+ BOOL srgb;
+
switch (location)
{
case SFLAG_INTEXTURE:
- surface_prepare_texture(surface, gl_info, FALSE);
- context_apply_attachment_filter_states(surface, location);
- gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_COLOR_ATTACHMENT0 + idx,
- surface->texture_target, surface->texture_name, surface->texture_level);
- break;
-
case SFLAG_INSRGBTEX:
- surface_prepare_texture(surface, gl_info, TRUE);
- context_apply_attachment_filter_states(surface, location);
+ srgb = location == SFLAG_INSRGBTEX;
+ surface_prepare_texture(surface, gl_info, srgb);
+ context_apply_attachment_filter_states(context, surface, location);
gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_COLOR_ATTACHMENT0 + idx,
- surface->texture_target, surface->texture_name_srgb, surface->texture_level);
+ surface->texture_target, surface_get_texture_name(surface, gl_info, srgb),
+ surface->texture_level);
break;
default:
@@ -303,7 +299,7 @@ static void context_attach_surface_fbo(const struct wined3d_context *context,
}
/* GL locking is done by the caller */
-static void context_check_fbo_status(struct wined3d_context *context, GLenum target)
+void context_check_fbo_status(struct wined3d_context *context, GLenum target)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
GLenum status;
@@ -312,9 +308,12 @@ static void context_check_fbo_status(struct wined3d_context *context, GLenum tar
if (status == GL_FRAMEBUFFER_COMPLETE)
{
TRACE("FBO complete\n");
- } else {
- IWineD3DSurfaceImpl *attachment;
+ }
+ else
+ {
+ struct wined3d_surface *attachment;
unsigned int i;
+
FIXME("FBO status %s (%#x)\n", debug_fbostatus(status), status);
if (!context->current_fbo)
@@ -348,7 +347,7 @@ static void context_check_fbo_status(struct wined3d_context *context, GLenum tar
}
static struct fbo_entry *context_create_fbo_entry(struct wined3d_context *context,
- IWineD3DSurfaceImpl **render_targets, IWineD3DSurfaceImpl *depth_stencil, DWORD location)
+ struct wined3d_surface **render_targets, struct wined3d_surface *depth_stencil, DWORD location)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
struct fbo_entry *entry;
@@ -366,7 +365,7 @@ static struct fbo_entry *context_create_fbo_entry(struct wined3d_context *contex
/* GL locking is done by the caller */
static void context_reuse_fbo_entry(struct wined3d_context *context, GLenum target,
- IWineD3DSurfaceImpl **render_targets, IWineD3DSurfaceImpl *depth_stencil,
+ struct wined3d_surface **render_targets, struct wined3d_surface *depth_stencil,
DWORD location, struct fbo_entry *entry)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
@@ -397,11 +396,21 @@ static void context_destroy_fbo_entry(struct wined3d_context *context, struct fb
/* GL locking is done by the caller */
static struct fbo_entry *context_find_fbo_entry(struct wined3d_context *context, GLenum target,
- IWineD3DSurfaceImpl **render_targets, IWineD3DSurfaceImpl *depth_stencil, DWORD location)
+ struct wined3d_surface **render_targets, struct wined3d_surface *depth_stencil, DWORD location)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
struct fbo_entry *entry;
+ if (depth_stencil && render_targets && render_targets[0])
+ {
+ if (depth_stencil->resource.width < render_targets[0]->resource.width ||
+ depth_stencil->resource.height < render_targets[0]->resource.height)
+ {
+ WARN("Depth stencil is smaller than the primary color buffer, disabling\n");
+ depth_stencil = NULL;
+ }
+ }
+
LIST_FOR_EACH_ENTRY(entry, &context->fbo_list, struct fbo_entry, entry)
{
if (!memcmp(entry->render_targets,
@@ -449,10 +458,7 @@ static void context_apply_fbo_entry(struct wined3d_context *context, GLenum targ
/* Apply depth targets */
if (entry->depth_stencil)
- {
- surface_set_compatible_renderbuffer(entry->depth_stencil,
- entry->render_targets[0]->pow2Width, entry->render_targets[0]->pow2Height);
- }
+ surface_set_compatible_renderbuffer(entry->depth_stencil, entry->render_targets[0]);
context_attach_depth_stencil_fbo(context, target, entry->depth_stencil, TRUE);
entry->attached = TRUE;
@@ -462,16 +468,16 @@ static void context_apply_fbo_entry(struct wined3d_context *context, GLenum targ
for (i = 0; i < gl_info->limits.buffers; ++i)
{
if (entry->render_targets[i])
- context_apply_attachment_filter_states(entry->render_targets[i], entry->location);
+ context_apply_attachment_filter_states(context, entry->render_targets[i], entry->location);
}
if (entry->depth_stencil)
- context_apply_attachment_filter_states(entry->depth_stencil, SFLAG_INTEXTURE);
+ context_apply_attachment_filter_states(context, entry->depth_stencil, SFLAG_INTEXTURE);
}
}
/* GL locking is done by the caller */
static void context_apply_fbo_state(struct wined3d_context *context, GLenum target,
- IWineD3DSurfaceImpl **render_targets, IWineD3DSurfaceImpl *depth_stencil, DWORD location)
+ struct wined3d_surface **render_targets, struct wined3d_surface *depth_stencil, DWORD location)
{
struct fbo_entry *entry, *entry2;
@@ -496,15 +502,13 @@ static void context_apply_fbo_state(struct wined3d_context *context, GLenum targ
context->current_fbo = NULL;
context_bind_fbo(context, target, NULL);
}
-
- context_check_fbo_status(context, target);
}
/* GL locking is done by the caller */
void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target,
- IWineD3DSurfaceImpl *render_target, IWineD3DSurfaceImpl *depth_stencil, DWORD location)
+ struct wined3d_surface *render_target, struct wined3d_surface *depth_stencil, DWORD location)
{
- if (surface_is_offscreen(render_target))
+ if (location != SFLAG_INDRAWABLE || surface_is_offscreen(render_target))
{
UINT clear_size = (context->gl_info->limits.buffers - 1) * sizeof(*context->blit_targets);
context->blit_targets[0] = render_target;
@@ -648,12 +652,12 @@ void context_free_event_query(struct wined3d_event_query *query)
typedef void (context_fbo_entry_func_t)(struct wined3d_context *context, struct fbo_entry *entry);
-static void context_enum_surface_fbo_entries(IWineD3DDeviceImpl *device,
- IWineD3DSurfaceImpl *surface, context_fbo_entry_func_t *callback)
+static void context_enum_surface_fbo_entries(struct wined3d_device *device,
+ struct wined3d_surface *surface, context_fbo_entry_func_t *callback)
{
UINT i;
- for (i = 0; i < device->numContexts; ++i)
+ for (i = 0; i < device->context_count; ++i)
{
struct wined3d_context *context = device->contexts[i];
const struct wined3d_gl_info *gl_info = context->gl_info;
@@ -689,14 +693,15 @@ static void context_queue_fbo_entry_destruction(struct wined3d_context *context,
list_add_head(&context->fbo_destroy_list, &entry->entry);
}
-void context_resource_released(IWineD3DDeviceImpl *device, IWineD3DResource *resource, WINED3DRESOURCETYPE type)
+void context_resource_released(struct wined3d_device *device,
+ struct wined3d_resource *resource, WINED3DRESOURCETYPE type)
{
if (!device->d3d_initialized) return;
switch (type)
{
case WINED3DRTYPE_SURFACE:
- context_enum_surface_fbo_entries(device, (IWineD3DSurfaceImpl *)resource,
+ context_enum_surface_fbo_entries(device, surface_from_resource(resource),
context_queue_fbo_entry_destruction);
break;
@@ -710,12 +715,13 @@ static void context_detach_fbo_entry(struct wined3d_context *context, struct fbo
entry->attached = FALSE;
}
-void context_resource_unloaded(IWineD3DDeviceImpl *device, IWineD3DResource *resource, WINED3DRESOURCETYPE type)
+void context_resource_unloaded(struct wined3d_device *device,
+ struct wined3d_resource *resource, WINED3DRESOURCETYPE type)
{
switch (type)
{
case WINED3DRTYPE_SURFACE:
- context_enum_surface_fbo_entries(device, (IWineD3DSurfaceImpl *)resource,
+ context_enum_surface_fbo_entries(device, surface_from_resource(resource),
context_detach_fbo_entry);
break;
@@ -724,7 +730,7 @@ void context_resource_unloaded(IWineD3DDeviceImpl *device, IWineD3DResource *res
}
}
-void context_surface_update(struct wined3d_context *context, IWineD3DSurfaceImpl *surface)
+void context_surface_update(struct wined3d_context *context, struct wined3d_surface *surface)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
struct fbo_entry *entry = context->current_fbo;
@@ -790,14 +796,98 @@ static BOOL context_set_pixel_format(const struct wined3d_gl_info *gl_info, HDC
return TRUE;
}
+static BOOL context_set_gl_context(struct wined3d_context *ctx)
+{
+ struct wined3d_swapchain *swapchain = ctx->swapchain;
+
+ if (!pwglMakeCurrent(ctx->hdc, ctx->glCtx))
+ {
+ WARN("Failed to make GL context %p current on device context %p, last error %#x.\n",
+ ctx->glCtx, ctx->hdc, GetLastError());
+ ctx->valid = 0;
+ WARN("Trying fallback to the backup window.\n");
+
+ if (!swapchain->backup_dc)
+ {
+ TRACE("Creating the backup window for swapchain %p.\n", swapchain);
+ swapchain->backup_wnd = CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME, "WineD3D fake window",
+ WS_OVERLAPPEDWINDOW, 10, 10, 10, 10, NULL, NULL, NULL, NULL);
+ if (!swapchain->backup_wnd)
+ {
+ ERR("Failed to create a window.\n");
+ goto fail;
+ }
+ swapchain->backup_dc = GetDC(swapchain->backup_wnd);
+ if (!swapchain->backup_dc)
+ {
+ ERR("Failed to get a DC.\n");
+ goto fail;
+ }
+ if (!context_set_pixel_format(ctx->gl_info, swapchain->backup_dc, ctx->pixel_format))
+ {
+ ERR("Failed to set pixel format %d on device context %p.\n",
+ ctx->pixel_format, swapchain->backup_dc);
+ goto fail;
+ }
+ }
+
+ if (!pwglMakeCurrent(swapchain->backup_dc, ctx->glCtx))
+ {
+ ERR("Fallback to backup window (dc %p) failed too, last error %#x.\n",
+ swapchain->backup_dc, GetLastError());
+ context_set_current(NULL);
+ return FALSE;
+ }
+ }
+ return TRUE;
+
+fail:
+ if (swapchain->backup_dc)
+ {
+ ReleaseDC(swapchain->backup_wnd, swapchain->backup_dc);
+ swapchain->backup_dc = NULL;
+ }
+ if (swapchain->backup_wnd)
+ {
+ DestroyWindow(swapchain->backup_wnd);
+ swapchain->backup_wnd = NULL;
+ }
+ context_set_current(NULL);
+ return FALSE;
+}
+
+static void context_restore_gl_context(HDC dc, HGLRC gl_ctx)
+{
+ if (!pwglMakeCurrent(dc, gl_ctx))
+ {
+ ERR("Failed to restore GL context %p on device context %p, last error %#x.\n",
+ gl_ctx, dc, GetLastError());
+ context_set_current(NULL);
+ }
+}
+
static void context_update_window(struct wined3d_context *context)
{
+ if (context->win_handle == context->swapchain->win_handle)
+ return;
+
TRACE("Updating context %p window from %p to %p.\n",
context, context->win_handle, context->swapchain->win_handle);
if (context->valid)
{
- if (!ReleaseDC(context->win_handle, context->hdc))
+ /* You'd figure ReleaseDC() would fail if the DC doesn't match the
+ * window. However, that's not what actually happens, and there are
+ * user32 tests that confirm ReleaseDC() with the wrong window is
+ * supposed to succeed. So explicitly check that the DC belongs to
+ * the window, since we want to avoid releasing a DC that belongs to
+ * some other window if the original window was already destroyed. */
+ if (WindowFromDC(context->hdc) != context->win_handle)
+ {
+ WARN("DC %p does not belong to window %p.\n",
+ context->hdc, context->win_handle);
+ }
+ else if (!ReleaseDC(context->win_handle, context->hdc))
{
ERR("Failed to release device context %p, last error %#x.\n",
context->hdc, GetLastError());
@@ -820,12 +910,7 @@ static void context_update_window(struct wined3d_context *context)
goto err;
}
- if (!pwglMakeCurrent(context->hdc, context->glCtx))
- {
- ERR("Failed to make GL context %p current on device context %p, last error %#x.\n",
- context->glCtx, context->hdc, GetLastError());
- goto err;
- }
+ context_set_gl_context(context);
return;
@@ -833,22 +918,6 @@ err:
context->valid = 0;
}
-/* Do not call while under the GL lock. */
-static void context_validate(struct wined3d_context *context)
-{
- HWND wnd = WindowFromDC(context->hdc);
-
- if (wnd != context->win_handle)
- {
- WARN("DC %p belongs to window %p instead of %p.\n",
- context->hdc, wnd, context->win_handle);
- context->valid = 0;
- }
-
- if (context->win_handle != context->swapchain->win_handle)
- context_update_window(context);
-}
-
/* Do not call while under the GL lock. */
static void context_destroy_gl_resources(struct wined3d_context *context)
{
@@ -863,8 +932,9 @@ static void context_destroy_gl_resources(struct wined3d_context *context)
restore_ctx = pwglGetCurrentContext();
restore_dc = pwglGetCurrentDC();
- context_validate(context);
- if (context->valid && restore_ctx != context->glCtx) pwglMakeCurrent(context->hdc, context->glCtx);
+ context_update_window(context);
+ if (context->valid && restore_ctx != context->glCtx)
+ context_set_gl_context(context);
else restore_ctx = NULL;
ENTER_GL();
@@ -919,7 +989,10 @@ static void context_destroy_gl_resources(struct wined3d_context *context)
if (gl_info->supported[ARB_SYNC])
{
- if (event_query->object.sync) GL_EXTCALL(glDeleteSync(event_query->object.sync));
+ for (i = 0; i < context->free_event_query_count; ++i)
+ {
+ GL_EXTCALL(glDeleteSync(context->free_event_queries[i].sync));
+ }
}
else if (gl_info->supported[APPLE_FENCE])
{
@@ -946,12 +1019,7 @@ static void context_destroy_gl_resources(struct wined3d_context *context)
if (restore_ctx)
{
- if (!pwglMakeCurrent(restore_dc, restore_ctx))
- {
- DWORD err = GetLastError();
- ERR("Failed to restore GL context %p on device context %p, last error %#x.\n",
- restore_ctx, restore_dc, err);
- }
+ context_restore_gl_context(restore_dc, restore_ctx);
}
else if (pwglGetCurrentContext() && !pwglMakeCurrent(NULL, NULL))
{
@@ -1009,15 +1077,15 @@ BOOL context_set_current(struct wined3d_context *ctx)
if (ctx)
{
- TRACE("Switching to D3D context %p, GL context %p, device context %p.\n", ctx, ctx->glCtx, ctx->hdc);
- if (!pwglMakeCurrent(ctx->hdc, ctx->glCtx))
+ if (!ctx->valid)
{
- DWORD err = GetLastError();
- ERR("Failed to make GL context %p current on device context %p, last error %#x.\n",
- ctx->glCtx, ctx->hdc, err);
- TlsSetValue(wined3d_context_tls_idx, NULL);
+ ERR("Trying to make invalid context %p current\n", ctx);
return FALSE;
}
+
+ TRACE("Switching to D3D context %p, GL context %p, device context %p.\n", ctx, ctx->glCtx, ctx->hdc);
+ if (!context_set_gl_context(ctx))
+ return FALSE;
ctx->current = 1;
}
else if(pwglGetCurrentContext())
@@ -1050,12 +1118,7 @@ void context_release(struct wined3d_context *context)
if (!--context->level && context->restore_ctx)
{
TRACE("Restoring GL context %p on device context %p.\n", context->restore_ctx, context->restore_dc);
- if (!pwglMakeCurrent(context->restore_dc, context->restore_ctx))
- {
- DWORD err = GetLastError();
- ERR("Failed to restore GL context %p on device context %p, last error %#x.\n",
- context->restore_ctx, context->restore_dc, err);
- }
+ context_restore_gl_context(context->restore_dc, context->restore_ctx);
context->restore_ctx = NULL;
context->restore_dc = NULL;
}
@@ -1108,14 +1171,14 @@ static void Context_MarkStateDirty(struct wined3d_context *context, DWORD state,
}
/* This function takes care of WineD3D pixel format selection. */
-static int WineD3D_ChoosePixelFormat(IWineD3DDeviceImpl *This, HDC hdc,
+static int WineD3D_ChoosePixelFormat(struct wined3d_device *device, HDC hdc,
const struct wined3d_format *color_format, const struct wined3d_format *ds_format,
BOOL auxBuffers, int numSamples, BOOL findCompatible)
{
int iPixelFormat=0;
unsigned int matchtry;
- short redBits, greenBits, blueBits, alphaBits, colorBits;
- short depthBits=0, stencilBits=0;
+ BYTE redBits, greenBits, blueBits, alphaBits, colorBits;
+ BYTE depthBits=0, stencilBits=0;
static const struct
{
@@ -1141,7 +1204,7 @@ static int WineD3D_ChoosePixelFormat(IWineD3DDeviceImpl *This, HDC hdc,
};
int i = 0;
- int nCfgs = This->adapter->nCfgs;
+ int nCfgs = device->adapter->nCfgs;
TRACE("ColorFormat=%s, DepthStencilFormat=%s, auxBuffers=%d, numSamples=%d, findCompatible=%d\n",
debug_d3dformat(color_format->id), debug_d3dformat(ds_format->id),
@@ -1156,10 +1219,12 @@ static int WineD3D_ChoosePixelFormat(IWineD3DDeviceImpl *This, HDC hdc,
getDepthStencilBits(ds_format, &depthBits, &stencilBits);
- for(matchtry = 0; matchtry < (sizeof(matches) / sizeof(matches[0])) && !iPixelFormat; matchtry++) {
- for(i=0; iadapter->cfgs[i];
BOOL exactDepthMatch = TRUE;
- WineD3D_PixelFormat *cfg = &This->adapter->cfgs[i];
/* For now only accept RGBA formats. Perhaps some day we will
* allow floating point formats for pbuffers. */
@@ -1208,7 +1273,8 @@ static int WineD3D_ChoosePixelFormat(IWineD3DDeviceImpl *This, HDC hdc,
* even when we don't need stencil because it could affect performance EXCEPT
* on cards which don't offer depth formats without stencil like the i915 drivers
* on Linux. */
- if(stencilBits != cfg->stencilSize && !(This->adapter->brokenStencil && stencilBits <= cfg->stencilSize))
+ if (stencilBits != cfg->stencilSize
+ && !(device->adapter->brokenStencil && stencilBits <= cfg->stencilSize))
continue;
/* Check multisampling support */
@@ -1268,10 +1334,10 @@ static int WineD3D_ChoosePixelFormat(IWineD3DDeviceImpl *This, HDC hdc,
}
/* Do not call while under the GL lock. */
-struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain,
- IWineD3DSurfaceImpl *target, const struct wined3d_format *ds_format)
+struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
+ struct wined3d_surface *target, const struct wined3d_format *ds_format)
{
- IWineD3DDeviceImpl *device = swapchain->device;
+ struct wined3d_device *device = swapchain->device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format *color_format;
struct wined3d_context *ret;
@@ -1280,6 +1346,7 @@ struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain,
int numSamples = 0;
int pixel_format;
unsigned int s;
+ int swap_interval;
DWORD state;
HGLRC ctx;
HDC hdc;
@@ -1314,7 +1381,7 @@ struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain,
}
/* DirectDraw supports 8bit paletted render targets and these are used by
- * old games like Starcraft and C&C. Most modern hardware doesn't support
+ * old games like StarCraft and C&C. Most modern hardware doesn't support
* 8bit natively so we perform some form of 8bit -> 32bit conversion. The
* conversion (ab)uses the alpha component for storing the palette index.
* For this reason we require a format with 8bit alpha, so request
@@ -1361,7 +1428,7 @@ struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain,
}
ctx = pwglCreateContext(hdc);
- if (device->numContexts)
+ if (device->context_count)
{
if (!pwglShareLists(device->contexts[0]->glCtx, ctx))
{
@@ -1410,7 +1477,7 @@ struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain,
ret->hdc = hdc;
ret->pixel_format = pixel_format;
- if (device->shader_backend->shader_dirtifyable_constants((IWineD3DDevice *)device))
+ if (device->shader_backend->shader_dirtifyable_constants())
{
/* Create the dirty constants array and initialize them to dirty */
ret->vshader_const_dirty = HeapAlloc(GetProcessHeap(), 0,
@@ -1460,6 +1527,36 @@ struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain,
goto out;
}
+ switch (swapchain->presentParms.PresentationInterval)
+ {
+ case WINED3DPRESENT_INTERVAL_IMMEDIATE:
+ swap_interval = 0;
+ break;
+ case WINED3DPRESENT_INTERVAL_DEFAULT:
+ case WINED3DPRESENT_INTERVAL_ONE:
+ swap_interval = 1;
+ break;
+ case WINED3DPRESENT_INTERVAL_TWO:
+ swap_interval = 2;
+ break;
+ case WINED3DPRESENT_INTERVAL_THREE:
+ swap_interval = 3;
+ break;
+ case WINED3DPRESENT_INTERVAL_FOUR:
+ swap_interval = 4;
+ break;
+ default:
+ FIXME("Unknown presentation interval %08x\n", swapchain->presentParms.PresentationInterval);
+ swap_interval = 1;
+ }
+
+ if (gl_info->supported[WGL_EXT_SWAP_CONTROL])
+ {
+ if (!GL_EXTCALL(wglSwapIntervalEXT(swap_interval)))
+ ERR("wglSwapIntervalEXT failed to set swap interval %d for context %p, last error %#x\n",
+ swap_interval, ret, GetLastError());
+ }
+
ENTER_GL();
glGetIntegerv(GL_AUX_BUFFERS, &ret->aux_buffers);
@@ -1544,23 +1641,6 @@ struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain,
checkGLcall("glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE)");
}
- if (gl_info->supported[WINED3D_GL_VERSION_2_0])
- {
- /* Windows doesn't support to query the glPointParameteri function pointer, so use the
- * NV_POINT_SPRITE extension.
- */
- if (glPointParameteri)
- {
- glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_UPPER_LEFT);
- checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_UPPER_LEFT)");
- }
- else if (gl_info->supported[NV_POINT_SPRITE])
- {
- GL_EXTCALL(glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, GL_UPPER_LEFT));
- checkGLcall("glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, GL_UPPER_LEFT)");
- }
- }
-
if (gl_info->supported[ARB_PROVOKING_VERTEX])
{
GL_EXTCALL(glProvokingVertex(GL_FIRST_VERTEX_CONVENTION));
@@ -1569,11 +1649,10 @@ struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain,
{
GL_EXTCALL(glProvokingVertexEXT(GL_FIRST_VERTEX_CONVENTION_EXT));
}
+ device->frag_pipe->enable_extension(TRUE);
LEAVE_GL();
- device->frag_pipe->enable_extension((IWineD3DDevice *)device, TRUE);
-
TRACE("Created context %p.\n", ret);
return ret;
@@ -1590,7 +1669,7 @@ out:
}
/* Do not call while under the GL lock. */
-void context_destroy(IWineD3DDeviceImpl *This, struct wined3d_context *context)
+void context_destroy(struct wined3d_device *device, struct wined3d_context *context)
{
BOOL destroy;
@@ -1612,7 +1691,7 @@ void context_destroy(IWineD3DDeviceImpl *This, struct wined3d_context *context)
HeapFree(GetProcessHeap(), 0, context->blit_targets);
HeapFree(GetProcessHeap(), 0, context->vshader_const_dirty);
HeapFree(GetProcessHeap(), 0, context->pshader_const_dirty);
- device_context_remove(This, context);
+ device_context_remove(device, context);
if (destroy) HeapFree(GetProcessHeap(), 0, context);
}
@@ -1622,7 +1701,7 @@ static inline void set_blit_dimension(UINT width, UINT height) {
checkGLcall("glMatrixMode(GL_PROJECTION)");
glLoadIdentity();
checkGLcall("glLoadIdentity()");
- glOrtho(0, width, height, 0, 0.0, -1.0);
+ glOrtho(0, width, 0, height, 0.0, -1.0);
checkGLcall("glOrtho");
glViewport(0, 0, width, height);
checkGLcall("glViewport");
@@ -1645,13 +1724,13 @@ static inline void set_blit_dimension(UINT width, UINT height) {
*
*****************************************************************************/
/* Context activation is done by the caller. */
-static void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context *context)
+static void SetupForBlit(struct wined3d_device *device, struct wined3d_context *context)
{
int i;
- const struct StateEntry *StateTable = This->StateTable;
+ const struct StateEntry *StateTable = device->StateTable;
const struct wined3d_gl_info *gl_info = context->gl_info;
- UINT width = context->current_rt->currentDesc.Width;
- UINT height = context->current_rt->currentDesc.Height;
+ UINT width = context->current_rt->resource.width;
+ UINT height = context->current_rt->resource.height;
DWORD sampler;
TRACE("Setting up context %p for blitting\n", context);
@@ -1675,7 +1754,7 @@ static void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context *conte
/* Disable shaders */
ENTER_GL();
- This->shader_backend->shader_select(context, FALSE, FALSE);
+ device->shader_backend->shader_select(context, FALSE, FALSE);
LEAVE_GL();
Context_MarkStateDirty(context, STATE_VSHADER, StateTable);
@@ -1696,7 +1775,7 @@ static void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context *conte
*/
for (i = gl_info->limits.textures - 1; i > 0 ; --i)
{
- sampler = This->rev_tex_unit_map[i];
+ sampler = device->rev_tex_unit_map[i];
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
checkGLcall("glActiveTextureARB");
@@ -1729,7 +1808,7 @@ static void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context *conte
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
checkGLcall("glActiveTextureARB");
- sampler = This->rev_tex_unit_map[0];
+ sampler = device->rev_tex_unit_map[0];
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
{
@@ -1758,7 +1837,7 @@ static void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context *conte
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
GL_TEXTURE_LOD_BIAS_EXT,
0.0f);
- checkGLcall("glTexEnvi GL_TEXTURE_LOD_BIAS_EXT ...");
+ checkGLcall("glTexEnvf GL_TEXTURE_LOD_BIAS_EXT ...");
}
if (sampler != WINED3D_UNMAPPED_STAGE)
@@ -1833,44 +1912,19 @@ static void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context *conte
Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_CLIPPING), StateTable);
set_blit_dimension(width, height);
+ device->frag_pipe->enable_extension(FALSE);
LEAVE_GL();
context->blit_w = width; context->blit_h = height;
Context_MarkStateDirty(context, STATE_VIEWPORT, StateTable);
Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION), StateTable);
-
-
- This->frag_pipe->enable_extension((IWineD3DDevice *) This, FALSE);
-}
-
-/*****************************************************************************
- * findThreadContextForSwapChain
- *
- * Searches a swapchain for all contexts and picks one for the thread tid.
- * If none can be found the swapchain is requested to create a new context
- *
- *****************************************************************************/
-static struct wined3d_context *findThreadContextForSwapChain(IWineD3DSwapChain *swapchain, DWORD tid)
-{
- unsigned int i;
-
- for(i = 0; i < ((IWineD3DSwapChainImpl *) swapchain)->num_contexts; i++) {
- if(((IWineD3DSwapChainImpl *) swapchain)->context[i]->tid == tid) {
- return ((IWineD3DSwapChainImpl *) swapchain)->context[i];
- }
-
- }
-
- /* Create a new context for the thread */
- return swapchain_create_context_for_thread(swapchain);
}
/* Do not call while under the GL lock. */
-static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target)
+static struct wined3d_context *FindContext(struct wined3d_device *device, struct wined3d_surface *target)
{
struct wined3d_context *current_context = context_get_current();
- DWORD tid = GetCurrentThreadId();
struct wined3d_context *context;
if (current_context && current_context->destroyed) current_context = NULL;
@@ -1879,13 +1933,13 @@ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSur
{
if (current_context
&& current_context->current_rt
- && current_context->swapchain->device == This)
+ && current_context->swapchain->device == device)
{
target = current_context->current_rt;
}
else
{
- IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)This->swapchains[0];
+ struct wined3d_swapchain *swapchain = device->swapchains[0];
if (swapchain->back_buffers) target = swapchain->back_buffers[0];
else target = swapchain->front_buffer;
}
@@ -1893,74 +1947,67 @@ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSur
if (current_context && current_context->current_rt == target)
{
- context_validate(current_context);
+ context_update_window(current_context);
return current_context;
}
if (target->container.type == WINED3D_CONTAINER_SWAPCHAIN)
{
- IWineD3DSwapChain *swapchain;
-
TRACE("Rendering onscreen\n");
- swapchain = (IWineD3DSwapChain *)target->container.u.swapchain;
- context = findThreadContextForSwapChain(swapchain, tid);
+ context = swapchain_get_context(target->container.u.swapchain);
}
else
{
TRACE("Rendering offscreen\n");
- /* Stay with the currently active context. */
- if (current_context && current_context->swapchain->device == This)
- {
+ /* Stay with the current context if possible. Otherwise use the
+ * context for the primary swapchain. */
+ if (current_context && current_context->swapchain->device == device)
context = current_context;
- }
else
- {
- /* This may happen if the app jumps straight into offscreen rendering
- * Start using the context of the primary swapchain. tid == 0 is no problem
- * for findThreadContextForSwapChain.
- *
- * Can also happen on thread switches - in that case findThreadContextForSwapChain
- * is perfect to call. */
- context = findThreadContextForSwapChain(This->swapchains[0], tid);
- }
+ context = swapchain_get_context(device->swapchains[0]);
}
- context_validate(context);
+ context_update_window(context);
return context;
}
-/* Context activation is done by the caller. */
-static void context_apply_draw_buffers(struct wined3d_context *context, UINT rt_count, IWineD3DSurfaceImpl **rts)
+/* Context activation and GL locking are done by the caller. */
+static void context_apply_draw_buffers(struct wined3d_context *context, DWORD rt_mask, struct wined3d_surface **rts)
{
- if (!surface_is_offscreen(rts[0]))
+ if (!rt_mask)
+ {
+ glDrawBuffer(GL_NONE);
+ checkGLcall("glDrawBuffer()");
+ }
+ else if (!surface_is_offscreen(rts[0]))
{
- ENTER_GL();
glDrawBuffer(surface_get_gl_buffer(rts[0]));
checkGLcall("glDrawBuffer()");
- LEAVE_GL();
}
else
{
- ENTER_GL();
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
- unsigned int i;
+ unsigned int i = 0;
- for (i = 0; i < gl_info->limits.buffers; ++i)
+ while (rt_mask)
{
- if (i < rt_count && rts[i])
+ if ((rt_mask & 1) && rts[i] && rts[i]->resource.format->id != WINED3DFMT_NULL)
context->draw_buffers[i] = GL_COLOR_ATTACHMENT0 + i;
else
context->draw_buffers[i] = GL_NONE;
+
+ rt_mask >>= 1;
+ ++i;
}
if (gl_info->supported[ARB_DRAW_BUFFERS])
{
- GL_EXTCALL(glDrawBuffersARB(gl_info->limits.buffers, context->draw_buffers));
+ GL_EXTCALL(glDrawBuffersARB(i, context->draw_buffers));
checkGLcall("glDrawBuffers()");
}
else
@@ -1974,7 +2021,6 @@ static void context_apply_draw_buffers(struct wined3d_context *context, UINT rt_
glDrawBuffer(rts[0]->resource.device->offscreenBuffer);
checkGLcall("glDrawBuffer()");
}
- LEAVE_GL();
}
}
@@ -1989,29 +2035,10 @@ void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer)
static inline void context_set_render_offscreen(struct wined3d_context *context, const struct StateEntry *StateTable,
BOOL offscreen)
{
- const struct wined3d_gl_info *gl_info = context->gl_info;
-
if (context->render_offscreen == offscreen) return;
- if (gl_info->supported[WINED3D_GL_VERSION_2_0])
- {
- /* Windows doesn't support to query the glPointParameteri function pointer, so use the
- * NV_POINT_SPRITE extension.
- */
- if (glPointParameteri)
- {
- glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, offscreen ? GL_LOWER_LEFT : GL_UPPER_LEFT);
- checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
- }
- else if (gl_info->supported[NV_POINT_SPRITE])
- {
- GL_EXTCALL(glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, offscreen ? GL_LOWER_LEFT : GL_UPPER_LEFT));
- checkGLcall("glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
- }
- }
-
+ Context_MarkStateDirty(context, STATE_POINTSPRITECOORDORIGIN, StateTable);
Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION), StateTable);
- Context_MarkStateDirty(context, STATE_VDECL, StateTable);
Context_MarkStateDirty(context, STATE_VIEWPORT, StateTable);
Context_MarkStateDirty(context, STATE_SCISSORRECT, StateTable);
Context_MarkStateDirty(context, STATE_FRONTFACE, StateTable);
@@ -2021,10 +2048,10 @@ static inline void context_set_render_offscreen(struct wined3d_context *context,
static BOOL match_depth_stencil_format(const struct wined3d_format *existing,
const struct wined3d_format *required)
{
- short existing_depth, existing_stencil, required_depth, required_stencil;
+ BYTE existing_depth, existing_stencil, required_depth, required_stencil;
- if(existing == required) return TRUE;
- if((existing->Flags & WINED3DFMT_FLAG_FLOAT) != (required->Flags & WINED3DFMT_FLAG_FLOAT)) return FALSE;
+ if (existing == required) return TRUE;
+ if ((existing->flags & WINED3DFMT_FLAG_FLOAT) != (required->flags & WINED3DFMT_FLAG_FLOAT)) return FALSE;
getDepthStencilBits(existing, &existing_depth, &existing_stencil);
getDepthStencilBits(required, &required_depth, &required_stencil);
@@ -2035,12 +2062,13 @@ static BOOL match_depth_stencil_format(const struct wined3d_format *existing,
if(required_stencil && required_stencil != existing_stencil) return FALSE;
return TRUE;
}
+
/* The caller provides a context */
-static void context_validate_onscreen_formats(IWineD3DDeviceImpl *device,
- struct wined3d_context *context, IWineD3DSurfaceImpl *depth_stencil)
+static void context_validate_onscreen_formats(struct wined3d_device *device,
+ struct wined3d_context *context, struct wined3d_surface *depth_stencil)
{
/* Onscreen surfaces are always in a swapchain */
- IWineD3DSwapChainImpl *swapchain = context->current_rt->container.u.swapchain;
+ struct wined3d_swapchain *swapchain = context->current_rt->container.u.swapchain;
if (context->render_offscreen || !depth_stencil) return;
if (match_depth_stencil_format(swapchain->ds_format, depth_stencil->resource.format)) return;
@@ -2057,7 +2085,7 @@ static void context_validate_onscreen_formats(IWineD3DDeviceImpl *device,
}
/* Context activation is done by the caller. */
-void context_apply_blit_state(struct wined3d_context *context, IWineD3DDeviceImpl *device)
+void context_apply_blit_state(struct wined3d_context *context, struct wined3d_device *device)
{
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
@@ -2065,7 +2093,6 @@ void context_apply_blit_state(struct wined3d_context *context, IWineD3DDeviceImp
if (context->render_offscreen)
{
- FIXME("Applying blit state for an offscreen target with ORM_FBO. This should be avoided.\n");
surface_internal_preload(context->current_rt, SRGB_RGB);
ENTER_GL();
@@ -2082,6 +2109,7 @@ void context_apply_blit_state(struct wined3d_context *context, IWineD3DDeviceImp
context->draw_buffer_dirty = TRUE;
}
+ ENTER_GL();
if (context->draw_buffer_dirty)
{
context_apply_draw_buffers(context, 1, &context->current_rt);
@@ -2089,27 +2117,56 @@ void context_apply_blit_state(struct wined3d_context *context, IWineD3DDeviceImp
context->draw_buffer_dirty = FALSE;
}
+ if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
+ {
+ context_check_fbo_status(context, GL_FRAMEBUFFER);
+ }
+ LEAVE_GL();
+
SetupForBlit(device, context);
}
+static BOOL context_validate_rt_config(UINT rt_count,
+ struct wined3d_surface **rts, struct wined3d_surface *ds)
+{
+ unsigned int i;
+
+ if (ds) return TRUE;
+
+ for (i = 0; i < rt_count; ++i)
+ {
+ if (rts[i] && rts[i]->resource.format->id != WINED3DFMT_NULL)
+ return TRUE;
+ }
+
+ WARN("Invalid render target config, need at least one attachment.\n");
+ return FALSE;
+}
+
/* Context activation is done by the caller. */
-void context_apply_clear_state(struct wined3d_context *context, IWineD3DDeviceImpl *device,
- UINT rt_count, IWineD3DSurfaceImpl **rts, IWineD3DSurfaceImpl *depth_stencil)
+BOOL context_apply_clear_state(struct wined3d_context *context, struct wined3d_device *device,
+ UINT rt_count, struct wined3d_surface **rts, struct wined3d_surface *depth_stencil)
{
const struct StateEntry *state_table = device->StateTable;
+ DWORD rt_mask = 0;
UINT i;
+ if (!context_validate_rt_config(rt_count, rts, depth_stencil))
+ return FALSE;
+
+
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
context_validate_onscreen_formats(device, context, depth_stencil);
ENTER_GL();
- if (surface_is_offscreen(rts[0]))
+ if (!rt_count || surface_is_offscreen(rts[0]))
{
for (i = 0; i < rt_count; ++i)
{
context->blit_targets[i] = rts[i];
+ rt_mask |= (1 << i);
}
while (i < context->gl_info->limits.buffers)
{
@@ -2117,27 +2174,39 @@ void context_apply_clear_state(struct wined3d_context *context, IWineD3DDeviceIm
++i;
}
context_apply_fbo_state(context, GL_FRAMEBUFFER, context->blit_targets, depth_stencil, SFLAG_INTEXTURE);
+ glReadBuffer(GL_NONE);
+ checkGLcall("glReadBuffer");
}
else
{
context_apply_fbo_state(context, GL_FRAMEBUFFER, NULL, NULL, SFLAG_INDRAWABLE);
+ rt_mask = 1;
}
LEAVE_GL();
}
+ else
+ {
+ rt_mask = 1;
+ }
- context_apply_draw_buffers(context, rt_count, rts);
+ ENTER_GL();
+ context_apply_draw_buffers(context, rt_mask, rts);
context->draw_buffer_dirty = TRUE;
+ if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
+ {
+ context_check_fbo_status(context, GL_FRAMEBUFFER);
+ }
+
if (context->last_was_blit)
{
- device->frag_pipe->enable_extension((IWineD3DDevice *)device, TRUE);
+ device->frag_pipe->enable_extension(TRUE);
}
/* Blending and clearing should be orthogonal, but tests on the nvidia
* driver show that disabling blending when clearing improves the clearing
* performance incredibly. */
- ENTER_GL();
glDisable(GL_BLEND);
glEnable(GL_SCISSOR_TEST);
checkGLcall("glEnable GL_SCISSOR_TEST");
@@ -2147,25 +2216,32 @@ void context_apply_clear_state(struct wined3d_context *context, IWineD3DDeviceIm
Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_table);
Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_SCISSORTESTENABLE), state_table);
Context_MarkStateDirty(context, STATE_SCISSORRECT, state_table);
+
+ return TRUE;
}
/* Context activation is done by the caller. */
-void context_apply_draw_state(struct wined3d_context *context, IWineD3DDeviceImpl *device)
+BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_device *device)
{
const struct StateEntry *state_table = device->StateTable;
+ const struct wined3d_fb_state *fb = &device->fb;
unsigned int i;
+ if (!context_validate_rt_config(context->gl_info->limits.buffers,
+ fb->render_targets, fb->depth_stencil))
+ return FALSE;
+
/* Preload resources before FBO setup. Texture preload in particular may
* result in changes to the current FBO, due to using e.g. FBO blits for
* updating a resource location. */
- IWineD3DDeviceImpl_FindTexUnitMap(device);
+ device_update_tex_unit_map(device);
device_preload_textures(device);
if (isStateDirty(context, STATE_VDECL))
device_update_stream_info(device, context->gl_info);
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
- context_validate_onscreen_formats(device, context, device->depth_stencil);
+ context_validate_onscreen_formats(device, context, fb->depth_stencil);
if (!context->render_offscreen)
{
@@ -2176,24 +2252,34 @@ void context_apply_draw_state(struct wined3d_context *context, IWineD3DDeviceImp
else
{
ENTER_GL();
- context_apply_fbo_state(context, GL_FRAMEBUFFER, device->render_targets,
- device->depth_stencil, SFLAG_INTEXTURE);
+ context_apply_fbo_state(context, GL_FRAMEBUFFER, fb->render_targets, fb->depth_stencil, SFLAG_INTEXTURE);
+ glReadBuffer(GL_NONE);
+ checkGLcall("glReadBuffer");
LEAVE_GL();
}
}
+ ENTER_GL();
if (context->draw_buffer_dirty)
{
- context_apply_draw_buffers(context, context->gl_info->limits.buffers, device->render_targets);
+ const struct wined3d_shader *ps = device->stateBlock->state.pixel_shader;
+ DWORD rt_mask = ps ? ps->reg_maps.rt_mask : 1;
+
+ rt_mask &= device->valid_rt_mask;
+ context_apply_draw_buffers(context, rt_mask, fb->render_targets);
context->draw_buffer_dirty = FALSE;
}
+ if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
+ {
+ context_check_fbo_status(context, GL_FRAMEBUFFER);
+ }
+
if (context->last_was_blit)
{
- device->frag_pipe->enable_extension((IWineD3DDevice *)device, TRUE);
+ device->frag_pipe->enable_extension(TRUE);
}
- ENTER_GL();
for (i = 0; i < context->numDirtyEntries; ++i)
{
DWORD rep = context->dirtyArray[i];
@@ -2205,10 +2291,12 @@ void context_apply_draw_state(struct wined3d_context *context, IWineD3DDeviceImp
LEAVE_GL();
context->numDirtyEntries = 0; /* This makes the whole list clean */
context->last_was_blit = FALSE;
+
+ return TRUE;
}
-static void context_setup_target(IWineD3DDeviceImpl *device,
- struct wined3d_context *context, IWineD3DSurfaceImpl *target)
+static void context_setup_target(struct wined3d_device *device,
+ struct wined3d_context *context, struct wined3d_surface *target)
{
BOOL old_render_offscreen = context->render_offscreen, render_offscreen;
const struct StateEntry *StateTable = device->StateTable;
@@ -2232,12 +2320,12 @@ static void context_setup_target(IWineD3DDeviceImpl *device,
{
/* Disable blending when the alpha mask has changed and when a format doesn't support blending. */
if ((old->alpha_mask && !new->alpha_mask) || (!old->alpha_mask && new->alpha_mask)
- || !(new->Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING))
+ || !(new->flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING))
{
Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), StateTable);
}
/* Update sRGB writing when switching between formats that do/do not support sRGB writing */
- if ((old->Flags & WINED3DFMT_FLAG_SRGB_WRITE) != (new->Flags & WINED3DFMT_FLAG_SRGB_WRITE))
+ if ((old->flags & WINED3DFMT_FLAG_SRGB_WRITE) != (new->flags & WINED3DFMT_FLAG_SRGB_WRITE))
{
Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_SRGBWRITEENABLE), StateTable);
}
@@ -2255,14 +2343,8 @@ static void context_setup_target(IWineD3DDeviceImpl *device,
{
/* Read the back buffer of the old drawable into the destination texture. */
if (context->current_rt->texture_name_srgb)
- {
- surface_internal_preload(context->current_rt, SRGB_BOTH);
- }
- else
- {
- surface_internal_preload(context->current_rt, SRGB_RGB);
- }
-
+ surface_internal_preload(context->current_rt, SRGB_SRGB);
+ surface_internal_preload(context->current_rt, SRGB_RGB);
surface_modify_location(context->current_rt, SFLAG_INDRAWABLE, FALSE);
}
}
@@ -2273,7 +2355,7 @@ static void context_setup_target(IWineD3DDeviceImpl *device,
}
/* Do not call while under the GL lock. */
-struct wined3d_context *context_acquire(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *target)
+struct wined3d_context *context_acquire(struct wined3d_device *device, struct wined3d_surface *target)
{
struct wined3d_context *current_context = context_get_current();
struct wined3d_context *context;
@@ -2287,8 +2369,16 @@ struct wined3d_context *context_acquire(IWineD3DDeviceImpl *device, IWineD3DSurf
if (context != current_context)
{
- if (!context_set_current(context)) ERR("Failed to activate the new context.\n");
- else device->frag_pipe->enable_extension((IWineD3DDevice *)device, !context->last_was_blit);
+ if (!context_set_current(context))
+ {
+ ERR("Failed to activate the new context.\n");
+ }
+ else
+ {
+ ENTER_GL();
+ device->frag_pipe->enable_extension(!context->last_was_blit);
+ LEAVE_GL();
+ }
if (context->vshader_const_dirty)
{
@@ -2305,12 +2395,7 @@ struct wined3d_context *context_acquire(IWineD3DDeviceImpl *device, IWineD3DSurf
}
else if (context->restore_ctx)
{
- if (!pwglMakeCurrent(context->hdc, context->glCtx))
- {
- DWORD err = GetLastError();
- ERR("Failed to make GL context %p current on device context %p, last error %#x.\n",
- context->hdc, context->glCtx, err);
- }
+ context_set_gl_context(context);
}
return context;
diff --git a/reactos/dll/directx/wine/wined3d/cubetexture.c b/reactos/dll/directx/wine/wined3d/cubetexture.c
deleted file mode 100644
index 2d2c04c2c21..00000000000
--- a/reactos/dll/directx/wine/wined3d/cubetexture.c
+++ /dev/null
@@ -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;
-}
diff --git a/reactos/dll/directx/wine/wined3d/device.c b/reactos/dll/directx/wine/wined3d/device.c
index 97acd5f9946..8724cdfb3e8 100644
--- a/reactos/dll/directx/wine/wined3d/device.c
+++ b/reactos/dll/directx/wine/wined3d/device.c
@@ -9,7 +9,7 @@
* Copyright 2006-2008 Stefan Dösinger for CodeWeavers
* Copyright 2006-2008 Henri Verbeet
* Copyright 2007 Andrew Riedi
- * 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
@@ -173,11 +173,11 @@ static BOOL fixed_get_input(BYTE usage, BYTE usage_idx, unsigned int *regnum)
}
/* Context activation is done by the caller. */
-void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
+void device_stream_info_from_declaration(struct wined3d_device *device,
BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup)
{
/* We need to deal with frequency data! */
- IWineD3DVertexDeclarationImpl *declaration = This->stateBlock->state.vertex_declaration;
+ struct wined3d_vertex_declaration *declaration = device->stateBlock->state.vertex_declaration;
unsigned int i;
stream_info->use_map = 0;
@@ -191,7 +191,7 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
for (i = 0; i < declaration->element_count; ++i)
{
const struct wined3d_vertex_declaration_element *element = &declaration->elements[i];
- struct wined3d_buffer *buffer = This->stateBlock->state.streams[element->input_slot].buffer;
+ struct wined3d_buffer *buffer = device->stateBlock->state.streams[element->input_slot].buffer;
GLuint buffer_object = 0;
const BYTE *data = NULL;
BOOL stride_used;
@@ -203,8 +203,8 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
if (!buffer) continue;
- stride = This->stateBlock->state.streams[element->input_slot].stride;
- if (This->stateBlock->state.user_stream)
+ stride = device->stateBlock->state.streams[element->input_slot].stride;
+ if (device->stateBlock->state.user_stream)
{
TRACE("Stream %u is UP, %p\n", element->input_slot, buffer);
buffer_object = 0;
@@ -213,20 +213,20 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
else
{
TRACE("Stream %u isn't UP, %p\n", element->input_slot, buffer);
- data = buffer_get_memory((IWineD3DBuffer *)buffer, &This->adapter->gl_info, &buffer_object);
+ data = buffer_get_memory(buffer, &device->adapter->gl_info, &buffer_object);
/* Can't use vbo's if the base vertex index is negative. OpenGL doesn't accept negative offsets
* (or rather offsets bigger than the vbo, because the pointer is unsigned), so use system memory
* sources. In most sane cases the pointer - offset will still be > 0, otherwise it will wrap
* around to some big value. Hope that with the indices, the driver wraps it back internally. If
* not, drawStridedSlow is needed, including a vertex buffer path. */
- if (This->stateBlock->state.load_base_vertex_index < 0)
+ if (device->stateBlock->state.load_base_vertex_index < 0)
{
WARN("load_base_vertex_index is < 0 (%d), not using VBOs.\n",
- This->stateBlock->state.load_base_vertex_index);
+ device->stateBlock->state.load_base_vertex_index);
buffer_object = 0;
- data = buffer_get_sysmem(buffer, &This->adapter->gl_info);
- if ((UINT_PTR)data < -This->stateBlock->state.load_base_vertex_index * stride)
+ data = buffer_get_sysmem(buffer, &device->adapter->gl_info);
+ if ((UINT_PTR)data < -device->stateBlock->state.load_base_vertex_index * stride)
{
FIXME("System memory vertex data load offset is negative!\n");
}
@@ -260,7 +260,7 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
/* TODO: Assuming vertexdeclarations are usually used with the
* same or a similar shader, it might be worth it to store the
* last used output slot and try that one first. */
- stride_used = vshader_get_input(This->stateBlock->state.vertex_shader,
+ stride_used = vshader_get_input(device->stateBlock->state.vertex_shader,
element->usage, element->usage_idx, &idx);
}
else
@@ -297,7 +297,7 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
stream_info->elements[idx].stream_idx = element->input_slot;
stream_info->elements[idx].buffer_object = buffer_object;
- if (!This->adapter->gl_info.supported[ARB_VERTEX_ARRAY_BGRA]
+ if (!device->adapter->gl_info.supported[ARB_VERTEX_ARRAY_BGRA]
&& element->format->id == WINED3DFMT_B8G8R8A8_UNORM)
{
stream_info->swizzle_map |= 1 << idx;
@@ -306,8 +306,8 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
}
}
- This->num_buffer_queries = 0;
- if (!This->stateBlock->state.user_stream)
+ device->num_buffer_queries = 0;
+ if (!device->stateBlock->state.user_stream)
{
WORD map = stream_info->use_map;
@@ -320,18 +320,18 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
if (!(map & 1)) continue;
element = &stream_info->elements[i];
- buffer = This->stateBlock->state.streams[element->stream_idx].buffer;
- IWineD3DBuffer_PreLoad((IWineD3DBuffer *)buffer);
+ buffer = device->stateBlock->state.streams[element->stream_idx].buffer;
+ wined3d_buffer_preload(buffer);
/* If PreLoad dropped the buffer object, update the stream info. */
if (buffer->buffer_object != element->buffer_object)
{
element->buffer_object = 0;
- element->data = buffer_get_sysmem(buffer, &This->adapter->gl_info) + (ptrdiff_t)element->data;
+ element->data = buffer_get_sysmem(buffer, &device->adapter->gl_info) + (ptrdiff_t)element->data;
}
if (buffer->query)
- This->buffer_queries[This->num_buffer_queries++] = buffer->query;
+ device->buffer_queries[device->num_buffer_queries++] = buffer->query;
}
}
}
@@ -405,7 +405,7 @@ static void device_trace_strided_stream_info(const struct wined3d_stream_info *s
}
/* Context activation is done by the caller. */
-void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_gl_info *gl_info)
+void device_update_stream_info(struct wined3d_device *device, const struct wined3d_gl_info *gl_info)
{
struct wined3d_stream_info *stream_info = &device->strided_streams;
const struct wined3d_state *state = &device->stateBlock->state;
@@ -455,15 +455,15 @@ void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_
static void device_preload_texture(const struct wined3d_state *state, unsigned int idx)
{
- IWineD3DBaseTextureImpl *texture;
+ struct wined3d_texture *texture;
enum WINED3DSRGB srgb;
if (!(texture = state->textures[idx])) return;
srgb = state->sampler_states[idx][WINED3DSAMP_SRGBTEXTURE] ? SRGB_SRGB : SRGB_RGB;
- texture->baseTexture.internal_preload((IWineD3DBaseTexture *)texture, srgb);
+ texture->texture_ops->texture_preload(texture, srgb);
}
-void device_preload_textures(IWineD3DDeviceImpl *device)
+void device_preload_textures(struct wined3d_device *device)
{
const struct wined3d_state *state = &device->stateBlock->state;
unsigned int i;
@@ -472,7 +472,7 @@ void device_preload_textures(IWineD3DDeviceImpl *device)
{
for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i)
{
- if (state->vertex_shader->baseShader.reg_maps.sampler_type[i])
+ if (state->vertex_shader->reg_maps.sampler_type[i])
device_preload_texture(state, MAX_FRAGMENT_SAMPLERS + i);
}
}
@@ -481,7 +481,7 @@ void device_preload_textures(IWineD3DDeviceImpl *device)
{
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
{
- if (state->pixel_shader->baseShader.reg_maps.sampler_type[i])
+ if (state->pixel_shader->reg_maps.sampler_type[i])
device_preload_texture(state, i);
}
}
@@ -497,14 +497,15 @@ void device_preload_textures(IWineD3DDeviceImpl *device)
}
}
-BOOL device_context_add(IWineD3DDeviceImpl *device, struct wined3d_context *context)
+BOOL device_context_add(struct wined3d_device *device, struct wined3d_context *context)
{
struct wined3d_context **new_array;
TRACE("Adding context %p.\n", context);
if (!device->contexts) new_array = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_array));
- else new_array = HeapReAlloc(GetProcessHeap(), 0, device->contexts, sizeof(*new_array) * (device->numContexts + 1));
+ else new_array = HeapReAlloc(GetProcessHeap(), 0, device->contexts,
+ sizeof(*new_array) * (device->context_count + 1));
if (!new_array)
{
@@ -512,12 +513,12 @@ BOOL device_context_add(IWineD3DDeviceImpl *device, struct wined3d_context *cont
return FALSE;
}
- new_array[device->numContexts++] = context;
+ new_array[device->context_count++] = context;
device->contexts = new_array;
return TRUE;
}
-void device_context_remove(IWineD3DDeviceImpl *device, struct wined3d_context *context)
+void device_context_remove(struct wined3d_device *device, struct wined3d_context *context)
{
struct wined3d_context **new_array;
BOOL found = FALSE;
@@ -525,7 +526,7 @@ void device_context_remove(IWineD3DDeviceImpl *device, struct wined3d_context *c
TRACE("Removing context %p.\n", context);
- for (i = 0; i < device->numContexts; ++i)
+ for (i = 0; i < device->context_count; ++i)
{
if (device->contexts[i] == context)
{
@@ -540,15 +541,15 @@ void device_context_remove(IWineD3DDeviceImpl *device, struct wined3d_context *c
return;
}
- if (!--device->numContexts)
+ if (!--device->context_count)
{
HeapFree(GetProcessHeap(), 0, device->contexts);
device->contexts = NULL;
return;
}
- memmove(&device->contexts[i], &device->contexts[i + 1], (device->numContexts - i) * sizeof(*device->contexts));
- new_array = HeapReAlloc(GetProcessHeap(), 0, device->contexts, device->numContexts * sizeof(*device->contexts));
+ memmove(&device->contexts[i], &device->contexts[i + 1], (device->context_count - i) * sizeof(*device->contexts));
+ new_array = HeapReAlloc(GetProcessHeap(), 0, device->contexts, device->context_count * sizeof(*device->contexts));
if (!new_array)
{
ERR("Failed to shrink context array. Oh well.\n");
@@ -558,9 +559,9 @@ void device_context_remove(IWineD3DDeviceImpl *device, struct wined3d_context *c
device->contexts = new_array;
}
-void device_get_draw_rect(IWineD3DDeviceImpl *device, RECT *rect)
+void device_get_draw_rect(struct wined3d_device *device, RECT *rect)
{
- IWineD3DStateBlockImpl *stateblock = device->stateBlock;
+ struct wined3d_stateblock *stateblock = device->stateBlock;
WINED3DVIEWPORT *vp = &stateblock->state.viewport;
SetRect(rect, vp->X, vp->Y, vp->X + vp->Width, vp->Y + vp->Height);
@@ -572,8 +573,8 @@ void device_get_draw_rect(IWineD3DDeviceImpl *device, RECT *rect)
}
/* Do not call while under the GL lock. */
-void device_switch_onscreen_ds(IWineD3DDeviceImpl *device,
- struct wined3d_context *context, IWineD3DSurfaceImpl *depth_stencil)
+void device_switch_onscreen_ds(struct wined3d_device *device,
+ struct wined3d_context *context, struct wined3d_surface *depth_stencil)
{
if (device->onscreen_depth_stencil)
{
@@ -581,35 +582,35 @@ void device_switch_onscreen_ds(IWineD3DDeviceImpl *device,
surface_modify_ds_location(device->onscreen_depth_stencil, SFLAG_DS_OFFSCREEN,
device->onscreen_depth_stencil->ds_current_size.cx,
device->onscreen_depth_stencil->ds_current_size.cy);
- IWineD3DSurface_Release((IWineD3DSurface *)device->onscreen_depth_stencil);
+ wined3d_surface_decref(device->onscreen_depth_stencil);
}
device->onscreen_depth_stencil = depth_stencil;
- IWineD3DSurface_AddRef((IWineD3DSurface *)device->onscreen_depth_stencil);
+ wined3d_surface_incref(device->onscreen_depth_stencil);
}
-static BOOL is_full_clear(IWineD3DSurfaceImpl *target, const RECT *draw_rect, const RECT *clear_rect)
+static BOOL is_full_clear(struct wined3d_surface *target, const RECT *draw_rect, const RECT *clear_rect)
{
/* partial draw rect */
if (draw_rect->left || draw_rect->top
- || draw_rect->right < target->currentDesc.Width
- || draw_rect->bottom < target->currentDesc.Height)
+ || draw_rect->right < target->resource.width
+ || draw_rect->bottom < target->resource.height)
return FALSE;
/* partial clear rect */
if (clear_rect && (clear_rect->left > 0 || clear_rect->top > 0
- || clear_rect->right < target->currentDesc.Width
- || clear_rect->bottom < target->currentDesc.Height))
+ || clear_rect->right < target->resource.width
+ || clear_rect->bottom < target->resource.height))
return FALSE;
return TRUE;
}
-static void prepare_ds_clear(IWineD3DSurfaceImpl *ds, struct wined3d_context *context,
+static void prepare_ds_clear(struct wined3d_surface *ds, struct wined3d_context *context,
DWORD location, const RECT *draw_rect, UINT rect_count, const RECT *clear_rect)
{
RECT current_rect, r;
- if (ds->Flags & location)
+ if (ds->flags & location)
SetRect(¤t_rect, 0, 0,
ds->ds_current_size.cx,
ds->ds_current_size.cy);
@@ -650,16 +651,16 @@ static void prepare_ds_clear(IWineD3DSurfaceImpl *ds, struct wined3d_context *co
}
/* Do not call while under the GL lock. */
-HRESULT device_clear_render_targets(IWineD3DDeviceImpl *device, UINT rt_count, IWineD3DSurfaceImpl **rts,
- UINT rect_count, const RECT *rects, const RECT *draw_rect, DWORD flags,
- const WINED3DCOLORVALUE *color, float depth, DWORD stencil)
+HRESULT device_clear_render_targets(struct wined3d_device *device, UINT rt_count, struct wined3d_surface **rts,
+ struct wined3d_surface *depth_stencil, UINT rect_count, const RECT *rects, const RECT *draw_rect,
+ DWORD flags, const WINED3DCOLORVALUE *color, float depth, DWORD stencil)
{
const RECT *clear_rect = (rect_count > 0 && rects) ? (const RECT *)rects : NULL;
- IWineD3DSurfaceImpl *depth_stencil = device->depth_stencil;
- IWineD3DSurfaceImpl *target = rts[0];
+ struct wined3d_surface *target = rt_count ? rts[0] : NULL;
UINT drawable_width, drawable_height;
struct wined3d_context *context;
GLbitfield clear_mask = 0;
+ BOOL render_offscreen;
unsigned int i;
/* When we're clearing parts of the drawable, make sure that the target surface is well up to date in the
@@ -686,9 +687,24 @@ HRESULT device_clear_render_targets(IWineD3DDeviceImpl *device, UINT rt_count, I
return WINED3D_OK;
}
- context_apply_clear_state(context, device, rt_count, rts, depth_stencil);
+ if (!context_apply_clear_state(context, device, rt_count, rts, depth_stencil))
+ {
+ context_release(context);
+ WARN("Failed to apply clear state, skipping clear.\n");
+ return WINED3D_OK;
+ }
- target->get_drawable_size(context, &drawable_width, &drawable_height);
+ if (target)
+ {
+ render_offscreen = context->render_offscreen;
+ target->get_drawable_size(context, &drawable_width, &drawable_height);
+ }
+ else
+ {
+ render_offscreen = TRUE;
+ drawable_width = depth_stencil->pow2Width;
+ drawable_height = depth_stencil->pow2Height;
+ }
ENTER_GL();
@@ -709,7 +725,7 @@ HRESULT device_clear_render_targets(IWineD3DDeviceImpl *device, UINT rt_count, I
if (flags & WINED3DCLEAR_ZBUFFER)
{
- DWORD location = context->render_offscreen ? SFLAG_DS_OFFSCREEN : SFLAG_DS_ONSCREEN;
+ DWORD location = render_offscreen ? SFLAG_DS_OFFSCREEN : SFLAG_DS_ONSCREEN;
if (location == SFLAG_DS_ONSCREEN && depth_stencil != device->onscreen_depth_stencil)
{
@@ -746,7 +762,7 @@ HRESULT device_clear_render_targets(IWineD3DDeviceImpl *device, UINT rt_count, I
if (!clear_rect)
{
- if (context->render_offscreen)
+ if (render_offscreen)
{
glScissor(draw_rect->left, draw_rect->top,
draw_rect->right - draw_rect->left, draw_rect->bottom - draw_rect->top);
@@ -783,7 +799,7 @@ HRESULT device_clear_render_targets(IWineD3DDeviceImpl *device, UINT rt_count, I
continue;
}
- if (context->render_offscreen)
+ if (render_offscreen)
{
glScissor(current_rect.left, current_rect.top,
current_rect.right - current_rect.left, current_rect.bottom - current_rect.top);
@@ -802,7 +818,8 @@ HRESULT device_clear_render_targets(IWineD3DDeviceImpl *device, UINT rt_count, I
LEAVE_GL();
- if (wined3d_settings.strict_draw_ordering || (target->container.type == WINED3D_CONTAINER_SWAPCHAIN
+ if (wined3d_settings.strict_draw_ordering || (flags & WINED3DCLEAR_TARGET
+ && target->container.type == WINED3D_CONTAINER_SWAPCHAIN
&& target->container.u.swapchain->front_buffer == target))
wglFlush(); /* Flush to ensure ordering across contexts. */
@@ -811,828 +828,90 @@ HRESULT device_clear_render_targets(IWineD3DDeviceImpl *device, UINT rt_count, I
return WINED3D_OK;
}
-
-/**********************************************************
- * IUnknown parts follows
- **********************************************************/
-
-static HRESULT WINAPI IWineD3DDeviceImpl_QueryInterface(IWineD3DDevice *iface, REFIID riid, void **object)
+ULONG CDECL wined3d_device_incref(struct wined3d_device *device)
{
- TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+ ULONG refcount = InterlockedIncrement(&device->ref);
- if (IsEqualGUID(riid, &IID_IWineD3DDevice)
- || IsEqualGUID(riid, &IID_IUnknown))
+ TRACE("%p increasing refcount to %u.\n", device, refcount);
+
+ return refcount;
+}
+
+ULONG CDECL wined3d_device_decref(struct wined3d_device *device)
+{
+ ULONG refcount = InterlockedDecrement(&device->ref);
+
+ TRACE("%p decreasing refcount to %u.\n", device, refcount);
+
+ if (!refcount)
{
- 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 IWineD3DDeviceImpl_AddRef(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- ULONG refCount = InterlockedIncrement(&This->ref);
-
- TRACE("(%p) : AddRef increasing from %d\n", This, refCount - 1);
- return refCount;
-}
-
-static ULONG WINAPI IWineD3DDeviceImpl_Release(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- ULONG refCount = InterlockedDecrement(&This->ref);
-
- TRACE("(%p) : Releasing from %d\n", This, refCount + 1);
-
- if (!refCount) {
UINT i;
- for (i = 0; i < sizeof(This->multistate_funcs)/sizeof(This->multistate_funcs[0]); ++i) {
- HeapFree(GetProcessHeap(), 0, This->multistate_funcs[i]);
- This->multistate_funcs[i] = NULL;
+ for (i = 0; i < sizeof(device->multistate_funcs) / sizeof(device->multistate_funcs[0]); ++i)
+ {
+ HeapFree(GetProcessHeap(), 0, device->multistate_funcs[i]);
+ device->multistate_funcs[i] = NULL;
}
- /* TODO: Clean up all the surfaces and textures! */
- /* NOTE: You must release the parent if the object was created via a callback
- ** ***************************/
-
- if (!list_empty(&This->resources))
+ if (!list_empty(&device->resources))
{
- IWineD3DResourceImpl *resource;
- FIXME("(%p) Device released with resources still bound, acceptable but unexpected\n", This);
+ struct wined3d_resource *resource;
- LIST_FOR_EACH_ENTRY(resource, &This->resources, IWineD3DResourceImpl, resource.resource_list_entry)
+ FIXME("Device released with resources still bound, acceptable but unexpected.\n");
+
+ LIST_FOR_EACH_ENTRY(resource, &device->resources, struct wined3d_resource, resource_list_entry)
{
- WINED3DRESOURCETYPE type = IWineD3DResource_GetType((IWineD3DResource *)resource);
FIXME("Leftover resource %p with type %s (%#x).\n",
- resource, debug_d3dresourcetype(type), type);
+ resource, debug_d3dresourcetype(resource->resourceType), resource->resourceType);
}
}
- if(This->contexts) ERR("Context array not freed!\n");
- if (This->hardwareCursor) DestroyCursor(This->hardwareCursor);
- This->haveHardwareCursor = FALSE;
+ if (device->contexts)
+ ERR("Context array not freed!\n");
+ if (device->hardwareCursor)
+ DestroyCursor(device->hardwareCursor);
+ device->hardwareCursor = 0;
- IWineD3D_Release(This->wined3d);
- This->wined3d = NULL;
- HeapFree(GetProcessHeap(), 0, This);
- TRACE("Freed device %p\n", This);
- This = NULL;
+ wined3d_decref(device->wined3d);
+ device->wined3d = NULL;
+ HeapFree(GetProcessHeap(), 0, device);
+ TRACE("Freed device %p.\n", device);
}
- return refCount;
+
+ return refcount;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateBuffer(IWineD3DDevice *iface, struct wined3d_buffer_desc *desc,
- const void *data, void *parent, const struct wined3d_parent_ops *parent_ops, IWineD3DBuffer **buffer)
+UINT CDECL wined3d_device_get_swapchain_count(struct wined3d_device *device)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- struct wined3d_buffer *object;
- HRESULT hr;
+ TRACE("device %p.\n", device);
- TRACE("iface %p, desc %p, data %p, parent %p, buffer %p\n", iface, desc, data, parent, buffer);
-
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
- {
- ERR("Failed to allocate memory\n");
- return E_OUTOFMEMORY;
- }
-
- FIXME("Ignoring access flags (pool)\n");
-
- hr = buffer_init(object, This, desc->byte_width, desc->usage, WINED3DFMT_UNKNOWN,
- WINED3DPOOL_MANAGED, GL_ARRAY_BUFFER_ARB, data, parent, parent_ops);
- if (FAILED(hr))
- {
- WARN("Failed to initialize buffer, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
- return hr;
- }
- object->desc = *desc;
-
- TRACE("Created buffer %p.\n", object);
-
- *buffer = (IWineD3DBuffer *)object;
-
- return WINED3D_OK;
+ return device->swapchain_count;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *iface,
- UINT Size, DWORD Usage, WINED3DPOOL Pool, void *parent,
- const struct wined3d_parent_ops *parent_ops, IWineD3DBuffer **ppVertexBuffer)
+HRESULT CDECL wined3d_device_get_swapchain(struct wined3d_device *device,
+ UINT swapchain_idx, struct wined3d_swapchain **swapchain)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- struct wined3d_buffer *object;
- HRESULT hr;
+ TRACE("device %p, swapchain_idx %u, swapchain %p.\n",
+ device, swapchain_idx, swapchain);
- TRACE("iface %p, size %u, usage %#x, pool %#x, buffer %p, parent %p, parent_ops %p.\n",
- iface, Size, Usage, Pool, ppVertexBuffer, parent, parent_ops);
-
- if (Pool == WINED3DPOOL_SCRATCH)
+ if (swapchain_idx >= device->swapchain_count)
{
- /* The d3d9 testsuit shows that this is not allowed. It doesn't make much sense
- * anyway, SCRATCH vertex buffers aren't usable anywhere
- */
- WARN("Vertex buffer in D3DPOOL_SCRATCH requested, returning WINED3DERR_INVALIDCALL\n");
- *ppVertexBuffer = NULL;
+ WARN("swapchain_idx %u >= swapchain_count %u.\n",
+ swapchain_idx, device->swapchain_count);
+ *swapchain = NULL;
+
return WINED3DERR_INVALIDCALL;
}
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
- {
- ERR("Out of memory\n");
- *ppVertexBuffer = NULL;
- return WINED3DERR_OUTOFVIDEOMEMORY;
- }
-
- hr = buffer_init(object, This, Size, Usage, WINED3DFMT_VERTEXDATA,
- Pool, GL_ARRAY_BUFFER_ARB, NULL, parent, parent_ops);
- if (FAILED(hr))
- {
- WARN("Failed to initialize buffer, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
- return hr;
- }
-
- TRACE("Created buffer %p.\n", object);
- *ppVertexBuffer = (IWineD3DBuffer *)object;
+ *swapchain = device->swapchains[swapchain_idx];
+ wined3d_swapchain_incref(*swapchain);
+ TRACE("Returning %p.\n", *swapchain);
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface,
- UINT Length, DWORD Usage, WINED3DPOOL Pool, void *parent,
- const struct wined3d_parent_ops *parent_ops, IWineD3DBuffer **ppIndexBuffer)
+static void IWineD3DDeviceImpl_LoadLogo(struct wined3d_device *device, const char *filename)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- struct wined3d_buffer *object;
- HRESULT hr;
-
- TRACE("(%p) Creating index buffer\n", This);
-
- /* Allocate the storage for the device */
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
- {
- ERR("Out of memory\n");
- *ppIndexBuffer = NULL;
- return WINED3DERR_OUTOFVIDEOMEMORY;
- }
-
- hr = buffer_init(object, This, Length, Usage | WINED3DUSAGE_STATICDECL,
- WINED3DFMT_UNKNOWN, Pool, GL_ELEMENT_ARRAY_BUFFER_ARB, NULL,
- parent, parent_ops);
- if (FAILED(hr))
- {
- WARN("Failed to initialize buffer, hr %#x\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
- return hr;
- }
-
- TRACE("Created buffer %p.\n", object);
-
- *ppIndexBuffer = (IWineD3DBuffer *) object;
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice *iface,
- WINED3DSTATEBLOCKTYPE type, IWineD3DStateBlock **stateblock)
-{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DStateBlockImpl *object;
- HRESULT hr;
-
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if(!object)
- {
- ERR("Failed to allocate stateblock memory.\n");
- return E_OUTOFMEMORY;
- }
-
- hr = stateblock_init(object, This, 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 = (IWineD3DStateBlock *)object;
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Width, UINT Height,
- enum wined3d_format_id Format, BOOL Lockable, BOOL Discard, UINT Level, DWORD Usage, WINED3DPOOL Pool,
- WINED3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, WINED3DSURFTYPE Impl,
- void *parent, const struct wined3d_parent_ops *parent_ops, IWineD3DSurface **surface)
-{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DSurfaceImpl *object;
- HRESULT hr;
-
- TRACE("iface %p, width %u, height %u, format %s (%#x), lockable %#x, discard %#x, level %u\n",
- iface, Width, Height, debug_d3dformat(Format), Format, Lockable, Discard, Level);
- TRACE("surface %p, usage %s (%#x), pool %s (%#x), multisample_type %#x, multisample_quality %u\n",
- surface, debug_d3dusage(Usage), Usage, debug_d3dpool(Pool), Pool, MultiSample, MultisampleQuality);
- TRACE("surface_type %#x, parent %p, parent_ops %p.\n", Impl, parent, parent_ops);
-
- if (Impl == SURFACE_OPENGL && !This->adapter)
- {
- ERR("OpenGL surfaces are not available without OpenGL.\n");
- return WINED3DERR_NOTAVAILABLE;
- }
-
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
- {
- ERR("Failed to allocate surface memory.\n");
- return WINED3DERR_OUTOFVIDEOMEMORY;
- }
-
- hr = surface_init(object, Impl, This->surface_alignment, Width, Height, Level, Lockable,
- Discard, MultiSample, MultisampleQuality, This, Usage, Format, Pool, parent, parent_ops);
- if (FAILED(hr))
- {
- WARN("Failed to initialize surface, returning %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
- return hr;
- }
-
- TRACE("(%p) : Created surface %p\n", This, object);
-
- *surface = (IWineD3DSurface *)object;
-
- return hr;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateRendertargetView(IWineD3DDevice *iface,
- IWineD3DResource *resource, void *parent, IWineD3DRendertargetView **rendertarget_view)
-{
- struct wined3d_rendertarget_view *object;
-
- TRACE("iface %p, resource %p, parent %p, rendertarget_view %p.\n",
- iface, 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 = (IWineD3DRendertargetView *)object;
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface,
- UINT Width, UINT Height, UINT Levels, DWORD Usage, enum wined3d_format_id Format, WINED3DPOOL Pool,
- void *parent, const struct wined3d_parent_ops *parent_ops, IWineD3DTexture **ppTexture)
-{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DTextureImpl *object;
- HRESULT hr;
-
- TRACE("(%p) : Width %d, Height %d, Levels %d, Usage %#x\n", This, Width, Height, Levels, Usage);
- TRACE("Format %#x (%s), Pool %#x, ppTexture %p, parent %p\n",
- Format, debug_d3dformat(Format), Pool, ppTexture, parent);
-
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
- {
- ERR("Out of memory\n");
- *ppTexture = NULL;
- return WINED3DERR_OUTOFVIDEOMEMORY;
- }
-
- hr = texture_init(object, Width, Height, Levels, This, Usage, Format, Pool, parent, parent_ops);
- if (FAILED(hr))
- {
- WARN("Failed to initialize texture, returning %#x\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
- *ppTexture = NULL;
- return hr;
- }
-
- *ppTexture = (IWineD3DTexture *)object;
-
- TRACE("(%p) : Created texture %p\n", This, object);
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *iface,
- UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, enum wined3d_format_id Format, WINED3DPOOL Pool,
- void *parent, const struct wined3d_parent_ops *parent_ops, IWineD3DVolumeTexture **ppVolumeTexture)
-{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DVolumeTextureImpl *object;
- HRESULT hr;
-
- TRACE("(%p) : W(%u) H(%u) D(%u), Lvl(%u) Usage(%#x), Fmt(%u,%s), Pool(%s)\n", This, Width, Height,
- Depth, Levels, Usage, Format, debug_d3dformat(Format), debug_d3dpool(Pool));
-
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
- {
- ERR("Out of memory\n");
- *ppVolumeTexture = NULL;
- return WINED3DERR_OUTOFVIDEOMEMORY;
- }
-
- hr = volumetexture_init(object, Width, Height, Depth, Levels, This, Usage, Format, Pool, parent, parent_ops);
- if (FAILED(hr))
- {
- WARN("Failed to initialize volumetexture, returning %#x\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
- *ppVolumeTexture = NULL;
- return hr;
- }
-
- TRACE("(%p) : Created volume texture %p.\n", This, object);
- *ppVolumeTexture = (IWineD3DVolumeTexture *)object;
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolume(IWineD3DDevice *iface, UINT Width, UINT Height,
- UINT Depth, DWORD Usage, enum wined3d_format_id Format, WINED3DPOOL Pool, void *parent,
- const struct wined3d_parent_ops *parent_ops, IWineD3DVolume **ppVolume)
-{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DVolumeImpl *object;
- HRESULT hr;
-
- TRACE("(%p) : W(%d) H(%d) D(%d), Usage(%d), Fmt(%u,%s), Pool(%s)\n", This, Width, Height,
- Depth, Usage, Format, debug_d3dformat(Format), debug_d3dpool(Pool));
-
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
- {
- ERR("Out of memory\n");
- *ppVolume = NULL;
- return WINED3DERR_OUTOFVIDEOMEMORY;
- }
-
- hr = volume_init(object, This, Width, Height, Depth, Usage, Format, Pool, parent, parent_ops);
- if (FAILED(hr))
- {
- WARN("Failed to initialize volume, returning %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
- return hr;
- }
-
- TRACE("(%p) : Created volume %p.\n", This, object);
- *ppVolume = (IWineD3DVolume *)object;
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface, UINT EdgeLength, UINT Levels,
- DWORD Usage, enum wined3d_format_id Format, WINED3DPOOL Pool, void *parent,
- const struct wined3d_parent_ops *parent_ops, IWineD3DCubeTexture **ppCubeTexture)
-{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DCubeTextureImpl *object; /** NOTE: impl ref allowed since this is a create function **/
- HRESULT hr;
-
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
- {
- ERR("Out of memory\n");
- *ppCubeTexture = NULL;
- return WINED3DERR_OUTOFVIDEOMEMORY;
- }
-
- hr = cubetexture_init(object, EdgeLength, Levels, This, Usage, Format, Pool, parent, parent_ops);
- if (FAILED(hr))
- {
- WARN("Failed to initialize cubetexture, returning %#x\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
- *ppCubeTexture = NULL;
- return hr;
- }
-
- TRACE("(%p) : Created Cube Texture %p\n", This, object);
- *ppCubeTexture = (IWineD3DCubeTexture *)object;
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface,
- WINED3DQUERYTYPE type, IWineD3DQuery **query)
-{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DQueryImpl *object;
- HRESULT hr;
-
- TRACE("iface %p, type %#x, query %p.\n", iface, 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, This, 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 = (IWineD3DQuery *)object;
-
- return WINED3D_OK;
-}
-
-/* Do not call while under the GL lock. */
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateSwapChain(IWineD3DDevice *iface,
- WINED3DPRESENT_PARAMETERS *present_parameters, WINED3DSURFTYPE surface_type,
- void *parent, IWineD3DSwapChain **swapchain)
-{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DSwapChainImpl *object;
- HRESULT hr;
-
- TRACE("iface %p, present_parameters %p, swapchain %p, parent %p, surface_type %#x.\n",
- iface, present_parameters, swapchain, parent, surface_type);
-
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
- {
- ERR("Failed to allocate swapchain memory.\n");
- return E_OUTOFMEMORY;
- }
-
- hr = swapchain_init(object, surface_type, This, present_parameters, parent);
- if (FAILED(hr))
- {
- WARN("Failed to initialize swapchain, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
- return hr;
- }
-
- TRACE("Created swapchain %p.\n", object);
- *swapchain = (IWineD3DSwapChain *)object;
-
- return WINED3D_OK;
-}
-
-/** NOTE: These are ahead of the other getters and setters to save using a forward declaration **/
-static UINT WINAPI IWineD3DDeviceImpl_GetNumberOfSwapChains(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- TRACE("(%p)\n", This);
-
- return This->NumberOfSwapChains;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_GetSwapChain(IWineD3DDevice *iface, UINT iSwapChain, IWineD3DSwapChain **pSwapChain) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- TRACE("(%p) : swapchain %d\n", This, iSwapChain);
-
- if(iSwapChain < This->NumberOfSwapChains) {
- *pSwapChain = This->swapchains[iSwapChain];
- IWineD3DSwapChain_AddRef(*pSwapChain);
- TRACE("(%p) returning %p\n", This, *pSwapChain);
- return WINED3D_OK;
- } else {
- TRACE("Swapchain out of range\n");
- *pSwapChain = NULL;
- return WINED3DERR_INVALIDCALL;
- }
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclaration(IWineD3DDevice *iface,
- const WINED3DVERTEXELEMENT *elements, UINT element_count, void *parent,
- const struct wined3d_parent_ops *parent_ops, IWineD3DVertexDeclaration **declaration)
-{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DVertexDeclarationImpl *object = NULL;
- HRESULT hr;
-
- TRACE("iface %p, declaration %p, parent %p, elements %p, element_count %u.\n",
- iface, declaration, parent, elements, element_count);
-
- 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, This, 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 = (IWineD3DVertexDeclaration *)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 ConvertFvfToDeclaration(IWineD3DDeviceImpl *This, /* For the GL info, which has the type table */
- DWORD fvf, WINED3DVERTEXELEMENT **ppVertexElements)
-{
- const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
- 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;
- }
- }
-
- *ppVertexElements = state.elements;
- return size;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclarationFromFVF(IWineD3DDevice *iface,
- DWORD fvf, void *parent, const struct wined3d_parent_ops *parent_ops,
- IWineD3DVertexDeclaration **declaration)
-{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
- WINED3DVERTEXELEMENT *elements;
- unsigned int size;
- DWORD hr;
-
- TRACE("iface %p, declaration %p, parent %p, fvf %#x.\n", iface, declaration, parent, fvf);
-
- size = ConvertFvfToDeclaration(This, fvf, &elements);
- if (size == ~0U) return E_OUTOFMEMORY;
-
- hr = IWineD3DDeviceImpl_CreateVertexDeclaration(iface, elements, size, parent, parent_ops, declaration);
- HeapFree(GetProcessHeap(), 0, elements);
- return hr;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexShader(IWineD3DDevice *iface,
- const DWORD *pFunction, const struct wined3d_shader_signature *output_signature,
- void *parent, const struct wined3d_parent_ops *parent_ops,
- IWineD3DVertexShader **ppVertexShader)
-{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DVertexShaderImpl *object;
- HRESULT hr;
-
- if (This->vs_selected_mode == SHADER_NONE)
- return WINED3DERR_INVALIDCALL;
-
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
- {
- ERR("Failed to allocate shader memory.\n");
- return E_OUTOFMEMORY;
- }
-
- hr = vertexshader_init(object, This, pFunction, output_signature, parent, parent_ops);
- if (FAILED(hr))
- {
- WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
- return hr;
- }
-
- TRACE("Created vertex shader %p.\n", object);
- *ppVertexShader = (IWineD3DVertexShader *)object;
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_CreateGeometryShader(IWineD3DDevice *iface,
- const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
- void *parent, const struct wined3d_parent_ops *parent_ops,
- IWineD3DGeometryShader **shader)
-{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- struct wined3d_geometryshader *object;
- HRESULT hr;
-
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
- {
- ERR("Failed to allocate shader memory.\n");
- return E_OUTOFMEMORY;
- }
-
- hr = geometryshader_init(object, This, byte_code, output_signature, parent, parent_ops);
- if (FAILED(hr))
- {
- WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
- return hr;
- }
-
- TRACE("Created geometry shader %p.\n", object);
- *shader = (IWineD3DGeometryShader *)object;
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_CreatePixelShader(IWineD3DDevice *iface,
- const DWORD *pFunction, const struct wined3d_shader_signature *output_signature,
- void *parent, const struct wined3d_parent_ops *parent_ops,
- IWineD3DPixelShader **ppPixelShader)
-{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DPixelShaderImpl *object;
- HRESULT hr;
-
- if (This->ps_selected_mode == SHADER_NONE)
- return WINED3DERR_INVALIDCALL;
-
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object)
- {
- ERR("Failed to allocate shader memory.\n");
- return E_OUTOFMEMORY;
- }
-
- hr = pixelshader_init(object, This, pFunction, output_signature, parent, parent_ops);
- if (FAILED(hr))
- {
- WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
- HeapFree(GetProcessHeap(), 0, object);
- return hr;
- }
-
- TRACE("Created pixel shader %p.\n", object);
- *ppPixelShader = (IWineD3DPixelShader *)object;
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_CreatePalette(IWineD3DDevice *iface, DWORD Flags,
- const PALETTEENTRY *PalEnt, void *parent, IWineD3DPalette **Palette)
-{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
- IWineD3DPaletteImpl *object;
- HRESULT hr;
-
- TRACE("iface %p, flags %#x, entries %p, palette %p, parent %p.\n",
- iface, Flags, PalEnt, 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, This, Flags, PalEnt, 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 = (IWineD3DPalette *)object;
-
- return WINED3D_OK;
-}
-
-static void IWineD3DDeviceImpl_LoadLogo(IWineD3DDeviceImpl *This, const char *filename) {
HBITMAP hbm;
BITMAP bm;
HRESULT hr;
@@ -1657,30 +936,31 @@ static void IWineD3DDeviceImpl_LoadLogo(IWineD3DDeviceImpl *This, const char *fi
bm.bmHeight = 32;
}
- hr = IWineD3DDevice_CreateSurface((IWineD3DDevice *)This, bm.bmWidth, bm.bmHeight, WINED3DFMT_B5G6R5_UNORM, TRUE,
+ hr = wined3d_surface_create(device, bm.bmWidth, bm.bmHeight, WINED3DFMT_B5G6R5_UNORM, TRUE,
FALSE, 0, 0, WINED3DPOOL_DEFAULT, WINED3DMULTISAMPLE_NONE, 0, SURFACE_OPENGL, NULL,
- &wined3d_null_parent_ops, &This->logo_surface);
+ &wined3d_null_parent_ops, &device->logo_surface);
if (FAILED(hr))
{
ERR("Wine logo requested, but failed to create surface, hr %#x.\n", hr);
goto out;
}
- if(dcb) {
- hr = IWineD3DSurface_GetDC(This->logo_surface, &dcs);
- if(FAILED(hr)) goto out;
+ if (dcb)
+ {
+ if (FAILED(hr = wined3d_surface_getdc(device->logo_surface, &dcs)))
+ goto out;
BitBlt(dcs, 0, 0, bm.bmWidth, bm.bmHeight, dcb, 0, 0, SRCCOPY);
- IWineD3DSurface_ReleaseDC(This->logo_surface, dcs);
+ wined3d_surface_releasedc(device->logo_surface, dcs);
colorkey.dwColorSpaceLowValue = 0;
colorkey.dwColorSpaceHighValue = 0;
- IWineD3DSurface_SetColorKey(This->logo_surface, WINEDDCKEY_SRCBLT, &colorkey);
+ wined3d_surface_set_color_key(device->logo_surface, WINEDDCKEY_SRCBLT, &colorkey);
}
else
{
const WINED3DCOLORVALUE c = {1.0f, 1.0f, 1.0f, 1.0f};
/* Fill the surface with a white color to show that wined3d is there */
- IWineD3DDevice_ColorFill((IWineD3DDevice *)This, This->logo_surface, NULL, &c);
+ wined3d_device_color_fill(device, device->logo_surface, NULL, &c);
}
out:
@@ -1689,9 +969,9 @@ out:
}
/* Context activation is done by the caller. */
-static void create_dummy_textures(IWineD3DDeviceImpl *This)
+static void create_dummy_textures(struct wined3d_device *device)
{
- const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
unsigned int i;
/* Under DirectX you can have texture stage operations even if no texture is
bound, whereas opengl will only do texture operations when a valid texture is
@@ -1716,13 +996,13 @@ static void create_dummy_textures(IWineD3DDeviceImpl *This)
checkGLcall("glActiveTextureARB");
/* Generate an opengl texture name */
- glGenTextures(1, &This->dummyTextureName[i]);
+ glGenTextures(1, &device->dummyTextureName[i]);
checkGLcall("glGenTextures");
- TRACE("Dummy Texture %d given name %d\n", i, This->dummyTextureName[i]);
+ TRACE("Dummy Texture %d given name %d.\n", i, device->dummyTextureName[i]);
/* Generate a dummy 2d texture (not using 1d because they cause many
* DRI drivers fall back to sw) */
- glBindTexture(GL_TEXTURE_2D, This->dummyTextureName[i]);
+ glBindTexture(GL_TEXTURE_2D, device->dummyTextureName[i]);
checkGLcall("glBindTexture");
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, &white);
@@ -1740,7 +1020,7 @@ static void create_dummy_textures(IWineD3DDeviceImpl *This)
}
/* Context activation is done by the caller. */
-static void destroy_dummy_textures(IWineD3DDeviceImpl *device, const struct wined3d_gl_info *gl_info)
+static void destroy_dummy_textures(struct wined3d_device *device, const struct wined3d_gl_info *gl_info)
{
ENTER_GL();
glDeleteTextures(gl_info->limits.textures, device->dummyTextureName);
@@ -1750,9 +1030,92 @@ static void destroy_dummy_textures(IWineD3DDeviceImpl *device, const struct wine
memset(device->dummyTextureName, 0, gl_info->limits.textures * sizeof(*device->dummyTextureName));
}
-static HRESULT WINAPI IWineD3DDeviceImpl_AcquireFocusWindow(IWineD3DDevice *iface, HWND window)
+static LONG fullscreen_style(LONG style)
{
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
+ /* Make sure the window is managed, otherwise we won't get keyboard input. */
+ style |= WS_POPUP | WS_SYSMENU;
+ style &= ~(WS_CAPTION | WS_THICKFRAME);
+
+ return style;
+}
+
+static LONG fullscreen_exstyle(LONG exstyle)
+{
+ /* Filter out window decorations. */
+ exstyle &= ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE);
+
+ return exstyle;
+}
+
+void CDECL wined3d_device_setup_fullscreen_window(struct wined3d_device *device, HWND window, UINT w, UINT h)
+{
+ BOOL filter_messages;
+ LONG style, exstyle;
+
+ TRACE("Setting up window %p for fullscreen mode.\n", window);
+
+ if (device->style || device->exStyle)
+ {
+ ERR("Changing the window style for window %p, but another style (%08x, %08x) is already stored.\n",
+ window, device->style, device->exStyle);
+ }
+
+ device->style = GetWindowLongW(window, GWL_STYLE);
+ device->exStyle = GetWindowLongW(window, GWL_EXSTYLE);
+
+ style = fullscreen_style(device->style);
+ exstyle = fullscreen_exstyle(device->exStyle);
+
+ TRACE("Old style was %08x, %08x, setting to %08x, %08x.\n",
+ device->style, device->exStyle, style, exstyle);
+
+ filter_messages = device->filter_messages;
+ device->filter_messages = TRUE;
+
+ SetWindowLongW(window, GWL_STYLE, style);
+ SetWindowLongW(window, GWL_EXSTYLE, exstyle);
+ SetWindowPos(window, HWND_TOP, 0, 0, w, h, SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOACTIVATE);
+
+ device->filter_messages = filter_messages;
+}
+
+void CDECL wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window)
+{
+ BOOL filter_messages;
+ LONG style, exstyle;
+
+ if (!device->style && !device->exStyle) return;
+
+ TRACE("Restoring window style of window %p to %08x, %08x.\n",
+ window, device->style, device->exStyle);
+
+ style = GetWindowLongW(window, GWL_STYLE);
+ exstyle = GetWindowLongW(window, GWL_EXSTYLE);
+
+ filter_messages = device->filter_messages;
+ device->filter_messages = TRUE;
+
+ /* Only restore the style if the application didn't modify it during the
+ * fullscreen phase. Some applications change it before calling Reset()
+ * when switching between windowed and fullscreen modes (HL2), some
+ * depend on the original style (Eve Online). */
+ if (style == fullscreen_style(device->style) && exstyle == fullscreen_exstyle(device->exStyle))
+ {
+ SetWindowLongW(window, GWL_STYLE, device->style);
+ SetWindowLongW(window, GWL_EXSTYLE, device->exStyle);
+ }
+ SetWindowPos(window, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
+
+ device->filter_messages = filter_messages;
+
+ /* Delete the old values. */
+ device->style = 0;
+ device->exStyle = 0;
+}
+
+HRESULT CDECL wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window)
+{
+ TRACE("device %p, window %p.\n", device, window);
if (!wined3d_register_window(window, device))
{
@@ -1761,131 +1124,146 @@ static HRESULT WINAPI IWineD3DDeviceImpl_AcquireFocusWindow(IWineD3DDevice *ifac
}
device->focus_window = window;
- SetForegroundWindow(window);
+ SetWindowPos(window, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
return WINED3D_OK;
}
-static void WINAPI IWineD3DDeviceImpl_ReleaseFocusWindow(IWineD3DDevice *iface)
+void CDECL wined3d_device_release_focus_window(struct wined3d_device *device)
{
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
+ TRACE("device %p.\n", device);
if (device->focus_window) wined3d_unregister_window(device->focus_window);
device->focus_window = NULL;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
- WINED3DPRESENT_PARAMETERS *pPresentationParameters)
+HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
+ WINED3DPRESENT_PARAMETERS *present_parameters)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
- const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
- IWineD3DSwapChainImpl *swapchain = NULL;
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+ struct wined3d_swapchain *swapchain = NULL;
struct wined3d_context *context;
HRESULT hr;
DWORD state;
unsigned int i;
- TRACE("(%p)->(%p)\n", This, pPresentationParameters);
+ TRACE("device %p, present_parameters %p.\n", device, present_parameters);
- if(This->d3d_initialized) return WINED3DERR_INVALIDCALL;
- if(!This->adapter->opengl) return WINED3DERR_INVALIDCALL;
+ if (device->d3d_initialized)
+ return WINED3DERR_INVALIDCALL;
+ if (!device->adapter->opengl)
+ return WINED3DERR_INVALIDCALL;
- TRACE("(%p) : Creating stateblock\n", This);
- hr = IWineD3DDevice_CreateStateBlock(iface, WINED3DSBT_INIT, (IWineD3DStateBlock **)&This->stateBlock);
+ TRACE("Creating stateblock.\n");
+ hr = wined3d_stateblock_create(device, WINED3DSBT_INIT, &device->stateBlock);
if (FAILED(hr))
{
WARN("Failed to create stateblock\n");
goto err_out;
}
- TRACE("(%p) : Created stateblock (%p)\n", This, This->stateBlock);
- This->updateStateBlock = This->stateBlock;
- IWineD3DStateBlock_AddRef((IWineD3DStateBlock*)This->updateStateBlock);
- This->render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- sizeof(*This->render_targets) * gl_info->limits.buffers);
+ TRACE("Created stateblock %p.\n", device->stateBlock);
+ device->updateStateBlock = device->stateBlock;
+ wined3d_stateblock_incref(device->updateStateBlock);
- This->NumberOfPalettes = 1;
- This->palettes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PALETTEENTRY*));
- if (!This->palettes || !This->render_targets)
+ device->valid_rt_mask = 0;
+ for (i = 0; i < gl_info->limits.buffers; ++i)
+ device->valid_rt_mask |= (1 << i);
+ device->fb.render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+ sizeof(*device->fb.render_targets) * gl_info->limits.buffers);
+
+ device->palette_count = 1;
+ device->palettes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PALETTEENTRY*));
+ if (!device->palettes || !device->fb.render_targets)
{
ERR("Out of memory!\n");
hr = E_OUTOFMEMORY;
goto err_out;
}
- This->palettes[0] = HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY) * 256);
- if(!This->palettes[0]) {
+
+ device->palettes[0] = HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY) * 256);
+ if (!device->palettes[0])
+ {
ERR("Out of memory!\n");
hr = E_OUTOFMEMORY;
goto err_out;
}
- for (i = 0; i < 256; ++i) {
- This->palettes[0][i].peRed = 0xFF;
- This->palettes[0][i].peGreen = 0xFF;
- This->palettes[0][i].peBlue = 0xFF;
- This->palettes[0][i].peFlags = 0xFF;
+
+ for (i = 0; i < 256; ++i)
+ {
+ device->palettes[0][i].peRed = 0xff;
+ device->palettes[0][i].peGreen = 0xff;
+ device->palettes[0][i].peBlue = 0xff;
+ device->palettes[0][i].peFlags = 0xff;
}
- This->currentPalette = 0;
+ device->currentPalette = 0;
/* Initialize the texture unit mapping to a 1:1 mapping */
for (state = 0; state < MAX_COMBINED_SAMPLERS; ++state)
{
if (state < gl_info->limits.fragment_samplers)
{
- This->texUnitMap[state] = state;
- This->rev_tex_unit_map[state] = state;
- } else {
- This->texUnitMap[state] = WINED3D_UNMAPPED_STAGE;
- This->rev_tex_unit_map[state] = WINED3D_UNMAPPED_STAGE;
+ device->texUnitMap[state] = state;
+ device->rev_tex_unit_map[state] = state;
+ }
+ else
+ {
+ device->texUnitMap[state] = WINED3D_UNMAPPED_STAGE;
+ device->rev_tex_unit_map[state] = WINED3D_UNMAPPED_STAGE;
}
}
/* Setup the implicit swapchain. This also initializes a context. */
TRACE("Creating implicit swapchain\n");
- hr = IWineD3DDeviceParent_CreateSwapChain(This->device_parent,
- pPresentationParameters, (IWineD3DSwapChain **)&swapchain);
+ hr = device->device_parent->ops->create_swapchain(device->device_parent,
+ present_parameters, &swapchain);
if (FAILED(hr))
{
WARN("Failed to create implicit swapchain\n");
goto err_out;
}
- This->NumberOfSwapChains = 1;
- This->swapchains = HeapAlloc(GetProcessHeap(), 0, This->NumberOfSwapChains * sizeof(IWineD3DSwapChain *));
- if(!This->swapchains) {
+ device->swapchain_count = 1;
+ device->swapchains = HeapAlloc(GetProcessHeap(), 0, device->swapchain_count * sizeof(*device->swapchains));
+ if (!device->swapchains)
+ {
ERR("Out of memory!\n");
goto err_out;
}
- This->swapchains[0] = (IWineD3DSwapChain *) swapchain;
+ device->swapchains[0] = swapchain;
if (swapchain->back_buffers && swapchain->back_buffers[0])
{
TRACE("Setting rendertarget to %p.\n", swapchain->back_buffers);
- This->render_targets[0] = swapchain->back_buffers[0];
+ device->fb.render_targets[0] = swapchain->back_buffers[0];
}
else
{
TRACE("Setting rendertarget to %p.\n", swapchain->front_buffer);
- This->render_targets[0] = swapchain->front_buffer;
+ device->fb.render_targets[0] = swapchain->front_buffer;
}
- IWineD3DSurface_AddRef((IWineD3DSurface *)This->render_targets[0]);
+ wined3d_surface_incref(device->fb.render_targets[0]);
/* Depth Stencil support */
- This->depth_stencil = This->auto_depth_stencil;
- if (This->depth_stencil)
- IWineD3DSurface_AddRef((IWineD3DSurface *)This->depth_stencil);
+ device->fb.depth_stencil = device->auto_depth_stencil;
+ if (device->fb.depth_stencil)
+ wined3d_surface_incref(device->fb.depth_stencil);
- hr = This->shader_backend->shader_alloc_private(iface);
- if(FAILED(hr)) {
+ hr = device->shader_backend->shader_alloc_private(device);
+ if (FAILED(hr))
+ {
TRACE("Shader private data couldn't be allocated\n");
goto err_out;
}
- hr = This->frag_pipe->alloc_private(iface);
- if(FAILED(hr)) {
+ hr = device->frag_pipe->alloc_private(device);
+ if (FAILED(hr))
+ {
TRACE("Fragment pipeline private data couldn't be allocated\n");
goto err_out;
}
- hr = This->blitter->alloc_private(iface);
- if(FAILED(hr)) {
+ hr = device->blitter->alloc_private(device);
+ if (FAILED(hr))
+ {
TRACE("Blitter private data couldn't be allocated\n");
goto err_out;
}
@@ -1893,23 +1271,22 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
/* Set up some starting GL setup */
/* Setup all the devices defaults */
- stateblock_init_default_state(This->stateBlock);
+ stateblock_init_default_state(device->stateBlock);
- context = context_acquire(This, swapchain->front_buffer);
+ context = context_acquire(device, swapchain->front_buffer);
- create_dummy_textures(This);
+ create_dummy_textures(device);
ENTER_GL();
/* Initialize the current view state */
- This->view_ident = 1;
- This->contexts[0]->last_was_rhw = 0;
- glGetIntegerv(GL_MAX_LIGHTS, &This->maxConcurrentLights);
- checkGLcall("glGetIntegerv(GL_MAX_LIGHTS, &This->maxConcurrentLights)");
+ device->view_ident = 1;
+ device->contexts[0]->last_was_rhw = 0;
- switch(wined3d_settings.offscreen_rendering_mode) {
+ switch (wined3d_settings.offscreen_rendering_mode)
+ {
case ORM_FBO:
- This->offscreenBuffer = GL_COLOR_ATTACHMENT0;
+ device->offscreenBuffer = GL_COLOR_ATTACHMENT0;
break;
case ORM_BACKBUFFER:
@@ -1917,265 +1294,272 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
if (context_get_current()->aux_buffers > 0)
{
TRACE("Using auxilliary buffer for offscreen rendering\n");
- This->offscreenBuffer = GL_AUX0;
- } else {
+ device->offscreenBuffer = GL_AUX0;
+ }
+ else
+ {
TRACE("Using back buffer for offscreen rendering\n");
- This->offscreenBuffer = GL_BACK;
+ device->offscreenBuffer = GL_BACK;
}
}
}
- TRACE("(%p) All defaults now set up, leaving Init3D with %p\n", This, This);
+ TRACE("All defaults now set up, leaving 3D init.\n");
LEAVE_GL();
context_release(context);
/* Clear the screen */
- IWineD3DDevice_Clear((IWineD3DDevice *) This, 0, NULL,
- WINED3DCLEAR_TARGET | pPresentationParameters->EnableAutoDepthStencil ? WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL : 0,
- 0x00, 1.0f, 0);
+ wined3d_device_clear(device, 0, NULL, WINED3DCLEAR_TARGET
+ | (present_parameters->EnableAutoDepthStencil ? WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL : 0),
+ 0x00, 1.0f, 0);
- This->d3d_initialized = TRUE;
+ device->d3d_initialized = TRUE;
- if(wined3d_settings.logo) {
- IWineD3DDeviceImpl_LoadLogo(This, wined3d_settings.logo);
- }
- This->highest_dirty_ps_const = 0;
- This->highest_dirty_vs_const = 0;
+ if (wined3d_settings.logo)
+ IWineD3DDeviceImpl_LoadLogo(device, wined3d_settings.logo);
+ device->highest_dirty_ps_const = 0;
+ device->highest_dirty_vs_const = 0;
return WINED3D_OK;
err_out:
- HeapFree(GetProcessHeap(), 0, This->render_targets);
- HeapFree(GetProcessHeap(), 0, This->swapchains);
- This->NumberOfSwapChains = 0;
- if(This->palettes) {
- HeapFree(GetProcessHeap(), 0, This->palettes[0]);
- HeapFree(GetProcessHeap(), 0, This->palettes);
+ HeapFree(GetProcessHeap(), 0, device->fb.render_targets);
+ HeapFree(GetProcessHeap(), 0, device->swapchains);
+ device->swapchain_count = 0;
+ if (device->palettes)
+ {
+ HeapFree(GetProcessHeap(), 0, device->palettes[0]);
+ HeapFree(GetProcessHeap(), 0, device->palettes);
}
- This->NumberOfPalettes = 0;
- if(swapchain) {
- IWineD3DSwapChain_Release( (IWineD3DSwapChain *) swapchain);
- }
- if(This->stateBlock) {
- IWineD3DStateBlock_Release((IWineD3DStateBlock *) This->stateBlock);
- This->stateBlock = NULL;
- }
- if (This->blit_priv) {
- This->blitter->free_private(iface);
- }
- if (This->fragment_priv) {
- This->frag_pipe->free_private(iface);
- }
- if (This->shader_priv) {
- This->shader_backend->shader_free_private(iface);
+ device->palette_count = 0;
+ if (swapchain)
+ wined3d_swapchain_decref(swapchain);
+ if (device->stateBlock)
+ {
+ wined3d_stateblock_decref(device->stateBlock);
+ device->stateBlock = NULL;
}
+ if (device->blit_priv)
+ device->blitter->free_private(device);
+ if (device->fragment_priv)
+ device->frag_pipe->free_private(device);
+ if (device->shader_priv)
+ device->shader_backend->shader_free_private(device);
+
return hr;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_InitGDI(IWineD3DDevice *iface,
- WINED3DPRESENT_PARAMETERS *pPresentationParameters)
+HRESULT CDECL wined3d_device_init_gdi(struct wined3d_device *device,
+ WINED3DPRESENT_PARAMETERS *present_parameters)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
- IWineD3DSwapChainImpl *swapchain = NULL;
+ struct wined3d_swapchain *swapchain = NULL;
HRESULT hr;
+ TRACE("device %p, present_parameters %p.\n", device, present_parameters);
+
/* Setup the implicit swapchain */
TRACE("Creating implicit swapchain\n");
- hr = IWineD3DDeviceParent_CreateSwapChain(This->device_parent,
- pPresentationParameters, (IWineD3DSwapChain **)&swapchain);
+ hr = device->device_parent->ops->create_swapchain(device->device_parent,
+ present_parameters, &swapchain);
if (FAILED(hr))
{
WARN("Failed to create implicit swapchain\n");
goto err_out;
}
- This->NumberOfSwapChains = 1;
- This->swapchains = HeapAlloc(GetProcessHeap(), 0, This->NumberOfSwapChains * sizeof(IWineD3DSwapChain *));
- if(!This->swapchains) {
+ device->swapchain_count = 1;
+ device->swapchains = HeapAlloc(GetProcessHeap(), 0, device->swapchain_count * sizeof(*device->swapchains));
+ if (!device->swapchains)
+ {
ERR("Out of memory!\n");
goto err_out;
}
- This->swapchains[0] = (IWineD3DSwapChain *) swapchain;
+ device->swapchains[0] = swapchain;
return WINED3D_OK;
err_out:
- IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
+ wined3d_swapchain_decref(swapchain);
return hr;
}
-static HRESULT WINAPI device_unload_resource(IWineD3DResource *resource, void *ctx)
+static HRESULT WINAPI device_unload_resource(struct wined3d_resource *resource, void *data)
{
- IWineD3DResource_UnLoad(resource);
- IWineD3DResource_Release(resource);
- return WINED3D_OK;
+ TRACE("Unloading resource %p.\n", resource);
+
+ resource->resource_ops->resource_unload(resource);
+
+ return S_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface,
- D3DCB_DESTROYSWAPCHAINFN D3DCB_DestroySwapChain)
+HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
- int sampler;
+ struct wined3d_surface *surface;
UINT i;
- TRACE("(%p)\n", This);
- if(!This->d3d_initialized) return WINED3DERR_INVALIDCALL;
+ TRACE("device %p.\n", device);
+ if (!device->d3d_initialized)
+ return WINED3DERR_INVALIDCALL;
+
+ /* Force making the context current again, to verify it is still valid
+ * (workaround for broken drivers) */
+ context_set_current(NULL);
/* I don't think that the interface guarantees that the device is destroyed from the same thread
* it was created. Thus make sure a context is active for the glDelete* calls
*/
- context = context_acquire(This, NULL);
+ context = context_acquire(device, NULL);
gl_info = context->gl_info;
- if(This->logo_surface) IWineD3DSurface_Release(This->logo_surface);
+ if (device->logo_surface)
+ wined3d_surface_decref(device->logo_surface);
/* Unload resources */
- IWineD3DDevice_EnumResources(iface, device_unload_resource, NULL);
+ wined3d_device_enum_resources(device, device_unload_resource, NULL);
TRACE("Deleting high order patches\n");
for(i = 0; i < PATCHMAP_SIZE; i++) {
struct list *e1, *e2;
struct WineD3DRectPatch *patch;
- LIST_FOR_EACH_SAFE(e1, e2, &This->patches[i]) {
+ LIST_FOR_EACH_SAFE(e1, e2, &device->patches[i])
+ {
patch = LIST_ENTRY(e1, struct WineD3DRectPatch, entry);
- IWineD3DDevice_DeletePatch(iface, patch->Handle);
+ wined3d_device_delete_patch(device, patch->Handle);
}
}
/* Delete the mouse cursor texture */
- if(This->cursorTexture) {
+ if (device->cursorTexture)
+ {
ENTER_GL();
- glDeleteTextures(1, &This->cursorTexture);
+ glDeleteTextures(1, &device->cursorTexture);
LEAVE_GL();
- This->cursorTexture = 0;
- }
-
- for (sampler = 0; sampler < MAX_FRAGMENT_SAMPLERS; ++sampler) {
- IWineD3DDevice_SetTexture(iface, sampler, NULL);
- }
- for (sampler = 0; sampler < MAX_VERTEX_SAMPLERS; ++sampler) {
- IWineD3DDevice_SetTexture(iface, WINED3DVERTEXTEXTURESAMPLER0 + sampler, NULL);
+ device->cursorTexture = 0;
}
/* Destroy the depth blt resources, they will be invalid after the reset. Also free shader
* private data, it might contain opengl pointers
*/
- if(This->depth_blt_texture) {
+ if (device->depth_blt_texture)
+ {
ENTER_GL();
- glDeleteTextures(1, &This->depth_blt_texture);
+ glDeleteTextures(1, &device->depth_blt_texture);
LEAVE_GL();
- This->depth_blt_texture = 0;
+ device->depth_blt_texture = 0;
}
- if (This->depth_blt_rb) {
+ if (device->depth_blt_rb)
+ {
ENTER_GL();
- gl_info->fbo_ops.glDeleteRenderbuffers(1, &This->depth_blt_rb);
+ gl_info->fbo_ops.glDeleteRenderbuffers(1, &device->depth_blt_rb);
LEAVE_GL();
- This->depth_blt_rb = 0;
- This->depth_blt_rb_w = 0;
- This->depth_blt_rb_h = 0;
+ device->depth_blt_rb = 0;
+ device->depth_blt_rb_w = 0;
+ device->depth_blt_rb_h = 0;
}
/* Release the update stateblock */
- if(IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->updateStateBlock) > 0){
- if(This->updateStateBlock != This->stateBlock)
- FIXME("(%p) Something's still holding the Update stateblock\n",This);
+ if (wined3d_stateblock_decref(device->updateStateBlock))
+ {
+ if (device->updateStateBlock != device->stateBlock)
+ FIXME("Something's still holding the update stateblock.\n");
}
- This->updateStateBlock = NULL;
+ device->updateStateBlock = NULL;
- { /* because were not doing proper internal refcounts releasing the primary state block
- causes recursion with the extra checks in ResourceReleased, to avoid this we have
- to set this->stateBlock = NULL; first */
- IWineD3DStateBlock *stateBlock = (IWineD3DStateBlock *)This->stateBlock;
- This->stateBlock = NULL;
+ {
+ struct wined3d_stateblock *stateblock = device->stateBlock;
+ device->stateBlock = NULL;
/* Release the stateblock */
- if(IWineD3DStateBlock_Release(stateBlock) > 0){
- FIXME("(%p) Something's still holding the Update stateblock\n",This);
- }
+ if (wined3d_stateblock_decref(stateblock))
+ FIXME("Something's still holding the stateblock.\n");
}
/* Destroy the shader backend. Note that this has to happen after all shaders are destroyed. */
- This->blitter->free_private(iface);
- This->frag_pipe->free_private(iface);
- This->shader_backend->shader_free_private(iface);
+ device->blitter->free_private(device);
+ device->frag_pipe->free_private(device);
+ device->shader_backend->shader_free_private(device);
/* Release the buffers (with sanity checks)*/
- if (This->onscreen_depth_stencil)
+ if (device->onscreen_depth_stencil)
{
- IWineD3DSurface_Release((IWineD3DSurface *)This->onscreen_depth_stencil);
- This->onscreen_depth_stencil = NULL;
+ surface = device->onscreen_depth_stencil;
+ device->onscreen_depth_stencil = NULL;
+ wined3d_surface_decref(surface);
}
- if (This->depth_stencil)
+ if (device->fb.depth_stencil)
{
- IWineD3DSurfaceImpl *ds = This->depth_stencil;
+ surface = device->fb.depth_stencil;
- TRACE("Releasing depth/stencil buffer %p.\n", ds);
+ TRACE("Releasing depth/stencil buffer %p.\n", surface);
- This->depth_stencil = NULL;
- if (IWineD3DSurface_Release((IWineD3DSurface *)ds)
- && ds != This->auto_depth_stencil)
- {
- ERR("Something is still holding a reference to depth/stencil buffer %p.\n", ds);
- }
+ device->fb.depth_stencil = NULL;
+ if (wined3d_surface_decref(surface)
+ && surface != device->auto_depth_stencil)
+ ERR("Something is still holding a reference to depth/stencil buffer %p.\n", surface);
}
- TRACE("Releasing the render target at %p\n", This->render_targets[0]);
- IWineD3DSurface_Release((IWineD3DSurface *)This->render_targets[0]);
-
- TRACE("Setting rendertarget to NULL\n");
- This->render_targets[0] = NULL;
-
- if (This->auto_depth_stencil)
+ if (device->auto_depth_stencil)
{
- if (IWineD3DSurface_Release((IWineD3DSurface *)This->auto_depth_stencil))
- {
- FIXME("(%p) Something's still holding the auto depth stencil buffer\n", This);
- }
- This->auto_depth_stencil = NULL;
+ surface = device->auto_depth_stencil;
+ device->auto_depth_stencil = NULL;
+ if (wined3d_surface_decref(surface))
+ FIXME("Something's still holding the auto depth stencil buffer (%p).\n", surface);
}
+ for (i = 1; i < gl_info->limits.buffers; ++i)
+ {
+ wined3d_device_set_render_target(device, i, NULL, FALSE);
+ }
+
+ surface = device->fb.render_targets[0];
+ TRACE("Setting rendertarget 0 to NULL\n");
+ device->fb.render_targets[0] = NULL;
+ TRACE("Releasing the render target at %p\n", surface);
+ wined3d_surface_decref(surface);
+
context_release(context);
- for(i=0; i < This->NumberOfSwapChains; i++) {
- TRACE("Releasing the implicit swapchain %d\n", i);
- if (D3DCB_DestroySwapChain(This->swapchains[i]) > 0) {
- FIXME("(%p) Something's still holding the implicit swapchain\n", This);
- }
+ for (i = 0; i < device->swapchain_count; ++i)
+ {
+ TRACE("Releasing the implicit swapchain %u.\n", i);
+ if (wined3d_swapchain_decref(device->swapchains[i]))
+ FIXME("Something's still holding the implicit swapchain.\n");
}
- HeapFree(GetProcessHeap(), 0, This->swapchains);
- This->swapchains = NULL;
- This->NumberOfSwapChains = 0;
+ HeapFree(GetProcessHeap(), 0, device->swapchains);
+ device->swapchains = NULL;
+ device->swapchain_count = 0;
- for (i = 0; i < This->NumberOfPalettes; i++) HeapFree(GetProcessHeap(), 0, This->palettes[i]);
- HeapFree(GetProcessHeap(), 0, This->palettes);
- This->palettes = NULL;
- This->NumberOfPalettes = 0;
+ for (i = 0; i < device->palette_count; ++i)
+ HeapFree(GetProcessHeap(), 0, device->palettes[i]);
+ HeapFree(GetProcessHeap(), 0, device->palettes);
+ device->palettes = NULL;
+ device->palette_count = 0;
- HeapFree(GetProcessHeap(), 0, This->render_targets);
- This->render_targets = NULL;
+ HeapFree(GetProcessHeap(), 0, device->fb.render_targets);
+ device->fb.render_targets = NULL;
- This->d3d_initialized = FALSE;
+ device->d3d_initialized = FALSE;
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_UninitGDI(IWineD3DDevice *iface, D3DCB_DESTROYSWAPCHAINFN D3DCB_DestroySwapChain) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
+HRESULT CDECL wined3d_device_uninit_gdi(struct wined3d_device *device)
+{
unsigned int i;
- for(i=0; i < This->NumberOfSwapChains; i++) {
- TRACE("Releasing the implicit swapchain %d\n", i);
- if (D3DCB_DestroySwapChain(This->swapchains[i]) > 0) {
- FIXME("(%p) Something's still holding the implicit swapchain\n", This);
- }
+ for (i = 0; i < device->swapchain_count; ++i)
+ {
+ TRACE("Releasing the implicit swapchain %u.\n", i);
+ if (wined3d_swapchain_decref(device->swapchains[i]))
+ FIXME("Something's still holding the implicit swapchain.\n");
}
- HeapFree(GetProcessHeap(), 0, This->swapchains);
- This->swapchains = NULL;
- This->NumberOfSwapChains = 0;
+ HeapFree(GetProcessHeap(), 0, device->swapchains);
+ device->swapchains = NULL;
+ device->swapchain_count = 0;
return WINED3D_OK;
}
@@ -2185,22 +1569,24 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UninitGDI(IWineD3DDevice *iface, D3DCB_
*
* There is no way to deactivate thread safety once it is enabled.
*/
-static void WINAPI IWineD3DDeviceImpl_SetMultithreaded(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
+void CDECL wined3d_device_set_multithreaded(struct wined3d_device *device)
+{
+ TRACE("device %p.\n", device);
- /*For now just store the flag(needed in case of ddraw) */
- This->createParms.BehaviorFlags |= WINED3DCREATE_MULTITHREADED;
+ /* For now just store the flag (needed in case of ddraw). */
+ device->createParms.BehaviorFlags |= WINED3DCREATE_MULTITHREADED;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_SetDisplayMode(IWineD3DDevice *iface, UINT iSwapChain,
- const WINED3DDISPLAYMODE* pMode) {
+HRESULT CDECL wined3d_device_set_display_mode(struct wined3d_device *device,
+ UINT swapchain_idx, const WINED3DDISPLAYMODE *mode)
+{
+ const struct wined3d_format *format = wined3d_get_format(&device->adapter->gl_info, mode->Format);
DEVMODEW devmode;
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- const struct wined3d_format *format = wined3d_get_format(&This->adapter->gl_info, pMode->Format);
LONG ret;
RECT clip_rc;
- TRACE("(%p)->(%d,%p) Mode=%dx%dx@%d, %s\n", This, iSwapChain, pMode, pMode->Width, pMode->Height, pMode->RefreshRate, debug_d3dformat(pMode->Format));
+ TRACE("device %p, swapchain_idx %u, mode %p (%ux%u@%u %s).\n", device, swapchain_idx, mode,
+ mode->Width, mode->Height, mode->RefreshRate, debug_d3dformat(mode->Format));
/* Resize the screen even without a window:
* The app could have unset it with SetCooperativeLevel, but not called
@@ -2212,16 +1598,16 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetDisplayMode(IWineD3DDevice *iface, U
devmode.dmSize = sizeof(devmode);
devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
devmode.dmBitsPerPel = format->byte_count * CHAR_BIT;
- devmode.dmPelsWidth = pMode->Width;
- devmode.dmPelsHeight = pMode->Height;
+ devmode.dmPelsWidth = mode->Width;
+ devmode.dmPelsHeight = mode->Height;
- devmode.dmDisplayFrequency = pMode->RefreshRate;
- if (pMode->RefreshRate)
+ devmode.dmDisplayFrequency = mode->RefreshRate;
+ if (mode->RefreshRate)
devmode.dmFields |= DM_DISPLAYFREQUENCY;
/* Only change the mode if necessary */
- if (This->ddraw_width == pMode->Width && This->ddraw_height == pMode->Height
- && This->ddraw_format == pMode->Format && !pMode->RefreshRate)
+ if (device->ddraw_width == mode->Width && device->ddraw_height == mode->Height
+ && device->ddraw_format == mode->Format && !mode->RefreshRate)
return WINED3D_OK;
ret = ChangeDisplaySettingsExW(NULL, &devmode, NULL, CDS_FULLSCREEN, NULL);
@@ -2240,310 +1626,296 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetDisplayMode(IWineD3DDevice *iface, U
}
/* Store the new values */
- This->ddraw_width = pMode->Width;
- This->ddraw_height = pMode->Height;
- This->ddraw_format = pMode->Format;
+ device->ddraw_width = mode->Width;
+ device->ddraw_height = mode->Height;
+ device->ddraw_format = mode->Format;
/* And finally clip mouse to our screen */
- SetRect(&clip_rc, 0, 0, pMode->Width, pMode->Height);
+ SetRect(&clip_rc, 0, 0, mode->Width, mode->Height);
ClipCursor(&clip_rc);
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetDirect3D(IWineD3DDevice *iface, IWineD3D **ppD3D) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- *ppD3D = This->wined3d;
- TRACE("Returning %p.\n", *ppD3D);
- IWineD3D_AddRef(*ppD3D);
- return WINED3D_OK;
-}
-
-static UINT WINAPI IWineD3DDeviceImpl_GetAvailableTextureMem(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-
- TRACE("(%p) : simulating %dMB, returning %dMB left\n", This,
- (This->adapter->TextureRam/(1024*1024)),
- ((This->adapter->TextureRam - This->adapter->UsedTextureRam) / (1024*1024)));
- /* return simulated texture memory left */
- return (This->adapter->TextureRam - This->adapter->UsedTextureRam);
-}
-
-/*****
- * Get / Set Stream Source
- *****/
-static HRESULT WINAPI IWineD3DDeviceImpl_SetStreamSource(IWineD3DDevice *iface, UINT StreamNumber,
- IWineD3DBuffer *pStreamData, UINT OffsetInBytes, UINT Stride)
+HRESULT CDECL wined3d_device_get_wined3d(struct wined3d_device *device, struct wined3d **wined3d)
+{
+ TRACE("device %p, wined3d %p.\n", device, wined3d);
+
+ *wined3d = device->wined3d;
+ wined3d_incref(*wined3d);
+
+ TRACE("Returning %p.\n", *wined3d);
+
+ return WINED3D_OK;
+}
+
+UINT CDECL wined3d_device_get_available_texture_mem(struct wined3d_device *device)
+{
+ TRACE("device %p.\n", device);
+
+ TRACE("Emulating %d MB, returning %d MB left.\n",
+ device->adapter->TextureRam / (1024 * 1024),
+ (device->adapter->TextureRam - device->adapter->UsedTextureRam) / (1024 * 1024));
+
+ return device->adapter->TextureRam - device->adapter->UsedTextureRam;
+}
+
+HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UINT stream_idx,
+ struct wined3d_buffer *buffer, UINT offset, UINT stride)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
struct wined3d_stream_state *stream;
- IWineD3DBuffer *oldSrc;
+ struct wined3d_buffer *prev_buffer;
- TRACE("iface %p, stream_idx %u, buffer %p, offset %u, stride %u.\n",
- iface, StreamNumber, pStreamData, OffsetInBytes, Stride);
+ TRACE("device %p, stream_idx %u, buffer %p, offset %u, stride %u.\n",
+ device, stream_idx, buffer, offset, stride);
- if (StreamNumber >= MAX_STREAMS) {
- WARN("Stream out of range %d\n", StreamNumber);
+ if (stream_idx >= MAX_STREAMS)
+ {
+ WARN("Stream index %u out of range.\n", stream_idx);
return WINED3DERR_INVALIDCALL;
- } else if(OffsetInBytes & 0x3) {
- WARN("OffsetInBytes is not 4 byte aligned: %d\n", OffsetInBytes);
+ }
+ else if (offset & 0x3)
+ {
+ WARN("Offset %u is not 4 byte aligned.\n", offset);
return WINED3DERR_INVALIDCALL;
}
- stream = &This->updateStateBlock->state.streams[StreamNumber];
- oldSrc = (IWineD3DBuffer *)stream->buffer;
+ stream = &device->updateStateBlock->state.streams[stream_idx];
+ prev_buffer = stream->buffer;
- This->updateStateBlock->changed.streamSource |= 1 << StreamNumber;
+ device->updateStateBlock->changed.streamSource |= 1 << stream_idx;
- if (oldSrc == pStreamData
- && stream->stride == Stride
- && stream->offset == OffsetInBytes)
+ if (prev_buffer == buffer
+ && stream->stride == stride
+ && stream->offset == offset)
{
- TRACE("Application is setting the old values over, nothing to do\n");
+ TRACE("Application is setting the old values over, nothing to do.\n");
return WINED3D_OK;
}
- stream->buffer = (struct wined3d_buffer *)pStreamData;
- if (pStreamData)
+ stream->buffer = buffer;
+ if (buffer)
{
- stream->stride = Stride;
- stream->offset = OffsetInBytes;
+ stream->stride = stride;
+ stream->offset = offset;
}
- /* Handle recording of state blocks */
- if (This->isRecordingState) {
- TRACE("Recording... not performing anything\n");
- if (pStreamData) IWineD3DBuffer_AddRef(pStreamData);
- if (oldSrc) IWineD3DBuffer_Release(oldSrc);
+ /* Handle recording of state blocks. */
+ if (device->isRecordingState)
+ {
+ TRACE("Recording... not performing anything.\n");
+ if (buffer)
+ wined3d_buffer_incref(buffer);
+ if (prev_buffer)
+ wined3d_buffer_decref(prev_buffer);
return WINED3D_OK;
}
- if (pStreamData)
+ if (buffer)
{
- InterlockedIncrement(&((struct wined3d_buffer *)pStreamData)->bind_count);
- IWineD3DBuffer_AddRef(pStreamData);
+ InterlockedIncrement(&buffer->bind_count);
+ wined3d_buffer_incref(buffer);
}
- if (oldSrc)
+ if (prev_buffer)
{
- InterlockedDecrement(&((struct wined3d_buffer *)oldSrc)->bind_count);
- IWineD3DBuffer_Release(oldSrc);
+ InterlockedDecrement(&prev_buffer->bind_count);
+ wined3d_buffer_decref(prev_buffer);
}
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_STREAMSRC);
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetStreamSource(IWineD3DDevice *iface,
- UINT StreamNumber, IWineD3DBuffer **pStream, UINT *pOffset, UINT *pStride)
+HRESULT CDECL wined3d_device_get_stream_source(struct wined3d_device *device,
+ UINT stream_idx, struct wined3d_buffer **buffer, UINT *offset, UINT *stride)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
struct wined3d_stream_state *stream;
- TRACE("iface %p, stream_idx %u, buffer %p, offset %p, stride %p.\n",
- iface, StreamNumber, pStream, pOffset, pStride);
+ TRACE("device %p, stream_idx %u, buffer %p, offset %p, stride %p.\n",
+ device, stream_idx, buffer, offset, stride);
- if (StreamNumber >= MAX_STREAMS)
+ if (stream_idx >= MAX_STREAMS)
{
- WARN("Stream out of range %d\n", StreamNumber);
+ WARN("Stream index %u out of range.\n", stream_idx);
return WINED3DERR_INVALIDCALL;
}
- stream = &This->stateBlock->state.streams[StreamNumber];
- *pStream = (IWineD3DBuffer *)stream->buffer;
- *pStride = stream->stride;
- if (pOffset) *pOffset = stream->offset;
-
- if (*pStream) IWineD3DBuffer_AddRef(*pStream);
+ stream = &device->stateBlock->state.streams[stream_idx];
+ *buffer = stream->buffer;
+ if (*buffer)
+ wined3d_buffer_incref(*buffer);
+ if (offset)
+ *offset = stream->offset;
+ *stride = stream->stride;
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_SetStreamSourceFreq(IWineD3DDevice *iface, UINT StreamNumber, UINT Divider) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+HRESULT CDECL wined3d_device_set_stream_source_freq(struct wined3d_device *device, UINT stream_idx, UINT divider)
+{
struct wined3d_stream_state *stream;
- UINT oldFlags, oldFreq;
+ UINT old_flags, old_freq;
- TRACE("iface %p, stream_idx %u, divider %#x.\n", iface, StreamNumber, Divider);
+ TRACE("device %p, stream_idx %u, divider %#x.\n", device, stream_idx, divider);
- /* Verify input at least in d3d9 this is invalid. */
- if ((Divider & WINED3DSTREAMSOURCE_INSTANCEDATA) && (Divider & WINED3DSTREAMSOURCE_INDEXEDDATA))
+ /* Verify input. At least in d3d9 this is invalid. */
+ if ((divider & WINED3DSTREAMSOURCE_INSTANCEDATA) && (divider & WINED3DSTREAMSOURCE_INDEXEDDATA))
{
- WARN("INSTANCEDATA and INDEXEDDATA were set, returning D3DERR_INVALIDCALL\n");
+ WARN("INSTANCEDATA and INDEXEDDATA were set, returning D3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
- if ((Divider & WINED3DSTREAMSOURCE_INSTANCEDATA) && !StreamNumber)
+ if ((divider & WINED3DSTREAMSOURCE_INSTANCEDATA) && !stream_idx)
{
- WARN("INSTANCEDATA used on stream 0, returning D3DERR_INVALIDCALL\n");
+ WARN("INSTANCEDATA used on stream 0, returning D3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
- if (!Divider)
+ if (!divider)
{
- WARN("Divider is 0, returning D3DERR_INVALIDCALL\n");
+ WARN("Divider is 0, returning D3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
- stream = &This->updateStateBlock->state.streams[StreamNumber];
- oldFlags = stream->flags;
- oldFreq = stream->frequency;
+ stream = &device->updateStateBlock->state.streams[stream_idx];
+ old_flags = stream->flags;
+ old_freq = stream->frequency;
- stream->flags = Divider & (WINED3DSTREAMSOURCE_INSTANCEDATA | WINED3DSTREAMSOURCE_INDEXEDDATA);
- stream->frequency = Divider & 0x7FFFFF;
+ stream->flags = divider & (WINED3DSTREAMSOURCE_INSTANCEDATA | WINED3DSTREAMSOURCE_INDEXEDDATA);
+ stream->frequency = divider & 0x7fffff;
- This->updateStateBlock->changed.streamFreq |= 1 << StreamNumber;
+ device->updateStateBlock->changed.streamFreq |= 1 << stream_idx;
- if (stream->frequency != oldFreq || stream->flags != oldFlags)
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
+ if (stream->frequency != old_freq || stream->flags != old_flags)
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_STREAMSRC);
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetStreamSourceFreq(IWineD3DDevice *iface, UINT StreamNumber, UINT* Divider) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+HRESULT CDECL wined3d_device_get_stream_source_freq(struct wined3d_device *device, UINT stream_idx, UINT *divider)
+{
struct wined3d_stream_state *stream;
- TRACE("iface %p, stream_idx %u, divider %p.\n", iface, StreamNumber, Divider);
+ TRACE("device %p, stream_idx %u, divider %p.\n", device, stream_idx, divider);
- stream = &This->updateStateBlock->state.streams[StreamNumber];
- *Divider = stream->flags | stream->frequency;
+ stream = &device->updateStateBlock->state.streams[stream_idx];
+ *divider = stream->flags | stream->frequency;
- TRACE("Returning %#x.\n", *Divider);
+ TRACE("Returning %#x.\n", *divider);
return WINED3D_OK;
}
-/*****
- * Get / Set & Multiply Transform
- *****/
-static HRESULT WINAPI IWineD3DDeviceImpl_SetTransform(IWineD3DDevice *iface, WINED3DTRANSFORMSTATETYPE d3dts, CONST WINED3DMATRIX* lpmatrix) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+HRESULT CDECL wined3d_device_set_transform(struct wined3d_device *device,
+ WINED3DTRANSFORMSTATETYPE d3dts, const WINED3DMATRIX *matrix)
+{
+ TRACE("device %p, state %s, matrix %p.\n",
+ device, debug_d3dtstype(d3dts), matrix);
- /* Most of this routine, comments included copied from ddraw tree initially: */
- TRACE("(%p) : Transform State=%s\n", This, debug_d3dtstype(d3dts));
-
- /* Handle recording of state blocks */
- if (This->isRecordingState) {
- TRACE("Recording... not performing anything\n");
- This->updateStateBlock->changed.transform[d3dts >> 5] |= 1 << (d3dts & 0x1f);
- This->updateStateBlock->state.transforms[d3dts] = *lpmatrix;
+ /* Handle recording of state blocks. */
+ if (device->isRecordingState)
+ {
+ TRACE("Recording... not performing anything.\n");
+ device->updateStateBlock->changed.transform[d3dts >> 5] |= 1 << (d3dts & 0x1f);
+ device->updateStateBlock->state.transforms[d3dts] = *matrix;
return WINED3D_OK;
}
- /*
- * If the new matrix is the same as the current one,
+ /* If the new matrix is the same as the current one,
* we cut off any further processing. this seems to be a reasonable
* optimization because as was noticed, some apps (warcraft3 for example)
* tend towards setting the same matrix repeatedly for some reason.
*
- * From here on we assume that the new matrix is different, wherever it matters.
- */
- if (!memcmp(&This->stateBlock->state.transforms[d3dts].u.m[0][0], lpmatrix, sizeof(*lpmatrix)))
+ * From here on we assume that the new matrix is different, wherever it matters. */
+ if (!memcmp(&device->stateBlock->state.transforms[d3dts].u.m[0][0], matrix, sizeof(*matrix)))
{
- TRACE("The app is setting the same matrix over again\n");
+ TRACE("The application is setting the same matrix over again.\n");
return WINED3D_OK;
}
- else
- {
- conv_mat(lpmatrix, &This->stateBlock->state.transforms[d3dts].u.m[0][0]);
- }
- /*
- ScreenCoord = ProjectionMat * ViewMat * WorldMat * ObjectCoord
- where ViewMat = Camera space, WorldMat = world space.
+ conv_mat(matrix, &device->stateBlock->state.transforms[d3dts].u.m[0][0]);
- In OpenGL, camera and world space is combined into GL_MODELVIEW
- matrix. The Projection matrix stay projection matrix.
- */
+ /* ScreenCoord = ProjectionMat * ViewMat * WorldMat * ObjectCoord
+ * where ViewMat = Camera space, WorldMat = world space.
+ *
+ * In OpenGL, camera and world space is combined into GL_MODELVIEW
+ * matrix. The Projection matrix stay projection matrix. */
- /* Capture the times we can just ignore the change for now */
- if (d3dts == WINED3DTS_VIEW) { /* handle the VIEW matrix */
- This->view_ident = !memcmp(lpmatrix, identity, 16 * sizeof(float));
- /* Handled by the state manager */
- }
+ if (d3dts == WINED3DTS_VIEW)
+ device->view_ident = !memcmp(matrix, identity, 16 * sizeof(float));
- if (d3dts < WINED3DTS_WORLDMATRIX(This->adapter->gl_info.limits.blends))
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TRANSFORM(d3dts));
+ if (d3dts < WINED3DTS_WORLDMATRIX(device->adapter->gl_info.limits.blends))
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_TRANSFORM(d3dts));
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetTransform(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_get_transform(struct wined3d_device *device,
WINED3DTRANSFORMSTATETYPE state, WINED3DMATRIX *matrix)
{
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
-
- TRACE("iface %p, state %s, matrix %p.\n", iface, debug_d3dtstype(state), matrix);
+ TRACE("device %p, state %s, matrix %p.\n", device, debug_d3dtstype(state), matrix);
*matrix = device->stateBlock->state.transforms[state];
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_MultiplyTransform(IWineD3DDevice *iface, WINED3DTRANSFORMSTATETYPE State, CONST WINED3DMATRIX* pMatrix) {
+HRESULT CDECL wined3d_device_multiply_transform(struct wined3d_device *device,
+ WINED3DTRANSFORMSTATETYPE state, const WINED3DMATRIX *matrix)
+{
const WINED3DMATRIX *mat = NULL;
WINED3DMATRIX temp;
+ TRACE("device %p, state %s, matrix %p.\n", device, debug_d3dtstype(state), matrix);
+
/* Note: Using 'updateStateBlock' rather than 'stateblock' in the code
* below means it will be recorded in a state block change, but it
* works regardless where it is recorded.
- * If this is found to be wrong, change to StateBlock.
- */
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- TRACE("(%p) : For state %s\n", This, debug_d3dtstype(State));
+ * If this is found to be wrong, change to StateBlock. */
- if (State <= HIGHEST_TRANSFORMSTATE)
- {
- mat = &This->updateStateBlock->state.transforms[State];
- }
+ if (state <= HIGHEST_TRANSFORMSTATE)
+ mat = &device->updateStateBlock->state.transforms[state];
else
- {
- FIXME("Unhandled transform state!!\n");
- }
+ FIXME("Unhandled transform state %#x.\n", state);
- multiply_matrix(&temp, mat, pMatrix);
+ multiply_matrix(&temp, mat, matrix);
- /* Apply change via set transform - will reapply to eg. lights this way */
- return IWineD3DDeviceImpl_SetTransform(iface, State, &temp);
+ /* Apply change via set transform - will reapply to eg. lights this way. */
+ return wined3d_device_set_transform(device, state, &temp);
}
-/*****
- * Get / Set Light
- *****/
-/* Note lights are real special cases. Although the device caps state only eg. 8 are supported,
- you can reference any indexes you want as long as that number max are enabled at any
- one point in time! Therefore since the indexes can be anything, we need a hashmap of them.
- However, this causes stateblock problems. When capturing the state block, I duplicate the hashmap,
- but when recording, just build a chain pretty much of commands to be replayed. */
-
-static HRESULT WINAPI IWineD3DDeviceImpl_SetLight(IWineD3DDevice *iface, DWORD Index, CONST WINED3DLIGHT* pLight) {
- float rho;
+/* Note lights are real special cases. Although the device caps state only
+ * e.g. 8 are supported, you can reference any indexes you want as long as
+ * that number max are enabled at any one point in time. Therefore since the
+ * indices can be anything, we need a hashmap of them. However, this causes
+ * stateblock problems. When capturing the state block, I duplicate the
+ * hashmap, but when recording, just build a chain pretty much of commands to
+ * be replayed. */
+HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, UINT light_idx, const WINED3DLIGHT *light)
+{
+ UINT hash_idx = LIGHTMAP_HASHFUNC(light_idx);
struct wined3d_light_info *object = NULL;
- UINT Hi = LIGHTMAP_HASHFUNC(Index);
struct list *e;
+ float rho;
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- TRACE("(%p) : Idx(%d), pLight(%p). Hash index is %d\n", This, Index, pLight, Hi);
+ TRACE("device %p, light_idx %u, light %p.\n", device, light_idx, light);
- /* Check the parameter range. Need for speed most wanted sets junk lights which confuse
- * the gl driver.
- */
- if(!pLight) {
- WARN("Light pointer = NULL, returning WINED3DERR_INVALIDCALL\n");
+ /* Check the parameter range. Need for speed most wanted sets junk lights
+ * which confuse the GL driver. */
+ if (!light)
return WINED3DERR_INVALIDCALL;
- }
- switch(pLight->Type) {
+ switch (light->Type)
+ {
case WINED3DLIGHT_POINT:
case WINED3DLIGHT_SPOT:
case WINED3DLIGHT_PARALLELPOINT:
case WINED3DLIGHT_GLSPOT:
- /* Incorrect attenuation values can cause the gl driver to crash. Happens with Need for speed
- * most wanted
- */
- if (pLight->Attenuation0 < 0.0f || pLight->Attenuation1 < 0.0f || pLight->Attenuation2 < 0.0f)
+ /* Incorrect attenuation values can cause the gl driver to crash.
+ * Happens with Need for speed most wanted. */
+ if (light->Attenuation0 < 0.0f || light->Attenuation1 < 0.0f || light->Attenuation2 < 0.0f)
{
- WARN("Attenuation is negative, returning WINED3DERR_INVALIDCALL\n");
+ WARN("Attenuation is negative, returning WINED3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
break;
@@ -2557,882 +1929,902 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetLight(IWineD3DDevice *iface, DWORD I
return WINED3DERR_INVALIDCALL;
}
- LIST_FOR_EACH(e, &This->updateStateBlock->state.light_map[Hi])
+ LIST_FOR_EACH(e, &device->updateStateBlock->state.light_map[hash_idx])
{
object = LIST_ENTRY(e, struct wined3d_light_info, entry);
- if(object->OriginalIndex == Index) break;
+ if (object->OriginalIndex == light_idx)
+ break;
object = NULL;
}
- if(!object) {
+ if (!object)
+ {
TRACE("Adding new light\n");
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if(!object) {
+ if (!object)
+ {
ERR("Out of memory error when allocating a light\n");
return E_OUTOFMEMORY;
}
- list_add_head(&This->updateStateBlock->state.light_map[Hi], &object->entry);
+ list_add_head(&device->updateStateBlock->state.light_map[hash_idx], &object->entry);
object->glIndex = -1;
- object->OriginalIndex = Index;
+ object->OriginalIndex = light_idx;
}
- /* Initialize the object */
- TRACE("Light %d setting to type %d, Diffuse(%f,%f,%f,%f), Specular(%f,%f,%f,%f), Ambient(%f,%f,%f,%f)\n", Index, pLight->Type,
- pLight->Diffuse.r, pLight->Diffuse.g, pLight->Diffuse.b, pLight->Diffuse.a,
- pLight->Specular.r, pLight->Specular.g, pLight->Specular.b, pLight->Specular.a,
- pLight->Ambient.r, pLight->Ambient.g, pLight->Ambient.b, pLight->Ambient.a);
- TRACE("... Pos(%f,%f,%f), Dirn(%f,%f,%f)\n", pLight->Position.x, pLight->Position.y, pLight->Position.z,
- pLight->Direction.x, pLight->Direction.y, pLight->Direction.z);
- TRACE("... Range(%f), Falloff(%f), Theta(%f), Phi(%f)\n", pLight->Range, pLight->Falloff, pLight->Theta, pLight->Phi);
+ /* Initialize the object. */
+ TRACE("Light %d setting to type %d, Diffuse(%f,%f,%f,%f), Specular(%f,%f,%f,%f), Ambient(%f,%f,%f,%f)\n",
+ light_idx, light->Type,
+ light->Diffuse.r, light->Diffuse.g, light->Diffuse.b, light->Diffuse.a,
+ light->Specular.r, light->Specular.g, light->Specular.b, light->Specular.a,
+ light->Ambient.r, light->Ambient.g, light->Ambient.b, light->Ambient.a);
+ TRACE("... Pos(%f,%f,%f), Dir(%f,%f,%f)\n", light->Position.x, light->Position.y, light->Position.z,
+ light->Direction.x, light->Direction.y, light->Direction.z);
+ TRACE("... Range(%f), Falloff(%f), Theta(%f), Phi(%f)\n",
+ light->Range, light->Falloff, light->Theta, light->Phi);
- /* Save away the information */
- object->OriginalParms = *pLight;
+ /* Save away the information. */
+ object->OriginalParms = *light;
- switch (pLight->Type) {
- case WINED3DLIGHT_POINT:
- /* Position */
- object->lightPosn[0] = pLight->Position.x;
- object->lightPosn[1] = pLight->Position.y;
- object->lightPosn[2] = pLight->Position.z;
- object->lightPosn[3] = 1.0f;
- object->cutoff = 180.0f;
- /* FIXME: Range */
- break;
+ switch (light->Type)
+ {
+ case WINED3DLIGHT_POINT:
+ /* Position */
+ object->lightPosn[0] = light->Position.x;
+ object->lightPosn[1] = light->Position.y;
+ object->lightPosn[2] = light->Position.z;
+ object->lightPosn[3] = 1.0f;
+ object->cutoff = 180.0f;
+ /* FIXME: Range */
+ break;
- case WINED3DLIGHT_DIRECTIONAL:
- /* Direction */
- object->lightPosn[0] = -pLight->Direction.x;
- object->lightPosn[1] = -pLight->Direction.y;
- object->lightPosn[2] = -pLight->Direction.z;
- object->lightPosn[3] = 0.0f;
- object->exponent = 0.0f;
- object->cutoff = 180.0f;
- break;
-
- case WINED3DLIGHT_SPOT:
- /* Position */
- object->lightPosn[0] = pLight->Position.x;
- object->lightPosn[1] = pLight->Position.y;
- object->lightPosn[2] = pLight->Position.z;
- object->lightPosn[3] = 1.0f;
-
- /* Direction */
- object->lightDirn[0] = pLight->Direction.x;
- object->lightDirn[1] = pLight->Direction.y;
- object->lightDirn[2] = pLight->Direction.z;
- object->lightDirn[3] = 1.0f;
-
- /*
- * opengl-ish and d3d-ish spot lights use too different models for the
- * light "intensity" as a function of the angle towards the main light direction,
- * so we only can approximate very roughly.
- * however spot lights are rather rarely used in games (if ever used at all).
- * furthermore if still used, probably nobody pays attention to such details.
- */
- if (!pLight->Falloff)
- {
- /* Falloff = 0 is easy, because d3d's and opengl's spot light equations have the
- * falloff resp. exponent parameter as an exponent, so the spot light lighting
- * will always be 1.0 for both of them, and we don't have to care for the
- * rest of the rather complex calculation
- */
+ case WINED3DLIGHT_DIRECTIONAL:
+ /* Direction */
+ object->lightPosn[0] = -light->Direction.x;
+ object->lightPosn[1] = -light->Direction.y;
+ object->lightPosn[2] = -light->Direction.z;
+ object->lightPosn[3] = 0.0f;
object->exponent = 0.0f;
- } else {
- rho = pLight->Theta + (pLight->Phi - pLight->Theta)/(2*pLight->Falloff);
- if (rho < 0.0001f) rho = 0.0001f;
- object->exponent = -0.3f/logf(cosf(rho/2));
- }
- if (object->exponent > 128.0f)
- {
- object->exponent = 128.0f;
- }
- object->cutoff = (float) (pLight->Phi*90/M_PI);
+ object->cutoff = 180.0f;
+ break;
- /* FIXME: Range */
- break;
+ case WINED3DLIGHT_SPOT:
+ /* Position */
+ object->lightPosn[0] = light->Position.x;
+ object->lightPosn[1] = light->Position.y;
+ object->lightPosn[2] = light->Position.z;
+ object->lightPosn[3] = 1.0f;
- default:
- FIXME("Unrecognized light type %d\n", pLight->Type);
+ /* Direction */
+ object->lightDirn[0] = light->Direction.x;
+ object->lightDirn[1] = light->Direction.y;
+ object->lightDirn[2] = light->Direction.z;
+ object->lightDirn[3] = 1.0f;
+
+ /* opengl-ish and d3d-ish spot lights use too different models
+ * for the light "intensity" as a function of the angle towards
+ * the main light direction, so we only can approximate very
+ * roughly. However, spot lights are rather rarely used in games
+ * (if ever used at all). Furthermore if still used, probably
+ * nobody pays attention to such details. */
+ if (!light->Falloff)
+ {
+ /* Falloff = 0 is easy, because d3d's and opengl's spot light
+ * equations have the falloff resp. exponent parameter as an
+ * exponent, so the spot light lighting will always be 1.0 for
+ * both of them, and we don't have to care for the rest of the
+ * rather complex calculation. */
+ object->exponent = 0.0f;
+ }
+ else
+ {
+ rho = light->Theta + (light->Phi - light->Theta) / (2 * light->Falloff);
+ if (rho < 0.0001f)
+ rho = 0.0001f;
+ object->exponent = -0.3f / logf(cosf(rho / 2));
+ }
+
+ if (object->exponent > 128.0f)
+ object->exponent = 128.0f;
+
+ object->cutoff = (float)(light->Phi * 90 / M_PI);
+ /* FIXME: Range */
+ break;
+
+ default:
+ FIXME("Unrecognized light type %#x.\n", light->Type);
}
- /* Update the live definitions if the light is currently assigned a glIndex */
- if (object->glIndex != -1 && !This->isRecordingState) {
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_ACTIVELIGHT(object->glIndex));
- }
+ /* Update the live definitions if the light is currently assigned a glIndex. */
+ if (object->glIndex != -1 && !device->isRecordingState)
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_ACTIVELIGHT(object->glIndex));
+
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetLight(IWineD3DDevice *iface, DWORD Index, WINED3DLIGHT *pLight)
+HRESULT CDECL wined3d_device_get_light(struct wined3d_device *device, UINT light_idx, WINED3DLIGHT *light)
{
- struct wined3d_light_info *lightInfo = NULL;
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- DWORD Hi = LIGHTMAP_HASHFUNC(Index);
+ UINT hash_idx = LIGHTMAP_HASHFUNC(light_idx);
+ struct wined3d_light_info *light_info = NULL;
struct list *e;
- TRACE("(%p) : Idx(%d), pLight(%p)\n", This, Index, pLight);
- LIST_FOR_EACH(e, &This->stateBlock->state.light_map[Hi])
+ TRACE("device %p, light_idx %u, light %p.\n", device, light_idx, light);
+
+ LIST_FOR_EACH(e, &device->stateBlock->state.light_map[hash_idx])
{
- lightInfo = LIST_ENTRY(e, struct wined3d_light_info, entry);
- if(lightInfo->OriginalIndex == Index) break;
- lightInfo = NULL;
+ light_info = LIST_ENTRY(e, struct wined3d_light_info, entry);
+ if (light_info->OriginalIndex == light_idx)
+ break;
+ light_info = NULL;
}
- if (!lightInfo)
+ if (!light_info)
{
TRACE("Light information requested but light not defined\n");
return WINED3DERR_INVALIDCALL;
}
- *pLight = lightInfo->OriginalParms;
+ *light = light_info->OriginalParms;
return WINED3D_OK;
}
-/*****
- * Get / Set Light Enable
- * (Note for consistency, renamed d3dx function by adding the 'set' prefix)
- *****/
-static HRESULT WINAPI IWineD3DDeviceImpl_SetLightEnable(IWineD3DDevice *iface, DWORD Index, BOOL Enable)
+HRESULT CDECL wined3d_device_set_light_enable(struct wined3d_device *device, UINT light_idx, BOOL enable)
{
- struct wined3d_light_info *lightInfo = NULL;
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- UINT Hi = LIGHTMAP_HASHFUNC(Index);
+ UINT hash_idx = LIGHTMAP_HASHFUNC(light_idx);
+ struct wined3d_light_info *light_info = NULL;
struct list *e;
- TRACE("(%p) : Idx(%d), enable? %d\n", This, Index, Enable);
- LIST_FOR_EACH(e, &This->updateStateBlock->state.light_map[Hi])
+ TRACE("device %p, light_idx %u, enable %#x.\n", device, light_idx, enable);
+
+ LIST_FOR_EACH(e, &device->updateStateBlock->state.light_map[hash_idx])
{
- lightInfo = LIST_ENTRY(e, struct wined3d_light_info, entry);
- if(lightInfo->OriginalIndex == Index) break;
- lightInfo = NULL;
+ light_info = LIST_ENTRY(e, struct wined3d_light_info, entry);
+ if (light_info->OriginalIndex == light_idx)
+ break;
+ light_info = NULL;
}
- TRACE("Found light: %p\n", lightInfo);
+ TRACE("Found light %p.\n", light_info);
- /* Special case - enabling an undefined light creates one with a strict set of parms! */
- if (!lightInfo)
+ /* Special case - enabling an undefined light creates one with a strict set of parameters. */
+ if (!light_info)
{
TRACE("Light enabled requested but light not defined, so defining one!\n");
- IWineD3DDeviceImpl_SetLight(iface, Index, &WINED3D_default_light);
+ wined3d_device_set_light(device, light_idx, &WINED3D_default_light);
- /* Search for it again! Should be fairly quick as near head of list */
- LIST_FOR_EACH(e, &This->updateStateBlock->state.light_map[Hi])
+ /* Search for it again! Should be fairly quick as near head of list. */
+ LIST_FOR_EACH(e, &device->updateStateBlock->state.light_map[hash_idx])
{
- lightInfo = LIST_ENTRY(e, struct wined3d_light_info, entry);
- if(lightInfo->OriginalIndex == Index) break;
- lightInfo = NULL;
+ light_info = LIST_ENTRY(e, struct wined3d_light_info, entry);
+ if (light_info->OriginalIndex == light_idx)
+ break;
+ light_info = NULL;
}
- if (!lightInfo)
+ if (!light_info)
{
FIXME("Adding default lights has failed dismally\n");
return WINED3DERR_INVALIDCALL;
}
}
- if(!Enable) {
- if(lightInfo->glIndex != -1) {
- if(!This->isRecordingState) {
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_ACTIVELIGHT(lightInfo->glIndex));
- }
+ if (!enable)
+ {
+ if (light_info->glIndex != -1)
+ {
+ if (!device->isRecordingState)
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_ACTIVELIGHT(light_info->glIndex));
- This->updateStateBlock->state.lights[lightInfo->glIndex] = NULL;
- lightInfo->glIndex = -1;
- } else {
+ device->updateStateBlock->state.lights[light_info->glIndex] = NULL;
+ light_info->glIndex = -1;
+ }
+ else
+ {
TRACE("Light already disabled, nothing to do\n");
}
- lightInfo->enabled = FALSE;
- } else {
- lightInfo->enabled = TRUE;
- if (lightInfo->glIndex != -1) {
- /* nop */
+ light_info->enabled = FALSE;
+ }
+ else
+ {
+ light_info->enabled = TRUE;
+ if (light_info->glIndex != -1)
+ {
TRACE("Nothing to do as light was enabled\n");
- } else {
- int i;
- /* Find a free gl light */
- for (i = 0; i < This->maxConcurrentLights; ++i)
+ }
+ else
+ {
+ unsigned int i;
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+ /* Find a free GL light. */
+ for (i = 0; i < gl_info->limits.lights; ++i)
{
- if (!This->updateStateBlock->state.lights[i])
+ if (!device->updateStateBlock->state.lights[i])
{
- This->updateStateBlock->state.lights[i] = lightInfo;
- lightInfo->glIndex = i;
+ device->updateStateBlock->state.lights[i] = light_info;
+ light_info->glIndex = i;
break;
}
}
- if(lightInfo->glIndex == -1) {
+ if (light_info->glIndex == -1)
+ {
/* Our tests show that Windows returns D3D_OK in this situation, even with
* D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE devices. This
* is consistent among ddraw, d3d8 and d3d9. GetLightEnable returns TRUE
* as well for those lights.
*
- * TODO: Test how this affects rendering
- */
+ * TODO: Test how this affects rendering. */
WARN("Too many concurrently active lights\n");
return WINED3D_OK;
}
- /* i == lightInfo->glIndex */
- if(!This->isRecordingState) {
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_ACTIVELIGHT(i));
- }
+ /* i == light_info->glIndex */
+ if (!device->isRecordingState)
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_ACTIVELIGHT(i));
}
}
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetLightEnable(IWineD3DDevice *iface, DWORD Index,BOOL* pEnable)
+HRESULT CDECL wined3d_device_get_light_enable(struct wined3d_device *device, UINT light_idx, BOOL *enable)
{
- struct wined3d_light_info *lightInfo = NULL;
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+ UINT hash_idx = LIGHTMAP_HASHFUNC(light_idx);
+ struct wined3d_light_info *light_info = NULL;
struct list *e;
- UINT Hi = LIGHTMAP_HASHFUNC(Index);
- TRACE("(%p) : for idx(%d)\n", This, Index);
- LIST_FOR_EACH(e, &This->stateBlock->state.light_map[Hi])
+ TRACE("device %p, light_idx %u, enable %p.\n", device, light_idx, enable);
+
+ LIST_FOR_EACH(e, &device->stateBlock->state.light_map[hash_idx])
{
- lightInfo = LIST_ENTRY(e, struct wined3d_light_info, entry);
- if(lightInfo->OriginalIndex == Index) break;
- lightInfo = NULL;
+ light_info = LIST_ENTRY(e, struct wined3d_light_info, entry);
+ if (light_info->OriginalIndex == light_idx)
+ break;
+ light_info = NULL;
}
- if (!lightInfo)
+ if (!light_info)
{
- TRACE("Light enabled state requested but light not defined\n");
+ TRACE("Light enabled state requested but light not defined.\n");
return WINED3DERR_INVALIDCALL;
}
/* true is 128 according to SetLightEnable */
- *pEnable = lightInfo->enabled ? 128 : 0;
+ *enable = light_info->enabled ? 128 : 0;
return WINED3D_OK;
}
-/*****
- * Get / Set Clip Planes
- *****/
-static HRESULT WINAPI IWineD3DDeviceImpl_SetClipPlane(IWineD3DDevice *iface, DWORD Index, CONST float *pPlane) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- TRACE("(%p) : for idx %d, %p\n", This, Index, pPlane);
-
- /* Validate Index */
- if (Index >= This->adapter->gl_info.limits.clipplanes)
- {
- TRACE("Application has requested clipplane this device doesn't support\n");
- return WINED3DERR_INVALIDCALL;
- }
-
- This->updateStateBlock->changed.clipplane |= 1 << Index;
-
- if (This->updateStateBlock->state.clip_planes[Index][0] == pPlane[0]
- && This->updateStateBlock->state.clip_planes[Index][1] == pPlane[1]
- && This->updateStateBlock->state.clip_planes[Index][2] == pPlane[2]
- && This->updateStateBlock->state.clip_planes[Index][3] == pPlane[3])
- {
- TRACE("Application is setting old values over, nothing to do\n");
- return WINED3D_OK;
- }
-
- This->updateStateBlock->state.clip_planes[Index][0] = pPlane[0];
- This->updateStateBlock->state.clip_planes[Index][1] = pPlane[1];
- This->updateStateBlock->state.clip_planes[Index][2] = pPlane[2];
- This->updateStateBlock->state.clip_planes[Index][3] = pPlane[3];
-
- /* Handle recording of state blocks */
- if (This->isRecordingState) {
- TRACE("Recording... not performing anything\n");
- return WINED3D_OK;
- }
-
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_CLIPPLANE(Index));
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_GetClipPlane(IWineD3DDevice *iface, DWORD Index, float *pPlane) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- TRACE("(%p) : for idx %d\n", This, Index);
-
- /* Validate Index */
- if (Index >= This->adapter->gl_info.limits.clipplanes)
- {
- TRACE("Application has requested clipplane this device doesn't support\n");
- return WINED3DERR_INVALIDCALL;
- }
-
- pPlane[0] = (float)This->stateBlock->state.clip_planes[Index][0];
- pPlane[1] = (float)This->stateBlock->state.clip_planes[Index][1];
- pPlane[2] = (float)This->stateBlock->state.clip_planes[Index][2];
- pPlane[3] = (float)This->stateBlock->state.clip_planes[Index][3];
- return WINED3D_OK;
-}
-
-/*****
- * Get / Set Clip Plane Status
- * WARNING: This code relies on the fact that D3DCLIPSTATUS8 == D3DCLIPSTATUS9
- *****/
-static HRESULT WINAPI IWineD3DDeviceImpl_SetClipStatus(IWineD3DDevice *iface, CONST WINED3DCLIPSTATUS* pClipStatus) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- FIXME("(%p) : stub\n", This);
-
- if (!pClipStatus)
- return WINED3DERR_INVALIDCALL;
-
- This->updateStateBlock->state.clip_status.ClipUnion = pClipStatus->ClipUnion;
- This->updateStateBlock->state.clip_status.ClipIntersection = pClipStatus->ClipIntersection;
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_GetClipStatus(IWineD3DDevice *iface, WINED3DCLIPSTATUS* pClipStatus) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- FIXME("(%p) : stub\n", This);
-
- if (!pClipStatus)
- return WINED3DERR_INVALIDCALL;
-
- pClipStatus->ClipUnion = This->updateStateBlock->state.clip_status.ClipUnion;
- pClipStatus->ClipIntersection = This->updateStateBlock->state.clip_status.ClipIntersection;
- return WINED3D_OK;
-}
-
-/*****
- * Get / Set Material
- *****/
-static HRESULT WINAPI IWineD3DDeviceImpl_SetMaterial(IWineD3DDevice *iface, CONST WINED3DMATERIAL* pMaterial) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-
- This->updateStateBlock->changed.material = TRUE;
- This->updateStateBlock->state.material = *pMaterial;
-
- /* Handle recording of state blocks */
- if (This->isRecordingState) {
- TRACE("Recording... not performing anything\n");
- return WINED3D_OK;
- }
-
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_MATERIAL);
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_GetMaterial(IWineD3DDevice *iface, WINED3DMATERIAL* pMaterial) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- *pMaterial = This->updateStateBlock->state.material;
- TRACE("(%p) : Diffuse (%f,%f,%f,%f)\n", This, pMaterial->Diffuse.r, pMaterial->Diffuse.g,
- pMaterial->Diffuse.b, pMaterial->Diffuse.a);
- TRACE("(%p) : Ambient (%f,%f,%f,%f)\n", This, pMaterial->Ambient.r, pMaterial->Ambient.g,
- pMaterial->Ambient.b, pMaterial->Ambient.a);
- TRACE("(%p) : Specular (%f,%f,%f,%f)\n", This, pMaterial->Specular.r, pMaterial->Specular.g,
- pMaterial->Specular.b, pMaterial->Specular.a);
- TRACE("(%p) : Emissive (%f,%f,%f,%f)\n", This, pMaterial->Emissive.r, pMaterial->Emissive.g,
- pMaterial->Emissive.b, pMaterial->Emissive.a);
- TRACE("(%p) : Power (%f)\n", This, pMaterial->Power);
-
- return WINED3D_OK;
-}
-
-/*****
- * Get / Set Indices
- *****/
-static HRESULT WINAPI IWineD3DDeviceImpl_SetIndexBuffer(IWineD3DDevice *iface,
- IWineD3DBuffer *pIndexData, enum wined3d_format_id fmt)
+HRESULT CDECL wined3d_device_set_clip_plane(struct wined3d_device *device, UINT plane_idx, const float *plane)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DBuffer *oldIdxs;
+ TRACE("device %p, plane_idx %u, plane %p.\n", device, plane_idx, plane);
- TRACE("(%p) : Setting to %p\n", This, pIndexData);
- oldIdxs = (IWineD3DBuffer *)This->updateStateBlock->state.index_buffer;
+ /* Validate plane_idx. */
+ if (plane_idx >= device->adapter->gl_info.limits.clipplanes)
+ {
+ TRACE("Application has requested clipplane this device doesn't support.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
- This->updateStateBlock->changed.indices = TRUE;
- This->updateStateBlock->state.index_buffer = (struct wined3d_buffer *)pIndexData;
- This->updateStateBlock->state.index_format = fmt;
+ device->updateStateBlock->changed.clipplane |= 1 << plane_idx;
- /* Handle recording of state blocks */
- if (This->isRecordingState) {
- TRACE("Recording... not performing anything\n");
- if(pIndexData) IWineD3DBuffer_AddRef(pIndexData);
- if(oldIdxs) IWineD3DBuffer_Release(oldIdxs);
+ if (device->updateStateBlock->state.clip_planes[plane_idx][0] == plane[0]
+ && device->updateStateBlock->state.clip_planes[plane_idx][1] == plane[1]
+ && device->updateStateBlock->state.clip_planes[plane_idx][2] == plane[2]
+ && device->updateStateBlock->state.clip_planes[plane_idx][3] == plane[3])
+ {
+ TRACE("Application is setting old values over, nothing to do.\n");
return WINED3D_OK;
}
- if(oldIdxs != pIndexData) {
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
- if(pIndexData) {
- InterlockedIncrement(&((struct wined3d_buffer *)pIndexData)->bind_count);
- IWineD3DBuffer_AddRef(pIndexData);
+ device->updateStateBlock->state.clip_planes[plane_idx][0] = plane[0];
+ device->updateStateBlock->state.clip_planes[plane_idx][1] = plane[1];
+ device->updateStateBlock->state.clip_planes[plane_idx][2] = plane[2];
+ device->updateStateBlock->state.clip_planes[plane_idx][3] = plane[3];
+
+ /* Handle recording of state blocks. */
+ if (device->isRecordingState)
+ {
+ TRACE("Recording... not performing anything.\n");
+ return WINED3D_OK;
+ }
+
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_CLIPPLANE(plane_idx));
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_get_clip_plane(struct wined3d_device *device, UINT plane_idx, float *plane)
+{
+ TRACE("device %p, plane_idx %u, plane %p.\n", device, plane_idx, plane);
+
+ /* Validate plane_idx. */
+ if (plane_idx >= device->adapter->gl_info.limits.clipplanes)
+ {
+ TRACE("Application has requested clipplane this device doesn't support.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ plane[0] = (float)device->stateBlock->state.clip_planes[plane_idx][0];
+ plane[1] = (float)device->stateBlock->state.clip_planes[plane_idx][1];
+ plane[2] = (float)device->stateBlock->state.clip_planes[plane_idx][2];
+ plane[3] = (float)device->stateBlock->state.clip_planes[plane_idx][3];
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_set_clip_status(struct wined3d_device *device, const WINED3DCLIPSTATUS *clip_status)
+{
+ FIXME("device %p, clip_status %p stub!\n", device, clip_status);
+
+ if (!clip_status)
+ return WINED3DERR_INVALIDCALL;
+
+ device->updateStateBlock->state.clip_status.ClipUnion = clip_status->ClipUnion;
+ device->updateStateBlock->state.clip_status.ClipIntersection = clip_status->ClipIntersection;
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_get_clip_status(struct wined3d_device *device, WINED3DCLIPSTATUS *clip_status)
+{
+ FIXME("device %p, clip_status %p stub!\n", device, clip_status);
+
+ if (!clip_status)
+ return WINED3DERR_INVALIDCALL;
+
+ clip_status->ClipUnion = device->updateStateBlock->state.clip_status.ClipUnion;
+ clip_status->ClipIntersection = device->updateStateBlock->state.clip_status.ClipIntersection;
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_set_material(struct wined3d_device *device, const WINED3DMATERIAL *material)
+{
+ TRACE("device %p, material %p.\n", device, material);
+
+ device->updateStateBlock->changed.material = TRUE;
+ device->updateStateBlock->state.material = *material;
+
+ /* Handle recording of state blocks */
+ if (device->isRecordingState)
+ {
+ TRACE("Recording... not performing anything.\n");
+ return WINED3D_OK;
+ }
+
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_MATERIAL);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_get_material(struct wined3d_device *device, WINED3DMATERIAL *material)
+{
+ TRACE("device %p, material %p.\n", device, material);
+
+ *material = device->updateStateBlock->state.material;
+
+ TRACE("Diffuse {%.8e, %.8e, %.8e, %.8e}\n",
+ material->Diffuse.r, material->Diffuse.g,
+ material->Diffuse.b, material->Diffuse.a);
+ TRACE("Ambient {%.8e, %.8e, %.8e, %.8e}\n",
+ material->Ambient.r, material->Ambient.g,
+ material->Ambient.b, material->Ambient.a);
+ TRACE("Specular {%.8e, %.8e, %.8e, %.8e}\n",
+ material->Specular.r, material->Specular.g,
+ material->Specular.b, material->Specular.a);
+ TRACE("Emissive {%.8e, %.8e, %.8e, %.8e}\n",
+ material->Emissive.r, material->Emissive.g,
+ material->Emissive.b, material->Emissive.a);
+ TRACE("Power %.8e.\n", material->Power);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_set_index_buffer(struct wined3d_device *device,
+ struct wined3d_buffer *buffer, enum wined3d_format_id format_id)
+{
+ struct wined3d_buffer *prev_buffer;
+
+ TRACE("device %p, buffer %p, format %s.\n",
+ device, buffer, debug_d3dformat(format_id));
+
+ prev_buffer = device->updateStateBlock->state.index_buffer;
+
+ device->updateStateBlock->changed.indices = TRUE;
+ device->updateStateBlock->state.index_buffer = buffer;
+ device->updateStateBlock->state.index_format = format_id;
+
+ /* Handle recording of state blocks. */
+ if (device->isRecordingState)
+ {
+ TRACE("Recording... not performing anything.\n");
+ if (buffer)
+ wined3d_buffer_incref(buffer);
+ if (prev_buffer)
+ wined3d_buffer_decref(prev_buffer);
+ return WINED3D_OK;
+ }
+
+ if (prev_buffer != buffer)
+ {
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_INDEXBUFFER);
+ if (buffer)
+ {
+ InterlockedIncrement(&buffer->bind_count);
+ wined3d_buffer_incref(buffer);
}
- if(oldIdxs) {
- InterlockedDecrement(&((struct wined3d_buffer *)oldIdxs)->bind_count);
- IWineD3DBuffer_Release(oldIdxs);
+ if (prev_buffer)
+ {
+ InterlockedDecrement(&prev_buffer->bind_count);
+ wined3d_buffer_decref(prev_buffer);
}
}
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetIndexBuffer(IWineD3DDevice *iface, IWineD3DBuffer **ppIndexData)
+HRESULT CDECL wined3d_device_get_index_buffer(struct wined3d_device *device, struct wined3d_buffer **buffer)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+ TRACE("device %p, buffer %p.\n", device, buffer);
- *ppIndexData = (IWineD3DBuffer *)This->stateBlock->state.index_buffer;
+ *buffer = device->stateBlock->state.index_buffer;
- /* up ref count on ppindexdata */
- if (*ppIndexData) {
- IWineD3DBuffer_AddRef(*ppIndexData);
- TRACE("(%p) index data set to %p\n", This, ppIndexData);
- }else{
- TRACE("(%p) No index data set\n", This);
- }
- TRACE("Returning %p\n", *ppIndexData);
+ if (*buffer)
+ wined3d_buffer_incref(*buffer);
+
+ TRACE("Returning %p.\n", *buffer);
return WINED3D_OK;
}
/* Method to offer d3d9 a simple way to set the base vertex index without messing with the index buffer */
-static HRESULT WINAPI IWineD3DDeviceImpl_SetBaseVertexIndex(IWineD3DDevice *iface, INT BaseIndex) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- TRACE("(%p)->(%d)\n", This, BaseIndex);
+HRESULT CDECL wined3d_device_set_base_vertex_index(struct wined3d_device *device, INT base_index)
+{
+ TRACE("device %p, base_index %d.\n", device, base_index);
- if (This->updateStateBlock->state.base_vertex_index == BaseIndex)
+ if (device->updateStateBlock->state.base_vertex_index == base_index)
{
TRACE("Application is setting the old value over, nothing to do\n");
return WINED3D_OK;
}
- This->updateStateBlock->state.base_vertex_index = BaseIndex;
+ device->updateStateBlock->state.base_vertex_index = base_index;
- if (This->isRecordingState) {
+ if (device->isRecordingState)
+ {
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
+
/* The base vertex index affects the stream sources */
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_GetBaseVertexIndex(IWineD3DDevice *iface, INT* base_index) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- TRACE("(%p) : base_index %p\n", This, base_index);
-
- *base_index = This->stateBlock->state.base_vertex_index;
-
- TRACE("Returning %u\n", *base_index);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_STREAMSRC);
return WINED3D_OK;
}
-/*****
- * Get / Set Viewports
- *****/
-static HRESULT WINAPI IWineD3DDeviceImpl_SetViewport(IWineD3DDevice *iface, CONST WINED3DVIEWPORT* pViewport) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+INT CDECL wined3d_device_get_base_vertex_index(struct wined3d_device *device)
+{
+ TRACE("device %p.\n", device);
- TRACE("(%p)\n", This);
- This->updateStateBlock->changed.viewport = TRUE;
- This->updateStateBlock->state.viewport = *pViewport;
+ return device->stateBlock->state.base_vertex_index;
+}
+
+HRESULT CDECL wined3d_device_set_viewport(struct wined3d_device *device, const WINED3DVIEWPORT *viewport)
+{
+ TRACE("device %p, viewport %p.\n", device, viewport);
+ TRACE("x %u, y %u, w %u, h %u, minz %.8e, maxz %.8e.\n",
+ viewport->X, viewport->Y, viewport->Width, viewport->Height, viewport->MinZ, viewport->MaxZ);
+
+ device->updateStateBlock->changed.viewport = TRUE;
+ device->updateStateBlock->state.viewport = *viewport;
/* Handle recording of state blocks */
- if (This->isRecordingState) {
- TRACE("Recording... not performing anything\n");
- return WINED3D_OK;
- }
-
- TRACE("(%p) : x=%d, y=%d, wid=%d, hei=%d, minz=%f, maxz=%f\n", This,
- pViewport->X, pViewport->Y, pViewport->Width, pViewport->Height, pViewport->MinZ, pViewport->MaxZ);
-
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VIEWPORT);
- return WINED3D_OK;
-
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_GetViewport(IWineD3DDevice *iface, WINED3DVIEWPORT* pViewport) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- TRACE("(%p)\n", This);
- *pViewport = This->stateBlock->state.viewport;
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderState(IWineD3DDevice *iface,
- WINED3DRENDERSTATETYPE State, DWORD Value)
-{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- DWORD oldValue = This->stateBlock->state.render_states[State];
-
- TRACE("iface %p, state %s (%#x), value %#x.\n", iface, debug_d3drenderstate(State), State, Value);
-
- This->updateStateBlock->changed.renderState[State >> 5] |= 1 << (State & 0x1f);
- This->updateStateBlock->state.render_states[State] = Value;
-
- /* Handle recording of state blocks */
- if (This->isRecordingState) {
- TRACE("Recording... not performing anything\n");
- return WINED3D_OK;
- }
-
- /* Compared here and not before the assignment to allow proper stateblock recording */
- if(Value == oldValue) {
- TRACE("Application is setting the old value over, nothing to do\n");
- } else {
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(State));
- }
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_GetRenderState(IWineD3DDevice *iface,
- WINED3DRENDERSTATETYPE State, DWORD *pValue)
-{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-
- TRACE("iface %p, state %s (%#x), value %p.\n", iface, debug_d3drenderstate(State), State, pValue);
-
- *pValue = This->stateBlock->state.render_states[State];
- return WINED3D_OK;
-}
-
-/*****
- * Get / Set Sampler States
- * TODO: Verify against dx9 definitions
- *****/
-
-static HRESULT WINAPI IWineD3DDeviceImpl_SetSamplerState(IWineD3DDevice *iface, DWORD Sampler, WINED3DSAMPLERSTATETYPE Type, DWORD Value) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- DWORD oldValue;
-
- TRACE("(%p) : Sampler %#x, Type %s (%#x), Value %#x\n",
- This, Sampler, debug_d3dsamplerstate(Type), Type, Value);
-
- if (Sampler >= WINED3DVERTEXTEXTURESAMPLER0 && Sampler <= WINED3DVERTEXTEXTURESAMPLER3) {
- Sampler -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
- }
-
- if (Sampler >= sizeof(This->stateBlock->state.sampler_states) / sizeof(*This->stateBlock->state.sampler_states))
+ if (device->isRecordingState)
{
- ERR("Current Sampler overflows sampleState0 array (sampler %d)\n", Sampler);
+ TRACE("Recording... not performing anything\n");
+ return WINED3D_OK;
+ }
+
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_VIEWPORT);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_get_viewport(struct wined3d_device *device, WINED3DVIEWPORT *viewport)
+{
+ TRACE("device %p, viewport %p.\n", device, viewport);
+
+ *viewport = device->stateBlock->state.viewport;
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_set_render_state(struct wined3d_device *device,
+ WINED3DRENDERSTATETYPE state, DWORD value)
+{
+ DWORD old_value = device->stateBlock->state.render_states[state];
+
+ TRACE("device %p, state %s (%#x), value %#x.\n", device, debug_d3drenderstate(state), state, value);
+
+ device->updateStateBlock->changed.renderState[state >> 5] |= 1 << (state & 0x1f);
+ device->updateStateBlock->state.render_states[state] = value;
+
+ /* Handle recording of state blocks. */
+ if (device->isRecordingState)
+ {
+ TRACE("Recording... not performing anything.\n");
+ return WINED3D_OK;
+ }
+
+ /* Compared here and not before the assignment to allow proper stateblock recording. */
+ if (value == old_value)
+ TRACE("Application is setting the old value over, nothing to do.\n");
+ else
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(state));
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_get_render_state(struct wined3d_device *device,
+ WINED3DRENDERSTATETYPE state, DWORD *value)
+{
+ TRACE("device %p, state %s (%#x), value %p.\n", device, debug_d3drenderstate(state), state, value);
+
+ *value = device->stateBlock->state.render_states[state];
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_set_sampler_state(struct wined3d_device *device,
+ UINT sampler_idx, WINED3DSAMPLERSTATETYPE state, DWORD value)
+{
+ DWORD old_value;
+
+ TRACE("device %p, sampler_idx %u, state %s, value %#x.\n",
+ device, sampler_idx, debug_d3dsamplerstate(state), value);
+
+ if (sampler_idx >= WINED3DVERTEXTEXTURESAMPLER0 && sampler_idx <= WINED3DVERTEXTEXTURESAMPLER3)
+ sampler_idx -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
+
+ if (sampler_idx >= sizeof(device->stateBlock->state.sampler_states)
+ / sizeof(*device->stateBlock->state.sampler_states))
+ {
+ WARN("Invalid sampler %u.\n", sampler_idx);
return WINED3D_OK; /* Windows accepts overflowing this array ... we do not. */
}
- oldValue = This->stateBlock->state.sampler_states[Sampler][Type];
- This->updateStateBlock->state.sampler_states[Sampler][Type] = Value;
- This->updateStateBlock->changed.samplerState[Sampler] |= 1 << Type;
+ old_value = device->stateBlock->state.sampler_states[sampler_idx][state];
+ device->updateStateBlock->state.sampler_states[sampler_idx][state] = value;
+ device->updateStateBlock->changed.samplerState[sampler_idx] |= 1 << state;
- /* Handle recording of state blocks */
- if (This->isRecordingState) {
- TRACE("Recording... not performing anything\n");
+ /* Handle recording of state blocks. */
+ if (device->isRecordingState)
+ {
+ TRACE("Recording... not performing anything.\n");
return WINED3D_OK;
}
- if(oldValue == Value) {
- TRACE("Application is setting the old value over, nothing to do\n");
+ if (old_value == value)
+ {
+ TRACE("Application is setting the old value over, nothing to do.\n");
return WINED3D_OK;
}
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(Sampler));
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(sampler_idx));
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetSamplerState(IWineD3DDevice *iface, DWORD Sampler, WINED3DSAMPLERSTATETYPE Type, DWORD* Value) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+HRESULT CDECL wined3d_device_get_sampler_state(struct wined3d_device *device,
+ UINT sampler_idx, WINED3DSAMPLERSTATETYPE state, DWORD *value)
+{
+ TRACE("device %p, sampler_idx %u, state %s, value %p.\n",
+ device, sampler_idx, debug_d3dsamplerstate(state), value);
- TRACE("(%p) : Sampler %#x, Type %s (%#x)\n",
- This, Sampler, debug_d3dsamplerstate(Type), Type);
+ if (sampler_idx >= WINED3DVERTEXTEXTURESAMPLER0 && sampler_idx <= WINED3DVERTEXTEXTURESAMPLER3)
+ sampler_idx -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
- if (Sampler >= WINED3DVERTEXTEXTURESAMPLER0 && Sampler <= WINED3DVERTEXTEXTURESAMPLER3) {
- Sampler -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
- }
-
- if (Sampler >= sizeof(This->stateBlock->state.sampler_states) / sizeof(*This->stateBlock->state.sampler_states))
+ if (sampler_idx >= sizeof(device->stateBlock->state.sampler_states)
+ / sizeof(*device->stateBlock->state.sampler_states))
{
- ERR("Current Sampler overflows sampleState0 array (sampler %d)\n", Sampler);
+ WARN("Invalid sampler %u.\n", sampler_idx);
return WINED3D_OK; /* Windows accepts overflowing this array ... we do not. */
}
- *Value = This->stateBlock->state.sampler_states[Sampler][Type];
- TRACE("(%p) : Returning %#x\n", This, *Value);
+
+ *value = device->stateBlock->state.sampler_states[sampler_idx][state];
+ TRACE("Returning %#x.\n", *value);
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_SetScissorRect(IWineD3DDevice *iface, CONST RECT* pRect) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+HRESULT CDECL wined3d_device_set_scissor_rect(struct wined3d_device *device, const RECT *rect)
+{
+ TRACE("device %p, rect %s.\n", device, wine_dbgstr_rect(rect));
- This->updateStateBlock->changed.scissorRect = TRUE;
- if (EqualRect(&This->updateStateBlock->state.scissor_rect, pRect))
+ device->updateStateBlock->changed.scissorRect = TRUE;
+ if (EqualRect(&device->updateStateBlock->state.scissor_rect, rect))
{
TRACE("App is setting the old scissor rectangle over, nothing to do.\n");
return WINED3D_OK;
}
- CopyRect(&This->updateStateBlock->state.scissor_rect, pRect);
+ CopyRect(&device->updateStateBlock->state.scissor_rect, rect);
- if(This->isRecordingState) {
- TRACE("Recording... not performing anything\n");
+ if (device->isRecordingState)
+ {
+ TRACE("Recording... not performing anything.\n");
return WINED3D_OK;
}
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SCISSORRECT);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SCISSORRECT);
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetScissorRect(IWineD3DDevice *iface, RECT* pRect) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-
- *pRect = This->updateStateBlock->state.scissor_rect;
- TRACE("(%p)Returning a Scissor Rect of %d:%d-%d:%d\n", This, pRect->left, pRect->top, pRect->right, pRect->bottom);
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexDeclaration(IWineD3DDevice* iface, IWineD3DVertexDeclaration* pDecl) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
- IWineD3DVertexDeclaration *oldDecl = (IWineD3DVertexDeclaration *)This->updateStateBlock->state.vertex_declaration;
-
- TRACE("(%p) : pDecl=%p\n", This, pDecl);
-
- if (pDecl) IWineD3DVertexDeclaration_AddRef(pDecl);
- if (oldDecl) IWineD3DVertexDeclaration_Release(oldDecl);
-
- This->updateStateBlock->state.vertex_declaration = (IWineD3DVertexDeclarationImpl *)pDecl;
- This->updateStateBlock->changed.vertexDecl = TRUE;
-
- if (This->isRecordingState) {
- TRACE("Recording... not performing anything\n");
- return WINED3D_OK;
- } else if(pDecl == oldDecl) {
- /* Checked after the assignment to allow proper stateblock recording */
- TRACE("Application is setting the old declaration over, nothing to do\n");
- return WINED3D_OK;
- }
-
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexDeclaration(IWineD3DDevice* iface, IWineD3DVertexDeclaration** ppDecl) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-
- TRACE("(%p) : ppDecl=%p\n", This, ppDecl);
-
- *ppDecl = (IWineD3DVertexDeclaration *)This->stateBlock->state.vertex_declaration;
- if (*ppDecl) IWineD3DVertexDeclaration_AddRef(*ppDecl);
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShader(IWineD3DDevice *iface, IWineD3DVertexShader *pShader)
+HRESULT CDECL wined3d_device_get_scissor_rect(struct wined3d_device *device, RECT *rect)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DVertexShader *oldShader = (IWineD3DVertexShader *)This->updateStateBlock->state.vertex_shader;
+ TRACE("device %p, rect %p.\n", device, rect);
- This->updateStateBlock->state.vertex_shader = (IWineD3DVertexShaderImpl *)pShader;
- This->updateStateBlock->changed.vertexShader = TRUE;
-
- if (This->isRecordingState) {
- if(pShader) IWineD3DVertexShader_AddRef(pShader);
- if(oldShader) IWineD3DVertexShader_Release(oldShader);
- TRACE("Recording... not performing anything\n");
- return WINED3D_OK;
- } else if(oldShader == pShader) {
- /* Checked here to allow proper stateblock recording */
- TRACE("App is setting the old shader over, nothing to do\n");
- return WINED3D_OK;
- }
-
- TRACE("(%p) : setting pShader(%p)\n", This, pShader);
- if(pShader) IWineD3DVertexShader_AddRef(pShader);
- if(oldShader) IWineD3DVertexShader_Release(oldShader);
-
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VSHADER);
+ *rect = device->updateStateBlock->state.scissor_rect;
+ TRACE("Returning rect %s.\n", wine_dbgstr_rect(rect));
return WINED3D_OK;
}
-static IWineD3DVertexShader * WINAPI IWineD3DDeviceImpl_GetVertexShader(IWineD3DDevice *iface)
+HRESULT CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device,
+ struct wined3d_vertex_declaration *declaration)
{
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
- IWineD3DVertexShader *shader;
+ struct wined3d_vertex_declaration *prev = device->updateStateBlock->state.vertex_declaration;
- TRACE("iface %p.\n", iface);
+ TRACE("device %p, declaration %p.\n", device, declaration);
- shader = (IWineD3DVertexShader *)device->stateBlock->state.vertex_shader;
- if (shader) IWineD3DVertexShader_AddRef(shader);
+ if (declaration)
+ wined3d_vertex_declaration_incref(declaration);
+ if (prev)
+ wined3d_vertex_declaration_decref(prev);
+
+ device->updateStateBlock->state.vertex_declaration = declaration;
+ device->updateStateBlock->changed.vertexDecl = TRUE;
+
+ if (device->isRecordingState)
+ {
+ TRACE("Recording... not performing anything.\n");
+ return WINED3D_OK;
+ }
+ else if (declaration == prev)
+ {
+ /* Checked after the assignment to allow proper stateblock recording. */
+ TRACE("Application is setting the old declaration over, nothing to do.\n");
+ return WINED3D_OK;
+ }
+
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_VDECL);
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_get_vertex_declaration(struct wined3d_device *device,
+ struct wined3d_vertex_declaration **declaration)
+{
+ TRACE("device %p, declaration %p.\n", device, declaration);
+
+ *declaration = device->stateBlock->state.vertex_declaration;
+ if (*declaration)
+ wined3d_vertex_declaration_incref(*declaration);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader)
+{
+ struct wined3d_shader *prev = device->updateStateBlock->state.vertex_shader;
+
+ TRACE("device %p, shader %p.\n", device, shader);
+
+ device->updateStateBlock->state.vertex_shader = shader;
+ device->updateStateBlock->changed.vertexShader = TRUE;
+
+ if (device->isRecordingState)
+ {
+ if (shader)
+ wined3d_shader_incref(shader);
+ if (prev)
+ wined3d_shader_decref(prev);
+ TRACE("Recording... not performing anything.\n");
+ return WINED3D_OK;
+ }
+
+ if (shader == prev)
+ {
+ TRACE("Application is setting the old shader over, nothing to do.\n");
+ return WINED3D_OK;
+ }
+
+ if (shader)
+ wined3d_shader_incref(shader);
+ if (prev)
+ wined3d_shader_decref(prev);
+
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_VSHADER);
+
+ return WINED3D_OK;
+}
+
+struct wined3d_shader * CDECL wined3d_device_get_vertex_shader(struct wined3d_device *device)
+{
+ struct wined3d_shader *shader;
+
+ TRACE("device %p.\n", device);
+
+ shader = device->stateBlock->state.vertex_shader;
+ if (shader)
+ wined3d_shader_incref(shader);
TRACE("Returning %p.\n", shader);
return shader;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantB(
- IWineD3DDevice *iface,
- UINT start,
- CONST BOOL *srcData,
- UINT count) {
-
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- unsigned int i, cnt = min(count, MAX_CONST_B - start);
-
- TRACE("(iface %p, srcData %p, start %d, count %d)\n",
- iface, srcData, start, count);
-
- if (!srcData || start >= MAX_CONST_B) return WINED3DERR_INVALIDCALL;
-
- memcpy(&This->updateStateBlock->state.vs_consts_b[start], srcData, cnt * sizeof(BOOL));
- for (i = 0; i < cnt; i++)
- TRACE("Set BOOL constant %u to %s\n", start + i, srcData[i]? "true":"false");
-
- for (i = start; i < cnt + start; ++i) {
- This->updateStateBlock->changed.vertexShaderConstantsB |= (1 << i);
- }
-
- if (!This->isRecordingState) IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VERTEXSHADERCONSTANT);
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantB(
- IWineD3DDevice *iface,
- UINT start,
- BOOL *dstData,
- UINT count) {
-
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int cnt = min(count, MAX_CONST_B - start);
-
- TRACE("(iface %p, dstData %p, start %d, count %d)\n",
- iface, dstData, start, count);
-
- if (!dstData || cnt < 0)
- return WINED3DERR_INVALIDCALL;
-
- memcpy(dstData, &This->stateBlock->state.vs_consts_b[start], cnt * sizeof(BOOL));
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantI(
- IWineD3DDevice *iface,
- UINT start,
- CONST int *srcData,
- UINT count) {
-
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- unsigned int i, cnt = min(count, MAX_CONST_I - start);
-
- TRACE("(iface %p, srcData %p, start %d, count %d)\n",
- iface, srcData, start, count);
-
- if (!srcData || start >= MAX_CONST_I) return WINED3DERR_INVALIDCALL;
-
- memcpy(&This->updateStateBlock->state.vs_consts_i[start * 4], srcData, cnt * sizeof(int) * 4);
- for (i = 0; i < cnt; i++)
- TRACE("Set INT constant %u to { %d, %d, %d, %d }\n", start + i,
- srcData[i*4], srcData[i*4+1], srcData[i*4+2], srcData[i*4+3]);
-
- for (i = start; i < cnt + start; ++i) {
- This->updateStateBlock->changed.vertexShaderConstantsI |= (1 << i);
- }
-
- if (!This->isRecordingState) IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VERTEXSHADERCONSTANT);
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantI(
- IWineD3DDevice *iface,
- UINT start,
- int *dstData,
- UINT count) {
-
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int cnt = min(count, MAX_CONST_I - start);
-
- TRACE("(iface %p, dstData %p, start %d, count %d)\n",
- iface, dstData, start, count);
-
- if (!dstData || ((signed int)MAX_CONST_I - (signed int)start) <= 0)
- return WINED3DERR_INVALIDCALL;
-
- memcpy(dstData, &This->stateBlock->state.vs_consts_i[start * 4], cnt * sizeof(int) * 4);
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantF(
- IWineD3DDevice *iface,
- UINT start,
- CONST float *srcData,
- UINT count) {
-
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+HRESULT CDECL wined3d_device_set_vs_consts_b(struct wined3d_device *device,
+ UINT start_register, const BOOL *constants, UINT bool_count)
+{
+ UINT count = min(bool_count, MAX_CONST_B - start_register);
UINT i;
- TRACE("(iface %p, srcData %p, start %d, count %d)\n",
- iface, srcData, start, count);
+ TRACE("device %p, start_register %u, constants %p, bool_count %u.\n",
+ device, start_register, constants, bool_count);
- /* Specifically test start > limit to catch MAX_UINT overflows when adding start + count */
- if (!srcData || start + count > This->d3d_vshader_constantF || start > This->d3d_vshader_constantF)
+ if (!constants || start_register >= MAX_CONST_B)
return WINED3DERR_INVALIDCALL;
- memcpy(&This->updateStateBlock->state.vs_consts_f[start * 4], srcData, count * sizeof(float) * 4);
- if(TRACE_ON(d3d)) {
- for (i = 0; i < count; i++)
- TRACE("Set FLOAT constant %u to { %f, %f, %f, %f }\n", start + i,
- srcData[i*4], srcData[i*4+1], srcData[i*4+2], srcData[i*4+3]);
- }
+ memcpy(&device->updateStateBlock->state.vs_consts_b[start_register], constants, count * sizeof(BOOL));
+ for (i = 0; i < count; ++i)
+ TRACE("Set BOOL constant %u to %s.\n", start_register + i, constants[i] ? "true" : "false");
- if (!This->isRecordingState)
- {
- This->shader_backend->shader_update_float_vertex_constants(iface, start, count);
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VERTEXSHADERCONSTANT);
- }
+ for (i = start_register; i < count + start_register; ++i)
+ device->updateStateBlock->changed.vertexShaderConstantsB |= (1 << i);
- memset(This->updateStateBlock->changed.vertexShaderConstantsF + start, 1,
- sizeof(*This->updateStateBlock->changed.vertexShaderConstantsF) * count);
+ if (!device->isRecordingState)
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_VERTEXSHADERCONSTANT);
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantF(
- IWineD3DDevice *iface,
- UINT start,
- float *dstData,
- UINT count) {
-
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int cnt = min(count, This->d3d_vshader_constantF - start);
-
- TRACE("(iface %p, dstData %p, start %d, count %d)\n",
- iface, dstData, start, count);
-
- if (!dstData || cnt < 0)
- return WINED3DERR_INVALIDCALL;
-
- memcpy(dstData, &This->stateBlock->state.vs_consts_f[start * 4], cnt * sizeof(float) * 4);
- return WINED3D_OK;
-}
-
-static inline void markTextureStagesDirty(IWineD3DDeviceImpl *This, DWORD stage) {
- DWORD i;
- for(i = 0; i <= WINED3D_HIGHEST_TEXTURE_STATE; ++i)
- {
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, i));
- }
-}
-
-static void device_map_stage(IWineD3DDeviceImpl *This, DWORD stage, DWORD unit)
+HRESULT CDECL wined3d_device_get_vs_consts_b(struct wined3d_device *device,
+ UINT start_register, BOOL *constants, UINT bool_count)
{
- DWORD i = This->rev_tex_unit_map[unit];
- DWORD j = This->texUnitMap[stage];
+ UINT count = min(bool_count, MAX_CONST_B - start_register);
- This->texUnitMap[stage] = unit;
- if (i != WINED3D_UNMAPPED_STAGE && i != stage)
+ TRACE("device %p, start_register %u, constants %p, bool_count %u.\n",
+ device, start_register, constants, bool_count);
+
+ if (!constants || start_register >= MAX_CONST_B)
+ return WINED3DERR_INVALIDCALL;
+
+ memcpy(constants, &device->stateBlock->state.vs_consts_b[start_register], count * sizeof(BOOL));
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_set_vs_consts_i(struct wined3d_device *device,
+ UINT start_register, const int *constants, UINT vector4i_count)
+{
+ UINT count = min(vector4i_count, MAX_CONST_I - start_register);
+ UINT i;
+
+ TRACE("device %p, start_register %u, constants %p, vector4i_count %u.\n",
+ device, start_register, constants, vector4i_count);
+
+ if (!constants || start_register >= MAX_CONST_I)
+ return WINED3DERR_INVALIDCALL;
+
+ memcpy(&device->updateStateBlock->state.vs_consts_i[start_register * 4], constants, count * sizeof(int) * 4);
+ for (i = 0; i < count; ++i)
+ TRACE("Set INT constant %u to {%d, %d, %d, %d}.\n", start_register + i,
+ constants[i * 4], constants[i * 4 + 1],
+ constants[i * 4 + 2], constants[i * 4 + 3]);
+
+ for (i = start_register; i < count + start_register; ++i)
+ device->updateStateBlock->changed.vertexShaderConstantsI |= (1 << i);
+
+ if (!device->isRecordingState)
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_VERTEXSHADERCONSTANT);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_get_vs_consts_i(struct wined3d_device *device,
+ UINT start_register, int *constants, UINT vector4i_count)
+{
+ UINT count = min(vector4i_count, MAX_CONST_I - start_register);
+
+ TRACE("device %p, start_register %u, constants %p, vector4i_count %u.\n",
+ device, start_register, constants, vector4i_count);
+
+ if (!constants || start_register >= MAX_CONST_I)
+ return WINED3DERR_INVALIDCALL;
+
+ memcpy(constants, &device->stateBlock->state.vs_consts_i[start_register * 4], count * sizeof(int) * 4);
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_set_vs_consts_f(struct wined3d_device *device,
+ UINT start_register, const float *constants, UINT vector4f_count)
+{
+ UINT i;
+
+ TRACE("device %p, start_register %u, constants %p, vector4f_count %u.\n",
+ device, start_register, constants, vector4f_count);
+
+ /* Specifically test start_register > limit to catch MAX_UINT overflows
+ * when adding start_register + vector4f_count. */
+ if (!constants
+ || start_register + vector4f_count > device->d3d_vshader_constantF
+ || start_register > device->d3d_vshader_constantF)
+ return WINED3DERR_INVALIDCALL;
+
+ memcpy(&device->updateStateBlock->state.vs_consts_f[start_register * 4],
+ constants, vector4f_count * sizeof(float) * 4);
+ if (TRACE_ON(d3d))
{
- This->texUnitMap[i] = WINED3D_UNMAPPED_STAGE;
+ for (i = 0; i < vector4f_count; ++i)
+ TRACE("Set FLOAT constant %u to {%.8e, %.8e, %.8e, %.8e}.\n", start_register + i,
+ constants[i * 4], constants[i * 4 + 1],
+ constants[i * 4 + 2], constants[i * 4 + 3]);
}
- This->rev_tex_unit_map[unit] = stage;
- if (j != WINED3D_UNMAPPED_STAGE && j != unit)
+ if (!device->isRecordingState)
{
- This->rev_tex_unit_map[j] = WINED3D_UNMAPPED_STAGE;
+ device->shader_backend->shader_update_float_vertex_constants(device, start_register, vector4f_count);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_VERTEXSHADERCONSTANT);
+ }
+
+ memset(device->updateStateBlock->changed.vertexShaderConstantsF + start_register, 1,
+ sizeof(*device->updateStateBlock->changed.vertexShaderConstantsF) * vector4f_count);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_get_vs_consts_f(struct wined3d_device *device,
+ UINT start_register, float *constants, UINT vector4f_count)
+{
+ int count = min(vector4f_count, device->d3d_vshader_constantF - start_register);
+
+ TRACE("device %p, start_register %u, constants %p, vector4f_count %u.\n",
+ device, start_register, constants, vector4f_count);
+
+ if (!constants || count < 0)
+ return WINED3DERR_INVALIDCALL;
+
+ memcpy(constants, &device->stateBlock->state.vs_consts_f[start_register * 4], count * sizeof(float) * 4);
+
+ return WINED3D_OK;
+}
+
+static inline void markTextureStagesDirty(struct wined3d_device *device, DWORD stage)
+{
+ DWORD i;
+
+ for (i = 0; i <= WINED3D_HIGHEST_TEXTURE_STATE; ++i)
+ {
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_TEXTURESTAGE(stage, i));
}
}
-static void device_update_fixed_function_usage_map(IWineD3DDeviceImpl *This) {
- int i;
+static void device_map_stage(struct wined3d_device *device, DWORD stage, DWORD unit)
+{
+ DWORD i = device->rev_tex_unit_map[unit];
+ DWORD j = device->texUnitMap[stage];
- This->fixed_function_usage_map = 0;
+ device->texUnitMap[stage] = unit;
+ if (i != WINED3D_UNMAPPED_STAGE && i != stage)
+ device->texUnitMap[i] = WINED3D_UNMAPPED_STAGE;
+
+ device->rev_tex_unit_map[unit] = stage;
+ if (j != WINED3D_UNMAPPED_STAGE && j != unit)
+ device->rev_tex_unit_map[j] = WINED3D_UNMAPPED_STAGE;
+}
+
+static void device_update_fixed_function_usage_map(struct wined3d_device *device)
+{
+ UINT i;
+
+ device->fixed_function_usage_map = 0;
for (i = 0; i < MAX_TEXTURES; ++i)
{
- const struct wined3d_state *state = &This->stateBlock->state;
+ const struct wined3d_state *state = &device->stateBlock->state;
WINED3DTEXTUREOP color_op = state->texture_states[i][WINED3DTSS_COLOROP];
WINED3DTEXTUREOP alpha_op = state->texture_states[i][WINED3DTSS_ALPHAOP];
DWORD color_arg1 = state->texture_states[i][WINED3DTSS_COLORARG1] & WINED3DTA_SELECTMASK;
@@ -3449,38 +2841,39 @@ static void device_update_fixed_function_usage_map(IWineD3DDeviceImpl *This) {
if (((color_arg1 == WINED3DTA_TEXTURE) && color_op != WINED3DTOP_SELECTARG2)
|| ((color_arg2 == WINED3DTA_TEXTURE) && color_op != WINED3DTOP_SELECTARG1)
- || ((color_arg3 == WINED3DTA_TEXTURE) && (color_op == WINED3DTOP_MULTIPLYADD || color_op == WINED3DTOP_LERP))
+ || ((color_arg3 == WINED3DTA_TEXTURE)
+ && (color_op == WINED3DTOP_MULTIPLYADD || color_op == WINED3DTOP_LERP))
|| ((alpha_arg1 == WINED3DTA_TEXTURE) && alpha_op != WINED3DTOP_SELECTARG2)
|| ((alpha_arg2 == WINED3DTA_TEXTURE) && alpha_op != WINED3DTOP_SELECTARG1)
- || ((alpha_arg3 == WINED3DTA_TEXTURE) && (alpha_op == WINED3DTOP_MULTIPLYADD || alpha_op == WINED3DTOP_LERP))) {
- This->fixed_function_usage_map |= (1 << i);
- }
+ || ((alpha_arg3 == WINED3DTA_TEXTURE)
+ && (alpha_op == WINED3DTOP_MULTIPLYADD || alpha_op == WINED3DTOP_LERP)))
+ device->fixed_function_usage_map |= (1 << i);
- if ((color_op == WINED3DTOP_BUMPENVMAP || color_op == WINED3DTOP_BUMPENVMAPLUMINANCE) && i < MAX_TEXTURES - 1) {
- This->fixed_function_usage_map |= (1 << (i + 1));
- }
+ if ((color_op == WINED3DTOP_BUMPENVMAP || color_op == WINED3DTOP_BUMPENVMAPLUMINANCE) && i < MAX_TEXTURES - 1)
+ device->fixed_function_usage_map |= (1 << (i + 1));
}
}
-static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This, const struct wined3d_gl_info *gl_info)
+static void device_map_fixed_function_samplers(struct wined3d_device *device, const struct wined3d_gl_info *gl_info)
{
unsigned int i, tex;
WORD ffu_map;
- device_update_fixed_function_usage_map(This);
- ffu_map = This->fixed_function_usage_map;
+ device_update_fixed_function_usage_map(device);
+ ffu_map = device->fixed_function_usage_map;
- if (This->max_ffp_textures == gl_info->limits.texture_stages
- || This->stateBlock->state.lowest_disabled_stage <= This->max_ffp_textures)
+ if (device->max_ffp_textures == gl_info->limits.texture_stages
+ || device->stateBlock->state.lowest_disabled_stage <= device->max_ffp_textures)
{
for (i = 0; ffu_map; ffu_map >>= 1, ++i)
{
if (!(ffu_map & 1)) continue;
- if (This->texUnitMap[i] != i) {
- device_map_stage(This, i, i);
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i));
- markTextureStagesDirty(This, i);
+ if (device->texUnitMap[i] != i)
+ {
+ device_map_stage(device, i, i);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(i));
+ markTextureStagesDirty(device, i);
}
}
return;
@@ -3492,39 +2885,42 @@ static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This, const s
{
if (!(ffu_map & 1)) continue;
- if (This->texUnitMap[i] != tex) {
- device_map_stage(This, i, tex);
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i));
- markTextureStagesDirty(This, i);
+ if (device->texUnitMap[i] != tex)
+ {
+ device_map_stage(device, i, tex);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(i));
+ markTextureStagesDirty(device, i);
}
++tex;
}
}
-static void device_map_psamplers(IWineD3DDeviceImpl *This, const struct wined3d_gl_info *gl_info)
+static void device_map_psamplers(struct wined3d_device *device, const struct wined3d_gl_info *gl_info)
{
const WINED3DSAMPLER_TEXTURE_TYPE *sampler_type =
- This->stateBlock->state.pixel_shader->baseShader.reg_maps.sampler_type;
+ device->stateBlock->state.pixel_shader->reg_maps.sampler_type;
unsigned int i;
- for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i) {
- if (sampler_type[i] && This->texUnitMap[i] != i)
+ for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
+ {
+ if (sampler_type[i] && device->texUnitMap[i] != i)
{
- device_map_stage(This, i, i);
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i));
+ device_map_stage(device, i, i);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(i));
if (i < gl_info->limits.texture_stages)
{
- markTextureStagesDirty(This, i);
+ markTextureStagesDirty(device, i);
}
}
}
}
-static BOOL device_unit_free_for_vs(IWineD3DDeviceImpl *This, const WINED3DSAMPLER_TEXTURE_TYPE *pshader_sampler_tokens,
+static BOOL device_unit_free_for_vs(struct wined3d_device *device,
+ const WINED3DSAMPLER_TEXTURE_TYPE *pshader_sampler_tokens,
const WINED3DSAMPLER_TEXTURE_TYPE *vshader_sampler_tokens, DWORD unit)
{
- DWORD current_mapping = This->rev_tex_unit_map[unit];
+ DWORD current_mapping = device->rev_tex_unit_map[unit];
/* Not currently used */
if (current_mapping == WINED3D_UNMAPPED_STAGE) return TRUE;
@@ -3534,7 +2930,7 @@ static BOOL device_unit_free_for_vs(IWineD3DDeviceImpl *This, const WINED3DSAMPL
if (!pshader_sampler_tokens) {
/* No pixel shader, check fixed function */
- return current_mapping >= MAX_TEXTURES || !(This->fixed_function_usage_map & (1 << current_mapping));
+ return current_mapping >= MAX_TEXTURES || !(device->fixed_function_usage_map & (1 << current_mapping));
}
/* Pixel shader, check the shader's sampler map */
@@ -3545,38 +2941,37 @@ static BOOL device_unit_free_for_vs(IWineD3DDeviceImpl *This, const WINED3DSAMPL
return !vshader_sampler_tokens[current_mapping - MAX_FRAGMENT_SAMPLERS];
}
-static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps, const struct wined3d_gl_info *gl_info)
+static void device_map_vsamplers(struct wined3d_device *device, BOOL ps, const struct wined3d_gl_info *gl_info)
{
const WINED3DSAMPLER_TEXTURE_TYPE *vshader_sampler_type =
- This->stateBlock->state.vertex_shader->baseShader.reg_maps.sampler_type;
+ device->stateBlock->state.vertex_shader->reg_maps.sampler_type;
const WINED3DSAMPLER_TEXTURE_TYPE *pshader_sampler_type = NULL;
int start = min(MAX_COMBINED_SAMPLERS, gl_info->limits.combined_samplers) - 1;
int i;
if (ps)
{
- IWineD3DPixelShaderImpl *pshader = This->stateBlock->state.pixel_shader;
-
/* Note that we only care if a sampler is sampled or not, not the sampler's specific type.
* Otherwise we'd need to call shader_update_samplers() here for 1.x pixelshaders. */
- pshader_sampler_type = pshader->baseShader.reg_maps.sampler_type;
+ pshader_sampler_type = device->stateBlock->state.pixel_shader->reg_maps.sampler_type;
}
for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i) {
DWORD vsampler_idx = i + MAX_FRAGMENT_SAMPLERS;
if (vshader_sampler_type[i])
{
- if (This->texUnitMap[vsampler_idx] != WINED3D_UNMAPPED_STAGE)
+ if (device->texUnitMap[vsampler_idx] != WINED3D_UNMAPPED_STAGE)
{
/* Already mapped somewhere */
continue;
}
- while (start >= 0) {
- if (device_unit_free_for_vs(This, pshader_sampler_type, vshader_sampler_type, start))
+ while (start >= 0)
+ {
+ if (device_unit_free_for_vs(device, pshader_sampler_type, vshader_sampler_type, start))
{
- device_map_stage(This, vsampler_idx, start);
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(vsampler_idx));
+ device_map_stage(device, vsampler_idx, start);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(vsampler_idx));
--start;
break;
@@ -3588,10 +2983,10 @@ static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps, const struct
}
}
-void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This)
+void device_update_tex_unit_map(struct wined3d_device *device)
{
- const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
- const struct wined3d_state *state = &This->stateBlock->state;
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+ const struct wined3d_state *state = &device->stateBlock->state;
BOOL vs = use_vs(state);
BOOL ps = use_ps(state);
/*
@@ -3601,214 +2996,209 @@ void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This)
* -> When the mapping of a stage is changed, sampler and ALL texture stage states have
* to be reset. Because of that try to work with a 1:1 mapping as much as possible
*/
- if (ps) device_map_psamplers(This, gl_info);
- else device_map_fixed_function_samplers(This, gl_info);
+ if (ps)
+ device_map_psamplers(device, gl_info);
+ else
+ device_map_fixed_function_samplers(device, gl_info);
- if (vs) device_map_vsamplers(This, ps, gl_info);
+ if (vs)
+ device_map_vsamplers(device, ps, gl_info);
}
-static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShader(IWineD3DDevice *iface, IWineD3DPixelShader *pShader)
+HRESULT CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct wined3d_shader *shader)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DPixelShader *oldShader = (IWineD3DPixelShader *)This->updateStateBlock->state.pixel_shader;
- This->updateStateBlock->state.pixel_shader = (IWineD3DPixelShaderImpl *)pShader;
- This->updateStateBlock->changed.pixelShader = TRUE;
+ struct wined3d_shader *prev = device->updateStateBlock->state.pixel_shader;
- /* Handle recording of state blocks */
- if (This->isRecordingState) {
- TRACE("Recording... not performing anything\n");
- }
+ TRACE("device %p, shader %p.\n", device, shader);
- if (This->isRecordingState) {
- TRACE("Recording... not performing anything\n");
- if(pShader) IWineD3DPixelShader_AddRef(pShader);
- if(oldShader) IWineD3DPixelShader_Release(oldShader);
+ device->updateStateBlock->state.pixel_shader = shader;
+ device->updateStateBlock->changed.pixelShader = TRUE;
+
+ if (device->isRecordingState)
+ {
+ if (shader)
+ wined3d_shader_incref(shader);
+ if (prev)
+ wined3d_shader_decref(prev);
+ TRACE("Recording... not performing anything.\n");
return WINED3D_OK;
}
- if(pShader == oldShader) {
- TRACE("App is setting the old pixel shader over, nothing to do\n");
+ if (shader == prev)
+ {
+ TRACE("Application is setting the old shader over, nothing to do.\n");
return WINED3D_OK;
}
- if(pShader) IWineD3DPixelShader_AddRef(pShader);
- if(oldShader) IWineD3DPixelShader_Release(oldShader);
+ if (shader)
+ wined3d_shader_incref(shader);
+ if (prev)
+ wined3d_shader_decref(prev);
- TRACE("(%p) : setting pShader(%p)\n", This, pShader);
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADER);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_PIXELSHADER);
return WINED3D_OK;
}
-static IWineD3DPixelShader * WINAPI IWineD3DDeviceImpl_GetPixelShader(IWineD3DDevice *iface)
+struct wined3d_shader * CDECL wined3d_device_get_pixel_shader(struct wined3d_device *device)
{
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
- IWineD3DPixelShader *shader;
+ struct wined3d_shader *shader;
- TRACE("iface %p.\n", iface);
+ TRACE("device %p.\n", device);
- shader = (IWineD3DPixelShader *)device->stateBlock->state.pixel_shader;
- if (shader) IWineD3DPixelShader_AddRef(shader);
+ shader = device->stateBlock->state.pixel_shader;
+ if (shader)
+ wined3d_shader_incref(shader);
TRACE("Returning %p.\n", shader);
return shader;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantB(
- IWineD3DDevice *iface,
- UINT start,
- CONST BOOL *srcData,
- UINT count) {
-
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- unsigned int i, cnt = min(count, MAX_CONST_B - start);
-
- TRACE("(iface %p, srcData %p, start %u, count %u)\n",
- iface, srcData, start, count);
-
- if (!srcData || start >= MAX_CONST_B) return WINED3DERR_INVALIDCALL;
-
- memcpy(&This->updateStateBlock->state.ps_consts_b[start], srcData, cnt * sizeof(BOOL));
- for (i = 0; i < cnt; i++)
- TRACE("Set BOOL constant %u to %s\n", start + i, srcData[i]? "true":"false");
-
- for (i = start; i < cnt + start; ++i) {
- This->updateStateBlock->changed.pixelShaderConstantsB |= (1 << i);
- }
-
- if (!This->isRecordingState) IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADERCONSTANT);
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantB(
- IWineD3DDevice *iface,
- UINT start,
- BOOL *dstData,
- UINT count) {
-
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int cnt = min(count, MAX_CONST_B - start);
-
- TRACE("(iface %p, dstData %p, start %d, count %d)\n",
- iface, dstData, start, count);
-
- if (!dstData || cnt < 0)
- return WINED3DERR_INVALIDCALL;
-
- memcpy(dstData, &This->stateBlock->state.ps_consts_b[start], cnt * sizeof(BOOL));
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantI(
- IWineD3DDevice *iface,
- UINT start,
- CONST int *srcData,
- UINT count) {
-
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- unsigned int i, cnt = min(count, MAX_CONST_I - start);
-
- TRACE("(iface %p, srcData %p, start %u, count %u)\n",
- iface, srcData, start, count);
-
- if (!srcData || start >= MAX_CONST_I) return WINED3DERR_INVALIDCALL;
-
- memcpy(&This->updateStateBlock->state.ps_consts_i[start * 4], srcData, cnt * sizeof(int) * 4);
- for (i = 0; i < cnt; i++)
- TRACE("Set INT constant %u to { %d, %d, %d, %d }\n", start + i,
- srcData[i*4], srcData[i*4+1], srcData[i*4+2], srcData[i*4+3]);
-
- for (i = start; i < cnt + start; ++i) {
- This->updateStateBlock->changed.pixelShaderConstantsI |= (1 << i);
- }
-
- if (!This->isRecordingState) IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADERCONSTANT);
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantI(
- IWineD3DDevice *iface,
- UINT start,
- int *dstData,
- UINT count) {
-
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int cnt = min(count, MAX_CONST_I - start);
-
- TRACE("(iface %p, dstData %p, start %d, count %d)\n",
- iface, dstData, start, count);
-
- if (!dstData || cnt < 0)
- return WINED3DERR_INVALIDCALL;
-
- memcpy(dstData, &This->stateBlock->state.ps_consts_i[start * 4], cnt * sizeof(int) * 4);
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantF(
- IWineD3DDevice *iface,
- UINT start,
- CONST float *srcData,
- UINT count) {
-
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+HRESULT CDECL wined3d_device_set_ps_consts_b(struct wined3d_device *device,
+ UINT start_register, const BOOL *constants, UINT bool_count)
+{
+ UINT count = min(bool_count, MAX_CONST_B - start_register);
UINT i;
- TRACE("(iface %p, srcData %p, start %d, count %d)\n",
- iface, srcData, start, count);
+ TRACE("device %p, start_register %u, constants %p, bool_count %u.\n",
+ device, start_register, constants, bool_count);
- /* Specifically test start > limit to catch MAX_UINT overflows when adding start + count */
- if (!srcData || start + count > This->d3d_pshader_constantF || start > This->d3d_pshader_constantF)
+ if (!constants || start_register >= MAX_CONST_B)
return WINED3DERR_INVALIDCALL;
- memcpy(&This->updateStateBlock->state.ps_consts_f[start * 4], srcData, count * sizeof(float) * 4);
- if(TRACE_ON(d3d)) {
- for (i = 0; i < count; i++)
- TRACE("Set FLOAT constant %u to { %f, %f, %f, %f }\n", start + i,
- srcData[i*4], srcData[i*4+1], srcData[i*4+2], srcData[i*4+3]);
- }
+ memcpy(&device->updateStateBlock->state.ps_consts_b[start_register], constants, count * sizeof(BOOL));
+ for (i = 0; i < count; ++i)
+ TRACE("Set BOOL constant %u to %s.\n", start_register + i, constants[i] ? "true" : "false");
- if (!This->isRecordingState)
- {
- This->shader_backend->shader_update_float_pixel_constants(iface, start, count);
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADERCONSTANT);
- }
+ for (i = start_register; i < count + start_register; ++i)
+ device->updateStateBlock->changed.pixelShaderConstantsB |= (1 << i);
- memset(This->updateStateBlock->changed.pixelShaderConstantsF + start, 1,
- sizeof(*This->updateStateBlock->changed.pixelShaderConstantsF) * count);
+ if (!device->isRecordingState)
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_PIXELSHADERCONSTANT);
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantF(
- IWineD3DDevice *iface,
- UINT start,
- float *dstData,
- UINT count) {
+HRESULT CDECL wined3d_device_get_ps_consts_b(struct wined3d_device *device,
+ UINT start_register, BOOL *constants, UINT bool_count)
+{
+ UINT count = min(bool_count, MAX_CONST_B - start_register);
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int cnt = min(count, This->d3d_pshader_constantF - start);
+ TRACE("device %p, start_register %u, constants %p, bool_count %u.\n",
+ device, start_register, constants, bool_count);
- TRACE("(iface %p, dstData %p, start %d, count %d)\n",
- iface, dstData, start, count);
-
- if (!dstData || cnt < 0)
+ if (!constants || start_register >= MAX_CONST_B)
return WINED3DERR_INVALIDCALL;
- memcpy(dstData, &This->stateBlock->state.ps_consts_f[start * 4], cnt * sizeof(float) * 4);
+ memcpy(constants, &device->stateBlock->state.ps_consts_b[start_register], count * sizeof(BOOL));
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_set_ps_consts_i(struct wined3d_device *device,
+ UINT start_register, const int *constants, UINT vector4i_count)
+{
+ UINT count = min(vector4i_count, MAX_CONST_I - start_register);
+ UINT i;
+
+ TRACE("device %p, start_register %u, constants %p, vector4i_count %u.\n",
+ device, start_register, constants, vector4i_count);
+
+ if (!constants || start_register >= MAX_CONST_I)
+ return WINED3DERR_INVALIDCALL;
+
+ memcpy(&device->updateStateBlock->state.ps_consts_i[start_register * 4], constants, count * sizeof(int) * 4);
+ for (i = 0; i < count; ++i)
+ TRACE("Set INT constant %u to {%d, %d, %d, %d}.\n", start_register + i,
+ constants[i * 4], constants[i * 4 + 1],
+ constants[i * 4 + 2], constants[i * 4 + 3]);
+
+ for (i = start_register; i < count + start_register; ++i)
+ device->updateStateBlock->changed.pixelShaderConstantsI |= (1 << i);
+
+ if (!device->isRecordingState)
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_PIXELSHADERCONSTANT);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_get_ps_consts_i(struct wined3d_device *device,
+ UINT start_register, int *constants, UINT vector4i_count)
+{
+ UINT count = min(vector4i_count, MAX_CONST_I - start_register);
+
+ TRACE("device %p, start_register %u, constants %p, vector4i_count %u.\n",
+ device, start_register, constants, vector4i_count);
+
+ if (!constants || start_register >= MAX_CONST_I)
+ return WINED3DERR_INVALIDCALL;
+
+ memcpy(constants, &device->stateBlock->state.ps_consts_i[start_register * 4], count * sizeof(int) * 4);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_set_ps_consts_f(struct wined3d_device *device,
+ UINT start_register, const float *constants, UINT vector4f_count)
+{
+ UINT i;
+
+ TRACE("device %p, start_register %u, constants %p, vector4f_count %u.\n",
+ device, start_register, constants, vector4f_count);
+
+ /* Specifically test start_register > limit to catch MAX_UINT overflows
+ * when adding start_register + vector4f_count. */
+ if (!constants
+ || start_register + vector4f_count > device->d3d_pshader_constantF
+ || start_register > device->d3d_pshader_constantF)
+ return WINED3DERR_INVALIDCALL;
+
+ memcpy(&device->updateStateBlock->state.ps_consts_f[start_register * 4],
+ constants, vector4f_count * sizeof(float) * 4);
+ if (TRACE_ON(d3d))
+ {
+ for (i = 0; i < vector4f_count; ++i)
+ TRACE("Set FLOAT constant %u to {%.8e, %.8e, %.8e, %.8e}.\n", start_register + i,
+ constants[i * 4], constants[i * 4 + 1],
+ constants[i * 4 + 2], constants[i * 4 + 3]);
+ }
+
+ if (!device->isRecordingState)
+ {
+ device->shader_backend->shader_update_float_pixel_constants(device, start_register, vector4f_count);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_PIXELSHADERCONSTANT);
+ }
+
+ memset(device->updateStateBlock->changed.pixelShaderConstantsF + start_register, 1,
+ sizeof(*device->updateStateBlock->changed.pixelShaderConstantsF) * vector4f_count);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_get_ps_consts_f(struct wined3d_device *device,
+ UINT start_register, float *constants, UINT vector4f_count)
+{
+ int count = min(vector4f_count, device->d3d_pshader_constantF - start_register);
+
+ TRACE("device %p, start_register %u, constants %p, vector4f_count %u.\n",
+ device, start_register, constants, vector4f_count);
+
+ if (!constants || count < 0)
+ return WINED3DERR_INVALIDCALL;
+
+ memcpy(constants, &device->stateBlock->state.ps_consts_f[start_register * 4], count * sizeof(float) * 4);
+
return WINED3D_OK;
}
/* Context activation is done by the caller. */
/* Do not call while under the GL lock. */
#define copy_and_next(dest, src, size) memcpy(dest, src, size); dest += (size)
-static HRESULT process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCount,
- const struct wined3d_stream_info *stream_info, struct wined3d_buffer *dest, DWORD dwFlags,
+static HRESULT process_vertices_strided(struct wined3d_device *device, DWORD dwDestIndex, DWORD dwCount,
+ const struct wined3d_stream_info *stream_info, struct wined3d_buffer *dest, DWORD flags,
DWORD DestFVF)
{
- const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
char *dest_ptr, *dest_conv = NULL, *dest_conv_addr = NULL;
unsigned int i;
WINED3DVIEWPORT vp;
@@ -3836,7 +3226,7 @@ static HRESULT process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIn
if (!dest->buffer_object && gl_info->supported[ARB_VERTEX_BUFFER_OBJECT])
{
dest->flags |= WINED3D_BUFFER_CREATEBO;
- IWineD3DBuffer_PreLoad((IWineD3DBuffer *)dest);
+ wined3d_buffer_preload(dest);
}
if (dest->buffer_object)
@@ -3855,7 +3245,7 @@ static HRESULT process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIn
dest_conv = dest_conv_addr;
}
- if (This->stateBlock->state.render_states[WINED3DRS_CLIPPING])
+ if (device->stateBlock->state.render_states[WINED3DRS_CLIPPING])
{
static BOOL warned = FALSE;
/*
@@ -3874,15 +3264,9 @@ static HRESULT process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIn
} else doClip = FALSE;
dest_ptr = ((char *)buffer_get_sysmem(dest, gl_info)) + dwDestIndex * get_flexible_vertex_size(DestFVF);
- IWineD3DDevice_GetTransform( (IWineD3DDevice *) This,
- WINED3DTS_VIEW,
- &view_mat);
- IWineD3DDevice_GetTransform( (IWineD3DDevice *) This,
- WINED3DTS_PROJECTION,
- &proj_mat);
- IWineD3DDevice_GetTransform( (IWineD3DDevice *) This,
- WINED3DTS_WORLDMATRIX(0),
- &world_mat);
+ wined3d_device_get_transform(device, WINED3DTS_VIEW, &view_mat);
+ wined3d_device_get_transform(device, WINED3DTS_PROJECTION, &proj_mat);
+ wined3d_device_get_transform(device, WINED3DTS_WORLDMATRIX(0), &world_mat);
TRACE("View mat:\n");
TRACE("%f %f %f %f\n", view_mat.u.s._11, view_mat.u.s._12, view_mat.u.s._13, view_mat.u.s._14);
@@ -3903,7 +3287,7 @@ static HRESULT process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIn
TRACE("%f %f %f %f\n", world_mat.u.s._41, world_mat.u.s._42, world_mat.u.s._43, world_mat.u.s._44);
/* Get the viewport */
- IWineD3DDevice_GetViewport( (IWineD3DDevice *) This, &vp);
+ wined3d_device_get_viewport(device, &vp);
TRACE("Viewport: X=%d, Y=%d, Width=%d, Height=%d, MinZ=%f, MaxZ=%f\n",
vp.X, vp.Y, vp.Width, vp.Height, vp.MinZ, vp.MaxZ);
@@ -4147,35 +3531,37 @@ static HRESULT process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIn
#undef copy_and_next
/* Do not call while under the GL lock. */
-static HRESULT WINAPI IWineD3DDeviceImpl_ProcessVertices(IWineD3DDevice *iface, UINT SrcStartIndex, UINT DestIndex,
- UINT VertexCount, IWineD3DBuffer *pDestBuffer, IWineD3DVertexDeclaration *pVertexDecl, DWORD Flags,
- DWORD DestFVF)
+HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device,
+ UINT src_start_idx, UINT dst_idx, UINT vertex_count, struct wined3d_buffer *dst_buffer,
+ struct wined3d_vertex_declaration *declaration, DWORD flags, DWORD dst_fvf)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+ BOOL vbo = FALSE, streamWasUP = device->stateBlock->state.user_stream;
struct wined3d_stream_info stream_info;
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
- BOOL vbo = FALSE, streamWasUP = This->stateBlock->state.user_stream;
HRESULT hr;
- TRACE("(%p)->(%d,%d,%d,%p,%p,%d\n", This, SrcStartIndex, DestIndex, VertexCount, pDestBuffer, pVertexDecl, Flags);
+ TRACE("device %p, src_start_idx %u, dst_idx %u, vertex_count %u, "
+ "dst_buffer %p, declaration %p, flags %#x, dst_fvf %#x.\n",
+ device, src_start_idx, dst_idx, vertex_count,
+ dst_buffer, declaration, flags, dst_fvf);
- if(pVertexDecl) {
- ERR("Output vertex declaration not implemented yet\n");
- }
+ if (declaration)
+ FIXME("Output vertex declaration not implemented yet.\n");
/* Need any context to write to the vbo. */
- context = context_acquire(This, NULL);
+ context = context_acquire(device, NULL);
gl_info = context->gl_info;
/* ProcessVertices reads from vertex buffers, which have to be assigned. DrawPrimitive and DrawPrimitiveUP
* control the streamIsUP flag, thus restore it afterwards.
*/
- This->stateBlock->state.user_stream = FALSE;
- device_stream_info_from_declaration(This, FALSE, &stream_info, &vbo);
- This->stateBlock->state.user_stream = streamWasUP;
+ device->stateBlock->state.user_stream = FALSE;
+ device_stream_info_from_declaration(device, FALSE, &stream_info, &vbo);
+ device->stateBlock->state.user_stream = streamWasUP;
- if(vbo || SrcStartIndex) {
+ if (vbo || src_start_idx)
+ {
unsigned int i;
/* ProcessVertices can't convert FROM a vbo, and vertex buffers used to source into ProcessVertices are
* unlikely to ever be used for drawing. Release vbos in those buffers and fix up the stream_info structure
@@ -4191,7 +3577,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ProcessVertices(IWineD3DDevice *iface,
e = &stream_info.elements[i];
if (e->buffer_object)
{
- struct wined3d_buffer *vb = This->stateBlock->state.streams[e->stream_idx].buffer;
+ struct wined3d_buffer *vb = device->stateBlock->state.streams[e->stream_idx].buffer;
e->buffer_object = 0;
e->data = (BYTE *)((ULONG_PTR)e->data + (ULONG_PTR)buffer_get_sysmem(vb, gl_info));
ENTER_GL();
@@ -4199,160 +3585,159 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ProcessVertices(IWineD3DDevice *iface,
vb->buffer_object = 0;
LEAVE_GL();
}
- if (e->data) e->data += e->stride * SrcStartIndex;
+ if (e->data)
+ e->data += e->stride * src_start_idx;
}
}
- hr = process_vertices_strided(This, DestIndex, VertexCount, &stream_info,
- (struct wined3d_buffer *)pDestBuffer, Flags, DestFVF);
+ hr = process_vertices_strided(device, dst_idx, vertex_count,
+ &stream_info, dst_buffer, flags, dst_fvf);
context_release(context);
return hr;
}
-/*****
- * Get / Set Texture Stage States
- * TODO: Verify against dx9 definitions
- *****/
-static HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *iface, DWORD Stage, WINED3DTEXTURESTAGESTATETYPE Type, DWORD Value)
+HRESULT CDECL wined3d_device_set_texture_stage_state(struct wined3d_device *device,
+ UINT stage, WINED3DTEXTURESTAGESTATETYPE state, DWORD value)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
- DWORD oldValue;
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+ DWORD old_value;
- TRACE("(%p) : Stage=%d, Type=%s(%d), Value=%d\n", This, Stage, debug_d3dtexturestate(Type), Type, Value);
+ TRACE("device %p, stage %u, state %s, value %#x.\n",
+ device, stage, debug_d3dtexturestate(state), value);
- if (Type > WINED3D_HIGHEST_TEXTURE_STATE)
+ if (state > WINED3D_HIGHEST_TEXTURE_STATE)
{
- WARN("Invalid Type %d passed.\n", Type);
+ WARN("Invalid state %#x passed.\n", state);
return WINED3D_OK;
}
- if (Stage >= gl_info->limits.texture_stages)
+ if (stage >= gl_info->limits.texture_stages)
{
WARN("Attempting to set stage %u which is higher than the max stage %u, ignoring.\n",
- Stage, gl_info->limits.texture_stages - 1);
+ stage, gl_info->limits.texture_stages - 1);
return WINED3D_OK;
}
- oldValue = This->updateStateBlock->state.texture_states[Stage][Type];
- This->updateStateBlock->changed.textureState[Stage] |= 1 << Type;
- This->updateStateBlock->state.texture_states[Stage][Type] = Value;
+ old_value = device->updateStateBlock->state.texture_states[stage][state];
+ device->updateStateBlock->changed.textureState[stage] |= 1 << state;
+ device->updateStateBlock->state.texture_states[stage][state] = value;
- if (This->isRecordingState) {
- TRACE("Recording... not performing anything\n");
+ if (device->isRecordingState)
+ {
+ TRACE("Recording... not performing anything.\n");
return WINED3D_OK;
}
- /* Checked after the assignments to allow proper stateblock recording */
- if(oldValue == Value) {
- TRACE("App is setting the old value over, nothing to do\n");
+ /* Checked after the assignments to allow proper stateblock recording. */
+ if (old_value == value)
+ {
+ TRACE("Application is setting the old value over, nothing to do.\n");
return WINED3D_OK;
}
- if (Stage > This->stateBlock->state.lowest_disabled_stage
- && This->StateTable[STATE_TEXTURESTAGE(0, Type)].representative
+ if (stage > device->stateBlock->state.lowest_disabled_stage
+ && device->StateTable[STATE_TEXTURESTAGE(0, state)].representative
== STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP))
{
- /* Colorop change above lowest disabled stage? That won't change anything in the gl setup
- * Changes in other states are important on disabled stages too
- */
+ /* Colorop change above lowest disabled stage? That won't change
+ * anything in the GL setup. Changes in other states are important on
+ * disabled stages too. */
return WINED3D_OK;
}
- if(Type == WINED3DTSS_COLOROP) {
+ if (state == WINED3DTSS_COLOROP)
+ {
unsigned int i;
- if(Value == WINED3DTOP_DISABLE && oldValue != WINED3DTOP_DISABLE) {
- /* Previously enabled stage disabled now. Make sure to dirtify all enabled stages above Stage,
- * they have to be disabled
+ if (value == WINED3DTOP_DISABLE && old_value != WINED3DTOP_DISABLE)
+ {
+ /* Previously enabled stage disabled now. Make sure to dirtify
+ * all enabled stages above stage, they have to be disabled.
*
- * The current stage is dirtified below.
- */
- for (i = Stage + 1; i < This->stateBlock->state.lowest_disabled_stage; ++i)
+ * The current stage is dirtified below. */
+ for (i = stage + 1; i < device->stateBlock->state.lowest_disabled_stage; ++i)
{
- TRACE("Additionally dirtifying stage %u\n", i);
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP));
+ TRACE("Additionally dirtifying stage %u.\n", i);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP));
}
- This->stateBlock->state.lowest_disabled_stage = Stage;
- TRACE("New lowest disabled: %u\n", Stage);
- } else if(Value != WINED3DTOP_DISABLE && oldValue == WINED3DTOP_DISABLE) {
- /* Previously disabled stage enabled. Stages above it may need enabling
- * stage must be lowest_disabled_stage here, if it's bigger success is returned above,
- * and stages below the lowest disabled stage can't be enabled(because they are enabled already).
+ device->stateBlock->state.lowest_disabled_stage = stage;
+ TRACE("New lowest disabled: %u.\n", stage);
+ }
+ else if (value != WINED3DTOP_DISABLE && old_value == WINED3DTOP_DISABLE)
+ {
+ /* Previously disabled stage enabled. Stages above it may need
+ * enabling. Stage must be lowest_disabled_stage here, if it's
+ * bigger success is returned above, and stages below the lowest
+ * disabled stage can't be enabled (because they are enabled
+ * already).
*
- * Again stage Stage doesn't need to be dirtified here, it is handled below.
- */
-
- for (i = Stage + 1; i < This->adapter->gl_info.limits.texture_stages; ++i)
+ * Again stage stage doesn't need to be dirtified here, it is
+ * handled below. */
+ for (i = stage + 1; i < gl_info->limits.texture_stages; ++i)
{
- if (This->updateStateBlock->state.texture_states[i][WINED3DTSS_COLOROP] == WINED3DTOP_DISABLE)
+ if (device->updateStateBlock->state.texture_states[i][WINED3DTSS_COLOROP] == WINED3DTOP_DISABLE)
break;
- TRACE("Additionally dirtifying stage %u due to enable\n", i);
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP));
+ TRACE("Additionally dirtifying stage %u due to enable.\n", i);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP));
}
- This->stateBlock->state.lowest_disabled_stage = i;
- TRACE("New lowest disabled: %u\n", i);
+ device->stateBlock->state.lowest_disabled_stage = i;
+ TRACE("New lowest disabled: %u.\n", i);
}
}
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(Stage, Type));
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_TEXTURESTAGE(stage, state));
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetTextureStageState(IWineD3DDevice *iface, DWORD Stage, WINED3DTEXTURESTAGESTATETYPE Type, DWORD *pValue)
+HRESULT CDECL wined3d_device_get_texture_stage_state(struct wined3d_device *device,
+ UINT stage, WINED3DTEXTURESTAGESTATETYPE state, DWORD *value)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+ TRACE("device %p, stage %u, state %s, value %p.\n",
+ device, stage, debug_d3dtexturestate(state), value);
- TRACE("iface %p, stage %u, state %s, value %p.\n",
- iface, Stage, debug_d3dtexturestate(Type), pValue);
-
- if (Type > WINED3D_HIGHEST_TEXTURE_STATE)
+ if (state > WINED3D_HIGHEST_TEXTURE_STATE)
{
- WARN("Invalid Type %d passed.\n", Type);
+ WARN("Invalid state %#x passed.\n", state);
return WINED3D_OK;
}
- *pValue = This->updateStateBlock->state.texture_states[Stage][Type];
- TRACE("Returning %#x.\n", *pValue);
+ *value = device->updateStateBlock->state.texture_states[stage][state];
+ TRACE("Returning %#x.\n", *value);
return WINED3D_OK;
}
-/*****
- * Get / Set Texture
- *****/
-static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface,
- DWORD stage, IWineD3DBaseTexture *texture)
+HRESULT CDECL wined3d_device_set_texture(struct wined3d_device *device,
+ UINT stage, struct wined3d_texture *texture)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
- IWineD3DBaseTexture *prev;
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+ struct wined3d_texture *prev;
- TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
+ TRACE("device %p, stage %u, texture %p.\n", device, stage, texture);
if (stage >= WINED3DVERTEXTEXTURESAMPLER0 && stage <= WINED3DVERTEXTEXTURESAMPLER3)
stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
/* Windows accepts overflowing this array... we do not. */
- if (stage >= sizeof(This->stateBlock->state.textures) / sizeof(*This->stateBlock->state.textures))
+ if (stage >= sizeof(device->stateBlock->state.textures) / sizeof(*device->stateBlock->state.textures))
{
WARN("Ignoring invalid stage %u.\n", stage);
return WINED3D_OK;
}
/* SetTexture isn't allowed on textures in WINED3DPOOL_SCRATCH */
- if (texture && ((IWineD3DTextureImpl *)texture)->resource.pool == WINED3DPOOL_SCRATCH)
+ if (texture && texture->resource.pool == WINED3DPOOL_SCRATCH)
{
WARN("Rejecting attempt to set scratch texture.\n");
return WINED3DERR_INVALIDCALL;
}
- This->updateStateBlock->changed.textures |= 1 << stage;
+ device->updateStateBlock->changed.textures |= 1 << stage;
- prev = (IWineD3DBaseTexture *)This->updateStateBlock->state.textures[stage];
+ prev = device->updateStateBlock->state.textures[stage];
TRACE("Previous texture %p.\n", prev);
if (texture == prev)
@@ -4362,55 +3747,53 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface,
}
TRACE("Setting new texture to %p.\n", texture);
- This->updateStateBlock->state.textures[stage] = (IWineD3DBaseTextureImpl *)texture;
+ device->updateStateBlock->state.textures[stage] = texture;
- if (This->isRecordingState)
+ if (device->isRecordingState)
{
TRACE("Recording... not performing anything\n");
- if (texture) IWineD3DBaseTexture_AddRef(texture);
- if (prev) IWineD3DBaseTexture_Release(prev);
+ if (texture) wined3d_texture_incref(texture);
+ if (prev) wined3d_texture_decref(prev);
return WINED3D_OK;
}
if (texture)
{
- IWineD3DBaseTextureImpl *t = (IWineD3DBaseTextureImpl *)texture;
- LONG bind_count = InterlockedIncrement(&t->baseTexture.bindCount);
- GLenum dimensions = t->baseTexture.target;
+ LONG bind_count = InterlockedIncrement(&texture->bind_count);
- IWineD3DBaseTexture_AddRef(texture);
+ wined3d_texture_incref(texture);
- if (!prev || dimensions != ((IWineD3DBaseTextureImpl *)prev)->baseTexture.target)
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADER);
+ if (!prev || texture->target != prev->target)
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_PIXELSHADER);
if (!prev && stage < gl_info->limits.texture_stages)
{
/* The source arguments for color and alpha ops have different
* meanings when a NULL texture is bound, so the COLOROP and
* ALPHAOP have to be dirtified. */
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, WINED3DTSS_COLOROP));
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, WINED3DTSS_ALPHAOP));
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_TEXTURESTAGE(stage, WINED3DTSS_COLOROP));
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_TEXTURESTAGE(stage, WINED3DTSS_ALPHAOP));
}
- if (bind_count == 1) t->baseTexture.sampler = stage;
+ if (bind_count == 1)
+ texture->sampler = stage;
}
if (prev)
{
- IWineD3DBaseTextureImpl *t = (IWineD3DBaseTextureImpl *)prev;
- LONG bind_count = InterlockedDecrement(&t->baseTexture.bindCount);
+ LONG bind_count = InterlockedDecrement(&prev->bind_count);
- IWineD3DBaseTexture_Release(prev);
+ wined3d_texture_decref(prev);
if (!texture && stage < gl_info->limits.texture_stages)
{
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, WINED3DTSS_COLOROP));
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, WINED3DTSS_ALPHAOP));
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_TEXTURESTAGE(stage, WINED3DTSS_COLOROP));
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_TEXTURESTAGE(stage, WINED3DTSS_ALPHAOP));
}
- if (bind_count && t->baseTexture.sampler == stage)
+ if (bind_count && prev->sampler == stage)
{
unsigned int i;
@@ -4419,66 +3802,62 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface,
TRACE("Searching for other stages the texture is bound to.\n");
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
{
- if (This->updateStateBlock->state.textures[i] == t)
+ if (device->updateStateBlock->state.textures[i] == prev)
{
TRACE("Texture is also bound to stage %u.\n", i);
- t->baseTexture.sampler = i;
+ prev->sampler = i;
break;
}
}
}
}
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(stage));
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(stage));
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetTexture(IWineD3DDevice *iface, DWORD Stage, IWineD3DBaseTexture** ppTexture) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+HRESULT CDECL wined3d_device_get_texture(struct wined3d_device *device,
+ UINT stage, struct wined3d_texture **texture)
+{
+ TRACE("device %p, stage %u, texture %p.\n", device, stage, texture);
- TRACE("(%p) : Stage %#x, ppTexture %p\n", This, Stage, ppTexture);
+ if (stage >= WINED3DVERTEXTEXTURESAMPLER0 && stage <= WINED3DVERTEXTEXTURESAMPLER3)
+ stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
- if (Stage >= WINED3DVERTEXTEXTURESAMPLER0 && Stage <= WINED3DVERTEXTEXTURESAMPLER3) {
- Stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
- }
-
- if (Stage >= sizeof(This->stateBlock->state.textures) / sizeof(*This->stateBlock->state.textures))
+ if (stage >= sizeof(device->stateBlock->state.textures) / sizeof(*device->stateBlock->state.textures))
{
- ERR("Current stage overflows textures array (stage %d)\n", Stage);
+ WARN("Ignoring invalid stage %u.\n", stage);
return WINED3D_OK; /* Windows accepts overflowing this array ... we do not. */
}
- *ppTexture = (IWineD3DBaseTexture *)This->stateBlock->state.textures[Stage];
- if (*ppTexture)
- IWineD3DBaseTexture_AddRef(*ppTexture);
+ *texture = device->stateBlock->state.textures[stage];
+ if (*texture)
+ wined3d_texture_incref(*texture);
- TRACE("(%p) : Returning %p\n", This, *ppTexture);
+ TRACE("Returning %p.\n", *texture);
return WINED3D_OK;
}
-/*****
- * Get Back Buffer
- *****/
-static HRESULT WINAPI IWineD3DDeviceImpl_GetBackBuffer(IWineD3DDevice *iface, UINT swapchain_idx,
- UINT backbuffer_idx, WINED3DBACKBUFFER_TYPE backbuffer_type, IWineD3DSurface **backbuffer)
+HRESULT CDECL wined3d_device_get_back_buffer(struct wined3d_device *device, UINT swapchain_idx,
+ UINT backbuffer_idx, WINED3DBACKBUFFER_TYPE backbuffer_type, struct wined3d_surface **backbuffer)
{
- IWineD3DSwapChain *swapchain;
+ struct wined3d_swapchain *swapchain;
HRESULT hr;
- TRACE("iface %p, swapchain_idx %u, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
- iface, swapchain_idx, backbuffer_idx, backbuffer_type, backbuffer);
+ TRACE("device %p, swapchain_idx %u, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
+ device, swapchain_idx, backbuffer_idx, backbuffer_type, backbuffer);
- hr = IWineD3DDeviceImpl_GetSwapChain(iface, swapchain_idx, &swapchain);
+ hr = wined3d_device_get_swapchain(device, swapchain_idx, &swapchain);
if (FAILED(hr))
{
WARN("Failed to get swapchain %u, hr %#x.\n", swapchain_idx, hr);
return hr;
}
- hr = IWineD3DSwapChain_GetBackBuffer(swapchain, backbuffer_idx, backbuffer_type, backbuffer);
- IWineD3DSwapChain_Release(swapchain);
+ hr = wined3d_swapchain_get_back_buffer(swapchain, backbuffer_idx, backbuffer_type, backbuffer);
+ wined3d_swapchain_decref(swapchain);
if (FAILED(hr))
{
WARN("Failed to get backbuffer %u, hr %#x.\n", backbuffer_idx, hr);
@@ -4488,371 +3867,377 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetBackBuffer(IWineD3DDevice *iface, UI
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetDeviceCaps(IWineD3DDevice *iface, WINED3DCAPS* pCaps) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- WARN("(%p) : stub, calling idirect3d for now\n", This);
- return IWineD3D_GetDeviceCaps(This->wined3d, This->adapter->ordinal, This->devType, pCaps);
+HRESULT CDECL wined3d_device_get_device_caps(struct wined3d_device *device, WINED3DCAPS *caps)
+{
+ TRACE("device %p, caps %p.\n", device, caps);
+
+ return wined3d_get_device_caps(device->wined3d, device->adapter->ordinal, device->devType, caps);
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetDisplayMode(IWineD3DDevice *iface, UINT iSwapChain, WINED3DDISPLAYMODE* pMode) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DSwapChain *swapChain;
+HRESULT CDECL wined3d_device_get_display_mode(struct wined3d_device *device,
+ UINT swapchain_idx, WINED3DDISPLAYMODE *mode)
+{
+ struct wined3d_swapchain *swapchain;
HRESULT hr;
- if(iSwapChain > 0) {
- hr = IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, &swapChain);
- if (hr == WINED3D_OK) {
- hr = IWineD3DSwapChain_GetDisplayMode(swapChain, pMode);
- IWineD3DSwapChain_Release(swapChain);
- } else {
- FIXME("(%p) Error getting display mode\n", This);
- }
- } else {
- /* Don't read the real display mode,
- but return the stored mode instead. X11 can't change the color
- depth, and some apps are pretty angry if they SetDisplayMode from
- 24 to 16 bpp and find out that GetDisplayMode still returns 24 bpp
+ TRACE("device %p, swapchain_idx %u, mode %p.\n", device, swapchain_idx, mode);
- Also don't relay to the swapchain because with ddraw it's possible
- that there isn't a swapchain at all */
- pMode->Width = This->ddraw_width;
- pMode->Height = This->ddraw_height;
- pMode->Format = This->ddraw_format;
- pMode->RefreshRate = 0;
+ if (swapchain_idx)
+ {
+ hr = wined3d_device_get_swapchain(device, swapchain_idx, &swapchain);
+ if (SUCCEEDED(hr))
+ {
+ hr = wined3d_swapchain_get_display_mode(swapchain, mode);
+ wined3d_swapchain_decref(swapchain);
+ }
+ }
+ else
+ {
+ /* Don't read the real display mode, but return the stored mode
+ * instead. X11 can't change the color depth, and some apps are
+ * pretty angry if they SetDisplayMode from 24 to 16 bpp and find out
+ * that GetDisplayMode still returns 24 bpp.
+ *
+ * Also don't relay to the swapchain because with ddraw it's possible
+ * that there isn't a swapchain at all. */
+ mode->Width = device->ddraw_width;
+ mode->Height = device->ddraw_height;
+ mode->Format = device->ddraw_format;
+ mode->RefreshRate = 0;
hr = WINED3D_OK;
}
return hr;
}
-/*****
- * Stateblock related functions
- *****/
-
-static HRESULT WINAPI IWineD3DDeviceImpl_BeginStateBlock(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DStateBlock *stateblock;
+HRESULT CDECL wined3d_device_begin_stateblock(struct wined3d_device *device)
+{
+ struct wined3d_stateblock *stateblock;
HRESULT hr;
- TRACE("(%p)\n", This);
+ TRACE("device %p.\n", device);
- if (This->isRecordingState) return WINED3DERR_INVALIDCALL;
+ if (device->isRecordingState)
+ return WINED3DERR_INVALIDCALL;
- hr = IWineD3DDeviceImpl_CreateStateBlock(iface, WINED3DSBT_RECORDED, &stateblock);
- if (FAILED(hr)) return hr;
+ hr = wined3d_stateblock_create(device, WINED3DSBT_RECORDED, &stateblock);
+ if (FAILED(hr))
+ return hr;
- IWineD3DStateBlock_Release((IWineD3DStateBlock*)This->updateStateBlock);
- This->updateStateBlock = (IWineD3DStateBlockImpl *)stateblock;
- This->isRecordingState = TRUE;
+ wined3d_stateblock_decref(device->updateStateBlock);
+ device->updateStateBlock = stateblock;
+ device->isRecordingState = TRUE;
- TRACE("(%p) recording stateblock %p\n", This, stateblock);
+ TRACE("Recording stateblock %p.\n", stateblock);
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IWineD3DStateBlock** ppStateBlock) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DStateBlockImpl *object = This->updateStateBlock;
+HRESULT CDECL wined3d_device_end_stateblock(struct wined3d_device *device,
+ struct wined3d_stateblock **stateblock)
+{
+ struct wined3d_stateblock *object = device->updateStateBlock;
- if (!This->isRecordingState) {
- WARN("(%p) not recording! returning error\n", This);
- *ppStateBlock = NULL;
+ TRACE("device %p, stateblock %p.\n", device, stateblock);
+
+ if (!device->isRecordingState)
+ {
+ WARN("Not recording.\n");
+ *stateblock = NULL;
return WINED3DERR_INVALIDCALL;
}
stateblock_init_contained_states(object);
- *ppStateBlock = (IWineD3DStateBlock*) object;
- This->isRecordingState = FALSE;
- This->updateStateBlock = This->stateBlock;
- IWineD3DStateBlock_AddRef((IWineD3DStateBlock*)This->updateStateBlock);
- /* IWineD3DStateBlock_AddRef(*ppStateBlock); don't need to do this, since we should really just release UpdateStateBlock first */
- TRACE("(%p) returning token (ptr to stateblock) of %p\n", This, *ppStateBlock);
+ *stateblock = object;
+ device->isRecordingState = FALSE;
+ device->updateStateBlock = device->stateBlock;
+ wined3d_stateblock_incref(device->updateStateBlock);
+
+ TRACE("Returning stateblock %p.\n", *stateblock);
+
return WINED3D_OK;
}
-/*****
- * Scene related functions
- *****/
-static HRESULT WINAPI IWineD3DDeviceImpl_BeginScene(IWineD3DDevice *iface) {
+HRESULT CDECL wined3d_device_begin_scene(struct wined3d_device *device)
+{
/* At the moment we have no need for any functionality at the beginning
- of a scene */
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- TRACE("(%p)\n", This);
+ * of a scene. */
+ TRACE("device %p.\n", device);
- if(This->inScene) {
- TRACE("Already in Scene, returning WINED3DERR_INVALIDCALL\n");
+ if (device->inScene)
+ {
+ WARN("Already in scene, returning WINED3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
- This->inScene = TRUE;
+ device->inScene = TRUE;
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_EndScene(IWineD3DDevice *iface)
+HRESULT CDECL wined3d_device_end_scene(struct wined3d_device *device)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
struct wined3d_context *context;
- TRACE("(%p)\n", This);
+ TRACE("device %p.\n", device);
- if(!This->inScene) {
- TRACE("Not in scene, returning WINED3DERR_INVALIDCALL\n");
+ if (!device->inScene)
+ {
+ WARN("Not in scene, returning WINED3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
- context = context_acquire(This, NULL);
+ context = context_acquire(device, NULL);
/* We only have to do this if we need to read the, swapbuffers performs a flush for us */
wglFlush();
/* No checkGLcall here to avoid locking the lock just for checking a call that hardly ever
* fails. */
context_release(context);
- This->inScene = FALSE;
+ device->inScene = FALSE;
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_Present(IWineD3DDevice *iface,
- const RECT *pSourceRect, const RECT *pDestRect,
- HWND hDestWindowOverride, const RGNDATA *pDirtyRegion)
+HRESULT CDECL wined3d_device_present(struct wined3d_device *device, const RECT *src_rect,
+ const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region)
{
- IWineD3DSwapChain *swapChain = NULL;
- int i;
- int swapchains = IWineD3DDeviceImpl_GetNumberOfSwapChains(iface);
+ UINT i;
- TRACE("iface %p.\n", iface);
+ TRACE("device %p, src_rect %s, dst_rect %s, dst_window_override %p, dirty_region %p.\n",
+ device, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect),
+ dst_window_override, dirty_region);
- for(i = 0 ; i < swapchains ; i ++) {
-
- IWineD3DDeviceImpl_GetSwapChain(iface, i, &swapChain);
- TRACE("Presenting chain %d, %p.\n", i, swapChain);
- IWineD3DSwapChain_Present(swapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, 0);
- IWineD3DSwapChain_Release(swapChain);
+ for (i = 0; i < device->swapchain_count; ++i)
+ {
+ wined3d_swapchain_present(device->swapchains[i], src_rect,
+ dst_rect, dst_window_override, dirty_region, 0);
}
return WINED3D_OK;
}
/* Do not call while under the GL lock. */
-static HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD rect_count,
+HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_count,
const RECT *rects, DWORD flags, WINED3DCOLOR color, float depth, DWORD stencil)
{
const WINED3DCOLORVALUE c = {D3DCOLOR_R(color), D3DCOLOR_G(color), D3DCOLOR_B(color), D3DCOLOR_A(color)};
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
RECT draw_rect;
- TRACE("iface %p, rect_count %u, rects %p, flags %#x, color 0x%08x, depth %.8e, stencil %u.\n",
- iface, rect_count, rects, flags, color, depth, stencil);
+ TRACE("device %p, rect_count %u, rects %p, flags %#x, color 0x%08x, depth %.8e, stencil %u.\n",
+ device, rect_count, rects, flags, color, depth, stencil);
- if (flags & (WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL) && !device->depth_stencil)
+ if (flags & (WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL))
{
- WARN("Clearing depth and/or stencil without a depth stencil buffer attached, returning WINED3DERR_INVALIDCALL\n");
- /* TODO: What about depth stencil buffers without stencil bits? */
- return WINED3DERR_INVALIDCALL;
+ struct wined3d_surface *ds = device->fb.depth_stencil;
+ if (!ds)
+ {
+ WARN("Clearing depth and/or stencil without a depth stencil buffer attached, returning WINED3DERR_INVALIDCALL\n");
+ /* TODO: What about depth stencil buffers without stencil bits? */
+ return WINED3DERR_INVALIDCALL;
+ }
+ else if (flags & WINED3DCLEAR_TARGET)
+ {
+ if (ds->resource.width < device->fb.render_targets[0]->resource.width
+ || ds->resource.height < device->fb.render_targets[0]->resource.height)
+ {
+ WARN("Silently ignoring depth and target clear with mismatching sizes\n");
+ return WINED3D_OK;
+ }
+ }
}
device_get_draw_rect(device, &draw_rect);
return device_clear_render_targets(device, device->adapter->gl_info.limits.buffers,
- device->render_targets, rect_count, rects, &draw_rect, flags, &c, depth, stencil);
+ device->fb.render_targets, device->fb.depth_stencil, rect_count, rects,
+ &draw_rect, flags, &c, depth, stencil);
}
-/*****
- * Drawing functions
- *****/
-
-static void WINAPI IWineD3DDeviceImpl_SetPrimitiveType(IWineD3DDevice *iface,
+void CDECL wined3d_device_set_primitive_type(struct wined3d_device *device,
WINED3DPRIMITIVETYPE primitive_type)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+ TRACE("device %p, primitive_type %s\n", device, debug_d3dprimitivetype(primitive_type));
- TRACE("iface %p, primitive_type %s\n", iface, debug_d3dprimitivetype(primitive_type));
-
- This->updateStateBlock->changed.primitive_type = TRUE;
- This->updateStateBlock->state.gl_primitive_type = gl_primitive_type_from_d3d(primitive_type);
+ device->updateStateBlock->changed.primitive_type = TRUE;
+ device->updateStateBlock->state.gl_primitive_type = gl_primitive_type_from_d3d(primitive_type);
}
-static void WINAPI IWineD3DDeviceImpl_GetPrimitiveType(IWineD3DDevice *iface,
+void CDECL wined3d_device_get_primitive_type(struct wined3d_device *device,
WINED3DPRIMITIVETYPE *primitive_type)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+ TRACE("device %p, primitive_type %p\n", device, primitive_type);
- TRACE("iface %p, primitive_type %p\n", iface, primitive_type);
-
- *primitive_type = d3d_primitive_type_from_gl(This->stateBlock->state.gl_primitive_type);
+ *primitive_type = d3d_primitive_type_from_gl(device->stateBlock->state.gl_primitive_type);
TRACE("Returning %s\n", debug_d3dprimitivetype(*primitive_type));
}
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, UINT StartVertex, UINT vertex_count)
+HRESULT CDECL wined3d_device_draw_primitive(struct wined3d_device *device, UINT start_vertex, UINT vertex_count)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+ TRACE("device %p, start_vertex %u, vertex_count %u.\n", device, start_vertex, vertex_count);
- TRACE("(%p) : start %u, count %u\n", This, StartVertex, vertex_count);
-
- if (!This->stateBlock->state.vertex_declaration)
+ if (!device->stateBlock->state.vertex_declaration)
{
- WARN("(%p) : Called without a valid vertex declaration set\n", This);
+ WARN("Called without a valid vertex declaration set.\n");
return WINED3DERR_INVALIDCALL;
}
/* The index buffer is not needed here, but restore it, otherwise it is hell to keep track of */
- if (This->stateBlock->state.user_stream)
+ if (device->stateBlock->state.user_stream)
{
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
- This->stateBlock->state.user_stream = FALSE;
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_INDEXBUFFER);
+ device->stateBlock->state.user_stream = FALSE;
}
- if (This->stateBlock->state.load_base_vertex_index)
+ if (device->stateBlock->state.load_base_vertex_index)
{
- This->stateBlock->state.load_base_vertex_index = 0;
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
+ device->stateBlock->state.load_base_vertex_index = 0;
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_STREAMSRC);
}
- /* Account for the loading offset due to index buffers. Instead of reloading all sources correct it with the startvertex parameter */
- drawPrimitive(iface, vertex_count, StartVertex /* start_idx */, 0 /* indxSize */, NULL /* indxData */);
+
+ /* Account for the loading offset due to index buffers. Instead of
+ * reloading all sources correct it with the startvertex parameter. */
+ drawPrimitive(device, vertex_count, start_vertex, 0, NULL);
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *iface, UINT startIndex, UINT index_count)
+HRESULT CDECL wined3d_device_draw_indexed_primitive(struct wined3d_device *device, UINT start_idx, UINT index_count)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
struct wined3d_buffer *index_buffer;
- UINT idxStride = 2;
+ UINT index_size = 2;
GLuint vbo;
- index_buffer = This->stateBlock->state.index_buffer;
+ TRACE("device %p, start_idx %u, index_count %u.\n", device, start_idx, index_count);
+
+ index_buffer = device->stateBlock->state.index_buffer;
if (!index_buffer)
{
/* D3D9 returns D3DERR_INVALIDCALL when DrawIndexedPrimitive is called
* without an index buffer set. (The first time at least...)
* D3D8 simply dies, but I doubt it can do much harm to return
* D3DERR_INVALIDCALL there as well. */
- WARN("(%p) : Called without a valid index buffer set, returning WINED3DERR_INVALIDCALL\n", This);
+ WARN("Called without a valid index buffer set, returning WINED3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
- if (!This->stateBlock->state.vertex_declaration)
+ if (!device->stateBlock->state.vertex_declaration)
{
- WARN("(%p) : Called without a valid vertex declaration set\n", This);
+ WARN("Called without a valid vertex declaration set.\n");
return WINED3DERR_INVALIDCALL;
}
- if (This->stateBlock->state.user_stream)
+ if (device->stateBlock->state.user_stream)
{
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
- This->stateBlock->state.user_stream = FALSE;
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_INDEXBUFFER);
+ device->stateBlock->state.user_stream = FALSE;
}
vbo = index_buffer->buffer_object;
- TRACE("(%p) : startIndex %u, index count %u.\n", This, startIndex, index_count);
-
- if (This->stateBlock->state.index_format == WINED3DFMT_R16_UINT)
- idxStride = 2;
+ if (device->stateBlock->state.index_format == WINED3DFMT_R16_UINT)
+ index_size = 2;
else
- idxStride = 4;
+ index_size = 4;
- if (This->stateBlock->state.load_base_vertex_index != This->stateBlock->state.base_vertex_index)
+ if (device->stateBlock->state.load_base_vertex_index != device->stateBlock->state.base_vertex_index)
{
- This->stateBlock->state.load_base_vertex_index = This->stateBlock->state.base_vertex_index;
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
+ device->stateBlock->state.load_base_vertex_index = device->stateBlock->state.base_vertex_index;
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_STREAMSRC);
}
- drawPrimitive(iface, index_count, startIndex, idxStride,
+ drawPrimitive(device, index_count, start_idx, index_size,
vbo ? NULL : index_buffer->resource.allocatedMemory);
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface, UINT vertex_count,
- const void *pVertexStreamZeroData, UINT VertexStreamZeroStride)
+HRESULT CDECL wined3d_device_draw_primitive_up(struct wined3d_device *device, UINT vertex_count,
+ const void *stream_data, UINT stream_stride)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
struct wined3d_stream_state *stream;
- IWineD3DBuffer *vb;
+ struct wined3d_buffer *vb;
- TRACE("(%p) : vertex count %u, pVtxData %p, stride %u\n",
- This, vertex_count, pVertexStreamZeroData, VertexStreamZeroStride);
+ TRACE("device %p, vertex count %u, stream_data %p, stream_stride %u.\n",
+ device, vertex_count, stream_data, stream_stride);
- if (!This->stateBlock->state.vertex_declaration)
+ if (!device->stateBlock->state.vertex_declaration)
{
- WARN("(%p) : Called without a valid vertex declaration set\n", This);
+ WARN("Called without a valid vertex declaration set.\n");
return WINED3DERR_INVALIDCALL;
}
/* Note in the following, it's not this type, but that's the purpose of streamIsUP */
- stream = &This->stateBlock->state.streams[0];
- vb = (IWineD3DBuffer *)stream->buffer;
- stream->buffer = (struct wined3d_buffer *)pVertexStreamZeroData;
- if (vb) IWineD3DBuffer_Release(vb);
+ stream = &device->stateBlock->state.streams[0];
+ vb = stream->buffer;
+ stream->buffer = (struct wined3d_buffer *)stream_data;
+ if (vb)
+ wined3d_buffer_decref(vb);
stream->offset = 0;
- stream->stride = VertexStreamZeroStride;
- This->stateBlock->state.user_stream = TRUE;
- This->stateBlock->state.load_base_vertex_index = 0;
+ stream->stride = stream_stride;
+ device->stateBlock->state.user_stream = TRUE;
+ device->stateBlock->state.load_base_vertex_index = 0;
/* TODO: Only mark dirty if drawing from a different UP address */
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_STREAMSRC);
- drawPrimitive(iface, vertex_count, 0 /* start_idx */, 0 /* indxSize*/, NULL /* indxData */);
+ drawPrimitive(device, vertex_count, 0, 0, NULL);
/* MSDN specifies stream zero settings must be set to NULL */
stream->buffer = NULL;
stream->stride = 0;
- /* stream zero settings set to null at end, as per the msdn. No need to mark dirty here, the app has to set
- * the new stream sources or use UP drawing again
- */
+ /* stream zero settings set to null at end, as per the msdn. No need to
+ * mark dirty here, the app has to set the new stream sources or use UP
+ * drawing again. */
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *iface,
- UINT index_count, const void *pIndexData, enum wined3d_format_id IndexDataFormat,
- const void *pVertexStreamZeroData, UINT VertexStreamZeroStride)
+HRESULT CDECL wined3d_device_draw_indexed_primitive_up(struct wined3d_device *device,
+ UINT index_count, const void *index_data, enum wined3d_format_id index_data_format_id,
+ const void *stream_data, UINT stream_stride)
{
- int idxStride;
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
struct wined3d_stream_state *stream;
- IWineD3DBuffer *vb;
- IWineD3DBuffer *ib;
+ struct wined3d_buffer *vb, *ib;
+ UINT index_size;
- TRACE("(%p) : index count %u, pidxdata %p, IdxFmt %u, pVtxdata %p, stride=%u.\n",
- This, index_count, pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
+ TRACE("device %p, index_count %u, index_data %p, index_data_format %s, stream_data %p, stream_stride %u.\n",
+ device, index_count, index_data, debug_d3dformat(index_data_format_id), stream_data, stream_stride);
- if (!This->stateBlock->state.vertex_declaration)
+ if (!device->stateBlock->state.vertex_declaration)
{
- WARN("(%p) : Called without a valid vertex declaration set\n", This);
+ WARN("(%p) : Called without a valid vertex declaration set\n", device);
return WINED3DERR_INVALIDCALL;
}
- if (IndexDataFormat == WINED3DFMT_R16_UINT) {
- idxStride = 2;
- } else {
- idxStride = 4;
- }
+ if (index_data_format_id == WINED3DFMT_R16_UINT)
+ index_size = 2;
+ else
+ index_size = 4;
- stream = &This->stateBlock->state.streams[0];
- vb = (IWineD3DBuffer *)stream->buffer;
- stream->buffer = (struct wined3d_buffer *)pVertexStreamZeroData;
- if (vb) IWineD3DBuffer_Release(vb);
+ stream = &device->stateBlock->state.streams[0];
+ vb = stream->buffer;
+ stream->buffer = (struct wined3d_buffer *)stream_data;
+ if (vb)
+ wined3d_buffer_decref(vb);
stream->offset = 0;
- stream->stride = VertexStreamZeroStride;
- This->stateBlock->state.user_stream = TRUE;
+ stream->stride = stream_stride;
+ device->stateBlock->state.user_stream = TRUE;
/* Set to 0 as per msdn. Do it now due to the stream source loading during drawPrimitive */
- This->stateBlock->state.base_vertex_index = 0;
- This->stateBlock->state.load_base_vertex_index = 0;
+ device->stateBlock->state.base_vertex_index = 0;
+ device->stateBlock->state.load_base_vertex_index = 0;
/* Mark the state dirty until we have nicer tracking of the stream source pointers */
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_VDECL);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_INDEXBUFFER);
- drawPrimitive(iface, index_count, 0 /* start_idx */, idxStride, pIndexData);
+ drawPrimitive(device, index_count, 0, index_size, index_data);
/* MSDN specifies stream zero settings and index buffer must be set to NULL */
stream->buffer = NULL;
stream->stride = 0;
- ib = (IWineD3DBuffer *)This->stateBlock->state.index_buffer;
+ ib = device->stateBlock->state.index_buffer;
if (ib)
{
- IWineD3DBuffer_Release(ib);
- This->stateBlock->state.index_buffer = NULL;
+ wined3d_buffer_decref(ib);
+ device->stateBlock->state.index_buffer = NULL;
}
/* No need to mark the stream source state dirty here. Either the app calls UP drawing again, or it has to call
* SetStreamSource to specify a vertex buffer
@@ -4861,86 +4246,82 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided(IWineD3DDevice *iface,
- UINT vertex_count, const WineDirect3DVertexStridedData *DrawPrimStrideData)
+HRESULT CDECL wined3d_device_draw_primitive_strided(struct wined3d_device *device,
+ UINT vertex_count, const WineDirect3DVertexStridedData *strided_data)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
-
- /* Mark the state dirty until we have nicer tracking
- * its fine to change baseVertexIndex because that call is only called by ddraw which does not need
- * that value.
- */
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
- This->stateBlock->state.base_vertex_index = 0;
- This->up_strided = DrawPrimStrideData;
- drawPrimitive(iface, vertex_count, 0, 0, NULL);
- This->up_strided = NULL;
+ /* Mark the state dirty until we have nicer tracking. It's fine to change
+ * baseVertexIndex because that call is only called by ddraw which does
+ * not need that value. */
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_VDECL);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_INDEXBUFFER);
+ device->stateBlock->state.base_vertex_index = 0;
+ device->up_strided = strided_data;
+ drawPrimitive(device, vertex_count, 0, 0, NULL);
+ device->up_strided = NULL;
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveStrided(IWineD3DDevice *iface,
- UINT vertex_count, const WineDirect3DVertexStridedData *DrawPrimStrideData,
- UINT NumVertices, const void *pIndexData, enum wined3d_format_id IndexDataFormat)
+HRESULT CDECL wined3d_device_draw_indexed_primitive_strided(struct wined3d_device *device,
+ UINT index_count, const WineDirect3DVertexStridedData *strided_data,
+ UINT vertex_count, const void *index_data, enum wined3d_format_id index_data_format_id)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
- DWORD idxSize = (IndexDataFormat == WINED3DFMT_R32_UINT ? 4 : 2);
+ UINT index_size = index_data_format_id == WINED3DFMT_R32_UINT ? 4 : 2;
/* Mark the state dirty until we have nicer tracking
* its fine to change baseVertexIndex because that call is only called by ddraw which does not need
* that value.
*/
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL);
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
- This->stateBlock->state.user_stream = TRUE;
- This->stateBlock->state.base_vertex_index = 0;
- This->up_strided = DrawPrimStrideData;
- drawPrimitive(iface, vertex_count, 0 /* start_idx */, idxSize, pIndexData);
- This->up_strided = NULL;
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_VDECL);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_INDEXBUFFER);
+ device->stateBlock->state.user_stream = TRUE;
+ device->stateBlock->state.base_vertex_index = 0;
+ device->up_strided = strided_data;
+ drawPrimitive(device, index_count, 0, index_size, index_data);
+ device->up_strided = NULL;
return WINED3D_OK;
}
/* This is a helper function for UpdateTexture, there is no UpdateVolume method in D3D. */
-static HRESULT IWineD3DDeviceImpl_UpdateVolume(IWineD3DDevice *iface,
- IWineD3DVolume *pSourceVolume, IWineD3DVolume *pDestinationVolume)
+static HRESULT IWineD3DDeviceImpl_UpdateVolume(struct wined3d_device *device,
+ struct wined3d_volume *src_volume, struct wined3d_volume *dst_volume)
{
WINED3DLOCKED_BOX src;
WINED3DLOCKED_BOX dst;
HRESULT hr;
- TRACE("iface %p, src_volume %p, dst_volume %p.\n",
- iface, pSourceVolume, pDestinationVolume);
+ TRACE("device %p, src_volume %p, dst_volume %p.\n",
+ device, src_volume, dst_volume);
- /* TODO: Implement direct loading into the gl volume instead of using memcpy and
- * dirtification to improve loading performance.
- */
- hr = IWineD3DVolume_LockBox(pSourceVolume, &src, NULL, WINED3DLOCK_READONLY);
- if(FAILED(hr)) return hr;
- hr = IWineD3DVolume_LockBox(pDestinationVolume, &dst, NULL, WINED3DLOCK_DISCARD);
- if(FAILED(hr)) {
- IWineD3DVolume_UnlockBox(pSourceVolume);
- return hr;
+ /* TODO: Implement direct loading into the gl volume instead of using
+ * memcpy and dirtification to improve loading performance. */
+ hr = wined3d_volume_map(src_volume, &src, NULL, WINED3DLOCK_READONLY);
+ if (FAILED(hr)) return hr;
+ hr = wined3d_volume_map(dst_volume, &dst, NULL, WINED3DLOCK_DISCARD);
+ if (FAILED(hr))
+ {
+ wined3d_volume_unmap(src_volume);
+ return hr;
}
- memcpy(dst.pBits, src.pBits, ((IWineD3DVolumeImpl *) pDestinationVolume)->resource.size);
+ memcpy(dst.pBits, src.pBits, dst_volume->resource.size);
+
+ hr = wined3d_volume_unmap(dst_volume);
+ if (FAILED(hr))
+ wined3d_volume_unmap(src_volume);
+ else
+ hr = wined3d_volume_unmap(src_volume);
- hr = IWineD3DVolume_UnlockBox(pDestinationVolume);
- if(FAILED(hr)) {
- IWineD3DVolume_UnlockBox(pSourceVolume);
- } else {
- hr = IWineD3DVolume_UnlockBox(pSourceVolume);
- }
return hr;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_UpdateTexture(IWineD3DDevice *iface,
- IWineD3DBaseTexture *src_texture, IWineD3DBaseTexture *dst_texture)
+HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
+ struct wined3d_texture *src_texture, struct wined3d_texture *dst_texture)
{
unsigned int level_count, i;
WINED3DRESOURCETYPE type;
HRESULT hr;
- TRACE("iface %p, src_texture %p, dst_texture %p.\n", iface, src_texture, dst_texture);
+ TRACE("device %p, src_texture %p, dst_texture %p.\n", device, src_texture, dst_texture);
/* Verify that the source and destination textures are non-NULL. */
if (!src_texture || !dst_texture)
@@ -4956,39 +4337,37 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateTexture(IWineD3DDevice *iface,
}
/* Verify that the source and destination textures are the same type. */
- type = IWineD3DBaseTexture_GetType(src_texture);
- if (IWineD3DBaseTexture_GetType(dst_texture) != type)
+ type = wined3d_texture_get_type(src_texture);
+ if (wined3d_texture_get_type(dst_texture) != type)
{
WARN("Source and destination have different types, returning WINED3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
/* Check that both textures have the identical numbers of levels. */
- level_count = IWineD3DBaseTexture_GetLevelCount(src_texture);
- if (IWineD3DBaseTexture_GetLevelCount(dst_texture) != level_count)
+ level_count = wined3d_texture_get_level_count(src_texture);
+ if (wined3d_texture_get_level_count(dst_texture) != level_count)
{
WARN("Source and destination have different level counts, returning WINED3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
}
/* Make sure that the destination texture is loaded. */
- ((IWineD3DBaseTextureImpl *)dst_texture)->baseTexture.internal_preload(dst_texture, SRGB_RGB);
+ dst_texture->texture_ops->texture_preload(dst_texture, SRGB_RGB);
/* Update every surface level of the texture. */
switch (type)
{
case WINED3DRTYPE_TEXTURE:
{
- IWineD3DSurface *src_surface;
- IWineD3DSurface *dst_surface;
+ struct wined3d_surface *src_surface;
+ struct wined3d_surface *dst_surface;
for (i = 0; i < level_count; ++i)
{
- IWineD3DTexture_GetSurfaceLevel((IWineD3DTexture *)src_texture, i, &src_surface);
- IWineD3DTexture_GetSurfaceLevel((IWineD3DTexture *)dst_texture, i, &dst_surface);
- hr = IWineD3DDevice_UpdateSurface(iface, src_surface, NULL, dst_surface, NULL);
- IWineD3DSurface_Release(dst_surface);
- IWineD3DSurface_Release(src_surface);
+ src_surface = surface_from_resource(wined3d_texture_get_sub_resource(src_texture, i));
+ dst_surface = surface_from_resource(wined3d_texture_get_sub_resource(dst_texture, i));
+ hr = wined3d_device_update_surface(device, src_surface, NULL, dst_surface, NULL);
if (FAILED(hr))
{
WARN("IWineD3DDevice_UpdateSurface failed, hr %#x.\n", hr);
@@ -5000,29 +4379,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateTexture(IWineD3DDevice *iface,
case WINED3DRTYPE_CUBETEXTURE:
{
- IWineD3DSurface *src_surface;
- IWineD3DSurface *dst_surface;
- WINED3DCUBEMAP_FACES face;
+ struct wined3d_surface *src_surface;
+ struct wined3d_surface *dst_surface;
- for (i = 0; i < level_count; ++i)
+ for (i = 0; i < level_count * 6; ++i)
{
- /* Update each cube face. */
- for (face = WINED3DCUBEMAP_FACE_POSITIVE_X; face <= WINED3DCUBEMAP_FACE_NEGATIVE_Z; ++face)
+ src_surface = surface_from_resource(wined3d_texture_get_sub_resource(src_texture, i));
+ dst_surface = surface_from_resource(wined3d_texture_get_sub_resource(dst_texture, i));
+ hr = wined3d_device_update_surface(device, src_surface, NULL, dst_surface, NULL);
+ if (FAILED(hr))
{
- hr = IWineD3DCubeTexture_GetCubeMapSurface((IWineD3DCubeTexture *)src_texture,
- face, i, &src_surface);
- if (FAILED(hr)) ERR("Failed to get src cube surface face %u, level %u, hr %#x.\n", face, i, hr);
- hr = IWineD3DCubeTexture_GetCubeMapSurface((IWineD3DCubeTexture *)dst_texture,
- face, i, &dst_surface);
- if (FAILED(hr)) ERR("Failed to get dst cube surface face %u, level %u, hr %#x.\n", face, i, hr);
- hr = IWineD3DDevice_UpdateSurface(iface, src_surface, NULL, dst_surface, NULL);
- IWineD3DSurface_Release(dst_surface);
- IWineD3DSurface_Release(src_surface);
- if (FAILED(hr))
- {
- WARN("IWineD3DDevice_UpdateSurface failed, hr %#x.\n", hr);
- return hr;
- }
+ WARN("IWineD3DDevice_UpdateSurface failed, hr %#x.\n", hr);
+ return hr;
}
}
break;
@@ -5030,16 +4398,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateTexture(IWineD3DDevice *iface,
case WINED3DRTYPE_VOLUMETEXTURE:
{
- IWineD3DVolume *src_volume;
- IWineD3DVolume *dst_volume;
-
for (i = 0; i < level_count; ++i)
{
- IWineD3DVolumeTexture_GetVolumeLevel((IWineD3DVolumeTexture *)src_texture, i, &src_volume);
- IWineD3DVolumeTexture_GetVolumeLevel((IWineD3DVolumeTexture *)dst_texture, i, &dst_volume);
- hr = IWineD3DDeviceImpl_UpdateVolume(iface, src_volume, dst_volume);
- IWineD3DVolume_Release(dst_volume);
- IWineD3DVolume_Release(src_volume);
+ hr = IWineD3DDeviceImpl_UpdateVolume(device,
+ volume_from_resource(wined3d_texture_get_sub_resource(src_texture, i)),
+ volume_from_resource(wined3d_texture_get_sub_resource(dst_texture, i)));
if (FAILED(hr))
{
WARN("IWineD3DDeviceImpl_UpdateVolume failed, hr %#x.\n", hr);
@@ -5057,78 +4420,93 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateTexture(IWineD3DDevice *iface,
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetFrontBufferData(IWineD3DDevice *iface,
- UINT swapchain_idx, IWineD3DSurface *dst_surface)
+HRESULT CDECL wined3d_device_get_front_buffer_data(struct wined3d_device *device,
+ UINT swapchain_idx, struct wined3d_surface *dst_surface)
{
- IWineD3DSwapChain *swapchain;
+ struct wined3d_swapchain *swapchain;
HRESULT hr;
- TRACE("iface %p, swapchain_idx %u, dst_surface %p.\n", iface, swapchain_idx, dst_surface);
+ TRACE("device %p, swapchain_idx %u, dst_surface %p.\n", device, swapchain_idx, dst_surface);
- hr = IWineD3DDeviceImpl_GetSwapChain(iface, swapchain_idx, &swapchain);
+ hr = wined3d_device_get_swapchain(device, swapchain_idx, &swapchain);
if (FAILED(hr)) return hr;
- hr = IWineD3DSwapChain_GetFrontBufferData(swapchain, dst_surface);
- IWineD3DSwapChain_Release(swapchain);
+ hr = wined3d_swapchain_get_front_buffer_data(swapchain, dst_surface);
+ wined3d_swapchain_decref(swapchain);
return hr;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_ValidateDevice(IWineD3DDevice *iface, DWORD* pNumPasses) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DBaseTextureImpl *texture;
+HRESULT CDECL wined3d_device_validate_device(struct wined3d_device *device, DWORD *num_passes)
+{
+ const struct wined3d_state *state = &device->stateBlock->state;
+ struct wined3d_texture *texture;
DWORD i;
- TRACE("(%p) : %p\n", This, pNumPasses);
+ TRACE("device %p, num_passes %p.\n", device, num_passes);
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
{
- if (This->stateBlock->state.sampler_states[i][WINED3DSAMP_MINFILTER] == WINED3DTEXF_NONE)
+ if (state->sampler_states[i][WINED3DSAMP_MINFILTER] == WINED3DTEXF_NONE)
{
WARN("Sampler state %u has minfilter D3DTEXF_NONE, returning D3DERR_UNSUPPORTEDTEXTUREFILTER\n", i);
return WINED3DERR_UNSUPPORTEDTEXTUREFILTER;
}
- if (This->stateBlock->state.sampler_states[i][WINED3DSAMP_MAGFILTER] == WINED3DTEXF_NONE)
+ if (state->sampler_states[i][WINED3DSAMP_MAGFILTER] == WINED3DTEXF_NONE)
{
WARN("Sampler state %u has magfilter D3DTEXF_NONE, returning D3DERR_UNSUPPORTEDTEXTUREFILTER\n", i);
return WINED3DERR_UNSUPPORTEDTEXTUREFILTER;
}
- texture = This->stateBlock->state.textures[i];
- if (!texture || texture->resource.format->Flags & WINED3DFMT_FLAG_FILTERING) continue;
+ texture = state->textures[i];
+ if (!texture || texture->resource.format->flags & WINED3DFMT_FLAG_FILTERING) continue;
- if (This->stateBlock->state.sampler_states[i][WINED3DSAMP_MAGFILTER] != WINED3DTEXF_POINT)
+ if (state->sampler_states[i][WINED3DSAMP_MAGFILTER] != WINED3DTEXF_POINT)
{
WARN("Non-filterable texture and mag filter enabled on samper %u, returning E_FAIL\n", i);
return E_FAIL;
}
- if (This->stateBlock->state.sampler_states[i][WINED3DSAMP_MINFILTER] != WINED3DTEXF_POINT)
+ if (state->sampler_states[i][WINED3DSAMP_MINFILTER] != WINED3DTEXF_POINT)
{
WARN("Non-filterable texture and min filter enabled on samper %u, returning E_FAIL\n", i);
return E_FAIL;
}
- if (This->stateBlock->state.sampler_states[i][WINED3DSAMP_MIPFILTER] != WINED3DTEXF_NONE
- && This->stateBlock->state.sampler_states[i][WINED3DSAMP_MIPFILTER] != WINED3DTEXF_POINT)
+ if (state->sampler_states[i][WINED3DSAMP_MIPFILTER] != WINED3DTEXF_NONE
+ && state->sampler_states[i][WINED3DSAMP_MIPFILTER] != WINED3DTEXF_POINT)
{
WARN("Non-filterable texture and mip filter enabled on samper %u, returning E_FAIL\n", i);
return E_FAIL;
}
}
+ if (state->render_states[WINED3DRS_ZENABLE] || state->render_states[WINED3DRS_ZWRITEENABLE] ||
+ state->render_states[WINED3DRS_STENCILENABLE])
+ {
+ struct wined3d_surface *ds = device->fb.depth_stencil;
+ struct wined3d_surface *target = device->fb.render_targets[0];
+
+ if(ds && target
+ && (ds->resource.width < target->resource.width || ds->resource.height < target->resource.height))
+ {
+ WARN("Depth stencil is smaller than the color buffer, returning D3DERR_CONFLICTINGRENDERSTATE\n");
+ return WINED3DERR_CONFLICTINGRENDERSTATE;
+ }
+ }
+
/* return a sensible default */
- *pNumPasses = 1;
+ *num_passes = 1;
TRACE("returning D3D_OK\n");
return WINED3D_OK;
}
-static void dirtify_p8_texture_samplers(IWineD3DDeviceImpl *device)
+static void dirtify_p8_texture_samplers(struct wined3d_device *device)
{
- int i;
+ UINT i;
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
{
- IWineD3DBaseTextureImpl *texture = device->stateBlock->state.textures[i];
+ struct wined3d_texture *texture = device->stateBlock->state.textures[i];
if (texture && (texture->resource.format->id == WINED3DFMT_P8_UINT
|| texture->resource.format->id == WINED3DFMT_P8_UINT_A8_UNORM))
{
@@ -5137,147 +4515,172 @@ static void dirtify_p8_texture_samplers(IWineD3DDeviceImpl *device)
}
}
-static HRESULT WINAPI IWineD3DDeviceImpl_SetPaletteEntries(IWineD3DDevice *iface, UINT PaletteNumber, CONST PALETTEENTRY* pEntries) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int j;
- UINT NewSize;
- PALETTEENTRY **palettes;
+HRESULT CDECL wined3d_device_set_palette_entries(struct wined3d_device *device,
+ UINT palette_idx, const PALETTEENTRY *entries)
+{
+ UINT i;
- TRACE("(%p) : PaletteNumber %u\n", This, PaletteNumber);
+ TRACE("device %p, palette_idx %u, entries %p.\n", device, palette_idx, entries);
- if (PaletteNumber >= MAX_PALETTES) {
- ERR("(%p) : (%u) Out of range 0-%u, returning Invalid Call\n", This, PaletteNumber, MAX_PALETTES);
+ if (palette_idx >= MAX_PALETTES)
+ {
+ WARN("Invalid palette index %u.\n", palette_idx);
return WINED3DERR_INVALIDCALL;
}
- if (PaletteNumber >= This->NumberOfPalettes) {
- NewSize = This->NumberOfPalettes;
- do {
- NewSize *= 2;
- } while(PaletteNumber >= NewSize);
- palettes = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->palettes, sizeof(PALETTEENTRY*) * NewSize);
- if (!palettes) {
+ if (palette_idx >= device->palette_count)
+ {
+ UINT new_size = device->palette_count;
+ PALETTEENTRY **palettes;
+
+ do
+ {
+ new_size *= 2;
+ } while (palette_idx >= new_size);
+ palettes = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, device->palettes, sizeof(*palettes) * new_size);
+ if (!palettes)
+ {
ERR("Out of memory!\n");
return E_OUTOFMEMORY;
}
- This->palettes = palettes;
- This->NumberOfPalettes = NewSize;
+ device->palettes = palettes;
+ device->palette_count = new_size;
}
- if (!This->palettes[PaletteNumber]) {
- This->palettes[PaletteNumber] = HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY) * 256);
- if (!This->palettes[PaletteNumber]) {
+ if (!device->palettes[palette_idx])
+ {
+ device->palettes[palette_idx] = HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY) * 256);
+ if (!device->palettes[palette_idx])
+ {
ERR("Out of memory!\n");
return E_OUTOFMEMORY;
}
}
- for (j = 0; j < 256; ++j) {
- This->palettes[PaletteNumber][j].peRed = pEntries[j].peRed;
- This->palettes[PaletteNumber][j].peGreen = pEntries[j].peGreen;
- This->palettes[PaletteNumber][j].peBlue = pEntries[j].peBlue;
- This->palettes[PaletteNumber][j].peFlags = pEntries[j].peFlags;
- }
- if (PaletteNumber == This->currentPalette) dirtify_p8_texture_samplers(This);
- TRACE("(%p) : returning\n", This);
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_GetPaletteEntries(IWineD3DDevice *iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int j;
- TRACE("(%p) : PaletteNumber %u\n", This, PaletteNumber);
- if (PaletteNumber >= This->NumberOfPalettes || !This->palettes[PaletteNumber]) {
- /* What happens in such situation isn't documented; Native seems to silently abort
- on such conditions. Return Invalid Call. */
- ERR("(%p) : (%u) Nonexistent palette. NumberOfPalettes %u\n", This, PaletteNumber, This->NumberOfPalettes);
- return WINED3DERR_INVALIDCALL;
- }
- for (j = 0; j < 256; ++j) {
- pEntries[j].peRed = This->palettes[PaletteNumber][j].peRed;
- pEntries[j].peGreen = This->palettes[PaletteNumber][j].peGreen;
- pEntries[j].peBlue = This->palettes[PaletteNumber][j].peBlue;
- pEntries[j].peFlags = This->palettes[PaletteNumber][j].peFlags;
- }
- TRACE("(%p) : returning\n", This);
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_SetCurrentTexturePalette(IWineD3DDevice *iface, UINT PaletteNumber) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- TRACE("(%p) : PaletteNumber %u\n", This, PaletteNumber);
- /* Native appears to silently abort on attempt to make an uninitialized palette current and render.
- (tested with reference rasterizer). Return Invalid Call. */
- if (PaletteNumber >= This->NumberOfPalettes || !This->palettes[PaletteNumber]) {
- ERR("(%p) : (%u) Nonexistent palette. NumberOfPalettes %u\n", This, PaletteNumber, This->NumberOfPalettes);
- return WINED3DERR_INVALIDCALL;
- }
- /*TODO: stateblocks */
- if (This->currentPalette != PaletteNumber) {
- This->currentPalette = PaletteNumber;
- dirtify_p8_texture_samplers(This);
- }
- TRACE("(%p) : returning\n", This);
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DDeviceImpl_GetCurrentTexturePalette(IWineD3DDevice *iface, UINT* PaletteNumber) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-
- if (!PaletteNumber)
+ for (i = 0; i < 256; ++i)
{
- WARN("(%p) : returning Invalid Call\n", This);
- return WINED3DERR_INVALIDCALL;
+ device->palettes[palette_idx][i].peRed = entries[i].peRed;
+ device->palettes[palette_idx][i].peGreen = entries[i].peGreen;
+ device->palettes[palette_idx][i].peBlue = entries[i].peBlue;
+ device->palettes[palette_idx][i].peFlags = entries[i].peFlags;
}
- /*TODO: stateblocks */
- *PaletteNumber = This->currentPalette;
- TRACE("(%p) : returning %u\n", This, *PaletteNumber);
+
+ if (palette_idx == device->currentPalette)
+ dirtify_p8_texture_samplers(device);
+
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_SetSoftwareVertexProcessing(IWineD3DDevice *iface, BOOL bSoftware) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+HRESULT CDECL wined3d_device_get_palette_entries(struct wined3d_device *device,
+ UINT palette_idx, PALETTEENTRY *entries)
+{
+ UINT i;
+
+ TRACE("device %p, palette_idx %u, entries %p.\n", device, palette_idx, entries);
+
+ if (palette_idx >= device->palette_count || !device->palettes[palette_idx])
+ {
+ /* What happens in such situation isn't documented; Native seems to
+ * silently abort on such conditions. */
+ WARN("Invalid palette index %u.\n", palette_idx);
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ for (i = 0; i < 256; ++i)
+ {
+ entries[i].peRed = device->palettes[palette_idx][i].peRed;
+ entries[i].peGreen = device->palettes[palette_idx][i].peGreen;
+ entries[i].peBlue = device->palettes[palette_idx][i].peBlue;
+ entries[i].peFlags = device->palettes[palette_idx][i].peFlags;
+ }
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_set_current_texture_palette(struct wined3d_device *device, UINT palette_idx)
+{
+ TRACE("device %p, palette_idx %u.\n", device, palette_idx);
+
+ /* Native appears to silently abort on attempt to make an uninitialized
+ * palette current and render. (tested with reference rasterizer). */
+ if (palette_idx >= device->palette_count || !device->palettes[palette_idx])
+ {
+ WARN("Invalid palette index %u.\n", palette_idx);
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ /* TODO: stateblocks? */
+ if (device->currentPalette != palette_idx)
+ {
+ device->currentPalette = palette_idx;
+ dirtify_p8_texture_samplers(device);
+ }
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_get_current_texture_palette(struct wined3d_device *device, UINT *palette_idx)
+{
+ TRACE("device %p, palette_idx %p.\n", device, palette_idx);
+
+ if (!palette_idx)
+ return WINED3DERR_INVALIDCALL;
+
+ *palette_idx = device->currentPalette;
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_device_set_software_vertex_processing(struct wined3d_device *device, BOOL software)
+{
static BOOL warned;
+
+ TRACE("device %p, software %#x.\n", device, software);
+
if (!warned)
{
- FIXME("(%p) : stub\n", This);
+ FIXME("device %p, software %#x stub!\n", device, software);
warned = TRUE;
}
- This->softwareVertexProcessing = bSoftware;
+ device->softwareVertexProcessing = software;
+
return WINED3D_OK;
}
-
-static BOOL WINAPI IWineD3DDeviceImpl_GetSoftwareVertexProcessing(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+BOOL CDECL wined3d_device_get_software_vertex_processing(struct wined3d_device *device)
+{
static BOOL warned;
+
+ TRACE("device %p.\n", device);
+
if (!warned)
{
- FIXME("(%p) : stub\n", This);
+ TRACE("device %p stub!\n", device);
warned = TRUE;
}
- return This->softwareVertexProcessing;
+
+ return device->softwareVertexProcessing;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetRasterStatus(IWineD3DDevice *iface,
+HRESULT CDECL wined3d_device_get_raster_status(struct wined3d_device *device,
UINT swapchain_idx, WINED3DRASTER_STATUS *raster_status)
{
- IWineD3DSwapChain *swapchain;
+ struct wined3d_swapchain *swapchain;
HRESULT hr;
- TRACE("iface %p, swapchain_idx %u, raster_status %p.\n",
- iface, swapchain_idx, raster_status);
+ TRACE("device %p, swapchain_idx %u, raster_status %p.\n",
+ device, swapchain_idx, raster_status);
- hr = IWineD3DDeviceImpl_GetSwapChain(iface, swapchain_idx, &swapchain);
+ hr = wined3d_device_get_swapchain(device, swapchain_idx, &swapchain);
if (FAILED(hr))
{
WARN("Failed to get swapchain %u, hr %#x.\n", swapchain_idx, hr);
return hr;
}
- hr = IWineD3DSwapChain_GetRasterStatus(swapchain, raster_status);
- IWineD3DSwapChain_Release(swapchain);
+ hr = wined3d_swapchain_get_raster_status(swapchain, raster_status);
+ wined3d_swapchain_decref(swapchain);
if (FAILED(hr))
{
WARN("Failed to get raster status, hr %#x.\n", hr);
@@ -5287,37 +4690,43 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetRasterStatus(IWineD3DDevice *iface,
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_SetNPatchMode(IWineD3DDevice *iface, float nSegments)
+HRESULT CDECL wined3d_device_set_npatch_mode(struct wined3d_device *device, float segments)
{
static BOOL warned;
- if(nSegments != 0.0f) {
+
+ TRACE("device %p, segments %.8e.\n", device, segments);
+
+ if (segments != 0.0f)
+ {
if (!warned)
{
- FIXME("iface %p, nSegments %.8e stub!\n", iface, nSegments);
+ FIXME("device %p, segments %.8e stub!\n", device, segments);
warned = TRUE;
}
}
+
return WINED3D_OK;
}
-static float WINAPI IWineD3DDeviceImpl_GetNPatchMode(IWineD3DDevice *iface)
+float CDECL wined3d_device_get_npatch_mode(struct wined3d_device *device)
{
static BOOL warned;
+
+ TRACE("device %p.\n", device);
+
if (!warned)
{
- FIXME("iface %p stub!\n", iface);
+ FIXME("device %p stub!\n", device);
warned = TRUE;
}
+
return 0.0f;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
- IWineD3DSurface *src_surface, const RECT *src_rect,
- IWineD3DSurface *dst_surface, const POINT *dst_point)
+HRESULT CDECL wined3d_device_update_surface(struct wined3d_device *device,
+ struct wined3d_surface *src_surface, const RECT *src_rect,
+ struct wined3d_surface *dst_surface, const POINT *dst_point)
{
- IWineD3DSurfaceImpl *src_impl = (IWineD3DSurfaceImpl *)src_surface;
- IWineD3DSurfaceImpl *dst_impl = (IWineD3DSurfaceImpl *)dst_surface;
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
const struct wined3d_format *src_format;
const struct wined3d_format *dst_format;
const struct wined3d_gl_info *gl_info;
@@ -5330,19 +4739,19 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
DWORD sampler;
struct wined3d_format format;
- TRACE("iface %p, src_surface %p, src_rect %s, dst_surface %p, dst_point %s.\n",
- iface, src_surface, wine_dbgstr_rect(src_rect),
+ TRACE("device %p, src_surface %p, src_rect %s, dst_surface %p, dst_point %s.\n",
+ device, src_surface, wine_dbgstr_rect(src_rect),
dst_surface, wine_dbgstr_point(dst_point));
- if (src_impl->resource.pool != WINED3DPOOL_SYSTEMMEM || dst_impl->resource.pool != WINED3DPOOL_DEFAULT)
+ if (src_surface->resource.pool != WINED3DPOOL_SYSTEMMEM || dst_surface->resource.pool != WINED3DPOOL_DEFAULT)
{
WARN("source %p must be SYSTEMMEM and dest %p must be DEFAULT, returning WINED3DERR_INVALIDCALL\n",
src_surface, dst_surface);
return WINED3DERR_INVALIDCALL;
}
- src_format = src_impl->resource.format;
- dst_format = dst_impl->resource.format;
+ src_format = src_surface->resource.format;
+ dst_format = dst_surface->resource.format;
if (src_format->id != dst_format->id)
{
@@ -5357,11 +4766,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
* surface to the destination's sysmem copy. If surface conversion is
* needed, use BltFast instead to copy in sysmem and use regular surface
* loading. */
- d3dfmt_get_conv(dst_impl, FALSE, TRUE, &format, &convert);
+ d3dfmt_get_conv(dst_surface, FALSE, TRUE, &format, &convert);
if (convert != NO_CONVERSION || format.convert)
- return IWineD3DSurface_BltFast(dst_surface, dst_x, dst_y, src_surface, src_rect, 0);
+ return wined3d_surface_bltfast(dst_surface, dst_x, dst_y, src_surface, src_rect, 0);
- context = context_acquire(This, NULL);
+ context = context_acquire(device, NULL);
gl_info = context->gl_info;
ENTER_GL();
@@ -5370,20 +4779,20 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
LEAVE_GL();
/* Make sure the surface is loaded and up to date */
- surface_internal_preload(dst_impl, SRGB_RGB);
- IWineD3DSurface_BindTexture(dst_surface, FALSE);
+ surface_internal_preload(dst_surface, SRGB_RGB);
+ surface_bind(dst_surface, gl_info, FALSE);
- src_w = src_impl->currentDesc.Width;
- src_h = src_impl->currentDesc.Height;
+ src_w = src_surface->resource.width;
+ src_h = src_surface->resource.height;
update_w = src_rect ? src_rect->right - src_rect->left : src_w;
update_h = src_rect ? src_rect->bottom - src_rect->top : src_h;
- data = IWineD3DSurface_GetData(src_surface);
+ data = src_surface->resource.allocatedMemory;
if (!data) ERR("Source surface has no allocated memory, but should be a sysmem surface.\n");
ENTER_GL();
- if (dst_format->Flags & WINED3DFMT_FLAG_COMPRESSED)
+ if (dst_format->flags & WINED3DFMT_FLAG_COMPRESSED)
{
UINT row_length = wined3d_format_calculate_size(src_format, 1, update_w, 1);
UINT row_count = (update_h + src_format->block_height - 1) / src_format->block_height;
@@ -5396,12 +4805,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
}
TRACE("glCompressedTexSubImage2DARB, target %#x, level %d, x %d, y %d, w %d, h %d, "
- "format %#x, image_size %#x, data %p.\n", dst_impl->texture_target, dst_impl->texture_level,
+ "format %#x, image_size %#x, data %p.\n", dst_surface->texture_target, dst_surface->texture_level,
dst_x, dst_y, update_w, update_h, dst_format->glFormat, row_count * row_length, data);
if (row_length == src_pitch)
{
- GL_EXTCALL(glCompressedTexSubImage2DARB(dst_impl->texture_target, dst_impl->texture_level,
+ GL_EXTCALL(glCompressedTexSubImage2DARB(dst_surface->texture_target, dst_surface->texture_level,
dst_x, dst_y, update_w, update_h, dst_format->glInternal, row_count * row_length, data));
}
else
@@ -5412,7 +4821,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
* can't use the unpack row length like below. */
for (row = 0, y = dst_y; row < row_count; ++row)
{
- GL_EXTCALL(glCompressedTexSubImage2DARB(dst_impl->texture_target, dst_impl->texture_level,
+ GL_EXTCALL(glCompressedTexSubImage2DARB(dst_surface->texture_target, dst_surface->texture_level,
dst_x, y, update_w, src_format->block_height, dst_format->glInternal, row_length, data));
y += src_format->block_height;
data += src_pitch;
@@ -5429,11 +4838,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
}
TRACE("glTexSubImage2D, target %#x, level %d, x %d, y %d, w %d, h %d, format %#x, type %#x, data %p.\n",
- dst_impl->texture_target, dst_impl->texture_level, dst_x, dst_y,
+ dst_surface->texture_target, dst_surface->texture_level, dst_x, dst_y,
update_w, update_h, dst_format->glFormat, dst_format->glType, data);
glPixelStorei(GL_UNPACK_ROW_LENGTH, src_w);
- glTexSubImage2D(dst_impl->texture_target, dst_impl->texture_level, dst_x, dst_y,
+ glTexSubImage2D(dst_surface->texture_target, dst_surface->texture_level, dst_x, dst_y,
update_w, update_h, dst_format->glFormat, dst_format->glType, data);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
checkGLcall("glTexSubImage2D");
@@ -5442,51 +4851,61 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
LEAVE_GL();
context_release(context);
- surface_modify_location(dst_impl, SFLAG_INTEXTURE, TRUE);
- sampler = This->rev_tex_unit_map[0];
+ surface_modify_location(dst_surface, SFLAG_INTEXTURE, TRUE);
+ sampler = device->rev_tex_unit_map[0];
if (sampler != WINED3D_UNMAPPED_STAGE)
{
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(sampler));
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(sampler));
}
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawRectPatch(IWineD3DDevice *iface, UINT Handle, CONST float* pNumSegs, CONST WINED3DRECTPATCH_INFO* pRectPatchInfo) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+HRESULT CDECL wined3d_device_draw_rect_patch(struct wined3d_device *device, UINT handle,
+ const float *num_segs, const WINED3DRECTPATCH_INFO *rect_patch_info)
+{
struct WineD3DRectPatch *patch;
GLenum old_primitive_type;
unsigned int i;
struct list *e;
BOOL found;
- TRACE("(%p) Handle(%d) noSegs(%p) rectpatch(%p)\n", This, Handle, pNumSegs, pRectPatchInfo);
- if(!(Handle || pRectPatchInfo)) {
+ TRACE("device %p, handle %#x, num_segs %p, rect_patch_info %p.\n",
+ device, handle, num_segs, rect_patch_info);
+
+ if (!(handle || rect_patch_info))
+ {
/* TODO: Write a test for the return value, thus the FIXME */
- FIXME("Both Handle and pRectPatchInfo are NULL\n");
+ FIXME("Both handle and rect_patch_info are NULL.\n");
return WINED3DERR_INVALIDCALL;
}
- if(Handle) {
- i = PATCHMAP_HASHFUNC(Handle);
+ if (handle)
+ {
+ i = PATCHMAP_HASHFUNC(handle);
found = FALSE;
- LIST_FOR_EACH(e, &This->patches[i]) {
+ LIST_FOR_EACH(e, &device->patches[i])
+ {
patch = LIST_ENTRY(e, struct WineD3DRectPatch, entry);
- if(patch->Handle == Handle) {
+ if (patch->Handle == handle)
+ {
found = TRUE;
break;
}
}
- if(!found) {
+ if (!found)
+ {
TRACE("Patch does not exist. Creating a new one\n");
patch = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*patch));
- patch->Handle = Handle;
- list_add_head(&This->patches[i], &patch->entry);
+ patch->Handle = handle;
+ list_add_head(&device->patches[i], &patch->entry);
} else {
TRACE("Found existing patch %p\n", patch);
}
- } else {
+ }
+ else
+ {
/* Since opengl does not load tesselated vertex attributes into numbered vertex
* attributes we have to tesselate, read back, and draw. This needs a patch
* management structure instance. Create one.
@@ -5498,68 +4917,73 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawRectPatch(IWineD3DDevice *iface, UI
patch = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*patch));
}
- if (pNumSegs[0] != patch->numSegs[0] || pNumSegs[1] != patch->numSegs[1]
- || pNumSegs[2] != patch->numSegs[2] || pNumSegs[3] != patch->numSegs[3]
- || (pRectPatchInfo && memcmp(pRectPatchInfo, &patch->RectPatchInfo, sizeof(*pRectPatchInfo))))
+ if (num_segs[0] != patch->numSegs[0] || num_segs[1] != patch->numSegs[1]
+ || num_segs[2] != patch->numSegs[2] || num_segs[3] != patch->numSegs[3]
+ || (rect_patch_info && memcmp(rect_patch_info, &patch->RectPatchInfo, sizeof(*rect_patch_info))))
{
HRESULT hr;
TRACE("Tesselation density or patch info changed, retesselating\n");
- if(pRectPatchInfo) {
- patch->RectPatchInfo = *pRectPatchInfo;
- }
- patch->numSegs[0] = pNumSegs[0];
- patch->numSegs[1] = pNumSegs[1];
- patch->numSegs[2] = pNumSegs[2];
- patch->numSegs[3] = pNumSegs[3];
+ if (rect_patch_info)
+ patch->RectPatchInfo = *rect_patch_info;
- hr = tesselate_rectpatch(This, patch);
- if(FAILED(hr)) {
- WARN("Patch tesselation failed\n");
+ patch->numSegs[0] = num_segs[0];
+ patch->numSegs[1] = num_segs[1];
+ patch->numSegs[2] = num_segs[2];
+ patch->numSegs[3] = num_segs[3];
+
+ hr = tesselate_rectpatch(device, patch);
+ if (FAILED(hr))
+ {
+ WARN("Patch tesselation failed.\n");
/* Do not release the handle to store the params of the patch */
- if(!Handle) {
+ if (!handle)
HeapFree(GetProcessHeap(), 0, patch);
- }
+
return hr;
}
}
- This->currentPatch = patch;
- old_primitive_type = This->stateBlock->state.gl_primitive_type;
- This->stateBlock->state.gl_primitive_type = GL_TRIANGLES;
- IWineD3DDevice_DrawPrimitiveStrided(iface, patch->numSegs[0] * patch->numSegs[1] * 2 * 3, &patch->strided);
- This->stateBlock->state.gl_primitive_type = old_primitive_type;
- This->currentPatch = NULL;
+ device->currentPatch = patch;
+ old_primitive_type = device->stateBlock->state.gl_primitive_type;
+ device->stateBlock->state.gl_primitive_type = GL_TRIANGLES;
+ wined3d_device_draw_primitive_strided(device, patch->numSegs[0] * patch->numSegs[1] * 2 * 3, &patch->strided);
+ device->stateBlock->state.gl_primitive_type = old_primitive_type;
+ device->currentPatch = NULL;
/* Destroy uncached patches */
- if(!Handle) {
+ if (!handle)
+ {
HeapFree(GetProcessHeap(), 0, patch->mem);
HeapFree(GetProcessHeap(), 0, patch);
}
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawTriPatch(IWineD3DDevice *iface,
- UINT handle, const float *segment_count, const WINED3DTRIPATCH_INFO *patch_info)
+HRESULT CDECL wined3d_device_draw_tri_patch(struct wined3d_device *device, UINT handle,
+ const float *segment_count, const WINED3DTRIPATCH_INFO *patch_info)
{
- FIXME("iface %p, handle %#x, segment_count %p, patch_info %p stub!\n",
- iface, handle, segment_count, patch_info);
+ FIXME("device %p, handle %#x, segment_count %p, patch_info %p stub!\n",
+ device, handle, segment_count, patch_info);
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_DeletePatch(IWineD3DDevice *iface, UINT Handle) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- int i;
+HRESULT CDECL wined3d_device_delete_patch(struct wined3d_device *device, UINT handle)
+{
struct WineD3DRectPatch *patch;
struct list *e;
- TRACE("(%p) Handle(%d)\n", This, Handle);
+ int i;
- i = PATCHMAP_HASHFUNC(Handle);
- LIST_FOR_EACH(e, &This->patches[i]) {
+ TRACE("device %p, handle %#x.\n", device, handle);
+
+ i = PATCHMAP_HASHFUNC(handle);
+ LIST_FOR_EACH(e, &device->patches[i])
+ {
patch = LIST_ENTRY(e, struct WineD3DRectPatch, entry);
- if(patch->Handle == Handle) {
+ if (patch->Handle == handle)
+ {
TRACE("Deleting patch %p\n", patch);
list_remove(&patch->entry);
HeapFree(GetProcessHeap(), 0, patch->mem);
@@ -5574,59 +4998,45 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DeletePatch(IWineD3DDevice *iface, UINT
}
/* Do not call while under the GL lock. */
-static HRESULT WINAPI IWineD3DDeviceImpl_ColorFill(IWineD3DDevice *iface,
- IWineD3DSurface *surface, const RECT *rect, const WINED3DCOLORVALUE *color)
+HRESULT CDECL wined3d_device_color_fill(struct wined3d_device *device,
+ struct wined3d_surface *surface, const RECT *rect, const WINED3DCOLORVALUE *color)
{
- IWineD3DSurfaceImpl *s = (IWineD3DSurfaceImpl *)surface;
-
- TRACE("iface %p, surface %p, rect %s, color {%.8e, %.8e, %.8e, %.8e}.\n",
- iface, surface, wine_dbgstr_rect(rect),
+ TRACE("device %p, surface %p, rect %s, color {%.8e, %.8e, %.8e, %.8e}.\n",
+ device, surface, wine_dbgstr_rect(rect),
color->r, color->g, color->b, color->a);
- if (s->resource.pool != WINED3DPOOL_DEFAULT && s->resource.pool != WINED3DPOOL_SYSTEMMEM)
+ if (surface->resource.pool != WINED3DPOOL_DEFAULT && surface->resource.pool != WINED3DPOOL_SYSTEMMEM)
{
FIXME("call to colorfill with non WINED3DPOOL_DEFAULT or WINED3DPOOL_SYSTEMMEM surface\n");
return WINED3DERR_INVALIDCALL;
}
- return surface_color_fill(s, rect, color);
+ return surface_color_fill(surface, rect, color);
}
/* Do not call while under the GL lock. */
-static void WINAPI IWineD3DDeviceImpl_ClearRendertargetView(IWineD3DDevice *iface,
- IWineD3DRendertargetView *rendertarget_view, const WINED3DCOLORVALUE *color)
+void CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *device,
+ struct wined3d_rendertarget_view *rendertarget_view, const WINED3DCOLORVALUE *color)
{
- IWineD3DResource *resource;
+ struct wined3d_resource *resource;
HRESULT hr;
- hr = IWineD3DRendertargetView_GetResource(rendertarget_view, &resource);
- if (FAILED(hr))
- {
- ERR("Failed to get resource, hr %#x\n", hr);
- return;
- }
-
- if (IWineD3DResource_GetType(resource) != WINED3DRTYPE_SURFACE)
+ resource = rendertarget_view->resource;
+ if (resource->resourceType != WINED3DRTYPE_SURFACE)
{
FIXME("Only supported on surface resources\n");
- IWineD3DResource_Release(resource);
return;
}
- hr = surface_color_fill((IWineD3DSurfaceImpl *)resource, NULL, color);
+ hr = surface_color_fill(surface_from_resource(resource), NULL, color);
if (FAILED(hr)) ERR("Color fill failed, hr %#x.\n", hr);
-
- IWineD3DResource_Release(resource);
}
-/* rendertarget and depth stencil functions */
-static HRESULT WINAPI IWineD3DDeviceImpl_GetRenderTarget(IWineD3DDevice *iface,
- DWORD render_target_idx, IWineD3DSurface **render_target)
+HRESULT CDECL wined3d_device_get_render_target(struct wined3d_device *device,
+ UINT render_target_idx, struct wined3d_surface **render_target)
{
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
-
- TRACE("iface %p, render_target_idx %u, render_target %p.\n",
- iface, render_target_idx, render_target);
+ TRACE("device %p, render_target_idx %u, render_target %p.\n",
+ device, render_target_idx, render_target);
if (render_target_idx >= device->adapter->gl_info.limits.buffers)
{
@@ -5634,36 +5044,37 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetRenderTarget(IWineD3DDevice *iface,
return WINED3DERR_INVALIDCALL;
}
- *render_target = (IWineD3DSurface *)device->render_targets[render_target_idx];
- if (*render_target) IWineD3DSurface_AddRef(*render_target);
+ *render_target = device->fb.render_targets[render_target_idx];
+ if (*render_target)
+ wined3d_surface_incref(*render_target);
TRACE("Returning render target %p.\n", *render_target);
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetDepthStencilSurface(IWineD3DDevice *iface, IWineD3DSurface **depth_stencil)
+HRESULT CDECL wined3d_device_get_depth_stencil(struct wined3d_device *device, struct wined3d_surface **depth_stencil)
{
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
+ TRACE("device %p, depth_stencil %p.\n", device, depth_stencil);
- TRACE("iface %p, depth_stencil %p.\n", iface, depth_stencil);
-
- *depth_stencil = (IWineD3DSurface *)device->depth_stencil;
+ *depth_stencil = device->fb.depth_stencil;
TRACE("Returning depth/stencil surface %p.\n", *depth_stencil);
- if (!*depth_stencil) return WINED3DERR_NOTFOUND;
- IWineD3DSurface_AddRef(*depth_stencil);
+
+ if (!*depth_stencil)
+ return WINED3DERR_NOTFOUND;
+
+ wined3d_surface_incref(*depth_stencil);
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface,
- DWORD render_target_idx, IWineD3DSurface *render_target, BOOL set_viewport)
+HRESULT CDECL wined3d_device_set_render_target(struct wined3d_device *device,
+ UINT render_target_idx, struct wined3d_surface *render_target, BOOL set_viewport)
{
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
- IWineD3DSurfaceImpl *prev;
+ struct wined3d_surface *prev;
- TRACE("iface %p, render_target_idx %u, render_target %p, set_viewport %#x.\n",
- iface, render_target_idx, render_target, set_viewport);
+ TRACE("device %p, render_target_idx %u, render_target %p, set_viewport %#x.\n",
+ device, render_target_idx, render_target, set_viewport);
if (render_target_idx >= device->adapter->gl_info.limits.buffers)
{
@@ -5671,8 +5082,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface,
return WINED3DERR_INVALIDCALL;
}
- prev = device->render_targets[render_target_idx];
- if (render_target == (IWineD3DSurface *)prev)
+ prev = device->fb.render_targets[render_target_idx];
+ if (render_target == prev)
{
TRACE("Trying to do a NOP SetRenderTarget operation.\n");
return WINED3D_OK;
@@ -5685,17 +5096,19 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface,
return WINED3DERR_INVALIDCALL;
}
- if (render_target && !(((IWineD3DSurfaceImpl *)render_target)->resource.usage & WINED3DUSAGE_RENDERTARGET))
+ if (render_target && !(render_target->resource.usage & WINED3DUSAGE_RENDERTARGET))
{
FIXME("Surface %p doesn't have render target usage.\n", render_target);
return WINED3DERR_INVALIDCALL;
}
- if (render_target) IWineD3DSurface_AddRef(render_target);
- device->render_targets[render_target_idx] = (IWineD3DSurfaceImpl *)render_target;
+ if (render_target)
+ wined3d_surface_incref(render_target);
+ device->fb.render_targets[render_target_idx] = render_target;
/* Release after the assignment, to prevent device_resource_released()
* from seeing the surface as still in use. */
- if (prev) IWineD3DSurface_Release((IWineD3DSurface *)prev);
+ if (prev)
+ wined3d_surface_decref(prev);
/* Render target 0 is special. */
if (!render_target_idx && set_viewport)
@@ -5703,8 +5116,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface,
/* Set the viewport and scissor rectangles, if requested. Tests show
* that stateblock recording is ignored, the change goes directly
* into the primary stateblock. */
- device->stateBlock->state.viewport.Height = device->render_targets[0]->currentDesc.Height;
- device->stateBlock->state.viewport.Width = device->render_targets[0]->currentDesc.Width;
+ device->stateBlock->state.viewport.Height = device->fb.render_targets[0]->resource.height;
+ device->stateBlock->state.viewport.Width = device->fb.render_targets[0]->resource.width;
device->stateBlock->state.viewport.X = 0;
device->stateBlock->state.viewport.Y = 0;
device->stateBlock->state.viewport.MaxZ = 1.0f;
@@ -5721,175 +5134,172 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface,
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_SetDepthStencilSurface(IWineD3DDevice *iface, IWineD3DSurface *depth_stencil)
+HRESULT CDECL wined3d_device_set_depth_stencil(struct wined3d_device *device, struct wined3d_surface *depth_stencil)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DSurfaceImpl *tmp;
+ struct wined3d_surface *prev = device->fb.depth_stencil;
- TRACE("device %p, depth_stencil %p, old depth_stencil %p.\n", This, depth_stencil, This->depth_stencil);
+ TRACE("device %p, depth_stencil %p, old depth_stencil %p.\n",
+ device, depth_stencil, prev);
- if (This->depth_stencil == (IWineD3DSurfaceImpl *)depth_stencil)
+ if (prev == depth_stencil)
{
TRACE("Trying to do a NOP SetRenderTarget operation.\n");
return WINED3D_OK;
}
- if (This->depth_stencil)
+ if (prev)
{
- if (((IWineD3DSwapChainImpl *)This->swapchains[0])->presentParms.Flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL
- || This->depth_stencil->Flags & SFLAG_DISCARD)
+ if (device->swapchains[0]->presentParms.Flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL
+ || prev->flags & SFLAG_DISCARD)
{
- surface_modify_ds_location(This->depth_stencil, SFLAG_DS_DISCARDED,
- This->depth_stencil->currentDesc.Width,
- This->depth_stencil->currentDesc.Height);
- if (This->depth_stencil == This->onscreen_depth_stencil)
+ surface_modify_ds_location(prev, SFLAG_DS_DISCARDED,
+ prev->resource.width, prev->resource.height);
+ if (prev == device->onscreen_depth_stencil)
{
- IWineD3DSurface_Release((IWineD3DSurface *)This->onscreen_depth_stencil);
- This->onscreen_depth_stencil = NULL;
+ wined3d_surface_decref(device->onscreen_depth_stencil);
+ device->onscreen_depth_stencil = NULL;
}
}
}
- tmp = This->depth_stencil;
- This->depth_stencil = (IWineD3DSurfaceImpl *)depth_stencil;
- if (This->depth_stencil) IWineD3DSurface_AddRef((IWineD3DSurface *)This->depth_stencil);
- if (tmp) IWineD3DSurface_Release((IWineD3DSurface *)tmp);
+ device->fb.depth_stencil = depth_stencil;
+ if (depth_stencil)
+ wined3d_surface_incref(depth_stencil);
+ if (prev)
+ wined3d_surface_decref(prev);
- if ((!tmp && depth_stencil) || (!depth_stencil && tmp))
+ if (!prev != !depth_stencil)
{
/* Swapping NULL / non NULL depth stencil affects the depth and tests */
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_ZENABLE));
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_STENCILENABLE));
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_STENCILWRITEMASK));
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_ZENABLE));
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_STENCILENABLE));
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_STENCILWRITEMASK));
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_DEPTHBIAS));
+ }
+ else if (prev && prev->resource.format->depth_size != depth_stencil->resource.format->depth_size)
+ {
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_DEPTHBIAS));
}
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice *iface,
- UINT XHotSpot, UINT YHotSpot, IWineD3DSurface *cursor_image)
+HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device,
+ UINT x_hotspot, UINT y_hotspot, struct wined3d_surface *cursor_image)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- IWineD3DSurfaceImpl *s = (IWineD3DSurfaceImpl *)cursor_image;
WINED3DLOCKED_RECT lockedRect;
- TRACE("iface %p, hotspot_x %u, hotspot_y %u, cursor_image %p.\n",
- iface, XHotSpot, YHotSpot, cursor_image);
+ TRACE("device %p, x_hotspot %u, y_hotspot %u, cursor_image %p.\n",
+ device, x_hotspot, y_hotspot, cursor_image);
/* some basic validation checks */
- if (This->cursorTexture)
+ if (device->cursorTexture)
{
- struct wined3d_context *context = context_acquire(This, NULL);
+ struct wined3d_context *context = context_acquire(device, NULL);
ENTER_GL();
- glDeleteTextures(1, &This->cursorTexture);
+ glDeleteTextures(1, &device->cursorTexture);
LEAVE_GL();
context_release(context);
- This->cursorTexture = 0;
+ device->cursorTexture = 0;
}
- if ((s->currentDesc.Width == 32) && (s->currentDesc.Height == 32))
- This->haveHardwareCursor = TRUE;
- else
- This->haveHardwareCursor = FALSE;
-
if (cursor_image)
{
WINED3DLOCKED_RECT rect;
/* MSDN: Cursor must be A8R8G8B8 */
- if (s->resource.format->id != WINED3DFMT_B8G8R8A8_UNORM)
+ if (cursor_image->resource.format->id != WINED3DFMT_B8G8R8A8_UNORM)
{
WARN("surface %p has an invalid format.\n", cursor_image);
return WINED3DERR_INVALIDCALL;
}
/* MSDN: Cursor must be smaller than the display mode */
- if (s->currentDesc.Width > This->ddraw_width
- || s->currentDesc.Height > This->ddraw_height)
+ if (cursor_image->resource.width > device->ddraw_width
+ || cursor_image->resource.height > device->ddraw_height)
{
WARN("Surface %p dimensions are %ux%u, but screen dimensions are %ux%u.\n",
- s, s->currentDesc.Width, s->currentDesc.Height, This->ddraw_width, This->ddraw_height);
+ cursor_image, cursor_image->resource.width, cursor_image->resource.height,
+ device->ddraw_width, device->ddraw_height);
return WINED3DERR_INVALIDCALL;
}
- if (!This->haveHardwareCursor) {
- /* TODO: MSDN: Cursor sizes must be a power of 2 */
+ /* TODO: MSDN: Cursor sizes must be a power of 2 */
- /* Do not store the surface's pointer because the application may
- * release it after setting the cursor image. Windows doesn't
- * addref the set surface, so we can't do this either without
- * creating circular refcount dependencies. Copy out the gl texture
- * instead.
- */
- This->cursorWidth = s->currentDesc.Width;
- This->cursorHeight = s->currentDesc.Height;
- if (SUCCEEDED(IWineD3DSurface_LockRect(cursor_image, &rect, NULL, WINED3DLOCK_READONLY)))
+ /* Do not store the surface's pointer because the application may
+ * release it after setting the cursor image. Windows doesn't
+ * addref the set surface, so we can't do this either without
+ * creating circular refcount dependencies. Copy out the gl texture
+ * instead. */
+ device->cursorWidth = cursor_image->resource.width;
+ device->cursorHeight = cursor_image->resource.height;
+ if (SUCCEEDED(wined3d_surface_map(cursor_image, &rect, NULL, WINED3DLOCK_READONLY)))
+ {
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+ const struct wined3d_format *format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM);
+ struct wined3d_context *context;
+ char *mem, *bits = rect.pBits;
+ GLint intfmt = format->glInternal;
+ GLint gl_format = format->glFormat;
+ GLint type = format->glType;
+ INT height = device->cursorHeight;
+ INT width = device->cursorWidth;
+ INT bpp = format->byte_count;
+ DWORD sampler;
+ INT i;
+
+ /* Reformat the texture memory (pitch and width can be
+ * different) */
+ mem = HeapAlloc(GetProcessHeap(), 0, width * height * bpp);
+ for(i = 0; i < height; i++)
+ memcpy(&mem[width * bpp * i], &bits[rect.Pitch * i], width * bpp);
+ wined3d_surface_unmap(cursor_image);
+
+ context = context_acquire(device, NULL);
+
+ ENTER_GL();
+
+ if (gl_info->supported[APPLE_CLIENT_STORAGE])
{
- const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
- const struct wined3d_format *format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM);
- struct wined3d_context *context;
- char *mem, *bits = rect.pBits;
- GLint intfmt = format->glInternal;
- GLint gl_format = format->glFormat;
- GLint type = format->glType;
- INT height = This->cursorHeight;
- INT width = This->cursorWidth;
- INT bpp = format->byte_count;
- DWORD sampler;
- INT i;
-
- /* Reformat the texture memory (pitch and width can be
- * different) */
- mem = HeapAlloc(GetProcessHeap(), 0, width * height * bpp);
- for(i = 0; i < height; i++)
- memcpy(&mem[width * bpp * i], &bits[rect.Pitch * i], width * bpp);
- IWineD3DSurface_UnlockRect(cursor_image);
-
- context = context_acquire(This, NULL);
-
- ENTER_GL();
-
- if (gl_info->supported[APPLE_CLIENT_STORAGE])
- {
- glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
- checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE)");
- }
-
- /* Make sure that a proper texture unit is selected */
- GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
- checkGLcall("glActiveTextureARB");
- sampler = This->rev_tex_unit_map[0];
- if (sampler != WINED3D_UNMAPPED_STAGE)
- {
- IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(sampler));
- }
- /* Create a new cursor texture */
- glGenTextures(1, &This->cursorTexture);
- checkGLcall("glGenTextures");
- glBindTexture(GL_TEXTURE_2D, This->cursorTexture);
- checkGLcall("glBindTexture");
- /* Copy the bitmap memory into the cursor texture */
- glTexImage2D(GL_TEXTURE_2D, 0, intfmt, width, height, 0, gl_format, type, mem);
- HeapFree(GetProcessHeap(), 0, mem);
- checkGLcall("glTexImage2D");
-
- if (gl_info->supported[APPLE_CLIENT_STORAGE])
- {
- glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
- checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)");
- }
-
- LEAVE_GL();
-
- context_release(context);
+ glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
+ checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE)");
}
- else
+
+ /* Make sure that a proper texture unit is selected */
+ GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
+ checkGLcall("glActiveTextureARB");
+ sampler = device->rev_tex_unit_map[0];
+ if (sampler != WINED3D_UNMAPPED_STAGE)
{
- FIXME("A cursor texture was not returned.\n");
- This->cursorTexture = 0;
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(sampler));
}
+ /* Create a new cursor texture */
+ glGenTextures(1, &device->cursorTexture);
+ checkGLcall("glGenTextures");
+ glBindTexture(GL_TEXTURE_2D, device->cursorTexture);
+ checkGLcall("glBindTexture");
+ /* Copy the bitmap memory into the cursor texture */
+ glTexImage2D(GL_TEXTURE_2D, 0, intfmt, width, height, 0, gl_format, type, mem);
+ checkGLcall("glTexImage2D");
+ HeapFree(GetProcessHeap(), 0, mem);
+
+ if (gl_info->supported[APPLE_CLIENT_STORAGE])
+ {
+ glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
+ checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)");
+ }
+
+ LEAVE_GL();
+
+ context_release(context);
}
else
+ {
+ FIXME("A cursor texture was not returned.\n");
+ device->cursorTexture = 0;
+ }
+
+ if (cursor_image->resource.width == 32 && cursor_image->resource.height == 32)
{
/* Draw a hardware cursor */
ICONINFO cursorInfo;
@@ -5898,104 +5308,126 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice *ifa
* 32-bit cursors. 32x32 bits split into 32-bit chunks == 32
* chunks. */
DWORD *maskBits = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- (s->currentDesc.Width * s->currentDesc.Height / 8));
- IWineD3DSurface_LockRect(cursor_image, &lockedRect, NULL,
+ (cursor_image->resource.width * cursor_image->resource.height / 8));
+ wined3d_surface_map(cursor_image, &lockedRect, NULL,
WINED3DLOCK_NO_DIRTY_UPDATE | WINED3DLOCK_READONLY);
- TRACE("width: %u height: %u.\n", s->currentDesc.Width, s->currentDesc.Height);
+ TRACE("width: %u height: %u.\n", cursor_image->resource.width, cursor_image->resource.height);
cursorInfo.fIcon = FALSE;
- cursorInfo.xHotspot = XHotSpot;
- cursorInfo.yHotspot = YHotSpot;
- cursorInfo.hbmMask = CreateBitmap(s->currentDesc.Width, s->currentDesc.Height, 1, 1, maskBits);
- cursorInfo.hbmColor = CreateBitmap(s->currentDesc.Width, s->currentDesc.Height, 1, 32, lockedRect.pBits);
- IWineD3DSurface_UnlockRect(cursor_image);
+ cursorInfo.xHotspot = x_hotspot;
+ cursorInfo.yHotspot = y_hotspot;
+ cursorInfo.hbmMask = CreateBitmap(cursor_image->resource.width, cursor_image->resource.height,
+ 1, 1, maskBits);
+ cursorInfo.hbmColor = CreateBitmap(cursor_image->resource.width, cursor_image->resource.height,
+ 1, 32, lockedRect.pBits);
+ wined3d_surface_unmap(cursor_image);
/* Create our cursor and clean up. */
cursor = CreateIconIndirect(&cursorInfo);
- SetCursor(cursor);
if (cursorInfo.hbmMask) DeleteObject(cursorInfo.hbmMask);
if (cursorInfo.hbmColor) DeleteObject(cursorInfo.hbmColor);
- if (This->hardwareCursor) DestroyCursor(This->hardwareCursor);
- This->hardwareCursor = cursor;
+ if (device->hardwareCursor) DestroyCursor(device->hardwareCursor);
+ device->hardwareCursor = cursor;
+ if (device->bCursorVisible) SetCursor( cursor );
HeapFree(GetProcessHeap(), 0, maskBits);
}
}
- This->xHotSpot = XHotSpot;
- This->yHotSpot = YHotSpot;
+ device->xHotSpot = x_hotspot;
+ device->yHotSpot = y_hotspot;
return WINED3D_OK;
}
-static void WINAPI IWineD3DDeviceImpl_SetCursorPosition(IWineD3DDevice* iface, int XScreenSpace, int YScreenSpace, DWORD Flags) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
- TRACE("(%p) : SetPos to (%u,%u)\n", This, XScreenSpace, YScreenSpace);
+void CDECL wined3d_device_set_cursor_position(struct wined3d_device *device,
+ int x_screen_space, int y_screen_space, DWORD flags)
+{
+ TRACE("device %p, x %d, y %d, flags %#x.\n",
+ device, x_screen_space, y_screen_space, flags);
- This->xScreenSpace = XScreenSpace;
- This->yScreenSpace = YScreenSpace;
-
- return;
+ device->xScreenSpace = x_screen_space;
+ device->yScreenSpace = y_screen_space;
+ /* switch to the software cursor if position diverges from the hardware one */
+ if (device->hardwareCursor)
+ {
+ POINT pt;
+ GetCursorPos( &pt );
+ if (x_screen_space != pt.x || y_screen_space != pt.y)
+ {
+ if (device->bCursorVisible) SetCursor( NULL );
+ DestroyCursor( device->hardwareCursor );
+ device->hardwareCursor = 0;
+ }
+ }
}
-static BOOL WINAPI IWineD3DDeviceImpl_ShowCursor(IWineD3DDevice* iface, BOOL bShow) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
- BOOL oldVisible = This->bCursorVisible;
- POINT pt;
+BOOL CDECL wined3d_device_show_cursor(struct wined3d_device *device, BOOL show)
+{
+ BOOL oldVisible = device->bCursorVisible;
- TRACE("(%p) : visible(%d)\n", This, bShow);
+ TRACE("device %p, show %#x.\n", device, show);
/*
* When ShowCursor is first called it should make the cursor appear at the OS's last
- * known cursor position. Because of this, some applications just repetitively call
- * ShowCursor in order to update the cursor's position. This behavior is undocumented.
+ * known cursor position.
*/
- GetCursorPos(&pt);
- This->xScreenSpace = pt.x;
- This->yScreenSpace = pt.y;
+ if (show && !oldVisible)
+ {
+ POINT pt;
+ GetCursorPos(&pt);
+ device->xScreenSpace = pt.x;
+ device->yScreenSpace = pt.y;
+ }
- if (This->haveHardwareCursor) {
- This->bCursorVisible = bShow;
- if (bShow)
- SetCursor(This->hardwareCursor);
+ if (device->hardwareCursor)
+ {
+ device->bCursorVisible = show;
+ if (show)
+ SetCursor(device->hardwareCursor);
else
SetCursor(NULL);
}
else
{
- if (This->cursorTexture)
- This->bCursorVisible = bShow;
+ if (device->cursorTexture)
+ device->bCursorVisible = show;
}
return oldVisible;
}
-static HRESULT WINAPI evict_managed_resource(IWineD3DResource *resource, void *data) {
+static HRESULT WINAPI evict_managed_resource(struct wined3d_resource *resource, void *data)
+{
TRACE("checking resource %p for eviction\n", resource);
- if(((IWineD3DResourceImpl *) resource)->resource.pool == WINED3DPOOL_MANAGED) {
- TRACE("Evicting %p\n", resource);
- IWineD3DResource_UnLoad(resource);
+
+ if (resource->pool == WINED3DPOOL_MANAGED)
+ {
+ TRACE("Evicting %p.\n", resource);
+ resource->resource_ops->resource_unload(resource);
}
- IWineD3DResource_Release(resource);
+
return S_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_EvictManagedResources(IWineD3DDevice *iface)
+HRESULT CDECL wined3d_device_evict_managed_resources(struct wined3d_device *device)
{
- TRACE("iface %p.\n", iface);
+ TRACE("device %p.\n", device);
- IWineD3DDevice_EnumResources(iface, evict_managed_resource, NULL);
+ wined3d_device_enum_resources(device, evict_managed_resource, NULL);
/* Invalidate stream sources, the buffer(s) may have been evicted. */
- IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)iface, STATE_STREAMSRC);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_STREAMSRC);
return WINED3D_OK;
}
-static HRESULT updateSurfaceDesc(IWineD3DSurfaceImpl *surface, const WINED3DPRESENT_PARAMETERS* pPresentationParameters)
+static HRESULT updateSurfaceDesc(struct wined3d_surface *surface,
+ const WINED3DPRESENT_PARAMETERS *pPresentationParameters)
{
- IWineD3DDeviceImpl *device = surface->resource.device;
+ struct wined3d_device *device = surface->resource.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
/* Reallocate proper memory for the front and back buffer and adjust their sizes */
- if(surface->Flags & SFLAG_DIBSECTION) {
+ if (surface->flags & SFLAG_DIBSECTION)
+ {
/* Release the DC */
SelectObject(surface->hDC, surface->dib.holdbitmap);
DeleteDC(surface->hDC);
@@ -6003,10 +5435,10 @@ static HRESULT updateSurfaceDesc(IWineD3DSurfaceImpl *surface, const WINED3DPRES
DeleteObject(surface->dib.DIBsection);
surface->dib.bitmap_data = NULL;
surface->resource.allocatedMemory = NULL;
- surface->Flags &= ~SFLAG_DIBSECTION;
+ surface->flags &= ~SFLAG_DIBSECTION;
}
- surface->currentDesc.Width = pPresentationParameters->BackBufferWidth;
- surface->currentDesc.Height = pPresentationParameters->BackBufferHeight;
+ surface->resource.width = pPresentationParameters->BackBufferWidth;
+ surface->resource.height = pPresentationParameters->BackBufferHeight;
if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] || gl_info->supported[ARB_TEXTURE_RECTANGLE]
|| gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT])
{
@@ -6026,18 +5458,21 @@ static HRESULT updateSurfaceDesc(IWineD3DSurfaceImpl *surface, const WINED3DPRES
LEAVE_GL();
context_release(context);
surface->texture_name = 0;
- surface->Flags &= ~SFLAG_CLIENT;
+ surface->flags &= ~SFLAG_CLIENT;
}
- if(surface->pow2Width != pPresentationParameters->BackBufferWidth ||
- surface->pow2Height != pPresentationParameters->BackBufferHeight) {
- surface->Flags |= SFLAG_NONPOW2;
- } else {
- surface->Flags &= ~SFLAG_NONPOW2;
+ if (surface->pow2Width != pPresentationParameters->BackBufferWidth
+ || surface->pow2Height != pPresentationParameters->BackBufferHeight)
+ {
+ surface->flags |= SFLAG_NONPOW2;
+ }
+ else
+ {
+ surface->flags &= ~SFLAG_NONPOW2;
}
HeapFree(GetProcessHeap(), 0, surface->resource.heapMemory);
surface->resource.allocatedMemory = NULL;
surface->resource.heapMemory = NULL;
- surface->resource.size = IWineD3DSurface_GetPitch((IWineD3DSurface *) surface) * surface->pow2Width;
+ surface->resource.size = wined3d_surface_get_pitch(surface) * surface->pow2Width;
/* Put all surfaces into sysmem - the drawable might disappear if the backbuffer was rendered
* to a FBO */
@@ -6048,14 +5483,7 @@ static HRESULT updateSurfaceDesc(IWineD3DSurfaceImpl *surface, const WINED3DPRES
return WINED3D_OK;
}
-static HRESULT WINAPI reset_unload_resources(IWineD3DResource *resource, void *data) {
- TRACE("Unloading resource %p\n", resource);
- IWineD3DResource_UnLoad(resource);
- IWineD3DResource_Release(resource);
- return S_OK;
-}
-
-static BOOL is_display_mode_supported(IWineD3DDeviceImpl *This, const WINED3DPRESENT_PARAMETERS *pp)
+static BOOL is_display_mode_supported(struct wined3d_device *device, const WINED3DPRESENT_PARAMETERS *pp)
{
UINT i, count;
WINED3DDISPLAYMODE m;
@@ -6066,61 +5494,62 @@ static BOOL is_display_mode_supported(IWineD3DDeviceImpl *This, const WINED3DPRE
if(!pp->BackBufferWidth) return TRUE;
if(!pp->BackBufferHeight) return TRUE;
- count = IWineD3D_GetAdapterModeCount(This->wined3d, This->adapter->ordinal, WINED3DFMT_UNKNOWN);
- for(i = 0; i < count; i++) {
+ count = wined3d_get_adapter_mode_count(device->wined3d, device->adapter->ordinal, WINED3DFMT_UNKNOWN);
+ for (i = 0; i < count; ++i)
+ {
memset(&m, 0, sizeof(m));
- hr = IWineD3D_EnumAdapterModes(This->wined3d, This->adapter->ordinal, WINED3DFMT_UNKNOWN, i, &m);
- if(FAILED(hr)) {
- ERR("EnumAdapterModes failed\n");
- }
- if(m.Width == pp->BackBufferWidth && m.Height == pp->BackBufferHeight) {
- /* Mode found, it is supported */
+ hr = wined3d_enum_adapter_modes(device->wined3d, device->adapter->ordinal, WINED3DFMT_UNKNOWN, i, &m);
+ if (FAILED(hr))
+ ERR("Failed to enumerate adapter mode.\n");
+ if (m.Width == pp->BackBufferWidth && m.Height == pp->BackBufferHeight)
+ /* Mode found, it is supported. */
return TRUE;
- }
}
/* Mode not found -> not supported */
return FALSE;
}
/* Do not call while under the GL lock. */
-static void delete_opengl_contexts(IWineD3DDevice *iface, IWineD3DSwapChainImpl *swapchain)
+static void delete_opengl_contexts(struct wined3d_device *device, struct wined3d_swapchain *swapchain)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
- IWineD3DBaseShaderImpl *shader;
+ struct wined3d_shader *shader;
- context = context_acquire(This, NULL);
+ context = context_acquire(device, NULL);
gl_info = context->gl_info;
- IWineD3DDevice_EnumResources(iface, reset_unload_resources, NULL);
- LIST_FOR_EACH_ENTRY(shader, &This->shaders, IWineD3DBaseShaderImpl, baseShader.shader_list_entry) {
- This->shader_backend->shader_destroy((IWineD3DBaseShader *) shader);
+ wined3d_device_enum_resources(device, device_unload_resource, NULL);
+ LIST_FOR_EACH_ENTRY(shader, &device->shaders, struct wined3d_shader, shader_list_entry)
+ {
+ device->shader_backend->shader_destroy(shader);
}
ENTER_GL();
- if(This->depth_blt_texture) {
- glDeleteTextures(1, &This->depth_blt_texture);
- This->depth_blt_texture = 0;
+ if (device->depth_blt_texture)
+ {
+ glDeleteTextures(1, &device->depth_blt_texture);
+ device->depth_blt_texture = 0;
}
- if (This->depth_blt_rb) {
- gl_info->fbo_ops.glDeleteRenderbuffers(1, &This->depth_blt_rb);
- This->depth_blt_rb = 0;
- This->depth_blt_rb_w = 0;
- This->depth_blt_rb_h = 0;
+ if (device->depth_blt_rb)
+ {
+ gl_info->fbo_ops.glDeleteRenderbuffers(1, &device->depth_blt_rb);
+ device->depth_blt_rb = 0;
+ device->depth_blt_rb_w = 0;
+ device->depth_blt_rb_h = 0;
}
LEAVE_GL();
- This->blitter->free_private(iface);
- This->frag_pipe->free_private(iface);
- This->shader_backend->shader_free_private(iface);
- destroy_dummy_textures(This, gl_info);
+ device->blitter->free_private(device);
+ device->frag_pipe->free_private(device);
+ device->shader_backend->shader_free_private(device);
+ destroy_dummy_textures(device, gl_info);
context_release(context);
- while (This->numContexts)
+ while (device->context_count)
{
- context_destroy(This, This->contexts[0]);
+ context_destroy(device, device->contexts[0]);
}
HeapFree(GetProcessHeap(), 0, swapchain->context);
swapchain->context = NULL;
@@ -6128,12 +5557,11 @@ static void delete_opengl_contexts(IWineD3DDevice *iface, IWineD3DSwapChainImpl
}
/* Do not call while under the GL lock. */
-static HRESULT create_primary_opengl_context(IWineD3DDevice *iface, IWineD3DSwapChainImpl *swapchain)
+static HRESULT create_primary_opengl_context(struct wined3d_device *device, struct wined3d_swapchain *swapchain)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
struct wined3d_context *context;
+ struct wined3d_surface *target;
HRESULT hr;
- IWineD3DSurfaceImpl *target;
/* Recreate the primary swapchain's context */
swapchain->context = HeapAlloc(GetProcessHeap(), 0, sizeof(*swapchain->context));
@@ -6153,67 +5581,70 @@ static HRESULT create_primary_opengl_context(IWineD3DDevice *iface, IWineD3DSwap
swapchain->context[0] = context;
swapchain->num_contexts = 1;
- create_dummy_textures(This);
+ create_dummy_textures(device);
context_release(context);
- hr = This->shader_backend->shader_alloc_private(iface);
+ hr = device->shader_backend->shader_alloc_private(device);
if (FAILED(hr))
{
ERR("Failed to allocate shader private data, hr %#x.\n", hr);
goto err;
}
- hr = This->frag_pipe->alloc_private(iface);
+ hr = device->frag_pipe->alloc_private(device);
if (FAILED(hr))
{
ERR("Failed to allocate fragment pipe private data, hr %#x.\n", hr);
- This->shader_backend->shader_free_private(iface);
+ device->shader_backend->shader_free_private(device);
goto err;
}
- hr = This->blitter->alloc_private(iface);
+ hr = device->blitter->alloc_private(device);
if (FAILED(hr))
{
ERR("Failed to allocate blitter private data, hr %#x.\n", hr);
- This->frag_pipe->free_private(iface);
- This->shader_backend->shader_free_private(iface);
+ device->frag_pipe->free_private(device);
+ device->shader_backend->shader_free_private(device);
goto err;
}
return WINED3D_OK;
err:
- context_acquire(This, NULL);
- destroy_dummy_textures(This, context->gl_info);
+ context_acquire(device, NULL);
+ destroy_dummy_textures(device, context->gl_info);
context_release(context);
- context_destroy(This, context);
+ context_destroy(device, context);
HeapFree(GetProcessHeap(), 0, swapchain->context);
swapchain->num_contexts = 0;
return hr;
}
/* Do not call while under the GL lock. */
-static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
- WINED3DPRESENT_PARAMETERS *pPresentationParameters)
+HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
+ WINED3DPRESENT_PARAMETERS *present_parameters)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
- IWineD3DSwapChainImpl *swapchain;
- HRESULT hr;
+ struct wined3d_swapchain *swapchain;
BOOL DisplayModeChanged = FALSE;
WINED3DDISPLAYMODE mode;
- TRACE("(%p)\n", This);
+ HRESULT hr;
- hr = IWineD3DDevice_GetSwapChain(iface, 0, (IWineD3DSwapChain **) &swapchain);
- if(FAILED(hr)) {
+ TRACE("device %p, present_parameters %p.\n", device, present_parameters);
+
+ hr = wined3d_device_get_swapchain(device, 0, &swapchain);
+ if (FAILED(hr))
+ {
ERR("Failed to get the first implicit swapchain\n");
return hr;
}
- if(!is_display_mode_supported(This, pPresentationParameters)) {
+ if (!is_display_mode_supported(device, present_parameters))
+ {
WARN("Rejecting Reset() call because the requested display mode is not supported\n");
- WARN("Requested mode: %d, %d\n", pPresentationParameters->BackBufferWidth,
- pPresentationParameters->BackBufferHeight);
- IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
+ WARN("Requested mode: %d, %d.\n",
+ present_parameters->BackBufferWidth,
+ present_parameters->BackBufferHeight);
+ wined3d_swapchain_decref(swapchain);
return WINED3DERR_INVALIDCALL;
}
@@ -6225,198 +5656,201 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
* TODO: Figure out what happens to explicit swapchains, or if we have more than one implicit swapchain
*/
TRACE("New params:\n");
- TRACE("BackBufferWidth = %d\n", pPresentationParameters->BackBufferWidth);
- TRACE("BackBufferHeight = %d\n", pPresentationParameters->BackBufferHeight);
- TRACE("BackBufferFormat = %s\n", debug_d3dformat(pPresentationParameters->BackBufferFormat));
- TRACE("BackBufferCount = %d\n", pPresentationParameters->BackBufferCount);
- TRACE("MultiSampleType = %d\n", pPresentationParameters->MultiSampleType);
- TRACE("MultiSampleQuality = %d\n", pPresentationParameters->MultiSampleQuality);
- TRACE("SwapEffect = %d\n", pPresentationParameters->SwapEffect);
- TRACE("hDeviceWindow = %p\n", pPresentationParameters->hDeviceWindow);
- TRACE("Windowed = %s\n", pPresentationParameters->Windowed ? "true" : "false");
- TRACE("EnableAutoDepthStencil = %s\n", pPresentationParameters->EnableAutoDepthStencil ? "true" : "false");
- TRACE("Flags = %08x\n", pPresentationParameters->Flags);
- TRACE("FullScreen_RefreshRateInHz = %d\n", pPresentationParameters->FullScreen_RefreshRateInHz);
- TRACE("PresentationInterval = %d\n", pPresentationParameters->PresentationInterval);
+ TRACE("BackBufferWidth = %d\n", present_parameters->BackBufferWidth);
+ TRACE("BackBufferHeight = %d\n", present_parameters->BackBufferHeight);
+ TRACE("BackBufferFormat = %s\n", debug_d3dformat(present_parameters->BackBufferFormat));
+ TRACE("BackBufferCount = %d\n", present_parameters->BackBufferCount);
+ TRACE("MultiSampleType = %d\n", present_parameters->MultiSampleType);
+ TRACE("MultiSampleQuality = %d\n", present_parameters->MultiSampleQuality);
+ TRACE("SwapEffect = %d\n", present_parameters->SwapEffect);
+ TRACE("hDeviceWindow = %p\n", present_parameters->hDeviceWindow);
+ TRACE("Windowed = %s\n", present_parameters->Windowed ? "true" : "false");
+ TRACE("EnableAutoDepthStencil = %s\n", present_parameters->EnableAutoDepthStencil ? "true" : "false");
+ TRACE("Flags = %08x\n", present_parameters->Flags);
+ TRACE("FullScreen_RefreshRateInHz = %d\n", present_parameters->FullScreen_RefreshRateInHz);
+ TRACE("PresentationInterval = %d\n", present_parameters->PresentationInterval);
/* No special treatment of these parameters. Just store them */
- swapchain->presentParms.SwapEffect = pPresentationParameters->SwapEffect;
- swapchain->presentParms.Flags = pPresentationParameters->Flags;
- swapchain->presentParms.PresentationInterval = pPresentationParameters->PresentationInterval;
- swapchain->presentParms.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
+ swapchain->presentParms.SwapEffect = present_parameters->SwapEffect;
+ swapchain->presentParms.Flags = present_parameters->Flags;
+ swapchain->presentParms.PresentationInterval = present_parameters->PresentationInterval;
+ swapchain->presentParms.FullScreen_RefreshRateInHz = present_parameters->FullScreen_RefreshRateInHz;
/* What to do about these? */
- if (pPresentationParameters->BackBufferCount
- && pPresentationParameters->BackBufferCount != swapchain->presentParms.BackBufferCount)
- ERR("Cannot change the back buffer count yet\n");
+ if (present_parameters->BackBufferCount
+ && present_parameters->BackBufferCount != swapchain->presentParms.BackBufferCount)
+ FIXME("Cannot change the back buffer count yet.\n");
- if(pPresentationParameters->BackBufferFormat != WINED3DFMT_UNKNOWN &&
- pPresentationParameters->BackBufferFormat != swapchain->presentParms.BackBufferFormat) {
- ERR("Cannot change the back buffer format yet\n");
- }
+ if (present_parameters->BackBufferFormat != WINED3DFMT_UNKNOWN
+ && present_parameters->BackBufferFormat != swapchain->presentParms.BackBufferFormat)
+ FIXME("Cannot change the back buffer format yet.\n");
- if (pPresentationParameters->hDeviceWindow
- && pPresentationParameters->hDeviceWindow != swapchain->presentParms.hDeviceWindow)
- ERR("Cannot change the device window yet\n");
+ if (present_parameters->hDeviceWindow
+ && present_parameters->hDeviceWindow != swapchain->presentParms.hDeviceWindow)
+ FIXME("Cannot change the device window yet.\n");
- if (pPresentationParameters->EnableAutoDepthStencil && !This->auto_depth_stencil)
+ if (present_parameters->EnableAutoDepthStencil && !device->auto_depth_stencil)
{
HRESULT hrc;
TRACE("Creating the depth stencil buffer\n");
- hrc = IWineD3DDeviceParent_CreateDepthStencilSurface(This->device_parent,
- pPresentationParameters->BackBufferWidth,
- pPresentationParameters->BackBufferHeight,
- pPresentationParameters->AutoDepthStencilFormat,
- pPresentationParameters->MultiSampleType,
- pPresentationParameters->MultiSampleQuality,
+ hrc = device->device_parent->ops->create_depth_stencil(device->device_parent,
+ present_parameters->BackBufferWidth,
+ present_parameters->BackBufferHeight,
+ present_parameters->AutoDepthStencilFormat,
+ present_parameters->MultiSampleType,
+ present_parameters->MultiSampleQuality,
FALSE,
- (IWineD3DSurface **)&This->auto_depth_stencil);
-
- if (FAILED(hrc)) {
- ERR("Failed to create the depth stencil buffer\n");
- IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
+ &device->auto_depth_stencil);
+ if (FAILED(hrc))
+ {
+ ERR("Failed to create the depth stencil buffer.\n");
+ wined3d_swapchain_decref(swapchain);
return WINED3DERR_INVALIDCALL;
}
}
- if (This->onscreen_depth_stencil)
+ if (device->onscreen_depth_stencil)
{
- IWineD3DSurface_Release((IWineD3DSurface *)This->onscreen_depth_stencil);
- This->onscreen_depth_stencil = NULL;
+ wined3d_surface_decref(device->onscreen_depth_stencil);
+ device->onscreen_depth_stencil = NULL;
}
/* Reset the depth stencil */
- if (pPresentationParameters->EnableAutoDepthStencil)
- IWineD3DDevice_SetDepthStencilSurface(iface, (IWineD3DSurface *)This->auto_depth_stencil);
+ if (present_parameters->EnableAutoDepthStencil)
+ wined3d_device_set_depth_stencil(device, device->auto_depth_stencil);
else
- IWineD3DDevice_SetDepthStencilSurface(iface, NULL);
+ wined3d_device_set_depth_stencil(device, NULL);
TRACE("Resetting stateblock\n");
- IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->updateStateBlock);
- IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->stateBlock);
+ wined3d_stateblock_decref(device->updateStateBlock);
+ wined3d_stateblock_decref(device->stateBlock);
- delete_opengl_contexts(iface, swapchain);
+ delete_opengl_contexts(device, swapchain);
- if(pPresentationParameters->Windowed) {
+ if (present_parameters->Windowed)
+ {
mode.Width = swapchain->orig_width;
mode.Height = swapchain->orig_height;
mode.RefreshRate = 0;
mode.Format = swapchain->presentParms.BackBufferFormat;
- } else {
- mode.Width = pPresentationParameters->BackBufferWidth;
- mode.Height = pPresentationParameters->BackBufferHeight;
- mode.RefreshRate = pPresentationParameters->FullScreen_RefreshRateInHz;
+ }
+ else
+ {
+ mode.Width = present_parameters->BackBufferWidth;
+ mode.Height = present_parameters->BackBufferHeight;
+ mode.RefreshRate = present_parameters->FullScreen_RefreshRateInHz;
mode.Format = swapchain->presentParms.BackBufferFormat;
}
/* Should Width == 800 && Height == 0 set 800x600? */
- if (pPresentationParameters->BackBufferWidth && pPresentationParameters->BackBufferHeight
- && (pPresentationParameters->BackBufferWidth != swapchain->presentParms.BackBufferWidth
- || pPresentationParameters->BackBufferHeight != swapchain->presentParms.BackBufferHeight))
+ if (present_parameters->BackBufferWidth && present_parameters->BackBufferHeight
+ && (present_parameters->BackBufferWidth != swapchain->presentParms.BackBufferWidth
+ || present_parameters->BackBufferHeight != swapchain->presentParms.BackBufferHeight))
{
UINT i;
- if(!pPresentationParameters->Windowed) {
+ if (!present_parameters->Windowed)
DisplayModeChanged = TRUE;
- }
- swapchain->presentParms.BackBufferWidth = pPresentationParameters->BackBufferWidth;
- swapchain->presentParms.BackBufferHeight = pPresentationParameters->BackBufferHeight;
- hr = updateSurfaceDesc(swapchain->front_buffer, pPresentationParameters);
- if(FAILED(hr))
+ swapchain->presentParms.BackBufferWidth = present_parameters->BackBufferWidth;
+ swapchain->presentParms.BackBufferHeight = present_parameters->BackBufferHeight;
+
+ hr = updateSurfaceDesc(swapchain->front_buffer, present_parameters);
+ if (FAILED(hr))
{
- IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
+ wined3d_swapchain_decref(swapchain);
return hr;
}
for (i = 0; i < swapchain->presentParms.BackBufferCount; ++i)
{
- hr = updateSurfaceDesc(swapchain->back_buffers[i], pPresentationParameters);
- if(FAILED(hr))
+ hr = updateSurfaceDesc(swapchain->back_buffers[i], present_parameters);
+ if (FAILED(hr))
{
- IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
+ wined3d_swapchain_decref(swapchain);
return hr;
}
}
- if (This->auto_depth_stencil)
+ if (device->auto_depth_stencil)
{
- hr = updateSurfaceDesc(This->auto_depth_stencil, pPresentationParameters);
- if(FAILED(hr))
+ hr = updateSurfaceDesc(device->auto_depth_stencil, present_parameters);
+ if (FAILED(hr))
{
- IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
+ wined3d_swapchain_decref(swapchain);
return hr;
}
}
}
- if (!pPresentationParameters->Windowed != !swapchain->presentParms.Windowed
+ if (!present_parameters->Windowed != !swapchain->presentParms.Windowed
|| DisplayModeChanged)
{
- BOOL filter = This->filter_messages;
- This->filter_messages = TRUE;
+ wined3d_device_set_display_mode(device, 0, &mode);
- IWineD3DDevice_SetDisplayMode(iface, 0, &mode);
-
- if (!pPresentationParameters->Windowed)
+ if (!present_parameters->Windowed)
{
if (swapchain->presentParms.Windowed)
{
- HWND focus_window = This->createParms.hFocusWindow;
- if (!focus_window) focus_window = pPresentationParameters->hDeviceWindow;
- if (FAILED(hr = IWineD3DDevice_AcquireFocusWindow(iface, focus_window)))
+ HWND focus_window = device->createParms.hFocusWindow;
+ if (!focus_window)
+ focus_window = present_parameters->hDeviceWindow;
+ if (FAILED(hr = wined3d_device_acquire_focus_window(device, focus_window)))
{
ERR("Failed to acquire focus window, hr %#x.\n", hr);
- IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
+ wined3d_swapchain_decref(swapchain);
return hr;
}
/* switch from windowed to fs */
- swapchain_setup_fullscreen_window(swapchain, pPresentationParameters->BackBufferWidth,
- pPresentationParameters->BackBufferHeight);
+ wined3d_device_setup_fullscreen_window(device, swapchain->device_window,
+ present_parameters->BackBufferWidth,
+ present_parameters->BackBufferHeight);
}
else
{
/* Fullscreen -> fullscreen mode change */
MoveWindow(swapchain->device_window, 0, 0,
- pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight,
+ present_parameters->BackBufferWidth, present_parameters->BackBufferHeight,
TRUE);
}
}
else if (!swapchain->presentParms.Windowed)
{
/* Fullscreen -> windowed switch */
- swapchain_restore_fullscreen_window(swapchain);
- IWineD3DDevice_ReleaseFocusWindow(iface);
+ wined3d_device_restore_fullscreen_window(device, swapchain->device_window);
+ wined3d_device_release_focus_window(device);
}
- swapchain->presentParms.Windowed = pPresentationParameters->Windowed;
-
- This->filter_messages = filter;
+ swapchain->presentParms.Windowed = present_parameters->Windowed;
}
- else if (!pPresentationParameters->Windowed)
+ else if (!present_parameters->Windowed)
{
- DWORD style = This->style, exStyle = This->exStyle;
+ DWORD style = device->style;
+ DWORD exStyle = device->exStyle;
/* If we're in fullscreen, and the mode wasn't changed, we have to get the window back into
* the right position. Some applications(Battlefield 2, Guild Wars) move it and then call
* Reset to clear up their mess. Guild Wars also loses the device during that.
*/
- This->style = 0;
- This->exStyle = 0;
- swapchain_setup_fullscreen_window(swapchain, pPresentationParameters->BackBufferWidth,
- pPresentationParameters->BackBufferHeight);
- This->style = style;
- This->exStyle = exStyle;
+ device->style = 0;
+ device->exStyle = 0;
+ wined3d_device_setup_fullscreen_window(device, swapchain->device_window,
+ present_parameters->BackBufferWidth,
+ present_parameters->BackBufferHeight);
+ device->style = style;
+ device->exStyle = exStyle;
}
/* Note: No parent needed for initial internal stateblock */
- hr = IWineD3DDevice_CreateStateBlock(iface, WINED3DSBT_INIT, (IWineD3DStateBlock **)&This->stateBlock);
- if (FAILED(hr)) ERR("Resetting the stateblock failed with error 0x%08x\n", hr);
- else TRACE("Created stateblock %p\n", This->stateBlock);
- This->updateStateBlock = This->stateBlock;
- IWineD3DStateBlock_AddRef((IWineD3DStateBlock *)This->updateStateBlock);
+ hr = wined3d_stateblock_create(device, WINED3DSBT_INIT, &device->stateBlock);
+ if (FAILED(hr))
+ ERR("Resetting the stateblock failed with error %#x.\n", hr);
+ else
+ TRACE("Created stateblock %p.\n", device->stateBlock);
+ device->updateStateBlock = device->stateBlock;
+ wined3d_stateblock_incref(device->updateStateBlock);
- stateblock_init_default_state(This->stateBlock);
+ stateblock_init_default_state(device->stateBlock);
if(wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
@@ -6444,8 +5878,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
}
}
- hr = create_primary_opengl_context(iface, swapchain);
- IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
+ hr = create_primary_opengl_context(device, swapchain);
+ wined3d_swapchain_decref(swapchain);
/* All done. There is no need to reload resources or shaders, this will happen automatically on the
* first use
@@ -6453,9 +5887,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
return hr;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_SetDialogBoxMode(IWineD3DDevice *iface, BOOL enable_dialogs)
+HRESULT CDECL wined3d_device_set_dialog_box_mode(struct wined3d_device *device, BOOL enable_dialogs)
{
- TRACE("iface %p, enable_dialogs %#x.\n", iface, enable_dialogs);
+ TRACE("device %p, enable_dialogs %#x.\n", device, enable_dialogs);
if (!enable_dialogs) FIXME("Dialogs cannot be disabled yet.\n");
@@ -6463,62 +5897,61 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetDialogBoxMode(IWineD3DDevice *iface,
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetCreationParameters(IWineD3DDevice *iface, WINED3DDEVICE_CREATION_PARAMETERS *pParameters) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
- TRACE("(%p) : pParameters %p\n", This, pParameters);
+HRESULT CDECL wined3d_device_get_creation_parameters(struct wined3d_device *device,
+ WINED3DDEVICE_CREATION_PARAMETERS *parameters)
+{
+ TRACE("device %p, parameters %p.\n", device, parameters);
- *pParameters = This->createParms;
+ *parameters = device->createParms;
return WINED3D_OK;
}
-static void WINAPI IWineD3DDeviceImpl_SetGammaRamp(IWineD3DDevice * iface, UINT iSwapChain, DWORD Flags, CONST WINED3DGAMMARAMP* pRamp) {
- IWineD3DSwapChain *swapchain;
+void CDECL wined3d_device_set_gamma_ramp(struct wined3d_device *device,
+ UINT swapchain_idx, DWORD flags, const WINED3DGAMMARAMP *ramp)
+{
+ struct wined3d_swapchain *swapchain;
- TRACE("Relaying to swapchain\n");
+ TRACE("device %p, swapchain_idx %u, flags %#x, ramp %p.\n",
+ device, swapchain_idx, flags, ramp);
- if (IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, &swapchain) == WINED3D_OK) {
- IWineD3DSwapChain_SetGammaRamp(swapchain, Flags, pRamp);
- IWineD3DSwapChain_Release(swapchain);
+ if (SUCCEEDED(wined3d_device_get_swapchain(device, swapchain_idx, &swapchain)))
+ {
+ wined3d_swapchain_set_gamma_ramp(swapchain, flags, ramp);
+ wined3d_swapchain_decref(swapchain);
}
}
-static void WINAPI IWineD3DDeviceImpl_GetGammaRamp(IWineD3DDevice *iface, UINT iSwapChain, WINED3DGAMMARAMP* pRamp) {
- IWineD3DSwapChain *swapchain;
+void CDECL wined3d_device_get_gamma_ramp(struct wined3d_device *device, UINT swapchain_idx, WINED3DGAMMARAMP *ramp)
+{
+ struct wined3d_swapchain *swapchain;
- TRACE("Relaying to swapchain\n");
+ TRACE("device %p, swapchain_idx %u, ramp %p.\n",
+ device, swapchain_idx, ramp);
- if (IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, &swapchain) == WINED3D_OK) {
- IWineD3DSwapChain_GetGammaRamp(swapchain, pRamp);
- IWineD3DSwapChain_Release(swapchain);
+ if (SUCCEEDED(wined3d_device_get_swapchain(device, swapchain_idx, &swapchain)))
+ {
+ wined3d_swapchain_get_gamma_ramp(swapchain, ramp);
+ wined3d_swapchain_decref(swapchain);
}
}
-
-/** ********************************************************
-* Notification functions
-** ********************************************************/
-/** This function must be called in the release of a resource when ref == 0,
-* the contents of resource must still be correct,
-* any handles to other resource held by the caller must be closed
-* (e.g. a texture should release all held surfaces because telling the device that it's been released.)
- *****************************************************/
-void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource)
+void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource)
{
- TRACE("(%p) : Adding resource %p\n", This, resource);
+ TRACE("device %p, resource %p.\n", device, resource);
- list_add_head(&This->resources, &((IWineD3DResourceImpl *) resource)->resource.resource_list_entry);
+ list_add_head(&device->resources, &resource->resource_list_entry);
}
-static void device_resource_remove(IWineD3DDeviceImpl *This, IWineD3DResource *resource)
+static void device_resource_remove(struct wined3d_device *device, struct wined3d_resource *resource)
{
- TRACE("(%p) : Removing resource %p\n", This, resource);
+ TRACE("device %p, resource %p.\n", device, resource);
- list_remove(&((IWineD3DResourceImpl *) resource)->resource.resource_list_entry);
+ list_remove(&resource->resource_list_entry);
}
-void device_resource_released(IWineD3DDeviceImpl *device, IWineD3DResource *resource)
+void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource)
{
- WINED3DRESOURCETYPE type = IWineD3DResource_GetType(resource);
+ WINED3DRESOURCETYPE type = resource->resourceType;
unsigned int i;
TRACE("device %p, resource %p, type %s.\n", device, resource, debug_d3dresourcetype(type));
@@ -6528,21 +5961,25 @@ void device_resource_released(IWineD3DDeviceImpl *device, IWineD3DResource *reso
switch (type)
{
case WINED3DRTYPE_SURFACE:
- if (!device->d3d_initialized) break;
-
- for (i = 0; i < device->adapter->gl_info.limits.buffers; ++i)
{
- if (device->render_targets[i] == (IWineD3DSurfaceImpl *)resource)
+ struct wined3d_surface *surface = surface_from_resource(resource);
+
+ if (!device->d3d_initialized) break;
+
+ for (i = 0; i < device->adapter->gl_info.limits.buffers; ++i)
{
- ERR("Surface %p is still in use as render target %u.\n", resource, i);
- device->render_targets[i] = NULL;
+ if (device->fb.render_targets[i] == surface)
+ {
+ ERR("Surface %p is still in use as render target %u.\n", surface, i);
+ device->fb.render_targets[i] = NULL;
+ }
}
- }
- if (device->depth_stencil == (IWineD3DSurfaceImpl *)resource)
- {
- ERR("Surface %p is still in use as depth/stencil buffer.\n", resource);
- device->depth_stencil = NULL;
+ if (device->fb.depth_stencil == surface)
+ {
+ ERR("Surface %p is still in use as depth/stencil buffer.\n", surface);
+ device->fb.depth_stencil = NULL;
+ }
}
break;
@@ -6551,57 +5988,62 @@ void device_resource_released(IWineD3DDeviceImpl *device, IWineD3DResource *reso
case WINED3DRTYPE_VOLUMETEXTURE:
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
{
- if (device->stateBlock && device->stateBlock->state.textures[i] == (IWineD3DBaseTextureImpl *)resource)
+ struct wined3d_texture *texture = wined3d_texture_from_resource(resource);
+
+ if (device->stateBlock && device->stateBlock->state.textures[i] == texture)
{
ERR("Texture %p is still in use by stateblock %p, stage %u.\n",
- resource, device->stateBlock, i);
+ texture, device->stateBlock, i);
device->stateBlock->state.textures[i] = NULL;
}
if (device->updateStateBlock != device->stateBlock
- && device->updateStateBlock->state.textures[i] == (IWineD3DBaseTextureImpl *)resource)
+ && device->updateStateBlock->state.textures[i] == texture)
{
ERR("Texture %p is still in use by stateblock %p, stage %u.\n",
- resource, device->updateStateBlock, i);
+ texture, device->updateStateBlock, i);
device->updateStateBlock->state.textures[i] = NULL;
}
}
break;
case WINED3DRTYPE_BUFFER:
- for (i = 0; i < MAX_STREAMS; ++i)
{
- if (device->stateBlock
- && device->stateBlock->state.streams[i].buffer == (struct wined3d_buffer *)resource)
+ struct wined3d_buffer *buffer = buffer_from_resource(resource);
+
+ for (i = 0; i < MAX_STREAMS; ++i)
{
- ERR("Buffer %p is still in use by stateblock %p, stream %u.\n",
- resource, device->stateBlock, i);
- device->stateBlock->state.streams[i].buffer = NULL;
+ if (device->stateBlock && device->stateBlock->state.streams[i].buffer == buffer)
+ {
+ ERR("Buffer %p is still in use by stateblock %p, stream %u.\n",
+ buffer, device->stateBlock, i);
+ device->stateBlock->state.streams[i].buffer = NULL;
+ }
+
+ if (device->updateStateBlock != device->stateBlock
+ && device->updateStateBlock->state.streams[i].buffer == buffer)
+ {
+ ERR("Buffer %p is still in use by stateblock %p, stream %u.\n",
+ buffer, device->updateStateBlock, i);
+ device->updateStateBlock->state.streams[i].buffer = NULL;
+ }
+
+ }
+
+ if (device->stateBlock && device->stateBlock->state.index_buffer == buffer)
+ {
+ ERR("Buffer %p is still in use by stateblock %p as index buffer.\n",
+ buffer, device->stateBlock);
+ device->stateBlock->state.index_buffer = NULL;
}
if (device->updateStateBlock != device->stateBlock
- && device->updateStateBlock->state.streams[i].buffer == (struct wined3d_buffer *)resource)
+ && device->updateStateBlock->state.index_buffer == buffer)
{
- ERR("Buffer %p is still in use by stateblock %p, stream %u.\n",
- resource, device->updateStateBlock, i);
- device->updateStateBlock->state.streams[i].buffer = NULL;
+ ERR("Buffer %p is still in use by stateblock %p as index buffer.\n",
+ buffer, device->updateStateBlock);
+ device->updateStateBlock->state.index_buffer = NULL;
}
-
- }
-
- if (device->stateBlock && device->stateBlock->state.index_buffer == (struct wined3d_buffer *)resource)
- {
- ERR("Buffer %p is still in use by stateblock %p as index buffer.\n",
- resource, device->stateBlock);
- device->stateBlock->state.index_buffer = NULL;
- }
-
- if (device->updateStateBlock != device->stateBlock
- && device->updateStateBlock->state.index_buffer == (struct wined3d_buffer *)resource)
- {
- ERR("Buffer %p is still in use by stateblock %p as index buffer.\n",
- resource, device->updateStateBlock);
- device->updateStateBlock->state.index_buffer = NULL;
}
break;
@@ -6615,38 +6057,43 @@ void device_resource_released(IWineD3DDeviceImpl *device, IWineD3DResource *reso
TRACE("Resource released.\n");
}
-static HRESULT WINAPI IWineD3DDeviceImpl_EnumResources(IWineD3DDevice *iface, D3DCB_ENUMRESOURCES pCallback, void *pData) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
- IWineD3DResourceImpl *resource, *cursor;
- HRESULT ret;
- TRACE("(%p)->(%p,%p)\n", This, pCallback, pData);
+HRESULT CDECL wined3d_device_enum_resources(struct wined3d_device *device,
+ D3DCB_ENUMRESOURCES callback, void *data)
+{
+ struct wined3d_resource *resource, *cursor;
- LIST_FOR_EACH_ENTRY_SAFE(resource, cursor, &This->resources, IWineD3DResourceImpl, resource.resource_list_entry) {
- TRACE("enumerating resource %p\n", resource);
- IWineD3DResource_AddRef((IWineD3DResource *) resource);
- ret = pCallback((IWineD3DResource *) resource, pData);
- if(ret == S_FALSE) {
- TRACE("Canceling enumeration\n");
+ TRACE("device %p, callback %p, data %p.\n", device, callback, data);
+
+ LIST_FOR_EACH_ENTRY_SAFE(resource, cursor, &device->resources, struct wined3d_resource, resource_list_entry)
+ {
+ TRACE("enumerating resource %p.\n", resource);
+ if (callback(resource, data) == S_FALSE)
+ {
+ TRACE("Canceling enumeration.\n");
break;
}
}
+
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_GetSurfaceFromDC(IWineD3DDevice *iface, HDC dc, IWineD3DSurface **surface)
+HRESULT CDECL wined3d_device_get_surface_from_dc(struct wined3d_device *device,
+ HDC dc, struct wined3d_surface **surface)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
- IWineD3DResourceImpl *resource;
+ struct wined3d_resource *resource;
- LIST_FOR_EACH_ENTRY(resource, &This->resources, IWineD3DResourceImpl, resource.resource_list_entry)
+ TRACE("device %p, dc %p, surface %p.\n", device, dc, surface);
+
+ LIST_FOR_EACH_ENTRY(resource, &device->resources, struct wined3d_resource, resource_list_entry)
{
- WINED3DRESOURCETYPE type = IWineD3DResource_GetType((IWineD3DResource *)resource);
- if (type == WINED3DRTYPE_SURFACE)
+ if (resource->resourceType == WINED3DRTYPE_SURFACE)
{
- if (((IWineD3DSurfaceImpl *)resource)->hDC == dc)
+ struct wined3d_surface *s = surface_from_resource(resource);
+
+ if (s->hDC == dc)
{
- TRACE("Found surface %p for dc %p.\n", resource, dc);
- *surface = (IWineD3DSurface *)resource;
+ TRACE("Found surface %p for dc %p.\n", s, dc);
+ *surface = s;
return WINED3D_OK;
}
}
@@ -6655,161 +6102,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetSurfaceFromDC(IWineD3DDevice *iface,
return WINED3DERR_INVALIDCALL;
}
-/**********************************************************
- * IWineD3DDevice VTbl follows
- **********************************************************/
-
-static const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl =
-{
- /*** IUnknown methods ***/
- IWineD3DDeviceImpl_QueryInterface,
- IWineD3DDeviceImpl_AddRef,
- IWineD3DDeviceImpl_Release,
- /*** IWineD3DDevice methods ***/
- /*** Creation methods**/
- IWineD3DDeviceImpl_CreateBuffer,
- IWineD3DDeviceImpl_CreateVertexBuffer,
- IWineD3DDeviceImpl_CreateIndexBuffer,
- IWineD3DDeviceImpl_CreateStateBlock,
- IWineD3DDeviceImpl_CreateSurface,
- IWineD3DDeviceImpl_CreateRendertargetView,
- IWineD3DDeviceImpl_CreateTexture,
- IWineD3DDeviceImpl_CreateVolumeTexture,
- IWineD3DDeviceImpl_CreateVolume,
- IWineD3DDeviceImpl_CreateCubeTexture,
- IWineD3DDeviceImpl_CreateQuery,
- IWineD3DDeviceImpl_CreateSwapChain,
- IWineD3DDeviceImpl_CreateVertexDeclaration,
- IWineD3DDeviceImpl_CreateVertexDeclarationFromFVF,
- IWineD3DDeviceImpl_CreateVertexShader,
- IWineD3DDeviceImpl_CreateGeometryShader,
- IWineD3DDeviceImpl_CreatePixelShader,
- IWineD3DDeviceImpl_CreatePalette,
- /*** Odd functions **/
- IWineD3DDeviceImpl_Init3D,
- IWineD3DDeviceImpl_InitGDI,
- IWineD3DDeviceImpl_Uninit3D,
- IWineD3DDeviceImpl_UninitGDI,
- IWineD3DDeviceImpl_SetMultithreaded,
- IWineD3DDeviceImpl_EvictManagedResources,
- IWineD3DDeviceImpl_GetAvailableTextureMem,
- IWineD3DDeviceImpl_GetBackBuffer,
- IWineD3DDeviceImpl_GetCreationParameters,
- IWineD3DDeviceImpl_GetDeviceCaps,
- IWineD3DDeviceImpl_GetDirect3D,
- IWineD3DDeviceImpl_GetDisplayMode,
- IWineD3DDeviceImpl_SetDisplayMode,
- IWineD3DDeviceImpl_GetNumberOfSwapChains,
- IWineD3DDeviceImpl_GetRasterStatus,
- IWineD3DDeviceImpl_GetSwapChain,
- IWineD3DDeviceImpl_Reset,
- IWineD3DDeviceImpl_SetDialogBoxMode,
- IWineD3DDeviceImpl_SetCursorProperties,
- IWineD3DDeviceImpl_SetCursorPosition,
- IWineD3DDeviceImpl_ShowCursor,
- /*** Getters and setters **/
- IWineD3DDeviceImpl_SetClipPlane,
- IWineD3DDeviceImpl_GetClipPlane,
- IWineD3DDeviceImpl_SetClipStatus,
- IWineD3DDeviceImpl_GetClipStatus,
- IWineD3DDeviceImpl_SetCurrentTexturePalette,
- IWineD3DDeviceImpl_GetCurrentTexturePalette,
- IWineD3DDeviceImpl_SetDepthStencilSurface,
- IWineD3DDeviceImpl_GetDepthStencilSurface,
- IWineD3DDeviceImpl_SetGammaRamp,
- IWineD3DDeviceImpl_GetGammaRamp,
- IWineD3DDeviceImpl_SetIndexBuffer,
- IWineD3DDeviceImpl_GetIndexBuffer,
- IWineD3DDeviceImpl_SetBaseVertexIndex,
- IWineD3DDeviceImpl_GetBaseVertexIndex,
- IWineD3DDeviceImpl_SetLight,
- IWineD3DDeviceImpl_GetLight,
- IWineD3DDeviceImpl_SetLightEnable,
- IWineD3DDeviceImpl_GetLightEnable,
- IWineD3DDeviceImpl_SetMaterial,
- IWineD3DDeviceImpl_GetMaterial,
- IWineD3DDeviceImpl_SetNPatchMode,
- IWineD3DDeviceImpl_GetNPatchMode,
- IWineD3DDeviceImpl_SetPaletteEntries,
- IWineD3DDeviceImpl_GetPaletteEntries,
- IWineD3DDeviceImpl_SetPixelShader,
- IWineD3DDeviceImpl_GetPixelShader,
- IWineD3DDeviceImpl_SetPixelShaderConstantB,
- IWineD3DDeviceImpl_GetPixelShaderConstantB,
- IWineD3DDeviceImpl_SetPixelShaderConstantI,
- IWineD3DDeviceImpl_GetPixelShaderConstantI,
- IWineD3DDeviceImpl_SetPixelShaderConstantF,
- IWineD3DDeviceImpl_GetPixelShaderConstantF,
- IWineD3DDeviceImpl_SetRenderState,
- IWineD3DDeviceImpl_GetRenderState,
- IWineD3DDeviceImpl_SetRenderTarget,
- IWineD3DDeviceImpl_GetRenderTarget,
- IWineD3DDeviceImpl_SetSamplerState,
- IWineD3DDeviceImpl_GetSamplerState,
- IWineD3DDeviceImpl_SetScissorRect,
- IWineD3DDeviceImpl_GetScissorRect,
- IWineD3DDeviceImpl_SetSoftwareVertexProcessing,
- IWineD3DDeviceImpl_GetSoftwareVertexProcessing,
- IWineD3DDeviceImpl_SetStreamSource,
- IWineD3DDeviceImpl_GetStreamSource,
- IWineD3DDeviceImpl_SetStreamSourceFreq,
- IWineD3DDeviceImpl_GetStreamSourceFreq,
- IWineD3DDeviceImpl_SetTexture,
- IWineD3DDeviceImpl_GetTexture,
- IWineD3DDeviceImpl_SetTextureStageState,
- IWineD3DDeviceImpl_GetTextureStageState,
- IWineD3DDeviceImpl_SetTransform,
- IWineD3DDeviceImpl_GetTransform,
- IWineD3DDeviceImpl_SetVertexDeclaration,
- IWineD3DDeviceImpl_GetVertexDeclaration,
- IWineD3DDeviceImpl_SetVertexShader,
- IWineD3DDeviceImpl_GetVertexShader,
- IWineD3DDeviceImpl_SetVertexShaderConstantB,
- IWineD3DDeviceImpl_GetVertexShaderConstantB,
- IWineD3DDeviceImpl_SetVertexShaderConstantI,
- IWineD3DDeviceImpl_GetVertexShaderConstantI,
- IWineD3DDeviceImpl_SetVertexShaderConstantF,
- IWineD3DDeviceImpl_GetVertexShaderConstantF,
- IWineD3DDeviceImpl_SetViewport,
- IWineD3DDeviceImpl_GetViewport,
- IWineD3DDeviceImpl_MultiplyTransform,
- IWineD3DDeviceImpl_ValidateDevice,
- IWineD3DDeviceImpl_ProcessVertices,
- /*** State block ***/
- IWineD3DDeviceImpl_BeginStateBlock,
- IWineD3DDeviceImpl_EndStateBlock,
- /*** Scene management ***/
- IWineD3DDeviceImpl_BeginScene,
- IWineD3DDeviceImpl_EndScene,
- IWineD3DDeviceImpl_Present,
- IWineD3DDeviceImpl_Clear,
- IWineD3DDeviceImpl_ClearRendertargetView,
- /*** Drawing ***/
- IWineD3DDeviceImpl_SetPrimitiveType,
- IWineD3DDeviceImpl_GetPrimitiveType,
- IWineD3DDeviceImpl_DrawPrimitive,
- IWineD3DDeviceImpl_DrawIndexedPrimitive,
- IWineD3DDeviceImpl_DrawPrimitiveUP,
- IWineD3DDeviceImpl_DrawIndexedPrimitiveUP,
- IWineD3DDeviceImpl_DrawPrimitiveStrided,
- IWineD3DDeviceImpl_DrawIndexedPrimitiveStrided,
- IWineD3DDeviceImpl_DrawRectPatch,
- IWineD3DDeviceImpl_DrawTriPatch,
- IWineD3DDeviceImpl_DeletePatch,
- IWineD3DDeviceImpl_ColorFill,
- IWineD3DDeviceImpl_UpdateTexture,
- IWineD3DDeviceImpl_UpdateSurface,
- IWineD3DDeviceImpl_GetFrontBufferData,
- /*** object tracking ***/
- IWineD3DDeviceImpl_EnumResources,
- IWineD3DDeviceImpl_GetSurfaceFromDC,
- IWineD3DDeviceImpl_AcquireFocusWindow,
- IWineD3DDeviceImpl_ReleaseFocusWindow,
-};
-
-HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d,
+HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d,
UINT adapter_idx, WINED3DDEVTYPE device_type, HWND focus_window, DWORD flags,
- IWineD3DDeviceParent *device_parent)
+ struct wined3d_device_parent *device_parent)
{
struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
const struct fragment_pipeline *fragment_pipeline;
@@ -6819,24 +6114,22 @@ HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d,
unsigned int i;
HRESULT hr;
- device->lpVtbl = &IWineD3DDevice_Vtbl;
device->ref = 1;
- device->wined3d = (IWineD3D *)wined3d;
- IWineD3D_AddRef(device->wined3d);
+ device->wined3d = wined3d;
+ wined3d_incref(device->wined3d);
device->adapter = wined3d->adapter_count ? adapter : NULL;
device->device_parent = device_parent;
list_init(&device->resources);
list_init(&device->shaders);
device->surface_alignment = wined3d->dxVersion == 7 ? DDRAW_PITCH_ALIGNMENT : D3D8_PITCH_ALIGNMENT;
- device->posFixup[0] = 1.0f; /* This is needed to get the x coord unmodified through a MAD. */
/* Get the initial screen setup for ddraw. */
- hr = IWineD3D_GetAdapterDisplayMode((IWineD3D *)wined3d, adapter_idx, &mode);
+ hr = wined3d_get_adapter_display_mode(wined3d, adapter_idx, &mode);
if (FAILED(hr))
{
ERR("Failed to get the adapter's display mode, hr %#x.\n", hr);
- IWineD3D_Release(device->wined3d);
+ wined3d_decref(device->wined3d);
return hr;
}
device->ddraw_width = mode.Width;
@@ -6874,7 +6167,7 @@ HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d,
if (FAILED(hr))
{
ERR("Failed to compile state table, hr %#x.\n", hr);
- IWineD3D_Release(device->wined3d);
+ wined3d_decref(device->wined3d);
return hr;
}
}
@@ -6884,15 +6177,17 @@ HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d,
}
-void IWineD3DDeviceImpl_MarkStateDirty(IWineD3DDeviceImpl *This, DWORD state) {
- DWORD rep = This->StateTable[state].representative;
+void IWineD3DDeviceImpl_MarkStateDirty(struct wined3d_device *device, DWORD state)
+{
+ DWORD rep = device->StateTable[state].representative;
struct wined3d_context *context;
DWORD idx;
BYTE shift;
UINT i;
- for(i = 0; i < This->numContexts; i++) {
- context = This->contexts[i];
+ for (i = 0; i < device->context_count; ++i)
+ {
+ context = device->contexts[i];
if(isStateDirty(context, rep)) continue;
context->dirtyArray[context->numDirtyEntries++] = rep;
@@ -6911,7 +6206,7 @@ void get_drawable_size_fbo(struct wined3d_context *context, UINT *width, UINT *h
void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width, UINT *height)
{
- IWineD3DSwapChainImpl *swapchain = context->swapchain;
+ struct wined3d_swapchain *swapchain = context->swapchain;
/* The drawable size of a backbuffer / aux buffer offscreen target is the size of the
* current context's drawable, which is the size of the back buffer of the swapchain
* the active context belongs to. */
@@ -6919,14 +6214,17 @@ void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width,
*height = swapchain->presentParms.BackBufferHeight;
}
-LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window,
+LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL unicode,
UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc)
{
if (device->filter_messages)
{
TRACE("Filtering message: window %p, message %#x, wparam %#lx, lparam %#lx.\n",
window, message, wparam, lparam);
- return DefWindowProcW(window, message, wparam, lparam);
+ if (unicode)
+ return DefWindowProcW(window, message, wparam, lparam);
+ else
+ return DefWindowProcA(window, message, wparam, lparam);
}
if (message == WM_DESTROY)
@@ -6938,5 +6236,8 @@ LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window,
else ERR("Window %p is not the focus window for device %p.\n", window, device);
}
- return CallWindowProcW(proc, window, message, wparam, lparam);
+ if (unicode)
+ return CallWindowProcW(proc, window, message, wparam, lparam);
+ else
+ return CallWindowProcA(proc, window, message, wparam, lparam);
}
diff --git a/reactos/dll/directx/wine/wined3d/directx.c b/reactos/dll/directx/wine/wined3d/directx.c
index 1df2eaa8082..f8cad58e59e 100644
--- a/reactos/dll/directx/wine/wined3d/directx.c
+++ b/reactos/dll/directx/wine/wined3d/directx.c
@@ -6,7 +6,7 @@
* Copyright 2004 Christian Costa
* 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
@@ -61,7 +61,6 @@ static const struct {
{"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4, 0 },
{"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL, 0 },
{"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX, 0 },
- {"GL_ARB_imaging", ARB_IMAGING, 0 },
{"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE, 0 },
{"GL_ARB_multisample", ARB_MULTISAMPLE, 0 }, /* needs GLX_ARB_MULTISAMPLE as well */
{"GL_ARB_multitexture", ARB_MULTITEXTURE, 0 },
@@ -105,6 +104,7 @@ static const struct {
{"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE, 0 },
{"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE, 0 },
{"GL_EXT_blend_minmax", EXT_BLEND_MINMAX, 0 },
+ {"GL_EXT_blend_subtract", EXT_BLEND_SUBTRACT, 0 },
{"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST, 0 },
{"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2, 0 },
{"GL_EXT_fog_coord", EXT_FOG_COORD, 0 },
@@ -129,6 +129,7 @@ static const struct {
{"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC, 0 },
{"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS, 0 },
{"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB, 0 },
+ {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE, 0 },
{"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA, 0 },
/* NV */
@@ -328,7 +329,7 @@ fail:
}
/* Adjust the amount of used texture memory */
-unsigned int WineD3DAdapterChangeGLRam(IWineD3DDeviceImpl *device, unsigned int glram)
+unsigned int WineD3DAdapterChangeGLRam(struct wined3d_device *device, int glram)
{
struct wined3d_adapter *adapter = device->adapter;
@@ -343,52 +344,33 @@ static void wined3d_adapter_cleanup(struct wined3d_adapter *adapter)
HeapFree(GetProcessHeap(), 0, adapter->cfgs);
}
-/**********************************************************
- * IUnknown parts follows
- **********************************************************/
-
-static HRESULT WINAPI IWineD3DImpl_QueryInterface(IWineD3D *iface,REFIID riid,LPVOID *ppobj)
+ULONG CDECL wined3d_incref(struct wined3d *wined3d)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
+ ULONG refcount = InterlockedIncrement(&wined3d->ref);
- TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
- if (IsEqualGUID(riid, &IID_IUnknown)
- || IsEqualGUID(riid, &IID_IWineD3DBase)
- || IsEqualGUID(riid, &IID_IWineD3DDevice)) {
- IUnknown_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
- *ppobj = NULL;
- return E_NOINTERFACE;
+ TRACE("%p increasing refcount to %u.\n", wined3d, refcount);
+
+ return refcount;
}
-static ULONG WINAPI IWineD3DImpl_AddRef(IWineD3D *iface) {
- IWineD3DImpl *This = (IWineD3DImpl *)iface;
- ULONG refCount = InterlockedIncrement(&This->ref);
+ULONG CDECL wined3d_decref(struct wined3d *wined3d)
+{
+ ULONG refcount = InterlockedDecrement(&wined3d->ref);
- TRACE("(%p) : AddRef increasing from %d\n", This, refCount - 1);
- return refCount;
-}
+ TRACE("%p decreasing refcount to %u.\n", wined3d, refcount);
-static ULONG WINAPI IWineD3DImpl_Release(IWineD3D *iface) {
- IWineD3DImpl *This = (IWineD3DImpl *)iface;
- ULONG ref;
- TRACE("(%p) : Releasing from %d\n", This, This->ref);
- ref = InterlockedDecrement(&This->ref);
-
- if (!ref)
+ if (!refcount)
{
unsigned int i;
- for (i = 0; i < This->adapter_count; ++i)
+ for (i = 0; i < wined3d->adapter_count; ++i)
{
- wined3d_adapter_cleanup(&This->adapters[i]);
+ wined3d_adapter_cleanup(&wined3d->adapters[i]);
}
- HeapFree(GetProcessHeap(), 0, This);
+ HeapFree(GetProcessHeap(), 0, wined3d);
}
- return ref;
+ return refcount;
}
/**********************************************************
@@ -442,13 +424,13 @@ static DWORD ver_for_ext(GL_SupportedExt ext)
return 0;
}
-static BOOL match_ati_r300_to_500(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
+static BOOL match_amd_r300_to_500(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
- if (card_vendor != HW_VENDOR_ATI) return FALSE;
- if (device == CARD_ATI_RADEON_9500) return TRUE;
- if (device == CARD_ATI_RADEON_X700) return TRUE;
- if (device == CARD_ATI_RADEON_X1600) return TRUE;
+ if (card_vendor != HW_VENDOR_AMD) return FALSE;
+ if (device == CARD_AMD_RADEON_9500) return TRUE;
+ if (device == CARD_AMD_RADEON_X700) return TRUE;
+ if (device == CARD_AMD_RADEON_X1600) return TRUE;
return FALSE;
}
@@ -573,8 +555,8 @@ static BOOL match_apple_nonr500ati(const struct wined3d_gl_info *gl_info, const
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
if (gl_vendor != GL_VENDOR_APPLE) return FALSE;
- if (card_vendor != HW_VENDOR_ATI) return FALSE;
- if (device == CARD_ATI_RADEON_X1600) return FALSE;
+ if (card_vendor != HW_VENDOR_AMD) return FALSE;
+ if (device == CARD_AMD_RADEON_X1600) return FALSE;
return TRUE;
}
@@ -774,7 +756,7 @@ static void quirk_one_point_sprite(struct wined3d_gl_info *gl_info)
}
}
-static void quirk_ati_dx9(struct wined3d_gl_info *gl_info)
+static void quirk_amd_dx9(struct wined3d_gl_info *gl_info)
{
quirk_arb_constants(gl_info);
@@ -879,9 +861,9 @@ struct driver_quirk
static const struct driver_quirk quirk_table[] =
{
{
- match_ati_r300_to_500,
- quirk_ati_dx9,
- "ATI GLSL constant and normalized texrect quirk"
+ match_amd_r300_to_500,
+ quirk_amd_dx9,
+ "AMD GLSL constant and normalized texrect quirk"
},
/* MacOS advertises more GLSL vertex shader uniforms than supported by the hardware, and if more are
* used it falls back to software. While the compiler can detect if the shader uses all declared
@@ -995,17 +977,17 @@ struct driver_version_information
/* The driver version table contains driver information for different devices on several OS versions. */
static const struct driver_version_information driver_version_table[] =
{
- /* ATI
+ /* AMD
* - Radeon HD2x00 (R600) and up supported by current drivers.
- * - Radeon 9500 (R300) - X1*00 (R5xx) supported upto Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
- * - Radeon 7xxx (R100) - 9250 (RV250) supported upto Catalyst 6.11 (XP)
- * - Rage 128 supported upto XP, latest official build 6.13.3279 dated October 2001 */
- {DRIVER_ATI_RAGE_128PRO, DRIVER_MODEL_NT5X, "ati2dvaa.dll", 13, 3279, 0},
- {DRIVER_ATI_R100, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6614},
- {DRIVER_ATI_R300, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6764},
- {DRIVER_ATI_R600, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 8681},
- {DRIVER_ATI_R300, DRIVER_MODEL_NT6X, "atiumdag.dll", 14, 10, 741 },
- {DRIVER_ATI_R600, DRIVER_MODEL_NT6X, "atiumdag.dll", 14, 10, 741 },
+ * - Radeon 9500 (R300) - X1*00 (R5xx) supported up to Catalyst 9.3 (Linux) and 10.2 (XP/Vista/Win7)
+ * - Radeon 7xxx (R100) - 9250 (RV250) supported up to Catalyst 6.11 (XP)
+ * - Rage 128 supported up to XP, latest official build 6.13.3279 dated October 2001 */
+ {DRIVER_AMD_RAGE_128PRO, DRIVER_MODEL_NT5X, "ati2dvaa.dll", 13, 3279, 0},
+ {DRIVER_AMD_R100, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6614},
+ {DRIVER_AMD_R300, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 6764},
+ {DRIVER_AMD_R600, DRIVER_MODEL_NT5X, "ati2dvag.dll", 14, 10, 8681},
+ {DRIVER_AMD_R300, DRIVER_MODEL_NT6X, "atiumdag.dll", 14, 10, 741 },
+ {DRIVER_AMD_R600, DRIVER_MODEL_NT6X, "atiumdag.dll", 14, 10, 741 },
/* Intel
* The drivers are unified but not all versions support all GPUs. At some point the 2k/xp
@@ -1027,8 +1009,8 @@ static const struct driver_version_information driver_version_table[] =
{DRIVER_NVIDIA_TNT, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 7186},
{DRIVER_NVIDIA_GEFORCE2MX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 10, 9371},
{DRIVER_NVIDIA_GEFORCEFX, DRIVER_MODEL_NT5X, "nv4_disp.dll", 14, 11, 7516},
- {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT5X, "nv4_disp.dll", 15, 11, 9745},
- {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT6X, "nvd3dum.dll", 15, 11, 9745},
+ {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT5X, "nv4_disp.dll", 15, 12, 6658},
+ {DRIVER_NVIDIA_GEFORCE6, DRIVER_MODEL_NT6X, "nvd3dum.dll", 15, 12, 6658},
};
struct gpu_description
@@ -1080,30 +1062,46 @@ static const struct gpu_description gpu_description_table[] =
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", DRIVER_NVIDIA_GEFORCE6, 1024},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", DRIVER_NVIDIA_GEFORCE6, 896 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", DRIVER_NVIDIA_GEFORCE6, 1024},
+ {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT320M, "NVIDIA GeForce GT 320M", DRIVER_NVIDIA_GEFORCE6, 1024},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT325M, "NVIDIA GeForce GT 325M", DRIVER_NVIDIA_GEFORCE6, 1024},
+ {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT330, "NVIDIA GeForce GT 330", DRIVER_NVIDIA_GEFORCE6, 1024},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS350M, "NVIDIA GeForce GTS 350M", DRIVER_NVIDIA_GEFORCE6, 1024},
+ {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT420, "NVIDIA GeForce GT 420", DRIVER_NVIDIA_GEFORCE6, 2048},
+ {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT430, "NVIDIA GeForce GT 430", DRIVER_NVIDIA_GEFORCE6, 1024},
+ {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT440, "NVIDIA GeForce GT 440", DRIVER_NVIDIA_GEFORCE6, 1024},
+ {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTS450, "NVIDIA GeForce GTS 450", DRIVER_NVIDIA_GEFORCE6, 1024},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX460, "NVIDIA GeForce GTX 460", DRIVER_NVIDIA_GEFORCE6, 768 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX465, "NVIDIA GeForce GTX 465", DRIVER_NVIDIA_GEFORCE6, 1024},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX470, "NVIDIA GeForce GTX 470", DRIVER_NVIDIA_GEFORCE6, 1280},
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX480, "NVIDIA GeForce GTX 480", DRIVER_NVIDIA_GEFORCE6, 1536},
- /* ATI cards */
- {HW_VENDOR_ATI, CARD_ATI_RAGE_128PRO, "ATI Rage Fury", DRIVER_ATI_RAGE_128PRO, 16 },
- {HW_VENDOR_ATI, CARD_ATI_RADEON_7200, "ATI RADEON 7200 SERIES", DRIVER_ATI_R100, 32 },
- {HW_VENDOR_ATI, CARD_ATI_RADEON_8500, "ATI RADEON 8500 SERIES", DRIVER_ATI_R100, 64 },
- {HW_VENDOR_ATI, CARD_ATI_RADEON_9500, "ATI Radeon 9500", DRIVER_ATI_R300, 64 },
- {HW_VENDOR_ATI, CARD_ATI_RADEON_XPRESS_200M, "ATI RADEON XPRESS 200M Series", DRIVER_ATI_R300, 64 },
- {HW_VENDOR_ATI, CARD_ATI_RADEON_X700, "ATI Radeon X700 SE", DRIVER_ATI_R300, 128 },
- {HW_VENDOR_ATI, CARD_ATI_RADEON_X1600, "ATI Radeon X1600 Series", DRIVER_ATI_R300, 128 },
- {HW_VENDOR_ATI, CARD_ATI_RADEON_HD2350, "ATI Mobility Radeon HD 2350", DRIVER_ATI_R600, 256 },
- {HW_VENDOR_ATI, CARD_ATI_RADEON_HD2600, "ATI Mobility Radeon HD 2600", DRIVER_ATI_R600, 256 },
- {HW_VENDOR_ATI, CARD_ATI_RADEON_HD2900, "ATI Radeon HD 2900 XT", DRIVER_ATI_R600, 512 },
- {HW_VENDOR_ATI, CARD_ATI_RADEON_HD3200, "ATI Radeon HD 3200 Graphics", DRIVER_ATI_R600, 128 },
- {HW_VENDOR_ATI, CARD_ATI_RADEON_HD4350, "ATI Radeon HD 4350", DRIVER_ATI_R600, 256 },
- {HW_VENDOR_ATI, CARD_ATI_RADEON_HD4600, "ATI Radeon HD 4600 Series", DRIVER_ATI_R600, 512 },
- {HW_VENDOR_ATI, CARD_ATI_RADEON_HD4700, "ATI Radeon HD 4700 Series", DRIVER_ATI_R600, 512 },
- {HW_VENDOR_ATI, CARD_ATI_RADEON_HD4800, "ATI Radeon HD 4800 Series", DRIVER_ATI_R600, 512 },
- {HW_VENDOR_ATI, CARD_ATI_RADEON_HD5700, "ATI Radeon HD 5700 Series", DRIVER_ATI_R600, 512 },
- {HW_VENDOR_ATI, CARD_ATI_RADEON_HD5800, "ATI Radeon HD 5800 Series", DRIVER_ATI_R600, 1024},
+ {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560, "NVIDIA GeForce GTX 560 TI", DRIVER_NVIDIA_GEFORCE6, 1024},
+ {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX570, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE6, 1280},
+ {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX580, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE6, 1536},
+
+ /* AMD cards */
+ {HW_VENDOR_AMD, CARD_AMD_RAGE_128PRO, "ATI Rage Fury", DRIVER_AMD_RAGE_128PRO, 16 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_7200, "ATI RADEON 7200 SERIES", DRIVER_AMD_R100, 32 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_8500, "ATI RADEON 8500 SERIES", DRIVER_AMD_R100, 64 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_9500, "ATI Radeon 9500", DRIVER_AMD_R300, 64 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_XPRESS_200M, "ATI RADEON XPRESS 200M Series", DRIVER_AMD_R300, 64 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_X700, "ATI Radeon X700 SE", DRIVER_AMD_R300, 128 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_X1600, "ATI Radeon X1600 Series", DRIVER_AMD_R300, 128 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2350, "ATI Mobility Radeon HD 2350", DRIVER_AMD_R600, 256 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2600, "ATI Mobility Radeon HD 2600", DRIVER_AMD_R600, 256 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_HD2900, "ATI Radeon HD 2900 XT", DRIVER_AMD_R600, 512 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_HD3200, "ATI Radeon HD 3200 Graphics", DRIVER_AMD_R600, 128 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4350, "ATI Radeon HD 4350", DRIVER_AMD_R600, 256 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4600, "ATI Radeon HD 4600 Series", DRIVER_AMD_R600, 512 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4700, "ATI Radeon HD 4700 Series", DRIVER_AMD_R600, 512 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_HD4800, "ATI Radeon HD 4800 Series", DRIVER_AMD_R600, 512 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5400, "ATI Radeon HD 5400 Series", DRIVER_AMD_R600, 512 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5600, "ATI Radeon HD 5600 Series", DRIVER_AMD_R600, 512 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5700, "ATI Radeon HD 5700 Series", DRIVER_AMD_R600, 512 },
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5800, "ATI Radeon HD 5800 Series", DRIVER_AMD_R600, 1024},
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_HD5900, "ATI Radeon HD 5900 Series", DRIVER_AMD_R600, 1024},
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6310, "AMD Radeon HD 6310 Graphics", DRIVER_AMD_R600, 1024},
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6800, "AMD Radeon HD 6800 Series", DRIVER_AMD_R600, 1024},
+ {HW_VENDOR_AMD, CARD_AMD_RADEON_HD6900, "AMD Radeon HD 6900 Series", DRIVER_AMD_R600, 2048},
/* Intel cards */
{HW_VENDOR_INTEL, CARD_INTEL_I830G, "Intel(R) 82830M Graphics Controller", DRIVER_INTEL_GMA800, 32 },
{HW_VENDOR_INTEL, CARD_INTEL_I855G, "Intel(R) 82852/82855 GM/GME Graphics Controller", DRIVER_INTEL_GMA800, 32 },
@@ -1111,7 +1109,8 @@ static const struct gpu_description gpu_description_table[] =
{HW_VENDOR_INTEL, CARD_INTEL_I915G, "Intel(R) 82915G/GV/910GL Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
{HW_VENDOR_INTEL, CARD_INTEL_I915GM, "Mobile Intel(R) 915GM/GMS,910GML Express Chipset Family", DRIVER_INTEL_GMA900, 64 },
{HW_VENDOR_INTEL, CARD_INTEL_I945GM, "Mobile Intel(R) 945GM Express Chipset Family", DRIVER_INTEL_GMA950, 64 },
- {HW_VENDOR_INTEL, CARD_INTEL_X3100, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000, 128}
+ {HW_VENDOR_INTEL, CARD_INTEL_X3100, "Mobile Intel(R) 965 Express Chipset Family", DRIVER_INTEL_GMA3000, 128},
+ {HW_VENDOR_INTEL, CARD_INTEL_GM45, "Mobile Intel(R) GM45 Express Chipset Family", DRIVER_INTEL_GMA3000, 512}
};
static const struct driver_version_information *get_driver_version_info(enum wined3d_display_driver driver,
@@ -1367,18 +1366,20 @@ static enum wined3d_gl_vendor wined3d_guess_gl_vendor(struct wined3d_gl_info *gl
static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_string, const char *gl_renderer)
{
- if (strstr(gl_vendor_string, "NVIDIA"))
+ if (strstr(gl_vendor_string, "NVIDIA")
+ || strstr(gl_vendor_string, "nouveau"))
return HW_VENDOR_NVIDIA;
if (strstr(gl_vendor_string, "ATI")
|| strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
|| strstr(gl_vendor_string, "X.Org R300 Project")
+ || strstr(gl_renderer, "AMD")
|| strstr(gl_renderer, "R100")
|| strstr(gl_renderer, "R200")
|| strstr(gl_renderer, "R300")
|| strstr(gl_renderer, "R600")
|| strstr(gl_renderer, "R700"))
- return HW_VENDOR_ATI;
+ return HW_VENDOR_AMD;
if (strstr(gl_vendor_string, "Intel(R)")
/* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
@@ -1401,161 +1402,74 @@ static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_s
static enum wined3d_pci_device select_card_nvidia_binary(const struct wined3d_gl_info *gl_info,
const char *gl_renderer)
{
+ unsigned int i;
+
if (WINE_D3D10_CAPABLE(gl_info))
{
- /* Geforce 400 - highend */
- if (strstr(gl_renderer, "GTX 480"))
+ static const struct
{
- return CARD_NVIDIA_GEFORCE_GTX480;
+ const char *renderer;
+ enum wined3d_pci_device id;
}
+ cards[] =
+ {
+ {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580}, /* Geforce 500 - highend */
+ {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570}, /* Geforce 500 - midend high */
+ {"GTX 560 TI", CARD_NVIDIA_GEFORCE_GTX560}, /* Geforce 500 - midend */
+ {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480}, /* Geforce 400 - highend */
+ {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470}, /* Geforce 400 - midend high */
+ {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465}, /* Geforce 400 - midend */
+ {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460}, /* Geforce 400 - midend */
+ {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450}, /* Geforce 400 - midend low */
+ {"GT 440", CARD_NVIDIA_GEFORCE_GT440}, /* Geforce 400 - lowend */
+ {"GT 430", CARD_NVIDIA_GEFORCE_GT430}, /* Geforce 400 - lowend */
+ {"GT 420", CARD_NVIDIA_GEFORCE_GT420}, /* Geforce 400 - lowend */
+ {"GT 330", CARD_NVIDIA_GEFORCE_GT330}, /* Geforce 300 - highend */
+ {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
+ {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M}, /* Geforce 300 - highend mobile */
+ {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
+ {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M}, /* Geforce 300 - midend mobile */
+ {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M}, /* Geforce 300 - midend mobile */
+ {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
+ {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
+ {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280}, /* Geforce 200 - highend */
+ {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275}, /* Geforce 200 - midend high */
+ {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260}, /* Geforce 200 - midend */
+ {"GT 240", CARD_NVIDIA_GEFORCE_GT240}, /* Geforce 200 - midend */
+ {"GT 220", CARD_NVIDIA_GEFORCE_GT220}, /* Geforce 200 - lowend */
+ {"Geforce 310", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
+ {"Geforce 305", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
+ {"Geforce 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
+ {"G 210", CARD_NVIDIA_GEFORCE_210}, /* Geforce 200 - lowend */
+ {"GTS 250", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
+ {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
+ {"9800", CARD_NVIDIA_GEFORCE_9800GT}, /* Geforce 9 - highend / Geforce 200 - midend */
+ {"GT 140", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
+ {"9600", CARD_NVIDIA_GEFORCE_9600GT}, /* Geforce 9 - midend */
+ {"GT 130", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
+ {"GT 120", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
+ {"9500", CARD_NVIDIA_GEFORCE_9500GT}, /* Geforce 9 - midend low / Geforce 200 - low */
+ {"9400", CARD_NVIDIA_GEFORCE_9400GT}, /* Geforce 9 - lowend */
+ {"9300", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
+ {"9200", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
+ {"9100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
+ {"G 100", CARD_NVIDIA_GEFORCE_9200}, /* Geforce 9 - lowend low */
+ {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX}, /* Geforce 8 - highend high */
+ {"8800", CARD_NVIDIA_GEFORCE_8800GTS}, /* Geforce 8 - highend */
+ {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT}, /* Geforce 8 - midend mobile */
+ {"8700", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
+ {"8600", CARD_NVIDIA_GEFORCE_8600GT}, /* Geforce 8 - midend */
+ {"8500", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */
+ {"8400", CARD_NVIDIA_GEFORCE_8400GS}, /* Geforce 8 - mid-lowend */
+ {"8300", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
+ {"8200", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
+ {"8100", CARD_NVIDIA_GEFORCE_8300GS}, /* Geforce 8 - lowend */
+ };
- /* Geforce 400 - midend high */
- if (strstr(gl_renderer, "GTX 470"))
+ for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
{
- return CARD_NVIDIA_GEFORCE_GTX470;
- }
-
- /* Geforce 400 - midend */
- if (strstr(gl_renderer, "GTX 465"))
- {
- return CARD_NVIDIA_GEFORCE_GTX465;
- }
-
- /* Geforce 400 - midend */
- if (strstr(gl_renderer, "GTX 460"))
- {
- return CARD_NVIDIA_GEFORCE_GTX460;
- }
-
- /* Geforce 300 highend mobile */
- if (strstr(gl_renderer, "GTS 350M")
- || strstr(gl_renderer, "GTS 360M"))
- {
- return CARD_NVIDIA_GEFORCE_GTS350M;
- }
-
- /* Geforce 300 midend mobile (Geforce GT 325M/330M use the same core) */
- if (strstr(gl_renderer, "GT 325M")
- || strstr(gl_renderer, "GT 330M"))
- {
- return CARD_NVIDIA_GEFORCE_GT325M;
- }
-
- /* Geforce 200 - highend */
- if (strstr(gl_renderer, "GTX 280")
- || strstr(gl_renderer, "GTX 285")
- || strstr(gl_renderer, "GTX 295"))
- {
- return CARD_NVIDIA_GEFORCE_GTX280;
- }
-
- /* Geforce 200 - midend high */
- if (strstr(gl_renderer, "GTX 275"))
- {
- return CARD_NVIDIA_GEFORCE_GTX275;
- }
-
- /* Geforce 200 - midend */
- if (strstr(gl_renderer, "GTX 260"))
- {
- return CARD_NVIDIA_GEFORCE_GTX260;
- }
- /* Geforce 200 - midend */
- if (strstr(gl_renderer, "GT 240"))
- {
- return CARD_NVIDIA_GEFORCE_GT240;
- }
-
- /* Geforce 200 lowend */
- if (strstr(gl_renderer, "GT 220"))
- {
- return CARD_NVIDIA_GEFORCE_GT220;
- }
- /* Geforce 200 lowend (Geforce 305/310 use the same core) */
- if (strstr(gl_renderer, "Geforce 210")
- || strstr(gl_renderer, "G 210")
- || strstr(gl_renderer, "Geforce 305")
- || strstr(gl_renderer, "Geforce 310"))
- {
- return CARD_NVIDIA_GEFORCE_210;
- }
-
- /* Geforce9 - highend / Geforce 200 - midend (GTS 150/250 are based on the same core) */
- if (strstr(gl_renderer, "9800")
- || strstr(gl_renderer, "GTS 150")
- || strstr(gl_renderer, "GTS 250"))
- {
- return CARD_NVIDIA_GEFORCE_9800GT;
- }
-
- /* Geforce9 - midend (GT 140 uses the same core as the 9600GT) */
- if (strstr(gl_renderer, "9600")
- || strstr(gl_renderer, "GT 140"))
- {
- return CARD_NVIDIA_GEFORCE_9600GT;
- }
-
- /* Geforce9 - midend low / Geforce 200 - low */
- if (strstr(gl_renderer, "9500")
- || strstr(gl_renderer, "GT 120")
- || strstr(gl_renderer, "GT 130"))
- {
- return CARD_NVIDIA_GEFORCE_9500GT;
- }
-
- /* Geforce9 - lowend */
- if (strstr(gl_renderer, "9400"))
- {
- return CARD_NVIDIA_GEFORCE_9400GT;
- }
-
- /* Geforce9 - lowend low */
- if (strstr(gl_renderer, "9100")
- || strstr(gl_renderer, "9200")
- || strstr(gl_renderer, "9300")
- || strstr(gl_renderer, "G 100"))
- {
- return CARD_NVIDIA_GEFORCE_9200;
- }
-
- /* Geforce8 - highend high*/
- if (strstr(gl_renderer, "8800 GTX"))
- {
- return CARD_NVIDIA_GEFORCE_8800GTX;
- }
-
- /* Geforce8 - highend */
- if (strstr(gl_renderer, "8800"))
- {
- return CARD_NVIDIA_GEFORCE_8800GTS;
- }
-
- /* Geforce8 - midend mobile */
- if (strstr(gl_renderer, "8600 M"))
- {
- return CARD_NVIDIA_GEFORCE_8600MGT;
- }
-
- /* Geforce8 - midend */
- if (strstr(gl_renderer, "8600")
- || strstr(gl_renderer, "8700"))
- {
- return CARD_NVIDIA_GEFORCE_8600GT;
- }
-
- /* Geforce8 - mid-lowend */
- if (strstr(gl_renderer, "8400")
- || strstr(gl_renderer, "8500"))
- {
- return CARD_NVIDIA_GEFORCE_8400GS;
- }
-
- /* Geforce8 - lowend */
- if (strstr(gl_renderer, "8100")
- || strstr(gl_renderer, "8200")
- || strstr(gl_renderer, "8300"))
- {
- return CARD_NVIDIA_GEFORCE_8300GS;
+ if (strstr(gl_renderer, cards[i].renderer))
+ return cards[i].id;
}
/* Geforce8-compatible fall back if the GPU is not in the list yet */
@@ -1567,50 +1481,35 @@ static enum wined3d_pci_device select_card_nvidia_binary(const struct wined3d_gl
*/
if (WINE_D3D9_CAPABLE(gl_info) && gl_info->supported[NV_VERTEX_PROGRAM3])
{
- /* Geforce7 - highend */
- if (strstr(gl_renderer, "7800")
- || strstr(gl_renderer, "7900")
- || strstr(gl_renderer, "7950")
- || strstr(gl_renderer, "Quadro FX 4")
- || strstr(gl_renderer, "Quadro FX 5"))
+ static const struct
{
- return CARD_NVIDIA_GEFORCE_7800GT;
+ const char *renderer;
+ enum wined3d_pci_device id;
+ }
+ cards[] =
+ {
+ {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
+ {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
+ {"7950", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
+ {"7900", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
+ {"7800", CARD_NVIDIA_GEFORCE_7800GT}, /* Geforce 7 - highend */
+ {"7700", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
+ {"7600", CARD_NVIDIA_GEFORCE_7600}, /* Geforce 7 - midend */
+ {"7400", CARD_NVIDIA_GEFORCE_7400}, /* Geforce 7 - lower medium */
+ {"7300", CARD_NVIDIA_GEFORCE_7300}, /* Geforce 7 - lowend */
+ {"6800", CARD_NVIDIA_GEFORCE_6800}, /* Geforce 6 - highend */
+ {"6700", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
+ {"6610", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
+ {"6600", CARD_NVIDIA_GEFORCE_6600GT}, /* Geforce 6 - midend */
+ };
+
+ for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
+ {
+ if (strstr(gl_renderer, cards[i].renderer))
+ return cards[i].id;
}
- /* Geforce7 midend */
- if (strstr(gl_renderer, "7600")
- || strstr(gl_renderer, "7700"))
- {
- return CARD_NVIDIA_GEFORCE_7600;
- }
-
- /* Geforce7 lower medium */
- if (strstr(gl_renderer, "7400"))
- {
- return CARD_NVIDIA_GEFORCE_7400;
- }
-
- /* Geforce7 lowend */
- if (strstr(gl_renderer, "7300"))
- {
- return CARD_NVIDIA_GEFORCE_7300;
- }
-
- /* Geforce6 highend */
- if (strstr(gl_renderer, "6800"))
- {
- return CARD_NVIDIA_GEFORCE_6800;
- }
-
- /* Geforce6 - midend */
- if (strstr(gl_renderer, "6600")
- || strstr(gl_renderer, "6610")
- || strstr(gl_renderer, "6700"))
- {
- return CARD_NVIDIA_GEFORCE_6600GT;
- }
-
- /* Geforce6/7 lowend */
+ /* Geforce 6/7 - lowend */
return CARD_NVIDIA_GEFORCE_6200; /* Geforce 6100/6150/6200/7300/7400/7500 */
}
@@ -1676,7 +1575,7 @@ static enum wined3d_pci_device select_card_nvidia_binary(const struct wined3d_gl
return CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */
}
-static enum wined3d_pci_device select_card_ati_binary(const struct wined3d_gl_info *gl_info,
+static enum wined3d_pci_device select_card_amd_binary(const struct wined3d_gl_info *gl_info,
const char *gl_renderer)
{
/* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
@@ -1685,93 +1584,67 @@ static enum wined3d_pci_device select_card_ati_binary(const struct wined3d_gl_in
* eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
if (WINE_D3D10_CAPABLE(gl_info))
{
- /* Radeon EG CYPRESS XT / PRO HD5800 - highend */
- if (strstr(gl_renderer, "HD 5800") /* Radeon EG CYPRESS HD58xx generic renderer string */
- || strstr(gl_renderer, "HD 5850") /* Radeon EG CYPRESS XT */
- || strstr(gl_renderer, "HD 5870")) /* Radeon EG CYPRESS PRO */
- {
- return CARD_ATI_RADEON_HD5800;
- }
+ unsigned int i;
- /* Radeon EG JUNIPER XT / LE HD5700 - midend */
- if (strstr(gl_renderer, "HD 5700") /* Radeon EG JUNIPER HD57xx generic renderer string */
- || strstr(gl_renderer, "HD 5750") /* Radeon EG JUNIPER LE */
- || strstr(gl_renderer, "HD 5770")) /* Radeon EG JUNIPER XT */
+ static const struct
{
- return CARD_ATI_RADEON_HD5700;
+ const char *renderer;
+ enum wined3d_pci_device id;
}
-
- /* Radeon R7xx HD4800 - highend */
- if (strstr(gl_renderer, "HD 4800") /* Radeon RV7xx HD48xx generic renderer string */
- || strstr(gl_renderer, "HD 4830") /* Radeon RV770 */
- || strstr(gl_renderer, "HD 4850") /* Radeon RV770 */
- || strstr(gl_renderer, "HD 4870") /* Radeon RV770 */
- || strstr(gl_renderer, "HD 4890")) /* Radeon RV790 */
+ cards[] =
{
- return CARD_ATI_RADEON_HD4800;
- }
+ /* Evergreen */
+ {"HD 5870", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS PRO */
+ {"HD 5850", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS XT */
+ {"HD 5800", CARD_AMD_RADEON_HD5800}, /* Radeon EG CYPRESS HD58xx generic renderer string */
+ {"HD 5770", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER XT */
+ {"HD 5750", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER LE */
+ {"HD 5700", CARD_AMD_RADEON_HD5700}, /* Radeon EG JUNIPER HD57xx generic renderer string */
+ {"HD 5670", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD XT */
+ {"HD 5570", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
+ {"HD 5550", CARD_AMD_RADEON_HD5600}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
+ {"HD 5450", CARD_AMD_RADEON_HD5400}, /* Radeon EG CEDAR PRO */
+ /* R700 */
+ {"HD 4890", CARD_AMD_RADEON_HD4800}, /* Radeon RV790 */
+ {"HD 4870", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
+ {"HD 4850", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
+ {"HD 4830", CARD_AMD_RADEON_HD4800}, /* Radeon RV770 */
+ {"HD 4800", CARD_AMD_RADEON_HD4800}, /* Radeon RV7xx HD48xx generic renderer string */
+ {"HD 4770", CARD_AMD_RADEON_HD4700}, /* Radeon RV740 */
+ {"HD 4700", CARD_AMD_RADEON_HD4700}, /* Radeon RV7xx HD47xx generic renderer string */
+ {"HD 4670", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
+ {"HD 4650", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
+ {"HD 4600", CARD_AMD_RADEON_HD4600}, /* Radeon RV730 */
+ {"HD 4550", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
+ {"HD 4350", CARD_AMD_RADEON_HD4350}, /* Radeon RV710 */
+ /* R600/R700 integrated */
+ {"HD 3300", CARD_AMD_RADEON_HD3200},
+ {"HD 3200", CARD_AMD_RADEON_HD3200},
+ {"HD 3100", CARD_AMD_RADEON_HD3200},
+ /* R600 */
+ {"HD 3870", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
+ {"HD 3850", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
+ {"HD 2900", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
+ {"HD 3830", CARD_AMD_RADEON_HD2600}, /* China-only midend */
+ {"HD 3690", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
+ {"HD 3650", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
+ {"HD 2600", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend */
+ {"HD 3470", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
+ {"HD 3450", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
+ {"HD 3430", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
+ {"HD 3400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
+ {"HD 2400", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
+ {"HD 2350", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
+ };
- /* Radeon R740 HD4700 - midend */
- if (strstr(gl_renderer, "HD 4700") /* Radeon RV770 */
- || strstr(gl_renderer, "HD 4770")) /* Radeon RV740 */
+ for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
{
- return CARD_ATI_RADEON_HD4700;
- }
-
- /* Radeon R730 HD4600 - midend */
- if (strstr(gl_renderer, "HD 4600") /* Radeon RV730 */
- || strstr(gl_renderer, "HD 4650") /* Radeon RV730 */
- || strstr(gl_renderer, "HD 4670")) /* Radeon RV730 */
- {
- return CARD_ATI_RADEON_HD4600;
- }
-
- /* Radeon R710 HD4500/HD4350 - lowend */
- if (strstr(gl_renderer, "HD 4350") /* Radeon RV710 */
- || strstr(gl_renderer, "HD 4550")) /* Radeon RV710 */
- {
- return CARD_ATI_RADEON_HD4350;
- }
-
- /* Radeon R6xx HD2900/HD3800 - highend */
- if (strstr(gl_renderer, "HD 2900")
- || strstr(gl_renderer, "HD 3870")
- || strstr(gl_renderer, "HD 3850"))
- {
- return CARD_ATI_RADEON_HD2900;
- }
-
- /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
- if (strstr(gl_renderer, "HD 2600")
- || strstr(gl_renderer, "HD 3830")
- || strstr(gl_renderer, "HD 3690")
- || strstr(gl_renderer, "HD 3650"))
- {
- return CARD_ATI_RADEON_HD2600;
- }
-
- /* Radeon R6xx HD2350/HD2400/HD3400 - lowend
- * Note HD2300=DX9, HD2350=DX10 */
- if (strstr(gl_renderer, "HD 2350")
- || strstr(gl_renderer, "HD 2400")
- || strstr(gl_renderer, "HD 3470")
- || strstr(gl_renderer, "HD 3450")
- || strstr(gl_renderer, "HD 3430")
- || strstr(gl_renderer, "HD 3400"))
- {
- return CARD_ATI_RADEON_HD2350;
- }
-
- /* Radeon R6xx/R7xx integrated */
- if (strstr(gl_renderer, "HD 3100")
- || strstr(gl_renderer, "HD 3200")
- || strstr(gl_renderer, "HD 3300"))
- {
- return CARD_ATI_RADEON_HD3200;
+ if (strstr(gl_renderer, cards[i].renderer))
+ return cards[i].id;
}
/* Default for when no GPU has been found */
- return CARD_ATI_RADEON_HD3200;
+ return CARD_AMD_RADEON_HD3200;
}
if (WINE_D3D8_CAPABLE(gl_info))
@@ -1783,7 +1656,7 @@ static enum wined3d_pci_device select_card_ati_binary(const struct wined3d_gl_in
|| strstr(gl_renderer, "X1900")
|| strstr(gl_renderer, "X1950"))
{
- return CARD_ATI_RADEON_X1600;
+ return CARD_AMD_RADEON_X1600;
}
/* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
@@ -1800,35 +1673,36 @@ static enum wined3d_pci_device select_card_ati_binary(const struct wined3d_gl_in
|| strstr(gl_renderer, "HD 2300")
)
{
- return CARD_ATI_RADEON_X700;
+ return CARD_AMD_RADEON_X700;
}
/* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
if (strstr(gl_renderer, "Radeon Xpress"))
{
- return CARD_ATI_RADEON_XPRESS_200M;
+ return CARD_AMD_RADEON_XPRESS_200M;
}
/* Radeon R3xx */
- return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
+ return CARD_AMD_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
}
if (WINE_D3D8_CAPABLE(gl_info))
{
- return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */
+ return CARD_AMD_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */
}
if (WINE_D3D7_CAPABLE(gl_info))
{
- return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */
+ return CARD_AMD_RADEON_7200; /* Radeon 7000/7100/7200/7500 */
}
- return CARD_ATI_RAGE_128PRO;
+ return CARD_AMD_RAGE_128PRO;
}
static enum wined3d_pci_device select_card_intel(const struct wined3d_gl_info *gl_info,
const char *gl_renderer)
{
+ if (strstr(gl_renderer, "GM45")) return CARD_INTEL_GM45;
if (strstr(gl_renderer, "X3100") || strstr(gl_renderer, "965GM"))
{
/* MacOS calls the card GMA X3100, otherwise known as GM965/GL960 */
@@ -1850,195 +1724,225 @@ static enum wined3d_pci_device select_card_intel(const struct wined3d_gl_info *g
}
-static enum wined3d_pci_device select_card_ati_mesa(const struct wined3d_gl_info *gl_info,
+static enum wined3d_pci_device select_card_amd_mesa(const struct wined3d_gl_info *gl_info,
const char *gl_renderer)
{
+ unsigned int i;
+
/* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
*
* Beware: renderer string do not match exact card model,
* eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
if (strstr(gl_renderer, "Gallium"))
{
- /* Radeon R7xx HD4800 - highend */
- if (strstr(gl_renderer, "R700") /* Radeon R7xx HD48xx generic renderer string */
- || strstr(gl_renderer, "RV770") /* Radeon RV770 */
- || strstr(gl_renderer, "RV790")) /* Radeon RV790 */
+ /* 20101109 - These are never returned by current Gallium radeon
+ * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351.
+ *
+ * These are returned but not handled: RC410, RV380. */
+ static const struct
{
- return CARD_ATI_RADEON_HD4800;
+ const char *renderer;
+ enum wined3d_pci_device id;
}
-
- /* Radeon R740 HD4700 - midend */
- if (strstr(gl_renderer, "RV740")) /* Radeon RV740 */
+ cards[] =
{
- return CARD_ATI_RADEON_HD4700;
- }
+ /* Northern Islands */
+ {"CAYMAN", CARD_AMD_RADEON_HD6900},
+ {"BARTS", CARD_AMD_RADEON_HD6800},
+ {"PALM", CARD_AMD_RADEON_HD6310},
+ /* Evergreen */
+ {"HEMLOCK", CARD_AMD_RADEON_HD5900},
+ {"CYPRESS", CARD_AMD_RADEON_HD5800},
+ {"JUNIPER", CARD_AMD_RADEON_HD5700},
+ {"REDWOOD", CARD_AMD_RADEON_HD5600},
+ {"CEDAR", CARD_AMD_RADEON_HD5400},
+ /* R700 */
+ {"R700", CARD_AMD_RADEON_HD4800}, /* HD4800 - highend */
+ {"RV790", CARD_AMD_RADEON_HD4800},
+ {"RV770", CARD_AMD_RADEON_HD4800},
+ {"RV740", CARD_AMD_RADEON_HD4700}, /* HD4700 - midend */
+ {"RV730", CARD_AMD_RADEON_HD4600}, /* HD4600 - midend */
+ {"RV710", CARD_AMD_RADEON_HD4350}, /* HD4500/HD4350 - lowend */
+ /* R600/R700 integrated */
+ {"RS880", CARD_AMD_RADEON_HD3200},
+ {"RS780", CARD_AMD_RADEON_HD3200},
+ /* R600 */
+ {"R680", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
+ {"R600", CARD_AMD_RADEON_HD2900},
+ {"RV670", CARD_AMD_RADEON_HD2900},
+ {"RV635", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
+ {"RV630", CARD_AMD_RADEON_HD2600},
+ {"RV620", CARD_AMD_RADEON_HD2350}, /* HD2350/HD2400/HD3400 - lowend */
+ {"RV610", CARD_AMD_RADEON_HD2350},
+ /* R500 */
+ {"R580", CARD_AMD_RADEON_X1600},
+ {"R520", CARD_AMD_RADEON_X1600},
+ {"RV570", CARD_AMD_RADEON_X1600},
+ {"RV560", CARD_AMD_RADEON_X1600},
+ {"RV535", CARD_AMD_RADEON_X1600},
+ {"RV530", CARD_AMD_RADEON_X1600},
+ {"RV516", CARD_AMD_RADEON_X700}, /* X700 is actually R400. */
+ {"RV515", CARD_AMD_RADEON_X700},
+ /* R400 */
+ {"R481", CARD_AMD_RADEON_X700},
+ {"R480", CARD_AMD_RADEON_X700},
+ {"R430", CARD_AMD_RADEON_X700},
+ {"R423", CARD_AMD_RADEON_X700},
+ {"R420", CARD_AMD_RADEON_X700},
+ {"R410", CARD_AMD_RADEON_X700},
+ {"RV410", CARD_AMD_RADEON_X700},
+ /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400MHz */
+ {"RS740", CARD_AMD_RADEON_XPRESS_200M},
+ {"RS690", CARD_AMD_RADEON_XPRESS_200M},
+ {"RS600", CARD_AMD_RADEON_XPRESS_200M},
+ {"RS485", CARD_AMD_RADEON_XPRESS_200M},
+ {"RS482", CARD_AMD_RADEON_XPRESS_200M},
+ {"RS480", CARD_AMD_RADEON_XPRESS_200M},
+ {"RS400", CARD_AMD_RADEON_XPRESS_200M},
+ /* R300 */
+ {"R360", CARD_AMD_RADEON_9500},
+ {"R350", CARD_AMD_RADEON_9500},
+ {"R300", CARD_AMD_RADEON_9500},
+ {"RV370", CARD_AMD_RADEON_9500},
+ {"RV360", CARD_AMD_RADEON_9500},
+ {"RV351", CARD_AMD_RADEON_9500},
+ {"RV350", CARD_AMD_RADEON_9500},
+ };
- /* Radeon R730 HD4600 - midend */
- if (strstr(gl_renderer, "RV730")) /* Radeon RV730 */
+ for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
{
- return CARD_ATI_RADEON_HD4600;
- }
-
- /* Radeon R710 HD4500/HD4350 - lowend */
- if (strstr(gl_renderer, "RV710")) /* Radeon RV710 */
- {
- return CARD_ATI_RADEON_HD4350;
- }
-
- /* Radeon R6xx HD2900/HD3800 - highend */
- if (strstr(gl_renderer, "R600")
- || strstr(gl_renderer, "RV670")
- || strstr(gl_renderer, "R680"))
- {
- return CARD_ATI_RADEON_HD2900;
- }
-
- /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
- if (strstr(gl_renderer, "RV630")
- || strstr(gl_renderer, "RV635"))
- {
- return CARD_ATI_RADEON_HD2600;
- }
-
- /* Radeon R6xx HD2350/HD2400/HD3400 - lowend */
- if (strstr(gl_renderer, "RV610")
- || strstr(gl_renderer, "RV620"))
- {
- return CARD_ATI_RADEON_HD2350;
- }
-
- /* Radeon R6xx/R7xx integrated */
- if (strstr(gl_renderer, "RS780")
- || strstr(gl_renderer, "RS880"))
- {
- return CARD_ATI_RADEON_HD3200;
- }
-
- /* Radeon R5xx */
- if (strstr(gl_renderer, "RV530")
- || strstr(gl_renderer, "RV535")
- || strstr(gl_renderer, "RV560")
- || strstr(gl_renderer, "R520")
- || strstr(gl_renderer, "RV570")
- || strstr(gl_renderer, "R580"))
- {
- return CARD_ATI_RADEON_X1600;
- }
-
- /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300 (lowend R5xx) */
- if (strstr(gl_renderer, "R410")
- || strstr(gl_renderer, "R420")
- || strstr(gl_renderer, "R423")
- || strstr(gl_renderer, "R430")
- || strstr(gl_renderer, "R480")
- || strstr(gl_renderer, "R481")
- || strstr(gl_renderer, "RV410")
- || strstr(gl_renderer, "RV515")
- || strstr(gl_renderer, "RV516"))
- {
- return CARD_ATI_RADEON_X700;
- }
-
- /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
- if (strstr(gl_renderer, "RS400")
- || strstr(gl_renderer, "RS480")
- || strstr(gl_renderer, "RS482")
- || strstr(gl_renderer, "RS485")
- || strstr(gl_renderer, "RS600")
- || strstr(gl_renderer, "RS690")
- || strstr(gl_renderer, "RS740"))
- {
- return CARD_ATI_RADEON_XPRESS_200M;
- }
-
- /* Radeon R3xx */
- if (strstr(gl_renderer, "R300")
- || strstr(gl_renderer, "RV350")
- || strstr(gl_renderer, "RV351")
- || strstr(gl_renderer, "RV360")
- || strstr(gl_renderer, "RV370")
- || strstr(gl_renderer, "R350")
- || strstr(gl_renderer, "R360"))
- {
- return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
+ if (strstr(gl_renderer, cards[i].renderer))
+ return cards[i].id;
}
}
if (WINE_D3D9_CAPABLE(gl_info))
{
- /* Radeon R7xx HD4800 - highend */
- if (strstr(gl_renderer, "(R700") /* Radeon R7xx HD48xx generic renderer string */
- || strstr(gl_renderer, "(RV770") /* Radeon RV770 */
- || strstr(gl_renderer, "(RV790")) /* Radeon RV790 */
+ static const struct
{
- return CARD_ATI_RADEON_HD4800;
+ const char *renderer;
+ enum wined3d_pci_device id;
}
-
- /* Radeon R740 HD4700 - midend */
- if (strstr(gl_renderer, "(RV740")) /* Radeon RV740 */
+ cards[] =
{
- return CARD_ATI_RADEON_HD4700;
- }
+ /* R700 */
+ {"(R700", CARD_AMD_RADEON_HD4800}, /* HD4800 - highend */
+ {"(RV790", CARD_AMD_RADEON_HD4800},
+ {"(RV770", CARD_AMD_RADEON_HD4800},
+ {"(RV740", CARD_AMD_RADEON_HD4700}, /* HD4700 - midend */
+ {"(RV730", CARD_AMD_RADEON_HD4600}, /* HD4600 - midend */
+ {"(RV710", CARD_AMD_RADEON_HD4350}, /* HD4500/HD4350 - lowend */
+ /* R600/R700 integrated */
+ {"RS880", CARD_AMD_RADEON_HD3200},
+ {"RS780", CARD_AMD_RADEON_HD3200},
+ /* R600 */
+ {"(R680", CARD_AMD_RADEON_HD2900}, /* HD2900/HD3800 - highend */
+ {"(R600", CARD_AMD_RADEON_HD2900},
+ {"(RV670", CARD_AMD_RADEON_HD2900},
+ {"(RV635", CARD_AMD_RADEON_HD2600}, /* HD2600/HD3600 - midend; HD3830 is China-only midend */
+ {"(RV630", CARD_AMD_RADEON_HD2600},
+ {"(RV620", CARD_AMD_RADEON_HD2350}, /* HD2300/HD2400/HD3400 - lowend */
+ {"(RV610", CARD_AMD_RADEON_HD2350},
+ };
- /* Radeon R730 HD4600 - midend */
- if (strstr(gl_renderer, "(RV730")) /* Radeon RV730 */
+ for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
{
- return CARD_ATI_RADEON_HD4600;
- }
-
- /* Radeon R710 HD4500/HD4350 - lowend */
- if (strstr(gl_renderer, "(RV710")) /* Radeon RV710 */
- {
- return CARD_ATI_RADEON_HD4350;
- }
-
- /* Radeon R6xx HD2900/HD3800 - highend */
- if (strstr(gl_renderer, "(R600")
- || strstr(gl_renderer, "(RV670")
- || strstr(gl_renderer, "(R680"))
- {
- return CARD_ATI_RADEON_HD2900;
- }
-
- /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
- if (strstr(gl_renderer, "(RV630")
- || strstr(gl_renderer, "(RV635"))
- {
- return CARD_ATI_RADEON_HD2600;
- }
-
- /* Radeon R6xx HD2300/HD2400/HD3400 - lowend */
- if (strstr(gl_renderer, "(RV610")
- || strstr(gl_renderer, "(RV620"))
- {
- return CARD_ATI_RADEON_HD2350;
- }
-
- /* Radeon R6xx/R7xx integrated */
- if (strstr(gl_renderer, "(RS780")
- || strstr(gl_renderer, "(RS880"))
- {
- return CARD_ATI_RADEON_HD3200;
+ if (strstr(gl_renderer, cards[i].renderer))
+ return cards[i].id;
}
}
if (WINE_D3D8_CAPABLE(gl_info))
{
- return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */
+ return CARD_AMD_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */
}
if (WINE_D3D7_CAPABLE(gl_info))
{
- return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */
+ return CARD_AMD_RADEON_7200; /* Radeon 7000/7100/7200/7500 */
}
- return CARD_ATI_RAGE_128PRO;
+ return CARD_AMD_RAGE_128PRO;
}
static enum wined3d_pci_device select_card_nvidia_mesa(const struct wined3d_gl_info *gl_info,
const char *gl_renderer)
{
- FIXME_(d3d_caps)("Card selection not handled for Mesa Nouveau driver\n");
+ if (strstr(gl_renderer, "Gallium"))
+ {
+ unsigned int i;
+
+ static const struct
+ {
+ const char *renderer;
+ enum wined3d_pci_device id;
+ }
+ cards[] =
+ {
+ {"NVC8", CARD_NVIDIA_GEFORCE_GTX570},
+ {"NVC4", CARD_NVIDIA_GEFORCE_GTX460},
+ {"NVC3", CARD_NVIDIA_GEFORCE_GT440},
+ {"NVC0", CARD_NVIDIA_GEFORCE_GTX480},
+ {"NVAF", CARD_NVIDIA_GEFORCE_GT320M},
+ {"NVAC", CARD_NVIDIA_GEFORCE_8200},
+ {"NVAA", CARD_NVIDIA_GEFORCE_8200},
+ {"NVA8", CARD_NVIDIA_GEFORCE_210},
+ {"NVA5", CARD_NVIDIA_GEFORCE_GT220},
+ {"NVA3", CARD_NVIDIA_GEFORCE_GT240},
+ {"NVA0", CARD_NVIDIA_GEFORCE_GTX280},
+ {"NV98", CARD_NVIDIA_GEFORCE_9200},
+ {"NV96", CARD_NVIDIA_GEFORCE_9400GT},
+ {"NV94", CARD_NVIDIA_GEFORCE_9600GT},
+ {"NV92", CARD_NVIDIA_GEFORCE_9800GT},
+ {"NV86", CARD_NVIDIA_GEFORCE_8500GT},
+ {"NV84", CARD_NVIDIA_GEFORCE_8600GT},
+ {"NV68", CARD_NVIDIA_GEFORCE_6200}, /* 7050 */
+ {"NV67", CARD_NVIDIA_GEFORCE_6200}, /* 7000M */
+ {"NV63", CARD_NVIDIA_GEFORCE_6200}, /* 7100 */
+ {"NV50", CARD_NVIDIA_GEFORCE_8800GTX},
+ {"NV4E", CARD_NVIDIA_GEFORCE_6200}, /* 6100 Go / 6150 Go */
+ {"NV4C", CARD_NVIDIA_GEFORCE_6200}, /* 6150SE */
+ {"NV4B", CARD_NVIDIA_GEFORCE_7600},
+ {"NV4A", CARD_NVIDIA_GEFORCE_6200},
+ {"NV49", CARD_NVIDIA_GEFORCE_7800GT}, /* 7900 */
+ {"NV47", CARD_NVIDIA_GEFORCE_7800GT},
+ {"NV46", CARD_NVIDIA_GEFORCE_7400},
+ {"NV45", CARD_NVIDIA_GEFORCE_6800},
+ {"NV44", CARD_NVIDIA_GEFORCE_6200},
+ {"NV43", CARD_NVIDIA_GEFORCE_6600GT},
+ {"NV42", CARD_NVIDIA_GEFORCE_6800},
+ {"NV41", CARD_NVIDIA_GEFORCE_6800},
+ {"NV40", CARD_NVIDIA_GEFORCE_6800},
+ {"NV38", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5950 Ultra */
+ {"NV36", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5700/5750 */
+ {"NV35", CARD_NVIDIA_GEFORCEFX_5800}, /* FX 5900 */
+ {"NV34", CARD_NVIDIA_GEFORCEFX_5200},
+ {"NV31", CARD_NVIDIA_GEFORCEFX_5600},
+ {"NV30", CARD_NVIDIA_GEFORCEFX_5800},
+ {"NV28", CARD_NVIDIA_GEFORCE4_TI4200},
+ {"NV25", CARD_NVIDIA_GEFORCE4_TI4200},
+ {"NV20", CARD_NVIDIA_GEFORCE3},
+ {"NV1F", CARD_NVIDIA_GEFORCE4_MX}, /* GF4 MX IGP */
+ {"NV1A", CARD_NVIDIA_GEFORCE2}, /* GF2 IGP */
+ {"NV18", CARD_NVIDIA_GEFORCE4_MX},
+ {"NV17", CARD_NVIDIA_GEFORCE4_MX},
+ {"NV16", CARD_NVIDIA_GEFORCE2},
+ {"NV15", CARD_NVIDIA_GEFORCE2},
+ {"NV11", CARD_NVIDIA_GEFORCE2_MX},
+ {"NV10", CARD_NVIDIA_GEFORCE},
+ {"NV05", CARD_NVIDIA_RIVA_TNT2},
+ {"NV04", CARD_NVIDIA_RIVA_TNT},
+ {"NV03", CARD_NVIDIA_RIVA_128},
+ };
+
+ for (i = 0; i < sizeof(cards) / sizeof(*cards); ++i)
+ {
+ if (strstr(gl_renderer, cards[i].renderer))
+ return cards[i].id;
+ }
+ }
+
+ FIXME_(d3d_caps)("Unknown renderer %s.\n", debugstr_a(gl_renderer));
if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCEFX_5600;
if (WINE_D3D8_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE3;
if (WINE_D3D7_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE;
@@ -2059,10 +1963,10 @@ static const struct vendor_card_selection vendor_card_select_table[] =
{
{GL_VENDOR_NVIDIA, HW_VENDOR_NVIDIA, "Nvidia binary driver", select_card_nvidia_binary},
{GL_VENDOR_APPLE, HW_VENDOR_NVIDIA, "Apple OSX NVidia binary driver", select_card_nvidia_binary},
- {GL_VENDOR_APPLE, HW_VENDOR_ATI, "Apple OSX AMD/ATI binary driver", select_card_ati_binary},
+ {GL_VENDOR_APPLE, HW_VENDOR_AMD, "Apple OSX AMD/ATI binary driver", select_card_amd_binary},
{GL_VENDOR_APPLE, HW_VENDOR_INTEL, "Apple OSX Intel binary driver", select_card_intel},
- {GL_VENDOR_FGLRX, HW_VENDOR_ATI, "AMD/ATI binary driver", select_card_ati_binary},
- {GL_VENDOR_MESA, HW_VENDOR_ATI, "Mesa AMD/ATI driver", select_card_ati_mesa},
+ {GL_VENDOR_FGLRX, HW_VENDOR_AMD, "AMD/ATI binary driver", select_card_amd_binary},
+ {GL_VENDOR_MESA, HW_VENDOR_AMD, "Mesa AMD/ATI driver", select_card_amd_mesa},
{GL_VENDOR_MESA, HW_VENDOR_NVIDIA, "Mesa Nouveau driver", select_card_nvidia_mesa},
{GL_VENDOR_MESA, HW_VENDOR_INTEL, "Mesa Intel driver", select_card_intel},
{GL_VENDOR_INTEL, HW_VENDOR_INTEL, "Mesa Intel driver", select_card_intel}
@@ -2167,7 +2071,7 @@ static const struct fragment_pipeline *select_fragment_implementation(struct win
else return &ffp_fragment_pipeline;
}
-static const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter)
+static const struct wined3d_shader_backend_ops *select_shader_backend(struct wined3d_adapter *adapter)
{
int vs_selected_mode, ps_selected_mode;
@@ -2750,6 +2654,10 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_adapter *adapter)
gl_info->supported[WGL_ARB_PIXEL_FORMAT] = TRUE;
TRACE_(d3d_caps)("FOUND: WGL_ARB_pixel_format support\n");
}
+ if (!strcmp(ThisExtn, "WGL_EXT_swap_control")) {
+ gl_info->supported[WGL_EXT_SWAP_CONTROL] = TRUE;
+ TRACE_(d3d_caps)("FOUND: WGL_EXT_swap_control support\n");
+ }
if (!strcmp(ThisExtn, "WGL_WINE_pixel_format_passthrough")) {
gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH] = TRUE;
TRACE_(d3d_caps)("FOUND: WGL_WINE_pixel_format_passthrough support\n");
@@ -2765,55 +2673,47 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_adapter *adapter)
return TRUE;
}
-/**********************************************************
- * IWineD3D implementation follows
- **********************************************************/
+UINT CDECL wined3d_get_adapter_count(const struct wined3d *wined3d)
+{
+ TRACE_(d3d_caps)("wined3d %p, reporting %u adapters.\n",
+ wined3d, wined3d->adapter_count);
-static UINT WINAPI IWineD3DImpl_GetAdapterCount (IWineD3D *iface) {
- IWineD3DImpl *This = (IWineD3DImpl *)iface;
-
- TRACE_(d3d_caps)("(%p): Reporting %u adapters\n", This, This->adapter_count);
-
- return This->adapter_count;
+ return wined3d->adapter_count;
}
-static HRESULT WINAPI IWineD3DImpl_RegisterSoftwareDevice(IWineD3D *iface, void *init_function)
+HRESULT CDECL wined3d_register_software_device(struct wined3d *wined3d, void *init_function)
{
- FIXME("iface %p, init_function %p stub!\n", iface, init_function);
+ FIXME("wined3d %p, init_function %p stub!\n", wined3d, init_function);
return WINED3D_OK;
}
-static HMONITOR WINAPI IWineD3DImpl_GetAdapterMonitor(IWineD3D *iface, UINT Adapter) {
- IWineD3DImpl *This = (IWineD3DImpl *)iface;
+HMONITOR CDECL wined3d_get_adapter_monitor(const struct wined3d *wined3d, UINT adapter_idx)
+{
+ TRACE_(d3d_caps)("wined3d %p, adapter_idx %u.\n", wined3d, adapter_idx);
- TRACE_(d3d_caps)("(%p)->(%d)\n", This, Adapter);
-
- if (Adapter >= IWineD3DImpl_GetAdapterCount(iface)) {
+ if (adapter_idx >= wined3d->adapter_count)
return NULL;
- }
- return MonitorFromPoint(This->adapters[Adapter].monitorPoint, MONITOR_DEFAULTTOPRIMARY);
+ return MonitorFromPoint(wined3d->adapters[adapter_idx].monitorPoint, MONITOR_DEFAULTTOPRIMARY);
}
/* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
of the same bpp but different resolutions */
/* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
-static UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Adapter, enum wined3d_format_id format_id)
+UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT adapter_idx,
+ enum wined3d_format_id format_id)
{
- IWineD3DImpl *This = (IWineD3DImpl *)iface;
+ TRACE_(d3d_caps)("wined3d %p, adapter_idx %u, format %s.\n", wined3d, adapter_idx, debug_d3dformat(format_id));
- TRACE_(d3d_caps)("iface %p, adapter %u, format_id: %s.\n", iface, Adapter, debug_d3dformat(format_id));
-
- if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
+ if (adapter_idx >= wined3d->adapter_count)
return 0;
- }
/* TODO: Store modes per adapter and read it from the adapter structure */
- if (Adapter == 0)
+ if (!adapter_idx)
{
- const struct wined3d_format *format = wined3d_get_format(&This->adapters[Adapter].gl_info, format_id);
+ const struct wined3d_format *format = wined3d_get_format(&wined3d->adapters[adapter_idx].gl_info, format_id);
UINT format_bits = format->byte_count * CHAR_BIT;
unsigned int i = 0;
unsigned int j = 0;
@@ -2837,34 +2737,36 @@ static UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Adapte
}
}
- TRACE_(d3d_caps)("(%p}->(Adapter: %d) => %d (out of %d)\n", This, Adapter, i, j);
+ TRACE_(d3d_caps)("Returning %u matching modes (out of %u total) for adapter %u.\n", i, j, adapter_idx);
+
return i;
- } else {
- FIXME_(d3d_caps)("Adapter not primary display\n");
}
+ else
+ {
+ FIXME_(d3d_caps)("Adapter not primary display.\n");
+ }
+
return 0;
}
/* Note: dx9 supplies a format. Calls from d3d8 supply WINED3DFMT_UNKNOWN */
-static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapter,
- enum wined3d_format_id format_id, UINT Mode, WINED3DDISPLAYMODE *pMode)
+HRESULT CDECL wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT adapter_idx,
+ enum wined3d_format_id format_id, UINT mode_idx, WINED3DDISPLAYMODE *mode)
{
- IWineD3DImpl *This = (IWineD3DImpl *)iface;
-
- TRACE_(d3d_caps)("iface %p, adapter_idx %u, format %s, mode_idx %u, mode %p.\n",
- iface, Adapter, debug_d3dformat(format_id), Mode, pMode);
+ TRACE_(d3d_caps)("wined3d %p, adapter_idx %u, format %s, mode_idx %u, mode %p.\n",
+ wined3d, adapter_idx, debug_d3dformat(format_id), mode_idx, mode);
/* Validate the parameters as much as possible */
- if (!pMode || Adapter >= IWineD3DImpl_GetAdapterCount(iface)
- || Mode >= IWineD3DImpl_GetAdapterModeCount(iface, Adapter, format_id))
+ if (!mode || adapter_idx >= wined3d->adapter_count
+ || mode_idx >= wined3d_get_adapter_mode_count(wined3d, adapter_idx, format_id))
{
return WINED3DERR_INVALIDCALL;
}
/* TODO: Store modes per adapter and read it from the adapter structure */
- if (Adapter == 0)
+ if (!adapter_idx)
{
- const struct wined3d_format *format = wined3d_get_format(&This->adapters[Adapter].gl_info, format_id);
+ const struct wined3d_format *format = wined3d_get_format(&wined3d->adapters[adapter_idx].gl_info, format_id);
UINT format_bits = format->byte_count * CHAR_BIT;
DEVMODEW DevModeW;
int ModeIdx = 0;
@@ -2877,7 +2779,7 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
/* If we are filtering to a specific format (D3D9), then need to skip
all unrelated modes, but if mode is irrelevant (D3D8), then we can
just count through the ones with valid bit depths */
- while ((i<=Mode) && EnumDisplaySettingsExW(NULL, j++, &DevModeW, 0))
+ while (i <= mode_idx && EnumDisplaySettingsExW(NULL, j++, &DevModeW, 0))
{
if (format_id == WINED3DFMT_UNKNOWN)
{
@@ -2898,28 +2800,28 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
ModeIdx = j - 1;
/* Now get the display mode via the calculated index */
- if (EnumDisplaySettingsExW(NULL, ModeIdx, &DevModeW, 0)) {
- pMode->Width = DevModeW.dmPelsWidth;
- pMode->Height = DevModeW.dmPelsHeight;
- pMode->RefreshRate = DEFAULT_REFRESH_RATE;
+ if (EnumDisplaySettingsExW(NULL, ModeIdx, &DevModeW, 0))
+ {
+ mode->Width = DevModeW.dmPelsWidth;
+ mode->Height = DevModeW.dmPelsHeight;
+ mode->RefreshRate = DEFAULT_REFRESH_RATE;
if (DevModeW.dmFields & DM_DISPLAYFREQUENCY)
- pMode->RefreshRate = DevModeW.dmDisplayFrequency;
+ mode->RefreshRate = DevModeW.dmDisplayFrequency;
if (format_id == WINED3DFMT_UNKNOWN)
- pMode->Format = pixelformat_for_depth(DevModeW.dmBitsPerPel);
+ mode->Format = pixelformat_for_depth(DevModeW.dmBitsPerPel);
else
- pMode->Format = format_id;
+ mode->Format = format_id;
}
else
{
- TRACE_(d3d_caps)("Requested mode out of range %d\n", Mode);
+ TRACE_(d3d_caps)("Requested mode %u out of range.\n", mode_idx);
return WINED3DERR_INVALIDCALL;
}
- TRACE_(d3d_caps)("W %d H %d rr %d fmt (%x - %s) bpp %u\n", pMode->Width, pMode->Height,
- pMode->RefreshRate, pMode->Format, debug_d3dformat(pMode->Format),
- DevModeW.dmBitsPerPel);
-
+ TRACE_(d3d_caps)("W %d H %d rr %d fmt (%x - %s) bpp %u\n",
+ mode->Width, mode->Height, mode->RefreshRate, mode->Format,
+ debug_d3dformat(mode->Format), DevModeW.dmBitsPerPel);
}
else
{
@@ -2929,115 +2831,116 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DImpl_GetAdapterDisplayMode(IWineD3D *iface, UINT Adapter, WINED3DDISPLAYMODE *pMode)
+HRESULT CDECL wined3d_get_adapter_display_mode(const struct wined3d *wined3d, UINT adapter_idx,
+ WINED3DDISPLAYMODE *mode)
{
- TRACE("iface %p, adapter_idx %u, display_mode %p.\n", iface, Adapter, pMode);
+ TRACE("wined3d %p, adapter_idx %u, display_mode %p.\n", wined3d, adapter_idx, mode);
- if (!pMode || Adapter >= IWineD3D_GetAdapterCount(iface))
+ if (!mode || adapter_idx >= wined3d->adapter_count)
return WINED3DERR_INVALIDCALL;
- if (Adapter == 0) { /* Display */
- int bpp = 0;
+ if (!adapter_idx)
+ {
DEVMODEW DevModeW;
+ unsigned int bpp;
ZeroMemory(&DevModeW, sizeof(DevModeW));
DevModeW.dmSize = sizeof(DevModeW);
EnumDisplaySettingsExW(NULL, ENUM_CURRENT_SETTINGS, &DevModeW, 0);
- pMode->Width = DevModeW.dmPelsWidth;
- pMode->Height = DevModeW.dmPelsHeight;
- bpp = DevModeW.dmBitsPerPel;
- pMode->RefreshRate = DEFAULT_REFRESH_RATE;
+ mode->Width = DevModeW.dmPelsWidth;
+ mode->Height = DevModeW.dmPelsHeight;
+ bpp = DevModeW.dmBitsPerPel;
+ mode->RefreshRate = DEFAULT_REFRESH_RATE;
if (DevModeW.dmFields&DM_DISPLAYFREQUENCY)
- {
- pMode->RefreshRate = DevModeW.dmDisplayFrequency;
- }
-
- pMode->Format = pixelformat_for_depth(bpp);
- } else {
+ mode->RefreshRate = DevModeW.dmDisplayFrequency;
+ mode->Format = pixelformat_for_depth(bpp);
+ }
+ else
+ {
FIXME_(d3d_caps)("Adapter not primary display\n");
}
- TRACE_(d3d_caps)("returning w:%d, h:%d, ref:%d, fmt:%s\n", pMode->Width,
- pMode->Height, pMode->RefreshRate, debug_d3dformat(pMode->Format));
+ TRACE_(d3d_caps)("returning w:%d, h:%d, ref:%d, fmt:%s\n", mode->Width,
+ mode->Height, mode->RefreshRate, debug_d3dformat(mode->Format));
return WINED3D_OK;
}
/* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
and fields being inserted in the middle, a new structure is used in place */
-static HRESULT WINAPI IWineD3DImpl_GetAdapterIdentifier(IWineD3D *iface, UINT Adapter, DWORD Flags,
- WINED3DADAPTER_IDENTIFIER* pIdentifier) {
- IWineD3DImpl *This = (IWineD3DImpl *)iface;
- struct wined3d_adapter *adapter;
+HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d,
+ UINT adapter_idx, DWORD flags, WINED3DADAPTER_IDENTIFIER *identifier)
+{
+ const struct wined3d_adapter *adapter;
size_t len;
- TRACE_(d3d_caps)("(%p}->(Adapter: %d, Flags: %x, pId=%p)\n", This, Adapter, Flags, pIdentifier);
+ TRACE_(d3d_caps)("wined3d %p, adapter_idx %u, flags %#x, indentifier %p.\n",
+ wined3d, adapter_idx, flags, identifier);
- if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
+ if (adapter_idx >= wined3d->adapter_count)
return WINED3DERR_INVALIDCALL;
- }
- adapter = &This->adapters[Adapter];
+ adapter = &wined3d->adapters[adapter_idx];
/* Return the information requested */
TRACE_(d3d_caps)("device/Vendor Name and Version detection using FillGLCaps\n");
- if (pIdentifier->driver_size)
+ if (identifier->driver_size)
{
const char *name = adapter->driver_info.name;
- len = min(strlen(name), pIdentifier->driver_size - 1);
- memcpy(pIdentifier->driver, name, len);
- pIdentifier->driver[len] = '\0';
+ len = min(strlen(name), identifier->driver_size - 1);
+ memcpy(identifier->driver, name, len);
+ identifier->driver[len] = '\0';
}
- if (pIdentifier->description_size)
+ if (identifier->description_size)
{
const char *description = adapter->driver_info.description;
- len = min(strlen(description), pIdentifier->description_size - 1);
- memcpy(pIdentifier->description, description, len);
- pIdentifier->description[len] = '\0';
+ len = min(strlen(description), identifier->description_size - 1);
+ memcpy(identifier->description, description, len);
+ identifier->description[len] = '\0';
}
/* Note that d3d8 doesn't supply a device name. */
- if (pIdentifier->device_name_size)
+ if (identifier->device_name_size)
{
static const char *device_name = "\\\\.\\DISPLAY1"; /* FIXME: May depend on desktop? */
len = strlen(device_name);
- if (len >= pIdentifier->device_name_size)
+ if (len >= identifier->device_name_size)
{
ERR("Device name size too small.\n");
return WINED3DERR_INVALIDCALL;
}
- memcpy(pIdentifier->device_name, device_name, len);
- pIdentifier->device_name[len] = '\0';
+ memcpy(identifier->device_name, device_name, len);
+ identifier->device_name[len] = '\0';
}
- pIdentifier->driver_version.u.HighPart = adapter->driver_info.version_high;
- pIdentifier->driver_version.u.LowPart = adapter->driver_info.version_low;
- pIdentifier->vendor_id = adapter->driver_info.vendor;
- pIdentifier->device_id = adapter->driver_info.device;
- pIdentifier->subsystem_id = 0;
- pIdentifier->revision = 0;
- memcpy(&pIdentifier->device_identifier, &IID_D3DDEVICE_D3DUID, sizeof(pIdentifier->device_identifier));
- pIdentifier->whql_level = (Flags & WINED3DENUM_NO_WHQL_LEVEL) ? 0 : 1;
- memcpy(&pIdentifier->adapter_luid, &adapter->luid, sizeof(pIdentifier->adapter_luid));
- pIdentifier->video_memory = adapter->TextureRam;
+ identifier->driver_version.u.HighPart = adapter->driver_info.version_high;
+ identifier->driver_version.u.LowPart = adapter->driver_info.version_low;
+ identifier->vendor_id = adapter->driver_info.vendor;
+ identifier->device_id = adapter->driver_info.device;
+ identifier->subsystem_id = 0;
+ identifier->revision = 0;
+ memcpy(&identifier->device_identifier, &IID_D3DDEVICE_D3DUID, sizeof(identifier->device_identifier));
+ identifier->whql_level = (flags & WINED3DENUM_NO_WHQL_LEVEL) ? 0 : 1;
+ memcpy(&identifier->adapter_luid, &adapter->luid, sizeof(identifier->adapter_luid));
+ identifier->video_memory = adapter->TextureRam;
return WINED3D_OK;
}
static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(const struct wined3d_gl_info *gl_info,
- const WineD3D_PixelFormat *cfg, const struct wined3d_format *format)
+ const struct wined3d_pixel_format *cfg, const struct wined3d_format *format)
{
- short redSize, greenSize, blueSize, alphaSize, colorBits;
+ BYTE redSize, greenSize, blueSize, alphaSize, colorBits;
if(!cfg)
return FALSE;
/* Float formats need FBOs. If FBOs are used this function isn't called */
- if (format->Flags & WINED3DFMT_FLAG_FLOAT) return FALSE;
+ if (format->flags & WINED3DFMT_FLAG_FLOAT) return FALSE;
if(cfg->iPixelType == WGL_TYPE_RGBA_ARB) { /* Integer RGBA formats */
if (!getColorBits(format, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits))
@@ -3066,9 +2969,9 @@ static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(const struct wined
}
static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(const struct wined3d_gl_info *gl_info,
- const WineD3D_PixelFormat *cfg, const struct wined3d_format *format)
+ const struct wined3d_pixel_format *cfg, const struct wined3d_format *format)
{
- short depthSize, stencilSize;
+ BYTE depthSize, stencilSize;
BOOL lockable = FALSE;
if(!cfg)
@@ -3081,7 +2984,7 @@ static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(const struct wined3
}
/* Float formats need FBOs. If FBOs are used this function isn't called */
- if (format->Flags & WINED3DFMT_FLAG_FLOAT) return FALSE;
+ if (format->flags & WINED3DFMT_FLAG_FLOAT) return FALSE;
if ((format->id == WINED3DFMT_D16_LOCKABLE) || (format->id == WINED3DFMT_D32_FLOAT))
lockable = TRUE;
@@ -3100,138 +3003,136 @@ static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(const struct wined3
return TRUE;
}
-static HRESULT WINAPI IWineD3DImpl_CheckDepthStencilMatch(IWineD3D *iface,
- UINT Adapter, WINED3DDEVTYPE DeviceType, enum wined3d_format_id AdapterFormat,
- enum wined3d_format_id RenderTargetFormat, enum wined3d_format_id DepthStencilFormat)
+HRESULT CDECL wined3d_check_depth_stencil_match(const struct wined3d *wined3d,
+ UINT adapter_idx, WINED3DDEVTYPE device_type, enum wined3d_format_id adapter_format_id,
+ enum wined3d_format_id render_target_format_id, enum wined3d_format_id depth_stencil_format_id)
{
- IWineD3DImpl *This = (IWineD3DImpl *)iface;
- int nCfgs;
- const WineD3D_PixelFormat *cfgs;
- const struct wined3d_adapter *adapter;
const struct wined3d_format *rt_format;
const struct wined3d_format *ds_format;
- int it;
+ const struct wined3d_adapter *adapter;
- WARN_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), AdptFmt:(%x,%s), RendrTgtFmt:(%x,%s), DepthStencilFmt:(%x,%s))\n",
- This, Adapter,
- DeviceType, debug_d3ddevicetype(DeviceType),
- AdapterFormat, debug_d3dformat(AdapterFormat),
- RenderTargetFormat, debug_d3dformat(RenderTargetFormat),
- DepthStencilFormat, debug_d3dformat(DepthStencilFormat));
+ TRACE_(d3d_caps)("wined3d %p, adapter_idx %u, device_type %s,\n"
+ "adapter_format %s, render_target_format %s, depth_stencil_format %s.\n",
+ wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
+ debug_d3dformat(render_target_format_id), debug_d3dformat(depth_stencil_format_id));
- if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
- TRACE("(%p) Failed: Atapter (%u) higher than supported adapters (%u) returning WINED3DERR_INVALIDCALL\n", This, Adapter, IWineD3D_GetAdapterCount(iface));
+ if (adapter_idx >= wined3d->adapter_count)
return WINED3DERR_INVALIDCALL;
- }
- adapter = &This->adapters[Adapter];
- rt_format = wined3d_get_format(&adapter->gl_info, RenderTargetFormat);
- ds_format = wined3d_get_format(&adapter->gl_info, DepthStencilFormat);
+ adapter = &wined3d->adapters[adapter_idx];
+ rt_format = wined3d_get_format(&adapter->gl_info, render_target_format_id);
+ ds_format = wined3d_get_format(&adapter->gl_info, depth_stencil_format_id);
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
- if ((rt_format->Flags & WINED3DFMT_FLAG_RENDERTARGET)
- && (ds_format->Flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
+ if ((rt_format->flags & WINED3DFMT_FLAG_RENDERTARGET)
+ && (ds_format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
{
- TRACE_(d3d_caps)("(%p) : Formats matched\n", This);
+ TRACE_(d3d_caps)("Formats match.\n");
return WINED3D_OK;
}
}
else
{
+ const struct wined3d_pixel_format *cfgs;
+ unsigned int cfg_count;
+ unsigned int i;
+
cfgs = adapter->cfgs;
- nCfgs = adapter->nCfgs;
- for (it = 0; it < nCfgs; ++it)
+ cfg_count = adapter->nCfgs;
+ for (i = 0; i < cfg_count; ++i)
{
- if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info, &cfgs[it], rt_format))
+ if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info, &cfgs[i], rt_format))
{
- if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter->gl_info, &cfgs[it], ds_format))
+ if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter->gl_info, &cfgs[i], ds_format))
{
- TRACE_(d3d_caps)("(%p) : Formats matched\n", This);
+ TRACE_(d3d_caps)("Formats match.\n");
return WINED3D_OK;
}
}
}
}
- WARN_(d3d_caps)("unsupported format pair: %s and %s\n", debug_d3dformat(RenderTargetFormat), debug_d3dformat(DepthStencilFormat));
+
+ TRACE_(d3d_caps)("Unsupported format pair: %s and %s.\n",
+ debug_d3dformat(render_target_format_id),
+ debug_d3dformat(depth_stencil_format_id));
return WINED3DERR_NOTAVAILABLE;
}
-static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, UINT Adapter,
- WINED3DDEVTYPE DeviceType, enum wined3d_format_id SurfaceFormat, BOOL Windowed,
- WINED3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels)
+HRESULT CDECL wined3d_check_device_multisample_type(const struct wined3d *wined3d, UINT adapter_idx,
+ WINED3DDEVTYPE device_type, enum wined3d_format_id surface_format_id, BOOL windowed,
+ WINED3DMULTISAMPLE_TYPE multisample_type, DWORD *quality_levels)
{
- IWineD3DImpl *This = (IWineD3DImpl *)iface;
const struct wined3d_adapter *adapter;
const struct wined3d_format *format;
- TRACE_(d3d_caps)("(%p)-> (Adptr:%d, DevType:(%x,%s), SurfFmt:(%x,%s), Win?%d, MultiSamp:%x, pQual:%p)\n",
- This,
- Adapter,
- DeviceType, debug_d3ddevicetype(DeviceType),
- SurfaceFormat, debug_d3dformat(SurfaceFormat),
- Windowed,
- MultiSampleType,
- pQualityLevels);
+ TRACE_(d3d_caps)("wined3d %p, adapter_idx %u, device_type %s, surface_format %s,\n"
+ "windowed %#x, multisample_type %#x, quality_levels %p.\n",
+ wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(surface_format_id),
+ windowed, multisample_type, quality_levels);
- if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
+ if (adapter_idx >= wined3d->adapter_count)
return WINED3DERR_INVALIDCALL;
- }
- /* TODO: handle Windowed, add more quality levels */
+ /* TODO: Handle windowed, add more quality levels. */
- if (WINED3DMULTISAMPLE_NONE == MultiSampleType) {
- if(pQualityLevels) *pQualityLevels = 1;
+ if (WINED3DMULTISAMPLE_NONE == multisample_type)
+ {
+ if (quality_levels) *quality_levels = 1;
return WINED3D_OK;
}
/* By default multisampling is disabled right now as it causes issues
* on some Nvidia driver versions and it doesn't work well in combination
* with FBOs yet. */
- if(!wined3d_settings.allow_multisampling)
+ if (!wined3d_settings.allow_multisampling)
return WINED3DERR_NOTAVAILABLE;
- adapter = &This->adapters[Adapter];
- format = wined3d_get_format(&adapter->gl_info, SurfaceFormat);
+ adapter = &wined3d->adapters[adapter_idx];
+ format = wined3d_get_format(&adapter->gl_info, surface_format_id);
if (!format) return WINED3DERR_INVALIDCALL;
- if (format->Flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
+ if (format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
{
- int i, nCfgs;
- const WineD3D_PixelFormat *cfgs;
+ const struct wined3d_pixel_format *cfgs;
+ unsigned int i, cfg_count;
cfgs = adapter->cfgs;
- nCfgs = adapter->nCfgs;
- for(i=0; inCfgs;
+ for (i = 0; i < cfg_count; ++i)
+ {
+ if(cfgs[i].numSamples != multisample_type)
continue;
if (!IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter->gl_info, &cfgs[i], format))
continue;
- TRACE("Found iPixelFormat=%d to support MultiSampleType=%d for format %s\n", cfgs[i].iPixelFormat, MultiSampleType, debug_d3dformat(SurfaceFormat));
+ TRACE("Found pixel format %u to support multisample_type %#x for format %s.\n",
+ cfgs[i].iPixelFormat, multisample_type, debug_d3dformat(surface_format_id));
+
+ if (quality_levels) *quality_levels = 1;
- if(pQualityLevels)
- *pQualityLevels = 1; /* Guess at a value! */
return WINED3D_OK;
}
}
- else if (format->Flags & WINED3DFMT_FLAG_RENDERTARGET)
+ else if (format->flags & WINED3DFMT_FLAG_RENDERTARGET)
{
- short redSize, greenSize, blueSize, alphaSize, colorBits;
- int i, nCfgs;
- const WineD3D_PixelFormat *cfgs;
+ BYTE redSize, greenSize, blueSize, alphaSize, colorBits;
+ const struct wined3d_pixel_format *cfgs;
+ unsigned int i, cfg_count;
if (!getColorBits(format, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits))
{
- ERR("Unable to color bits for format %#x, can't check multisampling capability!\n", SurfaceFormat);
+ ERR("Unable to get color bits for format %s, can't check multisampling capability.\n",
+ debug_d3dformat(surface_format_id));
return WINED3DERR_NOTAVAILABLE;
}
cfgs = adapter->cfgs;
- nCfgs = adapter->nCfgs;
- for(i=0; inCfgs;
+ for (i = 0; i < cfg_count; ++i)
+ {
+ if(cfgs[i].numSamples != multisample_type)
continue;
if(cfgs[i].redSize != redSize)
continue;
@@ -3239,16 +3140,18 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U
continue;
if(cfgs[i].blueSize != blueSize)
continue;
- /* Not all drivers report alpha-less formats since they use 32-bit anyway, so accept alpha even if we didn't ask for it. */
+ /* Not all drivers report alpha-less formats since they use 32-bit
+ * anyway, so accept alpha even if we didn't ask for it. */
if(alphaSize && cfgs[i].alphaSize != alphaSize)
continue;
if (cfgs[i].colorSize != (format->byte_count << 3))
continue;
- TRACE("Found iPixelFormat=%d to support MultiSampleType=%d for format %s\n", cfgs[i].iPixelFormat, MultiSampleType, debug_d3dformat(SurfaceFormat));
+ TRACE("Found pixel format %u to support multisample_type %#x for format %s.\n",
+ cfgs[i].iPixelFormat, multisample_type, debug_d3dformat(surface_format_id));
+
+ if (quality_levels) *quality_levels = 1;
- if(pQualityLevels)
- *pQualityLevels = 1; /* Guess at a value! */
return WINED3D_OK;
}
}
@@ -3256,17 +3159,17 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U
}
/* Check if we support bumpmapping for a format */
-static BOOL CheckBumpMapCapability(struct wined3d_adapter *adapter, const struct wined3d_format *format)
+static BOOL CheckBumpMapCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
{
/* Ask the fixed function pipeline implementation if it can deal
* with the conversion. If we've got a GL extension giving native
* support this will be an identity conversion. */
- return (format->Flags & WINED3DFMT_FLAG_BUMPMAP)
+ return (format->flags & WINED3DFMT_FLAG_BUMPMAP)
&& adapter->fragment_pipe->color_fixup_supported(format->color_fixup);
}
/* Check if the given DisplayFormat + DepthStencilFormat combination is valid for the Adapter */
-static BOOL CheckDepthStencilCapability(struct wined3d_adapter *adapter,
+static BOOL CheckDepthStencilCapability(const struct wined3d_adapter *adapter,
const struct wined3d_format *display_format, const struct wined3d_format *ds_format)
{
int it=0;
@@ -3277,14 +3180,14 @@ static BOOL CheckDepthStencilCapability(struct wined3d_adapter *adapter,
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
/* With FBOs WGL limitations do not apply, but the format needs to be FBO attachable */
- if (ds_format->Flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) return TRUE;
+ if (ds_format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) return TRUE;
}
else
{
/* Walk through all WGL pixel formats to find a match */
for (it = 0; it < adapter->nCfgs; ++it)
{
- WineD3D_PixelFormat *cfg = &adapter->cfgs[it];
+ const struct wined3d_pixel_format *cfg = &adapter->cfgs[it];
if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info, cfg, display_format))
{
if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter->gl_info, cfg, ds_format))
@@ -3298,26 +3201,26 @@ static BOOL CheckDepthStencilCapability(struct wined3d_adapter *adapter,
return FALSE;
}
-static BOOL CheckFilterCapability(struct wined3d_adapter *adapter, const struct wined3d_format *format)
+static BOOL CheckFilterCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
{
/* The flags entry of a format contains the filtering capability */
- if (format->Flags & WINED3DFMT_FLAG_FILTERING) return TRUE;
+ if (format->flags & WINED3DFMT_FLAG_FILTERING) return TRUE;
return FALSE;
}
/* Check the render target capabilities of a format */
-static BOOL CheckRenderTargetCapability(struct wined3d_adapter *adapter,
+static BOOL CheckRenderTargetCapability(const struct wined3d_adapter *adapter,
const struct wined3d_format *adapter_format, const struct wined3d_format *check_format)
{
/* Filter out non-RT formats */
- if (!(check_format->Flags & WINED3DFMT_FLAG_RENDERTARGET)) return FALSE;
+ if (!(check_format->flags & WINED3DFMT_FLAG_RENDERTARGET)) return FALSE;
if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
{
- WineD3D_PixelFormat *cfgs = adapter->cfgs;
+ BYTE AdapterRed, AdapterGreen, AdapterBlue, AdapterAlpha, AdapterTotalSize;
+ BYTE CheckRed, CheckGreen, CheckBlue, CheckAlpha, CheckTotalSize;
+ const struct wined3d_pixel_format *cfgs = adapter->cfgs;
int it;
- short AdapterRed, AdapterGreen, AdapterBlue, AdapterAlpha, AdapterTotalSize;
- short CheckRed, CheckGreen, CheckBlue, CheckAlpha, CheckTotalSize;
getColorBits(adapter_format, &AdapterRed, &AdapterGreen, &AdapterBlue, &AdapterAlpha, &AdapterTotalSize);
getColorBits(check_format, &CheckRed, &CheckGreen, &CheckBlue, &CheckAlpha, &CheckTotalSize);
@@ -3351,17 +3254,17 @@ static BOOL CheckRenderTargetCapability(struct wined3d_adapter *adapter,
return FALSE;
}
-static BOOL CheckSrgbReadCapability(struct wined3d_adapter *adapter, const struct wined3d_format *format)
+static BOOL CheckSrgbReadCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
{
- return adapter->gl_info.supported[EXT_TEXTURE_SRGB] && (format->Flags & WINED3DFMT_FLAG_SRGB_READ);
+ return format->flags & WINED3DFMT_FLAG_SRGB_READ;
}
-static BOOL CheckSrgbWriteCapability(struct wined3d_adapter *adapter, const struct wined3d_format *format)
+static BOOL CheckSrgbWriteCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
{
/* Only offer SRGB writing on X8R8G8B8/A8R8G8B8 when we use ARB or GLSL shaders as we are
* doing the color fixup in shaders.
* Note Windows drivers (at least on the Geforce 8800) also offer this on R5G6B5. */
- if (format->Flags & WINED3DFMT_FLAG_SRGB_WRITE)
+ if (format->flags & WINED3DFMT_FLAG_SRGB_WRITE)
{
int vs_selected_mode;
int ps_selected_mode;
@@ -3378,16 +3281,16 @@ static BOOL CheckSrgbWriteCapability(struct wined3d_adapter *adapter, const stru
}
/* Check if a format support blending in combination with pixel shaders */
-static BOOL CheckPostPixelShaderBlendingCapability(struct wined3d_adapter *adapter,
+static BOOL CheckPostPixelShaderBlendingCapability(const struct wined3d_adapter *adapter,
const struct wined3d_format *format)
{
/* The flags entry of a format contains the post pixel shader blending capability */
- if (format->Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING) return TRUE;
+ if (format->flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING) return TRUE;
return FALSE;
}
-static BOOL CheckWrapAndMipCapability(struct wined3d_adapter *adapter, const struct wined3d_format *format)
+static BOOL CheckWrapAndMipCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
{
/* OpenGL supports mipmapping on all formats basically. Wrapping is unsupported,
* but we have to report mipmapping so we cannot reject this flag. Tests show that
@@ -3402,7 +3305,7 @@ static BOOL CheckWrapAndMipCapability(struct wined3d_adapter *adapter, const str
}
/* Check if a texture format is supported on the given adapter */
-static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, const struct wined3d_format *format)
+static BOOL CheckTextureCapability(const struct wined3d_adapter *adapter, const struct wined3d_format *format)
{
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
@@ -3470,6 +3373,12 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, const struct
case WINED3DFMT_D32_FLOAT:
return TRUE;
+ case WINED3DFMT_INTZ:
+ if (gl_info->supported[EXT_PACKED_DEPTH_STENCIL]
+ || gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
+ return TRUE;
+ return FALSE;
+
/*****
* Not supported everywhere(depends on GL_ATI_envmap_bumpmap or
* GL_NV_texture_shader). Emulated by shaders
@@ -3637,6 +3546,11 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, const struct
TRACE_(d3d_caps)("[FAILED]\n");
return FALSE;
+ case WINED3DFMT_NULL:
+ if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
+ return TRUE;
+ return FALSE;
+
case WINED3DFMT_UNKNOWN:
return FALSE;
@@ -3647,7 +3561,7 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, const struct
return FALSE;
}
-static BOOL CheckSurfaceCapability(struct wined3d_adapter *adapter,
+static BOOL CheckSurfaceCapability(const struct wined3d_adapter *adapter,
const struct wined3d_format *adapter_format,
const struct wined3d_format *check_format,
WINED3DSURFTYPE SurfaceType)
@@ -3688,7 +3602,7 @@ static BOOL CheckSurfaceCapability(struct wined3d_adapter *adapter,
if (CheckDepthStencilCapability(adapter, adapter_format, check_format)) return TRUE;
/* If opengl can't process the format natively, the blitter may be able to convert it */
- if (adapter->blitter->blit_supported(&adapter->gl_info, BLIT_OP_BLIT,
+ if (adapter->blitter->blit_supported(&adapter->gl_info, WINED3D_BLIT_OP_COLOR_BLIT,
NULL, WINED3DPOOL_DEFAULT, 0, check_format,
NULL, WINED3DPOOL_DEFAULT, 0, adapter_format))
{
@@ -3701,37 +3615,32 @@ static BOOL CheckSurfaceCapability(struct wined3d_adapter *adapter,
return FALSE;
}
-static BOOL CheckVertexTextureCapability(struct wined3d_adapter *adapter,
+static BOOL CheckVertexTextureCapability(const struct wined3d_adapter *adapter,
const struct wined3d_format *format)
{
- return adapter->gl_info.limits.vertex_samplers && (format->Flags & WINED3DFMT_FLAG_VTF);
+ return adapter->gl_info.limits.vertex_samplers && (format->flags & WINED3DFMT_FLAG_VTF);
}
-static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType,
- enum wined3d_format_id AdapterFormat, DWORD Usage, WINED3DRESOURCETYPE RType,
- enum wined3d_format_id CheckFormat, WINED3DSURFTYPE SurfaceType)
+HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT adapter_idx,
+ WINED3DDEVTYPE device_type, enum wined3d_format_id adapter_format_id, DWORD usage,
+ WINED3DRESOURCETYPE resource_type, enum wined3d_format_id check_format_id, WINED3DSURFTYPE surface_type)
{
- IWineD3DImpl *This = (IWineD3DImpl *)iface;
- struct wined3d_adapter *adapter = &This->adapters[Adapter];
+ const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
- const struct wined3d_format *format = wined3d_get_format(gl_info, CheckFormat);
- const struct wined3d_format *adapter_format = wined3d_get_format(gl_info, AdapterFormat);
- DWORD UsageCaps = 0;
+ const struct wined3d_format *adapter_format = wined3d_get_format(gl_info, adapter_format_id);
+ const struct wined3d_format *format = wined3d_get_format(gl_info, check_format_id);
+ DWORD usage_caps = 0;
- TRACE_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%u,%s), AdptFmt:(%u,%s), Use:(%u,%s,%s), ResTyp:(%x,%s), CheckFmt:(%u,%s))\n",
- This,
- Adapter,
- DeviceType, debug_d3ddevicetype(DeviceType),
- AdapterFormat, debug_d3dformat(AdapterFormat),
- Usage, debug_d3dusage(Usage), debug_d3dusagequery(Usage),
- RType, debug_d3dresourcetype(RType),
- CheckFormat, debug_d3dformat(CheckFormat));
+ TRACE_(d3d_caps)("wined3d %p, adapter_idx %u, device_type %s, adapter_format %s, usage %s, %s,\n"
+ "resource_type %s, check_format %s, surface_type %#x.\n",
+ wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
+ debug_d3dusage(usage), debug_d3dusagequery(usage), debug_d3dresourcetype(resource_type),
+ debug_d3dformat(check_format_id), surface_type);
- if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
+ if (adapter_idx >= wined3d->adapter_count)
return WINED3DERR_INVALIDCALL;
- }
- switch (RType)
+ switch (resource_type)
{
case WINED3DRTYPE_CUBETEXTURE:
/* Cubetexture allows:
@@ -3743,7 +3652,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
* - WINED3DUSAGE_SOFTWAREPROCESSING
* - WINED3DUSAGE_QUERY_WRAPANDMIP
*/
- if (SurfaceType != SURFACE_OPENGL)
+ if (surface_type != SURFACE_OPENGL)
{
TRACE_(d3d_caps)("[FAILED]\n");
return WINED3DERR_NOTAVAILABLE;
@@ -3761,92 +3670,92 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
return WINED3DERR_NOTAVAILABLE;
}
- if (Usage & WINED3DUSAGE_AUTOGENMIPMAP)
+ if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
{
if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
/* When autogenmipmap isn't around continue and return
* WINED3DOK_NOAUTOGEN instead of D3D_OK. */
TRACE_(d3d_caps)("[FAILED] - No autogenmipmap support, but continuing\n");
else
- UsageCaps |= WINED3DUSAGE_AUTOGENMIPMAP;
+ usage_caps |= WINED3DUSAGE_AUTOGENMIPMAP;
}
/* Always report dynamic locking. */
- if (Usage & WINED3DUSAGE_DYNAMIC)
- UsageCaps |= WINED3DUSAGE_DYNAMIC;
+ if (usage & WINED3DUSAGE_DYNAMIC)
+ usage_caps |= WINED3DUSAGE_DYNAMIC;
- if (Usage & WINED3DUSAGE_RENDERTARGET)
+ if (usage & WINED3DUSAGE_RENDERTARGET)
{
if (!CheckRenderTargetCapability(adapter, adapter_format, format))
{
TRACE_(d3d_caps)("[FAILED] - No rendertarget support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_RENDERTARGET;
+ usage_caps |= WINED3DUSAGE_RENDERTARGET;
}
/* Always report software processing. */
- if (Usage & WINED3DUSAGE_SOFTWAREPROCESSING)
- UsageCaps |= WINED3DUSAGE_SOFTWAREPROCESSING;
+ if (usage & WINED3DUSAGE_SOFTWAREPROCESSING)
+ usage_caps |= WINED3DUSAGE_SOFTWAREPROCESSING;
- if (Usage & WINED3DUSAGE_QUERY_FILTER)
+ if (usage & WINED3DUSAGE_QUERY_FILTER)
{
if (!CheckFilterCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No query filter support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_FILTER;
+ usage_caps |= WINED3DUSAGE_QUERY_FILTER;
}
- if (Usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
+ if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
{
if (!CheckPostPixelShaderBlendingCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No query post pixelshader blending support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
+ usage_caps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
}
- if (Usage & WINED3DUSAGE_QUERY_SRGBREAD)
+ if (usage & WINED3DUSAGE_QUERY_SRGBREAD)
{
if (!CheckSrgbReadCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No query srgbread support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_SRGBREAD;
+ usage_caps |= WINED3DUSAGE_QUERY_SRGBREAD;
}
- if (Usage & WINED3DUSAGE_QUERY_SRGBWRITE)
+ if (usage & WINED3DUSAGE_QUERY_SRGBWRITE)
{
if (!CheckSrgbWriteCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No query srgbwrite support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_SRGBWRITE;
+ usage_caps |= WINED3DUSAGE_QUERY_SRGBWRITE;
}
- if (Usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
+ if (usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
{
if (!CheckVertexTextureCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No query vertextexture support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_VERTEXTEXTURE;
+ usage_caps |= WINED3DUSAGE_QUERY_VERTEXTEXTURE;
}
- if (Usage & WINED3DUSAGE_QUERY_WRAPANDMIP)
+ if (usage & WINED3DUSAGE_QUERY_WRAPANDMIP)
{
if (!CheckWrapAndMipCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No wrapping and mipmapping support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_WRAPANDMIP;
+ usage_caps |= WINED3DUSAGE_QUERY_WRAPANDMIP;
}
break;
@@ -3856,40 +3765,40 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
* - WINED3DUSAGE_NONSECURE (d3d9ex)
* - WINED3DUSAGE_RENDERTARGET
*/
- if (!CheckSurfaceCapability(adapter, adapter_format, format, SurfaceType))
+ if (!CheckSurfaceCapability(adapter, adapter_format, format, surface_type))
{
TRACE_(d3d_caps)("[FAILED] - Not supported for plain surfaces\n");
return WINED3DERR_NOTAVAILABLE;
}
- if (Usage & WINED3DUSAGE_DEPTHSTENCIL)
+ if (usage & WINED3DUSAGE_DEPTHSTENCIL)
{
if (!CheckDepthStencilCapability(adapter, adapter_format, format))
{
TRACE_(d3d_caps)("[FAILED] - No depthstencil support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_DEPTHSTENCIL;
+ usage_caps |= WINED3DUSAGE_DEPTHSTENCIL;
}
- if (Usage & WINED3DUSAGE_RENDERTARGET)
+ if (usage & WINED3DUSAGE_RENDERTARGET)
{
if (!CheckRenderTargetCapability(adapter, adapter_format, format))
{
TRACE_(d3d_caps)("[FAILED] - No rendertarget support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_RENDERTARGET;
+ usage_caps |= WINED3DUSAGE_RENDERTARGET;
}
- if (Usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
+ if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
{
if (!CheckPostPixelShaderBlendingCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No query post pixelshader blending support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
+ usage_caps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
}
break;
@@ -3905,7 +3814,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
* - WINED3DUSAGE_TEXTAPI (d3d9ex)
* - WINED3DUSAGE_QUERY_WRAPANDMIP
*/
- if (SurfaceType != SURFACE_OPENGL)
+ if (surface_type != SURFACE_OPENGL)
{
TRACE_(d3d_caps)("[FAILED]\n");
return WINED3DERR_NOTAVAILABLE;
@@ -3917,117 +3826,117 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
return WINED3DERR_NOTAVAILABLE;
}
- if (Usage & WINED3DUSAGE_AUTOGENMIPMAP)
+ if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
{
if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
/* When autogenmipmap isn't around continue and return
* WINED3DOK_NOAUTOGEN instead of D3D_OK. */
TRACE_(d3d_caps)("[FAILED] - No autogenmipmap support, but continuing\n");
else
- UsageCaps |= WINED3DUSAGE_AUTOGENMIPMAP;
+ usage_caps |= WINED3DUSAGE_AUTOGENMIPMAP;
}
/* Always report dynamic locking. */
- if (Usage & WINED3DUSAGE_DYNAMIC)
- UsageCaps |= WINED3DUSAGE_DYNAMIC;
+ if (usage & WINED3DUSAGE_DYNAMIC)
+ usage_caps |= WINED3DUSAGE_DYNAMIC;
- if (Usage & WINED3DUSAGE_RENDERTARGET)
+ if (usage & WINED3DUSAGE_RENDERTARGET)
{
if (!CheckRenderTargetCapability(adapter, adapter_format, format))
{
TRACE_(d3d_caps)("[FAILED] - No rendertarget support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_RENDERTARGET;
+ usage_caps |= WINED3DUSAGE_RENDERTARGET;
}
/* Always report software processing. */
- if (Usage & WINED3DUSAGE_SOFTWAREPROCESSING)
- UsageCaps |= WINED3DUSAGE_SOFTWAREPROCESSING;
+ if (usage & WINED3DUSAGE_SOFTWAREPROCESSING)
+ usage_caps |= WINED3DUSAGE_SOFTWAREPROCESSING;
- if (Usage & WINED3DUSAGE_QUERY_FILTER)
+ if (usage & WINED3DUSAGE_QUERY_FILTER)
{
if (!CheckFilterCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No query filter support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_FILTER;
+ usage_caps |= WINED3DUSAGE_QUERY_FILTER;
}
- if (Usage & WINED3DUSAGE_QUERY_LEGACYBUMPMAP)
+ if (usage & WINED3DUSAGE_QUERY_LEGACYBUMPMAP)
{
if (!CheckBumpMapCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No legacy bumpmap support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_LEGACYBUMPMAP;
+ usage_caps |= WINED3DUSAGE_QUERY_LEGACYBUMPMAP;
}
- if (Usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
+ if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
{
if (!CheckPostPixelShaderBlendingCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No query post pixelshader blending support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
+ usage_caps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
}
- if (Usage & WINED3DUSAGE_QUERY_SRGBREAD)
+ if (usage & WINED3DUSAGE_QUERY_SRGBREAD)
{
if (!CheckSrgbReadCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No query srgbread support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_SRGBREAD;
+ usage_caps |= WINED3DUSAGE_QUERY_SRGBREAD;
}
- if (Usage & WINED3DUSAGE_QUERY_SRGBWRITE)
+ if (usage & WINED3DUSAGE_QUERY_SRGBWRITE)
{
if (!CheckSrgbWriteCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No query srgbwrite support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_SRGBWRITE;
+ usage_caps |= WINED3DUSAGE_QUERY_SRGBWRITE;
}
- if (Usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
+ if (usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
{
if (!CheckVertexTextureCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No query vertextexture support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_VERTEXTEXTURE;
+ usage_caps |= WINED3DUSAGE_QUERY_VERTEXTEXTURE;
}
- if (Usage & WINED3DUSAGE_QUERY_WRAPANDMIP)
+ if (usage & WINED3DUSAGE_QUERY_WRAPANDMIP)
{
if (!CheckWrapAndMipCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No wrapping and mipmapping support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_WRAPANDMIP;
+ usage_caps |= WINED3DUSAGE_QUERY_WRAPANDMIP;
}
- if (Usage & WINED3DUSAGE_DEPTHSTENCIL)
+ if (usage & WINED3DUSAGE_DEPTHSTENCIL)
{
if (!CheckDepthStencilCapability(adapter, adapter_format, format))
{
TRACE_(d3d_caps)("[FAILED] - No depth stencil support\n");
return WINED3DERR_NOTAVAILABLE;
}
- if ((format->Flags & WINED3DFMT_FLAG_SHADOW) && !gl_info->supported[ARB_SHADOW])
+ if ((format->flags & WINED3DFMT_FLAG_SHADOW) && !gl_info->supported[ARB_SHADOW])
{
TRACE_(d3d_caps)("[FAILED] - No shadow sampler support.\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_DEPTHSTENCIL;
+ usage_caps |= WINED3DUSAGE_DEPTHSTENCIL;
}
break;
@@ -4043,7 +3952,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
* - D3DUSAGE_SOFTWAREPROCESSING
* - D3DUSAGE_QUERY_WRAPANDMIP
*/
- if (SurfaceType != SURFACE_OPENGL)
+ if (surface_type != SURFACE_OPENGL)
{
TRACE_(d3d_caps)("[FAILED]\n");
return WINED3DERR_NOTAVAILABLE;
@@ -4068,7 +3977,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
* leading applications into temptation. The windows drivers don't
* support most of those formats on volumes anyway, except for
* WINED3DFMT_R32_FLOAT. */
- switch (CheckFormat)
+ switch (check_format_id)
{
case WINED3DFMT_P8_UINT:
case WINED3DFMT_L4A4_UNORM:
@@ -4116,118 +4025,115 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
}
/* Always report dynamic locking. */
- if (Usage & WINED3DUSAGE_DYNAMIC)
- UsageCaps |= WINED3DUSAGE_DYNAMIC;
+ if (usage & WINED3DUSAGE_DYNAMIC)
+ usage_caps |= WINED3DUSAGE_DYNAMIC;
/* Always report software processing. */
- if (Usage & WINED3DUSAGE_SOFTWAREPROCESSING)
- UsageCaps |= WINED3DUSAGE_SOFTWAREPROCESSING;
+ if (usage & WINED3DUSAGE_SOFTWAREPROCESSING)
+ usage_caps |= WINED3DUSAGE_SOFTWAREPROCESSING;
- if (Usage & WINED3DUSAGE_QUERY_FILTER)
+ if (usage & WINED3DUSAGE_QUERY_FILTER)
{
if (!CheckFilterCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No query filter support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_FILTER;
+ usage_caps |= WINED3DUSAGE_QUERY_FILTER;
}
- if (Usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
+ if (usage & WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
{
if (!CheckPostPixelShaderBlendingCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No query post pixelshader blending support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
+ usage_caps |= WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING;
}
- if (Usage & WINED3DUSAGE_QUERY_SRGBREAD)
+ if (usage & WINED3DUSAGE_QUERY_SRGBREAD)
{
if (!CheckSrgbReadCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No query srgbread support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_SRGBREAD;
+ usage_caps |= WINED3DUSAGE_QUERY_SRGBREAD;
}
- if (Usage & WINED3DUSAGE_QUERY_SRGBWRITE)
+ if (usage & WINED3DUSAGE_QUERY_SRGBWRITE)
{
if (!CheckSrgbWriteCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No query srgbwrite support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_SRGBWRITE;
+ usage_caps |= WINED3DUSAGE_QUERY_SRGBWRITE;
}
- if (Usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
+ if (usage & WINED3DUSAGE_QUERY_VERTEXTEXTURE)
{
if (!CheckVertexTextureCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No query vertextexture support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_VERTEXTEXTURE;
+ usage_caps |= WINED3DUSAGE_QUERY_VERTEXTEXTURE;
}
- if (Usage & WINED3DUSAGE_QUERY_WRAPANDMIP)
+ if (usage & WINED3DUSAGE_QUERY_WRAPANDMIP)
{
if (!CheckWrapAndMipCapability(adapter, format))
{
TRACE_(d3d_caps)("[FAILED] - No wrapping and mipmapping support\n");
return WINED3DERR_NOTAVAILABLE;
}
- UsageCaps |= WINED3DUSAGE_QUERY_WRAPANDMIP;
+ usage_caps |= WINED3DUSAGE_QUERY_WRAPANDMIP;
}
break;
default:
- FIXME_(d3d_caps)("Unhandled resource type %s.\n", debug_d3dresourcetype(RType));
+ FIXME_(d3d_caps)("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type));
return WINED3DERR_NOTAVAILABLE;
}
- /* When the UsageCaps exactly matches Usage return WINED3D_OK except for
+ /* When the usage_caps exactly matches usage return WINED3D_OK except for
* the situation in which WINED3DUSAGE_AUTOGENMIPMAP isn't around, then
* WINED3DOK_NOAUTOGEN is returned if all the other usage flags match. */
- if (UsageCaps == Usage)
+ if (usage_caps == usage)
return WINED3D_OK;
- if (UsageCaps == (Usage & ~WINED3DUSAGE_AUTOGENMIPMAP))
+ if (usage_caps == (usage & ~WINED3DUSAGE_AUTOGENMIPMAP))
return WINED3DOK_NOAUTOGEN;
- TRACE_(d3d_caps)("[FAILED] - Usage %#x requested for CheckFormat %s and RType %s but only %#x is available\n",
- Usage, debug_d3dformat(CheckFormat), debug_d3dresourcetype(RType), UsageCaps);
+ TRACE_(d3d_caps)("[FAILED] - Usage %#x requested for format %s and resource_type %s but only %#x is available.\n",
+ usage, debug_d3dformat(check_format_id), debug_d3dresourcetype(resource_type), usage_caps);
return WINED3DERR_NOTAVAILABLE;
}
-static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormatConversion(IWineD3D *iface, UINT adapter_idx,
+HRESULT CDECL wined3d_check_device_format_conversion(const struct wined3d *wined3d, UINT adapter_idx,
WINED3DDEVTYPE device_type, enum wined3d_format_id src_format, enum wined3d_format_id dst_format)
{
- FIXME("iface %p, adapter_idx %u, device_type %s, src_format %s, dst_format %s stub!\n",
- iface, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(src_format),
+ FIXME("wined3d %p, adapter_idx %u, device_type %s, src_format %s, dst_format %s stub!\n",
+ wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(src_format),
debug_d3dformat(dst_format));
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT adapter_idx, WINED3DDEVTYPE device_type,
+HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adapter_idx, WINED3DDEVTYPE device_type,
enum wined3d_format_id display_format, enum wined3d_format_id backbuffer_format, BOOL windowed)
{
UINT mode_count;
HRESULT hr;
- TRACE("iface %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
- iface, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(display_format),
+ TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n",
+ wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(display_format),
debug_d3dformat(backbuffer_format), windowed);
- if (adapter_idx >= IWineD3D_GetAdapterCount(iface))
- {
- WARN_(d3d_caps)("adapter_idx >= IWineD3D_GetAdapterCount(iface), returning WINED3DERR_INVALIDCALL\n");
+ if (adapter_idx >= wined3d->adapter_count)
return WINED3DERR_INVALIDCALL;
- }
/* The task of this function is to check whether a certain display / backbuffer format
* combination is available on the given adapter. In fullscreen mode microsoft specified
@@ -4249,7 +4155,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT adapter
}
/* If the requested display format is not available, don't continue. */
- mode_count = IWineD3DImpl_GetAdapterModeCount(iface, adapter_idx, display_format);
+ mode_count = wined3d_get_adapter_mode_count(wined3d, adapter_idx, display_format);
if (!mode_count)
{
TRACE_(d3d_caps)("No available modes for display format %s.\n", debug_d3dformat(display_format));
@@ -4306,7 +4212,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT adapter
}
/* Use CheckDeviceFormat to see if the backbuffer_format is usable with the given display_format */
- hr = IWineD3DImpl_CheckDeviceFormat(iface, adapter_idx, device_type, display_format,
+ hr = wined3d_check_device_format(wined3d, adapter_idx, device_type, display_format,
WINED3DUSAGE_RENDERTARGET, WINED3DRTYPE_SURFACE, backbuffer_format, SURFACE_OPENGL);
if (FAILED(hr))
TRACE_(d3d_caps)("Unsupported display/backbuffer format combination %s / %s.\n",
@@ -4318,10 +4224,10 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT adapter
/* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a true
subset of a D3DCAPS9 structure. However, it has to come via a void *
as the d3d8 interface cannot import the d3d9 header */
-static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType, WINED3DCAPS* pCaps) {
-
- IWineD3DImpl *This = (IWineD3DImpl *)iface;
- struct wined3d_adapter *adapter = &This->adapters[Adapter];
+HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapter_idx,
+ WINED3DDEVTYPE device_type, WINED3DCAPS *caps)
+{
+ const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
int vs_selected_mode;
int ps_selected_mode;
@@ -4329,40 +4235,39 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
struct fragment_caps fragment_caps;
DWORD ckey_caps, blit_caps, fx_caps, pal_caps;
- TRACE_(d3d_caps)("(%p)->(Adptr:%d, DevType: %x, pCaps: %p)\n", This, Adapter, DeviceType, pCaps);
+ TRACE_(d3d_caps)("wined3d %p, adapter_idx %u, device_type %s, caps %p.\n",
+ wined3d, adapter_idx, debug_d3ddevicetype(device_type), caps);
- if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
+ if (adapter_idx >= wined3d->adapter_count)
return WINED3DERR_INVALIDCALL;
- }
select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
/* ------------------------------------------------
The following fields apply to both d3d8 and d3d9
------------------------------------------------ */
- pCaps->DeviceType = (DeviceType == WINED3DDEVTYPE_HAL) ? WINED3DDEVTYPE_HAL : WINED3DDEVTYPE_REF; /* Not quite true, but use h/w supported by opengl I suppose */
- pCaps->AdapterOrdinal = Adapter;
+ /* Not quite true, but use h/w supported by opengl I suppose */
+ caps->DeviceType = (device_type == WINED3DDEVTYPE_HAL) ? WINED3DDEVTYPE_HAL : WINED3DDEVTYPE_REF;
+ caps->AdapterOrdinal = adapter_idx;
- pCaps->Caps = 0;
- pCaps->Caps2 = WINED3DCAPS2_CANRENDERWINDOWED |
+ caps->Caps = 0;
+ caps->Caps2 = WINED3DCAPS2_CANRENDERWINDOWED |
WINED3DCAPS2_FULLSCREENGAMMA |
WINED3DCAPS2_DYNAMICTEXTURES;
if (gl_info->supported[SGIS_GENERATE_MIPMAP])
- {
- pCaps->Caps2 |= WINED3DCAPS2_CANAUTOGENMIPMAP;
- }
+ caps->Caps2 |= WINED3DCAPS2_CANAUTOGENMIPMAP;
- pCaps->Caps3 = WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD |
+ caps->Caps3 = WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD |
WINED3DCAPS3_COPY_TO_VIDMEM |
WINED3DCAPS3_COPY_TO_SYSTEMMEM;
- pCaps->PresentationIntervals = WINED3DPRESENT_INTERVAL_IMMEDIATE |
+ caps->PresentationIntervals = WINED3DPRESENT_INTERVAL_IMMEDIATE |
WINED3DPRESENT_INTERVAL_ONE;
- pCaps->CursorCaps = WINED3DCURSORCAPS_COLOR |
+ caps->CursorCaps = WINED3DCURSORCAPS_COLOR |
WINED3DCURSORCAPS_LOWRES;
- pCaps->DevCaps = WINED3DDEVCAPS_FLOATTLVERTEX |
+ caps->DevCaps = WINED3DDEVCAPS_FLOATTLVERTEX |
WINED3DDEVCAPS_EXECUTESYSTEMMEMORY |
WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY|
WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY |
@@ -4378,7 +4283,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
WINED3DDEVCAPS_DRAWPRIMITIVES2EX |
WINED3DDEVCAPS_RTPATCHES;
- pCaps->PrimitiveMiscCaps = WINED3DPMISCCAPS_CULLNONE |
+ caps->PrimitiveMiscCaps = WINED3DPMISCCAPS_CULLNONE |
WINED3DPMISCCAPS_CULLCCW |
WINED3DPMISCCAPS_CULLCW |
WINED3DPMISCCAPS_COLORWRITEENABLE |
@@ -4394,11 +4299,11 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
WINED3DPMISCCAPS_FOGVERTEXCLAMPED */
if (gl_info->supported[EXT_BLEND_EQUATION_SEPARATE] && gl_info->supported[EXT_BLEND_FUNC_SEPARATE])
- pCaps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_SEPARATEALPHABLEND;
+ caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_SEPARATEALPHABLEND;
if (gl_info->supported[EXT_DRAW_BUFFERS2])
- pCaps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS;
+ caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS;
- pCaps->RasterCaps = WINED3DPRASTERCAPS_DITHER |
+ caps->RasterCaps = WINED3DPRASTERCAPS_DITHER |
WINED3DPRASTERCAPS_PAT |
WINED3DPRASTERCAPS_WFOG |
WINED3DPRASTERCAPS_ZFOG |
@@ -4413,13 +4318,13 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
{
- pCaps->RasterCaps |= WINED3DPRASTERCAPS_ANISOTROPY |
+ caps->RasterCaps |= WINED3DPRASTERCAPS_ANISOTROPY |
WINED3DPRASTERCAPS_ZBIAS |
WINED3DPRASTERCAPS_MIPMAPLODBIAS;
}
if (gl_info->supported[NV_FOG_DISTANCE])
{
- pCaps->RasterCaps |= WINED3DPRASTERCAPS_FOGRANGE;
+ caps->RasterCaps |= WINED3DPRASTERCAPS_FOGRANGE;
}
/* FIXME Add:
WINED3DPRASTERCAPS_COLORPERSPECTIVE
@@ -4428,7 +4333,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
WINED3DPRASTERCAPS_ZBUFFERLESSHSR
WINED3DPRASTERCAPS_WBUFFER */
- pCaps->ZCmpCaps = WINED3DPCMPCAPS_ALWAYS |
+ caps->ZCmpCaps = WINED3DPCMPCAPS_ALWAYS |
WINED3DPCMPCAPS_EQUAL |
WINED3DPCMPCAPS_GREATER |
WINED3DPCMPCAPS_GREATEREQUAL |
@@ -4437,7 +4342,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
WINED3DPCMPCAPS_NEVER |
WINED3DPCMPCAPS_NOTEQUAL;
- pCaps->SrcBlendCaps = WINED3DPBLENDCAPS_BOTHINVSRCALPHA |
+ caps->SrcBlendCaps = WINED3DPBLENDCAPS_BOTHINVSRCALPHA |
WINED3DPBLENDCAPS_BOTHSRCALPHA |
WINED3DPBLENDCAPS_DESTALPHA |
WINED3DPBLENDCAPS_DESTCOLOR |
@@ -4451,7 +4356,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
WINED3DPBLENDCAPS_SRCCOLOR |
WINED3DPBLENDCAPS_ZERO;
- pCaps->DestBlendCaps = WINED3DPBLENDCAPS_DESTALPHA |
+ caps->DestBlendCaps = WINED3DPBLENDCAPS_DESTALPHA |
WINED3DPBLENDCAPS_DESTCOLOR |
WINED3DPBLENDCAPS_INVDESTALPHA |
WINED3DPBLENDCAPS_INVDESTCOLOR |
@@ -4470,12 +4375,12 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
if (gl_info->supported[EXT_BLEND_COLOR])
{
- pCaps->SrcBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
- pCaps->DestBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
+ caps->SrcBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
+ caps->DestBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR;
}
- pCaps->AlphaCmpCaps = WINED3DPCMPCAPS_ALWAYS |
+ caps->AlphaCmpCaps = WINED3DPCMPCAPS_ALWAYS |
WINED3DPCMPCAPS_EQUAL |
WINED3DPCMPCAPS_GREATER |
WINED3DPCMPCAPS_GREATEREQUAL |
@@ -4484,7 +4389,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
WINED3DPCMPCAPS_NEVER |
WINED3DPCMPCAPS_NOTEQUAL;
- pCaps->ShadeCaps = WINED3DPSHADECAPS_SPECULARGOURAUDRGB |
+ caps->ShadeCaps = WINED3DPSHADECAPS_SPECULARGOURAUDRGB |
WINED3DPSHADECAPS_COLORGOURAUDRGB |
WINED3DPSHADECAPS_ALPHAFLATBLEND |
WINED3DPSHADECAPS_ALPHAGOURAUDBLEND |
@@ -4493,7 +4398,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
WINED3DPSHADECAPS_FOGGOURAUD |
WINED3DPSHADECAPS_SPECULARFLATRGB;
- pCaps->TextureCaps = WINED3DPTEXTURECAPS_ALPHA |
+ caps->TextureCaps = WINED3DPTEXTURECAPS_ALPHA |
WINED3DPTEXTURECAPS_ALPHAPALETTE |
WINED3DPTEXTURECAPS_TRANSPARENCY |
WINED3DPTEXTURECAPS_BORDER |
@@ -4503,26 +4408,31 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
{
- pCaps->TextureCaps |= WINED3DPTEXTURECAPS_POW2 |
+ caps->TextureCaps |= WINED3DPTEXTURECAPS_POW2 |
WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL;
}
if (gl_info->supported[EXT_TEXTURE3D])
{
- pCaps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP |
- WINED3DPTEXTURECAPS_MIPVOLUMEMAP |
- WINED3DPTEXTURECAPS_VOLUMEMAP_POW2;
+ caps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP |
+ WINED3DPTEXTURECAPS_MIPVOLUMEMAP;
+ if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
+ {
+ caps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP_POW2;
+ }
}
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
{
- pCaps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP |
- WINED3DPTEXTURECAPS_MIPCUBEMAP |
- WINED3DPTEXTURECAPS_CUBEMAP_POW2;
-
+ caps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP |
+ WINED3DPTEXTURECAPS_MIPCUBEMAP;
+ if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
+ {
+ caps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP_POW2;
+ }
}
- pCaps->TextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
+ caps->TextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
WINED3DPTFILTERCAPS_MAGFPOINT |
WINED3DPTFILTERCAPS_MINFLINEAR |
WINED3DPTFILTERCAPS_MINFPOINT |
@@ -4537,13 +4447,13 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
{
- pCaps->TextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
+ caps->TextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
WINED3DPTFILTERCAPS_MINFANISOTROPIC;
}
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
{
- pCaps->CubeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
+ caps->CubeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
WINED3DPTFILTERCAPS_MAGFPOINT |
WINED3DPTFILTERCAPS_MINFLINEAR |
WINED3DPTFILTERCAPS_MINFPOINT |
@@ -4558,15 +4468,18 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
{
- pCaps->CubeTextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
+ caps->CubeTextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC |
WINED3DPTFILTERCAPS_MINFANISOTROPIC;
}
- } else
- pCaps->CubeTextureFilterCaps = 0;
+ }
+ else
+ {
+ caps->CubeTextureFilterCaps = 0;
+ }
if (gl_info->supported[EXT_TEXTURE3D])
{
- pCaps->VolumeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
+ caps->VolumeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR |
WINED3DPTFILTERCAPS_MAGFPOINT |
WINED3DPTFILTERCAPS_MINFLINEAR |
WINED3DPTFILTERCAPS_MINFPOINT |
@@ -4578,47 +4491,53 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
WINED3DPTFILTERCAPS_MIPLINEAR |
WINED3DPTFILTERCAPS_MIPNEAREST |
WINED3DPTFILTERCAPS_NEAREST;
- } else
- pCaps->VolumeTextureFilterCaps = 0;
+ }
+ else
+ {
+ caps->VolumeTextureFilterCaps = 0;
+ }
- pCaps->TextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
+ caps->TextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
WINED3DPTADDRESSCAPS_CLAMP |
WINED3DPTADDRESSCAPS_WRAP;
if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
{
- pCaps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
+ caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
}
if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT])
{
- pCaps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
+ caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
}
if (gl_info->supported[ATI_TEXTURE_MIRROR_ONCE])
{
- pCaps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
+ caps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
}
if (gl_info->supported[EXT_TEXTURE3D])
{
- pCaps->VolumeTextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
+ caps->VolumeTextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV |
WINED3DPTADDRESSCAPS_CLAMP |
WINED3DPTADDRESSCAPS_WRAP;
if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
{
- pCaps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
+ caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER;
}
if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT])
{
- pCaps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
+ caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR;
}
if (gl_info->supported[ATI_TEXTURE_MIRROR_ONCE])
{
- pCaps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
+ caps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE;
}
- } else
- pCaps->VolumeTextureAddressCaps = 0;
+ }
+ else
+ {
+ caps->VolumeTextureAddressCaps = 0;
+ }
- pCaps->LineCaps = WINED3DLINECAPS_TEXTURE |
+ caps->LineCaps = WINED3DLINECAPS_TEXTURE |
WINED3DLINECAPS_ZTEST |
WINED3DLINECAPS_BLEND |
WINED3DLINECAPS_ALPHACMP |
@@ -4627,26 +4546,26 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
* idea how generating the smoothing alpha values works; the result is different
*/
- pCaps->MaxTextureWidth = gl_info->limits.texture_size;
- pCaps->MaxTextureHeight = gl_info->limits.texture_size;
+ caps->MaxTextureWidth = gl_info->limits.texture_size;
+ caps->MaxTextureHeight = gl_info->limits.texture_size;
if (gl_info->supported[EXT_TEXTURE3D])
- pCaps->MaxVolumeExtent = gl_info->limits.texture3d_size;
+ caps->MaxVolumeExtent = gl_info->limits.texture3d_size;
else
- pCaps->MaxVolumeExtent = 0;
+ caps->MaxVolumeExtent = 0;
- pCaps->MaxTextureRepeat = 32768;
- pCaps->MaxTextureAspectRatio = gl_info->limits.texture_size;
- pCaps->MaxVertexW = 1.0f;
+ caps->MaxTextureRepeat = 32768;
+ caps->MaxTextureAspectRatio = gl_info->limits.texture_size;
+ caps->MaxVertexW = 1.0f;
- pCaps->GuardBandLeft = 0.0f;
- pCaps->GuardBandTop = 0.0f;
- pCaps->GuardBandRight = 0.0f;
- pCaps->GuardBandBottom = 0.0f;
+ caps->GuardBandLeft = 0.0f;
+ caps->GuardBandTop = 0.0f;
+ caps->GuardBandRight = 0.0f;
+ caps->GuardBandBottom = 0.0f;
- pCaps->ExtentsAdjust = 0.0f;
+ caps->ExtentsAdjust = 0.0f;
- pCaps->StencilCaps = WINED3DSTENCILCAPS_DECRSAT |
+ caps->StencilCaps = WINED3DSTENCILCAPS_DECRSAT |
WINED3DSTENCILCAPS_INCRSAT |
WINED3DSTENCILCAPS_INVERT |
WINED3DSTENCILCAPS_KEEP |
@@ -4654,162 +4573,185 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
WINED3DSTENCILCAPS_ZERO;
if (gl_info->supported[EXT_STENCIL_WRAP])
{
- pCaps->StencilCaps |= WINED3DSTENCILCAPS_DECR |
+ caps->StencilCaps |= WINED3DSTENCILCAPS_DECR |
WINED3DSTENCILCAPS_INCR;
}
if (gl_info->supported[EXT_STENCIL_TWO_SIDE] || gl_info->supported[ATI_SEPARATE_STENCIL])
{
- pCaps->StencilCaps |= WINED3DSTENCILCAPS_TWOSIDED;
+ caps->StencilCaps |= WINED3DSTENCILCAPS_TWOSIDED;
}
- pCaps->FVFCaps = WINED3DFVFCAPS_PSIZE | 0x0008; /* 8 texture coords */
+ caps->FVFCaps = WINED3DFVFCAPS_PSIZE | 0x0008; /* 8 texture coords */
- pCaps->MaxUserClipPlanes = gl_info->limits.clipplanes;
- pCaps->MaxActiveLights = gl_info->limits.lights;
+ caps->MaxUserClipPlanes = gl_info->limits.clipplanes;
+ caps->MaxActiveLights = gl_info->limits.lights;
- pCaps->MaxVertexBlendMatrices = gl_info->limits.blends;
- pCaps->MaxVertexBlendMatrixIndex = 0;
+ caps->MaxVertexBlendMatrices = gl_info->limits.blends;
+ caps->MaxVertexBlendMatrixIndex = 0;
- pCaps->MaxAnisotropy = gl_info->limits.anisotropy;
- pCaps->MaxPointSize = gl_info->limits.pointsize_max;
+ caps->MaxAnisotropy = gl_info->limits.anisotropy;
+ caps->MaxPointSize = gl_info->limits.pointsize_max;
/* FIXME: Add D3DVTXPCAPS_TWEENING, D3DVTXPCAPS_TEXGEN_SPHEREMAP */
- pCaps->VertexProcessingCaps = WINED3DVTXPCAPS_DIRECTIONALLIGHTS |
+ caps->VertexProcessingCaps = WINED3DVTXPCAPS_DIRECTIONALLIGHTS |
WINED3DVTXPCAPS_MATERIALSOURCE7 |
WINED3DVTXPCAPS_POSITIONALLIGHTS |
WINED3DVTXPCAPS_LOCALVIEWER |
WINED3DVTXPCAPS_VERTEXFOG |
WINED3DVTXPCAPS_TEXGEN;
- pCaps->MaxPrimitiveCount = 0xFFFFF; /* For now set 2^20-1 which is used by most >=Geforce3/Radeon8500 cards */
- pCaps->MaxVertexIndex = 0xFFFFF;
- pCaps->MaxStreams = MAX_STREAMS;
- pCaps->MaxStreamStride = 1024;
+ caps->MaxPrimitiveCount = 0xFFFFF; /* For now set 2^20-1 which is used by most >=Geforce3/Radeon8500 cards */
+ caps->MaxVertexIndex = 0xFFFFF;
+ caps->MaxStreams = MAX_STREAMS;
+ caps->MaxStreamStride = 1024;
/* d3d9.dll sets D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES here because StretchRects is implemented in d3d9 */
- pCaps->DevCaps2 = WINED3DDEVCAPS2_STREAMOFFSET |
- WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
- pCaps->MaxNpatchTessellationLevel = 0;
- pCaps->MasterAdapterOrdinal = 0;
- pCaps->AdapterOrdinalInGroup = 0;
- pCaps->NumberOfAdaptersInGroup = 1;
+ caps->DevCaps2 = WINED3DDEVCAPS2_STREAMOFFSET |
+ WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
+ caps->MaxNpatchTessellationLevel = 0;
+ caps->MasterAdapterOrdinal = 0;
+ caps->AdapterOrdinalInGroup = 0;
+ caps->NumberOfAdaptersInGroup = 1;
- pCaps->NumSimultaneousRTs = gl_info->limits.buffers;
+ caps->NumSimultaneousRTs = gl_info->limits.buffers;
- pCaps->StretchRectFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT |
+ caps->StretchRectFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT |
WINED3DPTFILTERCAPS_MAGFPOINT |
WINED3DPTFILTERCAPS_MINFLINEAR |
WINED3DPTFILTERCAPS_MAGFLINEAR;
- pCaps->VertexTextureFilterCaps = 0;
+ caps->VertexTextureFilterCaps = 0;
adapter->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps);
adapter->fragment_pipe->get_caps(&adapter->gl_info, &fragment_caps);
/* Add shader misc caps. Only some of them belong to the shader parts of the pipeline */
- pCaps->PrimitiveMiscCaps |= fragment_caps.PrimitiveMiscCaps;
+ caps->PrimitiveMiscCaps |= fragment_caps.PrimitiveMiscCaps;
/* This takes care for disabling vertex shader or pixel shader caps while leaving the other one enabled.
* Ignore shader model capabilities if disabled in config
*/
- if(vs_selected_mode == SHADER_NONE) {
+ if (vs_selected_mode == SHADER_NONE)
+ {
TRACE_(d3d_caps)("Vertex shader disabled in config, reporting version 0.0\n");
- pCaps->VertexShaderVersion = WINED3DVS_VERSION(0,0);
- pCaps->MaxVertexShaderConst = 0;
- } else {
- pCaps->VertexShaderVersion = shader_caps.VertexShaderVersion;
- pCaps->MaxVertexShaderConst = shader_caps.MaxVertexShaderConst;
+ caps->VertexShaderVersion = WINED3DVS_VERSION(0,0);
+ caps->MaxVertexShaderConst = 0;
+ }
+ else
+ {
+ caps->VertexShaderVersion = shader_caps.VertexShaderVersion;
+ caps->MaxVertexShaderConst = shader_caps.MaxVertexShaderConst;
}
- if(ps_selected_mode == SHADER_NONE) {
+ if (ps_selected_mode == SHADER_NONE)
+ {
TRACE_(d3d_caps)("Pixel shader disabled in config, reporting version 0.0\n");
- pCaps->PixelShaderVersion = WINED3DPS_VERSION(0,0);
- pCaps->PixelShader1xMaxValue = 0.0f;
+ caps->PixelShaderVersion = WINED3DPS_VERSION(0,0);
+ caps->PixelShader1xMaxValue = 0.0f;
} else {
- pCaps->PixelShaderVersion = shader_caps.PixelShaderVersion;
- pCaps->PixelShader1xMaxValue = shader_caps.PixelShader1xMaxValue;
+ caps->PixelShaderVersion = shader_caps.PixelShaderVersion;
+ caps->PixelShader1xMaxValue = shader_caps.PixelShader1xMaxValue;
}
- pCaps->TextureOpCaps = fragment_caps.TextureOpCaps;
- pCaps->MaxTextureBlendStages = fragment_caps.MaxTextureBlendStages;
- pCaps->MaxSimultaneousTextures = fragment_caps.MaxSimultaneousTextures;
+ caps->TextureOpCaps = fragment_caps.TextureOpCaps;
+ caps->MaxTextureBlendStages = fragment_caps.MaxTextureBlendStages;
+ caps->MaxSimultaneousTextures = fragment_caps.MaxSimultaneousTextures;
/* The following caps are shader specific, but they are things we cannot detect, or which
* are the same among all shader models. So to avoid code duplication set the shader version
* specific, but otherwise constant caps here
*/
- if(pCaps->VertexShaderVersion == WINED3DVS_VERSION(3,0)) {
- /* Where possible set the caps based on OpenGL extensions and if they aren't set (in case of software rendering)
- use the VS 3.0 from MSDN or else if there's OpenGL spec use a hardcoded value minimum VS3.0 value. */
- pCaps->VS20Caps.Caps = WINED3DVS20CAPS_PREDICATION;
- pCaps->VS20Caps.DynamicFlowControlDepth = WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH; /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
- pCaps->VS20Caps.NumTemps = max(32, adapter->gl_info.limits.arb_vs_temps);
- pCaps->VS20Caps.StaticFlowControlDepth = WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH ; /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
-
- pCaps->MaxVShaderInstructionsExecuted = 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
- pCaps->MaxVertexShader30InstructionSlots = max(512, adapter->gl_info.limits.arb_vs_instructions);
- }
- else if (pCaps->VertexShaderVersion == WINED3DVS_VERSION(2,0))
+ if (caps->VertexShaderVersion == WINED3DVS_VERSION(3,0))
{
- pCaps->VS20Caps.Caps = 0;
- pCaps->VS20Caps.DynamicFlowControlDepth = WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH;
- pCaps->VS20Caps.NumTemps = max(12, adapter->gl_info.limits.arb_vs_temps);
- pCaps->VS20Caps.StaticFlowControlDepth = 1;
+ /* Where possible set the caps based on OpenGL extensions and if they
+ * aren't set (in case of software rendering) use the VS 3.0 from
+ * MSDN or else if there's OpenGL spec use a hardcoded value minimum
+ * VS3.0 value. */
+ caps->VS20Caps.Caps = WINED3DVS20CAPS_PREDICATION;
+ /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
+ caps->VS20Caps.DynamicFlowControlDepth = WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH;
+ caps->VS20Caps.NumTemps = max(32, adapter->gl_info.limits.arb_vs_temps);
+ /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
+ caps->VS20Caps.StaticFlowControlDepth = WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH;
- pCaps->MaxVShaderInstructionsExecuted = 65535;
- pCaps->MaxVertexShader30InstructionSlots = 0;
- } else { /* VS 1.x */
- pCaps->VS20Caps.Caps = 0;
- pCaps->VS20Caps.DynamicFlowControlDepth = 0;
- pCaps->VS20Caps.NumTemps = 0;
- pCaps->VS20Caps.StaticFlowControlDepth = 0;
+ caps->MaxVShaderInstructionsExecuted = 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
+ caps->MaxVertexShader30InstructionSlots = max(512, adapter->gl_info.limits.arb_vs_instructions);
+ }
+ else if (caps->VertexShaderVersion == WINED3DVS_VERSION(2,0))
+ {
+ caps->VS20Caps.Caps = 0;
+ caps->VS20Caps.DynamicFlowControlDepth = WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH;
+ caps->VS20Caps.NumTemps = max(12, adapter->gl_info.limits.arb_vs_temps);
+ caps->VS20Caps.StaticFlowControlDepth = 1;
- pCaps->MaxVShaderInstructionsExecuted = 0;
- pCaps->MaxVertexShader30InstructionSlots = 0;
+ caps->MaxVShaderInstructionsExecuted = 65535;
+ caps->MaxVertexShader30InstructionSlots = 0;
+ }
+ else
+ { /* VS 1.x */
+ caps->VS20Caps.Caps = 0;
+ caps->VS20Caps.DynamicFlowControlDepth = 0;
+ caps->VS20Caps.NumTemps = 0;
+ caps->VS20Caps.StaticFlowControlDepth = 0;
+
+ caps->MaxVShaderInstructionsExecuted = 0;
+ caps->MaxVertexShader30InstructionSlots = 0;
}
- if(pCaps->PixelShaderVersion == WINED3DPS_VERSION(3,0)) {
- /* Where possible set the caps based on OpenGL extensions and if they aren't set (in case of software rendering)
- use the PS 3.0 from MSDN or else if there's OpenGL spec use a hardcoded value minimum PS 3.0 value. */
+ if (caps->PixelShaderVersion == WINED3DPS_VERSION(3,0))
+ {
+ /* Where possible set the caps based on OpenGL extensions and if they
+ * aren't set (in case of software rendering) use the PS 3.0 from
+ * MSDN or else if there's OpenGL spec use a hardcoded value minimum
+ * PS 3.0 value. */
- /* Caps is more or less undocumented on MSDN but it appears to be used for PS20Caps based on results from R9600/FX5900/Geforce6800 cards from Windows */
- pCaps->PS20Caps.Caps = WINED3DPS20CAPS_ARBITRARYSWIZZLE |
+ /* Caps is more or less undocumented on MSDN but it appears to be
+ * used for PS20Caps based on results from R9600/FX5900/Geforce6800
+ * cards from Windows */
+ caps->PS20Caps.Caps = WINED3DPS20CAPS_ARBITRARYSWIZZLE |
WINED3DPS20CAPS_GRADIENTINSTRUCTIONS |
WINED3DPS20CAPS_PREDICATION |
WINED3DPS20CAPS_NODEPENDENTREADLIMIT |
WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT;
- pCaps->PS20Caps.DynamicFlowControlDepth = WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH; /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
- pCaps->PS20Caps.NumTemps = max(32, adapter->gl_info.limits.arb_ps_temps);
- pCaps->PS20Caps.StaticFlowControlDepth = WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH; /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
- pCaps->PS20Caps.NumInstructionSlots = WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS; /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
+ /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
+ caps->PS20Caps.DynamicFlowControlDepth = WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH;
+ caps->PS20Caps.NumTemps = max(32, adapter->gl_info.limits.arb_ps_temps);
+ /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
+ caps->PS20Caps.StaticFlowControlDepth = WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH;
+ /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
+ caps->PS20Caps.NumInstructionSlots = WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS;
- pCaps->MaxPShaderInstructionsExecuted = 65535;
- pCaps->MaxPixelShader30InstructionSlots = max(WINED3DMIN30SHADERINSTRUCTIONS,
+ caps->MaxPShaderInstructionsExecuted = 65535;
+ caps->MaxPixelShader30InstructionSlots = max(WINED3DMIN30SHADERINSTRUCTIONS,
adapter->gl_info.limits.arb_ps_instructions);
}
- else if(pCaps->PixelShaderVersion == WINED3DPS_VERSION(2,0))
+ else if(caps->PixelShaderVersion == WINED3DPS_VERSION(2,0))
{
/* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
- pCaps->PS20Caps.Caps = 0;
- pCaps->PS20Caps.DynamicFlowControlDepth = 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
- pCaps->PS20Caps.NumTemps = max(12, adapter->gl_info.limits.arb_ps_temps);
- pCaps->PS20Caps.StaticFlowControlDepth = WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH; /* Minimum: 1 */
- pCaps->PS20Caps.NumInstructionSlots = WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS; /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
+ caps->PS20Caps.Caps = 0;
+ caps->PS20Caps.DynamicFlowControlDepth = 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
+ caps->PS20Caps.NumTemps = max(12, adapter->gl_info.limits.arb_ps_temps);
+ caps->PS20Caps.StaticFlowControlDepth = WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH; /* Minimum: 1 */
+ /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
+ caps->PS20Caps.NumInstructionSlots = WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS;
- pCaps->MaxPShaderInstructionsExecuted = 512; /* Minimum value, a GeforceFX uses 1024 */
- pCaps->MaxPixelShader30InstructionSlots = 0;
- } else { /* PS 1.x */
- pCaps->PS20Caps.Caps = 0;
- pCaps->PS20Caps.DynamicFlowControlDepth = 0;
- pCaps->PS20Caps.NumTemps = 0;
- pCaps->PS20Caps.StaticFlowControlDepth = 0;
- pCaps->PS20Caps.NumInstructionSlots = 0;
+ caps->MaxPShaderInstructionsExecuted = 512; /* Minimum value, a GeforceFX uses 1024 */
+ caps->MaxPixelShader30InstructionSlots = 0;
+ }
+ else /* PS 1.x */
+ {
+ caps->PS20Caps.Caps = 0;
+ caps->PS20Caps.DynamicFlowControlDepth = 0;
+ caps->PS20Caps.NumTemps = 0;
+ caps->PS20Caps.StaticFlowControlDepth = 0;
+ caps->PS20Caps.NumInstructionSlots = 0;
- pCaps->MaxPShaderInstructionsExecuted = 0;
- pCaps->MaxPixelShader30InstructionSlots = 0;
+ caps->MaxPShaderInstructionsExecuted = 0;
+ caps->MaxPixelShader30InstructionSlots = 0;
}
- if(pCaps->VertexShaderVersion >= WINED3DVS_VERSION(2,0)) {
+ if (caps->VertexShaderVersion >= WINED3DVS_VERSION(2,0))
+ {
/* OpenGL supports all the formats below, perhaps not always
* without conversion, but it supports them.
* Further GLSL doesn't seem to have an official unsigned type so
@@ -4817,17 +4759,20 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
* We might need to add some clamping in the shader engine to
* support it.
* TODO: WINED3DDTCAPS_USHORT2N, WINED3DDTCAPS_USHORT4N, WINED3DDTCAPS_UDEC3, WINED3DDTCAPS_DEC3N */
- pCaps->DeclTypes = WINED3DDTCAPS_UBYTE4 |
- WINED3DDTCAPS_UBYTE4N |
- WINED3DDTCAPS_SHORT2N |
- WINED3DDTCAPS_SHORT4N;
+ caps->DeclTypes = WINED3DDTCAPS_UBYTE4 |
+ WINED3DDTCAPS_UBYTE4N |
+ WINED3DDTCAPS_SHORT2N |
+ WINED3DDTCAPS_SHORT4N;
if (gl_info->supported[ARB_HALF_FLOAT_VERTEX])
{
- pCaps->DeclTypes |= WINED3DDTCAPS_FLOAT16_2 |
- WINED3DDTCAPS_FLOAT16_4;
+ caps->DeclTypes |= WINED3DDTCAPS_FLOAT16_2 |
+ WINED3DDTCAPS_FLOAT16_4;
}
- } else
- pCaps->DeclTypes = 0;
+ }
+ else
+ {
+ caps->DeclTypes = 0;
+ }
/* Set DirectDraw helper Caps */
ckey_caps = WINEDDCKEYCAPS_DESTBLT |
@@ -4858,28 +4803,28 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
WINEDDPCAPS_PRIMARYSURFACE;
/* Fill the ddraw caps structure */
- pCaps->DirectDrawCaps.Caps = WINEDDCAPS_GDI |
+ caps->DirectDrawCaps.Caps = WINEDDCAPS_GDI |
WINEDDCAPS_PALETTE |
blit_caps;
- pCaps->DirectDrawCaps.Caps2 = WINEDDCAPS2_CERTIFIED |
+ caps->DirectDrawCaps.Caps2 = WINEDDCAPS2_CERTIFIED |
WINEDDCAPS2_NOPAGELOCKREQUIRED |
WINEDDCAPS2_PRIMARYGAMMA |
WINEDDCAPS2_WIDESURFACES |
WINEDDCAPS2_CANRENDERWINDOWED;
- pCaps->DirectDrawCaps.CKeyCaps = ckey_caps;
- pCaps->DirectDrawCaps.FXCaps = fx_caps;
- pCaps->DirectDrawCaps.PalCaps = pal_caps;
- pCaps->DirectDrawCaps.SVBCaps = blit_caps;
- pCaps->DirectDrawCaps.SVBCKeyCaps = ckey_caps;
- pCaps->DirectDrawCaps.SVBFXCaps = fx_caps;
- pCaps->DirectDrawCaps.VSBCaps = blit_caps;
- pCaps->DirectDrawCaps.VSBCKeyCaps = ckey_caps;
- pCaps->DirectDrawCaps.VSBFXCaps = fx_caps;
- pCaps->DirectDrawCaps.SSBCaps = blit_caps;
- pCaps->DirectDrawCaps.SSBCKeyCaps = ckey_caps;
- pCaps->DirectDrawCaps.SSBFXCaps = fx_caps;
+ caps->DirectDrawCaps.CKeyCaps = ckey_caps;
+ caps->DirectDrawCaps.FXCaps = fx_caps;
+ caps->DirectDrawCaps.PalCaps = pal_caps;
+ caps->DirectDrawCaps.SVBCaps = blit_caps;
+ caps->DirectDrawCaps.SVBCKeyCaps = ckey_caps;
+ caps->DirectDrawCaps.SVBFXCaps = fx_caps;
+ caps->DirectDrawCaps.VSBCaps = blit_caps;
+ caps->DirectDrawCaps.VSBCKeyCaps = ckey_caps;
+ caps->DirectDrawCaps.VSBFXCaps = fx_caps;
+ caps->DirectDrawCaps.SSBCaps = blit_caps;
+ caps->DirectDrawCaps.SSBCKeyCaps = ckey_caps;
+ caps->DirectDrawCaps.SSBFXCaps = fx_caps;
- pCaps->DirectDrawCaps.ddsCaps = WINEDDSCAPS_ALPHA |
+ caps->DirectDrawCaps.ddsCaps = WINEDDSCAPS_ALPHA |
WINEDDSCAPS_BACKBUFFER |
WINEDDSCAPS_FLIP |
WINEDDSCAPS_FRONTBUFFER |
@@ -4889,37 +4834,34 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
WINEDDSCAPS_SYSTEMMEMORY |
WINEDDSCAPS_VIDEOMEMORY |
WINEDDSCAPS_VISIBLE;
- pCaps->DirectDrawCaps.StrideAlign = DDRAW_PITCH_ALIGNMENT;
+ caps->DirectDrawCaps.StrideAlign = DDRAW_PITCH_ALIGNMENT;
/* Set D3D caps if OpenGL is available. */
if (adapter->opengl)
{
- pCaps->DirectDrawCaps.ddsCaps |=WINEDDSCAPS_3DDEVICE |
+ caps->DirectDrawCaps.ddsCaps |= WINEDDSCAPS_3DDEVICE |
WINEDDSCAPS_MIPMAP |
WINEDDSCAPS_TEXTURE |
WINEDDSCAPS_ZBUFFER;
- pCaps->DirectDrawCaps.Caps |= WINEDDCAPS_3D;
+ caps->DirectDrawCaps.Caps |= WINEDDCAPS_3D;
}
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT adapter_idx, WINED3DDEVTYPE device_type,
- HWND focus_window, DWORD flags, IWineD3DDeviceParent *device_parent, IWineD3DDevice **device)
+HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx, WINED3DDEVTYPE device_type,
+ HWND focus_window, DWORD flags, struct wined3d_device_parent *device_parent, struct wined3d_device **device)
{
- IWineD3DImpl *This = (IWineD3DImpl *)iface;
- IWineD3DDeviceImpl *object;
+ struct wined3d_device *object;
HRESULT hr;
- TRACE("iface %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, device_parent %p, device %p.\n",
- iface, adapter_idx, device_type, focus_window, flags, device_parent, device);
+ TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, device_parent %p, device %p.\n",
+ wined3d, adapter_idx, device_type, focus_window, flags, device_parent, device);
/* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
* number and create a device without a 3D adapter for 2D only operation. */
- if (IWineD3D_GetAdapterCount(iface) && adapter_idx >= IWineD3D_GetAdapterCount(iface))
- {
+ if (wined3d->adapter_count && adapter_idx >= wined3d->adapter_count)
return WINED3DERR_INVALIDCALL;
- }
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
@@ -4928,7 +4870,7 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT adapter_id
return E_OUTOFMEMORY;
}
- hr = device_init(object, This, adapter_idx, device_type, focus_window, flags, device_parent);
+ hr = device_init(object, wined3d, adapter_idx, device_type, focus_window, flags, device_parent);
if (FAILED(hr))
{
WARN("Failed to initialize device, hr %#x.\n", hr);
@@ -4937,18 +4879,18 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT adapter_id
}
TRACE("Created device %p.\n", object);
- *device = (IWineD3DDevice *)object;
+ *device = object;
- IWineD3DDeviceParent_WineD3DDeviceCreated(device_parent, *device);
+ device_parent->ops->wined3d_device_created(device_parent, *device);
return WINED3D_OK;
}
-static void * WINAPI IWineD3DImpl_GetParent(IWineD3D *iface)
+void * CDECL wined3d_get_parent(const struct wined3d *wined3d)
{
- TRACE("iface %p.\n", iface);
+ TRACE("wined3d %p.\n", wined3d);
- return ((IWineD3DImpl *)iface)->parent;
+ return wined3d->parent;
}
static void WINE_GLAPI invalid_func(const void *data)
@@ -5138,7 +5080,7 @@ static void fillGLAttribFuncs(const struct wined3d_gl_info *gl_info)
}
/* Do not call while under the GL lock. */
-static BOOL InitAdapters(IWineD3DImpl *This)
+static BOOL InitAdapters(struct wined3d *wined3d)
{
static HMODULE mod_gl;
BOOL ret;
@@ -5195,13 +5137,13 @@ static BOOL InitAdapters(IWineD3DImpl *This)
/* For now only one default adapter */
{
- struct wined3d_adapter *adapter = &This->adapters[0];
+ struct wined3d_adapter *adapter = &wined3d->adapters[0];
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
struct wined3d_fake_gl_ctx fake_gl_ctx = {0};
+ struct wined3d_pixel_format *cfgs;
int iPixelFormat;
int res;
int i;
- WineD3D_PixelFormat *cfgs;
DISPLAY_DEVICEW DisplayDevice;
HDC hdc;
@@ -5260,7 +5202,7 @@ static BOOL InitAdapters(IWineD3DImpl *This)
attribute = WGL_NUMBER_PIXEL_FORMATS_ARB;
GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc, 0, 0, 1, &attribute, &adapter->nCfgs));
- adapter->cfgs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, adapter->nCfgs *sizeof(WineD3D_PixelFormat));
+ adapter->cfgs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, adapter->nCfgs * sizeof(*adapter->cfgs));
cfgs = adapter->cfgs;
attribs[nAttribs++] = WGL_RED_BITS_ARB;
attribs[nAttribs++] = WGL_GREEN_BITS_ARB;
@@ -5320,7 +5262,7 @@ static BOOL InitAdapters(IWineD3DImpl *This)
else
{
int nCfgs = DescribePixelFormat(hdc, 0, 0, 0);
- adapter->cfgs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nCfgs*sizeof(WineD3D_PixelFormat));
+ adapter->cfgs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nCfgs * sizeof(*adapter->cfgs));
adapter->nCfgs = 0; /* We won't accept all formats e.g. software accelerated ones will be skipped */
cfgs = adapter->cfgs;
@@ -5401,61 +5343,32 @@ static BOOL InitAdapters(IWineD3DImpl *This)
fillGLAttribFuncs(&adapter->gl_info);
adapter->opengl = TRUE;
}
- This->adapter_count = 1;
- TRACE("%u adapters successfully initialized\n", This->adapter_count);
+ wined3d->adapter_count = 1;
+ TRACE("%u adapters successfully initialized.\n", wined3d->adapter_count);
return TRUE;
nogl_adapter:
/* Initialize an adapter for ddraw-only memory counting */
- memset(This->adapters, 0, sizeof(This->adapters));
- This->adapters[0].ordinal = 0;
- This->adapters[0].opengl = FALSE;
- This->adapters[0].monitorPoint.x = -1;
- This->adapters[0].monitorPoint.y = -1;
+ memset(wined3d->adapters, 0, sizeof(wined3d->adapters));
+ wined3d->adapters[0].ordinal = 0;
+ wined3d->adapters[0].opengl = FALSE;
+ wined3d->adapters[0].monitorPoint.x = -1;
+ wined3d->adapters[0].monitorPoint.y = -1;
- This->adapters[0].driver_info.name = "Display";
- This->adapters[0].driver_info.description = "WineD3D DirectDraw Emulation";
- if(wined3d_settings.emulated_textureram) {
- This->adapters[0].TextureRam = wined3d_settings.emulated_textureram;
- } else {
- This->adapters[0].TextureRam = 8 * 1024 * 1024; /* This is plenty for a DDraw-only card */
- }
+ wined3d->adapters[0].driver_info.name = "Display";
+ wined3d->adapters[0].driver_info.description = "WineD3D DirectDraw Emulation";
+ if (wined3d_settings.emulated_textureram)
+ wined3d->adapters[0].TextureRam = wined3d_settings.emulated_textureram;
+ else
+ wined3d->adapters[0].TextureRam = 8 * 1024 * 1024; /* This is plenty for a DDraw-only card */
- initPixelFormatsNoGL(&This->adapters[0].gl_info);
+ initPixelFormatsNoGL(&wined3d->adapters[0].gl_info);
- This->adapter_count = 1;
+ wined3d->adapter_count = 1;
return FALSE;
}
-/**********************************************************
- * IWineD3D VTbl follows
- **********************************************************/
-
-static const struct IWineD3DVtbl IWineD3D_Vtbl =
-{
- /* IUnknown */
- IWineD3DImpl_QueryInterface,
- IWineD3DImpl_AddRef,
- IWineD3DImpl_Release,
- /* IWineD3D */
- IWineD3DImpl_GetParent,
- IWineD3DImpl_GetAdapterCount,
- IWineD3DImpl_RegisterSoftwareDevice,
- IWineD3DImpl_GetAdapterMonitor,
- IWineD3DImpl_GetAdapterModeCount,
- IWineD3DImpl_EnumAdapterModes,
- IWineD3DImpl_GetAdapterDisplayMode,
- IWineD3DImpl_GetAdapterIdentifier,
- IWineD3DImpl_CheckDeviceMultiSampleType,
- IWineD3DImpl_CheckDepthStencilMatch,
- IWineD3DImpl_CheckDeviceType,
- IWineD3DImpl_CheckDeviceFormat,
- IWineD3DImpl_CheckDeviceFormatConversion,
- IWineD3DImpl_GetDeviceCaps,
- IWineD3DImpl_CreateDevice
-};
-
static void STDMETHODCALLTYPE wined3d_null_wined3d_object_destroyed(void *parent) {}
const struct wined3d_parent_ops wined3d_null_parent_ops =
@@ -5464,9 +5377,8 @@ const struct wined3d_parent_ops wined3d_null_parent_ops =
};
/* Do not call while under the GL lock. */
-HRESULT wined3d_init(IWineD3DImpl *wined3d, UINT version, void *parent)
+HRESULT wined3d_init(struct wined3d *wined3d, UINT version, void *parent)
{
- wined3d->lpVtbl = &IWineD3D_Vtbl;
wined3d->dxVersion = version;
wined3d->ref = 1;
wined3d->parent = parent;
diff --git a/reactos/dll/directx/wine/wined3d/drawprim.c b/reactos/dll/directx/wine/wined3d/drawprim.c
index 6b6102bc330..4dbba92710b 100644
--- a/reactos/dll/directx/wine/wined3d/drawprim.c
+++ b/reactos/dll/directx/wine/wined3d/drawprim.c
@@ -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(¤t_rect, 0, 0,
- This->depth_stencil->ds_current_size.cx,
- This->depth_stencil->ds_current_size.cy);
+ if (ds->flags & location)
+ SetRect(¤t_rect, 0, 0, ds->ds_current_size.cx, ds->ds_current_size.cy);
else
SetRectEmpty(¤t_rect);
- device_get_draw_rect(This, &draw_rect);
+ device_get_draw_rect(device, &draw_rect);
IntersectRect(&r, &draw_rect, ¤t_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");
diff --git a/reactos/dll/directx/wine/wined3d/gl_compat.c b/reactos/dll/directx/wine/wined3d/gl_compat.c
index 0f8eaba83d2..57564452f46 100644
--- a/reactos/dll/directx/wine/wined3d/gl_compat.c
+++ b/reactos/dll/directx/wine/wined3d/gl_compat.c
@@ -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 */
diff --git a/reactos/dll/directx/wine/wined3d/glsl_shader.c b/reactos/dll/directx/wine/wined3d/glsl_shader.c
index 0b5bb3671d3..9b8cd5b4007 100644
--- a/reactos/dll/directx/wine/wined3d/glsl_shader.c
+++ b/reactos/dll/directx/wine/wined3d/glsl_shader.c
@@ -4,7 +4,7 @@
* Copyright 2006 Jason Green
* Copyright 2006-2007 Henri Verbeet
* Copyright 2007-2008 Stefan Dösinger for CodeWeavers
- * 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
@@ -109,20 +109,21 @@ struct glsl_shader_prog_link {
GLint luminanceoffset_location[MAX_TEXTURES];
GLint ycorrection_location;
GLenum vertex_color_clamp;
- IWineD3DVertexShader *vshader;
- IWineD3DPixelShader *pshader;
+ const struct wined3d_shader *vshader;
+ const struct wined3d_shader *pshader;
struct vs_compile_args vs_args;
struct ps_compile_args ps_args;
UINT constant_version;
const struct ps_np2fixup_info *np2Fixup_info;
};
-typedef struct {
- IWineD3DVertexShader *vshader;
- IWineD3DPixelShader *pshader;
+struct glsl_program_key
+{
+ const struct wined3d_shader *vshader;
+ const struct wined3d_shader *pshader;
struct ps_compile_args ps_args;
struct vs_compile_args vs_args;
-} glsl_program_key_t;
+};
struct shader_glsl_ctx_priv {
const struct vs_compile_args *cur_vs_args;
@@ -534,27 +535,27 @@ static inline void walk_constant_heap_clamped(const struct wined3d_gl_info *gl_i
/* Loads floating point constants (aka uniforms) into the currently set GLSL program. */
/* GL locking is done by the caller */
-static void shader_glsl_load_constantsF(IWineD3DBaseShaderImpl *This, const struct wined3d_gl_info *gl_info,
+static void shader_glsl_load_constantsF(const struct wined3d_shader *shader, const struct wined3d_gl_info *gl_info,
const float *constants, const GLint *constant_locations, const struct constant_heap *heap,
unsigned char *stack, UINT version)
{
const local_constant *lconst;
/* 1.X pshaders have the constants clamped to [-1;1] implicitly. */
- if (This->baseShader.reg_maps.shader_version.major == 1
- && shader_is_pshader_version(This->baseShader.reg_maps.shader_version.type))
+ if (shader->reg_maps.shader_version.major == 1
+ && shader_is_pshader_version(shader->reg_maps.shader_version.type))
walk_constant_heap_clamped(gl_info, constants, constant_locations, heap, stack, version);
else
walk_constant_heap(gl_info, constants, constant_locations, heap, stack, version);
- if (!This->baseShader.load_local_constsF)
+ if (!shader->load_local_constsF)
{
TRACE("No need to load local float constants for this shader\n");
return;
}
/* Immediate constants are clamped to [-1;1] at shader creation time if needed */
- LIST_FOR_EACH_ENTRY(lconst, &This->baseShader.constantsF, local_constant, entry)
+ LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, local_constant, entry)
{
GLint location = constant_locations[lconst->idx];
/* We found this uniform name in the program - go ahead and send the data */
@@ -565,7 +566,7 @@ static void shader_glsl_load_constantsF(IWineD3DBaseShaderImpl *This, const stru
/* Loads integer constants (aka uniforms) into the currently set GLSL program. */
/* GL locking is done by the caller */
-static void shader_glsl_load_constantsI(IWineD3DBaseShaderImpl *This, const struct wined3d_gl_info *gl_info,
+static void shader_glsl_load_constantsI(const struct wined3d_shader *shader, const struct wined3d_gl_info *gl_info,
const GLint locations[MAX_CONST_I], const int *constants, WORD constants_set)
{
unsigned int i;
@@ -584,8 +585,9 @@ static void shader_glsl_load_constantsI(IWineD3DBaseShaderImpl *This, const stru
}
/* Load immediate constants */
- ptr = list_head(&This->baseShader.constantsI);
- while (ptr) {
+ ptr = list_head(&shader->constantsI);
+ while (ptr)
+ {
const struct local_constant *lconst = LIST_ENTRY(ptr, const struct local_constant, entry);
unsigned int idx = lconst->idx;
const GLint *values = (const GLint *)lconst->value;
@@ -596,13 +598,13 @@ static void shader_glsl_load_constantsI(IWineD3DBaseShaderImpl *This, const stru
/* We found this uniform name in the program - go ahead and send the data */
GL_EXTCALL(glUniform4ivARB(locations[idx], 1, values));
checkGLcall("glUniform4ivARB");
- ptr = list_next(&This->baseShader.constantsI, ptr);
+ ptr = list_next(&shader->constantsI, ptr);
}
}
/* Loads boolean constants (aka uniforms) into the currently set GLSL program. */
/* GL locking is done by the caller */
-static void shader_glsl_load_constantsB(IWineD3DBaseShaderImpl *This, const struct wined3d_gl_info *gl_info,
+static void shader_glsl_load_constantsB(const struct wined3d_shader *shader, const struct wined3d_gl_info *gl_info,
GLhandleARB programId, const BOOL *constants, WORD constants_set)
{
GLint tmp_loc;
@@ -611,7 +613,7 @@ static void shader_glsl_load_constantsB(IWineD3DBaseShaderImpl *This, const stru
const char *prefix;
struct list* ptr;
- switch (This->baseShader.reg_maps.shader_version.type)
+ switch (shader->reg_maps.shader_version.type)
{
case WINED3D_SHADER_TYPE_VERTEX:
prefix = "VB";
@@ -627,7 +629,7 @@ static void shader_glsl_load_constantsB(IWineD3DBaseShaderImpl *This, const stru
default:
FIXME("Unknown shader type %#x.\n",
- This->baseShader.reg_maps.shader_version.type);
+ shader->reg_maps.shader_version.type);
prefix = "UB";
break;
}
@@ -653,8 +655,9 @@ static void shader_glsl_load_constantsB(IWineD3DBaseShaderImpl *This, const stru
}
/* Load immediate constants */
- ptr = list_head(&This->baseShader.constantsB);
- while (ptr) {
+ ptr = list_head(&shader->constantsB);
+ while (ptr)
+ {
const struct local_constant *lconst = LIST_ENTRY(ptr, const struct local_constant, entry);
unsigned int idx = lconst->idx;
const GLint *values = (const GLint *)lconst->value;
@@ -668,7 +671,7 @@ static void shader_glsl_load_constantsB(IWineD3DBaseShaderImpl *This, const stru
GL_EXTCALL(glUniform1ivARB(tmp_loc, 1, values));
checkGLcall("glUniform1ivARB");
}
- ptr = list_next(&This->baseShader.constantsB, ptr);
+ ptr = list_next(&shader->constantsB, ptr);
}
}
@@ -681,34 +684,28 @@ static void reset_program_constant_version(struct wine_rb_entry *entry, void *co
* Loads the texture dimensions for NP2 fixup into the currently set GLSL program.
*/
/* GL locking is done by the caller (state handler) */
-static void shader_glsl_load_np2fixup_constants(
- IWineD3DDevice* device,
- char usePixelShader,
- char useVertexShader) {
+static void shader_glsl_load_np2fixup_constants(void *shader_priv,
+ const struct wined3d_gl_info *gl_info, const struct wined3d_state *state)
+{
+ struct shader_glsl_priv *glsl_priv = shader_priv;
+ const struct glsl_shader_prog_link *prog = glsl_priv->glsl_program;
- const IWineD3DDeviceImpl* deviceImpl = (const IWineD3DDeviceImpl*) device;
- const struct glsl_shader_prog_link* prog = ((struct shader_glsl_priv *)(deviceImpl->shader_priv))->glsl_program;
+ /* No GLSL program set - nothing to do. */
+ if (!prog) return;
- if (!prog) {
- /* No GLSL program set - nothing to do. */
- return;
- }
+ /* NP2 texcoord fixup is (currently) only done for pixelshaders. */
+ if (!use_ps(state)) return;
- if (!usePixelShader) {
- /* NP2 texcoord fixup is (currently) only done for pixelshaders. */
- return;
- }
-
- if (prog->ps_args.np2_fixup && -1 != prog->np2Fixup_location) {
- const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info;
- const IWineD3DStateBlockImpl* stateBlock = (const IWineD3DStateBlockImpl*) deviceImpl->stateBlock;
+ if (prog->ps_args.np2_fixup && prog->np2Fixup_location != -1)
+ {
UINT i;
UINT fixup = prog->ps_args.np2_fixup;
GLfloat np2fixup_constants[4 * MAX_FRAGMENT_SAMPLERS];
- for (i = 0; fixup; fixup >>= 1, ++i) {
+ for (i = 0; fixup; fixup >>= 1, ++i)
+ {
+ const struct wined3d_texture *tex = state->textures[i];
const unsigned char idx = prog->np2Fixup_info->idx[i];
- const IWineD3DBaseTextureImpl *tex = stateBlock->state.textures[i];
GLfloat *tex_dim = &np2fixup_constants[(idx >> 1) * 4];
if (!tex)
@@ -717,10 +714,15 @@ static void shader_glsl_load_np2fixup_constants(
continue;
}
- if (idx % 2) {
- tex_dim[2] = tex->baseTexture.pow2Matrix[0]; tex_dim[3] = tex->baseTexture.pow2Matrix[5];
- } else {
- tex_dim[0] = tex->baseTexture.pow2Matrix[0]; tex_dim[1] = tex->baseTexture.pow2Matrix[5];
+ if (idx % 2)
+ {
+ tex_dim[2] = tex->pow2_matrix[0];
+ tex_dim[3] = tex->pow2_matrix[5];
+ }
+ else
+ {
+ tex_dim[0] = tex->pow2_matrix[0];
+ tex_dim[1] = tex->pow2_matrix[5];
}
}
@@ -736,9 +738,10 @@ static void shader_glsl_load_constants(const struct wined3d_context *context,
char usePixelShader, char useVertexShader)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
- IWineD3DDeviceImpl *device = context->swapchain->device;
- IWineD3DStateBlockImpl* stateBlock = device->stateBlock;
+ struct wined3d_device *device = context->swapchain->device;
+ struct wined3d_stateblock *stateBlock = device->stateBlock;
struct shader_glsl_priv *priv = device->shader_priv;
+ float position_fixup[4];
GLhandleARB programId;
struct glsl_shader_prog_link *prog = priv->glsl_program;
@@ -754,7 +757,7 @@ static void shader_glsl_load_constants(const struct wined3d_context *context,
if (useVertexShader)
{
- IWineD3DBaseShaderImpl *vshader = (IWineD3DBaseShaderImpl *)stateBlock->state.vertex_shader;
+ const struct wined3d_shader *vshader = stateBlock->state.vertex_shader;
/* Load DirectX 9 float constants/uniforms for vertex shader */
shader_glsl_load_constantsF(vshader, gl_info, stateBlock->state.vs_consts_f,
@@ -762,20 +765,21 @@ static void shader_glsl_load_constants(const struct wined3d_context *context,
/* Load DirectX 9 integer constants/uniforms for vertex shader */
shader_glsl_load_constantsI(vshader, gl_info, prog->vuniformI_locations, stateBlock->state.vs_consts_i,
- stateBlock->changed.vertexShaderConstantsI & vshader->baseShader.reg_maps.integer_constants);
+ stateBlock->changed.vertexShaderConstantsI & vshader->reg_maps.integer_constants);
/* Load DirectX 9 boolean constants/uniforms for vertex shader */
shader_glsl_load_constantsB(vshader, gl_info, programId, stateBlock->state.vs_consts_b,
- stateBlock->changed.vertexShaderConstantsB & vshader->baseShader.reg_maps.boolean_constants);
+ stateBlock->changed.vertexShaderConstantsB & vshader->reg_maps.boolean_constants);
/* Upload the position fixup params */
- GL_EXTCALL(glUniform4fvARB(prog->posFixup_location, 1, &device->posFixup[0]));
+ shader_get_position_fixup(context, &stateBlock->state, position_fixup);
+ GL_EXTCALL(glUniform4fvARB(prog->posFixup_location, 1, position_fixup));
checkGLcall("glUniform4fvARB");
}
if (usePixelShader)
{
- IWineD3DBaseShaderImpl *pshader = (IWineD3DBaseShaderImpl *)stateBlock->state.pixel_shader;
+ const struct wined3d_shader *pshader = stateBlock->state.pixel_shader;
/* Load DirectX 9 float constants/uniforms for pixel shader */
shader_glsl_load_constantsF(pshader, gl_info, stateBlock->state.ps_consts_f,
@@ -783,11 +787,11 @@ static void shader_glsl_load_constants(const struct wined3d_context *context,
/* Load DirectX 9 integer constants/uniforms for pixel shader */
shader_glsl_load_constantsI(pshader, gl_info, prog->puniformI_locations, stateBlock->state.ps_consts_i,
- stateBlock->changed.pixelShaderConstantsI & pshader->baseShader.reg_maps.integer_constants);
+ stateBlock->changed.pixelShaderConstantsI & pshader->reg_maps.integer_constants);
/* Load DirectX 9 boolean constants/uniforms for pixel shader */
shader_glsl_load_constantsB(pshader, gl_info, programId, stateBlock->state.ps_consts_b,
- stateBlock->changed.pixelShaderConstantsB & pshader->baseShader.reg_maps.boolean_constants);
+ stateBlock->changed.pixelShaderConstantsB & pshader->reg_maps.boolean_constants);
/* Upload the environment bump map matrix if needed. The needsbumpmat member specifies the texture stage to load the matrix from.
* It can't be 0 for a valid texbem instruction.
@@ -816,7 +820,8 @@ static void shader_glsl_load_constants(const struct wined3d_context *context,
}
}
- if(((IWineD3DPixelShaderImpl *) pshader)->vpos_uniform) {
+ if (pshader->u.ps.vpos_uniform)
+ {
float correction_params[4];
if (context->render_offscreen)
@@ -825,7 +830,7 @@ static void shader_glsl_load_constants(const struct wined3d_context *context,
correction_params[1] = 1.0f;
} else {
/* position is window relative, not viewport relative */
- correction_params[0] = context->current_rt->currentDesc.Height;
+ correction_params[0] = (float) context->current_rt->resource.height;
correction_params[1] = -1.0f;
}
GL_EXTCALL(glUniform4fvARB(prog->ycorrection_location, 1, correction_params));
@@ -867,32 +872,30 @@ static inline void update_heap_entry(struct constant_heap *heap, unsigned int id
positions[idx] = heap_idx;
}
-static void shader_glsl_update_float_vertex_constants(IWineD3DDevice *iface, UINT start, UINT count)
+static void shader_glsl_update_float_vertex_constants(struct wined3d_device *device, UINT start, UINT count)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- struct shader_glsl_priv *priv = This->shader_priv;
+ struct shader_glsl_priv *priv = device->shader_priv;
struct constant_heap *heap = &priv->vconst_heap;
UINT i;
for (i = start; i < count + start; ++i)
{
- if (!This->stateBlock->changed.vertexShaderConstantsF[i])
+ if (!device->stateBlock->changed.vertexShaderConstantsF[i])
update_heap_entry(heap, i, heap->size++, priv->next_constant_version);
else
update_heap_entry(heap, i, heap->positions[i], priv->next_constant_version);
}
}
-static void shader_glsl_update_float_pixel_constants(IWineD3DDevice *iface, UINT start, UINT count)
+static void shader_glsl_update_float_pixel_constants(struct wined3d_device *device, UINT start, UINT count)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- struct shader_glsl_priv *priv = This->shader_priv;
+ struct shader_glsl_priv *priv = device->shader_priv;
struct constant_heap *heap = &priv->pconst_heap;
UINT i;
for (i = start; i < count + start; ++i)
{
- if (!This->stateBlock->changed.pixelShaderConstantsF[i])
+ if (!device->stateBlock->changed.pixelShaderConstantsF[i])
update_heap_entry(heap, i, heap->size++, priv->next_constant_version);
else
update_heap_entry(heap, i, heap->positions[i], priv->next_constant_version);
@@ -912,14 +915,13 @@ static unsigned int vec4_varyings(DWORD shader_major, const struct wined3d_gl_in
/** Generate the variable & register declarations for the GLSL output target */
static void shader_generate_glsl_declarations(const struct wined3d_context *context,
- struct wined3d_shader_buffer *buffer, IWineD3DBaseShader *iface,
- const shader_reg_maps *reg_maps, struct shader_glsl_ctx_priv *ctx_priv)
+ struct wined3d_shader_buffer *buffer, struct wined3d_shader *shader,
+ const struct wined3d_shader_reg_maps *reg_maps, struct shader_glsl_ctx_priv *ctx_priv)
{
- IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device;
- const struct wined3d_state *state = &device->stateBlock->state;
+ const struct wined3d_state *state = &shader->device->stateBlock->state;
const struct ps_compile_args *ps_args = ctx_priv->cur_ps_args;
const struct wined3d_gl_info *gl_info = context->gl_info;
+ const struct wined3d_fb_state *fb = &shader->device->fb;
unsigned int i, extra_constants_needed = 0;
const local_constant *lconst;
DWORD map;
@@ -935,7 +937,8 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
}
/* Declare the constants (aka uniforms) */
- if (This->baseShader.limits.constant_float > 0) {
+ if (shader->limits.constant_float > 0)
+ {
unsigned max_constantsF;
/* Unless the shader uses indirect addressing, always declare the maximum array size and ignore that we need some
* uniforms privately. E.g. if GL supports 256 uniforms, and we need 2 for the pos fixup and immediate values, still
@@ -957,25 +960,29 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
}
else
{
- if(This->baseShader.reg_maps.usesrelconstF) {
- /* Subtract the other potential uniforms from the max available (bools, ints, and 1 row of projection matrix).
- * Subtract another uniform for immediate values, which have to be loaded via uniform by the driver as well.
- * The shader code only uses 0.5, 2.0, 1.0, 128 and -128 in vertex shader code, so one vec4 should be enough
- * (Unfortunately the Nvidia driver doesn't store 128 and -128 in one float).
+ if (reg_maps->usesrelconstF)
+ {
+ /* Subtract the other potential uniforms from the max
+ * available (bools, ints, and 1 row of projection matrix).
+ * Subtract another uniform for immediate values, which have
+ * to be loaded via uniform by the driver as well. The shader
+ * code only uses 0.5, 2.0, 1.0, 128 and -128 in vertex
+ * shader code, so one vec4 should be enough. (Unfortunately
+ * the Nvidia driver doesn't store 128 and -128 in one float).
*
- * Writing gl_ClipVertex requires one uniform for each clipplane as well.
- */
+ * Writing gl_ClipVertex requires one uniform for each
+ * clipplane as well. */
max_constantsF = gl_info->limits.glsl_vs_float_constants - 3;
if(ctx_priv->cur_vs_args->clip_enabled)
{
max_constantsF -= gl_info->limits.clipplanes;
}
- max_constantsF -= count_bits(This->baseShader.reg_maps.integer_constants);
+ max_constantsF -= count_bits(reg_maps->integer_constants);
/* Strictly speaking a bool only uses one scalar, but the nvidia(Linux) compiler doesn't pack them properly,
* so each scalar requires a full vec4. We could work around this by packing the booleans ourselves, but
* for now take this into account when calculating the number of available constants
*/
- max_constantsF -= count_bits(This->baseShader.reg_maps.boolean_constants);
+ max_constantsF -= count_bits(reg_maps->boolean_constants);
/* Set by driver quirks in directx.c */
max_constantsF -= gl_info->reserved_glsl_constants;
}
@@ -984,18 +991,18 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
max_constantsF = gl_info->limits.glsl_vs_float_constants;
}
}
- max_constantsF = min(This->baseShader.limits.constant_float, max_constantsF);
+ max_constantsF = min(shader->limits.constant_float, max_constantsF);
shader_addline(buffer, "uniform vec4 %cC[%u];\n", prefix, max_constantsF);
}
- /* Always declare the full set of constants, the compiler can remove the unused ones because d3d doesn't(yet)
- * support indirect int and bool constant addressing. This avoids problems if the app uses e.g. i0 and i9.
- */
- if (This->baseShader.limits.constant_int > 0 && This->baseShader.reg_maps.integer_constants)
- shader_addline(buffer, "uniform ivec4 %cI[%u];\n", prefix, This->baseShader.limits.constant_int);
+ /* Always declare the full set of constants, the compiler can remove the
+ * unused ones because d3d doesn't (yet) support indirect int and bool
+ * constant addressing. This avoids problems if the app uses e.g. i0 and i9. */
+ if (shader->limits.constant_int > 0 && reg_maps->integer_constants)
+ shader_addline(buffer, "uniform ivec4 %cI[%u];\n", prefix, shader->limits.constant_int);
- if (This->baseShader.limits.constant_bool > 0 && This->baseShader.reg_maps.boolean_constants)
- shader_addline(buffer, "uniform bool %cB[%u];\n", prefix, This->baseShader.limits.constant_bool);
+ if (shader->limits.constant_bool > 0 && reg_maps->boolean_constants)
+ shader_addline(buffer, "uniform bool %cB[%u];\n", prefix, shader->limits.constant_bool);
if (!pshader)
{
@@ -1029,19 +1036,21 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
}
if (reg_maps->vpos || reg_maps->usesdsy)
{
- if (This->baseShader.limits.constant_float + extra_constants_needed
+ if (shader->limits.constant_float + extra_constants_needed
+ 1 < gl_info->limits.glsl_ps_float_constants)
{
shader_addline(buffer, "uniform vec4 ycorrection;\n");
- ((IWineD3DPixelShaderImpl *) This)->vpos_uniform = 1;
+ shader->u.ps.vpos_uniform = 1;
extra_constants_needed++;
- } else {
+ }
+ else
+ {
/* This happens because we do not have proper tracking of the constant registers that are
* actually used, only the max limit of the shader version
*/
FIXME("Cannot find a free uniform for vpos correction params\n");
shader_addline(buffer, "const vec4 ycorrection = vec4(%f, %f, 0.0, 0.0);\n",
- context->render_offscreen ? 0.0f : device->render_targets[0]->currentDesc.Height,
+ context->render_offscreen ? 0.0f : fb->render_targets[0]->resource.height,
context->render_offscreen ? 1.0f : -1.0f);
}
shader_addline(buffer, "vec4 vpos;\n");
@@ -1049,10 +1058,11 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
}
/* Declare texture samplers */
- for (i = 0; i < This->baseShader.limits.sampler; i++) {
+ for (i = 0; i < shader->limits.sampler; ++i)
+ {
if (reg_maps->sampler_type[i])
{
- IWineD3DBaseTextureImpl *texture;
+ const struct wined3d_texture *texture;
switch (reg_maps->sampler_type[i])
{
@@ -1066,14 +1076,14 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
texture = state->textures[i];
if (pshader && ps_args->shadow & (1 << i))
{
- if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
+ if (texture && texture->target == GL_TEXTURE_RECTANGLE_ARB)
shader_addline(buffer, "uniform sampler2DRectShadow %csampler%u;\n", prefix, i);
else
shader_addline(buffer, "uniform sampler2DShadow %csampler%u;\n", prefix, i);
}
else
{
- if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
+ if (texture && texture->target == GL_TEXTURE_RECTANGLE_ARB)
shader_addline(buffer, "uniform sampler2DRect %csampler%u;\n", prefix, i);
else
shader_addline(buffer, "uniform sampler2D %csampler%u;\n", prefix, i);
@@ -1109,8 +1119,10 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
* samplerNP2Fixup stores texture dimensions and is updated through
* shader_glsl_load_np2fixup_constants when the sampler changes. */
- for (i = 0; i < This->baseShader.limits.sampler; ++i) {
- if (reg_maps->sampler_type[i]) {
+ for (i = 0; i < shader->limits.sampler; ++i)
+ {
+ if (reg_maps->sampler_type[i])
+ {
if (!(ps_args->np2_fixup & (1 << i))) continue;
if (WINED3DSTT_2D != reg_maps->sampler_type[i]) {
@@ -1156,9 +1168,8 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
}
/* Declare output register temporaries */
- if(This->baseShader.limits.packed_output) {
- shader_addline(buffer, "vec4 OUT[%u];\n", This->baseShader.limits.packed_output);
- }
+ if (shader->limits.packed_output)
+ shader_addline(buffer, "vec4 OUT[%u];\n", shader->limits.packed_output);
/* Declare temporary variables */
for (i = 0, map = reg_maps->temporary; map; map >>= 1, ++i)
@@ -1189,8 +1200,10 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
* They can't be hardcoded into the shader text via LC = {x, y, z, w}; because the
* float -> string conversion can cause precision loss.
*/
- if(!This->baseShader.load_local_constsF) {
- LIST_FOR_EACH_ENTRY(lconst, &This->baseShader.constantsF, local_constant, entry) {
+ if (!shader->load_local_constsF)
+ {
+ LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, local_constant, entry)
+ {
shader_addline(buffer, "uniform vec4 %cLC%u;\n", prefix, lconst->idx);
}
}
@@ -1201,7 +1214,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
/* DirectX apps expect integer values, while OpenGL drivers add approximately 0.5. This causes
* off-by-one problems as spotted by the vPos d3d9 visual test. Unfortunately the ATI cards do
* not add exactly 0.5, but rather something like 0.49999999 or 0.50000001, which still causes
- * precision troubles when we just substract 0.5.
+ * precision troubles when we just subtract 0.5.
*
* To deal with that just floor() the position. This will eliminate the fraction on all cards.
*
@@ -1305,9 +1318,10 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
/* oPos, oFog and oPts in D3D */
static const char * const hwrastout_reg_names[] = {"OUT[10]", "OUT[11].x", "OUT[11].y"};
- IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+ struct wined3d_shader *shader = ins->ctx->shader;
+ const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
- char pshader = shader_is_pshader_version(This->baseShader.reg_maps.shader_version.type);
+ char pshader = shader_is_pshader_version(reg_maps->shader_version.type);
*is_color = FALSE;
@@ -1328,10 +1342,10 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
}
/* pixel shaders >= 3.0 */
- if (This->baseShader.reg_maps.shader_version.major >= 3)
+ if (reg_maps->shader_version.major >= 3)
{
- DWORD idx = ((IWineD3DPixelShaderImpl *)This)->input_reg_map[reg->idx];
- unsigned int in_count = vec4_varyings(This->baseShader.reg_maps.shader_version.major, gl_info);
+ DWORD idx = shader->u.ps.input_reg_map[reg->idx];
+ unsigned int in_count = vec4_varyings(reg_maps->shader_version.major, gl_info);
if (reg->rel_addr)
{
@@ -1343,7 +1357,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
* operation there */
if (idx)
{
- if (((IWineD3DPixelShaderImpl *)This)->declared_in_count > in_count)
+ if (shader->u.ps.declared_in_count > in_count)
{
sprintf(register_name,
"((%s + %u) > %d ? (%s + %u) > %d ? gl_SecondaryColor : gl_Color : IN[%s + %u])",
@@ -1357,7 +1371,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
}
else
{
- if (((IWineD3DPixelShaderImpl *)This)->declared_in_count > in_count)
+ if (shader->u.ps.declared_in_count > in_count)
{
sprintf(register_name, "((%s) > %d ? (%s) > %d ? gl_SecondaryColor : gl_Color : IN[%s])",
rel_param.param_str, in_count - 1, rel_param.param_str, in_count,
@@ -1398,7 +1412,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
}
else
{
- if (shader_constant_is_local(This, reg->idx))
+ if (shader_constant_is_local(shader, reg->idx))
sprintf(register_name, "%cLC%u", prefix, reg->idx);
else
sprintf(register_name, "%cC[%u]", prefix, reg->idx);
@@ -1422,7 +1436,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
break;
case WINED3DSPR_LOOP:
- sprintf(register_name, "aL%u", This->baseShader.cur_loop_regno - 1);
+ sprintf(register_name, "aL%u", ins->ctx->loop_state->current_reg - 1);
break;
case WINED3DSPR_SAMPLER:
@@ -2219,13 +2233,13 @@ static void shader_glsl_pow(const struct wined3d_shader_instruction *ins)
if (dst_size > 1)
{
- shader_addline(buffer, "vec%u(pow(abs(%s), %s)));\n",
- dst_size, src0_param.param_str, src1_param.param_str);
+ shader_addline(buffer, "vec%u(%s == 0.0 ? 1.0 : pow(abs(%s), %s)));\n",
+ dst_size, src1_param.param_str, src0_param.param_str, src1_param.param_str);
}
else
{
- shader_addline(buffer, "pow(abs(%s), %s));\n",
- src0_param.param_str, src1_param.param_str);
+ shader_addline(buffer, "%s == 0.0 ? 1.0 : pow(abs(%s), %s));\n",
+ src1_param.param_str, src0_param.param_str, src1_param.param_str);
}
}
@@ -2311,16 +2325,18 @@ static void shader_glsl_nrm(const struct wined3d_shader_instruction *ins)
mask_size = shader_glsl_get_write_mask_size(write_mask);
shader_glsl_add_src_param(ins, &ins->src[0], write_mask, &src_param);
- shader_addline(buffer, "tmp0.x = length(%s);\n", src_param.param_str);
+ shader_addline(buffer, "tmp0.x = dot(%s, %s);\n",
+ src_param.param_str, src_param.param_str);
shader_glsl_append_dst(buffer, ins);
+
if (mask_size > 1)
{
- shader_addline(buffer, "tmp0.x == 0.0 ? vec%u(0.0) : (%s / tmp0.x));\n",
+ shader_addline(buffer, "tmp0.x == 0.0 ? vec%u(0.0) : (%s * inversesqrt(tmp0.x)));\n",
mask_size, src_param.param_str);
}
else
{
- shader_addline(buffer, "tmp0.x == 0.0 ? 0.0 : (%s / tmp0.x));\n",
+ shader_addline(buffer, "tmp0.x == 0.0 ? 0.0 : (%s * inversesqrt(tmp0.x)));\n",
src_param.param_str);
}
}
@@ -2825,8 +2841,9 @@ static void shader_glsl_sgn(const struct wined3d_shader_instruction *ins)
/* FIXME: I don't think nested loops will work correctly this way. */
static void shader_glsl_loop(const struct wined3d_shader_instruction *ins)
{
+ struct wined3d_shader_loop_state *loop_state = ins->ctx->loop_state;
glsl_src_param_t src1_param;
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+ struct wined3d_shader *shader = ins->ctx->shader;
const DWORD *control_values = NULL;
const local_constant *constant;
@@ -2839,7 +2856,8 @@ static void shader_glsl_loop(const struct wined3d_shader_instruction *ins)
*/
if (ins->src[1].reg.type == WINED3DSPR_CONSTINT)
{
- LIST_FOR_EACH_ENTRY(constant, &shader->baseShader.constantsI, local_constant, entry) {
+ LIST_FOR_EACH_ENTRY(constant, &shader->constantsI, local_constant, entry)
+ {
if (constant->idx == ins->src[1].reg.idx)
{
control_values = constant->value;
@@ -2858,57 +2876,58 @@ static void shader_glsl_loop(const struct wined3d_shader_instruction *ins)
if (loop_control.step > 0)
{
shader_addline(ins->ctx->buffer, "for (aL%u = %u; aL%u < (%u * %d + %u); aL%u += %d) {\n",
- shader->baseShader.cur_loop_depth, loop_control.start,
- shader->baseShader.cur_loop_depth, loop_control.count, loop_control.step, loop_control.start,
- shader->baseShader.cur_loop_depth, loop_control.step);
+ loop_state->current_depth, loop_control.start,
+ loop_state->current_depth, loop_control.count, loop_control.step, loop_control.start,
+ loop_state->current_depth, loop_control.step);
}
else if (loop_control.step < 0)
{
shader_addline(ins->ctx->buffer, "for (aL%u = %u; aL%u > (%u * %d + %u); aL%u += %d) {\n",
- shader->baseShader.cur_loop_depth, loop_control.start,
- shader->baseShader.cur_loop_depth, loop_control.count, loop_control.step, loop_control.start,
- shader->baseShader.cur_loop_depth, loop_control.step);
+ loop_state->current_depth, loop_control.start,
+ loop_state->current_depth, loop_control.count, loop_control.step, loop_control.start,
+ loop_state->current_depth, loop_control.step);
}
else
{
shader_addline(ins->ctx->buffer, "for (aL%u = %u, tmpInt%u = 0; tmpInt%u < %u; tmpInt%u++) {\n",
- shader->baseShader.cur_loop_depth, loop_control.start, shader->baseShader.cur_loop_depth,
- shader->baseShader.cur_loop_depth, loop_control.count,
- shader->baseShader.cur_loop_depth);
+ loop_state->current_depth, loop_control.start, loop_state->current_depth,
+ loop_state->current_depth, loop_control.count,
+ loop_state->current_depth);
}
} else {
shader_addline(ins->ctx->buffer,
"for (tmpInt%u = 0, aL%u = %s.y; tmpInt%u < %s.x; tmpInt%u++, aL%u += %s.z) {\n",
- shader->baseShader.cur_loop_depth, shader->baseShader.cur_loop_regno,
- src1_param.reg_name, shader->baseShader.cur_loop_depth, src1_param.reg_name,
- shader->baseShader.cur_loop_depth, shader->baseShader.cur_loop_regno, src1_param.reg_name);
+ loop_state->current_depth, loop_state->current_reg,
+ src1_param.reg_name, loop_state->current_depth, src1_param.reg_name,
+ loop_state->current_depth, loop_state->current_reg, src1_param.reg_name);
}
- shader->baseShader.cur_loop_depth++;
- shader->baseShader.cur_loop_regno++;
+ ++loop_state->current_depth;
+ ++loop_state->current_reg;
}
static void shader_glsl_end(const struct wined3d_shader_instruction *ins)
{
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+ struct wined3d_shader_loop_state *loop_state = ins->ctx->loop_state;
shader_addline(ins->ctx->buffer, "}\n");
if (ins->handler_idx == WINED3DSIH_ENDLOOP)
{
- shader->baseShader.cur_loop_depth--;
- shader->baseShader.cur_loop_regno--;
+ --loop_state->current_depth;
+ --loop_state->current_reg;
}
if (ins->handler_idx == WINED3DSIH_ENDREP)
{
- shader->baseShader.cur_loop_depth--;
+ --loop_state->current_depth;
}
}
static void shader_glsl_rep(const struct wined3d_shader_instruction *ins)
{
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
+ struct wined3d_shader *shader = ins->ctx->shader;
+ struct wined3d_shader_loop_state *loop_state = ins->ctx->loop_state;
glsl_src_param_t src0_param;
const DWORD *control_values = NULL;
const local_constant *constant;
@@ -2916,7 +2935,7 @@ static void shader_glsl_rep(const struct wined3d_shader_instruction *ins)
/* Try to hardcode local values to help the GLSL compiler to unroll and optimize the loop */
if (ins->src[0].reg.type == WINED3DSPR_CONSTINT)
{
- LIST_FOR_EACH_ENTRY(constant, &shader->baseShader.constantsI, local_constant, entry)
+ LIST_FOR_EACH_ENTRY(constant, &shader->constantsI, local_constant, entry)
{
if (constant->idx == ins->src[0].reg.idx)
{
@@ -2926,17 +2945,21 @@ static void shader_glsl_rep(const struct wined3d_shader_instruction *ins)
}
}
- if(control_values) {
+ if (control_values)
+ {
shader_addline(ins->ctx->buffer, "for (tmpInt%d = 0; tmpInt%d < %d; tmpInt%d++) {\n",
- shader->baseShader.cur_loop_depth, shader->baseShader.cur_loop_depth,
- control_values[0], shader->baseShader.cur_loop_depth);
- } else {
+ loop_state->current_depth, loop_state->current_depth,
+ control_values[0], loop_state->current_depth);
+ }
+ else
+ {
shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &src0_param);
shader_addline(ins->ctx->buffer, "for (tmpInt%d = 0; tmpInt%d < %s; tmpInt%d++) {\n",
- shader->baseShader.cur_loop_depth, shader->baseShader.cur_loop_depth,
- src0_param.param_str, shader->baseShader.cur_loop_depth);
+ loop_state->current_depth, loop_state->current_depth,
+ src0_param.param_str, loop_state->current_depth);
}
- shader->baseShader.cur_loop_depth++;
+
+ ++loop_state->current_depth;
}
static void shader_glsl_if(const struct wined3d_shader_instruction *ins)
@@ -3013,12 +3036,12 @@ static void shader_glsl_ret(const struct wined3d_shader_instruction *ins)
********************************************/
static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
{
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
- IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *)shader->baseShader.device;
+ struct wined3d_shader *shader = ins->ctx->shader;
+ struct wined3d_device *device = shader->device;
DWORD shader_version = WINED3D_SHADER_VERSION(ins->ctx->reg_maps->shader_version.major,
ins->ctx->reg_maps->shader_version.minor);
glsl_sample_function_t sample_function;
- IWineD3DBaseTextureImpl *texture;
+ const struct wined3d_texture *texture;
DWORD sample_flags = 0;
DWORD sampler_idx;
DWORD mask = 0, swizzle;
@@ -3027,7 +3050,7 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
* 2.0+: Use provided sampler source. */
if (shader_version < WINED3D_SHADER_VERSION(2,0)) sampler_idx = ins->dst[0].reg.idx;
else sampler_idx = ins->src[1].reg.idx;
- texture = deviceImpl->stateBlock->state.textures[sampler_idx];
+ texture = device->stateBlock->state.textures[sampler_idx];
if (shader_version < WINED3D_SHADER_VERSION(1,4))
{
@@ -3068,7 +3091,7 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
}
}
- if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
+ if (texture && texture->target == GL_TEXTURE_RECTANGLE_ARB)
sample_flags |= WINED3D_GLSL_SAMPLE_RECT;
shader_glsl_get_sample_function(ins->ctx, sampler_idx, sample_flags, &sample_function);
@@ -3103,15 +3126,15 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins)
{
- IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
- IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
+ struct wined3d_shader *shader = ins->ctx->shader;
+ struct wined3d_device *device = shader->device;
const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
glsl_sample_function_t sample_function;
glsl_src_param_t coord_param, dx_param, dy_param;
DWORD sample_flags = WINED3D_GLSL_SAMPLE_GRAD;
DWORD sampler_idx;
DWORD swizzle = ins->src[1].swizzle;
- IWineD3DBaseTextureImpl *texture;
+ const struct wined3d_texture *texture;
if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD] && !gl_info->supported[EXT_GPU_SHADER4])
{
@@ -3121,8 +3144,8 @@ static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins)
}
sampler_idx = ins->src[1].reg.idx;
- texture = deviceImpl->stateBlock->state.textures[sampler_idx];
- if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
+ texture = device->stateBlock->state.textures[sampler_idx];
+ if (texture && texture->target == GL_TEXTURE_RECTANGLE_ARB)
sample_flags |= WINED3D_GLSL_SAMPLE_RECT;
shader_glsl_get_sample_function(ins->ctx, sampler_idx, sample_flags, &sample_function);
@@ -3136,19 +3159,19 @@ static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins)
static void shader_glsl_texldl(const struct wined3d_shader_instruction *ins)
{
- IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
- IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
+ struct wined3d_shader *shader = ins->ctx->shader;
+ struct wined3d_device *device = shader->device;
const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
glsl_sample_function_t sample_function;
glsl_src_param_t coord_param, lod_param;
DWORD sample_flags = WINED3D_GLSL_SAMPLE_LOD;
DWORD sampler_idx;
DWORD swizzle = ins->src[1].swizzle;
- IWineD3DBaseTextureImpl *texture;
+ const struct wined3d_texture *texture;
sampler_idx = ins->src[1].reg.idx;
- texture = deviceImpl->stateBlock->state.textures[sampler_idx];
- if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
+ texture = device->stateBlock->state.textures[sampler_idx];
+ if (texture && texture->target == GL_TEXTURE_RECTANGLE_ARB)
sample_flags |= WINED3D_GLSL_SAMPLE_RECT;
shader_glsl_get_sample_function(ins->ctx, sampler_idx, sample_flags, &sample_function);
@@ -3330,16 +3353,15 @@ static void shader_glsl_texm3x2pad(const struct wined3d_shader_instruction *ins)
* Calculate the 1st or 2nd row of a 3-row matrix multiplication. */
static void shader_glsl_texm3x3pad(const struct wined3d_shader_instruction *ins)
{
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
DWORD reg = ins->dst[0].reg.idx;
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
- SHADER_PARSE_STATE* current_state = &shader->baseShader.parse_state;
+ struct wined3d_shader_tex_mx *tex_mx = ins->ctx->tex_mx;
glsl_src_param_t src0_param;
shader_glsl_add_src_param(ins, &ins->src[0], src_mask, &src0_param);
- shader_addline(buffer, "tmp0.%c = dot(T%u.xyz, %s);\n", 'x' + current_state->current_row, reg, src0_param.param_str);
- current_state->texcoord_w[current_state->current_row++] = reg;
+ shader_addline(buffer, "tmp0.%c = dot(T%u.xyz, %s);\n", 'x' + tex_mx->current_row, reg, src0_param.param_str);
+ tex_mx->texcoord_w[tex_mx->current_row++] = reg;
}
static void shader_glsl_texm3x2tex(const struct wined3d_shader_instruction *ins)
@@ -3364,8 +3386,7 @@ static void shader_glsl_texm3x2tex(const struct wined3d_shader_instruction *ins)
static void shader_glsl_texm3x3tex(const struct wined3d_shader_instruction *ins)
{
DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
- SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state;
+ struct wined3d_shader_tex_mx *tex_mx = ins->ctx->tex_mx;
glsl_src_param_t src0_param;
DWORD reg = ins->dst[0].reg.idx;
glsl_sample_function_t sample_function;
@@ -3379,7 +3400,7 @@ static void shader_glsl_texm3x3tex(const struct wined3d_shader_instruction *ins)
/* Sample the texture using the calculated coordinates */
shader_glsl_gen_sample_code(ins, reg, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, "tmp0.xyz");
- current_state->current_row = 0;
+ tex_mx->current_row = 0;
}
/** Process the WINED3DSIO_TEXM3X3 instruction in GLSL
@@ -3387,8 +3408,7 @@ static void shader_glsl_texm3x3tex(const struct wined3d_shader_instruction *ins)
static void shader_glsl_texm3x3(const struct wined3d_shader_instruction *ins)
{
DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
- SHADER_PARSE_STATE *current_state = &shader->baseShader.parse_state;
+ struct wined3d_shader_tex_mx *tex_mx = ins->ctx->tex_mx;
glsl_src_param_t src0_param;
char dst_mask[6];
DWORD reg = ins->dst[0].reg.idx;
@@ -3399,19 +3419,18 @@ static void shader_glsl_texm3x3(const struct wined3d_shader_instruction *ins)
shader_glsl_get_write_mask(&ins->dst[0], dst_mask);
shader_addline(ins->ctx->buffer, "vec4(tmp0.xy, dot(T%u.xyz, %s), 1.0)%s);\n", reg, src0_param.param_str, dst_mask);
- current_state->current_row = 0;
+ tex_mx->current_row = 0;
}
/* Process the WINED3DSIO_TEXM3X3SPEC instruction in GLSL
* Perform the final texture lookup based on the previous 2 3x3 matrix multiplies */
static void shader_glsl_texm3x3spec(const struct wined3d_shader_instruction *ins)
{
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
DWORD reg = ins->dst[0].reg.idx;
glsl_src_param_t src0_param;
glsl_src_param_t src1_param;
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
- SHADER_PARSE_STATE* current_state = &shader->baseShader.parse_state;
+ struct wined3d_shader_tex_mx *tex_mx = ins->ctx->tex_mx;
DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
glsl_sample_function_t sample_function;
@@ -3429,17 +3448,16 @@ static void shader_glsl_texm3x3spec(const struct wined3d_shader_instruction *ins
/* Sample the texture */
shader_glsl_gen_sample_code(ins, reg, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, "tmp0.xyz");
- current_state->current_row = 0;
+ tex_mx->current_row = 0;
}
/* Process the WINED3DSIO_TEXM3X3VSPEC instruction in GLSL
* Perform the final texture lookup based on the previous 2 3x3 matrix multiplies */
static void shader_glsl_texm3x3vspec(const struct wined3d_shader_instruction *ins)
{
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
DWORD reg = ins->dst[0].reg.idx;
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
- SHADER_PARSE_STATE* current_state = &shader->baseShader.parse_state;
+ struct wined3d_shader_tex_mx *tex_mx = ins->ctx->tex_mx;
glsl_src_param_t src0_param;
DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
glsl_sample_function_t sample_function;
@@ -3451,7 +3469,7 @@ static void shader_glsl_texm3x3vspec(const struct wined3d_shader_instruction *in
/* Construct the eye-ray vector from w coordinates */
shader_addline(buffer, "tmp1.xyz = normalize(vec3(gl_TexCoord[%u].w, gl_TexCoord[%u].w, gl_TexCoord[%u].w));\n",
- current_state->texcoord_w[0], current_state->texcoord_w[1], reg);
+ tex_mx->texcoord_w[0], tex_mx->texcoord_w[1], reg);
shader_addline(buffer, "tmp0.xyz = -reflect(tmp1.xyz, normalize(tmp0.xyz));\n");
/* Dependent read, not valid with conditional NP2 */
@@ -3460,7 +3478,7 @@ static void shader_glsl_texm3x3vspec(const struct wined3d_shader_instruction *in
/* Sample the texture using the calculated coordinates */
shader_glsl_gen_sample_code(ins, reg, &sample_function, WINED3DSP_NOSWIZZLE, NULL, NULL, NULL, "tmp0.xyz");
- current_state->current_row = 0;
+ tex_mx->current_row = 0;
}
/** Process the WINED3DSIO_TEXBEM instruction in GLSL.
@@ -3630,13 +3648,13 @@ static void shader_glsl_dp2add(const struct wined3d_shader_instruction *ins)
}
}
-static void shader_glsl_input_pack(IWineD3DPixelShader *iface, struct wined3d_shader_buffer *buffer,
- const struct wined3d_shader_signature_element *input_signature, const struct shader_reg_maps *reg_maps,
+static void shader_glsl_input_pack(const struct wined3d_shader *shader, struct wined3d_shader_buffer *buffer,
+ const struct wined3d_shader_signature_element *input_signature,
+ const struct wined3d_shader_reg_maps *reg_maps,
enum vertexprocessing_mode vertexprocessing)
{
- unsigned int i;
- IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface;
WORD map = reg_maps->input_registers;
+ unsigned int i;
for (i = 0; map; map >>= 1, ++i)
{
@@ -3655,27 +3673,27 @@ static void shader_glsl_input_pack(IWineD3DPixelShader *iface, struct wined3d_sh
{
if (semantic_idx < 8 && vertexprocessing == pretransformed)
shader_addline(buffer, "IN[%u]%s = gl_TexCoord[%u]%s;\n",
- This->input_reg_map[i], reg_mask, semantic_idx, reg_mask);
+ shader->u.ps.input_reg_map[i], reg_mask, semantic_idx, reg_mask);
else
shader_addline(buffer, "IN[%u]%s = vec4(0.0, 0.0, 0.0, 0.0)%s;\n",
- This->input_reg_map[i], reg_mask, reg_mask);
+ shader->u.ps.input_reg_map[i], reg_mask, reg_mask);
}
else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_COLOR))
{
if (!semantic_idx)
shader_addline(buffer, "IN[%u]%s = vec4(gl_Color)%s;\n",
- This->input_reg_map[i], reg_mask, reg_mask);
+ shader->u.ps.input_reg_map[i], reg_mask, reg_mask);
else if (semantic_idx == 1)
shader_addline(buffer, "IN[%u]%s = vec4(gl_SecondaryColor)%s;\n",
- This->input_reg_map[i], reg_mask, reg_mask);
+ shader->u.ps.input_reg_map[i], reg_mask, reg_mask);
else
shader_addline(buffer, "IN[%u]%s = vec4(0.0, 0.0, 0.0, 0.0)%s;\n",
- This->input_reg_map[i], reg_mask, reg_mask);
+ shader->u.ps.input_reg_map[i], reg_mask, reg_mask);
}
else
{
shader_addline(buffer, "IN[%u]%s = vec4(0.0, 0.0, 0.0, 0.0)%s;\n",
- This->input_reg_map[i], reg_mask, reg_mask);
+ shader->u.ps.input_reg_map[i], reg_mask, reg_mask);
}
}
}
@@ -3684,8 +3702,9 @@ static void shader_glsl_input_pack(IWineD3DPixelShader *iface, struct wined3d_sh
* Vertex Shader Specific Code begins here
********************************************/
-static void add_glsl_program_entry(struct shader_glsl_priv *priv, struct glsl_shader_prog_link *entry) {
- glsl_program_key_t key;
+static void add_glsl_program_entry(struct shader_glsl_priv *priv, struct glsl_shader_prog_link *entry)
+{
+ struct glsl_program_key key;
key.vshader = entry->vshader;
key.pshader = entry->pshader;
@@ -3699,10 +3718,11 @@ static void add_glsl_program_entry(struct shader_glsl_priv *priv, struct glsl_sh
}
static struct glsl_shader_prog_link *get_glsl_program_entry(struct shader_glsl_priv *priv,
- IWineD3DVertexShader *vshader, IWineD3DPixelShader *pshader, struct vs_compile_args *vs_args,
- struct ps_compile_args *ps_args) {
+ const struct wined3d_shader *vshader, const struct wined3d_shader *pshader,
+ struct vs_compile_args *vs_args, struct ps_compile_args *ps_args)
+{
struct wine_rb_entry *entry;
- glsl_program_key_t key;
+ struct glsl_program_key key;
key.vshader = vshader;
key.pshader = pshader;
@@ -3717,7 +3737,7 @@ static struct glsl_shader_prog_link *get_glsl_program_entry(struct shader_glsl_p
static void delete_glsl_program_entry(struct shader_glsl_priv *priv, const struct wined3d_gl_info *gl_info,
struct glsl_shader_prog_link *entry)
{
- glsl_program_key_t key;
+ struct glsl_program_key key;
key.vshader = entry->vshader;
key.pshader = entry->pshader;
@@ -3733,9 +3753,12 @@ static void delete_glsl_program_entry(struct shader_glsl_priv *priv, const struc
HeapFree(GetProcessHeap(), 0, entry);
}
-static void handle_ps3_input(struct wined3d_shader_buffer *buffer, const struct wined3d_gl_info *gl_info, const DWORD *map,
- const struct wined3d_shader_signature_element *input_signature, const struct shader_reg_maps *reg_maps_in,
- const struct wined3d_shader_signature_element *output_signature, const struct shader_reg_maps *reg_maps_out)
+static void handle_ps3_input(struct wined3d_shader_buffer *buffer,
+ const struct wined3d_gl_info *gl_info, const DWORD *map,
+ const struct wined3d_shader_signature_element *input_signature,
+ const struct wined3d_shader_reg_maps *reg_maps_in,
+ const struct wined3d_shader_signature_element *output_signature,
+ const struct wined3d_shader_reg_maps *reg_maps_out)
{
unsigned int i, j;
const char *semantic_name_in;
@@ -3789,7 +3812,7 @@ static void handle_ps3_input(struct wined3d_shader_buffer *buffer, const struct
set[in_idx] = mask;
shader_glsl_write_mask_to_str(mask, reg_mask);
- shader_addline(buffer, "%s%s = clamp(OUT[%u]%s, -FLT_MAX, FLT_MAX);\n",
+ shader_addline(buffer, "%s%s = OUT[%u]%s;\n",
destination, reg_mask, j, reg_mask);
}
}
@@ -3823,23 +3846,21 @@ static void handle_ps3_input(struct wined3d_shader_buffer *buffer, const struct
/* GL locking is done by the caller */
static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer *buffer,
- IWineD3DVertexShader *vertexshader, IWineD3DPixelShader *pixelshader, const struct wined3d_gl_info *gl_info)
+ const struct wined3d_shader *vs, const struct wined3d_shader *ps,
+ const struct wined3d_gl_info *gl_info)
{
GLhandleARB ret = 0;
- IWineD3DVertexShaderImpl *vs = (IWineD3DVertexShaderImpl *) vertexshader;
- IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) pixelshader;
- DWORD ps_major = ps ? ps->baseShader.reg_maps.shader_version.major : 0;
+ DWORD ps_major = ps ? ps->reg_maps.shader_version.major : 0;
unsigned int i;
const char *semantic_name;
UINT semantic_idx;
char reg_mask[6];
- const struct wined3d_shader_signature_element *output_signature = vs->baseShader.output_signature;
- WORD map = vs->baseShader.reg_maps.output_registers;
+ const struct wined3d_shader_signature_element *output_signature = vs->output_signature;
+ WORD map = vs->reg_maps.output_registers;
shader_buffer_clear(buffer);
shader_addline(buffer, "#version 120\n");
- shader_addline(buffer, "const float FLT_MAX = 1e38;\n");
if (ps_major < 3)
{
@@ -3859,15 +3880,15 @@ static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer
if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_COLOR))
{
if (!semantic_idx)
- shader_addline(buffer, "gl_FrontColor%s = clamp(OUT[%u]%s, -FLT_MAX, FLT_MAX);\n",
+ shader_addline(buffer, "gl_FrontColor%s = OUT[%u]%s;\n",
reg_mask, i, reg_mask);
else if (semantic_idx == 1)
- shader_addline(buffer, "gl_FrontSecondaryColor%s = clamp(OUT[%u]%s, -FLT_MAX, FLT_MAX);\n",
+ shader_addline(buffer, "gl_FrontSecondaryColor%s = OUT[%u]%s;\n",
reg_mask, i, reg_mask);
}
else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION))
{
- shader_addline(buffer, "gl_Position%s = clamp(OUT[%u]%s, -FLT_MAX, FLT_MAX);\n",
+ shader_addline(buffer, "gl_Position%s = OUT[%u]%s;\n",
reg_mask, i, reg_mask);
}
else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_TEXCOORD))
@@ -3877,7 +3898,7 @@ static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer
if (!(gl_info->quirks & WINED3D_QUIRK_SET_TEXCOORD_W) || ps_major > 0)
write_mask |= WINED3DSP_WRITEMASK_3;
- shader_addline(buffer, "gl_TexCoord[%u]%s = clamp(OUT[%u]%s, -FLT_MAX, FLT_MAX);\n",
+ shader_addline(buffer, "gl_TexCoord[%u]%s = OUT[%u]%s;\n",
semantic_idx, reg_mask, i, reg_mask);
if (!(write_mask & WINED3DSP_WRITEMASK_3))
shader_addline(buffer, "gl_TexCoord[%u].w = 1.0;\n", semantic_idx);
@@ -3885,11 +3906,11 @@ static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer
}
else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE))
{
- shader_addline(buffer, "gl_PointSize = clamp(OUT[%u].%c, -FLT_MAX, FLT_MAX);\n", i, reg_mask[1]);
+ shader_addline(buffer, "gl_PointSize = OUT[%u].%c;\n", i, reg_mask[1]);
}
else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_FOG))
{
- shader_addline(buffer, "gl_FogFragCoord = clamp(OUT[%u].%c, -FLT_MAX, FLT_MAX);\n", i, reg_mask[1]);
+ shader_addline(buffer, "gl_FogFragCoord = OUT[%u].%c;\n", i, reg_mask[1]);
}
}
shader_addline(buffer, "}\n");
@@ -3911,18 +3932,18 @@ static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer
if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION))
{
- shader_addline(buffer, "gl_Position%s = clamp(OUT[%u]%s, -FLT_MAX, FLT_MAX);\n",
+ shader_addline(buffer, "gl_Position%s = OUT[%u]%s;\n",
reg_mask, i, reg_mask);
}
else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE))
{
- shader_addline(buffer, "gl_PointSize = clamp(OUT[%u].%c, -FLT_MAX, FLT_MAX);\n", i, reg_mask[1]);
+ shader_addline(buffer, "gl_PointSize = OUT[%u].%c;\n", i, reg_mask[1]);
}
}
/* Then, fix the pixel shader input */
- handle_ps3_input(buffer, gl_info, ps->input_reg_map, ps->baseShader.input_signature,
- &ps->baseShader.reg_maps, output_signature, &vs->baseShader.reg_maps);
+ handle_ps3_input(buffer, gl_info, ps->u.ps.input_reg_map, ps->input_signature,
+ &ps->reg_maps, output_signature, &vs->reg_maps);
shader_addline(buffer, "}\n");
}
@@ -3935,15 +3956,16 @@ static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer
}
/* GL locking is done by the caller */
-static void hardcode_local_constants(IWineD3DBaseShaderImpl *shader, const struct wined3d_gl_info *gl_info,
- GLhandleARB programId, char prefix)
+static void hardcode_local_constants(const struct wined3d_shader *shader,
+ const struct wined3d_gl_info *gl_info, GLhandleARB programId, char prefix)
{
const local_constant *lconst;
GLint tmp_loc;
const float *value;
char glsl_name[8];
- LIST_FOR_EACH_ENTRY(lconst, &shader->baseShader.constantsF, local_constant, entry) {
+ LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, local_constant, entry)
+ {
value = (const float *)lconst->value;
snprintf(glsl_name, sizeof(glsl_name), "%cLC%u", prefix, lconst->idx);
tmp_loc = GL_EXTCALL(glGetUniformLocationARB(programId, glsl_name));
@@ -3954,12 +3976,12 @@ static void hardcode_local_constants(IWineD3DBaseShaderImpl *shader, const struc
/* GL locking is done by the caller */
static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context,
- struct wined3d_shader_buffer *buffer, IWineD3DPixelShaderImpl *This,
+ struct wined3d_shader_buffer *buffer, struct wined3d_shader *shader,
const struct ps_compile_args *args, struct ps_np2fixup_info *np2fixup_info)
{
- const struct shader_reg_maps *reg_maps = &This->baseShader.reg_maps;
+ const struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
const struct wined3d_gl_info *gl_info = context->gl_info;
- CONST DWORD *function = This->baseShader.function;
+ const DWORD *function = shader->function;
struct shader_glsl_ctx_priv priv_ctx;
/* Create the hw GLSL shader object and assign it as the shader->prgId */
@@ -3988,17 +4010,14 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
}
/* Base Declarations */
- shader_generate_glsl_declarations(context, buffer, (IWineD3DBaseShader *)This, reg_maps, &priv_ctx);
+ shader_generate_glsl_declarations(context, buffer, shader, reg_maps, &priv_ctx);
/* Pack 3.0 inputs */
if (reg_maps->shader_version.major >= 3 && args->vp_mode != vertexshader)
- {
- shader_glsl_input_pack((IWineD3DPixelShader *) This, buffer,
- This->baseShader.input_signature, reg_maps, args->vp_mode);
- }
+ shader_glsl_input_pack(shader, buffer, shader->input_signature, reg_maps, args->vp_mode);
/* Base Shader Body */
- shader_generate_main((IWineD3DBaseShader *)This, buffer, reg_maps, function, &priv_ctx);
+ shader_generate_main(shader, buffer, reg_maps, function, &priv_ctx);
/* Pixel shaders < 2.0 place the resulting color in R0 implicitly */
if (reg_maps->shader_version.major < 2)
@@ -4058,12 +4077,12 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
/* GL locking is done by the caller */
static GLuint shader_glsl_generate_vshader(const struct wined3d_context *context,
- struct wined3d_shader_buffer *buffer, IWineD3DVertexShaderImpl *This,
+ struct wined3d_shader_buffer *buffer, struct wined3d_shader *shader,
const struct vs_compile_args *args)
{
- const struct shader_reg_maps *reg_maps = &This->baseShader.reg_maps;
+ const struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
const struct wined3d_gl_info *gl_info = context->gl_info;
- CONST DWORD *function = This->baseShader.function;
+ const DWORD *function = shader->function;
struct shader_glsl_ctx_priv priv_ctx;
/* Create the hw GLSL shader program and assign it as the shader->prgId */
@@ -4072,18 +4091,16 @@ static GLuint shader_glsl_generate_vshader(const struct wined3d_context *context
shader_addline(buffer, "#version 120\n");
if (gl_info->supported[EXT_GPU_SHADER4])
- {
shader_addline(buffer, "#extension GL_EXT_gpu_shader4 : enable\n");
- }
memset(&priv_ctx, 0, sizeof(priv_ctx));
priv_ctx.cur_vs_args = args;
/* Base Declarations */
- shader_generate_glsl_declarations(context, buffer, (IWineD3DBaseShader *)This, reg_maps, &priv_ctx);
+ shader_generate_glsl_declarations(context, buffer, shader, reg_maps, &priv_ctx);
/* Base Shader Body */
- shader_generate_main((IWineD3DBaseShader*)This, buffer, reg_maps, function, &priv_ctx);
+ shader_generate_main(shader, buffer, reg_maps, function, &priv_ctx);
/* Unpack outputs */
shader_addline(buffer, "order_ps_input(OUT);\n");
@@ -4093,11 +4110,14 @@ static GLuint shader_glsl_generate_vshader(const struct wined3d_context *context
* the fog frag coord is thrown away. If the fog frag coord is used, but not written by
* the shader, it is set to 0.0(fully fogged, since start = 1.0, end = 0.0)
*/
- if(args->fog_src == VS_FOG_Z) {
+ if (args->fog_src == VS_FOG_Z)
shader_addline(buffer, "gl_FogFragCoord = gl_Position.z;\n");
- } else if (!reg_maps->fog) {
+ else if (!reg_maps->fog)
shader_addline(buffer, "gl_FogFragCoord = 0.0;\n");
- }
+
+ /* We always store the clipplanes without y inversion */
+ if (args->clip_enabled)
+ shader_addline(buffer, "gl_ClipVertex = gl_Position;\n");
/* Write the final position.
*
@@ -4108,9 +4128,6 @@ static GLuint shader_glsl_generate_vshader(const struct wined3d_context *context
*/
shader_addline(buffer, "gl_Position.y = gl_Position.y * posFixup.y;\n");
shader_addline(buffer, "gl_Position.xy += posFixup.zw * gl_Position.ww;\n");
- if(args->clip_enabled) {
- shader_addline(buffer, "gl_ClipVertex = gl_Position;\n");
- }
/* Z coord [0;1]->[-1;1] mapping, see comment in transform_projection in state.c
*
@@ -4129,10 +4146,10 @@ static GLuint shader_glsl_generate_vshader(const struct wined3d_context *context
}
static GLhandleARB find_glsl_pshader(const struct wined3d_context *context,
- struct wined3d_shader_buffer *buffer, IWineD3DPixelShaderImpl *shader,
+ struct wined3d_shader_buffer *buffer, struct wined3d_shader *shader,
const struct ps_compile_args *args, const struct ps_np2fixup_info **np2fixup_info)
{
- struct wined3d_state *state = &((IWineD3DDeviceImpl *)shader->baseShader.device)->stateBlock->state;
+ struct wined3d_state *state = &shader->device->stateBlock->state;
UINT i;
DWORD new_size;
struct glsl_ps_compiled_shader *new_array;
@@ -4140,16 +4157,16 @@ static GLhandleARB find_glsl_pshader(const struct wined3d_context *context,
struct ps_np2fixup_info *np2fixup = NULL;
GLhandleARB ret;
- if (!shader->baseShader.backend_data)
+ if (!shader->backend_data)
{
- shader->baseShader.backend_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
- if (!shader->baseShader.backend_data)
+ shader->backend_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
+ if (!shader->backend_data)
{
ERR("Failed to allocate backend data.\n");
return 0;
}
}
- shader_data = shader->baseShader.backend_data;
+ shader_data = shader->backend_data;
/* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
* so a linear search is more performant than a hashmap or a binary search
@@ -4189,7 +4206,7 @@ static GLhandleARB find_glsl_pshader(const struct wined3d_context *context,
memset(&shader_data->gl_shaders[shader_data->num_gl_shaders].np2fixup, 0, sizeof(struct ps_np2fixup_info));
if (args->np2_fixup) np2fixup = &shader_data->gl_shaders[shader_data->num_gl_shaders].np2fixup;
- pixelshader_update_samplers(&shader->baseShader.reg_maps, (IWineD3DBaseTexture **)state->textures);
+ pixelshader_update_samplers(&shader->reg_maps, state->textures);
shader_buffer_clear(buffer);
ret = shader_glsl_generate_pshader(context, buffer, shader, args, np2fixup);
@@ -4207,26 +4224,26 @@ static inline BOOL vs_args_equal(const struct vs_compile_args *stored, const str
}
static GLhandleARB find_glsl_vshader(const struct wined3d_context *context,
- struct wined3d_shader_buffer *buffer, IWineD3DVertexShaderImpl *shader,
+ struct wined3d_shader_buffer *buffer, struct wined3d_shader *shader,
const struct vs_compile_args *args)
{
UINT i;
DWORD new_size;
struct glsl_vs_compiled_shader *new_array;
- DWORD use_map = ((IWineD3DDeviceImpl *)shader->baseShader.device)->strided_streams.use_map;
+ DWORD use_map = shader->device->strided_streams.use_map;
struct glsl_vshader_private *shader_data;
GLhandleARB ret;
- if (!shader->baseShader.backend_data)
+ if (!shader->backend_data)
{
- shader->baseShader.backend_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
- if (!shader->baseShader.backend_data)
+ shader->backend_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
+ if (!shader->backend_data)
{
ERR("Failed to allocate backend data.\n");
return 0;
}
}
- shader_data = shader->baseShader.backend_data;
+ shader_data = shader->backend_data;
/* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
* so a linear search is more performant than a hashmap or a binary search
@@ -4279,11 +4296,11 @@ static GLhandleARB find_glsl_vshader(const struct wined3d_context *context,
/* GL locking is done by the caller */
static void set_glsl_shader_program(const struct wined3d_context *context,
- IWineD3DDeviceImpl *device, BOOL use_ps, BOOL use_vs)
+ struct wined3d_device *device, BOOL use_ps, BOOL use_vs)
{
const struct wined3d_state *state = &device->stateBlock->state;
- IWineD3DVertexShader *vshader = use_vs ? (IWineD3DVertexShader *)state->vertex_shader : NULL;
- IWineD3DPixelShader *pshader = use_ps ? (IWineD3DPixelShader *)state->pixel_shader : NULL;
+ struct wined3d_shader *vshader = use_vs ? state->vertex_shader : NULL;
+ struct wined3d_shader *pshader = use_ps ? state->pixel_shader : NULL;
const struct wined3d_gl_info *gl_info = context->gl_info;
struct shader_glsl_priv *priv = device->shader_priv;
struct glsl_shader_prog_link *entry = NULL;
@@ -4294,11 +4311,12 @@ static void set_glsl_shader_program(const struct wined3d_context *context,
struct ps_compile_args ps_compile_args;
struct vs_compile_args vs_compile_args;
- if (vshader) find_vs_compile_args(state, (IWineD3DVertexShaderImpl *)vshader, &vs_compile_args);
- if (pshader) find_ps_compile_args(state, (IWineD3DPixelShaderImpl *)pshader, &ps_compile_args);
+ if (vshader) find_vs_compile_args(state, vshader, &vs_compile_args);
+ if (pshader) find_ps_compile_args(state, pshader, &ps_compile_args);
entry = get_glsl_program_entry(priv, vshader, pshader, &vs_compile_args, &ps_compile_args);
- if (entry) {
+ if (entry)
+ {
priv->glsl_program = entry;
return;
}
@@ -4325,9 +4343,8 @@ static void set_glsl_shader_program(const struct wined3d_context *context,
/* Attach GLSL vshader */
if (vshader)
{
- GLhandleARB vshader_id = find_glsl_vshader(context, &priv->shader_buffer,
- (IWineD3DVertexShaderImpl *)vshader, &vs_compile_args);
- WORD map = ((IWineD3DBaseShaderImpl *)vshader)->baseShader.reg_maps.input_registers;
+ GLhandleARB vshader_id = find_glsl_vshader(context, &priv->shader_buffer, vshader, &vs_compile_args);
+ WORD map = vshader->reg_maps.input_registers;
char tmp_name[10];
reorder_shader_id = generate_param_reorder_function(&priv->shader_buffer, vshader, pshader, gl_info);
@@ -4361,19 +4378,19 @@ static void set_glsl_shader_program(const struct wined3d_context *context,
}
checkGLcall("glBindAttribLocationARB");
- list_add_head(&((IWineD3DBaseShaderImpl *)vshader)->baseShader.linked_programs, &entry->vshader_entry);
+ list_add_head(&vshader->linked_programs, &entry->vshader_entry);
}
/* Attach GLSL pshader */
if (pshader)
{
GLhandleARB pshader_id = find_glsl_pshader(context, &priv->shader_buffer,
- (IWineD3DPixelShaderImpl *)pshader, &ps_compile_args, &entry->np2Fixup_info);
+ pshader, &ps_compile_args, &entry->np2Fixup_info);
TRACE("Attaching GLSL shader object %u to program %u\n", pshader_id, programId);
GL_EXTCALL(glAttachObjectARB(programId, pshader_id));
checkGLcall("glAttachObjectARB");
- list_add_head(&((IWineD3DBaseShaderImpl *)pshader)->baseShader.linked_programs, &entry->pshader_entry);
+ list_add_head(&pshader->linked_programs, &entry->pshader_entry);
}
/* Link the program */
@@ -4431,9 +4448,8 @@ static void set_glsl_shader_program(const struct wined3d_context *context,
entry->ycorrection_location = GL_EXTCALL(glGetUniformLocationARB(programId, "ycorrection"));
checkGLcall("Find glsl program uniform locations");
- if (pshader
- && ((IWineD3DPixelShaderImpl *)pshader)->baseShader.reg_maps.shader_version.major >= 3
- && ((IWineD3DPixelShaderImpl *)pshader)->declared_in_count > vec4_varyings(3, gl_info))
+ if (pshader && pshader->reg_maps.shader_version.major >= 3
+ && pshader->u.ps.declared_in_count > vec4_varyings(3, gl_info))
{
TRACE("Shader %d needs vertex color clamping disabled\n", programId);
entry->vertex_color_clamp = GL_FALSE;
@@ -4460,14 +4476,10 @@ static void set_glsl_shader_program(const struct wined3d_context *context,
* load them now to have them hardcoded in the GLSL program. This saves some CPU cycles
* later
*/
- if (pshader && !((IWineD3DBaseShaderImpl *)pshader)->baseShader.load_local_constsF)
- {
- hardcode_local_constants((IWineD3DBaseShaderImpl *) pshader, gl_info, programId, 'P');
- }
- if (vshader && !((IWineD3DBaseShaderImpl *)vshader)->baseShader.load_local_constsF)
- {
- hardcode_local_constants((IWineD3DBaseShaderImpl *) vshader, gl_info, programId, 'V');
- }
+ if (pshader && !pshader->load_local_constsF)
+ hardcode_local_constants(pshader, gl_info, programId, 'P');
+ if (vshader && !vshader->load_local_constsF)
+ hardcode_local_constants(vshader, gl_info, programId, 'V');
}
/* GL locking is done by the caller */
@@ -4556,7 +4568,7 @@ static GLhandleARB create_glsl_blt_shader(const struct wined3d_gl_info *gl_info,
if (!blt_pshader)
{
FIXME("tex_type %#x not supported\n", tex_type);
- tex_type = tex_2d;
+ return 0;
}
vshader_id = GL_EXTCALL(glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB));
@@ -4584,7 +4596,7 @@ static GLhandleARB create_glsl_blt_shader(const struct wined3d_gl_info *gl_info,
static void shader_glsl_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
- IWineD3DDeviceImpl *device = context->swapchain->device;
+ struct wined3d_device *device = context->swapchain->device;
struct shader_glsl_priv *priv = device->shader_priv;
GLhandleARB program_id = 0;
GLenum old_vertex_color_clamp, current_vertex_color_clamp;
@@ -4619,18 +4631,16 @@ static void shader_glsl_select(const struct wined3d_context *context, BOOL usePS
* called between selecting the shader and using it, which results in wrong fixup for some frames. */
if (priv->glsl_program && priv->glsl_program->np2Fixup_info)
{
- shader_glsl_load_np2fixup_constants((IWineD3DDevice *)device, usePS, useVS);
+ shader_glsl_load_np2fixup_constants(priv, gl_info, &device->stateBlock->state);
}
}
/* GL locking is done by the caller */
-static void shader_glsl_select_depth_blt(IWineD3DDevice *iface,
+static void shader_glsl_select_depth_blt(void *shader_priv, const struct wined3d_gl_info *gl_info,
enum tex_types tex_type, const SIZE *ds_mask_size)
{
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
BOOL masked = ds_mask_size->cx && ds_mask_size->cy;
- struct shader_glsl_priv *priv = This->shader_priv;
+ struct shader_glsl_priv *priv = shader_priv;
GLhandleARB *blt_program;
GLint loc;
@@ -4655,10 +4665,9 @@ static void shader_glsl_select_depth_blt(IWineD3DDevice *iface,
}
/* GL locking is done by the caller */
-static void shader_glsl_deselect_depth_blt(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
- struct shader_glsl_priv *priv = This->shader_priv;
+static void shader_glsl_deselect_depth_blt(void *shader_priv, const struct wined3d_gl_info *gl_info)
+{
+ struct shader_glsl_priv *priv = shader_priv;
GLhandleARB program_id;
program_id = priv->glsl_program ? priv->glsl_program->programId : 0;
@@ -4668,52 +4677,52 @@ static void shader_glsl_deselect_depth_blt(IWineD3DDevice *iface) {
checkGLcall("glUseProgramObjectARB");
}
-static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
- const struct list *linked_programs;
- IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *) iface;
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)This->baseShader.device;
+static void shader_glsl_destroy(struct wined3d_shader *shader)
+{
+ struct wined3d_device *device = shader->device;
struct shader_glsl_priv *priv = device->shader_priv;
const struct wined3d_gl_info *gl_info;
+ const struct list *linked_programs;
struct wined3d_context *context;
- /* Note: Do not use QueryInterface here to find out which shader type this is because this code
- * can be called from IWineD3DBaseShader::Release
- */
- char pshader = shader_is_pshader_version(This->baseShader.reg_maps.shader_version.type);
+ char pshader = shader_is_pshader_version(shader->reg_maps.shader_version.type);
+
+ if (pshader)
+ {
+ struct glsl_pshader_private *shader_data = shader->backend_data;
- if(pshader) {
- struct glsl_pshader_private *shader_data;
- shader_data = This->baseShader.backend_data;
if (!shader_data || !shader_data->num_gl_shaders)
{
HeapFree(GetProcessHeap(), 0, shader_data);
- This->baseShader.backend_data = NULL;
+ shader->backend_data = NULL;
return;
}
context = context_acquire(device, NULL);
gl_info = context->gl_info;
- if (priv->glsl_program && (IWineD3DBaseShader *)priv->glsl_program->pshader == iface)
+ if (priv->glsl_program && priv->glsl_program->pshader == shader)
{
ENTER_GL();
shader_glsl_select(context, FALSE, FALSE);
LEAVE_GL();
}
- } else {
- struct glsl_vshader_private *shader_data;
- shader_data = This->baseShader.backend_data;
+ }
+ else
+ {
+ struct glsl_vshader_private *shader_data = shader->backend_data;
+
if (!shader_data || !shader_data->num_gl_shaders)
{
HeapFree(GetProcessHeap(), 0, shader_data);
- This->baseShader.backend_data = NULL;
+ shader->backend_data = NULL;
return;
}
context = context_acquire(device, NULL);
gl_info = context->gl_info;
- if (priv->glsl_program && (IWineD3DBaseShader *)priv->glsl_program->vshader == iface)
+ if (priv->glsl_program && priv->glsl_program->vshader == shader)
{
ENTER_GL();
shader_glsl_select(context, FALSE, FALSE);
@@ -4721,7 +4730,7 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
}
}
- linked_programs = &This->baseShader.linked_programs;
+ linked_programs = &shader->linked_programs;
TRACE("Deleting linked programs\n");
if (linked_programs->next) {
@@ -4740,9 +4749,10 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
LEAVE_GL();
}
- if(pshader) {
+ if (pshader)
+ {
+ struct glsl_pshader_private *shader_data = shader->backend_data;
UINT i;
- struct glsl_pshader_private *shader_data = This->baseShader.backend_data;
ENTER_GL();
for(i = 0; i < shader_data->num_gl_shaders; i++) {
@@ -4755,8 +4765,8 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
}
else
{
+ struct glsl_vshader_private *shader_data = shader->backend_data;
UINT i;
- struct glsl_vshader_private *shader_data = This->baseShader.backend_data;
ENTER_GL();
for(i = 0; i < shader_data->num_gl_shaders; i++) {
@@ -4768,15 +4778,15 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders);
}
- HeapFree(GetProcessHeap(), 0, This->baseShader.backend_data);
- This->baseShader.backend_data = NULL;
+ HeapFree(GetProcessHeap(), 0, shader->backend_data);
+ shader->backend_data = NULL;
context_release(context);
}
static int glsl_program_key_compare(const void *key, const struct wine_rb_entry *entry)
{
- const glsl_program_key_t *k = key;
+ const struct glsl_program_key *k = key;
const struct glsl_shader_prog_link *prog = WINE_RB_ENTRY_VALUE(entry,
const struct glsl_shader_prog_link, program_lookup_entry);
int cmp;
@@ -4825,9 +4835,9 @@ static const struct wine_rb_functions wined3d_glsl_program_rb_functions =
glsl_program_key_compare,
};
-static HRESULT shader_glsl_alloc(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
+static HRESULT shader_glsl_alloc(struct wined3d_device *device)
+{
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct shader_glsl_priv *priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct shader_glsl_priv));
SIZE_T stack_size = wined3d_log2i(max(gl_info->limits.glsl_vs_float_constants,
gl_info->limits.glsl_ps_float_constants)) + 1;
@@ -4865,7 +4875,7 @@ static HRESULT shader_glsl_alloc(IWineD3DDevice *iface) {
priv->next_constant_version = 1;
- This->shader_priv = priv;
+ device->shader_priv = priv;
return WINED3D_OK;
fail:
@@ -4878,10 +4888,10 @@ fail:
}
/* Context activation is done by the caller. */
-static void shader_glsl_free(IWineD3DDevice *iface) {
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
- struct shader_glsl_priv *priv = This->shader_priv;
+static void shader_glsl_free(struct wined3d_device *device)
+{
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+ struct shader_glsl_priv *priv = device->shader_priv;
int i;
ENTER_GL();
@@ -4904,51 +4914,49 @@ static void shader_glsl_free(IWineD3DDevice *iface) {
HeapFree(GetProcessHeap(), 0, priv->stack);
shader_buffer_free(&priv->shader_buffer);
- HeapFree(GetProcessHeap(), 0, This->shader_priv);
- This->shader_priv = NULL;
+ HeapFree(GetProcessHeap(), 0, device->shader_priv);
+ device->shader_priv = NULL;
}
-static BOOL shader_glsl_dirty_const(IWineD3DDevice *iface) {
+static BOOL shader_glsl_dirty_const(void)
+{
/* TODO: GL_EXT_bindable_uniform can be used to share constants across shaders */
return FALSE;
}
-static void shader_glsl_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps)
+static void shader_glsl_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *caps)
{
- /* Nvidia Geforce6/7 or Ati R4xx/R5xx cards with GLSL support, support VS 3.0 but older Nvidia/Ati
- * models with GLSL support only support 2.0. In case of nvidia we can detect VS 2.0 support based
- * on the version of NV_vertex_program.
- * For Ati cards there's no way using glsl (it abstracts the lowlevel info away) and also not
- * using ARB_vertex_program. It is safe to assume that when a card supports pixel shader 2.0 it
- * supports vertex shader 2.0 too and the way around. We can detect ps2.0 using the maximum number
- * of native instructions, so use that here. For more info see the pixel shader versioning code below.
- */
- if ((gl_info->supported[NV_VERTEX_PROGRAM2] && !gl_info->supported[NV_VERTEX_PROGRAM3])
- || gl_info->limits.arb_ps_instructions <= 512)
- pCaps->VertexShaderVersion = WINED3DVS_VERSION(2,0);
- else
- pCaps->VertexShaderVersion = WINED3DVS_VERSION(3,0);
- TRACE_(d3d_caps)("Hardware vertex shader version %d.%d enabled (GLSL)\n", (pCaps->VertexShaderVersion >> 8) & 0xff, pCaps->VertexShaderVersion & 0xff);
- pCaps->MaxVertexShaderConst = gl_info->limits.glsl_vs_float_constants;
-
- /* Older DX9-class videocards (GeforceFX / Radeon >9500/X*00) only support pixel shader 2.0/2.0a/2.0b.
- * In OpenGL the extensions related to GLSL abstract lowlevel GL info away which is needed
- * to distinguish between 2.0 and 3.0 (and 2.0a/2.0b). In case of Nvidia we use their fragment
- * program extensions. On other hardware including ATI GL_ARB_fragment_program offers the info
- * in max native instructions. Intel and others also offer the info in this extension but they
- * don't support GLSL (at least on Windows).
+ /* NVIDIA GeForce 6 / 7 or ATI R4xx / R5xx cards with GLSL support
+ * support SM3, but older NVIDIA / ATI models with GLSL support only
+ * support SM2. In case of NVIDIA we can detect SM3 support based on the
+ * version of NV_vertex_program / NV_fragment_program. For other cards we
+ * try to detect SM3 based on the maximum number of native fragment
+ * program instructions. PS2.0 requires at least 96 instructions, 2.0a/b
+ * goes up to 512. Assume that if the number of instructions is 512 or
+ * less we have to do with SM2 hardware. NOTE: SM3 requires 512 or more
+ * instructions but ATI and NVIDIA offer more than that (1024 vs 4096) on
+ * their most basic SM3 hardware.
*
- * PS2.0 requires at least 96 instructions, 2.0a/2.0b go up to 512. Assume that if the number
- * of instructions is 512 or less we have to do with ps2.0 hardware.
- * NOTE: ps3.0 hardware requires 512 or more instructions but ati and nvidia offer 'enough' (1024 vs 4096) on their most basic ps3.0 hardware.
- */
- if ((gl_info->supported[NV_FRAGMENT_PROGRAM] && !gl_info->supported[NV_FRAGMENT_PROGRAM2])
- || gl_info->limits.arb_ps_instructions <= 512)
- pCaps->PixelShaderVersion = WINED3DPS_VERSION(2,0);
+ * ARB_shader_texture_lod is a requirement for SM3 (texldd). Ideally we'd
+ * make this a hard requirement, but the extension is still somewhat new,
+ * and relatively few SM3 shaders actually depend on it. For the moment
+ * just use it to enable SM3 (20110423). */
+ if ((gl_info->supported[NV_VERTEX_PROGRAM3] && gl_info->supported[NV_FRAGMENT_PROGRAM2])
+ || gl_info->limits.arb_ps_instructions > 512
+ || gl_info->supported[ARB_SHADER_TEXTURE_LOD]
+ || gl_info->supported[EXT_GPU_SHADER4])
+ {
+ caps->VertexShaderVersion = WINED3DVS_VERSION(3,0);
+ caps->PixelShaderVersion = WINED3DPS_VERSION(3,0);
+ }
else
- pCaps->PixelShaderVersion = WINED3DPS_VERSION(3,0);
+ {
+ caps->VertexShaderVersion = WINED3DVS_VERSION(2,0);
+ caps->PixelShaderVersion = WINED3DPS_VERSION(2,0);
+ }
- pCaps->MaxPixelShaderConst = gl_info->limits.glsl_ps_float_constants;
+ caps->MaxVertexShaderConst = gl_info->limits.glsl_vs_float_constants;
+ caps->MaxPixelShaderConst = gl_info->limits.glsl_ps_float_constants;
/* FIXME: The following line is card dependent. -8.0 to 8.0 is the
* Direct3D minimum requirement.
@@ -4962,10 +4970,14 @@ static void shader_glsl_get_caps(const struct wined3d_gl_info *gl_info, struct s
* the shader will generate incorrect results too. Unfortunately, GL deliberately doesn't
* offer a way to query this.
*/
- pCaps->PixelShader1xMaxValue = 8.0;
- TRACE_(d3d_caps)("Hardware pixel shader version %d.%d enabled (GLSL)\n", (pCaps->PixelShaderVersion >> 8) & 0xff, pCaps->PixelShaderVersion & 0xff);
+ caps->PixelShader1xMaxValue = 8.0;
- pCaps->VSClipping = TRUE;
+ caps->VSClipping = TRUE;
+
+ TRACE_(d3d_caps)("Hardware vertex shader version %u.%u enabled (GLSL).\n",
+ (caps->VertexShaderVersion >> 8) & 0xff, caps->VertexShaderVersion & 0xff);
+ TRACE_(d3d_caps)("Hardware pixel shader version %u.%u enabled (GLSL).\n",
+ (caps->PixelShaderVersion >> 8) & 0xff, caps->PixelShaderVersion & 0xff);
}
static BOOL shader_glsl_color_fixup_supported(struct color_fixup_desc fixup)
@@ -5006,6 +5018,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
/* WINED3DSIH_DEF */ NULL,
/* WINED3DSIH_DEFB */ NULL,
/* WINED3DSIH_DEFI */ NULL,
+ /* WINED3DSIH_DIV */ NULL,
/* WINED3DSIH_DP2ADD */ shader_glsl_dp2add,
/* WINED3DSIH_DP3 */ shader_glsl_dot,
/* WINED3DSIH_DP4 */ shader_glsl_dot,
@@ -5020,12 +5033,16 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
/* WINED3DSIH_EXP */ shader_glsl_map2gl,
/* WINED3DSIH_EXPP */ shader_glsl_expp,
/* WINED3DSIH_FRC */ shader_glsl_map2gl,
+ /* WINED3DSIH_FTOI */ NULL,
/* WINED3DSIH_IADD */ NULL,
+ /* WINED3DSIH_IEQ */ NULL,
/* WINED3DSIH_IF */ shader_glsl_if,
/* WINED3DSIH_IFC */ shader_glsl_ifc,
/* WINED3DSIH_IGE */ NULL,
/* WINED3DSIH_IMUL */ NULL,
+ /* WINED3DSIH_ITOF */ NULL,
/* WINED3DSIH_LABEL */ shader_glsl_label,
+ /* WINED3DSIH_LD */ NULL,
/* WINED3DSIH_LIT */ shader_glsl_lit,
/* WINED3DSIH_LOG */ shader_glsl_log,
/* WINED3DSIH_LOGP */ shader_glsl_log,
@@ -5052,11 +5069,15 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
/* WINED3DSIH_REP */ shader_glsl_rep,
/* WINED3DSIH_RET */ shader_glsl_ret,
/* WINED3DSIH_RSQ */ shader_glsl_rsq,
+ /* WINED3DSIH_SAMPLE */ NULL,
+ /* WINED3DSIH_SAMPLE_GRAD */ NULL,
+ /* WINED3DSIH_SAMPLE_LOD */ NULL,
/* WINED3DSIH_SETP */ NULL,
/* WINED3DSIH_SGE */ shader_glsl_compare,
/* WINED3DSIH_SGN */ shader_glsl_sgn,
/* WINED3DSIH_SINCOS */ shader_glsl_sincos,
/* WINED3DSIH_SLT */ shader_glsl_compare,
+ /* WINED3DSIH_SQRT */ NULL,
/* WINED3DSIH_SUB */ shader_glsl_arith,
/* WINED3DSIH_TEX */ shader_glsl_tex,
/* WINED3DSIH_TEXBEM */ shader_glsl_texbem,
@@ -5080,6 +5101,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
/* WINED3DSIH_TEXREG2AR */ shader_glsl_texreg2ar,
/* WINED3DSIH_TEXREG2GB */ shader_glsl_texreg2gb,
/* WINED3DSIH_TEXREG2RGB */ shader_glsl_texreg2rgb,
+ /* WINED3DSIH_UTOF */ NULL,
};
static void shader_glsl_handle_instruction(const struct wined3d_shader_instruction *ins) {
@@ -5099,7 +5121,8 @@ static void shader_glsl_handle_instruction(const struct wined3d_shader_instructi
shader_glsl_add_instruction_modifiers(ins);
}
-const shader_backend_t glsl_shader_backend = {
+const struct wined3d_shader_backend_ops glsl_shader_backend =
+{
shader_glsl_handle_instruction,
shader_glsl_select,
shader_glsl_select_depth_blt,
diff --git a/reactos/dll/directx/wine/wined3d/nvidia_texture_shader.c b/reactos/dll/directx/wine/wined3d/nvidia_texture_shader.c
index 00a51f85dfa..f20fc7ac6a7 100644
--- a/reactos/dll/directx/wine/wined3d/nvidia_texture_shader.c
+++ b/reactos/dll/directx/wine/wined3d/nvidia_texture_shader.c
@@ -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
diff --git a/reactos/dll/directx/wine/wined3d/palette.c b/reactos/dll/directx/wine/wined3d/palette.c
index 2b7ce2cfc20..1fcc6ba1c9a 100644
--- a/reactos/dll/directx/wine/wined3d/palette.c
+++ b/reactos/dll/directx/wine/wined3d/palette.c
@@ -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;
+}
diff --git a/reactos/dll/directx/wine/wined3d/query.c b/reactos/dll/directx/wine/wined3d/query.c
index 254efbed825..ca4426f5cc7 100644
--- a/reactos/dll/directx/wine/wined3d/query.c
+++ b/reactos/dll/directx/wine/wined3d/query.c
@@ -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;
+}
diff --git a/reactos/dll/directx/wine/wined3d/resource.c b/reactos/dll/directx/wine/wined3d/resource.c
index c95cf1b8b55..4060bc67861 100644
--- a/reactos/dll/directx/wine/wined3d/resource.c
+++ b/reactos/dll/directx/wine/wined3d/resource.c
@@ -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;
}
diff --git a/reactos/dll/directx/wine/wined3d/shader.c b/reactos/dll/directx/wine/wined3d/shader.c
index bc39b3b2aa8..79a27595f02 100644
--- a/reactos/dll/directx/wine/wined3d/shader.c
+++ b/reactos/dll/directx/wine/wined3d/shader.c
@@ -5,7 +5,7 @@
* Copyright 2005 Oliver Stieber
* Copyright 2006 Ivan Gyurdiev
* Copyright 2007-2008 Stefan Dösinger for CodeWeavers
- * 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
@@ -52,6 +52,7 @@ static const char * const shader_opcode_names[] =
/* WINED3DSIH_DEF */ "def",
/* WINED3DSIH_DEFB */ "defb",
/* WINED3DSIH_DEFI */ "defi",
+ /* WINED3DSIH_DIV */ "div",
/* WINED3DSIH_DP2ADD */ "dp2add",
/* WINED3DSIH_DP3 */ "dp3",
/* WINED3DSIH_DP4 */ "dp4",
@@ -66,12 +67,16 @@ static const char * const shader_opcode_names[] =
/* WINED3DSIH_EXP */ "exp",
/* WINED3DSIH_EXPP */ "expp",
/* WINED3DSIH_FRC */ "frc",
+ /* WINED3DSIH_FTOI */ "ftoi",
/* WINED3DSIH_IADD */ "iadd",
+ /* WINED3DSIH_IEQ */ "ieq",
/* WINED3DSIH_IF */ "if",
/* WINED3DSIH_IFC */ "ifc",
/* WINED3DSIH_IGE */ "ige",
/* WINED3DSIH_IMUL */ "imul",
+ /* WINED3DSIH_ITOF */ "itof",
/* WINED3DSIH_LABEL */ "label",
+ /* WINED3DSIH_LD */ "ld",
/* WINED3DSIH_LIT */ "lit",
/* WINED3DSIH_LOG */ "log",
/* WINED3DSIH_LOGP */ "logp",
@@ -98,11 +103,15 @@ static const char * const shader_opcode_names[] =
/* WINED3DSIH_REP */ "rep",
/* WINED3DSIH_RET */ "ret",
/* WINED3DSIH_RSQ */ "rsq",
+ /* WINED3DSIH_SAMPLE */ "sample",
+ /* WINED3DSIH_SAMPLE_GRAD */ "sample_d",
+ /* WINED3DSIH_SAMPLE_LOD */ "sample_l",
/* WINED3DSIH_SETP */ "setp",
/* WINED3DSIH_SGE */ "sge",
/* WINED3DSIH_SGN */ "sgn",
/* WINED3DSIH_SINCOS */ "sincos",
/* WINED3DSIH_SLT */ "slt",
+ /* WINED3DSIH_SQRT */ "sqrt",
/* WINED3DSIH_SUB */ "sub",
/* WINED3DSIH_TEX */ "texld",
/* WINED3DSIH_TEXBEM */ "texbem",
@@ -126,6 +135,7 @@ static const char * const shader_opcode_names[] =
/* WINED3DSIH_TEXREG2AR */ "texreg2ar",
/* WINED3DSIH_TEXREG2GB */ "texreg2gb",
/* WINED3DSIH_TEXREG2RGB */ "texreg2rgb",
+ /* WINED3DSIH_UTOF */ "utof",
};
static const char * const semantic_names[] =
@@ -288,11 +298,11 @@ int shader_addline(struct wined3d_shader_buffer *buffer, const char *format, ...
return ret;
}
-static void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *device,
+static void shader_init(struct wined3d_shader *shader, struct wined3d_device *device,
void *parent, const struct wined3d_parent_ops *parent_ops)
{
shader->ref = 1;
- shader->device = (IWineD3DDevice *)device;
+ shader->device = device;
shader->parent = parent;
shader->parent_ops = parent_ops;
list_init(&shader->linked_programs);
@@ -338,7 +348,7 @@ static inline void set_bitmap_bit(DWORD *bitmap, DWORD bit)
bitmap[idx] |= (1 << shift);
}
-static void shader_record_register_usage(IWineD3DBaseShaderImpl *shader, struct shader_reg_maps *reg_maps,
+static void shader_record_register_usage(struct wined3d_shader *shader, struct wined3d_shader_reg_maps *reg_maps,
const struct wined3d_shader_register *reg, enum wined3d_shader_type shader_type)
{
switch (reg->type)
@@ -363,12 +373,12 @@ static void shader_record_register_usage(IWineD3DBaseShaderImpl *shader, struct
unsigned int i;
for (i = 0; i < MAX_REG_INPUT; ++i)
{
- ((IWineD3DPixelShaderImpl *)shader)->input_reg_used[i] = TRUE;
+ shader->u.ps.input_reg_used[i] = TRUE;
}
}
else
{
- ((IWineD3DPixelShaderImpl *)shader)->input_reg_used[reg->idx] = TRUE;
+ shader->u.ps.input_reg_used[reg->idx] = TRUE;
}
}
else reg_maps->input_registers |= 1 << reg->idx;
@@ -389,17 +399,8 @@ static void shader_record_register_usage(IWineD3DBaseShaderImpl *shader, struct
case WINED3DSPR_CONST:
if (reg->rel_addr)
{
- if (shader_type != WINED3D_SHADER_TYPE_PIXEL)
- {
- if (reg->idx < ((IWineD3DVertexShaderImpl *)shader)->min_rel_offset)
- {
- ((IWineD3DVertexShaderImpl *)shader)->min_rel_offset = reg->idx;
- }
- if (reg->idx > ((IWineD3DVertexShaderImpl *)shader)->max_rel_offset)
- {
- ((IWineD3DVertexShaderImpl *)shader)->max_rel_offset = reg->idx;
- }
- }
+ if (reg->idx < reg_maps->min_rel_offset) reg_maps->min_rel_offset = reg->idx;
+ if (reg->idx > reg_maps->max_rel_offset) reg_maps->max_rel_offset = reg->idx;
reg_maps->usesrelconstF = TRUE;
}
else
@@ -417,7 +418,7 @@ static void shader_record_register_usage(IWineD3DBaseShaderImpl *shader, struct
break;
case WINED3DSPR_COLOROUT:
- reg_maps->highest_render_target = max(reg_maps->highest_render_target, reg->idx);
+ reg_maps->rt_mask |= (1 << reg->idx);
break;
default:
@@ -447,24 +448,17 @@ static unsigned int get_instr_extra_regcount(enum WINED3D_SHADER_INSTRUCTION_HAN
}
/* Note that this does not count the loop register as an address register. */
-static HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe,
- struct shader_reg_maps *reg_maps, struct wined3d_shader_signature_element *input_signature,
+static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const struct wined3d_shader_frontend *fe,
+ struct wined3d_shader_reg_maps *reg_maps, struct wined3d_shader_signature_element *input_signature,
struct wined3d_shader_signature_element *output_signature, const DWORD *byte_code, DWORD constf_size)
{
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)iface;
unsigned int cur_loop_depth = 0, max_loop_depth = 0;
- void *fe_data = shader->baseShader.frontend_data;
+ void *fe_data = shader->frontend_data;
struct wined3d_shader_version shader_version;
const DWORD *ptr = byte_code;
memset(reg_maps, 0, sizeof(*reg_maps));
-
- /* get_registers_used() is called on every compile on some 1.x shaders,
- * which can result in stacking up a collection of local constants.
- * Delete the old constants if existing. */
- shader_delete_constant_list(&shader->baseShader.constantsF);
- shader_delete_constant_list(&shader->baseShader.constantsB);
- shader_delete_constant_list(&shader->baseShader.constantsI);
+ reg_maps->min_rel_offset = ~0U;
fe->shader_read_header(fe_data, &ptr, &shader_version);
reg_maps->shader_version = shader_version;
@@ -559,7 +553,7 @@ static HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct
else if (value[3] > 1.0f) value[3] = 1.0f;
}
- list_add_head(&shader->baseShader.constantsF, &lconst->entry);
+ list_add_head(&shader->constantsF, &lconst->entry);
}
else if (ins.handler_idx == WINED3DSIH_DEFI)
{
@@ -575,7 +569,7 @@ static HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct
memcpy(lconst->value, ptr, 4 * sizeof(DWORD));
ptr += 4;
- list_add_head(&shader->baseShader.constantsI, &lconst->entry);
+ list_add_head(&shader->constantsI, &lconst->entry);
reg_maps->local_int_consts |= (1 << dst.reg.idx);
}
else if (ins.handler_idx == WINED3DSIH_DEFB)
@@ -592,7 +586,7 @@ static HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct
memcpy(lconst->value, ptr, sizeof(DWORD));
++ptr;
- list_add_head(&shader->baseShader.constantsB, &lconst->entry);
+ list_add_head(&shader->constantsB, &lconst->entry);
reg_maps->local_bool_consts |= (1 << dst.reg.idx);
}
/* If there's a loop in the shader. */
@@ -634,7 +628,7 @@ static HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct
else
{
BOOL color0_mov = FALSE;
- int i, limit;
+ unsigned int i, limit;
/* This will loop over all the registers and try to
* make a bitmask of the ones we're interested in.
@@ -722,19 +716,16 @@ static HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct
if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
{
- IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)shader;
-
if (dst_param.reg.type == WINED3DSPR_COLOROUT && !dst_param.reg.idx)
{
- /* Many 2.0 and 3.0 pixel shaders end with a MOV from a temp register to
- * COLOROUT 0. If we know this in advance, the ARB shader backend can skip
- * the mov and perform the sRGB write correction from the source register.
- *
- * However, if the mov is only partial, we can't do this, and if the write
- * comes from an instruction other than MOV it is hard to do as well. If
- * COLOROUT 0 is overwritten partially later, the marker is dropped again. */
-
- ps->color0_mov = FALSE;
+ /* Many 2.0 and 3.0 pixel shaders end with a MOV from a temp register to
+ * COLOROUT 0. If we know this in advance, the ARB shader backend can skip
+ * the mov and perform the sRGB write correction from the source register.
+ *
+ * However, if the mov is only partial, we can't do this, and if the write
+ * comes from an instruction other than MOV it is hard to do as well. If
+ * COLOROUT 0 is overwritten partially later, the marker is dropped again. */
+ shader->u.ps.color0_mov = FALSE;
if (ins.handler_idx == WINED3DSIH_MOV
&& dst_param.write_mask == WINED3DSP_WRITEMASK_ALL)
{
@@ -745,9 +736,10 @@ static HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct
/* Also drop the MOV marker if the source register is overwritten prior to the shader
* end
*/
- else if (dst_param.reg.type == WINED3DSPR_TEMP && dst_param.reg.idx == ps->color0_reg)
+ else if (dst_param.reg.type == WINED3DSPR_TEMP
+ && dst_param.reg.idx == shader->u.ps.color0_reg)
{
- ps->color0_mov = FALSE;
+ shader->u.ps.color0_mov = FALSE;
}
}
@@ -796,7 +788,7 @@ static HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct
else if (ins.handler_idx == WINED3DSIH_MOVA) reg_maps->usesmova = 1;
else if (ins.handler_idx == WINED3DSIH_IFC) reg_maps->usesifc = 1;
else if (ins.handler_idx == WINED3DSIH_CALL) reg_maps->usescall = 1;
- else if (ins.handler_idx == WINED3DSIH_RCP) reg_maps->usesrcp = 1;
+ else if (ins.handler_idx == WINED3DSIH_POW) reg_maps->usespow = 1;
limit = ins.src_count + (ins.predicate ? 1 : 0);
for (i = 0; i < limit; ++i)
@@ -817,12 +809,11 @@ static HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct
if (color0_mov)
{
- IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)shader;
if (src_param.reg.type == WINED3DSPR_TEMP
&& src_param.swizzle == WINED3DSP_NOSWIZZLE)
{
- ps->color0_mov = TRUE;
- ps->color0_reg = src_param.reg.idx;
+ shader->u.ps.color0_mov = TRUE;
+ shader->u.ps.color0_reg = src_param.reg.idx;
}
}
}
@@ -830,12 +821,17 @@ static HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct
}
reg_maps->loop_depth = max_loop_depth;
- shader->baseShader.functionLength = ((const char *)ptr - (const char *)byte_code);
+ /* PS before 2.0 don't have explicit color outputs. Instead the value of
+ * R0 is written to the render target. */
+ if (shader_version.major < 2 && shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
+ reg_maps->rt_mask |= (1 << 0);
+
+ shader->functionLength = ((const char *)ptr - (const char *)byte_code);
return WINED3D_OK;
}
-unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max)
+unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps *reg_maps, unsigned int max)
{
DWORD map = 1 << max;
map |= map - 1;
@@ -1023,6 +1019,10 @@ static void shader_dump_register(const struct wined3d_shader_register *reg,
TRACE("null");
break;
+ case WINED3DSPR_RESOURCE:
+ TRACE("t");
+ break;
+
default:
TRACE("unhandled_rtype(%#x)", reg->type);
break;
@@ -1164,34 +1164,40 @@ void shader_dump_src_param(const struct wined3d_shader_src_param *param,
/* Shared code in order to generate the bulk of the shader string.
* NOTE: A description of how to parse tokens can be found on MSDN. */
-void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer,
- const shader_reg_maps *reg_maps, const DWORD *byte_code, void *backend_ctx)
+void shader_generate_main(struct wined3d_shader *shader, struct wined3d_shader_buffer *buffer,
+ const struct wined3d_shader_reg_maps *reg_maps, const DWORD *byte_code, void *backend_ctx)
{
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)iface;
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)shader->baseShader.device;
- const struct wined3d_shader_frontend *fe = shader->baseShader.frontend;
- void *fe_data = shader->baseShader.frontend_data;
+ struct wined3d_device *device = shader->device;
+ const struct wined3d_shader_frontend *fe = shader->frontend;
+ void *fe_data = shader->frontend_data;
struct wined3d_shader_src_param dst_rel_addr[2];
struct wined3d_shader_src_param src_rel_addr[4];
struct wined3d_shader_dst_param dst_param[2];
struct wined3d_shader_src_param src_param[4];
struct wined3d_shader_version shader_version;
+ struct wined3d_shader_loop_state loop_state;
struct wined3d_shader_instruction ins;
+ struct wined3d_shader_tex_mx tex_mx;
struct wined3d_shader_context ctx;
const DWORD *ptr = byte_code;
DWORD i;
/* Initialize current parsing state. */
- ctx.shader = iface;
+ tex_mx.current_row = 0;
+ loop_state.current_depth = 0;
+ loop_state.current_reg = 0;
+
+ ctx.shader = shader;
ctx.gl_info = &device->adapter->gl_info;
ctx.reg_maps = reg_maps;
ctx.buffer = buffer;
+ ctx.tex_mx = &tex_mx;
+ ctx.loop_state = &loop_state;
ctx.backend_data = backend_ctx;
ins.ctx = &ctx;
ins.dst = dst_param;
ins.src = src_param;
- shader->baseShader.parse_state.current_row = 0;
fe->shader_read_header(fe_data, &ptr, &shader_version);
@@ -1469,36 +1475,34 @@ static void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe
}
}
-static void shader_cleanup(IWineD3DBaseShader *iface)
+static void shader_cleanup(struct wined3d_shader *shader)
{
- IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)iface;
+ shader->device->shader_backend->shader_destroy(shader);
+ HeapFree(GetProcessHeap(), 0, shader->reg_maps.constf);
+ HeapFree(GetProcessHeap(), 0, shader->function);
+ shader_delete_constant_list(&shader->constantsF);
+ shader_delete_constant_list(&shader->constantsB);
+ shader_delete_constant_list(&shader->constantsI);
+ list_remove(&shader->shader_list_entry);
- ((IWineD3DDeviceImpl *)shader->baseShader.device)->shader_backend->shader_destroy(iface);
- HeapFree(GetProcessHeap(), 0, shader->baseShader.reg_maps.constf);
- HeapFree(GetProcessHeap(), 0, shader->baseShader.function);
- shader_delete_constant_list(&shader->baseShader.constantsF);
- shader_delete_constant_list(&shader->baseShader.constantsB);
- shader_delete_constant_list(&shader->baseShader.constantsI);
- list_remove(&shader->baseShader.shader_list_entry);
-
- if (shader->baseShader.frontend && shader->baseShader.frontend_data)
- {
- shader->baseShader.frontend->shader_free(shader->baseShader.frontend_data);
- }
+ if (shader->frontend && shader->frontend_data)
+ shader->frontend->shader_free(shader->frontend_data);
}
static void shader_none_handle_instruction(const struct wined3d_shader_instruction *ins) {}
static void shader_none_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS) {}
-static void shader_none_select_depth_blt(IWineD3DDevice *iface, enum tex_types tex_type, const SIZE *ds_mask_size) {}
-static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {}
-static void shader_none_update_float_vertex_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
-static void shader_none_update_float_pixel_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
+static void shader_none_select_depth_blt(void *shader_priv, const struct wined3d_gl_info *gl_info,
+ enum tex_types tex_type, const SIZE *ds_mask_size) {}
+static void shader_none_deselect_depth_blt(void *shader_priv, const struct wined3d_gl_info *gl_info) {}
+static void shader_none_update_float_vertex_constants(struct wined3d_device *device, UINT start, UINT count) {}
+static void shader_none_update_float_pixel_constants(struct wined3d_device *device, UINT start, UINT count) {}
static void shader_none_load_constants(const struct wined3d_context *context, char usePS, char useVS) {}
-static void shader_none_load_np2fixup_constants(IWineD3DDevice *iface, char usePS, char useVS) {}
-static void shader_none_destroy(IWineD3DBaseShader *iface) {}
-static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;}
-static void shader_none_free(IWineD3DDevice *iface) {}
-static BOOL shader_none_dirty_const(IWineD3DDevice *iface) {return FALSE;}
+static void shader_none_load_np2fixup_constants(void *shader_priv,
+ const struct wined3d_gl_info *gl_info, const struct wined3d_state *state) {}
+static void shader_none_destroy(struct wined3d_shader *shader) {}
+static HRESULT shader_none_alloc(struct wined3d_device *device) {return WINED3D_OK;}
+static void shader_none_free(struct wined3d_device *device) {}
+static BOOL shader_none_dirty_const(void) {return FALSE;}
static void shader_none_get_caps(const struct wined3d_gl_info *gl_info, struct shader_caps *caps)
{
@@ -1530,7 +1534,8 @@ static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup)
return FALSE;
}
-const shader_backend_t none_shader_backend = {
+const struct wined3d_shader_backend_ops none_shader_backend =
+{
shader_none_handle_instruction,
shader_none_select,
shader_none_select_depth_blt,
@@ -1547,31 +1552,10 @@ const shader_backend_t none_shader_backend = {
shader_none_color_fixup_supported,
};
-static HRESULT shader_get_function(IWineD3DBaseShaderImpl *shader, void *data, UINT *data_size)
-{
- if (!data)
- {
- *data_size = shader->baseShader.functionLength;
- return WINED3D_OK;
- }
-
- if (*data_size < shader->baseShader.functionLength)
- {
- /* MSDN claims (for d3d8 at least) that if *pSizeOfData is smaller
- * than the required size we should write the required size and
- * return D3DERR_MOREDATA. That's not actually true. */
- return WINED3DERR_INVALIDCALL;
- }
-
- memcpy(data, shader->baseShader.function, shader->baseShader.functionLength);
-
- return WINED3D_OK;
-}
-
-static HRESULT shader_set_function(IWineD3DBaseShaderImpl *shader, const DWORD *byte_code,
+static HRESULT shader_set_function(struct wined3d_shader *shader, const DWORD *byte_code,
const struct wined3d_shader_signature *output_signature, DWORD float_const_count)
{
- struct shader_reg_maps *reg_maps = &shader->baseShader.reg_maps;
+ struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
const struct wined3d_shader_frontend *fe;
HRESULT hr;
@@ -1584,59 +1568,40 @@ static HRESULT shader_set_function(IWineD3DBaseShaderImpl *shader, const DWORD *
FIXME("Unable to find frontend for shader.\n");
return WINED3DERR_INVALIDCALL;
}
- shader->baseShader.frontend = fe;
- shader->baseShader.frontend_data = fe->shader_init(byte_code, output_signature);
- if (!shader->baseShader.frontend_data)
+ shader->frontend = fe;
+ shader->frontend_data = fe->shader_init(byte_code, output_signature);
+ if (!shader->frontend_data)
{
FIXME("Failed to initialize frontend.\n");
return WINED3DERR_INVALIDCALL;
}
/* First pass: trace shader. */
- if (TRACE_ON(d3d_shader)) shader_trace_init(fe, shader->baseShader.frontend_data, byte_code);
+ if (TRACE_ON(d3d_shader))
+ shader_trace_init(fe, shader->frontend_data, byte_code);
/* Initialize immediate constant lists. */
- list_init(&shader->baseShader.constantsF);
- list_init(&shader->baseShader.constantsB);
- list_init(&shader->baseShader.constantsI);
+ list_init(&shader->constantsF);
+ list_init(&shader->constantsB);
+ list_init(&shader->constantsI);
/* Second pass: figure out which registers are used, what the semantics are, etc. */
- hr = shader_get_registers_used((IWineD3DBaseShader *)shader, fe,
- reg_maps, shader->baseShader.input_signature, shader->baseShader.output_signature,
+ hr = shader_get_registers_used(shader, fe,
+ reg_maps, shader->input_signature, shader->output_signature,
byte_code, float_const_count);
if (FAILED(hr)) return hr;
- shader->baseShader.function = HeapAlloc(GetProcessHeap(), 0, shader->baseShader.functionLength);
- if (!shader->baseShader.function) return E_OUTOFMEMORY;
- memcpy(shader->baseShader.function, byte_code, shader->baseShader.functionLength);
+ shader->function = HeapAlloc(GetProcessHeap(), 0, shader->functionLength);
+ if (!shader->function)
+ return E_OUTOFMEMORY;
+ memcpy(shader->function, byte_code, shader->functionLength);
return WINED3D_OK;
}
-static HRESULT STDMETHODCALLTYPE vertexshader_QueryInterface(IWineD3DVertexShader *iface, REFIID riid, void **object)
+ULONG CDECL wined3d_shader_incref(struct wined3d_shader *shader)
{
- TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
-
- if (IsEqualGUID(riid, &IID_IWineD3DVertexShader)
- || IsEqualGUID(riid, &IID_IWineD3DBaseShader)
- || 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 vertexshader_AddRef(IWineD3DVertexShader *iface)
-{
- IWineD3DVertexShaderImpl *shader = (IWineD3DVertexShaderImpl *)iface;
- ULONG refcount = InterlockedIncrement(&shader->baseShader.ref);
+ ULONG refcount = InterlockedIncrement(&shader->ref);
TRACE("%p increasing refcount to %u.\n", shader, refcount);
@@ -1644,89 +1609,91 @@ static ULONG STDMETHODCALLTYPE vertexshader_AddRef(IWineD3DVertexShader *iface)
}
/* Do not call while under the GL lock. */
-static ULONG STDMETHODCALLTYPE vertexshader_Release(IWineD3DVertexShader *iface)
+ULONG CDECL wined3d_shader_decref(struct wined3d_shader *shader)
{
- IWineD3DVertexShaderImpl *shader = (IWineD3DVertexShaderImpl *)iface;
- ULONG refcount = InterlockedDecrement(&shader->baseShader.ref);
+ ULONG refcount = InterlockedDecrement(&shader->ref);
TRACE("%p decreasing refcount to %u.\n", shader, refcount);
if (!refcount)
{
- shader_cleanup((IWineD3DBaseShader *)iface);
- shader->baseShader.parent_ops->wined3d_object_destroyed(shader->baseShader.parent);
+ shader_cleanup(shader);
+ shader->parent_ops->wined3d_object_destroyed(shader->parent);
HeapFree(GetProcessHeap(), 0, shader);
}
return refcount;
}
-static void * STDMETHODCALLTYPE vertexshader_GetParent(IWineD3DVertexShader *iface)
+void * CDECL wined3d_shader_get_parent(const struct wined3d_shader *shader)
{
- TRACE("iface %p.\n", iface);
+ TRACE("shader %p.\n", shader);
- return ((IWineD3DBaseShaderImpl *)iface)->baseShader.parent;
+ return shader->parent;
}
-static HRESULT STDMETHODCALLTYPE vertexshader_GetFunction(IWineD3DVertexShader *iface, void *data, UINT *data_size)
+HRESULT CDECL wined3d_shader_get_byte_code(const struct wined3d_shader *shader,
+ void *byte_code, UINT *byte_code_size)
{
- TRACE("iface %p, data %p, data_size %p.\n", iface, data, data_size);
+ TRACE("shader %p, byte_code %p, byte_code_size %p.\n", shader, byte_code, byte_code_size);
- return shader_get_function((IWineD3DBaseShaderImpl *)iface, data, data_size);
+ if (!byte_code)
+ {
+ *byte_code_size = shader->functionLength;
+ return WINED3D_OK;
+ }
+
+ if (*byte_code_size < shader->functionLength)
+ {
+ /* MSDN claims (for d3d8 at least) that if *byte_code_size is smaller
+ * than the required size we should write the required size and
+ * return D3DERR_MOREDATA. That's not actually true. */
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ memcpy(byte_code, shader->function, shader->functionLength);
+
+ return WINED3D_OK;
}
/* Set local constants for d3d8 shaders. */
-static HRESULT STDMETHODCALLTYPE vertexshader_SetLocalConstantsF(IWineD3DVertexShader *iface,
+HRESULT CDECL wined3d_shader_set_local_constants_float(struct wined3d_shader *shader,
UINT start_idx, const float *src_data, UINT count)
{
- IWineD3DVertexShaderImpl *shader =(IWineD3DVertexShaderImpl *)iface;
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)shader->baseShader.device;
- UINT i, end_idx;
+ UINT end_idx = start_idx + count;
+ UINT i;
- TRACE("iface %p, start_idx %u, src_data %p, count %u.\n", iface, start_idx, src_data, count);
+ TRACE("shader %p, start_idx %u, src_data %p, count %u.\n", shader, start_idx, src_data, count);
- end_idx = start_idx + count;
- if (end_idx > device->d3d_vshader_constantF)
+ if (end_idx > shader->limits.constant_float)
{
- WARN("end_idx %u > float constants limit %u.\n", end_idx, device->d3d_vshader_constantF);
- end_idx = device->d3d_vshader_constantF;
+ WARN("end_idx %u > float constants limit %u.\n",
+ end_idx, shader->limits.constant_float);
+ end_idx = shader->limits.constant_float;
}
for (i = start_idx; i < end_idx; ++i)
{
- local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
- if (!lconst) return E_OUTOFMEMORY;
+ struct local_constant *lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
+ if (!lconst)
+ return E_OUTOFMEMORY;
lconst->idx = i;
memcpy(lconst->value, src_data + (i - start_idx) * 4 /* 4 components */, 4 * sizeof(float));
- list_add_head(&shader->baseShader.constantsF, &lconst->entry);
+ list_add_head(&shader->constantsF, &lconst->entry);
}
return WINED3D_OK;
}
-static const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl =
-{
- /* IUnknown methods */
- vertexshader_QueryInterface,
- vertexshader_AddRef,
- vertexshader_Release,
- /* IWineD3DBase methods */
- vertexshader_GetParent,
- /* IWineD3DBaseShader methods */
- vertexshader_GetFunction,
- /* IWineD3DVertexShader methods */
- vertexshader_SetLocalConstantsF,
-};
-
void find_vs_compile_args(const struct wined3d_state *state,
- IWineD3DVertexShaderImpl *shader, struct vs_compile_args *args)
+ const struct wined3d_shader *shader, struct vs_compile_args *args)
{
args->fog_src = state->render_states[WINED3DRS_FOGTABLEMODE]
== WINED3DFOG_NONE ? VS_FOG_COORD : VS_FOG_Z;
args->clip_enabled = state->render_states[WINED3DRS_CLIPPING]
&& state->render_states[WINED3DRS_CLIPPLANEENABLE];
- args->swizzle_map = ((IWineD3DDeviceImpl *)shader->baseShader.device)->strided_streams.swizzle_map;
+ args->swizzle_map = shader->device->strided_streams.swizzle_map;
}
static BOOL match_usage(BYTE usage1, BYTE usage_idx1, BYTE usage2, BYTE usage_idx2)
@@ -1739,18 +1706,18 @@ static BOOL match_usage(BYTE usage1, BYTE usage_idx1, BYTE usage2, BYTE usage_id
return FALSE;
}
-BOOL vshader_get_input(struct IWineD3DVertexShaderImpl *shader,
+BOOL vshader_get_input(struct wined3d_shader *shader,
BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum)
{
- WORD map = shader->baseShader.reg_maps.input_registers;
+ WORD map = shader->reg_maps.input_registers;
unsigned int i;
for (i = 0; map; map >>= 1, ++i)
{
if (!(map & 1)) continue;
- if (match_usage(shader->attributes[i].usage,
- shader->attributes[i].usage_idx, usage_req, usage_idx_req))
+ if (match_usage(shader->u.vs.attributes[i].usage,
+ shader->u.vs.attributes[i].usage_idx, usage_req, usage_idx_req))
{
*regnum = i;
return TRUE;
@@ -1759,43 +1726,43 @@ BOOL vshader_get_input(struct IWineD3DVertexShaderImpl *shader,
return FALSE;
}
-static void vertexshader_set_limits(IWineD3DVertexShaderImpl *shader)
+static void vertexshader_set_limits(struct wined3d_shader *shader)
{
- DWORD shader_version = WINED3D_SHADER_VERSION(shader->baseShader.reg_maps.shader_version.major,
- shader->baseShader.reg_maps.shader_version.minor);
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)shader->baseShader.device;
+ DWORD shader_version = WINED3D_SHADER_VERSION(shader->reg_maps.shader_version.major,
+ shader->reg_maps.shader_version.minor);
+ struct wined3d_device *device = shader->device;
- shader->baseShader.limits.texcoord = 0;
- shader->baseShader.limits.attributes = 16;
- shader->baseShader.limits.packed_input = 0;
+ shader->limits.texcoord = 0;
+ shader->limits.attributes = 16;
+ shader->limits.packed_input = 0;
switch (shader_version)
{
case WINED3D_SHADER_VERSION(1, 0):
case WINED3D_SHADER_VERSION(1, 1):
- shader->baseShader.limits.temporary = 12;
- shader->baseShader.limits.constant_bool = 0;
- shader->baseShader.limits.constant_int = 0;
- shader->baseShader.limits.address = 1;
- shader->baseShader.limits.packed_output = 12;
- shader->baseShader.limits.sampler = 0;
- shader->baseShader.limits.label = 0;
+ shader->limits.temporary = 12;
+ shader->limits.constant_bool = 0;
+ shader->limits.constant_int = 0;
+ shader->limits.address = 1;
+ shader->limits.packed_output = 12;
+ shader->limits.sampler = 0;
+ shader->limits.label = 0;
/* TODO: vs_1_1 has a minimum of 96 constants. What happens when
* a vs_1_1 shader is used on a vs_3_0 capable card that has 256
* constants? */
- shader->baseShader.limits.constant_float = min(256, device->d3d_vshader_constantF);
+ shader->limits.constant_float = min(256, device->d3d_vshader_constantF);
break;
case WINED3D_SHADER_VERSION(2, 0):
case WINED3D_SHADER_VERSION(2, 1):
- shader->baseShader.limits.temporary = 12;
- shader->baseShader.limits.constant_bool = 16;
- shader->baseShader.limits.constant_int = 16;
- shader->baseShader.limits.address = 1;
- shader->baseShader.limits.packed_output = 12;
- shader->baseShader.limits.sampler = 0;
- shader->baseShader.limits.label = 16;
- shader->baseShader.limits.constant_float = min(256, device->d3d_vshader_constantF);
+ shader->limits.temporary = 12;
+ shader->limits.constant_bool = 16;
+ shader->limits.constant_int = 16;
+ shader->limits.address = 1;
+ shader->limits.packed_output = 12;
+ shader->limits.sampler = 0;
+ shader->limits.label = 16;
+ shader->limits.constant_float = min(256, device->d3d_vshader_constantF);
break;
case WINED3D_SHADER_VERSION(4, 0):
@@ -1803,68 +1770,65 @@ static void vertexshader_set_limits(IWineD3DVertexShaderImpl *shader)
/* Fall through. */
case WINED3D_SHADER_VERSION(3, 0):
- shader->baseShader.limits.temporary = 32;
- shader->baseShader.limits.constant_bool = 32;
- shader->baseShader.limits.constant_int = 32;
- shader->baseShader.limits.address = 1;
- shader->baseShader.limits.packed_output = 12;
- shader->baseShader.limits.sampler = 4;
- shader->baseShader.limits.label = 16; /* FIXME: 2048 */
+ shader->limits.temporary = 32;
+ shader->limits.constant_bool = 32;
+ shader->limits.constant_int = 32;
+ shader->limits.address = 1;
+ shader->limits.packed_output = 12;
+ shader->limits.sampler = 4;
+ shader->limits.label = 16; /* FIXME: 2048 */
/* DX10 cards on Windows advertise a d3d9 constant limit of 256
* even though they are capable of supporting much more (GL
* drivers advertise 1024). d3d9.dll and d3d8.dll clamp the
* wined3d-advertised maximum. Clamp the constant limit for <= 3.0
* shaders to 256. */
- shader->baseShader.limits.constant_float = min(256, device->d3d_vshader_constantF);
+ shader->limits.constant_float = min(256, device->d3d_vshader_constantF);
break;
default:
- shader->baseShader.limits.temporary = 12;
- shader->baseShader.limits.constant_bool = 16;
- shader->baseShader.limits.constant_int = 16;
- shader->baseShader.limits.address = 1;
- shader->baseShader.limits.packed_output = 12;
- shader->baseShader.limits.sampler = 0;
- shader->baseShader.limits.label = 16;
- shader->baseShader.limits.constant_float = min(256, device->d3d_vshader_constantF);
+ shader->limits.temporary = 12;
+ shader->limits.constant_bool = 16;
+ shader->limits.constant_int = 16;
+ shader->limits.address = 1;
+ shader->limits.packed_output = 12;
+ shader->limits.sampler = 0;
+ shader->limits.label = 16;
+ shader->limits.constant_float = min(256, device->d3d_vshader_constantF);
FIXME("Unrecognized vertex shader version \"%u.%u\".\n",
- shader->baseShader.reg_maps.shader_version.major,
- shader->baseShader.reg_maps.shader_version.minor);
+ shader->reg_maps.shader_version.major,
+ shader->reg_maps.shader_version.minor);
}
}
-HRESULT vertexshader_init(IWineD3DVertexShaderImpl *shader, IWineD3DDeviceImpl *device,
+static HRESULT vertexshader_init(struct wined3d_shader *shader, struct wined3d_device *device,
const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
void *parent, const struct wined3d_parent_ops *parent_ops)
{
- const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
- struct shader_reg_maps *reg_maps = &shader->baseShader.reg_maps;
+ struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
unsigned int i;
HRESULT hr;
WORD map;
if (!byte_code) return WINED3DERR_INVALIDCALL;
- shader->lpVtbl = &IWineD3DVertexShader_Vtbl;
- shader_init(&shader->baseShader, device, parent, parent_ops);
-
- hr = shader_set_function((IWineD3DBaseShaderImpl *)shader, byte_code,
- output_signature, device->d3d_vshader_constantF);
+ shader_init(shader, device, parent, parent_ops);
+ hr = shader_set_function(shader, byte_code, output_signature, device->d3d_vshader_constantF);
if (FAILED(hr))
{
WARN("Failed to set function, hr %#x.\n", hr);
- shader_cleanup((IWineD3DBaseShader *)shader);
+ shader_cleanup(shader);
return hr;
}
- map = shader->baseShader.reg_maps.input_registers;
+ map = reg_maps->input_registers;
for (i = 0; map; map >>= 1, ++i)
{
- if (!(map & 1) || !shader->baseShader.input_signature[i].semantic_name) continue;
+ if (!(map & 1) || !shader->input_signature[i].semantic_name)
+ continue;
- shader->attributes[i].usage =
- shader_usage_from_semantic_name(shader->baseShader.input_signature[i].semantic_name);
- shader->attributes[i].usage_idx = shader->baseShader.input_signature[i].semantic_idx;
+ shader->u.vs.attributes[i].usage =
+ shader_usage_from_semantic_name(shader->input_signature[i].semantic_name);
+ shader->u.vs.attributes[i].usage_idx = shader->input_signature[i].semantic_idx;
}
if (output_signature)
@@ -1873,229 +1837,54 @@ HRESULT vertexshader_init(IWineD3DVertexShaderImpl *shader, IWineD3DDeviceImpl *
{
struct wined3d_shader_signature_element *e = &output_signature->elements[i];
reg_maps->output_registers |= 1 << e->register_idx;
- shader->baseShader.output_signature[e->register_idx] = *e;
+ shader->output_signature[e->register_idx] = *e;
}
}
vertexshader_set_limits(shader);
- if (device->vs_selected_mode == SHADER_ARB
- && (gl_info->quirks & WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT)
- && shader->min_rel_offset <= shader->max_rel_offset)
- {
- if (shader->max_rel_offset - shader->min_rel_offset > 127)
- {
- FIXME("The difference between the minimum and maximum relative offset is > 127.\n");
- FIXME("Which this OpenGL implementation does not support. Try using GLSL.\n");
- FIXME("Min: %d, Max: %d.\n", shader->min_rel_offset, shader->max_rel_offset);
- }
- else if (shader->max_rel_offset - shader->min_rel_offset > 63)
- {
- shader->rel_offset = shader->min_rel_offset + 63;
- }
- else if (shader->max_rel_offset > 63)
- {
- shader->rel_offset = shader->min_rel_offset;
- }
- else
- {
- shader->rel_offset = 0;
- }
- }
-
- shader->baseShader.load_local_constsF = shader->baseShader.reg_maps.usesrelconstF
- && !list_empty(&shader->baseShader.constantsF);
+ shader->load_local_constsF = reg_maps->usesrelconstF
+ && !list_empty(&shader->constantsF);
return WINED3D_OK;
}
-static HRESULT STDMETHODCALLTYPE geometryshader_QueryInterface(IWineD3DGeometryShader *iface,
- REFIID riid, void **object)
-{
- TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
-
- if (IsEqualGUID(riid, &IID_IWineD3DGeometryShader)
- || IsEqualGUID(riid, &IID_IWineD3DBaseShader)
- || 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 geometryshader_AddRef(IWineD3DGeometryShader *iface)
-{
- struct wined3d_geometryshader *shader = (struct wined3d_geometryshader *)iface;
- ULONG refcount = InterlockedIncrement(&shader->base_shader.ref);
-
- TRACE("%p increasing refcount to %u.\n", shader, refcount);
-
- return refcount;
-}
-
-/* Do not call while under the GL lock. */
-static ULONG STDMETHODCALLTYPE geometryshader_Release(IWineD3DGeometryShader *iface)
-{
- struct wined3d_geometryshader *shader = (struct wined3d_geometryshader *)iface;
- ULONG refcount = InterlockedDecrement(&shader->base_shader.ref);
-
- TRACE("%p decreasing refcount to %u.\n", shader, refcount);
-
- if (!refcount)
- {
- shader_cleanup((IWineD3DBaseShader *)iface);
- shader->base_shader.parent_ops->wined3d_object_destroyed(shader->base_shader.parent);
- HeapFree(GetProcessHeap(), 0, shader);
- }
-
- return refcount;
-}
-
-static void * STDMETHODCALLTYPE geometryshader_GetParent(IWineD3DGeometryShader *iface)
-{
- TRACE("iface %p.\n", iface);
-
- return ((IWineD3DBaseShaderImpl *)iface)->baseShader.parent;
-}
-
-static HRESULT STDMETHODCALLTYPE geometryshader_GetFunction(IWineD3DGeometryShader *iface, void *data, UINT *data_size)
-{
- TRACE("iface %p, data %p, data_size %p.\n", iface, data, data_size);
-
- return shader_get_function((IWineD3DBaseShaderImpl *)iface, data, data_size);
-}
-
-static const IWineD3DGeometryShaderVtbl wined3d_geometryshader_vtbl =
-{
- /* IUnknown methods */
- geometryshader_QueryInterface,
- geometryshader_AddRef,
- geometryshader_Release,
- /* IWineD3DBase methods */
- geometryshader_GetParent,
- /* IWineD3DBaseShader methods */
- geometryshader_GetFunction,
-};
-
-HRESULT geometryshader_init(struct wined3d_geometryshader *shader, IWineD3DDeviceImpl *device,
+static HRESULT geometryshader_init(struct wined3d_shader *shader, struct wined3d_device *device,
const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
void *parent, const struct wined3d_parent_ops *parent_ops)
{
HRESULT hr;
- shader->vtbl = &wined3d_geometryshader_vtbl;
- shader_init(&shader->base_shader, device, parent, parent_ops);
-
- hr = shader_set_function((IWineD3DBaseShaderImpl *)shader, byte_code, output_signature, 0);
+ shader_init(shader, device, parent, parent_ops);
+ hr = shader_set_function(shader, byte_code, output_signature, 0);
if (FAILED(hr))
{
WARN("Failed to set function, hr %#x.\n", hr);
- shader_cleanup((IWineD3DBaseShader *)shader);
+ shader_cleanup(shader);
return hr;
}
- shader->base_shader.load_local_constsF = FALSE;
+ shader->load_local_constsF = FALSE;
return WINED3D_OK;
}
-static HRESULT STDMETHODCALLTYPE pixelshader_QueryInterface(IWineD3DPixelShader *iface, REFIID riid, void **object)
-{
- TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
-
- if (IsEqualGUID(riid, &IID_IWineD3DPixelShader)
- || IsEqualGUID(riid, &IID_IWineD3DBaseShader)
- || 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 pixelshader_AddRef(IWineD3DPixelShader *iface)
-{
- IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)iface;
- ULONG refcount = InterlockedIncrement(&shader->baseShader.ref);
-
- TRACE("%p increasing refcount to %u.\n", shader, refcount);
-
- return refcount;
-}
-
-/* Do not call while under the GL lock. */
-static ULONG STDMETHODCALLTYPE pixelshader_Release(IWineD3DPixelShader *iface)
-{
- IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)iface;
- ULONG refcount = InterlockedDecrement(&shader->baseShader.ref);
-
- TRACE("%p decreasing refcount to %u.\n", shader, refcount);
-
- if (!refcount)
- {
- shader_cleanup((IWineD3DBaseShader *)iface);
- shader->baseShader.parent_ops->wined3d_object_destroyed(shader->baseShader.parent);
- HeapFree(GetProcessHeap(), 0, shader);
- }
-
- return refcount;
-}
-
-static void * STDMETHODCALLTYPE pixelshader_GetParent(IWineD3DPixelShader *iface)
-{
- TRACE("iface %p.\n", iface);
-
- return ((IWineD3DBaseShaderImpl *)iface)->baseShader.parent;
-}
-
-static HRESULT STDMETHODCALLTYPE pixelshader_GetFunction(IWineD3DPixelShader *iface, void *data, UINT *data_size)
-{
- TRACE("iface %p, data %p, data_size %p.\n", iface, data, data_size);
-
- return shader_get_function((IWineD3DBaseShaderImpl *)iface, data, data_size);
-}
-
-static const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl =
-{
- /* IUnknown methods */
- pixelshader_QueryInterface,
- pixelshader_AddRef,
- pixelshader_Release,
- /* IWineD3DBase methods */
- pixelshader_GetParent,
- /* IWineD3DBaseShader methods */
- pixelshader_GetFunction
-};
-
void find_ps_compile_args(const struct wined3d_state *state,
- IWineD3DPixelShaderImpl *shader, struct ps_compile_args *args)
+ const struct wined3d_shader *shader, struct ps_compile_args *args)
{
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)shader->baseShader.device;
- IWineD3DBaseTextureImpl *texture;
+ struct wined3d_device *device = shader->device;
+ const struct wined3d_texture *texture;
UINT i;
memset(args, 0, sizeof(*args)); /* FIXME: Make sure all bits are set. */
if (state->render_states[WINED3DRS_SRGBWRITEENABLE])
{
- IWineD3DSurfaceImpl *rt = device->render_targets[0];
- if(rt->resource.format->Flags & WINED3DFMT_FLAG_SRGB_WRITE) args->srgb_correction = 1;
+ struct wined3d_surface *rt = device->fb.render_targets[0];
+ if (rt->resource.format->flags & WINED3DFMT_FLAG_SRGB_WRITE) args->srgb_correction = 1;
}
- if (shader->baseShader.reg_maps.shader_version.major == 1
- && shader->baseShader.reg_maps.shader_version.minor <= 3)
+ if (shader->reg_maps.shader_version.major == 1
+ && shader->reg_maps.shader_version.minor <= 3)
{
for (i = 0; i < 4; ++i)
{
@@ -2109,7 +1898,9 @@ void find_ps_compile_args(const struct wined3d_state *state,
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
{
- if (!shader->baseShader.reg_maps.sampler_type[i]) continue;
+ if (!shader->reg_maps.sampler_type[i])
+ continue;
+
texture = state->textures[i];
if (!texture)
{
@@ -2118,16 +1909,14 @@ void find_ps_compile_args(const struct wined3d_state *state,
}
args->color_fixup[i] = texture->resource.format->color_fixup;
- if (texture->resource.format->Flags & WINED3DFMT_FLAG_SHADOW)
+ if (texture->resource.format->flags & WINED3DFMT_FLAG_SHADOW)
args->shadow |= 1 << i;
/* Flag samplers that need NP2 texcoord fixup. */
- if (!texture->baseTexture.pow2Matrix_identity)
- {
+ if (!(texture->flags & WINED3D_TEXTURE_POW2_MAT_IDENT))
args->np2_fixup |= (1 << i);
- }
}
- if (shader->baseShader.reg_maps.shader_version.major >= 3)
+ if (shader->reg_maps.shader_version.major >= 3)
{
if (device->strided_streams.position_transformed)
{
@@ -2178,14 +1967,14 @@ void find_ps_compile_args(const struct wined3d_state *state,
}
}
-static void pixelshader_set_limits(IWineD3DPixelShaderImpl *shader)
+static void pixelshader_set_limits(struct wined3d_shader *shader)
{
- DWORD shader_version = WINED3D_SHADER_VERSION(shader->baseShader.reg_maps.shader_version.major,
- shader->baseShader.reg_maps.shader_version.minor);
+ DWORD shader_version = WINED3D_SHADER_VERSION(shader->reg_maps.shader_version.major,
+ shader->reg_maps.shader_version.minor);
- shader->baseShader.limits.attributes = 0;
- shader->baseShader.limits.address = 0;
- shader->baseShader.limits.packed_output = 0;
+ shader->limits.attributes = 0;
+ shader->limits.address = 0;
+ shader->limits.packed_output = 0;
switch (shader_version)
{
@@ -2193,47 +1982,47 @@ static void pixelshader_set_limits(IWineD3DPixelShaderImpl *shader)
case WINED3D_SHADER_VERSION(1, 1):
case WINED3D_SHADER_VERSION(1, 2):
case WINED3D_SHADER_VERSION(1, 3):
- shader->baseShader.limits.temporary = 2;
- shader->baseShader.limits.constant_float = 8;
- shader->baseShader.limits.constant_int = 0;
- shader->baseShader.limits.constant_bool = 0;
- shader->baseShader.limits.texcoord = 4;
- shader->baseShader.limits.sampler = 4;
- shader->baseShader.limits.packed_input = 0;
- shader->baseShader.limits.label = 0;
+ shader->limits.temporary = 2;
+ shader->limits.constant_float = 8;
+ shader->limits.constant_int = 0;
+ shader->limits.constant_bool = 0;
+ shader->limits.texcoord = 4;
+ shader->limits.sampler = 4;
+ shader->limits.packed_input = 0;
+ shader->limits.label = 0;
break;
case WINED3D_SHADER_VERSION(1, 4):
- shader->baseShader.limits.temporary = 6;
- shader->baseShader.limits.constant_float = 8;
- shader->baseShader.limits.constant_int = 0;
- shader->baseShader.limits.constant_bool = 0;
- shader->baseShader.limits.texcoord = 6;
- shader->baseShader.limits.sampler = 6;
- shader->baseShader.limits.packed_input = 0;
- shader->baseShader.limits.label = 0;
+ shader->limits.temporary = 6;
+ shader->limits.constant_float = 8;
+ shader->limits.constant_int = 0;
+ shader->limits.constant_bool = 0;
+ shader->limits.texcoord = 6;
+ shader->limits.sampler = 6;
+ shader->limits.packed_input = 0;
+ shader->limits.label = 0;
break;
/* FIXME: Temporaries must match D3DPSHADERCAPS2_0.NumTemps. */
case WINED3D_SHADER_VERSION(2, 0):
- shader->baseShader.limits.temporary = 32;
- shader->baseShader.limits.constant_float = 32;
- shader->baseShader.limits.constant_int = 16;
- shader->baseShader.limits.constant_bool = 16;
- shader->baseShader.limits.texcoord = 8;
- shader->baseShader.limits.sampler = 16;
- shader->baseShader.limits.packed_input = 0;
+ shader->limits.temporary = 32;
+ shader->limits.constant_float = 32;
+ shader->limits.constant_int = 16;
+ shader->limits.constant_bool = 16;
+ shader->limits.texcoord = 8;
+ shader->limits.sampler = 16;
+ shader->limits.packed_input = 0;
break;
case WINED3D_SHADER_VERSION(2, 1):
- shader->baseShader.limits.temporary = 32;
- shader->baseShader.limits.constant_float = 32;
- shader->baseShader.limits.constant_int = 16;
- shader->baseShader.limits.constant_bool = 16;
- shader->baseShader.limits.texcoord = 8;
- shader->baseShader.limits.sampler = 16;
- shader->baseShader.limits.packed_input = 0;
- shader->baseShader.limits.label = 16;
+ shader->limits.temporary = 32;
+ shader->limits.constant_float = 32;
+ shader->limits.constant_int = 16;
+ shader->limits.constant_bool = 16;
+ shader->limits.texcoord = 8;
+ shader->limits.sampler = 16;
+ shader->limits.packed_input = 0;
+ shader->limits.label = 16;
break;
case WINED3D_SHADER_VERSION(4, 0):
@@ -2241,32 +2030,32 @@ static void pixelshader_set_limits(IWineD3DPixelShaderImpl *shader)
/* Fall through. */
case WINED3D_SHADER_VERSION(3, 0):
- shader->baseShader.limits.temporary = 32;
- shader->baseShader.limits.constant_float = 224;
- shader->baseShader.limits.constant_int = 16;
- shader->baseShader.limits.constant_bool = 16;
- shader->baseShader.limits.texcoord = 0;
- shader->baseShader.limits.sampler = 16;
- shader->baseShader.limits.packed_input = 12;
- shader->baseShader.limits.label = 16; /* FIXME: 2048 */
+ shader->limits.temporary = 32;
+ shader->limits.constant_float = 224;
+ shader->limits.constant_int = 16;
+ shader->limits.constant_bool = 16;
+ shader->limits.texcoord = 0;
+ shader->limits.sampler = 16;
+ shader->limits.packed_input = 12;
+ shader->limits.label = 16; /* FIXME: 2048 */
break;
default:
- shader->baseShader.limits.temporary = 32;
- shader->baseShader.limits.constant_float = 32;
- shader->baseShader.limits.constant_int = 16;
- shader->baseShader.limits.constant_bool = 16;
- shader->baseShader.limits.texcoord = 8;
- shader->baseShader.limits.sampler = 16;
- shader->baseShader.limits.packed_input = 0;
- shader->baseShader.limits.label = 0;
+ shader->limits.temporary = 32;
+ shader->limits.constant_float = 32;
+ shader->limits.constant_int = 16;
+ shader->limits.constant_bool = 16;
+ shader->limits.texcoord = 8;
+ shader->limits.sampler = 16;
+ shader->limits.packed_input = 0;
+ shader->limits.label = 0;
FIXME("Unrecognized pixel shader version %u.%u\n",
- shader->baseShader.reg_maps.shader_version.major,
- shader->baseShader.reg_maps.shader_version.minor);
+ shader->reg_maps.shader_version.major,
+ shader->reg_maps.shader_version.minor);
}
}
-HRESULT pixelshader_init(IWineD3DPixelShaderImpl *shader, IWineD3DDeviceImpl *device,
+static HRESULT pixelshader_init(struct wined3d_shader *shader, struct wined3d_device *device,
const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
void *parent, const struct wined3d_parent_ops *parent_ops)
{
@@ -2276,15 +2065,12 @@ HRESULT pixelshader_init(IWineD3DPixelShaderImpl *shader, IWineD3DDeviceImpl *de
if (!byte_code) return WINED3DERR_INVALIDCALL;
- shader->lpVtbl = &IWineD3DPixelShader_Vtbl;
- shader_init(&shader->baseShader, device, parent, parent_ops);
-
- hr = shader_set_function((IWineD3DBaseShaderImpl *)shader, byte_code,
- output_signature, device->d3d_pshader_constantF);
+ shader_init(shader, device, parent, parent_ops);
+ hr = shader_set_function(shader, byte_code, output_signature, device->d3d_pshader_constantF);
if (FAILED(hr))
{
WARN("Failed to set function, hr %#x.\n", hr);
- shader_cleanup((IWineD3DBaseShader *)shader);
+ shader_cleanup(shader);
return hr;
}
@@ -2292,7 +2078,7 @@ HRESULT pixelshader_init(IWineD3DPixelShaderImpl *shader, IWineD3DDeviceImpl *de
for (i = 0; i < MAX_REG_INPUT; ++i)
{
- if (shader->input_reg_used[i])
+ if (shader->u.ps.input_reg_used[i])
{
++num_regs_used;
highest_reg_used = i;
@@ -2314,27 +2100,28 @@ HRESULT pixelshader_init(IWineD3DPixelShaderImpl *shader, IWineD3DDeviceImpl *de
for (i = 0; i < MAX_REG_INPUT; ++i)
{
- shader->input_reg_map[i] = i;
+ shader->u.ps.input_reg_map[i] = i;
}
- shader->declared_in_count = highest_reg_used + 1;
+ shader->u.ps.declared_in_count = highest_reg_used + 1;
}
else
{
- shader->declared_in_count = 0;
+ shader->u.ps.declared_in_count = 0;
for (i = 0; i < MAX_REG_INPUT; ++i)
{
- if (shader->input_reg_used[i]) shader->input_reg_map[i] = shader->declared_in_count++;
- else shader->input_reg_map[i] = ~0U;
+ if (shader->u.ps.input_reg_used[i])
+ shader->u.ps.input_reg_map[i] = shader->u.ps.declared_in_count++;
+ else shader->u.ps.input_reg_map[i] = ~0U;
}
}
- shader->baseShader.load_local_constsF = FALSE;
+ shader->load_local_constsF = FALSE;
return WINED3D_OK;
}
-void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD3DBaseTexture * const *textures)
+void pixelshader_update_samplers(struct wined3d_shader_reg_maps *reg_maps, struct wined3d_texture * const *textures)
{
WINED3DSAMPLER_TEXTURE_TYPE *sampler_type = reg_maps->sampler_type;
unsigned int i;
@@ -2353,7 +2140,7 @@ void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD3DBaseT
continue;
}
- switch (((IWineD3DBaseTextureImpl *)textures[i])->baseTexture.target)
+ switch (textures[i]->target)
{
case GL_TEXTURE_RECTANGLE_ARB:
case GL_TEXTURE_2D:
@@ -2372,9 +2159,107 @@ void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD3DBaseT
break;
default:
- FIXME("Unrecognized texture type %#x, using 2D.\n",
- ((IWineD3DBaseTextureImpl *)textures[i])->baseTexture.target);
+ FIXME("Unrecognized texture type %#x, using 2D.\n", textures[i]->target);
sampler_type[i] = WINED3DSTT_2D;
}
}
}
+
+HRESULT CDECL wined3d_shader_create_gs(struct wined3d_device *device, const DWORD *byte_code,
+ const struct wined3d_shader_signature *output_signature, void *parent,
+ const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
+{
+ struct wined3d_shader *object;
+ HRESULT hr;
+
+ TRACE("device %p, byte_code %p, output_signature %p, parent %p, parent_ops %p, shader %p.\n",
+ device, byte_code, output_signature, parent, parent_ops, shader);
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (!object)
+ {
+ ERR("Failed to allocate shader memory.\n");
+ return E_OUTOFMEMORY;
+ }
+
+ hr = geometryshader_init(object, device, byte_code, output_signature, parent, parent_ops);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize geometry shader, hr %#x.\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ return hr;
+ }
+
+ TRACE("Created geometry shader %p.\n", object);
+ *shader = object;
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_shader_create_ps(struct wined3d_device *device, const DWORD *byte_code,
+ const struct wined3d_shader_signature *output_signature, void *parent,
+ const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
+{
+ struct wined3d_shader *object;
+ HRESULT hr;
+
+ TRACE("device %p, byte_code %p, output_signature %p, parent %p, parent_ops %p, shader %p.\n",
+ device, byte_code, output_signature, parent, parent_ops, shader);
+
+ if (device->ps_selected_mode == SHADER_NONE)
+ return WINED3DERR_INVALIDCALL;
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (!object)
+ {
+ ERR("Failed to allocate shader memory.\n");
+ return E_OUTOFMEMORY;
+ }
+
+ hr = pixelshader_init(object, device, byte_code, output_signature, parent, parent_ops);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ return hr;
+ }
+
+ TRACE("Created pixel shader %p.\n", object);
+ *shader = object;
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_shader_create_vs(struct wined3d_device *device, const DWORD *byte_code,
+ const struct wined3d_shader_signature *output_signature, void *parent,
+ const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
+{
+ struct wined3d_shader *object;
+ HRESULT hr;
+
+ TRACE("device %p, byte_code %p, output_signature %p, parent %p, parent_ops %p, shader %p.\n",
+ device, byte_code, output_signature, parent, parent_ops, shader);
+
+ if (device->vs_selected_mode == SHADER_NONE)
+ return WINED3DERR_INVALIDCALL;
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (!object)
+ {
+ ERR("Failed to allocate shader memory.\n");
+ return E_OUTOFMEMORY;
+ }
+
+ hr = vertexshader_init(object, device, byte_code, output_signature, parent, parent_ops);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ return hr;
+ }
+
+ TRACE("Created vertex shader %p.\n", object);
+ *shader = object;
+
+ return WINED3D_OK;
+}
diff --git a/reactos/dll/directx/wine/wined3d/shader_sm4.c b/reactos/dll/directx/wine/wined3d/shader_sm4.c
index a43861498bc..d0b36c6715c 100644
--- a/reactos/dll/directx/wine/wined3d/shader_sm4.c
+++ b/reactos/dll/directx/wine/wined3d/shader_sm4.c
@@ -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);
diff --git a/reactos/dll/directx/wine/wined3d/state.c b/reactos/dll/directx/wine/wined3d/state.c
index 6a415eee807..a2c197bbfe0 100644
--- a/reactos/dll/directx/wine/wined3d/state.c
+++ b/reactos/dll/directx/wine/wined3d/state.c
@@ -8,7 +8,7 @@
* Copyright 2005 Oliver Stieber
* Copyright 2006 Henri Verbeet
* Copyright 2006-2008 Stefan Dösinger for CodeWeavers
- * 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
@@ -37,19 +37,19 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d_shader);
/* GL locking for state handlers is done by the caller. */
-static void state_blendop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context);
+static void state_blendop(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context);
-static void state_undefined(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_undefined(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
ERR("Undefined state.\n");
}
-static void state_nop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_nop(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
TRACE("%s: nop in current pipe config.\n", debug_d3dstate(state));
}
-static void state_fillmode(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_fillmode(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
WINED3DFILLMODE Value = stateblock->state.render_states[WINED3DRS_FILLMODE];
@@ -71,7 +71,7 @@ static void state_fillmode(DWORD state, IWineD3DStateBlockImpl *stateblock, stru
}
}
-static void state_lighting(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_lighting(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
/* Lighting is not enabled if transformed vertices are drawn
* but lighting does not affect the stream sources, so it is not grouped for performance reasons.
@@ -94,10 +94,10 @@ static void state_lighting(DWORD state, IWineD3DStateBlockImpl *stateblock, stru
}
}
-static void state_zenable(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_zenable(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
/* No z test without depth stencil buffers */
- if (!stateblock->device->depth_stencil)
+ if (!stateblock->device->fb.depth_stencil)
{
TRACE("No Z buffer - disabling depth test\n");
glDisable(GL_DEPTH_TEST); /* This also disables z writing in gl */
@@ -126,7 +126,7 @@ static void state_zenable(DWORD state, IWineD3DStateBlockImpl *stateblock, struc
}
}
-static void state_cullmode(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_cullmode(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
/* glFrontFace() is set in context.c at context init and on an
* offscreen / onscreen rendering switch. */
@@ -154,7 +154,7 @@ static void state_cullmode(DWORD state, IWineD3DStateBlockImpl *stateblock, stru
}
}
-static void state_shademode(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_shademode(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
switch (stateblock->state.render_states[WINED3DRS_SHADEMODE])
{
@@ -175,7 +175,7 @@ static void state_shademode(DWORD state, IWineD3DStateBlockImpl *stateblock, str
}
}
-static void state_ditherenable(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_ditherenable(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_DITHERENABLE])
{
@@ -189,7 +189,7 @@ static void state_ditherenable(DWORD state, IWineD3DStateBlockImpl *stateblock,
}
}
-static void state_zwritenable(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_zwritenable(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
/* TODO: Test if in d3d z writing is enabled even if ZENABLE is off.
* If yes, this has to be merged with ZENABLE and ZFUNC. */
@@ -205,7 +205,7 @@ static void state_zwritenable(DWORD state, IWineD3DStateBlockImpl *stateblock, s
}
}
-static void state_zfunc(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_zfunc(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
GLenum depth_func = CompareFunc(stateblock->state.render_states[WINED3DRS_ZFUNC]);
@@ -230,7 +230,7 @@ static void state_zfunc(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
checkGLcall("glDepthFunc");
}
-static void state_ambient(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_ambient(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
float col[4];
D3DCOLORTOGLFLOAT4(stateblock->state.render_states[WINED3DRS_AMBIENT], col);
@@ -240,12 +240,54 @@ static void state_ambient(DWORD state, IWineD3DStateBlockImpl *stateblock, struc
checkGLcall("glLightModel for MODEL_AMBIENT");
}
-static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static GLenum gl_blend_factor(WINED3DBLEND factor, const struct wined3d_format *dst_format)
{
- IWineD3DSurfaceImpl *target = stateblock->device->render_targets[0];
+ switch (factor)
+ {
+ case WINED3DBLEND_ZERO:
+ return GL_ZERO;
+ case WINED3DBLEND_ONE:
+ return GL_ONE;
+ case WINED3DBLEND_SRCCOLOR:
+ return GL_SRC_COLOR;
+ case WINED3DBLEND_INVSRCCOLOR:
+ return GL_ONE_MINUS_SRC_COLOR;
+ case WINED3DBLEND_SRCALPHA:
+ return GL_SRC_ALPHA;
+ case WINED3DBLEND_INVSRCALPHA:
+ return GL_ONE_MINUS_SRC_ALPHA;
+ case WINED3DBLEND_DESTCOLOR:
+ return GL_DST_COLOR;
+ case WINED3DBLEND_INVDESTCOLOR:
+ return GL_ONE_MINUS_DST_COLOR;
+ /* To compensate for the lack of format switching with backbuffer
+ * offscreen rendering, and with onscreen rendering, we modify the
+ * alpha test parameters for (INV)DESTALPHA if the render target
+ * doesn't support alpha blending. A nonexistent alpha channel
+ * returns 1.0, so WINED3DBLEND_DESTALPHA becomes GL_ONE, and
+ * WINED3DBLEND_INVDESTALPHA becomes GL_ZERO. */
+ case WINED3DBLEND_DESTALPHA:
+ return dst_format->alpha_mask ? GL_DST_ALPHA : GL_ONE;
+ case WINED3DBLEND_INVDESTALPHA:
+ return dst_format->alpha_mask ? GL_ONE_MINUS_DST_ALPHA : GL_ZERO;
+ case WINED3DBLEND_SRCALPHASAT:
+ return GL_SRC_ALPHA_SATURATE;
+ case WINED3DBLEND_BLENDFACTOR:
+ return GL_CONSTANT_COLOR_EXT;
+ case WINED3DBLEND_INVBLENDFACTOR:
+ return GL_ONE_MINUS_CONSTANT_COLOR_EXT;
+ default:
+ FIXME("Unhandled blend factor %#x.\n", factor);
+ return GL_NONE;
+ }
+}
+
+static void state_blend(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
+{
+ struct wined3d_surface *target = stateblock->device->fb.render_targets[0];
const struct wined3d_gl_info *gl_info = context->gl_info;
- int srcBlend = GL_ZERO;
- int dstBlend = GL_ZERO;
+ GLenum srcBlend, dstBlend;
+ WINED3DBLEND d3d_blend;
/* According to the red book, GL_LINE_SMOOTH needs GL_BLEND with specific
* blending parameters to work. */
@@ -257,7 +299,7 @@ static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
* With blending on we could face a big performance penalty.
* The d3d9 visual test confirms the behavior. */
if (context->render_offscreen
- && !(target->resource.format->Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING))
+ && !(target->resource.format->flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING))
{
glDisable(GL_BLEND);
checkGLcall("glDisable GL_BLEND");
@@ -273,86 +315,25 @@ static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
return;
};
- switch (stateblock->state.render_states[WINED3DRS_DESTBLEND])
+ /* WINED3DBLEND_BOTHSRCALPHA and WINED3DBLEND_BOTHINVSRCALPHA are legacy
+ * source blending values which are still valid up to d3d9. They should
+ * not occur as dest blend values. */
+ d3d_blend = stateblock->state.render_states[WINED3DRS_SRCBLEND];
+ if (d3d_blend == WINED3DBLEND_BOTHSRCALPHA)
{
- case WINED3DBLEND_ZERO : dstBlend = GL_ZERO; break;
- case WINED3DBLEND_ONE : dstBlend = GL_ONE; break;
- case WINED3DBLEND_SRCCOLOR : dstBlend = GL_SRC_COLOR; break;
- case WINED3DBLEND_INVSRCCOLOR : dstBlend = GL_ONE_MINUS_SRC_COLOR; break;
- case WINED3DBLEND_SRCALPHA : dstBlend = GL_SRC_ALPHA; break;
- case WINED3DBLEND_INVSRCALPHA : dstBlend = GL_ONE_MINUS_SRC_ALPHA; break;
- case WINED3DBLEND_DESTCOLOR : dstBlend = GL_DST_COLOR; break;
- case WINED3DBLEND_INVDESTCOLOR : dstBlend = GL_ONE_MINUS_DST_COLOR; break;
-
- /* To compensate the lack of format switching with backbuffer offscreen rendering,
- * and with onscreen rendering, we modify the alpha test parameters for (INV)DESTALPHA
- * if the render target doesn't support alpha blending. A nonexistent alpha channel
- * returns 1.0, so D3DBLEND_DESTALPHA is GL_ONE, and D3DBLEND_INVDESTALPHA is GL_ZERO
- */
- case WINED3DBLEND_DESTALPHA :
- dstBlend = target->resource.format->alpha_mask ? GL_DST_ALPHA : GL_ONE;
- break;
- case WINED3DBLEND_INVDESTALPHA :
- dstBlend = target->resource.format->alpha_mask ? GL_ONE_MINUS_DST_ALPHA : GL_ZERO;
- break;
-
- case WINED3DBLEND_SRCALPHASAT :
- dstBlend = GL_SRC_ALPHA_SATURATE;
- WARN("Application uses SRCALPHASAT as dest blend factor, expect problems\n");
- break;
-
- /* WINED3DBLEND_BOTHSRCALPHA and WINED3DBLEND_BOTHINVSRCALPHA are legacy source blending
- * values which are still valid up to d3d9. They should not occur as dest blend values
- */
- case WINED3DBLEND_BOTHSRCALPHA : dstBlend = GL_SRC_ALPHA;
- srcBlend = GL_SRC_ALPHA;
- FIXME("WINED3DRS_DESTBLEND = WINED3DBLEND_BOTHSRCALPHA, what to do?\n");
- break;
-
- case WINED3DBLEND_BOTHINVSRCALPHA : dstBlend = GL_ONE_MINUS_SRC_ALPHA;
- srcBlend = GL_ONE_MINUS_SRC_ALPHA;
- FIXME("WINED3DRS_DESTBLEND = WINED3DBLEND_BOTHINVSRCALPHA, what to do?\n");
- break;
-
- case WINED3DBLEND_BLENDFACTOR : dstBlend = GL_CONSTANT_COLOR; break;
- case WINED3DBLEND_INVBLENDFACTOR : dstBlend = GL_ONE_MINUS_CONSTANT_COLOR; break;
- default:
- FIXME("Unrecognized dst blend value %#x.\n",
- stateblock->state.render_states[WINED3DRS_DESTBLEND]);
+ srcBlend = GL_SRC_ALPHA;
+ dstBlend = GL_ONE_MINUS_SRC_ALPHA;
}
-
- switch (stateblock->state.render_states[WINED3DRS_SRCBLEND])
+ else if (d3d_blend == WINED3DBLEND_BOTHINVSRCALPHA)
{
- case WINED3DBLEND_ZERO : srcBlend = GL_ZERO; break;
- case WINED3DBLEND_ONE : srcBlend = GL_ONE; break;
- case WINED3DBLEND_SRCCOLOR : srcBlend = GL_SRC_COLOR; break;
- case WINED3DBLEND_INVSRCCOLOR : srcBlend = GL_ONE_MINUS_SRC_COLOR; break;
- case WINED3DBLEND_SRCALPHA : srcBlend = GL_SRC_ALPHA; break;
- case WINED3DBLEND_INVSRCALPHA : srcBlend = GL_ONE_MINUS_SRC_ALPHA; break;
- case WINED3DBLEND_DESTCOLOR : srcBlend = GL_DST_COLOR; break;
- case WINED3DBLEND_INVDESTCOLOR : srcBlend = GL_ONE_MINUS_DST_COLOR; break;
- case WINED3DBLEND_SRCALPHASAT : srcBlend = GL_SRC_ALPHA_SATURATE; break;
-
- case WINED3DBLEND_DESTALPHA :
- srcBlend = target->resource.format->alpha_mask ? GL_DST_ALPHA : GL_ONE;
- break;
- case WINED3DBLEND_INVDESTALPHA :
- srcBlend = target->resource.format->alpha_mask ? GL_ONE_MINUS_DST_ALPHA : GL_ZERO;
- break;
-
- case WINED3DBLEND_BOTHSRCALPHA : srcBlend = GL_SRC_ALPHA;
- dstBlend = GL_ONE_MINUS_SRC_ALPHA;
- break;
-
- case WINED3DBLEND_BOTHINVSRCALPHA : srcBlend = GL_ONE_MINUS_SRC_ALPHA;
- dstBlend = GL_SRC_ALPHA;
- break;
-
- case WINED3DBLEND_BLENDFACTOR : srcBlend = GL_CONSTANT_COLOR; break;
- case WINED3DBLEND_INVBLENDFACTOR : srcBlend = GL_ONE_MINUS_CONSTANT_COLOR; break;
- default:
- FIXME("Unrecognized src blend value %#x.\n",
- stateblock->state.render_states[WINED3DRS_SRCBLEND]);
+ srcBlend = GL_ONE_MINUS_SRC_ALPHA;
+ dstBlend = GL_SRC_ALPHA;
+ }
+ else
+ {
+ srcBlend = gl_blend_factor(d3d_blend, target->resource.format);
+ dstBlend = gl_blend_factor(stateblock->state.render_states[WINED3DRS_DESTBLEND],
+ target->resource.format);
}
if (stateblock->state.render_states[WINED3DRS_EDGEANTIALIAS]
@@ -378,8 +359,7 @@ static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
if (stateblock->state.render_states[WINED3DRS_SEPARATEALPHABLENDENABLE])
{
- int srcBlendAlpha = GL_ZERO;
- int dstBlendAlpha = GL_ZERO;
+ GLenum srcBlendAlpha, dstBlendAlpha;
/* Separate alpha blending requires GL_EXT_blend_function_separate, so make sure it is around */
if (!context->gl_info->supported[EXT_BLEND_FUNC_SEPARATE])
@@ -388,68 +368,25 @@ static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
return;
}
- switch (stateblock->state.render_states[WINED3DRS_DESTBLENDALPHA])
+ /* WINED3DBLEND_BOTHSRCALPHA and WINED3DBLEND_BOTHINVSRCALPHA are legacy
+ * source blending values which are still valid up to d3d9. They should
+ * not occur as dest blend values. */
+ d3d_blend = stateblock->state.render_states[WINED3DRS_SRCBLENDALPHA];
+ if (d3d_blend == WINED3DBLEND_BOTHSRCALPHA)
{
- case WINED3DBLEND_ZERO : dstBlendAlpha = GL_ZERO; break;
- case WINED3DBLEND_ONE : dstBlendAlpha = GL_ONE; break;
- case WINED3DBLEND_SRCCOLOR : dstBlendAlpha = GL_SRC_COLOR; break;
- case WINED3DBLEND_INVSRCCOLOR : dstBlendAlpha = GL_ONE_MINUS_SRC_COLOR; break;
- case WINED3DBLEND_SRCALPHA : dstBlendAlpha = GL_SRC_ALPHA; break;
- case WINED3DBLEND_INVSRCALPHA : dstBlendAlpha = GL_ONE_MINUS_SRC_ALPHA; break;
- case WINED3DBLEND_DESTCOLOR : dstBlendAlpha = GL_DST_COLOR; break;
- case WINED3DBLEND_INVDESTCOLOR : dstBlendAlpha = GL_ONE_MINUS_DST_COLOR; break;
- case WINED3DBLEND_DESTALPHA : dstBlendAlpha = GL_DST_ALPHA; break;
- case WINED3DBLEND_INVDESTALPHA : dstBlendAlpha = GL_DST_ALPHA; break;
- case WINED3DBLEND_SRCALPHASAT :
- dstBlend = GL_SRC_ALPHA_SATURATE;
- WARN("Application uses SRCALPHASAT as dest blend factor, expect problems\n");
- break;
- /* WINED3DBLEND_BOTHSRCALPHA and WINED3DBLEND_BOTHINVSRCALPHA are legacy source blending
- * values which are still valid up to d3d9. They should not occur as dest blend values
- */
- case WINED3DBLEND_BOTHSRCALPHA :
- dstBlendAlpha = GL_SRC_ALPHA;
- srcBlendAlpha = GL_SRC_ALPHA;
- FIXME("WINED3DRS_DESTBLENDALPHA = WINED3DBLEND_BOTHSRCALPHA, what to do?\n");
- break;
- case WINED3DBLEND_BOTHINVSRCALPHA :
- dstBlendAlpha = GL_ONE_MINUS_SRC_ALPHA;
- srcBlendAlpha = GL_ONE_MINUS_SRC_ALPHA;
- FIXME("WINED3DRS_DESTBLENDALPHA = WINED3DBLEND_BOTHINVSRCALPHA, what to do?\n");
- break;
- case WINED3DBLEND_BLENDFACTOR : dstBlendAlpha = GL_CONSTANT_COLOR; break;
- case WINED3DBLEND_INVBLENDFACTOR : dstBlendAlpha = GL_ONE_MINUS_CONSTANT_COLOR; break;
- default:
- FIXME("Unrecognized dst blend alpha value %#x.\n",
- stateblock->state.render_states[WINED3DRS_DESTBLENDALPHA]);
+ srcBlendAlpha = GL_SRC_ALPHA;
+ dstBlendAlpha = GL_ONE_MINUS_SRC_ALPHA;
}
-
- switch (stateblock->state.render_states[WINED3DRS_SRCBLENDALPHA])
+ else if (d3d_blend == WINED3DBLEND_BOTHINVSRCALPHA)
{
- case WINED3DBLEND_ZERO : srcBlendAlpha = GL_ZERO; break;
- case WINED3DBLEND_ONE : srcBlendAlpha = GL_ONE; break;
- case WINED3DBLEND_SRCCOLOR : srcBlendAlpha = GL_SRC_COLOR; break;
- case WINED3DBLEND_INVSRCCOLOR : srcBlendAlpha = GL_ONE_MINUS_SRC_COLOR; break;
- case WINED3DBLEND_SRCALPHA : srcBlendAlpha = GL_SRC_ALPHA; break;
- case WINED3DBLEND_INVSRCALPHA : srcBlendAlpha = GL_ONE_MINUS_SRC_ALPHA; break;
- case WINED3DBLEND_DESTCOLOR : srcBlendAlpha = GL_DST_COLOR; break;
- case WINED3DBLEND_INVDESTCOLOR : srcBlendAlpha = GL_ONE_MINUS_DST_COLOR; break;
- case WINED3DBLEND_SRCALPHASAT : srcBlendAlpha = GL_SRC_ALPHA_SATURATE; break;
- case WINED3DBLEND_DESTALPHA : srcBlendAlpha = GL_DST_ALPHA; break;
- case WINED3DBLEND_INVDESTALPHA : srcBlendAlpha = GL_DST_ALPHA; break;
- case WINED3DBLEND_BOTHSRCALPHA :
- srcBlendAlpha = GL_SRC_ALPHA;
- dstBlendAlpha = GL_ONE_MINUS_SRC_ALPHA;
- break;
- case WINED3DBLEND_BOTHINVSRCALPHA :
- srcBlendAlpha = GL_ONE_MINUS_SRC_ALPHA;
- dstBlendAlpha = GL_SRC_ALPHA;
- break;
- case WINED3DBLEND_BLENDFACTOR : srcBlendAlpha = GL_CONSTANT_COLOR; break;
- case WINED3DBLEND_INVBLENDFACTOR : srcBlendAlpha = GL_ONE_MINUS_CONSTANT_COLOR; break;
- default:
- FIXME("Unrecognized src blend alpha value %#x.\n",
- stateblock->state.render_states[WINED3DRS_SRCBLENDALPHA]);
+ srcBlendAlpha = GL_ONE_MINUS_SRC_ALPHA;
+ dstBlendAlpha = GL_SRC_ALPHA;
+ }
+ else
+ {
+ srcBlendAlpha = gl_blend_factor(d3d_blend, target->resource.format);
+ dstBlendAlpha = gl_blend_factor(stateblock->state.render_states[WINED3DRS_DESTBLENDALPHA],
+ target->resource.format);
}
GL_EXTCALL(glBlendFuncSeparateEXT(srcBlend, dstBlend, srcBlendAlpha, dstBlendAlpha));
@@ -466,12 +403,12 @@ static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
stateblock_apply_state(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), stateblock, context);
}
-static void state_blendfactor_w(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_blendfactor_w(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
WARN("Unsupported in local OpenGL implementation: glBlendColorEXT\n");
}
-static void state_blendfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_blendfactor(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
float col[4];
@@ -482,7 +419,7 @@ static void state_blendfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, s
checkGLcall("glBlendColor");
}
-static void state_alpha(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_alpha(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
int glParm = 0;
float ref;
@@ -498,12 +435,12 @@ static void state_alpha(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
*/
if (stateblock->state.textures[0])
{
- IWineD3DBaseTextureImpl *texture = stateblock->state.textures[0];
- GLenum texture_dimensions = texture->baseTexture.target;
+ struct wined3d_texture *texture = stateblock->state.textures[0];
+ GLenum 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)
{
@@ -547,7 +484,7 @@ static void state_alpha(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
}
}
-static void state_clipping(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_clipping(DWORD state_id, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_state *state = &stateblock->state;
@@ -629,16 +566,36 @@ static void state_clipping(DWORD state_id, IWineD3DStateBlockImpl *stateblock, s
}
}
-static void state_blendop_w(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_blendop_w(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
WARN("Unsupported in local OpenGL implementation: glBlendEquation\n");
}
-static void state_blendop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static GLenum gl_blend_op(WINED3DBLENDOP op)
+{
+ switch (op)
+ {
+ case WINED3DBLENDOP_ADD:
+ return GL_FUNC_ADD_EXT;
+ case WINED3DBLENDOP_SUBTRACT:
+ return GL_FUNC_SUBTRACT_EXT;
+ case WINED3DBLENDOP_REVSUBTRACT:
+ return GL_FUNC_REVERSE_SUBTRACT_EXT;
+ case WINED3DBLENDOP_MIN:
+ return GL_MIN_EXT;
+ case WINED3DBLENDOP_MAX:
+ return GL_MAX_EXT;
+ default:
+ FIXME("Unhandled blend op %#x.\n", op);
+ return GL_NONE;
+ }
+}
+
+static void state_blendop(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
- int blendEquation = GL_FUNC_ADD;
- int blendEquationAlpha = GL_FUNC_ADD;
+ int blendEquation = GL_FUNC_ADD_EXT;
+ int blendEquationAlpha = GL_FUNC_ADD_EXT;
/* BLENDOPALPHA requires GL_EXT_blend_equation_separate, so make sure it is around */
if (stateblock->state.render_states[WINED3DRS_BLENDOPALPHA]
@@ -648,29 +605,8 @@ static void state_blendop(DWORD state, IWineD3DStateBlockImpl *stateblock, struc
return;
}
- switch (stateblock->state.render_states[WINED3DRS_BLENDOP])
- {
- case WINED3DBLENDOP_ADD : blendEquation = GL_FUNC_ADD; break;
- case WINED3DBLENDOP_SUBTRACT : blendEquation = GL_FUNC_SUBTRACT; break;
- case WINED3DBLENDOP_REVSUBTRACT : blendEquation = GL_FUNC_REVERSE_SUBTRACT; break;
- case WINED3DBLENDOP_MIN : blendEquation = GL_MIN; break;
- case WINED3DBLENDOP_MAX : blendEquation = GL_MAX; break;
- default:
- FIXME("Unrecognized/Unhandled D3DBLENDOP value %#x.\n",
- stateblock->state.render_states[WINED3DRS_BLENDOP]);
- }
-
- switch (stateblock->state.render_states[WINED3DRS_BLENDOPALPHA])
- {
- case WINED3DBLENDOP_ADD : blendEquationAlpha = GL_FUNC_ADD; break;
- case WINED3DBLENDOP_SUBTRACT : blendEquationAlpha = GL_FUNC_SUBTRACT; break;
- case WINED3DBLENDOP_REVSUBTRACT : blendEquationAlpha = GL_FUNC_REVERSE_SUBTRACT; break;
- case WINED3DBLENDOP_MIN : blendEquationAlpha = GL_MIN; break;
- case WINED3DBLENDOP_MAX : blendEquationAlpha = GL_MAX; break;
- default:
- FIXME("Unrecognized/Unhandled D3DBLENDOP value %#x\n",
- stateblock->state.render_states[WINED3DRS_BLENDOPALPHA]);
- }
+ blendEquation = gl_blend_op(stateblock->state.render_states[WINED3DRS_BLENDOP]);
+ blendEquationAlpha = gl_blend_op(stateblock->state.render_states[WINED3DRS_BLENDOPALPHA]);
if (stateblock->state.render_states[WINED3DRS_SEPARATEALPHABLENDENABLE])
{
@@ -684,7 +620,7 @@ static void state_blendop(DWORD state, IWineD3DStateBlockImpl *stateblock, struc
}
}
-static void state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_specularenable(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
/* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
@@ -801,7 +737,7 @@ static void state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock
checkGLcall("glMaterialfv(GL_EMISSION)");
}
-static void state_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_texfactor(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
unsigned int i;
@@ -841,7 +777,7 @@ static void renderstate_stencil_twosided(struct wined3d_context *context, GLint
checkGLcall("glStencilOp(...)");
}
-static void state_stencil(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_stencil(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
DWORD onesided_enable = FALSE;
@@ -858,7 +794,7 @@ static void state_stencil(DWORD state, IWineD3DStateBlockImpl *stateblock, struc
GLint stencilPass_ccw = GL_KEEP;
/* No stencil test without a stencil buffer. */
- if (!stateblock->device->depth_stencil)
+ if (!stateblock->device->fb.depth_stencil)
{
glDisable(GL_STENCIL_TEST);
checkGLcall("glDisable GL_STENCIL_TEST");
@@ -939,9 +875,9 @@ static void state_stencil(DWORD state, IWineD3DStateBlockImpl *stateblock, struc
}
}
-static void state_stencilwrite2s(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_stencilwrite2s(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
- DWORD mask = stateblock->device->depth_stencil ? stateblock->state.render_states[WINED3DRS_STENCILWRITEMASK] : 0;
+ DWORD mask = stateblock->device->fb.depth_stencil ? stateblock->state.render_states[WINED3DRS_STENCILWRITEMASK] : 0;
const struct wined3d_gl_info *gl_info = context->gl_info;
GL_EXTCALL(glActiveStencilFaceEXT(GL_BACK));
@@ -953,15 +889,15 @@ static void state_stencilwrite2s(DWORD state, IWineD3DStateBlockImpl *stateblock
glStencilMask(mask);
}
-static void state_stencilwrite(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_stencilwrite(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
- DWORD mask = stateblock->device->depth_stencil ? stateblock->state.render_states[WINED3DRS_STENCILWRITEMASK] : 0;
+ DWORD mask = stateblock->device->fb.depth_stencil ? stateblock->state.render_states[WINED3DRS_STENCILWRITEMASK] : 0;
glStencilMask(mask);
checkGLcall("glStencilMask");
}
-static void state_fog_vertexpart(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_fog_vertexpart(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
TRACE("state %#x, stateblock %p, context %p\n", state, stateblock, context);
@@ -1001,7 +937,7 @@ static void state_fog_vertexpart(DWORD state, IWineD3DStateBlockImpl *stateblock
}
}
-void state_fogstartend(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+void state_fogstartend(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
float fogstart, fogend;
union {
@@ -1050,7 +986,7 @@ void state_fogstartend(DWORD state, IWineD3DStateBlockImpl *stateblock, struct w
TRACE("Fog End == %f\n", fogend);
}
-void state_fog_fragpart(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+void state_fog_fragpart(DWORD state_id, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_state *state = &stateblock->state;
enum fogsource new_source;
@@ -1202,13 +1138,13 @@ void state_fog_fragpart(DWORD state_id, IWineD3DStateBlockImpl *stateblock, stru
}
}
-static void state_rangefog_w(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_rangefog_w(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_RANGEFOGENABLE])
WARN("Range fog enabled, but not supported by this opengl implementation\n");
}
-static void state_rangefog(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_rangefog(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_RANGEFOGENABLE])
{
@@ -1220,7 +1156,7 @@ static void state_rangefog(DWORD state, IWineD3DStateBlockImpl *stateblock, stru
}
}
-void state_fogcolor(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+void state_fogcolor(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
float col[4];
D3DCOLORTOGLFLOAT4(stateblock->state.render_states[WINED3DRS_FOGCOLOR], col);
@@ -1228,7 +1164,7 @@ void state_fogcolor(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine
checkGLcall("glFog GL_FOG_COLOR");
}
-void state_fogdensity(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+void state_fogdensity(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
union {
DWORD d;
@@ -1239,10 +1175,10 @@ void state_fogdensity(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wi
checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)");
}
-static void state_colormat(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_colormat(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;
GLenum Parm = 0;
/* Depends on the decoded vertex declaration to read the existence of diffuse data.
@@ -1363,7 +1299,7 @@ static void state_colormat(DWORD state_id, IWineD3DStateBlockImpl *stateblock, s
context->tracking_parm = Parm;
}
-static void state_linepattern(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_linepattern(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
union {
DWORD d;
@@ -1384,37 +1320,7 @@ static void state_linepattern(DWORD state, IWineD3DStateBlockImpl *stateblock, s
}
}
-static void state_zbias(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
-{
- union {
- DWORD d;
- float f;
- } tmpvalue;
-
- if (stateblock->state.render_states[WINED3DRS_ZBIAS])
- {
- tmpvalue.d = stateblock->state.render_states[WINED3DRS_ZBIAS];
- TRACE("ZBias value %f\n", tmpvalue.f);
- glPolygonOffset(0, -tmpvalue.f);
- checkGLcall("glPolygonOffset(0, -Value)");
- glEnable(GL_POLYGON_OFFSET_FILL);
- checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL);");
- glEnable(GL_POLYGON_OFFSET_LINE);
- checkGLcall("glEnable(GL_POLYGON_OFFSET_LINE);");
- glEnable(GL_POLYGON_OFFSET_POINT);
- checkGLcall("glEnable(GL_POLYGON_OFFSET_POINT);");
- } else {
- glDisable(GL_POLYGON_OFFSET_FILL);
- checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL);");
- glDisable(GL_POLYGON_OFFSET_LINE);
- checkGLcall("glDisable(GL_POLYGON_OFFSET_LINE);");
- glDisable(GL_POLYGON_OFFSET_POINT);
- checkGLcall("glDisable(GL_POLYGON_OFFSET_POINT);");
- }
-}
-
-
-static void state_normalize(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_normalize(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if(isStateDirty(context, STATE_VDECL)) {
return;
@@ -1434,7 +1340,7 @@ static void state_normalize(DWORD state, IWineD3DStateBlockImpl *stateblock, str
}
}
-static void state_psizemin_w(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_psizemin_w(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
union {
DWORD d;
@@ -1454,7 +1360,7 @@ static void state_psizemin_w(DWORD state, IWineD3DStateBlockImpl *stateblock, st
}
-static void state_psizemin_ext(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_psizemin_ext(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
union
@@ -1477,7 +1383,7 @@ static void state_psizemin_ext(DWORD state, IWineD3DStateBlockImpl *stateblock,
checkGLcall("glPointParameterfEXT(...)");
}
-static void state_psizemin_arb(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_psizemin_arb(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
union
@@ -1500,7 +1406,7 @@ static void state_psizemin_arb(DWORD state, IWineD3DStateBlockImpl *stateblock,
checkGLcall("glPointParameterfARB(...)");
}
-static void state_pscale(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_pscale(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
/* TODO: Group this with the viewport */
@@ -1579,12 +1485,12 @@ static void state_pscale(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
checkGLcall("glPointSize(...);");
}
-static void state_debug_monitor(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_debug_monitor(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
WARN("token: %#x\n", stateblock->state.render_states[WINED3DRS_DEBUGMONITORTOKEN]);
}
-static void state_colorwrite(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_colorwrite(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
DWORD mask0 = stateblock->state.render_states[WINED3DRS_COLORWRITEENABLE];
DWORD mask1 = stateblock->state.render_states[WINED3DRS_COLORWRITEENABLE1];
@@ -1620,27 +1526,27 @@ static void set_color_mask(const struct wined3d_gl_info *gl_info, UINT index, DW
mask & WINED3DCOLORWRITEENABLE_ALPHA ? GL_TRUE : GL_FALSE));
}
-static void state_colorwrite0(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_colorwrite0(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
set_color_mask(context->gl_info, 0, stateblock->state.render_states[WINED3DRS_COLORWRITEENABLE]);
}
-static void state_colorwrite1(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_colorwrite1(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
set_color_mask(context->gl_info, 1, stateblock->state.render_states[WINED3DRS_COLORWRITEENABLE1]);
}
-static void state_colorwrite2(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_colorwrite2(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
set_color_mask(context->gl_info, 2, stateblock->state.render_states[WINED3DRS_COLORWRITEENABLE2]);
}
-static void state_colorwrite3(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_colorwrite3(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
set_color_mask(context->gl_info, 3, stateblock->state.render_states[WINED3DRS_COLORWRITEENABLE3]);
}
-static void state_localviewer(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_localviewer(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_LOCALVIEWER])
{
@@ -1652,7 +1558,7 @@ static void state_localviewer(DWORD state, IWineD3DStateBlockImpl *stateblock, s
}
}
-static void state_lastpixel(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_lastpixel(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_LASTPIXEL])
{
@@ -1668,7 +1574,7 @@ static void state_lastpixel(DWORD state, IWineD3DStateBlockImpl *stateblock, str
}
}
-static void state_pointsprite_w(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_pointsprite_w(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
static BOOL warned;
@@ -1681,7 +1587,7 @@ static void state_pointsprite_w(DWORD state, IWineD3DStateBlockImpl *stateblock,
}
}
-static void state_pointsprite(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_pointsprite(DWORD state_id, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_state *state = &stateblock->state;
@@ -1707,7 +1613,7 @@ static void state_pointsprite(DWORD state_id, IWineD3DStateBlockImpl *stateblock
}
}
-static void state_wrap(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_wrap(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
/**
http://www.cosc.brocku.ca/Offerings/3P98/course/lectures/texture/
@@ -1738,13 +1644,13 @@ static void state_wrap(DWORD state, IWineD3DStateBlockImpl *stateblock, struct w
}
}
-static void state_msaa_w(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_msaa_w(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_MULTISAMPLEANTIALIAS])
WARN("Multisample antialiasing not supported by gl\n");
}
-static void state_msaa(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_msaa(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_MULTISAMPLEANTIALIAS])
{
@@ -1756,7 +1662,7 @@ static void state_msaa(DWORD state, IWineD3DStateBlockImpl *stateblock, struct w
}
}
-static void state_scissor(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_scissor(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_SCISSORTESTENABLE])
{
@@ -1774,14 +1680,17 @@ static void state_scissor(DWORD state, IWineD3DStateBlockImpl *stateblock, struc
* convert from D3D to GL we need to divide the D3D depth bias by that value.
* There's no practical way to retrieve that value from a given GL
* implementation, but the D3D application has essentially the same problem,
- * which makes a guess of 1e-6f seem reasonable here. Note that
- * SLOPESCALEDEPTHBIAS is a scaling factor for the depth slope, and doesn't
- * need to be scaled. */
-static void state_depthbias(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+ * which makes a guess of the depth buffer format's highest possible value a
+ * reasonable guess. Note that SLOPESCALEDEPTHBIAS is a scaling factor for the
+ * depth slope, and doesn't need to be scaled. */
+static void state_depthbias(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_SLOPESCALEDEPTHBIAS]
|| stateblock->state.render_states[WINED3DRS_DEPTHBIAS])
{
+ struct wined3d_surface *depth = stateblock->device->fb.depth_stencil;
+ float scale;
+
union
{
DWORD d;
@@ -1794,7 +1703,21 @@ static void state_depthbias(DWORD state, IWineD3DStateBlockImpl *stateblock, str
glEnable(GL_POLYGON_OFFSET_FILL);
checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL)");
- glPolygonOffset(scale_bias.f, const_bias.f * 1e6f);
+ if (depth)
+ {
+ const struct wined3d_format *fmt = depth->resource.format;
+ scale = powf(2, fmt->depth_size) - 1;
+ TRACE("Depth format %s, using depthbias scale of %f\n",
+ debug_d3dformat(fmt->id), scale);
+ }
+ else
+ {
+ /* The context manager will reapply this state on a depth stencil change */
+ TRACE("No depth stencil, using depthbias scale of 0.0\n");
+ scale = 0;
+ }
+
+ glPolygonOffset(scale_bias.f, const_bias.f * scale);
checkGLcall("glPolygonOffset(...)");
} else {
glDisable(GL_POLYGON_OFFSET_FILL);
@@ -1802,13 +1725,13 @@ static void state_depthbias(DWORD state, IWineD3DStateBlockImpl *stateblock, str
}
}
-static void state_zvisible(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_zvisible(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_ZVISIBLE])
FIXME("WINED3DRS_ZVISIBLE not implemented.\n");
}
-static void state_perspective(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_perspective(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_TEXTUREPERSPECTIVE])
{
@@ -1820,33 +1743,33 @@ static void state_perspective(DWORD state, IWineD3DStateBlockImpl *stateblock, s
}
}
-static void state_stippledalpha(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_stippledalpha(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_STIPPLEDALPHA])
FIXME(" Stippled Alpha not supported yet.\n");
}
-static void state_antialias(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_antialias(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_ANTIALIAS])
FIXME("Antialias not supported yet.\n");
}
-static void state_multisampmask(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_multisampmask(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_MULTISAMPLEMASK] != 0xffffffff)
FIXME("WINED3DRS_MULTISAMPLEMASK %#x not yet implemented.\n",
stateblock->state.render_states[WINED3DRS_MULTISAMPLEMASK]);
}
-static void state_patchedgestyle(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_patchedgestyle(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_PATCHEDGESTYLE] != WINED3DPATCHEDGE_DISCRETE)
FIXME("WINED3DRS_PATCHEDGESTYLE %#x not yet implemented.\n",
stateblock->state.render_states[WINED3DRS_PATCHEDGESTYLE]);
}
-static void state_patchsegments(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_patchsegments(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
union {
DWORD d;
@@ -1866,28 +1789,28 @@ static void state_patchsegments(DWORD state, IWineD3DStateBlockImpl *stateblock,
}
}
-static void state_positiondegree(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_positiondegree(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_POSITIONDEGREE] != WINED3DDEGREE_CUBIC)
FIXME("WINED3DRS_POSITIONDEGREE %#x not yet implemented.\n",
stateblock->state.render_states[WINED3DRS_POSITIONDEGREE]);
}
-static void state_normaldegree(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_normaldegree(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_NORMALDEGREE] != WINED3DDEGREE_LINEAR)
FIXME("WINED3DRS_NORMALDEGREE %#x not yet implemented.\n",
stateblock->state.render_states[WINED3DRS_NORMALDEGREE]);
}
-static void state_tessellation(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_tessellation(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_ENABLEADAPTIVETESSELLATION])
FIXME("WINED3DRS_ENABLEADAPTIVETESSELLATION %#x not yet implemented.\n",
stateblock->state.render_states[WINED3DRS_ENABLEADAPTIVETESSELLATION]);
}
-static void state_nvdb(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_nvdb(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
union {
DWORD d;
@@ -1923,91 +1846,91 @@ static void state_nvdb(DWORD state, IWineD3DStateBlockImpl *stateblock, struct w
state_tessellation(state, stateblock, context);
}
-static void state_wrapu(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_wrapu(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_WRAPU])
FIXME("Render state WINED3DRS_WRAPU not implemented yet.\n");
}
-static void state_wrapv(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_wrapv(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_WRAPV])
FIXME("Render state WINED3DRS_WRAPV not implemented yet.\n");
}
-static void state_monoenable(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_monoenable(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_MONOENABLE])
FIXME("Render state WINED3DRS_MONOENABLE not implemented yet.\n");
}
-static void state_rop2(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_rop2(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_ROP2])
FIXME("Render state WINED3DRS_ROP2 not implemented yet.\n");
}
-static void state_planemask(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_planemask(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_PLANEMASK])
FIXME("Render state WINED3DRS_PLANEMASK not implemented yet.\n");
}
-static void state_subpixel(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_subpixel(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_SUBPIXEL])
FIXME("Render state WINED3DRS_SUBPIXEL not implemented yet.\n");
}
-static void state_subpixelx(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_subpixelx(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_SUBPIXELX])
FIXME("Render state WINED3DRS_SUBPIXELX not implemented yet.\n");
}
-static void state_stippleenable(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_stippleenable(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_STIPPLEENABLE])
FIXME("Render state WINED3DRS_STIPPLEENABLE not implemented yet.\n");
}
-static void state_mipmaplodbias(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_mipmaplodbias(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_MIPMAPLODBIAS])
FIXME("Render state WINED3DRS_MIPMAPLODBIAS not implemented yet.\n");
}
-static void state_anisotropy(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_anisotropy(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_ANISOTROPY])
FIXME("Render state WINED3DRS_ANISOTROPY not implemented yet.\n");
}
-static void state_flushbatch(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_flushbatch(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_FLUSHBATCH])
FIXME("Render state WINED3DRS_FLUSHBATCH not implemented yet.\n");
}
-static void state_translucentsi(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_translucentsi(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_TRANSLUCENTSORTINDEPENDENT])
FIXME("Render state WINED3DRS_TRANSLUCENTSORTINDEPENDENT not implemented yet.\n");
}
-static void state_extents(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_extents(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_EXTENTS])
FIXME("Render state WINED3DRS_EXTENTS not implemented yet.\n");
}
-static void state_ckeyblend(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_ckeyblend(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_COLORKEYBLENDENABLE])
FIXME("Render state WINED3DRS_COLORKEYBLENDENABLE not implemented yet.\n");
}
-static void state_swvp(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_swvp(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (stateblock->state.render_states[WINED3DRS_SOFTWAREVERTEXPROCESSING])
FIXME("Software vertex processing not implemented.\n");
@@ -3100,7 +3023,7 @@ static void set_tex_op(const struct wined3d_gl_info *gl_info, const struct wined
}
-static void tex_colorop(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void tex_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);
@@ -3163,7 +3086,7 @@ static void tex_colorop(DWORD state_id, IWineD3DStateBlockImpl *stateblock, stru
state->texture_states[stage][WINED3DTSS_COLORARG0]);
}
-void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+void tex_alphaop(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
BOOL tex_used = stateblock->device->fixed_function_usage_map & (1 << stage);
@@ -3191,12 +3114,12 @@ void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d
if (stateblock->state.render_states[WINED3DRS_COLORKEYENABLE] && !stage && stateblock->state.textures[0])
{
- IWineD3DBaseTextureImpl *texture = stateblock->state.textures[0];
- GLenum texture_dimensions = texture->baseTexture.target;
+ struct wined3d_texture *texture = stateblock->state.textures[0];
+ GLenum 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)
{
@@ -3264,7 +3187,7 @@ void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d
}
}
-static void transform_texture(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void transform_texture(DWORD state_id, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
DWORD texUnit = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
DWORD mapped_stage = stateblock->device->texUnitMap[texUnit];
@@ -3307,7 +3230,7 @@ static void transform_texture(DWORD state_id, IWineD3DStateBlockImpl *stateblock
if (!use_ps(state))
{
TRACE("Non power two matrix multiply fixup\n");
- glMultMatrixf(state->textures[texUnit]->baseTexture.pow2Matrix);
+ glMultMatrixf(state->textures[texUnit]->pow2_matrix);
}
}
}
@@ -3323,7 +3246,7 @@ static void unloadTexCoords(const struct wined3d_gl_info *gl_info)
}
}
-static void loadTexCoords(const struct wined3d_gl_info *gl_info, IWineD3DStateBlockImpl *stateblock,
+static void loadTexCoords(const struct wined3d_gl_info *gl_info, struct wined3d_stateblock *stateblock,
const struct wined3d_stream_info *si, GLuint *curVBO)
{
unsigned int mapped_stage = 0;
@@ -3374,7 +3297,7 @@ static void loadTexCoords(const struct wined3d_gl_info *gl_info, IWineD3DStateBl
checkGLcall("loadTexCoords");
}
-static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void tex_coordindex(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];
@@ -3550,10 +3473,10 @@ static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, stru
}
}
-static void shaderconstant(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void shaderconstant(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;
/* Vertex and pixel shader states will call a shader upload, don't do anything as long one of them
* has an update pending
@@ -3566,12 +3489,12 @@ static void shaderconstant(DWORD state_id, IWineD3DStateBlockImpl *stateblock, s
device->shader_backend->shader_load_constants(context, use_ps(state), use_vs(state));
}
-static void tex_bumpenvlscale(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void tex_bumpenvlscale(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
- IWineD3DPixelShaderImpl *ps = stateblock->state.pixel_shader;
+ const struct wined3d_shader *ps = stateblock->state.pixel_shader;
- if (ps && stage && (ps->baseShader.reg_maps.luminanceparams & (1 << stage)))
+ if (ps && stage && (ps->reg_maps.luminanceparams & (1 << stage)))
{
/* The pixel shader has to know the luminance scale. Do a constants update if it
* isn't scheduled anyway
@@ -3583,23 +3506,24 @@ static void tex_bumpenvlscale(DWORD state, IWineD3DStateBlockImpl *stateblock, s
}
}
-static void sampler_texmatrix(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void sampler_texmatrix(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const DWORD sampler = state - STATE_SAMPLER(0);
- IWineD3DBaseTextureImpl *texture = stateblock->state.textures[sampler];
+ struct wined3d_texture *texture = stateblock->state.textures[sampler];
TRACE("state %#x, stateblock %p, context %p\n", state, stateblock, context);
if(!texture) return;
/* The fixed function np2 texture emulation uses the texture matrix to fix up the coordinates
- * basetexture_apply_state_changes() multiplies the set matrix with a fixup matrix. Before the
+ * wined3d_texture_apply_state_changes() multiplies the set matrix with a fixup matrix. Before the
* scaling is reapplied or removed, the texture matrix has to be reapplied
*
* The mapped stage is already active because the sampler() function below, which is part of the
* misc pipeline
*/
- if(sampler < MAX_TEXTURES) {
- const BOOL texIsPow2 = !texture->baseTexture.pow2Matrix_identity;
+ if (sampler < MAX_TEXTURES)
+ {
+ const BOOL texIsPow2 = !(texture->flags & WINED3D_TEXTURE_POW2_MAT_IDENT);
if (texIsPow2 || (context->lastWasPow2Texture & (1 << sampler)))
{
@@ -3611,10 +3535,11 @@ static void sampler_texmatrix(DWORD state, IWineD3DStateBlockImpl *stateblock, s
}
}
-static void sampler(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void sampler(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];
+ struct wined3d_device *device = stateblock->device;
+ DWORD mapped_stage = device->texUnitMap[sampler];
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_state *state = &stateblock->state;
union {
@@ -3642,13 +3567,11 @@ static void sampler(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct w
if (state->textures[sampler])
{
- IWineD3DBaseTexture *texture = (IWineD3DBaseTexture *)state->textures[sampler];
+ struct wined3d_texture *texture = state->textures[sampler];
BOOL srgb = state->sampler_states[sampler][WINED3DSAMP_SRGBTEXTURE];
- IWineD3DBaseTexture_BindTexture(texture, srgb);
- basetexture_apply_state_changes(texture,
- state->texture_states[sampler],
- state->sampler_states[sampler], gl_info);
+ texture->texture_ops->texture_bind(texture, gl_info, srgb);
+ wined3d_texture_apply_state_changes(texture, state->sampler_states[sampler], gl_info);
if (gl_info->supported[EXT_TEXTURE_LOD_BIAS])
{
@@ -3656,7 +3579,7 @@ static void sampler(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct w
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
GL_TEXTURE_LOD_BIAS_EXT,
tmpvalue.f);
- checkGLcall("glTexEnvi(GL_TEXTURE_LOD_BIAS_EXT, ...)");
+ checkGLcall("glTexEnvf(GL_TEXTURE_LOD_BIAS_EXT, ...)");
}
if (!use_ps(state) && sampler < state->lowest_disabled_stage)
@@ -3671,12 +3594,8 @@ static void sampler(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct w
}
/* Trigger shader constant reloading (for NP2 texcoord fixup) */
- if (!state->textures[sampler]->baseTexture.pow2Matrix_identity)
- {
- IWineD3DDeviceImpl *d3ddevice = stateblock->device;
- d3ddevice->shader_backend->shader_load_np2fixup_constants(
- (IWineD3DDevice*)d3ddevice, use_ps(state), use_vs(state));
- }
+ if (!(texture->flags & WINED3D_TEXTURE_POW2_MAT_IDENT))
+ device->shader_backend->shader_load_np2fixup_constants(device->shader_priv, gl_info, state);
}
else if (mapped_stage < gl_info->limits.textures)
{
@@ -3691,15 +3610,15 @@ static void sampler(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct w
state_alpha(WINED3DRS_COLORKEYENABLE, stateblock, context);
}
} /* Otherwise tex_colorop disables the stage */
- glBindTexture(GL_TEXTURE_2D, stateblock->device->dummyTextureName[sampler]);
- checkGLcall("glBindTexture(GL_TEXTURE_2D, stateblock->device->dummyTextureName[sampler])");
+ glBindTexture(GL_TEXTURE_2D, device->dummyTextureName[sampler]);
+ checkGLcall("glBindTexture(GL_TEXTURE_2D, device->dummyTextureName[sampler])");
}
}
-void apply_pixelshader(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+void 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);
BOOL use_pshader = use_ps(state);
unsigned int i;
@@ -3741,12 +3660,12 @@ void apply_pixelshader(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struc
}
}
-static void shader_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void shader_bumpenvmat(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
- IWineD3DPixelShaderImpl *ps = stateblock->state.pixel_shader;
+ const struct wined3d_shader *ps = stateblock->state.pixel_shader;
- if (ps && stage && (ps->baseShader.reg_maps.bumpmat & (1 << stage)))
+ if (ps && stage && (ps->reg_maps.bumpmat & (1 << stage)))
{
/* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled
* anyway
@@ -3758,7 +3677,7 @@ static void shader_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, s
}
}
-static void transform_world(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void transform_world(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
/* This function is called by transform_view below if the view matrix was changed too
*
@@ -3790,7 +3709,7 @@ static void transform_world(DWORD state, IWineD3DStateBlockImpl *stateblock, str
}
}
-static void clipplane(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void clipplane(DWORD state_id, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_state *state = &stateblock->state;
UINT index = state_id - STATE_CLIPPLANE(0);
@@ -3800,24 +3719,17 @@ static void clipplane(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct
return;
}
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+
/* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
if (!use_vs(state))
- {
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
glLoadMatrixf(&state->transforms[WINED3DTS_VIEW].u.m[0][0]);
- }
else
- {
/* with vertex shaders, clip planes are not transformed in direct3d,
* in OpenGL they are still transformed by the model view.
- * Use this to swap the y coordinate if necessary
*/
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
glLoadIdentity();
- if (context->render_offscreen) glScalef(1.0f, -1.0f, 1.0f);
- }
TRACE("Clipplane [%.8e, %.8e, %.8e, %.8e]\n",
state->clip_planes[index][0],
@@ -3830,7 +3742,7 @@ static void clipplane(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct
glPopMatrix();
}
-static void transform_worldex(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void transform_worldex(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
UINT matrix = state - STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0));
GLenum glMat;
@@ -3874,7 +3786,7 @@ static void transform_worldex(DWORD state, IWineD3DStateBlockImpl *stateblock, s
}
}
-static void state_vertexblend_w(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_vertexblend_w(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
WINED3DVERTEXBLENDFLAGS f = stateblock->state.render_states[WINED3DRS_VERTEXBLEND];
static unsigned int once;
@@ -3885,7 +3797,7 @@ static void state_vertexblend_w(DWORD state, IWineD3DStateBlockImpl *stateblock,
else WARN("Vertex blend flags %#x not supported.\n", f);
}
-static void state_vertexblend(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void state_vertexblend(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
WINED3DVERTEXBLENDFLAGS val = stateblock->state.render_states[WINED3DRS_VERTEXBLEND];
const struct wined3d_gl_info *gl_info = context->gl_info;
@@ -3929,7 +3841,7 @@ static void state_vertexblend(DWORD state, IWineD3DStateBlockImpl *stateblock, s
}
}
-static void transform_view(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void transform_view(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_light_info *light = NULL;
@@ -3947,7 +3859,7 @@ static void transform_view(DWORD state, IWineD3DStateBlockImpl *stateblock, stru
checkGLcall("glLoadMatrixf(...)");
/* Reset lights. TODO: Call light apply func */
- for (k = 0; k < stateblock->device->maxConcurrentLights; ++k)
+ for (k = 0; k < gl_info->limits.lights; ++k)
{
light = stateblock->state.lights[k];
if(!light) continue;
@@ -3991,7 +3903,7 @@ static void transform_view(DWORD state, IWineD3DStateBlockImpl *stateblock, stru
}
}
-static void transform_projection(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void transform_projection(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
glMatrixMode(GL_PROJECTION);
checkGLcall("glMatrixMode(GL_PROJECTION)");
@@ -4137,14 +4049,13 @@ static inline void unloadNumberedArrays(struct wined3d_context *context)
}
}
-static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock,
+static void loadNumberedArrays(struct wined3d_stateblock *stateblock,
const struct wined3d_stream_info *stream_info, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
GLuint curVBO = gl_info->supported[ARB_VERTEX_BUFFER_OBJECT] ? ~0U : 0;
int i;
struct wined3d_buffer *vb;
- DWORD_PTR shift_index;
/* Default to no instancing */
stateblock->device->instancedDraw = FALSE;
@@ -4184,31 +4095,12 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock,
* curVBO will be 0. If there is a vertex buffer but no vbo we
* won't be load converted attributes anyway. */
vb = stream->buffer;
- if (curVBO && vb->conversion_shift)
- {
- TRACE("Loading attribute from shifted buffer\n");
- TRACE("Attrib %d has original stride %d, new stride %d\n",
- i, stream_info->elements[i].stride, vb->conversion_stride);
- TRACE("Original offset %p, additional offset 0x%08x\n",
- stream_info->elements[i].data, vb->conversion_shift[(DWORD_PTR)stream_info->elements[i].data]);
- TRACE("Opengl type %#x\n", stream_info->elements[i].format->gl_vtx_type);
- shift_index = ((DWORD_PTR)stream_info->elements[i].data + stream->offset);
- shift_index = shift_index % stream_info->elements[i].stride;
- GL_EXTCALL(glVertexAttribPointerARB(i, stream_info->elements[i].format->gl_vtx_format,
- stream_info->elements[i].format->gl_vtx_type,
- stream_info->elements[i].format->gl_normalized,
- vb->conversion_stride, stream_info->elements[i].data + vb->conversion_shift[shift_index]
- + stateblock->state.load_base_vertex_index * stream_info->elements[i].stride
- + stream->offset));
-
- } else {
- GL_EXTCALL(glVertexAttribPointerARB(i, stream_info->elements[i].format->gl_vtx_format,
- stream_info->elements[i].format->gl_vtx_type,
- stream_info->elements[i].format->gl_normalized,
- stream_info->elements[i].stride, stream_info->elements[i].data
- + stateblock->state.load_base_vertex_index * stream_info->elements[i].stride
- + stream->offset));
- }
+ GL_EXTCALL(glVertexAttribPointerARB(i, stream_info->elements[i].format->gl_vtx_format,
+ stream_info->elements[i].format->gl_vtx_type,
+ stream_info->elements[i].format->gl_normalized,
+ stream_info->elements[i].stride, stream_info->elements[i].data
+ + stateblock->state.load_base_vertex_index * stream_info->elements[i].stride
+ + stream->offset));
if (!(context->numbered_array_mask & (1 << i)))
{
@@ -4320,7 +4212,7 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock,
}
/* Used from 2 different functions, and too big to justify making it inlined */
-static void loadVertexData(const struct wined3d_context *context, IWineD3DStateBlockImpl *stateblock,
+static void loadVertexData(const struct wined3d_context *context, struct wined3d_stateblock *stateblock,
const struct wined3d_stream_info *si)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
@@ -4389,7 +4281,7 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB
{
static const GLbyte one = 1;
GL_EXTCALL(glWeightbvARB(1, &one));
- checkGLcall("glWeightivARB(gl_info->max_blends, weights)");
+ checkGLcall("glWeightbvARB(gl_info->max_blends, weights)");
}
}
@@ -4583,9 +4475,9 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB
loadTexCoords(gl_info, stateblock, si, &curVBO);
}
-static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void streamsrc(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
- IWineD3DDeviceImpl *device = stateblock->device;
+ struct wined3d_device *device = stateblock->device;
BOOL load_numbered = use_vs(&stateblock->state) && !device->useDrawStridedSlow;
BOOL load_named = !use_vs(&stateblock->state) && !device->useDrawStridedSlow;
@@ -4615,27 +4507,21 @@ static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wi
}
}
-static void vertexdeclaration(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void vertexdeclaration(DWORD state_id, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_state *state = &stateblock->state;
+ struct wined3d_device *device = stateblock->device;
BOOL useVertexShaderFunction = use_vs(state);
BOOL usePixelShaderFunction = use_ps(state);
BOOL updateFog = FALSE;
- IWineD3DDeviceImpl *device = stateblock->device;
BOOL transformed;
BOOL wasrhw = context->last_was_rhw;
unsigned int i;
transformed = device->strided_streams.position_transformed;
- if(transformed != context->last_was_rhw && !useVertexShaderFunction) {
+ if (transformed != context->last_was_rhw && !useVertexShaderFunction)
updateFog = TRUE;
- }
-
- /* Reapply lighting if it is not scheduled for reapplication already */
- if(!isStateDirty(context, STATE_RENDER(WINED3DRS_LIGHTING))) {
- state_lighting(STATE_RENDER(WINED3DRS_LIGHTING), stateblock, context);
- }
if (transformed) {
context->last_was_rhw = TRUE;
@@ -4645,20 +4531,6 @@ static void vertexdeclaration(DWORD state_id, IWineD3DStateBlockImpl *stateblock
context->last_was_rhw = FALSE;
/* This turns off the Z scale trick to 'disable' viewport frustum clipping in rhw mode*/
device->untransformed = TRUE;
-
- /* Todo for sw shaders: Vertex Shader output is already transformed, so set up identity matrices
- * Not needed as long as only hw shaders are supported
- */
-
- /* This sets the shader output position correction constants.
- * TODO: Move to the viewport state
- */
- if (useVertexShaderFunction)
- {
- GLfloat yoffset = -(63.0f / 64.0f) / stateblock->state.viewport.Height;
- device->posFixup[1] = context->render_offscreen ? -1.0f : 1.0f;
- device->posFixup[3] = device->posFixup[1] * yoffset;
- }
}
/* Don't have to apply the matrices when vertex shaders are used. When vshaders are turned
@@ -4693,6 +4565,9 @@ static void vertexdeclaration(DWORD state_id, IWineD3DStateBlockImpl *stateblock
if(!isStateDirty(context, STATE_RENDER(WINED3DRS_COLORVERTEX))) {
state_colormat(STATE_RENDER(WINED3DRS_COLORVERTEX), stateblock, context);
}
+ if(!isStateDirty(context, STATE_RENDER(WINED3DRS_LIGHTING))) {
+ state_lighting(STATE_RENDER(WINED3DRS_LIGHTING), stateblock, context);
+ }
if(context->last_was_vshader) {
updateFog = TRUE;
@@ -4777,14 +4652,16 @@ static void vertexdeclaration(DWORD state_id, IWineD3DStateBlockImpl *stateblock
}
}
-static void viewport_miscpart(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void viewport_miscpart(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
- IWineD3DSurfaceImpl *target = stateblock->device->render_targets[0];
+ struct wined3d_surface *target = stateblock->device->fb.render_targets[0];
UINT width, height;
WINED3DVIEWPORT vp = stateblock->state.viewport;
- if(vp.Width > target->currentDesc.Width) vp.Width = target->currentDesc.Width;
- if(vp.Height > target->currentDesc.Height) vp.Height = target->currentDesc.Height;
+ if (vp.Width > target->resource.width)
+ vp.Width = target->resource.width;
+ if (vp.Height > target->resource.height)
+ vp.Height = target->resource.height;
glDepthRange(vp.MinZ, vp.MaxZ);
checkGLcall("glDepthRange");
@@ -4804,24 +4681,20 @@ static void viewport_miscpart(DWORD state, IWineD3DStateBlockImpl *stateblock, s
checkGLcall("glViewport");
}
-static void viewport_vertexpart(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void viewport_vertexpart(DWORD state_id, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
- GLfloat yoffset = -(63.0f / 64.0f) / stateblock->state.viewport.Height;
-
- stateblock->device->posFixup[2] = (63.0f / 64.0f) / stateblock->state.viewport.Width;
- stateblock->device->posFixup[3] = stateblock->device->posFixup[1] * yoffset;
-
if(!isStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION))) {
transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION), stateblock, context);
}
if(!isStateDirty(context, STATE_RENDER(WINED3DRS_POINTSCALEENABLE))) {
state_pscale(STATE_RENDER(WINED3DRS_POINTSCALEENABLE), stateblock, context);
}
+ /* Update the position fixup. */
if (!isStateDirty(context, STATE_VERTEXSHADERCONSTANT))
shaderconstant(STATE_VERTEXSHADERCONSTANT, stateblock, context);
}
-static void light(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void light(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
UINT Index = state - STATE_ACTIVELIGHT(0);
const struct wined3d_light_info *lightInfo = stateblock->state.lights[Index];
@@ -4935,9 +4808,9 @@ static void light(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3
}
}
-static void scissorrect(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void scissorrect(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
- IWineD3DSurfaceImpl *target = stateblock->device->render_targets[0];
+ struct wined3d_surface *target = stateblock->device->fb.render_targets[0];
RECT *pRect = &stateblock->state.scissor_rect;
UINT height;
UINT width;
@@ -4958,7 +4831,7 @@ static void scissorrect(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
checkGLcall("glScissor");
}
-static void indexbuffer(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void indexbuffer(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
@@ -4973,7 +4846,7 @@ static void indexbuffer(DWORD state, IWineD3DStateBlockImpl *stateblock, struct
}
}
-static void frontface(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void frontface(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
if (context->render_offscreen)
{
@@ -4985,6 +4858,34 @@ static void frontface(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wi
}
}
+static void psorigin_w(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
+{
+ static BOOL warned;
+
+ if (!warned)
+ {
+ WARN("Point sprite coordinate origin switching not supported.\n");
+ warned = TRUE;
+ }
+}
+
+static void psorigin(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
+{
+ const struct wined3d_gl_info *gl_info = context->gl_info;
+ GLint origin = context->render_offscreen ? GL_LOWER_LEFT : GL_UPPER_LEFT;
+
+ if (glPointParameteri)
+ {
+ glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, origin);
+ checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
+ }
+ else if (gl_info->supported[NV_POINT_SPRITE])
+ {
+ GL_EXTCALL(glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, origin));
+ checkGLcall("glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
+ }
+}
+
const struct StateEntryTemplate misc_state_template[] = {
{ STATE_RENDER(WINED3DRS_SRCBLEND), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3DRS_DESTBLEND), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE },
@@ -5000,6 +4901,9 @@ const struct StateEntryTemplate misc_state_template[] = {
{ STATE_VDECL, { STATE_VDECL, streamsrc }, WINED3D_GL_EXT_NONE },
{ STATE_FRONTFACE, { STATE_FRONTFACE, frontface }, WINED3D_GL_EXT_NONE },
{ STATE_SCISSORRECT, { STATE_SCISSORRECT, scissorrect }, WINED3D_GL_EXT_NONE },
+ { STATE_POINTSPRITECOORDORIGIN, { STATE_POINTSPRITECOORDORIGIN, psorigin }, WINED3D_GL_VERSION_2_0 },
+ { STATE_POINTSPRITECOORDORIGIN, { STATE_POINTSPRITECOORDORIGIN, psorigin_w }, WINED3D_GL_EXT_NONE },
+
/* TODO: Move shader constant loading to vertex and fragment pipeline repectively, as soon as the pshader and
* vshader loadings are untied from each other
*/
@@ -5080,7 +4984,6 @@ const struct StateEntryTemplate misc_state_template[] = {
{ STATE_RENDER(WINED3DRS_SUBPIXEL), { STATE_RENDER(WINED3DRS_SUBPIXEL), state_subpixel }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3DRS_SUBPIXELX), { STATE_RENDER(WINED3DRS_SUBPIXELX), state_subpixelx }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3DRS_STIPPLEDALPHA), { STATE_RENDER(WINED3DRS_STIPPLEDALPHA), state_stippledalpha }, WINED3D_GL_EXT_NONE },
- { STATE_RENDER(WINED3DRS_ZBIAS), { STATE_RENDER(WINED3DRS_ZBIAS), state_zbias }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3DRS_STIPPLEENABLE), { STATE_RENDER(WINED3DRS_STIPPLEENABLE), state_stippleenable }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3DRS_MIPMAPLODBIAS), { STATE_RENDER(WINED3DRS_MIPMAPLODBIAS), state_mipmaplodbias }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3DRS_ANISOTROPY), { STATE_RENDER(WINED3DRS_ANISOTROPY), state_anisotropy }, WINED3D_GL_EXT_NONE },
@@ -5675,51 +5578,51 @@ static const struct StateEntryTemplate ffp_fragmentstate_template[] = {
{0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE },
};
-/* Context activation is done by the caller. */
-static void ffp_enable(IWineD3DDevice *iface, BOOL enable) { }
+/* Context activation and GL locking are done by the caller. */
+static void ffp_enable(BOOL enable) {}
-static void ffp_fragment_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *pCaps)
+static void ffp_fragment_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps)
{
- pCaps->PrimitiveMiscCaps = 0;
- pCaps->TextureOpCaps = WINED3DTEXOPCAPS_ADD |
- WINED3DTEXOPCAPS_ADDSIGNED |
- WINED3DTEXOPCAPS_ADDSIGNED2X |
- WINED3DTEXOPCAPS_MODULATE |
- WINED3DTEXOPCAPS_MODULATE2X |
- WINED3DTEXOPCAPS_MODULATE4X |
- WINED3DTEXOPCAPS_SELECTARG1 |
- WINED3DTEXOPCAPS_SELECTARG2 |
- WINED3DTEXOPCAPS_DISABLE;
+ caps->PrimitiveMiscCaps = 0;
+ caps->TextureOpCaps = WINED3DTEXOPCAPS_ADD
+ | WINED3DTEXOPCAPS_ADDSIGNED
+ | WINED3DTEXOPCAPS_ADDSIGNED2X
+ | WINED3DTEXOPCAPS_MODULATE
+ | WINED3DTEXOPCAPS_MODULATE2X
+ | WINED3DTEXOPCAPS_MODULATE4X
+ | WINED3DTEXOPCAPS_SELECTARG1
+ | WINED3DTEXOPCAPS_SELECTARG2
+ | WINED3DTEXOPCAPS_DISABLE;
if (gl_info->supported[ARB_TEXTURE_ENV_COMBINE]
|| gl_info->supported[EXT_TEXTURE_ENV_COMBINE]
|| gl_info->supported[NV_TEXTURE_ENV_COMBINE4])
{
- pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA |
- WINED3DTEXOPCAPS_BLENDTEXTUREALPHA |
- WINED3DTEXOPCAPS_BLENDFACTORALPHA |
- WINED3DTEXOPCAPS_BLENDCURRENTALPHA |
- WINED3DTEXOPCAPS_LERP |
- WINED3DTEXOPCAPS_SUBTRACT;
+ caps->TextureOpCaps |= WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA
+ | WINED3DTEXOPCAPS_BLENDTEXTUREALPHA
+ | WINED3DTEXOPCAPS_BLENDFACTORALPHA
+ | WINED3DTEXOPCAPS_BLENDCURRENTALPHA
+ | WINED3DTEXOPCAPS_LERP
+ | WINED3DTEXOPCAPS_SUBTRACT;
}
if (gl_info->supported[ATI_TEXTURE_ENV_COMBINE3]
|| gl_info->supported[NV_TEXTURE_ENV_COMBINE4])
{
- pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_ADDSMOOTH |
- WINED3DTEXOPCAPS_MULTIPLYADD |
- WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR |
- WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA |
- WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM;
+ caps->TextureOpCaps |= WINED3DTEXOPCAPS_ADDSMOOTH
+ | WINED3DTEXOPCAPS_MULTIPLYADD
+ | WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
+ | WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
+ | WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM;
}
if (gl_info->supported[ARB_TEXTURE_ENV_DOT3])
- pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_DOTPRODUCT3;
+ caps->TextureOpCaps |= WINED3DTEXOPCAPS_DOTPRODUCT3;
- pCaps->MaxTextureBlendStages = gl_info->limits.textures;
- pCaps->MaxSimultaneousTextures = gl_info->limits.textures;
+ caps->MaxTextureBlendStages = gl_info->limits.textures;
+ caps->MaxSimultaneousTextures = gl_info->limits.textures;
}
-static HRESULT ffp_fragment_alloc(IWineD3DDevice *iface) { return WINED3D_OK; }
-static void ffp_fragment_free(IWineD3DDevice *iface) {}
+static HRESULT ffp_fragment_alloc(struct wined3d_device *device) { return WINED3D_OK; }
+static void ffp_fragment_free(struct wined3d_device *device) {}
static BOOL ffp_color_fixup_supported(struct color_fixup_desc fixup)
{
if (TRACE_ON(d3d))
@@ -5756,13 +5659,13 @@ static unsigned int num_handlers(const APPLYSTATEFUNC *funcs)
return i;
}
-static void multistate_apply_2(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void multistate_apply_2(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
stateblock->device->multistate_funcs[state][0](state, stateblock, context);
stateblock->device->multistate_funcs[state][1](state, stateblock, context);
}
-static void multistate_apply_3(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+static void multistate_apply_3(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
{
stateblock->device->multistate_funcs[state][0](state, stateblock, context);
stateblock->device->multistate_funcs[state][1](state, stateblock, context);
@@ -5812,6 +5715,7 @@ static void validate_state_table(struct StateEntry *state_table)
{ 17, 18},
{ 21, 21},
{ 42, 45},
+ { 47, 47},
{ 61, 127},
{149, 150},
{169, 169},
@@ -5832,6 +5736,7 @@ static void validate_state_table(struct StateEntry *state_table)
STATE_VIEWPORT,
STATE_SCISSORRECT,
STATE_FRONTFACE,
+ STATE_POINTSPRITECOORDORIGIN,
};
unsigned int i, current;
diff --git a/reactos/dll/directx/wine/wined3d/stateblock.c b/reactos/dll/directx/wine/wined3d/stateblock.c
index de8ee8eff21..5beea287376 100644
--- a/reactos/dll/directx/wine/wined3d/stateblock.c
+++ b/reactos/dll/directx/wine/wined3d/stateblock.c
@@ -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;
}
diff --git a/reactos/dll/directx/wine/wined3d/surface.c b/reactos/dll/directx/wine/wined3d/surface.c
index 442ce757920..91b16a6fa0e 100644
--- a/reactos/dll/directx/wine/wined3d/surface.c
+++ b/reactos/dll/directx/wine/wined3d/surface.c
@@ -1,7 +1,6 @@
/*
- * IWineD3DSurface Implementation
- *
- * Copyright 1998 Lionel Ulmer
+ * 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
@@ -10,7 +9,7 @@
* Copyright 2006-2008 Stefan Dösinger for CodeWeavers
* Copyright 2007-2008 Henri Verbeet
* Copyright 2006-2008 Roderick Colenbrander
- * 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
@@ -34,34 +33,43 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
WINE_DECLARE_DEBUG_CHANNEL(d3d);
-static void surface_cleanup(IWineD3DSurfaceImpl *This)
-{
- TRACE("(%p) : Cleaning up.\n", This);
+static HRESULT surface_cpu_blt(struct wined3d_surface *dst_surface, const RECT *dst_rect,
+ struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
+ const WINEDDBLTFX *fx, WINED3DTEXTUREFILTERTYPE filter);
+static HRESULT surface_cpu_bltfast(struct wined3d_surface *dst_surface, DWORD dst_x, DWORD dst_y,
+ struct wined3d_surface *src_surface, const RECT *src_rect, DWORD trans);
+static HRESULT IWineD3DSurfaceImpl_BltOverride(struct wined3d_surface *dst_surface, const RECT *dst_rect,
+ struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags, const WINEDDBLTFX *fx,
+ WINED3DTEXTUREFILTERTYPE filter);
- if (This->texture_name || (This->Flags & SFLAG_PBO) || !list_empty(&This->renderbuffers))
+static void surface_cleanup(struct wined3d_surface *surface)
+{
+ TRACE("surface %p.\n", surface);
+
+ if (surface->texture_name || (surface->flags & SFLAG_PBO) || !list_empty(&surface->renderbuffers))
{
+ struct wined3d_renderbuffer_entry *entry, *entry2;
const struct wined3d_gl_info *gl_info;
- renderbuffer_entry_t *entry, *entry2;
struct wined3d_context *context;
- context = context_acquire(This->resource.device, NULL);
+ context = context_acquire(surface->resource.device, NULL);
gl_info = context->gl_info;
ENTER_GL();
- if (This->texture_name)
+ if (surface->texture_name)
{
- TRACE("Deleting texture %u.\n", This->texture_name);
- glDeleteTextures(1, &This->texture_name);
+ TRACE("Deleting texture %u.\n", surface->texture_name);
+ glDeleteTextures(1, &surface->texture_name);
}
- if (This->Flags & SFLAG_PBO)
+ if (surface->flags & SFLAG_PBO)
{
- TRACE("Deleting PBO %u.\n", This->pbo);
- GL_EXTCALL(glDeleteBuffersARB(1, &This->pbo));
+ TRACE("Deleting PBO %u.\n", surface->pbo);
+ GL_EXTCALL(glDeleteBuffersARB(1, &surface->pbo));
}
- LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &This->renderbuffers, renderbuffer_entry_t, entry)
+ LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &surface->renderbuffers, struct wined3d_renderbuffer_entry, entry)
{
TRACE("Deleting renderbuffer %u.\n", entry->id);
gl_info->fbo_ops.glDeleteRenderbuffers(1, &entry->id);
@@ -73,26 +81,28 @@ static void surface_cleanup(IWineD3DSurfaceImpl *This)
context_release(context);
}
- if (This->Flags & SFLAG_DIBSECTION)
+ if (surface->flags & SFLAG_DIBSECTION)
{
/* Release the DC. */
- SelectObject(This->hDC, This->dib.holdbitmap);
- DeleteDC(This->hDC);
+ SelectObject(surface->hDC, surface->dib.holdbitmap);
+ DeleteDC(surface->hDC);
/* Release the DIB section. */
- DeleteObject(This->dib.DIBsection);
- This->dib.bitmap_data = NULL;
- This->resource.allocatedMemory = NULL;
+ DeleteObject(surface->dib.DIBsection);
+ surface->dib.bitmap_data = NULL;
+ surface->resource.allocatedMemory = NULL;
}
- if (This->Flags & SFLAG_USERPTR) IWineD3DSurface_SetMem((IWineD3DSurface *)This, NULL);
- if (This->overlay_dest) list_remove(&This->overlay_entry);
+ if (surface->flags & SFLAG_USERPTR)
+ wined3d_surface_set_mem(surface, NULL);
+ if (surface->overlay_dest)
+ list_remove(&surface->overlay_entry);
- HeapFree(GetProcessHeap(), 0, This->palette9);
+ HeapFree(GetProcessHeap(), 0, surface->palette9);
- resource_cleanup((IWineD3DResource *)This);
+ resource_cleanup(&surface->resource);
}
-void surface_set_container(IWineD3DSurfaceImpl *surface, enum wined3d_container_type type, IWineD3DBase *container)
+void surface_set_container(struct wined3d_surface *surface, enum wined3d_container_type type, void *container)
{
TRACE("surface %p, container %p.\n", surface, container);
@@ -149,22 +159,11 @@ static inline void cube_coords_float(const RECT *r, UINT w, UINT h, struct float
f->b = ((r->bottom * 2.0f) / h) - 1.0f;
}
-static void surface_get_blt_info(GLenum target, const RECT *rect_in, GLsizei w, GLsizei h, struct blt_info *info)
+static void surface_get_blt_info(GLenum target, const RECT *rect, GLsizei w, GLsizei h, struct blt_info *info)
{
GLfloat (*coords)[3] = info->coords;
- RECT rect;
struct float_rect f;
- if (rect_in)
- rect = *rect_in;
- else
- {
- rect.left = 0;
- rect.top = h;
- rect.right = w;
- rect.bottom = 0;
- }
-
switch (target)
{
default:
@@ -174,20 +173,20 @@ static void surface_get_blt_info(GLenum target, const RECT *rect_in, GLsizei w,
info->binding = GL_TEXTURE_BINDING_2D;
info->bind_target = GL_TEXTURE_2D;
info->tex_type = tex_2d;
- coords[0][0] = (float)rect.left / w;
- coords[0][1] = (float)rect.top / h;
+ coords[0][0] = (float)rect->left / w;
+ coords[0][1] = (float)rect->top / h;
coords[0][2] = 0.0f;
- coords[1][0] = (float)rect.right / w;
- coords[1][1] = (float)rect.top / h;
+ coords[1][0] = (float)rect->right / w;
+ coords[1][1] = (float)rect->top / h;
coords[1][2] = 0.0f;
- coords[2][0] = (float)rect.left / w;
- coords[2][1] = (float)rect.bottom / h;
+ coords[2][0] = (float)rect->left / w;
+ coords[2][1] = (float)rect->bottom / h;
coords[2][2] = 0.0f;
- coords[3][0] = (float)rect.right / w;
- coords[3][1] = (float)rect.bottom / h;
+ coords[3][0] = (float)rect->right / w;
+ coords[3][1] = (float)rect->bottom / h;
coords[3][2] = 0.0f;
break;
@@ -195,17 +194,17 @@ static void surface_get_blt_info(GLenum target, const RECT *rect_in, GLsizei w,
info->binding = GL_TEXTURE_BINDING_RECTANGLE_ARB;
info->bind_target = GL_TEXTURE_RECTANGLE_ARB;
info->tex_type = tex_rect;
- coords[0][0] = rect.left; coords[0][1] = rect.top; coords[0][2] = 0.0f;
- coords[1][0] = rect.right; coords[1][1] = rect.top; coords[1][2] = 0.0f;
- coords[2][0] = rect.left; coords[2][1] = rect.bottom; coords[2][2] = 0.0f;
- coords[3][0] = rect.right; coords[3][1] = rect.bottom; coords[3][2] = 0.0f;
+ coords[0][0] = rect->left; coords[0][1] = rect->top; coords[0][2] = 0.0f;
+ coords[1][0] = rect->right; coords[1][1] = rect->top; coords[1][2] = 0.0f;
+ coords[2][0] = rect->left; coords[2][1] = rect->bottom; coords[2][2] = 0.0f;
+ coords[3][0] = rect->right; coords[3][1] = rect->bottom; coords[3][2] = 0.0f;
break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
info->tex_type = tex_cube;
- cube_coords_float(&rect, w, h, &f);
+ cube_coords_float(rect, w, h, &f);
coords[0][0] = 1.0f; coords[0][1] = -f.t; coords[0][2] = -f.l;
coords[1][0] = 1.0f; coords[1][1] = -f.t; coords[1][2] = -f.r;
@@ -217,7 +216,7 @@ static void surface_get_blt_info(GLenum target, const RECT *rect_in, GLsizei w,
info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
info->tex_type = tex_cube;
- cube_coords_float(&rect, w, h, &f);
+ cube_coords_float(rect, w, h, &f);
coords[0][0] = -1.0f; coords[0][1] = -f.t; coords[0][2] = f.l;
coords[1][0] = -1.0f; coords[1][1] = -f.t; coords[1][2] = f.r;
@@ -229,7 +228,7 @@ static void surface_get_blt_info(GLenum target, const RECT *rect_in, GLsizei w,
info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
info->tex_type = tex_cube;
- cube_coords_float(&rect, w, h, &f);
+ cube_coords_float(rect, w, h, &f);
coords[0][0] = f.l; coords[0][1] = 1.0f; coords[0][2] = f.t;
coords[1][0] = f.r; coords[1][1] = 1.0f; coords[1][2] = f.t;
@@ -241,7 +240,7 @@ static void surface_get_blt_info(GLenum target, const RECT *rect_in, GLsizei w,
info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
info->tex_type = tex_cube;
- cube_coords_float(&rect, w, h, &f);
+ cube_coords_float(rect, w, h, &f);
coords[0][0] = f.l; coords[0][1] = -1.0f; coords[0][2] = -f.t;
coords[1][0] = f.r; coords[1][1] = -1.0f; coords[1][2] = -f.t;
@@ -253,7 +252,7 @@ static void surface_get_blt_info(GLenum target, const RECT *rect_in, GLsizei w,
info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
info->tex_type = tex_cube;
- cube_coords_float(&rect, w, h, &f);
+ cube_coords_float(rect, w, h, &f);
coords[0][0] = f.l; coords[0][1] = -f.t; coords[0][2] = 1.0f;
coords[1][0] = f.r; coords[1][1] = -f.t; coords[1][2] = 1.0f;
@@ -265,7 +264,7 @@ static void surface_get_blt_info(GLenum target, const RECT *rect_in, GLsizei w,
info->binding = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
info->tex_type = tex_cube;
- cube_coords_float(&rect, w, h, &f);
+ cube_coords_float(rect, w, h, &f);
coords[0][0] = -f.l; coords[0][1] = -f.t; coords[0][2] = -1.0f;
coords[1][0] = -f.r; coords[1][1] = -f.t; coords[1][2] = -1.0f;
@@ -275,7 +274,7 @@ static void surface_get_blt_info(GLenum target, const RECT *rect_in, GLsizei w,
}
}
-static inline void surface_get_rect(IWineD3DSurfaceImpl *This, const RECT *rect_in, RECT *rect_out)
+static inline void surface_get_rect(struct wined3d_surface *surface, const RECT *rect_in, RECT *rect_out)
{
if (rect_in)
*rect_out = *rect_in;
@@ -283,13 +282,14 @@ static inline void surface_get_rect(IWineD3DSurfaceImpl *This, const RECT *rect_
{
rect_out->left = 0;
rect_out->top = 0;
- rect_out->right = This->currentDesc.Width;
- rect_out->bottom = This->currentDesc.Height;
+ rect_out->right = surface->resource.width;
+ rect_out->bottom = surface->resource.height;
}
}
/* GL locking and context activation is done by the caller */
-void draw_textured_quad(IWineD3DSurfaceImpl *src_surface, const RECT *src_rect, const RECT *dst_rect, WINED3DTEXTUREFILTERTYPE Filter)
+void draw_textured_quad(struct wined3d_surface *src_surface, const RECT *src_rect,
+ const RECT *dst_rect, WINED3DTEXTUREFILTERTYPE Filter)
{
struct blt_info info;
@@ -337,139 +337,1554 @@ void draw_textured_quad(IWineD3DSurfaceImpl *src_surface, const RECT *src_rect,
* container about this to get the filters reset properly next draw. */
if (src_surface->container.type == WINED3D_CONTAINER_TEXTURE)
{
- IWineD3DBaseTextureImpl *texture = src_surface->container.u.texture;
- texture->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
- texture->baseTexture.texture_rgb.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
- texture->baseTexture.texture_rgb.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
+ struct wined3d_texture *texture = src_surface->container.u.texture;
+ texture->texture_rgb.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
+ texture->texture_rgb.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
+ texture->texture_rgb.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
}
}
-HRESULT surface_init(IWineD3DSurfaceImpl *surface, WINED3DSURFTYPE surface_type, UINT alignment,
- UINT width, UINT height, UINT level, BOOL lockable, BOOL discard, WINED3DMULTISAMPLE_TYPE multisample_type,
- UINT multisample_quality, IWineD3DDeviceImpl *device, DWORD usage, enum wined3d_format_id format_id,
- WINED3DPOOL pool, void *parent, const struct wined3d_parent_ops *parent_ops)
+static HRESULT surface_create_dib_section(struct wined3d_surface *surface)
{
- const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
- const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
- void (*cleanup)(IWineD3DSurfaceImpl *This);
- unsigned int resource_size;
- HRESULT hr;
+ const struct wined3d_format *format = surface->resource.format;
+ SYSTEM_INFO sysInfo;
+ BITMAPINFO *b_info;
+ int extraline = 0;
+ DWORD *masks;
+ UINT usage;
+ HDC dc;
- if (multisample_quality > 0)
+ TRACE("surface %p.\n", surface);
+
+ if (!(format->flags & WINED3DFMT_FLAG_GETDC))
{
- FIXME("multisample_quality set to %u, substituting 0\n", multisample_quality);
- multisample_quality = 0;
+ WARN("Cannot use GetDC on a %s surface.\n", debug_d3dformat(format->id));
+ return WINED3DERR_INVALIDCALL;
}
- /* FIXME: Check that the format is supported by the device. */
-
- resource_size = wined3d_format_calculate_size(format, alignment, width, height);
-
- /* Look at the implementation and set the correct Vtable. */
- switch (surface_type)
+ switch (format->byte_count)
{
- case SURFACE_OPENGL:
- surface->lpVtbl = &IWineD3DSurface_Vtbl;
- cleanup = surface_cleanup;
+ case 2:
+ case 4:
+ /* Allocate extra space to store the RGB bit masks. */
+ b_info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BITMAPINFOHEADER) + 3 * sizeof(DWORD));
break;
- case SURFACE_GDI:
- surface->lpVtbl = &IWineGDISurface_Vtbl;
- cleanup = surface_gdi_cleanup;
+ case 3:
+ b_info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BITMAPINFOHEADER));
break;
default:
- ERR("Requested unknown surface implementation %#x.\n", surface_type);
+ /* Allocate extra space for a palette. */
+ b_info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+ sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * (1 << (format->byte_count * 8)));
+ break;
+ }
+
+ if (!b_info)
+ return E_OUTOFMEMORY;
+
+ /* Some applications access the surface in via DWORDs, and do not take
+ * the necessary care at the end of the surface. So we need at least
+ * 4 extra bytes at the end of the surface. Check against the page size,
+ * if the last page used for the surface has at least 4 spare bytes we're
+ * safe, otherwise add an extra line to the DIB section. */
+ GetSystemInfo(&sysInfo);
+ if( ((surface->resource.size + 3) % sysInfo.dwPageSize) < 4)
+ {
+ extraline = 1;
+ TRACE("Adding an extra line to the DIB section.\n");
+ }
+
+ b_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ /* TODO: Is there a nicer way to force a specific alignment? (8 byte for ddraw) */
+ b_info->bmiHeader.biWidth = wined3d_surface_get_pitch(surface) / format->byte_count;
+ b_info->bmiHeader.biHeight = 0 - surface->resource.height - extraline;
+ b_info->bmiHeader.biSizeImage = (surface->resource.height + extraline)
+ * wined3d_surface_get_pitch(surface);
+ b_info->bmiHeader.biPlanes = 1;
+ b_info->bmiHeader.biBitCount = format->byte_count * 8;
+
+ b_info->bmiHeader.biXPelsPerMeter = 0;
+ b_info->bmiHeader.biYPelsPerMeter = 0;
+ b_info->bmiHeader.biClrUsed = 0;
+ b_info->bmiHeader.biClrImportant = 0;
+
+ /* Get the bit masks */
+ masks = (DWORD *)b_info->bmiColors;
+ switch (surface->resource.format->id)
+ {
+ case WINED3DFMT_B8G8R8_UNORM:
+ usage = DIB_RGB_COLORS;
+ b_info->bmiHeader.biCompression = BI_RGB;
+ break;
+
+ case WINED3DFMT_B5G5R5X1_UNORM:
+ case WINED3DFMT_B5G5R5A1_UNORM:
+ case WINED3DFMT_B4G4R4A4_UNORM:
+ case WINED3DFMT_B4G4R4X4_UNORM:
+ case WINED3DFMT_B2G3R3_UNORM:
+ case WINED3DFMT_B2G3R3A8_UNORM:
+ case WINED3DFMT_R10G10B10A2_UNORM:
+ case WINED3DFMT_R8G8B8A8_UNORM:
+ case WINED3DFMT_R8G8B8X8_UNORM:
+ case WINED3DFMT_B10G10R10A2_UNORM:
+ case WINED3DFMT_B5G6R5_UNORM:
+ case WINED3DFMT_R16G16B16A16_UNORM:
+ usage = 0;
+ b_info->bmiHeader.biCompression = BI_BITFIELDS;
+ masks[0] = format->red_mask;
+ masks[1] = format->green_mask;
+ masks[2] = format->blue_mask;
+ break;
+
+ default:
+ /* Don't know palette */
+ b_info->bmiHeader.biCompression = BI_RGB;
+ usage = 0;
+ break;
+ }
+
+ if (!(dc = GetDC(0)))
+ {
+ HeapFree(GetProcessHeap(), 0, b_info);
+ return HRESULT_FROM_WIN32(GetLastError());
+ }
+
+ TRACE("Creating a DIB section with size %dx%dx%d, size=%d.\n",
+ b_info->bmiHeader.biWidth, b_info->bmiHeader.biHeight,
+ b_info->bmiHeader.biBitCount, b_info->bmiHeader.biSizeImage);
+ surface->dib.DIBsection = CreateDIBSection(dc, b_info, usage, &surface->dib.bitmap_data, 0, 0);
+ ReleaseDC(0, dc);
+
+ if (!surface->dib.DIBsection)
+ {
+ ERR("Failed to create DIB section.\n");
+ HeapFree(GetProcessHeap(), 0, b_info);
+ return HRESULT_FROM_WIN32(GetLastError());
+ }
+
+ TRACE("DIBSection at %p.\n", surface->dib.bitmap_data);
+ /* Copy the existing surface to the dib section. */
+ if (surface->resource.allocatedMemory)
+ {
+ memcpy(surface->dib.bitmap_data, surface->resource.allocatedMemory,
+ surface->resource.height * wined3d_surface_get_pitch(surface));
+ }
+ else
+ {
+ /* This is to make maps read the GL texture although memory is allocated. */
+ surface->flags &= ~SFLAG_INSYSMEM;
+ }
+ surface->dib.bitmap_size = b_info->bmiHeader.biSizeImage;
+
+ HeapFree(GetProcessHeap(), 0, b_info);
+
+ /* Now allocate a DC. */
+ surface->hDC = CreateCompatibleDC(0);
+ surface->dib.holdbitmap = SelectObject(surface->hDC, surface->dib.DIBsection);
+ TRACE("Using wined3d palette %p.\n", surface->palette);
+ SelectPalette(surface->hDC, surface->palette ? surface->palette->hpal : 0, FALSE);
+
+ surface->flags |= SFLAG_DIBSECTION;
+
+ HeapFree(GetProcessHeap(), 0, surface->resource.heapMemory);
+ surface->resource.heapMemory = NULL;
+
+ return WINED3D_OK;
+}
+
+static void surface_prepare_system_memory(struct wined3d_surface *surface)
+{
+ struct wined3d_device *device = surface->resource.device;
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+
+ TRACE("surface %p.\n", surface);
+
+ /* Performance optimization: Count how often a surface is locked, if it is
+ * locked regularly do not throw away the system memory copy. This avoids
+ * the need to download the surface from OpenGL all the time. The surface
+ * is still downloaded if the OpenGL texture is changed. */
+ if (!(surface->flags & SFLAG_DYNLOCK))
+ {
+ if (++surface->lockCount > MAXLOCKCOUNT)
+ {
+ TRACE("Surface is locked regularly, not freeing the system memory copy any more.\n");
+ surface->flags |= SFLAG_DYNLOCK;
+ }
+ }
+
+ /* Create a PBO for dynamically locked surfaces but don't do it for
+ * converted or NPOT surfaces. Also don't create a PBO for systemmem
+ * surfaces. */
+ if (gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] && (surface->flags & SFLAG_DYNLOCK)
+ && !(surface->flags & (SFLAG_PBO | SFLAG_CONVERTED | SFLAG_NONPOW2))
+ && (surface->resource.pool != WINED3DPOOL_SYSTEMMEM))
+ {
+ struct wined3d_context *context;
+ GLenum error;
+
+ context = context_acquire(device, NULL);
+ ENTER_GL();
+
+ GL_EXTCALL(glGenBuffersARB(1, &surface->pbo));
+ error = glGetError();
+ if (!surface->pbo || error != GL_NO_ERROR)
+ ERR("Failed to create a PBO with error %s (%#x).\n", debug_glerror(error), error);
+
+ TRACE("Binding PBO %u.\n", surface->pbo);
+
+ GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, surface->pbo));
+ checkGLcall("glBindBufferARB");
+
+ GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, surface->resource.size + 4,
+ surface->resource.allocatedMemory, GL_STREAM_DRAW_ARB));
+ checkGLcall("glBufferDataARB");
+
+ GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
+ checkGLcall("glBindBufferARB");
+
+ /* We don't need the system memory anymore and we can't even use it for PBOs. */
+ if (!(surface->flags & SFLAG_CLIENT))
+ {
+ HeapFree(GetProcessHeap(), 0, surface->resource.heapMemory);
+ surface->resource.heapMemory = NULL;
+ }
+ surface->resource.allocatedMemory = NULL;
+ surface->flags |= SFLAG_PBO;
+ LEAVE_GL();
+ context_release(context);
+ }
+ else if (!(surface->resource.allocatedMemory || surface->flags & SFLAG_PBO))
+ {
+ /* Whatever surface we have, make sure that there is memory allocated
+ * for the downloaded copy, or a PBO to map. */
+ if (!surface->resource.heapMemory)
+ surface->resource.heapMemory = HeapAlloc(GetProcessHeap(), 0, surface->resource.size + RESOURCE_ALIGNMENT);
+
+ surface->resource.allocatedMemory = (BYTE *)(((ULONG_PTR)surface->resource.heapMemory
+ + (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
+
+ if (surface->flags & SFLAG_INSYSMEM)
+ ERR("Surface without memory or PBO has SFLAG_INSYSMEM set.\n");
+ }
+}
+
+static void surface_evict_sysmem(struct wined3d_surface *surface)
+{
+ if (surface->flags & SFLAG_DONOTFREE)
+ return;
+
+ HeapFree(GetProcessHeap(), 0, surface->resource.heapMemory);
+ surface->resource.allocatedMemory = NULL;
+ surface->resource.heapMemory = NULL;
+ surface_modify_location(surface, SFLAG_INSYSMEM, FALSE);
+}
+
+/* Context activation is done by the caller. */
+static void surface_bind_and_dirtify(struct wined3d_surface *surface,
+ const struct wined3d_gl_info *gl_info, BOOL srgb)
+{
+ struct wined3d_device *device = surface->resource.device;
+ DWORD active_sampler;
+ GLint active_texture;
+
+ /* We don't need a specific texture unit, but after binding the texture
+ * the current unit is dirty. Read the unit back instead of switching to
+ * 0, this avoids messing around with the state manager's GL states. The
+ * current texture unit should always be a valid one.
+ *
+ * To be more specific, this is tricky because we can implicitly be
+ * called from sampler() in state.c. This means we can't touch anything
+ * other than whatever happens to be the currently active texture, or we
+ * would risk marking already applied sampler states dirty again.
+ *
+ * TODO: Track the current active texture per GL context instead of using
+ * glGet(). */
+
+ ENTER_GL();
+ glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
+ LEAVE_GL();
+ active_sampler = device->rev_tex_unit_map[active_texture - GL_TEXTURE0_ARB];
+
+ if (active_sampler != WINED3D_UNMAPPED_STAGE)
+ {
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(active_sampler));
+ }
+ surface_bind(surface, gl_info, srgb);
+}
+
+static void surface_force_reload(struct wined3d_surface *surface)
+{
+ surface->flags &= ~(SFLAG_ALLOCATED | SFLAG_SRGBALLOCATED);
+}
+
+static void surface_release_client_storage(struct wined3d_surface *surface)
+{
+ struct wined3d_context *context = context_acquire(surface->resource.device, NULL);
+
+ ENTER_GL();
+ glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
+ if (surface->texture_name)
+ {
+ surface_bind_and_dirtify(surface, context->gl_info, FALSE);
+ glTexImage2D(surface->texture_target, surface->texture_level,
+ GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
+ }
+ if (surface->texture_name_srgb)
+ {
+ surface_bind_and_dirtify(surface, context->gl_info, TRUE);
+ glTexImage2D(surface->texture_target, surface->texture_level,
+ GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
+ }
+ glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
+ LEAVE_GL();
+
+ context_release(context);
+
+ surface_modify_location(surface, SFLAG_INSRGBTEX, FALSE);
+ surface_modify_location(surface, SFLAG_INTEXTURE, FALSE);
+ surface_force_reload(surface);
+}
+
+static HRESULT surface_private_setup(struct wined3d_surface *surface)
+{
+ /* TODO: Check against the maximum texture sizes supported by the video card. */
+ const struct wined3d_gl_info *gl_info = &surface->resource.device->adapter->gl_info;
+ unsigned int pow2Width, pow2Height;
+
+ TRACE("surface %p.\n", surface);
+
+ surface->texture_name = 0;
+ surface->texture_target = GL_TEXTURE_2D;
+
+ /* Non-power2 support */
+ if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] || gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT])
+ {
+ pow2Width = surface->resource.width;
+ pow2Height = surface->resource.height;
+ }
+ else
+ {
+ /* Find the nearest pow2 match */
+ pow2Width = pow2Height = 1;
+ while (pow2Width < surface->resource.width)
+ pow2Width <<= 1;
+ while (pow2Height < surface->resource.height)
+ pow2Height <<= 1;
+ }
+ surface->pow2Width = pow2Width;
+ surface->pow2Height = pow2Height;
+
+ if (pow2Width > surface->resource.width || pow2Height > surface->resource.height)
+ {
+ /* TODO: Add support for non power two compressed textures. */
+ if (surface->resource.format->flags & WINED3DFMT_FLAG_COMPRESSED)
+ {
+ FIXME("(%p) Compressed non-power-two textures are not supported w(%d) h(%d)\n",
+ surface, surface->resource.width, surface->resource.height);
+ return WINED3DERR_NOTAVAILABLE;
+ }
+ }
+
+ if (pow2Width != surface->resource.width
+ || pow2Height != surface->resource.height)
+ {
+ surface->flags |= SFLAG_NONPOW2;
+ }
+
+ if ((surface->pow2Width > gl_info->limits.texture_size || surface->pow2Height > gl_info->limits.texture_size)
+ && !(surface->resource.usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL)))
+ {
+ /* One of three options:
+ * 1: Do the same as we do with NPOT and scale the texture, (any
+ * texture ops would require the texture to be scaled which is
+ * potentially slow)
+ * 2: Set the texture to the maximum size (bad idea).
+ * 3: WARN and return WINED3DERR_NOTAVAILABLE;
+ * 4: Create the surface, but allow it to be used only for DirectDraw
+ * Blts. Some apps (e.g. Swat 3) create textures with a Height of
+ * 16 and a Width > 3000 and blt 16x16 letter areas from them to
+ * the render target. */
+ if (surface->resource.pool == WINED3DPOOL_DEFAULT || surface->resource.pool == WINED3DPOOL_MANAGED)
+ {
+ WARN("Unable to allocate a surface which exceeds the maximum OpenGL texture size.\n");
+ return WINED3DERR_NOTAVAILABLE;
+ }
+
+ /* We should never use this surface in combination with OpenGL! */
+ TRACE("Creating an oversized surface: %ux%u.\n",
+ surface->pow2Width, surface->pow2Height);
+ }
+ else
+ {
+ /* Don't use ARB_TEXTURE_RECTANGLE in case the surface format is P8
+ * and EXT_PALETTED_TEXTURE is used in combination with texture
+ * uploads (RTL_READTEX/RTL_TEXTEX). The reason is that
+ * EXT_PALETTED_TEXTURE doesn't work in combination with
+ * ARB_TEXTURE_RECTANGLE. */
+ if (surface->flags & SFLAG_NONPOW2 && gl_info->supported[ARB_TEXTURE_RECTANGLE]
+ && !(surface->resource.format->id == WINED3DFMT_P8_UINT
+ && gl_info->supported[EXT_PALETTED_TEXTURE]
+ && wined3d_settings.rendertargetlock_mode == RTL_READTEX))
+ {
+ surface->texture_target = GL_TEXTURE_RECTANGLE_ARB;
+ surface->pow2Width = surface->resource.width;
+ surface->pow2Height = surface->resource.height;
+ surface->flags &= ~(SFLAG_NONPOW2 | SFLAG_NORMCOORD);
+ }
+ }
+
+ switch (wined3d_settings.offscreen_rendering_mode)
+ {
+ case ORM_FBO:
+ surface->get_drawable_size = get_drawable_size_fbo;
+ break;
+
+ case ORM_BACKBUFFER:
+ surface->get_drawable_size = get_drawable_size_backbuffer;
+ break;
+
+ default:
+ ERR("Unhandled offscreen rendering mode %#x.\n", wined3d_settings.offscreen_rendering_mode);
return WINED3DERR_INVALIDCALL;
}
- hr = resource_init((IWineD3DResource *)surface, WINED3DRTYPE_SURFACE,
- device, resource_size, usage, format, pool, parent, parent_ops);
- if (FAILED(hr))
+ surface->flags |= SFLAG_INSYSMEM;
+
+ return WINED3D_OK;
+}
+
+static void surface_realize_palette(struct wined3d_surface *surface)
+{
+ struct wined3d_palette *palette = surface->palette;
+
+ TRACE("surface %p.\n", surface);
+
+ if (!palette) return;
+
+ if (surface->resource.format->id == WINED3DFMT_P8_UINT
+ || surface->resource.format->id == WINED3DFMT_P8_UINT_A8_UNORM)
{
- WARN("Failed to initialize resource, returning %#x.\n", hr);
- return hr;
- }
+ if (surface->resource.usage & WINED3DUSAGE_RENDERTARGET)
+ {
+ /* Make sure the texture is up to date. This call doesn't do
+ * anything if the texture is already up to date. */
+ surface_load_location(surface, SFLAG_INTEXTURE, NULL);
- /* "Standalone" surface. */
- surface_set_container(surface, WINED3D_CONTAINER_NONE, NULL);
-
- surface->currentDesc.Width = width;
- surface->currentDesc.Height = height;
- surface->currentDesc.MultiSampleType = multisample_type;
- surface->currentDesc.MultiSampleQuality = multisample_quality;
- surface->texture_level = level;
- list_init(&surface->overlays);
-
- /* Flags */
- surface->Flags = SFLAG_NORMCOORD; /* Default to normalized coords. */
- if (discard) surface->Flags |= SFLAG_DISCARD;
- if (lockable || format_id == WINED3DFMT_D16_LOCKABLE) surface->Flags |= SFLAG_LOCKABLE;
-
- /* Quick lockable sanity check.
- * TODO: remove this after surfaces, usage and lockability have been debugged properly
- * this function is too deep to need to care about things like this.
- * Levels need to be checked too, since they all affect what can be done. */
- switch (pool)
- {
- case WINED3DPOOL_SCRATCH:
- if(!lockable)
+ /* We want to force a palette refresh, so mark the drawable as not being up to date */
+ if (!surface_is_offscreen(surface))
+ surface_modify_location(surface, SFLAG_INDRAWABLE, FALSE);
+ }
+ else
+ {
+ if (!(surface->flags & SFLAG_INSYSMEM))
{
- FIXME("Called with a pool of SCRATCH and a lockable of FALSE "
- "which are mutually exclusive, setting lockable to TRUE.\n");
- lockable = TRUE;
+ TRACE("Palette changed with surface that does not have an up to date system memory copy.\n");
+ surface_load_location(surface, SFLAG_INSYSMEM, NULL);
}
- break;
-
- case WINED3DPOOL_SYSTEMMEM:
- if (!lockable)
- FIXME("Called with a pool of SYSTEMMEM and a lockable of FALSE, this is acceptable but unexpected.\n");
- break;
-
- case WINED3DPOOL_MANAGED:
- if (usage & WINED3DUSAGE_DYNAMIC)
- FIXME("Called with a pool of MANAGED and a usage of DYNAMIC which are mutually exclusive.\n");
- break;
-
- case WINED3DPOOL_DEFAULT:
- if (lockable && !(usage & (WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL)))
- WARN("Creating a lockable surface with a POOL of DEFAULT, that doesn't specify DYNAMIC usage.\n");
- break;
-
- default:
- FIXME("Unknown pool %#x.\n", pool);
- break;
- };
-
- if (usage & WINED3DUSAGE_RENDERTARGET && pool != WINED3DPOOL_DEFAULT)
- {
- FIXME("Trying to create a render target that isn't in the default pool.\n");
+ surface_modify_location(surface, SFLAG_INSYSMEM, TRUE);
+ }
}
- /* Mark the texture as dirty so that it gets loaded first time around. */
- surface_add_dirty_rect(surface, NULL);
- list_init(&surface->renderbuffers);
-
- TRACE("surface %p, memory %p, size %u\n", surface, surface->resource.allocatedMemory, surface->resource.size);
-
- /* Call the private setup routine */
- hr = IWineD3DSurface_PrivateSetup((IWineD3DSurface *)surface);
- if (FAILED(hr))
+ if (surface->flags & SFLAG_DIBSECTION)
{
- ERR("Private setup failed, returning %#x\n", hr);
- cleanup(surface);
- return hr;
+ RGBQUAD col[256];
+ unsigned int i;
+
+ TRACE("Updating the DC's palette.\n");
+
+ for (i = 0; i < 256; ++i)
+ {
+ col[i].rgbRed = palette->palents[i].peRed;
+ col[i].rgbGreen = palette->palents[i].peGreen;
+ col[i].rgbBlue = palette->palents[i].peBlue;
+ col[i].rgbReserved = 0;
+ }
+ SetDIBColorTable(surface->hDC, 0, 256, col);
}
+ /* Propagate the changes to the drawable when we have a palette. */
+ if (surface->resource.usage & WINED3DUSAGE_RENDERTARGET)
+ surface_load_location(surface, SFLAG_INDRAWABLE, NULL);
+}
+
+static HRESULT surface_draw_overlay(struct wined3d_surface *surface)
+{
+ HRESULT hr;
+
+ /* If there's no destination surface there is nothing to do. */
+ if (!surface->overlay_dest)
+ return WINED3D_OK;
+
+ /* Blt calls ModifyLocation on the dest surface, which in turn calls
+ * DrawOverlay to update the overlay. Prevent an endless recursion. */
+ if (surface->overlay_dest->flags & SFLAG_INOVERLAYDRAW)
+ return WINED3D_OK;
+
+ surface->overlay_dest->flags |= SFLAG_INOVERLAYDRAW;
+ hr = wined3d_surface_blt(surface->overlay_dest, &surface->overlay_destrect, surface,
+ &surface->overlay_srcrect, WINEDDBLT_WAIT, NULL, WINED3DTEXF_LINEAR);
+ surface->overlay_dest->flags &= ~SFLAG_INOVERLAYDRAW;
+
return hr;
}
-static void surface_force_reload(IWineD3DSurfaceImpl *surface)
+static void surface_preload(struct wined3d_surface *surface)
{
- surface->Flags &= ~(SFLAG_ALLOCATED | SFLAG_SRGBALLOCATED);
+ TRACE("surface %p.\n", surface);
+
+ surface_internal_preload(surface, SRGB_ANY);
}
-void surface_set_texture_name(IWineD3DSurfaceImpl *surface, GLuint new_name, BOOL srgb)
+static void surface_map(struct wined3d_surface *surface, const RECT *rect, DWORD flags)
+{
+ struct wined3d_device *device = surface->resource.device;
+ const RECT *pass_rect = rect;
+
+ TRACE("surface %p, rect %s, flags %#x.\n",
+ surface, wine_dbgstr_rect(rect), flags);
+
+ if (flags & WINED3DLOCK_DISCARD)
+ {
+ TRACE("WINED3DLOCK_DISCARD flag passed, marking SYSMEM as up to date.\n");
+ surface_prepare_system_memory(surface);
+ surface_modify_location(surface, SFLAG_INSYSMEM, TRUE);
+ }
+ else
+ {
+ /* surface_load_location() does not check if the rectangle specifies
+ * the full surface. Most callers don't need that, so do it here. */
+ if (rect && !rect->top && !rect->left
+ && rect->right == surface->resource.width
+ && rect->bottom == surface->resource.height)
+ pass_rect = NULL;
+
+ if (!(wined3d_settings.rendertargetlock_mode == RTL_DISABLE
+ && ((surface->container.type == WINED3D_CONTAINER_SWAPCHAIN)
+ || surface == device->fb.render_targets[0])))
+ surface_load_location(surface, SFLAG_INSYSMEM, pass_rect);
+ }
+
+ if (surface->flags & SFLAG_PBO)
+ {
+ const struct wined3d_gl_info *gl_info;
+ struct wined3d_context *context;
+
+ context = context_acquire(device, NULL);
+ gl_info = context->gl_info;
+
+ ENTER_GL();
+ GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, surface->pbo));
+ checkGLcall("glBindBufferARB");
+
+ /* This shouldn't happen but could occur if some other function
+ * didn't handle the PBO properly. */
+ if (surface->resource.allocatedMemory)
+ ERR("The surface already has PBO memory allocated.\n");
+
+ surface->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_READ_WRITE_ARB));
+ checkGLcall("glMapBufferARB");
+
+ /* Make sure the PBO isn't set anymore in order not to break non-PBO
+ * calls. */
+ GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
+ checkGLcall("glBindBufferARB");
+
+ LEAVE_GL();
+ context_release(context);
+ }
+
+ if (!(flags & (WINED3DLOCK_NO_DIRTY_UPDATE | WINED3DLOCK_READONLY)))
+ {
+ if (!rect)
+ surface_add_dirty_rect(surface, NULL);
+ else
+ {
+ WINED3DBOX b;
+
+ b.Left = rect->left;
+ b.Top = rect->top;
+ b.Right = rect->right;
+ b.Bottom = rect->bottom;
+ b.Front = 0;
+ b.Back = 1;
+ surface_add_dirty_rect(surface, &b);
+ }
+ }
+}
+
+static void surface_unmap(struct wined3d_surface *surface)
+{
+ struct wined3d_device *device = surface->resource.device;
+ BOOL fullsurface;
+
+ TRACE("surface %p.\n", surface);
+
+ memset(&surface->lockedRect, 0, sizeof(surface->lockedRect));
+
+ if (surface->flags & SFLAG_PBO)
+ {
+ const struct wined3d_gl_info *gl_info;
+ struct wined3d_context *context;
+
+ TRACE("Freeing PBO memory.\n");
+
+ context = context_acquire(device, NULL);
+ gl_info = context->gl_info;
+
+ ENTER_GL();
+ GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, surface->pbo));
+ GL_EXTCALL(glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB));
+ GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
+ checkGLcall("glUnmapBufferARB");
+ LEAVE_GL();
+ context_release(context);
+
+ surface->resource.allocatedMemory = NULL;
+ }
+
+ TRACE("dirtyfied %u.\n", surface->flags & (SFLAG_INDRAWABLE | SFLAG_INTEXTURE) ? 0 : 1);
+
+ if (surface->flags & (SFLAG_INDRAWABLE | SFLAG_INTEXTURE))
+ {
+ TRACE("Not dirtified, nothing to do.\n");
+ goto done;
+ }
+
+ if (surface->container.type == WINED3D_CONTAINER_SWAPCHAIN
+ || (device->fb.render_targets && surface == device->fb.render_targets[0]))
+ {
+ if (wined3d_settings.rendertargetlock_mode == RTL_DISABLE)
+ {
+ static BOOL warned = FALSE;
+ if (!warned)
+ {
+ ERR("The application tries to write to the render target, but render target locking is disabled.\n");
+ warned = TRUE;
+ }
+ goto done;
+ }
+
+ if (!surface->dirtyRect.left && !surface->dirtyRect.top
+ && surface->dirtyRect.right == surface->resource.width
+ && surface->dirtyRect.bottom == surface->resource.height)
+ {
+ fullsurface = TRUE;
+ }
+ else
+ {
+ /* TODO: Proper partial rectangle tracking. */
+ fullsurface = FALSE;
+ surface->flags |= SFLAG_INSYSMEM;
+ }
+
+ surface_load_location(surface, SFLAG_INDRAWABLE, fullsurface ? NULL : &surface->dirtyRect);
+
+ /* Partial rectangle tracking is not commonly implemented, it is only
+ * done for render targets. INSYSMEM was set before to tell
+ * surface_load_location() where to read the rectangle from.
+ * Indrawable is set because all modifications from the partial
+ * sysmem copy are written back to the drawable, thus the surface is
+ * merged again in the drawable. The sysmem copy is not fully up to
+ * date because only a subrectangle was read in Map(). */
+ if (!fullsurface)
+ {
+ surface_modify_location(surface, SFLAG_INDRAWABLE, TRUE);
+ surface_evict_sysmem(surface);
+ }
+
+ surface->dirtyRect.left = surface->resource.width;
+ surface->dirtyRect.top = surface->resource.height;
+ surface->dirtyRect.right = 0;
+ surface->dirtyRect.bottom = 0;
+ }
+ else if (surface->resource.format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
+ {
+ FIXME("Depth / stencil buffer locking is not implemented.\n");
+ }
+
+done:
+ /* Overlays have to be redrawn manually after changes with the GL implementation */
+ if (surface->overlay_dest)
+ surface->surface_ops->surface_draw_overlay(surface);
+}
+
+static HRESULT surface_getdc(struct wined3d_surface *surface)
+{
+ WINED3DLOCKED_RECT lock;
+ HRESULT hr;
+
+ TRACE("surface %p.\n", surface);
+
+ /* Create a DIB section if there isn't a dc yet. */
+ if (!surface->hDC)
+ {
+ if (surface->flags & SFLAG_CLIENT)
+ {
+ surface_load_location(surface, SFLAG_INSYSMEM, NULL);
+ surface_release_client_storage(surface);
+ }
+ hr = surface_create_dib_section(surface);
+ if (FAILED(hr))
+ return WINED3DERR_INVALIDCALL;
+
+ /* Use the DIB section from now on if we are not using a PBO. */
+ if (!(surface->flags & SFLAG_PBO))
+ surface->resource.allocatedMemory = surface->dib.bitmap_data;
+ }
+
+ /* Map the surface. */
+ hr = wined3d_surface_map(surface, &lock, NULL, 0);
+ if (FAILED(hr))
+ ERR("Map failed, hr %#x.\n", hr);
+
+ /* Sync the DIB with the PBO. This can't be done earlier because Map()
+ * activates the allocatedMemory. */
+ if (surface->flags & SFLAG_PBO)
+ memcpy(surface->dib.bitmap_data, surface->resource.allocatedMemory, surface->dib.bitmap_size);
+
+ return hr;
+}
+
+static HRESULT surface_flip(struct wined3d_surface *surface, struct wined3d_surface *override)
+{
+ TRACE("surface %p, override %p.\n", surface, override);
+
+ /* Flipping is only supported on render targets and overlays. */
+ if (!(surface->resource.usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_OVERLAY)))
+ {
+ WARN("Tried to flip a non-render target, non-overlay surface.\n");
+ return WINEDDERR_NOTFLIPPABLE;
+ }
+
+ if (surface->resource.usage & WINED3DUSAGE_OVERLAY)
+ {
+ flip_surface(surface, override);
+
+ /* Update the overlay if it is visible */
+ if (surface->overlay_dest)
+ return surface->surface_ops->surface_draw_overlay(surface);
+ else
+ return WINED3D_OK;
+ }
+
+ return WINED3D_OK;
+}
+
+static BOOL surface_is_full_rect(struct wined3d_surface *surface, const RECT *r)
+{
+ if ((r->left && r->right) || abs(r->right - r->left) != surface->resource.width)
+ return FALSE;
+ if ((r->top && r->bottom) || abs(r->bottom - r->top) != surface->resource.height)
+ return FALSE;
+ return TRUE;
+}
+
+static void wined3d_surface_depth_blt_fbo(struct wined3d_device *device, struct wined3d_surface *src_surface,
+ const RECT *src_rect, struct wined3d_surface *dst_surface, const RECT *dst_rect)
+{
+ const struct wined3d_gl_info *gl_info;
+ struct wined3d_context *context;
+ DWORD src_mask, dst_mask;
+ GLbitfield gl_mask;
+
+ TRACE("device %p, src_surface %p, src_rect %s, dst_surface %p, dst_rect %s.\n",
+ device, src_surface, wine_dbgstr_rect(src_rect),
+ dst_surface, wine_dbgstr_rect(dst_rect));
+
+ src_mask = src_surface->resource.format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL);
+ dst_mask = dst_surface->resource.format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL);
+
+ if (src_mask != dst_mask)
+ {
+ ERR("Incompatible formats %s and %s.\n",
+ debug_d3dformat(src_surface->resource.format->id),
+ debug_d3dformat(dst_surface->resource.format->id));
+ return;
+ }
+
+ if (!src_mask)
+ {
+ ERR("Not a depth / stencil format: %s.\n",
+ debug_d3dformat(src_surface->resource.format->id));
+ return;
+ }
+
+ gl_mask = 0;
+ if (src_mask & WINED3DFMT_FLAG_DEPTH)
+ gl_mask |= GL_DEPTH_BUFFER_BIT;
+ if (src_mask & WINED3DFMT_FLAG_STENCIL)
+ gl_mask |= GL_STENCIL_BUFFER_BIT;
+
+ /* Make sure the locations are up-to-date. Loading the destination
+ * surface isn't required if the entire surface is overwritten. */
+ surface_load_location(src_surface, SFLAG_INTEXTURE, NULL);
+ if (!surface_is_full_rect(dst_surface, dst_rect))
+ surface_load_location(dst_surface, SFLAG_INTEXTURE, NULL);
+
+ context = context_acquire(device, NULL);
+ if (!context->valid)
+ {
+ context_release(context);
+ WARN("Invalid context, skipping blit.\n");
+ return;
+ }
+
+ gl_info = context->gl_info;
+
+ ENTER_GL();
+
+ context_apply_fbo_state_blit(context, GL_READ_FRAMEBUFFER, NULL, src_surface, SFLAG_INTEXTURE);
+ glReadBuffer(GL_NONE);
+ checkGLcall("glReadBuffer()");
+ context_check_fbo_status(context, GL_READ_FRAMEBUFFER);
+
+ context_apply_fbo_state_blit(context, GL_DRAW_FRAMEBUFFER, NULL, dst_surface, SFLAG_INTEXTURE);
+ context_set_draw_buffer(context, GL_NONE);
+ context_check_fbo_status(context, GL_DRAW_FRAMEBUFFER);
+
+ if (gl_mask & GL_DEPTH_BUFFER_BIT)
+ {
+ glDepthMask(GL_TRUE);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_ZWRITEENABLE));
+ }
+ if (gl_mask & GL_STENCIL_BUFFER_BIT)
+ {
+ if (context->gl_info->supported[EXT_STENCIL_TWO_SIDE])
+ {
+ glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_TWOSIDEDSTENCILMODE));
+ }
+ glStencilMask(~0U);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_STENCILWRITEMASK));
+ }
+
+ glDisable(GL_SCISSOR_TEST);
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_SCISSORTESTENABLE));
+
+ gl_info->fbo_ops.glBlitFramebuffer(src_rect->left, src_rect->top, src_rect->right, src_rect->bottom,
+ dst_rect->left, dst_rect->top, dst_rect->right, dst_rect->bottom, gl_mask, GL_NEAREST);
+ checkGLcall("glBlitFramebuffer()");
+
+ LEAVE_GL();
+
+ if (wined3d_settings.strict_draw_ordering)
+ wglFlush(); /* Flush to ensure ordering across contexts. */
+
+ context_release(context);
+}
+
+static BOOL fbo_blit_supported(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)
+{
+ if ((wined3d_settings.offscreen_rendering_mode != ORM_FBO) || !gl_info->fbo_ops.glBlitFramebuffer)
+ return FALSE;
+
+ /* Source and/or destination need to be on the GL side */
+ if (src_pool == WINED3DPOOL_SYSTEMMEM || dst_pool == WINED3DPOOL_SYSTEMMEM)
+ return FALSE;
+
+ switch (blit_op)
+ {
+ case WINED3D_BLIT_OP_COLOR_BLIT:
+ if (!((src_format->flags & WINED3DFMT_FLAG_FBO_ATTACHABLE) || (src_usage & WINED3DUSAGE_RENDERTARGET)))
+ return FALSE;
+ if (!((dst_format->flags & WINED3DFMT_FLAG_FBO_ATTACHABLE) || (dst_usage & WINED3DUSAGE_RENDERTARGET)))
+ return FALSE;
+ break;
+
+ case WINED3D_BLIT_OP_DEPTH_BLIT:
+ if (!(src_format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
+ return FALSE;
+ if (!(dst_format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
+ return FALSE;
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ if (!(src_format->id == dst_format->id
+ || (is_identity_fixup(src_format->color_fixup)
+ && is_identity_fixup(dst_format->color_fixup))))
+ return FALSE;
+
+ return TRUE;
+}
+
+static BOOL surface_convert_depth_to_float(struct wined3d_surface *surface, DWORD depth, float *float_depth)
+{
+ const struct wined3d_format *format = surface->resource.format;
+
+ switch (format->id)
+ {
+ case WINED3DFMT_S1_UINT_D15_UNORM:
+ *float_depth = depth / (float)0x00007fff;
+ break;
+
+ case WINED3DFMT_D16_UNORM:
+ *float_depth = depth / (float)0x0000ffff;
+ break;
+
+ case WINED3DFMT_D24_UNORM_S8_UINT:
+ case WINED3DFMT_X8D24_UNORM:
+ *float_depth = depth / (float)0x00ffffff;
+ break;
+
+ case WINED3DFMT_D32_UNORM:
+ *float_depth = depth / (float)0xffffffff;
+ break;
+
+ default:
+ ERR("Unhandled conversion from %s to floating point.\n", debug_d3dformat(format->id));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Do not call while under the GL lock. */
+static HRESULT wined3d_surface_depth_fill(struct wined3d_surface *surface, const RECT *rect, float depth)
+{
+ const struct wined3d_resource *resource = &surface->resource;
+ struct wined3d_device *device = resource->device;
+ const struct blit_shader *blitter;
+
+ blitter = wined3d_select_blitter(&device->adapter->gl_info, WINED3D_BLIT_OP_DEPTH_FILL,
+ NULL, 0, 0, NULL, rect, resource->usage, resource->pool, resource->format);
+ if (!blitter)
+ {
+ FIXME("No blitter is capable of performing the requested depth fill operation.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ return blitter->depth_fill(device, surface, rect, depth);
+}
+
+static HRESULT wined3d_surface_depth_blt(struct wined3d_surface *src_surface, const RECT *src_rect,
+ struct wined3d_surface *dst_surface, const RECT *dst_rect)
+{
+ struct wined3d_device *device = src_surface->resource.device;
+
+ if (!fbo_blit_supported(&device->adapter->gl_info, WINED3D_BLIT_OP_DEPTH_BLIT,
+ src_rect, src_surface->resource.usage, src_surface->resource.pool, src_surface->resource.format,
+ dst_rect, dst_surface->resource.usage, dst_surface->resource.pool, dst_surface->resource.format))
+ return WINED3DERR_INVALIDCALL;
+
+ wined3d_surface_depth_blt_fbo(device, src_surface, src_rect, dst_surface, dst_rect);
+
+ surface_modify_ds_location(dst_surface, SFLAG_DS_OFFSCREEN,
+ dst_surface->ds_current_size.cx, dst_surface->ds_current_size.cy);
+ surface_modify_location(dst_surface, SFLAG_INDRAWABLE, TRUE);
+
+ return WINED3D_OK;
+}
+
+/* Do not call while under the GL lock. */
+static HRESULT surface_blt(struct wined3d_surface *dst_surface, const RECT *dst_rect_in,
+ struct wined3d_surface *src_surface, const RECT *src_rect_in, DWORD flags,
+ const WINEDDBLTFX *fx, WINED3DTEXTUREFILTERTYPE filter)
+{
+ struct wined3d_device *device = dst_surface->resource.device;
+ DWORD src_ds_flags, dst_ds_flags;
+
+ TRACE("dst_surface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p, filter %s.\n",
+ dst_surface, wine_dbgstr_rect(dst_rect_in), src_surface, wine_dbgstr_rect(src_rect_in),
+ flags, fx, debug_d3dtexturefiltertype(filter));
+ TRACE("Usage is %s.\n", debug_d3dusage(dst_surface->resource.usage));
+
+ if ((dst_surface->flags & SFLAG_LOCKED) || (src_surface && (src_surface->flags & SFLAG_LOCKED)))
+ {
+ WARN(" Surface is busy, returning DDERR_SURFACEBUSY\n");
+ return WINEDDERR_SURFACEBUSY;
+ }
+
+ dst_ds_flags = dst_surface->resource.format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL);
+ if (src_surface)
+ src_ds_flags = src_surface->resource.format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL);
+ else
+ src_ds_flags = 0;
+
+ if (src_ds_flags || dst_ds_flags)
+ {
+ if (flags & WINEDDBLT_DEPTHFILL)
+ {
+ float depth;
+ RECT rect;
+
+ TRACE("Depth fill.\n");
+
+ surface_get_rect(dst_surface, dst_rect_in, &rect);
+
+ if (!surface_convert_depth_to_float(dst_surface, fx->u5.dwFillDepth, &depth))
+ return WINED3DERR_INVALIDCALL;
+
+ if (SUCCEEDED(wined3d_surface_depth_fill(dst_surface, &rect, depth)))
+ return WINED3D_OK;
+ }
+ else
+ {
+ RECT src_rect, dst_rect;
+
+ /* Accessing depth / stencil surfaces is supposed to fail while in
+ * a scene, except for fills, which seem to work. */
+ if (device->inScene)
+ {
+ WARN("Rejecting depth / stencil access while in scene.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ if (src_ds_flags != dst_ds_flags)
+ {
+ WARN("Rejecting depth / stencil blit between incompatible formats.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ if (src_rect_in && (src_rect_in->top || src_rect_in->left
+ || src_rect_in->bottom != src_surface->resource.height
+ || src_rect_in->right != src_surface->resource.width))
+ {
+ WARN("Rejecting depth / stencil blit with invalid source rect %s.\n",
+ wine_dbgstr_rect(src_rect_in));
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ if (dst_rect_in && (dst_rect_in->top || dst_rect_in->left
+ || dst_rect_in->bottom != dst_surface->resource.height
+ || dst_rect_in->right != dst_surface->resource.width))
+ {
+ WARN("Rejecting depth / stencil blit with invalid destination rect %s.\n",
+ wine_dbgstr_rect(src_rect_in));
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ if (src_surface->resource.height != dst_surface->resource.height
+ || src_surface->resource.width != dst_surface->resource.width)
+ {
+ WARN("Rejecting depth / stencil blit with mismatched surface sizes.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ surface_get_rect(src_surface, src_rect_in, &src_rect);
+ surface_get_rect(dst_surface, dst_rect_in, &dst_rect);
+
+ if (SUCCEEDED(wined3d_surface_depth_blt(src_surface, &src_rect, dst_surface, &dst_rect)))
+ return WINED3D_OK;
+ }
+ }
+
+ /* Special cases for render targets. */
+ if ((dst_surface->resource.usage & WINED3DUSAGE_RENDERTARGET)
+ || (src_surface && (src_surface->resource.usage & WINED3DUSAGE_RENDERTARGET)))
+ {
+ if (SUCCEEDED(IWineD3DSurfaceImpl_BltOverride(dst_surface, dst_rect_in,
+ src_surface, src_rect_in, flags, fx, filter)))
+ return WINED3D_OK;
+ }
+
+ /* For the rest call the X11 surface implementation. For render targets
+ * this should be implemented OpenGL accelerated in BltOverride, other
+ * blits are rather rare. */
+ return surface_cpu_blt(dst_surface, dst_rect_in, src_surface, src_rect_in, flags, fx, filter);
+}
+
+/* Do not call while under the GL lock. */
+static HRESULT surface_bltfast(struct wined3d_surface *dst_surface, DWORD dst_x, DWORD dst_y,
+ struct wined3d_surface *src_surface, const RECT *src_rect_in, DWORD trans)
+{
+ struct wined3d_device *device = dst_surface->resource.device;
+
+ TRACE("dst_surface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, flags %#x.\n",
+ dst_surface, dst_x, dst_y, src_surface, wine_dbgstr_rect(src_rect_in), trans);
+
+ if ((dst_surface->flags & SFLAG_LOCKED) || (src_surface->flags & SFLAG_LOCKED))
+ {
+ WARN("Surface is busy, returning WINEDDERR_SURFACEBUSY.\n");
+ return WINEDDERR_SURFACEBUSY;
+ }
+
+ if (device->inScene && (dst_surface == device->fb.depth_stencil || src_surface == device->fb.depth_stencil))
+ {
+ WARN("Attempt to access the depth / stencil surface while in a scene.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ /* Special cases for RenderTargets */
+ if ((dst_surface->resource.usage & WINED3DUSAGE_RENDERTARGET)
+ || (src_surface->resource.usage & WINED3DUSAGE_RENDERTARGET))
+ {
+
+ RECT src_rect, dst_rect;
+ DWORD flags = 0;
+
+ surface_get_rect(src_surface, src_rect_in, &src_rect);
+
+ dst_rect.left = dst_x;
+ dst_rect.top = dst_y;
+ dst_rect.right = dst_x + src_rect.right - src_rect.left;
+ dst_rect.bottom = dst_y + src_rect.bottom - src_rect.top;
+
+ /* Convert BltFast flags into Blt ones because BltOverride is called
+ * from Blt as well. */
+ if (trans & WINEDDBLTFAST_SRCCOLORKEY)
+ flags |= WINEDDBLT_KEYSRC;
+ if (trans & WINEDDBLTFAST_DESTCOLORKEY)
+ flags |= WINEDDBLT_KEYDEST;
+ if (trans & WINEDDBLTFAST_WAIT)
+ flags |= WINEDDBLT_WAIT;
+ if (trans & WINEDDBLTFAST_DONOTWAIT)
+ flags |= WINEDDBLT_DONOTWAIT;
+
+ if (SUCCEEDED(IWineD3DSurfaceImpl_BltOverride(dst_surface,
+ &dst_rect, src_surface, &src_rect, flags, NULL, WINED3DTEXF_POINT)))
+ return WINED3D_OK;
+ }
+
+ return surface_cpu_bltfast(dst_surface, dst_x, dst_y, src_surface, src_rect_in, trans);
+}
+
+static HRESULT surface_set_mem(struct wined3d_surface *surface, void *mem)
+{
+ TRACE("surface %p, mem %p.\n", surface, mem);
+
+ if (mem && mem != surface->resource.allocatedMemory)
+ {
+ void *release = NULL;
+
+ /* Do I have to copy the old surface content? */
+ if (surface->flags & SFLAG_DIBSECTION)
+ {
+ SelectObject(surface->hDC, surface->dib.holdbitmap);
+ DeleteDC(surface->hDC);
+ /* Release the DIB section. */
+ DeleteObject(surface->dib.DIBsection);
+ surface->dib.bitmap_data = NULL;
+ surface->resource.allocatedMemory = NULL;
+ surface->hDC = NULL;
+ surface->flags &= ~SFLAG_DIBSECTION;
+ }
+ else if (!(surface->flags & SFLAG_USERPTR))
+ {
+ release = surface->resource.heapMemory;
+ surface->resource.heapMemory = NULL;
+ }
+ surface->resource.allocatedMemory = mem;
+ surface->flags |= SFLAG_USERPTR;
+
+ /* Now the surface memory is most up do date. Invalidate drawable and texture. */
+ surface_modify_location(surface, SFLAG_INSYSMEM, TRUE);
+
+ /* For client textures OpenGL has to be notified. */
+ if (surface->flags & SFLAG_CLIENT)
+ surface_release_client_storage(surface);
+
+ /* Now free the old memory if any. */
+ HeapFree(GetProcessHeap(), 0, release);
+ }
+ else if (surface->flags & SFLAG_USERPTR)
+ {
+ /* Map and GetDC will re-create the dib section and allocated memory. */
+ surface->resource.allocatedMemory = NULL;
+ /* HeapMemory should be NULL already. */
+ if (surface->resource.heapMemory)
+ ERR("User pointer surface has heap memory allocated.\n");
+ surface->flags &= ~(SFLAG_USERPTR | SFLAG_INSYSMEM);
+
+ if (surface->flags & SFLAG_CLIENT)
+ surface_release_client_storage(surface);
+
+ surface_prepare_system_memory(surface);
+ surface_modify_location(surface, SFLAG_INSYSMEM, TRUE);
+ }
+
+ return WINED3D_OK;
+}
+
+/* Context activation is done by the caller. */
+static void surface_remove_pbo(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info)
+{
+ if (!surface->resource.heapMemory)
+ {
+ surface->resource.heapMemory = HeapAlloc(GetProcessHeap(), 0, surface->resource.size + RESOURCE_ALIGNMENT);
+ surface->resource.allocatedMemory = (BYTE *)(((ULONG_PTR)surface->resource.heapMemory
+ + (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
+ }
+
+ ENTER_GL();
+ GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, surface->pbo));
+ checkGLcall("glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, surface->pbo)");
+ GL_EXTCALL(glGetBufferSubDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0,
+ surface->resource.size, surface->resource.allocatedMemory));
+ checkGLcall("glGetBufferSubDataARB");
+ GL_EXTCALL(glDeleteBuffersARB(1, &surface->pbo));
+ checkGLcall("glDeleteBuffersARB");
+ LEAVE_GL();
+
+ surface->pbo = 0;
+ surface->flags &= ~SFLAG_PBO;
+}
+
+/* Do not call while under the GL lock. */
+static void surface_unload(struct wined3d_resource *resource)
+{
+ struct wined3d_surface *surface = surface_from_resource(resource);
+ struct wined3d_renderbuffer_entry *entry, *entry2;
+ struct wined3d_device *device = resource->device;
+ const struct wined3d_gl_info *gl_info;
+ struct wined3d_context *context;
+
+ TRACE("surface %p.\n", surface);
+
+ if (resource->pool == WINED3DPOOL_DEFAULT)
+ {
+ /* Default pool resources are supposed to be destroyed before Reset is called.
+ * Implicit resources stay however. So this means we have an implicit render target
+ * or depth stencil. The content may be destroyed, but we still have to tear down
+ * opengl resources, so we cannot leave early.
+ *
+ * Put the surfaces into sysmem, and reset the content. The D3D content is undefined,
+ * but we can't set the sysmem INDRAWABLE because when we're rendering the swapchain
+ * or the depth stencil into an FBO the texture or render buffer will be removed
+ * and all flags get lost
+ */
+ surface_init_sysmem(surface);
+ }
+ else
+ {
+ /* Load the surface into system memory */
+ surface_load_location(surface, SFLAG_INSYSMEM, NULL);
+ surface_modify_location(surface, SFLAG_INDRAWABLE, FALSE);
+ }
+ surface_modify_location(surface, SFLAG_INTEXTURE, FALSE);
+ surface_modify_location(surface, SFLAG_INSRGBTEX, FALSE);
+ surface->flags &= ~(SFLAG_ALLOCATED | SFLAG_SRGBALLOCATED);
+
+ context = context_acquire(device, NULL);
+ gl_info = context->gl_info;
+
+ /* Destroy PBOs, but load them into real sysmem before */
+ if (surface->flags & SFLAG_PBO)
+ surface_remove_pbo(surface, gl_info);
+
+ /* Destroy fbo render buffers. This is needed for implicit render targets, for
+ * all application-created targets the application has to release the surface
+ * before calling _Reset
+ */
+ LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &surface->renderbuffers, struct wined3d_renderbuffer_entry, entry)
+ {
+ ENTER_GL();
+ gl_info->fbo_ops.glDeleteRenderbuffers(1, &entry->id);
+ LEAVE_GL();
+ list_remove(&entry->entry);
+ HeapFree(GetProcessHeap(), 0, entry);
+ }
+ list_init(&surface->renderbuffers);
+ surface->current_renderbuffer = NULL;
+
+ /* If we're in a texture, the texture name belongs to the texture.
+ * Otherwise, destroy it. */
+ if (surface->container.type != WINED3D_CONTAINER_TEXTURE)
+ {
+ ENTER_GL();
+ glDeleteTextures(1, &surface->texture_name);
+ surface->texture_name = 0;
+ glDeleteTextures(1, &surface->texture_name_srgb);
+ surface->texture_name_srgb = 0;
+ LEAVE_GL();
+ }
+
+ context_release(context);
+
+ resource_unload(resource);
+}
+
+static const struct wined3d_resource_ops surface_resource_ops =
+{
+ surface_unload,
+};
+
+static const struct wined3d_surface_ops surface_ops =
+{
+ surface_private_setup,
+ surface_cleanup,
+ surface_realize_palette,
+ surface_draw_overlay,
+ surface_preload,
+ surface_map,
+ surface_unmap,
+ surface_getdc,
+ surface_flip,
+ surface_blt,
+ surface_bltfast,
+ surface_set_mem,
+};
+
+/*****************************************************************************
+ * 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 gdi_surface_private_setup(struct wined3d_surface *surface)
+{
+ HRESULT hr;
+
+ TRACE("surface %p.\n", surface);
+
+ if (surface->resource.usage & WINED3DUSAGE_OVERLAY)
+ {
+ ERR("Overlays not yet supported by GDI surfaces.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ /* Sysmem textures have memory already allocated - release it,
+ * this avoids an unnecessary memcpy. */
+ hr = surface_create_dib_section(surface);
+ if (SUCCEEDED(hr))
+ {
+ HeapFree(GetProcessHeap(), 0, surface->resource.heapMemory);
+ surface->resource.heapMemory = NULL;
+ surface->resource.allocatedMemory = surface->dib.bitmap_data;
+ }
+
+ /* We don't mind the nonpow2 stuff in GDI. */
+ surface->pow2Width = surface->resource.width;
+ surface->pow2Height = surface->resource.height;
+
+ return WINED3D_OK;
+}
+
+static void surface_gdi_cleanup(struct wined3d_surface *surface)
+{
+ TRACE("surface %p.\n", surface);
+
+ if (surface->flags & SFLAG_DIBSECTION)
+ {
+ /* Release the DC. */
+ SelectObject(surface->hDC, surface->dib.holdbitmap);
+ DeleteDC(surface->hDC);
+ /* Release the DIB section. */
+ DeleteObject(surface->dib.DIBsection);
+ surface->dib.bitmap_data = NULL;
+ surface->resource.allocatedMemory = NULL;
+ }
+
+ if (surface->flags & SFLAG_USERPTR)
+ wined3d_surface_set_mem(surface, NULL);
+ if (surface->overlay_dest)
+ list_remove(&surface->overlay_entry);
+
+ HeapFree(GetProcessHeap(), 0, surface->palette9);
+
+ resource_cleanup(&surface->resource);
+}
+
+static void gdi_surface_realize_palette(struct wined3d_surface *surface)
+{
+ struct wined3d_palette *palette = surface->palette;
+
+ TRACE("surface %p.\n", surface);
+
+ if (!palette) return;
+
+ if (surface->flags & SFLAG_DIBSECTION)
+ {
+ RGBQUAD col[256];
+ unsigned int i;
+
+ TRACE("Updating the DC's palette.\n");
+
+ for (i = 0; i < 256; ++i)
+ {
+ col[i].rgbRed = palette->palents[i].peRed;
+ col[i].rgbGreen = palette->palents[i].peGreen;
+ col[i].rgbBlue = palette->palents[i].peBlue;
+ col[i].rgbReserved = 0;
+ }
+ SetDIBColorTable(surface->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 (surface->container.type == WINED3D_CONTAINER_SWAPCHAIN)
+ {
+ struct wined3d_swapchain *swapchain = surface->container.u.swapchain;
+ if (surface == swapchain->front_buffer)
+ {
+ x11_copy_to_screen(swapchain, NULL);
+ }
+ }
+}
+
+static HRESULT gdi_surface_draw_overlay(struct wined3d_surface *surface)
+{
+ FIXME("GDI surfaces can't draw overlays yet.\n");
+ return E_FAIL;
+}
+
+static void gdi_surface_preload(struct wined3d_surface *surface)
+{
+ TRACE("surface %p.\n", surface);
+
+ ERR("Preloading GDI surfaces is not supported.\n");
+}
+
+static void gdi_surface_map(struct wined3d_surface *surface, const RECT *rect, DWORD flags)
+{
+ TRACE("surface %p, rect %s, flags %#x.\n",
+ surface, wine_dbgstr_rect(rect), flags);
+
+ if (!surface->resource.allocatedMemory)
+ {
+ /* This happens on gdi surfaces if the application set a user pointer
+ * and resets it. Recreate the DIB section. */
+ surface_create_dib_section(surface);
+ surface->resource.allocatedMemory = surface->dib.bitmap_data;
+ }
+}
+
+static void gdi_surface_unmap(struct wined3d_surface *surface)
+{
+ TRACE("surface %p.\n", surface);
+
+ /* Tell the swapchain to update the screen. */
+ if (surface->container.type == WINED3D_CONTAINER_SWAPCHAIN)
+ {
+ struct wined3d_swapchain *swapchain = surface->container.u.swapchain;
+ if (surface == swapchain->front_buffer)
+ {
+ x11_copy_to_screen(swapchain, &surface->lockedRect);
+ }
+ }
+
+ memset(&surface->lockedRect, 0, sizeof(RECT));
+}
+
+static HRESULT gdi_surface_getdc(struct wined3d_surface *surface)
+{
+ WINED3DLOCKED_RECT lock;
+ HRESULT hr;
+
+ TRACE("surface %p.\n", surface);
+
+ /* Should have a DIB section already. */
+ if (!(surface->flags & SFLAG_DIBSECTION))
+ {
+ WARN("DC not supported on this surface\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ /* Map the surface. */
+ hr = wined3d_surface_map(surface, &lock, NULL, 0);
+ if (FAILED(hr))
+ ERR("Map failed, hr %#x.\n", hr);
+
+ return hr;
+}
+
+static HRESULT gdi_surface_flip(struct wined3d_surface *surface, struct wined3d_surface *override)
+{
+ TRACE("surface %p, override %p.\n", surface, override);
+
+ return WINED3D_OK;
+}
+
+static HRESULT gdi_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst_rect,
+ struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
+ const WINEDDBLTFX *fx, WINED3DTEXTUREFILTERTYPE filter)
+{
+ TRACE("dst_surface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p, filter %s.\n",
+ dst_surface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect),
+ flags, fx, debug_d3dtexturefiltertype(filter));
+
+ return surface_cpu_blt(dst_surface, dst_rect, src_surface, src_rect, flags, fx, filter);
+}
+
+static HRESULT gdi_surface_bltfast(struct wined3d_surface *dst_surface, DWORD dst_x, DWORD dst_y,
+ struct wined3d_surface *src_surface, const RECT *src_rect, DWORD trans)
+{
+ TRACE("dst_surface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, flags %#x.\n",
+ dst_surface, dst_x, dst_y, src_surface, wine_dbgstr_rect(src_rect), trans);
+
+ return surface_cpu_bltfast(dst_surface, dst_x, dst_y, src_surface, src_rect, trans);
+}
+
+static HRESULT gdi_surface_set_mem(struct wined3d_surface *surface, void *mem)
+{
+ TRACE("surface %p, mem %p.\n", surface, mem);
+
+ /* Render targets depend on their hdc, and we can't create an hdc on a user pointer. */
+ if (surface->resource.usage & WINED3DUSAGE_RENDERTARGET)
+ {
+ ERR("Not supported on render targets.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ if (mem && mem != surface->resource.allocatedMemory)
+ {
+ void *release = NULL;
+
+ /* Do I have to copy the old surface content? */
+ if (surface->flags & SFLAG_DIBSECTION)
+ {
+ SelectObject(surface->hDC, surface->dib.holdbitmap);
+ DeleteDC(surface->hDC);
+ /* Release the DIB section. */
+ DeleteObject(surface->dib.DIBsection);
+ surface->dib.bitmap_data = NULL;
+ surface->resource.allocatedMemory = NULL;
+ surface->hDC = NULL;
+ surface->flags &= ~SFLAG_DIBSECTION;
+ }
+ else if (!(surface->flags & SFLAG_USERPTR))
+ {
+ release = surface->resource.allocatedMemory;
+ }
+ surface->resource.allocatedMemory = mem;
+ surface->flags |= SFLAG_USERPTR | SFLAG_INSYSMEM;
+
+ /* Now free the old memory, if any. */
+ HeapFree(GetProcessHeap(), 0, release);
+ }
+ else if (surface->flags & SFLAG_USERPTR)
+ {
+ /* Map() and GetDC() will re-create the dib section and allocated memory. */
+ surface->resource.allocatedMemory = NULL;
+ surface->flags &= ~SFLAG_USERPTR;
+ }
+
+ return WINED3D_OK;
+}
+
+static const struct wined3d_surface_ops gdi_surface_ops =
+{
+ gdi_surface_private_setup,
+ surface_gdi_cleanup,
+ gdi_surface_realize_palette,
+ gdi_surface_draw_overlay,
+ gdi_surface_preload,
+ gdi_surface_map,
+ gdi_surface_unmap,
+ gdi_surface_getdc,
+ gdi_surface_flip,
+ gdi_surface_blt,
+ gdi_surface_bltfast,
+ gdi_surface_set_mem,
+};
+
+void surface_set_texture_name(struct wined3d_surface *surface, GLuint new_name, BOOL srgb)
{
GLuint *name;
DWORD flag;
@@ -491,7 +1906,7 @@ void surface_set_texture_name(IWineD3DSurfaceImpl *surface, GLuint new_name, BOO
{
/* FIXME: We shouldn't need to remove SFLAG_INTEXTURE if the
* surface has no texture name yet. See if we can get rid of this. */
- if (surface->Flags & flag)
+ if (surface->flags & flag)
ERR("Surface has %s set, but no texture name.\n", debug_surflocation(flag));
surface_modify_location(surface, flag, FALSE);
}
@@ -500,7 +1915,7 @@ void surface_set_texture_name(IWineD3DSurfaceImpl *surface, GLuint new_name, BOO
surface_force_reload(surface);
}
-void surface_set_texture_target(IWineD3DSurfaceImpl *surface, GLenum target)
+void surface_set_texture_target(struct wined3d_surface *surface, GLenum target)
{
TRACE("surface %p, target %#x.\n", surface, target);
@@ -508,11 +1923,11 @@ void surface_set_texture_target(IWineD3DSurfaceImpl *surface, GLenum target)
{
if (target == GL_TEXTURE_RECTANGLE_ARB)
{
- surface->Flags &= ~SFLAG_NORMCOORD;
+ surface->flags &= ~SFLAG_NORMCOORD;
}
else if (surface->texture_target == GL_TEXTURE_RECTANGLE_ARB)
{
- surface->Flags |= SFLAG_NORMCOORD;
+ surface->flags |= SFLAG_NORMCOORD;
}
}
surface->texture_target = target;
@@ -520,39 +1935,62 @@ void surface_set_texture_target(IWineD3DSurfaceImpl *surface, GLenum target)
}
/* Context activation is done by the caller. */
-static void surface_bind_and_dirtify(IWineD3DSurfaceImpl *This, BOOL srgb) {
- DWORD active_sampler;
+void surface_bind(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info, BOOL srgb)
+{
+ TRACE("surface %p, gl_info %p, srgb %#x.\n", surface, gl_info, srgb);
- /* We don't need a specific texture unit, but after binding the texture the current unit is dirty.
- * Read the unit back instead of switching to 0, this avoids messing around with the state manager's
- * gl states. The current texture unit should always be a valid one.
- *
- * To be more specific, this is tricky because we can implicitly be called
- * from sampler() in state.c. This means we can't touch anything other than
- * whatever happens to be the currently active texture, or we would risk
- * marking already applied sampler states dirty again.
- *
- * TODO: Track the current active texture per GL context instead of using glGet
- */
- GLint active_texture;
- ENTER_GL();
- glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
- LEAVE_GL();
- active_sampler = This->resource.device->rev_tex_unit_map[active_texture - GL_TEXTURE0_ARB];
-
- if (active_sampler != WINED3D_UNMAPPED_STAGE)
+ if (surface->container.type == WINED3D_CONTAINER_TEXTURE)
{
- IWineD3DDeviceImpl_MarkStateDirty(This->resource.device, STATE_SAMPLER(active_sampler));
+ struct wined3d_texture *texture = surface->container.u.texture;
+
+ TRACE("Passing to container (%p).\n", texture);
+ texture->texture_ops->texture_bind(texture, gl_info, srgb);
+ }
+ else
+ {
+ if (surface->texture_level)
+ {
+ ERR("Standalone surface %p is non-zero texture level %u.\n",
+ surface, surface->texture_level);
+ }
+
+ if (srgb)
+ ERR("Trying to bind standalone surface %p as sRGB.\n", surface);
+
+ ENTER_GL();
+
+ if (!surface->texture_name)
+ {
+ glGenTextures(1, &surface->texture_name);
+ checkGLcall("glGenTextures");
+
+ TRACE("Surface %p given name %u.\n", surface, surface->texture_name);
+
+ glBindTexture(surface->texture_target, surface->texture_name);
+ checkGLcall("glBindTexture");
+ glTexParameteri(surface->texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(surface->texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(surface->texture_target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
+ glTexParameteri(surface->texture_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(surface->texture_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ checkGLcall("glTexParameteri");
+ }
+ else
+ {
+ glBindTexture(surface->texture_target, surface->texture_name);
+ checkGLcall("glBindTexture");
+ }
+
+ LEAVE_GL();
}
- IWineD3DSurface_BindTexture((IWineD3DSurface *)This, srgb);
}
/* This function checks if the primary render target uses the 8bit paletted format. */
-static BOOL primary_render_target_is_p8(IWineD3DDeviceImpl *device)
+static BOOL primary_render_target_is_p8(struct wined3d_device *device)
{
- if (device->render_targets && device->render_targets[0])
+ if (device->fb.render_targets && device->fb.render_targets[0])
{
- IWineD3DSurfaceImpl *render_target = device->render_targets[0];
+ struct wined3d_surface *render_target = device->fb.render_targets[0];
if ((render_target->resource.usage & WINED3DUSAGE_RENDERTARGET)
&& (render_target->resource.format->id == WINED3DFMT_P8_UINT))
return TRUE;
@@ -563,12 +2001,12 @@ static BOOL primary_render_target_is_p8(IWineD3DDeviceImpl *device)
/* This call just downloads data, the caller is responsible for binding the
* correct texture. */
/* Context activation is done by the caller. */
-static void surface_download_data(IWineD3DSurfaceImpl *This, const struct wined3d_gl_info *gl_info)
+static void surface_download_data(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info)
{
- const struct wined3d_format *format = This->resource.format;
+ const struct wined3d_format *format = surface->resource.format;
- /* Only support read back of converted P8 surfaces */
- if (This->Flags & SFLAG_CONVERTED && format->id != WINED3DFMT_P8_UINT)
+ /* Only support read back of converted P8 surfaces. */
+ if (surface->flags & SFLAG_CONVERTED && format->id != WINED3DFMT_P8_UINT)
{
FIXME("Readback conversion not supported for format %s.\n", debug_d3dformat(format->id));
return;
@@ -576,72 +2014,81 @@ static void surface_download_data(IWineD3DSurfaceImpl *This, const struct wined3
ENTER_GL();
- if (format->Flags & WINED3DFMT_FLAG_COMPRESSED)
+ if (format->flags & WINED3DFMT_FLAG_COMPRESSED)
{
TRACE("(%p) : Calling glGetCompressedTexImageARB level %d, format %#x, type %#x, data %p.\n",
- This, This->texture_level, format->glFormat, format->glType,
- This->resource.allocatedMemory);
+ surface, surface->texture_level, format->glFormat, format->glType,
+ surface->resource.allocatedMemory);
- if (This->Flags & SFLAG_PBO)
+ if (surface->flags & SFLAG_PBO)
{
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, This->pbo));
+ GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, surface->pbo));
checkGLcall("glBindBufferARB");
- GL_EXTCALL(glGetCompressedTexImageARB(This->texture_target, This->texture_level, NULL));
+ GL_EXTCALL(glGetCompressedTexImageARB(surface->texture_target, surface->texture_level, NULL));
checkGLcall("glGetCompressedTexImageARB");
GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0));
checkGLcall("glBindBufferARB");
}
else
{
- GL_EXTCALL(glGetCompressedTexImageARB(This->texture_target,
- This->texture_level, This->resource.allocatedMemory));
+ GL_EXTCALL(glGetCompressedTexImageARB(surface->texture_target,
+ surface->texture_level, surface->resource.allocatedMemory));
checkGLcall("glGetCompressedTexImageARB");
}
LEAVE_GL();
- } else {
+ }
+ else
+ {
void *mem;
GLenum gl_format = format->glFormat;
GLenum gl_type = format->glType;
int src_pitch = 0;
int dst_pitch = 0;
- /* In case of P8 the index is stored in the alpha component if the primary render target uses P8 */
- if (format->id == WINED3DFMT_P8_UINT && primary_render_target_is_p8(This->resource.device))
+ /* In case of P8 the index is stored in the alpha component if the primary render target uses P8. */
+ if (format->id == WINED3DFMT_P8_UINT && primary_render_target_is_p8(surface->resource.device))
{
gl_format = GL_ALPHA;
gl_type = GL_UNSIGNED_BYTE;
}
- if (This->Flags & SFLAG_NONPOW2) {
- unsigned char alignment = This->resource.device->surface_alignment;
- src_pitch = format->byte_count * This->pow2Width;
- dst_pitch = IWineD3DSurface_GetPitch((IWineD3DSurface *) This);
+ if (surface->flags & SFLAG_NONPOW2)
+ {
+ unsigned char alignment = surface->resource.device->surface_alignment;
+ src_pitch = format->byte_count * surface->pow2Width;
+ dst_pitch = wined3d_surface_get_pitch(surface);
src_pitch = (src_pitch + alignment - 1) & ~(alignment - 1);
- mem = HeapAlloc(GetProcessHeap(), 0, src_pitch * This->pow2Height);
- } else {
- mem = This->resource.allocatedMemory;
+ mem = HeapAlloc(GetProcessHeap(), 0, src_pitch * surface->pow2Height);
+ }
+ else
+ {
+ mem = surface->resource.allocatedMemory;
}
TRACE("(%p) : Calling glGetTexImage level %d, format %#x, type %#x, data %p\n",
- This, This->texture_level, gl_format, gl_type, mem);
+ surface, surface->texture_level, gl_format, gl_type, mem);
- if(This->Flags & SFLAG_PBO) {
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, This->pbo));
+ if (surface->flags & SFLAG_PBO)
+ {
+ GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, surface->pbo));
checkGLcall("glBindBufferARB");
- glGetTexImage(This->texture_target, This->texture_level, gl_format, gl_type, NULL);
+ glGetTexImage(surface->texture_target, surface->texture_level, gl_format, gl_type, NULL);
checkGLcall("glGetTexImage");
GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0));
checkGLcall("glBindBufferARB");
- } else {
- glGetTexImage(This->texture_target, This->texture_level, gl_format, gl_type, mem);
+ }
+ else
+ {
+ glGetTexImage(surface->texture_target, surface->texture_level, gl_format, gl_type, mem);
checkGLcall("glGetTexImage");
}
LEAVE_GL();
- if (This->Flags & SFLAG_NONPOW2) {
+ if (surface->flags & SFLAG_NONPOW2)
+ {
const BYTE *src_data;
BYTE *dst_data;
UINT y;
@@ -689,16 +2136,16 @@ static void surface_download_data(IWineD3DSurfaceImpl *This, const struct wined3
* standard texture with a non-power2 width instead of texture boxed up to be a power2 texture.
*
* internally the texture is still stored in a boxed format so any references to textureName will
- * get a boxed texture with width pow2width and not a texture of width currentDesc.Width.
+ * get a boxed texture with width pow2width and not a texture of width resource.width.
*
* Performance should not be an issue, because applications normally do not lock the surfaces when
* rendering. If an app does, the SFLAG_DYNLOCK flag will kick in and the memory copy won't be released,
- * and doesn't have to be re-read.
- */
+ * and doesn't have to be re-read. */
src_data = mem;
- dst_data = This->resource.allocatedMemory;
- TRACE("(%p) : Repacking the surface data from pitch %d to pitch %d\n", This, src_pitch, dst_pitch);
- for (y = 1 ; y < This->currentDesc.Height; y++) {
+ dst_data = surface->resource.allocatedMemory;
+ TRACE("(%p) : Repacking the surface data from pitch %d to pitch %d\n", surface, src_pitch, dst_pitch);
+ for (y = 1; y < surface->resource.height; ++y)
+ {
/* skip the first row */
src_data += src_pitch;
dst_data += dst_pitch;
@@ -710,24 +2157,24 @@ static void surface_download_data(IWineD3DSurfaceImpl *This, const struct wined3
}
/* Surface has now been downloaded */
- This->Flags |= SFLAG_INSYSMEM;
+ surface->flags |= SFLAG_INSYSMEM;
}
/* This call just uploads data, the caller is responsible for binding the
* correct texture. */
/* Context activation is done by the caller. */
-static void surface_upload_data(IWineD3DSurfaceImpl *This, const struct wined3d_gl_info *gl_info,
+static void surface_upload_data(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info,
const struct wined3d_format *format, BOOL srgb, const GLvoid *data)
{
- GLsizei width = This->currentDesc.Width;
- GLsizei height = This->currentDesc.Height;
+ GLsizei width = surface->resource.width;
+ GLsizei height = surface->resource.height;
GLenum internal;
if (srgb)
{
internal = format->glGammaInternal;
}
- else if (This->resource.usage & WINED3DUSAGE_RENDERTARGET && surface_is_offscreen(This))
+ else if (surface->resource.usage & WINED3DUSAGE_RENDERTARGET && surface_is_offscreen(surface))
{
internal = format->rtInternal;
}
@@ -736,42 +2183,42 @@ static void surface_upload_data(IWineD3DSurfaceImpl *This, const struct wined3d_
internal = format->glInternal;
}
- TRACE("This %p, internal %#x, width %d, height %d, format %#x, type %#x, data %p.\n",
- This, internal, width, height, format->glFormat, format->glType, data);
+ TRACE("surface %p, internal %#x, width %d, height %d, format %#x, type %#x, data %p.\n",
+ surface, internal, width, height, format->glFormat, format->glType, data);
TRACE("target %#x, level %u, resource size %u.\n",
- This->texture_target, This->texture_level, This->resource.size);
+ surface->texture_target, surface->texture_level, surface->resource.size);
if (format->heightscale != 1.0f && format->heightscale != 0.0f) height *= format->heightscale;
ENTER_GL();
- if (This->Flags & SFLAG_PBO)
+ if (surface->flags & SFLAG_PBO)
{
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->pbo));
+ GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, surface->pbo));
checkGLcall("glBindBufferARB");
- TRACE("(%p) pbo: %#x, data: %p.\n", This, This->pbo, data);
+ TRACE("(%p) pbo: %#x, data: %p.\n", surface, surface->pbo, data);
data = NULL;
}
- if (format->Flags & WINED3DFMT_FLAG_COMPRESSED)
+ if (format->flags & WINED3DFMT_FLAG_COMPRESSED)
{
TRACE("Calling glCompressedTexSubImage2DARB.\n");
- GL_EXTCALL(glCompressedTexSubImage2DARB(This->texture_target, This->texture_level,
- 0, 0, width, height, internal, This->resource.size, data));
+ GL_EXTCALL(glCompressedTexSubImage2DARB(surface->texture_target, surface->texture_level,
+ 0, 0, width, height, internal, surface->resource.size, data));
checkGLcall("glCompressedTexSubImage2DARB");
}
else
{
TRACE("Calling glTexSubImage2D.\n");
- glTexSubImage2D(This->texture_target, This->texture_level,
+ glTexSubImage2D(surface->texture_target, surface->texture_level,
0, 0, width, height, format->glFormat, format->glType, data);
checkGLcall("glTexSubImage2D");
}
- if (This->Flags & SFLAG_PBO)
+ if (surface->flags & SFLAG_PBO)
{
GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
checkGLcall("glBindBufferARB");
@@ -781,12 +2228,12 @@ static void surface_upload_data(IWineD3DSurfaceImpl *This, const struct wined3d_
if (gl_info->quirks & WINED3D_QUIRK_FBO_TEX_UPDATE)
{
- IWineD3DDeviceImpl *device = This->resource.device;
+ struct wined3d_device *device = surface->resource.device;
unsigned int i;
- for (i = 0; i < device->numContexts; ++i)
+ for (i = 0; i < device->context_count; ++i)
{
- context_surface_update(device->contexts[i], This);
+ context_surface_update(device->contexts[i], surface);
}
}
}
@@ -794,12 +2241,12 @@ static void surface_upload_data(IWineD3DSurfaceImpl *This, const struct wined3d_
/* This call just allocates the texture, the caller is responsible for binding
* the correct texture. */
/* Context activation is done by the caller. */
-static void surface_allocate_surface(IWineD3DSurfaceImpl *This, const struct wined3d_gl_info *gl_info,
+static void surface_allocate_surface(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info,
const struct wined3d_format *format, BOOL srgb)
{
BOOL enable_client_storage = FALSE;
- GLsizei width = This->pow2Width;
- GLsizei height = This->pow2Height;
+ GLsizei width = surface->pow2Width;
+ GLsizei height = surface->pow2Height;
const BYTE *mem = NULL;
GLenum internal;
@@ -807,7 +2254,7 @@ static void surface_allocate_surface(IWineD3DSurfaceImpl *This, const struct win
{
internal = format->glGammaInternal;
}
- else if (This->resource.usage & WINED3DUSAGE_RENDERTARGET && surface_is_offscreen(This))
+ else if (surface->resource.usage & WINED3DUSAGE_RENDERTARGET && surface_is_offscreen(surface))
{
internal = format->rtInternal;
}
@@ -819,15 +2266,15 @@ static void surface_allocate_surface(IWineD3DSurfaceImpl *This, const struct win
if (format->heightscale != 1.0f && format->heightscale != 0.0f) height *= format->heightscale;
TRACE("(%p) : Creating surface (target %#x) level %d, d3d format %s, internal format %#x, width %d, height %d, gl format %#x, gl type=%#x\n",
- This, This->texture_target, This->texture_level, debug_d3dformat(format->id),
+ surface, surface->texture_target, surface->texture_level, debug_d3dformat(format->id),
internal, width, height, format->glFormat, format->glType);
ENTER_GL();
if (gl_info->supported[APPLE_CLIENT_STORAGE])
{
- if (This->Flags & (SFLAG_NONPOW2 | SFLAG_DIBSECTION | SFLAG_CONVERTED)
- || !This->resource.allocatedMemory)
+ if (surface->flags & (SFLAG_NONPOW2 | SFLAG_DIBSECTION | SFLAG_CONVERTED)
+ || !surface->resource.allocatedMemory)
{
/* In some cases we want to disable client storage.
* SFLAG_NONPOW2 has a bigger opengl texture than the client memory, and different pitches
@@ -837,27 +2284,30 @@ static void surface_allocate_surface(IWineD3DSurfaceImpl *This, const struct win
*/
glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE)");
- This->Flags &= ~SFLAG_CLIENT;
+ surface->flags &= ~SFLAG_CLIENT;
enable_client_storage = TRUE;
- } else {
- This->Flags |= SFLAG_CLIENT;
+ }
+ else
+ {
+ surface->flags |= SFLAG_CLIENT;
- /* Point opengl to our allocated texture memory. Do not use resource.allocatedMemory here because
- * it might point into a pbo. Instead use heapMemory, but get the alignment right.
- */
- mem = (BYTE *)(((ULONG_PTR) This->resource.heapMemory + (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
+ /* Point OpenGL to our allocated texture memory. Do not use
+ * resource.allocatedMemory here because it might point into a
+ * PBO. Instead use heapMemory, but get the alignment right. */
+ mem = (BYTE *)(((ULONG_PTR)surface->resource.heapMemory
+ + (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
}
}
- if (format->Flags & WINED3DFMT_FLAG_COMPRESSED && mem)
+ if (format->flags & WINED3DFMT_FLAG_COMPRESSED && mem)
{
- GL_EXTCALL(glCompressedTexImage2DARB(This->texture_target, This->texture_level,
- internal, width, height, 0, This->resource.size, mem));
+ GL_EXTCALL(glCompressedTexImage2DARB(surface->texture_target, surface->texture_level,
+ internal, width, height, 0, surface->resource.size, mem));
checkGLcall("glCompressedTexImage2DARB");
}
else
{
- glTexImage2D(This->texture_target, This->texture_level,
+ glTexImage2D(surface->texture_target, surface->texture_level,
internal, width, height, 0, format->glFormat, format->glType, mem);
checkGLcall("glTexImage2D");
}
@@ -873,12 +2323,24 @@ static void surface_allocate_surface(IWineD3DSurfaceImpl *This, const struct win
* render target dimensions. With FBOs, the dimensions have to be an exact match. */
/* TODO: We should synchronize the renderbuffer's content with the texture's content. */
/* GL locking is done by the caller */
-void surface_set_compatible_renderbuffer(IWineD3DSurfaceImpl *surface, unsigned int width, unsigned int height)
+void surface_set_compatible_renderbuffer(struct wined3d_surface *surface, struct wined3d_surface *rt)
{
const struct wined3d_gl_info *gl_info = &surface->resource.device->adapter->gl_info;
- renderbuffer_entry_t *entry;
+ struct wined3d_renderbuffer_entry *entry;
GLuint renderbuffer = 0;
unsigned int src_width, src_height;
+ unsigned int width, height;
+
+ if (rt && rt->resource.format->id != WINED3DFMT_NULL)
+ {
+ width = rt->pow2Width;
+ height = rt->pow2Height;
+ }
+ else
+ {
+ width = surface->pow2Width;
+ height = surface->pow2Height;
+ }
src_width = surface->pow2Width;
src_height = surface->pow2Height;
@@ -895,7 +2357,7 @@ void surface_set_compatible_renderbuffer(IWineD3DSurfaceImpl *surface, unsigned
}
/* Look if we've already got a renderbuffer of the correct dimensions */
- LIST_FOR_EACH_ENTRY(entry, &surface->renderbuffers, renderbuffer_entry_t, entry)
+ LIST_FOR_EACH_ENTRY(entry, &surface->renderbuffers, struct wined3d_renderbuffer_entry, entry)
{
if (entry->width == width && entry->height == height)
{
@@ -912,7 +2374,7 @@ void surface_set_compatible_renderbuffer(IWineD3DSurfaceImpl *surface, unsigned
gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER,
surface->resource.format->glInternal, width, height);
- entry = HeapAlloc(GetProcessHeap(), 0, sizeof(renderbuffer_entry_t));
+ entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*entry));
entry->width = width;
entry->height = height;
entry->id = renderbuffer;
@@ -924,9 +2386,9 @@ void surface_set_compatible_renderbuffer(IWineD3DSurfaceImpl *surface, unsigned
checkGLcall("set_compatible_renderbuffer");
}
-GLenum surface_get_gl_buffer(IWineD3DSurfaceImpl *surface)
+GLenum surface_get_gl_buffer(struct wined3d_surface *surface)
{
- IWineD3DSwapChainImpl *swapchain = surface->container.u.swapchain;
+ struct wined3d_swapchain *swapchain = surface->container.u.swapchain;
TRACE("surface %p.\n", surface);
@@ -957,42 +2419,43 @@ GLenum surface_get_gl_buffer(IWineD3DSurfaceImpl *surface)
}
/* Slightly inefficient way to handle multiple dirty rects but it works :) */
-void surface_add_dirty_rect(IWineD3DSurfaceImpl *surface, const RECT *dirty_rect)
+void surface_add_dirty_rect(struct wined3d_surface *surface, const WINED3DBOX *dirty_rect)
{
- TRACE("surface %p, dirty_rect %s.\n", surface, wine_dbgstr_rect(dirty_rect));
+ TRACE("surface %p, dirty_rect %p.\n", surface, dirty_rect);
- if (!(surface->Flags & SFLAG_INSYSMEM) && (surface->Flags & SFLAG_INTEXTURE))
+ if (!(surface->flags & SFLAG_INSYSMEM) && (surface->flags & SFLAG_INTEXTURE))
/* No partial locking for textures yet. */
surface_load_location(surface, SFLAG_INSYSMEM, NULL);
surface_modify_location(surface, SFLAG_INSYSMEM, TRUE);
if (dirty_rect)
{
- surface->dirtyRect.left = min(surface->dirtyRect.left, dirty_rect->left);
- surface->dirtyRect.top = min(surface->dirtyRect.top, dirty_rect->top);
- surface->dirtyRect.right = max(surface->dirtyRect.right, dirty_rect->right);
- surface->dirtyRect.bottom = max(surface->dirtyRect.bottom, dirty_rect->bottom);
+ surface->dirtyRect.left = min(surface->dirtyRect.left, dirty_rect->Left);
+ surface->dirtyRect.top = min(surface->dirtyRect.top, dirty_rect->Top);
+ surface->dirtyRect.right = max(surface->dirtyRect.right, dirty_rect->Right);
+ surface->dirtyRect.bottom = max(surface->dirtyRect.bottom, dirty_rect->Bottom);
}
else
{
surface->dirtyRect.left = 0;
surface->dirtyRect.top = 0;
- surface->dirtyRect.right = surface->currentDesc.Width;
- surface->dirtyRect.bottom = surface->currentDesc.Height;
+ surface->dirtyRect.right = surface->resource.width;
+ surface->dirtyRect.bottom = surface->resource.height;
}
- /* if the container is a basetexture then mark it dirty. */
+ /* if the container is a texture then mark it dirty. */
if (surface->container.type == WINED3D_CONTAINER_TEXTURE)
{
TRACE("Passing to container.\n");
- IWineD3DBaseTexture_SetDirty((IWineD3DBaseTexture *)surface->container.u.texture, TRUE);
+ wined3d_texture_set_dirty(surface->container.u.texture, TRUE);
}
}
-static BOOL surface_convert_color_to_float(IWineD3DSurfaceImpl *surface, DWORD color, WINED3DCOLORVALUE *float_color)
+static BOOL surface_convert_color_to_float(struct wined3d_surface *surface,
+ DWORD color, WINED3DCOLORVALUE *float_color)
{
const struct wined3d_format *format = surface->resource.format;
- IWineD3DDeviceImpl *device = surface->resource.device;
+ struct wined3d_device *device = surface->resource.device;
switch (format->id)
{
@@ -1042,42 +2505,1145 @@ static BOOL surface_convert_color_to_float(IWineD3DSurfaceImpl *surface, DWORD c
return TRUE;
}
-/* Do not call while under the GL lock. */
-static ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface)
+HRESULT surface_load(struct wined3d_surface *surface, BOOL srgb)
{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
- ULONG ref = InterlockedDecrement(&This->resource.ref);
- TRACE("(%p) : Releasing from %d\n", This, ref + 1);
+ DWORD flag = srgb ? SFLAG_INSRGBTEX : SFLAG_INTEXTURE;
- if (!ref)
+ TRACE("surface %p, srgb %#x.\n", surface, srgb);
+
+ if (surface->resource.pool == WINED3DPOOL_SCRATCH)
{
- surface_cleanup(This);
- This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
-
- TRACE("(%p) Released.\n", This);
- HeapFree(GetProcessHeap(), 0, This);
+ ERR("Not supported on scratch surfaces.\n");
+ return WINED3DERR_INVALIDCALL;
}
- return ref;
+ if (!(surface->flags & flag))
+ {
+ TRACE("Reloading because surface is dirty\n");
+ }
+ /* Reload if either the texture and sysmem have different ideas about the
+ * color key, or the actual key values changed. */
+ else if (!(surface->flags & SFLAG_GLCKEY) != !(surface->CKeyFlags & WINEDDSD_CKSRCBLT)
+ || ((surface->CKeyFlags & WINEDDSD_CKSRCBLT)
+ && (surface->glCKey.dwColorSpaceLowValue != surface->SrcBltCKey.dwColorSpaceLowValue
+ || surface->glCKey.dwColorSpaceHighValue != surface->SrcBltCKey.dwColorSpaceHighValue)))
+ {
+ TRACE("Reloading because of color keying\n");
+ /* To perform the color key conversion we need a sysmem copy of
+ * the surface. Make sure we have it. */
+
+ surface_load_location(surface, SFLAG_INSYSMEM, NULL);
+ /* Make sure the texture is reloaded because of the color key change,
+ * this kills performance though :( */
+ /* TODO: This is not necessarily needed with hw palettized texture support. */
+ surface_modify_location(surface, SFLAG_INSYSMEM, TRUE);
+ }
+ else
+ {
+ TRACE("surface is already in texture\n");
+ return WINED3D_OK;
+ }
+
+ /* No partial locking for textures yet. */
+ surface_load_location(surface, flag, NULL);
+ surface_evict_sysmem(surface);
+
+ return WINED3D_OK;
}
-/* ****************************************************
- IWineD3DSurface IWineD3DResource parts follow
- **************************************************** */
+/* See also float_16_to_32() in wined3d_private.h */
+static inline unsigned short float_32_to_16(const float *in)
+{
+ int exp = 0;
+ float tmp = fabsf(*in);
+ unsigned int mantissa;
+ unsigned short ret;
+
+ /* Deal with special numbers */
+ if (*in == 0.0f)
+ return 0x0000;
+ if (isnan(*in))
+ return 0x7c01;
+ if (isinf(*in))
+ return (*in < 0.0f ? 0xfc00 : 0x7c00);
+
+ if (tmp < powf(2, 10))
+ {
+ do
+ {
+ tmp = tmp * 2.0f;
+ exp--;
+ } while (tmp < powf(2, 10));
+ }
+ else if (tmp >= powf(2, 11))
+ {
+ do
+ {
+ tmp /= 2.0f;
+ exp++;
+ } while (tmp >= powf(2, 11));
+ }
+
+ mantissa = (unsigned int)tmp;
+ if (tmp - mantissa >= 0.5f)
+ ++mantissa; /* Round to nearest, away from zero. */
+
+ exp += 10; /* Normalize the mantissa. */
+ exp += 15; /* Exponent is encoded with excess 15. */
+
+ if (exp > 30) /* too big */
+ {
+ ret = 0x7c00; /* INF */
+ }
+ else if (exp <= 0)
+ {
+ /* exp == 0: Non-normalized mantissa. Returns 0x0000 (=0.0) for too small numbers. */
+ while (exp <= 0)
+ {
+ mantissa = mantissa >> 1;
+ ++exp;
+ }
+ ret = mantissa & 0x3ff;
+ }
+ else
+ {
+ ret = (exp << 10) | (mantissa & 0x3ff);
+ }
+
+ ret |= ((*in < 0.0f ? 1 : 0) << 15); /* Add the sign */
+ return ret;
+}
+
+ULONG CDECL wined3d_surface_incref(struct wined3d_surface *surface)
+{
+ ULONG refcount;
+
+ TRACE("Surface %p, container %p of type %#x.\n",
+ surface, surface->container.u.base, surface->container.type);
+
+ switch (surface->container.type)
+ {
+ case WINED3D_CONTAINER_TEXTURE:
+ return wined3d_texture_incref(surface->container.u.texture);
+
+ case WINED3D_CONTAINER_SWAPCHAIN:
+ return wined3d_swapchain_incref(surface->container.u.swapchain);
+
+ default:
+ ERR("Unhandled container type %#x.\n", surface->container.type);
+ case WINED3D_CONTAINER_NONE:
+ break;
+ }
+
+ refcount = InterlockedIncrement(&surface->resource.ref);
+ TRACE("%p increasing refcount to %u.\n", surface, refcount);
+
+ return refcount;
+}
/* Do not call while under the GL lock. */
-void surface_internal_preload(IWineD3DSurfaceImpl *surface, enum WINED3DSRGB srgb)
+ULONG CDECL wined3d_surface_decref(struct wined3d_surface *surface)
{
- IWineD3DDeviceImpl *device = surface->resource.device;
+ ULONG refcount;
+
+ TRACE("Surface %p, container %p of type %#x.\n",
+ surface, surface->container.u.base, surface->container.type);
+
+ switch (surface->container.type)
+ {
+ case WINED3D_CONTAINER_TEXTURE:
+ return wined3d_texture_decref(surface->container.u.texture);
+
+ case WINED3D_CONTAINER_SWAPCHAIN:
+ return wined3d_swapchain_decref(surface->container.u.swapchain);
+
+ default:
+ ERR("Unhandled container type %#x.\n", surface->container.type);
+ case WINED3D_CONTAINER_NONE:
+ break;
+ }
+
+ refcount = InterlockedDecrement(&surface->resource.ref);
+ TRACE("%p decreasing refcount to %u.\n", surface, refcount);
+
+ if (!refcount)
+ {
+ surface->surface_ops->surface_cleanup(surface);
+ surface->resource.parent_ops->wined3d_object_destroyed(surface->resource.parent);
+
+ TRACE("Destroyed surface %p.\n", surface);
+ HeapFree(GetProcessHeap(), 0, surface);
+ }
+
+ return refcount;
+}
+
+HRESULT CDECL wined3d_surface_set_private_data(struct wined3d_surface *surface,
+ REFGUID riid, const void *data, DWORD data_size, DWORD flags)
+{
+ return resource_set_private_data(&surface->resource, riid, data, data_size, flags);
+}
+
+HRESULT CDECL wined3d_surface_get_private_data(const struct wined3d_surface *surface,
+ REFGUID guid, void *data, DWORD *data_size)
+{
+ return resource_get_private_data(&surface->resource, guid, data, data_size);
+}
+
+HRESULT CDECL wined3d_surface_free_private_data(struct wined3d_surface *surface, REFGUID refguid)
+{
+ return resource_free_private_data(&surface->resource, refguid);
+}
+
+DWORD CDECL wined3d_surface_set_priority(struct wined3d_surface *surface, DWORD priority)
+{
+ return resource_set_priority(&surface->resource, priority);
+}
+
+DWORD CDECL wined3d_surface_get_priority(const struct wined3d_surface *surface)
+{
+ return resource_get_priority(&surface->resource);
+}
+
+void CDECL wined3d_surface_preload(struct wined3d_surface *surface)
+{
+ TRACE("surface %p.\n", surface);
+
+ surface->surface_ops->surface_preload(surface);
+}
+
+void * CDECL wined3d_surface_get_parent(const struct wined3d_surface *surface)
+{
+ TRACE("surface %p.\n", surface);
+
+ return surface->resource.parent;
+}
+
+struct wined3d_resource * CDECL wined3d_surface_get_resource(struct wined3d_surface *surface)
+{
+ TRACE("surface %p.\n", surface);
+
+ return &surface->resource;
+}
+
+HRESULT CDECL wined3d_surface_get_blt_status(const struct wined3d_surface *surface, DWORD flags)
+{
+ TRACE("surface %p, flags %#x.\n", surface, flags);
+
+ switch (flags)
+ {
+ case WINEDDGBS_CANBLT:
+ case WINEDDGBS_ISBLTDONE:
+ return WINED3D_OK;
+
+ default:
+ return WINED3DERR_INVALIDCALL;
+ }
+}
+
+HRESULT CDECL wined3d_surface_get_flip_status(const struct wined3d_surface *surface, DWORD flags)
+{
+ TRACE("surface %p, flags %#x.\n", surface, flags);
+
+ /* XXX: DDERR_INVALIDSURFACETYPE */
+
+ switch (flags)
+ {
+ case WINEDDGFS_CANFLIP:
+ case WINEDDGFS_ISFLIPDONE:
+ return WINED3D_OK;
+
+ default:
+ return WINED3DERR_INVALIDCALL;
+ }
+}
+
+HRESULT CDECL wined3d_surface_is_lost(const struct wined3d_surface *surface)
+{
+ TRACE("surface %p.\n", surface);
+
+ /* D3D8 and 9 loose full devices, ddraw only surfaces. */
+ return surface->flags & SFLAG_LOST ? WINED3DERR_DEVICELOST : WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_surface_restore(struct wined3d_surface *surface)
+{
+ TRACE("surface %p.\n", surface);
+
+ /* So far we don't lose anything :) */
+ surface->flags &= ~SFLAG_LOST;
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_surface_set_palette(struct wined3d_surface *surface, struct wined3d_palette *palette)
+{
+ TRACE("surface %p, palette %p.\n", surface, palette);
+
+ if (surface->palette == palette)
+ {
+ TRACE("Nop palette change.\n");
+ return WINED3D_OK;
+ }
+
+ if (surface->palette && (surface->resource.usage & WINED3DUSAGE_RENDERTARGET))
+ surface->palette->flags &= ~WINEDDPCAPS_PRIMARYSURFACE;
+
+ surface->palette = palette;
+
+ if (palette)
+ {
+ if (surface->resource.usage & WINED3DUSAGE_RENDERTARGET)
+ palette->flags |= WINEDDPCAPS_PRIMARYSURFACE;
+
+ surface->surface_ops->surface_realize_palette(surface);
+ }
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_surface_set_color_key(struct wined3d_surface *surface,
+ DWORD flags, const WINEDDCOLORKEY *color_key)
+{
+ TRACE("surface %p, flags %#x, color_key %p.\n", surface, flags, color_key);
+
+ if (flags & WINEDDCKEY_COLORSPACE)
+ {
+ FIXME(" colorkey value not supported (%08x) !\n", flags);
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ /* Dirtify the surface, but only if a key was changed. */
+ if (color_key)
+ {
+ switch (flags & ~WINEDDCKEY_COLORSPACE)
+ {
+ case WINEDDCKEY_DESTBLT:
+ surface->DestBltCKey = *color_key;
+ surface->CKeyFlags |= WINEDDSD_CKDESTBLT;
+ break;
+
+ case WINEDDCKEY_DESTOVERLAY:
+ surface->DestOverlayCKey = *color_key;
+ surface->CKeyFlags |= WINEDDSD_CKDESTOVERLAY;
+ break;
+
+ case WINEDDCKEY_SRCOVERLAY:
+ surface->SrcOverlayCKey = *color_key;
+ surface->CKeyFlags |= WINEDDSD_CKSRCOVERLAY;
+ break;
+
+ case WINEDDCKEY_SRCBLT:
+ surface->SrcBltCKey = *color_key;
+ surface->CKeyFlags |= WINEDDSD_CKSRCBLT;
+ break;
+ }
+ }
+ else
+ {
+ switch (flags & ~WINEDDCKEY_COLORSPACE)
+ {
+ case WINEDDCKEY_DESTBLT:
+ surface->CKeyFlags &= ~WINEDDSD_CKDESTBLT;
+ break;
+
+ case WINEDDCKEY_DESTOVERLAY:
+ surface->CKeyFlags &= ~WINEDDSD_CKDESTOVERLAY;
+ break;
+
+ case WINEDDCKEY_SRCOVERLAY:
+ surface->CKeyFlags &= ~WINEDDSD_CKSRCOVERLAY;
+ break;
+
+ case WINEDDCKEY_SRCBLT:
+ surface->CKeyFlags &= ~WINEDDSD_CKSRCBLT;
+ break;
+ }
+ }
+
+ return WINED3D_OK;
+}
+
+struct wined3d_palette * CDECL wined3d_surface_get_palette(const struct wined3d_surface *surface)
+{
+ TRACE("surface %p.\n", surface);
+
+ return surface->palette;
+}
+
+DWORD CDECL wined3d_surface_get_pitch(const struct wined3d_surface *surface)
+{
+ const struct wined3d_format *format = surface->resource.format;
+ DWORD pitch;
+
+ TRACE("surface %p.\n", surface);
+
+ if ((format->flags & (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_COMPRESSED)
+ {
+ /* Since compressed formats are block based, pitch means the amount of
+ * bytes to the next row of block rather than the next row of pixels. */
+ UINT row_block_count = (surface->resource.width + format->block_width - 1) / format->block_width;
+ pitch = row_block_count * format->block_byte_count;
+ }
+ else
+ {
+ unsigned char alignment = surface->resource.device->surface_alignment;
+ pitch = surface->resource.format->byte_count * surface->resource.width; /* Bytes / row */
+ pitch = (pitch + alignment - 1) & ~(alignment - 1);
+ }
+
+ TRACE("Returning %u.\n", pitch);
+
+ return pitch;
+}
+
+HRESULT CDECL wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem)
+{
+ TRACE("surface %p, mem %p.\n", surface, mem);
+
+ if (surface->flags & (SFLAG_LOCKED | SFLAG_DCINUSE))
+ {
+ WARN("Surface is locked or the DC is in use.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ return surface->surface_ops->surface_set_mem(surface, mem);
+}
+
+HRESULT CDECL wined3d_surface_set_overlay_position(struct wined3d_surface *surface, LONG x, LONG y)
+{
+ LONG w, h;
+
+ TRACE("surface %p, x %d, y %d.\n", surface, x, y);
+
+ if (!(surface->resource.usage & WINED3DUSAGE_OVERLAY))
+ {
+ WARN("Not an overlay surface.\n");
+ return WINEDDERR_NOTAOVERLAYSURFACE;
+ }
+
+ w = surface->overlay_destrect.right - surface->overlay_destrect.left;
+ h = surface->overlay_destrect.bottom - surface->overlay_destrect.top;
+ surface->overlay_destrect.left = x;
+ surface->overlay_destrect.top = y;
+ surface->overlay_destrect.right = x + w;
+ surface->overlay_destrect.bottom = y + h;
+
+ surface->surface_ops->surface_draw_overlay(surface);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_surface_get_overlay_position(const struct wined3d_surface *surface, LONG *x, LONG *y)
+{
+ TRACE("surface %p, x %p, y %p.\n", surface, x, y);
+
+ if (!(surface->resource.usage & WINED3DUSAGE_OVERLAY))
+ {
+ TRACE("Not an overlay surface.\n");
+ return WINEDDERR_NOTAOVERLAYSURFACE;
+ }
+
+ if (!surface->overlay_dest)
+ {
+ TRACE("Overlay not visible.\n");
+ *x = 0;
+ *y = 0;
+ return WINEDDERR_OVERLAYNOTVISIBLE;
+ }
+
+ *x = surface->overlay_destrect.left;
+ *y = surface->overlay_destrect.top;
+
+ TRACE("Returning position %d, %d.\n", *x, *y);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_surface_update_overlay_z_order(struct wined3d_surface *surface,
+ DWORD flags, struct wined3d_surface *ref)
+{
+ FIXME("surface %p, flags %#x, ref %p stub!\n", surface, flags, ref);
+
+ if (!(surface->resource.usage & WINED3DUSAGE_OVERLAY))
+ {
+ TRACE("Not an overlay surface.\n");
+ return WINEDDERR_NOTAOVERLAYSURFACE;
+ }
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_surface_update_overlay(struct wined3d_surface *surface, const RECT *src_rect,
+ struct wined3d_surface *dst_surface, const RECT *dst_rect, DWORD flags, const WINEDDOVERLAYFX *fx)
+{
+ TRACE("surface %p, src_rect %s, dst_surface %p, dst_rect %s, flags %#x, fx %p.\n",
+ surface, wine_dbgstr_rect(src_rect), dst_surface, wine_dbgstr_rect(dst_rect), flags, fx);
+
+ if (!(surface->resource.usage & WINED3DUSAGE_OVERLAY))
+ {
+ WARN("Not an overlay surface.\n");
+ return WINEDDERR_NOTAOVERLAYSURFACE;
+ }
+ else if (!dst_surface)
+ {
+ WARN("Dest surface is NULL.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ if (src_rect)
+ {
+ surface->overlay_srcrect = *src_rect;
+ }
+ else
+ {
+ surface->overlay_srcrect.left = 0;
+ surface->overlay_srcrect.top = 0;
+ surface->overlay_srcrect.right = surface->resource.width;
+ surface->overlay_srcrect.bottom = surface->resource.height;
+ }
+
+ if (dst_rect)
+ {
+ surface->overlay_destrect = *dst_rect;
+ }
+ else
+ {
+ surface->overlay_destrect.left = 0;
+ surface->overlay_destrect.top = 0;
+ surface->overlay_destrect.right = dst_surface ? dst_surface->resource.width : 0;
+ surface->overlay_destrect.bottom = dst_surface ? dst_surface->resource.height : 0;
+ }
+
+ if (surface->overlay_dest && (surface->overlay_dest != dst_surface || flags & WINEDDOVER_HIDE))
+ {
+ list_remove(&surface->overlay_entry);
+ }
+
+ if (flags & WINEDDOVER_SHOW)
+ {
+ if (surface->overlay_dest != dst_surface)
+ {
+ surface->overlay_dest = dst_surface;
+ list_add_tail(&dst_surface->overlays, &surface->overlay_entry);
+ }
+ }
+ else if (flags & WINEDDOVER_HIDE)
+ {
+ /* tests show that the rectangles are erased on hide */
+ surface->overlay_srcrect.left = 0; surface->overlay_srcrect.top = 0;
+ surface->overlay_srcrect.right = 0; surface->overlay_srcrect.bottom = 0;
+ surface->overlay_destrect.left = 0; surface->overlay_destrect.top = 0;
+ surface->overlay_destrect.right = 0; surface->overlay_destrect.bottom = 0;
+ surface->overlay_dest = NULL;
+ }
+
+ surface->surface_ops->surface_draw_overlay(surface);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_surface_set_clipper(struct wined3d_surface *surface, struct wined3d_clipper *clipper)
+{
+ TRACE("surface %p, clipper %p.\n", surface, clipper);
+
+ surface->clipper = clipper;
+
+ return WINED3D_OK;
+}
+
+struct wined3d_clipper * CDECL wined3d_surface_get_clipper(const struct wined3d_surface *surface)
+{
+ TRACE("surface %p.\n", surface);
+
+ return surface->clipper;
+}
+
+HRESULT CDECL wined3d_surface_set_format(struct wined3d_surface *surface, enum wined3d_format_id format_id)
+{
+ const struct wined3d_format *format = wined3d_get_format(&surface->resource.device->adapter->gl_info, format_id);
+
+ TRACE("surface %p, format %s.\n", surface, debug_d3dformat(format_id));
+
+ if (surface->resource.format->id != WINED3DFMT_UNKNOWN)
+ {
+ FIXME("The format of the surface must be WINED3DFORMAT_UNKNOWN.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ surface->resource.size = wined3d_format_calculate_size(format, surface->resource.device->surface_alignment,
+ surface->pow2Width, surface->pow2Height);
+ surface->flags |= (WINED3DFMT_D16_LOCKABLE == format_id) ? SFLAG_LOCKABLE : 0;
+ surface->flags &= ~(SFLAG_ALLOCATED | SFLAG_SRGBALLOCATED);
+ surface->resource.format = format;
+
+ TRACE("size %u, byte_count %u\n", surface->resource.size, format->byte_count);
+ TRACE("glFormat %#x, glInternal %#x, glType %#x.\n",
+ format->glFormat, format->glInternal, format->glType);
+
+ return WINED3D_OK;
+}
+
+static void convert_r32_float_r16_float(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ unsigned short *dst_s;
+ const float *src_f;
+ unsigned int x, y;
+
+ TRACE("Converting %ux%u pixels, pitches %u %u.\n", w, h, pitch_in, pitch_out);
+
+ for (y = 0; y < h; ++y)
+ {
+ src_f = (const float *)(src + y * pitch_in);
+ dst_s = (unsigned short *) (dst + y * pitch_out);
+ for (x = 0; x < w; ++x)
+ {
+ dst_s[x] = float_32_to_16(src_f + x);
+ }
+ }
+}
+
+static void convert_r5g6b5_x8r8g8b8(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ static const unsigned char convert_5to8[] =
+ {
+ 0x00, 0x08, 0x10, 0x19, 0x21, 0x29, 0x31, 0x3a,
+ 0x42, 0x4a, 0x52, 0x5a, 0x63, 0x6b, 0x73, 0x7b,
+ 0x84, 0x8c, 0x94, 0x9c, 0xa5, 0xad, 0xb5, 0xbd,
+ 0xc5, 0xce, 0xd6, 0xde, 0xe6, 0xef, 0xf7, 0xff,
+ };
+ static const unsigned char convert_6to8[] =
+ {
+ 0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c,
+ 0x20, 0x24, 0x28, 0x2d, 0x31, 0x35, 0x39, 0x3d,
+ 0x41, 0x45, 0x49, 0x4d, 0x51, 0x55, 0x59, 0x5d,
+ 0x61, 0x65, 0x69, 0x6d, 0x71, 0x75, 0x79, 0x7d,
+ 0x82, 0x86, 0x8a, 0x8e, 0x92, 0x96, 0x9a, 0x9e,
+ 0xa2, 0xa6, 0xaa, 0xae, 0xb2, 0xb6, 0xba, 0xbe,
+ 0xc2, 0xc6, 0xca, 0xce, 0xd2, 0xd7, 0xdb, 0xdf,
+ 0xe3, 0xe7, 0xeb, 0xef, 0xf3, 0xf7, 0xfb, 0xff,
+ };
+ unsigned int x, y;
+
+ TRACE("Converting %ux%u pixels, pitches %u %u.\n", w, h, pitch_in, pitch_out);
+
+ for (y = 0; y < h; ++y)
+ {
+ const WORD *src_line = (const WORD *)(src + y * pitch_in);
+ DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
+ for (x = 0; x < w; ++x)
+ {
+ WORD pixel = src_line[x];
+ dst_line[x] = 0xff000000
+ | convert_5to8[(pixel & 0xf800) >> 11] << 16
+ | convert_6to8[(pixel & 0x07e0) >> 5] << 8
+ | convert_5to8[(pixel & 0x001f)];
+ }
+ }
+}
+
+static void convert_a8r8g8b8_x8r8g8b8(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ unsigned int x, y;
+
+ TRACE("Converting %ux%u pixels, pitches %u %u.\n", w, h, pitch_in, pitch_out);
+
+ for (y = 0; y < h; ++y)
+ {
+ const DWORD *src_line = (const DWORD *)(src + y * pitch_in);
+ DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
+
+ for (x = 0; x < w; ++x)
+ {
+ dst_line[x] = 0xff000000 | (src_line[x] & 0xffffff);
+ }
+ }
+}
+
+static inline BYTE cliptobyte(int x)
+{
+ return (BYTE)((x < 0) ? 0 : ((x > 255) ? 255 : x));
+}
+
+static void convert_yuy2_x8r8g8b8(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ int c2, d, e, r2 = 0, g2 = 0, b2 = 0;
+ unsigned int x, y;
+
+ TRACE("Converting %ux%u pixels, pitches %u %u.\n", w, h, pitch_in, pitch_out);
+
+ for (y = 0; y < h; ++y)
+ {
+ const BYTE *src_line = src + y * pitch_in;
+ DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
+ for (x = 0; x < w; ++x)
+ {
+ /* YUV to RGB conversion formulas from http://en.wikipedia.org/wiki/YUV:
+ * C = Y - 16; D = U - 128; E = V - 128;
+ * R = cliptobyte((298 * C + 409 * E + 128) >> 8);
+ * G = cliptobyte((298 * C - 100 * D - 208 * E + 128) >> 8);
+ * B = cliptobyte((298 * C + 516 * D + 128) >> 8);
+ * Two adjacent YUY2 pixels are stored as four bytes: Y0 U Y1 V .
+ * U and V are shared between the pixels. */
+ if (!(x & 1)) /* For every even pixel, read new U and V. */
+ {
+ d = (int) src_line[1] - 128;
+ e = (int) src_line[3] - 128;
+ r2 = 409 * e + 128;
+ g2 = - 100 * d - 208 * e + 128;
+ b2 = 516 * d + 128;
+ }
+ c2 = 298 * ((int) src_line[0] - 16);
+ dst_line[x] = 0xff000000
+ | cliptobyte((c2 + r2) >> 8) << 16 /* red */
+ | cliptobyte((c2 + g2) >> 8) << 8 /* green */
+ | cliptobyte((c2 + b2) >> 8); /* blue */
+ /* Scale RGB values to 0..255 range,
+ * then clip them if still not in range (may be negative),
+ * then shift them within DWORD if necessary. */
+ src_line += 2;
+ }
+ }
+}
+
+static void convert_yuy2_r5g6b5(const BYTE *src, BYTE *dst,
+ DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
+{
+ unsigned int x, y;
+ int c2, d, e, r2 = 0, g2 = 0, b2 = 0;
+
+ TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
+
+ for (y = 0; y < h; ++y)
+ {
+ const BYTE *src_line = src + y * pitch_in;
+ WORD *dst_line = (WORD *)(dst + y * pitch_out);
+ for (x = 0; x < w; ++x)
+ {
+ /* YUV to RGB conversion formulas from http://en.wikipedia.org/wiki/YUV:
+ * C = Y - 16; D = U - 128; E = V - 128;
+ * R = cliptobyte((298 * C + 409 * E + 128) >> 8);
+ * G = cliptobyte((298 * C - 100 * D - 208 * E + 128) >> 8);
+ * B = cliptobyte((298 * C + 516 * D + 128) >> 8);
+ * Two adjacent YUY2 pixels are stored as four bytes: Y0 U Y1 V .
+ * U and V are shared between the pixels. */
+ if (!(x & 1)) /* For every even pixel, read new U and V. */
+ {
+ d = (int) src_line[1] - 128;
+ e = (int) src_line[3] - 128;
+ r2 = 409 * e + 128;
+ g2 = - 100 * d - 208 * e + 128;
+ b2 = 516 * d + 128;
+ }
+ c2 = 298 * ((int) src_line[0] - 16);
+ dst_line[x] = (cliptobyte((c2 + r2) >> 8) >> 3) << 11 /* red */
+ | (cliptobyte((c2 + g2) >> 8) >> 2) << 5 /* green */
+ | (cliptobyte((c2 + b2) >> 8) >> 3); /* blue */
+ /* Scale RGB values to 0..255 range,
+ * then clip them if still not in range (may be negative),
+ * then shift them within DWORD if necessary. */
+ src_line += 2;
+ }
+ }
+}
+
+struct d3dfmt_convertor_desc
+{
+ enum wined3d_format_id from, to;
+ void (*convert)(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h);
+};
+
+static const struct d3dfmt_convertor_desc convertors[] =
+{
+ {WINED3DFMT_R32_FLOAT, WINED3DFMT_R16_FLOAT, convert_r32_float_r16_float},
+ {WINED3DFMT_B5G6R5_UNORM, WINED3DFMT_B8G8R8X8_UNORM, convert_r5g6b5_x8r8g8b8},
+ {WINED3DFMT_B8G8R8A8_UNORM, WINED3DFMT_B8G8R8X8_UNORM, convert_a8r8g8b8_x8r8g8b8},
+ {WINED3DFMT_YUY2, WINED3DFMT_B8G8R8X8_UNORM, convert_yuy2_x8r8g8b8},
+ {WINED3DFMT_YUY2, WINED3DFMT_B5G6R5_UNORM, convert_yuy2_r5g6b5},
+};
+
+static inline const struct d3dfmt_convertor_desc *find_convertor(enum wined3d_format_id from,
+ enum wined3d_format_id to)
+{
+ unsigned int i;
+
+ for (i = 0; i < (sizeof(convertors) / sizeof(*convertors)); ++i)
+ {
+ if (convertors[i].from == from && convertors[i].to == to)
+ return &convertors[i];
+ }
+
+ return NULL;
+}
+
+/*****************************************************************************
+ * surface_convert_format
+ *
+ * Creates a duplicate of a surface in a different format. Is used by Blt to
+ * blit between surfaces with different formats.
+ *
+ * Parameters
+ * source: Source surface
+ * fmt: Requested destination format
+ *
+ *****************************************************************************/
+static struct wined3d_surface *surface_convert_format(struct wined3d_surface *source, enum wined3d_format_id to_fmt)
+{
+ const struct d3dfmt_convertor_desc *conv;
+ WINED3DLOCKED_RECT lock_src, lock_dst;
+ struct wined3d_surface *ret = NULL;
+ HRESULT hr;
+
+ conv = find_convertor(source->resource.format->id, to_fmt);
+ if (!conv)
+ {
+ FIXME("Cannot find a conversion function from format %s to %s.\n",
+ debug_d3dformat(source->resource.format->id), debug_d3dformat(to_fmt));
+ return NULL;
+ }
+
+ wined3d_surface_create(source->resource.device, source->resource.width,
+ source->resource.height, to_fmt, TRUE /* lockable */, TRUE /* discard */, 0 /* level */,
+ 0 /* usage */, WINED3DPOOL_SCRATCH, WINED3DMULTISAMPLE_NONE /* TODO: Multisampled conversion */,
+ 0 /* MultiSampleQuality */, source->surface_type, NULL /* parent */, &wined3d_null_parent_ops, &ret);
+ if (!ret)
+ {
+ ERR("Failed to create a destination surface for conversion.\n");
+ return NULL;
+ }
+
+ memset(&lock_src, 0, sizeof(lock_src));
+ memset(&lock_dst, 0, sizeof(lock_dst));
+
+ hr = wined3d_surface_map(source, &lock_src, NULL, WINED3DLOCK_READONLY);
+ if (FAILED(hr))
+ {
+ ERR("Failed to lock the source surface.\n");
+ wined3d_surface_decref(ret);
+ return NULL;
+ }
+ hr = wined3d_surface_map(ret, &lock_dst, NULL, WINED3DLOCK_READONLY);
+ if (FAILED(hr))
+ {
+ ERR("Failed to lock the destination surface.\n");
+ wined3d_surface_unmap(source);
+ wined3d_surface_decref(ret);
+ return NULL;
+ }
+
+ conv->convert(lock_src.pBits, lock_dst.pBits, lock_src.Pitch, lock_dst.Pitch,
+ source->resource.width, source->resource.height);
+
+ wined3d_surface_unmap(ret);
+ wined3d_surface_unmap(source);
+
+ return ret;
+}
+
+static HRESULT _Blt_ColorFill(BYTE *buf, unsigned int width, unsigned int height,
+ unsigned int bpp, UINT pitch, DWORD color)
+{
+ BYTE *first;
+ int x, y;
+
+ /* Do first row */
+
+#define COLORFILL_ROW(type) \
+do { \
+ type *d = (type *)buf; \
+ for (x = 0; x < width; ++x) \
+ d[x] = (type)color; \
+} while(0)
+
+ switch (bpp)
+ {
+ case 1:
+ COLORFILL_ROW(BYTE);
+ break;
+
+ case 2:
+ COLORFILL_ROW(WORD);
+ break;
+
+ case 3:
+ {
+ BYTE *d = buf;
+ for (x = 0; x < width; ++x, d += 3)
+ {
+ d[0] = (color ) & 0xFF;
+ d[1] = (color >> 8) & 0xFF;
+ d[2] = (color >> 16) & 0xFF;
+ }
+ break;
+ }
+ case 4:
+ COLORFILL_ROW(DWORD);
+ break;
+
+ default:
+ FIXME("Color fill not implemented for bpp %u!\n", bpp * 8);
+ return WINED3DERR_NOTAVAILABLE;
+ }
+
+#undef COLORFILL_ROW
+
+ /* Now copy first row. */
+ first = buf;
+ for (y = 1; y < height; ++y)
+ {
+ buf += pitch;
+ memcpy(buf, first, width * bpp);
+ }
+
+ return WINED3D_OK;
+}
+
+/* Do not call while under the GL lock. */
+HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst_rect,
+ struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
+ const WINEDDBLTFX *fx, WINED3DTEXTUREFILTERTYPE filter)
+{
+ TRACE("dst_surface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p, filter %s.\n",
+ dst_surface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect),
+ flags, fx, debug_d3dtexturefiltertype(filter));
+
+ return dst_surface->surface_ops->surface_blt(dst_surface,
+ dst_rect, src_surface, src_rect, flags, fx, filter);
+}
+
+/* Do not call while under the GL lock. */
+HRESULT CDECL wined3d_surface_bltfast(struct wined3d_surface *dst_surface, DWORD dst_x, DWORD dst_y,
+ struct wined3d_surface *src_surface, const RECT *src_rect, DWORD trans)
+{
+ TRACE("dst_surface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, trans %#x.\n",
+ dst_surface, dst_x, dst_y, src_surface, wine_dbgstr_rect(src_rect), trans);
+
+ return dst_surface->surface_ops->surface_bltfast(dst_surface,
+ dst_x, dst_y, src_surface, src_rect, trans);
+}
+
+HRESULT CDECL wined3d_surface_unmap(struct wined3d_surface *surface)
+{
+ TRACE("surface %p.\n", surface);
+
+ if (!(surface->flags & SFLAG_LOCKED))
+ {
+ WARN("Trying to unmap unmapped surface.\n");
+ return WINEDDERR_NOTLOCKED;
+ }
+ surface->flags &= ~SFLAG_LOCKED;
+
+ surface->surface_ops->surface_unmap(surface);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
+ WINED3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags)
+{
+ TRACE("surface %p, locked_rect %p, rect %s, flags %#x.\n",
+ surface, locked_rect, wine_dbgstr_rect(rect), flags);
+
+ if (surface->flags & SFLAG_LOCKED)
+ {
+ WARN("Surface is already mapped.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+ surface->flags |= SFLAG_LOCKED;
+
+ if (!(surface->flags & SFLAG_LOCKABLE))
+ WARN("Trying to lock unlockable surface.\n");
+
+ surface->surface_ops->surface_map(surface, rect, flags);
+
+ locked_rect->Pitch = wined3d_surface_get_pitch(surface);
+
+ if (!rect)
+ {
+ locked_rect->pBits = surface->resource.allocatedMemory;
+ surface->lockedRect.left = 0;
+ surface->lockedRect.top = 0;
+ surface->lockedRect.right = surface->resource.width;
+ surface->lockedRect.bottom = surface->resource.height;
+ }
+ else
+ {
+ const struct wined3d_format *format = surface->resource.format;
+
+ if ((format->flags & (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_COMPRESSED)
+ {
+ /* Compressed textures are block based, so calculate the offset of
+ * the block that contains the top-left pixel of the locked rectangle. */
+ locked_rect->pBits = surface->resource.allocatedMemory
+ + ((rect->top / format->block_height) * locked_rect->Pitch)
+ + ((rect->left / format->block_width) * format->block_byte_count);
+ }
+ else
+ {
+ locked_rect->pBits = surface->resource.allocatedMemory
+ + (locked_rect->Pitch * rect->top)
+ + (rect->left * format->byte_count);
+ }
+ surface->lockedRect.left = rect->left;
+ surface->lockedRect.top = rect->top;
+ surface->lockedRect.right = rect->right;
+ surface->lockedRect.bottom = rect->bottom;
+ }
+
+ TRACE("Locked rect %s.\n", wine_dbgstr_rect(&surface->lockedRect));
+ TRACE("Returning memory %p, pitch %u.\n", locked_rect->pBits, locked_rect->Pitch);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc)
+{
+ HRESULT hr;
+
+ TRACE("surface %p, dc %p.\n", surface, dc);
+
+ if (surface->flags & SFLAG_USERPTR)
+ {
+ ERR("Not supported on surfaces with application-provided memory.\n");
+ return WINEDDERR_NODC;
+ }
+
+ /* Give more detailed info for ddraw. */
+ if (surface->flags & SFLAG_DCINUSE)
+ return WINEDDERR_DCALREADYCREATED;
+
+ /* Can't GetDC if the surface is locked. */
+ if (surface->flags & SFLAG_LOCKED)
+ return WINED3DERR_INVALIDCALL;
+
+ hr = surface->surface_ops->surface_getdc(surface);
+ if (FAILED(hr))
+ return hr;
+
+ if (surface->resource.format->id == WINED3DFMT_P8_UINT
+ || surface->resource.format->id == WINED3DFMT_P8_UINT_A8_UNORM)
+ {
+ /* GetDC on palettized formats is unsupported in D3D9, and the method
+ * is missing in D3D8, so this should only be used for DX <=7
+ * surfaces (with non-device palettes). */
+ const PALETTEENTRY *pal = NULL;
+
+ if (surface->palette)
+ {
+ pal = surface->palette->palents;
+ }
+ else
+ {
+ struct wined3d_swapchain *swapchain = surface->resource.device->swapchains[0];
+ struct wined3d_surface *dds_primary = swapchain->front_buffer;
+
+ if (dds_primary && dds_primary->palette)
+ pal = dds_primary->palette->palents;
+ }
+
+ if (pal)
+ {
+ RGBQUAD col[256];
+ unsigned int i;
+
+ for (i = 0; i < 256; ++i)
+ {
+ col[i].rgbRed = pal[i].peRed;
+ col[i].rgbGreen = pal[i].peGreen;
+ col[i].rgbBlue = pal[i].peBlue;
+ col[i].rgbReserved = 0;
+ }
+ SetDIBColorTable(surface->hDC, 0, 256, col);
+ }
+ }
+
+ surface->flags |= SFLAG_DCINUSE;
+
+ *dc = surface->hDC;
+ TRACE("Returning dc %p.\n", *dc);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc)
+{
+ TRACE("surface %p, dc %p.\n", surface, dc);
+
+ if (!(surface->flags & SFLAG_DCINUSE))
+ return WINEDDERR_NODC;
+
+ if (surface->hDC != dc)
+ {
+ WARN("Application tries to release invalid DC %p, surface DC is %p.\n",
+ dc, surface->hDC);
+ return WINEDDERR_NODC;
+ }
+
+ if ((surface->flags & SFLAG_PBO) && surface->resource.allocatedMemory)
+ {
+ /* Copy the contents of the DIB over to the PBO. */
+ memcpy(surface->resource.allocatedMemory, surface->dib.bitmap_data, surface->dib.bitmap_size);
+ }
+
+ /* We locked first, so unlock now. */
+ wined3d_surface_unmap(surface);
+
+ surface->flags &= ~SFLAG_DCINUSE;
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_surface_flip(struct wined3d_surface *surface, struct wined3d_surface *override, DWORD flags)
+{
+ struct wined3d_swapchain *swapchain;
+ HRESULT hr;
+
+ TRACE("surface %p, override %p, flags %#x.\n", surface, override, flags);
+
+ 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 = surface->surface_ops->surface_flip(surface, override);
+ if (FAILED(hr))
+ return hr;
+
+ /* Just overwrite the swapchain presentation interval. This is ok because
+ * only ddraw apps can call Flip, and only d3d8 and d3d9 applications
+ * specify the presentation interval. */
+ if (!(flags & (WINEDDFLIP_NOVSYNC | WINEDDFLIP_INTERVAL2 | WINEDDFLIP_INTERVAL3 | WINEDDFLIP_INTERVAL4)))
+ swapchain->presentParms.PresentationInterval = WINED3DPRESENT_INTERVAL_ONE;
+ else if (flags & WINEDDFLIP_NOVSYNC)
+ swapchain->presentParms.PresentationInterval = WINED3DPRESENT_INTERVAL_IMMEDIATE;
+ else if (flags & WINEDDFLIP_INTERVAL2)
+ swapchain->presentParms.PresentationInterval = WINED3DPRESENT_INTERVAL_TWO;
+ else if (flags & WINEDDFLIP_INTERVAL3)
+ swapchain->presentParms.PresentationInterval = WINED3DPRESENT_INTERVAL_THREE;
+ else
+ swapchain->presentParms.PresentationInterval = WINED3DPRESENT_INTERVAL_FOUR;
+
+ return wined3d_swapchain_present(swapchain, NULL, NULL, swapchain->win_handle, NULL, 0);
+}
+
+/* Do not call while under the GL lock. */
+void surface_internal_preload(struct wined3d_surface *surface, enum WINED3DSRGB srgb)
+{
+ struct wined3d_device *device = surface->resource.device;
TRACE("iface %p, srgb %#x.\n", surface, srgb);
if (surface->container.type == WINED3D_CONTAINER_TEXTURE)
{
- IWineD3DBaseTextureImpl *texture = surface->container.u.texture;
+ struct wined3d_texture *texture = surface->container.u.texture;
- TRACE("Passing to container.\n");
- texture->baseTexture.internal_preload((IWineD3DBaseTexture *)texture, srgb);
+ TRACE("Passing to container (%p).\n", texture);
+ texture->texture_ops->texture_preload(texture, srgb);
}
else
{
@@ -1100,7 +3666,7 @@ void surface_internal_preload(IWineD3DSurfaceImpl *surface, enum WINED3DSRGB srg
}
}
- IWineD3DSurface_LoadTexture((IWineD3DSurface *)surface, srgb == SRGB_SRGB ? TRUE : FALSE);
+ surface_load(surface, srgb == SRGB_SRGB ? TRUE : FALSE);
if (surface->resource.pool == WINED3DPOOL_DEFAULT)
{
@@ -1116,32 +3682,7 @@ void surface_internal_preload(IWineD3DSurfaceImpl *surface, enum WINED3DSRGB srg
}
}
-static void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface)
-{
- surface_internal_preload((IWineD3DSurfaceImpl *)iface, SRGB_ANY);
-}
-
-/* Context activation is done by the caller. */
-static void surface_remove_pbo(IWineD3DSurfaceImpl *This, const struct wined3d_gl_info *gl_info)
-{
- This->resource.heapMemory = HeapAlloc(GetProcessHeap() ,0 , This->resource.size + RESOURCE_ALIGNMENT);
- This->resource.allocatedMemory =
- (BYTE *)(((ULONG_PTR) This->resource.heapMemory + (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
-
- ENTER_GL();
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->pbo));
- checkGLcall("glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, This->pbo)");
- GL_EXTCALL(glGetBufferSubDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0, This->resource.size, This->resource.allocatedMemory));
- checkGLcall("glGetBufferSubDataARB");
- GL_EXTCALL(glDeleteBuffersARB(1, &This->pbo));
- checkGLcall("glDeleteBuffersARB");
- LEAVE_GL();
-
- This->pbo = 0;
- This->Flags &= ~SFLAG_PBO;
-}
-
-BOOL surface_init_sysmem(IWineD3DSurfaceImpl *surface)
+BOOL surface_init_sysmem(struct wined3d_surface *surface)
{
if (!surface->resource.allocatedMemory)
{
@@ -1165,86 +3706,10 @@ BOOL surface_init_sysmem(IWineD3DSurfaceImpl *surface)
return TRUE;
}
-/* Do not call while under the GL lock. */
-static void WINAPI IWineD3DSurfaceImpl_UnLoad(IWineD3DSurface *iface)
-{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
- IWineD3DDeviceImpl *device = This->resource.device;
- const struct wined3d_gl_info *gl_info;
- renderbuffer_entry_t *entry, *entry2;
- struct wined3d_context *context;
-
- TRACE("(%p)\n", iface);
-
- if(This->resource.pool == WINED3DPOOL_DEFAULT) {
- /* Default pool resources are supposed to be destroyed before Reset is called.
- * Implicit resources stay however. So this means we have an implicit render target
- * or depth stencil. The content may be destroyed, but we still have to tear down
- * opengl resources, so we cannot leave early.
- *
- * Put the surfaces into sysmem, and reset the content. The D3D content is undefined,
- * but we can't set the sysmem INDRAWABLE because when we're rendering the swapchain
- * or the depth stencil into an FBO the texture or render buffer will be removed
- * and all flags get lost
- */
- surface_init_sysmem(This);
- }
- else
- {
- /* Load the surface into system memory */
- surface_load_location(This, SFLAG_INSYSMEM, NULL);
- surface_modify_location(This, SFLAG_INDRAWABLE, FALSE);
- }
- surface_modify_location(This, SFLAG_INTEXTURE, FALSE);
- surface_modify_location(This, SFLAG_INSRGBTEX, FALSE);
- This->Flags &= ~(SFLAG_ALLOCATED | SFLAG_SRGBALLOCATED);
-
- context = context_acquire(device, NULL);
- gl_info = context->gl_info;
-
- /* Destroy PBOs, but load them into real sysmem before */
- if (This->Flags & SFLAG_PBO)
- surface_remove_pbo(This, gl_info);
-
- /* Destroy fbo render buffers. This is needed for implicit render targets, for
- * all application-created targets the application has to release the surface
- * before calling _Reset
- */
- LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &This->renderbuffers, renderbuffer_entry_t, entry) {
- ENTER_GL();
- gl_info->fbo_ops.glDeleteRenderbuffers(1, &entry->id);
- LEAVE_GL();
- list_remove(&entry->entry);
- HeapFree(GetProcessHeap(), 0, entry);
- }
- list_init(&This->renderbuffers);
- This->current_renderbuffer = NULL;
-
- /* If we're in a texture, the texture name belongs to the texture.
- * Otherwise, destroy it. */
- if (This->container.type != WINED3D_CONTAINER_TEXTURE)
- {
- ENTER_GL();
- glDeleteTextures(1, &This->texture_name);
- This->texture_name = 0;
- glDeleteTextures(1, &This->texture_name_srgb);
- This->texture_name_srgb = 0;
- LEAVE_GL();
- }
-
- context_release(context);
-
- resource_unload((IWineD3DResourceImpl *)This);
-}
-
-/* ******************************************************
- IWineD3DSurface IWineD3DSurface parts follow
- ****************************************************** */
-
/* Read the framebuffer back into the surface */
-static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, void *dest, UINT pitch)
+static void read_from_framebuffer(struct wined3d_surface *surface, const RECT *rect, void *dest, UINT pitch)
{
- IWineD3DDeviceImpl *device = This->resource.device;
+ struct wined3d_device *device = surface->resource.device;
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
BYTE *mem;
@@ -1268,12 +3733,7 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, v
return;
}
- /* Activate the surface. Set it up for blitting now, although not necessarily needed for LockRect.
- * Certain graphics drivers seem to dislike some enabled states when reading from opengl, the blitting usage
- * should help here. Furthermore unlockrect will need the context set up for blitting. The context manager will find
- * context->last_was_blit set on the unlock.
- */
- context = context_acquire(device, This);
+ context = context_acquire(device, surface);
context_apply_blit_state(context, device);
gl_info = context->gl_info;
@@ -1283,37 +3743,39 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, v
* There is no need to keep track of the current read buffer or reset it, every part of the code
* that reads sets the read buffer as desired.
*/
- if (surface_is_offscreen(This))
+ if (surface_is_offscreen(surface))
{
- /* Locking the primary render target which is not on a swapchain(=offscreen render target).
- * Read from the back buffer
- */
- TRACE("Locking offscreen render target\n");
+ /* Mapping the primary render target which is not on a swapchain.
+ * Read from the back buffer. */
+ TRACE("Mapping offscreen render target.\n");
glReadBuffer(device->offscreenBuffer);
srcIsUpsideDown = TRUE;
}
else
{
/* Onscreen surfaces are always part of a swapchain */
- GLenum buffer = surface_get_gl_buffer(This);
- TRACE("Locking %#x buffer\n", buffer);
+ GLenum buffer = surface_get_gl_buffer(surface);
+ TRACE("Mapping %#x buffer.\n", buffer);
glReadBuffer(buffer);
checkGLcall("glReadBuffer");
srcIsUpsideDown = FALSE;
}
/* TODO: Get rid of the extra rectangle comparison and construction of a full surface rectangle */
- if(!rect) {
+ if (!rect)
+ {
local_rect.left = 0;
local_rect.top = 0;
- local_rect.right = This->currentDesc.Width;
- local_rect.bottom = This->currentDesc.Height;
- } else {
+ local_rect.right = surface->resource.width;
+ local_rect.bottom = surface->resource.height;
+ }
+ else
+ {
local_rect = *rect;
}
/* TODO: Get rid of the extra GetPitch call, LockRect does that too. Cache the pitch */
- switch (This->resource.format->id)
+ switch (surface->resource.format->id)
{
case WINED3DFMT_P8_UINT:
{
@@ -1323,8 +3785,10 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, v
fmt = GL_ALPHA;
type = GL_UNSIGNED_BYTE;
mem = dest;
- bpp = This->resource.format->byte_count;
- } else {
+ bpp = surface->resource.format->byte_count;
+ }
+ else
+ {
/* GL can't return palettized data, so read ARGB pixels into a
* separate block of memory and convert them into palettized format
* in software. Slow, but if the app means to use palettized render
@@ -1337,26 +3801,28 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, v
fmt = GL_RGB;
type = GL_UNSIGNED_BYTE;
pitch *= 3;
- mem = HeapAlloc(GetProcessHeap(), 0, This->resource.size * 3);
- if(!mem) {
+ mem = HeapAlloc(GetProcessHeap(), 0, surface->resource.size * 3);
+ if (!mem)
+ {
ERR("Out of memory\n");
LEAVE_GL();
return;
}
- bpp = This->resource.format->byte_count * 3;
+ bpp = surface->resource.format->byte_count * 3;
}
}
break;
default:
mem = dest;
- fmt = This->resource.format->glFormat;
- type = This->resource.format->glType;
- bpp = This->resource.format->byte_count;
+ fmt = surface->resource.format->glFormat;
+ type = surface->resource.format->glType;
+ bpp = surface->resource.format->byte_count;
}
- if(This->Flags & SFLAG_PBO) {
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, This->pbo));
+ if (surface->flags & SFLAG_PBO)
+ {
+ GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, surface->pbo));
checkGLcall("glBindBufferARB");
if (mem)
{
@@ -1374,17 +3840,17 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, v
checkGLcall("glGetIntegerv");
/* Setup pixel store pack state -- to glReadPixels into the correct place */
- glPixelStorei(GL_PACK_ROW_LENGTH, This->currentDesc.Width);
+ glPixelStorei(GL_PACK_ROW_LENGTH, surface->resource.width);
checkGLcall("glPixelStorei");
glPixelStorei(GL_PACK_SKIP_PIXELS, local_rect.left);
checkGLcall("glPixelStorei");
glPixelStorei(GL_PACK_SKIP_ROWS, local_rect.top);
checkGLcall("glPixelStorei");
- glReadPixels(local_rect.left, (!srcIsUpsideDown) ? (This->currentDesc.Height - local_rect.bottom) : local_rect.top ,
- local_rect.right - local_rect.left,
- local_rect.bottom - local_rect.top,
- fmt, type, mem);
+ glReadPixels(local_rect.left, !srcIsUpsideDown ? (surface->resource.height - local_rect.bottom) : local_rect.top,
+ local_rect.right - local_rect.left,
+ local_rect.bottom - local_rect.top,
+ fmt, type, mem);
checkGLcall("glReadPixels");
/* Reset previous pixel store pack state */
@@ -1395,7 +3861,8 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, v
glPixelStorei(GL_PACK_SKIP_ROWS, skipRow);
checkGLcall("glPixelStorei");
- if(This->Flags & SFLAG_PBO) {
+ if (surface->flags & SFLAG_PBO)
+ {
GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0));
checkGLcall("glBindBufferARB");
@@ -1403,8 +3870,9 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, v
* to get a pointer to it and perform the flipping in software. This is a lot
* faster than calling glReadPixels for each line. In case we want more speed
* we should rerender it flipped in a FBO and read the data back from the FBO. */
- if(!srcIsUpsideDown) {
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->pbo));
+ if (!srcIsUpsideDown)
+ {
+ GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, surface->pbo));
checkGLcall("glBindBufferARB");
mem = GL_EXTCALL(glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_READ_WRITE_ARB));
@@ -1423,7 +3891,8 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, v
row = HeapAlloc(GetProcessHeap(), 0, len);
if(!row) {
ERR("Out of memory\n");
- if (This->resource.format->id == WINED3DFMT_P8_UINT) HeapFree(GetProcessHeap(), 0, mem);
+ if (surface->resource.format->id == WINED3DFMT_P8_UINT)
+ HeapFree(GetProcessHeap(), 0, mem);
LEAVE_GL();
return;
}
@@ -1440,7 +3909,8 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, v
HeapFree(GetProcessHeap(), 0, row);
/* Unmap the temp PBO buffer */
- if(This->Flags & SFLAG_PBO) {
+ if (surface->flags & SFLAG_PBO)
+ {
GL_EXTCALL(glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB));
GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
}
@@ -1449,23 +3919,26 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, v
LEAVE_GL();
context_release(context);
- /* For P8 textures we need to perform an inverse palette lookup. This is done by searching for a palette
- * index which matches the RGB value. Note this isn't guaranteed to work when there are multiple entries for
- * the same color but we have no choice.
- * In case of P8 render targets, the index is stored in the alpha component so no conversion is needed.
- */
- if (This->resource.format->id == WINED3DFMT_P8_UINT && !primary_render_target_is_p8(device))
+ /* For P8 textures we need to perform an inverse palette lookup. This is
+ * done by searching for a palette index which matches the RGB value.
+ * Note this isn't guaranteed to work when there are multiple entries for
+ * the same color but we have no choice. In case of P8 render targets,
+ * the index is stored in the alpha component so no conversion is needed. */
+ if (surface->resource.format->id == WINED3DFMT_P8_UINT && !primary_render_target_is_p8(device))
{
const PALETTEENTRY *pal = NULL;
DWORD width = pitch / 3;
int x, y, c;
- if(This->palette) {
- pal = This->palette->palents;
- } else {
+ if (surface->palette)
+ {
+ pal = surface->palette->palents;
+ }
+ else
+ {
ERR("Palette is missing, cannot perform inverse palette lookup\n");
HeapFree(GetProcessHeap(), 0, mem);
- return ;
+ return;
}
for(y = local_rect.top; y < local_rect.bottom; y++) {
@@ -1491,13 +3964,13 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, v
}
/* Read the framebuffer contents into a texture */
-static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This, BOOL srgb)
+static void read_from_framebuffer_texture(struct wined3d_surface *surface, BOOL srgb)
{
- IWineD3DDeviceImpl *device = This->resource.device;
+ struct wined3d_device *device = surface->resource.device;
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
- if (!surface_is_offscreen(This))
+ if (!surface_is_offscreen(surface))
{
/* We would need to flip onscreen surfaces, but there's no efficient
* way to do that here. It makes more sense for the caller to
@@ -1510,21 +3983,21 @@ static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This, BOOL srgb)
* locking during offscreen rendering). RESOURCELOAD is ok because glCopyTexSubImage2D isn't affected by any
* states in the stateblock, and no driver was found yet that had bugs in that regard.
*/
- context = context_acquire(device, This);
+ context = context_acquire(device, surface);
gl_info = context->gl_info;
- surface_prepare_texture(This, gl_info, srgb);
- surface_bind_and_dirtify(This, srgb);
+ surface_prepare_texture(surface, gl_info, srgb);
+ surface_bind_and_dirtify(surface, gl_info, srgb);
- TRACE("Reading back offscreen render target %p.\n", This);
+ TRACE("Reading back offscreen render target %p.\n", surface);
ENTER_GL();
glReadBuffer(device->offscreenBuffer);
checkGLcall("glReadBuffer");
- glCopyTexSubImage2D(This->texture_target, This->texture_level,
- 0, 0, 0, 0, This->currentDesc.Width, This->currentDesc.Height);
+ glCopyTexSubImage2D(surface->texture_target, surface->texture_level,
+ 0, 0, 0, 0, surface->resource.width, surface->resource.height);
checkGLcall("glCopyTexSubImage2D");
LEAVE_GL();
@@ -1533,38 +4006,38 @@ static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This, BOOL srgb)
}
/* Context activation is done by the caller. */
-static void surface_prepare_texture_internal(IWineD3DSurfaceImpl *surface,
+static void surface_prepare_texture_internal(struct wined3d_surface *surface,
const struct wined3d_gl_info *gl_info, BOOL srgb)
{
DWORD alloc_flag = srgb ? SFLAG_SRGBALLOCATED : SFLAG_ALLOCATED;
CONVERT_TYPES convert;
struct wined3d_format format;
- if (surface->Flags & alloc_flag) return;
+ if (surface->flags & alloc_flag) return;
d3dfmt_get_conv(surface, TRUE, TRUE, &format, &convert);
- if (convert != NO_CONVERSION || format.convert) surface->Flags |= SFLAG_CONVERTED;
- else surface->Flags &= ~SFLAG_CONVERTED;
+ if (convert != NO_CONVERSION || format.convert) surface->flags |= SFLAG_CONVERTED;
+ else surface->flags &= ~SFLAG_CONVERTED;
- surface_bind_and_dirtify(surface, srgb);
+ surface_bind_and_dirtify(surface, gl_info, srgb);
surface_allocate_surface(surface, gl_info, &format, srgb);
- surface->Flags |= alloc_flag;
+ surface->flags |= alloc_flag;
}
/* Context activation is done by the caller. */
-void surface_prepare_texture(IWineD3DSurfaceImpl *surface, const struct wined3d_gl_info *gl_info, BOOL srgb)
+void surface_prepare_texture(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info, BOOL srgb)
{
if (surface->container.type == WINED3D_CONTAINER_TEXTURE)
{
- IWineD3DBaseTextureImpl *texture = surface->container.u.texture;
- UINT sub_count = texture->baseTexture.level_count * texture->baseTexture.layer_count;
+ struct wined3d_texture *texture = surface->container.u.texture;
+ UINT sub_count = texture->level_count * texture->layer_count;
UINT i;
TRACE("surface %p is a subresource of texture %p.\n", surface, texture);
for (i = 0; i < sub_count; ++i)
{
- IWineD3DSurfaceImpl *s = (IWineD3DSurfaceImpl *)texture->baseTexture.sub_resources[i];
+ struct wined3d_surface *s = surface_from_resource(texture->sub_resources[i]);
surface_prepare_texture_internal(s, gl_info, srgb);
}
@@ -1574,563 +4047,96 @@ void surface_prepare_texture(IWineD3DSurfaceImpl *surface, const struct wined3d_
surface_prepare_texture_internal(surface, gl_info, srgb);
}
-static void surface_prepare_system_memory(IWineD3DSurfaceImpl *This)
+static void flush_to_framebuffer_drawpixels(struct wined3d_surface *surface,
+ const RECT *rect, GLenum fmt, GLenum type, UINT bpp, const BYTE *mem)
{
- IWineD3DDeviceImpl *device = This->resource.device;
- const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
-
- /* Performance optimization: Count how often a surface is locked, if it is locked regularly do not throw away the system memory copy.
- * This avoids the need to download the surface from opengl all the time. The surface is still downloaded if the opengl texture is
- * changed
- */
- if(!(This->Flags & SFLAG_DYNLOCK)) {
- This->lockCount++;
- /* MAXLOCKCOUNT is defined in wined3d_private.h */
- if(This->lockCount > MAXLOCKCOUNT) {
- TRACE("Surface is locked regularly, not freeing the system memory copy any more\n");
- This->Flags |= SFLAG_DYNLOCK;
- }
- }
-
- /* Create a PBO for dynamically locked surfaces but don't do it for converted or non-pow2 surfaces.
- * Also don't create a PBO for systemmem surfaces.
- */
- if (gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] && (This->Flags & SFLAG_DYNLOCK)
- && !(This->Flags & (SFLAG_PBO | SFLAG_CONVERTED | SFLAG_NONPOW2))
- && (This->resource.pool != WINED3DPOOL_SYSTEMMEM))
- {
- GLenum error;
- struct wined3d_context *context;
-
- context = context_acquire(device, NULL);
- ENTER_GL();
-
- GL_EXTCALL(glGenBuffersARB(1, &This->pbo));
- error = glGetError();
- if (!This->pbo || error != GL_NO_ERROR)
- ERR("Failed to bind the PBO with error %s (%#x)\n", debug_glerror(error), error);
-
- TRACE("Attaching pbo=%#x to (%p)\n", This->pbo, This);
-
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->pbo));
- checkGLcall("glBindBufferARB");
-
- GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->resource.size + 4, This->resource.allocatedMemory, GL_STREAM_DRAW_ARB));
- checkGLcall("glBufferDataARB");
-
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
- checkGLcall("glBindBufferARB");
-
- /* We don't need the system memory anymore and we can't even use it for PBOs */
- if(!(This->Flags & SFLAG_CLIENT)) {
- HeapFree(GetProcessHeap(), 0, This->resource.heapMemory);
- This->resource.heapMemory = NULL;
- }
- This->resource.allocatedMemory = NULL;
- This->Flags |= SFLAG_PBO;
- LEAVE_GL();
- context_release(context);
- }
- else if (!(This->resource.allocatedMemory || This->Flags & SFLAG_PBO))
- {
- /* Whatever surface we have, make sure that there is memory allocated for the downloaded copy,
- * or a pbo to map
- */
- if(!This->resource.heapMemory) {
- This->resource.heapMemory = HeapAlloc(GetProcessHeap() ,0 , This->resource.size + RESOURCE_ALIGNMENT);
- }
- This->resource.allocatedMemory =
- (BYTE *)(((ULONG_PTR) This->resource.heapMemory + (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
- if(This->Flags & SFLAG_INSYSMEM) {
- ERR("Surface without memory or pbo has SFLAG_INSYSMEM set!\n");
- }
- }
-}
-
-static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
- IWineD3DDeviceImpl *device = This->resource.device;
- const RECT *pass_rect = pRect;
-
- TRACE("iface %p, locked_rect %p, rect %s, flags %#x.\n",
- iface, pLockedRect, wine_dbgstr_rect(pRect), Flags);
-
- /* This is also done in the base class, but we have to verify this before loading any data from
- * gl into the sysmem copy. The PBO may be mapped, a different rectangle locked, the discard flag
- * may interfere, and all other bad things may happen
- */
- if (This->Flags & SFLAG_LOCKED) {
- WARN("Surface is already locked, returning D3DERR_INVALIDCALL\n");
- return WINED3DERR_INVALIDCALL;
- }
- This->Flags |= SFLAG_LOCKED;
-
- if (!(This->Flags & SFLAG_LOCKABLE))
- {
- TRACE("Warning: trying to lock unlockable surf@%p\n", This);
- }
-
- if (Flags & WINED3DLOCK_DISCARD) {
- /* Set SFLAG_INSYSMEM, so we'll never try to download the data from the texture. */
- TRACE("WINED3DLOCK_DISCARD flag passed, marking local copy as up to date\n");
- surface_prepare_system_memory(This); /* Makes sure memory is allocated */
- This->Flags |= SFLAG_INSYSMEM;
- goto lock_end;
- }
-
- if (This->Flags & SFLAG_INSYSMEM) {
- TRACE("Local copy is up to date, not downloading data\n");
- surface_prepare_system_memory(This); /* Makes sure memory is allocated */
- goto lock_end;
- }
-
- /* surface_load_location() does not check if the rectangle specifies
- * the full surface. Most callers don't need that, so do it here. */
- if (pRect && !pRect->top && !pRect->left
- && pRect->right == This->currentDesc.Width
- && pRect->bottom == This->currentDesc.Height)
- {
- pass_rect = NULL;
- }
-
- if (!(wined3d_settings.rendertargetlock_mode == RTL_DISABLE
- && ((This->container.type == WINED3D_CONTAINER_SWAPCHAIN) || This == device->render_targets[0])))
- {
- surface_load_location(This, SFLAG_INSYSMEM, pass_rect);
- }
-
-lock_end:
- if (This->Flags & SFLAG_PBO)
- {
- const struct wined3d_gl_info *gl_info;
- struct wined3d_context *context;
-
- context = context_acquire(device, NULL);
- gl_info = context->gl_info;
-
- ENTER_GL();
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->pbo));
- checkGLcall("glBindBufferARB");
-
- /* This shouldn't happen but could occur if some other function didn't handle the PBO properly */
- if(This->resource.allocatedMemory) {
- ERR("The surface already has PBO memory allocated!\n");
- }
-
- This->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_READ_WRITE_ARB));
- checkGLcall("glMapBufferARB");
-
- /* Make sure the pbo isn't set anymore in order not to break non-pbo calls */
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
- checkGLcall("glBindBufferARB");
-
- LEAVE_GL();
- context_release(context);
- }
-
- if (Flags & (WINED3DLOCK_NO_DIRTY_UPDATE | WINED3DLOCK_READONLY)) {
- /* Don't dirtify */
- }
- else
- {
- surface_add_dirty_rect(This, pRect);
-
- if (This->container.type == WINED3D_CONTAINER_TEXTURE)
- {
- TRACE("Making container dirty.\n");
- IWineD3DBaseTexture_SetDirty((IWineD3DBaseTexture *)This->container.u.texture, TRUE);
- }
- else
- {
- TRACE("Surface is standalone, no need to dirty the container\n");
- }
- }
-
- return IWineD3DBaseSurfaceImpl_LockRect(iface, pLockedRect, pRect, Flags);
-}
-
-static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This, GLenum fmt, GLenum type, UINT bpp, const BYTE *mem) {
- GLint prev_store;
- GLint prev_rasterpos[4];
- GLint skipBytes = 0;
- UINT pitch = IWineD3DSurface_GetPitch((IWineD3DSurface *) This); /* target is argb, 4 byte */
- IWineD3DDeviceImpl *device = This->resource.device;
+ struct wined3d_device *device = surface->resource.device;
+ UINT pitch = wined3d_surface_get_pitch(surface);
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
+ RECT local_rect;
+ UINT w, h;
+
+ surface_get_rect(surface, rect, &local_rect);
+
+ mem += local_rect.top * pitch + local_rect.left * bpp;
+ w = local_rect.right - local_rect.left;
+ h = local_rect.bottom - local_rect.top;
/* Activate the correct context for the render target */
- context = context_acquire(device, This);
+ context = context_acquire(device, surface);
context_apply_blit_state(context, device);
gl_info = context->gl_info;
ENTER_GL();
- if (!surface_is_offscreen(This))
+ if (!surface_is_offscreen(surface))
{
- GLenum buffer = surface_get_gl_buffer(This);
+ GLenum buffer = surface_get_gl_buffer(surface);
TRACE("Unlocking %#x buffer.\n", buffer);
context_set_draw_buffer(context, buffer);
+
+ surface_translate_drawable_coords(surface, context->win_handle, &local_rect);
+ glPixelZoom(1.0f, -1.0f);
}
else
{
/* Primary offscreen render target */
TRACE("Offscreen render target.\n");
context_set_draw_buffer(context, device->offscreenBuffer);
+
+ glPixelZoom(1.0f, 1.0f);
}
- glGetIntegerv(GL_PACK_SWAP_BYTES, &prev_store);
- checkGLcall("glGetIntegerv");
- glGetIntegerv(GL_CURRENT_RASTER_POSITION, &prev_rasterpos[0]);
- checkGLcall("glGetIntegerv");
- glPixelZoom(1.0f, -1.0f);
- checkGLcall("glPixelZoom");
-
- /* If not fullscreen, we need to skip a number of bytes to find the next row of data */
- glGetIntegerv(GL_UNPACK_ROW_LENGTH, &skipBytes);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, This->currentDesc.Width);
-
- glRasterPos3i(This->lockedRect.left, This->lockedRect.top, 1);
+ glRasterPos3i(local_rect.left, local_rect.top, 1);
checkGLcall("glRasterPos3i");
- /* Some drivers(radeon dri, others?) don't like exceptions during
- * glDrawPixels. If the surface is a DIB section, it might be in GDIMode
- * after ReleaseDC. Reading it will cause an exception, which x11drv will
- * catch to put the dib section in InSync mode, which leads to a crash
- * and a blocked x server on my radeon card.
- *
- * The following lines read the dib section so it is put in InSync mode
- * before glDrawPixels is called and the crash is prevented. There won't
- * be any interfering gdi accesses, because UnlockRect is called from
- * ReleaseDC, and the app won't use the dc any more afterwards.
- */
- if((This->Flags & SFLAG_DIBSECTION) && !(This->Flags & SFLAG_PBO)) {
- volatile BYTE read;
- read = This->resource.allocatedMemory[0];
- }
+ /* If not fullscreen, we need to skip a number of bytes to find the next row of data */
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, surface->resource.width);
- if(This->Flags & SFLAG_PBO) {
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->pbo));
+ if (surface->flags & SFLAG_PBO)
+ {
+ GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, surface->pbo));
checkGLcall("glBindBufferARB");
}
- /* When the surface is locked we only have to refresh the locked part else we need to update the whole image */
- if(This->Flags & SFLAG_LOCKED) {
- glDrawPixels(This->lockedRect.right - This->lockedRect.left,
- (This->lockedRect.bottom - This->lockedRect.top)-1,
- fmt, type,
- mem + bpp * This->lockedRect.left + pitch * This->lockedRect.top);
- checkGLcall("glDrawPixels");
- } else {
- glDrawPixels(This->currentDesc.Width,
- This->currentDesc.Height,
- fmt, type, mem);
- checkGLcall("glDrawPixels");
- }
+ glDrawPixels(w, h, fmt, type, mem);
+ checkGLcall("glDrawPixels");
- if(This->Flags & SFLAG_PBO) {
+ if (surface->flags & SFLAG_PBO)
+ {
GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
checkGLcall("glBindBufferARB");
}
- glPixelZoom(1.0f, 1.0f);
- checkGLcall("glPixelZoom");
-
- glRasterPos3iv(&prev_rasterpos[0]);
- checkGLcall("glRasterPos3iv");
-
- /* Reset to previous pack row length */
- glPixelStorei(GL_UNPACK_ROW_LENGTH, skipBytes);
- checkGLcall("glPixelStorei(GL_UNPACK_ROW_LENGTH)");
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ checkGLcall("glPixelStorei(GL_UNPACK_ROW_LENGTH, 0)");
LEAVE_GL();
+
+ if (wined3d_settings.strict_draw_ordering
+ || (surface->container.type == WINED3D_CONTAINER_SWAPCHAIN
+ && surface->container.u.swapchain->front_buffer == surface))
+ wglFlush();
+
context_release(context);
}
-static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
- IWineD3DDeviceImpl *device = This->resource.device;
- BOOL fullsurface;
-
- if (!(This->Flags & SFLAG_LOCKED)) {
- WARN("trying to Unlock an unlocked surf@%p\n", This);
- return WINEDDERR_NOTLOCKED;
- }
-
- if (This->Flags & SFLAG_PBO)
- {
- const struct wined3d_gl_info *gl_info;
- struct wined3d_context *context;
-
- TRACE("Freeing PBO memory\n");
-
- context = context_acquire(device, NULL);
- gl_info = context->gl_info;
-
- ENTER_GL();
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->pbo));
- GL_EXTCALL(glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB));
- GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
- checkGLcall("glUnmapBufferARB");
- LEAVE_GL();
- context_release(context);
-
- This->resource.allocatedMemory = NULL;
- }
-
- TRACE("(%p) : dirtyfied(%d)\n", This, This->Flags & (SFLAG_INDRAWABLE | SFLAG_INTEXTURE) ? 0 : 1);
-
- if (This->Flags & (SFLAG_INDRAWABLE | SFLAG_INTEXTURE)) {
- TRACE("(%p) : Not Dirtified so nothing to do, return now\n", This);
- goto unlock_end;
- }
-
- if (This->container.type == WINED3D_CONTAINER_SWAPCHAIN
- || (device->render_targets && This == device->render_targets[0]))
- {
- if(wined3d_settings.rendertargetlock_mode == RTL_DISABLE) {
- static BOOL warned = FALSE;
- if(!warned) {
- ERR("The application tries to write to the render target, but render target locking is disabled\n");
- warned = TRUE;
- }
- goto unlock_end;
- }
-
- if (!This->dirtyRect.left && !This->dirtyRect.top
- && This->dirtyRect.right == This->currentDesc.Width
- && This->dirtyRect.bottom == This->currentDesc.Height)
- {
- fullsurface = TRUE;
- } else {
- /* TODO: Proper partial rectangle tracking */
- fullsurface = FALSE;
- This->Flags |= SFLAG_INSYSMEM;
- }
-
- switch(wined3d_settings.rendertargetlock_mode) {
- case RTL_READTEX:
- surface_load_location(This, SFLAG_INTEXTURE, NULL /* partial texture loading not supported yet */);
- /* drop through */
-
- case RTL_READDRAW:
- surface_load_location(This, SFLAG_INDRAWABLE, fullsurface ? NULL : &This->dirtyRect);
- break;
- }
-
- if(!fullsurface) {
- /* Partial rectangle tracking is not commonly implemented, it is only done for render targets. Overwrite
- * the flags to bring them back into a sane state. INSYSMEM was set before to tell LoadLocation where
- * to read the rectangle from. Indrawable is set because all modifications from the partial sysmem copy
- * are written back to the drawable, thus the surface is merged again in the drawable. The sysmem copy is
- * not fully up to date because only a subrectangle was read in LockRect.
- */
- This->Flags &= ~SFLAG_INSYSMEM;
- This->Flags |= SFLAG_INDRAWABLE;
- }
-
- This->dirtyRect.left = This->currentDesc.Width;
- This->dirtyRect.top = This->currentDesc.Height;
- This->dirtyRect.right = 0;
- This->dirtyRect.bottom = 0;
- }
- else if (This == device->depth_stencil)
- {
- FIXME("Depth Stencil buffer locking is not implemented\n");
- } else {
- /* The rest should be a normal texture */
- /* Check if the texture is bound, if yes dirtify the sampler to force a re-upload of the texture
- * Can't load the texture here because PreLoad may destroy and recreate the gl texture, so sampler
- * states need resetting
- */
- if (This->container.type == WINED3D_CONTAINER_TEXTURE)
- {
- IWineD3DBaseTextureImpl *texture = This->container.u.texture;
- if (texture->baseTexture.bindCount)
- IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(texture->baseTexture.sampler));
- }
- }
-
- unlock_end:
- This->Flags &= ~SFLAG_LOCKED;
- memset(&This->lockedRect, 0, sizeof(RECT));
-
- /* Overlays have to be redrawn manually after changes with the GL implementation */
- if(This->overlay_dest) {
- IWineD3DSurface_DrawOverlay(iface);
- }
- return WINED3D_OK;
-}
-
-static void surface_release_client_storage(IWineD3DSurfaceImpl *surface)
-{
- struct wined3d_context *context;
-
- context = context_acquire(surface->resource.device, NULL);
-
- ENTER_GL();
- glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
- if (surface->texture_name)
- {
- surface_bind_and_dirtify(surface, FALSE);
- glTexImage2D(surface->texture_target, surface->texture_level,
- GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
- }
- if (surface->texture_name_srgb)
- {
- surface_bind_and_dirtify(surface, TRUE);
- glTexImage2D(surface->texture_target, surface->texture_level,
- GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
- }
- glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
-
- LEAVE_GL();
- context_release(context);
-
- surface_modify_location(surface, SFLAG_INSRGBTEX, FALSE);
- surface_modify_location(surface, SFLAG_INTEXTURE, FALSE);
- surface_force_reload(surface);
-}
-
-static HRESULT WINAPI IWineD3DSurfaceImpl_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_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 */
-
- /* Create a DIB section if there isn't a hdc yet */
- if (!This->hDC)
- {
- if (This->Flags & SFLAG_CLIENT)
- {
- surface_load_location(This, SFLAG_INSYSMEM, NULL);
- surface_release_client_storage(This);
- }
- hr = IWineD3DBaseSurfaceImpl_CreateDIBSection(iface);
- if(FAILED(hr)) return WINED3DERR_INVALIDCALL;
-
- /* Use the dib section from now on if we are not using a PBO */
- if(!(This->Flags & SFLAG_PBO))
- This->resource.allocatedMemory = This->dib.bitmap_data;
- }
-
- /* Lock the surface */
- hr = IWineD3DSurface_LockRect(iface,
- &lock,
- NULL,
- 0);
-
- if(This->Flags & SFLAG_PBO) {
- /* Sync the DIB with the PBO. This can't be done earlier because LockRect activates the allocatedMemory */
- memcpy(This->dib.bitmap_data, This->resource.allocatedMemory, This->dib.bitmap_size);
- }
-
- 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)
- {
- /* GetDC on palettized formats is unsupported in D3D9, and the method is missing in
- D3D8, so this should only be used for DX <=7 surfaces (with non-device palettes) */
- 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 IWineD3DSurfaceImpl_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;
- }
-
- if((This->Flags & SFLAG_PBO) && This->resource.allocatedMemory) {
- /* Copy the contents of the DIB over to the PBO */
- memcpy(This->resource.allocatedMemory, This->dib.bitmap_data, This->dib.bitmap_size);
- }
-
- /* we locked first, so unlock now */
- IWineD3DSurface_UnlockRect(iface);
-
- This->Flags &= ~SFLAG_DCINUSE;
-
- return WINED3D_OK;
-}
-
-/* ******************************************************
- IWineD3DSurface Internal (No mapping to directx api) parts follow
- ****************************************************** */
-
-HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck,
+HRESULT d3dfmt_get_conv(struct wined3d_surface *surface, BOOL need_alpha_ck,
BOOL use_texturing, struct wined3d_format *format, CONVERT_TYPES *convert)
{
- BOOL colorkey_active = need_alpha_ck && (This->CKeyFlags & WINEDDSD_CKSRCBLT);
- IWineD3DDeviceImpl *device = This->resource.device;
+ BOOL colorkey_active = need_alpha_ck && (surface->CKeyFlags & WINEDDSD_CKSRCBLT);
+ struct wined3d_device *device = surface->resource.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
BOOL blit_supported = FALSE;
/* Copy the default values from the surface. Below we might perform fixups */
/* TODO: get rid of color keying desc fixups by using e.g. a table. */
- *format = *This->resource.format;
+ *format = *surface->resource.format;
*convert = NO_CONVERSION;
/* Ok, now look if we have to do any conversion */
- switch (This->resource.format->id)
+ switch (surface->resource.format->id)
{
case WINED3DFMT_P8_UINT:
/* Below the call to blit_supported is disabled for Wine 1.2
@@ -2142,9 +4148,9 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck,
* 8-bit blits need to be handled by the blit_shader.
* TODO: get rid of this #if 0. */
#if 0
- blit_supported = device->blitter->blit_supported(&device->adapter->gl_info, BLIT_OP_BLIT,
- &rect, This->resource.usage, This->resource.pool, This->resource.format,
- &rect, This->resource.usage, This->resource.pool, This->resource.format);
+ blit_supported = device->blitter->blit_supported(&device->adapter->gl_info, WINED3D_BLIT_OP_COLOR_BLIT,
+ &rect, surface->resource.usage, surface->resource.pool, surface->resource.format,
+ &rect, surface->resource.usage, surface->resource.pool, surface->resource.format);
#endif
blit_supported = gl_info->supported[EXT_PALETTED_TEXTURE] || gl_info->supported[ARB_FRAGMENT_PROGRAM];
@@ -2154,7 +4160,7 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck,
* in which the main render target uses p8. Some games like GTA Vice City use P8 for texturing which
* conflicts with this.
*/
- if (!((blit_supported && device->render_targets && This == device->render_targets[0]))
+ if (!((blit_supported && device->fb.render_targets && surface == device->fb.render_targets[0]))
|| colorkey_active || !use_texturing)
{
format->glFormat = GL_RGBA;
@@ -2230,10 +4236,10 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck,
return WINED3D_OK;
}
-void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey)
+void d3dfmt_p8_init_palette(struct wined3d_surface *surface, BYTE table[256][4], BOOL colorkey)
{
- IWineD3DDeviceImpl *device = This->resource.device;
- IWineD3DPaletteImpl *pal = This->palette;
+ struct wined3d_device *device = surface->resource.device;
+ struct wined3d_palette *pal = surface->palette;
BOOL index_in_alpha = FALSE;
unsigned int i;
@@ -2246,7 +4252,7 @@ void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL
if (!pal)
{
- UINT dxVersion = ((IWineD3DImpl *)device->wined3d)->dxVersion;
+ UINT dxVersion = device->wined3d->dxVersion;
/* In DirectDraw the palette is a property of the surface, there are no such things as device palettes. */
if (dxVersion <= 7)
@@ -2293,12 +4299,12 @@ void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL
{
table[i][3] = i;
}
- else if (colorkey && (i >= This->SrcBltCKey.dwColorSpaceLowValue)
- && (i <= This->SrcBltCKey.dwColorSpaceHighValue))
+ else if (colorkey && (i >= surface->SrcBltCKey.dwColorSpaceLowValue)
+ && (i <= surface->SrcBltCKey.dwColorSpaceHighValue))
{
table[i][3] = 0x00;
}
- else if(pal->Flags & WINEDDPCAPS_ALPHA)
+ else if (pal->flags & WINEDDPCAPS_ALPHA)
{
table[i][3] = pal->palents[i].peFlags;
}
@@ -2311,11 +4317,11 @@ void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL
}
static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UINT width,
- UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *This)
+ UINT height, UINT outpitch, CONVERT_TYPES convert, struct wined3d_surface *surface)
{
const BYTE *source;
BYTE *dest;
- TRACE("(%p)->(%p),(%d,%d,%d,%d,%p)\n", src, dst, pitch, height, outpitch, convert,This);
+ TRACE("(%p)->(%p),(%d,%d,%d,%d,%p)\n", src, dst, pitch, height, outpitch, convert, surface);
switch (convert) {
case NO_CONVERSION:
@@ -2329,7 +4335,7 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI
BYTE table[256][4];
unsigned int x, y;
- d3dfmt_p8_init_palette(This, table, (convert == CONVERT_PALETTED_CK));
+ d3dfmt_p8_init_palette(surface, table, (convert == CONVERT_PALETTED_CK));
for (y = 0; y < height; y++)
{
@@ -2371,10 +4377,9 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI
for (x = 0; x < width; x++ ) {
WORD color = *Source++;
*Dest = ((color & 0xFFC0) | ((color & 0x1F) << 1));
- if ((color < This->SrcBltCKey.dwColorSpaceLowValue) ||
- (color > This->SrcBltCKey.dwColorSpaceHighValue)) {
+ if ((color < surface->SrcBltCKey.dwColorSpaceLowValue)
+ || (color > surface->SrcBltCKey.dwColorSpaceHighValue))
*Dest |= 0x0001;
- }
Dest++;
}
}
@@ -2394,13 +4399,11 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI
for (x = 0; x < width; x++ ) {
WORD color = *Source++;
*Dest = color;
- if ((color < This->SrcBltCKey.dwColorSpaceLowValue) ||
- (color > This->SrcBltCKey.dwColorSpaceHighValue)) {
+ if ((color < surface->SrcBltCKey.dwColorSpaceLowValue)
+ || (color > surface->SrcBltCKey.dwColorSpaceHighValue))
*Dest |= (1 << 15);
- }
- else {
+ else
*Dest &= ~(1 << 15);
- }
Dest++;
}
}
@@ -2418,10 +4421,9 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI
for (x = 0; x < width; x++) {
DWORD color = ((DWORD)source[0] << 16) + ((DWORD)source[1] << 8) + (DWORD)source[2] ;
DWORD dstcolor = color << 8;
- if ((color < This->SrcBltCKey.dwColorSpaceLowValue) ||
- (color > This->SrcBltCKey.dwColorSpaceHighValue)) {
+ if ((color < surface->SrcBltCKey.dwColorSpaceLowValue)
+ || (color > surface->SrcBltCKey.dwColorSpaceHighValue))
dstcolor |= 0xff;
- }
*(DWORD*)dest = dstcolor;
source += 3;
dest += 4;
@@ -2441,10 +4443,9 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI
for (x = 0; x < width; x++) {
DWORD color = 0xffffff & *(const DWORD*)source;
DWORD dstcolor = color << 8;
- if ((color < This->SrcBltCKey.dwColorSpaceLowValue) ||
- (color > This->SrcBltCKey.dwColorSpaceHighValue)) {
+ if ((color < surface->SrcBltCKey.dwColorSpaceLowValue)
+ || (color > surface->SrcBltCKey.dwColorSpaceHighValue))
dstcolor |= 0xff;
- }
*(DWORD*)dest = dstcolor;
source += 4;
dest += 4;
@@ -2459,12 +4460,12 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI
return WINED3D_OK;
}
-BOOL palette9_changed(IWineD3DSurfaceImpl *This)
+BOOL palette9_changed(struct wined3d_surface *surface)
{
- IWineD3DDeviceImpl *device = This->resource.device;
+ struct wined3d_device *device = surface->resource.device;
- if (This->palette || (This->resource.format->id != WINED3DFMT_P8_UINT
- && This->resource.format->id != WINED3DFMT_P8_UINT_A8_UNORM))
+ if (surface->palette || (surface->resource.format->id != WINED3DFMT_P8_UINT
+ && surface->resource.format->id != WINED3DFMT_P8_UINT_A8_UNORM))
{
/* If a ddraw-style palette is attached assume no d3d9 palette change.
* Also the palette isn't interesting if the surface format isn't P8 or A8P8
@@ -2472,199 +4473,24 @@ BOOL palette9_changed(IWineD3DSurfaceImpl *This)
return FALSE;
}
- if (This->palette9)
+ if (surface->palette9)
{
- if (!memcmp(This->palette9, device->palettes[device->currentPalette], sizeof(PALETTEENTRY) * 256))
+ if (!memcmp(surface->palette9, device->palettes[device->currentPalette], sizeof(PALETTEENTRY) * 256))
{
return FALSE;
}
- } else {
- This->palette9 = HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY) * 256);
- }
- memcpy(This->palette9, device->palettes[device->currentPalette], sizeof(PALETTEENTRY) * 256);
- return TRUE;
-}
-
-static HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, BOOL srgb_mode) {
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
- DWORD flag = srgb_mode ? SFLAG_INSRGBTEX : SFLAG_INTEXTURE;
-
- TRACE("iface %p, srgb %#x.\n", iface, srgb_mode);
-
- if (!(This->Flags & flag)) {
- TRACE("Reloading because surface is dirty\n");
- } else if(/* Reload: gl texture has ck, now no ckey is set OR */
- ((This->Flags & SFLAG_GLCKEY) && (!(This->CKeyFlags & WINEDDSD_CKSRCBLT))) ||
- /* Reload: vice versa OR */
- ((!(This->Flags & SFLAG_GLCKEY)) && (This->CKeyFlags & WINEDDSD_CKSRCBLT)) ||
- /* Also reload: Color key is active AND the color key has changed */
- ((This->CKeyFlags & WINEDDSD_CKSRCBLT) && (
- (This->glCKey.dwColorSpaceLowValue != This->SrcBltCKey.dwColorSpaceLowValue) ||
- (This->glCKey.dwColorSpaceHighValue != This->SrcBltCKey.dwColorSpaceHighValue)))) {
- TRACE("Reloading because of color keying\n");
- /* To perform the color key conversion we need a sysmem copy of
- * the surface. Make sure we have it
- */
-
- surface_load_location(This, SFLAG_INSYSMEM, NULL);
- /* Make sure the texture is reloaded because of the color key change, this kills performance though :( */
- /* TODO: This is not necessarily needed with hw palettized texture support */
- surface_modify_location(This, SFLAG_INSYSMEM, TRUE);
- } else {
- TRACE("surface is already in texture\n");
- return WINED3D_OK;
- }
-
- /* Resources are placed in system RAM and do not need to be recreated when a device is lost.
- * These resources are not bound by device size or format restrictions. Because of this,
- * these resources cannot be accessed by the Direct3D device nor set as textures or render targets.
- * However, these resources can always be created, locked, and copied.
- */
- if (This->resource.pool == WINED3DPOOL_SCRATCH )
- {
- FIXME("(%p) Operation not supported for scratch textures\n",This);
- return WINED3DERR_INVALIDCALL;
- }
-
- surface_load_location(This, flag, NULL /* no partial locking for textures yet */);
-
- if (!(This->Flags & SFLAG_DONOTFREE)) {
- HeapFree(GetProcessHeap(), 0, This->resource.heapMemory);
- This->resource.allocatedMemory = NULL;
- This->resource.heapMemory = NULL;
- surface_modify_location(This, SFLAG_INSYSMEM, FALSE);
- }
-
- return WINED3D_OK;
-}
-
-/* Context activation is done by the caller. */
-static void WINAPI IWineD3DSurfaceImpl_BindTexture(IWineD3DSurface *iface, BOOL srgb)
-{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
-
- TRACE("iface %p, srgb %#x.\n", iface, srgb);
-
- if (This->container.type == WINED3D_CONTAINER_TEXTURE)
- {
- TRACE("Passing to container.\n");
- IWineD3DBaseTexture_BindTexture((IWineD3DBaseTexture *)This->container.u.texture, srgb);
}
else
{
- GLuint *name;
-
- TRACE("(%p) : Binding surface\n", This);
-
- name = srgb ? &This->texture_name_srgb : &This->texture_name;
-
- ENTER_GL();
-
- if (!This->texture_level)
- {
- if (!*name) {
- glGenTextures(1, name);
- checkGLcall("glGenTextures");
- TRACE("Surface %p given name %d\n", This, *name);
-
- glBindTexture(This->texture_target, *name);
- checkGLcall("glBindTexture");
- glTexParameteri(This->texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- checkGLcall("glTexParameteri(dimension, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)");
- glTexParameteri(This->texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- checkGLcall("glTexParameteri(dimension, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)");
- glTexParameteri(This->texture_target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
- checkGLcall("glTexParameteri(dimension, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE)");
- glTexParameteri(This->texture_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- checkGLcall("glTexParameteri(dimension, GL_TEXTURE_MIN_FILTER, GL_NEAREST)");
- glTexParameteri(This->texture_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- checkGLcall("glTexParameteri(dimension, GL_TEXTURE_MAG_FILTER, GL_NEAREST)");
- }
- /* This is where we should be reducing the amount of GLMemoryUsed */
- } else if (*name) {
- /* Mipmap surfaces should have a base texture container */
- ERR("Mipmap surface has a glTexture bound to it!\n");
- }
-
- glBindTexture(This->texture_target, *name);
- checkGLcall("glBindTexture");
-
- LEAVE_GL();
+ surface->palette9 = HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY) * 256);
}
+ memcpy(surface->palette9, device->palettes[device->currentPalette], sizeof(PALETTEENTRY) * 256);
+
+ return TRUE;
}
-static HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, enum wined3d_format_id format)
+void flip_surface(struct wined3d_surface *front, struct wined3d_surface *back)
{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
- HRESULT hr;
-
- TRACE("(%p) : Calling base function first\n", This);
- hr = IWineD3DBaseSurfaceImpl_SetFormat(iface, format);
- if(SUCCEEDED(hr)) {
- This->Flags &= ~(SFLAG_ALLOCATED | SFLAG_SRGBALLOCATED);
- TRACE("(%p) : glFormat %d, glFormatInternal %d, glType %d\n", This, This->resource.format->glFormat,
- This->resource.format->glInternal, This->resource.format->glType);
- }
- return hr;
-}
-
-static HRESULT WINAPI IWineD3DSurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
-
- 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.heapMemory;
- This->resource.heapMemory = NULL;
- }
- This->resource.allocatedMemory = Mem;
- This->Flags |= SFLAG_USERPTR | SFLAG_INSYSMEM;
-
- /* Now the surface memory is most up do date. Invalidate drawable and texture */
- surface_modify_location(This, SFLAG_INSYSMEM, TRUE);
-
- /* For client textures opengl has to be notified */
- if (This->Flags & SFLAG_CLIENT)
- surface_release_client_storage(This);
-
- /* 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;
- /* HeapMemory should be NULL already */
- if (This->resource.heapMemory)
- ERR("User pointer surface has heap memory allocated.\n");
- This->Flags &= ~SFLAG_USERPTR;
-
- if (This->Flags & SFLAG_CLIENT)
- surface_release_client_storage(This);
- }
- return WINED3D_OK;
-}
-
-void flip_surface(IWineD3DSurfaceImpl *front, IWineD3DSurfaceImpl *back) {
-
/* Flip the surface contents */
/* Flip the DC */
{
@@ -2677,15 +4503,15 @@ void flip_surface(IWineD3DSurfaceImpl *front, IWineD3DSurfaceImpl *back) {
/* Flip the DIBsection */
{
HBITMAP tmp;
- BOOL hasDib = front->Flags & SFLAG_DIBSECTION;
+ BOOL hasDib = front->flags & SFLAG_DIBSECTION;
tmp = front->dib.DIBsection;
front->dib.DIBsection = back->dib.DIBsection;
back->dib.DIBsection = tmp;
- if(back->Flags & SFLAG_DIBSECTION) front->Flags |= SFLAG_DIBSECTION;
- else front->Flags &= ~SFLAG_DIBSECTION;
- if(hasDib) back->Flags |= SFLAG_DIBSECTION;
- else back->Flags &= ~SFLAG_DIBSECTION;
+ if (back->flags & SFLAG_DIBSECTION) front->flags |= SFLAG_DIBSECTION;
+ else front->flags &= ~SFLAG_DIBSECTION;
+ if (hasDib) back->flags |= SFLAG_DIBSECTION;
+ else back->flags &= ~SFLAG_DIBSECTION;
}
/* Flip the surface data */
@@ -2731,82 +4557,24 @@ void flip_surface(IWineD3DSurfaceImpl *front, IWineD3DSurfaceImpl *back) {
tmp = back->texture_name_srgb;
back->texture_name_srgb = front->texture_name_srgb;
front->texture_name_srgb = tmp;
+
+ resource_unload(&back->resource);
+ resource_unload(&front->resource);
}
{
- DWORD tmp_flags = back->Flags;
- back->Flags = front->Flags;
- front->Flags = tmp_flags;
+ DWORD tmp_flags = back->flags;
+ back->flags = front->flags;
+ front->flags = tmp_flags;
}
}
-static HRESULT WINAPI IWineD3DSurfaceImpl_Flip(IWineD3DSurface *iface, IWineD3DSurface *override, DWORD Flags) {
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
- IWineD3DSwapChainImpl *swapchain = NULL;
-
- TRACE("(%p)->(%p,%x)\n", This, override, Flags);
-
- /* Flipping is only supported on RenderTargets and overlays*/
- if( !(This->resource.usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_OVERLAY)) ) {
- WARN("Tried to flip a non-render target, non-overlay surface\n");
- return WINEDDERR_NOTFLIPPABLE;
- }
-
- if(This->resource.usage & WINED3DUSAGE_OVERLAY) {
- flip_surface(This, (IWineD3DSurfaceImpl *) override);
-
- /* Update the overlay if it is visible */
- if(This->overlay_dest) {
- return IWineD3DSurface_DrawOverlay((IWineD3DSurface *) This);
- } else {
- return WINED3D_OK;
- }
- }
-
- if(override) {
- /* DDraw sets this for the X11 surfaces, so don't confuse the user
- * FIXME("(%p) Target override is not supported by now\n", This);
- * Additionally, it isn't really possible to support triple-buffering
- * properly on opengl at all
- */
- }
-
- if (This->container.type != WINED3D_CONTAINER_SWAPCHAIN)
- {
- ERR("Flipped surface is not on a swapchain\n");
- return WINEDDERR_NOTFLIPPABLE;
- }
- swapchain = This->container.u.swapchain;
-
- /* Just overwrite the swapchain presentation interval. This is ok because only ddraw apps can call Flip,
- * and only d3d8 and d3d9 apps specify the presentation interval
- */
- if (!(Flags & (WINEDDFLIP_NOVSYNC | WINEDDFLIP_INTERVAL2 | WINEDDFLIP_INTERVAL3 | WINEDDFLIP_INTERVAL4)))
- {
- /* Most common case first to avoid wasting time on all the other cases */
- swapchain->presentParms.PresentationInterval = WINED3DPRESENT_INTERVAL_ONE;
- } else if(Flags & WINEDDFLIP_NOVSYNC) {
- swapchain->presentParms.PresentationInterval = WINED3DPRESENT_INTERVAL_IMMEDIATE;
- } else if(Flags & WINEDDFLIP_INTERVAL2) {
- swapchain->presentParms.PresentationInterval = WINED3DPRESENT_INTERVAL_TWO;
- } else if(Flags & WINEDDFLIP_INTERVAL3) {
- swapchain->presentParms.PresentationInterval = WINED3DPRESENT_INTERVAL_THREE;
- } else {
- swapchain->presentParms.PresentationInterval = WINED3DPRESENT_INTERVAL_FOUR;
- }
-
- /* Flipping a OpenGL surface -> Use WineD3DDevice::Present */
- return IWineD3DSwapChain_Present((IWineD3DSwapChain *)swapchain,
- NULL, NULL, swapchain->win_handle, NULL, 0);
-}
-
-/* Does a direct frame buffer -> texture copy. Stretching is done
- * with single pixel copy calls
- */
-static void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *dst_surface, IWineD3DSurfaceImpl *src_surface,
+/* Does a direct frame buffer -> texture copy. Stretching is done with single
+ * pixel copy calls. */
+static void fb_copy_to_texture_direct(struct wined3d_surface *dst_surface, struct wined3d_surface *src_surface,
const RECT *src_rect, const RECT *dst_rect_in, WINED3DTEXTUREFILTERTYPE Filter)
{
- IWineD3DDeviceImpl *device = dst_surface->resource.device;
+ struct wined3d_device *device = dst_surface->resource.device;
float xrel, yrel;
UINT row;
struct wined3d_context *context;
@@ -2868,10 +4636,12 @@ static void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *dst_surface, IWineD3D
glCopyTexSubImage2D(dst_surface->texture_target, dst_surface->texture_level,
dst_rect.left /*xoffset */, dst_rect.top /* y offset */,
- src_rect->left, src_surface->currentDesc.Height - src_rect->bottom,
+ src_rect->left, src_surface->resource.height - src_rect->bottom,
dst_rect.right - dst_rect.left, dst_rect.bottom - dst_rect.top);
- } else {
- UINT yoffset = src_surface->currentDesc.Height - src_rect->top + dst_rect.top - 1;
+ }
+ else
+ {
+ UINT yoffset = src_surface->resource.height - src_rect->top + dst_rect.top - 1;
/* I have to process this row by row to swap the image,
* otherwise it would be upside down, so stretching in y direction
* doesn't cost extra time
@@ -2913,15 +4683,15 @@ static void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *dst_surface, IWineD3D
}
/* Uses the hardware to stretch and flip the image */
-static void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *dst_surface, IWineD3DSurfaceImpl *src_surface,
+static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, struct wined3d_surface *src_surface,
const RECT *src_rect, const RECT *dst_rect_in, WINED3DTEXTUREFILTERTYPE Filter)
{
- IWineD3DDeviceImpl *device = dst_surface->resource.device;
+ struct wined3d_device *device = dst_surface->resource.device;
+ struct wined3d_swapchain *src_swapchain = NULL;
GLuint src, backup = 0;
- IWineD3DSwapChainImpl *src_swapchain = NULL;
float left, right, top, bottom; /* Texture coordinates */
- UINT fbwidth = src_surface->currentDesc.Width;
- UINT fbheight = src_surface->currentDesc.Height;
+ UINT fbwidth = src_surface->resource.width;
+ UINT fbheight = src_surface->resource.height;
struct wined3d_context *context;
GLenum drawBuffer = GL_BACK;
GLenum texture_target;
@@ -2976,7 +4746,7 @@ static void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *dst_surface, IWine
checkGLcall("glEnable(texture_target)");
/* For now invalidate the texture copy of the back buffer. Drawable and sysmem copy are untouched */
- src_surface->Flags &= ~SFLAG_INTEXTURE;
+ src_surface->flags &= ~SFLAG_INTEXTURE;
}
/* Make sure that the top pixel is always above the bottom pixel, and keep a separate upside down flag
@@ -3064,18 +4834,18 @@ static void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *dst_surface, IWine
left = src_rect->left;
right = src_rect->right;
- if (upsidedown)
+ if (!upsidedown)
{
- top = src_surface->currentDesc.Height - src_rect->top;
- bottom = src_surface->currentDesc.Height - src_rect->bottom;
+ top = src_surface->resource.height - src_rect->top;
+ bottom = src_surface->resource.height - src_rect->bottom;
}
else
{
- top = src_surface->currentDesc.Height - src_rect->bottom;
- bottom = src_surface->currentDesc.Height - src_rect->top;
+ top = src_surface->resource.height - src_rect->bottom;
+ bottom = src_surface->resource.height - src_rect->top;
}
- if (src_surface->Flags & SFLAG_NORMCOORD)
+ if (src_surface->flags & SFLAG_NORMCOORD)
{
left /= src_surface->pow2Width;
right /= src_surface->pow2Width;
@@ -3093,19 +4863,19 @@ static void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *dst_surface, IWine
glBegin(GL_QUADS);
/* bottom left */
glTexCoord2f(left, bottom);
- glVertex2i(0, fbheight);
+ glVertex2i(0, 0);
/* top left */
glTexCoord2f(left, top);
- glVertex2i(0, fbheight - dst_rect.bottom - dst_rect.top);
+ glVertex2i(0, dst_rect.bottom - dst_rect.top);
/* top right */
glTexCoord2f(right, top);
- glVertex2i(dst_rect.right - dst_rect.left, fbheight - dst_rect.bottom - dst_rect.top);
+ glVertex2i(dst_rect.right - dst_rect.left, dst_rect.bottom - dst_rect.top);
/* bottom right */
glTexCoord2f(right, bottom);
- glVertex2i(dst_rect.right - dst_rect.left, fbheight);
+ glVertex2i(dst_rect.right - dst_rect.left, 0);
glEnd();
checkGLcall("glEnd and previous");
@@ -3151,21 +4921,21 @@ static void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *dst_surface, IWine
glBegin(GL_QUADS);
/* top left */
- glTexCoord2f(0.0f, (float)fbheight / (float)src_surface->pow2Height);
- glVertex2i(0, 0);
-
- /* bottom left */
glTexCoord2f(0.0f, 0.0f);
glVertex2i(0, fbheight);
- /* bottom right */
- glTexCoord2f((float)fbwidth / (float)src_surface->pow2Width, 0.0f);
- glVertex2i(fbwidth, src_surface->currentDesc.Height);
+ /* bottom left */
+ glTexCoord2f(0.0f, (float)fbheight / (float)src_surface->pow2Height);
+ glVertex2i(0, 0);
- /* top right */
+ /* bottom right */
glTexCoord2f((float)fbwidth / (float)src_surface->pow2Width,
(float)fbheight / (float)src_surface->pow2Height);
glVertex2i(fbwidth, 0);
+
+ /* top right */
+ glTexCoord2f((float)fbwidth / (float)src_surface->pow2Width, 0.0f);
+ glVertex2i(fbwidth, fbheight);
glEnd();
}
glDisable(texture_target);
@@ -3194,40 +4964,40 @@ static void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *dst_surface, IWine
surface_modify_location(dst_surface, SFLAG_INTEXTURE, TRUE);
}
-/* Until the blit_shader is ready, define some prototypes here. */
-static BOOL fbo_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_operation 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);
-
/* Front buffer coordinates are always full screen coordinates, but our GL
* drawable is limited to the window's client area. The sysmem and texture
* copies do have the full screen size. Note that GL has a bottom-left
* origin, while D3D has a top-left origin. */
-void surface_translate_frontbuffer_coords(IWineD3DSurfaceImpl *surface, HWND window, RECT *rect)
+void surface_translate_drawable_coords(struct wined3d_surface *surface, HWND window, RECT *rect)
{
- POINT offset = {0, surface->currentDesc.Height};
- RECT windowsize;
+ UINT drawable_height;
- GetClientRect(window, &windowsize);
- offset.y -= windowsize.bottom - windowsize.top;
- ScreenToClient(window, &offset);
- OffsetRect(rect, offset.x, offset.y);
-}
+ if (surface->container.type == WINED3D_CONTAINER_SWAPCHAIN
+ && surface == surface->container.u.swapchain->front_buffer)
+ {
+ POINT offset = {0, 0};
+ RECT windowsize;
-static BOOL surface_is_full_rect(IWineD3DSurfaceImpl *surface, const RECT *r)
-{
- if ((r->left && r->right) || abs(r->right - r->left) != surface->currentDesc.Width)
- return FALSE;
- if ((r->top && r->bottom) || abs(r->bottom - r->top) != surface->currentDesc.Height)
- return FALSE;
- return TRUE;
+ ScreenToClient(window, &offset);
+ OffsetRect(rect, offset.x, offset.y);
+
+ GetClientRect(window, &windowsize);
+ drawable_height = windowsize.bottom - windowsize.top;
+ }
+ else
+ {
+ drawable_height = surface->resource.height;
+ }
+
+ rect->top = drawable_height - rect->top;
+ rect->bottom = drawable_height - rect->bottom;
}
/* blit between surface locations. onscreen on different swapchains is not supported.
* depth / stencil is not supported. */
-static void surface_blt_fbo(IWineD3DDeviceImpl *device, const WINED3DTEXTUREFILTERTYPE filter,
- IWineD3DSurfaceImpl *src_surface, DWORD src_location, const RECT *src_rect_in,
- IWineD3DSurfaceImpl *dst_surface, DWORD dst_location, const RECT *dst_rect_in)
+static void surface_blt_fbo(struct wined3d_device *device, const WINED3DTEXTUREFILTERTYPE filter,
+ struct wined3d_surface *src_surface, DWORD src_location, const RECT *src_rect_in,
+ struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect_in)
{
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
@@ -3289,11 +5059,7 @@ static void surface_blt_fbo(IWineD3DDeviceImpl *device, const WINED3DTEXTUREFILT
TRACE("Source surface %p is onscreen.\n", src_surface);
- if (buffer == GL_FRONT)
- surface_translate_frontbuffer_coords(src_surface, context->win_handle, &src_rect);
-
- src_rect.top = src_surface->currentDesc.Height - src_rect.top;
- src_rect.bottom = src_surface->currentDesc.Height - src_rect.bottom;
+ surface_translate_drawable_coords(src_surface, context->win_handle, &src_rect);
ENTER_GL();
context_bind_fbo(context, GL_READ_FRAMEBUFFER, NULL);
@@ -3308,6 +5074,7 @@ static void surface_blt_fbo(IWineD3DDeviceImpl *device, const WINED3DTEXTUREFILT
glReadBuffer(GL_COLOR_ATTACHMENT0);
checkGLcall("glReadBuffer()");
}
+ context_check_fbo_status(context, GL_READ_FRAMEBUFFER);
LEAVE_GL();
if (dst_location == SFLAG_INDRAWABLE)
@@ -3316,11 +5083,7 @@ static void surface_blt_fbo(IWineD3DDeviceImpl *device, const WINED3DTEXTUREFILT
TRACE("Destination surface %p is onscreen.\n", dst_surface);
- if (buffer == GL_FRONT)
- surface_translate_frontbuffer_coords(dst_surface, context->win_handle, &dst_rect);
-
- dst_rect.top = dst_surface->currentDesc.Height - dst_rect.top;
- dst_rect.bottom = dst_surface->currentDesc.Height - dst_rect.bottom;
+ surface_translate_drawable_coords(dst_surface, context->win_handle, &dst_rect);
ENTER_GL();
context_bind_fbo(context, GL_DRAW_FRAMEBUFFER, NULL);
@@ -3334,6 +5097,7 @@ static void surface_blt_fbo(IWineD3DDeviceImpl *device, const WINED3DTEXTUREFILT
context_apply_fbo_state_blit(context, GL_DRAW_FRAMEBUFFER, dst_surface, NULL, dst_location);
context_set_draw_buffer(context, GL_COLOR_ATTACHMENT0);
}
+ context_check_fbo_status(context, GL_DRAW_FRAMEBUFFER);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_COLORWRITEENABLE));
@@ -3350,18 +5114,90 @@ static void surface_blt_fbo(IWineD3DDeviceImpl *device, const WINED3DTEXTUREFILT
LEAVE_GL();
- if (wined3d_settings.strict_draw_ordering) wglFlush(); /* Flush to ensure ordering across contexts. */
+ if (wined3d_settings.strict_draw_ordering
+ || (dst_location == SFLAG_INDRAWABLE
+ && dst_surface->container.u.swapchain->front_buffer == dst_surface))
+ wglFlush();
+
+ context_release(context);
+}
+
+static void surface_blt_to_drawable(struct wined3d_device *device,
+ WINED3DTEXTUREFILTERTYPE filter, BOOL color_key,
+ struct wined3d_surface *src_surface, const RECT *src_rect_in,
+ struct wined3d_surface *dst_surface, const RECT *dst_rect_in)
+{
+ struct wined3d_context *context;
+ RECT src_rect, dst_rect;
+
+ src_rect = *src_rect_in;
+ dst_rect = *dst_rect_in;
+
+ /* Make sure the surface is up-to-date. This should probably use
+ * surface_load_location() and worry about the destination surface too,
+ * unless we're overwriting it completely. */
+ surface_internal_preload(src_surface, SRGB_RGB);
+
+ /* Activate the destination context, set it up for blitting */
+ context = context_acquire(device, dst_surface);
+ context_apply_blit_state(context, device);
+
+ if (!surface_is_offscreen(dst_surface))
+ surface_translate_drawable_coords(dst_surface, context->win_handle, &dst_rect);
+
+ device->blitter->set_shader(device->blit_priv, context->gl_info, src_surface);
+
+ ENTER_GL();
+
+ if (color_key)
+ {
+ glEnable(GL_ALPHA_TEST);
+ checkGLcall("glEnable(GL_ALPHA_TEST)");
+
+ /* When the primary render target uses P8, the alpha component
+ * contains the palette index. Which means that the colorkey is one of
+ * the palette entries. In other cases pixels that should be masked
+ * away have alpha set to 0. */
+ if (primary_render_target_is_p8(device))
+ glAlphaFunc(GL_NOTEQUAL, (float)src_surface->SrcBltCKey.dwColorSpaceLowValue / 256.0f);
+ else
+ glAlphaFunc(GL_NOTEQUAL, 0.0f);
+ checkGLcall("glAlphaFunc");
+ }
+ else
+ {
+ glDisable(GL_ALPHA_TEST);
+ checkGLcall("glDisable(GL_ALPHA_TEST)");
+ }
+
+ draw_textured_quad(src_surface, &src_rect, &dst_rect, filter);
+
+ if (color_key)
+ {
+ glDisable(GL_ALPHA_TEST);
+ checkGLcall("glDisable(GL_ALPHA_TEST)");
+ }
+
+ LEAVE_GL();
+
+ /* Leave the opengl state valid for blitting */
+ device->blitter->unset_shader(context->gl_info);
+
+ if (wined3d_settings.strict_draw_ordering
+ || (dst_surface->container.type == WINED3D_CONTAINER_SWAPCHAIN
+ && (dst_surface->container.u.swapchain->front_buffer == dst_surface)))
+ wglFlush(); /* Flush to ensure ordering across contexts. */
context_release(context);
}
/* Do not call while under the GL lock. */
-HRESULT surface_color_fill(IWineD3DSurfaceImpl *s, const RECT *rect, const WINED3DCOLORVALUE *color)
+HRESULT surface_color_fill(struct wined3d_surface *s, const RECT *rect, const WINED3DCOLORVALUE *color)
{
- IWineD3DDeviceImpl *device = s->resource.device;
+ struct wined3d_device *device = s->resource.device;
const struct blit_shader *blitter;
- blitter = wined3d_select_blitter(&device->adapter->gl_info, BLIT_OP_COLOR_FILL,
+ blitter = wined3d_select_blitter(&device->adapter->gl_info, WINED3D_BLIT_OP_COLOR_FILL,
NULL, 0, 0, NULL, rect, s->resource.usage, s->resource.pool, s->resource.format);
if (!blitter)
{
@@ -3372,20 +5208,19 @@ HRESULT surface_color_fill(IWineD3DSurfaceImpl *s, const RECT *rect, const WINED
return blitter->color_fill(device, s, rect, color);
}
-/* Not called from the VTable */
/* Do not call while under the GL lock. */
-static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface, const RECT *DestRect,
- IWineD3DSurfaceImpl *src_surface, const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx,
+static HRESULT IWineD3DSurfaceImpl_BltOverride(struct wined3d_surface *dst_surface, const RECT *DestRect,
+ struct wined3d_surface *src_surface, const RECT *SrcRect, DWORD flags, const WINEDDBLTFX *DDBltFx,
WINED3DTEXTUREFILTERTYPE Filter)
{
- IWineD3DDeviceImpl *device = dst_surface->resource.device;
+ struct wined3d_device *device = dst_surface->resource.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
- IWineD3DSwapChainImpl *srcSwapchain = NULL, *dstSwapchain = NULL;
+ struct wined3d_swapchain *srcSwapchain = NULL, *dstSwapchain = NULL;
RECT dst_rect, src_rect;
TRACE("dst_surface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, blt_fx %p, filter %s.\n",
dst_surface, wine_dbgstr_rect(DestRect), src_surface, wine_dbgstr_rect(SrcRect),
- Flags, DDBltFx, debug_d3dtexturefiltertype(Filter));
+ flags, DDBltFx, debug_d3dtexturefiltertype(Filter));
/* Get the swapchain. One of the surfaces has to be a primary surface */
if (dst_surface->resource.pool == WINED3DPOOL_SYSTEMMEM)
@@ -3411,15 +5246,16 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
/* Early sort out of cases where no render target is used */
if (!dstSwapchain && !srcSwapchain
- && src_surface != device->render_targets[0]
- && dst_surface != device->render_targets[0])
+ && src_surface != device->fb.render_targets[0]
+ && dst_surface != device->fb.render_targets[0])
{
TRACE("No surface is render target, not using hardware blit.\n");
return WINED3DERR_INVALIDCALL;
}
/* No destination color keying supported */
- if(Flags & (WINEDDBLT_KEYDEST | WINEDDBLT_KEYDESTOVERRIDE)) {
+ if (flags & (WINEDDBLT_KEYDEST | WINEDDBLT_KEYDESTOVERRIDE))
+ {
/* Can we support that with glBlendFunc if blitting to the frame buffer? */
TRACE("Destination color key not supported in accelerated Blit, falling back to software\n");
return WINED3DERR_INVALIDCALL;
@@ -3445,8 +5281,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
TRACE("Looking if a Present can be done...\n");
/* Source Rectangle must be full surface */
if (src_rect.left || src_rect.top
- || src_rect.right != src_surface->currentDesc.Width
- || src_rect.bottom != src_surface->currentDesc.Height)
+ || src_rect.right != src_surface->resource.width
+ || src_rect.bottom != src_surface->resource.height)
{
TRACE("No, Source rectangle doesn't match\n");
break;
@@ -3460,16 +5296,16 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
}
/* Destination must be full surface or match the clipping rectangle */
- if (dst_surface->clipper && ((IWineD3DClipperImpl *)dst_surface->clipper)->hWnd)
+ if (dst_surface->clipper && dst_surface->clipper->hWnd)
{
RECT cliprect;
POINT pos[2];
- GetClientRect(((IWineD3DClipperImpl *)dst_surface->clipper)->hWnd, &cliprect);
+ GetClientRect(dst_surface->clipper->hWnd, &cliprect);
pos[0].x = dst_rect.left;
pos[0].y = dst_rect.top;
pos[1].x = dst_rect.right;
pos[1].y = dst_rect.bottom;
- MapWindowPoints(GetDesktopWindow(), ((IWineD3DClipperImpl *)dst_surface->clipper)->hWnd, pos, 2);
+ MapWindowPoints(GetDesktopWindow(), dst_surface->clipper->hWnd, pos, 2);
if(pos[0].x != cliprect.left || pos[0].y != cliprect.top ||
pos[1].x != cliprect.right || pos[1].y != cliprect.bottom)
@@ -3481,8 +5317,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
}
}
else if (dst_rect.left || dst_rect.top
- || dst_rect.right != dst_surface->currentDesc.Width
- || dst_rect.bottom != dst_surface->currentDesc.Height)
+ || dst_rect.right != dst_surface->resource.width
+ || dst_rect.bottom != dst_surface->resource.height)
{
TRACE("No, dest rectangle doesn't match(surface size)\n");
break;
@@ -3491,7 +5327,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
TRACE("Yes\n");
/* These flags are unimportant for the flag check, remove them */
- if (!(Flags & ~(WINEDDBLT_DONOTWAIT | WINEDDBLT_WAIT)))
+ if (!(flags & ~(WINEDDBLT_DONOTWAIT | WINEDDBLT_WAIT)))
{
WINED3DSWAPEFFECT orig_swap = dstSwapchain->presentParms.SwapEffect;
@@ -3513,9 +5349,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
dstSwapchain->presentParms.SwapEffect = WINED3DSWAPEFFECT_COPY;
dstSwapchain->presentParms.PresentationInterval = WINED3DPRESENT_INTERVAL_IMMEDIATE;
- TRACE("Full screen back buffer -> front buffer blt, performing a flip instead\n");
- IWineD3DSwapChain_Present((IWineD3DSwapChain *)dstSwapchain,
- NULL, NULL, dstSwapchain->win_handle, NULL, 0);
+ TRACE("Full screen back buffer -> front buffer blt, performing a flip instead.\n");
+ wined3d_swapchain_present(dstSwapchain, NULL, NULL, dstSwapchain->win_handle, NULL, 0);
dstSwapchain->presentParms.SwapEffect = orig_swap;
@@ -3536,16 +5371,16 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
else if (dstSwapchain)
{
/* Handled with regular texture -> swapchain blit */
- if (src_surface == device->render_targets[0])
+ if (src_surface == device->fb.render_targets[0])
TRACE("Blit from active render target to a swapchain\n");
}
- else if (srcSwapchain && dst_surface == device->render_targets[0])
+ else if (srcSwapchain && dst_surface == device->fb.render_targets[0])
{
FIXME("Implement blit from a swapchain to the active render target\n");
return WINED3DERR_INVALIDCALL;
}
- if ((srcSwapchain || src_surface == device->render_targets[0]) && !dstSwapchain)
+ if ((srcSwapchain || src_surface == device->fb.render_targets[0]) && !dstSwapchain)
{
/* Blit from render target to texture */
BOOL stretchx;
@@ -3558,7 +5393,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
return WINED3DERR_INVALIDCALL;
}
- if(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE)) {
+ if (flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE))
+ {
TRACE("Color keying not supported by frame buffer to texture blit\n");
return WINED3DERR_INVALIDCALL;
/* Destination color key is checked above */
@@ -3583,9 +5419,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
*
* If EXT_framebuffer_blit is supported that can be used instead. Note that EXT_framebuffer_blit implies
* FBO support, so it doesn't really make sense to try and make it work with different offscreen rendering
- * backends.
- */
- if (fbo_blit_supported(gl_info, BLIT_OP_BLIT,
+ * backends. */
+ if (fbo_blit_supported(gl_info, WINED3D_BLIT_OP_COLOR_BLIT,
&src_rect, src_surface->resource.usage, src_surface->resource.pool, src_surface->resource.format,
&dst_rect, dst_surface->resource.usage, dst_surface->resource.pool, dst_surface->resource.format))
{
@@ -3594,8 +5429,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
dst_surface, SFLAG_INDRAWABLE, &dst_rect);
surface_modify_location(dst_surface, SFLAG_INDRAWABLE, TRUE);
}
- else if (!stretchx || dst_rect.right - dst_rect.left > src_surface->currentDesc.Width
- || dst_rect.bottom - dst_rect.top > src_surface->currentDesc.Height)
+ else if (!stretchx || dst_rect.right - dst_rect.left > src_surface->resource.width
+ || dst_rect.bottom - dst_rect.top > src_surface->resource.height)
{
TRACE("No stretching in x direction, using direct framebuffer -> texture copy\n");
fb_copy_to_texture_direct(dst_surface, src_surface, &src_rect, &dst_rect, Filter);
@@ -3604,7 +5439,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
fb_copy_to_texture_hwstretch(dst_surface, src_surface, &src_rect, &dst_rect, Filter);
}
- if (!(dst_surface->Flags & SFLAG_DONOTFREE))
+ if (!(dst_surface->flags & SFLAG_DONOTFREE))
{
HeapFree(GetProcessHeap(), 0, dst_surface->resource.heapMemory);
dst_surface->resource.allocatedMemory = NULL;
@@ -3612,7 +5447,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
}
else
{
- dst_surface->Flags &= ~SFLAG_INSYSMEM;
+ dst_surface->flags &= ~SFLAG_INSYSMEM;
}
return WINED3D_OK;
@@ -3622,12 +5457,11 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
/* Blit from offscreen surface to render target */
DWORD oldCKeyFlags = src_surface->CKeyFlags;
WINEDDCOLORKEY oldBltCKey = src_surface->SrcBltCKey;
- struct wined3d_context *context;
TRACE("Blt from surface %p to rendertarget %p\n", src_surface, dst_surface);
- if (!(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE))
- && fbo_blit_supported(gl_info, BLIT_OP_BLIT,
+ if (!(flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE))
+ && fbo_blit_supported(gl_info, WINED3D_BLIT_OP_COLOR_BLIT,
&src_rect, src_surface->resource.usage, src_surface->resource.pool,
src_surface->resource.format,
&dst_rect, dst_surface->resource.usage, dst_surface->resource.pool,
@@ -3643,14 +5477,23 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
return WINED3D_OK;
}
- if (!(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE))
- && arbfp_blit.blit_supported(gl_info, BLIT_OP_BLIT,
+ if (!(flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE))
+ && arbfp_blit.blit_supported(gl_info, WINED3D_BLIT_OP_COLOR_BLIT,
&src_rect, src_surface->resource.usage, src_surface->resource.pool,
src_surface->resource.format,
&dst_rect, dst_surface->resource.usage, dst_surface->resource.pool,
dst_surface->resource.format))
{
- return arbfp_blit_surface(device, src_surface, &src_rect, dst_surface, &dst_rect, BLIT_OP_BLIT, Filter);
+ return arbfp_blit_surface(device, src_surface, &src_rect, dst_surface, &dst_rect,
+ WINED3D_BLIT_OP_COLOR_BLIT, Filter);
+ }
+
+ if (!device->blitter->blit_supported(gl_info, WINED3D_BLIT_OP_COLOR_BLIT,
+ &src_rect, src_surface->resource.usage, src_surface->resource.pool, src_surface->resource.format,
+ &dst_rect, dst_surface->resource.usage, dst_surface->resource.pool, dst_surface->resource.format))
+ {
+ FIXME("Unsupported blit operation falling back to software\n");
+ return WINED3DERR_INVALIDCALL;
}
/* Color keying: Check if we have to do a color keyed blt,
@@ -3660,86 +5503,29 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
* The surface keeps track of the color key last used to load the opengl surface.
* PreLoad will catch the change to the flags and color key and reload if necessary.
*/
- if(Flags & WINEDDBLT_KEYSRC) {
+ if (flags & WINEDDBLT_KEYSRC)
+ {
/* Use color key from surface */
- } else if(Flags & WINEDDBLT_KEYSRCOVERRIDE) {
+ }
+ else if (flags & WINEDDBLT_KEYSRCOVERRIDE)
+ {
/* Use color key from DDBltFx */
src_surface->CKeyFlags |= WINEDDSD_CKSRCBLT;
src_surface->SrcBltCKey = DDBltFx->ddckSrcColorkey;
- } else {
+ }
+ else
+ {
/* Do not use color key */
src_surface->CKeyFlags &= ~WINEDDSD_CKSRCBLT;
}
- /* Now load the surface */
- surface_internal_preload(src_surface, SRGB_RGB);
-
- /* Activate the destination context, set it up for blitting */
- context = context_acquire(device, dst_surface);
- context_apply_blit_state(context, device);
-
- if (dstSwapchain && dst_surface == dstSwapchain->front_buffer)
- surface_translate_frontbuffer_coords(dst_surface, context->win_handle, &dst_rect);
-
- if (!device->blitter->blit_supported(gl_info, BLIT_OP_BLIT,
- &src_rect, src_surface->resource.usage, src_surface->resource.pool, src_surface->resource.format,
- &dst_rect, dst_surface->resource.usage, dst_surface->resource.pool, dst_surface->resource.format))
- {
- FIXME("Unsupported blit operation falling back to software\n");
- return WINED3DERR_INVALIDCALL;
- }
-
- device->blitter->set_shader((IWineD3DDevice *)device, src_surface);
-
- ENTER_GL();
-
- /* This is for color keying */
- if(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE)) {
- glEnable(GL_ALPHA_TEST);
- checkGLcall("glEnable(GL_ALPHA_TEST)");
-
- /* When the primary render target uses P8, the alpha component contains the palette index.
- * Which means that the colorkey is one of the palette entries. In other cases pixels that
- * should be masked away have alpha set to 0. */
- if (primary_render_target_is_p8(device))
- glAlphaFunc(GL_NOTEQUAL, (float)src_surface->SrcBltCKey.dwColorSpaceLowValue / 256.0f);
- else
- glAlphaFunc(GL_NOTEQUAL, 0.0f);
- checkGLcall("glAlphaFunc");
- } else {
- glDisable(GL_ALPHA_TEST);
- checkGLcall("glDisable(GL_ALPHA_TEST)");
- }
-
- /* Draw a textured quad
- */
- draw_textured_quad(src_surface, &src_rect, &dst_rect, Filter);
-
- if(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE)) {
- glDisable(GL_ALPHA_TEST);
- checkGLcall("glDisable(GL_ALPHA_TEST)");
- }
+ surface_blt_to_drawable(device, Filter, flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE),
+ src_surface, &src_rect, dst_surface, &dst_rect);
/* Restore the color key parameters */
src_surface->CKeyFlags = oldCKeyFlags;
src_surface->SrcBltCKey = oldBltCKey;
- LEAVE_GL();
-
- /* Leave the opengl state valid for blitting */
- device->blitter->unset_shader((IWineD3DDevice *)device);
-
- if (wined3d_settings.strict_draw_ordering || (dstSwapchain
- && (dst_surface == dstSwapchain->front_buffer
- || dstSwapchain->num_contexts > 1)))
- wglFlush(); /* Flush to ensure ordering across contexts. */
-
- context_release(context);
-
- /* TODO: If the surface is locked often, perform the Blt in software on the memory instead */
- /* The surface is now in the drawable. On onscreen surfaces or without fbos the texture
- * is outdated now
- */
surface_modify_location(dst_surface, SFLAG_INDRAWABLE, TRUE);
return WINED3D_OK;
@@ -3747,7 +5533,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
else
{
/* Source-Less Blit to render target */
- if (Flags & WINEDDBLT_COLORFILL)
+ if (flags & WINEDDBLT_COLORFILL)
{
WINED3DCOLORVALUE color;
@@ -3766,305 +5552,15 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
return WINED3DERR_INVALIDCALL;
}
-static HRESULT IWineD3DSurfaceImpl_BltZ(IWineD3DSurfaceImpl *This, const RECT *DestRect,
- IWineD3DSurface *src_surface, const RECT *src_rect, DWORD Flags, const WINEDDBLTFX *DDBltFx)
-{
- IWineD3DDeviceImpl *device = This->resource.device;
- float depth;
-
- if (Flags & WINEDDBLT_DEPTHFILL)
- {
- switch (This->resource.format->id)
- {
- case WINED3DFMT_D16_UNORM:
- depth = (float) DDBltFx->u5.dwFillDepth / (float) 0x0000ffff;
- break;
- case WINED3DFMT_S1_UINT_D15_UNORM:
- depth = (float) DDBltFx->u5.dwFillDepth / (float) 0x00007fff;
- break;
- case WINED3DFMT_D24_UNORM_S8_UINT:
- case WINED3DFMT_X8D24_UNORM:
- depth = (float) DDBltFx->u5.dwFillDepth / (float) 0x00ffffff;
- break;
- case WINED3DFMT_D32_UNORM:
- depth = (float) DDBltFx->u5.dwFillDepth / (float) 0xffffffff;
- break;
- default:
- depth = 0.0f;
- ERR("Unexpected format for depth fill: %s.\n", debug_d3dformat(This->resource.format->id));
- }
-
- return IWineD3DDevice_Clear((IWineD3DDevice *)device, DestRect ? 1 : 0, DestRect,
- WINED3DCLEAR_ZBUFFER, 0x00000000, depth, 0x00000000);
- }
-
- FIXME("(%p): Unsupp depthstencil blit\n", This);
- return WINED3DERR_INVALIDCALL;
-}
-
-static HRESULT WINAPI IWineD3DSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *DestRect,
- IWineD3DSurface *src_surface, const RECT *SrcRect, DWORD Flags,
- const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter)
-{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
- IWineD3DSurfaceImpl *src = (IWineD3DSurfaceImpl *)src_surface;
- IWineD3DDeviceImpl *device = This->resource.device;
-
- TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p, filter %s.\n",
- iface, wine_dbgstr_rect(DestRect), src_surface, wine_dbgstr_rect(SrcRect),
- Flags, DDBltFx, debug_d3dtexturefiltertype(Filter));
- TRACE("Usage is %s.\n", debug_d3dusage(This->resource.usage));
-
- if ((This->Flags & SFLAG_LOCKED) || (src && (src->Flags & SFLAG_LOCKED)))
- {
- WARN(" Surface is busy, returning DDERR_SURFACEBUSY\n");
- return WINEDDERR_SURFACEBUSY;
- }
-
- /* Accessing the depth stencil is supposed to fail between a BeginScene and EndScene pair,
- * except depth blits, which seem to work
- */
- if (This == device->depth_stencil || (src && src == device->depth_stencil))
- {
- if (device->inScene && !(Flags & WINEDDBLT_DEPTHFILL))
- {
- TRACE("Attempt to access the depth stencil surface in a BeginScene / EndScene pair, returning WINED3DERR_INVALIDCALL\n");
- return WINED3DERR_INVALIDCALL;
- }
- else if (SUCCEEDED(IWineD3DSurfaceImpl_BltZ(This, DestRect, src_surface, SrcRect, Flags, DDBltFx)))
- {
- TRACE("Z Blit override handled the blit\n");
- return WINED3D_OK;
- }
- }
-
- /* Special cases for RenderTargets */
- if ((This->resource.usage & WINED3DUSAGE_RENDERTARGET)
- || (src && (src->resource.usage & WINED3DUSAGE_RENDERTARGET)))
- {
- if (SUCCEEDED(IWineD3DSurfaceImpl_BltOverride(This, DestRect, src, SrcRect, Flags, DDBltFx, Filter)))
- return WINED3D_OK;
- }
-
- /* For the rest call the X11 surface implementation.
- * For RenderTargets this should be implemented OpenGL accelerated in BltOverride,
- * other Blts are rather rare. */
- return IWineD3DBaseSurfaceImpl_Blt(iface, DestRect, src_surface, SrcRect, Flags, DDBltFx, Filter);
-}
-
-static HRESULT WINAPI IWineD3DSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty,
- IWineD3DSurface *src_surface, const RECT *rsrc, DWORD trans)
-{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
- IWineD3DSurfaceImpl *src = (IWineD3DSurfaceImpl *)src_surface;
- IWineD3DDeviceImpl *device = This->resource.device;
-
- TRACE("iface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, flags %#x.\n",
- iface, dstx, dsty, src_surface, wine_dbgstr_rect(rsrc), trans);
-
- if ((This->Flags & SFLAG_LOCKED) || (src->Flags & SFLAG_LOCKED))
- {
- WARN(" Surface is busy, returning DDERR_SURFACEBUSY\n");
- return WINEDDERR_SURFACEBUSY;
- }
-
- if (device->inScene && (This == device->depth_stencil || src == device->depth_stencil))
- {
- TRACE("Attempt to access the depth stencil surface in a BeginScene / EndScene pair, returning WINED3DERR_INVALIDCALL\n");
- return WINED3DERR_INVALIDCALL;
- }
-
- /* Special cases for RenderTargets */
- if ((This->resource.usage & WINED3DUSAGE_RENDERTARGET)
- || (src->resource.usage & WINED3DUSAGE_RENDERTARGET))
- {
-
- RECT SrcRect, DstRect;
- DWORD Flags=0;
-
- surface_get_rect(src, rsrc, &SrcRect);
-
- DstRect.left = dstx;
- DstRect.top=dsty;
- DstRect.right = dstx + SrcRect.right - SrcRect.left;
- DstRect.bottom = dsty + SrcRect.bottom - SrcRect.top;
-
- /* Convert BltFast flags into Btl ones because it is called from SurfaceImpl_Blt as well */
- if(trans & WINEDDBLTFAST_SRCCOLORKEY)
- Flags |= WINEDDBLT_KEYSRC;
- if(trans & WINEDDBLTFAST_DESTCOLORKEY)
- Flags |= WINEDDBLT_KEYDEST;
- if(trans & WINEDDBLTFAST_WAIT)
- Flags |= WINEDDBLT_WAIT;
- if(trans & WINEDDBLTFAST_DONOTWAIT)
- Flags |= WINEDDBLT_DONOTWAIT;
-
- if (SUCCEEDED(IWineD3DSurfaceImpl_BltOverride(This,
- &DstRect, src, &SrcRect, Flags, NULL, WINED3DTEXF_POINT)))
- return WINED3D_OK;
- }
-
- return IWineD3DBaseSurfaceImpl_BltFast(iface, dstx, dsty, src_surface, rsrc, trans);
-}
-
-static HRESULT WINAPI IWineD3DSurfaceImpl_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->resource.format->id == WINED3DFMT_P8_UINT
- || This->resource.format->id == WINED3DFMT_P8_UINT_A8_UNORM)
- {
- if (This->resource.usage & WINED3DUSAGE_RENDERTARGET)
- {
- /* Make sure the texture is up to date. This call doesn't do
- * anything if the texture is already up to date. */
- surface_load_location(This, SFLAG_INTEXTURE, NULL);
-
- /* We want to force a palette refresh, so mark the drawable as not being up to date */
- surface_modify_location(This, SFLAG_INDRAWABLE, FALSE);
- }
- else
- {
- if (!(This->Flags & SFLAG_INSYSMEM))
- {
- TRACE("Palette changed with surface that does not have an up to date system memory copy.\n");
- surface_load_location(This, SFLAG_INSYSMEM, NULL);
- }
- TRACE("Dirtifying surface\n");
- surface_modify_location(This, SFLAG_INSYSMEM, TRUE);
- }
- }
-
- 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);
- }
-
- /* Propagate the changes to the drawable when we have a palette. */
- if (This->resource.usage & WINED3DUSAGE_RENDERTARGET)
- surface_load_location(This, SFLAG_INDRAWABLE, NULL);
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) {
- /** Check against the maximum texture sizes supported by the video card **/
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
- const struct wined3d_gl_info *gl_info = &This->resource.device->adapter->gl_info;
- unsigned int pow2Width, pow2Height;
-
- This->texture_name = 0;
- This->texture_target = GL_TEXTURE_2D;
-
- /* Non-power2 support */
- if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] || gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT])
- {
- pow2Width = This->currentDesc.Width;
- pow2Height = This->currentDesc.Height;
- }
- else
- {
- /* Find the nearest pow2 match */
- pow2Width = pow2Height = 1;
- while (pow2Width < This->currentDesc.Width) pow2Width <<= 1;
- while (pow2Height < This->currentDesc.Height) pow2Height <<= 1;
- }
- This->pow2Width = pow2Width;
- This->pow2Height = pow2Height;
-
- if (pow2Width > This->currentDesc.Width || pow2Height > This->currentDesc.Height)
- {
- /* TODO: Add support for non power two compressed textures. */
- if (This->resource.format->Flags & WINED3DFMT_FLAG_COMPRESSED)
- {
- FIXME("(%p) Compressed non-power-two textures are not supported w(%d) h(%d)\n",
- This, This->currentDesc.Width, This->currentDesc.Height);
- return WINED3DERR_NOTAVAILABLE;
- }
- }
-
- if(pow2Width != This->currentDesc.Width ||
- pow2Height != This->currentDesc.Height) {
- This->Flags |= SFLAG_NONPOW2;
- }
-
- TRACE("%p\n", This);
- if ((This->pow2Width > gl_info->limits.texture_size || This->pow2Height > gl_info->limits.texture_size)
- && !(This->resource.usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL)))
- {
- /* one of three options
- 1: Do the same as we do with nonpow 2 and scale the texture, (any texture ops would require the texture to be scaled which is potentially slow)
- 2: Set the texture to the maximum size (bad idea)
- 3: WARN and return WINED3DERR_NOTAVAILABLE;
- 4: Create the surface, but allow it to be used only for DirectDraw Blts. Some apps(e.g. Swat 3) create textures with a Height of 16 and a Width > 3000 and blt 16x16 letter areas from them to the render target.
- */
- if(This->resource.pool == WINED3DPOOL_DEFAULT || This->resource.pool == WINED3DPOOL_MANAGED)
- {
- WARN("(%p) Unable to allocate a surface which exceeds the maximum OpenGL texture size\n", This);
- return WINED3DERR_NOTAVAILABLE;
- }
-
- /* We should never use this surface in combination with OpenGL! */
- TRACE("(%p) Creating an oversized surface: %ux%u\n", This, This->pow2Width, This->pow2Height);
- }
- else
- {
- /* Don't use ARB_TEXTURE_RECTANGLE in case the surface format is P8 and EXT_PALETTED_TEXTURE
- is used in combination with texture uploads (RTL_READTEX/RTL_TEXTEX). The reason is that EXT_PALETTED_TEXTURE
- doesn't work in combination with ARB_TEXTURE_RECTANGLE.
- */
- if (This->Flags & SFLAG_NONPOW2 && gl_info->supported[ARB_TEXTURE_RECTANGLE]
- && !(This->resource.format->id == WINED3DFMT_P8_UINT
- && gl_info->supported[EXT_PALETTED_TEXTURE]
- && wined3d_settings.rendertargetlock_mode == RTL_READTEX))
- {
- This->texture_target = GL_TEXTURE_RECTANGLE_ARB;
- This->pow2Width = This->currentDesc.Width;
- This->pow2Height = This->currentDesc.Height;
- This->Flags &= ~(SFLAG_NONPOW2 | SFLAG_NORMCOORD);
- }
- }
-
- switch (wined3d_settings.offscreen_rendering_mode)
- {
- case ORM_FBO:
- This->get_drawable_size = get_drawable_size_fbo;
- break;
-
- case ORM_BACKBUFFER:
- This->get_drawable_size = get_drawable_size_backbuffer;
- break;
-
- default:
- ERR("Unhandled offscreen rendering mode %#x.\n", wined3d_settings.offscreen_rendering_mode);
- return WINED3DERR_INVALIDCALL;
- }
-
- This->Flags |= SFLAG_INSYSMEM;
-
- return WINED3D_OK;
-}
-
/* GL locking is done by the caller */
-static void surface_depth_blt(IWineD3DSurfaceImpl *This, const struct wined3d_gl_info *gl_info,
+static void surface_depth_blt(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info,
GLuint texture, GLsizei w, GLsizei h, GLenum target)
{
- IWineD3DDeviceImpl *device = This->resource.device;
+ struct wined3d_device *device = surface->resource.device;
GLint compare_mode = GL_NONE;
struct blt_info info;
GLint old_binding = 0;
+ RECT rect;
glPushAttrib(GL_ENABLE_BIT | GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_VIEWPORT_BIT);
@@ -4077,9 +5573,10 @@ static void surface_depth_blt(IWineD3DSurfaceImpl *This, const struct wined3d_gl
glDepthFunc(GL_ALWAYS);
glDepthMask(GL_TRUE);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
- glViewport(0, 0, w, h);
+ glViewport(0, surface->pow2Height - h, w, h);
- surface_get_blt_info(target, NULL, w, h, &info);
+ SetRect(&rect, 0, h, w, 0);
+ surface_get_blt_info(target, &rect, surface->pow2Width, surface->pow2Height, &info);
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
glGetIntegerv(info.binding, &old_binding);
glBindTexture(info.bind_target, texture);
@@ -4089,8 +5586,8 @@ static void surface_depth_blt(IWineD3DSurfaceImpl *This, const struct wined3d_gl
if (compare_mode != GL_NONE) glTexParameteri(info.bind_target, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
}
- device->shader_backend->shader_select_depth_blt((IWineD3DDevice *)device,
- info.tex_type, &This->ds_current_size);
+ device->shader_backend->shader_select_depth_blt(device->shader_priv,
+ gl_info, info.tex_type, &surface->ds_current_size);
glBegin(GL_TRIANGLE_STRIP);
glTexCoord3fv(info.coords[0]);
@@ -4108,10 +5605,10 @@ static void surface_depth_blt(IWineD3DSurfaceImpl *This, const struct wined3d_gl
glPopAttrib();
- device->shader_backend->shader_deselect_depth_blt((IWineD3DDevice *)device);
+ device->shader_backend->shader_deselect_depth_blt(device->shader_priv, gl_info);
}
-void surface_modify_ds_location(IWineD3DSurfaceImpl *surface,
+void surface_modify_ds_location(struct wined3d_surface *surface,
DWORD location, UINT w, UINT h)
{
TRACE("surface %p, new location %#x, w %u, h %u.\n", surface, location, w, h);
@@ -4121,29 +5618,37 @@ void surface_modify_ds_location(IWineD3DSurfaceImpl *surface,
surface->ds_current_size.cx = w;
surface->ds_current_size.cy = h;
- surface->Flags &= ~SFLAG_DS_LOCATIONS;
- surface->Flags |= location;
+ surface->flags &= ~SFLAG_DS_LOCATIONS;
+ surface->flags |= location;
}
/* Context activation is done by the caller. */
-void surface_load_ds_location(IWineD3DSurfaceImpl *surface, struct wined3d_context *context, DWORD location)
+void surface_load_ds_location(struct wined3d_surface *surface, struct wined3d_context *context, DWORD location)
{
- IWineD3DDeviceImpl *device = surface->resource.device;
+ struct wined3d_device *device = surface->resource.device;
const struct wined3d_gl_info *gl_info = context->gl_info;
+ GLsizei w, h;
TRACE("surface %p, new location %#x.\n", surface, location);
/* TODO: Make this work for modes other than FBO */
if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return;
- if (!(surface->Flags & location))
+ if (!(surface->flags & location))
{
+ w = surface->ds_current_size.cx;
+ h = surface->ds_current_size.cy;
surface->ds_current_size.cx = 0;
surface->ds_current_size.cy = 0;
}
+ else
+ {
+ w = surface->resource.width;
+ h = surface->resource.height;
+ }
- if (surface->ds_current_size.cx == surface->currentDesc.Width
- && surface->ds_current_size.cy == surface->currentDesc.Height)
+ if (surface->ds_current_size.cx == surface->resource.width
+ && surface->ds_current_size.cy == surface->resource.height)
{
TRACE("Location (%#x) is already up to date.\n", location);
return;
@@ -4155,10 +5660,17 @@ void surface_load_ds_location(IWineD3DSurfaceImpl *surface, struct wined3d_conte
return;
}
- if (!(surface->Flags & SFLAG_LOCATIONS))
+ if (!(surface->flags & SFLAG_DS_LOCATIONS))
{
+ /* This mostly happens when a depth / stencil is used without being
+ * cleared first. In principle we could upload from sysmem, or
+ * explicitly clear before first usage. For the moment there don't
+ * appear to be a lot of applications depending on this, so a FIXME
+ * should do. */
FIXME("No up to date depth stencil location.\n");
- surface->Flags |= location;
+ surface->flags |= location;
+ surface->ds_current_size.cx = surface->resource.width;
+ surface->ds_current_size.cy = surface->resource.height;
return;
}
@@ -4166,14 +5678,13 @@ void surface_load_ds_location(IWineD3DSurfaceImpl *surface, struct wined3d_conte
{
GLint old_binding = 0;
GLenum bind_target;
- GLsizei w, h;
/* The render target is allowed to be smaller than the depth/stencil
* buffer, so the onscreen depth/stencil buffer is potentially smaller
* than the offscreen surface. Don't overwrite the offscreen surface
* with undefined data. */
- w = min(surface->currentDesc.Width, context->swapchain->presentParms.BackBufferWidth);
- h = min(surface->currentDesc.Height, context->swapchain->presentParms.BackBufferHeight);
+ w = min(w, context->swapchain->presentParms.BackBufferWidth);
+ h = min(h, context->swapchain->presentParms.BackBufferHeight);
TRACE("Copying onscreen depth buffer to depth texture.\n");
@@ -4248,7 +5759,7 @@ void surface_load_ds_location(IWineD3DSurfaceImpl *surface, struct wined3d_conte
context_bind_fbo(context, GL_FRAMEBUFFER, NULL);
surface_depth_blt(surface, gl_info, surface->texture_name,
- surface->currentDesc.Width, surface->currentDesc.Height, surface->texture_target);
+ w, h, surface->texture_target);
checkGLcall("depth_blt");
if (context->current_fbo) context_bind_fbo(context, GL_FRAMEBUFFER, &context->current_fbo->id);
@@ -4262,14 +5773,15 @@ void surface_load_ds_location(IWineD3DSurfaceImpl *surface, struct wined3d_conte
ERR("Invalid location (%#x) specified.\n", location);
}
- surface->Flags |= location;
- surface->ds_current_size.cx = surface->currentDesc.Width;
- surface->ds_current_size.cy = surface->currentDesc.Height;
+ surface->flags |= location;
+ surface->ds_current_size.cx = surface->resource.width;
+ surface->ds_current_size.cy = surface->resource.height;
}
-void surface_modify_location(IWineD3DSurfaceImpl *surface, DWORD flag, BOOL persistent)
+void surface_modify_location(struct wined3d_surface *surface, DWORD flag, BOOL persistent)
{
- IWineD3DSurfaceImpl *overlay;
+ const struct wined3d_gl_info *gl_info = &surface->resource.device->adapter->gl_info;
+ struct wined3d_surface *overlay;
TRACE("surface %p, location %s, persistent %#x.\n",
surface, debug_surflocation(flag), persistent);
@@ -4287,93 +5799,75 @@ void surface_modify_location(IWineD3DSurfaceImpl *surface, DWORD flag, BOOL pers
}
}
+ if (flag & (SFLAG_INTEXTURE | SFLAG_INSRGBTEX)
+ && gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
+ {
+ flag |= (SFLAG_INTEXTURE | SFLAG_INSRGBTEX);
+ }
+
if (persistent)
{
- if (((surface->Flags & SFLAG_INTEXTURE) && !(flag & SFLAG_INTEXTURE))
- || ((surface->Flags & SFLAG_INSRGBTEX) && !(flag & SFLAG_INSRGBTEX)))
+ if (((surface->flags & SFLAG_INTEXTURE) && !(flag & SFLAG_INTEXTURE))
+ || ((surface->flags & SFLAG_INSRGBTEX) && !(flag & SFLAG_INSRGBTEX)))
{
if (surface->container.type == WINED3D_CONTAINER_TEXTURE)
{
TRACE("Passing to container.\n");
- IWineD3DBaseTexture_SetDirty((IWineD3DBaseTexture *)surface->container.u.texture, TRUE);
+ wined3d_texture_set_dirty(surface->container.u.texture, TRUE);
}
}
- surface->Flags &= ~SFLAG_LOCATIONS;
- surface->Flags |= flag;
+ surface->flags &= ~SFLAG_LOCATIONS;
+ surface->flags |= flag;
/* Redraw emulated overlays, if any */
if (flag & SFLAG_INDRAWABLE && !list_empty(&surface->overlays))
{
- LIST_FOR_EACH_ENTRY(overlay, &surface->overlays, IWineD3DSurfaceImpl, overlay_entry)
+ LIST_FOR_EACH_ENTRY(overlay, &surface->overlays, struct wined3d_surface, overlay_entry)
{
- IWineD3DSurface_DrawOverlay((IWineD3DSurface *)overlay);
+ overlay->surface_ops->surface_draw_overlay(overlay);
}
}
}
else
{
- if ((surface->Flags & (SFLAG_INTEXTURE | SFLAG_INSRGBTEX)) && (flag & (SFLAG_INTEXTURE | SFLAG_INSRGBTEX)))
+ if ((surface->flags & (SFLAG_INTEXTURE | SFLAG_INSRGBTEX)) && (flag & (SFLAG_INTEXTURE | SFLAG_INSRGBTEX)))
{
if (surface->container.type == WINED3D_CONTAINER_TEXTURE)
{
TRACE("Passing to container\n");
- IWineD3DBaseTexture_SetDirty((IWineD3DBaseTexture *)surface->container.u.texture, TRUE);
+ wined3d_texture_set_dirty(surface->container.u.texture, TRUE);
}
}
- surface->Flags &= ~flag;
+ surface->flags &= ~flag;
}
- if (!(surface->Flags & SFLAG_LOCATIONS))
+ if (!(surface->flags & SFLAG_LOCATIONS))
{
ERR("Surface %p does not have any up to date location.\n", surface);
}
}
-static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT *rect_in)
+static DWORD resource_access_from_location(DWORD location)
{
- IWineD3DDeviceImpl *device = This->resource.device;
- IWineD3DSwapChainImpl *swapchain;
- struct wined3d_context *context;
- RECT src_rect, dst_rect;
-
- surface_get_rect(This, rect_in, &src_rect);
-
- context = context_acquire(device, This);
- context_apply_blit_state(context, device);
- if (context->render_offscreen)
+ switch (location)
{
- dst_rect.left = src_rect.left;
- dst_rect.right = src_rect.right;
- dst_rect.top = src_rect.bottom;
- dst_rect.bottom = src_rect.top;
+ case SFLAG_INSYSMEM:
+ return WINED3D_RESOURCE_ACCESS_CPU;
+
+ case SFLAG_INDRAWABLE:
+ case SFLAG_INSRGBTEX:
+ case SFLAG_INTEXTURE:
+ return WINED3D_RESOURCE_ACCESS_GPU;
+
+ default:
+ FIXME("Unhandled location %#x.\n", location);
+ return 0;
}
- else
- {
- dst_rect = src_rect;
- }
-
- swapchain = This->container.type == WINED3D_CONTAINER_SWAPCHAIN ? This->container.u.swapchain : NULL;
- if (swapchain && This == swapchain->front_buffer)
- surface_translate_frontbuffer_coords(This, context->win_handle, &dst_rect);
-
- device->blitter->set_shader((IWineD3DDevice *) device, This);
-
- ENTER_GL();
- draw_textured_quad(This, &src_rect, &dst_rect, WINED3DTEXF_POINT);
- LEAVE_GL();
-
- device->blitter->unset_shader((IWineD3DDevice *) device);
-
- if (wined3d_settings.strict_draw_ordering || (swapchain
- && (This == swapchain->front_buffer || swapchain->num_contexts > 1)))
- wglFlush(); /* Flush to ensure ordering across contexts. */
-
- context_release(context);
}
-HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RECT *rect)
+HRESULT surface_load_location(struct wined3d_surface *surface, DWORD flag, const RECT *rect)
{
- IWineD3DDeviceImpl *device = surface->resource.device;
+ struct wined3d_device *device = surface->resource.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
BOOL drawable_read_ok = surface_is_offscreen(surface);
struct wined3d_format format;
@@ -4416,16 +5910,29 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE
}
}
- if (surface->Flags & flag)
+ if (flag == SFLAG_INSRGBTEX && gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
+ {
+ flag = SFLAG_INTEXTURE;
+ }
+
+ if (surface->flags & flag)
{
TRACE("Location already up to date\n");
return WINED3D_OK;
}
- if (!(surface->Flags & SFLAG_LOCATIONS))
+ if (WARN_ON(d3d_surface))
+ {
+ DWORD required_access = resource_access_from_location(flag);
+ if ((surface->resource.access_flags & required_access) != required_access)
+ WARN("Operation requires %#x access, but surface only has %#x.\n",
+ required_access, surface->resource.access_flags);
+ }
+
+ if (!(surface->flags & SFLAG_LOCATIONS))
{
ERR("Surface %p does not have any up to date location.\n", surface);
- surface->Flags |= SFLAG_LOST;
+ surface->flags |= SFLAG_LOST;
return WINED3DERR_DEVICELOST;
}
@@ -4434,13 +5941,13 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE
surface_prepare_system_memory(surface);
/* Download the surface to system memory */
- if (surface->Flags & (SFLAG_INTEXTURE | SFLAG_INSRGBTEX))
+ if (surface->flags & (SFLAG_INTEXTURE | SFLAG_INSRGBTEX))
{
struct wined3d_context *context = NULL;
if (!device->isInDraw) context = context_acquire(device, NULL);
- surface_bind_and_dirtify(surface, !(surface->Flags & SFLAG_INTEXTURE));
+ surface_bind_and_dirtify(surface, gl_info, !(surface->flags & SFLAG_INTEXTURE));
surface_download_data(surface, gl_info);
if (context) context_release(context);
@@ -4449,19 +5956,25 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE
{
/* Note: It might be faster to download into a texture first. */
read_from_framebuffer(surface, rect, surface->resource.allocatedMemory,
- IWineD3DSurface_GetPitch((IWineD3DSurface *)surface));
+ wined3d_surface_get_pitch(surface));
}
}
else if (flag == SFLAG_INDRAWABLE)
{
- if (surface->Flags & SFLAG_INTEXTURE)
+ if (wined3d_settings.rendertargetlock_mode == RTL_READTEX)
+ surface_load_location(surface, SFLAG_INTEXTURE, NULL);
+
+ if (surface->flags & SFLAG_INTEXTURE)
{
- surface_blt_to_drawable(surface, rect);
+ RECT r;
+
+ surface_get_rect(surface, rect, &r);
+ surface_blt_to_drawable(device, WINED3DTEXF_POINT, FALSE, surface, &r, surface, &r);
}
else
{
int byte_count;
- if ((surface->Flags & SFLAG_LOCATIONS) == SFLAG_INSRGBTEX)
+ if ((surface->flags & SFLAG_LOCATIONS) == SFLAG_INSRGBTEX)
{
/* This needs a shader to convert the srgb data sampled from the GL texture into RGB
* values, otherwise we get incorrect values in the target. For now go the slow way
@@ -4474,12 +5987,12 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE
FALSE /* We won't use textures */, &format, &convert);
/* The width is in 'length' not in bytes */
- width = surface->currentDesc.Width;
- pitch = IWineD3DSurface_GetPitch((IWineD3DSurface *)surface);
+ width = surface->resource.width;
+ pitch = wined3d_surface_get_pitch(surface);
/* Don't use PBOs for converted surfaces. During PBO conversion we look at SFLAG_CONVERTED
* but it isn't set (yet) in all cases it is getting called. */
- if ((convert != NO_CONVERSION) && (surface->Flags & SFLAG_PBO))
+ if ((convert != NO_CONVERSION) && (surface->flags & SFLAG_PBO))
{
struct wined3d_context *context = NULL;
@@ -4492,7 +6005,7 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE
if ((convert != NO_CONVERSION) && surface->resource.allocatedMemory)
{
- int height = surface->currentDesc.Height;
+ int height = surface->resource.height;
byte_count = format.conv_byte_count;
/* Stick to the alignment for the converted surface too, makes it easier to load the surface */
@@ -4507,19 +6020,19 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE
d3dfmt_convert_surface(surface->resource.allocatedMemory, mem, pitch,
width, height, outpitch, convert, surface);
- surface->Flags |= SFLAG_CONVERTED;
+ surface->flags |= SFLAG_CONVERTED;
}
else
{
- surface->Flags &= ~SFLAG_CONVERTED;
+ surface->flags &= ~SFLAG_CONVERTED;
mem = surface->resource.allocatedMemory;
byte_count = format.byte_count;
}
- flush_to_framebuffer_drawpixels(surface, format.glFormat, format.glType, byte_count, mem);
+ flush_to_framebuffer_drawpixels(surface, rect, format.glFormat, format.glType, byte_count, mem);
/* Don't delete PBO memory */
- if ((mem != surface->resource.allocatedMemory) && !(surface->Flags & SFLAG_PBO))
+ if ((mem != surface->resource.allocatedMemory) && !(surface->flags & SFLAG_PBO))
HeapFree(GetProcessHeap(), 0, mem);
}
}
@@ -4527,18 +6040,18 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE
{
const DWORD attach_flags = WINED3DFMT_FLAG_FBO_ATTACHABLE | WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB;
- if (drawable_read_ok && (surface->Flags & SFLAG_INDRAWABLE))
+ if (drawable_read_ok && (surface->flags & SFLAG_INDRAWABLE))
{
read_from_framebuffer_texture(surface, flag == SFLAG_INSRGBTEX);
}
- else if (surface->Flags & (SFLAG_INSRGBTEX | SFLAG_INTEXTURE)
- && (surface->resource.format->Flags & attach_flags) == attach_flags
- && fbo_blit_supported(gl_info, BLIT_OP_BLIT,
+ else if (surface->flags & (SFLAG_INSRGBTEX | SFLAG_INTEXTURE)
+ && (surface->resource.format->flags & attach_flags) == attach_flags
+ && fbo_blit_supported(gl_info, WINED3D_BLIT_OP_COLOR_BLIT,
NULL, surface->resource.usage, surface->resource.pool, surface->resource.format,
NULL, surface->resource.usage, surface->resource.pool, surface->resource.format))
{
DWORD src_location = flag == SFLAG_INSRGBTEX ? SFLAG_INTEXTURE : SFLAG_INSRGBTEX;
- RECT rect = {0, 0, surface->currentDesc.Width, surface->currentDesc.Height};
+ RECT rect = {0, 0, surface->resource.width, surface->resource.height};
surface_blt_fbo(surface->resource.device, WINED3DTEXF_POINT,
surface, src_location, &rect, surface, flag, &rect);
@@ -4554,7 +6067,7 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE
if (srgb)
{
- if ((surface->Flags & (SFLAG_INTEXTURE | SFLAG_INSYSMEM)) == SFLAG_INTEXTURE)
+ if ((surface->flags & (SFLAG_INTEXTURE | SFLAG_INSYSMEM)) == SFLAG_INTEXTURE)
{
/* Performance warning... */
FIXME("Downloading RGB surface %p to reload it as sRGB.\n", surface);
@@ -4563,14 +6076,14 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE
}
else
{
- if ((surface->Flags & (SFLAG_INSRGBTEX | SFLAG_INSYSMEM)) == SFLAG_INSRGBTEX)
+ if ((surface->flags & (SFLAG_INSRGBTEX | SFLAG_INSYSMEM)) == SFLAG_INSRGBTEX)
{
/* Performance warning... */
FIXME("Downloading sRGB surface %p to reload it as RGB.\n", surface);
surface_load_location(surface, SFLAG_INSYSMEM, rect);
}
}
- if (!(surface->Flags & SFLAG_INSYSMEM))
+ if (!(surface->flags & SFLAG_INSYSMEM))
{
WARN("Trying to load a texture from sysmem, but SFLAG_INSYSMEM is not set.\n");
/* Lets hope we get it from somewhere... */
@@ -4580,22 +6093,22 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE
if (!device->isInDraw) context = context_acquire(device, NULL);
surface_prepare_texture(surface, gl_info, srgb);
- surface_bind_and_dirtify(surface, srgb);
+ surface_bind_and_dirtify(surface, gl_info, srgb);
if (surface->CKeyFlags & WINEDDSD_CKSRCBLT)
{
- surface->Flags |= SFLAG_GLCKEY;
+ surface->flags |= SFLAG_GLCKEY;
surface->glCKey = surface->SrcBltCKey;
}
- else surface->Flags &= ~SFLAG_GLCKEY;
+ else surface->flags &= ~SFLAG_GLCKEY;
/* The width is in 'length' not in bytes */
- width = surface->currentDesc.Width;
- pitch = IWineD3DSurface_GetPitch((IWineD3DSurface *)surface);
+ width = surface->resource.width;
+ pitch = wined3d_surface_get_pitch(surface);
/* Don't use PBOs for converted surfaces. During PBO conversion we look at SFLAG_CONVERTED
* but it isn't set (yet) in all cases it is getting called. */
- if ((convert != NO_CONVERSION || format.convert) && (surface->Flags & SFLAG_PBO))
+ if ((convert != NO_CONVERSION || format.convert) && (surface->flags & SFLAG_PBO))
{
TRACE("Removing the pbo attached to surface %p.\n", surface);
surface_remove_pbo(surface, gl_info);
@@ -4604,7 +6117,7 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE
if (format.convert)
{
/* This code is entered for texture formats which need a fixup. */
- int height = surface->currentDesc.Height;
+ UINT height = surface->resource.height;
/* Stick to the alignment for the converted surface too, makes it easier to load the surface */
outpitch = width * format.conv_byte_count;
@@ -4621,7 +6134,7 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE
else if (convert != NO_CONVERSION && surface->resource.allocatedMemory)
{
/* This code is only entered for color keying fixups */
- int height = surface->currentDesc.Height;
+ UINT height = surface->resource.height;
/* Stick to the alignment for the converted surface too, makes it easier to load the surface */
outpitch = width * format.conv_byte_count;
@@ -4646,7 +6159,7 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE
glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
LEAVE_GL();
- if (mem || (surface->Flags & SFLAG_PBO))
+ if (mem || (surface->flags & SFLAG_PBO))
surface_upload_data(surface, gl_info, &format, srgb, mem);
/* Restore the default pitch */
@@ -4657,51 +6170,37 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE
if (context) context_release(context);
/* Don't delete PBO memory */
- if ((mem != surface->resource.allocatedMemory) && !(surface->Flags & SFLAG_PBO))
+ if ((mem != surface->resource.allocatedMemory) && !(surface->flags & SFLAG_PBO))
HeapFree(GetProcessHeap(), 0, mem);
}
}
- if (!rect) surface->Flags |= flag;
+ if (!rect)
+ {
+ surface->flags |= flag;
- if (in_fbo && (surface->Flags & (SFLAG_INTEXTURE | SFLAG_INDRAWABLE)))
+ if (flag != SFLAG_INSYSMEM && (surface->flags & SFLAG_INSYSMEM))
+ surface_evict_sysmem(surface);
+ }
+
+ if (in_fbo && (surface->flags & (SFLAG_INTEXTURE | SFLAG_INDRAWABLE)))
{
/* With ORM_FBO, SFLAG_INTEXTURE and SFLAG_INDRAWABLE are the same for offscreen targets. */
- surface->Flags |= (SFLAG_INTEXTURE | SFLAG_INDRAWABLE);
+ surface->flags |= (SFLAG_INTEXTURE | SFLAG_INDRAWABLE);
+ }
+
+ if (surface->flags & (SFLAG_INTEXTURE | SFLAG_INSRGBTEX)
+ && gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
+ {
+ surface->flags |= (SFLAG_INTEXTURE | SFLAG_INSRGBTEX);
}
return WINED3D_OK;
}
-static WINED3DSURFTYPE WINAPI IWineD3DSurfaceImpl_GetImplType(IWineD3DSurface *iface) {
- return SURFACE_OPENGL;
-}
-
-static HRESULT WINAPI IWineD3DSurfaceImpl_DrawOverlay(IWineD3DSurface *iface) {
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
- HRESULT hr;
-
- /* If there's no destination surface there is nothing to do */
- if(!This->overlay_dest) return WINED3D_OK;
-
- /* Blt calls ModifyLocation on the dest surface, which in turn calls DrawOverlay to
- * update the overlay. Prevent an endless recursion
- */
- if(This->overlay_dest->Flags & SFLAG_INOVERLAYDRAW) {
- return WINED3D_OK;
- }
- This->overlay_dest->Flags |= SFLAG_INOVERLAYDRAW;
- hr = IWineD3DSurfaceImpl_Blt((IWineD3DSurface *) This->overlay_dest, &This->overlay_destrect,
- iface, &This->overlay_srcrect, WINEDDBLT_WAIT,
- NULL, WINED3DTEXF_LINEAR);
- This->overlay_dest->Flags &= ~SFLAG_INOVERLAYDRAW;
-
- return hr;
-}
-
-BOOL surface_is_offscreen(IWineD3DSurfaceImpl *surface)
+BOOL surface_is_offscreen(struct wined3d_surface *surface)
{
- IWineD3DSwapChainImpl *swapchain = surface->container.u.swapchain;
+ struct wined3d_swapchain *swapchain = surface->container.u.swapchain;
/* Not on a swapchain - must be offscreen */
if (surface->container.type != WINED3D_CONTAINER_SWAPCHAIN) return TRUE;
@@ -4714,64 +6213,13 @@ BOOL surface_is_offscreen(IWineD3DSurfaceImpl *surface)
return swapchain->render_to_fbo;
}
-const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl =
-{
- /* IUnknown */
- IWineD3DBaseSurfaceImpl_QueryInterface,
- IWineD3DBaseSurfaceImpl_AddRef,
- IWineD3DSurfaceImpl_Release,
- /* IWineD3DResource */
- IWineD3DBaseSurfaceImpl_GetParent,
- IWineD3DBaseSurfaceImpl_SetPrivateData,
- IWineD3DBaseSurfaceImpl_GetPrivateData,
- IWineD3DBaseSurfaceImpl_FreePrivateData,
- IWineD3DBaseSurfaceImpl_SetPriority,
- IWineD3DBaseSurfaceImpl_GetPriority,
- IWineD3DSurfaceImpl_PreLoad,
- IWineD3DSurfaceImpl_UnLoad,
- IWineD3DBaseSurfaceImpl_GetType,
- /* IWineD3DSurface */
- IWineD3DBaseSurfaceImpl_GetDesc,
- IWineD3DSurfaceImpl_LockRect,
- IWineD3DSurfaceImpl_UnlockRect,
- IWineD3DSurfaceImpl_GetDC,
- IWineD3DSurfaceImpl_ReleaseDC,
- IWineD3DSurfaceImpl_Flip,
- IWineD3DSurfaceImpl_Blt,
- IWineD3DBaseSurfaceImpl_GetBltStatus,
- IWineD3DBaseSurfaceImpl_GetFlipStatus,
- IWineD3DBaseSurfaceImpl_IsLost,
- IWineD3DBaseSurfaceImpl_Restore,
- IWineD3DSurfaceImpl_BltFast,
- IWineD3DBaseSurfaceImpl_GetPalette,
- IWineD3DBaseSurfaceImpl_SetPalette,
- IWineD3DSurfaceImpl_RealizePalette,
- IWineD3DBaseSurfaceImpl_SetColorKey,
- IWineD3DBaseSurfaceImpl_GetPitch,
- IWineD3DSurfaceImpl_SetMem,
- IWineD3DBaseSurfaceImpl_SetOverlayPosition,
- IWineD3DBaseSurfaceImpl_GetOverlayPosition,
- IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder,
- IWineD3DBaseSurfaceImpl_UpdateOverlay,
- IWineD3DBaseSurfaceImpl_SetClipper,
- IWineD3DBaseSurfaceImpl_GetClipper,
- /* Internal use: */
- IWineD3DSurfaceImpl_LoadTexture,
- IWineD3DSurfaceImpl_BindTexture,
- IWineD3DBaseSurfaceImpl_GetData,
- IWineD3DSurfaceImpl_SetFormat,
- IWineD3DSurfaceImpl_PrivateSetup,
- IWineD3DSurfaceImpl_GetImplType,
- IWineD3DSurfaceImpl_DrawOverlay
-};
-
-static HRESULT ffp_blit_alloc(IWineD3DDevice *iface) { return WINED3D_OK; }
+static HRESULT ffp_blit_alloc(struct wined3d_device *device) { return WINED3D_OK; }
/* Context activation is done by the caller. */
-static void ffp_blit_free(IWineD3DDevice *iface) { }
+static void ffp_blit_free(struct wined3d_device *device) { }
/* This function is used in case of 8bit paletted textures using GL_EXT_paletted_texture */
/* Context activation is done by the caller. */
-static void ffp_blit_p8_upload_palette(IWineD3DSurfaceImpl *surface, const struct wined3d_gl_info *gl_info)
+static void ffp_blit_p8_upload_palette(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info)
{
BYTE table[256][4];
BOOL colorkey_active = (surface->CKeyFlags & WINEDDSD_CKSRCBLT) ? TRUE : FALSE;
@@ -4785,10 +6233,8 @@ static void ffp_blit_p8_upload_palette(IWineD3DSurfaceImpl *surface, const struc
}
/* Context activation is done by the caller. */
-static HRESULT ffp_blit_set(IWineD3DDevice *iface, IWineD3DSurfaceImpl *surface)
+static HRESULT ffp_blit_set(void *blit_priv, const struct wined3d_gl_info *gl_info, struct wined3d_surface *surface)
{
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) iface;
- const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
enum complex_fixup fixup = get_complex_fixup(surface->resource.format->color_fixup);
/* When EXT_PALETTED_TEXTURE is around, palette conversion is done by the GPU
@@ -4805,11 +6251,8 @@ static HRESULT ffp_blit_set(IWineD3DDevice *iface, IWineD3DSurfaceImpl *surface)
}
/* Context activation is done by the caller. */
-static void ffp_blit_unset(IWineD3DDevice *iface)
+static void ffp_blit_unset(const struct wined3d_gl_info *gl_info)
{
- IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) iface;
- const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
-
ENTER_GL();
glDisable(GL_TEXTURE_2D);
checkGLcall("glDisable(GL_TEXTURE_2D)");
@@ -4826,67 +6269,80 @@ static void ffp_blit_unset(IWineD3DDevice *iface)
LEAVE_GL();
}
-static BOOL ffp_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
+static BOOL ffp_blit_supported(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)
{
enum complex_fixup src_fixup;
- if (blit_op == BLIT_OP_COLOR_FILL)
+ switch (blit_op)
{
- if (!(dst_usage & WINED3DUSAGE_RENDERTARGET))
- {
- TRACE("Color fill not supported\n");
+ case WINED3D_BLIT_OP_COLOR_BLIT:
+ src_fixup = get_complex_fixup(src_format->color_fixup);
+ if (TRACE_ON(d3d_surface) && TRACE_ON(d3d))
+ {
+ TRACE("Checking support for fixup:\n");
+ dump_color_fixup_desc(src_format->color_fixup);
+ }
+
+ if (!is_identity_fixup(dst_format->color_fixup))
+ {
+ TRACE("Destination fixups are not supported\n");
+ return FALSE;
+ }
+
+ if (src_fixup == COMPLEX_FIXUP_P8 && gl_info->supported[EXT_PALETTED_TEXTURE])
+ {
+ TRACE("P8 fixup supported\n");
+ return TRUE;
+ }
+
+ /* We only support identity conversions. */
+ if (is_identity_fixup(src_format->color_fixup))
+ {
+ TRACE("[OK]\n");
+ return TRUE;
+ }
+
+ TRACE("[FAILED]\n");
return FALSE;
- }
- return TRUE;
+ case WINED3D_BLIT_OP_COLOR_FILL:
+ if (!(dst_usage & WINED3DUSAGE_RENDERTARGET))
+ {
+ TRACE("Color fill not supported\n");
+ return FALSE;
+ }
+
+ return TRUE;
+
+ case WINED3D_BLIT_OP_DEPTH_FILL:
+ return TRUE;
+
+ default:
+ TRACE("Unsupported blit_op=%d\n", blit_op);
+ return FALSE;
}
-
- src_fixup = get_complex_fixup(src_format->color_fixup);
- if (TRACE_ON(d3d_surface) && TRACE_ON(d3d))
- {
- TRACE("Checking support for fixup:\n");
- dump_color_fixup_desc(src_format->color_fixup);
- }
-
- if (blit_op != BLIT_OP_BLIT)
- {
- TRACE("Unsupported blit_op=%d\n", blit_op);
- return FALSE;
- }
-
- if (!is_identity_fixup(dst_format->color_fixup))
- {
- TRACE("Destination fixups are not supported\n");
- return FALSE;
- }
-
- if (src_fixup == COMPLEX_FIXUP_P8 && gl_info->supported[EXT_PALETTED_TEXTURE])
- {
- TRACE("P8 fixup supported\n");
- return TRUE;
- }
-
- /* We only support identity conversions. */
- if (is_identity_fixup(src_format->color_fixup))
- {
- TRACE("[OK]\n");
- return TRUE;
- }
-
- TRACE("[FAILED]\n");
- return FALSE;
}
/* Do not call while under the GL lock. */
-static HRESULT ffp_blit_color_fill(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface,
+static HRESULT ffp_blit_color_fill(struct wined3d_device *device, struct wined3d_surface *dst_surface,
const RECT *dst_rect, const WINED3DCOLORVALUE *color)
{
- const RECT draw_rect = {0, 0, dst_surface->currentDesc.Width, dst_surface->currentDesc.Height};
+ const RECT draw_rect = {0, 0, dst_surface->resource.width, dst_surface->resource.height};
- return device_clear_render_targets(device, 1 /* rt_count */, &dst_surface, 1 /* rect_count */,
- dst_rect, &draw_rect, WINED3DCLEAR_TARGET, color, 0.0f /* depth */, 0 /* stencil */);
+ return device_clear_render_targets(device, 1, &dst_surface, NULL,
+ 1, dst_rect, &draw_rect, WINED3DCLEAR_TARGET, color, 0.0f, 0);
+}
+
+/* Do not call while under the GL lock. */
+static HRESULT ffp_blit_depth_fill(struct wined3d_device *device,
+ struct wined3d_surface *surface, const RECT *rect, float depth)
+{
+ const RECT draw_rect = {0, 0, surface->resource.width, surface->resource.height};
+
+ return device_clear_render_targets(device, 0, NULL, surface,
+ 1, rect, &draw_rect, WINED3DCLEAR_ZBUFFER, 0, depth, 0);
}
const struct blit_shader ffp_blit = {
@@ -4895,35 +6351,36 @@ const struct blit_shader ffp_blit = {
ffp_blit_set,
ffp_blit_unset,
ffp_blit_supported,
- ffp_blit_color_fill
+ ffp_blit_color_fill,
+ ffp_blit_depth_fill,
};
-static HRESULT cpu_blit_alloc(IWineD3DDevice *iface)
+static HRESULT cpu_blit_alloc(struct wined3d_device *device)
{
return WINED3D_OK;
}
/* Context activation is done by the caller. */
-static void cpu_blit_free(IWineD3DDevice *iface)
+static void cpu_blit_free(struct wined3d_device *device)
{
}
/* Context activation is done by the caller. */
-static HRESULT cpu_blit_set(IWineD3DDevice *iface, IWineD3DSurfaceImpl *surface)
+static HRESULT cpu_blit_set(void *blit_priv, const struct wined3d_gl_info *gl_info, struct wined3d_surface *surface)
{
return WINED3D_OK;
}
/* Context activation is done by the caller. */
-static void cpu_blit_unset(IWineD3DDevice *iface)
+static void cpu_blit_unset(const struct wined3d_gl_info *gl_info)
{
}
-static BOOL cpu_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
+static BOOL cpu_blit_supported(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)
{
- if (blit_op == BLIT_OP_COLOR_FILL)
+ if (blit_op == WINED3D_BLIT_OP_COLOR_FILL)
{
return TRUE;
}
@@ -4931,8 +6388,915 @@ static BOOL cpu_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_
return FALSE;
}
+static HRESULT surface_cpu_blt(struct wined3d_surface *dst_surface, const RECT *dst_rect,
+ struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
+ const WINEDDBLTFX *fx, WINED3DTEXTUREFILTERTYPE filter)
+{
+ int bpp, srcheight, srcwidth, dstheight, dstwidth, width;
+ const struct wined3d_format *src_format, *dst_format;
+ struct wined3d_surface *orig_src = src_surface;
+ WINED3DLOCKED_RECT dlock, slock;
+ HRESULT hr = WINED3D_OK;
+ const BYTE *sbuf;
+ RECT xdst,xsrc;
+ BYTE *dbuf;
+ int x, y;
+
+ TRACE("dst_surface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p, filter %s.\n",
+ dst_surface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect),
+ flags, fx, debug_d3dtexturefiltertype(filter));
+
+ if ((dst_surface->flags & SFLAG_LOCKED) || (src_surface && (src_surface->flags & SFLAG_LOCKED)))
+ {
+ WARN("Surface is busy, returning WINEDDERR_SURFACEBUSY\n");
+ return WINEDDERR_SURFACEBUSY;
+ }
+
+ /* First check for the validity of source / destination rectangles.
+ * This was verified using a test application and by MSDN. */
+ if (src_rect)
+ {
+ if (src_surface)
+ {
+ if (src_rect->right < src_rect->left || src_rect->bottom < src_rect->top
+ || src_rect->left > src_surface->resource.width || src_rect->left < 0
+ || src_rect->top > src_surface->resource.height || src_rect->top < 0
+ || src_rect->right > src_surface->resource.width || src_rect->right < 0
+ || src_rect->bottom > src_surface->resource.height || src_rect->bottom < 0)
+ {
+ WARN("Application gave us bad source rectangle for Blt.\n");
+ return WINEDDERR_INVALIDRECT;
+ }
+
+ if (!src_rect->right || !src_rect->bottom
+ || src_rect->left == (int)src_surface->resource.width
+ || src_rect->top == (int)src_surface->resource.height)
+ {
+ TRACE("Nothing to be done.\n");
+ return WINED3D_OK;
+ }
+ }
+
+ xsrc = *src_rect;
+ }
+ else if (src_surface)
+ {
+ xsrc.left = 0;
+ xsrc.top = 0;
+ xsrc.right = src_surface->resource.width;
+ xsrc.bottom = src_surface->resource.height;
+ }
+ else
+ {
+ memset(&xsrc, 0, sizeof(xsrc));
+ }
+
+ if (dst_rect)
+ {
+ /* For the Destination rect, it can be out of bounds on the condition
+ * that a clipper is set for the given surface. */
+ if (!dst_surface->clipper && (dst_rect->right < dst_rect->left || dst_rect->bottom < dst_rect->top
+ || dst_rect->left > dst_surface->resource.width || dst_rect->left < 0
+ || dst_rect->top > dst_surface->resource.height || dst_rect->top < 0
+ || dst_rect->right > dst_surface->resource.width || dst_rect->right < 0
+ || dst_rect->bottom > dst_surface->resource.height || dst_rect->bottom < 0))
+ {
+ WARN("Application gave us bad destination rectangle for Blt without a clipper set.\n");
+ return WINEDDERR_INVALIDRECT;
+ }
+
+ if (dst_rect->right <= 0 || dst_rect->bottom <= 0
+ || dst_rect->left >= (int)dst_surface->resource.width
+ || dst_rect->top >= (int)dst_surface->resource.height)
+ {
+ TRACE("Nothing to be done.\n");
+ return WINED3D_OK;
+ }
+
+ if (!src_surface)
+ {
+ RECT full_rect;
+
+ full_rect.left = 0;
+ full_rect.top = 0;
+ full_rect.right = dst_surface->resource.width;
+ full_rect.bottom = dst_surface->resource.height;
+ IntersectRect(&xdst, &full_rect, dst_rect);
+ }
+ else
+ {
+ BOOL clip_horiz, clip_vert;
+
+ xdst = *dst_rect;
+ clip_horiz = xdst.left < 0 || xdst.right > (int)dst_surface->resource.width;
+ clip_vert = xdst.top < 0 || xdst.bottom > (int)dst_surface->resource.height;
+
+ if (clip_vert || clip_horiz)
+ {
+ /* Now check if this is a special case or not... */
+ if ((flags & WINEDDBLT_DDFX)
+ || (clip_horiz && xdst.right - xdst.left != xsrc.right - xsrc.left)
+ || (clip_vert && xdst.bottom - xdst.top != xsrc.bottom - xsrc.top))
+ {
+ WARN("Out of screen rectangle in special case. Not handled right now.\n");
+ return WINED3D_OK;
+ }
+
+ if (clip_horiz)
+ {
+ if (xdst.left < 0)
+ {
+ xsrc.left -= xdst.left;
+ xdst.left = 0;
+ }
+ if (xdst.right > dst_surface->resource.width)
+ {
+ xsrc.right -= (xdst.right - (int)dst_surface->resource.width);
+ xdst.right = (int)dst_surface->resource.width;
+ }
+ }
+
+ if (clip_vert)
+ {
+ if (xdst.top < 0)
+ {
+ xsrc.top -= xdst.top;
+ xdst.top = 0;
+ }
+ if (xdst.bottom > dst_surface->resource.height)
+ {
+ xsrc.bottom -= (xdst.bottom - (int)dst_surface->resource.height);
+ xdst.bottom = (int)dst_surface->resource.height;
+ }
+ }
+
+ /* And check if after clipping something is still to be done... */
+ if ((xdst.right <= 0) || (xdst.bottom <= 0)
+ || (xdst.left >= (int)dst_surface->resource.width)
+ || (xdst.top >= (int)dst_surface->resource.height)
+ || (xsrc.right <= 0) || (xsrc.bottom <= 0)
+ || (xsrc.left >= (int)src_surface->resource.width)
+ || (xsrc.top >= (int)src_surface->resource.height))
+ {
+ TRACE("Nothing to be done after clipping.\n");
+ return WINED3D_OK;
+ }
+ }
+ }
+ }
+ else
+ {
+ xdst.left = 0;
+ xdst.top = 0;
+ xdst.right = dst_surface->resource.width;
+ xdst.bottom = dst_surface->resource.height;
+ }
+
+ if (src_surface == dst_surface)
+ {
+ wined3d_surface_map(dst_surface, &dlock, NULL, 0);
+ slock = dlock;
+ src_format = dst_surface->resource.format;
+ dst_format = src_format;
+ }
+ else
+ {
+ dst_format = dst_surface->resource.format;
+ if (src_surface)
+ {
+ if (dst_surface->resource.format->id != src_surface->resource.format->id)
+ {
+ src_surface = surface_convert_format(src_surface, dst_format->id);
+ if (!src_surface)
+ {
+ /* The conv function writes a FIXME */
+ WARN("Cannot convert source surface format to dest format.\n");
+ goto release;
+ }
+ }
+ wined3d_surface_map(src_surface, &slock, NULL, WINED3DLOCK_READONLY);
+ src_format = src_surface->resource.format;
+ }
+ else
+ {
+ src_format = dst_format;
+ }
+ if (dst_rect)
+ wined3d_surface_map(dst_surface, &dlock, &xdst, 0);
+ else
+ wined3d_surface_map(dst_surface, &dlock, NULL, 0);
+ }
+
+ if (!fx || !(fx->dwDDFX)) flags &= ~WINEDDBLT_DDFX;
+
+ if (src_format->flags & dst_format->flags & WINED3DFMT_FLAG_FOURCC)
+ {
+ if (!dst_rect || src_surface == dst_surface)
+ {
+ memcpy(dlock.pBits, slock.pBits, dst_surface->resource.size);
+ goto release;
+ }
+ }
+
+ bpp = dst_surface->resource.format->byte_count;
+ srcheight = xsrc.bottom - xsrc.top;
+ srcwidth = xsrc.right - xsrc.left;
+ dstheight = xdst.bottom - xdst.top;
+ dstwidth = xdst.right - xdst.left;
+ width = (xdst.right - xdst.left) * bpp;
+
+ if (dst_rect && src_surface != dst_surface)
+ dbuf = dlock.pBits;
+ else
+ dbuf = (BYTE*)dlock.pBits+(xdst.top*dlock.Pitch)+(xdst.left*bpp);
+
+ if (flags & WINEDDBLT_WAIT)
+ {
+ flags &= ~WINEDDBLT_WAIT;
+ }
+ if (flags & WINEDDBLT_ASYNC)
+ {
+ static BOOL displayed = FALSE;
+ if (!displayed)
+ FIXME("Can't handle WINEDDBLT_ASYNC flag right now.\n");
+ displayed = TRUE;
+ flags &= ~WINEDDBLT_ASYNC;
+ }
+ if (flags & WINEDDBLT_DONOTWAIT)
+ {
+ /* WINEDDBLT_DONOTWAIT appeared in DX7 */
+ static BOOL displayed = FALSE;
+ if (!displayed)
+ FIXME("Can't handle WINEDDBLT_DONOTWAIT flag right now.\n");
+ displayed = TRUE;
+ flags &= ~WINEDDBLT_DONOTWAIT;
+ }
+
+ /* First, all the 'source-less' blits */
+ if (flags & WINEDDBLT_COLORFILL)
+ {
+ hr = _Blt_ColorFill(dbuf, dstwidth, dstheight, bpp, dlock.Pitch, fx->u5.dwFillColor);
+ flags &= ~WINEDDBLT_COLORFILL;
+ }
+
+ if (flags & WINEDDBLT_DEPTHFILL)
+ {
+ FIXME("DDBLT_DEPTHFILL needs to be implemented!\n");
+ }
+ if (flags & WINEDDBLT_ROP)
+ {
+ /* Catch some degenerate cases here. */
+ switch (fx->dwROP)
+ {
+ case BLACKNESS:
+ hr = _Blt_ColorFill(dbuf,dstwidth,dstheight,bpp,dlock.Pitch,0);
+ break;
+ case 0xAA0029: /* No-op */
+ break;
+ case WHITENESS:
+ hr = _Blt_ColorFill(dbuf,dstwidth,dstheight,bpp,dlock.Pitch,~0);
+ break;
+ case SRCCOPY: /* Well, we do that below? */
+ break;
+ default:
+ FIXME("Unsupported raster op: %08x Pattern: %p\n", fx->dwROP, fx->u5.lpDDSPattern);
+ goto error;
+ }
+ flags &= ~WINEDDBLT_ROP;
+ }
+ if (flags & WINEDDBLT_DDROPS)
+ {
+ FIXME("\tDdraw Raster Ops: %08x Pattern: %p\n", fx->dwDDROP, fx->u5.lpDDSPattern);
+ }
+ /* Now the 'with source' blits. */
+ if (src_surface)
+ {
+ const BYTE *sbase;
+ int sx, xinc, sy, yinc;
+
+ if (!dstwidth || !dstheight) /* Hmm... stupid program? */
+ goto release;
+
+ if (filter != WINED3DTEXF_NONE && filter != WINED3DTEXF_POINT
+ && (srcwidth != dstwidth || srcheight != dstheight))
+ {
+ /* Can happen when d3d9 apps do a StretchRect() call which isn't handled in GL. */
+ FIXME("Filter %s not supported in software blit.\n", debug_d3dtexturefiltertype(filter));
+ }
+
+ sbase = (BYTE*)slock.pBits+(xsrc.top*slock.Pitch)+xsrc.left*bpp;
+ xinc = (srcwidth << 16) / dstwidth;
+ yinc = (srcheight << 16) / dstheight;
+
+ if (!flags)
+ {
+ /* No effects, we can cheat here. */
+ if (dstwidth == srcwidth)
+ {
+ if (dstheight == srcheight)
+ {
+ /* No stretching in either direction. This needs to be as
+ * fast as possible. */
+ sbuf = sbase;
+
+ /* Check for overlapping surfaces. */
+ if (src_surface != dst_surface || xdst.top < xsrc.top
+ || xdst.right <= xsrc.left || xsrc.right <= xdst.left)
+ {
+ /* No overlap, or dst above src, so copy from top downwards. */
+ for (y = 0; y < dstheight; ++y)
+ {
+ memcpy(dbuf, sbuf, width);
+ sbuf += slock.Pitch;
+ dbuf += dlock.Pitch;
+ }
+ }
+ else if (xdst.top > xsrc.top)
+ {
+ /* Copy from bottom upwards. */
+ sbuf += (slock.Pitch*dstheight);
+ dbuf += (dlock.Pitch*dstheight);
+ for (y = 0; y < dstheight; ++y)
+ {
+ sbuf -= slock.Pitch;
+ dbuf -= dlock.Pitch;
+ memcpy(dbuf, sbuf, width);
+ }
+ }
+ else
+ {
+ /* Src and dst overlapping on the same line, use memmove. */
+ for (y = 0; y < dstheight; ++y)
+ {
+ memmove(dbuf, sbuf, width);
+ sbuf += slock.Pitch;
+ dbuf += dlock.Pitch;
+ }
+ }
+ }
+ else
+ {
+ /* Stretching in y direction only. */
+ for (y = sy = 0; y < dstheight; ++y, sy += yinc)
+ {
+ sbuf = sbase + (sy >> 16) * slock.Pitch;
+ memcpy(dbuf, sbuf, width);
+ dbuf += dlock.Pitch;
+ }
+ }
+ }
+ else
+ {
+ /* Stretching in X direction. */
+ int last_sy = -1;
+ for (y = sy = 0; y < dstheight; ++y, sy += yinc)
+ {
+ sbuf = sbase + (sy >> 16) * slock.Pitch;
+
+ if ((sy >> 16) == (last_sy >> 16))
+ {
+ /* This source row is the same as last source row -
+ * Copy the already stretched row. */
+ memcpy(dbuf, dbuf - dlock.Pitch, width);
+ }
+ else
+ {
+#define STRETCH_ROW(type) \
+do { \
+ const type *s = (const type *)sbuf; \
+ type *d = (type *)dbuf; \
+ for (x = sx = 0; x < dstwidth; ++x, sx += xinc) \
+ d[x] = s[sx >> 16]; \
+} while(0)
+
+ switch(bpp)
+ {
+ case 1:
+ STRETCH_ROW(BYTE);
+ break;
+ case 2:
+ STRETCH_ROW(WORD);
+ break;
+ case 4:
+ STRETCH_ROW(DWORD);
+ break;
+ case 3:
+ {
+ const BYTE *s;
+ BYTE *d = dbuf;
+ for (x = sx = 0; x < dstwidth; x++, sx+= xinc)
+ {
+ DWORD pixel;
+
+ s = sbuf + 3 * (sx >> 16);
+ pixel = s[0] | (s[1] << 8) | (s[2] << 16);
+ d[0] = (pixel ) & 0xff;
+ d[1] = (pixel >> 8) & 0xff;
+ d[2] = (pixel >> 16) & 0xff;
+ d += 3;
+ }
+ break;
+ }
+ default:
+ FIXME("Stretched blit not implemented for bpp %u!\n", bpp * 8);
+ hr = WINED3DERR_NOTAVAILABLE;
+ goto error;
+ }
+#undef STRETCH_ROW
+ }
+ dbuf += dlock.Pitch;
+ last_sy = sy;
+ }
+ }
+ }
+ else
+ {
+ LONG dstyinc = dlock.Pitch, dstxinc = bpp;
+ DWORD keylow = 0xFFFFFFFF, keyhigh = 0, keymask = 0xFFFFFFFF;
+ DWORD destkeylow = 0x0, destkeyhigh = 0xFFFFFFFF, destkeymask = 0xFFFFFFFF;
+ if (flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYDEST | WINEDDBLT_KEYSRCOVERRIDE | WINEDDBLT_KEYDESTOVERRIDE))
+ {
+ /* The color keying flags are checked for correctness in ddraw */
+ if (flags & WINEDDBLT_KEYSRC)
+ {
+ keylow = src_surface->SrcBltCKey.dwColorSpaceLowValue;
+ keyhigh = src_surface->SrcBltCKey.dwColorSpaceHighValue;
+ }
+ else if (flags & WINEDDBLT_KEYSRCOVERRIDE)
+ {
+ keylow = fx->ddckSrcColorkey.dwColorSpaceLowValue;
+ keyhigh = fx->ddckSrcColorkey.dwColorSpaceHighValue;
+ }
+
+ if (flags & WINEDDBLT_KEYDEST)
+ {
+ /* Destination color keys are taken from the source surface! */
+ destkeylow = src_surface->DestBltCKey.dwColorSpaceLowValue;
+ destkeyhigh = src_surface->DestBltCKey.dwColorSpaceHighValue;
+ }
+ else if (flags & WINEDDBLT_KEYDESTOVERRIDE)
+ {
+ destkeylow = fx->ddckDestColorkey.dwColorSpaceLowValue;
+ destkeyhigh = fx->ddckDestColorkey.dwColorSpaceHighValue;
+ }
+
+ if (bpp == 1)
+ {
+ keymask = 0xff;
+ }
+ else
+ {
+ keymask = src_format->red_mask
+ | src_format->green_mask
+ | src_format->blue_mask;
+ }
+ flags &= ~(WINEDDBLT_KEYSRC | WINEDDBLT_KEYDEST | WINEDDBLT_KEYSRCOVERRIDE | WINEDDBLT_KEYDESTOVERRIDE);
+ }
+
+ if (flags & WINEDDBLT_DDFX)
+ {
+ BYTE *dTopLeft, *dTopRight, *dBottomLeft, *dBottomRight, *tmp;
+ LONG tmpxy;
+ dTopLeft = dbuf;
+ dTopRight = dbuf + ((dstwidth - 1) * bpp);
+ dBottomLeft = dTopLeft + ((dstheight - 1) * dlock.Pitch);
+ dBottomRight = dBottomLeft + ((dstwidth - 1) * bpp);
+
+ if (fx->dwDDFX & WINEDDBLTFX_ARITHSTRETCHY)
+ {
+ /* I don't think we need to do anything about this flag */
+ WARN("flags=DDBLT_DDFX nothing done for WINEDDBLTFX_ARITHSTRETCHY\n");
+ }
+ if (fx->dwDDFX & WINEDDBLTFX_MIRRORLEFTRIGHT)
+ {
+ tmp = dTopRight;
+ dTopRight = dTopLeft;
+ dTopLeft = tmp;
+ tmp = dBottomRight;
+ dBottomRight = dBottomLeft;
+ dBottomLeft = tmp;
+ dstxinc = dstxinc * -1;
+ }
+ if (fx->dwDDFX & WINEDDBLTFX_MIRRORUPDOWN)
+ {
+ tmp = dTopLeft;
+ dTopLeft = dBottomLeft;
+ dBottomLeft = tmp;
+ tmp = dTopRight;
+ dTopRight = dBottomRight;
+ dBottomRight = tmp;
+ dstyinc = dstyinc * -1;
+ }
+ if (fx->dwDDFX & WINEDDBLTFX_NOTEARING)
+ {
+ /* I don't think we need to do anything about this flag */
+ WARN("flags=DDBLT_DDFX nothing done for WINEDDBLTFX_NOTEARING\n");
+ }
+ if (fx->dwDDFX & WINEDDBLTFX_ROTATE180)
+ {
+ tmp = dBottomRight;
+ dBottomRight = dTopLeft;
+ dTopLeft = tmp;
+ tmp = dBottomLeft;
+ dBottomLeft = dTopRight;
+ dTopRight = tmp;
+ dstxinc = dstxinc * -1;
+ dstyinc = dstyinc * -1;
+ }
+ if (fx->dwDDFX & WINEDDBLTFX_ROTATE270)
+ {
+ tmp = dTopLeft;
+ dTopLeft = dBottomLeft;
+ dBottomLeft = dBottomRight;
+ dBottomRight = dTopRight;
+ dTopRight = tmp;
+ tmpxy = dstxinc;
+ dstxinc = dstyinc;
+ dstyinc = tmpxy;
+ dstxinc = dstxinc * -1;
+ }
+ if (fx->dwDDFX & WINEDDBLTFX_ROTATE90)
+ {
+ tmp = dTopLeft;
+ dTopLeft = dTopRight;
+ dTopRight = dBottomRight;
+ dBottomRight = dBottomLeft;
+ dBottomLeft = tmp;
+ tmpxy = dstxinc;
+ dstxinc = dstyinc;
+ dstyinc = tmpxy;
+ dstyinc = dstyinc * -1;
+ }
+ if (fx->dwDDFX & WINEDDBLTFX_ZBUFFERBASEDEST)
+ {
+ /* I don't think we need to do anything about this flag */
+ WARN("flags=WINEDDBLT_DDFX nothing done for WINEDDBLTFX_ZBUFFERBASEDEST\n");
+ }
+ dbuf = dTopLeft;
+ flags &= ~(WINEDDBLT_DDFX);
+ }
+
+#define COPY_COLORKEY_FX(type) \
+do { \
+ const type *s; \
+ type *d = (type *)dbuf, *dx, tmp; \
+ for (y = sy = 0; y < dstheight; ++y, sy += yinc) \
+ { \
+ s = (const type *)(sbase + (sy >> 16) * slock.Pitch); \
+ dx = d; \
+ for (x = sx = 0; x < dstwidth; ++x, sx += xinc) \
+ { \
+ tmp = s[sx >> 16]; \
+ if (((tmp & keymask) < keylow || (tmp & keymask) > keyhigh) \
+ && ((dx[0] & destkeymask) >= destkeylow && (dx[0] & destkeymask) <= destkeyhigh)) \
+ { \
+ dx[0] = tmp; \
+ } \
+ dx = (type *)(((BYTE *)dx) + dstxinc); \
+ } \
+ d = (type *)(((BYTE *)d) + dstyinc); \
+ } \
+} while(0)
+
+ switch (bpp)
+ {
+ case 1:
+ COPY_COLORKEY_FX(BYTE);
+ break;
+ case 2:
+ COPY_COLORKEY_FX(WORD);
+ break;
+ case 4:
+ COPY_COLORKEY_FX(DWORD);
+ break;
+ case 3:
+ {
+ const BYTE *s;
+ BYTE *d = dbuf, *dx;
+ for (y = sy = 0; y < dstheight; ++y, sy += yinc)
+ {
+ sbuf = sbase + (sy >> 16) * slock.Pitch;
+ dx = d;
+ for (x = sx = 0; x < dstwidth; ++x, sx+= xinc)
+ {
+ DWORD pixel, dpixel = 0;
+ s = sbuf + 3 * (sx>>16);
+ pixel = s[0] | (s[1] << 8) | (s[2] << 16);
+ dpixel = dx[0] | (dx[1] << 8 ) | (dx[2] << 16);
+ if (((pixel & keymask) < keylow || (pixel & keymask) > keyhigh)
+ && ((dpixel & keymask) >= destkeylow || (dpixel & keymask) <= keyhigh))
+ {
+ dx[0] = (pixel ) & 0xff;
+ dx[1] = (pixel >> 8) & 0xff;
+ dx[2] = (pixel >> 16) & 0xff;
+ }
+ dx += dstxinc;
+ }
+ d += dstyinc;
+ }
+ break;
+ }
+ default:
+ FIXME("%s color-keyed blit not implemented for bpp %u!\n",
+ (flags & WINEDDBLT_KEYSRC) ? "Source" : "Destination", bpp * 8);
+ hr = WINED3DERR_NOTAVAILABLE;
+ goto error;
+#undef COPY_COLORKEY_FX
+ }
+ }
+ }
+
+error:
+ if (flags && FIXME_ON(d3d_surface))
+ {
+ FIXME("\tUnsupported flags: %#x.\n", flags);
+ }
+
+release:
+ wined3d_surface_unmap(dst_surface);
+ if (src_surface && src_surface != dst_surface)
+ wined3d_surface_unmap(src_surface);
+ /* Release the converted surface, if any. */
+ if (src_surface && src_surface != orig_src)
+ wined3d_surface_decref(src_surface);
+
+ return hr;
+}
+
+static HRESULT surface_cpu_bltfast(struct wined3d_surface *dst_surface, DWORD dst_x, DWORD dst_y,
+ struct wined3d_surface *src_surface, const RECT *src_rect, DWORD trans)
+{
+ const struct wined3d_format *src_format, *dst_format;
+ RECT lock_src, lock_dst, lock_union;
+ WINED3DLOCKED_RECT dlock, slock;
+ HRESULT hr = WINED3D_OK;
+ int bpp, w, h, x, y;
+ const BYTE *sbuf;
+ BYTE *dbuf;
+ RECT rsrc2;
+
+ TRACE("dst_surface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, flags %#x.\n",
+ dst_surface, dst_x, dst_y, src_surface, wine_dbgstr_rect(src_rect), trans);
+
+ if ((dst_surface->flags & SFLAG_LOCKED) || (src_surface->flags & SFLAG_LOCKED))
+ {
+ WARN(" Surface is busy, returning DDERR_SURFACEBUSY\n");
+ return WINEDDERR_SURFACEBUSY;
+ }
+
+ if (!src_rect)
+ {
+ WARN("src_rect is NULL!\n");
+ rsrc2.left = 0;
+ rsrc2.top = 0;
+ rsrc2.right = src_surface->resource.width;
+ rsrc2.bottom = src_surface->resource.height;
+ src_rect = &rsrc2;
+ }
+
+ /* Check source rect for validity. Copied from normal Blt. Fixes Baldur's Gate. */
+ if ((src_rect->bottom > src_surface->resource.height) || (src_rect->bottom < 0)
+ || (src_rect->top > src_surface->resource.height) || (src_rect->top < 0)
+ || (src_rect->left > src_surface->resource.width) || (src_rect->left < 0)
+ || (src_rect->right > src_surface->resource.width) || (src_rect->right < 0)
+ || (src_rect->right < src_rect->left) || (src_rect->bottom < src_rect->top))
+ {
+ WARN("Application gave us bad source rectangle for BltFast.\n");
+ return WINEDDERR_INVALIDRECT;
+ }
+
+ h = src_rect->bottom - src_rect->top;
+ if (h > dst_surface->resource.height - dst_y)
+ h = dst_surface->resource.height - dst_y;
+ if (h > src_surface->resource.height - src_rect->top)
+ h = src_surface->resource.height - src_rect->top;
+ if (h <= 0)
+ return WINEDDERR_INVALIDRECT;
+
+ w = src_rect->right - src_rect->left;
+ if (w > dst_surface->resource.width - dst_x)
+ w = dst_surface->resource.width - dst_x;
+ if (w > src_surface->resource.width - src_rect->left)
+ w = src_surface->resource.width - src_rect->left;
+ if (w <= 0)
+ return WINEDDERR_INVALIDRECT;
+
+ /* Now compute the locking rectangle... */
+ lock_src.left = src_rect->left;
+ lock_src.top = src_rect->top;
+ lock_src.right = lock_src.left + w;
+ lock_src.bottom = lock_src.top + h;
+
+ lock_dst.left = dst_x;
+ lock_dst.top = dst_y;
+ lock_dst.right = dst_x + w;
+ lock_dst.bottom = dst_y + h;
+
+ bpp = dst_surface->resource.format->byte_count;
+
+ /* We need to lock the surfaces, or we won't get refreshes when done. */
+ if (src_surface == dst_surface)
+ {
+ int pitch;
+
+ UnionRect(&lock_union, &lock_src, &lock_dst);
+
+ /* Lock the union of the two rectangles. */
+ hr = wined3d_surface_map(dst_surface, &dlock, &lock_union, 0);
+ if (FAILED(hr))
+ goto error;
+
+ pitch = dlock.Pitch;
+ slock.Pitch = dlock.Pitch;
+
+ /* Since slock was originally copied from this surface's description, we can just reuse it. */
+ sbuf = dst_surface->resource.allocatedMemory + lock_src.top * pitch + lock_src.left * bpp;
+ dbuf = dst_surface->resource.allocatedMemory + lock_dst.top * pitch + lock_dst.left * bpp;
+ src_format = src_surface->resource.format;
+ dst_format = src_format;
+ }
+ else
+ {
+ hr = wined3d_surface_map(src_surface, &slock, &lock_src, WINED3DLOCK_READONLY);
+ if (FAILED(hr))
+ goto error;
+ hr = wined3d_surface_map(dst_surface, &dlock, &lock_dst, 0);
+ if (FAILED(hr))
+ goto error;
+
+ sbuf = slock.pBits;
+ dbuf = dlock.pBits;
+ TRACE("Dst is at %p, Src is at %p.\n", dbuf, sbuf);
+
+ src_format = src_surface->resource.format;
+ dst_format = dst_surface->resource.format;
+ }
+
+ /* Handle compressed surfaces first... */
+ if (src_format->flags & dst_format->flags & WINED3DFMT_FLAG_COMPRESSED)
+ {
+ UINT row_block_count;
+
+ TRACE("compressed -> compressed copy\n");
+ if (trans)
+ FIXME("trans arg not supported when a compressed surface is involved\n");
+ if (dst_x || dst_y)
+ FIXME("offset for destination surface is not supported\n");
+ if (src_surface->resource.format->id != dst_surface->resource.format->id)
+ {
+ FIXME("compressed -> compressed copy only supported for the same type of surface\n");
+ hr = WINED3DERR_WRONGTEXTUREFORMAT;
+ goto error;
+ }
+
+ row_block_count = (w + dst_format->block_width - 1) / dst_format->block_width;
+ for (y = 0; y < h; y += dst_format->block_height)
+ {
+ memcpy(dbuf, sbuf, row_block_count * dst_format->block_byte_count);
+ dbuf += dlock.Pitch;
+ sbuf += slock.Pitch;
+ }
+
+ goto error;
+ }
+ if ((src_format->flags & WINED3DFMT_FLAG_COMPRESSED) && !(dst_format->flags & WINED3DFMT_FLAG_COMPRESSED))
+ {
+ /* TODO: Use the libtxc_dxtn.so shared library to do software
+ * decompression. */
+ ERR("Software decompression not supported.\n");
+ goto error;
+ }
+
+ if (trans & (WINEDDBLTFAST_SRCCOLORKEY | WINEDDBLTFAST_DESTCOLORKEY))
+ {
+ DWORD keylow, keyhigh;
+ DWORD mask = src_surface->resource.format->red_mask
+ | src_surface->resource.format->green_mask
+ | src_surface->resource.format->blue_mask;
+
+ /* For some 8-bit formats like L8 and P8 color masks don't make sense */
+ if (!mask && bpp == 1)
+ mask = 0xff;
+
+ TRACE("Color keyed copy.\n");
+ if (trans & WINEDDBLTFAST_SRCCOLORKEY)
+ {
+ keylow = src_surface->SrcBltCKey.dwColorSpaceLowValue;
+ keyhigh = src_surface->SrcBltCKey.dwColorSpaceHighValue;
+ }
+ else
+ {
+ /* I'm not sure if this is correct. */
+ FIXME("WINEDDBLTFAST_DESTCOLORKEY not fully supported yet.\n");
+ keylow = dst_surface->DestBltCKey.dwColorSpaceLowValue;
+ keyhigh = dst_surface->DestBltCKey.dwColorSpaceHighValue;
+ }
+
+#define COPYBOX_COLORKEY(type) \
+do { \
+ const type *s = (const type *)sbuf; \
+ type *d = (type *)dbuf; \
+ type tmp; \
+ for (y = 0; y < h; y++) \
+ { \
+ for (x = 0; x < w; x++) \
+ { \
+ tmp = s[x]; \
+ if ((tmp & mask) < keylow || (tmp & mask) > keyhigh) d[x] = tmp; \
+ } \
+ s = (const type *)((const BYTE *)s + slock.Pitch); \
+ d = (type *)((BYTE *)d + dlock.Pitch); \
+ } \
+} while(0)
+
+ switch (bpp)
+ {
+ case 1:
+ COPYBOX_COLORKEY(BYTE);
+ break;
+ case 2:
+ COPYBOX_COLORKEY(WORD);
+ break;
+ case 4:
+ COPYBOX_COLORKEY(DWORD);
+ break;
+ case 3:
+ {
+ const BYTE *s;
+ DWORD tmp;
+ BYTE *d;
+ s = sbuf;
+ d = dbuf;
+ for (y = 0; y < h; ++y)
+ {
+ for (x = 0; x < w * 3; x += 3)
+ {
+ tmp = (DWORD)s[x] + ((DWORD)s[x + 1] << 8) + ((DWORD)s[x + 2] << 16);
+ if (tmp < keylow || tmp > keyhigh)
+ {
+ d[x + 0] = s[x + 0];
+ d[x + 1] = s[x + 1];
+ d[x + 2] = s[x + 2];
+ }
+ }
+ s += slock.Pitch;
+ d += dlock.Pitch;
+ }
+ break;
+ }
+ default:
+ FIXME("Source color key blitting not supported for bpp %u.\n", bpp * 8);
+ hr = WINED3DERR_NOTAVAILABLE;
+ goto error;
+ }
+#undef COPYBOX_COLORKEY
+ TRACE("Copy done.\n");
+ }
+ else
+ {
+ int width = w * bpp;
+ INT sbufpitch, dbufpitch;
+
+ TRACE("No color key copy.\n");
+ /* Handle overlapping surfaces. */
+ if (sbuf < dbuf)
+ {
+ sbuf += (h - 1) * slock.Pitch;
+ dbuf += (h - 1) * dlock.Pitch;
+ sbufpitch = -slock.Pitch;
+ dbufpitch = -dlock.Pitch;
+ }
+ else
+ {
+ sbufpitch = slock.Pitch;
+ dbufpitch = dlock.Pitch;
+ }
+ for (y = 0; y < h; ++y)
+ {
+ /* This is pretty easy, a line for line memcpy. */
+ memmove(dbuf, sbuf, width);
+ sbuf += sbufpitch;
+ dbuf += dbufpitch;
+ }
+ TRACE("Copy done.\n");
+ }
+
+error:
+ if (src_surface == dst_surface)
+ {
+ wined3d_surface_unmap(dst_surface);
+ }
+ else
+ {
+ wined3d_surface_unmap(dst_surface);
+ wined3d_surface_unmap(src_surface);
+ }
+
+ return hr;
+}
+
/* Do not call while under the GL lock. */
-static HRESULT cpu_blit_color_fill(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface,
+static HRESULT cpu_blit_color_fill(struct wined3d_device *device, struct wined3d_surface *dst_surface,
const RECT *dst_rect, const WINED3DCOLORVALUE *color)
{
WINEDDBLTFX BltFx;
@@ -4940,8 +7304,16 @@ static HRESULT cpu_blit_color_fill(IWineD3DDeviceImpl *device, IWineD3DSurfaceIm
memset(&BltFx, 0, sizeof(BltFx));
BltFx.dwSize = sizeof(BltFx);
BltFx.u5.dwFillColor = wined3d_format_convert_from_float(dst_surface->resource.format, color);
- return IWineD3DBaseSurfaceImpl_Blt((IWineD3DSurface*)dst_surface, dst_rect,
- NULL, NULL, WINEDDBLT_COLORFILL, &BltFx, WINED3DTEXF_POINT);
+ return wined3d_surface_blt(dst_surface, dst_rect, NULL, NULL,
+ WINEDDBLT_COLORFILL, &BltFx, WINED3DTEXF_POINT);
+}
+
+/* Do not call while under the GL lock. */
+static HRESULT cpu_blit_depth_fill(struct wined3d_device *device,
+ struct wined3d_surface *surface, const RECT *rect, float depth)
+{
+ FIXME("Depth filling not implemented by cpu_blit.\n");
+ return WINED3DERR_INVALIDCALL;
}
const struct blit_shader cpu_blit = {
@@ -4950,38 +7322,175 @@ const struct blit_shader cpu_blit = {
cpu_blit_set,
cpu_blit_unset,
cpu_blit_supported,
- cpu_blit_color_fill
+ cpu_blit_color_fill,
+ cpu_blit_depth_fill,
};
-static BOOL fbo_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_operation 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)
+static HRESULT surface_init(struct wined3d_surface *surface, WINED3DSURFTYPE surface_type, UINT alignment,
+ UINT width, UINT height, UINT level, BOOL lockable, BOOL discard, WINED3DMULTISAMPLE_TYPE multisample_type,
+ UINT multisample_quality, struct wined3d_device *device, DWORD usage, enum wined3d_format_id format_id,
+ WINED3DPOOL pool, void *parent, const struct wined3d_parent_ops *parent_ops)
{
- if ((wined3d_settings.offscreen_rendering_mode != ORM_FBO) || !gl_info->fbo_ops.glBlitFramebuffer)
- return FALSE;
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+ const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
+ unsigned int resource_size;
+ HRESULT hr;
- /* We only support blitting. Things like color keying / color fill should
- * be handled by other blitters.
- */
- if (blit_op != BLIT_OP_BLIT)
- return FALSE;
+ if (multisample_quality > 0)
+ {
+ FIXME("multisample_quality set to %u, substituting 0.\n", multisample_quality);
+ multisample_quality = 0;
+ }
- /* Source and/or destination need to be on the GL side */
- if (src_pool == WINED3DPOOL_SYSTEMMEM || dst_pool == WINED3DPOOL_SYSTEMMEM)
- return FALSE;
+ /* Quick lockable sanity check.
+ * TODO: remove this after surfaces, usage and lockability have been debugged properly
+ * this function is too deep to need to care about things like this.
+ * Levels need to be checked too, since they all affect what can be done. */
+ switch (pool)
+ {
+ case WINED3DPOOL_SCRATCH:
+ if (!lockable)
+ {
+ FIXME("Called with a pool of SCRATCH and a lockable of FALSE "
+ "which are mutually exclusive, setting lockable to TRUE.\n");
+ lockable = TRUE;
+ }
+ break;
- if (!((src_format->Flags & WINED3DFMT_FLAG_FBO_ATTACHABLE) || (src_usage & WINED3DUSAGE_RENDERTARGET))
- && ((dst_format->Flags & WINED3DFMT_FLAG_FBO_ATTACHABLE) || (dst_usage & WINED3DUSAGE_RENDERTARGET)))
- return FALSE;
+ case WINED3DPOOL_SYSTEMMEM:
+ if (!lockable)
+ FIXME("Called with a pool of SYSTEMMEM and a lockable of FALSE, this is acceptable but unexpected.\n");
+ break;
- if (!is_identity_fixup(src_format->color_fixup)
- || !is_identity_fixup(dst_format->color_fixup))
- return FALSE;
+ case WINED3DPOOL_MANAGED:
+ if (usage & WINED3DUSAGE_DYNAMIC)
+ FIXME("Called with a pool of MANAGED and a usage of DYNAMIC which are mutually exclusive.\n");
+ break;
- if (!(src_format->id == dst_format->id
- || (is_identity_fixup(src_format->color_fixup)
- && is_identity_fixup(dst_format->color_fixup))))
- return FALSE;
+ case WINED3DPOOL_DEFAULT:
+ if (lockable && !(usage & (WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL)))
+ WARN("Creating a lockable surface with a POOL of DEFAULT, that doesn't specify DYNAMIC usage.\n");
+ break;
- return TRUE;
+ default:
+ FIXME("Unknown pool %#x.\n", pool);
+ break;
+ };
+
+ if (usage & WINED3DUSAGE_RENDERTARGET && pool != WINED3DPOOL_DEFAULT)
+ FIXME("Trying to create a render target that isn't in the default pool.\n");
+
+ /* FIXME: Check that the format is supported by the device. */
+
+ resource_size = wined3d_format_calculate_size(format, alignment, width, height);
+ if (!resource_size)
+ return WINED3DERR_INVALIDCALL;
+
+ surface->surface_type = surface_type;
+
+ switch (surface_type)
+ {
+ case SURFACE_OPENGL:
+ surface->surface_ops = &surface_ops;
+ break;
+
+ case SURFACE_GDI:
+ surface->surface_ops = &gdi_surface_ops;
+ break;
+
+ default:
+ ERR("Requested unknown surface implementation %#x.\n", surface_type);
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ hr = resource_init(&surface->resource, device, WINED3DRTYPE_SURFACE, format,
+ multisample_type, multisample_quality, usage, pool, width, height, 1,
+ resource_size, parent, parent_ops, &surface_resource_ops);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize resource, returning %#x.\n", hr);
+ return hr;
+ }
+
+ /* "Standalone" surface. */
+ surface_set_container(surface, WINED3D_CONTAINER_NONE, NULL);
+
+ surface->texture_level = level;
+ list_init(&surface->overlays);
+
+ /* Flags */
+ surface->flags = SFLAG_NORMCOORD; /* Default to normalized coords. */
+ if (discard)
+ surface->flags |= SFLAG_DISCARD;
+ if (lockable || format_id == WINED3DFMT_D16_LOCKABLE)
+ surface->flags |= SFLAG_LOCKABLE;
+ /* I'm not sure if this qualifies as a hack or as an optimization. It
+ * seems reasonable to assume that lockable render targets will get
+ * locked, so we might as well set SFLAG_DYNLOCK right at surface
+ * creation. However, the other reason we want to do this is that several
+ * ddraw applications access surface memory while the surface isn't
+ * mapped. The SFLAG_DYNLOCK behaviour of keeping SYSMEM around for
+ * future locks prevents these from crashing. */
+ if (lockable && (usage & WINED3DUSAGE_RENDERTARGET))
+ surface->flags |= SFLAG_DYNLOCK;
+
+ /* Mark the texture as dirty so that it gets loaded first time around. */
+ surface_add_dirty_rect(surface, NULL);
+ list_init(&surface->renderbuffers);
+
+ TRACE("surface %p, memory %p, size %u\n",
+ surface, surface->resource.allocatedMemory, surface->resource.size);
+
+ /* Call the private setup routine */
+ hr = surface->surface_ops->surface_private_setup(surface);
+ if (FAILED(hr))
+ {
+ ERR("Private setup failed, returning %#x\n", hr);
+ surface->surface_ops->surface_cleanup(surface);
+ return hr;
+ }
+
+ return hr;
+}
+
+HRESULT CDECL wined3d_surface_create(struct wined3d_device *device, UINT width, UINT height,
+ enum wined3d_format_id format_id, BOOL lockable, BOOL discard, UINT level, DWORD usage, WINED3DPOOL pool,
+ WINED3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality, WINED3DSURFTYPE surface_type,
+ void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_surface **surface)
+{
+ struct wined3d_surface *object;
+ HRESULT hr;
+
+ TRACE("device %p, width %u, height %u, format %s, lockable %#x, discard %#x, level %u\n",
+ device, width, height, debug_d3dformat(format_id), lockable, discard, level);
+ TRACE("surface %p, usage %s (%#x), pool %s, multisample_type %#x, multisample_quality %u\n",
+ surface, debug_d3dusage(usage), usage, debug_d3dpool(pool), multisample_type, multisample_quality);
+ TRACE("surface_type %#x, parent %p, parent_ops %p.\n", surface_type, parent, parent_ops);
+
+ if (surface_type == SURFACE_OPENGL && !device->adapter)
+ {
+ ERR("OpenGL surfaces are not available without OpenGL.\n");
+ return WINED3DERR_NOTAVAILABLE;
+ }
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (!object)
+ {
+ ERR("Failed to allocate surface memory.\n");
+ return WINED3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ hr = surface_init(object, surface_type, device->surface_alignment, width, height, level, lockable,
+ discard, multisample_type, multisample_quality, device, usage, format_id, pool, parent, parent_ops);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize surface, returning %#x.\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ return hr;
+ }
+
+ TRACE("Created surface %p.\n", object);
+ *surface = object;
+
+ return hr;
}
diff --git a/reactos/dll/directx/wine/wined3d/surface_base.c b/reactos/dll/directx/wine/wined3d/surface_base.c
deleted file mode 100644
index e4dd853b0b3..00000000000
--- a/reactos/dll/directx/wine/wined3d/surface_base.c
+++ /dev/null
@@ -1,1875 +0,0 @@
-/*
- * IWineD3DSurface Implementation of management(non-rendering) functions
- *
- * Copyright 1998 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 for CodeWeavers
- * Copyright 2007 Henri Verbeet
- * Copyright 2006-2007 Roderick Colenbrander
- * 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 "wine/port.h"
-#include "wined3d_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
-
-/* See also float_16_to_32() in wined3d_private.h */
-static inline unsigned short float_32_to_16(const float *in)
-{
- int exp = 0;
- float tmp = fabs(*in);
- unsigned int mantissa;
- unsigned short ret;
-
- /* Deal with special numbers */
- if (*in == 0.0f) return 0x0000;
- if(isnan(*in)) return 0x7C01;
- if (isinf(*in)) return (*in < 0.0f ? 0xFC00 : 0x7c00);
-
- if(tmp < powf(2, 10)) {
- do
- {
- tmp = tmp * 2.0f;
- exp--;
- }while(tmp < powf(2, 10));
- } else if(tmp >= powf(2, 11)) {
- do
- {
- tmp /= 2.0f;
- exp++;
- }while(tmp >= powf(2, 11));
- }
-
- mantissa = (unsigned int) tmp;
- if(tmp - mantissa >= 0.5f) mantissa++; /* round to nearest, away from zero */
-
- exp += 10; /* Normalize the mantissa */
- exp += 15; /* Exponent is encoded with excess 15 */
-
- if(exp > 30) { /* too big */
- ret = 0x7c00; /* INF */
- } else if(exp <= 0) {
- /* exp == 0: Non-normalized mantissa. Returns 0x0000 (=0.0) for too small numbers */
- while(exp <= 0) {
- mantissa = mantissa >> 1;
- exp++;
- }
- ret = mantissa & 0x3ff;
- } else {
- ret = (exp << 10) | (mantissa & 0x3ff);
- }
-
- ret |= ((*in < 0.0f ? 1 : 0) << 15); /* Add the sign */
- return ret;
-}
-
-/* *******************************************
- IWineD3DSurface IUnknown parts follow
- ******************************************* */
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_QueryInterface(IWineD3DSurface *iface, REFIID riid, LPVOID *ppobj)
-{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
- /* Warn ,but be nice about things */
- 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_IWineD3DSurface)) {
- IUnknown_AddRef((IUnknown*)iface);
- *ppobj = This;
- return S_OK;
- }
- *ppobj = NULL;
- return E_NOINTERFACE;
-}
-
-ULONG WINAPI IWineD3DBaseSurfaceImpl_AddRef(IWineD3DSurface *iface) {
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
- ULONG ref = InterlockedIncrement(&This->resource.ref);
- TRACE("(%p) : AddRef increasing from %d\n", This,ref - 1);
- return ref;
-}
-
-/* ****************************************************
- IWineD3DSurface IWineD3DResource parts follow
- **************************************************** */
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPrivateData(IWineD3DSurface *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
- return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPrivateData(IWineD3DSurface *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
- return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGUID refguid) {
- return resource_free_private_data((IWineD3DResource *)iface, refguid);
-}
-
-DWORD WINAPI IWineD3DBaseSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew) {
- return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
-}
-
-DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPriority(IWineD3DSurface *iface) {
- return resource_get_priority((IWineD3DResource *)iface);
-}
-
-WINED3DRESOURCETYPE WINAPI IWineD3DBaseSurfaceImpl_GetType(IWineD3DSurface *iface) {
- TRACE("(%p) : calling resourceimpl_GetType\n", iface);
- return resource_get_type((IWineD3DResource *)iface);
-}
-
-void * WINAPI IWineD3DBaseSurfaceImpl_GetParent(IWineD3DSurface *iface)
-{
- TRACE("iface %p.\n", iface);
-
- return ((IWineD3DSurfaceImpl *)iface)->resource.parent;
-}
-
-void WINAPI IWineD3DBaseSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFACE_DESC *desc)
-{
- IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)iface;
-
- TRACE("iface %p, desc %p.\n", iface, desc);
-
- desc->format = surface->resource.format->id;
- desc->resource_type = surface->resource.resourceType;
- desc->usage = surface->resource.usage;
- desc->pool = surface->resource.pool;
- desc->size = surface->resource.size; /* dx8 only */
- desc->multisample_type = surface->currentDesc.MultiSampleType;
- desc->multisample_quality = surface->currentDesc.MultiSampleQuality;
- desc->width = surface->currentDesc.Width;
- desc->height = surface->currentDesc.Height;
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetBltStatus(IWineD3DSurface *iface, DWORD Flags)
-{
- TRACE("iface %p, flags %#x.\n", iface, Flags);
-
- switch (Flags)
- {
- case WINEDDGBS_CANBLT:
- case WINEDDGBS_ISBLTDONE:
- return WINED3D_OK;
-
- default:
- return WINED3DERR_INVALIDCALL;
- }
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetFlipStatus(IWineD3DSurface *iface, DWORD Flags) {
- /* XXX: DDERR_INVALIDSURFACETYPE */
-
- TRACE("(%p)->(%08x)\n",iface,Flags);
- switch (Flags) {
- case WINEDDGFS_CANFLIP:
- case WINEDDGFS_ISFLIPDONE:
- return WINED3D_OK;
-
- default:
- return WINED3DERR_INVALIDCALL;
- }
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_IsLost(IWineD3DSurface *iface) {
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
- TRACE("(%p)\n", This);
-
- /* D3D8 and 9 loose full devices, ddraw only surfaces */
- return This->Flags & SFLAG_LOST ? WINED3DERR_DEVICELOST : WINED3D_OK;
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_Restore(IWineD3DSurface *iface) {
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
- TRACE("(%p)\n", This);
-
- /* So far we don't lose anything :) */
- This->Flags &= ~SFLAG_LOST;
- return WINED3D_OK;
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal) {
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
- IWineD3DPaletteImpl *PalImpl = (IWineD3DPaletteImpl *) Pal;
- TRACE("(%p)->(%p)\n", This, Pal);
-
- if(This->palette == PalImpl) {
- TRACE("Nop palette change\n");
- return WINED3D_OK;
- }
-
- if (This->palette)
- if (This->resource.usage & WINED3DUSAGE_RENDERTARGET)
- This->palette->Flags &= ~WINEDDPCAPS_PRIMARYSURFACE;
-
- This->palette = PalImpl;
-
- if (PalImpl)
- {
- if (This->resource.usage & WINED3DUSAGE_RENDERTARGET)
- PalImpl->Flags |= WINEDDPCAPS_PRIMARYSURFACE;
-
- return IWineD3DSurface_RealizePalette(iface);
- }
- else return WINED3D_OK;
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, const WINEDDCOLORKEY *CKey)
-{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
- TRACE("(%p)->(%08x,%p)\n", This, Flags, CKey);
-
- if (Flags & WINEDDCKEY_COLORSPACE)
- {
- FIXME(" colorkey value not supported (%08x) !\n", Flags);
- return WINED3DERR_INVALIDCALL;
- }
-
- /* Dirtify the surface, but only if a key was changed */
- if(CKey) {
- switch (Flags & ~WINEDDCKEY_COLORSPACE) {
- case WINEDDCKEY_DESTBLT:
- This->DestBltCKey = *CKey;
- This->CKeyFlags |= WINEDDSD_CKDESTBLT;
- break;
-
- case WINEDDCKEY_DESTOVERLAY:
- This->DestOverlayCKey = *CKey;
- This->CKeyFlags |= WINEDDSD_CKDESTOVERLAY;
- break;
-
- case WINEDDCKEY_SRCOVERLAY:
- This->SrcOverlayCKey = *CKey;
- This->CKeyFlags |= WINEDDSD_CKSRCOVERLAY;
- break;
-
- case WINEDDCKEY_SRCBLT:
- This->SrcBltCKey = *CKey;
- This->CKeyFlags |= WINEDDSD_CKSRCBLT;
- break;
- }
- }
- else {
- switch (Flags & ~WINEDDCKEY_COLORSPACE) {
- case WINEDDCKEY_DESTBLT:
- This->CKeyFlags &= ~WINEDDSD_CKDESTBLT;
- break;
-
- case WINEDDCKEY_DESTOVERLAY:
- This->CKeyFlags &= ~WINEDDSD_CKDESTOVERLAY;
- break;
-
- case WINEDDCKEY_SRCOVERLAY:
- This->CKeyFlags &= ~WINEDDSD_CKSRCOVERLAY;
- break;
-
- case WINEDDCKEY_SRCBLT:
- This->CKeyFlags &= ~WINEDDSD_CKSRCBLT;
- break;
- }
- }
-
- return WINED3D_OK;
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPalette(IWineD3DSurface *iface, IWineD3DPalette **Pal) {
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
- TRACE("(%p)->(%p)\n", This, Pal);
-
- *Pal = (IWineD3DPalette *) This->palette;
- return WINED3D_OK;
-}
-
-DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPitch(IWineD3DSurface *iface)
-{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
- const struct wined3d_format *format = This->resource.format;
- DWORD ret;
- TRACE("(%p)\n", This);
-
- if ((format->Flags & (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_COMPRESSED)
- {
- /* Since compressed formats are block based, pitch means the amount of
- * bytes to the next row of block rather than the next row of pixels. */
- UINT row_block_count = (This->currentDesc.Width + format->block_width - 1) / format->block_width;
- ret = row_block_count * format->block_byte_count;
- }
- else
- {
- unsigned char alignment = This->resource.device->surface_alignment;
- ret = This->resource.format->byte_count * This->currentDesc.Width; /* Bytes / row */
- ret = (ret + alignment - 1) & ~(alignment - 1);
- }
- TRACE("(%p) Returning %d\n", This, ret);
- return ret;
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetOverlayPosition(IWineD3DSurface *iface, LONG X, LONG Y) {
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
- LONG w, h;
-
- TRACE("(%p)->(%d,%d) Stub!\n", This, X, Y);
-
- if(!(This->resource.usage & WINED3DUSAGE_OVERLAY))
- {
- TRACE("(%p): Not an overlay surface\n", This);
- return WINEDDERR_NOTAOVERLAYSURFACE;
- }
-
- w = This->overlay_destrect.right - This->overlay_destrect.left;
- h = This->overlay_destrect.bottom - This->overlay_destrect.top;
- This->overlay_destrect.left = X;
- This->overlay_destrect.top = Y;
- This->overlay_destrect.right = X + w;
- This->overlay_destrect.bottom = Y + h;
-
- IWineD3DSurface_DrawOverlay(iface);
-
- return WINED3D_OK;
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetOverlayPosition(IWineD3DSurface *iface, LONG *X, LONG *Y) {
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
- HRESULT hr;
-
- TRACE("(%p)->(%p,%p)\n", This, X, Y);
-
- if(!(This->resource.usage & WINED3DUSAGE_OVERLAY))
- {
- TRACE("(%p): Not an overlay surface\n", This);
- return WINEDDERR_NOTAOVERLAYSURFACE;
- }
-
- if (!This->overlay_dest)
- {
- *X = 0; *Y = 0;
- hr = WINEDDERR_OVERLAYNOTVISIBLE;
- } else {
- *X = This->overlay_destrect.left;
- *Y = This->overlay_destrect.top;
- hr = WINED3D_OK;
- }
-
- TRACE("Returning 0x%08x, position %d, %d\n", hr, *X, *Y);
- return hr;
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *iface, DWORD Flags, IWineD3DSurface *Ref) {
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
-
- FIXME("iface %p, flags %#x, ref %p stub!\n", iface, Flags, Ref);
-
- if(!(This->resource.usage & WINED3DUSAGE_OVERLAY))
- {
- TRACE("(%p): Not an overlay surface\n", This);
- return WINEDDERR_NOTAOVERLAYSURFACE;
- }
-
- return WINED3D_OK;
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, const RECT *SrcRect,
- IWineD3DSurface *DstSurface, const RECT *DstRect, DWORD Flags, const WINEDDOVERLAYFX *FX)
-{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
- IWineD3DSurfaceImpl *Dst = (IWineD3DSurfaceImpl *) DstSurface;
- TRACE("(%p)->(%p, %p, %p, %08x, %p)\n", This, SrcRect, Dst, DstRect, Flags, FX);
-
- if(!(This->resource.usage & WINED3DUSAGE_OVERLAY))
- {
- WARN("(%p): Not an overlay surface\n", This);
- return WINEDDERR_NOTAOVERLAYSURFACE;
- } else if(!DstSurface) {
- WARN("(%p): Dest surface is NULL\n", This);
- return WINED3DERR_INVALIDCALL;
- }
-
- if(SrcRect) {
- This->overlay_srcrect = *SrcRect;
- } else {
- This->overlay_srcrect.left = 0;
- This->overlay_srcrect.top = 0;
- This->overlay_srcrect.right = This->currentDesc.Width;
- This->overlay_srcrect.bottom = This->currentDesc.Height;
- }
-
- if(DstRect) {
- This->overlay_destrect = *DstRect;
- } else {
- This->overlay_destrect.left = 0;
- This->overlay_destrect.top = 0;
- This->overlay_destrect.right = Dst ? Dst->currentDesc.Width : 0;
- This->overlay_destrect.bottom = Dst ? Dst->currentDesc.Height : 0;
- }
-
- if(This->overlay_dest && (This->overlay_dest != Dst || Flags & WINEDDOVER_HIDE)) {
- list_remove(&This->overlay_entry);
- }
-
- if(Flags & WINEDDOVER_SHOW) {
- if(This->overlay_dest != Dst) {
- This->overlay_dest = Dst;
- list_add_tail(&Dst->overlays, &This->overlay_entry);
- }
- } else if(Flags & WINEDDOVER_HIDE) {
- /* tests show that the rectangles are erased on hide */
- This->overlay_srcrect.left = 0; This->overlay_srcrect.top = 0;
- This->overlay_srcrect.right = 0; This->overlay_srcrect.bottom = 0;
- This->overlay_destrect.left = 0; This->overlay_destrect.top = 0;
- This->overlay_destrect.right = 0; This->overlay_destrect.bottom = 0;
- This->overlay_dest = NULL;
- }
-
- IWineD3DSurface_DrawOverlay(iface);
-
- return WINED3D_OK;
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetClipper(IWineD3DSurface *iface, IWineD3DClipper *clipper)
-{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
- TRACE("(%p)->(%p)\n", This, clipper);
-
- This->clipper = clipper;
- return WINED3D_OK;
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetClipper(IWineD3DSurface *iface, IWineD3DClipper **clipper)
-{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
- TRACE("(%p)->(%p)\n", This, clipper);
-
- *clipper = This->clipper;
- if(*clipper) {
- IWineD3DClipper_AddRef(*clipper);
- }
- return WINED3D_OK;
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, enum wined3d_format_id format_id)
-{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
- const struct wined3d_format *format = wined3d_get_format(&This->resource.device->adapter->gl_info, format_id);
-
- if (This->resource.format->id != WINED3DFMT_UNKNOWN)
- {
- FIXME("(%p) : The format of the surface must be WINED3DFORMAT_UNKNOWN\n", This);
- return WINED3DERR_INVALIDCALL;
- }
-
- TRACE("(%p) : Setting texture format to %s (%#x).\n", This, debug_d3dformat(format_id), format_id);
-
- This->resource.size = wined3d_format_calculate_size(format, This->resource.device->surface_alignment,
- This->pow2Width, This->pow2Height);
-
- This->Flags |= (WINED3DFMT_D16_LOCKABLE == format_id) ? SFLAG_LOCKABLE : 0;
-
- This->resource.format = format;
-
- TRACE("(%p) : Size %d, bytesPerPixel %d\n", This, This->resource.size, format->byte_count);
-
- return WINED3D_OK;
-}
-
-HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface)
-{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
- const struct wined3d_format *format = This->resource.format;
- int extraline = 0;
- SYSTEM_INFO sysInfo;
- BITMAPINFO* b_info;
- HDC ddc;
- DWORD *masks;
- UINT usage;
-
- if (!(format->Flags & WINED3DFMT_FLAG_GETDC))
- {
- WARN("Cannot use GetDC on a %s surface\n", debug_d3dformat(format->id));
- return WINED3DERR_INVALIDCALL;
- }
-
- switch (format->byte_count)
- {
- case 2:
- case 4:
- /* Allocate extra space to store the RGB bit masks. */
- b_info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BITMAPINFOHEADER) + 3 * sizeof(DWORD));
- break;
-
- case 3:
- b_info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BITMAPINFOHEADER));
- break;
-
- default:
- /* Allocate extra space for a palette. */
- b_info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * (1 << (format->byte_count * 8)));
- break;
- }
-
- if (!b_info)
- return E_OUTOFMEMORY;
-
- /* Some apps access the surface in via DWORDs, and do not take the necessary care at the end of the
- * surface. So we need at least extra 4 bytes at the end of the surface. Check against the page size,
- * if the last page used for the surface has at least 4 spare bytes we're safe, otherwise
- * add an extra line to the dib section
- */
- GetSystemInfo(&sysInfo);
- if( ((This->resource.size + 3) % sysInfo.dwPageSize) < 4) {
- extraline = 1;
- TRACE("Adding an extra line to the dib section\n");
- }
-
- b_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- /* TODO: Is there a nicer way to force a specific alignment? (8 byte for ddraw) */
- b_info->bmiHeader.biWidth = IWineD3DSurface_GetPitch(iface) / format->byte_count;
- b_info->bmiHeader.biHeight = -This->currentDesc.Height -extraline;
- b_info->bmiHeader.biSizeImage = ( This->currentDesc.Height + extraline) * IWineD3DSurface_GetPitch(iface);
- b_info->bmiHeader.biPlanes = 1;
- b_info->bmiHeader.biBitCount = format->byte_count * 8;
-
- b_info->bmiHeader.biXPelsPerMeter = 0;
- b_info->bmiHeader.biYPelsPerMeter = 0;
- b_info->bmiHeader.biClrUsed = 0;
- b_info->bmiHeader.biClrImportant = 0;
-
- /* Get the bit masks */
- masks = (DWORD *)b_info->bmiColors;
- switch (This->resource.format->id)
- {
- case WINED3DFMT_B8G8R8_UNORM:
- usage = DIB_RGB_COLORS;
- b_info->bmiHeader.biCompression = BI_RGB;
- break;
-
- case WINED3DFMT_B5G5R5X1_UNORM:
- case WINED3DFMT_B5G5R5A1_UNORM:
- case WINED3DFMT_B4G4R4A4_UNORM:
- case WINED3DFMT_B4G4R4X4_UNORM:
- case WINED3DFMT_B2G3R3_UNORM:
- case WINED3DFMT_B2G3R3A8_UNORM:
- case WINED3DFMT_R10G10B10A2_UNORM:
- case WINED3DFMT_R8G8B8A8_UNORM:
- case WINED3DFMT_R8G8B8X8_UNORM:
- case WINED3DFMT_B10G10R10A2_UNORM:
- case WINED3DFMT_B5G6R5_UNORM:
- case WINED3DFMT_R16G16B16A16_UNORM:
- usage = 0;
- b_info->bmiHeader.biCompression = BI_BITFIELDS;
- masks[0] = format->red_mask;
- masks[1] = format->green_mask;
- masks[2] = format->blue_mask;
- break;
-
- default:
- /* Don't know palette */
- b_info->bmiHeader.biCompression = BI_RGB;
- usage = 0;
- break;
- }
-
- if (!(ddc = GetDC(0)))
- {
- HeapFree(GetProcessHeap(), 0, b_info);
- return HRESULT_FROM_WIN32(GetLastError());
- }
-
- TRACE("Creating a DIB section with size %dx%dx%d, size=%d\n", b_info->bmiHeader.biWidth, b_info->bmiHeader.biHeight, b_info->bmiHeader.biBitCount, b_info->bmiHeader.biSizeImage);
- This->dib.DIBsection = CreateDIBSection(ddc, b_info, usage, &This->dib.bitmap_data, 0 /* Handle */, 0 /* Offset */);
- ReleaseDC(0, ddc);
-
- if (!This->dib.DIBsection) {
- ERR("CreateDIBSection failed!\n");
- HeapFree(GetProcessHeap(), 0, b_info);
- return HRESULT_FROM_WIN32(GetLastError());
- }
-
- TRACE("DIBSection at : %p\n", This->dib.bitmap_data);
- /* copy the existing surface to the dib section */
- if(This->resource.allocatedMemory) {
- memcpy(This->dib.bitmap_data, This->resource.allocatedMemory, This->currentDesc.Height * IWineD3DSurface_GetPitch(iface));
- } else {
- /* This is to make LockRect read the gl Texture although memory is allocated */
- This->Flags &= ~SFLAG_INSYSMEM;
- }
- This->dib.bitmap_size = b_info->bmiHeader.biSizeImage;
-
- HeapFree(GetProcessHeap(), 0, b_info);
-
- /* Now allocate a HDC */
- This->hDC = CreateCompatibleDC(0);
- This->dib.holdbitmap = SelectObject(This->hDC, This->dib.DIBsection);
- TRACE("using wined3d palette %p\n", This->palette);
- SelectPalette(This->hDC,
- This->palette ? This->palette->hpal : 0,
- FALSE);
-
- This->Flags |= SFLAG_DIBSECTION;
-
- HeapFree(GetProcessHeap(), 0, This->resource.heapMemory);
- This->resource.heapMemory = NULL;
-
- return WINED3D_OK;
-}
-
-static void convert_r32_float_r16_float(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out,
- unsigned int w, unsigned int h)
-{
- unsigned int x, y;
- const float *src_f;
- unsigned short *dst_s;
-
- TRACE("Converting %dx%d pixels, pitches %d %d\n", w, h, pitch_in, pitch_out);
- for(y = 0; y < h; y++) {
- src_f = (const float *)(src + y * pitch_in);
- dst_s = (unsigned short *) (dst + y * pitch_out);
- for(x = 0; x < w; x++) {
- dst_s[x] = float_32_to_16(src_f + x);
- }
- }
-}
-
-static void convert_r5g6b5_x8r8g8b8(const BYTE *src, BYTE *dst,
- DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
-{
- static const unsigned char convert_5to8[] =
- {
- 0x00, 0x08, 0x10, 0x19, 0x21, 0x29, 0x31, 0x3a,
- 0x42, 0x4a, 0x52, 0x5a, 0x63, 0x6b, 0x73, 0x7b,
- 0x84, 0x8c, 0x94, 0x9c, 0xa5, 0xad, 0xb5, 0xbd,
- 0xc5, 0xce, 0xd6, 0xde, 0xe6, 0xef, 0xf7, 0xff,
- };
- static const unsigned char convert_6to8[] =
- {
- 0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c,
- 0x20, 0x24, 0x28, 0x2d, 0x31, 0x35, 0x39, 0x3d,
- 0x41, 0x45, 0x49, 0x4d, 0x51, 0x55, 0x59, 0x5d,
- 0x61, 0x65, 0x69, 0x6d, 0x71, 0x75, 0x79, 0x7d,
- 0x82, 0x86, 0x8a, 0x8e, 0x92, 0x96, 0x9a, 0x9e,
- 0xa2, 0xa6, 0xaa, 0xae, 0xb2, 0xb6, 0xba, 0xbe,
- 0xc2, 0xc6, 0xca, 0xce, 0xd2, 0xd7, 0xdb, 0xdf,
- 0xe3, 0xe7, 0xeb, 0xef, 0xf3, 0xf7, 0xfb, 0xff,
- };
- unsigned int x, y;
-
- TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
-
- for (y = 0; y < h; ++y)
- {
- const WORD *src_line = (const WORD *)(src + y * pitch_in);
- DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
- for (x = 0; x < w; ++x)
- {
- WORD pixel = src_line[x];
- dst_line[x] = 0xff000000
- | convert_5to8[(pixel & 0xf800) >> 11] << 16
- | convert_6to8[(pixel & 0x07e0) >> 5] << 8
- | convert_5to8[(pixel & 0x001f)];
- }
- }
-}
-
-static void convert_a8r8g8b8_x8r8g8b8(const BYTE *src, BYTE *dst,
- DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
-{
- unsigned int x, y;
-
- TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
-
- for (y = 0; y < h; ++y)
- {
- const DWORD *src_line = (const DWORD *)(src + y * pitch_in);
- DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
-
- for (x = 0; x < w; ++x)
- {
- dst_line[x] = 0xff000000 | (src_line[x] & 0xffffff);
- }
- }
-}
-
-static inline BYTE cliptobyte(int x)
-{
- return (BYTE) ((x < 0) ? 0 : ((x > 255) ? 255 : x));
-}
-
-static void convert_yuy2_x8r8g8b8(const BYTE *src, BYTE *dst,
- DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
-{
- unsigned int x, y;
- int c2, d, e, r2 = 0, g2 = 0, b2 = 0;
-
- TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
-
- for (y = 0; y < h; ++y)
- {
- const BYTE *src_line = src + y * pitch_in;
- DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
- for (x = 0; x < w; ++x)
- {
- /* YUV to RGB conversion formulas from http://en.wikipedia.org/wiki/YUV:
- * C = Y - 16; D = U - 128; E = V - 128;
- * R = cliptobyte((298 * C + 409 * E + 128) >> 8);
- * G = cliptobyte((298 * C - 100 * D - 208 * E + 128) >> 8);
- * B = cliptobyte((298 * C + 516 * D + 128) >> 8);
- * Two adjacent YUY2 pixels are stored as four bytes: Y0 U Y1 V .
- * U and V are shared between the pixels.
- */
- if (!(x & 1)) /* for every even pixel, read new U and V */
- {
- d = (int) src_line[1] - 128;
- e = (int) src_line[3] - 128;
- r2 = 409 * e + 128;
- g2 = - 100 * d - 208 * e + 128;
- b2 = 516 * d + 128;
- }
- c2 = 298 * ((int) src_line[0] - 16);
- dst_line[x] = 0xff000000
- | cliptobyte((c2 + r2) >> 8) << 16 /* red */
- | cliptobyte((c2 + g2) >> 8) << 8 /* green */
- | cliptobyte((c2 + b2) >> 8); /* blue */
- /* Scale RGB values to 0..255 range,
- * then clip them if still not in range (may be negative),
- * then shift them within DWORD if necessary.
- */
- src_line += 2;
- }
- }
-}
-
-struct d3dfmt_convertor_desc
-{
- enum wined3d_format_id from, to;
- void (*convert)(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h);
-};
-
-static const struct d3dfmt_convertor_desc convertors[] =
-{
- {WINED3DFMT_R32_FLOAT, WINED3DFMT_R16_FLOAT, convert_r32_float_r16_float},
- {WINED3DFMT_B5G6R5_UNORM, WINED3DFMT_B8G8R8X8_UNORM, convert_r5g6b5_x8r8g8b8},
- {WINED3DFMT_B8G8R8A8_UNORM, WINED3DFMT_B8G8R8X8_UNORM, convert_a8r8g8b8_x8r8g8b8},
- {WINED3DFMT_YUY2, WINED3DFMT_B8G8R8X8_UNORM, convert_yuy2_x8r8g8b8},
-};
-
-static inline const struct d3dfmt_convertor_desc *find_convertor(enum wined3d_format_id from, enum wined3d_format_id to)
-{
- unsigned int i;
- for(i = 0; i < (sizeof(convertors) / sizeof(convertors[0])); i++) {
- if(convertors[i].from == from && convertors[i].to == to) {
- return &convertors[i];
- }
- }
- return NULL;
-}
-
-/*****************************************************************************
- * surface_convert_format
- *
- * Creates a duplicate of a surface in a different format. Is used by Blt to
- * blit between surfaces with different formats
- *
- * Parameters
- * source: Source surface
- * fmt: Requested destination format
- *
- *****************************************************************************/
-static IWineD3DSurfaceImpl *surface_convert_format(IWineD3DSurfaceImpl *source, enum wined3d_format_id to_fmt)
-{
- IWineD3DSurface *ret = NULL;
- const struct d3dfmt_convertor_desc *conv;
- WINED3DLOCKED_RECT lock_src, lock_dst;
- HRESULT hr;
-
- conv = find_convertor(source->resource.format->id, to_fmt);
- if (!conv)
- {
- FIXME("Cannot find a conversion function from format %s to %s.\n",
- debug_d3dformat(source->resource.format->id), debug_d3dformat(to_fmt));
- return NULL;
- }
-
- IWineD3DDevice_CreateSurface((IWineD3DDevice *)source->resource.device, source->currentDesc.Width,
- source->currentDesc.Height, to_fmt, TRUE /* lockable */, TRUE /* discard */, 0 /* level */,
- 0 /* usage */, WINED3DPOOL_SCRATCH, WINED3DMULTISAMPLE_NONE /* TODO: Multisampled conversion */,
- 0 /* MultiSampleQuality */, IWineD3DSurface_GetImplType((IWineD3DSurface *) source),
- NULL /* parent */, &wined3d_null_parent_ops, &ret);
- if(!ret) {
- ERR("Failed to create a destination surface for conversion\n");
- return NULL;
- }
-
- memset(&lock_src, 0, sizeof(lock_src));
- memset(&lock_dst, 0, sizeof(lock_dst));
-
- hr = IWineD3DSurface_LockRect((IWineD3DSurface *) source, &lock_src, NULL, WINED3DLOCK_READONLY);
- if(FAILED(hr)) {
- ERR("Failed to lock the source surface\n");
- IWineD3DSurface_Release(ret);
- return NULL;
- }
- hr = IWineD3DSurface_LockRect(ret, &lock_dst, NULL, WINED3DLOCK_READONLY);
- if(FAILED(hr)) {
- ERR("Failed to lock the dest surface\n");
- IWineD3DSurface_UnlockRect((IWineD3DSurface *) source);
- IWineD3DSurface_Release(ret);
- return NULL;
- }
-
- conv->convert(lock_src.pBits, lock_dst.pBits, lock_src.Pitch, lock_dst.Pitch,
- source->currentDesc.Width, source->currentDesc.Height);
-
- IWineD3DSurface_UnlockRect(ret);
- IWineD3DSurface_UnlockRect((IWineD3DSurface *) source);
-
- return (IWineD3DSurfaceImpl *) ret;
-}
-
-/*****************************************************************************
- * _Blt_ColorFill
- *
- * Helper function that fills a memory area with a specific color
- *
- * Params:
- * buf: memory address to start filling at
- * width, height: Dimensions of the area to fill
- * bpp: Bit depth of the surface
- * lPitch: pitch of the surface
- * color: Color to fill with
- *
- *****************************************************************************/
-static HRESULT
- _Blt_ColorFill(BYTE *buf,
- int width, int height,
- int bpp, LONG lPitch,
- DWORD color)
-{
- int x, y;
- LPBYTE first;
-
- /* Do first row */
-
-#define COLORFILL_ROW(type) \
- { \
- type *d = (type *) buf; \
- for (x = 0; x < width; x++) \
- d[x] = (type) color; \
- break; \
-}
- switch(bpp)
- {
- case 1: COLORFILL_ROW(BYTE)
- case 2: COLORFILL_ROW(WORD)
- case 3:
- {
- BYTE *d = buf;
- for (x = 0; x < width; x++,d+=3)
- {
- d[0] = (color ) & 0xFF;
- d[1] = (color>> 8) & 0xFF;
- d[2] = (color>>16) & 0xFF;
- }
- break;
- }
- case 4: COLORFILL_ROW(DWORD)
- default:
- FIXME("Color fill not implemented for bpp %d!\n", bpp*8);
- return WINED3DERR_NOTAVAILABLE;
- }
-
-#undef COLORFILL_ROW
-
- /* Now copy first row */
- first = buf;
- for (y = 1; y < height; y++)
- {
- buf += lPitch;
- memcpy(buf, first, width * bpp);
- }
- return WINED3D_OK;
-}
-
-/*****************************************************************************
- * IWineD3DSurface::Blt, SW emulation version
- *
- * Performs a blit to a surface, with or without a source surface.
- * This is the main functionality of DirectDraw
- *
- * Params:
- * DestRect: Destination rectangle to write to
- * src_surface: Source surface, can be NULL
- * SrcRect: Source rectangle
- *****************************************************************************/
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *DestRect, IWineD3DSurface *src_surface,
- const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter)
-{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
- IWineD3DSurfaceImpl *src = (IWineD3DSurfaceImpl *)src_surface;
- RECT xdst,xsrc;
- HRESULT ret = WINED3D_OK;
- WINED3DLOCKED_RECT dlock, slock;
- int bpp, srcheight, srcwidth, dstheight, dstwidth, width;
- const struct wined3d_format *sEntry, *dEntry;
- int x, y;
- const BYTE *sbuf;
- BYTE *dbuf;
-
- TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p, filter %s.\n",
- iface, wine_dbgstr_rect(DestRect), src_surface, wine_dbgstr_rect(SrcRect),
- Flags, DDBltFx, debug_d3dtexturefiltertype(Filter));
-
- if ((This->Flags & SFLAG_LOCKED) || (src && (src->Flags & SFLAG_LOCKED)))
- {
- WARN(" Surface is busy, returning DDERR_SURFACEBUSY\n");
- return WINEDDERR_SURFACEBUSY;
- }
-
- if(Filter != WINED3DTEXF_NONE && Filter != WINED3DTEXF_POINT) {
- /* Can happen when d3d9 apps do a StretchRect call which isn't handled in gl */
- FIXME("Filters not supported in software blit\n");
- }
-
- /* First check for the validity of source / destination rectangles.
- * This was verified using a test application + by MSDN. */
-
- if (SrcRect)
- {
- if (src)
- {
- if (SrcRect->right < SrcRect->left || SrcRect->bottom < SrcRect->top
- || SrcRect->left > src->currentDesc.Width || SrcRect->left < 0
- || SrcRect->top > src->currentDesc.Height || SrcRect->top < 0
- || SrcRect->right > src->currentDesc.Width || SrcRect->right < 0
- || SrcRect->bottom > src->currentDesc.Height || SrcRect->bottom < 0)
- {
- WARN("Application gave us bad source rectangle for Blt.\n");
- return WINEDDERR_INVALIDRECT;
- }
-
- if (!SrcRect->right || !SrcRect->bottom
- || SrcRect->left == (int)src->currentDesc.Width
- || SrcRect->top == (int)src->currentDesc.Height)
- {
- TRACE("Nothing to be done.\n");
- return WINED3D_OK;
- }
- }
-
- xsrc = *SrcRect;
- }
- else if (src)
- {
- xsrc.left = 0;
- xsrc.top = 0;
- xsrc.right = src->currentDesc.Width;
- xsrc.bottom = src->currentDesc.Height;
- }
- else
- {
- memset(&xsrc, 0, sizeof(xsrc));
- }
-
- if (DestRect)
- {
- /* For the Destination rect, it can be out of bounds on the condition
- * that a clipper is set for the given surface. */
- if (!This->clipper && (DestRect->right < DestRect->left || DestRect->bottom < DestRect->top
- || DestRect->left > This->currentDesc.Width || DestRect->left < 0
- || DestRect->top > This->currentDesc.Height || DestRect->top < 0
- || DestRect->right > This->currentDesc.Width || DestRect->right < 0
- || DestRect->bottom > This->currentDesc.Height || DestRect->bottom < 0))
- {
- WARN("Application gave us bad destination rectangle for Blt without a clipper set.\n");
- return WINEDDERR_INVALIDRECT;
- }
-
- if (DestRect->right <= 0 || DestRect->bottom <= 0
- || DestRect->left >= (int)This->currentDesc.Width
- || DestRect->top >= (int)This->currentDesc.Height)
- {
- TRACE("Nothing to be done.\n");
- return WINED3D_OK;
- }
-
- if (!src)
- {
- RECT full_rect;
-
- full_rect.left = 0;
- full_rect.top = 0;
- full_rect.right = This->currentDesc.Width;
- full_rect.bottom = This->currentDesc.Height;
- IntersectRect(&xdst, &full_rect, DestRect);
- }
- else
- {
- BOOL clip_horiz, clip_vert;
-
- xdst = *DestRect;
- clip_horiz = xdst.left < 0 || xdst.right > (int)This->currentDesc.Width;
- clip_vert = xdst.top < 0 || xdst.bottom > (int)This->currentDesc.Height;
-
- if (clip_vert || clip_horiz)
- {
- /* Now check if this is a special case or not... */
- if ((Flags & WINEDDBLT_DDFX)
- || (clip_horiz && xdst.right - xdst.left != xsrc.right - xsrc.left)
- || (clip_vert && xdst.bottom - xdst.top != xsrc.bottom - xsrc.top))
- {
- WARN("Out of screen rectangle in special case. Not handled right now.\n");
- return WINED3D_OK;
- }
-
- if (clip_horiz)
- {
- if (xdst.left < 0)
- {
- xsrc.left -= xdst.left;
- xdst.left = 0;
- }
- if (xdst.right > This->currentDesc.Width)
- {
- xsrc.right -= (xdst.right - (int)This->currentDesc.Width);
- xdst.right = (int)This->currentDesc.Width;
- }
- }
-
- if (clip_vert)
- {
- if (xdst.top < 0)
- {
- xsrc.top -= xdst.top;
- xdst.top = 0;
- }
- if (xdst.bottom > This->currentDesc.Height)
- {
- xsrc.bottom -= (xdst.bottom - (int)This->currentDesc.Height);
- xdst.bottom = (int)This->currentDesc.Height;
- }
- }
-
- /* And check if after clipping something is still to be done... */
- if ((xdst.right <= 0) || (xdst.bottom <= 0)
- || (xdst.left >= (int)This->currentDesc.Width)
- || (xdst.top >= (int)This->currentDesc.Height)
- || (xsrc.right <= 0) || (xsrc.bottom <= 0)
- || (xsrc.left >= (int)src->currentDesc.Width)
- || (xsrc.top >= (int)src->currentDesc.Height))
- {
- TRACE("Nothing to be done after clipping.\n");
- return WINED3D_OK;
- }
- }
- }
- }
- else
- {
- xdst.left = 0;
- xdst.top = 0;
- xdst.right = This->currentDesc.Width;
- xdst.bottom = This->currentDesc.Height;
- }
-
- if (src == This)
- {
- IWineD3DSurface_LockRect(iface, &dlock, NULL, 0);
- slock = dlock;
- sEntry = This->resource.format;
- dEntry = sEntry;
- }
- else
- {
- dEntry = This->resource.format;
- if (src)
- {
- if (This->resource.format->id != src->resource.format->id)
- {
- src = surface_convert_format(src, dEntry->id);
- if (!src)
- {
- /* The conv function writes a FIXME */
- WARN("Cannot convert source surface format to dest format\n");
- goto release;
- }
- }
- IWineD3DSurface_LockRect((IWineD3DSurface *)src, &slock, NULL, WINED3DLOCK_READONLY);
- sEntry = src->resource.format;
- }
- else
- {
- sEntry = dEntry;
- }
- if (DestRect)
- IWineD3DSurface_LockRect(iface, &dlock, &xdst, 0);
- else
- IWineD3DSurface_LockRect(iface, &dlock, NULL, 0);
- }
-
- if (!DDBltFx || !(DDBltFx->dwDDFX)) Flags &= ~WINEDDBLT_DDFX;
-
- if (sEntry->Flags & dEntry->Flags & WINED3DFMT_FLAG_FOURCC)
- {
- if (!DestRect || src == This)
- {
- memcpy(dlock.pBits, slock.pBits, This->resource.size);
- goto release;
- }
- }
-
- bpp = This->resource.format->byte_count;
- srcheight = xsrc.bottom - xsrc.top;
- srcwidth = xsrc.right - xsrc.left;
- dstheight = xdst.bottom - xdst.top;
- dstwidth = xdst.right - xdst.left;
- width = (xdst.right - xdst.left) * bpp;
-
- if (DestRect && src != This)
- dbuf = dlock.pBits;
- else
- dbuf = (BYTE*)dlock.pBits+(xdst.top*dlock.Pitch)+(xdst.left*bpp);
-
- if (Flags & WINEDDBLT_WAIT)
- {
- Flags &= ~WINEDDBLT_WAIT;
- }
- if (Flags & WINEDDBLT_ASYNC)
- {
- static BOOL displayed = FALSE;
- if (!displayed)
- FIXME("Can't handle WINEDDBLT_ASYNC flag right now.\n");
- displayed = TRUE;
- Flags &= ~WINEDDBLT_ASYNC;
- }
- if (Flags & WINEDDBLT_DONOTWAIT)
- {
- /* WINEDDBLT_DONOTWAIT appeared in DX7 */
- static BOOL displayed = FALSE;
- if (!displayed)
- FIXME("Can't handle WINEDDBLT_DONOTWAIT flag right now.\n");
- displayed = TRUE;
- Flags &= ~WINEDDBLT_DONOTWAIT;
- }
-
- /* First, all the 'source-less' blits */
- if (Flags & WINEDDBLT_COLORFILL)
- {
- ret = _Blt_ColorFill(dbuf, dstwidth, dstheight, bpp,
- dlock.Pitch, DDBltFx->u5.dwFillColor);
- Flags &= ~WINEDDBLT_COLORFILL;
- }
-
- if (Flags & WINEDDBLT_DEPTHFILL)
- {
- FIXME("DDBLT_DEPTHFILL needs to be implemented!\n");
- }
- if (Flags & WINEDDBLT_ROP)
- {
- /* Catch some degenerate cases here */
- switch(DDBltFx->dwROP)
- {
- case BLACKNESS:
- ret = _Blt_ColorFill(dbuf,dstwidth,dstheight,bpp,dlock.Pitch,0);
- break;
- case 0xAA0029: /* No-op */
- break;
- case WHITENESS:
- ret = _Blt_ColorFill(dbuf,dstwidth,dstheight,bpp,dlock.Pitch,~0);
- break;
- case SRCCOPY: /* well, we do that below ? */
- break;
- default:
- FIXME("Unsupported raster op: %08x Pattern: %p\n", DDBltFx->dwROP, DDBltFx->u5.lpDDSPattern);
- goto error;
- }
- Flags &= ~WINEDDBLT_ROP;
- }
- if (Flags & WINEDDBLT_DDROPS)
- {
- FIXME("\tDdraw Raster Ops: %08x Pattern: %p\n", DDBltFx->dwDDROP, DDBltFx->u5.lpDDSPattern);
- }
- /* Now the 'with source' blits */
- if (src)
- {
- const BYTE *sbase;
- int sx, xinc, sy, yinc;
-
- if (!dstwidth || !dstheight) /* hmm... stupid program ? */
- goto release;
- sbase = (BYTE*)slock.pBits+(xsrc.top*slock.Pitch)+xsrc.left*bpp;
- xinc = (srcwidth << 16) / dstwidth;
- yinc = (srcheight << 16) / dstheight;
-
- if (!Flags)
- {
- /* No effects, we can cheat here */
- if (dstwidth == srcwidth)
- {
- if (dstheight == srcheight)
- {
- /* No stretching in either direction. This needs to be as
- * fast as possible */
- sbuf = sbase;
-
- /* check for overlapping surfaces */
- if (src != This || xdst.top < xsrc.top ||
- xdst.right <= xsrc.left || xsrc.right <= xdst.left)
- {
- /* no overlap, or dst above src, so copy from top downwards */
- for (y = 0; y < dstheight; y++)
- {
- memcpy(dbuf, sbuf, width);
- sbuf += slock.Pitch;
- dbuf += dlock.Pitch;
- }
- }
- else if (xdst.top > xsrc.top) /* copy from bottom upwards */
- {
- sbuf += (slock.Pitch*dstheight);
- dbuf += (dlock.Pitch*dstheight);
- for (y = 0; y < dstheight; y++)
- {
- sbuf -= slock.Pitch;
- dbuf -= dlock.Pitch;
- memcpy(dbuf, sbuf, width);
- }
- }
- else /* src and dst overlapping on the same line, use memmove */
- {
- for (y = 0; y < dstheight; y++)
- {
- memmove(dbuf, sbuf, width);
- sbuf += slock.Pitch;
- dbuf += dlock.Pitch;
- }
- }
- } else {
- /* Stretching in Y direction only */
- for (y = sy = 0; y < dstheight; y++, sy += yinc) {
- sbuf = sbase + (sy >> 16) * slock.Pitch;
- memcpy(dbuf, sbuf, width);
- dbuf += dlock.Pitch;
- }
- }
- }
- else
- {
- /* Stretching in X direction */
- int last_sy = -1;
- for (y = sy = 0; y < dstheight; y++, sy += yinc)
- {
- sbuf = sbase + (sy >> 16) * slock.Pitch;
-
- if ((sy >> 16) == (last_sy >> 16))
- {
- /* this sourcerow is the same as last sourcerow -
- * copy already stretched row
- */
- memcpy(dbuf, dbuf - dlock.Pitch, width);
- }
- else
- {
-#define STRETCH_ROW(type) { \
- const type *s = (const type *)sbuf; \
- type *d = (type *)dbuf; \
- for (x = sx = 0; x < dstwidth; x++, sx += xinc) \
- d[x] = s[sx >> 16]; \
- break; }
-
- switch(bpp)
- {
- case 1: STRETCH_ROW(BYTE)
- case 2: STRETCH_ROW(WORD)
- case 4: STRETCH_ROW(DWORD)
- case 3:
- {
- const BYTE *s;
- BYTE *d = dbuf;
- for (x = sx = 0; x < dstwidth; x++, sx+= xinc)
- {
- DWORD pixel;
-
- s = sbuf+3*(sx>>16);
- pixel = s[0]|(s[1]<<8)|(s[2]<<16);
- d[0] = (pixel )&0xff;
- d[1] = (pixel>> 8)&0xff;
- d[2] = (pixel>>16)&0xff;
- d+=3;
- }
- break;
- }
- default:
- FIXME("Stretched blit not implemented for bpp %d!\n", bpp*8);
- ret = WINED3DERR_NOTAVAILABLE;
- goto error;
- }
-#undef STRETCH_ROW
- }
- dbuf += dlock.Pitch;
- last_sy = sy;
- }
- }
- }
- else
- {
- LONG dstyinc = dlock.Pitch, dstxinc = bpp;
- DWORD keylow = 0xFFFFFFFF, keyhigh = 0, keymask = 0xFFFFFFFF;
- DWORD destkeylow = 0x0, destkeyhigh = 0xFFFFFFFF, destkeymask = 0xFFFFFFFF;
- if (Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYDEST | WINEDDBLT_KEYSRCOVERRIDE | WINEDDBLT_KEYDESTOVERRIDE))
- {
- /* The color keying flags are checked for correctness in ddraw */
- if (Flags & WINEDDBLT_KEYSRC)
- {
- keylow = src->SrcBltCKey.dwColorSpaceLowValue;
- keyhigh = src->SrcBltCKey.dwColorSpaceHighValue;
- }
- else if (Flags & WINEDDBLT_KEYSRCOVERRIDE)
- {
- keylow = DDBltFx->ddckSrcColorkey.dwColorSpaceLowValue;
- keyhigh = DDBltFx->ddckSrcColorkey.dwColorSpaceHighValue;
- }
-
- if (Flags & WINEDDBLT_KEYDEST)
- {
- /* Destination color keys are taken from the source surface ! */
- destkeylow = src->DestBltCKey.dwColorSpaceLowValue;
- destkeyhigh = src->DestBltCKey.dwColorSpaceHighValue;
- }
- else if (Flags & WINEDDBLT_KEYDESTOVERRIDE)
- {
- destkeylow = DDBltFx->ddckDestColorkey.dwColorSpaceLowValue;
- destkeyhigh = DDBltFx->ddckDestColorkey.dwColorSpaceHighValue;
- }
-
- if(bpp == 1)
- {
- keymask = 0xff;
- }
- else
- {
- keymask = sEntry->red_mask
- | sEntry->green_mask
- | sEntry->blue_mask;
- }
- Flags &= ~(WINEDDBLT_KEYSRC | WINEDDBLT_KEYDEST | WINEDDBLT_KEYSRCOVERRIDE | WINEDDBLT_KEYDESTOVERRIDE);
- }
-
- if (Flags & WINEDDBLT_DDFX)
- {
- LPBYTE dTopLeft, dTopRight, dBottomLeft, dBottomRight, tmp;
- LONG tmpxy;
- dTopLeft = dbuf;
- dTopRight = dbuf+((dstwidth-1)*bpp);
- dBottomLeft = dTopLeft+((dstheight-1)*dlock.Pitch);
- dBottomRight = dBottomLeft+((dstwidth-1)*bpp);
-
- if (DDBltFx->dwDDFX & WINEDDBLTFX_ARITHSTRETCHY)
- {
- /* I don't think we need to do anything about this flag */
- WARN("Flags=DDBLT_DDFX nothing done for WINEDDBLTFX_ARITHSTRETCHY\n");
- }
- if (DDBltFx->dwDDFX & WINEDDBLTFX_MIRRORLEFTRIGHT)
- {
- tmp = dTopRight;
- dTopRight = dTopLeft;
- dTopLeft = tmp;
- tmp = dBottomRight;
- dBottomRight = dBottomLeft;
- dBottomLeft = tmp;
- dstxinc = dstxinc *-1;
- }
- if (DDBltFx->dwDDFX & WINEDDBLTFX_MIRRORUPDOWN)
- {
- tmp = dTopLeft;
- dTopLeft = dBottomLeft;
- dBottomLeft = tmp;
- tmp = dTopRight;
- dTopRight = dBottomRight;
- dBottomRight = tmp;
- dstyinc = dstyinc *-1;
- }
- if (DDBltFx->dwDDFX & WINEDDBLTFX_NOTEARING)
- {
- /* I don't think we need to do anything about this flag */
- WARN("Flags=DDBLT_DDFX nothing done for WINEDDBLTFX_NOTEARING\n");
- }
- if (DDBltFx->dwDDFX & WINEDDBLTFX_ROTATE180)
- {
- tmp = dBottomRight;
- dBottomRight = dTopLeft;
- dTopLeft = tmp;
- tmp = dBottomLeft;
- dBottomLeft = dTopRight;
- dTopRight = tmp;
- dstxinc = dstxinc * -1;
- dstyinc = dstyinc * -1;
- }
- if (DDBltFx->dwDDFX & WINEDDBLTFX_ROTATE270)
- {
- tmp = dTopLeft;
- dTopLeft = dBottomLeft;
- dBottomLeft = dBottomRight;
- dBottomRight = dTopRight;
- dTopRight = tmp;
- tmpxy = dstxinc;
- dstxinc = dstyinc;
- dstyinc = tmpxy;
- dstxinc = dstxinc * -1;
- }
- if (DDBltFx->dwDDFX & WINEDDBLTFX_ROTATE90)
- {
- tmp = dTopLeft;
- dTopLeft = dTopRight;
- dTopRight = dBottomRight;
- dBottomRight = dBottomLeft;
- dBottomLeft = tmp;
- tmpxy = dstxinc;
- dstxinc = dstyinc;
- dstyinc = tmpxy;
- dstyinc = dstyinc * -1;
- }
- if (DDBltFx->dwDDFX & WINEDDBLTFX_ZBUFFERBASEDEST)
- {
- /* I don't think we need to do anything about this flag */
- WARN("Flags=WINEDDBLT_DDFX nothing done for WINEDDBLTFX_ZBUFFERBASEDEST\n");
- }
- dbuf = dTopLeft;
- Flags &= ~(WINEDDBLT_DDFX);
- }
-
-#define COPY_COLORKEY_FX(type) { \
- const type *s; \
- type *d = (type *)dbuf, *dx, tmp; \
- for (y = sy = 0; y < dstheight; y++, sy += yinc) { \
- s = (const type*)(sbase + (sy >> 16) * slock.Pitch); \
- dx = d; \
- for (x = sx = 0; x < dstwidth; x++, sx += xinc) { \
- tmp = s[sx >> 16]; \
- if (((tmp & keymask) < keylow || (tmp & keymask) > keyhigh) && \
- ((dx[0] & destkeymask) >= destkeylow && (dx[0] & destkeymask) <= destkeyhigh)) { \
- dx[0] = tmp; \
- } \
- dx = (type*)(((LPBYTE)dx)+dstxinc); \
- } \
- d = (type*)(((LPBYTE)d)+dstyinc); \
- } \
- break; }
-
- switch (bpp) {
- case 1: COPY_COLORKEY_FX(BYTE)
- case 2: COPY_COLORKEY_FX(WORD)
- case 4: COPY_COLORKEY_FX(DWORD)
- case 3:
- {
- const BYTE *s;
- BYTE *d = dbuf, *dx;
- for (y = sy = 0; y < dstheight; y++, sy += yinc)
- {
- sbuf = sbase + (sy >> 16) * slock.Pitch;
- dx = d;
- for (x = sx = 0; x < dstwidth; x++, sx+= xinc)
- {
- DWORD pixel, dpixel = 0;
- s = sbuf+3*(sx>>16);
- pixel = s[0]|(s[1]<<8)|(s[2]<<16);
- dpixel = dx[0]|(dx[1]<<8)|(dx[2]<<16);
- if (((pixel & keymask) < keylow || (pixel & keymask) > keyhigh) &&
- ((dpixel & keymask) >= destkeylow || (dpixel & keymask) <= keyhigh))
- {
- dx[0] = (pixel )&0xff;
- dx[1] = (pixel>> 8)&0xff;
- dx[2] = (pixel>>16)&0xff;
- }
- dx+= dstxinc;
- }
- d += dstyinc;
- }
- break;
- }
- default:
- FIXME("%s color-keyed blit not implemented for bpp %d!\n",
- (Flags & WINEDDBLT_KEYSRC) ? "Source" : "Destination", bpp*8);
- ret = WINED3DERR_NOTAVAILABLE;
- goto error;
-#undef COPY_COLORKEY_FX
- }
- }
- }
-
-error:
- if (Flags && FIXME_ON(d3d_surface))
- {
- FIXME("\tUnsupported flags: %08x\n", Flags);
- }
-
-release:
- IWineD3DSurface_UnlockRect(iface);
- if (src && src != This) IWineD3DSurface_UnlockRect((IWineD3DSurface *)src);
- /* Release the converted surface if any */
- if (src && src_surface != (IWineD3DSurface *)src) IWineD3DSurface_Release((IWineD3DSurface *)src);
- return ret;
-}
-
-/*****************************************************************************
- * IWineD3DSurface::BltFast, SW emulation version
- *
- * This is the software implementation of BltFast, as used by GDI surfaces
- * and as a fallback for OpenGL surfaces. This code is taken from the old
- * DirectDraw code, and was originally written by TransGaming.
- *
- * Params:
- * dstx:
- * dsty:
- * src_surface: Source surface to copy from
- * rsrc: Source rectangle
- * trans: Some Flags
- *
- * Returns:
- * WINED3D_OK on success
- *
- *****************************************************************************/
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty,
- IWineD3DSurface *src_surface, const RECT *rsrc, DWORD trans)
-{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
- IWineD3DSurfaceImpl *src = (IWineD3DSurfaceImpl *)src_surface;
-
- int bpp, w, h, x, y;
- WINED3DLOCKED_RECT dlock,slock;
- HRESULT ret = WINED3D_OK;
- RECT rsrc2;
- RECT lock_src, lock_dst, lock_union;
- const BYTE *sbuf;
- BYTE *dbuf;
- const struct wined3d_format *sEntry, *dEntry;
-
- TRACE("iface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, flags %#x.\n",
- iface, dstx, dsty, src_surface, wine_dbgstr_rect(rsrc), trans);
-
- if ((This->Flags & SFLAG_LOCKED) || (src->Flags & SFLAG_LOCKED))
- {
- WARN(" Surface is busy, returning DDERR_SURFACEBUSY\n");
- return WINEDDERR_SURFACEBUSY;
- }
-
- if (!rsrc)
- {
- WARN("rsrc is NULL!\n");
- rsrc2.left = 0;
- rsrc2.top = 0;
- rsrc2.right = src->currentDesc.Width;
- rsrc2.bottom = src->currentDesc.Height;
- rsrc = &rsrc2;
- }
-
- /* Check source rect for validity. Copied from normal Blt. Fixes Baldur's Gate.*/
- if ((rsrc->bottom > src->currentDesc.Height) || (rsrc->bottom < 0)
- || (rsrc->top > src->currentDesc.Height) || (rsrc->top < 0)
- || (rsrc->left > src->currentDesc.Width) || (rsrc->left < 0)
- || (rsrc->right > src->currentDesc.Width) || (rsrc->right < 0)
- || (rsrc->right < rsrc->left) || (rsrc->bottom < rsrc->top))
- {
- WARN("Application gave us bad source rectangle for BltFast.\n");
- return WINEDDERR_INVALIDRECT;
- }
-
- h = rsrc->bottom - rsrc->top;
- if (h > This->currentDesc.Height-dsty) h = This->currentDesc.Height-dsty;
- if (h > src->currentDesc.Height-rsrc->top) h = src->currentDesc.Height-rsrc->top;
- if (h <= 0) return WINEDDERR_INVALIDRECT;
-
- w = rsrc->right - rsrc->left;
- if (w > This->currentDesc.Width-dstx) w = This->currentDesc.Width-dstx;
- if (w > src->currentDesc.Width-rsrc->left) w = src->currentDesc.Width-rsrc->left;
- if (w <= 0) return WINEDDERR_INVALIDRECT;
-
- /* Now compute the locking rectangle... */
- lock_src.left = rsrc->left;
- lock_src.top = rsrc->top;
- lock_src.right = lock_src.left + w;
- lock_src.bottom = lock_src.top + h;
-
- lock_dst.left = dstx;
- lock_dst.top = dsty;
- lock_dst.right = dstx + w;
- lock_dst.bottom = dsty + h;
-
- bpp = This->resource.format->byte_count;
-
- /* We need to lock the surfaces, or we won't get refreshes when done. */
- if (src == This)
- {
- int pitch;
-
- UnionRect(&lock_union, &lock_src, &lock_dst);
-
- /* Lock the union of the two rectangles */
- ret = IWineD3DSurface_LockRect(iface, &dlock, &lock_union, 0);
- if(ret != WINED3D_OK) goto error;
-
- pitch = dlock.Pitch;
- slock.Pitch = dlock.Pitch;
-
- /* Since slock was originally copied from this surface's description, we can just reuse it */
- sbuf = This->resource.allocatedMemory + lock_src.top * pitch + lock_src.left * bpp;
- dbuf = This->resource.allocatedMemory + lock_dst.top * pitch + lock_dst.left * bpp;
- sEntry = src->resource.format;
- dEntry = sEntry;
- }
- else
- {
- ret = IWineD3DSurface_LockRect(src_surface, &slock, &lock_src, WINED3DLOCK_READONLY);
- if(ret != WINED3D_OK) goto error;
- ret = IWineD3DSurface_LockRect(iface, &dlock, &lock_dst, 0);
- if(ret != WINED3D_OK) goto error;
-
- sbuf = slock.pBits;
- dbuf = dlock.pBits;
- TRACE("Dst is at %p, Src is at %p\n", dbuf, sbuf);
-
- sEntry = src->resource.format;
- dEntry = This->resource.format;
- }
-
- /* Handle compressed surfaces first... */
- if (sEntry->Flags & dEntry->Flags & WINED3DFMT_FLAG_COMPRESSED)
- {
- UINT row_block_count;
-
- TRACE("compressed -> compressed copy\n");
- if (trans)
- FIXME("trans arg not supported when a compressed surface is involved\n");
- if (dstx || dsty)
- FIXME("offset for destination surface is not supported\n");
- if (src->resource.format->id != This->resource.format->id)
- {
- FIXME("compressed -> compressed copy only supported for the same type of surface\n");
- ret = WINED3DERR_WRONGTEXTUREFORMAT;
- goto error;
- }
-
- row_block_count = (w + dEntry->block_width - 1) / dEntry->block_width;
- for (y = 0; y < h; y += dEntry->block_height)
- {
- memcpy(dbuf, sbuf, row_block_count * dEntry->block_byte_count);
- dbuf += dlock.Pitch;
- sbuf += slock.Pitch;
- }
-
- goto error;
- }
- if ((sEntry->Flags & WINED3DFMT_FLAG_COMPRESSED) && !(dEntry->Flags & WINED3DFMT_FLAG_COMPRESSED))
- {
- /* TODO: Use the libtxc_dxtn.so shared library to do
- * software decompression
- */
- ERR("Software decompression not supported.\n");
- goto error;
- }
-
- if (trans & (WINEDDBLTFAST_SRCCOLORKEY | WINEDDBLTFAST_DESTCOLORKEY))
- {
- DWORD keylow, keyhigh;
- DWORD mask = src->resource.format->red_mask
- | src->resource.format->green_mask
- | src->resource.format->blue_mask;
-
- /* For some 8-bit formats like L8 and P8 color masks don't make sense */
- if(!mask && bpp==1)
- mask = 0xff;
-
- TRACE("Color keyed copy\n");
- if (trans & WINEDDBLTFAST_SRCCOLORKEY)
- {
- keylow = src->SrcBltCKey.dwColorSpaceLowValue;
- keyhigh = src->SrcBltCKey.dwColorSpaceHighValue;
- }
- else
- {
- /* I'm not sure if this is correct */
- FIXME("WINEDDBLTFAST_DESTCOLORKEY not fully supported yet.\n");
- keylow = This->DestBltCKey.dwColorSpaceLowValue;
- keyhigh = This->DestBltCKey.dwColorSpaceHighValue;
- }
-
-#define COPYBOX_COLORKEY(type) { \
- const type *s = (const type *)sbuf; \
- type *d = (type *)dbuf; \
- type tmp; \
- for (y = 0; y < h; y++) { \
- for (x = 0; x < w; x++) { \
- tmp = s[x]; \
- if ((tmp & mask) < keylow || (tmp & mask) > keyhigh) d[x] = tmp; \
- } \
- s = (const type *)((const BYTE *)s + slock.Pitch); \
- d = (type *)((BYTE *)d + dlock.Pitch); \
- } \
- break; \
- }
-
- switch (bpp) {
- case 1: COPYBOX_COLORKEY(BYTE)
- case 2: COPYBOX_COLORKEY(WORD)
- case 4: COPYBOX_COLORKEY(DWORD)
- case 3:
- {
- const BYTE *s;
- BYTE *d;
- DWORD tmp;
- s = sbuf;
- d = dbuf;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w * 3; x += 3)
- {
- tmp = (DWORD)s[x] + ((DWORD)s[x + 1] << 8) + ((DWORD)s[x + 2] << 16);
- if (tmp < keylow || tmp > keyhigh)
- {
- d[x + 0] = s[x + 0];
- d[x + 1] = s[x + 1];
- d[x + 2] = s[x + 2];
- }
- }
- s += slock.Pitch;
- d += dlock.Pitch;
- }
- break;
- }
- default:
- FIXME("Source color key blitting not supported for bpp %d\n",bpp*8);
- ret = WINED3DERR_NOTAVAILABLE;
- goto error;
- }
-#undef COPYBOX_COLORKEY
- TRACE("Copy Done\n");
- }
- else
- {
- int width = w * bpp;
- INT sbufpitch, dbufpitch;
-
- TRACE("NO color key copy\n");
- /* Handle overlapping surfaces */
- if (sbuf < dbuf)
- {
- sbuf += (h - 1) * slock.Pitch;
- dbuf += (h - 1) * dlock.Pitch;
- sbufpitch = -slock.Pitch;
- dbufpitch = -dlock.Pitch;
- }
- else
- {
- sbufpitch = slock.Pitch;
- dbufpitch = dlock.Pitch;
- }
- for (y = 0; y < h; y++)
- {
- /* This is pretty easy, a line for line memcpy */
- memmove(dbuf, sbuf, width);
- sbuf += sbufpitch;
- dbuf += dbufpitch;
- }
- TRACE("Copy done\n");
- }
-
-error:
- if (src == This)
- {
- IWineD3DSurface_UnlockRect(iface);
- }
- else
- {
- IWineD3DSurface_UnlockRect(iface);
- IWineD3DSurface_UnlockRect(src_surface);
- }
-
- return ret;
-}
-
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags)
-{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
-
- TRACE("(%p) : rect@%p flags(%08x), output lockedRect@%p, memory@%p\n",
- This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
-
- pLockedRect->Pitch = IWineD3DSurface_GetPitch(iface);
-
- if (!pRect)
- {
- pLockedRect->pBits = This->resource.allocatedMemory;
- This->lockedRect.left = 0;
- This->lockedRect.top = 0;
- This->lockedRect.right = This->currentDesc.Width;
- This->lockedRect.bottom = This->currentDesc.Height;
-
- TRACE("Locked Rect (%p) = l %d, t %d, r %d, b %d\n",
- &This->lockedRect, This->lockedRect.left, This->lockedRect.top,
- This->lockedRect.right, This->lockedRect.bottom);
- }
- else
- {
- const struct wined3d_format *format = This->resource.format;
-
- TRACE("Lock Rect (%p) = l %d, t %d, r %d, b %d\n",
- pRect, pRect->left, pRect->top, pRect->right, pRect->bottom);
-
- if ((format->Flags & (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_COMPRESSED)
- {
- /* Compressed textures are block based, so calculate the offset of
- * the block that contains the top-left pixel of the locked rectangle. */
- pLockedRect->pBits = This->resource.allocatedMemory
- + ((pRect->top / format->block_height) * pLockedRect->Pitch)
- + ((pRect->left / format->block_width) * format->block_byte_count);
- }
- else
- {
- pLockedRect->pBits = This->resource.allocatedMemory +
- (pLockedRect->Pitch * pRect->top) +
- (pRect->left * format->byte_count);
- }
- This->lockedRect.left = pRect->left;
- This->lockedRect.top = pRect->top;
- This->lockedRect.right = pRect->right;
- This->lockedRect.bottom = pRect->bottom;
- }
-
- /* No dirtifying is needed for this surface implementation */
- TRACE("returning memory@%p, pitch(%d)\n", pLockedRect->pBits, pLockedRect->Pitch);
-
- return WINED3D_OK;
-}
-
-/* TODO: think about moving this down to resource? */
-const void *WINAPI IWineD3DBaseSurfaceImpl_GetData(IWineD3DSurface *iface)
-{
- IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
-
- /* This should only be called for sysmem textures, it may be a good idea
- * to extend this to all pools at some point in the future */
- if (This->resource.pool != WINED3DPOOL_SYSTEMMEM)
- {
- FIXME("(%p) Attempting to get system memory for a non-system memory texture\n", iface);
- }
- return This->resource.allocatedMemory;
-}
diff --git a/reactos/dll/directx/wine/wined3d/surface_gdi.c b/reactos/dll/directx/wine/wined3d/surface_gdi.c
deleted file mode 100644
index a640b794ee5..00000000000
--- a/reactos/dll/directx/wine/wined3d/surface_gdi.c
+++ /dev/null
@@ -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
-
-/* 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
-};
diff --git a/reactos/dll/directx/wine/wined3d/swapchain.c b/reactos/dll/directx/wine/wined3d/swapchain.c
index 35558adadaa..0b32eca0a91 100644
--- a/reactos/dll/directx/wine/wined3d/swapchain.c
+++ b/reactos/dll/directx/wine/wined3d/swapchain.c
@@ -1,105 +1,287 @@
/*
- *IDirect3DSwapChain9 implementation
+ * Copyright 2002-2003 Jason Edmeades
+ * Copyright 2002-2003 Raphael Junqueira
+ * Copyright 2005 Oliver Stieber
+ * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
+ * Copyright 2011 Henri Verbeet for CodeWeavers
*
- *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 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.
*
- *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
+ * 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"
-
-/*TODO: some of the additional parameters may be required to
- set the gamma ramp (for some weird reason microsoft have left swap gammaramp in device
- but it operates on a swapchain, it may be a good idea to move it to IWineD3DSwapChain for IWineD3D)*/
-
-
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DECLARE_DEBUG_CHANNEL(fps);
/* Do not call while under the GL lock. */
-static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface)
+static void swapchain_cleanup(struct wined3d_swapchain *swapchain)
{
- IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
WINED3DDISPLAYMODE mode;
- unsigned int i;
+ UINT i;
- TRACE("Destroying swapchain %p\n", iface);
+ TRACE("Destroying swapchain %p.\n", swapchain);
- IWineD3DSwapChain_SetGammaRamp(iface, 0, &This->orig_gamma);
+ wined3d_swapchain_set_gamma_ramp(swapchain, 0, &swapchain->orig_gamma);
- /* Release the swapchain's draw buffers. Make sure This->back_buffers[0] is
- * the last buffer to be destroyed, FindContext() depends on that. */
- if (This->front_buffer)
+ /* Release the swapchain's draw buffers. Make sure swapchain->back_buffers[0]
+ * is the last buffer to be destroyed, FindContext() depends on that. */
+ if (swapchain->front_buffer)
{
- surface_set_container(This->front_buffer, WINED3D_CONTAINER_NONE, NULL);
- if (IWineD3DSurface_Release((IWineD3DSurface *)This->front_buffer))
- {
- WARN("(%p) Something's still holding the front buffer (%p).\n",
- This, This->front_buffer);
- }
- This->front_buffer = NULL;
+ surface_set_container(swapchain->front_buffer, WINED3D_CONTAINER_NONE, NULL);
+ if (wined3d_surface_decref(swapchain->front_buffer))
+ WARN("Something's still holding the front buffer (%p).\n", swapchain->front_buffer);
+ swapchain->front_buffer = NULL;
}
- if (This->back_buffers)
+ if (swapchain->back_buffers)
{
- UINT i = This->presentParms.BackBufferCount;
+ i = swapchain->presentParms.BackBufferCount;
while (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 back buffer %u (%p).\n",
- This, i, This->back_buffers[i]);
+ surface_set_container(swapchain->back_buffers[i], WINED3D_CONTAINER_NONE, NULL);
+ if (wined3d_surface_decref(swapchain->back_buffers[i]))
+ WARN("Something's still holding back buffer %u (%p).\n", i, swapchain->back_buffers[i]);
}
- HeapFree(GetProcessHeap(), 0, This->back_buffers);
- This->back_buffers = NULL;
+ HeapFree(GetProcessHeap(), 0, swapchain->back_buffers);
+ swapchain->back_buffers = NULL;
}
- for (i = 0; i < This->num_contexts; ++i)
+ for (i = 0; i < swapchain->num_contexts; ++i)
{
- context_destroy(This->device, This->context[i]);
+ context_destroy(swapchain->device, swapchain->context[i]);
}
- /* 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)
+ HeapFree(GetProcessHeap(), 0, swapchain->context);
+
+ /* 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 (!swapchain->presentParms.Windowed && swapchain->presentParms.AutoRestoreDisplayMode)
{
- mode.Width = This->orig_width;
- mode.Height = This->orig_height;
+ mode.Width = swapchain->orig_width;
+ mode.Height = swapchain->orig_height;
mode.RefreshRate = 0;
- mode.Format = This->orig_fmt;
- IWineD3DDevice_SetDisplayMode((IWineD3DDevice *)This->device, 0, &mode);
+ mode.Format = swapchain->orig_fmt;
+ wined3d_device_set_display_mode(swapchain->device, 0, &mode);
}
- HeapFree(GetProcessHeap(), 0, This->context);
- HeapFree(GetProcessHeap(), 0, This);
+ if (swapchain->backup_dc)
+ {
+ TRACE("Destroying backup wined3d window %p, dc %p.\n", swapchain->backup_wnd, swapchain->backup_dc);
+
+ ReleaseDC(swapchain->backup_wnd, swapchain->backup_dc);
+ DestroyWindow(swapchain->backup_wnd);
+ }
+}
+
+ULONG CDECL wined3d_swapchain_incref(struct wined3d_swapchain *swapchain)
+{
+ ULONG refcount = InterlockedIncrement(&swapchain->ref);
+
+ TRACE("%p increasing refcount to %u.\n", swapchain, refcount);
+
+ return refcount;
+}
+
+/* Do not call while under the GL lock. */
+ULONG CDECL wined3d_swapchain_decref(struct wined3d_swapchain *swapchain)
+{
+ ULONG refcount = InterlockedDecrement(&swapchain->ref);
+
+ TRACE("%p decreasing refcount to %u.\n", swapchain, refcount);
+
+ if (!refcount)
+ {
+ swapchain_cleanup(swapchain);
+ swapchain->parent_ops->wined3d_object_destroyed(swapchain->parent);
+ HeapFree(GetProcessHeap(), 0, swapchain);
+ }
+
+ return refcount;
+}
+
+void * CDECL wined3d_swapchain_get_parent(const struct wined3d_swapchain *swapchain)
+{
+ TRACE("swapchain %p.\n", swapchain);
+
+ return swapchain->parent;
+}
+
+HRESULT CDECL wined3d_swapchain_set_window(struct wined3d_swapchain *swapchain, HWND window)
+{
+ if (!window)
+ window = swapchain->device_window;
+ if (window == swapchain->win_handle)
+ return WINED3D_OK;
+
+ TRACE("Setting swapchain %p window from %p to %p.\n",
+ swapchain, swapchain->win_handle, window);
+ swapchain->win_handle = window;
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_swapchain_present(struct wined3d_swapchain *swapchain,
+ const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override,
+ const RGNDATA *dirty_region, DWORD flags)
+{
+ TRACE("swapchain %p, src_rect %s, dst_rect %s, dst_window_override %p, dirty_region %p, flags %#x.\n",
+ swapchain, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect),
+ dst_window_override, dirty_region, flags);
+
+ wined3d_swapchain_set_window(swapchain, dst_window_override);
+
+ return swapchain->swapchain_ops->swapchain_present(swapchain,
+ src_rect, dst_rect, dirty_region, flags);
+}
+
+HRESULT CDECL wined3d_swapchain_get_front_buffer_data(const struct wined3d_swapchain *swapchain,
+ struct wined3d_surface *dst_surface)
+{
+ POINT offset = {0, 0};
+
+ TRACE("swapchain %p, dst_surface %p.\n", swapchain, dst_surface);
+
+ if (swapchain->presentParms.Windowed)
+ MapWindowPoints(swapchain->win_handle, NULL, &offset, 1);
+
+ wined3d_surface_bltfast(dst_surface, offset.x, offset.y, swapchain->front_buffer, NULL, 0);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_swapchain_get_back_buffer(const struct wined3d_swapchain *swapchain,
+ UINT back_buffer_idx, WINED3DBACKBUFFER_TYPE type, struct wined3d_surface **back_buffer)
+{
+ TRACE("swapchain %p, back_buffer_idx %u, type %#x, back_buffer %p.\n",
+ swapchain, 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
+ * stateblock_init_default_state() 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 = swapchain->back_buffers[back_buffer_idx];
+ if (*back_buffer)
+ wined3d_surface_incref(*back_buffer);
+
+ TRACE("Returning back buffer %p.\n", *back_buffer);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_swapchain_get_raster_status(const struct wined3d_swapchain *swapchain,
+ WINED3DRASTER_STATUS *raster_status)
+{
+ static BOOL warned;
+ /* No OpenGL equivalent */
+ if (!warned)
+ {
+ FIXME("swapchain %p, raster_status %p stub!\n", swapchain, raster_status);
+ warned = TRUE;
+ }
+
+ /* Obtaining the raster status is a widely implemented but optional
+ * feature. When this method returns OK StarCraft 2 expects the
+ * raster_status->InVBlank value to actually change over time. To prevent
+ * StarCraft 2 from running in an infinite loop at startup this method
+ * returns INVALIDCALL. */
+ return WINED3DERR_INVALIDCALL;
+}
+
+HRESULT CDECL wined3d_swapchain_get_display_mode(const struct wined3d_swapchain *swapchain, WINED3DDISPLAYMODE *mode)
+{
+ HRESULT hr;
+
+ TRACE("swapchain %p, mode %p.\n", swapchain, mode);
+
+ hr = wined3d_get_adapter_display_mode(swapchain->device->wined3d, swapchain->device->adapter->ordinal, mode);
+
+ TRACE("Returning w %u, h %u, refresh rate %u, format %s.\n",
+ mode->Width, mode->Height, mode->RefreshRate, debug_d3dformat(mode->Format));
+
+ return hr;
+}
+
+struct wined3d_device * CDECL wined3d_swapchain_get_device(const struct wined3d_swapchain *swapchain)
+{
+ TRACE("swapchain %p.\n", swapchain);
+
+ return swapchain->device;
+}
+
+HRESULT CDECL wined3d_swapchain_get_present_parameters(const struct wined3d_swapchain *swapchain,
+ WINED3DPRESENT_PARAMETERS *present_parameters)
+{
+ TRACE("swapchain %p, present_parameters %p.\n", swapchain, present_parameters);
+
+ *present_parameters = swapchain->presentParms;
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_swapchain_set_gamma_ramp(const struct wined3d_swapchain *swapchain,
+ DWORD flags, const WINED3DGAMMARAMP *ramp)
+{
+ HDC dc;
+
+ TRACE("swapchain %p, flags %#x, ramp %p.\n", swapchain, flags, ramp);
+
+ if (flags)
+ FIXME("Ignoring flags %#x.\n", flags);
+
+ dc = GetDC(swapchain->device_window);
+ SetDeviceGammaRamp(dc, (void *)ramp);
+ ReleaseDC(swapchain->device_window, dc);
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_swapchain_get_gamma_ramp(const struct wined3d_swapchain *swapchain,
+ WINED3DGAMMARAMP *ramp)
+{
+ HDC dc;
+
+ TRACE("swapchain %p, ramp %p.\n", swapchain, ramp);
+
+ dc = GetDC(swapchain->device_window);
+ GetDeviceGammaRamp(dc, ramp);
+ ReleaseDC(swapchain->device_window, dc);
+
+ return WINED3D_OK;
}
/* A GL context is provided by the caller */
-static void swapchain_blit(IWineD3DSwapChainImpl *This, struct wined3d_context *context,
- const RECT *src_rect, const RECT *dst_rect)
+static void swapchain_blit(struct wined3d_swapchain *swapchain,
+ struct wined3d_context *context, const RECT *src_rect, const RECT *dst_rect)
{
- IWineD3DDeviceImpl *device = This->device;
- IWineD3DSurfaceImpl *backbuffer = This->back_buffers[0];
+ struct wined3d_surface *backbuffer = swapchain->back_buffers[0];
+ struct wined3d_device *device = swapchain->device;
UINT src_w = src_rect->right - src_rect->left;
UINT src_h = src_rect->bottom - src_rect->top;
GLenum gl_filter;
@@ -108,14 +290,14 @@ static void swapchain_blit(IWineD3DSwapChainImpl *This, struct wined3d_context *
UINT win_h;
TRACE("swapchain %p, context %p, src_rect %s, dst_rect %s.\n",
- This, context, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect));
+ swapchain, context, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect));
if (src_w == dst_rect->right - dst_rect->left && src_h == dst_rect->bottom - dst_rect->top)
gl_filter = GL_NEAREST;
else
gl_filter = GL_LINEAR;
- GetClientRect(This->win_handle, &win_rect);
+ GetClientRect(swapchain->win_handle, &win_rect);
win_h = win_rect.bottom - win_rect.top;
if (gl_info->fbo_ops.glBlitFramebuffer && is_identity_fixup(backbuffer->resource.format->color_fixup))
@@ -123,6 +305,7 @@ static void swapchain_blit(IWineD3DSwapChainImpl *This, struct wined3d_context *
ENTER_GL();
context_apply_fbo_state_blit(context, GL_READ_FRAMEBUFFER, backbuffer, NULL, SFLAG_INTEXTURE);
glReadBuffer(GL_COLOR_ATTACHMENT0);
+ context_check_fbo_status(context, GL_READ_FRAMEBUFFER);
context_bind_fbo(context, GL_DRAW_FRAMEBUFFER, NULL);
context_set_draw_buffer(context, GL_BACK);
@@ -134,7 +317,7 @@ static void swapchain_blit(IWineD3DSwapChainImpl *This, struct wined3d_context *
IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_COLORWRITEENABLE3));
glDisable(GL_SCISSOR_TEST);
- IWineD3DDeviceImpl_MarkStateDirty(This->device, STATE_RENDER(WINED3DRS_SCISSORTESTENABLE));
+ IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_SCISSORTESTENABLE));
/* Note that the texture is upside down */
gl_info->fbo_ops.glBlitFramebuffer(src_rect->left, src_rect->top, src_rect->right, src_rect->bottom,
@@ -151,10 +334,10 @@ static void swapchain_blit(IWineD3DSwapChainImpl *This, struct wined3d_context *
float tex_right = src_rect->right;
float tex_bottom = src_rect->bottom;
- context2 = context_acquire(This->device, This->back_buffers[0]);
+ context2 = context_acquire(device, swapchain->back_buffers[0]);
context_apply_blit_state(context2, device);
- if(backbuffer->Flags & SFLAG_NORMCOORD)
+ if (backbuffer->flags & SFLAG_NORMCOORD)
{
tex_left /= src_w;
tex_right /= src_w;
@@ -171,7 +354,7 @@ static void swapchain_blit(IWineD3DSwapChainImpl *This, struct wined3d_context *
/* Set up the texture. The surface is not in a IWineD3D*Texture container,
* so there are no d3d texture settings to dirtify
*/
- device->blitter->set_shader((IWineD3DDevice *) device, backbuffer);
+ device->blitter->set_shader(device->blit_priv, context2->gl_info, backbuffer);
glTexParameteri(backbuffer->texture_target, GL_TEXTURE_MIN_FILTER, gl_filter);
glTexParameteri(backbuffer->texture_target, GL_TEXTURE_MAG_FILTER, gl_filter);
@@ -212,7 +395,7 @@ static void swapchain_blit(IWineD3DSwapChainImpl *This, struct wined3d_context *
glPopMatrix();
glPopAttrib();
- device->blitter->unset_shader((IWineD3DDevice *) device);
+ device->blitter->unset_shader(context->gl_info);
checkGLcall("Swapchain present blit(manual)\n");
LEAVE_GL();
@@ -220,18 +403,16 @@ static void swapchain_blit(IWineD3DSwapChainImpl *This, struct wined3d_context *
}
}
-static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion, DWORD dwFlags) {
- IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
+static HRESULT swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT *src_rect_in,
+ const RECT *dst_rect_in, const RGNDATA *dirty_region, DWORD flags)
+{
+ const struct wined3d_fb_state *fb = &swapchain->device->fb;
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
RECT src_rect, dst_rect;
BOOL render_to_fbo;
- unsigned int sync;
- int retval;
- IWineD3DSwapChain_SetDestWindowOverride(iface, hDestWindowOverride);
-
- context = context_acquire(This->device, This->back_buffers[0]);
+ context = context_acquire(swapchain->device, swapchain->back_buffers[0]);
if (!context->valid)
{
context_release(context);
@@ -242,15 +423,17 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
gl_info = context->gl_info;
/* Render the cursor onto the back buffer, using our nifty directdraw blitting code :-) */
- if (This->device->bCursorVisible && This->device->cursorTexture)
+ if (swapchain->device->bCursorVisible &&
+ swapchain->device->cursorTexture &&
+ !swapchain->device->hardwareCursor)
{
- IWineD3DSurfaceImpl cursor;
+ struct wined3d_surface cursor;
RECT destRect =
{
- This->device->xScreenSpace - This->device->xHotSpot,
- This->device->yScreenSpace - This->device->yHotSpot,
- This->device->xScreenSpace + This->device->cursorWidth - This->device->xHotSpot,
- This->device->yScreenSpace + This->device->cursorHeight - This->device->yHotSpot,
+ swapchain->device->xScreenSpace - swapchain->device->xHotSpot,
+ swapchain->device->yScreenSpace - swapchain->device->yHotSpot,
+ swapchain->device->xScreenSpace + swapchain->device->cursorWidth - swapchain->device->xHotSpot,
+ swapchain->device->yScreenSpace + swapchain->device->cursorHeight - swapchain->device->yHotSpot,
};
TRACE("Rendering the cursor. Creating fake surface at %p\n", &cursor);
/* Build a fake surface to call the Blitting code. It is not possible to use the interface passed by
@@ -258,49 +441,47 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
* allows to use the Blitting engine and avoid copying the whole texture -> render target blitting code.
*/
memset(&cursor, 0, sizeof(cursor));
- cursor.lpVtbl = &IWineD3DSurface_Vtbl;
cursor.resource.ref = 1;
- cursor.resource.device = This->device;
+ cursor.resource.device = swapchain->device;
cursor.resource.pool = WINED3DPOOL_SCRATCH;
cursor.resource.format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM);
cursor.resource.resourceType = WINED3DRTYPE_SURFACE;
- cursor.texture_name = This->device->cursorTexture;
+ cursor.texture_name = swapchain->device->cursorTexture;
cursor.texture_target = GL_TEXTURE_2D;
cursor.texture_level = 0;
- cursor.currentDesc.Width = This->device->cursorWidth;
- cursor.currentDesc.Height = This->device->cursorHeight;
+ cursor.resource.width = swapchain->device->cursorWidth;
+ cursor.resource.height = swapchain->device->cursorHeight;
/* The cursor must have pow2 sizes */
- cursor.pow2Width = cursor.currentDesc.Width;
- cursor.pow2Height = cursor.currentDesc.Height;
+ cursor.pow2Width = cursor.resource.width;
+ cursor.pow2Height = cursor.resource.height;
/* The surface is in the texture */
- cursor.Flags |= SFLAG_INTEXTURE;
+ cursor.flags |= SFLAG_INTEXTURE;
/* DDBLT_KEYSRC will cause BltOverride to enable the alpha test with GL_NOTEQUAL, 0.0,
* which is exactly what we want :-)
*/
- if (This->presentParms.Windowed) {
- MapWindowPoints(NULL, This->win_handle, (LPPOINT)&destRect, 2);
- }
- IWineD3DSurface_Blt((IWineD3DSurface *)This->back_buffers[0], &destRect, (IWineD3DSurface *)&cursor,
- NULL, WINEDDBLT_KEYSRC, NULL, WINED3DTEXF_POINT);
+ if (swapchain->presentParms.Windowed)
+ MapWindowPoints(NULL, swapchain->win_handle, (LPPOINT)&destRect, 2);
+ wined3d_surface_blt(swapchain->back_buffers[0], &destRect,
+ &cursor, NULL, WINEDDBLT_KEYSRC, NULL, WINED3DTEXF_POINT);
}
- if (This->device->logo_surface)
+ if (swapchain->device->logo_surface)
{
/* Blit the logo into the upper left corner of the drawable. */
- IWineD3DSurface_BltFast((IWineD3DSurface *)This->back_buffers[0], 0, 0,
- This->device->logo_surface, NULL, WINEDDBLTFAST_SRCCOLORKEY);
+ wined3d_surface_bltfast(swapchain->back_buffers[0], 0, 0,
+ swapchain->device->logo_surface, NULL, WINEDDBLTFAST_SRCCOLORKEY);
}
TRACE("Presenting HDC %p.\n", context->hdc);
- render_to_fbo = This->render_to_fbo;
+ render_to_fbo = swapchain->render_to_fbo;
- if (pSourceRect)
+ if (src_rect_in)
{
- src_rect = *pSourceRect;
+ src_rect = *src_rect_in;
if (!render_to_fbo && (src_rect.left || src_rect.top
- || src_rect.right != This->presentParms.BackBufferWidth
- || src_rect.bottom != This->presentParms.BackBufferHeight))
+ || src_rect.right != swapchain->presentParms.BackBufferWidth
+ || src_rect.bottom != swapchain->presentParms.BackBufferHeight))
{
render_to_fbo = TRUE;
}
@@ -309,16 +490,18 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
{
src_rect.left = 0;
src_rect.top = 0;
- src_rect.right = This->presentParms.BackBufferWidth;
- src_rect.bottom = This->presentParms.BackBufferHeight;
+ src_rect.right = swapchain->presentParms.BackBufferWidth;
+ src_rect.bottom = swapchain->presentParms.BackBufferHeight;
}
- if (pDestRect) dst_rect = *pDestRect;
- else GetClientRect(This->win_handle, &dst_rect);
+ if (dst_rect_in)
+ dst_rect = *dst_rect_in;
+ else
+ GetClientRect(swapchain->win_handle, &dst_rect);
if (!render_to_fbo && (dst_rect.left || dst_rect.top
- || dst_rect.right != This->presentParms.BackBufferWidth
- || dst_rect.bottom != This->presentParms.BackBufferHeight))
+ || dst_rect.right != swapchain->presentParms.BackBufferWidth
+ || dst_rect.bottom != swapchain->presentParms.BackBufferHeight))
{
render_to_fbo = TRUE;
}
@@ -330,31 +513,29 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
* Note that FBO_blit from the backbuffer to the frontbuffer cannot solve
* all these issues - this fails if the window is smaller than the backbuffer.
*/
- if (!This->render_to_fbo && render_to_fbo && wined3d_settings.offscreen_rendering_mode == ORM_FBO)
+ if (!swapchain->render_to_fbo && render_to_fbo && wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
- surface_load_location(This->back_buffers[0], SFLAG_INTEXTURE, NULL);
- surface_modify_location(This->back_buffers[0], SFLAG_INDRAWABLE, FALSE);
- This->render_to_fbo = TRUE;
+ surface_load_location(swapchain->back_buffers[0], SFLAG_INTEXTURE, NULL);
+ surface_modify_location(swapchain->back_buffers[0], SFLAG_INDRAWABLE, FALSE);
+ swapchain->render_to_fbo = TRUE;
}
- if(This->render_to_fbo)
+ if (swapchain->render_to_fbo)
{
/* This codepath should only be hit with the COPY swapeffect. Otherwise a backbuffer-
* window size mismatch is impossible(fullscreen) and src and dst rectangles are
* not allowed(they need the COPY swapeffect)
*
* The DISCARD swap effect is ok as well since any backbuffer content is allowed after
- * the swap
- */
- if(This->presentParms.SwapEffect == WINED3DSWAPEFFECT_FLIP )
- {
+ * the swap. */
+ if (swapchain->presentParms.SwapEffect == WINED3DSWAPEFFECT_FLIP)
FIXME("Render-to-fbo with WINED3DSWAPEFFECT_FLIP\n");
- }
- swapchain_blit(This, context, &src_rect, &dst_rect);
+ swapchain_blit(swapchain, context, &src_rect, &dst_rect);
}
- if (This->num_contexts > 1) wglFinish();
+ if (swapchain->num_contexts > 1)
+ wglFinish();
SwapBuffers(context->hdc); /* TODO: cycle through the swapchain buffers */
TRACE("SwapBuffers called, Starting new frame\n");
@@ -362,12 +543,15 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
if (TRACE_ON(fps))
{
DWORD time = GetTickCount();
- This->frames++;
+ ++swapchain->frames;
+
/* every 1.5 seconds */
- if (time - This->prev_time > 1500) {
- TRACE_(fps)("%p @ approx %.2ffps\n", This, 1000.0*This->frames/(time - This->prev_time));
- This->prev_time = time;
- This->frames = 0;
+ if (time - swapchain->prev_time > 1500)
+ {
+ TRACE_(fps)("%p @ approx %.2ffps\n",
+ swapchain, 1000.0 * swapchain->frames / (time - swapchain->prev_time));
+ swapchain->prev_time = time;
+ swapchain->frames = 0;
}
}
@@ -385,23 +569,23 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
* gets a dark background image. If we clear it with a bright ugly color, the game's
* bug shows up much more than it does on Windows, and the players see single pixels
* with wrong colors.
- * (The Max Payne bug has been confirmed on Windows with the debug runtime)
- */
- if (FALSE && This->presentParms.SwapEffect == WINED3DSWAPEFFECT_DISCARD) {
+ * (The Max Payne bug has been confirmed on Windows with the debug runtime) */
+ if (FALSE && swapchain->presentParms.SwapEffect == WINED3DSWAPEFFECT_DISCARD)
+ {
TRACE("Clearing the color buffer with cyan color\n");
- IWineD3DDevice_Clear((IWineD3DDevice *)This->device, 0, NULL,
+ wined3d_device_clear(swapchain->device, 0, NULL,
WINED3DCLEAR_TARGET, 0xff00ffff, 1.0f, 0);
}
- if (!This->render_to_fbo && ((This->front_buffer->Flags & SFLAG_INSYSMEM)
- || (This->back_buffers[0]->Flags & SFLAG_INSYSMEM)))
+ if (!swapchain->render_to_fbo && ((swapchain->front_buffer->flags & SFLAG_INSYSMEM)
+ || (swapchain->back_buffers[0]->flags & SFLAG_INSYSMEM)))
{
/* Both memory copies of the surfaces are ok, flip them around too instead of dirtifying
* Doesn't work with render_to_fbo because we're not flipping
*/
- IWineD3DSurfaceImpl *front = This->front_buffer;
- IWineD3DSurfaceImpl *back = This->back_buffers[0];
+ struct wined3d_surface *front = swapchain->front_buffer;
+ struct wined3d_surface *back = swapchain->back_buffers[0];
if(front->resource.size == back->resource.size) {
DWORD fbflags;
@@ -409,11 +593,10 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
/* Tell the front buffer surface that is has been modified. However,
* the other locations were preserved during that, so keep the flags.
- * This serves to update the emulated overlay, if any
- */
- fbflags = front->Flags;
+ * This serves to update the emulated overlay, if any. */
+ fbflags = front->flags;
surface_modify_location(front, SFLAG_INDRAWABLE, TRUE);
- front->Flags = fbflags;
+ front->flags = fbflags;
}
else
{
@@ -423,206 +606,207 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
}
else
{
- surface_modify_location(This->front_buffer, SFLAG_INDRAWABLE, TRUE);
+ surface_modify_location(swapchain->front_buffer, SFLAG_INDRAWABLE, TRUE);
/* If the swapeffect is DISCARD, the back buffer is undefined. That means the SYSMEM
* and INTEXTURE copies can keep their old content if they have any defined content.
* If the swapeffect is COPY, the content remains the same. If it is FLIP however,
* the texture / sysmem copy needs to be reloaded from the drawable
*/
- if (This->presentParms.SwapEffect == WINED3DSWAPEFFECT_FLIP)
- {
- surface_modify_location(This->back_buffers[0], SFLAG_INDRAWABLE, TRUE);
- }
+ if (swapchain->presentParms.SwapEffect == WINED3DSWAPEFFECT_FLIP)
+ surface_modify_location(swapchain->back_buffers[0], SFLAG_INDRAWABLE, TRUE);
}
- if (This->device->depth_stencil)
+ if (fb->depth_stencil)
{
- if (This->presentParms.Flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL
- || This->device->depth_stencil->Flags & SFLAG_DISCARD)
+ if (swapchain->presentParms.Flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL
+ || fb->depth_stencil->flags & SFLAG_DISCARD)
{
- surface_modify_ds_location(This->device->depth_stencil, SFLAG_DS_DISCARDED,
- This->device->depth_stencil->currentDesc.Width,
- This->device->depth_stencil->currentDesc.Height);
- if (This->device->depth_stencil == This->device->onscreen_depth_stencil)
+ surface_modify_ds_location(fb->depth_stencil, SFLAG_DS_DISCARDED,
+ fb->depth_stencil->resource.width,
+ fb->depth_stencil->resource.height);
+ if (fb->depth_stencil == swapchain->device->onscreen_depth_stencil)
{
- IWineD3DSurface_Release((IWineD3DSurface *)This->device->onscreen_depth_stencil);
- This->device->onscreen_depth_stencil = NULL;
+ wined3d_surface_decref(swapchain->device->onscreen_depth_stencil);
+ swapchain->device->onscreen_depth_stencil = NULL;
}
}
}
- if (This->presentParms.PresentationInterval != WINED3DPRESENT_INTERVAL_IMMEDIATE
- && gl_info->supported[SGI_VIDEO_SYNC])
- {
- if ((retval = GL_EXTCALL(glXGetVideoSyncSGI(&sync))))
- ERR("glXGetVideoSyncSGI failed(retval = %d\n", retval);
-
- switch(This->presentParms.PresentationInterval) {
- case WINED3DPRESENT_INTERVAL_DEFAULT:
- case WINED3DPRESENT_INTERVAL_ONE:
- if(sync <= This->vSyncCounter) {
- retval = GL_EXTCALL(glXWaitVideoSyncSGI(1, 0, &This->vSyncCounter));
- } else {
- This->vSyncCounter = sync;
- }
- break;
- case WINED3DPRESENT_INTERVAL_TWO:
- if(sync <= This->vSyncCounter + 1) {
- retval = GL_EXTCALL(glXWaitVideoSyncSGI(2, This->vSyncCounter & 0x1, &This->vSyncCounter));
- } else {
- This->vSyncCounter = sync;
- }
- break;
- case WINED3DPRESENT_INTERVAL_THREE:
- if(sync <= This->vSyncCounter + 2) {
- retval = GL_EXTCALL(glXWaitVideoSyncSGI(3, This->vSyncCounter % 0x3, &This->vSyncCounter));
- } else {
- This->vSyncCounter = sync;
- }
- break;
- case WINED3DPRESENT_INTERVAL_FOUR:
- if(sync <= This->vSyncCounter + 3) {
- retval = GL_EXTCALL(glXWaitVideoSyncSGI(4, This->vSyncCounter & 0x3, &This->vSyncCounter));
- } else {
- This->vSyncCounter = sync;
- }
- break;
- default:
- FIXME("Unknown presentation interval %08x\n", This->presentParms.PresentationInterval);
- }
- }
-
context_release(context);
TRACE("returning\n");
return WINED3D_OK;
}
-static HRESULT WINAPI IWineD3DSwapChainImpl_SetDestWindowOverride(IWineD3DSwapChain *iface, HWND window)
+static const struct wined3d_swapchain_ops swapchain_gl_ops =
{
- IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)iface;
+ swapchain_gl_present,
+};
- if (!window) window = swapchain->device_window;
- if (window == swapchain->win_handle) return WINED3D_OK;
+/* Helper function that blits the front buffer contents to the target window. */
+void x11_copy_to_screen(struct wined3d_swapchain *swapchain, const RECT *rect)
+{
+ struct wined3d_surface *front;
+ POINT offset = {0, 0};
+ HDC src_dc, dst_dc;
+ RECT draw_rect;
+ HWND window;
- TRACE("Setting swapchain %p window from %p to %p\n", swapchain, swapchain->win_handle, window);
- swapchain->win_handle = window;
+ TRACE("swapchain %p, rect %s.\n", swapchain, wine_dbgstr_rect(rect));
+
+ front = swapchain->front_buffer;
+ if (!(front->resource.usage & WINED3DUSAGE_RENDERTARGET))
+ return;
+
+ TRACE("Copying surface %p to screen.\n", front);
+
+ src_dc = front->hDC;
+ window = swapchain->win_handle;
+ dst_dc = GetDCEx(window, 0, DCX_CLIPSIBLINGS | DCX_CACHE);
+
+ /* Front buffer coordinates are screen coordinates. Map them to the
+ * destination window if not fullscreened. */
+ if (swapchain->presentParms.Windowed)
+ ClientToScreen(window, &offset);
+
+ TRACE("offset %s.\n", wine_dbgstr_point(&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(dst_dc, front->palette->hpal, FALSE);
+ RealizePalette(dst_dc); /* sends messages => deadlocks */
+ }
+#endif
+
+ draw_rect.left = 0;
+ draw_rect.right = front->resource.width;
+ draw_rect.top = 0;
+ draw_rect.bottom = front->resource.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(&draw_rect, &draw_rect, &xrc);
+ }
+ }
+#endif
+
+ if (!rect)
+ {
+ /* 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(&draw_rect, &draw_rect, &front->lockedRect);
+ }
+ else
+ {
+ IntersectRect(&draw_rect, &draw_rect, rect);
+ }
+
+ BitBlt(dst_dc, draw_rect.left - offset.x, draw_rect.top - offset.y,
+ draw_rect.right - draw_rect.left, draw_rect.bottom - draw_rect.top,
+ src_dc, draw_rect.left, draw_rect.top, SRCCOPY);
+ ReleaseDC(window, dst_dc);
+}
+
+static HRESULT swapchain_gdi_present(struct wined3d_swapchain *swapchain, const RECT *src_rect_in,
+ const RECT *dst_rect_in, const RGNDATA *dirty_region, DWORD flags)
+{
+ struct wined3d_surface *front, *back;
+
+ if (!swapchain->back_buffers)
+ {
+ WARN("Swapchain doesn't have a backbuffer, returning WINED3DERR_INVALIDCALL\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+ front = swapchain->front_buffer;
+ back = swapchain->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(swapchain, NULL);
return WINED3D_OK;
}
-static const IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl =
+static const struct wined3d_swapchain_ops swapchain_gdi_ops =
{
- /* IUnknown */
- IWineD3DBaseSwapChainImpl_QueryInterface,
- IWineD3DBaseSwapChainImpl_AddRef,
- IWineD3DBaseSwapChainImpl_Release,
- /* IWineD3DSwapChain */
- IWineD3DBaseSwapChainImpl_GetParent,
- IWineD3DSwapChainImpl_Destroy,
- IWineD3DBaseSwapChainImpl_GetDevice,
- IWineD3DSwapChainImpl_Present,
- IWineD3DSwapChainImpl_SetDestWindowOverride,
- IWineD3DBaseSwapChainImpl_GetFrontBufferData,
- IWineD3DBaseSwapChainImpl_GetBackBuffer,
- IWineD3DBaseSwapChainImpl_GetRasterStatus,
- IWineD3DBaseSwapChainImpl_GetDisplayMode,
- IWineD3DBaseSwapChainImpl_GetPresentParameters,
- IWineD3DBaseSwapChainImpl_SetGammaRamp,
- IWineD3DBaseSwapChainImpl_GetGammaRamp
+ swapchain_gdi_present,
};
-static LONG fullscreen_style(LONG style)
-{
- /* Make sure the window is managed, otherwise we won't get keyboard input. */
- style |= WS_POPUP | WS_SYSMENU;
- style &= ~(WS_CAPTION | WS_THICKFRAME);
-
- return style;
-}
-
-static LONG fullscreen_exstyle(LONG exstyle)
-{
- /* Filter out window decorations. */
- exstyle &= ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE);
-
- return exstyle;
-}
-
-void swapchain_setup_fullscreen_window(IWineD3DSwapChainImpl *swapchain, UINT w, UINT h)
-{
- IWineD3DDeviceImpl *device = swapchain->device;
- HWND window = swapchain->device_window;
- BOOL filter_messages;
- LONG style, exstyle;
-
- TRACE("Setting up window %p for fullscreen mode.\n", window);
-
- if (device->style || device->exStyle)
- {
- ERR("Changing the window style for window %p, but another style (%08x, %08x) is already stored.\n",
- window, device->style, device->exStyle);
- }
-
- device->style = GetWindowLongW(window, GWL_STYLE);
- device->exStyle = GetWindowLongW(window, GWL_EXSTYLE);
-
- style = fullscreen_style(device->style);
- exstyle = fullscreen_exstyle(device->exStyle);
-
- TRACE("Old style was %08x, %08x, setting to %08x, %08x.\n",
- device->style, device->exStyle, style, exstyle);
-
- filter_messages = device->filter_messages;
- device->filter_messages = TRUE;
-
- SetWindowLongW(window, GWL_STYLE, style);
- SetWindowLongW(window, GWL_EXSTYLE, exstyle);
- SetWindowPos(window, HWND_TOP, 0, 0, w, h, SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOACTIVATE);
-
- device->filter_messages = filter_messages;
-}
-
-void swapchain_restore_fullscreen_window(IWineD3DSwapChainImpl *swapchain)
-{
- IWineD3DDeviceImpl *device = swapchain->device;
- HWND window = swapchain->device_window;
- BOOL filter_messages;
- LONG style, exstyle;
-
- if (!device->style && !device->exStyle) return;
-
- TRACE("Restoring window style of window %p to %08x, %08x.\n",
- window, device->style, device->exStyle);
-
- style = GetWindowLongW(window, GWL_STYLE);
- exstyle = GetWindowLongW(window, GWL_EXSTYLE);
-
- filter_messages = device->filter_messages;
- device->filter_messages = TRUE;
-
- /* Only restore the style if the application didn't modify it during the
- * fullscreen phase. Some applications change it before calling Reset()
- * when switching between windowed and fullscreen modes (HL2), some
- * depend on the original style (Eve Online). */
- if (style == fullscreen_style(device->style) && exstyle == fullscreen_exstyle(device->exStyle))
- {
- SetWindowLongW(window, GWL_STYLE, device->style);
- SetWindowLongW(window, GWL_EXSTYLE, device->exStyle);
- }
- SetWindowPos(window, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
-
- device->filter_messages = filter_messages;
-
- /* Delete the old values. */
- device->style = 0;
- device->exStyle = 0;
-}
-
-
/* Do not call while under the GL lock. */
-HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface_type,
- IWineD3DDeviceImpl *device, WINED3DPRESENT_PARAMETERS *present_parameters, void *parent)
+static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, WINED3DSURFTYPE surface_type,
+ struct wined3d_device *device, WINED3DPRESENT_PARAMETERS *present_parameters,
+ void *parent, const struct wined3d_parent_ops *parent_ops)
{
const struct wined3d_adapter *adapter = device->adapter;
const struct wined3d_format *format;
@@ -649,11 +833,11 @@ HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface
switch (surface_type)
{
case SURFACE_GDI:
- swapchain->lpVtbl = &IWineGDISwapChain_Vtbl;
+ swapchain->swapchain_ops = &swapchain_gdi_ops;
break;
case SURFACE_OPENGL:
- swapchain->lpVtbl = &IWineD3DSwapChain_Vtbl;
+ swapchain->swapchain_ops = &swapchain_gl_ops;
break;
case SURFACE_UNKNOWN:
@@ -665,17 +849,12 @@ HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface
swapchain->device = device;
swapchain->parent = parent;
+ swapchain->parent_ops = parent_ops;
swapchain->ref = 1;
swapchain->win_handle = window;
swapchain->device_window = window;
- if (!present_parameters->Windowed && window)
- {
- swapchain_setup_fullscreen_window(swapchain, present_parameters->BackBufferWidth,
- present_parameters->BackBufferHeight);
- }
-
- IWineD3D_GetAdapterDisplayMode(device->wined3d, adapter->ordinal, &mode);
+ wined3d_get_adapter_display_mode(device->wined3d, adapter->ordinal, &mode);
swapchain->orig_width = mode.Width;
swapchain->orig_height = mode.Height;
swapchain->orig_fmt = mode.Format;
@@ -720,18 +899,18 @@ HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface
}
TRACE("Creating front buffer.\n");
- hr = IWineD3DDeviceParent_CreateRenderTarget(device->device_parent, parent,
+ hr = device->device_parent->ops->create_rendertarget(device->device_parent, parent,
swapchain->presentParms.BackBufferWidth, swapchain->presentParms.BackBufferHeight,
swapchain->presentParms.BackBufferFormat, swapchain->presentParms.MultiSampleType,
swapchain->presentParms.MultiSampleQuality, TRUE /* Lockable */,
- (IWineD3DSurface **)&swapchain->front_buffer);
+ &swapchain->front_buffer);
if (FAILED(hr))
{
WARN("Failed to create front buffer, hr %#x.\n", hr);
goto err;
}
- surface_set_container(swapchain->front_buffer, WINED3D_CONTAINER_SWAPCHAIN, (IWineD3DBase *)swapchain);
+ surface_set_container(swapchain->front_buffer, WINED3D_CONTAINER_SWAPCHAIN, swapchain);
if (surface_type == SURFACE_OPENGL)
{
surface_modify_location(swapchain->front_buffer, SFLAG_INDRAWABLE, TRUE);
@@ -751,7 +930,7 @@ HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface
mode.Format = present_parameters->BackBufferFormat;
mode.RefreshRate = present_parameters->FullScreen_RefreshRateInHz;
- hr = IWineD3DDevice_SetDisplayMode((IWineD3DDevice *)device, 0, &mode);
+ hr = wined3d_device_set_display_mode(device, 0, &mode);
if (FAILED(hr))
{
WARN("Failed to set display mode, hr %#x.\n", hr);
@@ -760,15 +939,6 @@ HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface
displaymode_set = TRUE;
}
- swapchain->context = HeapAlloc(GetProcessHeap(), 0, sizeof(swapchain->context));
- if (!swapchain->context)
- {
- ERR("Failed to create the context array.\n");
- hr = E_OUTOFMEMORY;
- goto err;
- }
- swapchain->num_contexts = 1;
-
if (surface_type == SURFACE_OPENGL)
{
static const enum wined3d_format_id formats[] =
@@ -782,6 +952,15 @@ HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+ swapchain->context = HeapAlloc(GetProcessHeap(), 0, sizeof(swapchain->context));
+ if (!swapchain->context)
+ {
+ ERR("Failed to create the context array.\n");
+ hr = E_OUTOFMEMORY;
+ goto err;
+ }
+ swapchain->num_contexts = 1;
+
/* In WGL both color, depth and stencil are features of a pixel format. In case of D3D they are separate.
* You are able to add a depth + stencil surface at a later stage when you need it.
* In order to support this properly in WineD3D we need the ability to recreate the opengl context and
@@ -816,10 +995,6 @@ HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface
}
context_release(swapchain->context[0]);
}
- else
- {
- swapchain->context[0] = NULL;
- }
if (swapchain->presentParms.BackBufferCount > 0)
{
@@ -835,18 +1010,18 @@ HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface
for (i = 0; i < swapchain->presentParms.BackBufferCount; ++i)
{
TRACE("Creating back buffer %u.\n", i);
- hr = IWineD3DDeviceParent_CreateRenderTarget(device->device_parent, parent,
+ hr = device->device_parent->ops->create_rendertarget(device->device_parent, parent,
swapchain->presentParms.BackBufferWidth, swapchain->presentParms.BackBufferHeight,
swapchain->presentParms.BackBufferFormat, swapchain->presentParms.MultiSampleType,
swapchain->presentParms.MultiSampleQuality, TRUE /* Lockable */,
- (IWineD3DSurface **)&swapchain->back_buffers[i]);
+ &swapchain->back_buffers[i]);
if (FAILED(hr))
{
WARN("Failed to create back buffer %u, hr %#x.\n", i, hr);
goto err;
}
- surface_set_container(swapchain->back_buffers[i], WINED3D_CONTAINER_SWAPCHAIN, (IWineD3DBase *)swapchain);
+ surface_set_container(swapchain->back_buffers[i], WINED3D_CONTAINER_SWAPCHAIN, swapchain);
}
}
@@ -856,11 +1031,11 @@ HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface
TRACE("Creating depth/stencil buffer.\n");
if (!device->auto_depth_stencil)
{
- hr = IWineD3DDeviceParent_CreateDepthStencilSurface(device->device_parent,
+ hr = device->device_parent->ops->create_depth_stencil(device->device_parent,
swapchain->presentParms.BackBufferWidth, swapchain->presentParms.BackBufferHeight,
swapchain->presentParms.AutoDepthStencilFormat, swapchain->presentParms.MultiSampleType,
swapchain->presentParms.MultiSampleQuality, FALSE /* FIXME: Discard */,
- (IWineD3DSurface **)&device->auto_depth_stencil);
+ &device->auto_depth_stencil);
if (FAILED(hr))
{
WARN("Failed to create the auto depth stencil, hr %#x.\n", hr);
@@ -871,7 +1046,7 @@ HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface
}
}
- IWineD3DSwapChain_GetGammaRamp((IWineD3DSwapChain *)swapchain, &swapchain->orig_gamma);
+ wined3d_swapchain_get_gamma_ramp(swapchain, &swapchain->orig_gamma);
return WINED3D_OK;
@@ -896,7 +1071,8 @@ err:
{
for (i = 0; i < swapchain->presentParms.BackBufferCount; ++i)
{
- if (swapchain->back_buffers[i]) IWineD3DSurface_Release((IWineD3DSurface *)swapchain->back_buffers[i]);
+ if (swapchain->back_buffers[i])
+ wined3d_surface_decref(swapchain->back_buffers[i]);
}
HeapFree(GetProcessHeap(), 0, swapchain->back_buffers);
}
@@ -912,47 +1088,95 @@ err:
HeapFree(GetProcessHeap(), 0, swapchain->context);
}
- if (swapchain->front_buffer) IWineD3DSurface_Release((IWineD3DSurface *)swapchain->front_buffer);
+ if (swapchain->front_buffer)
+ wined3d_surface_decref(swapchain->front_buffer);
return hr;
}
/* Do not call while under the GL lock. */
-struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChain *iface)
+HRESULT CDECL wined3d_swapchain_create(struct wined3d_device *device,
+ WINED3DPRESENT_PARAMETERS *present_parameters, WINED3DSURFTYPE surface_type,
+ void *parent, const struct wined3d_parent_ops *parent_ops,
+ struct wined3d_swapchain **swapchain)
+{
+ struct wined3d_swapchain *object;
+ HRESULT hr;
+
+ TRACE("device %p, present_parameters %p, swapchain %p, parent %p, surface_type %#x.\n",
+ device, present_parameters, swapchain, parent, surface_type);
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (!object)
+ {
+ ERR("Failed to allocate swapchain memory.\n");
+ return E_OUTOFMEMORY;
+ }
+
+ hr = swapchain_init(object, surface_type, device, present_parameters, parent, parent_ops);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize swapchain, hr %#x.\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ return hr;
+ }
+
+ TRACE("Created swapchain %p.\n", object);
+ *swapchain = object;
+
+ return WINED3D_OK;
+}
+
+/* Do not call while under the GL lock. */
+static struct wined3d_context *swapchain_create_context(struct wined3d_swapchain *swapchain)
{
- IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *) iface;
struct wined3d_context **newArray;
struct wined3d_context *ctx;
- TRACE("Creating a new context for swapchain %p, thread %d\n", This, GetCurrentThreadId());
+ TRACE("Creating a new context for swapchain %p, thread %u.\n", swapchain, GetCurrentThreadId());
- if (!(ctx = context_create(This, This->front_buffer, This->ds_format)))
+ if (!(ctx = context_create(swapchain, swapchain->front_buffer, swapchain->ds_format)))
{
ERR("Failed to create a new context for the swapchain\n");
return NULL;
}
context_release(ctx);
- newArray = HeapAlloc(GetProcessHeap(), 0, sizeof(*newArray) * (This->num_contexts + 1));
+ newArray = HeapAlloc(GetProcessHeap(), 0, sizeof(*newArray) * (swapchain->num_contexts + 1));
if(!newArray) {
ERR("Out of memory when trying to allocate a new context array\n");
- context_destroy(This->device, ctx);
+ context_destroy(swapchain->device, ctx);
return NULL;
}
- memcpy(newArray, This->context, sizeof(*newArray) * This->num_contexts);
- HeapFree(GetProcessHeap(), 0, This->context);
- newArray[This->num_contexts] = ctx;
- This->context = newArray;
- This->num_contexts++;
+ memcpy(newArray, swapchain->context, sizeof(*newArray) * swapchain->num_contexts);
+ HeapFree(GetProcessHeap(), 0, swapchain->context);
+ newArray[swapchain->num_contexts] = ctx;
+ swapchain->context = newArray;
+ swapchain->num_contexts++;
TRACE("Returning context %p\n", ctx);
return ctx;
}
+struct wined3d_context *swapchain_get_context(struct wined3d_swapchain *swapchain)
+{
+ DWORD tid = GetCurrentThreadId();
+ unsigned int i;
+
+ for (i = 0; i < swapchain->num_contexts; ++i)
+ {
+ if (swapchain->context[i]->tid == tid)
+ return swapchain->context[i];
+ }
+
+ /* Create a new context for the thread */
+ return swapchain_create_context(swapchain);
+}
+
void get_drawable_size_swapchain(struct wined3d_context *context, UINT *width, UINT *height)
{
/* The drawable size of an onscreen drawable is the surface size.
* (Actually: The window size, but the surface is created in window size) */
- *width = context->current_rt->currentDesc.Width;
- *height = context->current_rt->currentDesc.Height;
+ *width = context->current_rt->resource.width;
+ *height = context->current_rt->resource.height;
}
diff --git a/reactos/dll/directx/wine/wined3d/swapchain_base.c b/reactos/dll/directx/wine/wined3d/swapchain_base.c
deleted file mode 100644
index 083585fbb56..00000000000
--- a/reactos/dll/directx/wine/wined3d/swapchain_base.c
+++ /dev/null
@@ -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;
-
-}
diff --git a/reactos/dll/directx/wine/wined3d/swapchain_gdi.c b/reactos/dll/directx/wine/wined3d/swapchain_gdi.c
deleted file mode 100644
index 8920caec85c..00000000000
--- a/reactos/dll/directx/wine/wined3d/swapchain_gdi.c
+++ /dev/null
@@ -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
-};
diff --git a/reactos/dll/directx/wine/wined3d/texture.c b/reactos/dll/directx/wine/wined3d/texture.c
index ce95567f547..34801b8e510 100644
--- a/reactos/dll/directx/wine/wined3d/texture.c
+++ b/reactos/dll/directx/wine/wined3d/texture.c
@@ -1,11 +1,9 @@
/*
- * IWineD3DTexture 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
+ * 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,270 +25,610 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
-/* Do not call while under the GL lock. */
-static void texture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb)
+static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops,
+ UINT layer_count, UINT level_count, WINED3DRESOURCETYPE resource_type, struct wined3d_device *device,
+ DWORD usage, const struct wined3d_format *format, WINED3DPOOL pool, void *parent,
+ const struct wined3d_parent_ops *parent_ops, const struct wined3d_resource_ops *resource_ops)
{
- /* Override the IWineD3DResource PreLoad method. */
- IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
- IWineD3DDeviceImpl *device = This->resource.device;
- struct wined3d_context *context = NULL;
- unsigned int i;
- BOOL srgb_mode;
- BOOL *dirty;
+ HRESULT hr;
- TRACE("(%p) : About to load texture.\n", This);
-
- switch (srgb)
+ hr = resource_init(&texture->resource, device, resource_type, format,
+ WINED3DMULTISAMPLE_NONE, 0, usage, pool, 0, 0, 0, 0,
+ parent, parent_ops, resource_ops);
+ if (FAILED(hr))
{
- case SRGB_RGB:
- srgb_mode = FALSE;
- break;
-
- case SRGB_BOTH:
- texture_internal_preload(iface, SRGB_RGB);
- /* Fallthrough */
-
- case SRGB_SRGB:
- srgb_mode = TRUE;
- break;
-
- default:
- srgb_mode = This->baseTexture.is_srgb;
- break;
+ WARN("Failed to initialize resource, returning %#x\n", hr);
+ return hr;
}
- dirty = srgb_mode ? &This->baseTexture.texture_srgb.dirty : &This->baseTexture.texture_rgb.dirty;
- if (!device->isInDraw)
+ texture->texture_ops = texture_ops;
+ texture->sub_resources = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+ level_count * layer_count * sizeof(*texture->sub_resources));
+ if (!texture->sub_resources)
+ {
+ ERR("Failed to allocate sub-resource array.\n");
+ resource_cleanup(&texture->resource);
+ return E_OUTOFMEMORY;
+ }
+
+ texture->layer_count = layer_count;
+ texture->level_count = level_count;
+ texture->filter_type = (usage & WINED3DUSAGE_AUTOGENMIPMAP) ? WINED3DTEXF_LINEAR : WINED3DTEXF_NONE;
+ texture->lod = 0;
+ texture->texture_rgb.dirty = TRUE;
+ texture->texture_srgb.dirty = TRUE;
+ texture->flags = WINED3D_TEXTURE_POW2_MAT_IDENT;
+
+ if (texture->resource.format->flags & WINED3DFMT_FLAG_FILTERING)
+ {
+ texture->min_mip_lookup = minMipLookup;
+ texture->mag_lookup = magLookup;
+ }
+ else
+ {
+ texture->min_mip_lookup = minMipLookup_noFilter;
+ texture->mag_lookup = magLookup_noFilter;
+ }
+
+ return WINED3D_OK;
+}
+
+/* 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;
+}
+
+static void wined3d_texture_unload(struct wined3d_texture *texture)
+{
+ struct wined3d_device *device = texture->resource.device;
+ struct wined3d_context *context = NULL;
+
+ if (texture->texture_rgb.name || texture->texture_srgb.name)
{
- /* context_acquire() sets isInDraw to TRUE when loading a pbuffer into a texture,
- * thus no danger of recursive calls. */
context = context_acquire(device, NULL);
}
- if (This->resource.format->id == WINED3DFMT_P8_UINT
- || This->resource.format->id == WINED3DFMT_P8_UINT_A8_UNORM)
+ if (texture->texture_rgb.name)
+ gltexture_delete(&texture->texture_rgb);
+
+ if (texture->texture_srgb.name)
+ gltexture_delete(&texture->texture_srgb);
+
+ if (context) context_release(context);
+
+ wined3d_texture_set_dirty(texture, TRUE);
+
+ resource_unload(&texture->resource);
+}
+
+static void wined3d_texture_cleanup(struct wined3d_texture *texture)
+{
+ UINT sub_count = texture->level_count * texture->layer_count;
+ UINT i;
+
+ TRACE("texture %p.\n", texture);
+
+ for (i = 0; i < sub_count; ++i)
{
- for (i = 0; i < This->baseTexture.level_count; ++i)
- {
- IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)This->baseTexture.sub_resources[i];
- if (palette9_changed(surface))
- {
- TRACE("Reloading surface because the d3d8/9 palette was changed.\n");
- /* 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);
- }
- }
+ struct wined3d_resource *sub_resource = texture->sub_resources[i];
+
+ if (sub_resource)
+ texture->texture_ops->texture_sub_resource_cleanup(sub_resource);
}
- /* If the texture is marked dirty or the srgb sampler setting has changed
- * since the last load then reload the surfaces. */
- if (*dirty)
+ wined3d_texture_unload(texture);
+ HeapFree(GetProcessHeap(), 0, texture->sub_resources);
+ resource_cleanup(&texture->resource);
+}
+
+void wined3d_texture_set_dirty(struct wined3d_texture *texture, BOOL dirty)
+{
+ texture->texture_rgb.dirty = dirty;
+ texture->texture_srgb.dirty = dirty;
+}
+
+/* Context activation is done by the caller. */
+static HRESULT wined3d_texture_bind(struct wined3d_texture *texture,
+ const struct wined3d_gl_info *gl_info, BOOL srgb, BOOL *set_surface_desc)
+{
+ struct gl_texture *gl_tex;
+ BOOL new_texture = FALSE;
+ HRESULT hr = WINED3D_OK;
+ GLenum target;
+
+ TRACE("texture %p, srgb %#x, set_surface_desc %p.\n", texture, srgb, set_surface_desc);
+
+ /* sRGB mode cache for preload() calls outside drawprim. */
+ if (srgb)
+ texture->flags |= WINED3D_TEXTURE_IS_SRGB;
+ else
+ texture->flags &= ~WINED3D_TEXTURE_IS_SRGB;
+
+ gl_tex = wined3d_texture_get_gl_texture(texture, gl_info, srgb);
+ target = texture->target;
+
+ ENTER_GL();
+ /* Generate a texture name if we don't already have one. */
+ if (!gl_tex->name)
{
- for (i = 0; i < This->baseTexture.level_count; ++i)
+ *set_surface_desc = TRUE;
+ glGenTextures(1, &gl_tex->name);
+ checkGLcall("glGenTextures");
+ TRACE("Generated texture %d.\n", gl_tex->name);
+ if (texture->resource.pool == WINED3DPOOL_DEFAULT)
{
- IWineD3DSurface_LoadTexture((IWineD3DSurface *)This->baseTexture.sub_resources[i], srgb_mode);
+ /* Tell OpenGL to try and keep this texture in video ram (well mostly). */
+ GLclampf tmp = 0.9f;
+ glPrioritizeTextures(1, &gl_tex->name, &tmp);
+ }
+ /* Initialise the state of the texture object to the OpenGL defaults,
+ * not the D3D 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;
+ if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
+ gl_tex->states[WINED3DTEXSTA_SRGBTEXTURE] = TRUE;
+ else
+ gl_tex->states[WINED3DTEXSTA_SRGBTEXTURE] = srgb;
+ gl_tex->states[WINED3DTEXSTA_SHADOW] = FALSE;
+ wined3d_texture_set_dirty(texture, TRUE);
+ new_texture = TRUE;
+
+ if (texture->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(target, gl_tex->name);
+ checkGLcall("glBindTexture");
+ glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
+ checkGLcall("glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE)");
}
}
else
{
- TRACE("(%p) Texture not dirty, nothing to do.\n", iface);
+ *set_surface_desc = FALSE;
}
- if (context) context_release(context);
+ if (gl_tex->name)
+ {
+ glBindTexture(target, gl_tex->name);
+ checkGLcall("glBindTexture");
+ if (new_texture)
+ {
+ /* For a new texture we have to set the texture levels after
+ * binding the texture. 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. (I.e., do not care about cond_np2 here,
+ * just look for GL_TEXTURE_RECTANGLE_ARB.) */
+ if (target != GL_TEXTURE_RECTANGLE_ARB)
+ {
+ TRACE("Setting GL_TEXTURE_MAX_LEVEL to %u.\n", texture->level_count - 1);
+ glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, texture->level_count - 1);
+ checkGLcall("glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, texture->level_count)");
+ }
+ if (target == GL_TEXTURE_CUBE_MAP_ARB)
+ {
+ /* Cubemaps are always set to clamp, regardless of the sampler state. */
+ glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
+ }
+ }
+ }
+ else
+ {
+ ERR("This texture doesn't have an OpenGL texture assigned to it.\n");
+ hr = WINED3DERR_INVALIDCALL;
+ }
- /* No longer dirty. */
- *dirty = FALSE;
+ LEAVE_GL();
+ return hr;
}
-static void texture_cleanup(IWineD3DTextureImpl *This)
+/* 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)
{
- unsigned int i;
+ GLint gl_wrap;
- TRACE("(%p) : Cleaning up\n", This);
-
- for (i = 0; i < This->baseTexture.level_count; ++i)
+ if (d3d_wrap < WINED3DTADDRESS_WRAP || d3d_wrap > WINED3DTADDRESS_MIRRORONCE)
{
- IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)This->baseTexture.sub_resources[i];
- if (surface)
+ FIXME("Unrecognized or unsupported WINED3DTEXTUREADDRESS %#x.\n", d3d_wrap);
+ return;
+ }
+
+ /* Cubemaps are always set to clamp, regardless of the sampler state. */
+ if (target == GL_TEXTURE_CUBE_MAP_ARB
+ || (cond_np2 && d3d_wrap == WINED3DTADDRESS_WRAP))
+ 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 wined3d_texture_apply_state_changes(struct wined3d_texture *texture,
+ const DWORD sampler_states[WINED3D_HIGHEST_SAMPLER_STATE + 1],
+ const struct wined3d_gl_info *gl_info)
+{
+ BOOL cond_np2 = texture->flags & WINED3D_TEXTURE_COND_NP2;
+ GLenum target = texture->target;
+ struct gl_texture *gl_tex;
+ DWORD state;
+ DWORD aniso;
+
+ TRACE("texture %p, sampler_states %p.\n", texture, sampler_states);
+
+ gl_tex = wined3d_texture_get_gl_texture(texture, gl_info,
+ texture->flags & WINED3D_TEXTURE_IS_SRGB);
+
+ /* This function relies on the correct texture being bound and loaded. */
+
+ if (sampler_states[WINED3DSAMP_ADDRESSU] != gl_tex->states[WINED3DTEXSTA_ADDRESSU])
+ {
+ state = sampler_states[WINED3DSAMP_ADDRESSU];
+ apply_wrap(gl_info, target, state, GL_TEXTURE_WRAP_S, cond_np2);
+ gl_tex->states[WINED3DTEXSTA_ADDRESSU] = state;
+ }
+
+ if (sampler_states[WINED3DSAMP_ADDRESSV] != gl_tex->states[WINED3DTEXSTA_ADDRESSV])
+ {
+ state = sampler_states[WINED3DSAMP_ADDRESSV];
+ apply_wrap(gl_info, target, state, GL_TEXTURE_WRAP_T, cond_np2);
+ gl_tex->states[WINED3DTEXSTA_ADDRESSV] = state;
+ }
+
+ if (sampler_states[WINED3DSAMP_ADDRESSW] != gl_tex->states[WINED3DTEXSTA_ADDRESSW])
+ {
+ state = sampler_states[WINED3DSAMP_ADDRESSW];
+ apply_wrap(gl_info, target, state, GL_TEXTURE_WRAP_R, cond_np2);
+ gl_tex->states[WINED3DTEXSTA_ADDRESSW] = state;
+ }
+
+ if (sampler_states[WINED3DSAMP_BORDERCOLOR] != gl_tex->states[WINED3DTEXSTA_BORDERCOLOR])
+ {
+ float col[4];
+
+ state = sampler_states[WINED3DSAMP_BORDERCOLOR];
+ D3DCOLORTOGLFLOAT4(state, col);
+ TRACE("Setting border color for %#x to %#x.\n", target, state);
+ glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, &col[0]);
+ checkGLcall("glTexParameterfv(..., GL_TEXTURE_BORDER_COLOR, ...)");
+ gl_tex->states[WINED3DTEXSTA_BORDERCOLOR] = state;
+ }
+
+ if (sampler_states[WINED3DSAMP_MAGFILTER] != gl_tex->states[WINED3DTEXSTA_MAGFILTER])
+ {
+ GLint gl_value;
+
+ state = sampler_states[WINED3DSAMP_MAGFILTER];
+ if (state > WINED3DTEXF_ANISOTROPIC)
+ FIXME("Unrecognized or unsupported MAGFILTER* value %d.\n", state);
+
+ gl_value = wined3d_gl_mag_filter(texture->mag_lookup,
+ min(max(state, WINED3DTEXF_POINT), WINED3DTEXF_LINEAR));
+ TRACE("ValueMAG=%#x setting MAGFILTER to %#x.\n", state, gl_value);
+ glTexParameteri(target, GL_TEXTURE_MAG_FILTER, gl_value);
+
+ gl_tex->states[WINED3DTEXSTA_MAGFILTER] = state;
+ }
+
+ if ((sampler_states[WINED3DSAMP_MINFILTER] != gl_tex->states[WINED3DTEXSTA_MINFILTER]
+ || sampler_states[WINED3DSAMP_MIPFILTER] != gl_tex->states[WINED3DTEXSTA_MIPFILTER]
+ || sampler_states[WINED3DSAMP_MAXMIPLEVEL] != gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL]))
+ {
+ GLint gl_value;
+
+ gl_tex->states[WINED3DTEXSTA_MIPFILTER] = sampler_states[WINED3DSAMP_MIPFILTER];
+ gl_tex->states[WINED3DTEXSTA_MINFILTER] = sampler_states[WINED3DSAMP_MINFILTER];
+ gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] = sampler_states[WINED3DSAMP_MAXMIPLEVEL];
+
+ if (gl_tex->states[WINED3DTEXSTA_MINFILTER] > WINED3DTEXF_ANISOTROPIC
+ || gl_tex->states[WINED3DTEXSTA_MIPFILTER] > WINED3DTEXF_ANISOTROPIC)
{
- /* 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);
+ FIXME("Unrecognized or unsupported D3DSAMP_MINFILTER value %#x D3DSAMP_MIPFILTER value %#x.\n",
+ gl_tex->states[WINED3DTEXSTA_MINFILTER],
+ gl_tex->states[WINED3DTEXSTA_MIPFILTER]);
+ }
+ gl_value = wined3d_gl_min_mip_filter(texture->min_mip_lookup,
+ min(max(sampler_states[WINED3DSAMP_MINFILTER], WINED3DTEXF_POINT), WINED3DTEXF_LINEAR),
+ min(max(sampler_states[WINED3DSAMP_MIPFILTER], WINED3DTEXF_NONE), WINED3DTEXF_LINEAR));
+
+ TRACE("ValueMIN=%#x, ValueMIP=%#x, setting MINFILTER to %#x.\n",
+ sampler_states[WINED3DSAMP_MINFILTER],
+ sampler_states[WINED3DSAMP_MIPFILTER], gl_value);
+ glTexParameteri(target, GL_TEXTURE_MIN_FILTER, gl_value);
+ checkGLcall("glTexParameter GL_TEXTURE_MIN_FILTER, ...");
+
+ if (!cond_np2)
+ {
+ if (gl_tex->states[WINED3DTEXSTA_MIPFILTER] == WINED3DTEXF_NONE)
+ gl_value = texture->lod;
+ else if (gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] >= texture->level_count)
+ gl_value = texture->level_count - 1;
+ else if (gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] < texture->lod)
+ /* texture->lod is already clamped in the setter. */
+ gl_value = texture->lod;
+ else
+ gl_value = gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL];
+
+ /* Note that WINED3DSAMP_MAXMIPLEVEL specifies the largest mipmap
+ * (default 0), while GL_TEXTURE_MAX_LEVEL specifies the smallest
+ * mimap used (default 1000). So WINED3DSAMP_MAXMIPLEVEL
+ * corresponds to GL_TEXTURE_BASE_LEVEL. */
+ glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, gl_value);
}
}
- TRACE("(%p) : Cleaning up base texture\n", This);
- basetexture_cleanup((IWineD3DBaseTexture *)This);
-}
+ 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 = sampler_states[WINED3DSAMP_MAXANISOTROPY];
-/* *******************************************
- IWineD3DTexture IUnknown parts follow
- ******************************************* */
-
-static HRESULT WINAPI IWineD3DTextureImpl_QueryInterface(IWineD3DTexture *iface, REFIID riid, LPVOID *ppobj)
-{
- IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)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_IWineD3DTexture)){
- IUnknown_AddRef(iface);
- *ppobj = This;
- return WINED3D_OK;
- }
- *ppobj = NULL;
- return E_NOINTERFACE;
-}
-
-static ULONG WINAPI IWineD3DTextureImpl_AddRef(IWineD3DTexture *iface) {
- IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)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 IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
- IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
- ULONG ref;
- TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
- ref = InterlockedDecrement(&This->resource.ref);
- if (!ref)
+ if (gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] != aniso)
{
- texture_cleanup(This);
- This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
- HeapFree(GetProcessHeap(), 0, This);
+ if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
+ {
+ glTexParameteri(target, 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;
}
- return ref;
-}
-
-/* ****************************************************
- IWineD3DTexture IWineD3DResource parts follow
- **************************************************** */
-static HRESULT WINAPI IWineD3DTextureImpl_SetPrivateData(IWineD3DTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
- return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
-}
-
-static HRESULT WINAPI IWineD3DTextureImpl_GetPrivateData(IWineD3DTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
- return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
-}
-
-static HRESULT WINAPI IWineD3DTextureImpl_FreePrivateData(IWineD3DTexture *iface, REFGUID refguid) {
- return resource_free_private_data((IWineD3DResource *)iface, refguid);
-}
-
-static DWORD WINAPI IWineD3DTextureImpl_SetPriority(IWineD3DTexture *iface, DWORD PriorityNew) {
- return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
-}
-
-static DWORD WINAPI IWineD3DTextureImpl_GetPriority(IWineD3DTexture *iface) {
- return resource_get_priority((IWineD3DResource *)iface);
-}
-
-/* Do not call while under the GL lock. */
-static void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) {
- texture_internal_preload((IWineD3DBaseTexture *) iface, SRGB_ANY);
-}
-
-/* Do not call while under the GL lock. */
-static void WINAPI IWineD3DTextureImpl_UnLoad(IWineD3DTexture *iface) {
- unsigned int i;
- IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)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)
+ /* These should always be the same unless EXT_texture_sRGB_decode is supported. */
+ if (sampler_states[WINED3DSAMP_SRGBTEXTURE] != gl_tex->states[WINED3DTEXSTA_SRGBTEXTURE])
{
- IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)This->baseTexture.sub_resources[i];
- IWineD3DSurface_UnLoad((IWineD3DSurface *)surface);
- surface_set_texture_name(surface, 0, FALSE); /* Delete rgb name */
- surface_set_texture_name(surface, 0, TRUE); /* delete srgb name */
+ glTexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT,
+ sampler_states[WINED3DSAMP_SRGBTEXTURE] ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT);
+ checkGLcall("glTexParameteri(GL_TEXTURE_SRGB_DECODE_EXT)");
}
- basetexture_unload((IWineD3DBaseTexture *)iface);
+ if (!(texture->resource.format->flags & WINED3DFMT_FLAG_SHADOW)
+ != !gl_tex->states[WINED3DTEXSTA_SHADOW])
+ {
+ if (texture->resource.format->flags & WINED3DFMT_FLAG_SHADOW)
+ {
+ glTexParameteri(target, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE);
+ glTexParameteri(target, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
+ checkGLcall("glTexParameteri(target, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB)");
+ gl_tex->states[WINED3DTEXSTA_SHADOW] = TRUE;
+ }
+ else
+ {
+ glTexParameteri(target, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
+ checkGLcall("glTexParameteri(target, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE)");
+ gl_tex->states[WINED3DTEXSTA_SHADOW] = FALSE;
+ }
+ }
}
-static WINED3DRESOURCETYPE WINAPI IWineD3DTextureImpl_GetType(IWineD3DTexture *iface) {
- return resource_get_type((IWineD3DResource *)iface);
-}
-
-static void * WINAPI IWineD3DTextureImpl_GetParent(IWineD3DTexture *iface)
+ULONG CDECL wined3d_texture_incref(struct wined3d_texture *texture)
{
- TRACE("iface %p.\n", iface);
+ ULONG refcount = InterlockedIncrement(&texture->resource.ref);
- return ((IWineD3DTextureImpl *)iface)->resource.parent;
+ TRACE("%p increasing refcount to %u.\n", texture, refcount);
+
+ return refcount;
}
-/* ******************************************************
- IWineD3DTexture IWineD3DBaseTexture parts follow
- ****************************************************** */
-static DWORD WINAPI IWineD3DTextureImpl_SetLOD(IWineD3DTexture *iface, DWORD LODNew) {
- return basetexture_set_lod((IWineD3DBaseTexture *)iface, LODNew);
+/* Do not call while under the GL lock. */
+ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
+{
+ ULONG refcount = InterlockedDecrement(&texture->resource.ref);
+
+ TRACE("%p decreasing refcount to %u.\n", texture, refcount);
+
+ if (!refcount)
+ {
+ wined3d_texture_cleanup(texture);
+ texture->resource.parent_ops->wined3d_object_destroyed(texture->resource.parent);
+ HeapFree(GetProcessHeap(), 0, texture);
+ }
+
+ return refcount;
}
-static DWORD WINAPI IWineD3DTextureImpl_GetLOD(IWineD3DTexture *iface) {
- return basetexture_get_lod((IWineD3DBaseTexture *)iface);
+HRESULT CDECL wined3d_texture_set_private_data(struct wined3d_texture *texture,
+ REFGUID guid, const void *data, DWORD data_size, DWORD flags)
+{
+ return resource_set_private_data(&texture->resource, guid, data, data_size, flags);
}
-static DWORD WINAPI IWineD3DTextureImpl_GetLevelCount(IWineD3DTexture *iface) {
- return basetexture_get_level_count((IWineD3DBaseTexture *)iface);
+HRESULT CDECL wined3d_texture_get_private_data(const struct wined3d_texture *texture,
+ REFGUID guid, void *data, DWORD *data_size)
+{
+ return resource_get_private_data(&texture->resource, guid, data, data_size);
}
-static HRESULT WINAPI IWineD3DTextureImpl_SetAutoGenFilterType(IWineD3DTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
- return basetexture_set_autogen_filter_type((IWineD3DBaseTexture *)iface, FilterType);
+HRESULT CDECL wined3d_texture_free_private_data(struct wined3d_texture *texture, REFGUID guid)
+{
+ return resource_free_private_data(&texture->resource, guid);
}
-static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DTextureImpl_GetAutoGenFilterType(IWineD3DTexture *iface) {
- return basetexture_get_autogen_filter_type((IWineD3DBaseTexture *)iface);
+DWORD CDECL wined3d_texture_set_priority(struct wined3d_texture *texture, DWORD priority)
+{
+ return resource_set_priority(&texture->resource, priority);
}
-static void WINAPI IWineD3DTextureImpl_GenerateMipSubLevels(IWineD3DTexture *iface) {
- basetexture_generate_mipmaps((IWineD3DBaseTexture *)iface);
+DWORD CDECL wined3d_texture_get_priority(const struct wined3d_texture *texture)
+{
+ return resource_get_priority(&texture->resource);
}
-/* Internal function, No d3d mapping */
-static BOOL WINAPI IWineD3DTextureImpl_SetDirty(IWineD3DTexture *iface, BOOL dirty) {
- return basetexture_set_dirty((IWineD3DBaseTexture *)iface, dirty);
+/* Do not call while under the GL lock. */
+void CDECL wined3d_texture_preload(struct wined3d_texture *texture)
+{
+ texture->texture_ops->texture_preload(texture, SRGB_ANY);
}
-static BOOL WINAPI IWineD3DTextureImpl_GetDirty(IWineD3DTexture *iface) {
- return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
+WINED3DRESOURCETYPE CDECL wined3d_texture_get_type(const struct wined3d_texture *texture)
+{
+ TRACE("texture %p.\n", texture);
+
+ return texture->resource.resourceType;
+}
+
+void * CDECL wined3d_texture_get_parent(const struct wined3d_texture *texture)
+{
+ TRACE("texture %p.\n", texture);
+
+ return texture->resource.parent;
+}
+
+DWORD CDECL wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod)
+{
+ DWORD old = texture->lod;
+
+ TRACE("texture %p, lod %u.\n", texture, 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 (texture->resource.pool != WINED3DPOOL_MANAGED)
+ {
+ TRACE("Ignoring SetLOD on %s texture, returning 0.\n", debug_d3dpool(texture->resource.pool));
+ return 0;
+ }
+
+ if (lod >= texture->level_count)
+ lod = texture->level_count - 1;
+
+ if (texture->lod != lod)
+ {
+ texture->lod = lod;
+
+ texture->texture_rgb.states[WINED3DTEXSTA_MAXMIPLEVEL] = ~0U;
+ texture->texture_srgb.states[WINED3DTEXSTA_MAXMIPLEVEL] = ~0U;
+ if (texture->bind_count)
+ IWineD3DDeviceImpl_MarkStateDirty(texture->resource.device, STATE_SAMPLER(texture->sampler));
+ }
+
+ return old;
+}
+
+DWORD CDECL wined3d_texture_get_lod(const struct wined3d_texture *texture)
+{
+ TRACE("texture %p, returning %u.\n", texture, texture->lod);
+
+ return texture->lod;
+}
+
+DWORD CDECL wined3d_texture_get_level_count(const struct wined3d_texture *texture)
+{
+ TRACE("texture %p, returning %u.\n", texture, texture->level_count);
+
+ return texture->level_count;
+}
+
+HRESULT CDECL wined3d_texture_set_autogen_filter_type(struct wined3d_texture *texture,
+ WINED3DTEXTUREFILTERTYPE filter_type)
+{
+ FIXME("texture %p, filter_type %s stub!\n", texture, debug_d3dtexturefiltertype(filter_type));
+
+ if (!(texture->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP))
+ {
+ WARN("Texture doesn't have AUTOGENMIPMAP usage.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ texture->filter_type = filter_type;
+
+ return WINED3D_OK;
+}
+
+WINED3DTEXTUREFILTERTYPE CDECL wined3d_texture_get_autogen_filter_type(const struct wined3d_texture *texture)
+{
+ TRACE("texture %p.\n", texture);
+
+ return texture->filter_type;
+}
+
+void CDECL wined3d_texture_generate_mipmaps(struct wined3d_texture *texture)
+{
+ /* TODO: Implement filters using GL_SGI_generate_mipmaps. */
+ FIXME("texture %p stub!\n", texture);
+}
+
+struct wined3d_resource * CDECL wined3d_texture_get_sub_resource(struct wined3d_texture *texture,
+ UINT sub_resource_idx)
+{
+ UINT sub_count = texture->level_count * texture->layer_count;
+
+ TRACE("texture %p, sub_resource_idx %u.\n", texture, sub_resource_idx);
+
+ if (sub_resource_idx >= sub_count)
+ {
+ WARN("sub_resource_idx %u >= sub_count %u.\n", sub_resource_idx, sub_count);
+ return NULL;
+ }
+
+ return texture->sub_resources[sub_resource_idx];
+}
+
+HRESULT CDECL wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
+ UINT layer, const WINED3DBOX *dirty_region)
+{
+ struct wined3d_resource *sub_resource;
+
+ TRACE("texture %p, layer %u, dirty_region %p.\n", texture, layer, dirty_region);
+
+ if (!(sub_resource = wined3d_texture_get_sub_resource(texture, layer * texture->level_count)))
+ {
+ WARN("Failed to get sub-resource.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+
+ wined3d_texture_set_dirty(texture, TRUE);
+ texture->texture_ops->texture_sub_resource_add_dirty_region(sub_resource, dirty_region);
+
+ return WINED3D_OK;
}
/* Context activation is done by the caller. */
-static HRESULT WINAPI IWineD3DTextureImpl_BindTexture(IWineD3DTexture *iface, BOOL srgb) {
- IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
+static HRESULT texture2d_bind(struct wined3d_texture *texture,
+ const struct wined3d_gl_info *gl_info, BOOL srgb)
+{
BOOL set_gl_texture_desc;
HRESULT hr;
- TRACE("(%p) : relay to BaseTexture\n", This);
+ TRACE("texture %p, gl_info %p, srgb %#x.\n", texture, gl_info, srgb);
- hr = basetexture_bind((IWineD3DBaseTexture *)iface, srgb, &set_gl_texture_desc);
- if (set_gl_texture_desc && SUCCEEDED(hr)) {
- UINT i;
+ hr = wined3d_texture_bind(texture, gl_info, srgb, &set_gl_texture_desc);
+ if (set_gl_texture_desc && SUCCEEDED(hr))
+ {
+ UINT sub_count = texture->level_count * texture->layer_count;
+ BOOL srgb_tex = !gl_info->supported[EXT_TEXTURE_SRGB_DECODE]
+ && (texture->flags & WINED3D_TEXTURE_IS_SRGB);
struct gl_texture *gl_tex;
+ UINT i;
- if(This->baseTexture.is_srgb) {
- gl_tex = &This->baseTexture.texture_srgb;
- } else {
- gl_tex = &This->baseTexture.texture_rgb;
- }
+ gl_tex = wined3d_texture_get_gl_texture(texture, gl_info, srgb_tex);
- for (i = 0; i < This->baseTexture.level_count; ++i)
+ for (i = 0; i < sub_count; ++i)
{
- IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)This->baseTexture.sub_resources[i];
- surface_set_texture_name(surface, gl_tex->name, This->baseTexture.is_srgb);
+ struct wined3d_surface *surface = surface_from_resource(texture->sub_resources[i]);
+ surface_set_texture_name(surface, gl_tex->name, srgb_tex);
}
/* Conditinal non power of two textures use a different clamping
@@ -301,9 +639,9 @@ static HRESULT WINAPI IWineD3DTextureImpl_BindTexture(IWineD3DTexture *iface, BO
* state. The same applies to filtering. Even if the texture has only
* one mip level, the default LINEAR_MIPMAP_LINEAR filter causes a SW
* fallback on macos. */
- if (IWineD3DBaseTexture_IsCondNP2(iface))
+ if (texture->flags & WINED3D_TEXTURE_COND_NP2)
{
- GLenum target = This->baseTexture.target;
+ GLenum target = texture->target;
ENTER_GL();
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@@ -326,147 +664,257 @@ static HRESULT WINAPI IWineD3DTextureImpl_BindTexture(IWineD3DTexture *iface, BO
return hr;
}
-static BOOL WINAPI IWineD3DTextureImpl_IsCondNP2(IWineD3DTexture *iface) {
- IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
- TRACE("(%p)\n", This);
+static BOOL texture_srgb_mode(struct wined3d_texture *texture, enum WINED3DSRGB srgb)
+{
+ switch (srgb)
+ {
+ case SRGB_RGB:
+ return FALSE;
- return This->cond_np2;
+ case SRGB_SRGB:
+ return TRUE;
+
+ default:
+ return texture->flags & WINED3D_TEXTURE_IS_SRGB;
+ }
}
-/* *******************************************
- IWineD3DTexture IWineD3DTexture parts follow
- ******************************************* */
-static HRESULT WINAPI IWineD3DTextureImpl_GetLevelDesc(IWineD3DTexture *iface, UINT level, WINED3DSURFACE_DESC *desc)
+/* Do not call while under the GL lock. */
+static void texture2d_preload(struct wined3d_texture *texture, enum WINED3DSRGB srgb)
{
- IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
- IWineD3DSurface *surface;
+ UINT sub_count = texture->level_count * texture->layer_count;
+ struct wined3d_device *device = texture->resource.device;
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+ struct wined3d_context *context = NULL;
+ struct gl_texture *gl_tex;
+ BOOL srgb_mode;
+ UINT i;
- TRACE("iface %p, level %u, desc %p.\n", iface, level, desc);
+ TRACE("texture %p, srgb %#x.\n", texture, srgb);
- if (!(surface = (IWineD3DSurface *)basetexture_get_sub_resource(texture, 0, level)))
+ srgb_mode = texture_srgb_mode(texture, srgb);
+ gl_tex = wined3d_texture_get_gl_texture(texture, gl_info, srgb_mode);
+
+ if (!device->isInDraw)
{
- WARN("Failed to get sub-resource.\n");
- return WINED3DERR_INVALIDCALL;
+ /* No danger of recursive calls, context_acquire() sets isInDraw to TRUE
+ * when loading offscreen render targets into the texture. */
+ context = context_acquire(device, NULL);
}
- IWineD3DSurface_GetDesc(surface, desc);
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DTextureImpl_GetSurfaceLevel(IWineD3DTexture *iface,
- UINT level, IWineD3DSurface **surface)
-{
- IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
- IWineD3DSurface *s;
-
- TRACE("iface %p, level %u, surface %p.\n", iface, level, surface);
-
- if (!(s = (IWineD3DSurface *)basetexture_get_sub_resource(texture, 0, level)))
+ if (texture->resource.format->id == WINED3DFMT_P8_UINT
+ || texture->resource.format->id == WINED3DFMT_P8_UINT_A8_UNORM)
{
- WARN("Failed to get sub-resource.\n");
- return WINED3DERR_INVALIDCALL;
+ for (i = 0; i < sub_count; ++i)
+ {
+ struct wined3d_surface *surface = surface_from_resource(texture->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);
+ }
+ }
}
- IWineD3DSurface_AddRef(s);
- *surface = s;
-
- TRACE("Returning surface %p.\n", *surface);
-
- return WINED3D_OK;
-}
-
-static HRESULT WINAPI IWineD3DTextureImpl_LockRect(IWineD3DTexture *iface,
- UINT level, WINED3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags)
-{
- IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
- IWineD3DSurface *surface;
-
- TRACE("iface %p, level %u, locked_rect %p, rect %s, flags %#x.\n",
- iface, level, locked_rect, wine_dbgstr_rect(rect), flags);
-
- if (!(surface = (IWineD3DSurface *)basetexture_get_sub_resource(texture, 0, level)))
+ if (gl_tex->dirty)
{
- WARN("Failed to get sub-resource.\n");
- return WINED3DERR_INVALIDCALL;
+ /* Reload the surfaces if the texture is marked dirty. */
+ for (i = 0; i < sub_count; ++i)
+ {
+ surface_load(surface_from_resource(texture->sub_resources[i]), srgb_mode);
+ }
+ }
+ else
+ {
+ TRACE("Texture %p not dirty, nothing to do.\n", texture);
}
- return IWineD3DSurface_LockRect(surface, locked_rect, rect, flags);
+ /* No longer dirty. */
+ gl_tex->dirty = FALSE;
+
+ if (context) context_release(context);
}
-static HRESULT WINAPI IWineD3DTextureImpl_UnlockRect(IWineD3DTexture *iface, UINT level)
+static void texture2d_sub_resource_add_dirty_region(struct wined3d_resource *sub_resource,
+ const WINED3DBOX *dirty_region)
{
- IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
- IWineD3DSurface *surface;
+ surface_add_dirty_rect(surface_from_resource(sub_resource), dirty_region);
+}
- TRACE("iface %p, level %u.\n", iface, level);
+static void texture2d_sub_resource_cleanup(struct wined3d_resource *sub_resource)
+{
+ struct wined3d_surface *surface = surface_from_resource(sub_resource);
- if (!(surface = (IWineD3DSurface *)basetexture_get_sub_resource(texture, 0, level)))
+ /* 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);
+ wined3d_surface_decref(surface);
+}
+
+/* Do not call while under the GL lock. */
+static void texture2d_unload(struct wined3d_resource *resource)
+{
+ struct wined3d_texture *texture = wined3d_texture_from_resource(resource);
+ UINT sub_count = texture->level_count * texture->layer_count;
+ UINT i;
+
+ TRACE("texture %p.\n", texture);
+
+ for (i = 0; i < sub_count; ++i)
{
- WARN("Failed to get sub-resource.\n");
- return WINED3DERR_INVALIDCALL;
+ struct wined3d_resource *sub_resource = texture->sub_resources[i];
+ struct wined3d_surface *surface = surface_from_resource(sub_resource);
+
+ sub_resource->resource_ops->resource_unload(sub_resource);
+ surface_set_texture_name(surface, 0, FALSE); /* Delete RGB name */
+ surface_set_texture_name(surface, 0, TRUE); /* Delete sRGB name */
}
- return IWineD3DSurface_UnlockRect(surface);
+ wined3d_texture_unload(texture);
}
-static HRESULT WINAPI IWineD3DTextureImpl_AddDirtyRect(IWineD3DTexture *iface, const RECT *dirty_rect)
+static const struct wined3d_texture_ops texture2d_ops =
{
- IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
- IWineD3DSurfaceImpl *surface;
-
- TRACE("iface %p, dirty_rect %s.\n", iface, wine_dbgstr_rect(dirty_rect));
-
- if (!(surface = (IWineD3DSurfaceImpl *)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;
- surface_add_dirty_rect(surface, dirty_rect);
-
- return WINED3D_OK;
-}
-
-static const IWineD3DTextureVtbl IWineD3DTexture_Vtbl =
-{
- /* IUnknown */
- IWineD3DTextureImpl_QueryInterface,
- IWineD3DTextureImpl_AddRef,
- IWineD3DTextureImpl_Release,
- /* IWineD3DResource */
- IWineD3DTextureImpl_GetParent,
- IWineD3DTextureImpl_SetPrivateData,
- IWineD3DTextureImpl_GetPrivateData,
- IWineD3DTextureImpl_FreePrivateData,
- IWineD3DTextureImpl_SetPriority,
- IWineD3DTextureImpl_GetPriority,
- IWineD3DTextureImpl_PreLoad,
- IWineD3DTextureImpl_UnLoad,
- IWineD3DTextureImpl_GetType,
- /* IWineD3DBaseTexture */
- IWineD3DTextureImpl_SetLOD,
- IWineD3DTextureImpl_GetLOD,
- IWineD3DTextureImpl_GetLevelCount,
- IWineD3DTextureImpl_SetAutoGenFilterType,
- IWineD3DTextureImpl_GetAutoGenFilterType,
- IWineD3DTextureImpl_GenerateMipSubLevels,
- IWineD3DTextureImpl_SetDirty,
- IWineD3DTextureImpl_GetDirty,
- IWineD3DTextureImpl_BindTexture,
- IWineD3DTextureImpl_IsCondNP2,
- /* IWineD3DTexture */
- IWineD3DTextureImpl_GetLevelDesc,
- IWineD3DTextureImpl_GetSurfaceLevel,
- IWineD3DTextureImpl_LockRect,
- IWineD3DTextureImpl_UnlockRect,
- IWineD3DTextureImpl_AddDirtyRect
+ texture2d_bind,
+ texture2d_preload,
+ texture2d_sub_resource_add_dirty_region,
+ texture2d_sub_resource_cleanup,
};
-HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT levels,
- IWineD3DDeviceImpl *device, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool,
+static const struct wined3d_resource_ops texture2d_resource_ops =
+{
+ texture2d_unload,
+};
+
+static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_length, UINT levels,
+ struct wined3d_device *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);
+ }
+
+ hr = wined3d_texture_init(texture, &texture2d_ops, 6, levels,
+ WINED3DRTYPE_CUBETEXTURE, device, usage, format, pool,
+ parent, parent_ops, &texture2d_resource_ops);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize texture, 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->pow2_matrix[0] = 1.0f;
+ texture->pow2_matrix[5] = 1.0f;
+ texture->pow2_matrix[10] = 1.0f;
+ texture->pow2_matrix[15] = 1.0f;
+ }
+ else
+ {
+ /* Precalculated scaling for 'faked' non power of two texture coords. */
+ texture->pow2_matrix[0] = ((float)edge_length) / ((float)pow2_edge_length);
+ texture->pow2_matrix[5] = ((float)edge_length) / ((float)pow2_edge_length);
+ texture->pow2_matrix[10] = ((float)edge_length) / ((float)pow2_edge_length);
+ texture->pow2_matrix[15] = 1.0f;
+ texture->flags &= ~WINED3D_TEXTURE_POW2_MAT_IDENT;
+ }
+ texture->target = GL_TEXTURE_CUBE_MAP_ARB;
+
+ /* Generate all the surfaces. */
+ tmp_w = edge_length;
+ for (i = 0; i < texture->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->level_count + i;
+ struct wined3d_surface *surface;
+
+ hr = device->device_parent->ops->create_surface(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);
+ wined3d_texture_cleanup(texture);
+ return hr;
+ }
+
+ surface_set_container(surface, WINED3D_CONTAINER_TEXTURE, texture);
+ surface_set_texture_target(surface, cube_targets[j]);
+ texture->sub_resources[idx] = &surface->resource;
+ TRACE("Created surface level %u @ %p.\n", i, surface);
+ }
+ tmp_w = max(1, tmp_w >> 1);
+ }
+
+ return WINED3D_OK;
+}
+
+static HRESULT texture_init(struct wined3d_texture *texture, UINT width, UINT height, UINT levels,
+ struct wined3d_device *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;
@@ -531,13 +979,12 @@ HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT
TRACE("Calculated levels = %u.\n", levels);
}
- texture->lpVtbl = &IWineD3DTexture_Vtbl;
-
- hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, 1, levels,
- WINED3DRTYPE_TEXTURE, device, 0, usage, format, pool, parent, parent_ops);
+ hr = wined3d_texture_init(texture, &texture2d_ops, 1, levels,
+ WINED3DRTYPE_TEXTURE, device, usage, format, pool,
+ parent, parent_ops, &texture2d_resource_ops);
if (FAILED(hr))
{
- WARN("Failed to initialize basetexture, returning %#x.\n", hr);
+ WARN("Failed to initialize texture, returning %#x.\n", hr);
return hr;
}
@@ -547,83 +994,395 @@ HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT
* doesn't work in combination with ARB_TEXTURE_RECTANGLE. */
if (gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT] && (width != pow2_width || height != pow2_height))
{
- 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_2D;
- texture->cond_np2 = TRUE;
- texture->baseTexture.minMipLookup = minMipLookup_noFilter;
+ texture->pow2_matrix[0] = 1.0f;
+ texture->pow2_matrix[5] = 1.0f;
+ texture->pow2_matrix[10] = 1.0f;
+ texture->pow2_matrix[15] = 1.0f;
+ texture->target = GL_TEXTURE_2D;
+ texture->flags |= WINED3D_TEXTURE_COND_NP2;
+ texture->min_mip_lookup = minMipLookup_noFilter;
}
else if (gl_info->supported[ARB_TEXTURE_RECTANGLE] && (width != pow2_width || height != pow2_height)
&& !(format->id == WINED3DFMT_P8_UINT && gl_info->supported[EXT_PALETTED_TEXTURE]
&& wined3d_settings.rendertargetlock_mode == RTL_READTEX))
{
- if ((width != 1) || (height != 1)) texture->baseTexture.pow2Matrix_identity = FALSE;
+ if (width != 1 || height != 1)
+ texture->flags &= ~WINED3D_TEXTURE_POW2_MAT_IDENT;
- texture->baseTexture.pow2Matrix[0] = (float)width;
- texture->baseTexture.pow2Matrix[5] = (float)height;
- texture->baseTexture.pow2Matrix[10] = 1.0f;
- texture->baseTexture.pow2Matrix[15] = 1.0f;
- texture->baseTexture.target = GL_TEXTURE_RECTANGLE_ARB;
- texture->cond_np2 = TRUE;
+ texture->pow2_matrix[0] = (float)width;
+ texture->pow2_matrix[5] = (float)height;
+ texture->pow2_matrix[10] = 1.0f;
+ texture->pow2_matrix[15] = 1.0f;
+ texture->target = GL_TEXTURE_RECTANGLE_ARB;
+ texture->flags |= WINED3D_TEXTURE_COND_NP2;
- if(texture->resource.format->Flags & WINED3DFMT_FLAG_FILTERING)
- {
- texture->baseTexture.minMipLookup = minMipLookup_noMip;
- }
+ if (texture->resource.format->flags & WINED3DFMT_FLAG_FILTERING)
+ texture->min_mip_lookup = minMipLookup_noMip;
else
- {
- texture->baseTexture.minMipLookup = minMipLookup_noFilter;
- }
+ texture->min_mip_lookup = minMipLookup_noFilter;
}
else
{
if ((width != pow2_width) || (height != pow2_height))
{
- texture->baseTexture.pow2Matrix_identity = FALSE;
- texture->baseTexture.pow2Matrix[0] = (((float)width) / ((float)pow2_width));
- texture->baseTexture.pow2Matrix[5] = (((float)height) / ((float)pow2_height));
+ texture->pow2_matrix[0] = (((float)width) / ((float)pow2_width));
+ texture->pow2_matrix[5] = (((float)height) / ((float)pow2_height));
+ texture->flags &= ~WINED3D_TEXTURE_POW2_MAT_IDENT;
}
else
{
- texture->baseTexture.pow2Matrix[0] = 1.0f;
- texture->baseTexture.pow2Matrix[5] = 1.0f;
+ texture->pow2_matrix[0] = 1.0f;
+ texture->pow2_matrix[5] = 1.0f;
}
- texture->baseTexture.pow2Matrix[10] = 1.0f;
- texture->baseTexture.pow2Matrix[15] = 1.0f;
- texture->baseTexture.target = GL_TEXTURE_2D;
- texture->cond_np2 = FALSE;
+ texture->pow2_matrix[10] = 1.0f;
+ texture->pow2_matrix[15] = 1.0f;
+ texture->target = GL_TEXTURE_2D;
}
- TRACE("xf(%f) yf(%f)\n", texture->baseTexture.pow2Matrix[0], texture->baseTexture.pow2Matrix[5]);
+ TRACE("xf(%f) yf(%f)\n", texture->pow2_matrix[0], texture->pow2_matrix[5]);
/* Generate all the surfaces. */
tmp_w = width;
tmp_h = height;
- for (i = 0; i < texture->baseTexture.level_count; ++i)
+ for (i = 0; i < texture->level_count; ++i)
{
- IWineD3DSurface *surface;
+ struct wined3d_surface *surface;
/* Use the callback to create the texture surface. */
- hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_h,
+ hr = device->device_parent->ops->create_surface(device->device_parent, parent, tmp_w, tmp_h,
format->id, usage, pool, i, 0, &surface);
if (FAILED(hr))
{
FIXME("Failed to create surface %p, hr %#x\n", texture, hr);
- texture_cleanup(texture);
+ wined3d_texture_cleanup(texture);
return hr;
}
- surface_set_container((IWineD3DSurfaceImpl *)surface, WINED3D_CONTAINER_TEXTURE, (IWineD3DBase *)texture);
- surface_set_texture_target((IWineD3DSurfaceImpl *)surface, texture->baseTexture.target);
- texture->baseTexture.sub_resources[i] = (IWineD3DResourceImpl *)surface;
+ surface_set_container(surface, WINED3D_CONTAINER_TEXTURE, texture);
+ surface_set_texture_target(surface, texture->target);
+ texture->sub_resources[i] = &surface->resource;
TRACE("Created surface level %u @ %p.\n", i, surface);
/* Calculate the next mipmap level. */
tmp_w = max(1, tmp_w >> 1);
tmp_h = max(1, tmp_h >> 1);
}
- texture->baseTexture.internal_preload = texture_internal_preload;
+
+ return WINED3D_OK;
+}
+
+/* Context activation is done by the caller. */
+static HRESULT texture3d_bind(struct wined3d_texture *texture,
+ const struct wined3d_gl_info *gl_info, BOOL srgb)
+{
+ BOOL dummy;
+
+ TRACE("texture %p, gl_info %p, srgb %#x.\n", texture, gl_info, srgb);
+
+ return wined3d_texture_bind(texture, gl_info, srgb, &dummy);
+}
+
+/* Do not call while under the GL lock. */
+static void texture3d_preload(struct wined3d_texture *texture, enum WINED3DSRGB srgb)
+{
+ struct wined3d_device *device = texture->resource.device;
+ struct wined3d_context *context = NULL;
+ BOOL srgb_was_toggled = FALSE;
+ unsigned int i;
+
+ TRACE("texture %p, srgb %#x.\n", texture, srgb);
+
+ if (!device->isInDraw)
+ context = context_acquire(device, NULL);
+ else if (texture->bind_count > 0)
+ {
+ BOOL texture_srgb = texture->flags & WINED3D_TEXTURE_IS_SRGB;
+ BOOL sampler_srgb = texture_srgb_mode(texture, srgb);
+ srgb_was_toggled = !texture_srgb != !sampler_srgb;
+
+ if (srgb_was_toggled)
+ {
+ if (sampler_srgb)
+ texture->flags |= WINED3D_TEXTURE_IS_SRGB;
+ else
+ texture->flags &= ~WINED3D_TEXTURE_IS_SRGB;
+ }
+ }
+
+ /* If the texture is marked dirty or the sRGB sampler setting has changed
+ * since the last load then reload the volumes. */
+ if (texture->texture_rgb.dirty)
+ {
+ for (i = 0; i < texture->level_count; ++i)
+ {
+ volume_load(volume_from_resource(texture->sub_resources[i]), i,
+ texture->flags & WINED3D_TEXTURE_IS_SRGB);
+ }
+ }
+ else if (srgb_was_toggled)
+ {
+ for (i = 0; i < texture->level_count; ++i)
+ {
+ struct wined3d_volume *volume = volume_from_resource(texture->sub_resources[i]);
+ volume_add_dirty_box(volume, NULL);
+ volume_load(volume, i, texture->flags & WINED3D_TEXTURE_IS_SRGB);
+ }
+ }
+ else
+ {
+ TRACE("Texture %p not dirty, nothing to do.\n", texture);
+ }
+
+ if (context)
+ context_release(context);
+
+ /* No longer dirty */
+ texture->texture_rgb.dirty = FALSE;
+}
+
+static void texture3d_sub_resource_add_dirty_region(struct wined3d_resource *sub_resource,
+ const WINED3DBOX *dirty_region)
+{
+ volume_add_dirty_box(volume_from_resource(sub_resource), dirty_region);
+}
+
+static void texture3d_sub_resource_cleanup(struct wined3d_resource *sub_resource)
+{
+ struct wined3d_volume *volume = volume_from_resource(sub_resource);
+
+ /* Cleanup the container. */
+ volume_set_container(volume, NULL);
+ wined3d_volume_decref(volume);
+}
+
+/* Do not call while under the GL lock. */
+static void texture3d_unload(struct wined3d_resource *resource)
+{
+ struct wined3d_texture *texture = wined3d_texture_from_resource(resource);
+ UINT i;
+
+ TRACE("texture %p.\n", texture);
+
+ for (i = 0; i < texture->level_count; ++i)
+ {
+ struct wined3d_resource *sub_resource = texture->sub_resources[i];
+ sub_resource->resource_ops->resource_unload(sub_resource);
+ }
+
+ wined3d_texture_unload(texture);
+}
+
+static const struct wined3d_texture_ops texture3d_ops =
+{
+ texture3d_bind,
+ texture3d_preload,
+ texture3d_sub_resource_add_dirty_region,
+ texture3d_sub_resource_cleanup,
+};
+
+static const struct wined3d_resource_ops texture3d_resource_ops =
+{
+ texture3d_unload,
+};
+
+static HRESULT volumetexture_init(struct wined3d_texture *texture, UINT width, UINT height,
+ UINT depth, UINT levels, struct wined3d_device *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);
+ }
+
+ hr = wined3d_texture_init(texture, &texture3d_ops, 1, levels,
+ WINED3DRTYPE_VOLUMETEXTURE, device, usage, format, pool,
+ parent, parent_ops, &texture3d_resource_ops);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize texture, returning %#x.\n", hr);
+ return hr;
+ }
+
+ /* Is NP2 support for volumes needed? */
+ texture->pow2_matrix[0] = 1.0f;
+ texture->pow2_matrix[5] = 1.0f;
+ texture->pow2_matrix[10] = 1.0f;
+ texture->pow2_matrix[15] = 1.0f;
+ texture->target = GL_TEXTURE_3D;
+
+ /* Generate all the surfaces. */
+ tmp_w = width;
+ tmp_h = height;
+ tmp_d = depth;
+
+ for (i = 0; i < texture->level_count; ++i)
+ {
+ struct wined3d_volume *volume;
+
+ /* Create the volume. */
+ hr = device->device_parent->ops->create_volume(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);
+ wined3d_texture_cleanup(texture);
+ return hr;
+ }
+
+ /* Set its container to this texture. */
+ volume_set_container(volume, texture);
+ texture->sub_resources[i] = &volume->resource;
+
+ /* 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);
+ }
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_texture_create_2d(struct wined3d_device *device, UINT width, UINT height,
+ UINT level_count, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool, void *parent,
+ const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture)
+{
+ struct wined3d_texture *object;
+ HRESULT hr;
+
+ TRACE("device %p, width %u, height %u, level_count %u, usage %#x\n",
+ device, width, height, level_count, usage);
+ TRACE("format %s, pool %#x, parent %p, parent_ops %p, texture %p.\n",
+ debug_d3dformat(format_id), pool, parent, parent_ops, texture);
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (!object)
+ {
+ ERR("Out of memory.\n");
+ *texture = NULL;
+ return WINED3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ hr = texture_init(object, width, height, level_count,
+ device, usage, format_id, pool, parent, parent_ops);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize texture, returning %#x.\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ *texture = NULL;
+ return hr;
+ }
+
+ TRACE("Created texture %p.\n", object);
+ *texture = object;
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_texture_create_3d(struct wined3d_device *device, UINT width, UINT height, UINT depth,
+ UINT level_count, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool, void *parent,
+ const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture)
+{
+ struct wined3d_texture *object;
+ HRESULT hr;
+
+ TRACE("device %p, width %u, height %u, depth %u, level_count %u, usage %#x\n",
+ device, width, height, depth, level_count, usage);
+ TRACE("format %s, pool %#x, parent %p, parent_ops %p, texture %p.\n",
+ debug_d3dformat(format_id), pool, parent, parent_ops, texture);
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (!object)
+ {
+ ERR("Out of memory\n");
+ *texture = NULL;
+ return WINED3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ hr = volumetexture_init(object, width, height, depth, level_count,
+ device, usage, format_id, pool, parent, parent_ops);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize volumetexture, returning %#x\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ *texture = NULL;
+ return hr;
+ }
+
+ TRACE("Created texture %p.\n", object);
+ *texture = object;
+
+ return WINED3D_OK;
+}
+
+HRESULT CDECL wined3d_texture_create_cube(struct wined3d_device *device, UINT edge_length,
+ UINT level_count, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool, void *parent,
+ const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture)
+{
+ struct wined3d_texture *object;
+ HRESULT hr;
+
+ TRACE("device %p, edge_length %u, level_count %u, usage %#x\n",
+ device, edge_length, level_count, usage);
+ TRACE("format %s, pool %#x, parent %p, parent_ops %p, texture %p.\n",
+ debug_d3dformat(format_id), pool, parent, parent_ops, texture);
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (!object)
+ {
+ ERR("Out of memory\n");
+ *texture = NULL;
+ return WINED3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ hr = cubetexture_init(object, edge_length, level_count,
+ device, usage, format_id, pool, parent, parent_ops);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize cubetexture, returning %#x\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ *texture = NULL;
+ return hr;
+ }
+
+ TRACE("Created texture %p.\n", object);
+ *texture = object;
return WINED3D_OK;
}
diff --git a/reactos/dll/directx/wine/wined3d/utils.c b/reactos/dll/directx/wine/wined3d/utils.c
index 2957c5a3e4e..25c0512ccc0 100644
--- a/reactos/dll/directx/wine/wined3d/utils.c
+++ b/reactos/dll/directx/wine/wined3d/utils.c
@@ -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)
{
diff --git a/reactos/dll/directx/wine/wined3d/vertexdeclaration.c b/reactos/dll/directx/wine/wined3d/vertexdeclaration.c
index 59219f034c2..d5eae1604c0 100644
--- a/reactos/dll/directx/wine/wined3d/vertexdeclaration.c
+++ b/reactos/dll/directx/wine/wined3d/vertexdeclaration.c
@@ -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;
+}
diff --git a/reactos/dll/directx/wine/wined3d/view.c b/reactos/dll/directx/wine/wined3d/view.c
index e4e40fc38bb..872335f2bd5 100644
--- a/reactos/dll/directx/wine/wined3d/view.c
+++ b/reactos/dll/directx/wine/wined3d/view.c
@@ -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;
+}
diff --git a/reactos/dll/directx/wine/wined3d/volume.c b/reactos/dll/directx/wine/wined3d/volume.c
index 8d42d547329..e0f8ed6a4c6 100644
--- a/reactos/dll/directx/wine/wined3d/volume.c
+++ b/reactos/dll/directx/wine/wined3d/volume.c
@@ -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;
}
diff --git a/reactos/dll/directx/wine/wined3d/volumetexture.c b/reactos/dll/directx/wine/wined3d/volumetexture.c
deleted file mode 100644
index a2c0c6d796a..00000000000
--- a/reactos/dll/directx/wine/wined3d/volumetexture.c
+++ /dev/null
@@ -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;
-}
diff --git a/reactos/dll/directx/wine/wined3d/wined3d.rbuild b/reactos/dll/directx/wine/wined3d/wined3d.rbuild
index 56fe6eea97c..aa464944fe9 100644
--- a/reactos/dll/directx/wine/wined3d/wined3d.rbuild
+++ b/reactos/dll/directx/wine/wined3d/wined3d.rbuild
@@ -17,11 +17,9 @@
ati_fragment_shader.c
arb_program_shader.c
- basetexture.c
buffer.c
clipper.c
context.c
- cubetexture.c
device.c
directx.c
drawprim.c
@@ -36,18 +34,13 @@
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
diff --git a/reactos/dll/directx/wine/wined3d/wined3d.spec b/reactos/dll/directx/wine/wined3d/wined3d.spec
index c375b385d49..fd8e8ea4293 100644
--- a/reactos/dll/directx/wine/wined3d/wined3d.spec
+++ b/reactos/dll/directx/wine/wined3d/wined3d.spec
@@ -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)
diff --git a/reactos/dll/directx/wine/wined3d/wined3d_gl.h b/reactos/dll/directx/wine/wined3d/wined3d_gl.h
index 9c2c0c1594c..be50b2f672b 100644
--- a/reactos/dll/directx/wine/wined3d/wined3d_gl.h
+++ b/reactos/dll/directx/wine/wined3d/wined3d_gl.h
@@ -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 */
diff --git a/reactos/dll/directx/wine/wined3d/wined3d_main.c b/reactos/dll/directx/wine/wined3d/wined3d_main.c
index 26945efb860..4f7b1cb03a1 100644
--- a/reactos/dll/directx/wine/wined3d/wined3d_main.c
+++ b/reactos/dll/directx/wine/wined3d/wined3d_main.c
@@ -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 */
diff --git a/reactos/dll/directx/wine/wined3d/wined3d_private.h b/reactos/dll/directx/wine/wined3d/wined3d_private.h
index 0b6f57efe52..aaf142339d7 100644
--- a/reactos/dll/directx/wine/wined3d/wined3d_private.h
+++ b/reactos/dll/directx/wine/wined3d/wined3d_private.h
@@ -252,26 +252,27 @@ static inline float float_24_to_32(DWORD in)
/* NOTE: When adding fields to this structure, make sure to update the default
* values in wined3d_main.c as well. */
-typedef struct wined3d_settings_s {
-/* vertex and pixel shader modes */
- int vs_mode;
- int ps_mode;
-/* Ideally, we don't want the user to have to request GLSL. If the hardware supports GLSL,
- we should use it. However, until it's fully implemented, we'll leave it as a registry
- setting for developers. */
- BOOL glslRequested;
- int offscreen_rendering_mode;
- int rendertargetlock_mode;
- unsigned short pci_vendor_id;
- unsigned short pci_device_id;
-/* Memory tracking and object counting */
- unsigned int emulated_textureram;
- char *logo;
- int allow_multisampling;
- BOOL strict_draw_ordering;
-} wined3d_settings_t;
+struct wined3d_settings
+{
+ /* vertex and pixel shader modes */
+ int vs_mode;
+ int ps_mode;
+ /* Ideally, we don't want the user to have to request GLSL. If the
+ * hardware supports GLSL, we should use it. However, until it's fully
+ * implemented, we'll leave it as a registry setting for developers. */
+ BOOL glslRequested;
+ int offscreen_rendering_mode;
+ int rendertargetlock_mode;
+ unsigned short pci_vendor_id;
+ unsigned short pci_device_id;
+ /* Memory tracking and object counting. */
+ unsigned int emulated_textureram;
+ char *logo;
+ int allow_multisampling;
+ BOOL strict_draw_ordering;
+};
-extern wined3d_settings_t wined3d_settings DECLSPEC_HIDDEN;
+extern struct wined3d_settings wined3d_settings DECLSPEC_HIDDEN;
typedef enum _WINED3DSAMPLER_TEXTURE_TYPE
{
@@ -309,6 +310,7 @@ typedef enum _WINED3DSHADER_PARAM_REGISTER_TYPE
WINED3DSPR_IMMCONST,
WINED3DSPR_CONSTBUFFER,
WINED3DSPR_NULL,
+ WINED3DSPR_RESOURCE,
} WINED3DSHADER_PARAM_REGISTER_TYPE;
enum wined3d_immconst_type
@@ -420,6 +422,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER
WINED3DSIH_DEF,
WINED3DSIH_DEFB,
WINED3DSIH_DEFI,
+ WINED3DSIH_DIV,
WINED3DSIH_DP2ADD,
WINED3DSIH_DP3,
WINED3DSIH_DP4,
@@ -434,12 +437,16 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER
WINED3DSIH_EXP,
WINED3DSIH_EXPP,
WINED3DSIH_FRC,
+ WINED3DSIH_FTOI,
WINED3DSIH_IADD,
+ WINED3DSIH_IEQ,
WINED3DSIH_IF,
WINED3DSIH_IFC,
WINED3DSIH_IGE,
WINED3DSIH_IMUL,
+ WINED3DSIH_ITOF,
WINED3DSIH_LABEL,
+ WINED3DSIH_LD,
WINED3DSIH_LIT,
WINED3DSIH_LOG,
WINED3DSIH_LOGP,
@@ -466,11 +473,15 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER
WINED3DSIH_REP,
WINED3DSIH_RET,
WINED3DSIH_RSQ,
+ WINED3DSIH_SAMPLE,
+ WINED3DSIH_SAMPLE_GRAD,
+ WINED3DSIH_SAMPLE_LOD,
WINED3DSIH_SETP,
WINED3DSIH_SGE,
WINED3DSIH_SGN,
WINED3DSIH_SINCOS,
WINED3DSIH_SLT,
+ WINED3DSIH_SQRT,
WINED3DSIH_SUB,
WINED3DSIH_TEX,
WINED3DSIH_TEXBEM,
@@ -494,6 +505,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER
WINED3DSIH_TEXREG2AR,
WINED3DSIH_TEXREG2GB,
WINED3DSIH_TEXREG2RGB,
+ WINED3DSIH_UTOF,
WINED3DSIH_TABLE_SIZE
};
@@ -513,7 +525,7 @@ struct wined3d_shader_version
#define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
-typedef struct shader_reg_maps
+struct wined3d_shader_reg_maps
{
struct wined3d_shader_version shader_version;
BYTE texcoord; /* MAX_REG_TEXCRD, 8 */
@@ -545,21 +557,38 @@ typedef struct shader_reg_maps
WORD usestexldl : 1;
WORD usesifc : 1;
WORD usescall : 1;
- WORD usesrcp : 1;
+ WORD usespow : 1;
WORD padding : 3;
+ DWORD rt_mask; /* Used render targets, 32 max. */
+
/* Whether or not loops are used in this shader, and nesting depth */
unsigned loop_depth;
- unsigned highest_render_target;
+ UINT min_rel_offset, max_rel_offset;
+};
-} shader_reg_maps;
+/* Keeps track of details for TEX_M#x# instructions which need to maintain
+ * state information between multiple instructions. */
+struct wined3d_shader_tex_mx
+{
+ unsigned int current_row;
+ DWORD texcoord_w[2];
+};
+
+struct wined3d_shader_loop_state
+{
+ UINT current_depth;
+ UINT current_reg;
+};
struct wined3d_shader_context
{
- IWineD3DBaseShader *shader;
+ struct wined3d_shader *shader;
const struct wined3d_gl_info *gl_info;
- const struct shader_reg_maps *reg_maps;
+ const struct wined3d_shader_reg_maps *reg_maps;
struct wined3d_shader_buffer *buffer;
+ struct wined3d_shader_tex_mx *tex_mx;
+ struct wined3d_shader_loop_state *loop_state;
void *backend_data;
};
@@ -712,28 +741,31 @@ struct vs_compile_args {
};
struct wined3d_context;
+struct wined3d_state;
-typedef struct {
+struct wined3d_shader_backend_ops
+{
void (*shader_handle_instruction)(const struct wined3d_shader_instruction *);
void (*shader_select)(const struct wined3d_context *context, BOOL usePS, BOOL useVS);
- void (*shader_select_depth_blt)(IWineD3DDevice *iface, enum tex_types tex_type, const SIZE *ds_mask_size);
- void (*shader_deselect_depth_blt)(IWineD3DDevice *iface);
- void (*shader_update_float_vertex_constants)(IWineD3DDevice *iface, UINT start, UINT count);
- void (*shader_update_float_pixel_constants)(IWineD3DDevice *iface, UINT start, UINT count);
+ void (*shader_select_depth_blt)(void *shader_priv, const struct wined3d_gl_info *gl_info,
+ enum tex_types tex_type, const SIZE *ds_mask_size);
+ void (*shader_deselect_depth_blt)(void *shader_priv, const struct wined3d_gl_info *gl_info);
+ void (*shader_update_float_vertex_constants)(struct wined3d_device *device, UINT start, UINT count);
+ void (*shader_update_float_pixel_constants)(struct wined3d_device *device, UINT start, UINT count);
void (*shader_load_constants)(const struct wined3d_context *context, char usePS, char useVS);
- void (*shader_load_np2fixup_constants)(IWineD3DDevice *iface, char usePS, char useVS);
- void (*shader_destroy)(IWineD3DBaseShader *iface);
- HRESULT (*shader_alloc_private)(IWineD3DDevice *iface);
- void (*shader_free_private)(IWineD3DDevice *iface);
- BOOL (*shader_dirtifyable_constants)(IWineD3DDevice *iface);
+ void (*shader_load_np2fixup_constants)(void *shader_priv, const struct wined3d_gl_info *gl_info,
+ const struct wined3d_state *state);
+ void (*shader_destroy)(struct wined3d_shader *shader);
+ HRESULT (*shader_alloc_private)(struct wined3d_device *device);
+ void (*shader_free_private)(struct wined3d_device *device);
+ BOOL (*shader_dirtifyable_constants)(void);
void (*shader_get_caps)(const struct wined3d_gl_info *gl_info, struct shader_caps *caps);
BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup);
- void (*shader_add_instruction_modifiers)(const struct wined3d_shader_instruction *ins);
-} shader_backend_t;
+};
-extern const shader_backend_t glsl_shader_backend DECLSPEC_HIDDEN;
-extern const shader_backend_t arb_program_shader_backend DECLSPEC_HIDDEN;
-extern const shader_backend_t none_shader_backend DECLSPEC_HIDDEN;
+extern const struct wined3d_shader_backend_ops glsl_shader_backend DECLSPEC_HIDDEN;
+extern const struct wined3d_shader_backend_ops arb_program_shader_backend DECLSPEC_HIDDEN;
+extern const struct wined3d_shader_backend_ops none_shader_backend DECLSPEC_HIDDEN;
/* X11 locking */
@@ -818,13 +850,6 @@ do {
si->elements[name].data, si->elements[name].stride, si->elements[name].format->id, \
si->elements[name].buffer_object, si->elements[name].stream_idx); } while(0)
-/* Advance declaration of structures to satisfy compiler */
-typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl;
-typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl;
-typedef struct IWineD3DPaletteImpl IWineD3DPaletteImpl;
-typedef struct IWineD3DDeviceImpl IWineD3DDeviceImpl;
-typedef struct IWineD3DSwapChainImpl IWineD3DSwapChainImpl;
-
/* Global variables */
extern const float identity[16] DECLSPEC_HIDDEN;
@@ -891,7 +916,7 @@ struct wined3d_stream_info
*/
/* Routine common to the draw primitive and draw indexed primitive routines */
-void drawPrimitive(IWineD3DDevice *iface, UINT index_count,
+void drawPrimitive(struct wined3d_device *device, UINT index_count,
UINT start_idx, UINT idxBytes, const void *idxData) DECLSPEC_HIDDEN;
DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN;
@@ -961,7 +986,10 @@ extern glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC
#define STATE_FRONTFACE (STATE_MATERIAL + 1)
#define STATE_IS_FRONTFACE(a) ((a) == STATE_FRONTFACE)
-#define STATE_HIGHEST (STATE_FRONTFACE)
+#define STATE_POINTSPRITECOORDORIGIN (STATE_FRONTFACE + 1)
+#define STATE_IS_POINTSPRITECOORDORIGIN(a) ((a) == STATE_POINTSPRITECOORDORIGIN)
+
+#define STATE_HIGHEST (STATE_POINTSPRITECOORDORIGIN)
enum fogsource {
FOGSOURCE_FFP,
@@ -1001,9 +1029,9 @@ enum wined3d_event_query_result
};
void wined3d_event_query_destroy(struct wined3d_event_query *query) DECLSPEC_HIDDEN;
-enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
-enum wined3d_event_query_result wined3d_event_query_finish(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
-void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
+enum wined3d_event_query_result wined3d_event_query_finish(struct wined3d_event_query *query,
+ struct wined3d_device *device) DECLSPEC_HIDDEN;
+void wined3d_event_query_issue(struct wined3d_event_query *query, struct wined3d_device *device) DECLSPEC_HIDDEN;
BOOL wined3d_event_query_supported(const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
struct wined3d_context
@@ -1019,8 +1047,8 @@ struct wined3d_context
DWORD numDirtyEntries;
DWORD isStateDirty[STATE_HIGHEST / (sizeof(DWORD) * CHAR_BIT) + 1]; /* Bitmap to find out quickly if a state is dirty */
- IWineD3DSwapChainImpl *swapchain;
- IWineD3DSurfaceImpl *current_rt;
+ struct wined3d_swapchain *swapchain;
+ struct wined3d_surface *current_rt;
DWORD tid; /* Thread ID which owns this context at the moment */
/* Stores some information about the context state for optimization */
@@ -1068,7 +1096,7 @@ struct wined3d_context
GLuint fbo_read_binding;
GLuint fbo_draw_binding;
BOOL rebind_fbo;
- IWineD3DSurfaceImpl **blit_targets;
+ struct wined3d_surface **blit_targets;
GLenum *draw_buffers;
/* Queries */
@@ -1089,7 +1117,7 @@ struct wined3d_context
GLuint dummy_arbfp_prog;
};
-typedef void (*APPLYSTATEFUNC)(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *ctx);
+typedef void (*APPLYSTATEFUNC)(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *ctx);
struct StateEntry
{
@@ -1114,10 +1142,10 @@ struct fragment_caps
struct fragment_pipeline
{
- void (*enable_extension)(IWineD3DDevice *iface, BOOL enable);
+ void (*enable_extension)(BOOL enable);
void (*get_caps)(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps);
- HRESULT (*alloc_private)(IWineD3DDevice *iface);
- void (*free_private)(IWineD3DDevice *iface);
+ HRESULT (*alloc_private)(struct wined3d_device *device);
+ void (*free_private)(struct wined3d_device *device);
BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
const struct StateEntryTemplate *states;
BOOL ffp_proj_control;
@@ -1136,71 +1164,76 @@ HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_
const struct wined3d_gl_info *gl_info, const struct StateEntryTemplate *vertex,
const struct fragment_pipeline *fragment, const struct StateEntryTemplate *misc) DECLSPEC_HIDDEN;
-enum blit_operation
+enum wined3d_blit_op
{
- BLIT_OP_BLIT,
- BLIT_OP_COLOR_FILL
+ WINED3D_BLIT_OP_COLOR_BLIT,
+ WINED3D_BLIT_OP_COLOR_FILL,
+ WINED3D_BLIT_OP_DEPTH_FILL,
+ WINED3D_BLIT_OP_DEPTH_BLIT,
};
/* Shaders for color conversions in blits. Do not do blit operations while
* already under the GL lock. */
struct blit_shader
{
- HRESULT (*alloc_private)(IWineD3DDevice *iface);
- void (*free_private)(IWineD3DDevice *iface);
- HRESULT (*set_shader)(IWineD3DDevice *iface, IWineD3DSurfaceImpl *surface);
- void (*unset_shader)(IWineD3DDevice *iface);
- BOOL (*blit_supported)(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
+ HRESULT (*alloc_private)(struct wined3d_device *device);
+ void (*free_private)(struct wined3d_device *device);
+ HRESULT (*set_shader)(void *blit_priv, const struct wined3d_gl_info *gl_info, struct wined3d_surface *surface);
+ void (*unset_shader)(const struct wined3d_gl_info *gl_info);
+ BOOL (*blit_supported)(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);
- HRESULT (*color_fill)(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface,
+ HRESULT (*color_fill)(struct wined3d_device *device, struct wined3d_surface *dst_surface,
const RECT *dst_rect, const WINED3DCOLORVALUE *color);
+ HRESULT (*depth_fill)(struct wined3d_device *device,
+ struct wined3d_surface *surface, const RECT *rect, float depth);
};
extern const struct blit_shader ffp_blit DECLSPEC_HIDDEN;
extern const struct blit_shader arbfp_blit DECLSPEC_HIDDEN;
extern const struct blit_shader cpu_blit DECLSPEC_HIDDEN;
-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)
DECLSPEC_HIDDEN;
/* Temporary blit_shader helper functions */
-HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_surface, const RECT *src_rect,
- IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect_in, enum blit_operation blit_op,
- DWORD Filter) DECLSPEC_HIDDEN;
+HRESULT arbfp_blit_surface(struct wined3d_device *device, struct wined3d_surface *src_surface,
+ const RECT *src_rect, struct wined3d_surface *dst_surface, const RECT *dst_rect_in,
+ enum wined3d_blit_op blit_op, DWORD Filter) DECLSPEC_HIDDEN;
-struct wined3d_context *context_acquire(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target) DECLSPEC_HIDDEN;
+struct wined3d_context *context_acquire(struct wined3d_device *device, struct wined3d_surface *target) DECLSPEC_HIDDEN;
void context_alloc_event_query(struct wined3d_context *context,
struct wined3d_event_query *query) DECLSPEC_HIDDEN;
void context_alloc_occlusion_query(struct wined3d_context *context,
struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
-void context_apply_blit_state(struct wined3d_context *context, IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
-void context_apply_clear_state(struct wined3d_context *context, IWineD3DDeviceImpl *device,
- UINT rt_count, IWineD3DSurfaceImpl **rts, IWineD3DSurfaceImpl *depth_stencil) DECLSPEC_HIDDEN;
-void context_apply_draw_state(struct wined3d_context *context, IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
+void context_apply_blit_state(struct wined3d_context *context, struct wined3d_device *device) DECLSPEC_HIDDEN;
+BOOL context_apply_clear_state(struct wined3d_context *context, struct wined3d_device *device,
+ UINT rt_count, struct wined3d_surface **rts, struct wined3d_surface *depth_stencil) DECLSPEC_HIDDEN;
+BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_device *device) DECLSPEC_HIDDEN;
void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target,
- IWineD3DSurfaceImpl *render_target, IWineD3DSurfaceImpl *depth_stencil, DWORD location) DECLSPEC_HIDDEN;
+ struct wined3d_surface *render_target, struct wined3d_surface *depth_stencil, DWORD location) DECLSPEC_HIDDEN;
void context_attach_depth_stencil_fbo(struct wined3d_context *context,
- GLenum fbo_target, IWineD3DSurfaceImpl *depth_stencil, BOOL use_render_buffer) DECLSPEC_HIDDEN;
+ GLenum fbo_target, struct wined3d_surface *depth_stencil, BOOL use_render_buffer) DECLSPEC_HIDDEN;
void context_bind_fbo(struct wined3d_context *context, GLenum target, GLuint *fbo) DECLSPEC_HIDDEN;
-struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target,
+void context_check_fbo_status(struct wined3d_context *context, GLenum target) DECLSPEC_HIDDEN;
+struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, struct wined3d_surface *target,
const struct wined3d_format *ds_format) DECLSPEC_HIDDEN;
-void context_destroy(IWineD3DDeviceImpl *This, struct wined3d_context *context) DECLSPEC_HIDDEN;
+void context_destroy(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
void context_free_event_query(struct wined3d_event_query *query) DECLSPEC_HIDDEN;
void context_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
struct wined3d_context *context_get_current(void) DECLSPEC_HIDDEN;
DWORD context_get_tls_idx(void) DECLSPEC_HIDDEN;
void context_release(struct wined3d_context *context) DECLSPEC_HIDDEN;
-void context_resource_released(IWineD3DDeviceImpl *device,
- IWineD3DResource *resource, WINED3DRESOURCETYPE type) DECLSPEC_HIDDEN;
-void context_resource_unloaded(IWineD3DDeviceImpl *device,
- IWineD3DResource *resource, WINED3DRESOURCETYPE type) DECLSPEC_HIDDEN;
+void context_resource_released(struct wined3d_device *device,
+ struct wined3d_resource *resource, WINED3DRESOURCETYPE type) DECLSPEC_HIDDEN;
+void context_resource_unloaded(struct wined3d_device *device,
+ struct wined3d_resource *resource, WINED3DRESOURCETYPE type) DECLSPEC_HIDDEN;
BOOL context_set_current(struct wined3d_context *ctx) DECLSPEC_HIDDEN;
void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer) DECLSPEC_HIDDEN;
void context_set_tls_idx(DWORD idx) DECLSPEC_HIDDEN;
-void context_surface_update(struct wined3d_context *context, IWineD3DSurfaceImpl *surface) DECLSPEC_HIDDEN;
+void context_surface_update(struct wined3d_context *context, struct wined3d_surface *surface) DECLSPEC_HIDDEN;
/* Macros for doing basic GPU detection based on opengl capabilities */
#define WINE_D3D6_CAPABLE(gl_info) (gl_info->supported[ARB_MULTITEXTURE])
@@ -1231,7 +1264,7 @@ struct wined3d_light_info
/* The default light parameters */
extern const WINED3DLIGHT WINED3D_default_light DECLSPEC_HIDDEN;
-typedef struct WineD3D_PixelFormat
+struct wined3d_pixel_format
{
int iPixelFormat; /* WGL pixel format */
int iPixelType; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
@@ -1241,17 +1274,17 @@ typedef struct WineD3D_PixelFormat
BOOL doubleBuffer;
int auxBuffers;
int numSamples;
-} WineD3D_PixelFormat;
+};
/* The driver names reflect the lowest GPU supported
- * by a certain driver, so DRIVER_ATI_R300 supports
+ * by a certain driver, so DRIVER_AMD_R300 supports
* R3xx, R4xx and R5xx GPUs. */
enum wined3d_display_driver
{
- DRIVER_ATI_RAGE_128PRO,
- DRIVER_ATI_R100,
- DRIVER_ATI_R300,
- DRIVER_ATI_R600,
+ DRIVER_AMD_RAGE_128PRO,
+ DRIVER_AMD_R100,
+ DRIVER_AMD_R300,
+ DRIVER_AMD_R600,
DRIVER_INTEL_GMA800,
DRIVER_INTEL_GMA900,
DRIVER_INTEL_GMA950,
@@ -1285,7 +1318,7 @@ enum wined3d_gl_vendor
enum wined3d_pci_vendor
{
HW_VENDOR_SOFTWARE = 0x0000,
- HW_VENDOR_ATI = 0x1002,
+ HW_VENDOR_AMD = 0x1002,
HW_VENDOR_NVIDIA = 0x10de,
HW_VENDOR_INTEL = 0x8086,
};
@@ -1294,35 +1327,41 @@ enum wined3d_pci_device
{
CARD_WINE = 0x0000,
- CARD_ATI_RAGE_128PRO = 0x5246,
- CARD_ATI_RADEON_7200 = 0x5144,
- CARD_ATI_RADEON_8500 = 0x514c,
- CARD_ATI_RADEON_9500 = 0x4144,
- CARD_ATI_RADEON_XPRESS_200M = 0x5955,
- CARD_ATI_RADEON_X700 = 0x5e4c,
- CARD_ATI_RADEON_X1600 = 0x71c2,
- CARD_ATI_RADEON_HD2350 = 0x94c7,
- CARD_ATI_RADEON_HD2600 = 0x9581,
- CARD_ATI_RADEON_HD2900 = 0x9400,
- CARD_ATI_RADEON_HD3200 = 0x9620,
- CARD_ATI_RADEON_HD4350 = 0x954f,
- CARD_ATI_RADEON_HD4550 = 0x9540,
- CARD_ATI_RADEON_HD4600 = 0x9495,
- CARD_ATI_RADEON_HD4650 = 0x9498,
- CARD_ATI_RADEON_HD4670 = 0x9490,
- CARD_ATI_RADEON_HD4700 = 0x944e,
- CARD_ATI_RADEON_HD4770 = 0x94b3,
- CARD_ATI_RADEON_HD4800 = 0x944c, /* Picked one value between 9440, 944c, 9442, 9460 */
- CARD_ATI_RADEON_HD4830 = 0x944c,
- CARD_ATI_RADEON_HD4850 = 0x9442,
- CARD_ATI_RADEON_HD4870 = 0x9440,
- CARD_ATI_RADEON_HD4890 = 0x9460,
- CARD_ATI_RADEON_HD5700 = 0x68BE, /* Picked HD5750 */
- CARD_ATI_RADEON_HD5750 = 0x68BE,
- CARD_ATI_RADEON_HD5770 = 0x68B8,
- CARD_ATI_RADEON_HD5800 = 0x6898, /* Picked HD5850 */
- CARD_ATI_RADEON_HD5850 = 0x6898,
- CARD_ATI_RADEON_HD5870 = 0x6899,
+ CARD_AMD_RAGE_128PRO = 0x5246,
+ CARD_AMD_RADEON_7200 = 0x5144,
+ CARD_AMD_RADEON_8500 = 0x514c,
+ CARD_AMD_RADEON_9500 = 0x4144,
+ CARD_AMD_RADEON_XPRESS_200M = 0x5955,
+ CARD_AMD_RADEON_X700 = 0x5e4c,
+ CARD_AMD_RADEON_X1600 = 0x71c2,
+ CARD_AMD_RADEON_HD2350 = 0x94c7,
+ CARD_AMD_RADEON_HD2600 = 0x9581,
+ CARD_AMD_RADEON_HD2900 = 0x9400,
+ CARD_AMD_RADEON_HD3200 = 0x9620,
+ CARD_AMD_RADEON_HD4350 = 0x954f,
+ CARD_AMD_RADEON_HD4550 = 0x9540,
+ CARD_AMD_RADEON_HD4600 = 0x9495,
+ CARD_AMD_RADEON_HD4650 = 0x9498,
+ CARD_AMD_RADEON_HD4670 = 0x9490,
+ CARD_AMD_RADEON_HD4700 = 0x944e,
+ CARD_AMD_RADEON_HD4770 = 0x94b3,
+ CARD_AMD_RADEON_HD4800 = 0x944c, /* Picked one value between 9440, 944c, 9442, 9460 */
+ CARD_AMD_RADEON_HD4830 = 0x944c,
+ CARD_AMD_RADEON_HD4850 = 0x9442,
+ CARD_AMD_RADEON_HD4870 = 0x9440,
+ CARD_AMD_RADEON_HD4890 = 0x9460,
+ CARD_AMD_RADEON_HD5400 = 0x68f9,
+ CARD_AMD_RADEON_HD5600 = 0x68d8,
+ CARD_AMD_RADEON_HD5700 = 0x68BE, /* Picked HD5750 */
+ CARD_AMD_RADEON_HD5750 = 0x68BE,
+ CARD_AMD_RADEON_HD5770 = 0x68B8,
+ CARD_AMD_RADEON_HD5800 = 0x6898, /* Picked HD5850 */
+ CARD_AMD_RADEON_HD5850 = 0x6898,
+ CARD_AMD_RADEON_HD5870 = 0x6899,
+ CARD_AMD_RADEON_HD5900 = 0x689c,
+ CARD_AMD_RADEON_HD6310 = 0x9803,
+ CARD_AMD_RADEON_HD6800 = 0x6739,
+ CARD_AMD_RADEON_HD6900 = 0x6719,
CARD_NVIDIA_RIVA_128 = 0x0018,
CARD_NVIDIA_RIVA_TNT = 0x0020,
@@ -1363,12 +1402,21 @@ enum wined3d_pci_device
CARD_NVIDIA_GEFORCE_GTX260 = 0x05e2,
CARD_NVIDIA_GEFORCE_GTX275 = 0x05e6,
CARD_NVIDIA_GEFORCE_GTX280 = 0x05e1,
+ CARD_NVIDIA_GEFORCE_GT320M = 0x0a2d,
CARD_NVIDIA_GEFORCE_GT325M = 0x0a35,
+ CARD_NVIDIA_GEFORCE_GT330 = 0x0ca0,
CARD_NVIDIA_GEFORCE_GTS350M = 0x0cb0,
+ CARD_NVIDIA_GEFORCE_GT420 = 0x0de2,
+ CARD_NVIDIA_GEFORCE_GT430 = 0x0de1,
+ CARD_NVIDIA_GEFORCE_GT440 = 0x0de0,
+ CARD_NVIDIA_GEFORCE_GTS450 = 0x0dc4,
CARD_NVIDIA_GEFORCE_GTX460 = 0x0e22,
CARD_NVIDIA_GEFORCE_GTX465 = 0x06c4,
CARD_NVIDIA_GEFORCE_GTX470 = 0x06cd,
CARD_NVIDIA_GEFORCE_GTX480 = 0x06c0,
+ CARD_NVIDIA_GEFORCE_GTX560 = 0x1200,
+ CARD_NVIDIA_GEFORCE_GTX570 = 0x1081,
+ CARD_NVIDIA_GEFORCE_GTX580 = 0x1080,
CARD_INTEL_845G = 0x2562,
CARD_INTEL_I830G = 0x3577,
@@ -1378,6 +1426,7 @@ enum wined3d_pci_device
CARD_INTEL_I915GM = 0x2592,
CARD_INTEL_I945GM = 0x27a2, /* Same as GMA 950? */
CARD_INTEL_X3100 = 0x2a02, /* Found in Macs. Same as GM965/GL960 */
+ CARD_INTEL_GM45 = 0x2a42,
};
struct wined3d_fbo_ops
@@ -1480,20 +1529,20 @@ struct wined3d_adapter
struct wined3d_driver_info driver_info;
WCHAR DeviceName[CCHDEVICENAME]; /* DeviceName for use with e.g. ChangeDisplaySettings */
int nCfgs;
- WineD3D_PixelFormat *cfgs;
+ struct wined3d_pixel_format *cfgs;
BOOL brokenStencil; /* Set on cards which only offer mixed depth+stencil */
unsigned int TextureRam; /* Amount of texture memory both video ram + AGP/TurboCache/HyperMemory/.. */
unsigned int UsedTextureRam;
LUID luid;
const struct fragment_pipeline *fragment_pipe;
- const shader_backend_t *shader_backend;
+ const struct wined3d_shader_backend_ops *shader_backend;
const struct blit_shader *blitter;
};
BOOL initPixelFormats(struct wined3d_gl_info *gl_info, enum wined3d_pci_vendor vendor) DECLSPEC_HIDDEN;
BOOL initPixelFormatsNoGL(struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
-extern unsigned int WineD3DAdapterChangeGLRam(IWineD3DDeviceImpl *D3DDevice, unsigned int glram) DECLSPEC_HIDDEN;
+extern unsigned int WineD3DAdapterChangeGLRam(struct wined3d_device *device, int glram) DECLSPEC_HIDDEN;
extern void add_gl_compat_wrappers(struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
/*****************************************************************************
@@ -1510,7 +1559,7 @@ struct WineD3DRectPatch
struct list entry;
};
-HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This, struct WineD3DRectPatch *patch) DECLSPEC_HIDDEN;
+HRESULT tesselate_rectpatch(struct wined3d_device *device, struct WineD3DRectPatch *patch) DECLSPEC_HIDDEN;
enum projection_types
{
@@ -1565,31 +1614,23 @@ struct ffp_frag_desc
extern const struct wine_rb_functions wined3d_ffp_frag_program_rb_functions DECLSPEC_HIDDEN;
extern const struct wined3d_parent_ops wined3d_null_parent_ops DECLSPEC_HIDDEN;
-void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_settings *settings,
+void gen_ffp_frag_op(struct wined3d_stateblock *stateblock, struct ffp_frag_settings *settings,
BOOL ignore_textype) DECLSPEC_HIDDEN;
const struct ffp_frag_desc *find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders,
const struct ffp_frag_settings *settings) DECLSPEC_HIDDEN;
void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc) DECLSPEC_HIDDEN;
-/*****************************************************************************
- * IWineD3D implementation structure
- */
-typedef struct IWineD3DImpl
+struct wined3d
{
- /* IUnknown fields */
- const IWineD3DVtbl *lpVtbl;
- LONG ref; /* Note: Ref counting not required */
-
- /* WineD3D Information */
+ LONG ref;
void *parent;
- UINT dxVersion;
-
+ UINT dxVersion;
UINT adapter_count;
struct wined3d_adapter adapters[1];
-} IWineD3DImpl;
+};
-HRESULT wined3d_init(IWineD3DImpl *wined3d, UINT version, void *parent) DECLSPEC_HIDDEN;
-BOOL wined3d_register_window(HWND window, struct IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
+HRESULT wined3d_init(struct wined3d *wined3d, UINT version, void *parent) DECLSPEC_HIDDEN;
+BOOL wined3d_register_window(HWND window, struct wined3d_device *device) DECLSPEC_HIDDEN;
void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
/*****************************************************************************
@@ -1600,15 +1641,19 @@ void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
/* Multithreaded flag. Removed from the public header to signal that IWineD3D::CreateDevice ignores it */
#define WINED3DCREATE_MULTITHREADED 0x00000004
-struct IWineD3DDeviceImpl
+struct wined3d_fb_state
{
- /* IUnknown fields */
- const IWineD3DDeviceVtbl *lpVtbl;
- LONG ref; /* Note: Ref counting not required */
+ struct wined3d_surface **render_targets;
+ struct wined3d_surface *depth_stencil;
+};
+
+struct wined3d_device
+{
+ LONG ref;
/* WineD3D Information */
- IWineD3DDeviceParent *device_parent;
- IWineD3D *wined3d;
+ struct wined3d_device_parent *device_parent;
+ struct wined3d *wined3d;
struct wined3d_adapter *adapter;
/* Window styles to restore when switching fullscreen mode */
@@ -1616,13 +1661,12 @@ struct IWineD3DDeviceImpl
LONG exStyle;
/* X and GL Information */
- GLint maxConcurrentLights;
GLenum offscreenBuffer;
/* Selected capabilities */
int vs_selected_mode;
int ps_selected_mode;
- const shader_backend_t *shader_backend;
+ const struct wined3d_shader_backend_ops *shader_backend;
void *shader_priv;
void *fragment_priv;
void *blit_priv;
@@ -1642,14 +1686,13 @@ struct IWineD3DDeviceImpl
WORD isRecordingState : 1;
WORD isInDraw : 1;
WORD bCursorVisible : 1;
- WORD haveHardwareCursor : 1;
WORD d3d_initialized : 1;
WORD inScene : 1; /* A flag to check for proper BeginScene / EndScene call pairs */
WORD softwareVertexProcessing : 1; /* process vertex shaders using software or hardware */
WORD useDrawStridedSlow : 1;
WORD instancedDraw : 1;
WORD filter_messages : 1;
- WORD padding : 3;
+ WORD padding : 4;
BYTE fixed_function_usage_map; /* MAX_TEXTURES, 8 */
@@ -1658,31 +1701,31 @@ struct IWineD3DDeviceImpl
unsigned char surface_alignment; /* Line Alignment of surfaces */
/* State block related */
- IWineD3DStateBlockImpl *stateBlock;
- IWineD3DStateBlockImpl *updateStateBlock;
+ struct wined3d_stateblock *stateBlock;
+ struct wined3d_stateblock *updateStateBlock;
/* Internal use fields */
WINED3DDEVICE_CREATION_PARAMETERS createParms;
WINED3DDEVTYPE devType;
HWND focus_window;
- IWineD3DSwapChain **swapchains;
- UINT NumberOfSwapChains;
+ struct wined3d_swapchain **swapchains;
+ UINT swapchain_count;
struct list resources; /* a linked list to track resources created by the device */
struct list shaders; /* a linked list to track shaders (pixel and vertex) */
unsigned int highest_dirty_ps_const, highest_dirty_vs_const;
/* Render Target Support */
- IWineD3DSurfaceImpl **render_targets;
- IWineD3DSurfaceImpl *auto_depth_stencil;
- IWineD3DSurfaceImpl *onscreen_depth_stencil;
- IWineD3DSurfaceImpl *depth_stencil;
+ DWORD valid_rt_mask;
+ struct wined3d_fb_state fb;
+ struct wined3d_surface *onscreen_depth_stencil;
+ struct wined3d_surface *auto_depth_stencil;
/* palettes texture management */
- UINT NumberOfPalettes;
- PALETTEENTRY **palettes;
- UINT currentPalette;
+ PALETTEENTRY **palettes;
+ UINT palette_count;
+ UINT currentPalette;
/* For rendering to a texture using glCopyTexImage */
GLuint depth_blt_texture;
@@ -1700,7 +1743,7 @@ struct IWineD3DDeviceImpl
HCURSOR hardwareCursor;
/* The Wine logo surface */
- IWineD3DSurface *logo_surface;
+ struct wined3d_surface *logo_surface;
/* Textures for when no other textures are mapped */
UINT dummyTextureName[MAX_TEXTURES];
@@ -1709,9 +1752,6 @@ struct IWineD3DDeviceImpl
DWORD ddraw_width, ddraw_height;
enum wined3d_format_id ddraw_format;
- /* Final position fixup constant */
- float posFixup[4];
-
/* With register combiners we can skip junk texture stages */
DWORD texUnitMap[MAX_COMBINED_SAMPLERS];
DWORD rev_tex_unit_map[MAX_COMBINED_SAMPLERS];
@@ -1724,7 +1764,7 @@ struct IWineD3DDeviceImpl
/* Context management */
struct wined3d_context **contexts;
- UINT numContexts;
+ UINT context_count;
/* High level patch management */
#define PATCHMAP_SIZE 43
@@ -1733,27 +1773,27 @@ struct IWineD3DDeviceImpl
struct WineD3DRectPatch *currentPatch;
};
-HRESULT device_clear_render_targets(IWineD3DDeviceImpl *device, UINT rt_count, IWineD3DSurfaceImpl **rts,
- UINT rect_count, const RECT *rects, const RECT *draw_rect, DWORD flags,
- const WINED3DCOLORVALUE *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
-BOOL device_context_add(IWineD3DDeviceImpl *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
-void device_context_remove(IWineD3DDeviceImpl *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
-void device_get_draw_rect(IWineD3DDeviceImpl *device, RECT *rect) DECLSPEC_HIDDEN;
-HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d,
+HRESULT device_clear_render_targets(struct wined3d_device *device, UINT rt_count, struct wined3d_surface **rts,
+ struct wined3d_surface *depth_stencil, UINT rect_count, const RECT *rects, const RECT *draw_rect,
+ DWORD flags, const WINED3DCOLORVALUE *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
+BOOL device_context_add(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
+void device_context_remove(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
+void device_get_draw_rect(struct wined3d_device *device, RECT *rect) DECLSPEC_HIDDEN;
+HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d,
UINT adapter_idx, WINED3DDEVTYPE device_type, HWND focus_window, DWORD flags,
- IWineD3DDeviceParent *device_parent) DECLSPEC_HIDDEN;
-void device_preload_textures(IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
-LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window,
+ struct wined3d_device_parent *device_parent) DECLSPEC_HIDDEN;
+void device_preload_textures(struct wined3d_device *device) DECLSPEC_HIDDEN;
+LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL unicode,
UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN;
-void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;
-void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;
-void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
+void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
+void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
+void device_stream_info_from_declaration(struct wined3d_device *device,
BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup) DECLSPEC_HIDDEN;
-void device_switch_onscreen_ds(IWineD3DDeviceImpl *device, struct wined3d_context *context,
- IWineD3DSurfaceImpl *depth_stencil) DECLSPEC_HIDDEN;
-void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
-void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) DECLSPEC_HIDDEN;
-void IWineD3DDeviceImpl_MarkStateDirty(IWineD3DDeviceImpl *This, DWORD state) DECLSPEC_HIDDEN;
+void device_switch_onscreen_ds(struct wined3d_device *device, struct wined3d_context *context,
+ struct wined3d_surface *depth_stencil) DECLSPEC_HIDDEN;
+void device_update_stream_info(struct wined3d_device *device, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
+void device_update_tex_unit_map(struct wined3d_device *device) DECLSPEC_HIDDEN;
+void IWineD3DDeviceImpl_MarkStateDirty(struct wined3d_device *device, DWORD state) DECLSPEC_HIDDEN;
static inline BOOL isStateDirty(struct wined3d_context *context, DWORD state)
{
@@ -1762,38 +1802,32 @@ static inline BOOL isStateDirty(struct wined3d_context *context, DWORD state)
return context->isStateDirty[idx] & (1 << shift);
}
-/* Support for IWineD3DResource ::Set/Get/FreePrivateData. */
-typedef struct PrivateData
+#define WINED3D_RESOURCE_ACCESS_GPU 0x1
+#define WINED3D_RESOURCE_ACCESS_CPU 0x2
+/* SCRATCH is mostly the same as CPU, but can't be used by the GPU at all,
+ * not even for resource uploads. */
+#define WINED3D_RESOURCE_ACCESS_SCRATCH 0x4
+
+struct wined3d_resource_ops
{
- struct list entry;
+ void (*resource_unload)(struct wined3d_resource *resource);
+};
- GUID tag;
- DWORD flags; /* DDSPD_* */
-
- union
- {
- LPVOID data;
- LPUNKNOWN object;
- } ptr;
-
- DWORD size;
-} PrivateData;
-
-/*****************************************************************************
- * IWineD3DResource implementation structure
- */
-typedef struct IWineD3DResourceClass
+struct wined3d_resource
{
- /* IUnknown fields */
- LONG ref; /* Note: Ref counting not required */
-
- /* WineD3DResource Information */
+ LONG ref;
+ struct wined3d_device *device;
WINED3DRESOURCETYPE resourceType;
- IWineD3DDeviceImpl *device;
- WINED3DPOOL pool;
- UINT size;
- DWORD usage;
const struct wined3d_format *format;
+ WINED3DMULTISAMPLE_TYPE multisample_type;
+ UINT multisample_quality;
+ DWORD usage;
+ WINED3DPOOL pool;
+ DWORD access_flags;
+ UINT width;
+ UINT height;
+ UINT depth;
+ UINT size;
DWORD priority;
BYTE *allocatedMemory; /* Pointer to the real data location */
BYTE *heapMemory; /* Pointer to the HeapAlloced block of memory */
@@ -1802,36 +1836,28 @@ typedef struct IWineD3DResourceClass
void *parent;
const struct wined3d_parent_ops *parent_ops;
-} IWineD3DResourceClass;
+ const struct wined3d_resource_ops *resource_ops;
+};
-typedef struct IWineD3DResourceImpl
-{
- /* IUnknown & WineD3DResource Information */
- const IWineD3DResourceVtbl *lpVtbl;
- IWineD3DResourceClass resource;
-} IWineD3DResourceImpl;
-
-void resource_cleanup(IWineD3DResource *iface) DECLSPEC_HIDDEN;
-HRESULT resource_free_private_data(IWineD3DResource *iface, REFGUID guid) DECLSPEC_HIDDEN;
-DWORD resource_get_priority(IWineD3DResource *iface) DECLSPEC_HIDDEN;
-HRESULT resource_get_private_data(IWineD3DResource *iface, REFGUID guid,
+void resource_cleanup(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
+HRESULT resource_free_private_data(struct wined3d_resource *resource, REFGUID guid) DECLSPEC_HIDDEN;
+DWORD resource_get_priority(const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
+HRESULT resource_get_private_data(const struct wined3d_resource *resource, REFGUID guid,
void *data, DWORD *data_size) DECLSPEC_HIDDEN;
-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) DECLSPEC_HIDDEN;
-WINED3DRESOURCETYPE resource_get_type(IWineD3DResource *iface) DECLSPEC_HIDDEN;
-DWORD resource_set_priority(IWineD3DResource *iface, DWORD new_priority) DECLSPEC_HIDDEN;
-HRESULT resource_set_private_data(IWineD3DResource *iface, REFGUID guid,
+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) DECLSPEC_HIDDEN;
+DWORD resource_set_priority(struct wined3d_resource *resource, DWORD priority) DECLSPEC_HIDDEN;
+HRESULT resource_set_private_data(struct wined3d_resource *resource, REFGUID guid,
const void *data, DWORD data_size, DWORD flags) DECLSPEC_HIDDEN;
-void resource_unload(IWineD3DResourceImpl *resource) DECLSPEC_HIDDEN;
+void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
/* Tests show that the start address of resources is 32 byte aligned */
#define RESOURCE_ALIGNMENT 16
-/*****************************************************************************
- * IWineD3DBaseTexture D3D- > openGL state map lookups
- */
-
typedef enum winetexturestates {
WINED3DTEXSTA_ADDRESSU = 0,
WINED3DTEXSTA_ADDRESSV = 1,
@@ -1852,7 +1878,6 @@ enum WINED3DSRGB
SRGB_ANY = 0, /* Uses the cached value(e.g. external calls) */
SRGB_RGB = 1, /* Loads the rgb texture */
SRGB_SRGB = 2, /* Loads the srgb texture */
- SRGB_BOTH = 3, /* Loads both textures */
};
struct gl_texture
@@ -1862,148 +1887,75 @@ struct gl_texture
GLuint name;
};
-/*****************************************************************************
- * IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
- */
-typedef struct IWineD3DBaseTextureClass
+struct wined3d_texture_ops
{
- struct gl_texture texture_rgb, texture_srgb;
- IWineD3DResourceImpl **sub_resources;
+ HRESULT (*texture_bind)(struct wined3d_texture *texture,
+ const struct wined3d_gl_info *gl_info, BOOL srgb);
+ void (*texture_preload)(struct wined3d_texture *texture, enum WINED3DSRGB srgb);
+ void (*texture_sub_resource_add_dirty_region)(struct wined3d_resource *sub_resource,
+ const WINED3DBOX *dirty_region);
+ void (*texture_sub_resource_cleanup)(struct wined3d_resource *sub_resource);
+};
+
+#define WINED3D_TEXTURE_COND_NP2 0x1
+#define WINED3D_TEXTURE_POW2_MAT_IDENT 0x2
+#define WINED3D_TEXTURE_IS_SRGB 0x4
+
+struct wined3d_texture
+{
+ struct wined3d_resource resource;
+ const struct wined3d_texture_ops *texture_ops;
+ struct gl_texture texture_rgb, texture_srgb;
+ struct wined3d_resource **sub_resources;
UINT layer_count;
UINT level_count;
- float pow2Matrix[16];
- UINT LOD;
- WINED3DTEXTUREFILTERTYPE filterType;
- LONG bindCount;
- DWORD sampler;
- BOOL is_srgb;
- BOOL pow2Matrix_identity;
- const struct min_lookup *minMipLookup;
- const GLenum *magLookup;
+ float pow2_matrix[16];
+ UINT lod;
+ WINED3DTEXTUREFILTERTYPE filter_type;
+ LONG bind_count;
+ DWORD sampler;
+ DWORD flags;
+ const struct min_lookup *min_mip_lookup;
+ const GLenum *mag_lookup;
GLenum target;
- void (*internal_preload)(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb);
-} IWineD3DBaseTextureClass;
+};
-typedef struct IWineD3DBaseTextureImpl
+static inline struct wined3d_texture *wined3d_texture_from_resource(struct wined3d_resource *resource)
{
- /* IUnknown & WineD3DResource Information */
- const IWineD3DBaseTextureVtbl *lpVtbl;
- IWineD3DResourceClass resource;
- IWineD3DBaseTextureClass baseTexture;
+ return CONTAINING_RECORD(resource, struct wined3d_texture, resource);
+}
-} IWineD3DBaseTextureImpl;
+static inline struct gl_texture *wined3d_texture_get_gl_texture(struct wined3d_texture *texture,
+ const struct wined3d_gl_info *gl_info, BOOL srgb)
+{
+ return srgb && !gl_info->supported[EXT_TEXTURE_SRGB_DECODE]
+ ? &texture->texture_srgb : &texture->texture_rgb;
+}
-void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
- const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
+void wined3d_texture_apply_state_changes(struct wined3d_texture *texture,
const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1],
const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
-HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surface_desc) DECLSPEC_HIDDEN;
-void basetexture_cleanup(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
-void basetexture_generate_mipmaps(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
-WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
-BOOL basetexture_get_dirty(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
-DWORD basetexture_get_level_count(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
-DWORD basetexture_get_lod(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
-IWineD3DResourceImpl *basetexture_get_sub_resource(IWineD3DBaseTextureImpl *texture,
- UINT layer, UINT level) DECLSPEC_HIDDEN;
-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) DECLSPEC_HIDDEN;
-HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface,
- WINED3DTEXTUREFILTERTYPE filter_type) DECLSPEC_HIDDEN;
-BOOL basetexture_set_dirty(IWineD3DBaseTexture *iface, BOOL dirty) DECLSPEC_HIDDEN;
-DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD new_lod) DECLSPEC_HIDDEN;
-void basetexture_unload(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
+void wined3d_texture_set_dirty(struct wined3d_texture *texture, BOOL dirty) DECLSPEC_HIDDEN;
-/*****************************************************************************
- * IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
- */
-typedef struct IWineD3DTextureImpl
+struct wined3d_volume
{
- /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
- const IWineD3DTextureVtbl *lpVtbl;
- IWineD3DResourceClass resource;
- IWineD3DBaseTextureClass baseTexture;
-
- /* IWineD3DTexture */
- BOOL cond_np2;
-
-} IWineD3DTextureImpl;
-
-HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT levels,
- IWineD3DDeviceImpl *device, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool,
- void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
-
-/*****************************************************************************
- * IWineD3DCubeTexture implementation structure (extends IWineD3DBaseTextureImpl)
- */
-typedef struct IWineD3DCubeTextureImpl
-{
- /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
- const IWineD3DCubeTextureVtbl *lpVtbl;
- IWineD3DResourceClass resource;
- IWineD3DBaseTextureClass baseTexture;
-} IWineD3DCubeTextureImpl;
-
-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) DECLSPEC_HIDDEN;
-
-typedef struct _WINED3DVOLUMET_DESC
-{
- UINT Width;
- UINT Height;
- UINT Depth;
-} WINED3DVOLUMET_DESC;
-
-/*****************************************************************************
- * IWineD3DVolume implementation structure (extends IUnknown)
- */
-typedef struct IWineD3DVolumeImpl
-{
- /* IUnknown & WineD3DResource fields */
- const IWineD3DVolumeVtbl *lpVtbl;
- IWineD3DResourceClass resource;
-
- /* WineD3DVolume Information */
- WINED3DVOLUMET_DESC currentDesc;
- struct IWineD3DVolumeTextureImpl *container;
+ struct wined3d_resource resource;
+ struct wined3d_texture *container;
BOOL lockable;
BOOL locked;
WINED3DBOX lockedBox;
WINED3DBOX dirtyBox;
BOOL dirty;
-} IWineD3DVolumeImpl;
+};
-void volume_add_dirty_box(IWineD3DVolume *iface, const WINED3DBOX *dirty_box) DECLSPEC_HIDDEN;
-HRESULT volume_init(IWineD3DVolumeImpl *volume, IWineD3DDeviceImpl *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) DECLSPEC_HIDDEN;
-void volume_set_container(IWineD3DVolumeImpl *volume, struct IWineD3DVolumeTextureImpl *container) DECLSPEC_HIDDEN;
-
-/*****************************************************************************
- * IWineD3DVolumeTexture implementation structure (extends IWineD3DBaseTextureImpl)
- */
-typedef struct IWineD3DVolumeTextureImpl
+static inline struct wined3d_volume *volume_from_resource(struct wined3d_resource *resource)
{
- /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
- const IWineD3DVolumeTextureVtbl *lpVtbl;
- IWineD3DResourceClass resource;
- IWineD3DBaseTextureClass baseTexture;
-} IWineD3DVolumeTextureImpl;
+ return CONTAINING_RECORD(resource, struct wined3d_volume, resource);
+}
-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) DECLSPEC_HIDDEN;
-
-typedef struct _WINED3DSURFACET_DESC
-{
- WINED3DMULTISAMPLE_TYPE MultiSampleType;
- DWORD MultiSampleQuality;
- UINT Width;
- UINT Height;
-} WINED3DSURFACET_DESC;
+void volume_add_dirty_box(struct wined3d_volume *volume, const WINED3DBOX *dirty_box) DECLSPEC_HIDDEN;
+void volume_load(struct wined3d_volume *volume, UINT level, BOOL srgb_mode) DECLSPEC_HIDDEN;
+void volume_set_container(struct wined3d_volume *volume, struct wined3d_texture *container) DECLSPEC_HIDDEN;
/*****************************************************************************
* Structure for DIB Surfaces (GetDC and GDI surfaces)
@@ -2016,33 +1968,30 @@ typedef struct wineD3DSurface_DIB {
BOOL client_memory;
} wineD3DSurface_DIB;
-typedef struct {
+struct wined3d_renderbuffer_entry
+{
struct list entry;
GLuint id;
UINT width;
UINT height;
-} renderbuffer_entry_t;
+};
struct fbo_entry
{
struct list entry;
- IWineD3DSurfaceImpl **render_targets;
- IWineD3DSurfaceImpl *depth_stencil;
+ struct wined3d_surface **render_targets;
+ struct wined3d_surface *depth_stencil;
DWORD location;
BOOL attached;
GLuint id;
};
-/*****************************************************************************
- * IWineD3DClipp implementation structure
- */
-typedef struct IWineD3DClipperImpl
+struct wined3d_clipper
{
- const IWineD3DClipperVtbl *lpVtbl;
LONG ref;
HWND hWnd;
-} IWineD3DClipperImpl;
+};
enum wined3d_container_type
{
@@ -2056,30 +2005,42 @@ struct wined3d_subresource_container
enum wined3d_container_type type;
union
{
- struct IWineD3DBase *base;
- struct IWineD3DSwapChainImpl *swapchain;
- struct IWineD3DBaseTextureImpl *texture;
+ struct wined3d_swapchain *swapchain;
+ struct wined3d_texture *texture;
+ void *base;
} u;
};
-/*****************************************************************************
- * IWineD3DSurface implementation structure
- */
-struct IWineD3DSurfaceImpl
+struct wined3d_surface_ops
{
- /* IUnknown & IWineD3DResource Information */
- const IWineD3DSurfaceVtbl *lpVtbl;
- IWineD3DResourceClass resource;
+ HRESULT (*surface_private_setup)(struct wined3d_surface *surface);
+ void (*surface_cleanup)(struct wined3d_surface *surface);
+ void (*surface_realize_palette)(struct wined3d_surface *surface);
+ HRESULT (*surface_draw_overlay)(struct wined3d_surface *surface);
+ void (*surface_preload)(struct wined3d_surface *surface);
+ void (*surface_map)(struct wined3d_surface *surface, const RECT *rect, DWORD flags);
+ void (*surface_unmap)(struct wined3d_surface *surface);
+ HRESULT (*surface_getdc)(struct wined3d_surface *surface);
+ HRESULT (*surface_flip)(struct wined3d_surface *surface, struct wined3d_surface *override);
+ HRESULT (*surface_blt)(struct wined3d_surface *dst_surface, const RECT *dst_rect,
+ struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
+ const WINEDDBLTFX *fx, WINED3DTEXTUREFILTERTYPE filter);
+ HRESULT (*surface_bltfast)(struct wined3d_surface *dst_surface, DWORD dst_x, DWORD dst_y,
+ struct wined3d_surface *src_surface, const RECT *src_rect, DWORD trans);
+ HRESULT (*surface_set_mem)(struct wined3d_surface *surface, void *mem);
+};
- /* IWineD3DSurface fields */
+struct wined3d_surface
+{
+ struct wined3d_resource resource;
+ const struct wined3d_surface_ops *surface_ops;
struct wined3d_subresource_container container;
- WINED3DSURFACET_DESC currentDesc;
- IWineD3DPaletteImpl *palette; /* D3D7 style palette handling */
+ struct wined3d_palette *palette; /* D3D7 style palette handling */
PALETTEENTRY *palette9; /* D3D8/9 style palette handling */
- /* TODO: move this off into a management class(maybe!) */
- DWORD Flags;
+ DWORD flags;
+ WINED3DSURFTYPE surface_type;
UINT pow2Width;
UINT pow2Height;
@@ -2112,98 +2073,61 @@ struct IWineD3DSurfaceImpl
WINEDDCOLORKEY glCKey;
struct list renderbuffers;
- renderbuffer_entry_t *current_renderbuffer;
+ struct wined3d_renderbuffer_entry *current_renderbuffer;
SIZE ds_current_size;
/* DirectDraw clippers */
- IWineD3DClipper *clipper;
+ struct wined3d_clipper *clipper;
/* DirectDraw Overlay handling */
RECT overlay_srcrect;
RECT overlay_destrect;
- IWineD3DSurfaceImpl *overlay_dest;
+ struct wined3d_surface *overlay_dest;
struct list overlays;
struct list overlay_entry;
};
-extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl DECLSPEC_HIDDEN;
-extern const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl DECLSPEC_HIDDEN;
+static inline struct wined3d_surface *surface_from_resource(struct wined3d_resource *resource)
+{
+ return CONTAINING_RECORD(resource, struct wined3d_surface, resource);
+}
-void surface_add_dirty_rect(IWineD3DSurfaceImpl *surface, const RECT *dirty_rect) DECLSPEC_HIDDEN;
-HRESULT surface_color_fill(IWineD3DSurfaceImpl *s, const RECT *rect, const WINED3DCOLORVALUE *color) DECLSPEC_HIDDEN;
-void surface_gdi_cleanup(IWineD3DSurfaceImpl *This) DECLSPEC_HIDDEN;
-GLenum surface_get_gl_buffer(IWineD3DSurfaceImpl *surface) DECLSPEC_HIDDEN;
-HRESULT surface_init(IWineD3DSurfaceImpl *surface, WINED3DSURFTYPE surface_type, UINT alignment,
- UINT width, UINT height, UINT level, BOOL lockable, BOOL discard, WINED3DMULTISAMPLE_TYPE multisample_type,
- UINT multisample_quality, IWineD3DDeviceImpl *device, DWORD usage, enum wined3d_format_id format_id,
- WINED3DPOOL pool, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
-BOOL surface_init_sysmem(IWineD3DSurfaceImpl *surface) DECLSPEC_HIDDEN;
-void surface_internal_preload(IWineD3DSurfaceImpl *surface, enum WINED3DSRGB srgb) DECLSPEC_HIDDEN;
-BOOL surface_is_offscreen(IWineD3DSurfaceImpl *iface) DECLSPEC_HIDDEN;
-void surface_load_ds_location(IWineD3DSurfaceImpl *surface,
+static inline GLuint surface_get_texture_name(struct wined3d_surface *surface,
+ const struct wined3d_gl_info *gl_info, BOOL srgb)
+{
+ return srgb && !gl_info->supported[EXT_TEXTURE_SRGB_DECODE]
+ ? surface->texture_name_srgb : surface->texture_name;
+}
+
+void surface_add_dirty_rect(struct wined3d_surface *surface, const WINED3DBOX *dirty_rect) DECLSPEC_HIDDEN;
+void surface_bind(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info, BOOL srgb) DECLSPEC_HIDDEN;
+HRESULT surface_color_fill(struct wined3d_surface *s, const RECT *rect, const WINED3DCOLORVALUE *color) DECLSPEC_HIDDEN;
+GLenum surface_get_gl_buffer(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
+BOOL surface_init_sysmem(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
+void surface_internal_preload(struct wined3d_surface *surface, enum WINED3DSRGB srgb) DECLSPEC_HIDDEN;
+BOOL surface_is_offscreen(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
+HRESULT surface_load(struct wined3d_surface *surface, BOOL srgb) DECLSPEC_HIDDEN;
+void surface_load_ds_location(struct wined3d_surface *surface,
struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
-HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RECT *rect) DECLSPEC_HIDDEN;
-void surface_modify_ds_location(IWineD3DSurfaceImpl *surface, DWORD location, UINT w, UINT h) DECLSPEC_HIDDEN;
-void surface_modify_location(IWineD3DSurfaceImpl *surface, DWORD flag, BOOL persistent) DECLSPEC_HIDDEN;
-void surface_prepare_texture(IWineD3DSurfaceImpl *surface,
+HRESULT surface_load_location(struct wined3d_surface *surface, DWORD flag, const RECT *rect) DECLSPEC_HIDDEN;
+void surface_modify_ds_location(struct wined3d_surface *surface, DWORD location, UINT w, UINT h) DECLSPEC_HIDDEN;
+void surface_modify_location(struct wined3d_surface *surface, DWORD flag, BOOL persistent) DECLSPEC_HIDDEN;
+void surface_prepare_texture(struct wined3d_surface *surface,
const struct wined3d_gl_info *gl_info, BOOL srgb) DECLSPEC_HIDDEN;
-void surface_set_compatible_renderbuffer(IWineD3DSurfaceImpl *surface,
- unsigned int width, unsigned int height) DECLSPEC_HIDDEN;
-void surface_set_container(IWineD3DSurfaceImpl *surface,
- enum wined3d_container_type type, IWineD3DBase *container) DECLSPEC_HIDDEN;
-void surface_set_texture_name(IWineD3DSurfaceImpl *surface, GLuint name, BOOL srgb_name) DECLSPEC_HIDDEN;
-void surface_set_texture_target(IWineD3DSurfaceImpl *surface, GLenum target) DECLSPEC_HIDDEN;
-void surface_translate_frontbuffer_coords(IWineD3DSurfaceImpl *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN;
-
-/* Predeclare the shared Surface functions */
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_QueryInterface(IWineD3DSurface *iface,
- REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN;
-ULONG WINAPI IWineD3DBaseSurfaceImpl_AddRef(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
-void * WINAPI IWineD3DBaseSurfaceImpl_GetParent(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPrivateData(IWineD3DSurface *iface,
- REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPrivateData(IWineD3DSurface *iface,
- REFGUID refguid, void *pData, DWORD *pSizeOfData) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGUID refguid) DECLSPEC_HIDDEN;
-DWORD WINAPI IWineD3DBaseSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew) DECLSPEC_HIDDEN;
-DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPriority(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
-WINED3DRESOURCETYPE WINAPI IWineD3DBaseSurfaceImpl_GetType(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
-void WINAPI IWineD3DBaseSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFACE_DESC *desc) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetBltStatus(IWineD3DSurface *iface, DWORD Flags) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetFlipStatus(IWineD3DSurface *iface, DWORD Flags) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_IsLost(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_Restore(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPalette(IWineD3DSurface *iface, IWineD3DPalette **Pal) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface,
- DWORD Flags, const WINEDDCOLORKEY *CKey) DECLSPEC_HIDDEN;
-DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPitch(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetOverlayPosition(IWineD3DSurface *iface, LONG X, LONG Y) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetOverlayPosition(IWineD3DSurface *iface, LONG *X, LONG *Y) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *iface,
- DWORD Flags, IWineD3DSurface *Ref) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, const RECT *SrcRect,
- IWineD3DSurface *DstSurface, const RECT *DstRect, DWORD Flags, const WINEDDOVERLAYFX *FX) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetClipper(IWineD3DSurface *iface, IWineD3DClipper *clipper) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetClipper(IWineD3DSurface *iface, IWineD3DClipper **clipper) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface,
- enum wined3d_format_id format_id) DECLSPEC_HIDDEN;
-HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *dst_rect, IWineD3DSurface *src_surface,
- const RECT *src_rect, DWORD flags, const WINEDDBLTFX *fx, WINED3DTEXTUREFILTERTYPE filter) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty,
- IWineD3DSurface *Source, const RECT *rsrc, DWORD trans) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DLOCKED_RECT *pLockedRect,
- const RECT *pRect, DWORD Flags) DECLSPEC_HIDDEN;
-const void *WINAPI IWineD3DBaseSurfaceImpl_GetData(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
+void surface_set_compatible_renderbuffer(struct wined3d_surface *surface, struct wined3d_surface *rt) DECLSPEC_HIDDEN;
+void surface_set_container(struct wined3d_surface *surface,
+ enum wined3d_container_type type, void *container) DECLSPEC_HIDDEN;
+void surface_set_texture_name(struct wined3d_surface *surface, GLuint name, BOOL srgb_name) DECLSPEC_HIDDEN;
+void surface_set_texture_target(struct wined3d_surface *surface, GLenum target) DECLSPEC_HIDDEN;
+void surface_translate_drawable_coords(struct wined3d_surface *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN;
void get_drawable_size_swapchain(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
void get_drawable_size_fbo(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
-void draw_textured_quad(IWineD3DSurfaceImpl *src_surface, const RECT *src_rect,
+void draw_textured_quad(struct wined3d_surface *src_surface, const RECT *src_rect,
const RECT *dst_rect, WINED3DTEXTUREFILTERTYPE Filter) DECLSPEC_HIDDEN;
-void flip_surface(IWineD3DSurfaceImpl *front, IWineD3DSurfaceImpl *back) DECLSPEC_HIDDEN;
+void flip_surface(struct wined3d_surface *front, struct wined3d_surface *back) DECLSPEC_HIDDEN;
/* Surface flags: */
#define SFLAG_CONVERTED 0x00000002 /* Converted for color keying or Palettized */
@@ -2265,15 +2189,11 @@ typedef enum {
CONVERT_RGB32_888
} CONVERT_TYPES;
-HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *surface, BOOL need_alpha_ck, BOOL use_texturing,
+HRESULT d3dfmt_get_conv(struct wined3d_surface *surface, BOOL need_alpha_ck, BOOL use_texturing,
struct wined3d_format *format, CONVERT_TYPES *convert) DECLSPEC_HIDDEN;
-void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *surface, BYTE table[256][4], BOOL colorkey) DECLSPEC_HIDDEN;
+void d3dfmt_p8_init_palette(struct wined3d_surface *surface, BYTE table[256][4], BOOL colorkey) DECLSPEC_HIDDEN;
-BOOL palette9_changed(IWineD3DSurfaceImpl *This) DECLSPEC_HIDDEN;
-
-/*****************************************************************************
- * IWineD3DVertexDeclaration implementation structure
- */
+BOOL palette9_changed(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
struct wined3d_vertex_declaration_element
{
@@ -2287,14 +2207,12 @@ struct wined3d_vertex_declaration_element
BYTE usage_idx;
};
-typedef struct IWineD3DVertexDeclarationImpl {
- /* IUnknown Information */
- const IWineD3DVertexDeclarationVtbl *lpVtbl;
- LONG ref;
-
+struct wined3d_vertex_declaration
+{
+ LONG ref;
void *parent;
const struct wined3d_parent_ops *parent_ops;
- IWineD3DDeviceImpl *device;
+ struct wined3d_device *device;
struct wined3d_vertex_declaration_element *elements;
UINT element_count;
@@ -2303,15 +2221,7 @@ typedef struct IWineD3DVertexDeclarationImpl {
UINT num_streams;
BOOL position_transformed;
BOOL half_float_conv_needed;
-} IWineD3DVertexDeclarationImpl;
-
-HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *declaration, IWineD3DDeviceImpl *device,
- const WINED3DVERTEXELEMENT *elements, UINT element_count,
- void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
-
-/*****************************************************************************
- * IWineD3DStateBlock implementation structure
- */
+};
/* Internal state Block for Begin/End/Capture/Create/Apply info */
/* Note: Very long winded but gl Lists are not flexible enough */
@@ -2358,7 +2268,7 @@ struct wined3d_stream_state
struct wined3d_state
{
- IWineD3DVertexDeclarationImpl *vertex_declaration;
+ struct wined3d_vertex_declaration *vertex_declaration;
struct wined3d_stream_state streams[MAX_STREAMS + 1 /* tesselated pseudo-stream */];
BOOL user_stream;
struct wined3d_buffer *index_buffer;
@@ -2367,17 +2277,17 @@ struct wined3d_state
INT load_base_vertex_index; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
GLenum gl_primitive_type;
- struct IWineD3DVertexShaderImpl *vertex_shader;
+ struct wined3d_shader *vertex_shader;
BOOL vs_consts_b[MAX_CONST_B];
INT vs_consts_i[MAX_CONST_I * 4];
float *vs_consts_f;
- struct IWineD3DPixelShaderImpl *pixel_shader;
+ struct wined3d_shader *pixel_shader;
BOOL ps_consts_b[MAX_CONST_B];
INT ps_consts_i[MAX_CONST_I * 4];
float *ps_consts_f;
- IWineD3DBaseTextureImpl *textures[MAX_COMBINED_SAMPLERS];
+ struct wined3d_texture *textures[MAX_COMBINED_SAMPLERS];
DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
DWORD texture_states[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
DWORD lowest_disabled_stage;
@@ -2398,14 +2308,10 @@ struct wined3d_state
DWORD render_states[WINEHIGHEST_RENDER_STATE + 1];
};
-struct IWineD3DStateBlockImpl
+struct wined3d_stateblock
{
- /* IUnknown fields */
- const IWineD3DStateBlockVtbl *lpVtbl;
LONG ref; /* Note: Ref counting not required */
-
- /* IWineD3DStateBlock information */
- IWineD3DDeviceImpl *device;
+ struct wined3d_device *device;
WINED3DSTATEBLOCKTYPE blockType;
/* Array indicating whether things have been set or changed */
@@ -2435,12 +2341,10 @@ struct IWineD3DStateBlockImpl
unsigned int num_contained_sampler_states;
};
-HRESULT stateblock_init(IWineD3DStateBlockImpl *stateblock,
- IWineD3DDeviceImpl *device, WINED3DSTATEBLOCKTYPE type) DECLSPEC_HIDDEN;
-void stateblock_init_contained_states(IWineD3DStateBlockImpl *object) DECLSPEC_HIDDEN;
-void stateblock_init_default_state(IWineD3DStateBlockImpl *stateblock) DECLSPEC_HIDDEN;
+void stateblock_init_contained_states(struct wined3d_stateblock *stateblock) DECLSPEC_HIDDEN;
+void stateblock_init_default_state(struct wined3d_stateblock *stateblock) DECLSPEC_HIDDEN;
-static inline void stateblock_apply_state(DWORD state, IWineD3DStateBlockImpl *stateblock,
+static inline void stateblock_apply_state(DWORD state, struct wined3d_stateblock *stateblock,
struct wined3d_context *context)
{
const struct StateEntry *statetable = stateblock->device->StateTable;
@@ -2457,26 +2361,23 @@ enum query_state {
QUERY_SIGNALLED,
QUERY_BUILDING
};
-/*****************************************************************************
- * IWineD3DQueryImpl implementation structure (extends IUnknown)
- */
-typedef struct IWineD3DQueryImpl
+
+struct wined3d_query_ops
{
- const IWineD3DQueryVtbl *lpVtbl;
- LONG ref; /* Note: Ref counting not required */
+ HRESULT (*query_get_data)(struct wined3d_query *query, void *data, DWORD data_size, DWORD flags);
+ HRESULT (*query_issue)(struct wined3d_query *query, DWORD flags);
+};
- IWineD3DDeviceImpl *device;
-
- /* IWineD3DQuery fields */
+struct wined3d_query
+{
+ LONG ref;
+ const struct wined3d_query_ops *query_ops;
+ struct wined3d_device *device;
enum query_state state;
WINED3DQUERYTYPE type;
- /* TODO: Think about using a IUnknown instead of a void* */
+ DWORD data_size;
void *extendedData;
-} IWineD3DQueryImpl;
-
-HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device, WINED3DQUERYTYPE type) DECLSPEC_HIDDEN;
-
-/* IWineD3DBuffer */
+};
/* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
* fixed function semantics as D3DCOLOR or FLOAT16 */
@@ -2485,7 +2386,6 @@ enum wined3d_buffer_conversion_type
CONV_NONE,
CONV_D3DCOLOR,
CONV_POSITIONT,
- CONV_FLOAT16_2, /* Also handles FLOAT16_4 */
};
struct wined3d_map_range
@@ -2505,8 +2405,7 @@ struct wined3d_map_range
struct wined3d_buffer
{
- const struct IWineD3DBufferVtbl *vtbl;
- IWineD3DResourceClass resource;
+ struct wined3d_resource resource;
struct wined3d_buffer_desc desc;
@@ -2528,93 +2427,63 @@ struct wined3d_buffer
UINT stride; /* 0 if no conversion */
UINT conversion_stride; /* 0 if no shifted conversion */
enum wined3d_buffer_conversion_type *conversion_map; /* NULL if no conversion */
- /* Extra load offsets, for FLOAT16 conversion */
- UINT *conversion_shift; /* NULL if no shifted conversion */
};
-const BYTE *buffer_get_memory(IWineD3DBuffer *iface, const struct wined3d_gl_info *gl_info,
+static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resource *resource)
+{
+ return CONTAINING_RECORD(resource, struct wined3d_buffer, resource);
+}
+
+const BYTE *buffer_get_memory(struct wined3d_buffer *buffer, const struct wined3d_gl_info *gl_info,
GLuint *buffer_object) DECLSPEC_HIDDEN;
BYTE *buffer_get_sysmem(struct wined3d_buffer *This, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
-HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device,
- UINT size, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool, GLenum bind_hint,
- const char *data, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
-/* IWineD3DRendertargetView */
struct wined3d_rendertarget_view
{
- const struct IWineD3DRendertargetViewVtbl *vtbl;
LONG refcount;
- IWineD3DResource *resource;
+ struct wined3d_resource *resource;
void *parent;
};
-void wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *view,
- IWineD3DResource *resource, void *parent) DECLSPEC_HIDDEN;
-
-/*****************************************************************************
- * IWineD3DSwapChainImpl implementation structure (extends IUnknown)
- */
-
-struct IWineD3DSwapChainImpl
+struct wined3d_swapchain_ops
{
- /*IUnknown part*/
- const IWineD3DSwapChainVtbl *lpVtbl;
- LONG ref; /* Note: Ref counting not required */
+ HRESULT (*swapchain_present)(struct wined3d_swapchain *swapchain, const RECT *src_rect,
+ const RECT *dst_rect, const RGNDATA *dirty_region, DWORD flags);
+};
+struct wined3d_swapchain
+{
+ LONG ref;
void *parent;
- IWineD3DDeviceImpl *device;
+ const struct wined3d_parent_ops *parent_ops;
+ const struct wined3d_swapchain_ops *swapchain_ops;
+ struct wined3d_device *device;
- /* IWineD3DSwapChain fields */
- IWineD3DSurfaceImpl **back_buffers;
- IWineD3DSurfaceImpl *front_buffer;
+ struct wined3d_surface **back_buffers;
+ struct wined3d_surface *front_buffer;
WINED3DPRESENT_PARAMETERS presentParms;
- DWORD orig_width, orig_height;
+ DWORD orig_width, orig_height;
enum wined3d_format_id orig_fmt;
- WINED3DGAMMARAMP orig_gamma;
- BOOL render_to_fbo;
+ WINED3DGAMMARAMP orig_gamma;
+ BOOL render_to_fbo;
const struct wined3d_format *ds_format;
LONG prev_time, frames; /* Performance tracking */
- unsigned int vSyncCounter;
struct wined3d_context **context;
- unsigned int num_contexts;
+ unsigned int num_contexts;
- HWND win_handle;
+ HWND win_handle;
HWND device_window;
+
+ HDC backup_dc;
+ HWND backup_wnd;
};
-extern const IWineD3DSwapChainVtbl IWineGDISwapChain_Vtbl DECLSPEC_HIDDEN;
-void x11_copy_to_screen(IWineD3DSwapChainImpl *This, const RECT *rc) DECLSPEC_HIDDEN;
+void x11_copy_to_screen(struct wined3d_swapchain *swapchain, const RECT *rect) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface,
- REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN;
-ULONG WINAPI IWineD3DBaseSwapChainImpl_AddRef(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
-ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
-void * WINAPI IWineD3DBaseSwapChainImpl_GetParent(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface,
- IWineD3DSurface *dst_surface) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface, UINT iBackBuffer,
- WINED3DBACKBUFFER_TYPE Type, IWineD3DSurface **ppBackBuffer) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface,
- WINED3DRASTER_STATUS *pRasterStatus) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface,
- WINED3DDISPLAYMODE *pMode) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDevice(IWineD3DSwapChain *iface,
- IWineD3DDevice **device) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface,
- WINED3DPRESENT_PARAMETERS *pPresentationParameters) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface,
- DWORD Flags, const WINED3DGAMMARAMP *pRamp) DECLSPEC_HIDDEN;
-HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface,
- WINED3DGAMMARAMP *pRamp) DECLSPEC_HIDDEN;
-
-struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
-HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface_type,
- IWineD3DDeviceImpl *device, WINED3DPRESENT_PARAMETERS *present_parameters, void *parent) DECLSPEC_HIDDEN;
-void swapchain_restore_fullscreen_window(IWineD3DSwapChainImpl *swapchain) DECLSPEC_HIDDEN;
-void swapchain_setup_fullscreen_window(IWineD3DSwapChainImpl *swapchain, UINT w, UINT h) DECLSPEC_HIDDEN;
+struct wined3d_context *swapchain_get_context(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
#define DEFAULT_REFRESH_RATE 0
@@ -2631,7 +2500,7 @@ const char *debug_d3dusagequery(DWORD usagequery) DECLSPEC_HIDDEN;
const char *debug_d3ddeclmethod(WINED3DDECLMETHOD method) DECLSPEC_HIDDEN;
const char *debug_d3ddeclusage(BYTE usage) DECLSPEC_HIDDEN;
const char *debug_d3dprimitivetype(WINED3DPRIMITIVETYPE PrimitiveType) DECLSPEC_HIDDEN;
-const char *debug_d3drenderstate(WINED3DRENDERSTATETYPE state) DECLSPEC_HIDDEN;
+const char *debug_d3drenderstate(DWORD state) DECLSPEC_HIDDEN;
const char *debug_d3dsamplerstate(DWORD state) DECLSPEC_HIDDEN;
const char *debug_d3dstate(DWORD state) DECLSPEC_HIDDEN;
const char *debug_d3dtexturefiltertype(WINED3DTEXTUREFILTERTYPE filter_type) DECLSPEC_HIDDEN;
@@ -2656,27 +2525,27 @@ void set_tex_op_nvrc(const struct wined3d_gl_info *gl_info, const struct wined3d
INT texture_idx, DWORD dst) DECLSPEC_HIDDEN;
void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords,
BOOL transformed, enum wined3d_format_id coordtype, BOOL ffp_can_disable_proj) DECLSPEC_HIDDEN;
-void texture_activate_dimensions(IWineD3DBaseTextureImpl *texture,
+void texture_activate_dimensions(const struct wined3d_texture *texture,
const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
-void sampler_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock,
+void sampler_texdim(DWORD state, struct wined3d_stateblock *stateblock,
struct wined3d_context *context) DECLSPEC_HIDDEN;
-void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock,
+void tex_alphaop(DWORD state, struct wined3d_stateblock *stateblock,
struct wined3d_context *context) DECLSPEC_HIDDEN;
-void apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock,
+void apply_pixelshader(DWORD state, struct wined3d_stateblock *stateblock,
struct wined3d_context *context) DECLSPEC_HIDDEN;
-void state_fogcolor(DWORD state, IWineD3DStateBlockImpl *stateblock,
+void state_fogcolor(DWORD state, struct wined3d_stateblock *stateblock,
struct wined3d_context *context) DECLSPEC_HIDDEN;
-void state_fogdensity(DWORD state, IWineD3DStateBlockImpl *stateblock,
+void state_fogdensity(DWORD state, struct wined3d_stateblock *stateblock,
struct wined3d_context *context) DECLSPEC_HIDDEN;
-void state_fogstartend(DWORD state, IWineD3DStateBlockImpl *stateblock,
+void state_fogstartend(DWORD state, struct wined3d_stateblock *stateblock,
struct wined3d_context *context) DECLSPEC_HIDDEN;
-void state_fog_fragpart(DWORD state, IWineD3DStateBlockImpl *stateblock,
+void state_fog_fragpart(DWORD state, struct wined3d_stateblock *stateblock,
struct wined3d_context *context) DECLSPEC_HIDDEN;
BOOL getColorBits(const struct wined3d_format *format,
- short *redSize, short *greenSize, short *blueSize, short *alphaSize, short *totalSize) DECLSPEC_HIDDEN;
+ BYTE *redSize, BYTE *greenSize, BYTE *blueSize, BYTE *alphaSize, BYTE *totalSize) DECLSPEC_HIDDEN;
BOOL getDepthStencilBits(const struct wined3d_format *format,
- short *depthSize, short *stencilSize) DECLSPEC_HIDDEN;
+ BYTE *depthSize, BYTE *stencilSize) DECLSPEC_HIDDEN;
/* Math utils */
void multiply_matrix(WINED3DMATRIX *dest, const WINED3DMATRIX *src1, const WINED3DMATRIX *src2) DECLSPEC_HIDDEN;
@@ -2691,7 +2560,8 @@ typedef struct local_constant {
DWORD value[4];
} local_constant;
-typedef struct SHADER_LIMITS {
+struct wined3d_shader_limits
+{
unsigned int temporary;
unsigned int texcoord;
unsigned int sampler;
@@ -2703,14 +2573,7 @@ typedef struct SHADER_LIMITS {
unsigned int packed_input;
unsigned int attributes;
unsigned int label;
-} SHADER_LIMITS;
-
-/* Keeps track of details for TEX_M#x# shader opcodes which need to
- * maintain state information between multiple codes */
-typedef struct SHADER_PARSE_STATE {
- unsigned int current_row;
- DWORD texcoord_w[2];
-} SHADER_PARSE_STATE;
+};
#ifdef __GNUC__
#define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
@@ -2723,21 +2586,34 @@ int shader_addline(struct wined3d_shader_buffer *buffer, const char *fmt, ...) P
int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *fmt, va_list args) DECLSPEC_HIDDEN;
/* Vertex shader utility functions */
-extern BOOL vshader_get_input(struct IWineD3DVertexShaderImpl *shader,
+extern BOOL vshader_get_input(struct wined3d_shader *shader,
BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) DECLSPEC_HIDDEN;
-/*****************************************************************************
- * IDirect3DBaseShader implementation structure
- */
-typedef struct IWineD3DBaseShaderClass
+struct wined3d_vertex_shader
{
- LONG ref;
- SHADER_LIMITS limits;
- SHADER_PARSE_STATE parse_state;
- DWORD *function;
- UINT functionLength;
- UINT cur_loop_depth, cur_loop_regno;
- BOOL load_local_constsF;
+ struct wined3d_shader_attribute attributes[MAX_ATTRIBS];
+};
+
+struct wined3d_pixel_shader
+{
+ /* Pixel shader input semantics */
+ DWORD input_reg_map[MAX_REG_INPUT];
+ BOOL input_reg_used[MAX_REG_INPUT];
+ unsigned int declared_in_count;
+
+ /* Some information about the shader behavior */
+ char vpos_uniform;
+ BOOL color0_mov;
+ DWORD color0_reg;
+};
+
+struct wined3d_shader
+{
+ LONG ref;
+ struct wined3d_shader_limits limits;
+ DWORD *function;
+ UINT functionLength;
+ BOOL load_local_constsF;
const struct wined3d_shader_frontend *frontend;
void *frontend_data;
void *backend_data;
@@ -2752,24 +2628,29 @@ typedef struct IWineD3DBaseShaderClass
struct list constantsB;
struct list constantsF;
struct list constantsI;
- shader_reg_maps reg_maps;
+ struct wined3d_shader_reg_maps reg_maps;
struct wined3d_shader_signature_element input_signature[max(MAX_ATTRIBS, MAX_REG_INPUT)];
struct wined3d_shader_signature_element output_signature[MAX_REG_OUTPUT];
/* Pointer to the parent device */
- IWineD3DDevice *device;
- struct list shader_list_entry;
+ struct wined3d_device *device;
+ struct list shader_list_entry;
-} IWineD3DBaseShaderClass;
+ union
+ {
+ struct wined3d_vertex_shader vs;
+ struct wined3d_pixel_shader ps;
+ } u;
+};
-typedef struct IWineD3DBaseShaderImpl {
- /* IUnknown */
- const IWineD3DBaseShaderVtbl *lpVtbl;
+void pixelshader_update_samplers(struct wined3d_shader_reg_maps *reg_maps,
+ struct wined3d_texture * const *textures) DECLSPEC_HIDDEN;
+void find_ps_compile_args(const struct wined3d_state *state,
+ const struct wined3d_shader *shader, struct ps_compile_args *args) DECLSPEC_HIDDEN;
- /* IWineD3DBaseShader */
- IWineD3DBaseShaderClass baseShader;
-} IWineD3DBaseShaderImpl;
+void find_vs_compile_args(const struct wined3d_state *state,
+ const struct wined3d_shader *shader, struct vs_compile_args *args) DECLSPEC_HIDDEN;
void shader_buffer_clear(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN;
BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN;
@@ -2778,9 +2659,10 @@ void shader_dump_src_param(const struct wined3d_shader_src_param *param,
const struct wined3d_shader_version *shader_version) DECLSPEC_HIDDEN;
void shader_dump_dst_param(const struct wined3d_shader_dst_param *param,
const struct wined3d_shader_version *shader_version) DECLSPEC_HIDDEN;
-unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max) DECLSPEC_HIDDEN;
-void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer,
- const shader_reg_maps *reg_maps, const DWORD *pFunction, void *backend_ctx) DECLSPEC_HIDDEN;
+unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps *reg_maps,
+ unsigned int max) DECLSPEC_HIDDEN;
+void shader_generate_main(struct wined3d_shader *shader, struct wined3d_shader_buffer *buffer,
+ const struct wined3d_shader_reg_maps *reg_maps, const DWORD *pFunction, void *backend_ctx) DECLSPEC_HIDDEN;
BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage) DECLSPEC_HIDDEN;
static inline BOOL shader_is_pshader_version(enum wined3d_shader_type type)
@@ -2828,53 +2710,36 @@ static inline BOOL shader_is_scalar(const struct wined3d_shader_register *reg)
}
}
-static inline BOOL shader_constant_is_local(IWineD3DBaseShaderImpl* This, DWORD reg) {
- local_constant* lconst;
+static inline void shader_get_position_fixup(const struct wined3d_context *context,
+ const struct wined3d_state *state, float *position_fixup)
+{
+ position_fixup[0] = 1.0f;
+ position_fixup[1] = 1.0f;
+ position_fixup[2] = (63.0f / 64.0f) / state->viewport.Width;
+ position_fixup[3] = -(63.0f / 64.0f) / state->viewport.Height;
- if(This->baseShader.load_local_constsF) return FALSE;
- LIST_FOR_EACH_ENTRY(lconst, &This->baseShader.constantsF, local_constant, entry) {
- if(lconst->idx == reg) return TRUE;
+ if (context->render_offscreen)
+ {
+ position_fixup[1] *= -1.0f;
+ position_fixup[3] *= -1.0f;
}
- return FALSE;
-
}
-/*****************************************************************************
- * IDirect3DVertexShader implementation structures
- */
-typedef struct IWineD3DVertexShaderImpl {
- /* IUnknown parts */
- const IWineD3DVertexShaderVtbl *lpVtbl;
-
- /* IWineD3DBaseShader */
- IWineD3DBaseShaderClass baseShader;
-
- /* Vertex shader attributes. */
- struct wined3d_shader_attribute attributes[MAX_ATTRIBS];
-
- UINT min_rel_offset, max_rel_offset;
- UINT rel_offset;
-} IWineD3DVertexShaderImpl;
-
-void find_vs_compile_args(const struct wined3d_state *state,
- IWineD3DVertexShaderImpl *shader, struct vs_compile_args *args) DECLSPEC_HIDDEN;
-HRESULT vertexshader_init(IWineD3DVertexShaderImpl *shader, IWineD3DDeviceImpl *device,
- const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
- void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
-
-struct wined3d_geometryshader
+static inline BOOL shader_constant_is_local(const struct wined3d_shader *shader, DWORD reg)
{
- const struct IWineD3DGeometryShaderVtbl *vtbl;
- IWineD3DBaseShaderClass base_shader;
-};
+ struct local_constant *lconst;
-HRESULT geometryshader_init(struct wined3d_geometryshader *shader, IWineD3DDeviceImpl *device,
- const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
- void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
+ if (shader->load_local_constsF)
+ return FALSE;
-/*****************************************************************************
- * IDirect3DPixelShader implementation structure
- */
+ LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, local_constant, entry)
+ {
+ if (lconst->idx == reg)
+ return TRUE;
+ }
+
+ return FALSE;
+}
/* Using additional shader constants (uniforms in GLSL / program environment
* or local parameters in ARB) is costly:
@@ -2893,34 +2758,6 @@ struct ps_np2fixup_info {
WORD num_consts;
};
-typedef struct IWineD3DPixelShaderImpl {
- /* IUnknown parts */
- const IWineD3DPixelShaderVtbl *lpVtbl;
-
- /* IWineD3DBaseShader */
- IWineD3DBaseShaderClass baseShader;
-
- /* Pixel shader input semantics */
- DWORD input_reg_map[MAX_REG_INPUT];
- BOOL input_reg_used[MAX_REG_INPUT];
- unsigned int declared_in_count;
-
- /* Some information about the shader behavior */
- char vpos_uniform;
-
- BOOL color0_mov;
- DWORD color0_reg;
-
-} IWineD3DPixelShaderImpl;
-
-HRESULT pixelshader_init(IWineD3DPixelShaderImpl *shader, IWineD3DDeviceImpl *device,
- const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
- void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
-void pixelshader_update_samplers(struct shader_reg_maps *reg_maps,
- IWineD3DBaseTexture * const *textures) DECLSPEC_HIDDEN;
-void find_ps_compile_args(const struct wined3d_state *state,
- IWineD3DPixelShaderImpl *shader, struct ps_compile_args *args) DECLSPEC_HIDDEN;
-
/* sRGB correction constants */
static const float srgb_cmp = 0.0031308f;
static const float srgb_mul_low = 12.92f;
@@ -2928,30 +2765,21 @@ static const float srgb_pow = 0.41666f;
static const float srgb_mul_high = 1.055f;
static const float srgb_sub_high = 0.055f;
-/*****************************************************************************
- * IWineD3DPalette implementation structure
- */
-struct IWineD3DPaletteImpl {
- /* IUnknown parts */
- const IWineD3DPaletteVtbl *lpVtbl;
- LONG ref;
-
+struct wined3d_palette
+{
+ LONG ref;
void *parent;
- IWineD3DDeviceImpl *device;
+ struct wined3d_device *device;
- /* IWineD3DPalette */
HPALETTE hpal;
WORD palVersion; /*| */
WORD palNumEntries; /*| LOGPALETTE */
PALETTEENTRY palents[256]; /*| */
/* This is to store the palette in 'screen format' */
int screen_palents[256];
- DWORD Flags;
+ DWORD flags;
};
-HRESULT wined3d_palette_init(IWineD3DPaletteImpl *palette, IWineD3DDeviceImpl *device,
- DWORD flags, const PALETTEENTRY *entries, void *parent) DECLSPEC_HIDDEN;
-
/* DirectDraw utility functions */
extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN;
@@ -2987,8 +2815,8 @@ struct wined3d_format
DWORD blue_mask;
DWORD alpha_mask;
UINT byte_count;
- WORD depth_size;
- WORD stencil_size;
+ BYTE depth_size;
+ BYTE stencil_size;
UINT block_width;
UINT block_height;
@@ -3007,7 +2835,7 @@ struct wined3d_format
GLint glFormat;
GLint glType;
UINT conv_byte_count;
- unsigned int Flags;
+ unsigned int flags;
float heightscale;
struct color_fixup_desc color_fixup;
void (*convert)(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height);
@@ -3037,10 +2865,6 @@ static inline BOOL use_ps(const struct wined3d_state *state)
/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
#define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
-#define WINEMAKEFOURCC(ch0, ch1, ch2, ch3) \
- ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \
- ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))
-
#define MAKEDWORD_VERSION(maj, min) (((maj & 0xffff) << 16) | (min & 0xffff))
#endif
diff --git a/reactos/include/reactos/wine/CMakeLists.txt b/reactos/include/reactos/wine/CMakeLists.txt
index d74cd51349e..54c4099bd23 100644
--- a/reactos/include/reactos/wine/CMakeLists.txt
+++ b/reactos/include/reactos/wine/CMakeLists.txt
@@ -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)
\ No newline at end of file
diff --git a/reactos/include/reactos/wine/wined3d.h b/reactos/include/reactos/wine/wined3d.h
new file mode 100644
index 00000000000..ed269f006e9
--- /dev/null
+++ b/reactos/include/reactos/wine/wined3d.h
@@ -0,0 +1,2547 @@
+/*
+ * Copyright 2002-2003 The wine-d3d team
+ * Copyright 2002-2003 Jason Edmeades
+ * Copyright 2002-2003 Raphael Junqueira
+ * Copyright 2005 Oliver Stieber
+ * Copyright 2006 Stefan Dösinger
+ * Copyright 2006 Stefan Dösinger for CodeWeavers
+ * Copyright 2007 Henri Verbeet
+ * Copyright 2008 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
+ */
+
+#ifndef __WINE_WINED3D_H
+#define __WINE_WINED3D_H
+
+#define WINED3D_OK S_OK
+
+#define _FACWINED3D 0x876
+#define MAKE_WINED3DSTATUS(code) MAKE_HRESULT(0, _FACWINED3D, code)
+#define WINED3DOK_NOAUTOGEN MAKE_WINED3DSTATUS(2159)
+
+#define MAKE_WINED3DHRESULT(code) MAKE_HRESULT(1, _FACWINED3D, code)
+#define WINED3DERR_WRONGTEXTUREFORMAT MAKE_WINED3DHRESULT(2072)
+#define WINED3DERR_UNSUPPORTEDCOLOROPERATION MAKE_WINED3DHRESULT(2073)
+#define WINED3DERR_UNSUPPORTEDCOLORARG MAKE_WINED3DHRESULT(2074)
+#define WINED3DERR_UNSUPPORTEDALPHAOPERATION MAKE_WINED3DHRESULT(2075)
+#define WINED3DERR_UNSUPPORTEDALPHAARG MAKE_WINED3DHRESULT(2076)
+#define WINED3DERR_TOOMANYOPERATIONS MAKE_WINED3DHRESULT(2077)
+#define WINED3DERR_CONFLICTINGTEXTUREFILTER MAKE_WINED3DHRESULT(2078)
+#define WINED3DERR_UNSUPPORTEDFACTORVALUE MAKE_WINED3DHRESULT(2079)
+#define WINED3DERR_CONFLICTINGRENDERSTATE MAKE_WINED3DHRESULT(2081)
+#define WINED3DERR_UNSUPPORTEDTEXTUREFILTER MAKE_WINED3DHRESULT(2082)
+#define WINED3DERR_CONFLICTINGTEXTUREPALETTE MAKE_WINED3DHRESULT(2086)
+#define WINED3DERR_DRIVERINTERNALERROR MAKE_WINED3DHRESULT(2087)
+#define WINED3DERR_NOTFOUND MAKE_WINED3DHRESULT(2150)
+#define WINED3DERR_MOREDATA MAKE_WINED3DHRESULT(2151)
+#define WINED3DERR_DEVICELOST MAKE_WINED3DHRESULT(2152)
+#define WINED3DERR_DEVICENOTRESET MAKE_WINED3DHRESULT(2153)
+#define WINED3DERR_NOTAVAILABLE MAKE_WINED3DHRESULT(2154)
+#define WINED3DERR_OUTOFVIDEOMEMORY MAKE_WINED3DHRESULT(380)
+#define WINED3DERR_INVALIDDEVICE MAKE_WINED3DHRESULT(2155)
+#define WINED3DERR_INVALIDCALL MAKE_WINED3DHRESULT(2156)
+#define WINED3DERR_DRIVERINVALIDCALL MAKE_WINED3DHRESULT(2157)
+#define WINED3DERR_WASSTILLDRAWING MAKE_WINED3DHRESULT(540)
+#define WINEDDERR_NOTAOVERLAYSURFACE MAKE_WINED3DHRESULT(580)
+#define WINEDDERR_NOTLOCKED MAKE_WINED3DHRESULT(584)
+#define WINEDDERR_NODC MAKE_WINED3DHRESULT(586)
+#define WINEDDERR_DCALREADYCREATED MAKE_WINED3DHRESULT(620)
+#define WINEDDERR_NOTFLIPPABLE MAKE_WINED3DHRESULT(582)
+#define WINEDDERR_SURFACEBUSY MAKE_WINED3DHRESULT(430)
+#define WINEDDERR_INVALIDRECT MAKE_WINED3DHRESULT(150)
+#define WINEDDERR_NOCLIPLIST MAKE_WINED3DHRESULT(205)
+#define WINEDDERR_OVERLAYNOTVISIBLE MAKE_WINED3DHRESULT(577)
+
+typedef DWORD WINED3DCOLOR;
+
+typedef enum _WINED3DLIGHTTYPE
+{
+ WINED3DLIGHT_POINT = 1,
+ WINED3DLIGHT_SPOT = 2,
+ WINED3DLIGHT_DIRECTIONAL = 3,
+ WINED3DLIGHT_PARALLELPOINT = 4, /* D3D7 */
+ WINED3DLIGHT_GLSPOT = 5, /* D3D7 */
+ WINED3DLIGHT_FORCE_DWORD = 0x7fffffff
+} WINED3DLIGHTTYPE;
+
+typedef enum _WINED3DPRIMITIVETYPE
+{
+ WINED3DPT_UNDEFINED = 0,
+ WINED3DPT_POINTLIST = 1,
+ WINED3DPT_LINELIST = 2,
+ WINED3DPT_LINESTRIP = 3,
+ WINED3DPT_TRIANGLELIST = 4,
+ WINED3DPT_TRIANGLESTRIP = 5,
+ WINED3DPT_TRIANGLEFAN = 6,
+ WINED3DPT_LINELIST_ADJ = 10,
+ WINED3DPT_LINESTRIP_ADJ = 11,
+ WINED3DPT_TRIANGLELIST_ADJ = 12,
+ WINED3DPT_TRIANGLESTRIP_ADJ = 13,
+ WINED3DPT_FORCE_DWORD = 0x7fffffff
+} WINED3DPRIMITIVETYPE;
+
+typedef enum _WINED3DDEVTYPE
+{
+ WINED3DDEVTYPE_HAL = 1,
+ WINED3DDEVTYPE_REF = 2,
+ WINED3DDEVTYPE_SW = 3,
+ WINED3DDEVTYPE_NULLREF = 4,
+ WINED3DDEVTYPE_FORCE_DWORD = 0xffffffff
+} WINED3DDEVTYPE;
+
+typedef enum _WINED3DDEGREETYPE
+{
+ WINED3DDEGREE_LINEAR = 1,
+ WINED3DDEGREE_QUADRATIC = 2,
+ WINED3DDEGREE_CUBIC = 3,
+ WINED3DDEGREE_QUINTIC = 5,
+ WINED3DDEGREE_FORCE_DWORD = 0x7fffffff
+} WINED3DDEGREETYPE;
+
+#define WINEMAKEFOURCC(ch0, ch1, ch2, ch3) \
+ ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \
+ ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24))
+
+enum wined3d_format_id
+{
+ WINED3DFMT_UNKNOWN,
+ WINED3DFMT_B8G8R8_UNORM,
+ WINED3DFMT_B5G5R5X1_UNORM,
+ WINED3DFMT_B4G4R4A4_UNORM,
+ WINED3DFMT_B2G3R3_UNORM,
+ WINED3DFMT_B2G3R3A8_UNORM,
+ WINED3DFMT_B4G4R4X4_UNORM,
+ WINED3DFMT_R8G8B8X8_UNORM,
+ WINED3DFMT_B10G10R10A2_UNORM,
+ WINED3DFMT_P8_UINT_A8_UNORM,
+ WINED3DFMT_P8_UINT,
+ WINED3DFMT_L8_UNORM,
+ WINED3DFMT_L8A8_UNORM,
+ WINED3DFMT_L4A4_UNORM,
+ WINED3DFMT_R5G5_SNORM_L6_UNORM,
+ WINED3DFMT_R8G8_SNORM_L8X8_UNORM,
+ WINED3DFMT_R10G11B11_SNORM,
+ WINED3DFMT_R10G10B10_SNORM_A2_UNORM,
+ WINED3DFMT_D16_LOCKABLE,
+ WINED3DFMT_D32_UNORM,
+ WINED3DFMT_S1_UINT_D15_UNORM,
+ WINED3DFMT_X8D24_UNORM,
+ WINED3DFMT_S4X4_UINT_D24_UNORM,
+ WINED3DFMT_L16_UNORM,
+ WINED3DFMT_S8_UINT_D24_FLOAT,
+ WINED3DFMT_VERTEXDATA,
+ WINED3DFMT_R8G8_SNORM_Cx,
+ WINED3DFMT_R32G32B32A32_TYPELESS,
+ WINED3DFMT_R32G32B32A32_FLOAT,
+ WINED3DFMT_R32G32B32A32_UINT,
+ WINED3DFMT_R32G32B32A32_SINT,
+ WINED3DFMT_R32G32B32_TYPELESS,
+ WINED3DFMT_R32G32B32_FLOAT,
+ WINED3DFMT_R32G32B32_UINT,
+ WINED3DFMT_R32G32B32_SINT,
+ WINED3DFMT_R16G16B16A16_TYPELESS,
+ WINED3DFMT_R16G16B16A16_FLOAT,
+ WINED3DFMT_R16G16B16A16_UNORM,
+ WINED3DFMT_R16G16B16A16_UINT,
+ WINED3DFMT_R16G16B16A16_SNORM,
+ WINED3DFMT_R16G16B16A16_SINT,
+ WINED3DFMT_R32G32_TYPELESS,
+ WINED3DFMT_R32G32_FLOAT,
+ WINED3DFMT_R32G32_UINT,
+ WINED3DFMT_R32G32_SINT,
+ WINED3DFMT_R32G8X24_TYPELESS,
+ WINED3DFMT_D32_FLOAT_S8X24_UINT,
+ WINED3DFMT_R32_FLOAT_X8X24_TYPELESS,
+ WINED3DFMT_X32_TYPELESS_G8X24_UINT,
+ WINED3DFMT_R10G10B10A2_TYPELESS,
+ WINED3DFMT_R10G10B10A2_UNORM,
+ WINED3DFMT_R10G10B10A2_UINT,
+ WINED3DFMT_R10G10B10A2_SNORM,
+ WINED3DFMT_R11G11B10_FLOAT,
+ WINED3DFMT_R8G8B8A8_TYPELESS,
+ WINED3DFMT_R8G8B8A8_UNORM,
+ WINED3DFMT_R8G8B8A8_UNORM_SRGB,
+ WINED3DFMT_R8G8B8A8_UINT,
+ WINED3DFMT_R8G8B8A8_SNORM,
+ WINED3DFMT_R8G8B8A8_SINT,
+ WINED3DFMT_R16G16_TYPELESS,
+ WINED3DFMT_R16G16_FLOAT,
+ WINED3DFMT_R16G16_UNORM,
+ WINED3DFMT_R16G16_UINT,
+ WINED3DFMT_R16G16_SNORM,
+ WINED3DFMT_R16G16_SINT,
+ WINED3DFMT_R32_TYPELESS,
+ WINED3DFMT_D32_FLOAT,
+ WINED3DFMT_R32_FLOAT,
+ WINED3DFMT_R32_UINT,
+ WINED3DFMT_R32_SINT,
+ WINED3DFMT_R24G8_TYPELESS,
+ WINED3DFMT_D24_UNORM_S8_UINT,
+ WINED3DFMT_R24_UNORM_X8_TYPELESS,
+ WINED3DFMT_X24_TYPELESS_G8_UINT,
+ WINED3DFMT_R8G8_TYPELESS,
+ WINED3DFMT_R8G8_UNORM,
+ WINED3DFMT_R8G8_UINT,
+ WINED3DFMT_R8G8_SNORM,
+ WINED3DFMT_R8G8_SINT,
+ WINED3DFMT_R16_TYPELESS,
+ WINED3DFMT_R16_FLOAT,
+ WINED3DFMT_D16_UNORM,
+ WINED3DFMT_R16_UNORM,
+ WINED3DFMT_R16_UINT,
+ WINED3DFMT_R16_SNORM,
+ WINED3DFMT_R16_SINT,
+ WINED3DFMT_R8_TYPELESS,
+ WINED3DFMT_R8_UNORM,
+ WINED3DFMT_R8_UINT,
+ WINED3DFMT_R8_SNORM,
+ WINED3DFMT_R8_SINT,
+ WINED3DFMT_A8_UNORM,
+ WINED3DFMT_R1_UNORM,
+ WINED3DFMT_R9G9B9E5_SHAREDEXP,
+ WINED3DFMT_R8G8_B8G8_UNORM,
+ WINED3DFMT_G8R8_G8B8_UNORM,
+ WINED3DFMT_BC1_TYPELESS,
+ WINED3DFMT_BC1_UNORM,
+ WINED3DFMT_BC1_UNORM_SRGB,
+ WINED3DFMT_BC2_TYPELESS,
+ WINED3DFMT_BC2_UNORM,
+ WINED3DFMT_BC2_UNORM_SRGB,
+ WINED3DFMT_BC3_TYPELESS,
+ WINED3DFMT_BC3_UNORM,
+ WINED3DFMT_BC3_UNORM_SRGB,
+ WINED3DFMT_BC4_TYPELESS,
+ WINED3DFMT_BC4_UNORM,
+ WINED3DFMT_BC4_SNORM,
+ WINED3DFMT_BC5_TYPELESS,
+ WINED3DFMT_BC5_UNORM,
+ WINED3DFMT_BC5_SNORM,
+ WINED3DFMT_B5G6R5_UNORM,
+ WINED3DFMT_B5G5R5A1_UNORM,
+ WINED3DFMT_B8G8R8A8_UNORM,
+ WINED3DFMT_B8G8R8X8_UNORM,
+ /* FOURCC formats. */
+ WINED3DFMT_UYVY = WINEMAKEFOURCC('U','Y','V','Y'),
+ WINED3DFMT_YUY2 = WINEMAKEFOURCC('Y','U','Y','2'),
+ WINED3DFMT_YV12 = WINEMAKEFOURCC('Y','V','1','2'),
+ WINED3DFMT_DXT1 = WINEMAKEFOURCC('D','X','T','1'),
+ WINED3DFMT_DXT2 = WINEMAKEFOURCC('D','X','T','2'),
+ WINED3DFMT_DXT3 = WINEMAKEFOURCC('D','X','T','3'),
+ WINED3DFMT_DXT4 = WINEMAKEFOURCC('D','X','T','4'),
+ WINED3DFMT_DXT5 = WINEMAKEFOURCC('D','X','T','5'),
+ WINED3DFMT_MULTI2_ARGB8 = WINEMAKEFOURCC('M','E','T','1'),
+ WINED3DFMT_G8R8_G8B8 = WINEMAKEFOURCC('G','R','G','B'),
+ WINED3DFMT_R8G8_B8G8 = WINEMAKEFOURCC('R','G','B','G'),
+ WINED3DFMT_ATI2N = WINEMAKEFOURCC('A','T','I','2'),
+ WINED3DFMT_INST = WINEMAKEFOURCC('I','N','S','T'),
+ WINED3DFMT_NVDB = WINEMAKEFOURCC('N','V','D','B'),
+ WINED3DFMT_NVHU = WINEMAKEFOURCC('N','V','H','U'),
+ WINED3DFMT_NVHS = WINEMAKEFOURCC('N','V','H','S'),
+ WINED3DFMT_INTZ = WINEMAKEFOURCC('I','N','T','Z'),
+ WINED3DFMT_NULL = WINEMAKEFOURCC('N','U','L','L'),
+
+ WINED3DFMT_FORCE_DWORD = 0xffffffff
+};
+
+typedef enum _WINED3DRENDERSTATETYPE
+{
+ WINED3DRS_ANTIALIAS = 2, /* d3d7 */
+ WINED3DRS_TEXTUREPERSPECTIVE = 4, /* d3d7 */
+ WINED3DRS_WRAPU = 5, /* d3d7 */
+ WINED3DRS_WRAPV = 6, /* d3d7 */
+ WINED3DRS_ZENABLE = 7,
+ WINED3DRS_FILLMODE = 8,
+ WINED3DRS_SHADEMODE = 9,
+ WINED3DRS_LINEPATTERN = 10, /* d3d7, d3d8 */
+ WINED3DRS_MONOENABLE = 11, /* d3d7 */
+ WINED3DRS_ROP2 = 12, /* d3d7 */
+ WINED3DRS_PLANEMASK = 13, /* d3d7 */
+ WINED3DRS_ZWRITEENABLE = 14,
+ WINED3DRS_ALPHATESTENABLE = 15,
+ WINED3DRS_LASTPIXEL = 16,
+ WINED3DRS_SRCBLEND = 19,
+ WINED3DRS_DESTBLEND = 20,
+ WINED3DRS_CULLMODE = 22,
+ WINED3DRS_ZFUNC = 23,
+ WINED3DRS_ALPHAREF = 24,
+ WINED3DRS_ALPHAFUNC = 25,
+ WINED3DRS_DITHERENABLE = 26,
+ WINED3DRS_ALPHABLENDENABLE = 27,
+ WINED3DRS_FOGENABLE = 28,
+ WINED3DRS_SPECULARENABLE = 29,
+ WINED3DRS_ZVISIBLE = 30, /* d3d7, d3d8 */
+ WINED3DRS_SUBPIXEL = 31, /* d3d7 */
+ WINED3DRS_SUBPIXELX = 32, /* d3d7 */
+ WINED3DRS_STIPPLEDALPHA = 33, /* d3d7 */
+ WINED3DRS_FOGCOLOR = 34,
+ WINED3DRS_FOGTABLEMODE = 35,
+ WINED3DRS_FOGSTART = 36,
+ WINED3DRS_FOGEND = 37,
+ WINED3DRS_FOGDENSITY = 38,
+ WINED3DRS_STIPPLEENABLE = 39, /* d3d7 */
+ WINED3DRS_EDGEANTIALIAS = 40, /* d3d7, d3d8 */
+ WINED3DRS_COLORKEYENABLE = 41, /* d3d7 */
+ WINED3DRS_MIPMAPLODBIAS = 46, /* d3d7 */
+ WINED3DRS_RANGEFOGENABLE = 48,
+ WINED3DRS_ANISOTROPY = 49, /* d3d7 */
+ WINED3DRS_FLUSHBATCH = 50, /* d3d7 */
+ WINED3DRS_TRANSLUCENTSORTINDEPENDENT = 51, /* d3d7 */
+ WINED3DRS_STENCILENABLE = 52,
+ WINED3DRS_STENCILFAIL = 53,
+ WINED3DRS_STENCILZFAIL = 54,
+ WINED3DRS_STENCILPASS = 55,
+ WINED3DRS_STENCILFUNC = 56,
+ WINED3DRS_STENCILREF = 57,
+ WINED3DRS_STENCILMASK = 58,
+ WINED3DRS_STENCILWRITEMASK = 59,
+ WINED3DRS_TEXTUREFACTOR = 60,
+ WINED3DRS_WRAP0 = 128,
+ WINED3DRS_WRAP1 = 129,
+ WINED3DRS_WRAP2 = 130,
+ WINED3DRS_WRAP3 = 131,
+ WINED3DRS_WRAP4 = 132,
+ WINED3DRS_WRAP5 = 133,
+ WINED3DRS_WRAP6 = 134,
+ WINED3DRS_WRAP7 = 135,
+ WINED3DRS_CLIPPING = 136,
+ WINED3DRS_LIGHTING = 137,
+ WINED3DRS_EXTENTS = 138, /* d3d7 */
+ WINED3DRS_AMBIENT = 139,
+ WINED3DRS_FOGVERTEXMODE = 140,
+ WINED3DRS_COLORVERTEX = 141,
+ WINED3DRS_LOCALVIEWER = 142,
+ WINED3DRS_NORMALIZENORMALS = 143,
+ WINED3DRS_COLORKEYBLENDENABLE = 144, /* d3d7 */
+ WINED3DRS_DIFFUSEMATERIALSOURCE = 145,
+ WINED3DRS_SPECULARMATERIALSOURCE = 146,
+ WINED3DRS_AMBIENTMATERIALSOURCE = 147,
+ WINED3DRS_EMISSIVEMATERIALSOURCE = 148,
+ WINED3DRS_VERTEXBLEND = 151,
+ WINED3DRS_CLIPPLANEENABLE = 152,
+ WINED3DRS_SOFTWAREVERTEXPROCESSING = 153, /* d3d8 */
+ WINED3DRS_POINTSIZE = 154,
+ WINED3DRS_POINTSIZE_MIN = 155,
+ WINED3DRS_POINTSPRITEENABLE = 156,
+ WINED3DRS_POINTSCALEENABLE = 157,
+ WINED3DRS_POINTSCALE_A = 158,
+ WINED3DRS_POINTSCALE_B = 159,
+ WINED3DRS_POINTSCALE_C = 160,
+ WINED3DRS_MULTISAMPLEANTIALIAS = 161,
+ WINED3DRS_MULTISAMPLEMASK = 162,
+ WINED3DRS_PATCHEDGESTYLE = 163,
+ WINED3DRS_PATCHSEGMENTS = 164, /* d3d8 */
+ WINED3DRS_DEBUGMONITORTOKEN = 165,
+ WINED3DRS_POINTSIZE_MAX = 166,
+ WINED3DRS_INDEXEDVERTEXBLENDENABLE = 167,
+ WINED3DRS_COLORWRITEENABLE = 168,
+ WINED3DRS_TWEENFACTOR = 170,
+ WINED3DRS_BLENDOP = 171,
+ WINED3DRS_POSITIONDEGREE = 172,
+ WINED3DRS_NORMALDEGREE = 173,
+ WINED3DRS_SCISSORTESTENABLE = 174,
+ WINED3DRS_SLOPESCALEDEPTHBIAS = 175,
+ WINED3DRS_ANTIALIASEDLINEENABLE = 176,
+ WINED3DRS_MINTESSELLATIONLEVEL = 178,
+ WINED3DRS_MAXTESSELLATIONLEVEL = 179,
+ WINED3DRS_ADAPTIVETESS_X = 180,
+ WINED3DRS_ADAPTIVETESS_Y = 181,
+ WINED3DRS_ADAPTIVETESS_Z = 182,
+ WINED3DRS_ADAPTIVETESS_W = 183,
+ WINED3DRS_ENABLEADAPTIVETESSELLATION = 184,
+ WINED3DRS_TWOSIDEDSTENCILMODE = 185,
+ WINED3DRS_CCW_STENCILFAIL = 186,
+ WINED3DRS_CCW_STENCILZFAIL = 187,
+ WINED3DRS_CCW_STENCILPASS = 188,
+ WINED3DRS_CCW_STENCILFUNC = 189,
+ WINED3DRS_COLORWRITEENABLE1 = 190,
+ WINED3DRS_COLORWRITEENABLE2 = 191,
+ WINED3DRS_COLORWRITEENABLE3 = 192,
+ WINED3DRS_BLENDFACTOR = 193,
+ WINED3DRS_SRGBWRITEENABLE = 194,
+ WINED3DRS_DEPTHBIAS = 195,
+ WINED3DRS_WRAP8 = 198,
+ WINED3DRS_WRAP9 = 199,
+ WINED3DRS_WRAP10 = 200,
+ WINED3DRS_WRAP11 = 201,
+ WINED3DRS_WRAP12 = 202,
+ WINED3DRS_WRAP13 = 203,
+ WINED3DRS_WRAP14 = 204,
+ WINED3DRS_WRAP15 = 205,
+ WINED3DRS_SEPARATEALPHABLENDENABLE = 206,
+ WINED3DRS_SRCBLENDALPHA = 207,
+ WINED3DRS_DESTBLENDALPHA = 208,
+ WINED3DRS_BLENDOPALPHA = 209,
+ WINED3DRS_FORCE_DWORD = 0x7fffffff
+} WINED3DRENDERSTATETYPE;
+#define WINEHIGHEST_RENDER_STATE WINED3DRS_BLENDOPALPHA
+
+typedef enum _WINED3DBLEND
+{
+ WINED3DBLEND_ZERO = 1,
+ WINED3DBLEND_ONE = 2,
+ WINED3DBLEND_SRCCOLOR = 3,
+ WINED3DBLEND_INVSRCCOLOR = 4,
+ WINED3DBLEND_SRCALPHA = 5,
+ WINED3DBLEND_INVSRCALPHA = 6,
+ WINED3DBLEND_DESTALPHA = 7,
+ WINED3DBLEND_INVDESTALPHA = 8,
+ WINED3DBLEND_DESTCOLOR = 9,
+ WINED3DBLEND_INVDESTCOLOR = 10,
+ WINED3DBLEND_SRCALPHASAT = 11,
+ WINED3DBLEND_BOTHSRCALPHA = 12,
+ WINED3DBLEND_BOTHINVSRCALPHA = 13,
+ WINED3DBLEND_BLENDFACTOR = 14,
+ WINED3DBLEND_INVBLENDFACTOR = 15,
+ WINED3DBLEND_FORCE_DWORD = 0x7fffffff
+} WINED3DBLEND;
+
+typedef enum _WINED3DBLENDOP
+{
+ WINED3DBLENDOP_ADD = 1,
+ WINED3DBLENDOP_SUBTRACT = 2,
+ WINED3DBLENDOP_REVSUBTRACT = 3,
+ WINED3DBLENDOP_MIN = 4,
+ WINED3DBLENDOP_MAX = 5,
+ WINED3DBLENDOP_FORCE_DWORD = 0x7fffffff
+} WINED3DBLENDOP;
+
+typedef enum _WINED3DVERTEXBLENDFLAGS
+{
+ WINED3DVBF_DISABLE = 0,
+ WINED3DVBF_1WEIGHTS = 1,
+ WINED3DVBF_2WEIGHTS = 2,
+ WINED3DVBF_3WEIGHTS = 3,
+ WINED3DVBF_TWEENING = 255,
+ WINED3DVBF_0WEIGHTS = 256
+} WINED3DVERTEXBLENDFLAGS;
+
+typedef enum _WINED3DCMPFUNC
+{
+ WINED3DCMP_NEVER = 1,
+ WINED3DCMP_LESS = 2,
+ WINED3DCMP_EQUAL = 3,
+ WINED3DCMP_LESSEQUAL = 4,
+ WINED3DCMP_GREATER = 5,
+ WINED3DCMP_NOTEQUAL = 6,
+ WINED3DCMP_GREATEREQUAL = 7,
+ WINED3DCMP_ALWAYS = 8,
+ WINED3DCMP_FORCE_DWORD = 0x7fffffff
+} WINED3DCMPFUNC;
+
+typedef enum _WINED3DZBUFFERTYPE
+{
+ WINED3DZB_FALSE = 0,
+ WINED3DZB_TRUE = 1,
+ WINED3DZB_USEW = 2,
+ WINED3DZB_FORCE_DWORD = 0x7fffffff
+} WINED3DZBUFFERTYPE;
+
+typedef enum _WINED3DFOGMODE
+{
+ WINED3DFOG_NONE = 0,
+ WINED3DFOG_EXP = 1,
+ WINED3DFOG_EXP2 = 2,
+ WINED3DFOG_LINEAR = 3,
+ WINED3DFOG_FORCE_DWORD = 0x7fffffff
+} WINED3DFOGMODE;
+
+typedef enum _WINED3DSHADEMODE
+{
+ WINED3DSHADE_FLAT = 1,
+ WINED3DSHADE_GOURAUD = 2,
+ WINED3DSHADE_PHONG = 3,
+ WINED3DSHADE_FORCE_DWORD = 0x7fffffff
+} WINED3DSHADEMODE;
+
+typedef enum _WINED3DFILLMODE
+{
+ WINED3DFILL_POINT = 1,
+ WINED3DFILL_WIREFRAME = 2,
+ WINED3DFILL_SOLID = 3,
+ WINED3DFILL_FORCE_DWORD = 0x7fffffff
+} WINED3DFILLMODE;
+
+typedef enum _WINED3DCULL
+{
+ WINED3DCULL_NONE = 1,
+ WINED3DCULL_CW = 2,
+ WINED3DCULL_CCW = 3,
+ WINED3DCULL_FORCE_DWORD = 0x7fffffff
+} WINED3DCULL;
+
+typedef enum _WINED3DSTENCILOP
+{
+ WINED3DSTENCILOP_KEEP = 1,
+ WINED3DSTENCILOP_ZERO = 2,
+ WINED3DSTENCILOP_REPLACE = 3,
+ WINED3DSTENCILOP_INCRSAT = 4,
+ WINED3DSTENCILOP_DECRSAT = 5,
+ WINED3DSTENCILOP_INVERT = 6,
+ WINED3DSTENCILOP_INCR = 7,
+ WINED3DSTENCILOP_DECR = 8,
+ WINED3DSTENCILOP_FORCE_DWORD = 0x7fffffff
+} WINED3DSTENCILOP;
+
+typedef enum _WINED3DMATERIALCOLORSOURCE
+{
+ WINED3DMCS_MATERIAL = 0,
+ WINED3DMCS_COLOR1 = 1,
+ WINED3DMCS_COLOR2 = 2,
+ WINED3DMCS_FORCE_DWORD = 0x7fffffff
+} WINED3DMATERIALCOLORSOURCE;
+
+typedef enum _WINED3DPATCHEDGESTYLE
+{
+ WINED3DPATCHEDGE_DISCRETE = 0,
+ WINED3DPATCHEDGE_CONTINUOUS = 1,
+ WINED3DPATCHEDGE_FORCE_DWORD = 0x7fffffff
+} WINED3DPATCHEDGESTYLE;
+
+typedef enum _WINED3DBACKBUFFER_TYPE
+{
+ WINED3DBACKBUFFER_TYPE_MONO = 0,
+ WINED3DBACKBUFFER_TYPE_LEFT = 1,
+ WINED3DBACKBUFFER_TYPE_RIGHT = 2,
+ WINED3DBACKBUFFER_TYPE_FORCE_DWORD = 0x7fffffff
+} WINED3DBACKBUFFER_TYPE;
+
+typedef enum _WINED3DSWAPEFFECT
+{
+ WINED3DSWAPEFFECT_DISCARD = 1,
+ WINED3DSWAPEFFECT_FLIP = 2,
+ WINED3DSWAPEFFECT_COPY = 3,
+ WINED3DSWAPEFFECT_COPY_VSYNC = 4,
+ WINED3DSWAPEFFECT_FORCE_DWORD = 0xffffffff
+} WINED3DSWAPEFFECT;
+
+typedef enum _WINED3DSAMPLERSTATETYPE
+{
+ WINED3DSAMP_ADDRESSU = 1,
+ WINED3DSAMP_ADDRESSV = 2,
+ WINED3DSAMP_ADDRESSW = 3,
+ WINED3DSAMP_BORDERCOLOR = 4,
+ WINED3DSAMP_MAGFILTER = 5,
+ WINED3DSAMP_MINFILTER = 6,
+ WINED3DSAMP_MIPFILTER = 7,
+ WINED3DSAMP_MIPMAPLODBIAS = 8,
+ WINED3DSAMP_MAXMIPLEVEL = 9,
+ WINED3DSAMP_MAXANISOTROPY = 10,
+ WINED3DSAMP_SRGBTEXTURE = 11,
+ WINED3DSAMP_ELEMENTINDEX = 12,
+ WINED3DSAMP_DMAPOFFSET = 13,
+ WINED3DSAMP_FORCE_DWORD = 0x7fffffff,
+} WINED3DSAMPLERSTATETYPE;
+#define WINED3D_HIGHEST_SAMPLER_STATE WINED3DSAMP_DMAPOFFSET
+
+typedef enum _WINED3DMULTISAMPLE_TYPE
+{
+ WINED3DMULTISAMPLE_NONE = 0,
+ WINED3DMULTISAMPLE_NONMASKABLE = 1,
+ WINED3DMULTISAMPLE_2_SAMPLES = 2,
+ WINED3DMULTISAMPLE_3_SAMPLES = 3,
+ WINED3DMULTISAMPLE_4_SAMPLES = 4,
+ WINED3DMULTISAMPLE_5_SAMPLES = 5,
+ WINED3DMULTISAMPLE_6_SAMPLES = 6,
+ WINED3DMULTISAMPLE_7_SAMPLES = 7,
+ WINED3DMULTISAMPLE_8_SAMPLES = 8,
+ WINED3DMULTISAMPLE_9_SAMPLES = 9,
+ WINED3DMULTISAMPLE_10_SAMPLES = 10,
+ WINED3DMULTISAMPLE_11_SAMPLES = 11,
+ WINED3DMULTISAMPLE_12_SAMPLES = 12,
+ WINED3DMULTISAMPLE_13_SAMPLES = 13,
+ WINED3DMULTISAMPLE_14_SAMPLES = 14,
+ WINED3DMULTISAMPLE_15_SAMPLES = 15,
+ WINED3DMULTISAMPLE_16_SAMPLES = 16,
+ WINED3DMULTISAMPLE_FORCE_DWORD = 0xffffffff
+} WINED3DMULTISAMPLE_TYPE;
+
+typedef enum _WINED3DTEXTURESTAGESTATETYPE
+{
+ WINED3DTSS_COLOROP = 0,
+ WINED3DTSS_COLORARG1 = 1,
+ WINED3DTSS_COLORARG2 = 2,
+ WINED3DTSS_ALPHAOP = 3,
+ WINED3DTSS_ALPHAARG1 = 4,
+ WINED3DTSS_ALPHAARG2 = 5,
+ WINED3DTSS_BUMPENVMAT00 = 6,
+ WINED3DTSS_BUMPENVMAT01 = 7,
+ WINED3DTSS_BUMPENVMAT10 = 8,
+ WINED3DTSS_BUMPENVMAT11 = 9,
+ WINED3DTSS_TEXCOORDINDEX = 10,
+ WINED3DTSS_BUMPENVLSCALE = 11,
+ WINED3DTSS_BUMPENVLOFFSET = 12,
+ WINED3DTSS_TEXTURETRANSFORMFLAGS = 13,
+ WINED3DTSS_COLORARG0 = 14,
+ WINED3DTSS_ALPHAARG0 = 15,
+ WINED3DTSS_RESULTARG = 16,
+ WINED3DTSS_CONSTANT = 17,
+ WINED3DTSS_FORCE_DWORD = 0x7fffffff
+} WINED3DTEXTURESTAGESTATETYPE;
+#define WINED3D_HIGHEST_TEXTURE_STATE WINED3DTSS_CONSTANT
+
+typedef enum _WINED3DTEXTURETRANSFORMFLAGS
+{
+ WINED3DTTFF_DISABLE = 0,
+ WINED3DTTFF_COUNT1 = 1,
+ WINED3DTTFF_COUNT2 = 2,
+ WINED3DTTFF_COUNT3 = 3,
+ WINED3DTTFF_COUNT4 = 4,
+ WINED3DTTFF_PROJECTED = 256,
+ WINED3DTTFF_FORCE_DWORD = 0x7fffffff
+} WINED3DTEXTURETRANSFORMFLAGS;
+
+typedef enum _WINED3DTEXTUREOP
+{
+ WINED3DTOP_DISABLE = 1,
+ WINED3DTOP_SELECTARG1 = 2,
+ WINED3DTOP_SELECTARG2 = 3,
+ WINED3DTOP_MODULATE = 4,
+ WINED3DTOP_MODULATE2X = 5,
+ WINED3DTOP_MODULATE4X = 6,
+ WINED3DTOP_ADD = 7,
+ WINED3DTOP_ADDSIGNED = 8,
+ WINED3DTOP_ADDSIGNED2X = 9,
+ WINED3DTOP_SUBTRACT = 10,
+ WINED3DTOP_ADDSMOOTH = 11,
+ WINED3DTOP_BLENDDIFFUSEALPHA = 12,
+ WINED3DTOP_BLENDTEXTUREALPHA = 13,
+ WINED3DTOP_BLENDFACTORALPHA = 14,
+ WINED3DTOP_BLENDTEXTUREALPHAPM = 15,
+ WINED3DTOP_BLENDCURRENTALPHA = 16,
+ WINED3DTOP_PREMODULATE = 17,
+ WINED3DTOP_MODULATEALPHA_ADDCOLOR = 18,
+ WINED3DTOP_MODULATECOLOR_ADDALPHA = 19,
+ WINED3DTOP_MODULATEINVALPHA_ADDCOLOR = 20,
+ WINED3DTOP_MODULATEINVCOLOR_ADDALPHA = 21,
+ WINED3DTOP_BUMPENVMAP = 22,
+ WINED3DTOP_BUMPENVMAPLUMINANCE = 23,
+ WINED3DTOP_DOTPRODUCT3 = 24,
+ WINED3DTOP_MULTIPLYADD = 25,
+ WINED3DTOP_LERP = 26,
+ WINED3DTOP_FORCE_DWORD = 0x7fffffff,
+} WINED3DTEXTUREOP;
+
+typedef enum _WINED3DTEXTUREADDRESS
+{
+ WINED3DTADDRESS_WRAP = 1,
+ WINED3DTADDRESS_MIRROR = 2,
+ WINED3DTADDRESS_CLAMP = 3,
+ WINED3DTADDRESS_BORDER = 4,
+ WINED3DTADDRESS_MIRRORONCE = 5,
+ WINED3DTADDRESS_FORCE_DWORD = 0x7fffffff
+} WINED3DTEXTUREADDRESS;
+
+typedef enum _WINED3DTRANSFORMSTATETYPE
+{
+ WINED3DTS_VIEW = 2,
+ WINED3DTS_PROJECTION = 3,
+ WINED3DTS_TEXTURE0 = 16,
+ WINED3DTS_TEXTURE1 = 17,
+ WINED3DTS_TEXTURE2 = 18,
+ WINED3DTS_TEXTURE3 = 19,
+ WINED3DTS_TEXTURE4 = 20,
+ WINED3DTS_TEXTURE5 = 21,
+ WINED3DTS_TEXTURE6 = 22,
+ WINED3DTS_TEXTURE7 = 23,
+ WINED3DTS_WORLD = 256, /*WINED3DTS_WORLDMATRIX(0)*/
+ WINED3DTS_WORLD1 = 257,
+ WINED3DTS_WORLD2 = 258,
+ WINED3DTS_WORLD3 = 259,
+ WINED3DTS_FORCE_DWORD = 0x7fffffff
+} WINED3DTRANSFORMSTATETYPE;
+
+#define WINED3DTS_WORLDMATRIX(index) (WINED3DTRANSFORMSTATETYPE)(index + 256)
+
+typedef enum _WINED3DBASISTYPE
+{
+ WINED3DBASIS_BEZIER = 0,
+ WINED3DBASIS_BSPLINE = 1,
+ WINED3DBASIS_INTERPOLATE = 2,
+ WINED3DBASIS_FORCE_DWORD = 0x7fffffff
+} WINED3DBASISTYPE;
+
+typedef enum _WINED3DCUBEMAP_FACES
+{
+ WINED3DCUBEMAP_FACE_POSITIVE_X = 0,
+ WINED3DCUBEMAP_FACE_NEGATIVE_X = 1,
+ WINED3DCUBEMAP_FACE_POSITIVE_Y = 2,
+ WINED3DCUBEMAP_FACE_NEGATIVE_Y = 3,
+ WINED3DCUBEMAP_FACE_POSITIVE_Z = 4,
+ WINED3DCUBEMAP_FACE_NEGATIVE_Z = 5,
+ WINED3DCUBEMAP_FACE_FORCE_DWORD = 0xffffffff
+} WINED3DCUBEMAP_FACES;
+
+typedef enum _WINED3DTEXTUREFILTERTYPE
+{
+ WINED3DTEXF_NONE = 0,
+ WINED3DTEXF_POINT = 1,
+ WINED3DTEXF_LINEAR = 2,
+ WINED3DTEXF_ANISOTROPIC = 3,
+ WINED3DTEXF_FLATCUBIC = 4,
+ WINED3DTEXF_GAUSSIANCUBIC = 5,
+ WINED3DTEXF_PYRAMIDALQUAD = 6,
+ WINED3DTEXF_GAUSSIANQUAD = 7,
+ WINED3DTEXF_FORCE_DWORD = 0x7fffffff
+} WINED3DTEXTUREFILTERTYPE;
+
+typedef enum _WINED3DRESOURCETYPE
+{
+ WINED3DRTYPE_SURFACE = 1,
+ WINED3DRTYPE_VOLUME = 2,
+ WINED3DRTYPE_TEXTURE = 3,
+ WINED3DRTYPE_VOLUMETEXTURE = 4,
+ WINED3DRTYPE_CUBETEXTURE = 5,
+ WINED3DRTYPE_BUFFER = 6,
+ WINED3DRTYPE_FORCE_DWORD = 0x7fffffff
+} WINED3DRESOURCETYPE;
+#define WINED3DRTYPECOUNT WINED3DRTYPE_BUFFER
+
+typedef enum _WINED3DPOOL
+{
+ WINED3DPOOL_DEFAULT = 0,
+ WINED3DPOOL_MANAGED = 1,
+ WINED3DPOOL_SYSTEMMEM = 2,
+ WINED3DPOOL_SCRATCH = 3,
+ WINED3DPOOL_FORCE_DWORD = 0x7fffffff
+} WINED3DPOOL;
+
+typedef enum _WINED3DQUERYTYPE
+{
+ WINED3DQUERYTYPE_VCACHE = 4,
+ WINED3DQUERYTYPE_RESOURCEMANAGER = 5,
+ WINED3DQUERYTYPE_VERTEXSTATS = 6,
+ WINED3DQUERYTYPE_EVENT = 8,
+ WINED3DQUERYTYPE_OCCLUSION = 9,
+ WINED3DQUERYTYPE_TIMESTAMP = 10,
+ WINED3DQUERYTYPE_TIMESTAMPDISJOINT = 11,
+ WINED3DQUERYTYPE_TIMESTAMPFREQ = 12,
+ WINED3DQUERYTYPE_PIPELINETIMINGS = 13,
+ WINED3DQUERYTYPE_INTERFACETIMINGS = 14,
+ WINED3DQUERYTYPE_VERTEXTIMINGS = 15,
+ WINED3DQUERYTYPE_PIXELTIMINGS = 16,
+ WINED3DQUERYTYPE_BANDWIDTHTIMINGS = 17,
+ WINED3DQUERYTYPE_CACHEUTILIZATION = 18
+} WINED3DQUERYTYPE;
+
+#define WINED3DISSUE_BEGIN (1 << 1)
+#define WINED3DISSUE_END (1 << 0)
+#define WINED3DGETDATA_FLUSH (1 << 0)
+
+typedef enum _WINED3DSTATEBLOCKTYPE
+{
+ WINED3DSBT_INIT = 0,
+ WINED3DSBT_ALL = 1,
+ WINED3DSBT_PIXELSTATE = 2,
+ WINED3DSBT_VERTEXSTATE = 3,
+ WINED3DSBT_RECORDED = 4, /* WineD3D private */
+ WINED3DSBT_FORCE_DWORD = 0xffffffff
+} WINED3DSTATEBLOCKTYPE;
+
+typedef enum _WINED3DDECLMETHOD
+{
+ WINED3DDECLMETHOD_DEFAULT = 0,
+ WINED3DDECLMETHOD_PARTIALU = 1,
+ WINED3DDECLMETHOD_PARTIALV = 2,
+ WINED3DDECLMETHOD_CROSSUV = 3,
+ WINED3DDECLMETHOD_UV = 4,
+ WINED3DDECLMETHOD_LOOKUP = 5,
+ WINED3DDECLMETHOD_LOOKUPPRESAMPLED = 6
+} WINED3DDECLMETHOD;
+
+typedef enum _WINED3DDECLUSAGE
+{
+ WINED3DDECLUSAGE_POSITION = 0,
+ WINED3DDECLUSAGE_BLENDWEIGHT = 1,
+ WINED3DDECLUSAGE_BLENDINDICES = 2,
+ WINED3DDECLUSAGE_NORMAL = 3,
+ WINED3DDECLUSAGE_PSIZE = 4,
+ WINED3DDECLUSAGE_TEXCOORD = 5,
+ WINED3DDECLUSAGE_TANGENT = 6,
+ WINED3DDECLUSAGE_BINORMAL = 7,
+ WINED3DDECLUSAGE_TESSFACTOR = 8,
+ WINED3DDECLUSAGE_POSITIONT = 9,
+ WINED3DDECLUSAGE_COLOR = 10,
+ WINED3DDECLUSAGE_FOG = 11,
+ WINED3DDECLUSAGE_DEPTH = 12,
+ WINED3DDECLUSAGE_SAMPLE = 13
+} WINED3DDECLUSAGE;
+
+typedef enum _WINED3DSURFTYPE
+{
+ SURFACE_UNKNOWN = 0, /* Default / Unknown surface type */
+ SURFACE_OPENGL, /* OpenGL surface: Renders using libGL, needed for 3D */
+ SURFACE_GDI, /* User surface. No 3D, DirectDraw rendering with GDI */
+} WINED3DSURFTYPE;
+
+enum wined3d_sysval_semantic
+{
+ WINED3D_SV_DEPTH = 0xffffffff,
+ WINED3D_SV_TARGET0 = 0,
+ WINED3D_SV_TARGET1 = 1,
+ WINED3D_SV_TARGET2 = 2,
+ WINED3D_SV_TARGET3 = 3,
+ WINED3D_SV_TARGET4 = 4,
+ WINED3D_SV_TARGET5 = 5,
+ WINED3D_SV_TARGET6 = 6,
+ WINED3D_SV_TARGET7 = 7,
+};
+
+#define WINED3DCOLORWRITEENABLE_RED (1 << 0)
+#define WINED3DCOLORWRITEENABLE_GREEN (1 << 1)
+#define WINED3DCOLORWRITEENABLE_BLUE (1 << 2)
+#define WINED3DCOLORWRITEENABLE_ALPHA (1 << 3)
+
+#define WINED3DADAPTER_DEFAULT 0
+#define WINED3DENUM_NO_WHQL_LEVEL 2
+#define WINED3DPRESENT_BACK_BUFFER_MAX 3
+
+#define WINED3DTSS_TCI_PASSTHRU 0x00000
+#define WINED3DTSS_TCI_CAMERASPACENORMAL 0x10000
+#define WINED3DTSS_TCI_CAMERASPACEPOSITION 0x20000
+#define WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR 0x30000
+#define WINED3DTSS_TCI_SPHEREMAP 0x40000
+
+#define WINED3DTA_SELECTMASK 0x0000000f
+#define WINED3DTA_DIFFUSE 0x00000000
+#define WINED3DTA_CURRENT 0x00000001
+#define WINED3DTA_TEXTURE 0x00000002
+#define WINED3DTA_TFACTOR 0x00000003
+#define WINED3DTA_SPECULAR 0x00000004
+#define WINED3DTA_TEMP 0x00000005
+#define WINED3DTA_CONSTANT 0x00000006
+#define WINED3DTA_COMPLEMENT 0x00000010
+#define WINED3DTA_ALPHAREPLICATE 0x00000020
+
+#define WINED3DPRESENTFLAG_LOCKABLE_BACKBUFFER 0x00000001
+#define WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL 0x00000002
+#define WINED3DPRESENTFLAG_DEVICECLIP 0x00000004
+#define WINED3DPRESENTFLAG_VIDEO 0x00000010
+#define WINED3DPRESENTFLAG_NOAUTOROTATE 0x00000020
+#define WINED3DPRESENTFLAG_UNPRUNEDMODE 0x00000040
+
+#define WINED3DDP_MAXTEXCOORD 8
+
+#define WINED3DUSAGE_RENDERTARGET 0x00000001
+#define WINED3DUSAGE_DEPTHSTENCIL 0x00000002
+#define WINED3DUSAGE_WRITEONLY 0x00000008
+#define WINED3DUSAGE_SOFTWAREPROCESSING 0x00000010
+#define WINED3DUSAGE_DONOTCLIP 0x00000020
+#define WINED3DUSAGE_POINTS 0x00000040
+#define WINED3DUSAGE_RTPATCHES 0x00000080
+#define WINED3DUSAGE_NPATCHES 0x00000100
+#define WINED3DUSAGE_DYNAMIC 0x00000200
+#define WINED3DUSAGE_AUTOGENMIPMAP 0x00000400
+#define WINED3DUSAGE_DMAP 0x00004000
+#define WINED3DUSAGE_MASK 0x00004fff
+#define WINED3DUSAGE_STATICDECL 0x40000000
+#define WINED3DUSAGE_OVERLAY 0x80000000
+
+#define WINED3DUSAGE_QUERY_LEGACYBUMPMAP 0x00008000
+#define WINED3DUSAGE_QUERY_FILTER 0x00020000
+#define WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING 0x00080000
+#define WINED3DUSAGE_QUERY_SRGBREAD 0x00010000
+#define WINED3DUSAGE_QUERY_SRGBWRITE 0x00040000
+#define WINED3DUSAGE_QUERY_VERTEXTEXTURE 0x00100000
+#define WINED3DUSAGE_QUERY_WRAPANDMIP 0x00200000
+#define WINED3DUSAGE_QUERY_MASK 0x003f8000
+
+#define WINED3DLOCK_READONLY 0x0010
+#define WINED3DLOCK_NOSYSLOCK 0x0800
+#define WINED3DLOCK_NOOVERWRITE 0x1000
+#define WINED3DLOCK_DISCARD 0x2000
+#define WINED3DLOCK_DONOTWAIT 0x4000
+#define WINED3DLOCK_NO_DIRTY_UPDATE 0x8000
+
+#define WINED3DPRESENT_RATE_DEFAULT 0x00000000
+
+#define WINED3DPRESENT_INTERVAL_DEFAULT 0x00000000
+#define WINED3DPRESENT_INTERVAL_ONE 0x00000001
+#define WINED3DPRESENT_INTERVAL_TWO 0x00000002
+#define WINED3DPRESENT_INTERVAL_THREE 0x00000004
+#define WINED3DPRESENT_INTERVAL_FOUR 0x00000008
+#define WINED3DPRESENT_INTERVAL_IMMEDIATE 0x80000000
+
+#define WINED3DMAXUSERCLIPPLANES 32
+#define WINED3DCLIPPLANE0 (1 << 0)
+#define WINED3DCLIPPLANE1 (1 << 1)
+#define WINED3DCLIPPLANE2 (1 << 2)
+#define WINED3DCLIPPLANE3 (1 << 3)
+#define WINED3DCLIPPLANE4 (1 << 4)
+#define WINED3DCLIPPLANE5 (1 << 5)
+
+/* FVF (Flexible Vertex Format) codes */
+#define WINED3DFVF_RESERVED0 0x0001
+#define WINED3DFVF_POSITION_MASK 0x400e
+#define WINED3DFVF_XYZ 0x0002
+#define WINED3DFVF_XYZRHW 0x0004
+#define WINED3DFVF_XYZB1 0x0006
+#define WINED3DFVF_XYZB2 0x0008
+#define WINED3DFVF_XYZB3 0x000a
+#define WINED3DFVF_XYZB4 0x000c
+#define WINED3DFVF_XYZB5 0x000e
+#define WINED3DFVF_XYZW 0x4002
+#define WINED3DFVF_NORMAL 0x0010
+#define WINED3DFVF_PSIZE 0x0020
+#define WINED3DFVF_DIFFUSE 0x0040
+#define WINED3DFVF_SPECULAR 0x0080
+#define WINED3DFVF_TEXCOUNT_MASK 0x0f00
+#define WINED3DFVF_TEXCOUNT_SHIFT 8
+#define WINED3DFVF_TEX0 0x0000
+#define WINED3DFVF_TEX1 0x0100
+#define WINED3DFVF_TEX2 0x0200
+#define WINED3DFVF_TEX3 0x0300
+#define WINED3DFVF_TEX4 0x0400
+#define WINED3DFVF_TEX5 0x0500
+#define WINED3DFVF_TEX6 0x0600
+#define WINED3DFVF_TEX7 0x0700
+#define WINED3DFVF_TEX8 0x0800
+#define WINED3DFVF_LASTBETA_UBYTE4 0x1000
+#define WINED3DFVF_LASTBETA_D3DCOLOR 0x8000
+#define WINED3DFVF_RESERVED2 0x6000
+
+#define WINED3DFVF_TEXTUREFORMAT1 3
+#define WINED3DFVF_TEXTUREFORMAT2 0
+#define WINED3DFVF_TEXTUREFORMAT3 1
+#define WINED3DFVF_TEXTUREFORMAT4 2
+#define WINED3DFVF_TEXCOORDSIZE1(idx) (WINED3DFVF_TEXTUREFORMAT1 << (idx * 2 + 16))
+#define WINED3DFVF_TEXCOORDSIZE2(idx) (WINED3DFVF_TEXTUREFORMAT2 << (idx * 2 + 16))
+#define WINED3DFVF_TEXCOORDSIZE3(idx) (WINED3DFVF_TEXTUREFORMAT3 << (idx * 2 + 16))
+#define WINED3DFVF_TEXCOORDSIZE4(idx) (WINED3DFVF_TEXTUREFORMAT4 << (idx * 2 + 16))
+
+/* Clear flags */
+#define WINED3DCLEAR_TARGET 0x00000001
+#define WINED3DCLEAR_ZBUFFER 0x00000002
+#define WINED3DCLEAR_STENCIL 0x00000004
+
+/* Stream source flags */
+#define WINED3DSTREAMSOURCE_INDEXEDDATA (1 << 30)
+#define WINED3DSTREAMSOURCE_INSTANCEDATA (2 << 30)
+
+/* SetPrivateData flags */
+#define WINED3DSPD_IUNKNOWN 0x00000001
+
+/* IWineD3D::CreateDevice behaviour flags */
+#define WINED3DCREATE_FPU_PRESERVE 0x00000002
+#define WINED3DCREATE_PUREDEVICE 0x00000010
+#define WINED3DCREATE_SOFTWARE_VERTEXPROCESSING 0x00000020
+#define WINED3DCREATE_HARDWARE_VERTEXPROCESSING 0x00000040
+#define WINED3DCREATE_MIXED_VERTEXPROCESSING 0x00000080
+#define WINED3DCREATE_DISABLE_DRIVER_MANAGEMENT 0x00000100
+#define WINED3DCREATE_ADAPTERGROUP_DEVICE 0x00000200
+
+/* VTF defines */
+#define WINED3DDMAPSAMPLER 0x100
+#define WINED3DVERTEXTEXTURESAMPLER0 (WINED3DDMAPSAMPLER + 1)
+#define WINED3DVERTEXTEXTURESAMPLER1 (WINED3DDMAPSAMPLER + 2)
+#define WINED3DVERTEXTEXTURESAMPLER2 (WINED3DDMAPSAMPLER + 3)
+#define WINED3DVERTEXTEXTURESAMPLER3 (WINED3DDMAPSAMPLER + 4)
+
+#define WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020
+#define WINED3DCAPS3_LINEAR_TO_SRGB_PRESENTATION 0x00000080
+#define WINED3DCAPS3_COPY_TO_VIDMEM 0x00000100
+#define WINED3DCAPS3_COPY_TO_SYSTEMMEM 0x00000200
+#define WINED3DCAPS3_RESERVED 0x8000001f
+
+#define WINED3DDEVCAPS2_STREAMOFFSET 0x00000001
+#define WINED3DDEVCAPS2_DMAPNPATCH 0x00000002
+#define WINED3DDEVCAPS2_ADAPTIVETESSRTPATCH 0x00000004
+#define WINED3DDEVCAPS2_ADAPTIVETESSNPATCH 0x00000008
+#define WINED3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES 0x00000010
+#define WINED3DDEVCAPS2_PRESAMPLEDDMAPNPATCH 0x00000020
+#define WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET 0x00000040
+
+#define WINED3DDTCAPS_UBYTE4 0x00000001
+#define WINED3DDTCAPS_UBYTE4N 0x00000002
+#define WINED3DDTCAPS_SHORT2N 0x00000004
+#define WINED3DDTCAPS_SHORT4N 0x00000008
+#define WINED3DDTCAPS_USHORT2N 0x00000010
+#define WINED3DDTCAPS_USHORT4N 0x00000020
+#define WINED3DDTCAPS_UDEC3 0x00000040
+#define WINED3DDTCAPS_DEC3N 0x00000080
+#define WINED3DDTCAPS_FLOAT16_2 0x00000100
+#define WINED3DDTCAPS_FLOAT16_4 0x00000200
+
+#define WINED3DFVFCAPS_TEXCOORDCOUNTMASK 0x0000ffff
+#define WINED3DFVFCAPS_DONOTSTRIPELEMENTS 0x00080000
+#define WINED3DFVFCAPS_PSIZE 0x00100000
+
+#define WINED3DLINECAPS_TEXTURE 0x00000001
+#define WINED3DLINECAPS_ZTEST 0x00000002
+#define WINED3DLINECAPS_BLEND 0x00000004
+#define WINED3DLINECAPS_ALPHACMP 0x00000008
+#define WINED3DLINECAPS_FOG 0x00000010
+#define WINED3DLINECAPS_ANTIALIAS 0x00000020
+
+#define WINED3DMAX30SHADERINSTRUCTIONS 32768
+#define WINED3DMIN30SHADERINSTRUCTIONS 512
+
+#define WINED3DPBLENDCAPS_ZERO 0x00000001
+#define WINED3DPBLENDCAPS_ONE 0x00000002
+#define WINED3DPBLENDCAPS_SRCCOLOR 0x00000004
+#define WINED3DPBLENDCAPS_INVSRCCOLOR 0x00000008
+#define WINED3DPBLENDCAPS_SRCALPHA 0x00000010
+#define WINED3DPBLENDCAPS_INVSRCALPHA 0x00000020
+#define WINED3DPBLENDCAPS_DESTALPHA 0x00000040
+#define WINED3DPBLENDCAPS_INVDESTALPHA 0x00000080
+#define WINED3DPBLENDCAPS_DESTCOLOR 0x00000100
+#define WINED3DPBLENDCAPS_INVDESTCOLOR 0x00000200
+#define WINED3DPBLENDCAPS_SRCALPHASAT 0x00000400
+#define WINED3DPBLENDCAPS_BOTHSRCALPHA 0x00000800
+#define WINED3DPBLENDCAPS_BOTHINVSRCALPHA 0x00001000
+#define WINED3DPBLENDCAPS_BLENDFACTOR 0x00002000
+
+#define WINED3DPCMPCAPS_NEVER 0x00000001
+#define WINED3DPCMPCAPS_LESS 0x00000002
+#define WINED3DPCMPCAPS_EQUAL 0x00000004
+#define WINED3DPCMPCAPS_LESSEQUAL 0x00000008
+#define WINED3DPCMPCAPS_GREATER 0x00000010
+#define WINED3DPCMPCAPS_NOTEQUAL 0x00000020
+#define WINED3DPCMPCAPS_GREATEREQUAL 0x00000040
+#define WINED3DPCMPCAPS_ALWAYS 0x00000080
+
+#define WINED3DPMISCCAPS_MASKZ 0x00000002
+#define WINED3DPMISCCAPS_LINEPATTERNREP 0x00000004
+#define WINED3DPMISCCAPS_CULLNONE 0x00000010
+#define WINED3DPMISCCAPS_CULLCW 0x00000020
+#define WINED3DPMISCCAPS_CULLCCW 0x00000040
+#define WINED3DPMISCCAPS_COLORWRITEENABLE 0x00000080
+#define WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS 0x00000100
+#define WINED3DPMISCCAPS_CLIPTLVERTS 0x00000200
+#define WINED3DPMISCCAPS_TSSARGTEMP 0x00000400
+#define WINED3DPMISCCAPS_BLENDOP 0x00000800
+#define WINED3DPMISCCAPS_NULLREFERENCE 0x00001000
+#define WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS 0x00004000
+#define WINED3DPMISCCAPS_PERSTAGECONSTANT 0x00008000
+#define WINED3DPMISCCAPS_FOGANDSPECULARALPHA 0x00010000
+#define WINED3DPMISCCAPS_SEPARATEALPHABLEND 0x00020000
+#define WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS 0x00040000
+#define WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING 0x00080000
+#define WINED3DPMISCCAPS_FOGVERTEXCLAMPED 0x00100000
+
+#define WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH 24
+#define WINED3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH 0
+#define WINED3DPS20_MAX_NUMTEMPS 32
+#define WINED3DPS20_MIN_NUMTEMPS 12
+#define WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH 4
+#define WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH 0
+#define WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS 512
+#define WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS 96
+
+#define WINED3DPS20CAPS_ARBITRARYSWIZZLE 0x00000001
+#define WINED3DPS20CAPS_GRADIENTINSTRUCTIONS 0x00000002
+#define WINED3DPS20CAPS_PREDICATION 0x00000004
+#define WINED3DPS20CAPS_NODEPENDENTREADLIMIT 0x00000008
+#define WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT 0x00000010
+
+#define WINED3DPTADDRESSCAPS_WRAP 0x00000001
+#define WINED3DPTADDRESSCAPS_MIRROR 0x00000002
+#define WINED3DPTADDRESSCAPS_CLAMP 0x00000004
+#define WINED3DPTADDRESSCAPS_BORDER 0x00000008
+#define WINED3DPTADDRESSCAPS_INDEPENDENTUV 0x00000010
+#define WINED3DPTADDRESSCAPS_MIRRORONCE 0x00000020
+
+#define WINED3DSTENCILCAPS_KEEP 0x00000001
+#define WINED3DSTENCILCAPS_ZERO 0x00000002
+#define WINED3DSTENCILCAPS_REPLACE 0x00000004
+#define WINED3DSTENCILCAPS_INCRSAT 0x00000008
+#define WINED3DSTENCILCAPS_DECRSAT 0x00000010
+#define WINED3DSTENCILCAPS_INVERT 0x00000020
+#define WINED3DSTENCILCAPS_INCR 0x00000040
+#define WINED3DSTENCILCAPS_DECR 0x00000080
+#define WINED3DSTENCILCAPS_TWOSIDED 0x00000100
+
+#define WINED3DTEXOPCAPS_DISABLE 0x00000001
+#define WINED3DTEXOPCAPS_SELECTARG1 0x00000002
+#define WINED3DTEXOPCAPS_SELECTARG2 0x00000004
+#define WINED3DTEXOPCAPS_MODULATE 0x00000008
+#define WINED3DTEXOPCAPS_MODULATE2X 0x00000010
+#define WINED3DTEXOPCAPS_MODULATE4X 0x00000020
+#define WINED3DTEXOPCAPS_ADD 0x00000040
+#define WINED3DTEXOPCAPS_ADDSIGNED 0x00000080
+#define WINED3DTEXOPCAPS_ADDSIGNED2X 0x00000100
+#define WINED3DTEXOPCAPS_SUBTRACT 0x00000200
+#define WINED3DTEXOPCAPS_ADDSMOOTH 0x00000400
+#define WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA 0x00000800
+#define WINED3DTEXOPCAPS_BLENDTEXTUREALPHA 0x00001000
+#define WINED3DTEXOPCAPS_BLENDFACTORALPHA 0x00002000
+#define WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM 0x00004000
+#define WINED3DTEXOPCAPS_BLENDCURRENTALPHA 0x00008000
+#define WINED3DTEXOPCAPS_PREMODULATE 0x00010000
+#define WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR 0x00020000
+#define WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA 0x00040000
+#define WINED3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR 0x00080000
+#define WINED3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA 0x00100000
+#define WINED3DTEXOPCAPS_BUMPENVMAP 0x00200000
+#define WINED3DTEXOPCAPS_BUMPENVMAPLUMINANCE 0x00400000
+#define WINED3DTEXOPCAPS_DOTPRODUCT3 0x00800000
+#define WINED3DTEXOPCAPS_MULTIPLYADD 0x01000000
+#define WINED3DTEXOPCAPS_LERP 0x02000000
+
+#define WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH 24
+#define WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH 0
+#define WINED3DVS20_MAX_NUMTEMPS 32
+#define WINED3DVS20_MIN_NUMTEMPS 12
+#define WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH 4
+#define WINED3DVS20_MIN_STATICFLOWCONTROLDEPTH 1
+
+#define WINED3DVS20CAPS_PREDICATION 0x00000001
+
+#define WINED3DCAPS2_NO2DDURING3DSCENE 0x00000002
+#define WINED3DCAPS2_FULLSCREENGAMMA 0x00020000
+#define WINED3DCAPS2_CANRENDERWINDOWED 0x00080000
+#define WINED3DCAPS2_CANCALIBRATEGAMMA 0x00100000
+#define WINED3DCAPS2_RESERVED 0x02000000
+#define WINED3DCAPS2_CANMANAGERESOURCE 0x10000000
+#define WINED3DCAPS2_DYNAMICTEXTURES 0x20000000
+#define WINED3DCAPS2_CANAUTOGENMIPMAP 0x40000000
+
+#define WINED3DPRASTERCAPS_DITHER 0x00000001
+#define WINED3DPRASTERCAPS_ROP2 0x00000002
+#define WINED3DPRASTERCAPS_XOR 0x00000004
+#define WINED3DPRASTERCAPS_PAT 0x00000008
+#define WINED3DPRASTERCAPS_ZTEST 0x00000010
+#define WINED3DPRASTERCAPS_SUBPIXEL 0x00000020
+#define WINED3DPRASTERCAPS_SUBPIXELX 0x00000040
+#define WINED3DPRASTERCAPS_FOGVERTEX 0x00000080
+#define WINED3DPRASTERCAPS_FOGTABLE 0x00000100
+#define WINED3DPRASTERCAPS_STIPPLE 0x00000200
+#define WINED3DPRASTERCAPS_ANTIALIASSORTDEPENDENT 0x00000400
+#define WINED3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT 0x00000800
+#define WINED3DPRASTERCAPS_ANTIALIASEDGES 0x00001000
+#define WINED3DPRASTERCAPS_MIPMAPLODBIAS 0x00002000
+#define WINED3DPRASTERCAPS_ZBIAS 0x00004000
+#define WINED3DPRASTERCAPS_ZBUFFERLESSHSR 0x00008000
+#define WINED3DPRASTERCAPS_FOGRANGE 0x00010000
+#define WINED3DPRASTERCAPS_ANISOTROPY 0x00020000
+#define WINED3DPRASTERCAPS_WBUFFER 0x00040000
+#define WINED3DPRASTERCAPS_TRANSLUCENTSORTINDEPENDENT 0x00080000
+#define WINED3DPRASTERCAPS_WFOG 0x00100000
+#define WINED3DPRASTERCAPS_ZFOG 0x00200000
+#define WINED3DPRASTERCAPS_COLORPERSPECTIVE 0x00400000
+#define WINED3DPRASTERCAPS_SCISSORTEST 0x01000000
+#define WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS 0x02000000
+#define WINED3DPRASTERCAPS_DEPTHBIAS 0x04000000
+#define WINED3DPRASTERCAPS_MULTISAMPLE_TOGGLE 0x08000000
+
+#define WINED3DPSHADECAPS_COLORFLATMONO 0x00000001
+#define WINED3DPSHADECAPS_COLORFLATRGB 0x00000002
+#define WINED3DPSHADECAPS_COLORGOURAUDMONO 0x00000004
+#define WINED3DPSHADECAPS_COLORGOURAUDRGB 0x00000008
+#define WINED3DPSHADECAPS_COLORPHONGMONO 0x00000010
+#define WINED3DPSHADECAPS_COLORPHONGRGB 0x00000020
+#define WINED3DPSHADECAPS_SPECULARFLATMONO 0x00000040
+#define WINED3DPSHADECAPS_SPECULARFLATRGB 0x00000080
+#define WINED3DPSHADECAPS_SPECULARGOURAUDMONO 0x00000100
+#define WINED3DPSHADECAPS_SPECULARGOURAUDRGB 0x00000200
+#define WINED3DPSHADECAPS_SPECULARPHONGMONO 0x00000400
+#define WINED3DPSHADECAPS_SPECULARPHONGRGB 0x00000800
+#define WINED3DPSHADECAPS_ALPHAFLATBLEND 0x00001000
+#define WINED3DPSHADECAPS_ALPHAFLATSTIPPLED 0x00002000
+#define WINED3DPSHADECAPS_ALPHAGOURAUDBLEND 0x00004000
+#define WINED3DPSHADECAPS_ALPHAGOURAUDSTIPPLED 0x00008000
+#define WINED3DPSHADECAPS_ALPHAPHONGBLEND 0x00010000
+#define WINED3DPSHADECAPS_ALPHAPHONGSTIPPLED 0x00020000
+#define WINED3DPSHADECAPS_FOGFLAT 0x00040000
+#define WINED3DPSHADECAPS_FOGGOURAUD 0x00080000
+#define WINED3DPSHADECAPS_FOGPHONG 0x00100000
+
+#define WINED3DPTEXTURECAPS_PERSPECTIVE 0x00000001
+#define WINED3DPTEXTURECAPS_POW2 0x00000002
+#define WINED3DPTEXTURECAPS_ALPHA 0x00000004
+#define WINED3DPTEXTURECAPS_TRANSPARENCY 0x00000008
+#define WINED3DPTEXTURECAPS_BORDER 0x00000010
+#define WINED3DPTEXTURECAPS_SQUAREONLY 0x00000020
+#define WINED3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00000040
+#define WINED3DPTEXTURECAPS_ALPHAPALETTE 0x00000080
+#define WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL 0x00000100
+#define WINED3DPTEXTURECAPS_PROJECTED 0x00000400
+#define WINED3DPTEXTURECAPS_CUBEMAP 0x00000800
+#define WINED3DPTEXTURECAPS_COLORKEYBLEND 0x00001000
+#define WINED3DPTEXTURECAPS_VOLUMEMAP 0x00002000
+#define WINED3DPTEXTURECAPS_MIPMAP 0x00004000
+#define WINED3DPTEXTURECAPS_MIPVOLUMEMAP 0x00008000
+#define WINED3DPTEXTURECAPS_MIPCUBEMAP 0x00010000
+#define WINED3DPTEXTURECAPS_CUBEMAP_POW2 0x00020000
+#define WINED3DPTEXTURECAPS_VOLUMEMAP_POW2 0x00040000
+#define WINED3DPTEXTURECAPS_NOPROJECTEDBUMPENV 0x00200000
+
+#define WINED3DPTFILTERCAPS_NEAREST 0x00000001
+#define WINED3DPTFILTERCAPS_LINEAR 0x00000002
+#define WINED3DPTFILTERCAPS_MIPNEAREST 0x00000004
+#define WINED3DPTFILTERCAPS_MIPLINEAR 0x00000008
+#define WINED3DPTFILTERCAPS_LINEARMIPNEAREST 0x00000010
+#define WINED3DPTFILTERCAPS_LINEARMIPLINEAR 0x00000020
+#define WINED3DPTFILTERCAPS_MINFPOINT 0x00000100
+#define WINED3DPTFILTERCAPS_MINFLINEAR 0x00000200
+#define WINED3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400
+#define WINED3DPTFILTERCAPS_MIPFPOINT 0x00010000
+#define WINED3DPTFILTERCAPS_MIPFLINEAR 0x00020000
+#define WINED3DPTFILTERCAPS_MAGFPOINT 0x01000000
+#define WINED3DPTFILTERCAPS_MAGFLINEAR 0x02000000
+#define WINED3DPTFILTERCAPS_MAGFANISOTROPIC 0x04000000
+#define WINED3DPTFILTERCAPS_MAGFPYRAMIDALQUAD 0x08000000
+#define WINED3DPTFILTERCAPS_MAGFGAUSSIANQUAD 0x10000000
+
+#define WINED3DVTXPCAPS_TEXGEN 0x00000001
+#define WINED3DVTXPCAPS_MATERIALSOURCE7 0x00000002
+#define WINED3DVTXPCAPS_VERTEXFOG 0x00000004
+#define WINED3DVTXPCAPS_DIRECTIONALLIGHTS 0x00000008
+#define WINED3DVTXPCAPS_POSITIONALLIGHTS 0x00000010
+#define WINED3DVTXPCAPS_LOCALVIEWER 0x00000020
+#define WINED3DVTXPCAPS_TWEENING 0x00000040
+#define WINED3DVTXPCAPS_TEXGEN_SPHEREMAP 0x00000100
+#define WINED3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER 0x00000200
+
+#define WINED3DCURSORCAPS_COLOR 0x00000001
+#define WINED3DCURSORCAPS_LOWRES 0x00000002
+
+#define WINED3DDEVCAPS_FLOATTLVERTEX 0x00000001
+#define WINED3DDEVCAPS_SORTINCREASINGZ 0x00000002
+#define WINED3DDEVCAPS_SORTDECREASINGZ 0X00000004
+#define WINED3DDEVCAPS_SORTEXACT 0x00000008
+#define WINED3DDEVCAPS_EXECUTESYSTEMMEMORY 0x00000010
+#define WINED3DDEVCAPS_EXECUTEVIDEOMEMORY 0x00000020
+#define WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY 0x00000040
+#define WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY 0x00000080
+#define WINED3DDEVCAPS_TEXTURESYSTEMMEMORY 0x00000100
+#define WINED3DDEVCAPS_TEXTUREVIDEOMEMORY 0x00000200
+#define WINED3DDEVCAPS_DRAWPRIMTLVERTEX 0x00000400
+#define WINED3DDEVCAPS_CANRENDERAFTERFLIP 0x00000800
+#define WINED3DDEVCAPS_TEXTURENONLOCALVIDMEM 0x00001000
+#define WINED3DDEVCAPS_DRAWPRIMITIVES2 0x00002000
+#define WINED3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x00004000
+#define WINED3DDEVCAPS_DRAWPRIMITIVES2EX 0x00008000
+#define WINED3DDEVCAPS_HWTRANSFORMANDLIGHT 0x00010000
+#define WINED3DDEVCAPS_CANBLTSYSTONONLOCAL 0x00020000
+#define WINED3DDEVCAPS_HWRASTERIZATION 0x00080000
+#define WINED3DDEVCAPS_PUREDEVICE 0x00100000
+#define WINED3DDEVCAPS_QUINTICRTPATCHES 0x00200000
+#define WINED3DDEVCAPS_RTPATCHES 0x00400000
+#define WINED3DDEVCAPS_RTPATCHHANDLEZERO 0x00800000
+#define WINED3DDEVCAPS_NPATCHES 0x01000000
+
+/* dwDDFX */
+/* arithmetic stretching along y axis */
+#define WINEDDBLTFX_ARITHSTRETCHY 0x00000001
+/* mirror on y axis */
+#define WINEDDBLTFX_MIRRORLEFTRIGHT 0x00000002
+/* mirror on x axis */
+#define WINEDDBLTFX_MIRRORUPDOWN 0x00000004
+/* do not tear */
+#define WINEDDBLTFX_NOTEARING 0x00000008
+/* 180 degrees clockwise rotation */
+#define WINEDDBLTFX_ROTATE180 0x00000010
+/* 270 degrees clockwise rotation */
+#define WINEDDBLTFX_ROTATE270 0x00000020
+/* 90 degrees clockwise rotation */
+#define WINEDDBLTFX_ROTATE90 0x00000040
+/* dwZBufferLow and dwZBufferHigh specify limits to the copied Z values */
+#define WINEDDBLTFX_ZBUFFERRANGE 0x00000080
+/* add dwZBufferBaseDest to every source z value before compare */
+#define WINEDDBLTFX_ZBUFFERBASEDEST 0x00000100
+
+/* dwFlags for Blt* */
+#define WINEDDBLT_ALPHADEST 0x00000001
+#define WINEDDBLT_ALPHADESTCONSTOVERRIDE 0x00000002
+#define WINEDDBLT_ALPHADESTNEG 0x00000004
+#define WINEDDBLT_ALPHADESTSURFACEOVERRIDE 0x00000008
+#define WINEDDBLT_ALPHAEDGEBLEND 0x00000010
+#define WINEDDBLT_ALPHASRC 0x00000020
+#define WINEDDBLT_ALPHASRCCONSTOVERRIDE 0x00000040
+#define WINEDDBLT_ALPHASRCNEG 0x00000080
+#define WINEDDBLT_ALPHASRCSURFACEOVERRIDE 0x00000100
+#define WINEDDBLT_ASYNC 0x00000200
+#define WINEDDBLT_COLORFILL 0x00000400
+#define WINEDDBLT_DDFX 0x00000800
+#define WINEDDBLT_DDROPS 0x00001000
+#define WINEDDBLT_KEYDEST 0x00002000
+#define WINEDDBLT_KEYDESTOVERRIDE 0x00004000
+#define WINEDDBLT_KEYSRC 0x00008000
+#define WINEDDBLT_KEYSRCOVERRIDE 0x00010000
+#define WINEDDBLT_ROP 0x00020000
+#define WINEDDBLT_ROTATIONANGLE 0x00040000
+#define WINEDDBLT_ZBUFFER 0x00080000
+#define WINEDDBLT_ZBUFFERDESTCONSTOVERRIDE 0x00100000
+#define WINEDDBLT_ZBUFFERDESTOVERRIDE 0x00200000
+#define WINEDDBLT_ZBUFFERSRCCONSTOVERRIDE 0x00400000
+#define WINEDDBLT_ZBUFFERSRCOVERRIDE 0x00800000
+#define WINEDDBLT_WAIT 0x01000000
+#define WINEDDBLT_DEPTHFILL 0x02000000
+#define WINEDDBLT_DONOTWAIT 0x08000000
+
+/* dwTrans for BltFast */
+#define WINEDDBLTFAST_NOCOLORKEY 0x00000000
+#define WINEDDBLTFAST_SRCCOLORKEY 0x00000001
+#define WINEDDBLTFAST_DESTCOLORKEY 0x00000002
+#define WINEDDBLTFAST_WAIT 0x00000010
+#define WINEDDBLTFAST_DONOTWAIT 0x00000020
+
+/* DDSURFACEDESC.dwFlags */
+#define WINEDDSD_CAPS 0x00000001
+#define WINEDDSD_HEIGHT 0x00000002
+#define WINEDDSD_WIDTH 0x00000004
+#define WINEDDSD_PITCH 0x00000008
+#define WINEDDSD_BACKBUFFERCOUNT 0x00000020
+#define WINEDDSD_ZBUFFERBITDEPTH 0x00000040
+#define WINEDDSD_ALPHABITDEPTH 0x00000080
+#define WINEDDSD_LPSURFACE 0x00000800
+#define WINEDDSD_PIXELFORMAT 0x00001000
+#define WINEDDSD_CKDESTOVERLAY 0x00002000
+#define WINEDDSD_CKDESTBLT 0x00004000
+#define WINEDDSD_CKSRCOVERLAY 0x00008000
+#define WINEDDSD_CKSRCBLT 0x00010000
+#define WINEDDSD_MIPMAPCOUNT 0x00020000
+#define WINEDDSD_REFRESHRATE 0x00040000
+#define WINEDDSD_LINEARSIZE 0x00080000
+#define WINEDDSD_TEXTURESTAGE 0x00100000
+#define WINEDDSD_FVF 0x00200000
+#define WINEDDSD_SRCVBHANDLE 0x00400000
+#define WINEDDSD_ALL 0x007ff9ee
+
+/* Set/Get Colour Key Flags */
+#define WINEDDCKEY_COLORSPACE 0x00000001 /* Struct is single colour space */
+#define WINEDDCKEY_DESTBLT 0x00000002 /* To be used as dest for blt */
+#define WINEDDCKEY_DESTOVERLAY 0x00000004 /* To be used as dest for CK overlays */
+#define WINEDDCKEY_SRCBLT 0x00000008 /* To be used as src for blt */
+#define WINEDDCKEY_SRCOVERLAY 0x00000010 /* To be used as src for CK overlays */
+
+/* dwFlags for GetBltStatus */
+#define WINEDDGBS_CANBLT 0x00000001
+#define WINEDDGBS_ISBLTDONE 0x00000002
+
+/* dwFlags for GetFlipStatus */
+#define WINEDDGFS_CANFLIP 0x00000001
+#define WINEDDGFS_ISFLIPDONE 0x00000002
+
+/* dwFlags for Flip */
+#define WINEDDFLIP_WAIT 0x00000001
+#define WINEDDFLIP_EVEN 0x00000002 /* only valid for overlay */
+#define WINEDDFLIP_ODD 0x00000004 /* only valid for overlay */
+#define WINEDDFLIP_NOVSYNC 0x00000008
+#define WINEDDFLIP_STEREO 0x00000010
+#define WINEDDFLIP_DONOTWAIT 0x00000020
+#define WINEDDFLIP_INTERVAL2 0x02000000
+#define WINEDDFLIP_INTERVAL3 0x03000000
+#define WINEDDFLIP_INTERVAL4 0x04000000
+
+#define WINEDDOVER_ALPHADEST 0x00000001
+#define WINEDDOVER_ALPHADESTCONSTOVERRIDE 0x00000002
+#define WINEDDOVER_ALPHADESTNEG 0x00000004
+#define WINEDDOVER_ALPHADESTSURFACEOVERRIDE 0x00000008
+#define WINEDDOVER_ALPHAEDGEBLEND 0x00000010
+#define WINEDDOVER_ALPHASRC 0x00000020
+#define WINEDDOVER_ALPHASRCCONSTOVERRIDE 0x00000040
+#define WINEDDOVER_ALPHASRCNEG 0x00000080
+#define WINEDDOVER_ALPHASRCSURFACEOVERRIDE 0x00000100
+#define WINEDDOVER_HIDE 0x00000200
+#define WINEDDOVER_KEYDEST 0x00000400
+#define WINEDDOVER_KEYDESTOVERRIDE 0x00000800
+#define WINEDDOVER_KEYSRC 0x00001000
+#define WINEDDOVER_KEYSRCOVERRIDE 0x00002000
+#define WINEDDOVER_SHOW 0x00004000
+#define WINEDDOVER_ADDDIRTYRECT 0x00008000
+#define WINEDDOVER_REFRESHDIRTYRECTS 0x00010000
+#define WINEDDOVER_REFRESHALL 0x00020000
+#define WINEDDOVER_DDFX 0x00080000
+#define WINEDDOVER_AUTOFLIP 0x00100000
+#define WINEDDOVER_BOB 0x00200000
+#define WINEDDOVER_OVERRIDEBOBWEAVE 0x00400000
+#define WINEDDOVER_INTERLEAVED 0x00800000
+
+/* DirectDraw Caps */
+#define WINEDDSCAPS_RESERVED1 0x00000001
+#define WINEDDSCAPS_ALPHA 0x00000002
+#define WINEDDSCAPS_BACKBUFFER 0x00000004
+#define WINEDDSCAPS_COMPLEX 0x00000008
+#define WINEDDSCAPS_FLIP 0x00000010
+#define WINEDDSCAPS_FRONTBUFFER 0x00000020
+#define WINEDDSCAPS_OFFSCREENPLAIN 0x00000040
+#define WINEDDSCAPS_OVERLAY 0x00000080
+#define WINEDDSCAPS_PALETTE 0x00000100
+#define WINEDDSCAPS_PRIMARYSURFACE 0x00000200
+#define WINEDDSCAPS_PRIMARYSURFACELEFT 0x00000400
+#define WINEDDSCAPS_SYSTEMMEMORY 0x00000800
+#define WINEDDSCAPS_TEXTURE 0x00001000
+#define WINEDDSCAPS_3DDEVICE 0x00002000
+#define WINEDDSCAPS_VIDEOMEMORY 0x00004000
+#define WINEDDSCAPS_VISIBLE 0x00008000
+#define WINEDDSCAPS_WRITEONLY 0x00010000
+#define WINEDDSCAPS_ZBUFFER 0x00020000
+#define WINEDDSCAPS_OWNDC 0x00040000
+#define WINEDDSCAPS_LIVEVIDEO 0x00080000
+#define WINEDDSCAPS_HWCODEC 0x00100000
+#define WINEDDSCAPS_MODEX 0x00200000
+#define WINEDDSCAPS_MIPMAP 0x00400000
+#define WINEDDSCAPS_RESERVED2 0x00800000
+#define WINEDDSCAPS_ALLOCONLOAD 0x04000000
+#define WINEDDSCAPS_VIDEOPORT 0x08000000
+#define WINEDDSCAPS_LOCALVIDMEM 0x10000000
+#define WINEDDSCAPS_NONLOCALVIDMEM 0x20000000
+#define WINEDDSCAPS_STANDARDVGAMODE 0x40000000
+#define WINEDDSCAPS_OPTIMIZED 0x80000000
+
+#define WINEDDCKEYCAPS_DESTBLT 0x00000001
+#define WINEDDCKEYCAPS_DESTBLTCLRSPACE 0x00000002
+#define WINEDDCKEYCAPS_DESTBLTCLRSPACEYUV 0x00000004
+#define WINEDDCKEYCAPS_DESTBLTYUV 0x00000008
+#define WINEDDCKEYCAPS_DESTOVERLAY 0x00000010
+#define WINEDDCKEYCAPS_DESTOVERLAYCLRSPACE 0x00000020
+#define WINEDDCKEYCAPS_DESTOVERLAYCLRSPACEYUV 0x00000040
+#define WINEDDCKEYCAPS_DESTOVERLAYONEACTIVE 0x00000080
+#define WINEDDCKEYCAPS_DESTOVERLAYYUV 0x00000100
+#define WINEDDCKEYCAPS_SRCBLT 0x00000200
+#define WINEDDCKEYCAPS_SRCBLTCLRSPACE 0x00000400
+#define WINEDDCKEYCAPS_SRCBLTCLRSPACEYUV 0x00000800
+#define WINEDDCKEYCAPS_SRCBLTYUV 0x00001000
+#define WINEDDCKEYCAPS_SRCOVERLAY 0x00002000
+#define WINEDDCKEYCAPS_SRCOVERLAYCLRSPACE 0x00004000
+#define WINEDDCKEYCAPS_SRCOVERLAYCLRSPACEYUV 0x00008000
+#define WINEDDCKEYCAPS_SRCOVERLAYONEACTIVE 0x00010000
+#define WINEDDCKEYCAPS_SRCOVERLAYYUV 0x00020000
+#define WINEDDCKEYCAPS_NOCOSTOVERLAY 0x00040000
+
+#define WINEDDFXCAPS_BLTALPHA 0x00000001
+#define WINEDDFXCAPS_OVERLAYALPHA 0x00000004
+#define WINEDDFXCAPS_BLTARITHSTRETCHYN 0x00000010
+#define WINEDDFXCAPS_BLTARITHSTRETCHY 0x00000020
+#define WINEDDFXCAPS_BLTMIRRORLEFTRIGHT 0x00000040
+#define WINEDDFXCAPS_BLTMIRRORUPDOWN 0x00000080
+#define WINEDDFXCAPS_BLTROTATION 0x00000100
+#define WINEDDFXCAPS_BLTROTATION90 0x00000200
+#define WINEDDFXCAPS_BLTSHRINKX 0x00000400
+#define WINEDDFXCAPS_BLTSHRINKXN 0x00000800
+#define WINEDDFXCAPS_BLTSHRINKY 0x00001000
+#define WINEDDFXCAPS_BLTSHRINKYN 0x00002000
+#define WINEDDFXCAPS_BLTSTRETCHX 0x00004000
+#define WINEDDFXCAPS_BLTSTRETCHXN 0x00008000
+#define WINEDDFXCAPS_BLTSTRETCHY 0x00010000
+#define WINEDDFXCAPS_BLTSTRETCHYN 0x00020000
+#define WINEDDFXCAPS_OVERLAYARITHSTRETCHY 0x00040000
+#define WINEDDFXCAPS_OVERLAYARITHSTRETCHYN 0x00000008
+#define WINEDDFXCAPS_OVERLAYSHRINKX 0x00080000
+#define WINEDDFXCAPS_OVERLAYSHRINKXN 0x00100000
+#define WINEDDFXCAPS_OVERLAYSHRINKY 0x00200000
+#define WINEDDFXCAPS_OVERLAYSHRINKYN 0x00400000
+#define WINEDDFXCAPS_OVERLAYSTRETCHX 0x00800000
+#define WINEDDFXCAPS_OVERLAYSTRETCHXN 0x01000000
+#define WINEDDFXCAPS_OVERLAYSTRETCHY 0x02000000
+#define WINEDDFXCAPS_OVERLAYSTRETCHYN 0x04000000
+#define WINEDDFXCAPS_OVERLAYMIRRORLEFTRIGHT 0x08000000
+#define WINEDDFXCAPS_OVERLAYMIRRORUPDOWN 0x10000000
+
+#define WINEDDCAPS_3D 0x00000001
+#define WINEDDCAPS_ALIGNBOUNDARYDEST 0x00000002
+#define WINEDDCAPS_ALIGNSIZEDEST 0x00000004
+#define WINEDDCAPS_ALIGNBOUNDARYSRC 0x00000008
+#define WINEDDCAPS_ALIGNSIZESRC 0x00000010
+#define WINEDDCAPS_ALIGNSTRIDE 0x00000020
+#define WINEDDCAPS_BLT 0x00000040
+#define WINEDDCAPS_BLTQUEUE 0x00000080
+#define WINEDDCAPS_BLTFOURCC 0x00000100
+#define WINEDDCAPS_BLTSTRETCH 0x00000200
+#define WINEDDCAPS_GDI 0x00000400
+#define WINEDDCAPS_OVERLAY 0x00000800
+#define WINEDDCAPS_OVERLAYCANTCLIP 0x00001000
+#define WINEDDCAPS_OVERLAYFOURCC 0x00002000
+#define WINEDDCAPS_OVERLAYSTRETCH 0x00004000
+#define WINEDDCAPS_PALETTE 0x00008000
+#define WINEDDCAPS_PALETTEVSYNC 0x00010000
+#define WINEDDCAPS_READSCANLINE 0x00020000
+#define WINEDDCAPS_STEREOVIEW 0x00040000
+#define WINEDDCAPS_VBI 0x00080000
+#define WINEDDCAPS_ZBLTS 0x00100000
+#define WINEDDCAPS_ZOVERLAYS 0x00200000
+#define WINEDDCAPS_COLORKEY 0x00400000
+#define WINEDDCAPS_ALPHA 0x00800000
+#define WINEDDCAPS_COLORKEYHWASSIST 0x01000000
+#define WINEDDCAPS_NOHARDWARE 0x02000000
+#define WINEDDCAPS_BLTCOLORFILL 0x04000000
+#define WINEDDCAPS_BANKSWITCHED 0x08000000
+#define WINEDDCAPS_BLTDEPTHFILL 0x10000000
+#define WINEDDCAPS_CANCLIP 0x20000000
+#define WINEDDCAPS_CANCLIPSTRETCHED 0x40000000
+#define WINEDDCAPS_CANBLTSYSMEM 0x80000000
+
+#define WINEDDCAPS2_CERTIFIED 0x00000001
+#define WINEDDCAPS2_NO2DDURING3DSCENE 0x00000002
+#define WINEDDCAPS2_VIDEOPORT 0x00000004
+#define WINEDDCAPS2_AUTOFLIPOVERLAY 0x00000008
+#define WINEDDCAPS2_CANBOBINTERLEAVED 0x00000010
+#define WINEDDCAPS2_CANBOBNONINTERLEAVED 0x00000020
+#define WINEDDCAPS2_COLORCONTROLOVERLAY 0x00000040
+#define WINEDDCAPS2_COLORCONTROLPRIMARY 0x00000080
+#define WINEDDCAPS2_CANDROPZ16BIT 0x00000100
+#define WINEDDCAPS2_NONLOCALVIDMEM 0x00000200
+#define WINEDDCAPS2_NONLOCALVIDMEMCAPS 0x00000400
+#define WINEDDCAPS2_NOPAGELOCKREQUIRED 0x00000800
+#define WINEDDCAPS2_WIDESURFACES 0x00001000
+#define WINEDDCAPS2_CANFLIPODDEVEN 0x00002000
+#define WINEDDCAPS2_CANBOBHARDWARE 0x00004000
+#define WINEDDCAPS2_COPYFOURCC 0x00008000
+#define WINEDDCAPS2_PRIMARYGAMMA 0x00020000
+#define WINEDDCAPS2_CANRENDERWINDOWED 0x00080000
+#define WINEDDCAPS2_CANCALIBRATEGAMMA 0x00100000
+#define WINEDDCAPS2_FLIPINTERVAL 0x00200000
+#define WINEDDCAPS2_FLIPNOVSYNC 0x00400000
+#define WINEDDCAPS2_CANMANAGETEXTURE 0x00800000
+#define WINEDDCAPS2_TEXMANINNONLOCALVIDMEM 0x01000000
+#define WINEDDCAPS2_STEREO 0x02000000
+#define WINEDDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL 0x04000000
+
+/* DDCAPS.d */
+#define WINEDDPCAPS_4BIT 0x00000001
+#define WINEDDPCAPS_8BITENTRIES 0x00000002
+#define WINEDDPCAPS_8BIT 0x00000004
+#define WINEDDPCAPS_INITIALIZE 0x00000008
+#define WINEDDPCAPS_PRIMARYSURFACE 0x00000010
+#define WINEDDPCAPS_PRIMARYSURFACELEFT 0x00000020
+#define WINEDDPCAPS_ALLOW256 0x00000040
+#define WINEDDPCAPS_VSYNC 0x00000080
+#define WINEDDPCAPS_1BIT 0x00000100
+#define WINEDDPCAPS_2BIT 0x00000200
+#define WINEDDPCAPS_ALPHA 0x00000400
+
+typedef struct _WINED3DDISPLAYMODE
+{
+ UINT Width;
+ UINT Height;
+ UINT RefreshRate;
+ enum wined3d_format_id Format;
+} WINED3DDISPLAYMODE;
+
+typedef struct _WINED3DCOLORVALUE
+{
+ float r;
+ float g;
+ float b;
+ float a;
+} WINED3DCOLORVALUE;
+
+typedef struct _WINED3DVECTOR
+{
+ float x;
+ float y;
+ float z;
+} WINED3DVECTOR;
+
+typedef struct _WINED3DMATRIX
+{
+ union
+ {
+ struct
+ {
+ float _11, _12, _13, _14;
+ float _21, _22, _23, _24;
+ float _31, _32, _33, _34;
+ float _41, _42, _43, _44;
+ } DUMMYSTRUCTNAME;
+ float m[4][4];
+ } DUMMYUNIONNAME;
+} WINED3DMATRIX;
+
+typedef struct _WINED3DLIGHT
+{
+ WINED3DLIGHTTYPE Type;
+ WINED3DCOLORVALUE Diffuse;
+ WINED3DCOLORVALUE Specular;
+ WINED3DCOLORVALUE Ambient;
+ WINED3DVECTOR Position;
+ WINED3DVECTOR Direction;
+ float Range;
+ float Falloff;
+ float Attenuation0;
+ float Attenuation1;
+ float Attenuation2;
+ float Theta;
+ float Phi;
+} WINED3DLIGHT;
+
+typedef struct _WINED3DMATERIAL
+{
+ WINED3DCOLORVALUE Diffuse;
+ WINED3DCOLORVALUE Ambient;
+ WINED3DCOLORVALUE Specular;
+ WINED3DCOLORVALUE Emissive;
+ float Power;
+} WINED3DMATERIAL;
+
+typedef struct _WINED3DVIEWPORT
+{
+ DWORD X;
+ DWORD Y;
+ DWORD Width;
+ DWORD Height;
+ float MinZ;
+ float MaxZ;
+} WINED3DVIEWPORT;
+
+typedef struct _WINED3DGAMMARAMP
+{
+ WORD red[256];
+ WORD green[256];
+ WORD blue[256];
+} WINED3DGAMMARAMP;
+
+typedef struct _WINED3DLINEPATTERN
+{
+ WORD wRepeatFactor;
+ WORD wLinePattern;
+} WINED3DLINEPATTERN;
+
+typedef struct _WINEDD3DRECTPATCH_INFO
+{
+ UINT StartVertexOffsetWidth;
+ UINT StartVertexOffsetHeight;
+ UINT Width;
+ UINT Height;
+ UINT Stride;
+ WINED3DBASISTYPE Basis;
+ WINED3DDEGREETYPE Degree;
+} WINED3DRECTPATCH_INFO;
+
+typedef struct _WINED3DTRIPATCH_INFO
+{
+ UINT StartVertexOffset;
+ UINT NumVertices;
+ WINED3DBASISTYPE Basis;
+ WINED3DDEGREETYPE Degree;
+} WINED3DTRIPATCH_INFO;
+
+typedef struct _WINED3DADAPTER_IDENTIFIER
+{
+ char *driver;
+ UINT driver_size;
+ char *description;
+ UINT description_size;
+ char *device_name;
+ UINT device_name_size;
+ LARGE_INTEGER driver_version;
+ DWORD vendor_id;
+ DWORD device_id;
+ DWORD subsystem_id;
+ DWORD revision;
+ GUID device_identifier;
+ DWORD whql_level;
+ LUID adapter_luid;
+ SIZE_T video_memory;
+} WINED3DADAPTER_IDENTIFIER;
+
+typedef struct _WINED3DPRESENT_PARAMETERS
+{
+ UINT BackBufferWidth;
+ UINT BackBufferHeight;
+ enum wined3d_format_id BackBufferFormat;
+ UINT BackBufferCount;
+ WINED3DMULTISAMPLE_TYPE MultiSampleType;
+ DWORD MultiSampleQuality;
+ WINED3DSWAPEFFECT SwapEffect;
+ HWND hDeviceWindow;
+ BOOL Windowed;
+ BOOL EnableAutoDepthStencil;
+ enum wined3d_format_id AutoDepthStencilFormat;
+ DWORD Flags;
+ UINT FullScreen_RefreshRateInHz;
+ UINT PresentationInterval;
+ BOOL AutoRestoreDisplayMode;
+} WINED3DPRESENT_PARAMETERS;
+
+struct wined3d_resource_desc
+{
+ WINED3DRESOURCETYPE resource_type;
+ enum wined3d_format_id format;
+ WINED3DMULTISAMPLE_TYPE multisample_type;
+ UINT multisample_quality;
+ DWORD usage;
+ WINED3DPOOL pool;
+ UINT width;
+ UINT height;
+ UINT depth;
+ UINT size;
+};
+
+typedef struct _WINED3DCLIPSTATUS
+{
+ DWORD ClipUnion;
+ DWORD ClipIntersection;
+} WINED3DCLIPSTATUS;
+
+typedef struct _WINED3DVERTEXELEMENT
+{
+ enum wined3d_format_id format;
+ WORD input_slot;
+ WORD offset;
+ UINT output_slot; /* D3D 8 & 10 */
+ BYTE method;
+ BYTE usage;
+ BYTE usage_idx;
+} WINED3DVERTEXELEMENT;
+
+typedef struct _WINED3DDEVICE_CREATION_PARAMETERS
+{
+ UINT AdapterOrdinal;
+ WINED3DDEVTYPE DeviceType;
+ HWND hFocusWindow;
+ DWORD BehaviorFlags;
+} WINED3DDEVICE_CREATION_PARAMETERS;
+
+typedef struct _WINED3DDEVINFO_BANDWIDTHTIMINGS
+{
+ float MaxBandwidthUtilized;
+ float FrontEndUploadMemoryUtilizedPercent;
+ float VertexRateUtilizedPercent;
+ float TriangleSetupRateUtilizedPercent;
+ float FillRateUtilizedPercent;
+} WINED3DDEVINFO_BANDWIDTHTIMINGS;
+
+typedef struct _WINED3DDEVINFO_CACHEUTILIZATION
+{
+ float TextureCacheHitRate;
+ float PostTransformVertexCacheHitRate;
+} WINED3DDEVINFO_CACHEUTILIZATION;
+
+typedef struct _WINED3DDEVINFO_INTERFACETIMINGS
+{
+ float WaitingForGPUToUseApplicationResourceTimePercent;
+ float WaitingForGPUToAcceptMoreCommandsTimePercent;
+ float WaitingForGPUToStayWithinLatencyTimePercent;
+ float WaitingForGPUExclusiveResourceTimePercent;
+ float WaitingForGPUOtherTimePercent;
+} WINED3DDEVINFO_INTERFACETIMINGS;
+
+typedef struct _WINED3DDEVINFO_PIPELINETIMINGS
+{
+ float VertexProcessingTimePercent;
+ float PixelProcessingTimePercent;
+ float OtherGPUProcessingTimePercent;
+ float GPUIdleTimePercent;
+} WINED3DDEVINFO_PIPELINETIMINGS;
+
+typedef struct _WINED3DDEVINFO_STAGETIMINGS
+{
+ float MemoryProcessingPercent;
+ float ComputationProcessingPercent;
+} WINED3DDEVINFO_STAGETIMINGS;
+
+typedef struct _WINED3DRASTER_STATUS
+{
+ BOOL InVBlank;
+ UINT ScanLine;
+} WINED3DRASTER_STATUS;
+
+typedef struct WINED3DRESOURCESTATS
+{
+ BOOL bThrashing;
+ DWORD ApproxBytesDownloaded;
+ DWORD NumEvicts;
+ DWORD NumVidCreates;
+ DWORD LastPri;
+ DWORD NumUsed;
+ DWORD NumUsedInVidMem;
+ DWORD WorkingSet;
+ DWORD WorkingSetBytes;
+ DWORD TotalManaged;
+ DWORD TotalBytes;
+} WINED3DRESOURCESTATS;
+
+typedef struct _WINED3DDEVINFO_RESOURCEMANAGER
+{
+ WINED3DRESOURCESTATS stats[WINED3DRTYPECOUNT];
+} WINED3DDEVINFO_RESOURCEMANAGER;
+
+typedef struct _WINED3DDEVINFO_VERTEXSTATS
+{
+ DWORD NumRenderedTriangles;
+ DWORD NumExtraClippingTriangles;
+} WINED3DDEVINFO_VERTEXSTATS;
+
+typedef struct _WINED3DLOCKED_RECT
+{
+ INT Pitch;
+ void *pBits;
+} WINED3DLOCKED_RECT;
+
+typedef struct _WINED3DLOCKED_BOX
+{
+ INT RowPitch;
+ INT SlicePitch;
+ void *pBits;
+} WINED3DLOCKED_BOX;
+
+typedef struct _WINED3DBOX
+{
+ UINT Left;
+ UINT Top;
+ UINT Right;
+ UINT Bottom;
+ UINT Front;
+ UINT Back;
+} WINED3DBOX;
+
+/*Vertex cache optimization hints.*/
+typedef struct WINED3DDEVINFO_VCACHE
+{
+ DWORD Pattern; /* Must be a 4 char code FOURCC (e.g. CACH) */
+ DWORD OptMethod; /* 0 to get the longest strips, 1 vertex cache */
+ DWORD CacheSize; /* Cache size to use (only valid if OptMethod==1) */
+ DWORD MagicNumber; /* Internal for deciding when to restart strips,
+ non user modifiable (only valid if OptMethod==1) */
+} WINED3DDEVINFO_VCACHE;
+
+typedef struct WineDirect3DStridedData
+{
+ enum wined3d_format_id format; /* Format of the data */
+ const BYTE *lpData; /* Pointer to start of data */
+ DWORD dwStride; /* Stride between occurrences of this data */
+} WineDirect3DStridedData;
+
+typedef struct WineDirect3DVertexStridedData
+{
+ WineDirect3DStridedData position;
+ WineDirect3DStridedData normal;
+ WineDirect3DStridedData diffuse;
+ WineDirect3DStridedData specular;
+ WineDirect3DStridedData texCoords[WINED3DDP_MAXTEXCOORD];
+ BOOL position_transformed;
+} WineDirect3DVertexStridedData;
+
+typedef struct _WINED3DVSHADERCAPS2_0
+{
+ DWORD Caps;
+ INT DynamicFlowControlDepth;
+ INT NumTemps;
+ INT StaticFlowControlDepth;
+} WINED3DVSHADERCAPS2_0;
+
+typedef struct _WINED3DPSHADERCAPS2_0
+{
+ DWORD Caps;
+ INT DynamicFlowControlDepth;
+ INT NumTemps;
+ INT StaticFlowControlDepth;
+ INT NumInstructionSlots;
+} WINED3DPSHADERCAPS2_0;
+
+typedef struct _WINEDDCAPS
+{
+ DWORD Caps;
+ DWORD Caps2;
+ DWORD CKeyCaps;
+ DWORD FXCaps;
+ DWORD FXAlphaCaps;
+ DWORD PalCaps;
+ DWORD SVCaps;
+ DWORD SVBCaps;
+ DWORD SVBCKeyCaps;
+ DWORD SVBFXCaps;
+ DWORD VSBCaps;
+ DWORD VSBCKeyCaps;
+ DWORD VSBFXCaps;
+ DWORD SSBCaps;
+ DWORD SSBCKeyCaps;
+ DWORD SSBFXCaps;
+ DWORD ddsCaps;
+ DWORD StrideAlign;
+} WINEDDCAPS;
+
+typedef struct _WINED3DCAPS
+{
+ WINED3DDEVTYPE DeviceType;
+ UINT AdapterOrdinal;
+
+ DWORD Caps;
+ DWORD Caps2;
+ DWORD Caps3;
+ DWORD PresentationIntervals;
+
+ DWORD CursorCaps;
+ DWORD DevCaps;
+ DWORD PrimitiveMiscCaps;
+ DWORD RasterCaps;
+ DWORD ZCmpCaps;
+ DWORD SrcBlendCaps;
+ DWORD DestBlendCaps;
+ DWORD AlphaCmpCaps;
+ DWORD ShadeCaps;
+ DWORD TextureCaps;
+ DWORD TextureFilterCaps;
+ DWORD CubeTextureFilterCaps;
+ DWORD VolumeTextureFilterCaps;
+ DWORD TextureAddressCaps;
+ DWORD VolumeTextureAddressCaps;
+ DWORD LineCaps;
+
+ DWORD MaxTextureWidth;
+ DWORD MaxTextureHeight;
+ DWORD MaxVolumeExtent;
+ DWORD MaxTextureRepeat;
+ DWORD MaxTextureAspectRatio;
+ DWORD MaxAnisotropy;
+ float MaxVertexW;
+
+ float GuardBandLeft;
+ float GuardBandTop;
+ float GuardBandRight;
+ float GuardBandBottom;
+
+ float ExtentsAdjust;
+ DWORD StencilCaps;
+
+ DWORD FVFCaps;
+ DWORD TextureOpCaps;
+ DWORD MaxTextureBlendStages;
+ DWORD MaxSimultaneousTextures;
+
+ DWORD VertexProcessingCaps;
+ DWORD MaxActiveLights;
+ DWORD MaxUserClipPlanes;
+ DWORD MaxVertexBlendMatrices;
+ DWORD MaxVertexBlendMatrixIndex;
+
+ float MaxPointSize;
+
+ DWORD MaxPrimitiveCount;
+ DWORD MaxVertexIndex;
+ DWORD MaxStreams;
+ DWORD MaxStreamStride;
+
+ DWORD VertexShaderVersion;
+ DWORD MaxVertexShaderConst;
+
+ DWORD PixelShaderVersion;
+ float PixelShader1xMaxValue;
+
+ /* DX 9 */
+ DWORD DevCaps2;
+
+ float MaxNpatchTessellationLevel;
+ DWORD Reserved5; /* undocumented */
+
+ UINT MasterAdapterOrdinal;
+ UINT AdapterOrdinalInGroup;
+ UINT NumberOfAdaptersInGroup;
+ DWORD DeclTypes;
+ DWORD NumSimultaneousRTs;
+ DWORD StretchRectFilterCaps;
+ WINED3DVSHADERCAPS2_0 VS20Caps;
+ WINED3DPSHADERCAPS2_0 PS20Caps;
+ DWORD VertexTextureFilterCaps;
+ DWORD MaxVShaderInstructionsExecuted;
+ DWORD MaxPShaderInstructionsExecuted;
+ DWORD MaxVertexShader30InstructionSlots;
+ DWORD MaxPixelShader30InstructionSlots;
+ DWORD Reserved2; /* Not in the microsoft headers but documented */
+ DWORD Reserved3;
+
+ WINEDDCAPS DirectDrawCaps;
+} WINED3DCAPS;
+
+/* DirectDraw types */
+
+typedef struct _WINEDDCOLORKEY
+{
+ DWORD dwColorSpaceLowValue; /* low boundary of color space that is to
+ * be treated as Color Key, inclusive */
+ DWORD dwColorSpaceHighValue; /* high boundary of color space that is
+ * to be treated as Color Key, inclusive */
+} WINEDDCOLORKEY,*LPWINEDDCOLORKEY;
+
+typedef struct _WINEDDBLTFX
+{
+ DWORD dwSize; /* size of structure */
+ DWORD dwDDFX; /* FX operations */
+ DWORD dwROP; /* Win32 raster operations */
+ DWORD dwDDROP; /* Raster operations new for DirectDraw */
+ DWORD dwRotationAngle; /* Rotation angle for blt */
+ DWORD dwZBufferOpCode; /* ZBuffer compares */
+ DWORD dwZBufferLow; /* Low limit of Z buffer */
+ DWORD dwZBufferHigh; /* High limit of Z buffer */
+ DWORD dwZBufferBaseDest; /* Destination base value */
+ DWORD dwZDestConstBitDepth; /* Bit depth used to specify Z constant for destination */
+ union
+ {
+ DWORD dwZDestConst; /* Constant to use as Z buffer for dest */
+ struct wined3d_surface *lpDDSZBufferDest; /* Surface to use as Z buffer for dest */
+ } DUMMYUNIONNAME1;
+ DWORD dwZSrcConstBitDepth; /* Bit depth used to specify Z constant for source */
+ union
+ {
+ DWORD dwZSrcConst; /* Constant to use as Z buffer for src */
+ struct wined3d_surface *lpDDSZBufferSrc; /* Surface to use as Z buffer for src */
+ } DUMMYUNIONNAME2;
+ DWORD dwAlphaEdgeBlendBitDepth; /* Bit depth used to specify constant for alpha edge blend */
+ DWORD dwAlphaEdgeBlend; /* Alpha for edge blending */
+ DWORD dwReserved;
+ DWORD dwAlphaDestConstBitDepth; /* Bit depth used to specify alpha constant for destination */
+ union
+ {
+ DWORD dwAlphaDestConst; /* Constant to use as Alpha Channel */
+ struct wined3d_surface *lpDDSAlphaDest; /* Surface to use as Alpha Channel */
+ } DUMMYUNIONNAME3;
+ DWORD dwAlphaSrcConstBitDepth; /* Bit depth used to specify alpha constant for source */
+ union
+ {
+ DWORD dwAlphaSrcConst; /* Constant to use as Alpha Channel */
+ struct wined3d_surface *lpDDSAlphaSrc; /* Surface to use as Alpha Channel */
+ } DUMMYUNIONNAME4;
+ union
+ {
+ DWORD dwFillColor; /* color in RGB or Palettized */
+ DWORD dwFillDepth; /* depth value for z-buffer */
+ DWORD dwFillPixel; /* pixel val for RGBA or RGBZ */
+ struct wined3d_surface *lpDDSPattern; /* Surface to use as pattern */
+ } DUMMYUNIONNAME5;
+ WINEDDCOLORKEY ddckDestColorkey; /* DestColorkey override */
+ WINEDDCOLORKEY ddckSrcColorkey; /* SrcColorkey override */
+} WINEDDBLTFX,*LPWINEDDBLTFX;
+
+typedef struct _WINEDDOVERLAYFX
+{
+ DWORD dwSize; /* size of structure */
+ DWORD dwAlphaEdgeBlendBitDepth; /* Bit depth used to specify constant for alpha edge blend */
+ DWORD dwAlphaEdgeBlend; /* Constant to use as alpha for edge blend */
+ DWORD dwReserved;
+ DWORD dwAlphaDestConstBitDepth; /* Bit depth used to specify alpha constant for destination */
+ union
+ {
+ DWORD dwAlphaDestConst; /* Constant to use as alpha channel for dest */
+ struct wined3d_surface *lpDDSAlphaDest; /* Surface to use as alpha channel for dest */
+ } DUMMYUNIONNAME1;
+ DWORD dwAlphaSrcConstBitDepth; /* Bit depth used to specify alpha constant for source */
+ union
+ {
+ DWORD dwAlphaSrcConst; /* Constant to use as alpha channel for src */
+ struct wined3d_surface *lpDDSAlphaSrc; /* Surface to use as alpha channel for src */
+ } DUMMYUNIONNAME2;
+ WINEDDCOLORKEY dckDestColorkey; /* DestColorkey override */
+ WINEDDCOLORKEY dckSrcColorkey; /* SrcColorkey override */
+ DWORD dwDDFX; /* Overlay FX */
+ DWORD dwFlags; /* flags */
+} WINEDDOVERLAYFX;
+
+struct wined3d_buffer_desc
+{
+ UINT byte_width;
+ DWORD usage;
+ UINT bind_flags;
+ UINT cpu_access_flags;
+ UINT misc_flags;
+};
+
+struct wined3d_shader_signature_element
+{
+ const char *semantic_name;
+ UINT semantic_idx;
+ enum wined3d_sysval_semantic sysval_semantic;
+ DWORD component_type;
+ UINT register_idx;
+ DWORD mask;
+};
+
+struct wined3d_shader_signature
+{
+ UINT element_count;
+ struct wined3d_shader_signature_element *elements;
+ char *string_data;
+};
+
+struct wined3d_parent_ops
+{
+ void (__stdcall *wined3d_object_destroyed)(void *parent);
+};
+
+struct wined3d;
+struct wined3d_buffer;
+struct wined3d_clipper;
+struct wined3d_device;
+struct wined3d_palette;
+struct wined3d_query;
+struct wined3d_rendertarget_view;
+struct wined3d_resource;
+struct wined3d_shader;
+struct wined3d_stateblock;
+struct wined3d_surface;
+struct wined3d_swapchain;
+struct wined3d_texture;
+struct wined3d_vertex_declaration;
+struct wined3d_volume;
+
+struct wined3d_device_parent
+{
+ const struct wined3d_device_parent_ops *ops;
+};
+
+struct wined3d_device_parent_ops
+{
+ void (__cdecl *wined3d_device_created)(struct wined3d_device_parent *device_parent, struct wined3d_device *device);
+ HRESULT (__cdecl *create_surface)(struct wined3d_device_parent *device_parent, void *container_parent,
+ UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage, WINED3DPOOL pool,
+ UINT level, WINED3DCUBEMAP_FACES face, struct wined3d_surface **surface);
+ HRESULT (__cdecl *create_rendertarget)(struct wined3d_device_parent *device_parent, void *container_parent,
+ UINT width, UINT height, enum wined3d_format_id format_id, WINED3DMULTISAMPLE_TYPE multisample_type,
+ DWORD multisample_quality, BOOL lockable, struct wined3d_surface **surface);
+ HRESULT (__cdecl *create_depth_stencil)(struct wined3d_device_parent *device_parent,
+ UINT width, UINT height, enum wined3d_format_id format_id, WINED3DMULTISAMPLE_TYPE multisample_type,
+ DWORD multisample_quality, BOOL discard, struct wined3d_surface **surface);
+ HRESULT (__cdecl *create_volume)(struct wined3d_device_parent *device_parent, void *container_parent,
+ UINT width, UINT height, UINT depth, enum wined3d_format_id format_id, WINED3DPOOL pool, DWORD usage,
+ struct wined3d_volume **volume);
+ HRESULT (__cdecl *create_swapchain)(struct wined3d_device_parent *device_parent,
+ WINED3DPRESENT_PARAMETERS *present_parameters, struct wined3d_swapchain **swapchain);
+};
+
+typedef HRESULT (__stdcall *D3DCB_ENUMRESOURCES)(struct wined3d_resource *resource, void *pData);
+
+void __stdcall wined3d_mutex_lock(void);
+void __stdcall wined3d_mutex_unlock(void);
+
+HRESULT __cdecl wined3d_check_depth_stencil_match(const struct wined3d *wined3d, UINT adapter_idx,
+ WINED3DDEVTYPE device_type, enum wined3d_format_id adapter_format_id,
+ enum wined3d_format_id render_target_format_id, enum wined3d_format_id depth_stencil_format_id);
+HRESULT __cdecl wined3d_check_device_format(const struct wined3d *wined3d, UINT adaper_idx,
+ WINED3DDEVTYPE device_type, enum wined3d_format_id adapter_format_id, DWORD usage,
+ WINED3DRESOURCETYPE resource_type, enum wined3d_format_id check_format_id,
+ WINED3DSURFTYPE surface_type);
+HRESULT __cdecl wined3d_check_device_format_conversion(const struct wined3d *wined3d, UINT adapter_idx,
+ WINED3DDEVTYPE device_type, enum wined3d_format_id source_format_id,
+ enum wined3d_format_id target_format_id);
+HRESULT __cdecl wined3d_check_device_multisample_type(const struct wined3d *wined3d, UINT adapter_idx,
+ WINED3DDEVTYPE device_type, enum wined3d_format_id surface_format_id, BOOL windowed,
+ WINED3DMULTISAMPLE_TYPE multisample_type, DWORD *quality_levels);
+HRESULT __cdecl wined3d_check_device_type(const struct wined3d *wined3d, UINT adapter_idx,
+ WINED3DDEVTYPE device_type, enum wined3d_format_id display_format_id,
+ enum wined3d_format_id backbuffer_format_id, BOOL windowed);
+struct wined3d * __cdecl wined3d_create(UINT dxVersion, void *parent);
+ULONG __cdecl wined3d_decref(struct wined3d *wined3d);
+HRESULT __cdecl wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT adapter_idx,
+ enum wined3d_format_id format_id, UINT mode_idx, WINED3DDISPLAYMODE *mode);
+UINT __cdecl wined3d_get_adapter_count(const struct wined3d *wined3d);
+HRESULT __cdecl wined3d_get_adapter_display_mode(const struct wined3d *wined3d, UINT adapter_idx,
+ WINED3DDISPLAYMODE *mode);
+HRESULT __cdecl wined3d_get_adapter_identifier(const struct wined3d *wined3d, UINT adapter_idx,
+ DWORD flags, WINED3DADAPTER_IDENTIFIER *identifier);
+UINT __cdecl wined3d_get_adapter_mode_count(const struct wined3d *wined3d,
+ UINT adapter_idx, enum wined3d_format_id format_id);
+HMONITOR __cdecl wined3d_get_adapter_monitor(const struct wined3d *wined3d, UINT adapter_idx);
+HRESULT __cdecl wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapter_idx,
+ WINED3DDEVTYPE device_type, WINED3DCAPS *caps);
+void * __cdecl wined3d_get_parent(const struct wined3d *wined3d);
+ULONG __cdecl wined3d_incref(struct wined3d *wined3d);
+HRESULT __cdecl wined3d_register_software_device(struct wined3d *wined3d, void *init_function);
+
+HRESULT __cdecl wined3d_buffer_create(struct wined3d_device *device, struct wined3d_buffer_desc *desc,
+ const void *data, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer);
+HRESULT __cdecl wined3d_buffer_create_ib(struct wined3d_device *device, UINT length, DWORD usage, WINED3DPOOL pool,
+ void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer);
+HRESULT __cdecl wined3d_buffer_create_vb(struct wined3d_device *device, UINT length, DWORD usage, WINED3DPOOL pool,
+ void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer);
+ULONG __cdecl wined3d_buffer_decref(struct wined3d_buffer *buffer);
+HRESULT __cdecl wined3d_buffer_free_private_data(struct wined3d_buffer *buffer, REFGUID guid);
+void * __cdecl wined3d_buffer_get_parent(const struct wined3d_buffer *buffer);
+DWORD __cdecl wined3d_buffer_get_priority(const struct wined3d_buffer *buffer);
+HRESULT __cdecl wined3d_buffer_get_private_data(const struct wined3d_buffer *buffer,
+ REFGUID guid, void *data, DWORD *data_size);
+struct wined3d_resource * __cdecl wined3d_buffer_get_resource(struct wined3d_buffer *buffer);
+ULONG __cdecl wined3d_buffer_incref(struct wined3d_buffer *buffer);
+HRESULT __cdecl wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UINT size, BYTE **data, DWORD flags);
+void __cdecl wined3d_buffer_preload(struct wined3d_buffer *buffer);
+DWORD __cdecl wined3d_buffer_set_priority(struct wined3d_buffer *buffer, DWORD new_priority);
+HRESULT __cdecl wined3d_buffer_set_private_data(struct wined3d_buffer *buffer,
+ REFGUID guid, const void *data, DWORD data_size, DWORD flags);
+void __cdecl wined3d_buffer_unmap(struct wined3d_buffer *buffer);
+
+struct wined3d_clipper * __cdecl wined3d_clipper_create(void);
+ULONG __cdecl wined3d_clipper_decref(struct wined3d_clipper *clipper);
+HRESULT __cdecl wined3d_clipper_get_clip_list(const struct wined3d_clipper *clipper,
+ const RECT *rect, RGNDATA *clip_list, DWORD *clip_list_size);
+HRESULT __cdecl wined3d_clipper_get_window(const struct wined3d_clipper *clipper, HWND *hwnd);
+ULONG __cdecl wined3d_clipper_incref(struct wined3d_clipper *clipper);
+HRESULT __cdecl wined3d_clipper_is_clip_list_changed(const struct wined3d_clipper *clipper, BOOL *changed);
+HRESULT __cdecl wined3d_clipper_set_clip_list(struct wined3d_clipper *clipper, const RGNDATA *clip_list, DWORD flags);
+HRESULT __cdecl wined3d_clipper_set_window(struct wined3d_clipper *clipper, DWORD flags, HWND hwnd);
+
+HRESULT __cdecl wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window);
+HRESULT __cdecl wined3d_device_begin_scene(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_begin_stateblock(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_clear(struct wined3d_device *device, DWORD rect_count, const RECT *rects, DWORD flags,
+ WINED3DCOLOR color, float z, DWORD stencil);
+void __cdecl wined3d_device_clear_rendertarget_view(struct wined3d_device *device,
+ struct wined3d_rendertarget_view *rendertarget_view, const WINED3DCOLORVALUE *color);
+HRESULT __cdecl wined3d_device_color_fill(struct wined3d_device *device, struct wined3d_surface *surface,
+ const RECT *rect, const WINED3DCOLORVALUE *color);
+HRESULT __cdecl wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx,
+ WINED3DDEVTYPE device_type, HWND focus_window, DWORD behaviour_flags,
+ struct wined3d_device_parent *device_parent, struct wined3d_device **device);
+ULONG __cdecl wined3d_device_decref(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_delete_patch(struct wined3d_device *device, UINT handle);
+HRESULT __cdecl wined3d_device_draw_indexed_primitive(struct wined3d_device *device, UINT start_idx, UINT index_count);
+HRESULT __cdecl wined3d_device_draw_indexed_primitive_strided(struct wined3d_device *device, UINT index_count,
+ const WineDirect3DVertexStridedData *strided_data, UINT vertex_count, const void *index_data,
+ enum wined3d_format_id index_data_format_id);
+HRESULT __cdecl wined3d_device_draw_indexed_primitive_up(struct wined3d_device *device,
+ UINT index_count, const void *index_data, enum wined3d_format_id index_data_format_id,
+ const void *stream_data, UINT stream_stride);
+HRESULT __cdecl wined3d_device_draw_primitive(struct wined3d_device *device, UINT start_vertex, UINT vertex_count);
+HRESULT __cdecl wined3d_device_draw_primitive_strided(struct wined3d_device *device,
+ UINT vertex_count, const WineDirect3DVertexStridedData *strided_data);
+HRESULT __cdecl wined3d_device_draw_primitive_up(struct wined3d_device *device,
+ UINT vertex_count, const void *stream_data, UINT stream_stride);
+HRESULT __cdecl wined3d_device_draw_rect_patch(struct wined3d_device *device, UINT handle,
+ const float *num_segs, const WINED3DRECTPATCH_INFO *rect_patch_info);
+HRESULT __cdecl wined3d_device_draw_tri_patch(struct wined3d_device *device, UINT handle,
+ const float *num_segs, const WINED3DTRIPATCH_INFO *tri_patch_info);
+HRESULT __cdecl wined3d_device_end_scene(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_end_stateblock(struct wined3d_device *device, struct wined3d_stateblock **stateblock);
+HRESULT __cdecl wined3d_device_enum_resources(struct wined3d_device *device, D3DCB_ENUMRESOURCES callback, void *data);
+HRESULT __cdecl wined3d_device_evict_managed_resources(struct wined3d_device *device);
+UINT __cdecl wined3d_device_get_available_texture_mem(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_get_back_buffer(struct wined3d_device *device, UINT swapchain_idx,
+ UINT backbuffer_idx, WINED3DBACKBUFFER_TYPE backbuffer_type, struct wined3d_surface **backbuffer);
+INT __cdecl wined3d_device_get_base_vertex_index(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_get_clip_plane(struct wined3d_device *device, UINT plane_idx, float *plane);
+HRESULT __cdecl wined3d_device_get_clip_status(struct wined3d_device *device, WINED3DCLIPSTATUS *clip_status);
+HRESULT __cdecl wined3d_device_get_creation_parameters(struct wined3d_device *device,
+ WINED3DDEVICE_CREATION_PARAMETERS *creation_parameters);
+HRESULT __cdecl wined3d_device_get_current_texture_palette(struct wined3d_device *device, UINT *palette_idx);
+HRESULT __cdecl wined3d_device_get_depth_stencil(struct wined3d_device *device,
+ struct wined3d_surface **depth_stencil);
+HRESULT __cdecl wined3d_device_get_device_caps(struct wined3d_device *device, WINED3DCAPS *caps);
+HRESULT __cdecl wined3d_device_get_display_mode(struct wined3d_device *device,
+ UINT swapchain_idx, WINED3DDISPLAYMODE *mode);
+HRESULT __cdecl wined3d_device_get_front_buffer_data(struct wined3d_device *device,
+ UINT swapchain_idx, struct wined3d_surface *dst_surface);
+void __cdecl wined3d_device_get_gamma_ramp(struct wined3d_device *device, UINT swapchain_idx, WINED3DGAMMARAMP *ramp);
+HRESULT __cdecl wined3d_device_get_index_buffer(struct wined3d_device *device, struct wined3d_buffer **index_buffer);
+HRESULT __cdecl wined3d_device_get_light(struct wined3d_device *device, UINT light_idx, WINED3DLIGHT *light);
+HRESULT __cdecl wined3d_device_get_light_enable(struct wined3d_device *device, UINT light_idx, BOOL *enable);
+HRESULT __cdecl wined3d_device_get_material(struct wined3d_device *device, WINED3DMATERIAL *material);
+float __cdecl wined3d_device_get_npatch_mode(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_get_palette_entries(struct wined3d_device *device,
+ UINT palette_idx, PALETTEENTRY *entries);
+struct wined3d_shader * __cdecl wined3d_device_get_pixel_shader(struct wined3d_device *device);
+void __cdecl wined3d_device_get_primitive_type(struct wined3d_device *device, WINED3DPRIMITIVETYPE *primitive_topology);
+HRESULT __cdecl wined3d_device_get_ps_consts_b(struct wined3d_device *device,
+ UINT start_register, BOOL *constants, UINT bool_count);
+HRESULT __cdecl wined3d_device_get_ps_consts_f(struct wined3d_device *device,
+ UINT start_register, float *constants, UINT vector4f_count);
+HRESULT __cdecl wined3d_device_get_ps_consts_i(struct wined3d_device *device,
+ UINT start_register, int *constants, UINT vector4i_count);
+HRESULT __cdecl wined3d_device_get_raster_status(struct wined3d_device *device,
+ UINT swapchain_idx, WINED3DRASTER_STATUS *raster_status);
+HRESULT __cdecl wined3d_device_get_render_state(struct wined3d_device *device,
+ WINED3DRENDERSTATETYPE state, DWORD *value);
+HRESULT __cdecl wined3d_device_get_render_target(struct wined3d_device *device,
+ UINT render_target_idx, struct wined3d_surface **render_target);
+HRESULT __cdecl wined3d_device_get_sampler_state(struct wined3d_device *device,
+ UINT sampler_idx, WINED3DSAMPLERSTATETYPE state, DWORD *value);
+HRESULT __cdecl wined3d_device_get_scissor_rect(struct wined3d_device *device, RECT *rect);
+BOOL __cdecl wined3d_device_get_software_vertex_processing(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_get_stream_source(struct wined3d_device *device,
+ UINT stream_idx, struct wined3d_buffer **buffer, UINT *offset, UINT *stride);
+HRESULT __cdecl wined3d_device_get_stream_source_freq(struct wined3d_device *device, UINT stream_idx, UINT *divider);
+HRESULT __cdecl wined3d_device_get_surface_from_dc(struct wined3d_device *device,
+ HDC dc, struct wined3d_surface **surface);
+HRESULT __cdecl wined3d_device_get_swapchain(struct wined3d_device *device,
+ UINT swapchain_idx, struct wined3d_swapchain **swapchain);
+UINT __cdecl wined3d_device_get_swapchain_count(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_get_texture(struct wined3d_device *device,
+ UINT stage, struct wined3d_texture **texture);
+HRESULT __cdecl wined3d_device_get_texture_stage_state(struct wined3d_device *device,
+ UINT stage, WINED3DTEXTURESTAGESTATETYPE state, DWORD *value);
+HRESULT __cdecl wined3d_device_get_transform(struct wined3d_device *device,
+ WINED3DTRANSFORMSTATETYPE state, WINED3DMATRIX *matrix);
+HRESULT __cdecl wined3d_device_get_vertex_declaration(struct wined3d_device *device,
+ struct wined3d_vertex_declaration **declaration);
+struct wined3d_shader * __cdecl wined3d_device_get_vertex_shader(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_get_viewport(struct wined3d_device *device, WINED3DVIEWPORT *viewport);
+HRESULT __cdecl wined3d_device_get_vs_consts_b(struct wined3d_device *device,
+ UINT start_register, BOOL *constants, UINT bool_count);
+HRESULT __cdecl wined3d_device_get_vs_consts_f(struct wined3d_device *device,
+ UINT start_register, float *constants, UINT vector4f_count);
+HRESULT __cdecl wined3d_device_get_vs_consts_i(struct wined3d_device *device,
+ UINT start_register, int *constants, UINT vector4i_count);
+HRESULT __cdecl wined3d_device_get_wined3d(struct wined3d_device *device, struct wined3d **d3d);
+ULONG __cdecl wined3d_device_incref(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_init_3d(struct wined3d_device *device, WINED3DPRESENT_PARAMETERS *present_parameters);
+HRESULT __cdecl wined3d_device_init_gdi(struct wined3d_device *device, WINED3DPRESENT_PARAMETERS *present_parameters);
+HRESULT __cdecl wined3d_device_multiply_transform(struct wined3d_device *device,
+ WINED3DTRANSFORMSTATETYPE state, const WINED3DMATRIX *matrix);
+HRESULT __cdecl wined3d_device_present(struct wined3d_device *device, const RECT *src_rect,
+ const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region);
+HRESULT __cdecl wined3d_device_process_vertices(struct wined3d_device *device,
+ UINT src_start_idx, UINT dst_idx, UINT vertex_count, struct wined3d_buffer *dst_buffer,
+ struct wined3d_vertex_declaration *declaration, DWORD flags, DWORD dst_fvf);
+void __cdecl wined3d_device_release_focus_window(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_reset(struct wined3d_device *device, WINED3DPRESENT_PARAMETERS *present_parameters);
+void __cdecl wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window);
+HRESULT __cdecl wined3d_device_set_base_vertex_index(struct wined3d_device *device, INT base_index);
+HRESULT __cdecl wined3d_device_set_clip_plane(struct wined3d_device *device, UINT plane_idx, const float *plane);
+HRESULT __cdecl wined3d_device_set_clip_status(struct wined3d_device *device, const WINED3DCLIPSTATUS *clip_status);
+HRESULT __cdecl wined3d_device_set_current_texture_palette(struct wined3d_device *device, UINT palette_idx);
+void __cdecl wined3d_device_set_cursor_position(struct wined3d_device *device,
+ int x_screen_space, int y_screen_space, DWORD flags);
+HRESULT __cdecl wined3d_device_set_cursor_properties(struct wined3d_device *device,
+ UINT x_hotspot, UINT y_hotspot, struct wined3d_surface *cursor_surface);
+HRESULT __cdecl wined3d_device_set_depth_stencil(struct wined3d_device *device, struct wined3d_surface *depth_stencil);
+HRESULT __cdecl wined3d_device_set_dialog_box_mode(struct wined3d_device *device, BOOL enable_dialogs);
+HRESULT __cdecl wined3d_device_set_display_mode(struct wined3d_device *device,
+ UINT swapchain_idx, const WINED3DDISPLAYMODE *mode);
+void __cdecl wined3d_device_set_gamma_ramp(struct wined3d_device *device,
+ UINT swapchain_idx, DWORD flags, const WINED3DGAMMARAMP *ramp);
+HRESULT __cdecl wined3d_device_set_index_buffer(struct wined3d_device *device,
+ struct wined3d_buffer *index_buffer, enum wined3d_format_id format_id);
+HRESULT __cdecl wined3d_device_set_light(struct wined3d_device *device, UINT light_idx, const WINED3DLIGHT *light);
+HRESULT __cdecl wined3d_device_set_light_enable(struct wined3d_device *device, UINT light_idx, BOOL enable);
+HRESULT __cdecl wined3d_device_set_material(struct wined3d_device *device, const WINED3DMATERIAL *material);
+void __cdecl wined3d_device_set_multithreaded(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_set_npatch_mode(struct wined3d_device *device, float segments);
+HRESULT __cdecl wined3d_device_set_palette_entries(struct wined3d_device *device,
+ UINT palette_idx, const PALETTEENTRY *entries);
+HRESULT __cdecl wined3d_device_set_pixel_shader(struct wined3d_device *device, struct wined3d_shader *shader);
+void __cdecl wined3d_device_set_primitive_type(struct wined3d_device *device, WINED3DPRIMITIVETYPE primitive_topology);
+HRESULT __cdecl wined3d_device_set_ps_consts_b(struct wined3d_device *device,
+ UINT start_register, const BOOL *constants, UINT bool_count);
+HRESULT __cdecl wined3d_device_set_ps_consts_f(struct wined3d_device *device,
+ UINT start_register, const float *constants, UINT vector4f_count);
+HRESULT __cdecl wined3d_device_set_ps_consts_i(struct wined3d_device *device,
+ UINT start_register, const int *constants, UINT vector4i_count);
+HRESULT __cdecl wined3d_device_set_render_state(struct wined3d_device *device,
+ WINED3DRENDERSTATETYPE state, DWORD value);
+HRESULT __cdecl wined3d_device_set_render_target(struct wined3d_device *device,
+ UINT render_target_idx, struct wined3d_surface *render_target, BOOL set_viewport);
+HRESULT __cdecl wined3d_device_set_sampler_state(struct wined3d_device *device,
+ UINT sampler_idx, WINED3DSAMPLERSTATETYPE state, DWORD value);
+HRESULT __cdecl wined3d_device_set_scissor_rect(struct wined3d_device *device, const RECT *rect);
+HRESULT __cdecl wined3d_device_set_software_vertex_processing(struct wined3d_device *device, BOOL software);
+HRESULT __cdecl wined3d_device_set_stream_source(struct wined3d_device *device,
+ UINT stream_idx, struct wined3d_buffer *buffer, UINT offset, UINT stride);
+HRESULT __cdecl wined3d_device_set_stream_source_freq(struct wined3d_device *device, UINT stream_idx, UINT divider);
+HRESULT __cdecl wined3d_device_set_texture(struct wined3d_device *device, UINT stage, struct wined3d_texture *texture);
+HRESULT __cdecl wined3d_device_set_texture_stage_state(struct wined3d_device *device,
+ UINT stage, WINED3DTEXTURESTAGESTATETYPE state, DWORD value);
+HRESULT __cdecl wined3d_device_set_transform(struct wined3d_device *device,
+ WINED3DTRANSFORMSTATETYPE state, const WINED3DMATRIX *matrix);
+HRESULT __cdecl wined3d_device_set_vertex_declaration(struct wined3d_device *device,
+ struct wined3d_vertex_declaration *declaration);
+HRESULT __cdecl wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader);
+HRESULT __cdecl wined3d_device_set_viewport(struct wined3d_device *device, const WINED3DVIEWPORT *viewport);
+HRESULT __cdecl wined3d_device_set_vs_consts_b(struct wined3d_device *device,
+ UINT start_register, const BOOL *constants, UINT bool_count);
+HRESULT __cdecl wined3d_device_set_vs_consts_f(struct wined3d_device *device,
+ UINT start_register, const float *constants, UINT vector4f_count);
+HRESULT __cdecl wined3d_device_set_vs_consts_i(struct wined3d_device *device,
+ UINT start_register, const int *constants, UINT vector4i_count);
+void __cdecl wined3d_device_setup_fullscreen_window(struct wined3d_device *device, HWND window, UINT w, UINT h);
+BOOL __cdecl wined3d_device_show_cursor(struct wined3d_device *device, BOOL show);
+HRESULT __cdecl wined3d_device_uninit_3d(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_uninit_gdi(struct wined3d_device *device);
+HRESULT __cdecl wined3d_device_update_surface(struct wined3d_device *device, struct wined3d_surface *src_surface,
+ const RECT *src_rect, struct wined3d_surface *dst_surface, const POINT *dst_point);
+HRESULT __cdecl wined3d_device_update_texture(struct wined3d_device *device,
+ struct wined3d_texture *src_texture, struct wined3d_texture *dst_texture);
+HRESULT __cdecl wined3d_device_validate_device(struct wined3d_device *device, DWORD *num_passes);
+
+HRESULT __cdecl wined3d_palette_create(struct wined3d_device *device, DWORD flags,
+ const PALETTEENTRY *entries, void *parent, struct wined3d_palette **palette);
+ULONG __cdecl wined3d_palette_decref(struct wined3d_palette *palette);
+HRESULT __cdecl wined3d_palette_get_entries(const struct wined3d_palette *palette,
+ DWORD flags, DWORD start, DWORD count, PALETTEENTRY *entries);
+DWORD __cdecl wined3d_palette_get_flags(const struct wined3d_palette *palette);
+void * __cdecl wined3d_palette_get_parent(const struct wined3d_palette *palette);
+ULONG __cdecl wined3d_palette_incref(struct wined3d_palette *palette);
+HRESULT __cdecl wined3d_palette_set_entries(struct wined3d_palette *palette,
+ DWORD flags, DWORD start, DWORD count, const PALETTEENTRY *entries);
+
+HRESULT __cdecl wined3d_query_create(struct wined3d_device *device,
+ WINED3DQUERYTYPE type, struct wined3d_query **query);
+ULONG __cdecl wined3d_query_decref(struct wined3d_query *query);
+HRESULT __cdecl wined3d_query_get_data(struct wined3d_query *query, void *data, UINT data_size, DWORD flags);
+UINT __cdecl wined3d_query_get_data_size(const struct wined3d_query *query);
+WINED3DQUERYTYPE __cdecl wined3d_query_get_type(const struct wined3d_query *query);
+ULONG __cdecl wined3d_query_incref(struct wined3d_query *query);
+HRESULT __cdecl wined3d_query_issue(struct wined3d_query *query, DWORD flags);
+
+void __cdecl wined3d_resource_get_desc(const struct wined3d_resource *resource,
+ struct wined3d_resource_desc *desc);
+void * __cdecl wined3d_resource_get_parent(const struct wined3d_resource *resource);
+
+HRESULT __cdecl wined3d_rendertarget_view_create(struct wined3d_resource *resource,
+ void *parent, struct wined3d_rendertarget_view **rendertarget_view);
+ULONG __cdecl wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *view);
+void * __cdecl wined3d_rendertarget_view_get_parent(const struct wined3d_rendertarget_view *view);
+struct wined3d_resource * __cdecl wined3d_rendertarget_view_get_resource(const struct wined3d_rendertarget_view *view);
+ULONG __cdecl wined3d_rendertarget_view_incref(struct wined3d_rendertarget_view *view);
+
+HRESULT __cdecl wined3d_shader_create_gs(struct wined3d_device *device, const DWORD *byte_code,
+ const struct wined3d_shader_signature *output_signature, void *parent,
+ const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader);
+HRESULT __cdecl wined3d_shader_create_ps(struct wined3d_device *device, const DWORD *byte_code,
+ const struct wined3d_shader_signature *output_signature, void *parent,
+ const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader);
+HRESULT __cdecl wined3d_shader_create_vs(struct wined3d_device *device, const DWORD *byte_code,
+ const struct wined3d_shader_signature *output_signature, void *parent,
+ const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader);
+ULONG __cdecl wined3d_shader_decref(struct wined3d_shader *shader);
+HRESULT __cdecl wined3d_shader_get_byte_code(const struct wined3d_shader *shader,
+ void *byte_code, UINT *byte_code_size);
+void * __cdecl wined3d_shader_get_parent(const struct wined3d_shader *shader);
+ULONG __cdecl wined3d_shader_incref(struct wined3d_shader *shader);
+HRESULT __cdecl wined3d_shader_set_local_constants_float(struct wined3d_shader *shader,
+ UINT start_idx, const float *src_data, UINT vector4f_count);
+
+HRESULT __cdecl wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock);
+HRESULT __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock);
+HRESULT __cdecl wined3d_stateblock_create(struct wined3d_device *device,
+ WINED3DSTATEBLOCKTYPE type, struct wined3d_stateblock **stateblock);
+ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock);
+ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock);
+
+HRESULT __cdecl wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst_rect,
+ struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
+ const WINEDDBLTFX *blt_fx, WINED3DTEXTUREFILTERTYPE filter);
+HRESULT __cdecl wined3d_surface_bltfast(struct wined3d_surface *dst_surface, DWORD dst_x, DWORD dst_y,
+ struct wined3d_surface *src_surface, const RECT *src_rect, DWORD trans);
+HRESULT __cdecl wined3d_surface_create(struct wined3d_device *device, UINT width, UINT height,
+ enum wined3d_format_id format_id, BOOL lockable, BOOL discard, UINT level, DWORD usage, WINED3DPOOL pool,
+ WINED3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality, WINED3DSURFTYPE surface_type,
+ void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_surface **surface);
+ULONG __cdecl wined3d_surface_decref(struct wined3d_surface *surface);
+HRESULT __cdecl wined3d_surface_flip(struct wined3d_surface *surface, struct wined3d_surface *override, DWORD flags);
+HRESULT __cdecl wined3d_surface_free_private_data(struct wined3d_surface *surface, REFGUID guid);
+HRESULT __cdecl wined3d_surface_get_blt_status(const struct wined3d_surface *surface, DWORD flags);
+struct wined3d_clipper * __cdecl wined3d_surface_get_clipper(const struct wined3d_surface *surface);
+HRESULT __cdecl wined3d_surface_get_flip_status(const struct wined3d_surface *surface, DWORD flags);
+HRESULT __cdecl wined3d_surface_get_overlay_position(const struct wined3d_surface *surface, LONG *x, LONG *y);
+struct wined3d_palette * __cdecl wined3d_surface_get_palette(const struct wined3d_surface *surface);
+void * __cdecl wined3d_surface_get_parent(const struct wined3d_surface *surface);
+DWORD __cdecl wined3d_surface_get_pitch(const struct wined3d_surface *surface);
+DWORD __cdecl wined3d_surface_get_priority(const struct wined3d_surface *surface);
+HRESULT __cdecl wined3d_surface_get_private_data(const struct wined3d_surface *surface,
+ REFGUID guid, void *data, DWORD *data_size);
+struct wined3d_resource * __cdecl wined3d_surface_get_resource(struct wined3d_surface *surface);
+HRESULT __cdecl wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc);
+ULONG __cdecl wined3d_surface_incref(struct wined3d_surface *surface);
+HRESULT __cdecl wined3d_surface_is_lost(const struct wined3d_surface *surface);
+HRESULT __cdecl wined3d_surface_map(struct wined3d_surface *surface,
+ WINED3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags);
+void __cdecl wined3d_surface_preload(struct wined3d_surface *surface);
+HRESULT __cdecl wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc);
+HRESULT __cdecl wined3d_surface_restore(struct wined3d_surface *surface);
+HRESULT __cdecl wined3d_surface_set_clipper(struct wined3d_surface *surface, struct wined3d_clipper *clipper);
+HRESULT __cdecl wined3d_surface_set_color_key(struct wined3d_surface *surface,
+ DWORD flags, const WINEDDCOLORKEY *color_key);
+HRESULT __cdecl wined3d_surface_set_format(struct wined3d_surface *surface, enum wined3d_format_id format_id);
+HRESULT __cdecl wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem);
+HRESULT __cdecl wined3d_surface_set_overlay_position(struct wined3d_surface *surface, LONG x, LONG y);
+HRESULT __cdecl wined3d_surface_set_palette(struct wined3d_surface *surface, struct wined3d_palette *palette);
+DWORD __cdecl wined3d_surface_set_priority(struct wined3d_surface *surface, DWORD new_priority);
+HRESULT __cdecl wined3d_surface_set_private_data(struct wined3d_surface *surface,
+ REFGUID guid, const void *data, DWORD data_size, DWORD flags);
+HRESULT __cdecl wined3d_surface_unmap(struct wined3d_surface *surface);
+HRESULT __cdecl wined3d_surface_update_overlay(struct wined3d_surface *surface, const RECT *src_rect,
+ struct wined3d_surface *dst_surface, const RECT *dst_rect, DWORD flags, const WINEDDOVERLAYFX *fx);
+HRESULT __cdecl wined3d_surface_update_overlay_z_order(struct wined3d_surface *surface,
+ DWORD flags, struct wined3d_surface *ref);
+
+HRESULT __cdecl wined3d_swapchain_create(struct wined3d_device *device,
+ WINED3DPRESENT_PARAMETERS *present_parameters, WINED3DSURFTYPE surface_type, void *parent,
+ const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain);
+ULONG __cdecl wined3d_swapchain_decref(struct wined3d_swapchain *swapchain);
+HRESULT __cdecl wined3d_swapchain_get_back_buffer(const struct wined3d_swapchain *swapchain,
+ UINT backbuffer_idx, WINED3DBACKBUFFER_TYPE backbuffer_type, struct wined3d_surface **backbuffer);
+struct wined3d_device * __cdecl wined3d_swapchain_get_device(const struct wined3d_swapchain *swapchain);
+HRESULT __cdecl wined3d_swapchain_get_display_mode(const struct wined3d_swapchain *swapchain,
+ WINED3DDISPLAYMODE *mode);
+HRESULT __cdecl wined3d_swapchain_get_front_buffer_data(const struct wined3d_swapchain *swapchain,
+ struct wined3d_surface *dst_surface);
+HRESULT __cdecl wined3d_swapchain_get_gamma_ramp(const struct wined3d_swapchain *swapchain,
+ WINED3DGAMMARAMP *ramp);
+void * __cdecl wined3d_swapchain_get_parent(const struct wined3d_swapchain *swapchain);
+HRESULT __cdecl wined3d_swapchain_get_present_parameters(const struct wined3d_swapchain *swapchain,
+ WINED3DPRESENT_PARAMETERS *present_parameters);
+HRESULT __cdecl wined3d_swapchain_get_raster_status(const struct wined3d_swapchain *swapchain,
+ WINED3DRASTER_STATUS *raster_status);
+ULONG __cdecl wined3d_swapchain_incref(struct wined3d_swapchain *swapchain);
+HRESULT __cdecl wined3d_swapchain_present(struct wined3d_swapchain *swapchain,
+ const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override,
+ const RGNDATA *dirty_region, DWORD flags);
+HRESULT __cdecl wined3d_swapchain_set_gamma_ramp(const struct wined3d_swapchain *swapchain,
+ DWORD flags, const WINED3DGAMMARAMP *ramp);
+HRESULT __cdecl wined3d_swapchain_set_window(struct wined3d_swapchain *swapchain, HWND window);
+
+HRESULT __cdecl wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
+ UINT layer, const WINED3DBOX *dirty_region);
+HRESULT __cdecl wined3d_texture_create_2d(struct wined3d_device *device, UINT width, UINT height,
+ UINT level_count, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool, void *parent,
+ const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
+HRESULT __cdecl wined3d_texture_create_3d(struct wined3d_device *device, UINT width, UINT height, UINT depth,
+ UINT level_count, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool, void *parent,
+ const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
+HRESULT __cdecl wined3d_texture_create_cube(struct wined3d_device *device, UINT edge_length,
+ UINT level_count, DWORD usage, enum wined3d_format_id format_id, WINED3DPOOL pool, void *parent,
+ const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
+ULONG __cdecl wined3d_texture_decref(struct wined3d_texture *texture);
+HRESULT __cdecl wined3d_texture_free_private_data(struct wined3d_texture *texture, REFGUID guid);
+void __cdecl wined3d_texture_generate_mipmaps(struct wined3d_texture *texture);
+WINED3DTEXTUREFILTERTYPE __cdecl wined3d_texture_get_autogen_filter_type(const struct wined3d_texture *texture);
+DWORD __cdecl wined3d_texture_get_level_count(const struct wined3d_texture *texture);
+DWORD __cdecl wined3d_texture_get_lod(const struct wined3d_texture *texture);
+void * __cdecl wined3d_texture_get_parent(const struct wined3d_texture *texture);
+DWORD __cdecl wined3d_texture_get_priority(const struct wined3d_texture *texture);
+HRESULT __cdecl wined3d_texture_get_private_data(const struct wined3d_texture *texture,
+ REFGUID guid, void *data, DWORD *data_size);
+struct wined3d_resource * __cdecl wined3d_texture_get_sub_resource(struct wined3d_texture *texture,
+ UINT sub_resource_idx);
+WINED3DRESOURCETYPE __cdecl wined3d_texture_get_type(const struct wined3d_texture *texture);
+ULONG __cdecl wined3d_texture_incref(struct wined3d_texture *texture);
+void __cdecl wined3d_texture_preload(struct wined3d_texture *texture);
+HRESULT __cdecl wined3d_texture_set_autogen_filter_type(struct wined3d_texture *texture,
+ WINED3DTEXTUREFILTERTYPE filter_type);
+DWORD __cdecl wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod);
+DWORD __cdecl wined3d_texture_set_priority(struct wined3d_texture *texture, DWORD priority);
+HRESULT __cdecl wined3d_texture_set_private_data(struct wined3d_texture *texture,
+ REFGUID guid, const void *data, DWORD data_size, DWORD flags);
+
+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);
+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);
+ULONG __cdecl wined3d_vertex_declaration_decref(struct wined3d_vertex_declaration *declaration);
+void * __cdecl wined3d_vertex_declaration_get_parent(const struct wined3d_vertex_declaration *declaration);
+ULONG __cdecl wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration);
+
+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);
+ULONG __cdecl wined3d_volume_decref(struct wined3d_volume *volume);
+HRESULT __cdecl wined3d_volume_free_private_data(struct wined3d_volume *volume, REFGUID guid);
+struct wined3d_volume * __cdecl wined3d_volume_from_resource(struct wined3d_resource *resource);
+void * __cdecl wined3d_volume_get_parent(const struct wined3d_volume *volume);
+DWORD __cdecl wined3d_volume_get_priority(const struct wined3d_volume *volume);
+HRESULT __cdecl wined3d_volume_get_private_data(const struct wined3d_volume *volume,
+ REFGUID guid, void *data, DWORD *data_size);
+struct wined3d_resource * __cdecl wined3d_volume_get_resource(struct wined3d_volume *volume);
+ULONG __cdecl wined3d_volume_incref(struct wined3d_volume *volume);
+HRESULT __cdecl wined3d_volume_map(struct wined3d_volume *volume,
+ WINED3DLOCKED_BOX *locked_box, const WINED3DBOX *box, DWORD flags);
+void __cdecl wined3d_volume_preload(struct wined3d_volume *volume);
+DWORD __cdecl wined3d_volume_set_priority(struct wined3d_volume *volume, DWORD new_priority);
+HRESULT __cdecl wined3d_volume_set_private_data(struct wined3d_volume *volume,
+ REFGUID guid, const void *data, DWORD data_size, DWORD flags);
+HRESULT __cdecl wined3d_volume_unmap(struct wined3d_volume *volume);
+
+#endif /* __WINE_WINED3D_H */
diff --git a/reactos/include/reactos/wine/wined3d.idl b/reactos/include/reactos/wine/wined3d.idl
deleted file mode 100644
index 99f29763b72..00000000000
--- a/reactos/include/reactos/wine/wined3d.idl
+++ /dev/null
@@ -1,3388 +0,0 @@
-/*
- * Copyright 2002-2003 The wine-d3d team
- * Copyright 2002-2003 Jason Edmeades
- * Copyright 2002-2003 Raphael Junqueira
- * Copyright 2005 Oliver Stieber
- * Copyright 2006 Stefan Dösinger
- * Copyright 2006 Stefan Dösinger for CodeWeavers
- * Copyright 2007 Henri Verbeet
- * Copyright 2008 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
- */
-
-import "unknwn.idl";
-
-cpp_quote("#if 0")
-typedef HANDLE HMONITOR;
-
-typedef struct _RGNDATAHEADER
-{
- DWORD dwSize;
- DWORD iType;
- DWORD nCount;
- DWORD nRgnSize;
- RECT rcBound;
-} RGNDATAHEADER;
-
-typedef struct _RGNDATA
-{
- RGNDATAHEADER rdh;
- char Buffer[1];
-} RGNDATA;
-
-typedef struct _LUID
-{
- DWORD LowPart;
- LONG HighPart;
-} LUID, *PLUID;
-cpp_quote("#endif")
-
-cpp_quote("#define WINED3D_OK S_OK")
-
-const UINT _FACWINED3D = 0x876;
-cpp_quote("#define MAKE_WINED3DSTATUS(code) MAKE_HRESULT(0, _FACWINED3D, code)")
-cpp_quote("#define WINED3DOK_NOAUTOGEN MAKE_WINED3DSTATUS(2159)")
-
-cpp_quote("#define MAKE_WINED3DHRESULT(code) MAKE_HRESULT(1, _FACWINED3D, code)")
-cpp_quote("#define WINED3DERR_WRONGTEXTUREFORMAT MAKE_WINED3DHRESULT(2072)")
-cpp_quote("#define WINED3DERR_UNSUPPORTEDCOLOROPERATION MAKE_WINED3DHRESULT(2073)")
-cpp_quote("#define WINED3DERR_UNSUPPORTEDCOLORARG MAKE_WINED3DHRESULT(2074)")
-cpp_quote("#define WINED3DERR_UNSUPPORTEDALPHAOPERATION MAKE_WINED3DHRESULT(2075)")
-cpp_quote("#define WINED3DERR_UNSUPPORTEDALPHAARG MAKE_WINED3DHRESULT(2076)")
-cpp_quote("#define WINED3DERR_TOOMANYOPERATIONS MAKE_WINED3DHRESULT(2077)")
-cpp_quote("#define WINED3DERR_CONFLICTINGTEXTUREFILTER MAKE_WINED3DHRESULT(2078)")
-cpp_quote("#define WINED3DERR_UNSUPPORTEDFACTORVALUE MAKE_WINED3DHRESULT(2079)")
-cpp_quote("#define WINED3DERR_CONFLICTINGRENDERSTATE MAKE_WINED3DHRESULT(2081)")
-cpp_quote("#define WINED3DERR_UNSUPPORTEDTEXTUREFILTER MAKE_WINED3DHRESULT(2082)")
-cpp_quote("#define WINED3DERR_CONFLICTINGTEXTUREPALETTE MAKE_WINED3DHRESULT(2086)")
-cpp_quote("#define WINED3DERR_DRIVERINTERNALERROR MAKE_WINED3DHRESULT(2087)")
-cpp_quote("#define WINED3DERR_NOTFOUND MAKE_WINED3DHRESULT(2150)")
-cpp_quote("#define WINED3DERR_MOREDATA MAKE_WINED3DHRESULT(2151)")
-cpp_quote("#define WINED3DERR_DEVICELOST MAKE_WINED3DHRESULT(2152)")
-cpp_quote("#define WINED3DERR_DEVICENOTRESET MAKE_WINED3DHRESULT(2153)")
-cpp_quote("#define WINED3DERR_NOTAVAILABLE MAKE_WINED3DHRESULT(2154)")
-cpp_quote("#define WINED3DERR_OUTOFVIDEOMEMORY MAKE_WINED3DHRESULT(380)")
-cpp_quote("#define WINED3DERR_INVALIDDEVICE MAKE_WINED3DHRESULT(2155)")
-cpp_quote("#define WINED3DERR_INVALIDCALL MAKE_WINED3DHRESULT(2156)")
-cpp_quote("#define WINED3DERR_DRIVERINVALIDCALL MAKE_WINED3DHRESULT(2157)")
-cpp_quote("#define WINED3DERR_WASSTILLDRAWING MAKE_WINED3DHRESULT(540)")
-cpp_quote("#define WINEDDERR_NOTAOVERLAYSURFACE MAKE_WINED3DHRESULT(580)")
-cpp_quote("#define WINEDDERR_NOTLOCKED MAKE_WINED3DHRESULT(584)")
-cpp_quote("#define WINEDDERR_NODC MAKE_WINED3DHRESULT(586)")
-cpp_quote("#define WINEDDERR_DCALREADYCREATED MAKE_WINED3DHRESULT(620)")
-cpp_quote("#define WINEDDERR_NOTFLIPPABLE MAKE_WINED3DHRESULT(582)")
-cpp_quote("#define WINEDDERR_SURFACEBUSY MAKE_WINED3DHRESULT(430)")
-cpp_quote("#define WINEDDERR_INVALIDRECT MAKE_WINED3DHRESULT(150)")
-cpp_quote("#define WINEDDERR_NOCLIPLIST MAKE_WINED3DHRESULT(205)")
-cpp_quote("#define WINEDDERR_OVERLAYNOTVISIBLE MAKE_WINED3DHRESULT(577)")
-
-typedef DWORD WINED3DCOLOR;
-
-typedef enum _WINED3DLIGHTTYPE
-{
- WINED3DLIGHT_POINT = 1,
- WINED3DLIGHT_SPOT = 2,
- WINED3DLIGHT_DIRECTIONAL = 3,
- WINED3DLIGHT_PARALLELPOINT = 4, /* D3D7 */
- WINED3DLIGHT_GLSPOT = 5, /* D3D7 */
- WINED3DLIGHT_FORCE_DWORD = 0x7fffffff
-} WINED3DLIGHTTYPE;
-
-typedef enum _WINED3DPRIMITIVETYPE
-{
- WINED3DPT_UNDEFINED = 0,
- WINED3DPT_POINTLIST = 1,
- WINED3DPT_LINELIST = 2,
- WINED3DPT_LINESTRIP = 3,
- WINED3DPT_TRIANGLELIST = 4,
- WINED3DPT_TRIANGLESTRIP = 5,
- WINED3DPT_TRIANGLEFAN = 6,
- WINED3DPT_LINELIST_ADJ = 10,
- WINED3DPT_LINESTRIP_ADJ = 11,
- WINED3DPT_TRIANGLELIST_ADJ = 12,
- WINED3DPT_TRIANGLESTRIP_ADJ = 13,
- WINED3DPT_FORCE_DWORD = 0x7fffffff
-} WINED3DPRIMITIVETYPE;
-
-typedef enum _WINED3DDEVTYPE
-{
- WINED3DDEVTYPE_HAL = 1,
- WINED3DDEVTYPE_REF = 2,
- WINED3DDEVTYPE_SW = 3,
- WINED3DDEVTYPE_NULLREF = 4,
- WINED3DDEVTYPE_FORCE_DWORD = 0xffffffff
-} WINED3DDEVTYPE;
-
-typedef enum _WINED3DDEGREETYPE
-{
- WINED3DDEGREE_LINEAR = 1,
- WINED3DDEGREE_QUADRATIC = 2,
- WINED3DDEGREE_CUBIC = 3,
- WINED3DDEGREE_QUINTIC = 5,
- WINED3DDEGREE_FORCE_DWORD = 0x7fffffff
-} WINED3DDEGREETYPE;
-
-enum wined3d_format_id
-{
- WINED3DFMT_UNKNOWN,
- WINED3DFMT_B8G8R8_UNORM,
- WINED3DFMT_B5G5R5X1_UNORM,
- WINED3DFMT_B4G4R4A4_UNORM,
- WINED3DFMT_B2G3R3_UNORM,
- WINED3DFMT_B2G3R3A8_UNORM,
- WINED3DFMT_B4G4R4X4_UNORM,
- WINED3DFMT_R8G8B8X8_UNORM,
- WINED3DFMT_B10G10R10A2_UNORM,
- WINED3DFMT_P8_UINT_A8_UNORM,
- WINED3DFMT_P8_UINT,
- WINED3DFMT_L8_UNORM,
- WINED3DFMT_L8A8_UNORM,
- WINED3DFMT_L4A4_UNORM,
- WINED3DFMT_R5G5_SNORM_L6_UNORM,
- WINED3DFMT_R8G8_SNORM_L8X8_UNORM,
- WINED3DFMT_R10G11B11_SNORM,
- WINED3DFMT_R10G10B10_SNORM_A2_UNORM,
- WINED3DFMT_D16_LOCKABLE,
- WINED3DFMT_D32_UNORM,
- WINED3DFMT_S1_UINT_D15_UNORM,
- WINED3DFMT_X8D24_UNORM,
- WINED3DFMT_S4X4_UINT_D24_UNORM,
- WINED3DFMT_L16_UNORM,
- WINED3DFMT_S8_UINT_D24_FLOAT,
- WINED3DFMT_VERTEXDATA,
- WINED3DFMT_R8G8_SNORM_Cx,
- WINED3DFMT_R32G32B32A32_TYPELESS,
- WINED3DFMT_R32G32B32A32_FLOAT,
- WINED3DFMT_R32G32B32A32_UINT,
- WINED3DFMT_R32G32B32A32_SINT,
- WINED3DFMT_R32G32B32_TYPELESS,
- WINED3DFMT_R32G32B32_FLOAT,
- WINED3DFMT_R32G32B32_UINT,
- WINED3DFMT_R32G32B32_SINT,
- WINED3DFMT_R16G16B16A16_TYPELESS,
- WINED3DFMT_R16G16B16A16_FLOAT,
- WINED3DFMT_R16G16B16A16_UNORM,
- WINED3DFMT_R16G16B16A16_UINT,
- WINED3DFMT_R16G16B16A16_SNORM,
- WINED3DFMT_R16G16B16A16_SINT,
- WINED3DFMT_R32G32_TYPELESS,
- WINED3DFMT_R32G32_FLOAT,
- WINED3DFMT_R32G32_UINT,
- WINED3DFMT_R32G32_SINT,
- WINED3DFMT_R32G8X24_TYPELESS,
- WINED3DFMT_D32_FLOAT_S8X24_UINT,
- WINED3DFMT_R32_FLOAT_X8X24_TYPELESS,
- WINED3DFMT_X32_TYPELESS_G8X24_UINT,
- WINED3DFMT_R10G10B10A2_TYPELESS,
- WINED3DFMT_R10G10B10A2_UNORM,
- WINED3DFMT_R10G10B10A2_UINT,
- WINED3DFMT_R10G10B10A2_SNORM,
- WINED3DFMT_R11G11B10_FLOAT,
- WINED3DFMT_R8G8B8A8_TYPELESS,
- WINED3DFMT_R8G8B8A8_UNORM,
- WINED3DFMT_R8G8B8A8_UNORM_SRGB,
- WINED3DFMT_R8G8B8A8_UINT,
- WINED3DFMT_R8G8B8A8_SNORM,
- WINED3DFMT_R8G8B8A8_SINT,
- WINED3DFMT_R16G16_TYPELESS,
- WINED3DFMT_R16G16_FLOAT,
- WINED3DFMT_R16G16_UNORM,
- WINED3DFMT_R16G16_UINT,
- WINED3DFMT_R16G16_SNORM,
- WINED3DFMT_R16G16_SINT,
- WINED3DFMT_R32_TYPELESS,
- WINED3DFMT_D32_FLOAT,
- WINED3DFMT_R32_FLOAT,
- WINED3DFMT_R32_UINT,
- WINED3DFMT_R32_SINT,
- WINED3DFMT_R24G8_TYPELESS,
- WINED3DFMT_D24_UNORM_S8_UINT,
- WINED3DFMT_R24_UNORM_X8_TYPELESS,
- WINED3DFMT_X24_TYPELESS_G8_UINT,
- WINED3DFMT_R8G8_TYPELESS,
- WINED3DFMT_R8G8_UNORM,
- WINED3DFMT_R8G8_UINT,
- WINED3DFMT_R8G8_SNORM,
- WINED3DFMT_R8G8_SINT,
- WINED3DFMT_R16_TYPELESS,
- WINED3DFMT_R16_FLOAT,
- WINED3DFMT_D16_UNORM,
- WINED3DFMT_R16_UNORM,
- WINED3DFMT_R16_UINT,
- WINED3DFMT_R16_SNORM,
- WINED3DFMT_R16_SINT,
- WINED3DFMT_R8_TYPELESS,
- WINED3DFMT_R8_UNORM,
- WINED3DFMT_R8_UINT,
- WINED3DFMT_R8_SNORM,
- WINED3DFMT_R8_SINT,
- WINED3DFMT_A8_UNORM,
- WINED3DFMT_R1_UNORM,
- WINED3DFMT_R9G9B9E5_SHAREDEXP,
- WINED3DFMT_R8G8_B8G8_UNORM,
- WINED3DFMT_G8R8_G8B8_UNORM,
- WINED3DFMT_BC1_TYPELESS,
- WINED3DFMT_BC1_UNORM,
- WINED3DFMT_BC1_UNORM_SRGB,
- WINED3DFMT_BC2_TYPELESS,
- WINED3DFMT_BC2_UNORM,
- WINED3DFMT_BC2_UNORM_SRGB,
- WINED3DFMT_BC3_TYPELESS,
- WINED3DFMT_BC3_UNORM,
- WINED3DFMT_BC3_UNORM_SRGB,
- WINED3DFMT_BC4_TYPELESS,
- WINED3DFMT_BC4_UNORM,
- WINED3DFMT_BC4_SNORM,
- WINED3DFMT_BC5_TYPELESS,
- WINED3DFMT_BC5_UNORM,
- WINED3DFMT_BC5_SNORM,
- WINED3DFMT_B5G6R5_UNORM,
- WINED3DFMT_B5G5R5A1_UNORM,
- WINED3DFMT_B8G8R8A8_UNORM,
- WINED3DFMT_B8G8R8X8_UNORM,
- /* FOURCC formats. */
- WINED3DFMT_UYVY = 0x59565955, /* UYVY */
- WINED3DFMT_YUY2 = 0x32595559, /* YUY2 */
- WINED3DFMT_YV12 = 0x32315659, /* YV12 */
- WINED3DFMT_DXT1 = 0x31545844, /* DXT1 */
- WINED3DFMT_DXT2 = 0x32545844, /* DXT2 */
- WINED3DFMT_DXT3 = 0x33545844, /* DXT3 */
- WINED3DFMT_DXT4 = 0x34545844, /* DXT4 */
- WINED3DFMT_DXT5 = 0x35545844, /* DXT5 */
- WINED3DFMT_MULTI2_ARGB8 = 0x3154454d, /* MET1 */
- WINED3DFMT_G8R8_G8B8 = 0x42475247, /* GRGB */
- WINED3DFMT_R8G8_B8G8 = 0x47424752, /* RGBG */
- WINED3DFMT_ATI2N = 0x32495441, /* ATI2 */
- WINED3DFMT_INST = 0x54534e49, /* INST */
- WINED3DFMT_NVDB = 0x4244564e, /* NVDB */
- WINED3DFMT_NVHU = 0x5548564e, /* NVHU */
- WINED3DFMT_NVHS = 0x5348564e, /* NVHS */
-
- WINED3DFMT_FORCE_DWORD = 0xffffffff
-};
-
-typedef enum _WINED3DRENDERSTATETYPE
-{
- WINED3DRS_ANTIALIAS = 2, /* d3d7 */
- WINED3DRS_TEXTUREPERSPECTIVE = 4, /* d3d7 */
- WINED3DRS_WRAPU = 5, /* d3d7 */
- WINED3DRS_WRAPV = 6, /* d3d7 */
- WINED3DRS_ZENABLE = 7,
- WINED3DRS_FILLMODE = 8,
- WINED3DRS_SHADEMODE = 9,
- WINED3DRS_LINEPATTERN = 10, /* d3d7, d3d8 */
- WINED3DRS_MONOENABLE = 11, /* d3d7 */
- WINED3DRS_ROP2 = 12, /* d3d7 */
- WINED3DRS_PLANEMASK = 13, /* d3d7 */
- WINED3DRS_ZWRITEENABLE = 14,
- WINED3DRS_ALPHATESTENABLE = 15,
- WINED3DRS_LASTPIXEL = 16,
- WINED3DRS_SRCBLEND = 19,
- WINED3DRS_DESTBLEND = 20,
- WINED3DRS_CULLMODE = 22,
- WINED3DRS_ZFUNC = 23,
- WINED3DRS_ALPHAREF = 24,
- WINED3DRS_ALPHAFUNC = 25,
- WINED3DRS_DITHERENABLE = 26,
- WINED3DRS_ALPHABLENDENABLE = 27,
- WINED3DRS_FOGENABLE = 28,
- WINED3DRS_SPECULARENABLE = 29,
- WINED3DRS_ZVISIBLE = 30, /* d3d7, d3d8 */
- WINED3DRS_SUBPIXEL = 31, /* d3d7 */
- WINED3DRS_SUBPIXELX = 32, /* d3d7 */
- WINED3DRS_STIPPLEDALPHA = 33, /* d3d7 */
- WINED3DRS_FOGCOLOR = 34,
- WINED3DRS_FOGTABLEMODE = 35,
- WINED3DRS_FOGSTART = 36,
- WINED3DRS_FOGEND = 37,
- WINED3DRS_FOGDENSITY = 38,
- WINED3DRS_STIPPLEENABLE = 39, /* d3d7 */
- WINED3DRS_EDGEANTIALIAS = 40, /* d3d7, d3d8 */
- WINED3DRS_COLORKEYENABLE = 41, /* d3d7 */
- WINED3DRS_MIPMAPLODBIAS = 46, /* d3d7 */
- WINED3DRS_ZBIAS = 47, /* d3d7, d3d8 */
- WINED3DRS_RANGEFOGENABLE = 48,
- WINED3DRS_ANISOTROPY = 49, /* d3d7 */
- WINED3DRS_FLUSHBATCH = 50, /* d3d7 */
- WINED3DRS_TRANSLUCENTSORTINDEPENDENT = 51, /* d3d7 */
- WINED3DRS_STENCILENABLE = 52,
- WINED3DRS_STENCILFAIL = 53,
- WINED3DRS_STENCILZFAIL = 54,
- WINED3DRS_STENCILPASS = 55,
- WINED3DRS_STENCILFUNC = 56,
- WINED3DRS_STENCILREF = 57,
- WINED3DRS_STENCILMASK = 58,
- WINED3DRS_STENCILWRITEMASK = 59,
- WINED3DRS_TEXTUREFACTOR = 60,
- WINED3DRS_WRAP0 = 128,
- WINED3DRS_WRAP1 = 129,
- WINED3DRS_WRAP2 = 130,
- WINED3DRS_WRAP3 = 131,
- WINED3DRS_WRAP4 = 132,
- WINED3DRS_WRAP5 = 133,
- WINED3DRS_WRAP6 = 134,
- WINED3DRS_WRAP7 = 135,
- WINED3DRS_CLIPPING = 136,
- WINED3DRS_LIGHTING = 137,
- WINED3DRS_EXTENTS = 138, /* d3d7 */
- WINED3DRS_AMBIENT = 139,
- WINED3DRS_FOGVERTEXMODE = 140,
- WINED3DRS_COLORVERTEX = 141,
- WINED3DRS_LOCALVIEWER = 142,
- WINED3DRS_NORMALIZENORMALS = 143,
- WINED3DRS_COLORKEYBLENDENABLE = 144, /* d3d7 */
- WINED3DRS_DIFFUSEMATERIALSOURCE = 145,
- WINED3DRS_SPECULARMATERIALSOURCE = 146,
- WINED3DRS_AMBIENTMATERIALSOURCE = 147,
- WINED3DRS_EMISSIVEMATERIALSOURCE = 148,
- WINED3DRS_VERTEXBLEND = 151,
- WINED3DRS_CLIPPLANEENABLE = 152,
- WINED3DRS_SOFTWAREVERTEXPROCESSING = 153, /* d3d8 */
- WINED3DRS_POINTSIZE = 154,
- WINED3DRS_POINTSIZE_MIN = 155,
- WINED3DRS_POINTSPRITEENABLE = 156,
- WINED3DRS_POINTSCALEENABLE = 157,
- WINED3DRS_POINTSCALE_A = 158,
- WINED3DRS_POINTSCALE_B = 159,
- WINED3DRS_POINTSCALE_C = 160,
- WINED3DRS_MULTISAMPLEANTIALIAS = 161,
- WINED3DRS_MULTISAMPLEMASK = 162,
- WINED3DRS_PATCHEDGESTYLE = 163,
- WINED3DRS_PATCHSEGMENTS = 164, /* d3d8 */
- WINED3DRS_DEBUGMONITORTOKEN = 165,
- WINED3DRS_POINTSIZE_MAX = 166,
- WINED3DRS_INDEXEDVERTEXBLENDENABLE = 167,
- WINED3DRS_COLORWRITEENABLE = 168,
- WINED3DRS_TWEENFACTOR = 170,
- WINED3DRS_BLENDOP = 171,
- WINED3DRS_POSITIONDEGREE = 172,
- WINED3DRS_NORMALDEGREE = 173,
- WINED3DRS_SCISSORTESTENABLE = 174,
- WINED3DRS_SLOPESCALEDEPTHBIAS = 175,
- WINED3DRS_ANTIALIASEDLINEENABLE = 176,
- WINED3DRS_MINTESSELLATIONLEVEL = 178,
- WINED3DRS_MAXTESSELLATIONLEVEL = 179,
- WINED3DRS_ADAPTIVETESS_X = 180,
- WINED3DRS_ADAPTIVETESS_Y = 181,
- WINED3DRS_ADAPTIVETESS_Z = 182,
- WINED3DRS_ADAPTIVETESS_W = 183,
- WINED3DRS_ENABLEADAPTIVETESSELLATION = 184,
- WINED3DRS_TWOSIDEDSTENCILMODE = 185,
- WINED3DRS_CCW_STENCILFAIL = 186,
- WINED3DRS_CCW_STENCILZFAIL = 187,
- WINED3DRS_CCW_STENCILPASS = 188,
- WINED3DRS_CCW_STENCILFUNC = 189,
- WINED3DRS_COLORWRITEENABLE1 = 190,
- WINED3DRS_COLORWRITEENABLE2 = 191,
- WINED3DRS_COLORWRITEENABLE3 = 192,
- WINED3DRS_BLENDFACTOR = 193,
- WINED3DRS_SRGBWRITEENABLE = 194,
- WINED3DRS_DEPTHBIAS = 195,
- WINED3DRS_WRAP8 = 198,
- WINED3DRS_WRAP9 = 199,
- WINED3DRS_WRAP10 = 200,
- WINED3DRS_WRAP11 = 201,
- WINED3DRS_WRAP12 = 202,
- WINED3DRS_WRAP13 = 203,
- WINED3DRS_WRAP14 = 204,
- WINED3DRS_WRAP15 = 205,
- WINED3DRS_SEPARATEALPHABLENDENABLE = 206,
- WINED3DRS_SRCBLENDALPHA = 207,
- WINED3DRS_DESTBLENDALPHA = 208,
- WINED3DRS_BLENDOPALPHA = 209,
- WINED3DRS_FORCE_DWORD = 0x7fffffff
-} WINED3DRENDERSTATETYPE;
-const UINT WINEHIGHEST_RENDER_STATE = WINED3DRS_BLENDOPALPHA;
-
-typedef enum _WINED3DBLEND
-{
- WINED3DBLEND_ZERO = 1,
- WINED3DBLEND_ONE = 2,
- WINED3DBLEND_SRCCOLOR = 3,
- WINED3DBLEND_INVSRCCOLOR = 4,
- WINED3DBLEND_SRCALPHA = 5,
- WINED3DBLEND_INVSRCALPHA = 6,
- WINED3DBLEND_DESTALPHA = 7,
- WINED3DBLEND_INVDESTALPHA = 8,
- WINED3DBLEND_DESTCOLOR = 9,
- WINED3DBLEND_INVDESTCOLOR = 10,
- WINED3DBLEND_SRCALPHASAT = 11,
- WINED3DBLEND_BOTHSRCALPHA = 12,
- WINED3DBLEND_BOTHINVSRCALPHA = 13,
- WINED3DBLEND_BLENDFACTOR = 14,
- WINED3DBLEND_INVBLENDFACTOR = 15,
- WINED3DBLEND_FORCE_DWORD = 0x7fffffff
-} WINED3DBLEND;
-
-typedef enum _WINED3DBLENDOP
-{
- WINED3DBLENDOP_ADD = 1,
- WINED3DBLENDOP_SUBTRACT = 2,
- WINED3DBLENDOP_REVSUBTRACT = 3,
- WINED3DBLENDOP_MIN = 4,
- WINED3DBLENDOP_MAX = 5,
- WINED3DBLENDOP_FORCE_DWORD = 0x7fffffff
-} WINED3DBLENDOP;
-
-typedef enum _WINED3DVERTEXBLENDFLAGS
-{
- WINED3DVBF_DISABLE = 0,
- WINED3DVBF_1WEIGHTS = 1,
- WINED3DVBF_2WEIGHTS = 2,
- WINED3DVBF_3WEIGHTS = 3,
- WINED3DVBF_TWEENING = 255,
- WINED3DVBF_0WEIGHTS = 256
-} WINED3DVERTEXBLENDFLAGS;
-
-typedef enum _WINED3DCMPFUNC
-{
- WINED3DCMP_NEVER = 1,
- WINED3DCMP_LESS = 2,
- WINED3DCMP_EQUAL = 3,
- WINED3DCMP_LESSEQUAL = 4,
- WINED3DCMP_GREATER = 5,
- WINED3DCMP_NOTEQUAL = 6,
- WINED3DCMP_GREATEREQUAL = 7,
- WINED3DCMP_ALWAYS = 8,
- WINED3DCMP_FORCE_DWORD = 0x7fffffff
-} WINED3DCMPFUNC;
-
-typedef enum _WINED3DZBUFFERTYPE
-{
- WINED3DZB_FALSE = 0,
- WINED3DZB_TRUE = 1,
- WINED3DZB_USEW = 2,
- WINED3DZB_FORCE_DWORD = 0x7fffffff
-} WINED3DZBUFFERTYPE;
-
-typedef enum _WINED3DFOGMODE
-{
- WINED3DFOG_NONE = 0,
- WINED3DFOG_EXP = 1,
- WINED3DFOG_EXP2 = 2,
- WINED3DFOG_LINEAR = 3,
- WINED3DFOG_FORCE_DWORD = 0x7fffffff
-} WINED3DFOGMODE;
-
-typedef enum _WINED3DSHADEMODE
-{
- WINED3DSHADE_FLAT = 1,
- WINED3DSHADE_GOURAUD = 2,
- WINED3DSHADE_PHONG = 3,
- WINED3DSHADE_FORCE_DWORD = 0x7fffffff
-} WINED3DSHADEMODE;
-
-typedef enum _WINED3DFILLMODE
-{
- WINED3DFILL_POINT = 1,
- WINED3DFILL_WIREFRAME = 2,
- WINED3DFILL_SOLID = 3,
- WINED3DFILL_FORCE_DWORD = 0x7fffffff
-} WINED3DFILLMODE;
-
-typedef enum _WINED3DCULL
-{
- WINED3DCULL_NONE = 1,
- WINED3DCULL_CW = 2,
- WINED3DCULL_CCW = 3,
- WINED3DCULL_FORCE_DWORD = 0x7fffffff
-} WINED3DCULL;
-
-typedef enum _WINED3DSTENCILOP
-{
- WINED3DSTENCILOP_KEEP = 1,
- WINED3DSTENCILOP_ZERO = 2,
- WINED3DSTENCILOP_REPLACE = 3,
- WINED3DSTENCILOP_INCRSAT = 4,
- WINED3DSTENCILOP_DECRSAT = 5,
- WINED3DSTENCILOP_INVERT = 6,
- WINED3DSTENCILOP_INCR = 7,
- WINED3DSTENCILOP_DECR = 8,
- WINED3DSTENCILOP_FORCE_DWORD = 0x7fffffff
-} WINED3DSTENCILOP;
-
-typedef enum _WINED3DMATERIALCOLORSOURCE
-{
- WINED3DMCS_MATERIAL = 0,
- WINED3DMCS_COLOR1 = 1,
- WINED3DMCS_COLOR2 = 2,
- WINED3DMCS_FORCE_DWORD = 0x7fffffff
-} WINED3DMATERIALCOLORSOURCE;
-
-typedef enum _WINED3DPATCHEDGESTYLE
-{
- WINED3DPATCHEDGE_DISCRETE = 0,
- WINED3DPATCHEDGE_CONTINUOUS = 1,
- WINED3DPATCHEDGE_FORCE_DWORD = 0x7fffffff
-} WINED3DPATCHEDGESTYLE;
-
-typedef enum _WINED3DBACKBUFFER_TYPE
-{
- WINED3DBACKBUFFER_TYPE_MONO = 0,
- WINED3DBACKBUFFER_TYPE_LEFT = 1,
- WINED3DBACKBUFFER_TYPE_RIGHT = 2,
- WINED3DBACKBUFFER_TYPE_FORCE_DWORD = 0x7fffffff
-} WINED3DBACKBUFFER_TYPE;
-
-typedef enum _WINED3DSWAPEFFECT
-{
- WINED3DSWAPEFFECT_DISCARD = 1,
- WINED3DSWAPEFFECT_FLIP = 2,
- WINED3DSWAPEFFECT_COPY = 3,
- WINED3DSWAPEFFECT_COPY_VSYNC = 4,
- WINED3DSWAPEFFECT_FORCE_DWORD = 0xffffffff
-} WINED3DSWAPEFFECT;
-
-typedef enum _WINED3DSAMPLERSTATETYPE
-{
- WINED3DSAMP_ADDRESSU = 1,
- WINED3DSAMP_ADDRESSV = 2,
- WINED3DSAMP_ADDRESSW = 3,
- WINED3DSAMP_BORDERCOLOR = 4,
- WINED3DSAMP_MAGFILTER = 5,
- WINED3DSAMP_MINFILTER = 6,
- WINED3DSAMP_MIPFILTER = 7,
- WINED3DSAMP_MIPMAPLODBIAS = 8,
- WINED3DSAMP_MAXMIPLEVEL = 9,
- WINED3DSAMP_MAXANISOTROPY = 10,
- WINED3DSAMP_SRGBTEXTURE = 11,
- WINED3DSAMP_ELEMENTINDEX = 12,
- WINED3DSAMP_DMAPOFFSET = 13,
- WINED3DSAMP_FORCE_DWORD = 0x7fffffff,
-} WINED3DSAMPLERSTATETYPE;
-const UINT WINED3D_HIGHEST_SAMPLER_STATE = WINED3DSAMP_DMAPOFFSET;
-
-typedef enum _WINED3DMULTISAMPLE_TYPE
-{
- WINED3DMULTISAMPLE_NONE = 0,
- WINED3DMULTISAMPLE_NONMASKABLE = 1,
- WINED3DMULTISAMPLE_2_SAMPLES = 2,
- WINED3DMULTISAMPLE_3_SAMPLES = 3,
- WINED3DMULTISAMPLE_4_SAMPLES = 4,
- WINED3DMULTISAMPLE_5_SAMPLES = 5,
- WINED3DMULTISAMPLE_6_SAMPLES = 6,
- WINED3DMULTISAMPLE_7_SAMPLES = 7,
- WINED3DMULTISAMPLE_8_SAMPLES = 8,
- WINED3DMULTISAMPLE_9_SAMPLES = 9,
- WINED3DMULTISAMPLE_10_SAMPLES = 10,
- WINED3DMULTISAMPLE_11_SAMPLES = 11,
- WINED3DMULTISAMPLE_12_SAMPLES = 12,
- WINED3DMULTISAMPLE_13_SAMPLES = 13,
- WINED3DMULTISAMPLE_14_SAMPLES = 14,
- WINED3DMULTISAMPLE_15_SAMPLES = 15,
- WINED3DMULTISAMPLE_16_SAMPLES = 16,
- WINED3DMULTISAMPLE_FORCE_DWORD = 0xffffffff
-} WINED3DMULTISAMPLE_TYPE;
-
-typedef enum _WINED3DTEXTURESTAGESTATETYPE
-{
- WINED3DTSS_COLOROP = 0,
- WINED3DTSS_COLORARG1 = 1,
- WINED3DTSS_COLORARG2 = 2,
- WINED3DTSS_ALPHAOP = 3,
- WINED3DTSS_ALPHAARG1 = 4,
- WINED3DTSS_ALPHAARG2 = 5,
- WINED3DTSS_BUMPENVMAT00 = 6,
- WINED3DTSS_BUMPENVMAT01 = 7,
- WINED3DTSS_BUMPENVMAT10 = 8,
- WINED3DTSS_BUMPENVMAT11 = 9,
- WINED3DTSS_TEXCOORDINDEX = 10,
- WINED3DTSS_BUMPENVLSCALE = 11,
- WINED3DTSS_BUMPENVLOFFSET = 12,
- WINED3DTSS_TEXTURETRANSFORMFLAGS = 13,
- WINED3DTSS_COLORARG0 = 14,
- WINED3DTSS_ALPHAARG0 = 15,
- WINED3DTSS_RESULTARG = 16,
- WINED3DTSS_CONSTANT = 17,
- WINED3DTSS_FORCE_DWORD = 0x7fffffff
-} WINED3DTEXTURESTAGESTATETYPE;
-const UINT WINED3D_HIGHEST_TEXTURE_STATE = WINED3DTSS_CONSTANT;
-
-typedef enum _WINED3DTEXTURETRANSFORMFLAGS
-{
- WINED3DTTFF_DISABLE = 0,
- WINED3DTTFF_COUNT1 = 1,
- WINED3DTTFF_COUNT2 = 2,
- WINED3DTTFF_COUNT3 = 3,
- WINED3DTTFF_COUNT4 = 4,
- WINED3DTTFF_PROJECTED = 256,
- WINED3DTTFF_FORCE_DWORD = 0x7fffffff
-} WINED3DTEXTURETRANSFORMFLAGS;
-
-typedef enum _WINED3DTEXTUREOP
-{
- WINED3DTOP_DISABLE = 1,
- WINED3DTOP_SELECTARG1 = 2,
- WINED3DTOP_SELECTARG2 = 3,
- WINED3DTOP_MODULATE = 4,
- WINED3DTOP_MODULATE2X = 5,
- WINED3DTOP_MODULATE4X = 6,
- WINED3DTOP_ADD = 7,
- WINED3DTOP_ADDSIGNED = 8,
- WINED3DTOP_ADDSIGNED2X = 9,
- WINED3DTOP_SUBTRACT = 10,
- WINED3DTOP_ADDSMOOTH = 11,
- WINED3DTOP_BLENDDIFFUSEALPHA = 12,
- WINED3DTOP_BLENDTEXTUREALPHA = 13,
- WINED3DTOP_BLENDFACTORALPHA = 14,
- WINED3DTOP_BLENDTEXTUREALPHAPM = 15,
- WINED3DTOP_BLENDCURRENTALPHA = 16,
- WINED3DTOP_PREMODULATE = 17,
- WINED3DTOP_MODULATEALPHA_ADDCOLOR = 18,
- WINED3DTOP_MODULATECOLOR_ADDALPHA = 19,
- WINED3DTOP_MODULATEINVALPHA_ADDCOLOR = 20,
- WINED3DTOP_MODULATEINVCOLOR_ADDALPHA = 21,
- WINED3DTOP_BUMPENVMAP = 22,
- WINED3DTOP_BUMPENVMAPLUMINANCE = 23,
- WINED3DTOP_DOTPRODUCT3 = 24,
- WINED3DTOP_MULTIPLYADD = 25,
- WINED3DTOP_LERP = 26,
- WINED3DTOP_FORCE_DWORD = 0x7fffffff,
-} WINED3DTEXTUREOP;
-
-typedef enum _WINED3DTEXTUREADDRESS
-{
- WINED3DTADDRESS_WRAP = 1,
- WINED3DTADDRESS_MIRROR = 2,
- WINED3DTADDRESS_CLAMP = 3,
- WINED3DTADDRESS_BORDER = 4,
- WINED3DTADDRESS_MIRRORONCE = 5,
- WINED3DTADDRESS_FORCE_DWORD = 0x7fffffff
-} WINED3DTEXTUREADDRESS;
-
-typedef enum _WINED3DTRANSFORMSTATETYPE
-{
- WINED3DTS_VIEW = 2,
- WINED3DTS_PROJECTION = 3,
- WINED3DTS_TEXTURE0 = 16,
- WINED3DTS_TEXTURE1 = 17,
- WINED3DTS_TEXTURE2 = 18,
- WINED3DTS_TEXTURE3 = 19,
- WINED3DTS_TEXTURE4 = 20,
- WINED3DTS_TEXTURE5 = 21,
- WINED3DTS_TEXTURE6 = 22,
- WINED3DTS_TEXTURE7 = 23,
- WINED3DTS_WORLD = 256, /*WINED3DTS_WORLDMATRIX(0)*/
- WINED3DTS_WORLD1 = 257,
- WINED3DTS_WORLD2 = 258,
- WINED3DTS_WORLD3 = 259,
- WINED3DTS_FORCE_DWORD = 0x7fffffff
-} WINED3DTRANSFORMSTATETYPE;
-cpp_quote("#define WINED3DTS_WORLDMATRIX(index) (WINED3DTRANSFORMSTATETYPE)(index + 256)")
-
-typedef enum _WINED3DBASISTYPE
-{
- WINED3DBASIS_BEZIER = 0,
- WINED3DBASIS_BSPLINE = 1,
- WINED3DBASIS_INTERPOLATE = 2,
- WINED3DBASIS_FORCE_DWORD = 0x7fffffff
-} WINED3DBASISTYPE;
-
-typedef enum _WINED3DCUBEMAP_FACES
-{
- WINED3DCUBEMAP_FACE_POSITIVE_X = 0,
- WINED3DCUBEMAP_FACE_NEGATIVE_X = 1,
- WINED3DCUBEMAP_FACE_POSITIVE_Y = 2,
- WINED3DCUBEMAP_FACE_NEGATIVE_Y = 3,
- WINED3DCUBEMAP_FACE_POSITIVE_Z = 4,
- WINED3DCUBEMAP_FACE_NEGATIVE_Z = 5,
- WINED3DCUBEMAP_FACE_FORCE_DWORD = 0xffffffff
-} WINED3DCUBEMAP_FACES;
-
-typedef enum _WINED3DTEXTUREFILTERTYPE
-{
- WINED3DTEXF_NONE = 0,
- WINED3DTEXF_POINT = 1,
- WINED3DTEXF_LINEAR = 2,
- WINED3DTEXF_ANISOTROPIC = 3,
- WINED3DTEXF_FLATCUBIC = 4,
- WINED3DTEXF_GAUSSIANCUBIC = 5,
- WINED3DTEXF_PYRAMIDALQUAD = 6,
- WINED3DTEXF_GAUSSIANQUAD = 7,
- WINED3DTEXF_FORCE_DWORD = 0x7fffffff
-} WINED3DTEXTUREFILTERTYPE;
-
-typedef enum _WINED3DRESOURCETYPE
-{
- WINED3DRTYPE_SURFACE = 1,
- WINED3DRTYPE_VOLUME = 2,
- WINED3DRTYPE_TEXTURE = 3,
- WINED3DRTYPE_VOLUMETEXTURE = 4,
- WINED3DRTYPE_CUBETEXTURE = 5,
- WINED3DRTYPE_BUFFER = 6,
- WINED3DRTYPE_FORCE_DWORD = 0x7fffffff
-} WINED3DRESOURCETYPE;
-const UINT WINED3DRTYPECOUNT = WINED3DRTYPE_BUFFER + 1;
-
-typedef enum _WINED3DPOOL
-{
- WINED3DPOOL_DEFAULT = 0,
- WINED3DPOOL_MANAGED = 1,
- WINED3DPOOL_SYSTEMMEM = 2,
- WINED3DPOOL_SCRATCH = 3,
- WINED3DPOOL_FORCE_DWORD = 0x7fffffff
-} WINED3DPOOL;
-
-typedef enum _WINED3DQUERYTYPE
-{
- WINED3DQUERYTYPE_VCACHE = 4,
- WINED3DQUERYTYPE_RESOURCEMANAGER = 5,
- WINED3DQUERYTYPE_VERTEXSTATS = 6,
- WINED3DQUERYTYPE_EVENT = 8,
- WINED3DQUERYTYPE_OCCLUSION = 9,
- WINED3DQUERYTYPE_TIMESTAMP = 10,
- WINED3DQUERYTYPE_TIMESTAMPDISJOINT = 11,
- WINED3DQUERYTYPE_TIMESTAMPFREQ = 12,
- WINED3DQUERYTYPE_PIPELINETIMINGS = 13,
- WINED3DQUERYTYPE_INTERFACETIMINGS = 14,
- WINED3DQUERYTYPE_VERTEXTIMINGS = 15,
- WINED3DQUERYTYPE_PIXELTIMINGS = 16,
- WINED3DQUERYTYPE_BANDWIDTHTIMINGS = 17,
- WINED3DQUERYTYPE_CACHEUTILIZATION = 18
-} WINED3DQUERYTYPE;
-
-const UINT WINED3DISSUE_BEGIN = (1 << 1);
-const UINT WINED3DISSUE_END = (1 << 0);
-const UINT WINED3DGETDATA_FLUSH = (1 << 0);
-
-typedef enum _WINED3DSTATEBLOCKTYPE
-{
- WINED3DSBT_INIT = 0,
- WINED3DSBT_ALL = 1,
- WINED3DSBT_PIXELSTATE = 2,
- WINED3DSBT_VERTEXSTATE = 3,
- WINED3DSBT_RECORDED = 4, /* WineD3D private */
- WINED3DSBT_FORCE_DWORD = 0xffffffff
-} WINED3DSTATEBLOCKTYPE;
-
-typedef enum _WINED3DDECLMETHOD
-{
- WINED3DDECLMETHOD_DEFAULT = 0,
- WINED3DDECLMETHOD_PARTIALU = 1,
- WINED3DDECLMETHOD_PARTIALV = 2,
- WINED3DDECLMETHOD_CROSSUV = 3,
- WINED3DDECLMETHOD_UV = 4,
- WINED3DDECLMETHOD_LOOKUP = 5,
- WINED3DDECLMETHOD_LOOKUPPRESAMPLED = 6
-} WINED3DDECLMETHOD;
-
-typedef enum _WINED3DDECLUSAGE
-{
- WINED3DDECLUSAGE_POSITION = 0,
- WINED3DDECLUSAGE_BLENDWEIGHT = 1,
- WINED3DDECLUSAGE_BLENDINDICES = 2,
- WINED3DDECLUSAGE_NORMAL = 3,
- WINED3DDECLUSAGE_PSIZE = 4,
- WINED3DDECLUSAGE_TEXCOORD = 5,
- WINED3DDECLUSAGE_TANGENT = 6,
- WINED3DDECLUSAGE_BINORMAL = 7,
- WINED3DDECLUSAGE_TESSFACTOR = 8,
- WINED3DDECLUSAGE_POSITIONT = 9,
- WINED3DDECLUSAGE_COLOR = 10,
- WINED3DDECLUSAGE_FOG = 11,
- WINED3DDECLUSAGE_DEPTH = 12,
- WINED3DDECLUSAGE_SAMPLE = 13
-} WINED3DDECLUSAGE;
-
-typedef enum _WINED3DSURFTYPE
-{
- SURFACE_UNKNOWN = 0, /* Default / Unknown surface type */
- SURFACE_OPENGL, /* OpenGL surface: Renders using libGL, needed for 3D */
- SURFACE_GDI, /* User surface. No 3D, DirectDraw rendering with GDI */
-} WINED3DSURFTYPE;
-
-enum wined3d_sysval_semantic
-{
- WINED3D_SV_DEPTH = 0xffffffff,
- WINED3D_SV_TARGET0 = 0,
- WINED3D_SV_TARGET1 = 1,
- WINED3D_SV_TARGET2 = 2,
- WINED3D_SV_TARGET3 = 3,
- WINED3D_SV_TARGET4 = 4,
- WINED3D_SV_TARGET5 = 5,
- WINED3D_SV_TARGET6 = 6,
- WINED3D_SV_TARGET7 = 7,
-};
-
-const UINT WINED3DCOLORWRITEENABLE_RED = (1<<0);
-const UINT WINED3DCOLORWRITEENABLE_GREEN = (1<<1);
-const UINT WINED3DCOLORWRITEENABLE_BLUE = (1<<2);
-const UINT WINED3DCOLORWRITEENABLE_ALPHA = (1<<3);
-
-const UINT WINED3DADAPTER_DEFAULT = 0;
-const UINT WINED3DENUM_NO_WHQL_LEVEL = 2;
-const UINT WINED3DPRESENT_BACK_BUFFER_MAX = 3;
-
-const UINT WINED3DTSS_TCI_PASSTHRU = 0x00000;
-const UINT WINED3DTSS_TCI_CAMERASPACENORMAL = 0x10000;
-const UINT WINED3DTSS_TCI_CAMERASPACEPOSITION = 0x20000;
-const UINT WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR = 0x30000;
-const UINT WINED3DTSS_TCI_SPHEREMAP = 0x40000;
-
-const UINT WINED3DTA_SELECTMASK = 0x0000000f;
-const UINT WINED3DTA_DIFFUSE = 0x00000000;
-const UINT WINED3DTA_CURRENT = 0x00000001;
-const UINT WINED3DTA_TEXTURE = 0x00000002;
-const UINT WINED3DTA_TFACTOR = 0x00000003;
-const UINT WINED3DTA_SPECULAR = 0x00000004;
-const UINT WINED3DTA_TEMP = 0x00000005;
-const UINT WINED3DTA_CONSTANT = 0x00000006;
-const UINT WINED3DTA_COMPLEMENT = 0x00000010;
-const UINT WINED3DTA_ALPHAREPLICATE = 0x00000020;
-
-const UINT WINED3DPRESENTFLAG_LOCKABLE_BACKBUFFER = 0x00000001;
-const UINT WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL = 0x00000002;
-const UINT WINED3DPRESENTFLAG_DEVICECLIP = 0x00000004;
-const UINT WINED3DPRESENTFLAG_VIDEO = 0x00000010;
-const UINT WINED3DPRESENTFLAG_NOAUTOROTATE = 0x00000020;
-const UINT WINED3DPRESENTFLAG_UNPRUNEDMODE = 0x00000040;
-
-const UINT WINED3DDP_MAXTEXCOORD = 8;
-
-const UINT WINED3DUSAGE_RENDERTARGET = 0x00000001;
-const UINT WINED3DUSAGE_DEPTHSTENCIL = 0x00000002;
-const UINT WINED3DUSAGE_WRITEONLY = 0x00000008;
-const UINT WINED3DUSAGE_SOFTWAREPROCESSING = 0x00000010;
-const UINT WINED3DUSAGE_DONOTCLIP = 0x00000020;
-const UINT WINED3DUSAGE_POINTS = 0x00000040;
-const UINT WINED3DUSAGE_RTPATCHES = 0x00000080;
-const UINT WINED3DUSAGE_NPATCHES = 0x00000100;
-const UINT WINED3DUSAGE_DYNAMIC = 0x00000200;
-const UINT WINED3DUSAGE_AUTOGENMIPMAP = 0x00000400;
-const UINT WINED3DUSAGE_DMAP = 0x00004000;
-const UINT WINED3DUSAGE_MASK = 0x00004fff;
-const UINT WINED3DUSAGE_STATICDECL = 0x40000000;
-const UINT WINED3DUSAGE_OVERLAY = 0x80000000;
-
-const UINT WINED3DUSAGE_QUERY_LEGACYBUMPMAP = 0x00008000;
-const UINT WINED3DUSAGE_QUERY_FILTER = 0x00020000;
-const UINT WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING = 0x00080000;
-const UINT WINED3DUSAGE_QUERY_SRGBREAD = 0x00010000;
-const UINT WINED3DUSAGE_QUERY_SRGBWRITE = 0x00040000;
-const UINT WINED3DUSAGE_QUERY_VERTEXTEXTURE = 0x00100000;
-const UINT WINED3DUSAGE_QUERY_WRAPANDMIP = 0x00200000;
-const UINT WINED3DUSAGE_QUERY_MASK = 0x003f8000;
-
-const UINT WINED3DLOCK_READONLY = 0x0010;
-const UINT WINED3DLOCK_NOSYSLOCK = 0x0800;
-const UINT WINED3DLOCK_NOOVERWRITE = 0x1000;
-const UINT WINED3DLOCK_DISCARD = 0x2000;
-const UINT WINED3DLOCK_DONOTWAIT = 0x4000;
-const UINT WINED3DLOCK_NO_DIRTY_UPDATE = 0x8000;
-
-const UINT WINED3DPRESENT_RATE_DEFAULT = 0x000000000;
-
-const UINT WINED3DPRESENT_INTERVAL_DEFAULT = 0x00000000;
-const UINT WINED3DPRESENT_INTERVAL_ONE = 0x00000001;
-const UINT WINED3DPRESENT_INTERVAL_TWO = 0x00000002;
-const UINT WINED3DPRESENT_INTERVAL_THREE = 0x00000004;
-const UINT WINED3DPRESENT_INTERVAL_FOUR = 0x00000008;
-const UINT WINED3DPRESENT_INTERVAL_IMMEDIATE = 0x80000000;
-
-const UINT WINED3DMAXUSERCLIPPLANES = 32;
-const UINT WINED3DCLIPPLANE0 = (1 << 0);
-const UINT WINED3DCLIPPLANE1 = (1 << 1);
-const UINT WINED3DCLIPPLANE2 = (1 << 2);
-const UINT WINED3DCLIPPLANE3 = (1 << 3);
-const UINT WINED3DCLIPPLANE4 = (1 << 4);
-const UINT WINED3DCLIPPLANE5 = (1 << 5);
-
-/* FVF (Flexible Vertex Format) codes */
-const UINT WINED3DFVF_RESERVED0 = 0x0001;
-const UINT WINED3DFVF_POSITION_MASK = 0x400e;
-const UINT WINED3DFVF_XYZ = 0x0002;
-const UINT WINED3DFVF_XYZRHW = 0x0004;
-const UINT WINED3DFVF_XYZB1 = 0x0006;
-const UINT WINED3DFVF_XYZB2 = 0x0008;
-const UINT WINED3DFVF_XYZB3 = 0x000a;
-const UINT WINED3DFVF_XYZB4 = 0x000c;
-const UINT WINED3DFVF_XYZB5 = 0x000e;
-const UINT WINED3DFVF_XYZW = 0x4002;
-const UINT WINED3DFVF_NORMAL = 0x0010;
-const UINT WINED3DFVF_PSIZE = 0x0020;
-const UINT WINED3DFVF_DIFFUSE = 0x0040;
-const UINT WINED3DFVF_SPECULAR = 0x0080;
-const UINT WINED3DFVF_TEXCOUNT_MASK = 0x0f00;
-const UINT WINED3DFVF_TEXCOUNT_SHIFT = 8;
-const UINT WINED3DFVF_TEX0 = 0x0000;
-const UINT WINED3DFVF_TEX1 = 0x0100;
-const UINT WINED3DFVF_TEX2 = 0x0200;
-const UINT WINED3DFVF_TEX3 = 0x0300;
-const UINT WINED3DFVF_TEX4 = 0x0400;
-const UINT WINED3DFVF_TEX5 = 0x0500;
-const UINT WINED3DFVF_TEX6 = 0x0600;
-const UINT WINED3DFVF_TEX7 = 0x0700;
-const UINT WINED3DFVF_TEX8 = 0x0800;
-const UINT WINED3DFVF_LASTBETA_UBYTE4 = 0x1000;
-const UINT WINED3DFVF_LASTBETA_D3DCOLOR = 0x8000;
-const UINT WINED3DFVF_RESERVED2 = 0x6000;
-
-const UINT WINED3DFVF_TEXTUREFORMAT1 = 3;
-const UINT WINED3DFVF_TEXTUREFORMAT2 = 0;
-const UINT WINED3DFVF_TEXTUREFORMAT3 = 1;
-const UINT WINED3DFVF_TEXTUREFORMAT4 = 2;
-cpp_quote("#define WINED3DFVF_TEXCOORDSIZE1(CoordIndex) (WINED3DFVF_TEXTUREFORMAT1 << (CoordIndex*2 + 16))")
-cpp_quote("#define WINED3DFVF_TEXCOORDSIZE2(CoordIndex) (WINED3DFVF_TEXTUREFORMAT2)")
-cpp_quote("#define WINED3DFVF_TEXCOORDSIZE3(CoordIndex) (WINED3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16))")
-cpp_quote("#define WINED3DFVF_TEXCOORDSIZE4(CoordIndex) (WINED3DFVF_TEXTUREFORMAT4 << (CoordIndex*2 + 16))")
-
-/* Clear flags */
-const UINT WINED3DCLEAR_TARGET = 0x00000001;
-const UINT WINED3DCLEAR_ZBUFFER = 0x00000002;
-const UINT WINED3DCLEAR_STENCIL = 0x00000004;
-
-/* Stream source flags */
-const UINT WINED3DSTREAMSOURCE_INDEXEDDATA = (1 << 30);
-const UINT WINED3DSTREAMSOURCE_INSTANCEDATA = (2 << 30);
-
-/* SetPrivateData flags */
-const UINT WINED3DSPD_IUNKNOWN = 0x00000001;
-
-/* IWineD3D::CreateDevice behaviour flags */
-const UINT WINED3DCREATE_FPU_PRESERVE = 0x00000002;
-const UINT WINED3DCREATE_PUREDEVICE = 0x00000010;
-const UINT WINED3DCREATE_SOFTWARE_VERTEXPROCESSING = 0x00000020;
-const UINT WINED3DCREATE_HARDWARE_VERTEXPROCESSING = 0x00000040;
-const UINT WINED3DCREATE_MIXED_VERTEXPROCESSING = 0x00000080;
-const UINT WINED3DCREATE_DISABLE_DRIVER_MANAGEMENT = 0x00000100;
-const UINT WINED3DCREATE_ADAPTERGROUP_DEVICE = 0x00000200;
-
-/* VTF defines */
-const UINT WINED3DDMAPSAMPLER = 0x100;
-const UINT WINED3DVERTEXTEXTURESAMPLER0 = (WINED3DDMAPSAMPLER + 1);
-const UINT WINED3DVERTEXTEXTURESAMPLER1 = (WINED3DDMAPSAMPLER + 2);
-const UINT WINED3DVERTEXTEXTURESAMPLER2 = (WINED3DDMAPSAMPLER + 3);
-const UINT WINED3DVERTEXTEXTURESAMPLER3 = (WINED3DDMAPSAMPLER + 4);
-
-const UINT WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD = 0x00000020;
-const UINT WINED3DCAPS3_LINEAR_TO_SRGB_PRESENTATION = 0x00000080;
-const UINT WINED3DCAPS3_COPY_TO_VIDMEM = 0x00000100;
-const UINT WINED3DCAPS3_COPY_TO_SYSTEMMEM = 0x00000200;
-const UINT WINED3DCAPS3_RESERVED = 0x8000001f;
-
-const UINT WINED3DDEVCAPS2_STREAMOFFSET = 0x00000001;
-const UINT WINED3DDEVCAPS2_DMAPNPATCH = 0x00000002;
-const UINT WINED3DDEVCAPS2_ADAPTIVETESSRTPATCH = 0x00000004;
-const UINT WINED3DDEVCAPS2_ADAPTIVETESSNPATCH = 0x00000008;
-const UINT WINED3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES = 0x00000010;
-const UINT WINED3DDEVCAPS2_PRESAMPLEDDMAPNPATCH = 0x00000020;
-const UINT WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET = 0x00000040;
-
-const UINT WINED3DDTCAPS_UBYTE4 = 0x00000001;
-const UINT WINED3DDTCAPS_UBYTE4N = 0x00000002;
-const UINT WINED3DDTCAPS_SHORT2N = 0x00000004;
-const UINT WINED3DDTCAPS_SHORT4N = 0x00000008;
-const UINT WINED3DDTCAPS_USHORT2N = 0x00000010;
-const UINT WINED3DDTCAPS_USHORT4N = 0x00000020;
-const UINT WINED3DDTCAPS_UDEC3 = 0x00000040;
-const UINT WINED3DDTCAPS_DEC3N = 0x00000080;
-const UINT WINED3DDTCAPS_FLOAT16_2 = 0x00000100;
-const UINT WINED3DDTCAPS_FLOAT16_4 = 0x00000200;
-
-const UINT WINED3DFVFCAPS_TEXCOORDCOUNTMASK = 0x0000ffff;
-const UINT WINED3DFVFCAPS_DONOTSTRIPELEMENTS = 0x00080000;
-const UINT WINED3DFVFCAPS_PSIZE = 0x00100000;
-
-const UINT WINED3DLINECAPS_TEXTURE = 0x00000001;
-const UINT WINED3DLINECAPS_ZTEST = 0x00000002;
-const UINT WINED3DLINECAPS_BLEND = 0x00000004;
-const UINT WINED3DLINECAPS_ALPHACMP = 0x00000008;
-const UINT WINED3DLINECAPS_FOG = 0x00000010;
-const UINT WINED3DLINECAPS_ANTIALIAS = 0x00000020;
-
-const UINT WINED3DMAX30SHADERINSTRUCTIONS = 32768;
-const UINT WINED3DMIN30SHADERINSTRUCTIONS = 512;
-
-const UINT WINED3DPBLENDCAPS_ZERO = 0x00000001;
-const UINT WINED3DPBLENDCAPS_ONE = 0x00000002;
-const UINT WINED3DPBLENDCAPS_SRCCOLOR = 0x00000004;
-const UINT WINED3DPBLENDCAPS_INVSRCCOLOR = 0x00000008;
-const UINT WINED3DPBLENDCAPS_SRCALPHA = 0x00000010;
-const UINT WINED3DPBLENDCAPS_INVSRCALPHA = 0x00000020;
-const UINT WINED3DPBLENDCAPS_DESTALPHA = 0x00000040;
-const UINT WINED3DPBLENDCAPS_INVDESTALPHA = 0x00000080;
-const UINT WINED3DPBLENDCAPS_DESTCOLOR = 0x00000100;
-const UINT WINED3DPBLENDCAPS_INVDESTCOLOR = 0x00000200;
-const UINT WINED3DPBLENDCAPS_SRCALPHASAT = 0x00000400;
-const UINT WINED3DPBLENDCAPS_BOTHSRCALPHA = 0x00000800;
-const UINT WINED3DPBLENDCAPS_BOTHINVSRCALPHA = 0x00001000;
-const UINT WINED3DPBLENDCAPS_BLENDFACTOR = 0x00002000;
-
-const UINT WINED3DPCMPCAPS_NEVER = 0x00000001;
-const UINT WINED3DPCMPCAPS_LESS = 0x00000002;
-const UINT WINED3DPCMPCAPS_EQUAL = 0x00000004;
-const UINT WINED3DPCMPCAPS_LESSEQUAL = 0x00000008;
-const UINT WINED3DPCMPCAPS_GREATER = 0x00000010;
-const UINT WINED3DPCMPCAPS_NOTEQUAL = 0x00000020;
-const UINT WINED3DPCMPCAPS_GREATEREQUAL = 0x00000040;
-const UINT WINED3DPCMPCAPS_ALWAYS = 0x00000080;
-
-const UINT WINED3DPMISCCAPS_MASKZ = 0x00000002;
-const UINT WINED3DPMISCCAPS_LINEPATTERNREP = 0x00000004;
-const UINT WINED3DPMISCCAPS_CULLNONE = 0x00000010;
-const UINT WINED3DPMISCCAPS_CULLCW = 0x00000020;
-const UINT WINED3DPMISCCAPS_CULLCCW = 0x00000040;
-const UINT WINED3DPMISCCAPS_COLORWRITEENABLE = 0x00000080;
-const UINT WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS = 0x00000100;
-const UINT WINED3DPMISCCAPS_CLIPTLVERTS = 0x00000200;
-const UINT WINED3DPMISCCAPS_TSSARGTEMP = 0x00000400;
-const UINT WINED3DPMISCCAPS_BLENDOP = 0x00000800;
-const UINT WINED3DPMISCCAPS_NULLREFERENCE = 0x00001000;
-const UINT WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS = 0x00004000;
-const UINT WINED3DPMISCCAPS_PERSTAGECONSTANT = 0x00008000;
-const UINT WINED3DPMISCCAPS_FOGANDSPECULARALPHA = 0x00010000;
-const UINT WINED3DPMISCCAPS_SEPARATEALPHABLEND = 0x00020000;
-const UINT WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS = 0x00040000;
-const UINT WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING = 0x00080000;
-const UINT WINED3DPMISCCAPS_FOGVERTEXCLAMPED = 0x00100000;
-
-const UINT WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH = 24;
-const UINT WINED3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0;
-const UINT WINED3DPS20_MAX_NUMTEMPS = 32;
-const UINT WINED3DPS20_MIN_NUMTEMPS = 12;
-const UINT WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH = 4;
-const UINT WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH = 0;
-const UINT WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS = 512;
-const UINT WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS = 96;
-
-const UINT WINED3DPS20CAPS_ARBITRARYSWIZZLE = 0x00000001;
-const UINT WINED3DPS20CAPS_GRADIENTINSTRUCTIONS = 0x00000002;
-const UINT WINED3DPS20CAPS_PREDICATION = 0x00000004;
-const UINT WINED3DPS20CAPS_NODEPENDENTREADLIMIT = 0x00000008;
-const UINT WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT = 0x00000010;
-
-const UINT WINED3DPTADDRESSCAPS_WRAP = 0x00000001;
-const UINT WINED3DPTADDRESSCAPS_MIRROR = 0x00000002;
-const UINT WINED3DPTADDRESSCAPS_CLAMP = 0x00000004;
-const UINT WINED3DPTADDRESSCAPS_BORDER = 0x00000008;
-const UINT WINED3DPTADDRESSCAPS_INDEPENDENTUV = 0x00000010;
-const UINT WINED3DPTADDRESSCAPS_MIRRORONCE = 0x00000020;
-
-const UINT WINED3DSTENCILCAPS_KEEP = 0x00000001;
-const UINT WINED3DSTENCILCAPS_ZERO = 0x00000002;
-const UINT WINED3DSTENCILCAPS_REPLACE = 0x00000004;
-const UINT WINED3DSTENCILCAPS_INCRSAT = 0x00000008;
-const UINT WINED3DSTENCILCAPS_DECRSAT = 0x00000010;
-const UINT WINED3DSTENCILCAPS_INVERT = 0x00000020;
-const UINT WINED3DSTENCILCAPS_INCR = 0x00000040;
-const UINT WINED3DSTENCILCAPS_DECR = 0x00000080;
-const UINT WINED3DSTENCILCAPS_TWOSIDED = 0x00000100;
-
-const UINT WINED3DTEXOPCAPS_DISABLE = 0x00000001;
-const UINT WINED3DTEXOPCAPS_SELECTARG1 = 0x00000002;
-const UINT WINED3DTEXOPCAPS_SELECTARG2 = 0x00000004;
-const UINT WINED3DTEXOPCAPS_MODULATE = 0x00000008;
-const UINT WINED3DTEXOPCAPS_MODULATE2X = 0x00000010;
-const UINT WINED3DTEXOPCAPS_MODULATE4X = 0x00000020;
-const UINT WINED3DTEXOPCAPS_ADD = 0x00000040;
-const UINT WINED3DTEXOPCAPS_ADDSIGNED = 0x00000080;
-const UINT WINED3DTEXOPCAPS_ADDSIGNED2X = 0x00000100;
-const UINT WINED3DTEXOPCAPS_SUBTRACT = 0x00000200;
-const UINT WINED3DTEXOPCAPS_ADDSMOOTH = 0x00000400;
-const UINT WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA = 0x00000800;
-const UINT WINED3DTEXOPCAPS_BLENDTEXTUREALPHA = 0x00001000;
-const UINT WINED3DTEXOPCAPS_BLENDFACTORALPHA = 0x00002000;
-const UINT WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM = 0x00004000;
-const UINT WINED3DTEXOPCAPS_BLENDCURRENTALPHA = 0x00008000;
-const UINT WINED3DTEXOPCAPS_PREMODULATE = 0x00010000;
-const UINT WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR = 0x00020000;
-const UINT WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA = 0x00040000;
-const UINT WINED3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR = 0x00080000;
-const UINT WINED3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA = 0x00100000;
-const UINT WINED3DTEXOPCAPS_BUMPENVMAP = 0x00200000;
-const UINT WINED3DTEXOPCAPS_BUMPENVMAPLUMINANCE = 0x00400000;
-const UINT WINED3DTEXOPCAPS_DOTPRODUCT3 = 0x00800000;
-const UINT WINED3DTEXOPCAPS_MULTIPLYADD = 0x01000000;
-const UINT WINED3DTEXOPCAPS_LERP = 0x02000000;
-
-const UINT WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH = 24;
-const UINT WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0;
-const UINT WINED3DVS20_MAX_NUMTEMPS = 32;
-const UINT WINED3DVS20_MIN_NUMTEMPS = 12;
-const UINT WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH = 4;
-const UINT WINED3DVS20_MIN_STATICFLOWCONTROLDEPTH = 1;
-
-const UINT WINED3DVS20CAPS_PREDICATION = 0x00000001;
-
-const UINT WINED3DCAPS2_NO2DDURING3DSCENE = 0x00000002;
-const UINT WINED3DCAPS2_FULLSCREENGAMMA = 0x00020000;
-const UINT WINED3DCAPS2_CANRENDERWINDOWED = 0x00080000;
-const UINT WINED3DCAPS2_CANCALIBRATEGAMMA = 0x00100000;
-const UINT WINED3DCAPS2_RESERVED = 0x02000000;
-const UINT WINED3DCAPS2_CANMANAGERESOURCE = 0x10000000;
-const UINT WINED3DCAPS2_DYNAMICTEXTURES = 0x20000000;
-const UINT WINED3DCAPS2_CANAUTOGENMIPMAP = 0x40000000;
-
-const UINT WINED3DPRASTERCAPS_DITHER = 0x00000001;
-const UINT WINED3DPRASTERCAPS_ROP2 = 0x00000002;
-const UINT WINED3DPRASTERCAPS_XOR = 0x00000004;
-const UINT WINED3DPRASTERCAPS_PAT = 0x00000008;
-const UINT WINED3DPRASTERCAPS_ZTEST = 0x00000010;
-const UINT WINED3DPRASTERCAPS_SUBPIXEL = 0x00000020;
-const UINT WINED3DPRASTERCAPS_SUBPIXELX = 0x00000040;
-const UINT WINED3DPRASTERCAPS_FOGVERTEX = 0x00000080;
-const UINT WINED3DPRASTERCAPS_FOGTABLE = 0x00000100;
-const UINT WINED3DPRASTERCAPS_STIPPLE = 0x00000200;
-const UINT WINED3DPRASTERCAPS_ANTIALIASSORTDEPENDENT = 0x00000400;
-const UINT WINED3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT = 0x00000800;
-const UINT WINED3DPRASTERCAPS_ANTIALIASEDGES = 0x00001000;
-const UINT WINED3DPRASTERCAPS_MIPMAPLODBIAS = 0x00002000;
-const UINT WINED3DPRASTERCAPS_ZBIAS = 0x00004000;
-const UINT WINED3DPRASTERCAPS_ZBUFFERLESSHSR = 0x00008000;
-const UINT WINED3DPRASTERCAPS_FOGRANGE = 0x00010000;
-const UINT WINED3DPRASTERCAPS_ANISOTROPY = 0x00020000;
-const UINT WINED3DPRASTERCAPS_WBUFFER = 0x00040000;
-const UINT WINED3DPRASTERCAPS_TRANSLUCENTSORTINDEPENDENT = 0x00080000;
-const UINT WINED3DPRASTERCAPS_WFOG = 0x00100000;
-const UINT WINED3DPRASTERCAPS_ZFOG = 0x00200000;
-const UINT WINED3DPRASTERCAPS_COLORPERSPECTIVE = 0x00400000;
-const UINT WINED3DPRASTERCAPS_SCISSORTEST = 0x01000000;
-const UINT WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS = 0x02000000;
-const UINT WINED3DPRASTERCAPS_DEPTHBIAS = 0x04000000;
-const UINT WINED3DPRASTERCAPS_MULTISAMPLE_TOGGLE = 0x08000000;
-
-const UINT WINED3DPSHADECAPS_COLORFLATMONO = 0x00000001;
-const UINT WINED3DPSHADECAPS_COLORFLATRGB = 0x00000002;
-const UINT WINED3DPSHADECAPS_COLORGOURAUDMONO = 0x00000004;
-const UINT WINED3DPSHADECAPS_COLORGOURAUDRGB = 0x00000008;
-const UINT WINED3DPSHADECAPS_COLORPHONGMONO = 0x00000010;
-const UINT WINED3DPSHADECAPS_COLORPHONGRGB = 0x00000020;
-const UINT WINED3DPSHADECAPS_SPECULARFLATMONO = 0x00000040;
-const UINT WINED3DPSHADECAPS_SPECULARFLATRGB = 0x00000080;
-const UINT WINED3DPSHADECAPS_SPECULARGOURAUDMONO = 0x00000100;
-const UINT WINED3DPSHADECAPS_SPECULARGOURAUDRGB = 0x00000200;
-const UINT WINED3DPSHADECAPS_SPECULARPHONGMONO = 0x00000400;
-const UINT WINED3DPSHADECAPS_SPECULARPHONGRGB = 0x00000800;
-const UINT WINED3DPSHADECAPS_ALPHAFLATBLEND = 0x00001000;
-const UINT WINED3DPSHADECAPS_ALPHAFLATSTIPPLED = 0x00002000;
-const UINT WINED3DPSHADECAPS_ALPHAGOURAUDBLEND = 0x00004000;
-const UINT WINED3DPSHADECAPS_ALPHAGOURAUDSTIPPLED = 0x00008000;
-const UINT WINED3DPSHADECAPS_ALPHAPHONGBLEND = 0x00010000;
-const UINT WINED3DPSHADECAPS_ALPHAPHONGSTIPPLED = 0x00020000;
-const UINT WINED3DPSHADECAPS_FOGFLAT = 0x00040000;
-const UINT WINED3DPSHADECAPS_FOGGOURAUD = 0x00080000;
-const UINT WINED3DPSHADECAPS_FOGPHONG = 0x00100000;
-
-const UINT WINED3DPTEXTURECAPS_PERSPECTIVE = 0x00000001;
-const UINT WINED3DPTEXTURECAPS_POW2 = 0x00000002;
-const UINT WINED3DPTEXTURECAPS_ALPHA = 0x00000004;
-const UINT WINED3DPTEXTURECAPS_TRANSPARENCY = 0x00000008;
-const UINT WINED3DPTEXTURECAPS_BORDER = 0x00000010;
-const UINT WINED3DPTEXTURECAPS_SQUAREONLY = 0x00000020;
-const UINT WINED3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE = 0x00000040;
-const UINT WINED3DPTEXTURECAPS_ALPHAPALETTE = 0x00000080;
-const UINT WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL = 0x00000100;
-const UINT WINED3DPTEXTURECAPS_PROJECTED = 0x00000400;
-const UINT WINED3DPTEXTURECAPS_CUBEMAP = 0x00000800;
-const UINT WINED3DPTEXTURECAPS_COLORKEYBLEND = 0x00001000;
-const UINT WINED3DPTEXTURECAPS_VOLUMEMAP = 0x00002000;
-const UINT WINED3DPTEXTURECAPS_MIPMAP = 0x00004000;
-const UINT WINED3DPTEXTURECAPS_MIPVOLUMEMAP = 0x00008000;
-const UINT WINED3DPTEXTURECAPS_MIPCUBEMAP = 0x00010000;
-const UINT WINED3DPTEXTURECAPS_CUBEMAP_POW2 = 0x00020000;
-const UINT WINED3DPTEXTURECAPS_VOLUMEMAP_POW2 = 0x00040000;
-const UINT WINED3DPTEXTURECAPS_NOPROJECTEDBUMPENV = 0x00200000;
-
-const UINT WINED3DPTFILTERCAPS_NEAREST = 0x00000001;
-const UINT WINED3DPTFILTERCAPS_LINEAR = 0x00000002;
-const UINT WINED3DPTFILTERCAPS_MIPNEAREST = 0x00000004;
-const UINT WINED3DPTFILTERCAPS_MIPLINEAR = 0x00000008;
-const UINT WINED3DPTFILTERCAPS_LINEARMIPNEAREST = 0x00000010;
-const UINT WINED3DPTFILTERCAPS_LINEARMIPLINEAR = 0x00000020;
-const UINT WINED3DPTFILTERCAPS_MINFPOINT = 0x00000100;
-const UINT WINED3DPTFILTERCAPS_MINFLINEAR = 0x00000200;
-const UINT WINED3DPTFILTERCAPS_MINFANISOTROPIC = 0x00000400;
-const UINT WINED3DPTFILTERCAPS_MIPFPOINT = 0x00010000;
-const UINT WINED3DPTFILTERCAPS_MIPFLINEAR = 0x00020000;
-const UINT WINED3DPTFILTERCAPS_MAGFPOINT = 0x01000000;
-const UINT WINED3DPTFILTERCAPS_MAGFLINEAR = 0x02000000;
-const UINT WINED3DPTFILTERCAPS_MAGFANISOTROPIC = 0x04000000;
-const UINT WINED3DPTFILTERCAPS_MAGFPYRAMIDALQUAD = 0x08000000;
-const UINT WINED3DPTFILTERCAPS_MAGFGAUSSIANQUAD = 0x10000000;
-
-const UINT WINED3DVTXPCAPS_TEXGEN = 0x00000001;
-const UINT WINED3DVTXPCAPS_MATERIALSOURCE7 = 0x00000002;
-const UINT WINED3DVTXPCAPS_VERTEXFOG = 0x00000004;
-const UINT WINED3DVTXPCAPS_DIRECTIONALLIGHTS = 0x00000008;
-const UINT WINED3DVTXPCAPS_POSITIONALLIGHTS = 0x00000010;
-const UINT WINED3DVTXPCAPS_LOCALVIEWER = 0x00000020;
-const UINT WINED3DVTXPCAPS_TWEENING = 0x00000040;
-const UINT WINED3DVTXPCAPS_TEXGEN_SPHEREMAP = 0x00000100;
-const UINT WINED3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER = 0x00000200;
-
-const UINT WINED3DCURSORCAPS_COLOR = 0x00000001;
-const UINT WINED3DCURSORCAPS_LOWRES = 0x00000002;
-
-const UINT WINED3DDEVCAPS_FLOATTLVERTEX = 0x00000001;
-const UINT WINED3DDEVCAPS_SORTINCREASINGZ = 0x00000002;
-const UINT WINED3DDEVCAPS_SORTDECREASINGZ = 0X00000004;
-const UINT WINED3DDEVCAPS_SORTEXACT = 0x00000008;
-const UINT WINED3DDEVCAPS_EXECUTESYSTEMMEMORY = 0x00000010;
-const UINT WINED3DDEVCAPS_EXECUTEVIDEOMEMORY = 0x00000020;
-const UINT WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY = 0x00000040;
-const UINT WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY = 0x00000080;
-const UINT WINED3DDEVCAPS_TEXTURESYSTEMMEMORY = 0x00000100;
-const UINT WINED3DDEVCAPS_TEXTUREVIDEOMEMORY = 0x00000200;
-const UINT WINED3DDEVCAPS_DRAWPRIMTLVERTEX = 0x00000400;
-const UINT WINED3DDEVCAPS_CANRENDERAFTERFLIP = 0x00000800;
-const UINT WINED3DDEVCAPS_TEXTURENONLOCALVIDMEM = 0x00001000;
-const UINT WINED3DDEVCAPS_DRAWPRIMITIVES2 = 0x00002000;
-const UINT WINED3DDEVCAPS_SEPARATETEXTUREMEMORIES = 0x00004000;
-const UINT WINED3DDEVCAPS_DRAWPRIMITIVES2EX = 0x00008000;
-const UINT WINED3DDEVCAPS_HWTRANSFORMANDLIGHT = 0x00010000;
-const UINT WINED3DDEVCAPS_CANBLTSYSTONONLOCAL = 0x00020000;
-const UINT WINED3DDEVCAPS_HWRASTERIZATION = 0x00080000;
-const UINT WINED3DDEVCAPS_PUREDEVICE = 0x00100000;
-const UINT WINED3DDEVCAPS_QUINTICRTPATCHES = 0x00200000;
-const UINT WINED3DDEVCAPS_RTPATCHES = 0x00400000;
-const UINT WINED3DDEVCAPS_RTPATCHHANDLEZERO = 0x00800000;
-const UINT WINED3DDEVCAPS_NPATCHES = 0x01000000;
-
-/* dwDDFX */
-/* arithmetic stretching along y axis */
-const UINT WINEDDBLTFX_ARITHSTRETCHY = 0x00000001;
-/* mirror on y axis */
-const UINT WINEDDBLTFX_MIRRORLEFTRIGHT = 0x00000002;
-/* mirror on x axis */
-const UINT WINEDDBLTFX_MIRRORUPDOWN = 0x00000004;
-/* do not tear */
-const UINT WINEDDBLTFX_NOTEARING = 0x00000008;
-/* 180 degrees clockwise rotation */
-const UINT WINEDDBLTFX_ROTATE180 = 0x00000010;
-/* 270 degrees clockwise rotation */
-const UINT WINEDDBLTFX_ROTATE270 = 0x00000020;
-/* 90 degrees clockwise rotation */
-const UINT WINEDDBLTFX_ROTATE90 = 0x00000040;
-/* dwZBufferLow and dwZBufferHigh specify limits to the copied Z values */
-const UINT WINEDDBLTFX_ZBUFFERRANGE = 0x00000080;
-/* add dwZBufferBaseDest to every source z value before compare */
-const UINT WINEDDBLTFX_ZBUFFERBASEDEST = 0x00000100;
-
-/* dwFlags for Blt* */
-const UINT WINEDDBLT_ALPHADEST = 0x00000001;
-const UINT WINEDDBLT_ALPHADESTCONSTOVERRIDE = 0x00000002;
-const UINT WINEDDBLT_ALPHADESTNEG = 0x00000004;
-const UINT WINEDDBLT_ALPHADESTSURFACEOVERRIDE = 0x00000008;
-const UINT WINEDDBLT_ALPHAEDGEBLEND = 0x00000010;
-const UINT WINEDDBLT_ALPHASRC = 0x00000020;
-const UINT WINEDDBLT_ALPHASRCCONSTOVERRIDE = 0x00000040;
-const UINT WINEDDBLT_ALPHASRCNEG = 0x00000080;
-const UINT WINEDDBLT_ALPHASRCSURFACEOVERRIDE = 0x00000100;
-const UINT WINEDDBLT_ASYNC = 0x00000200;
-const UINT WINEDDBLT_COLORFILL = 0x00000400;
-const UINT WINEDDBLT_DDFX = 0x00000800;
-const UINT WINEDDBLT_DDROPS = 0x00001000;
-const UINT WINEDDBLT_KEYDEST = 0x00002000;
-const UINT WINEDDBLT_KEYDESTOVERRIDE = 0x00004000;
-const UINT WINEDDBLT_KEYSRC = 0x00008000;
-const UINT WINEDDBLT_KEYSRCOVERRIDE = 0x00010000;
-const UINT WINEDDBLT_ROP = 0x00020000;
-const UINT WINEDDBLT_ROTATIONANGLE = 0x00040000;
-const UINT WINEDDBLT_ZBUFFER = 0x00080000;
-const UINT WINEDDBLT_ZBUFFERDESTCONSTOVERRIDE = 0x00100000;
-const UINT WINEDDBLT_ZBUFFERDESTOVERRIDE = 0x00200000;
-const UINT WINEDDBLT_ZBUFFERSRCCONSTOVERRIDE = 0x00400000;
-const UINT WINEDDBLT_ZBUFFERSRCOVERRIDE = 0x00800000;
-const UINT WINEDDBLT_WAIT = 0x01000000;
-const UINT WINEDDBLT_DEPTHFILL = 0x02000000;
-const UINT WINEDDBLT_DONOTWAIT = 0x08000000;
-
-/* dwTrans for BltFast */
-const UINT WINEDDBLTFAST_NOCOLORKEY = 0x00000000;
-const UINT WINEDDBLTFAST_SRCCOLORKEY = 0x00000001;
-const UINT WINEDDBLTFAST_DESTCOLORKEY = 0x00000002;
-const UINT WINEDDBLTFAST_WAIT = 0x00000010;
-const UINT WINEDDBLTFAST_DONOTWAIT = 0x00000020;
-
-/* DDSURFACEDESC.dwFlags */
-const UINT WINEDDSD_CAPS = 0x00000001;
-const UINT WINEDDSD_HEIGHT = 0x00000002;
-const UINT WINEDDSD_WIDTH = 0x00000004;
-const UINT WINEDDSD_PITCH = 0x00000008;
-const UINT WINEDDSD_BACKBUFFERCOUNT = 0x00000020;
-const UINT WINEDDSD_ZBUFFERBITDEPTH = 0x00000040;
-const UINT WINEDDSD_ALPHABITDEPTH = 0x00000080;
-const UINT WINEDDSD_LPSURFACE = 0x00000800;
-const UINT WINEDDSD_PIXELFORMAT = 0x00001000;
-const UINT WINEDDSD_CKDESTOVERLAY = 0x00002000;
-const UINT WINEDDSD_CKDESTBLT = 0x00004000;
-const UINT WINEDDSD_CKSRCOVERLAY = 0x00008000;
-const UINT WINEDDSD_CKSRCBLT = 0x00010000;
-const UINT WINEDDSD_MIPMAPCOUNT = 0x00020000;
-const UINT WINEDDSD_REFRESHRATE = 0x00040000;
-const UINT WINEDDSD_LINEARSIZE = 0x00080000;
-const UINT WINEDDSD_TEXTURESTAGE = 0x00100000;
-const UINT WINEDDSD_FVF = 0x00200000;
-const UINT WINEDDSD_SRCVBHANDLE = 0x00400000;
-const UINT WINEDDSD_ALL = 0x007ff9ee;
-
-/* Set/Get Colour Key Flags */
-const UINT WINEDDCKEY_COLORSPACE = 0x00000001; /* Struct is single colour space */
-const UINT WINEDDCKEY_DESTBLT = 0x00000002; /* To be used as dest for blt */
-const UINT WINEDDCKEY_DESTOVERLAY = 0x00000004; /* To be used as dest for CK overlays */
-const UINT WINEDDCKEY_SRCBLT = 0x00000008; /* To be used as src for blt */
-const UINT WINEDDCKEY_SRCOVERLAY = 0x00000010; /* To be used as src for CK overlays */
-
-/* dwFlags for GetBltStatus */
-const UINT WINEDDGBS_CANBLT = 0x00000001;
-const UINT WINEDDGBS_ISBLTDONE = 0x00000002;
-
-/* dwFlags for GetFlipStatus */
-const UINT WINEDDGFS_CANFLIP = 0x00000001;
-const UINT WINEDDGFS_ISFLIPDONE = 0x00000002;
-
-/* dwFlags for Flip */
-const UINT WINEDDFLIP_WAIT = 0x00000001;
-const UINT WINEDDFLIP_EVEN = 0x00000002; /* only valid for overlay */
-const UINT WINEDDFLIP_ODD = 0x00000004; /* only valid for overlay */
-const UINT WINEDDFLIP_NOVSYNC = 0x00000008;
-const UINT WINEDDFLIP_STEREO = 0x00000010;
-const UINT WINEDDFLIP_DONOTWAIT = 0x00000020;
-const UINT WINEDDFLIP_INTERVAL2 = 0x02000000;
-const UINT WINEDDFLIP_INTERVAL3 = 0x03000000;
-const UINT WINEDDFLIP_INTERVAL4 = 0x04000000;
-
-const UINT WINEDDOVER_ALPHADEST = 0x00000001;
-const UINT WINEDDOVER_ALPHADESTCONSTOVERRIDE = 0x00000002;
-const UINT WINEDDOVER_ALPHADESTNEG = 0x00000004;
-const UINT WINEDDOVER_ALPHADESTSURFACEOVERRIDE = 0x00000008;
-const UINT WINEDDOVER_ALPHAEDGEBLEND = 0x00000010;
-const UINT WINEDDOVER_ALPHASRC = 0x00000020;
-const UINT WINEDDOVER_ALPHASRCCONSTOVERRIDE = 0x00000040;
-const UINT WINEDDOVER_ALPHASRCNEG = 0x00000080;
-const UINT WINEDDOVER_ALPHASRCSURFACEOVERRIDE = 0x00000100;
-const UINT WINEDDOVER_HIDE = 0x00000200;
-const UINT WINEDDOVER_KEYDEST = 0x00000400;
-const UINT WINEDDOVER_KEYDESTOVERRIDE = 0x00000800;
-const UINT WINEDDOVER_KEYSRC = 0x00001000;
-const UINT WINEDDOVER_KEYSRCOVERRIDE = 0x00002000;
-const UINT WINEDDOVER_SHOW = 0x00004000;
-const UINT WINEDDOVER_ADDDIRTYRECT = 0x00008000;
-const UINT WINEDDOVER_REFRESHDIRTYRECTS = 0x00010000;
-const UINT WINEDDOVER_REFRESHALL = 0x00020000;
-const UINT WINEDDOVER_DDFX = 0x00080000;
-const UINT WINEDDOVER_AUTOFLIP = 0x00100000;
-const UINT WINEDDOVER_BOB = 0x00200000;
-const UINT WINEDDOVER_OVERRIDEBOBWEAVE = 0x00400000;
-const UINT WINEDDOVER_INTERLEAVED = 0x00800000;
-
-/* DirectDraw Caps */
-const UINT WINEDDSCAPS_RESERVED1 = 0x00000001;
-const UINT WINEDDSCAPS_ALPHA = 0x00000002;
-const UINT WINEDDSCAPS_BACKBUFFER = 0x00000004;
-const UINT WINEDDSCAPS_COMPLEX = 0x00000008;
-const UINT WINEDDSCAPS_FLIP = 0x00000010;
-const UINT WINEDDSCAPS_FRONTBUFFER = 0x00000020;
-const UINT WINEDDSCAPS_OFFSCREENPLAIN = 0x00000040;
-const UINT WINEDDSCAPS_OVERLAY = 0x00000080;
-const UINT WINEDDSCAPS_PALETTE = 0x00000100;
-const UINT WINEDDSCAPS_PRIMARYSURFACE = 0x00000200;
-const UINT WINEDDSCAPS_PRIMARYSURFACELEFT = 0x00000400;
-const UINT WINEDDSCAPS_SYSTEMMEMORY = 0x00000800;
-const UINT WINEDDSCAPS_TEXTURE = 0x00001000;
-const UINT WINEDDSCAPS_3DDEVICE = 0x00002000;
-const UINT WINEDDSCAPS_VIDEOMEMORY = 0x00004000;
-const UINT WINEDDSCAPS_VISIBLE = 0x00008000;
-const UINT WINEDDSCAPS_WRITEONLY = 0x00010000;
-const UINT WINEDDSCAPS_ZBUFFER = 0x00020000;
-const UINT WINEDDSCAPS_OWNDC = 0x00040000;
-const UINT WINEDDSCAPS_LIVEVIDEO = 0x00080000;
-const UINT WINEDDSCAPS_HWCODEC = 0x00100000;
-const UINT WINEDDSCAPS_MODEX = 0x00200000;
-const UINT WINEDDSCAPS_MIPMAP = 0x00400000;
-const UINT WINEDDSCAPS_RESERVED2 = 0x00800000;
-const UINT WINEDDSCAPS_ALLOCONLOAD = 0x04000000;
-const UINT WINEDDSCAPS_VIDEOPORT = 0x08000000;
-const UINT WINEDDSCAPS_LOCALVIDMEM = 0x10000000;
-const UINT WINEDDSCAPS_NONLOCALVIDMEM = 0x20000000;
-const UINT WINEDDSCAPS_STANDARDVGAMODE = 0x40000000;
-const UINT WINEDDSCAPS_OPTIMIZED = 0x80000000;
-
-const UINT WINEDDCKEYCAPS_DESTBLT = 0x00000001;
-const UINT WINEDDCKEYCAPS_DESTBLTCLRSPACE = 0x00000002;
-const UINT WINEDDCKEYCAPS_DESTBLTCLRSPACEYUV = 0x00000004;
-const UINT WINEDDCKEYCAPS_DESTBLTYUV = 0x00000008;
-const UINT WINEDDCKEYCAPS_DESTOVERLAY = 0x00000010;
-const UINT WINEDDCKEYCAPS_DESTOVERLAYCLRSPACE = 0x00000020;
-const UINT WINEDDCKEYCAPS_DESTOVERLAYCLRSPACEYUV = 0x00000040;
-const UINT WINEDDCKEYCAPS_DESTOVERLAYONEACTIVE = 0x00000080;
-const UINT WINEDDCKEYCAPS_DESTOVERLAYYUV = 0x00000100;
-const UINT WINEDDCKEYCAPS_SRCBLT = 0x00000200;
-const UINT WINEDDCKEYCAPS_SRCBLTCLRSPACE = 0x00000400;
-const UINT WINEDDCKEYCAPS_SRCBLTCLRSPACEYUV = 0x00000800;
-const UINT WINEDDCKEYCAPS_SRCBLTYUV = 0x00001000;
-const UINT WINEDDCKEYCAPS_SRCOVERLAY = 0x00002000;
-const UINT WINEDDCKEYCAPS_SRCOVERLAYCLRSPACE = 0x00004000;
-const UINT WINEDDCKEYCAPS_SRCOVERLAYCLRSPACEYUV = 0x00008000;
-const UINT WINEDDCKEYCAPS_SRCOVERLAYONEACTIVE = 0x00010000;
-const UINT WINEDDCKEYCAPS_SRCOVERLAYYUV = 0x00020000;
-const UINT WINEDDCKEYCAPS_NOCOSTOVERLAY = 0x00040000;
-
-const UINT WINEDDFXCAPS_BLTALPHA = 0x00000001;
-const UINT WINEDDFXCAPS_OVERLAYALPHA = 0x00000004;
-const UINT WINEDDFXCAPS_BLTARITHSTRETCHYN = 0x00000010;
-const UINT WINEDDFXCAPS_BLTARITHSTRETCHY = 0x00000020;
-const UINT WINEDDFXCAPS_BLTMIRRORLEFTRIGHT = 0x00000040;
-const UINT WINEDDFXCAPS_BLTMIRRORUPDOWN = 0x00000080;
-const UINT WINEDDFXCAPS_BLTROTATION = 0x00000100;
-const UINT WINEDDFXCAPS_BLTROTATION90 = 0x00000200;
-const UINT WINEDDFXCAPS_BLTSHRINKX = 0x00000400;
-const UINT WINEDDFXCAPS_BLTSHRINKXN = 0x00000800;
-const UINT WINEDDFXCAPS_BLTSHRINKY = 0x00001000;
-const UINT WINEDDFXCAPS_BLTSHRINKYN = 0x00002000;
-const UINT WINEDDFXCAPS_BLTSTRETCHX = 0x00004000;
-const UINT WINEDDFXCAPS_BLTSTRETCHXN = 0x00008000;
-const UINT WINEDDFXCAPS_BLTSTRETCHY = 0x00010000;
-const UINT WINEDDFXCAPS_BLTSTRETCHYN = 0x00020000;
-const UINT WINEDDFXCAPS_OVERLAYARITHSTRETCHY = 0x00040000;
-const UINT WINEDDFXCAPS_OVERLAYARITHSTRETCHYN = 0x00000008;
-const UINT WINEDDFXCAPS_OVERLAYSHRINKX = 0x00080000;
-const UINT WINEDDFXCAPS_OVERLAYSHRINKXN = 0x00100000;
-const UINT WINEDDFXCAPS_OVERLAYSHRINKY = 0x00200000;
-const UINT WINEDDFXCAPS_OVERLAYSHRINKYN = 0x00400000;
-const UINT WINEDDFXCAPS_OVERLAYSTRETCHX = 0x00800000;
-const UINT WINEDDFXCAPS_OVERLAYSTRETCHXN = 0x01000000;
-const UINT WINEDDFXCAPS_OVERLAYSTRETCHY = 0x02000000;
-const UINT WINEDDFXCAPS_OVERLAYSTRETCHYN = 0x04000000;
-const UINT WINEDDFXCAPS_OVERLAYMIRRORLEFTRIGHT = 0x08000000;
-const UINT WINEDDFXCAPS_OVERLAYMIRRORUPDOWN = 0x10000000;
-
-const UINT WINEDDCAPS_3D = 0x00000001;
-const UINT WINEDDCAPS_ALIGNBOUNDARYDEST = 0x00000002;
-const UINT WINEDDCAPS_ALIGNSIZEDEST = 0x00000004;
-const UINT WINEDDCAPS_ALIGNBOUNDARYSRC = 0x00000008;
-const UINT WINEDDCAPS_ALIGNSIZESRC = 0x00000010;
-const UINT WINEDDCAPS_ALIGNSTRIDE = 0x00000020;
-const UINT WINEDDCAPS_BLT = 0x00000040;
-const UINT WINEDDCAPS_BLTQUEUE = 0x00000080;
-const UINT WINEDDCAPS_BLTFOURCC = 0x00000100;
-const UINT WINEDDCAPS_BLTSTRETCH = 0x00000200;
-const UINT WINEDDCAPS_GDI = 0x00000400;
-const UINT WINEDDCAPS_OVERLAY = 0x00000800;
-const UINT WINEDDCAPS_OVERLAYCANTCLIP = 0x00001000;
-const UINT WINEDDCAPS_OVERLAYFOURCC = 0x00002000;
-const UINT WINEDDCAPS_OVERLAYSTRETCH = 0x00004000;
-const UINT WINEDDCAPS_PALETTE = 0x00008000;
-const UINT WINEDDCAPS_PALETTEVSYNC = 0x00010000;
-const UINT WINEDDCAPS_READSCANLINE = 0x00020000;
-const UINT WINEDDCAPS_STEREOVIEW = 0x00040000;
-const UINT WINEDDCAPS_VBI = 0x00080000;
-const UINT WINEDDCAPS_ZBLTS = 0x00100000;
-const UINT WINEDDCAPS_ZOVERLAYS = 0x00200000;
-const UINT WINEDDCAPS_COLORKEY = 0x00400000;
-const UINT WINEDDCAPS_ALPHA = 0x00800000;
-const UINT WINEDDCAPS_COLORKEYHWASSIST = 0x01000000;
-const UINT WINEDDCAPS_NOHARDWARE = 0x02000000;
-const UINT WINEDDCAPS_BLTCOLORFILL = 0x04000000;
-const UINT WINEDDCAPS_BANKSWITCHED = 0x08000000;
-const UINT WINEDDCAPS_BLTDEPTHFILL = 0x10000000;
-const UINT WINEDDCAPS_CANCLIP = 0x20000000;
-const UINT WINEDDCAPS_CANCLIPSTRETCHED = 0x40000000;
-const UINT WINEDDCAPS_CANBLTSYSMEM = 0x80000000;
-
-const UINT WINEDDCAPS2_CERTIFIED = 0x00000001;
-const UINT WINEDDCAPS2_NO2DDURING3DSCENE = 0x00000002;
-const UINT WINEDDCAPS2_VIDEOPORT = 0x00000004;
-const UINT WINEDDCAPS2_AUTOFLIPOVERLAY = 0x00000008;
-const UINT WINEDDCAPS2_CANBOBINTERLEAVED = 0x00000010;
-const UINT WINEDDCAPS2_CANBOBNONINTERLEAVED = 0x00000020;
-const UINT WINEDDCAPS2_COLORCONTROLOVERLAY = 0x00000040;
-const UINT WINEDDCAPS2_COLORCONTROLPRIMARY = 0x00000080;
-const UINT WINEDDCAPS2_CANDROPZ16BIT = 0x00000100;
-const UINT WINEDDCAPS2_NONLOCALVIDMEM = 0x00000200;
-const UINT WINEDDCAPS2_NONLOCALVIDMEMCAPS = 0x00000400;
-const UINT WINEDDCAPS2_NOPAGELOCKREQUIRED = 0x00000800;
-const UINT WINEDDCAPS2_WIDESURFACES = 0x00001000;
-const UINT WINEDDCAPS2_CANFLIPODDEVEN = 0x00002000;
-const UINT WINEDDCAPS2_CANBOBHARDWARE = 0x00004000;
-const UINT WINEDDCAPS2_COPYFOURCC = 0x00008000;
-const UINT WINEDDCAPS2_PRIMARYGAMMA = 0x00020000;
-const UINT WINEDDCAPS2_CANRENDERWINDOWED = 0x00080000;
-const UINT WINEDDCAPS2_CANCALIBRATEGAMMA = 0x00100000;
-const UINT WINEDDCAPS2_FLIPINTERVAL = 0x00200000;
-const UINT WINEDDCAPS2_FLIPNOVSYNC = 0x00400000;
-const UINT WINEDDCAPS2_CANMANAGETEXTURE = 0x00800000;
-const UINT WINEDDCAPS2_TEXMANINNONLOCALVIDMEM = 0x01000000;
-const UINT WINEDDCAPS2_STEREO = 0x02000000;
-const UINT WINEDDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL = 0x04000000;
-
-/* DDCAPS.d */
-const UINT WINEDDPCAPS_4BIT = 0x00000001;
-const UINT WINEDDPCAPS_8BITENTRIES = 0x00000002;
-const UINT WINEDDPCAPS_8BIT = 0x00000004;
-const UINT WINEDDPCAPS_INITIALIZE = 0x00000008;
-const UINT WINEDDPCAPS_PRIMARYSURFACE = 0x00000010;
-const UINT WINEDDPCAPS_PRIMARYSURFACELEFT = 0x00000020;
-const UINT WINEDDPCAPS_ALLOW256 = 0x00000040;
-const UINT WINEDDPCAPS_VSYNC = 0x00000080;
-const UINT WINEDDPCAPS_1BIT = 0x00000100;
-const UINT WINEDDPCAPS_2BIT = 0x00000200;
-const UINT WINEDDPCAPS_ALPHA = 0x00000400;
-
-typedef struct _WINED3DDISPLAYMODE
-{
- UINT Width;
- UINT Height;
- UINT RefreshRate;
- enum wined3d_format_id Format;
-} WINED3DDISPLAYMODE;
-
-typedef struct _WINED3DCOLORVALUE
-{
- float r;
- float g;
- float b;
- float a;
-} WINED3DCOLORVALUE;
-
-typedef struct _WINED3DVECTOR
-{
- float x;
- float y;
- float z;
-} WINED3DVECTOR;
-
-typedef struct _WINED3DMATRIX
-{
- union
- {
- struct
- {
- float _11, _12, _13, _14;
- float _21, _22, _23, _24;
- float _31, _32, _33, _34;
- float _41, _42, _43, _44;
- } DUMMYSTRUCTNAME;
- float m[4][4];
- } DUMMYUNIONNAME;
-} WINED3DMATRIX;
-
-typedef struct _WINED3DLIGHT
-{
- WINED3DLIGHTTYPE Type;
- WINED3DCOLORVALUE Diffuse;
- WINED3DCOLORVALUE Specular;
- WINED3DCOLORVALUE Ambient;
- WINED3DVECTOR Position;
- WINED3DVECTOR Direction;
- float Range;
- float Falloff;
- float Attenuation0;
- float Attenuation1;
- float Attenuation2;
- float Theta;
- float Phi;
-} WINED3DLIGHT;
-
-typedef struct _WINED3DMATERIAL
-{
- WINED3DCOLORVALUE Diffuse;
- WINED3DCOLORVALUE Ambient;
- WINED3DCOLORVALUE Specular;
- WINED3DCOLORVALUE Emissive;
- float Power;
-} WINED3DMATERIAL;
-
-typedef struct _WINED3DVIEWPORT
-{
- DWORD X;
- DWORD Y;
- DWORD Width;
- DWORD Height;
- float MinZ;
- float MaxZ;
-} WINED3DVIEWPORT;
-
-typedef struct _WINED3DGAMMARAMP
-{
- WORD red[256];
- WORD green[256];
- WORD blue[256];
-} WINED3DGAMMARAMP;
-
-typedef struct _WINED3DLINEPATTERN
-{
- WORD wRepeatFactor;
- WORD wLinePattern;
-} WINED3DLINEPATTERN;
-
-typedef struct _WINEDD3DRECTPATCH_INFO
-{
- UINT StartVertexOffsetWidth;
- UINT StartVertexOffsetHeight;
- UINT Width;
- UINT Height;
- UINT Stride;
- WINED3DBASISTYPE Basis;
- WINED3DDEGREETYPE Degree;
-} WINED3DRECTPATCH_INFO;
-
-typedef struct _WINED3DTRIPATCH_INFO
-{
- UINT StartVertexOffset;
- UINT NumVertices;
- WINED3DBASISTYPE Basis;
- WINED3DDEGREETYPE Degree;
-} WINED3DTRIPATCH_INFO;
-
-typedef struct _WINED3DADAPTER_IDENTIFIER
-{
- char *driver;
- UINT driver_size;
- char *description;
- UINT description_size;
- char *device_name;
- UINT device_name_size;
- LARGE_INTEGER driver_version;
- DWORD vendor_id;
- DWORD device_id;
- DWORD subsystem_id;
- DWORD revision;
- GUID device_identifier;
- DWORD whql_level;
- LUID adapter_luid;
- SIZE_T video_memory;
-} WINED3DADAPTER_IDENTIFIER;
-
-typedef struct _WINED3DPRESENT_PARAMETERS
-{
- UINT BackBufferWidth;
- UINT BackBufferHeight;
- enum wined3d_format_id BackBufferFormat;
- UINT BackBufferCount;
- WINED3DMULTISAMPLE_TYPE MultiSampleType;
- DWORD MultiSampleQuality;
- WINED3DSWAPEFFECT SwapEffect;
- HWND hDeviceWindow;
- BOOL Windowed;
- BOOL EnableAutoDepthStencil;
- enum wined3d_format_id AutoDepthStencilFormat;
- DWORD Flags;
- UINT FullScreen_RefreshRateInHz;
- UINT PresentationInterval;
- BOOL AutoRestoreDisplayMode;
-} WINED3DPRESENT_PARAMETERS;
-
-typedef struct _WINED3DSURFACE_DESC
-{
- enum wined3d_format_id format;
- WINED3DRESOURCETYPE resource_type;
- DWORD usage;
- WINED3DPOOL pool;
- UINT size;
- WINED3DMULTISAMPLE_TYPE multisample_type;
- DWORD multisample_quality;
- UINT width;
- UINT height;
-} WINED3DSURFACE_DESC;
-
-typedef struct _WINED3DVOLUME_DESC
-{
- enum wined3d_format_id Format;
- WINED3DRESOURCETYPE Type;
- DWORD Usage;
- WINED3DPOOL Pool;
- UINT Size;
- UINT Width;
- UINT Height;
- UINT Depth;
-} WINED3DVOLUME_DESC;
-
-typedef struct _WINED3DCLIPSTATUS
-{
- DWORD ClipUnion;
- DWORD ClipIntersection;
-} WINED3DCLIPSTATUS;
-
-typedef struct _WINED3DVERTEXELEMENT
-{
- enum wined3d_format_id format;
- WORD input_slot;
- WORD offset;
- UINT output_slot; /* D3D 8 & 10 */
- BYTE method;
- BYTE usage;
- BYTE usage_idx;
-} WINED3DVERTEXELEMENT;
-
-typedef struct _WINED3DDEVICE_CREATION_PARAMETERS
-{
- UINT AdapterOrdinal;
- WINED3DDEVTYPE DeviceType;
- HWND hFocusWindow;
- DWORD BehaviorFlags;
-} WINED3DDEVICE_CREATION_PARAMETERS;
-
-typedef struct _WINED3DDEVINFO_BANDWIDTHTIMINGS
-{
- float MaxBandwidthUtilized;
- float FrontEndUploadMemoryUtilizedPercent;
- float VertexRateUtilizedPercent;
- float TriangleSetupRateUtilizedPercent;
- float FillRateUtilizedPercent;
-} WINED3DDEVINFO_BANDWIDTHTIMINGS;
-
-typedef struct _WINED3DDEVINFO_CACHEUTILIZATION
-{
- float TextureCacheHitRate;
- float PostTransformVertexCacheHitRate;
-} WINED3DDEVINFO_CACHEUTILIZATION;
-
-typedef struct _WINED3DDEVINFO_INTERFACETIMINGS
-{
- float WaitingForGPUToUseApplicationResourceTimePercent;
- float WaitingForGPUToAcceptMoreCommandsTimePercent;
- float WaitingForGPUToStayWithinLatencyTimePercent;
- float WaitingForGPUExclusiveResourceTimePercent;
- float WaitingForGPUOtherTimePercent;
-} WINED3DDEVINFO_INTERFACETIMINGS;
-
-typedef struct _WINED3DDEVINFO_PIPELINETIMINGS
-{
- float VertexProcessingTimePercent;
- float PixelProcessingTimePercent;
- float OtherGPUProcessingTimePercent;
- float GPUIdleTimePercent;
-} WINED3DDEVINFO_PIPELINETIMINGS;
-
-typedef struct _WINED3DDEVINFO_STAGETIMINGS
-{
- float MemoryProcessingPercent;
- float ComputationProcessingPercent;
-} WINED3DDEVINFO_STAGETIMINGS;
-
-typedef struct _WINED3DRASTER_STATUS
-{
- BOOL InVBlank;
- UINT ScanLine;
-} WINED3DRASTER_STATUS;
-
-typedef struct WINED3DRESOURCESTATS
-{
- BOOL bThrashing;
- DWORD ApproxBytesDownloaded;
- DWORD NumEvicts;
- DWORD NumVidCreates;
- DWORD LastPri;
- DWORD NumUsed;
- DWORD NumUsedInVidMem;
- DWORD WorkingSet;
- DWORD WorkingSetBytes;
- DWORD TotalManaged;
- DWORD TotalBytes;
-} WINED3DRESOURCESTATS;
-
-typedef struct _WINED3DDEVINFO_RESOURCEMANAGER
-{
- WINED3DRESOURCESTATS stats[WINED3DRTYPECOUNT];
-} WINED3DDEVINFO_RESOURCEMANAGER;
-
-typedef struct _WINED3DDEVINFO_VERTEXSTATS
-{
- DWORD NumRenderedTriangles;
- DWORD NumExtraClippingTriangles;
-} WINED3DDEVINFO_VERTEXSTATS;
-
-typedef struct _WINED3DLOCKED_RECT
-{
- INT Pitch;
- void *pBits;
-} WINED3DLOCKED_RECT;
-
-typedef struct _WINED3DLOCKED_BOX
-{
- INT RowPitch;
- INT SlicePitch;
- void *pBits;
-} WINED3DLOCKED_BOX;
-
-typedef struct _WINED3DBOX
-{
- UINT Left;
- UINT Top;
- UINT Right;
- UINT Bottom;
- UINT Front;
- UINT Back;
-} WINED3DBOX;
-
-/*Vertex cache optimization hints.*/
-typedef struct WINED3DDEVINFO_VCACHE
-{
- DWORD Pattern; /* Must be a 4 char code FOURCC (e.g. CACH) */
- DWORD OptMethod; /* 0 to get the longest strips, 1 vertex cache */
- DWORD CacheSize; /* Cache size to use (only valid if OptMethod==1) */
- DWORD MagicNumber; /* Internal for deciding when to restart strips,
- non user modifiable (only valid if OptMethod==1) */
-} WINED3DDEVINFO_VCACHE;
-
-typedef struct _WINED3DBUFFER_DESC
-{
- WINED3DRESOURCETYPE Type;
- DWORD Usage;
- WINED3DPOOL Pool;
- UINT Size;
-} WINED3DBUFFER_DESC;
-
-typedef struct WineDirect3DStridedData
-{
- enum wined3d_format_id format; /* Format of the data */
- const BYTE *lpData; /* Pointer to start of data */
- DWORD dwStride; /* Stride between occurrences of this data */
-} WineDirect3DStridedData;
-
-typedef struct WineDirect3DVertexStridedData
-{
- WineDirect3DStridedData position;
- WineDirect3DStridedData normal;
- WineDirect3DStridedData diffuse;
- WineDirect3DStridedData specular;
- WineDirect3DStridedData texCoords[WINED3DDP_MAXTEXCOORD];
- BOOL position_transformed;
-} WineDirect3DVertexStridedData;
-
-typedef struct _WINED3DVSHADERCAPS2_0
-{
- DWORD Caps;
- INT DynamicFlowControlDepth;
- INT NumTemps;
- INT StaticFlowControlDepth;
-} WINED3DVSHADERCAPS2_0;
-
-typedef struct _WINED3DPSHADERCAPS2_0
-{
- DWORD Caps;
- INT DynamicFlowControlDepth;
- INT NumTemps;
- INT StaticFlowControlDepth;
- INT NumInstructionSlots;
-} WINED3DPSHADERCAPS2_0;
-
-typedef struct _WINEDDCAPS
-{
- DWORD Caps;
- DWORD Caps2;
- DWORD CKeyCaps;
- DWORD FXCaps;
- DWORD FXAlphaCaps;
- DWORD PalCaps;
- DWORD SVCaps;
- DWORD SVBCaps;
- DWORD SVBCKeyCaps;
- DWORD SVBFXCaps;
- DWORD VSBCaps;
- DWORD VSBCKeyCaps;
- DWORD VSBFXCaps;
- DWORD SSBCaps;
- DWORD SSBCKeyCaps;
- DWORD SSBFXCaps;
- DWORD ddsCaps;
- DWORD StrideAlign;
-} WINEDDCAPS;
-
-typedef struct _WINED3DCAPS
-{
- WINED3DDEVTYPE DeviceType;
- UINT AdapterOrdinal;
-
- DWORD Caps;
- DWORD Caps2;
- DWORD Caps3;
- DWORD PresentationIntervals;
-
- DWORD CursorCaps;
- DWORD DevCaps;
- DWORD PrimitiveMiscCaps;
- DWORD RasterCaps;
- DWORD ZCmpCaps;
- DWORD SrcBlendCaps;
- DWORD DestBlendCaps;
- DWORD AlphaCmpCaps;
- DWORD ShadeCaps;
- DWORD TextureCaps;
- DWORD TextureFilterCaps;
- DWORD CubeTextureFilterCaps;
- DWORD VolumeTextureFilterCaps;
- DWORD TextureAddressCaps;
- DWORD VolumeTextureAddressCaps;
- DWORD LineCaps;
-
- DWORD MaxTextureWidth;
- DWORD MaxTextureHeight;
- DWORD MaxVolumeExtent;
- DWORD MaxTextureRepeat;
- DWORD MaxTextureAspectRatio;
- DWORD MaxAnisotropy;
- float MaxVertexW;
-
- float GuardBandLeft;
- float GuardBandTop;
- float GuardBandRight;
- float GuardBandBottom;
-
- float ExtentsAdjust;
- DWORD StencilCaps;
-
- DWORD FVFCaps;
- DWORD TextureOpCaps;
- DWORD MaxTextureBlendStages;
- DWORD MaxSimultaneousTextures;
-
- DWORD VertexProcessingCaps;
- DWORD MaxActiveLights;
- DWORD MaxUserClipPlanes;
- DWORD MaxVertexBlendMatrices;
- DWORD MaxVertexBlendMatrixIndex;
-
- float MaxPointSize;
-
- DWORD MaxPrimitiveCount;
- DWORD MaxVertexIndex;
- DWORD MaxStreams;
- DWORD MaxStreamStride;
-
- DWORD VertexShaderVersion;
- DWORD MaxVertexShaderConst;
-
- DWORD PixelShaderVersion;
- float PixelShader1xMaxValue;
-
- /* DX 9 */
- DWORD DevCaps2;
-
- float MaxNpatchTessellationLevel;
- DWORD Reserved5; /* undocumented */
-
- UINT MasterAdapterOrdinal;
- UINT AdapterOrdinalInGroup;
- UINT NumberOfAdaptersInGroup;
- DWORD DeclTypes;
- DWORD NumSimultaneousRTs;
- DWORD StretchRectFilterCaps;
- WINED3DVSHADERCAPS2_0 VS20Caps;
- WINED3DPSHADERCAPS2_0 PS20Caps;
- DWORD VertexTextureFilterCaps;
- DWORD MaxVShaderInstructionsExecuted;
- DWORD MaxPShaderInstructionsExecuted;
- DWORD MaxVertexShader30InstructionSlots;
- DWORD MaxPixelShader30InstructionSlots;
- DWORD Reserved2; /* Not in the microsoft headers but documented */
- DWORD Reserved3;
-
- WINEDDCAPS DirectDrawCaps;
-} WINED3DCAPS;
-
-/* DirectDraw types */
-
-typedef struct _WINEDDCOLORKEY
-{
- DWORD dwColorSpaceLowValue; /* low boundary of color space that is to
- * be treated as Color Key, inclusive */
- DWORD dwColorSpaceHighValue; /* high boundary of color space that is
- * to be treated as Color Key, inclusive */
-} WINEDDCOLORKEY,*LPWINEDDCOLORKEY;
-
-typedef struct _WINEDDBLTFX
-{
- DWORD dwSize; /* size of structure */
- DWORD dwDDFX; /* FX operations */
- DWORD dwROP; /* Win32 raster operations */
- DWORD dwDDROP; /* Raster operations new for DirectDraw */
- DWORD dwRotationAngle; /* Rotation angle for blt */
- DWORD dwZBufferOpCode; /* ZBuffer compares */
- DWORD dwZBufferLow; /* Low limit of Z buffer */
- DWORD dwZBufferHigh; /* High limit of Z buffer */
- DWORD dwZBufferBaseDest; /* Destination base value */
- DWORD dwZDestConstBitDepth; /* Bit depth used to specify Z constant for destination */
- union
- {
- DWORD dwZDestConst; /* Constant to use as Z buffer for dest */
- struct IWineD3DSurface *lpDDSZBufferDest; /* Surface to use as Z buffer for dest */
- } DUMMYUNIONNAME1;
- DWORD dwZSrcConstBitDepth; /* Bit depth used to specify Z constant for source */
- union
- {
- DWORD dwZSrcConst; /* Constant to use as Z buffer for src */
- struct IWineD3DSurface *lpDDSZBufferSrc; /* Surface to use as Z buffer for src */
- } DUMMYUNIONNAME2;
- DWORD dwAlphaEdgeBlendBitDepth; /* Bit depth used to specify constant for alpha edge blend */
- DWORD dwAlphaEdgeBlend; /* Alpha for edge blending */
- DWORD dwReserved;
- DWORD dwAlphaDestConstBitDepth; /* Bit depth used to specify alpha constant for destination */
- union
- {
- DWORD dwAlphaDestConst; /* Constant to use as Alpha Channel */
- struct IWineD3DSurface *lpDDSAlphaDest; /* Surface to use as Alpha Channel */
- } DUMMYUNIONNAME3;
- DWORD dwAlphaSrcConstBitDepth; /* Bit depth used to specify alpha constant for source */
- union
- {
- DWORD dwAlphaSrcConst; /* Constant to use as Alpha Channel */
- struct IWineD3DSurface *lpDDSAlphaSrc; /* Surface to use as Alpha Channel */
- } DUMMYUNIONNAME4;
- union
- {
- DWORD dwFillColor; /* color in RGB or Palettized */
- DWORD dwFillDepth; /* depth value for z-buffer */
- DWORD dwFillPixel; /* pixel val for RGBA or RGBZ */
- struct IWineD3DSurface *lpDDSPattern; /* Surface to use as pattern */
- } DUMMYUNIONNAME5;
- WINEDDCOLORKEY ddckDestColorkey; /* DestColorkey override */
- WINEDDCOLORKEY ddckSrcColorkey; /* SrcColorkey override */
-} WINEDDBLTFX,*LPWINEDDBLTFX;
-
-typedef struct _WINEDDOVERLAYFX
-{
- DWORD dwSize; /* size of structure */
- DWORD dwAlphaEdgeBlendBitDepth; /* Bit depth used to specify constant for alpha edge blend */
- DWORD dwAlphaEdgeBlend; /* Constant to use as alpha for edge blend */
- DWORD dwReserved;
- DWORD dwAlphaDestConstBitDepth; /* Bit depth used to specify alpha constant for destination */
- union
- {
- DWORD dwAlphaDestConst; /* Constant to use as alpha channel for dest */
- struct IWineD3DSurface *lpDDSAlphaDest; /* Surface to use as alpha channel for dest */
- } DUMMYUNIONNAME1;
- DWORD dwAlphaSrcConstBitDepth; /* Bit depth used to specify alpha constant for source */
- union
- {
- DWORD dwAlphaSrcConst; /* Constant to use as alpha channel for src */
- struct IWineD3DSurface *lpDDSAlphaSrc; /* Surface to use as alpha channel for src */
- } DUMMYUNIONNAME2;
- WINEDDCOLORKEY dckDestColorkey; /* DestColorkey override */
- WINEDDCOLORKEY dckSrcColorkey; /* SrcColorkey override */
- DWORD dwDDFX; /* Overlay FX */
- DWORD dwFlags; /* flags */
-} WINEDDOVERLAYFX;
-
-struct wined3d_buffer_desc
-{
- UINT byte_width;
- DWORD usage;
- UINT bind_flags;
- UINT cpu_access_flags;
- UINT misc_flags;
-};
-
-struct wined3d_shader_signature_element
-{
- const char *semantic_name;
- UINT semantic_idx;
- enum wined3d_sysval_semantic sysval_semantic;
- DWORD component_type;
- UINT register_idx;
- DWORD mask;
-};
-
-struct wined3d_shader_signature
-{
- UINT element_count;
- struct wined3d_shader_signature_element *elements;
- char *string_data;
-};
-
-struct wined3d_parent_ops
-{
- void (__stdcall *wined3d_object_destroyed)(void *parent);
-};
-
-interface IWineD3DResource;
-interface IWineD3DSurface;
-interface IWineD3DVolume;
-interface IWineD3DSwapChain;
-interface IWineD3DDevice;
-
-[
- object,
- local,
- uuid(aeb62dfc-bdcb-4f02-9519-1eeea00c15cd)
-]
-interface IWineD3DDeviceParent : IUnknown
-{
- void WineD3DDeviceCreated(
- [in] IWineD3DDevice *device
- );
-
- HRESULT CreateSurface(
- [in] IUnknown *superior,
- [in] UINT width,
- [in] UINT height,
- [in] enum wined3d_format_id format_id,
- [in] DWORD usage,
- [in] WINED3DPOOL pool,
- [in] UINT level,
- [in] WINED3DCUBEMAP_FACES face,
- [out] IWineD3DSurface **surface
- );
-
- HRESULT CreateRenderTarget(
- [in] IUnknown *superior,
- [in] UINT width,
- [in] UINT height,
- [in] enum wined3d_format_id format_id,
- [in] WINED3DMULTISAMPLE_TYPE multisample_type,
- [in] DWORD multisample_quality,
- [in] BOOL lockable,
- [out] IWineD3DSurface **surface
- );
-
- HRESULT CreateDepthStencilSurface(
- [in] UINT width,
- [in] UINT height,
- [in] enum wined3d_format_id format_id,
- [in] WINED3DMULTISAMPLE_TYPE multisample_type,
- [in] DWORD multisample_quality,
- [in] BOOL discard,
- [out] IWineD3DSurface **surface
- );
-
- HRESULT CreateVolume(
- [in] IUnknown *superior,
- [in] UINT width,
- [in] UINT height,
- [in] UINT depth,
- [in] enum wined3d_format_id format_id,
- [in] WINED3DPOOL pool,
- [in] DWORD usage,
- [out] IWineD3DVolume **volume
- );
-
- HRESULT CreateSwapChain(
- [in, out] WINED3DPRESENT_PARAMETERS *present_parameters,
- [out] IWineD3DSwapChain **swapchain
- );
-}
-typedef ULONG (__stdcall *D3DCB_DESTROYSWAPCHAINFN)(IWineD3DSwapChain *pSwapChain);
-typedef HRESULT (__stdcall *D3DCB_ENUMRESOURCES)(IWineD3DResource *resource, void *pData);
-
-[
- object,
- local,
- uuid(46799311-8e0e-40ce-b2ec-ddb99f18fcb4)
-]
-interface IWineD3DBase : IUnknown
-{
- void *GetParent(
- );
-}
-
-[
- object,
- local,
- uuid(108f9c44-6f30-11d9-c687-00046142c14f)
-]
-interface IWineD3D : IWineD3DBase
-{
- UINT GetAdapterCount(
- );
- HRESULT RegisterSoftwareDevice(
- [in] void *pInitializeFunction
- );
- HMONITOR GetAdapterMonitor(
- [in] UINT adapter_idx
- );
- UINT GetAdapterModeCount(
- [in] UINT adapter_idx,
- [in] enum wined3d_format_id format_id
- );
- HRESULT EnumAdapterModes(
- [in] UINT adapter_idx,
- [in] enum wined3d_format_id format_id,
- [in] UINT mode_idx,
- [out] WINED3DDISPLAYMODE *mode
- );
- HRESULT GetAdapterDisplayMode(
- [in] UINT adapter_idx,
- [out] WINED3DDISPLAYMODE *mode
- );
- HRESULT GetAdapterIdentifier(
- [in] UINT adapter_idx,
- [in] DWORD flags,
- [out] WINED3DADAPTER_IDENTIFIER *identifier
- );
- HRESULT CheckDeviceMultiSampleType(
- [in] UINT adapter_idx,
- [in] WINED3DDEVTYPE device_type,
- [in] enum wined3d_format_id surface_format_id,
- [in] BOOL windowed,
- [in] WINED3DMULTISAMPLE_TYPE multisample_type,
- [out] DWORD *quality_levels
- );
- HRESULT CheckDepthStencilMatch(
- [in] UINT adapter_idx,
- [in] WINED3DDEVTYPE device_type,
- [in] enum wined3d_format_id adapter_format_id,
- [in] enum wined3d_format_id render_target_format_id,
- [in] enum wined3d_format_id depth_stencil_format_id
- );
- HRESULT CheckDeviceType(
- [in] UINT adapter_idx,
- [in] WINED3DDEVTYPE device_type,
- [in] enum wined3d_format_id display_format_id,
- [in] enum wined3d_format_id backbuffer_format_id,
- [in] BOOL windowed
- );
- HRESULT CheckDeviceFormat(
- [in] UINT adaper_idx,
- [in] WINED3DDEVTYPE device_type,
- [in] enum wined3d_format_id adapter_format_id,
- [in] DWORD usage,
- [in] WINED3DRESOURCETYPE resource_type,
- [in] enum wined3d_format_id check_format,
- [in] WINED3DSURFTYPE surface_type
- );
- HRESULT CheckDeviceFormatConversion(
- [in] UINT adapter_idx,
- [in] WINED3DDEVTYPE device_type,
- [in] enum wined3d_format_id source_format_id,
- [in] enum wined3d_format_id target_format_id
- );
- HRESULT GetDeviceCaps(
- [in] UINT adapter_idx,
- [in] WINED3DDEVTYPE device_type,
- [out] WINED3DCAPS *caps
- );
- HRESULT CreateDevice(
- [in] UINT adapter_idx,
- [in] WINED3DDEVTYPE device_type,
- [in] HWND focus_window,
- [in] DWORD behaviour_flags,
- [in] IWineD3DDeviceParent *device_parent,
- [out] IWineD3DDevice **device
- );
-}
-
-[
- object,
- local,
- uuid(1f3bfb34-6f30-11d9-c687-00046142c14f)
-]
-interface IWineD3DResource : IWineD3DBase
-{
- HRESULT SetPrivateData(
- [in] REFGUID guid,
- [in] const void *data,
- [in] DWORD data_size,
- [in] DWORD flags
- );
- HRESULT GetPrivateData(
- [in] REFGUID guid,
- [out] void *data,
- [in, out] DWORD *data_size
- );
- HRESULT FreePrivateData(
- [in] REFGUID guid
- );
- DWORD SetPriority(
- [in] DWORD new_priority
- );
- DWORD GetPriority(
- );
- void PreLoad(
- );
- void UnLoad(
- );
- WINED3DRESOURCETYPE GetType(
- );
-}
-
-[
- object,
- local,
- uuid(f7d8abf4-fb93-43e4-9c96-4618cf9b3cbc)
-]
-interface IWineD3DRendertargetView : IWineD3DBase
-{
- HRESULT GetResource(
- [out] IWineD3DResource **resource
- );
-}
-
-[
- object,
- local,
- uuid(f756720c-32b9-4439-b5a3-1d6c97037d9e)
-]
-interface IWineD3DPalette : IWineD3DBase
-{
- HRESULT GetEntries(
- [in] DWORD flags,
- [in] DWORD start,
- [in] DWORD count,
- [out] PALETTEENTRY *entries
- );
- HRESULT GetCaps(
- [out] DWORD *caps
- );
- HRESULT SetEntries(
- [in] DWORD flags,
- [in] DWORD start,
- [in] DWORD count,
- [in] const PALETTEENTRY *entries
- );
-}
-
-[
- object,
- local,
- uuid(8f2bceb1-d338-488c-ab7f-0ec980bf5d2d)
-]
-interface IWineD3DClipper : IUnknown
-{
- HRESULT GetClipList(
- [in] const RECT *rect,
- [out] RGNDATA *clip_list,
- [in, out] DWORD *clip_list_size
- );
- HRESULT GetHWnd(
- [out] HWND *hwnd
- );
- HRESULT IsClipListChanged(
- [out] BOOL *changed
- );
- HRESULT SetClipList(
- [in] const RGNDATA *clip_list,
- [in] DWORD flags
- );
- HRESULT SetHWnd(
- [in] DWORD flags,
- [in] HWND hwnd
- );
-}
-
-[
- object,
- local,
- uuid(37cd5526-6f30-11d9-c687-00046142c14f)
-]
-interface IWineD3DSurface : IWineD3DResource
-{
- void GetDesc(
- [out] WINED3DSURFACE_DESC *desc
- );
- HRESULT LockRect(
- [out] WINED3DLOCKED_RECT *locked_rect,
- [in] const RECT *rect,
- [in] DWORD flags
- );
- HRESULT UnlockRect(
- );
- HRESULT GetDC(
- [out] HDC *dc
- );
- HRESULT ReleaseDC(
- [in] HDC dc
- );
- HRESULT Flip(
- [in] IWineD3DSurface *override,
- [in] DWORD flags
- );
- HRESULT Blt(
- [in] const RECT *dst_rect,
- [in] IWineD3DSurface *src_surface,
- [in] const RECT *src_rect,
- [in] DWORD flags,
- [in] const WINEDDBLTFX *blt_fx,
- [in] WINED3DTEXTUREFILTERTYPE filter
- );
- HRESULT GetBltStatus(
- [in] DWORD flags
- );
- HRESULT GetFlipStatus(
- [in] DWORD flags
- );
- HRESULT IsLost(
- );
- HRESULT Restore(
- );
- HRESULT BltFast(
- [in] DWORD dst_x,
- [in] DWORD dst_y,
- [in] IWineD3DSurface *src_surface,
- [in] const RECT *src_rect,
- [in] DWORD trans
- );
- HRESULT GetPalette(
- [out] IWineD3DPalette **palette
- );
- HRESULT SetPalette(
- [in] IWineD3DPalette *palette
- );
- HRESULT RealizePalette(
- );
- HRESULT SetColorKey(
- [in] DWORD flags,
- [in] const WINEDDCOLORKEY *color_key
- );
- DWORD GetPitch(
- );
- HRESULT SetMem(
- [in] void *mem
- );
- HRESULT SetOverlayPosition(
- [in] LONG x,
- [in] LONG y
- );
- HRESULT GetOverlayPosition(
- [out] LONG *x,
- [out] LONG *y
- );
- HRESULT UpdateOverlayZOrder(
- [in] DWORD flags,
- [in] IWineD3DSurface *ref
- );
- HRESULT UpdateOverlay(
- [in] const RECT *src_rect,
- [in] IWineD3DSurface *dst_surface,
- [in] const RECT *dst_rect,
- [in] DWORD flags,
- [in] const WINEDDOVERLAYFX *fx
- );
- HRESULT SetClipper(
- [in] IWineD3DClipper *clipper
- );
- HRESULT GetClipper(
- [out] IWineD3DClipper **clipper
- );
- HRESULT LoadTexture(
- [in] BOOL srgb_mode
- );
- void BindTexture(
- [in] BOOL srgb
- );
- const void *GetData(
- );
- HRESULT SetFormat(
- [in] enum wined3d_format_id format_id
- );
- HRESULT PrivateSetup(
- );
- WINED3DSURFTYPE GetImplType(
- );
- HRESULT DrawOverlay(
- );
-}
-
-[
- object,
- local,
- uuid(24769ed8-6f30-11d9-c687-00046142c14f)
-]
-interface IWineD3DVolume : IWineD3DResource
-{
- void GetDesc(
- [out] WINED3DVOLUME_DESC *desc
- );
- HRESULT LockBox(
- [out] WINED3DLOCKED_BOX *locked_box,
- [in] const WINED3DBOX *box,
- [in] DWORD flags
- );
- HRESULT UnlockBox(
- );
- HRESULT LoadTexture(
- [in] int gl_level,
- [in] BOOL srgb_mode
- );
-}
-
-[
- object,
- local,
- uuid(3c2aebf6-6f30-11d9-c687-00046142c14f)
-]
-interface IWineD3DBaseTexture : IWineD3DResource
-{
- DWORD SetLOD(
- [in] DWORD new_lod
- );
- DWORD GetLOD(
- );
- DWORD GetLevelCount(
- );
- HRESULT SetAutoGenFilterType(
- WINED3DTEXTUREFILTERTYPE filter_type
- );
- WINED3DTEXTUREFILTERTYPE GetAutoGenFilterType(
- );
- void GenerateMipSubLevels(
- );
- BOOL SetDirty(
- BOOL dirty
- );
- BOOL GetDirty(
- );
- HRESULT BindTexture(
- [in] BOOL srgb
- );
- BOOL IsCondNP2(
- );
-}
-
-[
- object,
- local,
- uuid(3e72cc1c-6f30-11d9-c687-00046142c14f)
-]
-interface IWineD3DTexture : IWineD3DBaseTexture
-{
- HRESULT GetLevelDesc(
- [in] UINT level,
- [out] WINED3DSURFACE_DESC *desc
- );
- HRESULT GetSurfaceLevel(
- [in] UINT level,
- [out] IWineD3DSurface **surface
- );
- HRESULT LockRect(
- [in] UINT level,
- [out] WINED3DLOCKED_RECT *locked_rect,
- [in] const RECT *rect,
- [in] DWORD flags
- );
- HRESULT UnlockRect(
- [in] UINT level
- );
- HRESULT AddDirtyRect(
- [in] const RECT *dirty_rect
- );
-}
-
-[
- object,
- local,
- uuid(41752900-6f30-11d9-c687-00046142c14f)
-]
-interface IWineD3DCubeTexture : IWineD3DBaseTexture
-{
- HRESULT GetLevelDesc(
- [in] UINT level,
- [out] WINED3DSURFACE_DESC *desc
- );
- HRESULT GetCubeMapSurface(
- [in] WINED3DCUBEMAP_FACES face,
- [in] UINT level,
- [out] IWineD3DSurface **surface
- );
- HRESULT LockRect(
- [in] WINED3DCUBEMAP_FACES face,
- [in] UINT level,
- [out] WINED3DLOCKED_RECT *locked_rect,
- [in] const RECT *rect,
- [in] DWORD flags
- );
- HRESULT UnlockRect(
- [in] WINED3DCUBEMAP_FACES face,
- [in] UINT level
- );
- HRESULT AddDirtyRect(
- [in] WINED3DCUBEMAP_FACES face,
- [in] const RECT *dirty_rect
- );
-}
-
-[
- object,
- local,
- uuid(7b39470c-6f30-11d9-c687-00046142c14f)
-]
-interface IWineD3DVolumeTexture : IWineD3DBaseTexture
-{
- HRESULT GetLevelDesc(
- [in] UINT level,
- [out] WINED3DVOLUME_DESC *desc
- );
- HRESULT GetVolumeLevel(
- [in] UINT level,
- [out] IWineD3DVolume **volume
- );
- HRESULT LockBox(
- [in] UINT level,
- [out] WINED3DLOCKED_BOX *locked_box,
- [in] const WINED3DBOX *box,
- [in] DWORD flags
- );
- HRESULT UnlockBox(
- [in] UINT level
- );
- HRESULT AddDirtyBox(
- [in] const WINED3DBOX *dirty_box
- );
-}
-
-[
- object,
- local,
- uuid(7cd55be6-6f30-11d9-c687-00046142c14f)
-]
-interface IWineD3DVertexDeclaration : IWineD3DBase
-{
-}
-
-[
- object,
- local,
- uuid(83b073ce-6f30-11d9-c687-00046142c14f)
-]
-interface IWineD3DStateBlock : IUnknown
-{
- HRESULT Capture(
- );
- HRESULT Apply(
- );
-}
-
-[
- object,
- local,
- uuid(905ddbac-6f30-11d9-c687-00046142c14f)
-]
-interface IWineD3DQuery : IUnknown
-{
- HRESULT GetData(
- [out] void *data,
- [in] DWORD data_size,
- [in] DWORD flags
- );
- DWORD GetDataSize(
- );
- WINED3DQUERYTYPE GetType(
- );
- HRESULT Issue(
- DWORD flags
- );
-}
-
-[
- object,
- local,
- uuid(34d01b10-6f30-11d9-c687-00046142c14f)
-]
-interface IWineD3DSwapChain : IWineD3DBase
-{
- void Destroy(
- );
- HRESULT GetDevice(
- [out] IWineD3DDevice **device
- );
- HRESULT Present(
- [in] const RECT *src_rect,
- [in] const RECT *dst_rect,
- [in] HWND dst_window_override,
- [in] const RGNDATA *dirty_region,
- [in] DWORD flags
- );
- HRESULT SetDestWindowOverride(
- [in] HWND window
- );
- HRESULT GetFrontBufferData(
- [in] IWineD3DSurface *dst_surface
- );
- HRESULT GetBackBuffer(
- [in] UINT backbuffer_idx,
- [in] WINED3DBACKBUFFER_TYPE backbuffer_type,
- [out] IWineD3DSurface **backbuffer
- );
- HRESULT GetRasterStatus(
- [out] WINED3DRASTER_STATUS *raster_status
- );
- HRESULT GetDisplayMode(
- [out] WINED3DDISPLAYMODE *mode
- );
- HRESULT GetPresentParameters(
- [out] WINED3DPRESENT_PARAMETERS *present_parameters
- );
- HRESULT SetGammaRamp(
- [in] DWORD flags,
- [in] const WINED3DGAMMARAMP *ramp
- );
- HRESULT GetGammaRamp(
- [out] WINED3DGAMMARAMP *ramp
- );
-}
-
-[
- object,
- local,
- uuid(b3f028e8-1a40-4ab3-9292-5bf6cfd80209)
-]
-interface IWineD3DBuffer : IWineD3DResource
-{
- HRESULT Map(
- [in] UINT offset,
- [in] UINT size,
- [out] BYTE **data,
- [in] DWORD flags
- );
- HRESULT Unmap(
- );
- void GetDesc(
- [out] WINED3DBUFFER_DESC *desc
- );
-}
-
-[
- object,
- local,
- uuid(eac93065-a4df-446f-86a1-9ef2bca40a3c)
-]
-interface IWineD3DBaseShader : IWineD3DBase
-{
- HRESULT GetFunction(
- [out] void *data,
- [in, out] UINT *data_size
- );
-}
-
-[
- object,
- local,
- uuid(7f7a2b60-6f30-11d9-c687-00046142c14f)
-]
-interface IWineD3DVertexShader : IWineD3DBaseShader
-{
- HRESULT SetLocalConstantsF(
- [in] UINT start_idx,
- [in] const float *src_data,
- [in] UINT vector4f_count
- );
-}
-
-[
- object,
- local,
- uuid(8276c113-388b-49d1-ad8b-c9dd8bcbabcd)
-]
-interface IWineD3DGeometryShader : IWineD3DBaseShader
-{
-}
-
-[
- object,
- local,
- uuid(818503da-6f30-11d9-c687-00046142c14f)
-]
-interface IWineD3DPixelShader : IWineD3DBaseShader
-{
-}
-
-[
- object,
- local,
- uuid(6d10a2ce-09d0-4a53-a427-11388f9f8ca5)
-]
-interface IWineD3DDevice : IUnknown
-{
- HRESULT CreateBuffer(
- [in] struct wined3d_buffer_desc *desc,
- [in] const void *data,
- [in] void *parent,
- [in] const struct wined3d_parent_ops *parent_ops,
- [out] IWineD3DBuffer **buffer
- );
- HRESULT CreateVertexBuffer(
- [in] UINT length,
- [in] DWORD usage,
- [in] WINED3DPOOL pool,
- [in] void *parent,
- [in] const struct wined3d_parent_ops *parent_ops,
- [out] IWineD3DBuffer **vertex_buffer
- );
- HRESULT CreateIndexBuffer(
- [in] UINT length,
- [in] DWORD usage,
- [in] WINED3DPOOL pool,
- [in] void *parent,
- [in] const struct wined3d_parent_ops *parent_ops,
- [out] IWineD3DBuffer **index_buffer
- );
- HRESULT CreateStateBlock(
- [in] WINED3DSTATEBLOCKTYPE type,
- [out] IWineD3DStateBlock **stateblock
- );
- HRESULT CreateSurface(
- [in] UINT width,
- [in] UINT height,
- [in] enum wined3d_format_id format_id,
- [in] BOOL lockable,
- [in] BOOL discard,
- [in] UINT level,
- [in] DWORD usage,
- [in] WINED3DPOOL pool,
- [in] WINED3DMULTISAMPLE_TYPE multisample_type,
- [in] DWORD multisample_quality,
- [in] WINED3DSURFTYPE surface_type,
- [in] void *parent,
- [in] const struct wined3d_parent_ops *parent_ops,
- [out] IWineD3DSurface **surface
- );
- HRESULT CreateRendertargetView(
- [in] IWineD3DResource *resource,
- [in] void *parent,
- [out] IWineD3DRendertargetView **rendertarget_view
- );
- HRESULT CreateTexture(
- [in] UINT width,
- [in] UINT height,
- [in] UINT levels,
- [in] DWORD usage,
- [in] enum wined3d_format_id format_id,
- [in] WINED3DPOOL pool,
- [in] void *parent,
- [in] const struct wined3d_parent_ops *parent_ops,
- [out] IWineD3DTexture **texture
- );
- HRESULT CreateVolumeTexture(
- [in] UINT width,
- [in] UINT height,
- [in] UINT depth,
- [in] UINT levels,
- [in] DWORD usage,
- [in] enum wined3d_format_id format_id,
- [in] WINED3DPOOL pool,
- [in] void *parent,
- [in] const struct wined3d_parent_ops *parent_ops,
- [out] IWineD3DVolumeTexture **texture
- );
- HRESULT CreateVolume(
- [in] UINT width,
- [in] UINT height,
- [in] UINT depth,
- [in] DWORD usage,
- [in] enum wined3d_format_id format_id,
- [in] WINED3DPOOL pool,
- [in] void *parent,
- [in] const struct wined3d_parent_ops *parent_ops,
- [out] IWineD3DVolume **volume
- );
- HRESULT CreateCubeTexture(
- [in] UINT edge_length,
- [in] UINT levels,
- [in] DWORD usage,
- [in] enum wined3d_format_id format_id,
- [in] WINED3DPOOL pool,
- [in] void *parent,
- [in] const struct wined3d_parent_ops *parent_ops,
- [out] IWineD3DCubeTexture **texture
- );
- HRESULT CreateQuery(
- [in] WINED3DQUERYTYPE type,
- [out] IWineD3DQuery **query
- );
- HRESULT CreateSwapChain(
- [in] WINED3DPRESENT_PARAMETERS *present_parameters,
- [in] WINED3DSURFTYPE surface_type,
- [in] void *parent,
- [out] IWineD3DSwapChain **swapchain
- );
- HRESULT CreateVertexDeclaration(
- [in] const WINED3DVERTEXELEMENT *elements,
- [in] UINT element_count,
- [in] void *parent,
- [in] const struct wined3d_parent_ops *parent_ops,
- [out] IWineD3DVertexDeclaration **declaration
- );
- HRESULT CreateVertexDeclarationFromFVF(
- [in] DWORD fvf,
- [in] void *parent,
- [in] const struct wined3d_parent_ops *parent_ops,
- [out] IWineD3DVertexDeclaration **declaration
- );
- HRESULT CreateVertexShader(
- [in] const DWORD *function,
- [in] const struct wined3d_shader_signature *output_signature,
- [in] void *parent,
- [in] const struct wined3d_parent_ops *parent_ops,
- [out] IWineD3DVertexShader **shader
- );
- HRESULT CreateGeometryShader(
- [in] const DWORD *byte_code,
- [in] const struct wined3d_shader_signature *output_signature,
- [in] void *parent,
- [in] const struct wined3d_parent_ops *parent_ops,
- [out] IWineD3DGeometryShader **shader
- );
- HRESULT CreatePixelShader(
- [in] const DWORD *function,
- [in] const struct wined3d_shader_signature *output_signature,
- [in] void *parent,
- [in] const struct wined3d_parent_ops *parent_ops,
- [out] IWineD3DPixelShader **shader
- );
- HRESULT CreatePalette(
- [in] DWORD flags,
- [in] const PALETTEENTRY *palette_entry,
- [in] void *parent,
- [out] IWineD3DPalette **palette
- );
- HRESULT Init3D(
- [in] WINED3DPRESENT_PARAMETERS *present_parameters
- );
- HRESULT InitGDI(
- [in] WINED3DPRESENT_PARAMETERS *present_parameters
- );
- HRESULT Uninit3D(
- [in] D3DCB_DESTROYSWAPCHAINFN destroy_swapchain_callback
- );
- HRESULT UninitGDI(
- [in] D3DCB_DESTROYSWAPCHAINFN destroy_swapchain_callback
- );
- void SetMultithreaded(
- );
- HRESULT EvictManagedResources(
- );
- UINT GetAvailableTextureMem(
- );
- HRESULT GetBackBuffer(
- [in] UINT swapchain_idx,
- [in] UINT backbuffer_idx,
- [in] WINED3DBACKBUFFER_TYPE backbuffer_type,
- [out] IWineD3DSurface **backbuffer
- );
- HRESULT GetCreationParameters(
- [out] WINED3DDEVICE_CREATION_PARAMETERS *creation_parameters
- );
- HRESULT GetDeviceCaps(
- [out] WINED3DCAPS *caps
- );
- HRESULT GetDirect3D(
- [out] IWineD3D** d3d
- );
- HRESULT GetDisplayMode(
- [in] UINT swapchain_idx,
- [out] WINED3DDISPLAYMODE *mode
- );
- HRESULT SetDisplayMode(
- [in] UINT swapchain_idx,
- [in] const WINED3DDISPLAYMODE *mode
- );
- UINT GetNumberOfSwapChains(
- );
- HRESULT GetRasterStatus(
- [in] UINT swapchain_idx,
- [out] WINED3DRASTER_STATUS *raster_status
- );
- HRESULT GetSwapChain(
- [in] UINT swapchain_idx,
- [out] IWineD3DSwapChain **swapchain
- );
- HRESULT Reset(
- [in] WINED3DPRESENT_PARAMETERS *present_parameters
- );
- HRESULT SetDialogBoxMode(
- [in] BOOL enable_dialogs
- );
- HRESULT SetCursorProperties(
- [in] UINT x_hotspot,
- [in] UINT y_hotspot,
- [in] IWineD3DSurface *cursor_surface
- );
- void SetCursorPosition(
- [in] int x_screen_space,
- [in] int y_screen_space,
- [in] DWORD flags
- );
- BOOL ShowCursor(
- [in] BOOL show
- );
- HRESULT SetClipPlane(
- [in] DWORD plane_idx,
- [in] const float *plane
- );
- HRESULT GetClipPlane(
- [in] DWORD plane_idx,
- [out] float *plane
- );
- HRESULT SetClipStatus(
- [in] const WINED3DCLIPSTATUS *clip_status
- );
- HRESULT GetClipStatus(
- [out] WINED3DCLIPSTATUS *clip_status
- );
- HRESULT SetCurrentTexturePalette(
- [in] UINT palette_number
- );
- HRESULT GetCurrentTexturePalette(
- [out] UINT *palette_number
- );
- HRESULT SetDepthStencilSurface(
- [in] IWineD3DSurface *depth_stencil
- );
- HRESULT GetDepthStencilSurface(
- [out] IWineD3DSurface **depth_stencil
- );
- void SetGammaRamp(
- [in] UINT swapchain_idx,
- [in] DWORD flags,
- [in] const WINED3DGAMMARAMP *ramp
- );
- void GetGammaRamp(
- [in] UINT swapchain_idx,
- [out] WINED3DGAMMARAMP *ramp
- );
- HRESULT SetIndexBuffer(
- [in] IWineD3DBuffer *index_buffer,
- [in] enum wined3d_format_id format_id
- );
- HRESULT GetIndexBuffer(
- [out] IWineD3DBuffer **index_buffer
- );
- HRESULT SetBaseVertexIndex(
- [in] INT base_index
- );
- HRESULT GetBaseVertexIndex(
- [out] INT *base_index
- );
- HRESULT SetLight(
- [in] DWORD light_idx,
- [in] const WINED3DLIGHT *light
- );
- HRESULT GetLight(
- [in] DWORD light_idx,
- [out] WINED3DLIGHT *light
- );
- HRESULT SetLightEnable(
- [in] DWORD light_idx,
- [in] BOOL enable
- );
- HRESULT GetLightEnable(
- [in] DWORD light_idx,
- [out] BOOL *enable
- );
- HRESULT SetMaterial(
- [in] const WINED3DMATERIAL *material
- );
- HRESULT GetMaterial(
- [out] WINED3DMATERIAL *material
- );
- HRESULT SetNPatchMode(
- [in] float segments
- );
- float GetNPatchMode(
- );
- HRESULT SetPaletteEntries(
- [in] UINT palette_number,
- [in] const PALETTEENTRY *entries
- );
- HRESULT GetPaletteEntries(
- [in] UINT palette_number,
- [out] PALETTEENTRY *entries
- );
- HRESULT SetPixelShader(
- [in] IWineD3DPixelShader *shader
- );
- IWineD3DPixelShader *GetPixelShader(
- );
- HRESULT SetPixelShaderConstantB(
- [in] UINT start_register,
- [in] const BOOL *constants,
- [in] UINT bool_count
- );
- HRESULT GetPixelShaderConstantB(
- [in] UINT start_register,
- [out] BOOL *constants,
- [in] UINT bool_count
- );
- HRESULT SetPixelShaderConstantI(
- [in] UINT start_register,
- [in] const int *constants,
- [in] UINT vector4i_count
- );
- HRESULT GetPixelShaderConstantI(
- [in] UINT start_register,
- [out] int *constants,
- [in] UINT vector4i_count
- );
- HRESULT SetPixelShaderConstantF(
- [in] UINT start_register,
- [in] const float *constants,
- [in] UINT vector4f_count
- );
- HRESULT GetPixelShaderConstantF(
- [in] UINT start_register,
- [out] float *constants,
- [in] UINT vector4f_count
- );
- HRESULT SetRenderState(
- [in] WINED3DRENDERSTATETYPE state,
- [in] DWORD value
- );
- HRESULT GetRenderState(
- [in] WINED3DRENDERSTATETYPE state,
- [out] DWORD *value
- );
- HRESULT SetRenderTarget(
- [in] DWORD render_target_idx,
- [in] IWineD3DSurface *render_target,
- [in] BOOL set_viewport
- );
- HRESULT GetRenderTarget(
- [in] DWORD render_target_idx,
- [out] IWineD3DSurface **render_target
- );
- HRESULT SetSamplerState(
- [in] DWORD sampler_idx,
- [in] WINED3DSAMPLERSTATETYPE state,
- [in] DWORD value
- );
- HRESULT GetSamplerState(
- [in] DWORD sampler_idx,
- [in] WINED3DSAMPLERSTATETYPE state,
- [out] DWORD *value
- );
- HRESULT SetScissorRect(
- [in] const RECT *rect
- );
- HRESULT GetScissorRect(
- [out] RECT *rect
- );
- HRESULT SetSoftwareVertexProcessing(
- [in] BOOL software
- );
- BOOL GetSoftwareVertexProcessing(
- );
- HRESULT SetStreamSource(
- [in] UINT stream_idx,
- [in] IWineD3DBuffer *buffer,
- [in] UINT offset,
- [in] UINT stride
- );
- HRESULT GetStreamSource(
- [in] UINT stream_idx,
- [out] IWineD3DBuffer **buffer,
- [out] UINT *offset,
- [out] UINT *stride
- );
- HRESULT SetStreamSourceFreq(
- [in] UINT stream_idx,
- [in] UINT divider
- );
- HRESULT GetStreamSourceFreq(
- [in] UINT stream_idx,
- [out] UINT *divider
- );
- HRESULT SetTexture(
- [in] DWORD stage,
- [in] IWineD3DBaseTexture *texture
- );
- HRESULT GetTexture(
- [in] DWORD stage,
- [out] IWineD3DBaseTexture **texture
- );
- HRESULT SetTextureStageState(
- [in] DWORD stage,
- [in] WINED3DTEXTURESTAGESTATETYPE state,
- [in] DWORD value
- );
- HRESULT GetTextureStageState(
- [in] DWORD stage,
- [in] WINED3DTEXTURESTAGESTATETYPE state,
- [out] DWORD *value
- );
- HRESULT SetTransform(
- [in] WINED3DTRANSFORMSTATETYPE state,
- [in] const WINED3DMATRIX *matrix
- );
- HRESULT GetTransform(
- [in] WINED3DTRANSFORMSTATETYPE state,
- [out] WINED3DMATRIX *matrix
- );
- HRESULT SetVertexDeclaration(
- [in] IWineD3DVertexDeclaration *declaration
- );
- HRESULT GetVertexDeclaration(
- [out] IWineD3DVertexDeclaration **declaration
- );
- HRESULT SetVertexShader(
- [in] IWineD3DVertexShader *shader
- );
- IWineD3DVertexShader *GetVertexShader(
- );
- HRESULT SetVertexShaderConstantB(
- [in] UINT start_register,
- [in] const BOOL *constants,
- [in] UINT bool_count
- );
- HRESULT GetVertexShaderConstantB(
- [in] UINT start_register,
- [out] BOOL *constants,
- [in] UINT bool_count
- );
- HRESULT SetVertexShaderConstantI(
- [in] UINT start_register,
- [in] const int *constants,
- [in] UINT vector4i_count
- );
- HRESULT GetVertexShaderConstantI(
- [in] UINT start_register,
- [out] int *constants,
- [in] UINT vector4i_count
- );
- HRESULT SetVertexShaderConstantF(
- [in] UINT start_register,
- [in] const float *constants,
- [in] UINT vector4f_count
- );
- HRESULT GetVertexShaderConstantF(
- [in] UINT start_register,
- [out] float *constants,
- [in] UINT vector4f_count
- );
- HRESULT SetViewport(
- [in] const WINED3DVIEWPORT *viewport
- );
- HRESULT GetViewport(
- [out] WINED3DVIEWPORT *viewport
- );
- HRESULT MultiplyTransform(
- [in] WINED3DTRANSFORMSTATETYPE state,
- [in] const WINED3DMATRIX *matrix
- );
- HRESULT ValidateDevice(
- [out] DWORD *num_passes
- );
- HRESULT ProcessVertices(
- [in] UINT src_start_idx,
- [in] UINT dst_idx,
- [in] UINT vertex_count,
- [in] IWineD3DBuffer *dest_buffer,
- [in] IWineD3DVertexDeclaration *declaration,
- [in] DWORD flags,
- [in] DWORD DestFVF
- );
- HRESULT BeginStateBlock(
- );
- HRESULT EndStateBlock(
- [out] IWineD3DStateBlock **stateblock
- );
- HRESULT BeginScene(
- );
- HRESULT EndScene(
- );
- HRESULT Present(
- [in] const RECT *src_rect,
- [in] const RECT *dst_rect,
- [in] HWND dst_window_override,
- [in] const RGNDATA *dirty_region
- );
- HRESULT Clear(
- [in] DWORD rect_count,
- [in] const RECT *rects,
- [in] DWORD flags,
- [in] WINED3DCOLOR color,
- [in] float z,
- [in] DWORD stencil
- );
- void ClearRendertargetView(
- [in] IWineD3DRendertargetView *rendertarget_view,
- [in] const WINED3DCOLORVALUE *color
- );
- void SetPrimitiveType(
- [in] WINED3DPRIMITIVETYPE primitive_topology
- );
- void GetPrimitiveType(
- [out] WINED3DPRIMITIVETYPE *primitive_topology
- );
- HRESULT DrawPrimitive(
- [in] UINT start_vertex,
- [in] UINT vertex_count
- );
- HRESULT DrawIndexedPrimitive(
- [in] UINT start_idx,
- [in] UINT index_count
- );
- HRESULT DrawPrimitiveUP(
- [in] UINT vertex_count,
- [in] const void *stream_data,
- [in] UINT stream_stride
- );
- HRESULT DrawIndexedPrimitiveUP(
- [in] UINT index_count,
- [in] const void *index_data,
- [in] enum wined3d_format_id index_data_format_id,
- [in] const void *stream_data,
- [in] UINT stream_stride
- );
- HRESULT DrawPrimitiveStrided(
- [in] UINT vertex_count,
- [in] const WineDirect3DVertexStridedData *strided_data
- );
- HRESULT DrawIndexedPrimitiveStrided(
- [in] UINT index_count,
- [in] const WineDirect3DVertexStridedData *strided_data,
- [in] UINT vertex_count,
- [in] const void *index_data,
- [in] enum wined3d_format_id index_data_format_id
- );
- HRESULT DrawRectPatch(
- [in] UINT handle,
- [in] const float *num_segs,
- [in] const WINED3DRECTPATCH_INFO *rect_patch_info
- );
- HRESULT DrawTriPatch(
- [in] UINT handle,
- [in] const float *num_segs,
- [in] const WINED3DTRIPATCH_INFO *tri_patch_info
- );
- HRESULT DeletePatch(
- [in] UINT handle
- );
- HRESULT ColorFill(
- [in] IWineD3DSurface *surface,
- [in] const RECT *rect,
- [in] const WINED3DCOLORVALUE *color
- );
- HRESULT UpdateTexture(
- [in] IWineD3DBaseTexture *src_texture,
- [in] IWineD3DBaseTexture *dst_texture
- );
- HRESULT UpdateSurface(
- [in] IWineD3DSurface *src_surface,
- [in] const RECT *src_rect,
- [in] IWineD3DSurface *dst_surface,
- [in] const POINT *dst_point
- );
- HRESULT GetFrontBufferData(
- [in] UINT swapchain_idx,
- [in] IWineD3DSurface *dst_surface
- );
- HRESULT EnumResources(
- [in] D3DCB_ENUMRESOURCES callback,
- [in] void *data
- );
- HRESULT GetSurfaceFromDC(
- [in] HDC dc,
- [out] IWineD3DSurface **surface
- );
- HRESULT AcquireFocusWindow(
- [in] HWND window
- );
- void ReleaseFocusWindow(
- );
-}
-
-#ifdef __midl
-IWineD3D * __stdcall WineDirect3DCreate(UINT dxVersion, void *parent);
-IWineD3DClipper * __stdcall WineDirect3DCreateClipper(void);
-void __stdcall wined3d_mutex_lock(void);
-void __stdcall wined3d_mutex_unlock(void);
-#else
-IWineD3D *WineDirect3DCreate(UINT dxVersion, void *parent);
-IWineD3DClipper *WineDirect3DCreateClipper(void);
-void wined3d_mutex_lock(void);
-void wined3d_mutex_unlock(void);
-#endif
-
diff --git a/reactos/include/reactos/wine/wineheaders.rbuild b/reactos/include/reactos/wine/wineheaders.rbuild
index e299181b900..8b9a00e3855 100644
--- a/reactos/include/reactos/wine/wineheaders.rbuild
+++ b/reactos/include/reactos/wine/wineheaders.rbuild
@@ -2,5 +2,4 @@
itss.idl
- wined3d.idl