Update wined3d, ddraw, d3d8 and d3d9 to Wine 1.3.4.
svn path=/trunk/; revision=49116
--- /dev/null
+/*
+ * Copyright 2005 Oliver Stieber
+ *
+ * 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 "d3d8_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
+
+static HRESULT WINAPI d3d8_vertexbuffer_QueryInterface(IDirect3DVertexBuffer8 *iface, REFIID riid, void **object)
+{
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+
+ if (IsEqualGUID(riid, &IID_IDirect3DVertexBuffer8)
+ || IsEqualGUID(riid, &IID_IDirect3DResource8)
+ || 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 WINAPI d3d8_vertexbuffer_AddRef(IDirect3DVertexBuffer8 *iface)
+{
+ IDirect3DVertexBuffer8Impl *buffer = (IDirect3DVertexBuffer8Impl *)iface;
+ ULONG refcount = InterlockedIncrement(&buffer->ref);
+
+ TRACE("%p increasing refcount to %u.\n", iface, refcount);
+
+ if (refcount == 1)
+ {
+ IDirect3DDevice8_AddRef(buffer->parentDevice);
+ wined3d_mutex_lock();
+ IWineD3DBuffer_AddRef(buffer->wineD3DVertexBuffer);
+ wined3d_mutex_unlock();
+ }
+
+ return refcount;
+}
+
+static ULONG WINAPI d3d8_vertexbuffer_Release(IDirect3DVertexBuffer8 *iface)
+{
+ IDirect3DVertexBuffer8Impl *buffer = (IDirect3DVertexBuffer8Impl *)iface;
+ ULONG refcount = InterlockedDecrement(&buffer->ref);
+
+ TRACE("%p decreasing refcount to %u.\n", iface, refcount);
+
+ if (!refcount)
+ {
+ IDirect3DDevice8 *device = buffer->parentDevice;
+
+ wined3d_mutex_lock();
+ IWineD3DBuffer_Release(buffer->wineD3DVertexBuffer);
+ wined3d_mutex_unlock();
+
+ /* Release the device last, as it may cause the device to be destroyed. */
+ IDirect3DDevice8_Release(device);
+ }
+
+ return refcount;
+}
+
+static HRESULT WINAPI d3d8_vertexbuffer_GetDevice(IDirect3DVertexBuffer8 *iface, IDirect3DDevice8 **device)
+{
+ TRACE("iface %p, device %p.\n", iface, device);
+
+ *device = (IDirect3DDevice8 *)((IDirect3DVertexBuffer8Impl *)iface)->parentDevice;
+ IDirect3DDevice8_AddRef(*device);
+
+ TRACE("Returning device %p.\n", *device);
+
+ return D3D_OK;
+}
+
+static HRESULT WINAPI d3d8_vertexbuffer_SetPrivateData(IDirect3DVertexBuffer8 *iface,
+ REFGUID guid, const void *data, DWORD data_size, DWORD flags)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
+ iface, debugstr_guid(guid), data, data_size, flags);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DBuffer_SetPrivateData(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer,
+ guid, data, data_size, flags);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI d3d8_vertexbuffer_GetPrivateData(IDirect3DVertexBuffer8 *iface,
+ REFGUID guid, void *data, DWORD *data_size)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, guid %s, data %p, data_size %p.\n",
+ iface, debugstr_guid(guid), data, data_size);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DBuffer_GetPrivateData(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer,
+ guid, data, data_size);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI d3d8_vertexbuffer_FreePrivateData(IDirect3DVertexBuffer8 *iface, REFGUID guid)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
+
+ wined3d_mutex_lock();
+ hr = IWineD3DBuffer_FreePrivateData(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer, guid);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static DWORD WINAPI d3d8_vertexbuffer_SetPriority(IDirect3DVertexBuffer8 *iface, DWORD priority)
+{
+ DWORD previous;
+
+ TRACE("iface %p, priority %u.\n", iface, priority);
+
+ wined3d_mutex_lock();
+ previous = IWineD3DBuffer_SetPriority(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer, priority);
+ wined3d_mutex_unlock();
+
+ return previous;
+}
+
+static DWORD WINAPI d3d8_vertexbuffer_GetPriority(IDirect3DVertexBuffer8 *iface)
+{
+ DWORD priority;
+
+ TRACE("iface %p.\n", iface);
+
+ wined3d_mutex_lock();
+ priority = IWineD3DBuffer_GetPriority(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer);
+ wined3d_mutex_unlock();
+
+ return priority;
+}
+
+static void WINAPI d3d8_vertexbuffer_PreLoad(IDirect3DVertexBuffer8 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ wined3d_mutex_lock();
+ IWineD3DBuffer_PreLoad(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer);
+ wined3d_mutex_unlock();
+}
+
+static D3DRESOURCETYPE WINAPI d3d8_vertexbuffer_GetType(IDirect3DVertexBuffer8 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return D3DRTYPE_VERTEXBUFFER;
+}
+
+static HRESULT WINAPI d3d8_vertexbuffer_Lock(IDirect3DVertexBuffer8 *iface,
+ UINT offset, UINT size, BYTE **data, DWORD flags)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n",
+ iface, offset, size, data, flags);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DBuffer_Map(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer,
+ offset, size, data, flags);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+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_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI d3d8_vertexbuffer_GetDesc(IDirect3DVertexBuffer8 *iface, D3DVERTEXBUFFER_DESC *desc)
+{
+ IDirect3DVertexBuffer8Impl *buffer = (IDirect3DVertexBuffer8Impl *)iface;
+ WINED3DBUFFER_DESC wined3d_desc;
+
+ TRACE("iface %p, desc %p.\n", iface, desc);
+
+ wined3d_mutex_lock();
+ IWineD3DBuffer_GetDesc(buffer->wineD3DVertexBuffer, &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->FVF = buffer->fvf;
+ desc->Format = D3DFMT_VERTEXDATA;
+
+ return D3D_OK;
+}
+
+static const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl =
+{
+ /* IUnknown */
+ d3d8_vertexbuffer_QueryInterface,
+ d3d8_vertexbuffer_AddRef,
+ d3d8_vertexbuffer_Release,
+ /* IDirect3DResource8 */
+ d3d8_vertexbuffer_GetDevice,
+ d3d8_vertexbuffer_SetPrivateData,
+ d3d8_vertexbuffer_GetPrivateData,
+ d3d8_vertexbuffer_FreePrivateData,
+ d3d8_vertexbuffer_SetPriority,
+ d3d8_vertexbuffer_GetPriority,
+ d3d8_vertexbuffer_PreLoad,
+ d3d8_vertexbuffer_GetType,
+ /* IDirect3DVertexBuffer8 */
+ d3d8_vertexbuffer_Lock,
+ d3d8_vertexbuffer_Unlock,
+ d3d8_vertexbuffer_GetDesc,
+};
+
+static void STDMETHODCALLTYPE d3d8_vertexbuffer_wined3d_object_destroyed(void *parent)
+{
+ HeapFree(GetProcessHeap(), 0, parent);
+}
+
+static const struct wined3d_parent_ops d3d8_vertexbuffer_wined3d_parent_ops =
+{
+ d3d8_vertexbuffer_wined3d_object_destroyed,
+};
+
+HRESULT vertexbuffer_init(IDirect3DVertexBuffer8Impl *buffer, IDirect3DDevice8Impl *device,
+ UINT size, DWORD usage, DWORD fvf, D3DPOOL pool)
+{
+ HRESULT hr;
+
+ buffer->lpVtbl = &Direct3DVertexBuffer8_Vtbl;
+ buffer->ref = 1;
+ buffer->fvf = fvf;
+
+ wined3d_mutex_lock();
+ hr = IWineD3DDevice_CreateVertexBuffer(device->WineD3DDevice, size, usage & WINED3DUSAGE_MASK,
+ (WINED3DPOOL)pool, buffer, &d3d8_vertexbuffer_wined3d_parent_ops, &buffer->wineD3DVertexBuffer);
+ wined3d_mutex_unlock();
+ if (FAILED(hr))
+ {
+ WARN("Failed to create wined3d buffer, hr %#x.\n", hr);
+ return hr;
+ }
+
+ buffer->parentDevice = (IDirect3DDevice8 *)device;
+ IUnknown_AddRef(buffer->parentDevice);
+
+ return D3D_OK;
+}
+
+static HRESULT WINAPI d3d8_indexbuffer_QueryInterface(IDirect3DIndexBuffer8 *iface, REFIID riid, void **object)
+{
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+
+ if (IsEqualGUID(riid, &IID_IDirect3DIndexBuffer8)
+ || IsEqualGUID(riid, &IID_IDirect3DResource8)
+ || 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 WINAPI d3d8_indexbuffer_AddRef(IDirect3DIndexBuffer8 *iface)
+{
+ IDirect3DIndexBuffer8Impl *buffer = (IDirect3DIndexBuffer8Impl *)iface;
+ ULONG refcount = InterlockedIncrement(&buffer->ref);
+
+ TRACE("%p increasing refcount to %u.\n", iface, refcount);
+
+ if (refcount == 1)
+ {
+ IDirect3DDevice8_AddRef(buffer->parentDevice);
+ wined3d_mutex_lock();
+ IWineD3DBuffer_AddRef(buffer->wineD3DIndexBuffer);
+ wined3d_mutex_unlock();
+ }
+
+ return refcount;
+}
+
+static ULONG WINAPI d3d8_indexbuffer_Release(IDirect3DIndexBuffer8 *iface)
+{
+ IDirect3DIndexBuffer8Impl *buffer = (IDirect3DIndexBuffer8Impl *)iface;
+ ULONG refcount = InterlockedDecrement(&buffer->ref);
+
+ TRACE("%p decreasing refcount to %u.\n", iface, refcount);
+
+ if (!refcount)
+ {
+ IDirect3DDevice8 *device = buffer->parentDevice;
+
+ wined3d_mutex_lock();
+ IWineD3DBuffer_Release(buffer->wineD3DIndexBuffer);
+ wined3d_mutex_unlock();
+
+ /* Release the device last, as it may cause the device to be destroyed. */
+ IDirect3DDevice8_Release(device);
+ }
+
+ return refcount;
+}
+
+static HRESULT WINAPI d3d8_indexbuffer_GetDevice(IDirect3DIndexBuffer8 *iface, IDirect3DDevice8 **device)
+{
+ TRACE("iface %p, device %p.\n", iface, device);
+
+ *device = (IDirect3DDevice8 *)((IDirect3DIndexBuffer8Impl *)iface)->parentDevice;
+ IDirect3DDevice8_AddRef(*device);
+
+ TRACE("Returning device %p.\n", *device);
+
+ return D3D_OK;
+}
+
+static HRESULT WINAPI d3d8_indexbuffer_SetPrivateData(IDirect3DIndexBuffer8 *iface,
+ REFGUID guid, const void *data, DWORD data_size, DWORD flags)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
+ iface, debugstr_guid(guid), data, data_size, flags);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DBuffer_SetPrivateData(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer,
+ guid, data, data_size, flags);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI d3d8_indexbuffer_GetPrivateData(IDirect3DIndexBuffer8 *iface,
+ REFGUID guid, void *data, DWORD *data_size)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, guid %s, data %p, data_size %p.\n",
+ iface, debugstr_guid(guid), data, data_size);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DBuffer_GetPrivateData(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer,
+ guid, data, data_size);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI d3d8_indexbuffer_FreePrivateData(IDirect3DIndexBuffer8 *iface, REFGUID guid)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
+
+ wined3d_mutex_lock();
+ hr = IWineD3DBuffer_FreePrivateData(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer, guid);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static DWORD WINAPI d3d8_indexbuffer_SetPriority(IDirect3DIndexBuffer8 *iface, DWORD priority)
+{
+ DWORD previous;
+
+ TRACE("iface %p, priority %u.\n", iface, priority);
+
+ wined3d_mutex_lock();
+ previous = IWineD3DBuffer_SetPriority(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer, priority);
+ wined3d_mutex_unlock();
+
+ return previous;
+}
+
+static DWORD WINAPI d3d8_indexbuffer_GetPriority(IDirect3DIndexBuffer8 *iface)
+{
+ DWORD priority;
+
+ TRACE("iface %p.\n", iface);
+
+ wined3d_mutex_lock();
+ priority = IWineD3DBuffer_GetPriority(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer);
+ wined3d_mutex_unlock();
+
+ return priority;
+}
+
+static void WINAPI d3d8_indexbuffer_PreLoad(IDirect3DIndexBuffer8 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ wined3d_mutex_lock();
+ IWineD3DBuffer_PreLoad(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer);
+ wined3d_mutex_unlock();
+}
+
+static D3DRESOURCETYPE WINAPI d3d8_indexbuffer_GetType(IDirect3DIndexBuffer8 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return D3DRTYPE_INDEXBUFFER;
+}
+
+static HRESULT WINAPI d3d8_indexbuffer_Lock(IDirect3DIndexBuffer8 *iface,
+ UINT offset, UINT size, BYTE **data, DWORD flags)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n",
+ iface, offset, size, data, flags);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DBuffer_Map(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer,
+ offset, size, data, flags);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+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_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI d3d8_indexbuffer_GetDesc(IDirect3DIndexBuffer8 *iface, D3DINDEXBUFFER_DESC *desc)
+{
+ IDirect3DIndexBuffer8Impl *buffer = (IDirect3DIndexBuffer8Impl *)iface;
+ WINED3DBUFFER_DESC wined3d_desc;
+
+ TRACE("iface %p, desc %p.\n", iface, desc);
+
+ wined3d_mutex_lock();
+ IWineD3DBuffer_GetDesc(buffer->wineD3DIndexBuffer, &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;
+
+ return D3D_OK;
+}
+
+static const IDirect3DIndexBuffer8Vtbl d3d8_indexbuffer_vtbl =
+{
+ /* IUnknown */
+ d3d8_indexbuffer_QueryInterface,
+ d3d8_indexbuffer_AddRef,
+ d3d8_indexbuffer_Release,
+ /* IDirect3DResource8 */
+ d3d8_indexbuffer_GetDevice,
+ d3d8_indexbuffer_SetPrivateData,
+ d3d8_indexbuffer_GetPrivateData,
+ d3d8_indexbuffer_FreePrivateData,
+ d3d8_indexbuffer_SetPriority,
+ d3d8_indexbuffer_GetPriority,
+ d3d8_indexbuffer_PreLoad,
+ d3d8_indexbuffer_GetType,
+ /* IDirect3DIndexBuffer8 */
+ d3d8_indexbuffer_Lock,
+ d3d8_indexbuffer_Unlock,
+ d3d8_indexbuffer_GetDesc,
+};
+
+static void STDMETHODCALLTYPE d3d8_indexbuffer_wined3d_object_destroyed(void *parent)
+{
+ HeapFree(GetProcessHeap(), 0, parent);
+}
+
+static const struct wined3d_parent_ops d3d8_indexbuffer_wined3d_parent_ops =
+{
+ d3d8_indexbuffer_wined3d_object_destroyed,
+};
+
+HRESULT indexbuffer_init(IDirect3DIndexBuffer8Impl *buffer, IDirect3DDevice8Impl *device,
+ UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool)
+{
+ HRESULT hr;
+
+ buffer->lpVtbl = &d3d8_indexbuffer_vtbl;
+ buffer->ref = 1;
+ buffer->format = wined3dformat_from_d3dformat(format);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DDevice_CreateIndexBuffer(device->WineD3DDevice, size, usage & WINED3DUSAGE_MASK,
+ (WINED3DPOOL)pool, buffer, &d3d8_indexbuffer_wined3d_parent_ops, &buffer->wineD3DIndexBuffer);
+ wined3d_mutex_unlock();
+ if (FAILED(hr))
+ {
+ WARN("Failed to create wined3d buffer, hr %#x.\n", hr);
+ return hr;
+ }
+
+ buffer->parentDevice = (IDirect3DDevice8 *)device;
+ IUnknown_AddRef(buffer->parentDevice);
+
+ return D3D_OK;
+}
return hr;
}
-static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface8 **ppCubeMapSurface) {
+static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetCubeMapSurface(IDirect3DCubeTexture8 *iface,
+ D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface8 **ppCubeMapSurface)
+{
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
- HRESULT hrc = D3D_OK;
IWineD3DSurface *mySurface = NULL;
+ HRESULT hr;
TRACE("iface %p, face %#x, level %u, surface %p.\n", iface, FaceType, Level, ppCubeMapSurface);
wined3d_mutex_lock();
- hrc = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, &mySurface);
- if (hrc == D3D_OK && NULL != ppCubeMapSurface) {
- IWineD3DCubeTexture_GetParent(mySurface, (IUnknown **)ppCubeMapSurface);
+ hr = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture,
+ (WINED3DCUBEMAP_FACES) FaceType, Level, &mySurface);
+ if (SUCCEEDED(hr) && ppCubeMapSurface)
+ {
+ *ppCubeMapSurface = IWineD3DCubeTexture_GetParent(mySurface);
+ IDirect3DSurface8_AddRef(*ppCubeMapSurface);
IWineD3DCubeTexture_Release(mySurface);
}
wined3d_mutex_unlock();
- return hrc;
+ return hr;
}
static HRESULT WINAPI IDirect3DCubeTexture8Impl_LockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT *pRect, DWORD Flags) {
texture->ref = 1;
wined3d_mutex_lock();
- hr = IWineD3DDevice_CreateCubeTexture(device->WineD3DDevice, edge_length, levels, usage & WINED3DUSAGE_MASK,
- wined3dformat_from_d3dformat(format), pool, &texture->wineD3DCubeTexture,
- (IUnknown *)texture, &d3d8_cubetexture_wined3d_parent_ops);
+ hr = IWineD3DDevice_CreateCubeTexture(device->WineD3DDevice, edge_length, levels,
+ usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool, texture,
+ &d3d8_cubetexture_wined3d_parent_ops, &texture->wineD3DCubeTexture);
wined3d_mutex_unlock();
if (FAILED(hr))
{
<library>advapi32</library>
<library>wined3d</library>
+ <file>buffer.c</file>
<file>cubetexture.c</file>
<file>d3d8_main.c</file>
<file>device.c</file>
<file>directx.c</file>
- <file>indexbuffer.c</file>
- <file>pixelshader.c</file>
+ <file>shader.c</file>
<file>surface.c</file>
<file>swapchain.c</file>
<file>texture.c</file>
- <file>vertexbuffer.c</file>
<file>vertexdeclaration.c</file>
- <file>vertexshader.c</file>
<file>volume.c</file>
<file>volumetexture.c</file>
<file>version.rc</file>
ret=S_OK;
break;
default:
- ERR("vertexshader version mismatch\n");
+ WARN("Invalid shader version token %#x.\n", *vertexshader);
ret=E_FAIL;
}
ret=S_OK;
break;
default:
- ERR("pixelshader version mismatch\n");
+ WARN("Invalid shader version token %#x.\n", *pixelshader);
ret=E_FAIL;
}
return ret;
};
HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device, UINT width, UINT height,
- UINT depth, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool) DECLSPEC_HIDDEN;
+ UINT depth, DWORD usage, enum wined3d_format_id format, WINED3DPOOL pool) DECLSPEC_HIDDEN;
/* ------------------- */
/* IDirect3DSwapChain8 */
/* Parent reference */
LPDIRECT3DDEVICE8 parentDevice;
- WINED3DFORMAT format;
+ enum wined3d_format_id format;
};
HRESULT indexbuffer_init(IDirect3DIndexBuffer8Impl *buffer, IDirect3DDevice8Impl *device,
HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl *device,
const DWORD *byte_code, DWORD shader_handle) DECLSPEC_HIDDEN;
-/**
- * Internals functions
- *
- * to see how not defined it here
- */
-D3DFORMAT d3dformat_from_wined3dformat(WINED3DFORMAT format) DECLSPEC_HIDDEN;
-WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN;
+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;
size_t parse_token(const DWORD *pToken) DECLSPEC_HIDDEN;
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
-D3DFORMAT d3dformat_from_wined3dformat(WINED3DFORMAT format)
+D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format)
{
BYTE *c = (BYTE *)&format;
case WINED3DFMT_R16_UINT: return D3DFMT_INDEX16;
case WINED3DFMT_R32_UINT: return D3DFMT_INDEX32;
default:
- FIXME("Unhandled WINED3DFORMAT %#x\n", format);
+ FIXME("Unhandled wined3d format %#x.\n", format);
return D3DFMT_UNKNOWN;
}
}
-WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format)
+enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format)
{
BYTE *c = (BYTE *)&format;
TRACE("swapchain %p.\n", swapchain);
- IWineD3DSwapChain_GetParent(swapchain, &parent);
- IUnknown_Release(parent);
+ parent = IWineD3DSwapChain_GetParent(swapchain);
return IUnknown_Release(parent);
}
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetDirect3D(LPDIRECT3DDEVICE8 iface, IDirect3D8** ppD3D8) {
+static HRESULT WINAPI IDirect3DDevice8Impl_GetDirect3D(IDirect3DDevice8 *iface, IDirect3D8 **ppD3D8)
+{
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- HRESULT hr = D3D_OK;
- IWineD3D* pWineD3D;
+ IWineD3D *pWineD3D;
+ HRESULT hr;
TRACE("iface %p, d3d8 %p.\n", iface, ppD3D8);
wined3d_mutex_lock();
hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &pWineD3D);
- if (hr == D3D_OK && pWineD3D != NULL)
+ if (SUCCEEDED(hr) && pWineD3D)
{
- IWineD3D_GetParent(pWineD3D,(IUnknown **)ppD3D8);
+ *ppD3D8 = IWineD3D_GetParent(pWineD3D);
+ IDirect3D8_AddRef(*ppD3D8);
IWineD3D_Release(pWineD3D);
- } else {
+ }
+ else
+ {
FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
*ppD3D8 = NULL;
}
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetBackBuffer(LPDIRECT3DDEVICE8 iface, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8** ppBackBuffer) {
+static HRESULT WINAPI IDirect3DDevice8Impl_GetBackBuffer(IDirect3DDevice8 *iface,
+ UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8 **ppBackBuffer)
+{
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
IWineD3DSurface *retSurface = NULL;
- HRESULT rc = D3D_OK;
+ HRESULT hr;
TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
iface, BackBuffer, Type, ppBackBuffer);
wined3d_mutex_lock();
- rc = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, 0, BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &retSurface);
- if (rc == D3D_OK && NULL != retSurface && NULL != ppBackBuffer) {
- IWineD3DSurface_GetParent(retSurface, (IUnknown **)ppBackBuffer);
+ hr = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, 0, BackBuffer, (WINED3DBACKBUFFER_TYPE)Type, &retSurface);
+ if (SUCCEEDED(hr) && retSurface && ppBackBuffer)
+ {
+ *ppBackBuffer = IWineD3DSurface_GetParent(retSurface);
+ IDirect3DSurface8_AddRef(*ppBackBuffer);
IWineD3DSurface_Release(retSurface);
}
wined3d_mutex_unlock();
- return rc;
+ return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_GetRasterStatus(LPDIRECT3DDEVICE8 iface, D3DRASTER_STATUS* pRasterStatus) {
IDirect3DSurface8Impl *Dest = (IDirect3DSurface8Impl *) pDestinationSurface;
HRESULT hr = WINED3D_OK;
- WINED3DFORMAT srcFormat, destFormat;
+ enum wined3d_format_id srcFormat, destFormat;
WINED3DSURFACE_DESC winedesc;
TRACE("iface %p, src_surface %p, src_rects %p, rect_count %u, dst_surface %p, dst_points %p.\n",
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderTarget(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8** ppRenderTarget) {
+static HRESULT WINAPI IDirect3DDevice8Impl_GetRenderTarget(IDirect3DDevice8 *iface,
+ IDirect3DSurface8 **ppRenderTarget)
+{
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- HRESULT hr = D3D_OK;
IWineD3DSurface *pRenderTarget;
+ HRESULT hr;
TRACE("iface %p, render_target %p.\n", iface, ppRenderTarget);
wined3d_mutex_lock();
hr = IWineD3DDevice_GetRenderTarget(This->WineD3DDevice, 0, &pRenderTarget);
-
- if (hr == D3D_OK && pRenderTarget != NULL) {
- IWineD3DSurface_GetParent(pRenderTarget,(IUnknown**)ppRenderTarget);
+ if (SUCCEEDED(hr) && pRenderTarget)
+ {
+ *ppRenderTarget = IWineD3DSurface_GetParent(pRenderTarget);
+ IDirect3DSurface8_AddRef(*ppRenderTarget);
IWineD3DSurface_Release(pRenderTarget);
- } else {
+ }
+ else
+ {
FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
*ppRenderTarget = NULL;
}
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8** ppZStencilSurface) {
+static HRESULT WINAPI IDirect3DDevice8Impl_GetDepthStencilSurface(IDirect3DDevice8 *iface,
+ IDirect3DSurface8 **ppZStencilSurface)
+{
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- HRESULT hr = D3D_OK;
IWineD3DSurface *pZStencilSurface;
+ HRESULT hr;
TRACE("iface %p, depth_stencil %p.\n", iface, ppZStencilSurface);
}
wined3d_mutex_lock();
- hr=IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface);
- if (hr == WINED3D_OK) {
- IWineD3DSurface_GetParent(pZStencilSurface,(IUnknown**)ppZStencilSurface);
+ hr = IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice, &pZStencilSurface);
+ if (SUCCEEDED(hr))
+ {
+ *ppZStencilSurface = IWineD3DSurface_GetParent(pZStencilSurface);
+ IDirect3DSurface8_AddRef(*ppZStencilSurface);
IWineD3DSurface_Release(pZStencilSurface);
- }else{
+ }
+ else
+ {
if (hr != WINED3DERR_NOTFOUND)
FIXME("Call to IWineD3DDevice_GetDepthStencilSurface failed with 0x%08x\n", hr);
*ppZStencilSurface = NULL;
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);
- /* Note: D3DRECT is compatible with WINED3DRECT */
wined3d_mutex_lock();
- hr = IWineD3DDevice_Clear(This->WineD3DDevice, Count, (CONST WINED3DRECT*) pRects, Flags, Color, Z, Stencil);
+ hr = IWineD3DDevice_Clear(This->WineD3DDevice, Count, (const RECT *)pRects, Flags, Color, Z, Stencil);
wined3d_mutex_unlock();
return hr;
}
wined3d_mutex_lock();
- hr = IWineD3DDevice_CreateStateBlock(This->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)Type,
- &stateblock, NULL);
+ hr = IWineD3DDevice_CreateStateBlock(This->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)Type, &stateblock);
if (FAILED(hr))
{
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetTexture(LPDIRECT3DDEVICE8 iface, DWORD Stage,IDirect3DBaseTexture8** ppTexture) {
+static HRESULT WINAPI IDirect3DDevice8Impl_GetTexture(IDirect3DDevice8 *iface,
+ DWORD Stage, IDirect3DBaseTexture8 **ppTexture)
+{
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
IWineD3DBaseTexture *retTexture;
HRESULT hr;
if (retTexture)
{
- IWineD3DBaseTexture_GetParent(retTexture, (IUnknown **)ppTexture);
+ *ppTexture = IWineD3DBaseTexture_GetParent(retTexture);
+ IDirect3DBaseTexture8_AddRef(*ppTexture);
IWineD3DBaseTexture_Release(retTexture);
}
else
{FALSE, WINED3DTSS_RESULTARG}, /* 28, D3DTSS_RESULTARG */
};
-static HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) {
+static HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD *pValue)
+{
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- const struct tss_lookup *l = &tss_lookup[Type];
+ const struct tss_lookup *l;
HRESULT hr;
TRACE("iface %p, stage %u, state %#x, value %p.\n", iface, Stage, Type, pValue);
+ if (Type >= sizeof(tss_lookup) / sizeof(*tss_lookup))
+ {
+ WARN("Invalid Type %#x passed.\n", Type);
+ return D3D_OK;
+ }
+
+ 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);
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
+static HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value)
+{
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- const struct tss_lookup *l = &tss_lookup[Type];
+ const struct tss_lookup *l;
HRESULT hr;
TRACE("iface %p, stage %u, state %#x, value %#x.\n", iface, Stage, Type, Value);
+ if (Type >= sizeof(tss_lookup) / sizeof(*tss_lookup))
+ {
+ WARN("Invalid Type %#x passed.\n", Type);
+ return D3D_OK;
+ }
+
+ 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);
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD* ppShader) {
+static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(IDirect3DDevice8 *iface, DWORD *ppShader)
+{
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
IWineD3DVertexDeclaration *wined3d_declaration;
IDirect3DVertexDeclaration8 *d3d8_declaration;
- HRESULT hrc;
+ HRESULT hr;
TRACE("iface %p, shader %p.\n", iface, ppShader);
wined3d_mutex_lock();
- hrc = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &wined3d_declaration);
- if (FAILED(hrc))
+ hr = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &wined3d_declaration);
+ if (FAILED(hr))
{
wined3d_mutex_unlock();
WARN("(%p) : Call to IWineD3DDevice_GetVertexDeclaration failed %#x (device %p)\n",
- This, hrc, This->WineD3DDevice);
- return hrc;
+ This, hr, This->WineD3DDevice);
+ return hr;
}
if (!wined3d_declaration)
return D3D_OK;
}
- hrc = IWineD3DVertexDeclaration_GetParent(wined3d_declaration, (IUnknown **)&d3d8_declaration);
+ d3d8_declaration = IWineD3DVertexDeclaration_GetParent(wined3d_declaration);
IWineD3DVertexDeclaration_Release(wined3d_declaration);
wined3d_mutex_unlock();
- if (SUCCEEDED(hrc))
- {
- *ppShader = ((IDirect3DVertexDeclaration8Impl *)d3d8_declaration)->shader_handle;
- IDirect3DVertexDeclaration8_Release(d3d8_declaration);
- }
+ *ppShader = ((IDirect3DVertexDeclaration8Impl *)d3d8_declaration)->shader_handle;
TRACE("(%p) : returning %#x\n", This, *ppShader);
- return hrc;
+ return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_DeleteVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
IDirect3DVertexShader8Impl *shader;
- IWineD3DVertexShader *cur = NULL;
+ IWineD3DVertexShader *cur;
TRACE("iface %p, shader %#x.\n", iface, pShader);
return D3DERR_INVALIDCALL;
}
- IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &cur);
-
+ cur = IWineD3DDevice_GetVertexShader(This->WineD3DDevice);
if (cur)
{
if (cur == shader->wineD3DVertexShader) IDirect3DDevice8_SetVertexShader(iface, 0);
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetIndices(LPDIRECT3DDEVICE8 iface, IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex) {
+static HRESULT WINAPI IDirect3DDevice8Impl_GetIndices(IDirect3DDevice8 *iface,
+ IDirect3DIndexBuffer8 **ppIndexData, UINT *pBaseVertexIndex)
+{
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
IWineD3DBuffer *retIndexData = NULL;
- HRESULT rc = D3D_OK;
+ HRESULT hr;
TRACE("iface %p, buffer %p, base_vertex_index %p.\n", iface, ppIndexData, pBaseVertexIndex);
/* The case from UINT to INT is safe because d3d8 will never set negative values */
wined3d_mutex_lock();
IWineD3DDevice_GetBaseVertexIndex(This->WineD3DDevice, (INT *) pBaseVertexIndex);
- rc = IWineD3DDevice_GetIndexBuffer(This->WineD3DDevice, &retIndexData);
- if (SUCCEEDED(rc) && retIndexData) {
- IWineD3DBuffer_GetParent(retIndexData, (IUnknown **)ppIndexData);
+ hr = IWineD3DDevice_GetIndexBuffer(This->WineD3DDevice, &retIndexData);
+ if (SUCCEEDED(hr) && retIndexData)
+ {
+ *ppIndexData = IWineD3DBuffer_GetParent(retIndexData);
+ IDirect3DIndexBuffer8_AddRef(*ppIndexData);
IWineD3DBuffer_Release(retIndexData);
} else {
- if (FAILED(rc)) FIXME("Call to GetIndices failed\n");
+ if (FAILED(hr)) FIXME("Call to GetIndices failed\n");
*ppIndexData = NULL;
}
wined3d_mutex_unlock();
- return rc;
+ return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_CreatePixelShader(IDirect3DDevice8 *iface,
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(LPDIRECT3DDEVICE8 iface, DWORD* ppShader) {
+static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShader(IDirect3DDevice8 *iface, DWORD *ppShader)
+{
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
IWineD3DPixelShader *object;
- HRESULT hrc = D3D_OK;
TRACE("iface %p, shader %p.\n", iface, ppShader);
}
wined3d_mutex_lock();
- hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object);
- if (D3D_OK == hrc && NULL != object) {
+ object = IWineD3DDevice_GetPixelShader(This->WineD3DDevice);
+ if (object)
+ {
IDirect3DPixelShader8Impl *d3d8_shader;
- hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)&d3d8_shader);
+ d3d8_shader = IWineD3DPixelShader_GetParent(object);
IWineD3DPixelShader_Release(object);
*ppShader = d3d8_shader->handle;
- IDirect3DPixelShader8_Release((IDirect3DPixelShader8 *)d3d8_shader);
- } else {
+ }
+ else
+ {
*ppShader = 0;
}
wined3d_mutex_unlock();
TRACE("(%p) : returning %#x\n", This, *ppShader);
- return hrc;
+ return D3D_OK;
}
static HRESULT WINAPI IDirect3DDevice8Impl_DeletePixelShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
IDirect3DPixelShader8Impl *shader;
- IWineD3DPixelShader *cur = NULL;
+ IWineD3DPixelShader *cur;
TRACE("iface %p, shader %#x.\n", iface, pShader);
return D3DERR_INVALIDCALL;
}
- IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &cur);
-
+ cur = IWineD3DDevice_GetPixelShader(This->WineD3DDevice);
if (cur)
{
if (cur == shader->wineD3DPixelShader) IDirect3DDevice8_SetPixelShader(iface, 0);
return hr;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_GetStreamSource(LPDIRECT3DDEVICE8 iface, UINT StreamNumber,IDirect3DVertexBuffer8** pStream,UINT* pStride) {
+static HRESULT WINAPI IDirect3DDevice8Impl_GetStreamSource(IDirect3DDevice8 *iface,
+ UINT StreamNumber, IDirect3DVertexBuffer8 **pStream, UINT *pStride)
+{
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
IWineD3DBuffer *retStream = NULL;
- HRESULT rc = D3D_OK;
+ HRESULT hr;
TRACE("iface %p, stream_idx %u, buffer %p, stride %p.\n",
iface, StreamNumber, pStream, pStride);
}
wined3d_mutex_lock();
- rc = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, &retStream, 0 /* Offset in bytes */, pStride);
- if (rc == D3D_OK && NULL != retStream) {
- IWineD3DBuffer_GetParent(retStream, (IUnknown **)pStream);
+ hr = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber,
+ &retStream, 0 /* Offset in bytes */, pStride);
+ if (SUCCEEDED(hr) && retStream)
+ {
+ *pStream = IWineD3DBuffer_GetParent(retStream);
+ IDirect3DVertexBuffer8_AddRef(*pStream);
IWineD3DBuffer_Release(retStream);
- }else{
- if (rc != D3D_OK){
- FIXME("Call to GetStreamSource failed %p\n", pStride);
- }
+ }
+ else
+ {
+ if (FAILED(hr)) FIXME("Call to GetStreamSource failed, hr %#x.\n", hr);
*pStream = NULL;
}
wined3d_mutex_unlock();
- return rc;
+ return hr;
}
static const IDirect3DDevice8Vtbl Direct3DDevice8_Vtbl =
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
+ 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);
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateRenderTarget(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
- DWORD multisample_quality, BOOL lockable, IWineD3DSurface **surface)
+ IUnknown *superior, UINT width, UINT height, enum wined3d_format_id format,
+ WINED3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality, BOOL lockable,
+ IWineD3DSurface **surface)
{
struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
IDirect3DSurface8Impl *d3d_surface;
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
+ UINT width, UINT height, enum wined3d_format_id format, WINED3DMULTISAMPLE_TYPE multisample_type,
DWORD multisample_quality, BOOL discard, IWineD3DSurface **surface)
{
struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
IDirect3DSurface8Impl *d3d_surface;
HRESULT hr;
- TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
+ TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x,\n"
"\tmultisample_quality %u, discard %u, surface %p\n",
- iface, superior, width, height, format, multisample_type, multisample_quality, discard, surface);
+ iface, width, height, format, multisample_type, multisample_quality, discard, surface);
hr = IDirect3DDevice8_CreateDepthStencilSurface((IDirect3DDevice8 *)This, width, height,
d3dformat_from_wined3dformat(format), multisample_type, (IDirect3DSurface8 **)&d3d_surface);
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, UINT depth, WINED3DFORMAT format,
+ IUnknown *superior, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
WINED3DPOOL pool, DWORD usage, IWineD3DVolume **volume)
{
struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
static void setup_fpu(void)
{
- WORD cw;
-
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
+ WORD cw;
__asm__ volatile ("fnstcw %0" : "=m" (cw));
cw = (cw & ~0xf3f) | 0x3f;
__asm__ volatile ("fldcw %0" : : "m" (cw));
if (!(flags & D3DCREATE_FPU_PRESERVE)) setup_fpu();
wined3d_mutex_lock();
- hr = IWineD3D_CreateDevice(wined3d, adapter, device_type, focus_window, flags, (IUnknown *)device,
+ hr = IWineD3D_CreateDevice(wined3d, adapter, device_type, focus_window, flags,
(IWineD3DDeviceParent *)&device->device_parent_vtbl, &device->WineD3DDevice);
if (FAILED(hr))
{
+++ /dev/null
-/*
- * IDirect3DIndexBuffer8 implementation
- *
- * Copyright 2005 Oliver Stieber
- *
- * 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 "d3d8_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
-
-/* IDirect3DIndexBuffer8 IUnknown parts follow: */
-static HRESULT WINAPI IDirect3DIndexBuffer8Impl_QueryInterface(LPDIRECT3DINDEXBUFFER8 iface, REFIID riid, LPVOID *ppobj) {
- IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
-
- TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
-
- if (IsEqualGUID(riid, &IID_IUnknown)
- || IsEqualGUID(riid, &IID_IDirect3DResource8)
- || IsEqualGUID(riid, &IID_IDirect3DIndexBuffer8)) {
- IUnknown_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
-
- WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
- *ppobj = NULL;
- return E_NOINTERFACE;
-}
-
-static ULONG WINAPI IDirect3DIndexBuffer8Impl_AddRef(LPDIRECT3DINDEXBUFFER8 iface) {
- IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
- ULONG ref = InterlockedIncrement(&This->ref);
-
- TRACE("%p increasing refcount to %u.\n", iface, ref);
-
- if (ref == 1)
- {
- IDirect3DDevice8_AddRef(This->parentDevice);
- wined3d_mutex_lock();
- IWineD3DBuffer_AddRef(This->wineD3DIndexBuffer);
- wined3d_mutex_unlock();
- }
-
- return ref;
-}
-
-static ULONG WINAPI IDirect3DIndexBuffer8Impl_Release(LPDIRECT3DINDEXBUFFER8 iface) {
- IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
- ULONG ref = InterlockedDecrement(&This->ref);
-
- TRACE("%p decreasing refcount to %u.\n", iface, ref);
-
- if (ref == 0) {
- IDirect3DDevice8 *parentDevice = This->parentDevice;
-
- wined3d_mutex_lock();
- IWineD3DBuffer_Release(This->wineD3DIndexBuffer);
- wined3d_mutex_unlock();
-
- /* Release the device last, as it may cause the device to be destroyed. */
- IDirect3DDevice8_Release(parentDevice);
- }
- return ref;
-}
-
-/* IDirect3DIndexBuffer8 IDirect3DResource8 Interface follow: */
-static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(IDirect3DIndexBuffer8 *iface, IDirect3DDevice8 **device)
-{
- IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
-
- TRACE("iface %p, device %p.\n", iface, device);
-
- *device = (IDirect3DDevice8 *)This->parentDevice;
- IDirect3DDevice8_AddRef(*device);
-
- TRACE("Returning device %p.\n", *device);
-
- return D3D_OK;
-}
-
-static HRESULT WINAPI IDirect3DIndexBuffer8Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
- IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)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 = IWineD3DBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
- IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, guid %s, data %p, data_size %p.\n",
- iface, debugstr_guid(refguid), pData, pSizeOfData);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DIndexBuffer8Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid) {
- IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static DWORD WINAPI IDirect3DIndexBuffer8Impl_SetPriority(LPDIRECT3DINDEXBUFFER8 iface, DWORD PriorityNew) {
- IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
- DWORD ret;
-
- TRACE("iface %p, priority %u.\n", iface, PriorityNew);
-
- wined3d_mutex_lock();
- ret = IWineD3DBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew);
- wined3d_mutex_unlock();
-
- return ret;
-}
-
-static DWORD WINAPI IDirect3DIndexBuffer8Impl_GetPriority(LPDIRECT3DINDEXBUFFER8 iface) {
- IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
- DWORD ret;
-
- TRACE("iface %p.\n", iface);
-
- wined3d_mutex_lock();
- ret = IWineD3DBuffer_GetPriority(This->wineD3DIndexBuffer);
- wined3d_mutex_unlock();
-
- return ret;
-}
-
-static void WINAPI IDirect3DIndexBuffer8Impl_PreLoad(LPDIRECT3DINDEXBUFFER8 iface) {
- IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
-
- TRACE("iface %p.\n", iface);
-
- wined3d_mutex_lock();
- IWineD3DBuffer_PreLoad(This->wineD3DIndexBuffer);
- wined3d_mutex_unlock();
-}
-
-static D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer8Impl_GetType(IDirect3DIndexBuffer8 *iface)
-{
- TRACE("iface %p.\n", iface);
-
- return D3DRTYPE_INDEXBUFFER;
-}
-
-/* IDirect3DIndexBuffer8 Interface follow: */
-static HRESULT WINAPI IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE **ppbData, DWORD Flags) {
- IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n",
- iface, OffsetToLock, SizeToLock, ppbData, Flags);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_Map(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DIndexBuffer8Impl_Unlock(LPDIRECT3DINDEXBUFFER8 iface) {
- IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p.\n", iface);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_Unmap(This->wineD3DIndexBuffer);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 iface, D3DINDEXBUFFER_DESC *pDesc) {
- IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
- HRESULT hr;
- WINED3DBUFFER_DESC desc;
-
- TRACE("iface %p, desc %p.\n", iface, pDesc);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_GetDesc(This->wineD3DIndexBuffer, &desc);
- wined3d_mutex_unlock();
-
- if (SUCCEEDED(hr)) {
- pDesc->Format = d3dformat_from_wined3dformat(This->format);
- pDesc->Type = D3DRTYPE_INDEXBUFFER;
- pDesc->Usage = desc.Usage;
- pDesc->Pool = desc.Pool;
- pDesc->Size = desc.Size;
- }
-
- return hr;
-}
-
-static const IDirect3DIndexBuffer8Vtbl Direct3DIndexBuffer8_Vtbl =
-{
- /* IUnknown */
- IDirect3DIndexBuffer8Impl_QueryInterface,
- IDirect3DIndexBuffer8Impl_AddRef,
- IDirect3DIndexBuffer8Impl_Release,
- /* IDirect3DResource8 */
- IDirect3DIndexBuffer8Impl_GetDevice,
- IDirect3DIndexBuffer8Impl_SetPrivateData,
- IDirect3DIndexBuffer8Impl_GetPrivateData,
- IDirect3DIndexBuffer8Impl_FreePrivateData,
- IDirect3DIndexBuffer8Impl_SetPriority,
- IDirect3DIndexBuffer8Impl_GetPriority,
- IDirect3DIndexBuffer8Impl_PreLoad,
- IDirect3DIndexBuffer8Impl_GetType,
- /* IDirect3DIndexBuffer8 */
- IDirect3DIndexBuffer8Impl_Lock,
- IDirect3DIndexBuffer8Impl_Unlock,
- IDirect3DIndexBuffer8Impl_GetDesc
-};
-
-static void STDMETHODCALLTYPE d3d8_indexbuffer_wined3d_object_destroyed(void *parent)
-{
- HeapFree(GetProcessHeap(), 0, parent);
-}
-
-static const struct wined3d_parent_ops d3d8_indexbuffer_wined3d_parent_ops =
-{
- d3d8_indexbuffer_wined3d_object_destroyed,
-};
-
-HRESULT indexbuffer_init(IDirect3DIndexBuffer8Impl *buffer, IDirect3DDevice8Impl *device,
- UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool)
-{
- HRESULT hr;
-
- buffer->lpVtbl = &Direct3DIndexBuffer8_Vtbl;
- buffer->ref = 1;
- buffer->format = wined3dformat_from_d3dformat(format);
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_CreateIndexBuffer(device->WineD3DDevice, size,
- usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, &buffer->wineD3DIndexBuffer,
- (IUnknown *)buffer, &d3d8_indexbuffer_wined3d_parent_ops);
- wined3d_mutex_unlock();
- if (FAILED(hr))
- {
- WARN("Failed to create wined3d buffer, hr %#x.\n", hr);
- return hr;
- }
-
- buffer->parentDevice = (IDirect3DDevice8 *)device;
- IUnknown_AddRef(buffer->parentDevice);
-
- return D3D_OK;
-}
+++ /dev/null
-/*
- * IDirect3DPixelShader8 implementation
- *
- * Copyright 2002-2003 Jason Edmeades
- * Raphael Junqueira
- *
- * 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 "d3d8_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
-
-/* IDirect3DPixelShader8 IUnknown parts follow: */
-static HRESULT WINAPI IDirect3DPixelShader8Impl_QueryInterface(IDirect3DPixelShader8 *iface, REFIID riid, LPVOID *ppobj) {
- IDirect3DPixelShader8Impl *This = (IDirect3DPixelShader8Impl *)iface;
-
- TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
-
- if (IsEqualGUID(riid, &IID_IUnknown)
- || IsEqualGUID(riid, &IID_IDirect3DPixelShader8)) {
- IUnknown_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
-
- WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
- *ppobj = NULL;
- return E_NOINTERFACE;
-}
-
-static ULONG WINAPI IDirect3DPixelShader8Impl_AddRef(IDirect3DPixelShader8 *iface) {
- IDirect3DPixelShader8Impl *This = (IDirect3DPixelShader8Impl *)iface;
- ULONG ref = InterlockedIncrement(&This->ref);
-
- TRACE("%p increasing refcount to %u.\n", iface, ref);
-
- if (ref == 1)
- {
- wined3d_mutex_lock();
- IWineD3DPixelShader_AddRef(This->wineD3DPixelShader);
- wined3d_mutex_unlock();
- }
-
- return ref;
-}
-
-static ULONG WINAPI IDirect3DPixelShader8Impl_Release(IDirect3DPixelShader8 * iface) {
- IDirect3DPixelShader8Impl *This = (IDirect3DPixelShader8Impl *)iface;
- ULONG ref = InterlockedDecrement(&This->ref);
-
- TRACE("%p decreasing refcount to %u.\n", iface, ref);
-
- if (ref == 0) {
- wined3d_mutex_lock();
- IWineD3DPixelShader_Release(This->wineD3DPixelShader);
- wined3d_mutex_unlock();
- }
- return ref;
-}
-
-static const IDirect3DPixelShader8Vtbl Direct3DPixelShader8_Vtbl =
-{
- /* IUnknown */
- IDirect3DPixelShader8Impl_QueryInterface,
- IDirect3DPixelShader8Impl_AddRef,
- IDirect3DPixelShader8Impl_Release,
-};
-
-static void STDMETHODCALLTYPE d3d8_pixelshader_wined3d_object_destroyed(void *parent)
-{
- HeapFree(GetProcessHeap(), 0, parent);
-}
-
-static const struct wined3d_parent_ops d3d8_pixelshader_wined3d_parent_ops =
-{
- d3d8_pixelshader_wined3d_object_destroyed,
-};
-
-HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl *device,
- const DWORD *byte_code, DWORD shader_handle)
-{
- HRESULT hr;
-
- shader->ref = 1;
- shader->lpVtbl = &Direct3DPixelShader8_Vtbl;
- shader->handle = shader_handle;
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_CreatePixelShader(device->WineD3DDevice, byte_code,
- NULL, &shader->wineD3DPixelShader, (IUnknown *)shader,
- &d3d8_pixelshader_wined3d_parent_ops);
- wined3d_mutex_unlock();
- if (FAILED(hr))
- {
- WARN("Failed to create wined3d pixel shader, hr %#x.\n", hr);
- return hr;
- }
-
- return D3D_OK;
-}
--- /dev/null
+/*
+ * Copyright 2002-2003 Jason Edmeades
+ * Raphael Junqueira
+ *
+ * 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 "d3d8_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
+
+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);
+
+ if (IsEqualGUID(riid, &IID_IDirect3DVertexShader8)
+ || 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 WINAPI d3d8_vertexshader_AddRef(IDirect3DVertexShader8 *iface)
+{
+ IDirect3DVertexShader8Impl *shader = (IDirect3DVertexShader8Impl *)iface;
+ ULONG refcount = InterlockedIncrement(&shader->ref);
+
+ TRACE("%p increasing refcount to %u.\n", iface, refcount);
+
+ if (refcount == 1 && shader->wineD3DVertexShader)
+ {
+ wined3d_mutex_lock();
+ IWineD3DVertexShader_AddRef(shader->wineD3DVertexShader);
+ wined3d_mutex_unlock();
+ }
+
+ return refcount;
+}
+
+static void STDMETHODCALLTYPE d3d8_vertexshader_wined3d_object_destroyed(void *parent)
+{
+ IDirect3DVertexShader8Impl *shader = parent;
+ IDirect3DVertexDeclaration8_Release(shader->vertex_declaration);
+ HeapFree(GetProcessHeap(), 0, shader);
+}
+
+static ULONG WINAPI d3d8_vertexshader_Release(IDirect3DVertexShader8 *iface)
+{
+ IDirect3DVertexShader8Impl *shader = (IDirect3DVertexShader8Impl *)iface;
+ ULONG refcount = InterlockedDecrement(&shader->ref);
+
+ TRACE("%p decreasing refcount to %u.\n", iface, refcount);
+
+ if (!refcount)
+ {
+ if (shader->wineD3DVertexShader)
+ {
+ wined3d_mutex_lock();
+ IWineD3DVertexShader_Release(shader->wineD3DVertexShader);
+ wined3d_mutex_unlock();
+ }
+ else
+ {
+ d3d8_vertexshader_wined3d_object_destroyed(shader);
+ }
+ }
+
+ return refcount;
+}
+
+static const IDirect3DVertexShader8Vtbl d3d8_vertexshader_vtbl =
+{
+ /* IUnknown */
+ d3d8_vertexshader_QueryInterface,
+ d3d8_vertexshader_AddRef,
+ d3d8_vertexshader_Release,
+};
+
+static const struct wined3d_parent_ops d3d8_vertexshader_wined3d_parent_ops =
+{
+ d3d8_vertexshader_wined3d_object_destroyed,
+};
+
+static HRESULT d3d8_vertexshader_create_vertexdeclaration(IDirect3DDevice8Impl *device,
+ const DWORD *declaration, DWORD shader_handle, IDirect3DVertexDeclaration8 **decl_ptr)
+{
+ IDirect3DVertexDeclaration8Impl *object;
+ HRESULT hr;
+
+ TRACE("device %p, declaration %p, shader_handle %#x, decl_ptr %p.\n",
+ device, declaration, shader_handle, decl_ptr);
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (!object)
+ {
+ ERR("Memory allocation failed.\n");
+ return E_OUTOFMEMORY;
+ }
+
+ hr = vertexdeclaration_init(object, device, declaration, shader_handle);
+ 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);
+ *decl_ptr = (IDirect3DVertexDeclaration8 *)object;
+
+ return D3D_OK;
+}
+
+HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Impl *device,
+ const DWORD *declaration, const DWORD *byte_code, DWORD shader_handle, DWORD usage)
+{
+ const DWORD *token = declaration;
+ HRESULT hr;
+
+ /* Test if the vertex declaration is valid. */
+ while (D3DVSD_END() != *token)
+ {
+ D3DVSD_TOKENTYPE token_type = ((*token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT);
+
+ if (token_type == D3DVSD_TOKEN_STREAMDATA && !(token_type & 0x10000000))
+ {
+ DWORD type = ((*token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT);
+ DWORD reg = ((*token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT);
+
+ if (reg == D3DVSDE_NORMAL && type != D3DVSDT_FLOAT3 && !byte_code)
+ {
+ WARN("Attempt to use a non-FLOAT3 normal with the fixed function function\n");
+ return D3DERR_INVALIDCALL;
+ }
+ }
+ token += parse_token(token);
+ }
+
+ shader->ref = 1;
+ shader->lpVtbl = &d3d8_vertexshader_vtbl;
+
+ hr = d3d8_vertexshader_create_vertexdeclaration(device, declaration, shader_handle, &shader->vertex_declaration);
+ if (FAILED(hr))
+ {
+ WARN("Failed to create vertex declaration, hr %#x.\n", hr);
+ return hr;
+ }
+
+ if (byte_code)
+ {
+ 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);
+ wined3d_mutex_unlock();
+ if (FAILED(hr))
+ {
+ WARN("Failed to create wined3d vertex shader, hr %#x.\n", hr);
+ IDirect3DVertexDeclaration8_Release(shader->vertex_declaration);
+ return hr;
+ }
+
+ load_local_constants(declaration, shader->wineD3DVertexShader);
+ }
+
+ return D3D_OK;
+}
+
+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);
+
+ if (IsEqualGUID(riid, &IID_IDirect3DPixelShader8)
+ || 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 WINAPI d3d8_pixelshader_AddRef(IDirect3DPixelShader8 *iface)
+{
+ IDirect3DPixelShader8Impl *shader = (IDirect3DPixelShader8Impl *)iface;
+ ULONG refcount = InterlockedIncrement(&shader->ref);
+
+ TRACE("%p increasing refcount to %u.\n", iface, refcount);
+
+ if (refcount == 1)
+ {
+ wined3d_mutex_lock();
+ IWineD3DPixelShader_AddRef(shader->wineD3DPixelShader);
+ wined3d_mutex_unlock();
+ }
+
+ return refcount;
+}
+
+static ULONG WINAPI d3d8_pixelshader_Release(IDirect3DPixelShader8 *iface)
+{
+ IDirect3DPixelShader8Impl *shader = (IDirect3DPixelShader8Impl *)iface;
+ ULONG refcount = InterlockedDecrement(&shader->ref);
+
+ TRACE("%p decreasing refcount to %u.\n", iface, refcount);
+
+ if (!refcount)
+ {
+ wined3d_mutex_lock();
+ IWineD3DPixelShader_Release(shader->wineD3DPixelShader);
+ wined3d_mutex_unlock();
+ }
+
+ return refcount;
+}
+
+static const IDirect3DPixelShader8Vtbl d3d8_pixelshader_vtbl =
+{
+ /* IUnknown */
+ d3d8_pixelshader_QueryInterface,
+ d3d8_pixelshader_AddRef,
+ d3d8_pixelshader_Release,
+};
+
+static void STDMETHODCALLTYPE d3d8_pixelshader_wined3d_object_destroyed(void *parent)
+{
+ HeapFree(GetProcessHeap(), 0, parent);
+}
+
+static const struct wined3d_parent_ops d3d8_pixelshader_wined3d_parent_ops =
+{
+ d3d8_pixelshader_wined3d_object_destroyed,
+};
+
+HRESULT pixelshader_init(IDirect3DPixelShader8Impl *shader, IDirect3DDevice8Impl *device,
+ const DWORD *byte_code, DWORD shader_handle)
+{
+ HRESULT hr;
+
+ shader->ref = 1;
+ shader->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);
+ wined3d_mutex_unlock();
+ if (FAILED(hr))
+ {
+ WARN("Failed to create wined3d pixel shader, hr %#x.\n", hr);
+ return hr;
+ }
+
+ return D3D_OK;
+}
static HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(LPDIRECT3DSURFACE8 iface, D3DSURFACE_DESC *pDesc) {
IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
- HRESULT hr;
TRACE("iface %p, desc %p.\n", iface, pDesc);
wined3d_mutex_lock();
- hr = IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
+ IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
wined3d_mutex_unlock();
- if (SUCCEEDED(hr))
- {
- 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;
- }
+ 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;
- return hr;
+ return D3D_OK;
}
static HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKED_RECT *pLockedRect, CONST RECT *pRect, DWORD Flags) {
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateSurface(device->WineD3DDevice, width, height, wined3dformat_from_d3dformat(format),
- lockable, discard, level, &surface->wineD3DSurface, usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool,
- multisample_type, multisample_quality, SURFACE_OPENGL, (IUnknown *)surface,
- &d3d8_surface_wined3d_parent_ops);
+ lockable, discard, level, usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, multisample_type,
+ multisample_quality, SURFACE_OPENGL, surface, &d3d8_surface_wined3d_parent_ops, &surface->wineD3DSurface);
wined3d_mutex_unlock();
if (FAILED(hr))
{
return hr;
}
-static HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN8 iface, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8** ppBackBuffer) {
+static HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(IDirect3DSwapChain8 *iface,
+ UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8 **ppBackBuffer)
+{
IDirect3DSwapChain8Impl *This = (IDirect3DSwapChain8Impl *)iface;
- HRESULT hrc = D3D_OK;
IWineD3DSurface *mySurface = NULL;
+ HRESULT hr;
TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
iface, iBackBuffer, Type, ppBackBuffer);
wined3d_mutex_lock();
- hrc = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer, (WINED3DBACKBUFFER_TYPE )Type, &mySurface);
- if (hrc == D3D_OK && NULL != mySurface) {
- IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppBackBuffer);
- IWineD3DSurface_Release(mySurface);
+ hr = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer,
+ (WINED3DBACKBUFFER_TYPE)Type, &mySurface);
+ if (SUCCEEDED(hr) && mySurface)
+ {
+ *ppBackBuffer = IWineD3DSurface_GetParent(mySurface);
+ IDirect3DSurface8_AddRef(*ppBackBuffer);
+ IWineD3DSurface_Release(mySurface);
}
wined3d_mutex_unlock();
- return hrc;
+ return hr;
}
static const IDirect3DSwapChain8Vtbl Direct3DSwapChain8_Vtbl =
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateSwapChain(device->WineD3DDevice, &wined3d_parameters,
- &swapchain->wineD3DSwapChain, (IUnknown *)swapchain, SURFACE_OPENGL);
+ SURFACE_OPENGL, swapchain, &swapchain->wineD3DSwapChain);
wined3d_mutex_unlock();
present_parameters->BackBufferWidth = wined3d_parameters.BackBufferWidth;
return hr;
}
-static HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 iface, UINT Level, IDirect3DSurface8 **ppSurfaceLevel) {
+static HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(IDirect3DTexture8 *iface,
+ UINT Level, IDirect3DSurface8 **ppSurfaceLevel)
+{
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
- HRESULT hrc = D3D_OK;
IWineD3DSurface *mySurface = NULL;
+ HRESULT hr;
TRACE("iface %p, level %u, surface %p.\n", iface, Level, ppSurfaceLevel);
wined3d_mutex_lock();
- hrc = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
- if (hrc == D3D_OK && NULL != ppSurfaceLevel) {
- IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppSurfaceLevel);
+ hr = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
+ if (SUCCEEDED(hr) && ppSurfaceLevel)
+ {
+ *ppSurfaceLevel = IWineD3DSurface_GetParent(mySurface);
+ IDirect3DSurface8_AddRef(*ppSurfaceLevel);
IWineD3DSurface_Release(mySurface);
}
wined3d_mutex_unlock();
- return hrc;
+ return hr;
}
static HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface, UINT Level, D3DLOCKED_RECT *pLockedRect, CONST RECT *pRect, DWORD Flags) {
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateTexture(device->WineD3DDevice, width, height, levels,
usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool,
- &texture->wineD3DTexture, (IUnknown *)texture, &d3d8_texture_wined3d_parent_ops);
+ texture, &d3d8_texture_wined3d_parent_ops, &texture->wineD3DTexture);
wined3d_mutex_unlock();
if (FAILED(hr))
{
+++ /dev/null
-/*
- * IDirect3DVertexBuffer8 implementation
- *
- * Copyright 2005 Oliver Stieber
- *
- * 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 "d3d8_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
-
-/* IDirect3DVertexBuffer8 IUnknown parts follow: */
-static HRESULT WINAPI IDirect3DVertexBuffer8Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER8 iface, REFIID riid, LPVOID *ppobj) {
- IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
-
- TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
-
- if (IsEqualGUID(riid, &IID_IUnknown)
- || IsEqualGUID(riid, &IID_IDirect3DResource8)
- || IsEqualGUID(riid, &IID_IDirect3DVertexBuffer8)) {
- IUnknown_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
-
- WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
-
- *ppobj = NULL;
- return E_NOINTERFACE;
-}
-
-static ULONG WINAPI IDirect3DVertexBuffer8Impl_AddRef(LPDIRECT3DVERTEXBUFFER8 iface) {
- IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
- ULONG ref = InterlockedIncrement(&This->ref);
-
- TRACE("%p increasing refcount to %u.\n", iface, ref);
-
- if (ref == 1)
- {
- IDirect3DDevice8_AddRef(This->parentDevice);
- wined3d_mutex_lock();
- IWineD3DBuffer_AddRef(This->wineD3DVertexBuffer);
- wined3d_mutex_unlock();
- }
-
- return ref;
-}
-
-static ULONG WINAPI IDirect3DVertexBuffer8Impl_Release(LPDIRECT3DVERTEXBUFFER8 iface) {
- IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
- ULONG ref = InterlockedDecrement(&This->ref);
-
- TRACE("%p decreasing refcount to %u.\n", iface, ref);
-
- if (ref == 0) {
- IDirect3DDevice8 *parentDevice = This->parentDevice;
-
- wined3d_mutex_lock();
- IWineD3DBuffer_Release(This->wineD3DVertexBuffer);
- wined3d_mutex_unlock();
-
- /* Release the device last, as it may cause the device to be destroyed. */
- IDirect3DDevice8_Release(parentDevice);
- }
-
- return ref;
-}
-
-/* IDirect3DVertexBuffer8 IDirect3DResource8 Interface follow: */
-static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDevice(IDirect3DVertexBuffer8 *iface, IDirect3DDevice8 **device)
-{
- IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
-
- TRACE("iface %p, device %p.\n", iface, device);
-
- *device = (IDirect3DDevice8 *)This->parentDevice;
- IDirect3DDevice8_AddRef(*device);
-
- TRACE("Returning device %p.\n", *device);
-
- return D3D_OK;
-}
-
-static HRESULT WINAPI IDirect3DVertexBuffer8Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
- IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)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 = IWineD3DBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
- IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, guid %s, data %p, data_size %p.\n",
- iface, debugstr_guid(refguid), pData, pSizeOfData);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DVertexBuffer8Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid) {
- IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static DWORD WINAPI IDirect3DVertexBuffer8Impl_SetPriority(LPDIRECT3DVERTEXBUFFER8 iface, DWORD PriorityNew) {
- IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
- DWORD ret;
-
- TRACE("iface %p, priority %u.\n", iface, PriorityNew);
-
- wined3d_mutex_lock();
- ret = IWineD3DBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
- wined3d_mutex_unlock();
-
- return ret;
-}
-
-static DWORD WINAPI IDirect3DVertexBuffer8Impl_GetPriority(LPDIRECT3DVERTEXBUFFER8 iface) {
- IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
- DWORD ret;
-
- TRACE("iface %p.\n", iface);
-
- wined3d_mutex_lock();
- ret = IWineD3DBuffer_GetPriority(This->wineD3DVertexBuffer);
- wined3d_mutex_unlock();
-
- return ret;
-}
-
-static void WINAPI IDirect3DVertexBuffer8Impl_PreLoad(LPDIRECT3DVERTEXBUFFER8 iface) {
- IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
-
- TRACE("iface %p.\n", iface);
-
- wined3d_mutex_lock();
- IWineD3DBuffer_PreLoad(This->wineD3DVertexBuffer);
- wined3d_mutex_unlock();
-}
-
-static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer8Impl_GetType(IDirect3DVertexBuffer8 *iface)
-{
- TRACE("iface %p.\n", iface);
-
- return D3DRTYPE_VERTEXBUFFER;
-}
-
-/* IDirect3DVertexBuffer8 Interface follow: */
-static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Lock(LPDIRECT3DVERTEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE **ppbData, DWORD Flags) {
- IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n",
- iface, OffsetToLock, SizeToLock, ppbData, Flags);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_Map(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Unlock(LPDIRECT3DVERTEXBUFFER8 iface) {
- IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p.\n", iface);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_Unmap(This->wineD3DVertexBuffer);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8 iface, D3DVERTEXBUFFER_DESC *pDesc) {
- IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
- HRESULT hr;
- WINED3DBUFFER_DESC desc;
-
- TRACE("iface %p, desc %p.\n", iface, pDesc);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &desc);
- wined3d_mutex_unlock();
-
- if (SUCCEEDED(hr)) {
- pDesc->Type = D3DRTYPE_VERTEXBUFFER;
- pDesc->Usage = desc.Usage;
- pDesc->Pool = desc.Pool;
- pDesc->Size = desc.Size;
- pDesc->FVF = This->fvf;
- pDesc->Format = D3DFMT_VERTEXDATA;
- }
-
- return hr;
-}
-
-static const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl =
-{
- /* IUnknown */
- IDirect3DVertexBuffer8Impl_QueryInterface,
- IDirect3DVertexBuffer8Impl_AddRef,
- IDirect3DVertexBuffer8Impl_Release,
- /* IDirect3DResource8 */
- IDirect3DVertexBuffer8Impl_GetDevice,
- IDirect3DVertexBuffer8Impl_SetPrivateData,
- IDirect3DVertexBuffer8Impl_GetPrivateData,
- IDirect3DVertexBuffer8Impl_FreePrivateData,
- IDirect3DVertexBuffer8Impl_SetPriority,
- IDirect3DVertexBuffer8Impl_GetPriority,
- IDirect3DVertexBuffer8Impl_PreLoad,
- IDirect3DVertexBuffer8Impl_GetType,
- /* IDirect3DVertexBuffer8 */
- IDirect3DVertexBuffer8Impl_Lock,
- IDirect3DVertexBuffer8Impl_Unlock,
- IDirect3DVertexBuffer8Impl_GetDesc
-};
-
-static void STDMETHODCALLTYPE d3d8_vertexbuffer_wined3d_object_destroyed(void *parent)
-{
- HeapFree(GetProcessHeap(), 0, parent);
-}
-
-static const struct wined3d_parent_ops d3d8_vertexbuffer_wined3d_parent_ops =
-{
- d3d8_vertexbuffer_wined3d_object_destroyed,
-};
-
-HRESULT vertexbuffer_init(IDirect3DVertexBuffer8Impl *buffer, IDirect3DDevice8Impl *device,
- UINT size, DWORD usage, DWORD fvf, D3DPOOL pool)
-{
- HRESULT hr;
-
- buffer->lpVtbl = &Direct3DVertexBuffer8_Vtbl;
- buffer->ref = 1;
- buffer->fvf = fvf;
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_CreateVertexBuffer(device->WineD3DDevice, size,
- usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, &buffer->wineD3DVertexBuffer,
- (IUnknown *)buffer, &d3d8_vertexbuffer_wined3d_parent_ops);
- wined3d_mutex_unlock();
- if (FAILED(hr))
- {
- WARN("Failed to create wined3d buffer, hr %#x.\n", hr);
- return hr;
- }
-
- buffer->parentDevice = (IDirect3DDevice8 *)device;
- IUnknown_AddRef(buffer->parentDevice);
-
- return D3D_OK;
-}
/*WINED3DDECLTYPE_FLOAT16_4*/ 4 * sizeof(short int)
};
-static const WINED3DFORMAT wined3d_format_lookup[] =
+static const enum wined3d_format_id wined3d_format_lookup[] =
{
/*WINED3DDECLTYPE_FLOAT1*/ WINED3DFMT_R32_FLOAT,
/*WINED3DDECLTYPE_FLOAT2*/ WINED3DFMT_R32G32_FLOAT,
memcpy(declaration->elements, elements, declaration->elements_size);
wined3d_mutex_lock();
- hr = IWineD3DDevice_CreateVertexDeclaration(device->WineD3DDevice, &declaration->wined3d_vertex_declaration,
- (IUnknown *)declaration, &d3d8_vertexdeclaration_wined3d_parent_ops,
- wined3d_elements, wined3d_element_count);
+ hr = IWineD3DDevice_CreateVertexDeclaration(device->WineD3DDevice, wined3d_elements, wined3d_element_count,
+ declaration, &d3d8_vertexdeclaration_wined3d_parent_ops, &declaration->wined3d_vertex_declaration);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, wined3d_elements);
if (FAILED(hr))
declaration->elements_size = 0;
declaration->shader_handle = fvf;
- hr = IWineD3DDevice_CreateVertexDeclarationFromFVF(device->WineD3DDevice,
- &declaration->wined3d_vertex_declaration, (IUnknown *)declaration,
- &d3d8_vertexdeclaration_wined3d_parent_ops, fvf);
+ hr = IWineD3DDevice_CreateVertexDeclarationFromFVF(device->WineD3DDevice, fvf, declaration,
+ &d3d8_vertexdeclaration_wined3d_parent_ops, &declaration->wined3d_vertex_declaration);
if (FAILED(hr))
{
WARN("Failed to create wined3d vertex declaration, hr %#x.\n", hr);
+++ /dev/null
-/*
- * IDirect3DVertexShader8 implementation
- *
- * Copyright 2002-2003 Jason Edmeades
- * Raphael Junqueira
- *
- * 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 "d3d8_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
-
-/* IDirect3DVertexShader8 IUnknown parts follow: */
-static HRESULT WINAPI IDirect3DVertexShader8Impl_QueryInterface(IDirect3DVertexShader8 *iface, REFIID riid, LPVOID* ppobj) {
- IDirect3DVertexShader8Impl *This = (IDirect3DVertexShader8Impl *)iface;
-
- TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
-
- if (IsEqualGUID(riid, &IID_IUnknown)
- || IsEqualGUID(riid, &IID_IDirect3DVertexShader8)) {
- IUnknown_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
-
- WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
- *ppobj = NULL;
- return E_NOINTERFACE;
-}
-
-static ULONG WINAPI IDirect3DVertexShader8Impl_AddRef(IDirect3DVertexShader8 *iface) {
- IDirect3DVertexShader8Impl *This = (IDirect3DVertexShader8Impl *)iface;
- ULONG ref = InterlockedIncrement(&This->ref);
-
- TRACE("%p increasing refcount to %u.\n", iface, ref);
-
- if (ref == 1 && This->wineD3DVertexShader)
- {
- wined3d_mutex_lock();
- IWineD3DVertexShader_AddRef(This->wineD3DVertexShader);
- wined3d_mutex_unlock();
- }
-
- return ref;
-}
-
-static void STDMETHODCALLTYPE d3d8_vertexshader_wined3d_object_destroyed(void *parent)
-{
- IDirect3DVertexShader8Impl *shader = parent;
- IDirect3DVertexDeclaration8_Release(shader->vertex_declaration);
- HeapFree(GetProcessHeap(), 0, shader);
-}
-
-static ULONG WINAPI IDirect3DVertexShader8Impl_Release(IDirect3DVertexShader8 *iface) {
- IDirect3DVertexShader8Impl *This = (IDirect3DVertexShader8Impl *)iface;
- ULONG ref = InterlockedDecrement(&This->ref);
-
- TRACE("%p decreasing refcount to %u.\n", iface, ref);
-
- if (ref == 0) {
- if (This->wineD3DVertexShader)
- {
- wined3d_mutex_lock();
- IWineD3DVertexShader_Release(This->wineD3DVertexShader);
- wined3d_mutex_unlock();
- }
- else
- {
- d3d8_vertexshader_wined3d_object_destroyed(This);
- }
- }
- return ref;
-}
-
-static const IDirect3DVertexShader8Vtbl Direct3DVertexShader8_Vtbl =
-{
- /* IUnknown */
- IDirect3DVertexShader8Impl_QueryInterface,
- IDirect3DVertexShader8Impl_AddRef,
- IDirect3DVertexShader8Impl_Release,
-};
-
-static const struct wined3d_parent_ops d3d8_vertexshader_wined3d_parent_ops =
-{
- d3d8_vertexshader_wined3d_object_destroyed,
-};
-
-static HRESULT vertexshader_create_vertexdeclaration(IDirect3DDevice8Impl *device,
- const DWORD *declaration, DWORD shader_handle, IDirect3DVertexDeclaration8 **decl_ptr)
-{
- IDirect3DVertexDeclaration8Impl *object;
- HRESULT hr;
-
- TRACE("device %p, declaration %p, shader_handle %#x, decl_ptr %p.\n",
- device, declaration, shader_handle, decl_ptr);
-
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
- if (!object) {
- ERR("Memory allocation failed\n");
- *decl_ptr = NULL;
- return D3DERR_OUTOFVIDEOMEMORY;
- }
-
- hr = vertexdeclaration_init(object, device, declaration, shader_handle);
- 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);
- *decl_ptr = (IDirect3DVertexDeclaration8 *)object;
-
- return D3D_OK;
-}
-
-HRESULT vertexshader_init(IDirect3DVertexShader8Impl *shader, IDirect3DDevice8Impl *device,
- const DWORD *declaration, const DWORD *byte_code, DWORD shader_handle, DWORD usage)
-{
- const DWORD *token = declaration;
- HRESULT hr;
-
- /* Test if the vertex declaration is valid */
- while (D3DVSD_END() != *token)
- {
- D3DVSD_TOKENTYPE token_type = ((*token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT);
-
- if (token_type == D3DVSD_TOKEN_STREAMDATA && !(token_type & 0x10000000))
- {
- DWORD type = ((*token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT);
- DWORD reg = ((*token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT);
-
- if (reg == D3DVSDE_NORMAL && type != D3DVSDT_FLOAT3 && !byte_code)
- {
- WARN("Attempt to use a non-FLOAT3 normal with the fixed function function\n");
- return D3DERR_INVALIDCALL;
- }
- }
- token += parse_token(token);
- }
-
- shader->ref = 1;
- shader->lpVtbl = &Direct3DVertexShader8_Vtbl;
-
- hr = vertexshader_create_vertexdeclaration(device, declaration, shader_handle, &shader->vertex_declaration);
- if (FAILED(hr))
- {
- WARN("Failed to create vertex declaration, hr %#x.\n", hr);
- return hr;
- }
-
- if (byte_code)
- {
- if (usage) FIXME("Usage %#x not implemented.\n", usage);
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_CreateVertexShader(device->WineD3DDevice, byte_code,
- NULL /* output signature */, &shader->wineD3DVertexShader,
- (IUnknown *)shader, &d3d8_vertexshader_wined3d_parent_ops);
- wined3d_mutex_unlock();
- if (FAILED(hr))
- {
- WARN("Failed to create wined3d vertex shader, hr %#x.\n", hr);
- IDirect3DVertexDeclaration8_Release(shader->vertex_declaration);
- return hr;
- }
-
- load_local_constants(declaration, shader->wineD3DVertexShader);
- }
-
- return D3D_OK;
-}
static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC *pDesc) {
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
- HRESULT hr;
- WINED3DVOLUME_DESC wined3ddesc;
+ WINED3DVOLUME_DESC wined3ddesc;
TRACE("iface %p, desc %p.\n", iface, pDesc);
wined3d_mutex_lock();
- hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
+ IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
wined3d_mutex_unlock();
- if (SUCCEEDED(hr))
- {
- 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;
- }
+ 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;
- return hr;
+ return D3D_OK;
}
static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
};
HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device, UINT width, UINT height,
- UINT depth, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool)
+ UINT depth, DWORD usage, enum wined3d_format_id format, WINED3DPOOL pool)
{
HRESULT hr;
volume->ref = 1;
hr = IWineD3DDevice_CreateVolume(device->WineD3DDevice, width, height, depth, usage,
- format, pool, &volume->wineD3DVolume, (IUnknown *)volume, &d3d8_volume_wined3d_parent_ops);
+ format, pool, volume, &d3d8_volume_wined3d_parent_ops, &volume->wineD3DVolume);
if (FAILED(hr))
{
WARN("Failed to create wined3d volume, hr %#x.\n", hr);
return hr;
}
-static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, IDirect3DVolume8 **ppVolumeLevel) {
+static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(IDirect3DVolumeTexture8 *iface,
+ UINT Level, IDirect3DVolume8 **ppVolumeLevel)
+{
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
- HRESULT hrc = D3D_OK;
IWineD3DVolume *myVolume = NULL;
+ HRESULT hr;
TRACE("iface %p, level %u, volume %p.\n", iface, Level, ppVolumeLevel);
wined3d_mutex_lock();
- hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
- if (hrc == D3D_OK && NULL != ppVolumeLevel) {
- IWineD3DVolumeTexture_GetParent(myVolume, (IUnknown **)ppVolumeLevel);
- IWineD3DVolumeTexture_Release(myVolume);
+ hr = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
+ if (SUCCEEDED(hr) && ppVolumeLevel)
+ {
+ *ppVolumeLevel = IWineD3DVolumeTexture_GetParent(myVolume);
+ IDirect3DVolume8_AddRef(*ppVolumeLevel);
+ IWineD3DVolumeTexture_Release(myVolume);
}
wined3d_mutex_unlock();
- return hrc;
+ return hr;
}
static HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateVolumeTexture(device->WineD3DDevice, width, height, depth, levels,
- usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool,
- &texture->wineD3DVolumeTexture, (IUnknown *)texture, &d3d8_volumetexture_wined3d_parent_ops);
+ usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool, texture,
+ &d3d8_volumetexture_wined3d_parent_ops, &texture->wineD3DVolumeTexture);
wined3d_mutex_unlock();
if (FAILED(hr))
{
--- /dev/null
+/*
+ * Copyright 2002-2004 Jason Edmeades
+ * Copyright 2002-2004 Raphael Junqueira
+ * Copyright 2005 Oliver Stieber
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+static HRESULT WINAPI d3d9_vertexbuffer_QueryInterface(IDirect3DVertexBuffer9 *iface, REFIID riid, void **object)
+{
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+
+ if (IsEqualGUID(riid, &IID_IDirect3DVertexBuffer9)
+ || IsEqualGUID(riid, &IID_IDirect3DResource9)
+ || IsEqualGUID(riid, &IID_IUnknown))
+ {
+ IDirect3DVertexBuffer9_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 d3d9_vertexbuffer_AddRef(IDirect3DVertexBuffer9 *iface)
+{
+ IDirect3DVertexBuffer9Impl *buffer = (IDirect3DVertexBuffer9Impl *)iface;
+ ULONG refcount = InterlockedIncrement(&buffer->ref);
+
+ TRACE("%p increasing refcount to %u.\n", iface, refcount);
+
+ if (refcount == 1)
+ {
+ IDirect3DDevice9Ex_AddRef(buffer->parentDevice);
+ wined3d_mutex_lock();
+ IWineD3DBuffer_AddRef(buffer->wineD3DVertexBuffer);
+ wined3d_mutex_unlock();
+ }
+
+ return refcount;
+}
+
+static ULONG WINAPI d3d9_vertexbuffer_Release(IDirect3DVertexBuffer9 *iface)
+{
+ IDirect3DVertexBuffer9Impl *buffer = (IDirect3DVertexBuffer9Impl *)iface;
+ ULONG refcount = InterlockedDecrement(&buffer->ref);
+
+ TRACE("%p decreasing refcount to %u.\n", iface, refcount);
+
+ if (!refcount)
+ {
+ IDirect3DDevice9Ex *device = buffer->parentDevice;
+
+ wined3d_mutex_lock();
+ IWineD3DBuffer_Release(buffer->wineD3DVertexBuffer);
+ wined3d_mutex_unlock();
+
+ /* Release the device last, as it may cause the device to be destroyed. */
+ IDirect3DDevice9Ex_Release(device);
+ }
+
+ return refcount;
+}
+
+static HRESULT WINAPI d3d9_vertexbuffer_GetDevice(IDirect3DVertexBuffer9 *iface, IDirect3DDevice9 **device)
+{
+ TRACE("iface %p, device %p.\n", iface, device);
+
+ *device = (IDirect3DDevice9 *)((IDirect3DVertexBuffer9Impl *)iface)->parentDevice;
+ IDirect3DDevice9_AddRef(*device);
+
+ TRACE("Returning device %p.\n", *device);
+
+ return D3D_OK;
+}
+
+static HRESULT WINAPI d3d9_vertexbuffer_SetPrivateData(IDirect3DVertexBuffer9 *iface,
+ REFGUID guid, const void *data, DWORD data_size, DWORD flags)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
+ iface, debugstr_guid(guid), data, data_size, flags);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DBuffer_SetPrivateData(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer,
+ guid, data, data_size, flags);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI d3d9_vertexbuffer_GetPrivateData(IDirect3DVertexBuffer9 *iface,
+ REFGUID guid, void *data, DWORD *data_size)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, guid %s, data %p, data_size %p.\n",
+ iface, debugstr_guid(guid), data, data_size);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DBuffer_GetPrivateData(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer,
+ guid, data, data_size);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI d3d9_vertexbuffer_FreePrivateData(IDirect3DVertexBuffer9 *iface, REFGUID guid)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
+
+ wined3d_mutex_lock();
+ hr = IWineD3DBuffer_FreePrivateData(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer, guid);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static DWORD WINAPI d3d9_vertexbuffer_SetPriority(IDirect3DVertexBuffer9 *iface, DWORD priority)
+{
+ DWORD previous;
+
+ TRACE("iface %p, priority %u.\n", iface, priority);
+
+ wined3d_mutex_lock();
+ previous = IWineD3DBuffer_SetPriority(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer, priority);
+ wined3d_mutex_unlock();
+
+ return previous;
+}
+
+static DWORD WINAPI d3d9_vertexbuffer_GetPriority(IDirect3DVertexBuffer9 *iface)
+{
+ DWORD priority;
+
+ TRACE("iface %p.\n", iface);
+
+ wined3d_mutex_lock();
+ priority = IWineD3DBuffer_GetPriority(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer);
+ wined3d_mutex_unlock();
+
+ return priority;
+}
+
+static void WINAPI d3d9_vertexbuffer_PreLoad(IDirect3DVertexBuffer9 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ wined3d_mutex_lock();
+ IWineD3DBuffer_PreLoad(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer);
+ wined3d_mutex_unlock();
+}
+
+static D3DRESOURCETYPE WINAPI d3d9_vertexbuffer_GetType(IDirect3DVertexBuffer9 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return D3DRTYPE_VERTEXBUFFER;
+}
+
+static HRESULT WINAPI d3d9_vertexbuffer_Lock(IDirect3DVertexBuffer9 *iface,
+ UINT offset, UINT size, void **data, DWORD flags)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n",
+ iface, offset, size, data, flags);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DBuffer_Map(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer,
+ offset, size, (BYTE **)data, flags);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+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_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI d3d9_vertexbuffer_GetDesc(IDirect3DVertexBuffer9 *iface, D3DVERTEXBUFFER_DESC *desc)
+{
+ IDirect3DVertexBuffer9Impl *buffer = (IDirect3DVertexBuffer9Impl *)iface;
+ WINED3DBUFFER_DESC wined3d_desc;
+
+ TRACE("iface %p, desc %p.\n", iface, desc);
+
+ wined3d_mutex_lock();
+ IWineD3DBuffer_GetDesc(buffer->wineD3DVertexBuffer, &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->Type = D3DRTYPE_VERTEXBUFFER;
+ desc->FVF = buffer->fvf;
+
+ return D3D_OK;
+}
+
+static const IDirect3DVertexBuffer9Vtbl d3d9_vertexbuffer_vtbl =
+{
+ /* IUnknown */
+ d3d9_vertexbuffer_QueryInterface,
+ d3d9_vertexbuffer_AddRef,
+ d3d9_vertexbuffer_Release,
+ /* IDirect3DResource9 */
+ d3d9_vertexbuffer_GetDevice,
+ d3d9_vertexbuffer_SetPrivateData,
+ d3d9_vertexbuffer_GetPrivateData,
+ d3d9_vertexbuffer_FreePrivateData,
+ d3d9_vertexbuffer_SetPriority,
+ d3d9_vertexbuffer_GetPriority,
+ d3d9_vertexbuffer_PreLoad,
+ d3d9_vertexbuffer_GetType,
+ /* IDirect3DVertexBuffer9 */
+ d3d9_vertexbuffer_Lock,
+ d3d9_vertexbuffer_Unlock,
+ d3d9_vertexbuffer_GetDesc,
+};
+
+static void STDMETHODCALLTYPE d3d9_vertexbuffer_wined3d_object_destroyed(void *parent)
+{
+ HeapFree(GetProcessHeap(), 0, parent);
+}
+
+static const struct wined3d_parent_ops d3d9_vertexbuffer_wined3d_parent_ops =
+{
+ d3d9_vertexbuffer_wined3d_object_destroyed,
+};
+
+HRESULT vertexbuffer_init(IDirect3DVertexBuffer9Impl *buffer, IDirect3DDevice9Impl *device,
+ UINT size, UINT usage, DWORD fvf, D3DPOOL pool)
+{
+ HRESULT hr;
+
+ buffer->lpVtbl = &d3d9_vertexbuffer_vtbl;
+ buffer->ref = 1;
+ buffer->fvf = fvf;
+
+ wined3d_mutex_lock();
+ hr = IWineD3DDevice_CreateVertexBuffer(device->WineD3DDevice, size, usage & WINED3DUSAGE_MASK,
+ (WINED3DPOOL)pool, buffer, &d3d9_vertexbuffer_wined3d_parent_ops, &buffer->wineD3DVertexBuffer);
+ wined3d_mutex_unlock();
+ if (FAILED(hr))
+ {
+ WARN("Failed to create wined3d buffer, hr %#x.\n", hr);
+ return hr;
+ }
+
+ buffer->parentDevice = (IDirect3DDevice9Ex *)device;
+ IDirect3DDevice9Ex_AddRef(buffer->parentDevice);
+
+ return D3D_OK;
+}
+
+static HRESULT WINAPI d3d9_indexbuffer_QueryInterface(IDirect3DIndexBuffer9 *iface, REFIID riid, void **object)
+{
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+
+ if (IsEqualGUID(riid, &IID_IDirect3DIndexBuffer9)
+ || IsEqualGUID(riid, &IID_IDirect3DResource9)
+ || IsEqualGUID(riid, &IID_IUnknown))
+ {
+ IDirect3DIndexBuffer9_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 d3d9_indexbuffer_AddRef(IDirect3DIndexBuffer9 *iface)
+{
+ IDirect3DIndexBuffer9Impl *buffer = (IDirect3DIndexBuffer9Impl *)iface;
+ ULONG refcount = InterlockedIncrement(&buffer->ref);
+
+ TRACE("%p increasing refcount to %u.\n", iface, refcount);
+
+ if (refcount == 1)
+ {
+ IDirect3DDevice9Ex_AddRef(buffer->parentDevice);
+ wined3d_mutex_lock();
+ IWineD3DBuffer_AddRef(buffer->wineD3DIndexBuffer);
+ wined3d_mutex_unlock();
+ }
+
+ return refcount;
+}
+
+static ULONG WINAPI d3d9_indexbuffer_Release(IDirect3DIndexBuffer9 *iface)
+{
+ IDirect3DIndexBuffer9Impl *buffer = (IDirect3DIndexBuffer9Impl *)iface;
+ ULONG refcount = InterlockedDecrement(&buffer->ref);
+
+ TRACE("%p decreasing refcount to %u.\n", iface, refcount);
+
+ if (!refcount)
+ {
+ IDirect3DDevice9Ex *device = buffer->parentDevice;
+
+ wined3d_mutex_lock();
+ IWineD3DBuffer_Release(buffer->wineD3DIndexBuffer);
+ wined3d_mutex_unlock();
+
+ /* Release the device last, as it may cause the device to be destroyed. */
+ IDirect3DDevice9Ex_Release(device);
+ }
+
+ return refcount;
+}
+
+static HRESULT WINAPI d3d9_indexbuffer_GetDevice(IDirect3DIndexBuffer9 *iface, IDirect3DDevice9 **device)
+{
+ TRACE("iface %p, device %p.\n", iface, device);
+
+ *device = (IDirect3DDevice9 *)((IDirect3DIndexBuffer9Impl *)iface)->parentDevice;
+ IDirect3DDevice9_AddRef(*device);
+
+ TRACE("Returning device %p.\n", *device);
+
+ return D3D_OK;
+}
+
+static HRESULT WINAPI d3d9_indexbuffer_SetPrivateData(IDirect3DIndexBuffer9 *iface,
+ REFGUID guid, const void *data, DWORD data_size, DWORD flags)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
+ iface, debugstr_guid(guid), data, data_size, flags);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DBuffer_SetPrivateData(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer,
+ guid, data, data_size, flags);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI d3d9_indexbuffer_GetPrivateData(IDirect3DIndexBuffer9 *iface,
+ REFGUID guid, void *data, DWORD *data_size)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, guid %s, data %p, data_size %p.\n",
+ iface, debugstr_guid(guid), data, data_size);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DBuffer_GetPrivateData(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer,
+ guid, data, data_size);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI d3d9_indexbuffer_FreePrivateData(IDirect3DIndexBuffer9 *iface, REFGUID guid)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
+
+ wined3d_mutex_lock();
+ hr = IWineD3DBuffer_FreePrivateData(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer, guid);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static DWORD WINAPI d3d9_indexbuffer_SetPriority(IDirect3DIndexBuffer9 *iface, DWORD priority)
+{
+ DWORD previous;
+
+ TRACE("iface %p, priority %u.\n", iface, priority);
+
+ wined3d_mutex_lock();
+ previous = IWineD3DBuffer_SetPriority(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer, priority);
+ wined3d_mutex_unlock();
+
+ return previous;
+}
+
+static DWORD WINAPI d3d9_indexbuffer_GetPriority(IDirect3DIndexBuffer9 *iface)
+{
+ DWORD priority;
+
+ TRACE("iface %p.\n", iface);
+
+ wined3d_mutex_lock();
+ priority = IWineD3DBuffer_GetPriority(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer);
+ wined3d_mutex_unlock();
+
+ return priority;
+}
+
+static void WINAPI d3d9_indexbuffer_PreLoad(IDirect3DIndexBuffer9 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ wined3d_mutex_lock();
+ IWineD3DBuffer_PreLoad(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer);
+ wined3d_mutex_unlock();
+}
+
+static D3DRESOURCETYPE WINAPI d3d9_indexbuffer_GetType(IDirect3DIndexBuffer9 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return D3DRTYPE_INDEXBUFFER;
+}
+
+static HRESULT WINAPI d3d9_indexbuffer_Lock(IDirect3DIndexBuffer9 *iface,
+ UINT offset, UINT size, void **data, DWORD flags)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n",
+ iface, offset, size, data, flags);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DBuffer_Map(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer,
+ offset, size, (BYTE **)data, flags);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+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_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI d3d9_indexbuffer_GetDesc(IDirect3DIndexBuffer9 *iface, D3DINDEXBUFFER_DESC *desc)
+{
+ IDirect3DIndexBuffer9Impl *buffer = (IDirect3DIndexBuffer9Impl *)iface;
+ WINED3DBUFFER_DESC wined3d_desc;
+
+ TRACE("iface %p, desc %p.\n", iface, desc);
+
+ wined3d_mutex_lock();
+ IWineD3DBuffer_GetDesc(buffer->wineD3DIndexBuffer, &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->Type = D3DRTYPE_INDEXBUFFER;
+
+ return D3D_OK;
+}
+
+static const IDirect3DIndexBuffer9Vtbl d3d9_indexbuffer_vtbl =
+{
+ /* IUnknown */
+ d3d9_indexbuffer_QueryInterface,
+ d3d9_indexbuffer_AddRef,
+ d3d9_indexbuffer_Release,
+ /* IDirect3DResource9 */
+ d3d9_indexbuffer_GetDevice,
+ d3d9_indexbuffer_SetPrivateData,
+ d3d9_indexbuffer_GetPrivateData,
+ d3d9_indexbuffer_FreePrivateData,
+ d3d9_indexbuffer_SetPriority,
+ d3d9_indexbuffer_GetPriority,
+ d3d9_indexbuffer_PreLoad,
+ d3d9_indexbuffer_GetType,
+ /* IDirect3DIndexBuffer9 */
+ d3d9_indexbuffer_Lock,
+ d3d9_indexbuffer_Unlock,
+ d3d9_indexbuffer_GetDesc,
+};
+
+static void STDMETHODCALLTYPE d3d9_indexbuffer_wined3d_object_destroyed(void *parent)
+{
+ HeapFree(GetProcessHeap(), 0, parent);
+}
+
+static const struct wined3d_parent_ops d3d9_indexbuffer_wined3d_parent_ops =
+{
+ d3d9_indexbuffer_wined3d_object_destroyed,
+};
+
+HRESULT indexbuffer_init(IDirect3DIndexBuffer9Impl *buffer, IDirect3DDevice9Impl *device,
+ UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool)
+{
+ HRESULT hr;
+
+ buffer->lpVtbl = &d3d9_indexbuffer_vtbl;
+ buffer->ref = 1;
+ buffer->format = wined3dformat_from_d3dformat(format);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DDevice_CreateIndexBuffer(device->WineD3DDevice, size, usage & WINED3DUSAGE_MASK,
+ (WINED3DPOOL)pool, buffer, &d3d9_indexbuffer_wined3d_parent_ops, &buffer->wineD3DIndexBuffer);
+ wined3d_mutex_unlock();
+ if (FAILED(hr))
+ {
+ WARN("Failed to create wined3d buffer, hr %#x.\n", hr);
+ return hr;
+ }
+
+ buffer->parentDevice = (IDirect3DDevice9Ex *)device;
+ IDirect3DDevice9Ex_AddRef(buffer->parentDevice);
+
+ return D3D_OK;
+}
return hr;
}
-static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9** ppCubeMapSurface) {
+static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetCubeMapSurface(IDirect3DCubeTexture9 *iface,
+ D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9 **ppCubeMapSurface)
+{
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
- HRESULT hrc = D3D_OK;
IWineD3DSurface *mySurface = NULL;
+ HRESULT hr;
TRACE("iface %p, face %#x, level %u, surface %p.\n", iface, FaceType, Level, ppCubeMapSurface);
wined3d_mutex_lock();
- hrc = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, &mySurface);
- if (hrc == D3D_OK && NULL != ppCubeMapSurface) {
- IWineD3DCubeTexture_GetParent(mySurface, (IUnknown **)ppCubeMapSurface);
- IWineD3DCubeTexture_Release(mySurface);
+ hr = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture,
+ (WINED3DCUBEMAP_FACES)FaceType, Level, &mySurface);
+ if (SUCCEEDED(hr) && ppCubeMapSurface)
+ {
+ *ppCubeMapSurface = IWineD3DCubeTexture_GetParent(mySurface);
+ IDirect3DSurface9_AddRef(*ppCubeMapSurface);
+ IWineD3DCubeTexture_Release(mySurface);
}
wined3d_mutex_unlock();
- return hrc;
+ return hr;
}
static HRESULT WINAPI IDirect3DCubeTexture9Impl_LockRect(LPDIRECT3DCUBETEXTURE9 iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
texture->ref = 1;
wined3d_mutex_lock();
- hr = IWineD3DDevice_CreateCubeTexture(device->WineD3DDevice, edge_length, levels, usage,
- wined3dformat_from_d3dformat(format), pool, &texture->wineD3DCubeTexture,
- (IUnknown *)texture, &d3d9_cubetexture_wined3d_parent_ops);
+ hr = IWineD3DDevice_CreateCubeTexture(device->WineD3DDevice, edge_length,
+ levels, usage, wined3dformat_from_d3dformat(format), pool, texture,
+ &d3d9_cubetexture_wined3d_parent_ops, &texture->wineD3DCubeTexture);
wined3d_mutex_unlock();
if (FAILED(hr))
{
<library>advapi32</library>
<library>wined3d</library>
+ <file>buffer.c</file>
<file>cubetexture.c</file>
<file>d3d9_main.c</file>
<file>device.c</file>
<file>directx.c</file>
- <file>indexbuffer.c</file>
- <file>pixelshader.c</file>
<file>query.c</file>
+ <file>shader.c</file>
<file>stateblock.c</file>
<file>surface.c</file>
<file>swapchain.c</file>
<file>texture.c</file>
- <file>vertexbuffer.c</file>
<file>vertexdeclaration.c</file>
- <file>vertexshader.c</file>
<file>volume.c</file>
<file>volumetexture.c</file>
<file>version.rc</file>
Internal use
=========================================================================== */
extern HRESULT vdecl_convert_fvf(DWORD FVF, D3DVERTEXELEMENT9 **ppVertexElements) DECLSPEC_HIDDEN;
-D3DFORMAT d3dformat_from_wined3dformat(WINED3DFORMAT format) DECLSPEC_HIDDEN;
-WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN;
+D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN;
+enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN;
/* ===========================================================================
Macros
HRESULT device_init(IDirect3DDevice9Impl *device, IWineD3D *wined3d, UINT adapter, D3DDEVTYPE device_type,
HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters) DECLSPEC_HIDDEN;
-/* IDirect3DDevice9: */
-extern HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(IDirect3DDevice9Ex *iface,
- UINT iSwapChain, IDirect3DSwapChain9 **pSwapChain) DECLSPEC_HIDDEN;
-extern UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(IDirect3DDevice9Ex *iface) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(IDirect3DDevice9Ex *iface,
- IDirect3DVertexDeclaration9 *pDecl) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(IDirect3DDevice9Ex *iface,
- IDirect3DVertexDeclaration9 **ppDecl) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(IDirect3DDevice9Ex *iface,
- IDirect3DVertexShader9 *pShader) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(IDirect3DDevice9Ex *iface,
- IDirect3DVertexShader9 **ppShader) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(IDirect3DDevice9Ex *iface,
- UINT StartRegister, const float *pConstantData, UINT Vector4fCount) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(IDirect3DDevice9Ex *iface,
- UINT StartRegister, float *pConstantData, UINT Vector4fCount) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(IDirect3DDevice9Ex *iface,
- UINT StartRegister, const int *pConstantData, UINT Vector4iCount) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(IDirect3DDevice9Ex *iface,
- UINT StartRegister, int *pConstantData, UINT Vector4iCount) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(IDirect3DDevice9Ex *iface,
- UINT StartRegister, const BOOL *pConstantData, UINT BoolCount) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(IDirect3DDevice9Ex *iface,
- UINT StartRegister, BOOL *pConstantData, UINT BoolCount) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(IDirect3DDevice9Ex *iface,
- IDirect3DPixelShader9 *pShader) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(IDirect3DDevice9Ex *iface,
- IDirect3DPixelShader9 **ppShader) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(IDirect3DDevice9Ex *iface,
- UINT StartRegister, const float *pConstantData, UINT Vector4fCount) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(IDirect3DDevice9Ex *iface,
- UINT StartRegister, float *pConstantData, UINT Vector4fCount) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(IDirect3DDevice9Ex *iface,
- UINT StartRegister, const int *pConstantData, UINT Vector4iCount) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(IDirect3DDevice9Ex *iface,
- UINT StartRegister, int *pConstantData, UINT Vector4iCount) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(IDirect3DDevice9Ex *iface,
- UINT StartRegister, const BOOL *pConstantData, UINT BoolCount) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(IDirect3DDevice9Ex *iface,
- UINT StartRegister, BOOL *pConstantData, UINT BoolCount) DECLSPEC_HIDDEN;
-
-/* ---------------- */
-/* IDirect3DVolume9 */
-/* ---------------- */
-
/*****************************************************************************
* IDirect3DVolume9 implementation structure
*/
} IDirect3DVolume9Impl;
HRESULT volume_init(IDirect3DVolume9Impl *volume, IDirect3DDevice9Impl *device, UINT width, UINT height,
- UINT depth, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool) DECLSPEC_HIDDEN;
+ UINT depth, DWORD usage, enum wined3d_format_id format, WINED3DPOOL pool) DECLSPEC_HIDDEN;
/* ------------------- */
/* IDirect3DSwapChain9 */
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;
- WINED3DFORMAT format;
+ enum wined3d_format_id format;
} IDirect3DIndexBuffer9Impl;
HRESULT indexbuffer_init(IDirect3DIndexBuffer9Impl *buffer, IDirect3DDevice9Impl *device,
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
-D3DFORMAT d3dformat_from_wined3dformat(WINED3DFORMAT format)
+D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format)
{
BYTE *c = (BYTE *)&format;
case WINED3DFMT_R32G32B32A32_FLOAT: return D3DFMT_A32B32G32R32F;
case WINED3DFMT_R8G8_SNORM_Cx: return D3DFMT_CxV8U8;
default:
- FIXME("Unhandled WINED3DFORMAT %#x\n", format);
+ FIXME("Unhandled wined3d format %#x.\n", format);
return D3DFMT_UNKNOWN;
}
}
-WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format)
+enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format)
{
BYTE *c = (BYTE *)&format;
TRACE("swapchain %p.\n", swapchain);
- IWineD3DSwapChain_GetParent(swapchain, (IUnknown **)&parent);
+ parent = IWineD3DSwapChain_GetParent(swapchain);
parent->isImplicit = FALSE;
+ IDirect3DSwapChain9_AddRef((IDirect3DSwapChain9 *)parent);
return IDirect3DSwapChain9_Release((IDirect3DSwapChain9 *)parent);
}
hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &pWineD3D);
if (hr == D3D_OK && pWineD3D != NULL)
{
- IWineD3D_GetParent(pWineD3D,(IUnknown **)ppD3D9);
+ *ppD3D9 = IWineD3D_GetParent(pWineD3D);
+ IDirect3D9_AddRef(*ppD3D9);
IWineD3D_Release(pWineD3D);
} else {
FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
return D3D_OK;
}
+static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_GetSwapChain(IDirect3DDevice9Ex *iface,
+ UINT swapchain_idx, IDirect3DSwapChain9 **swapchain)
+{
+ IWineD3DSwapChain *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)
+ {
+ *swapchain = IWineD3DSwapChain_GetParent(wined3d_swapchain);
+ IDirect3DSwapChain9_AddRef(*swapchain);
+ IWineD3DSwapChain_Release(wined3d_swapchain);
+ }
+ else
+ {
+ *swapchain = NULL;
+ }
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(IDirect3DDevice9Ex *iface)
+{
+ UINT count;
+
+ TRACE("iface %p.\n", iface);
+
+ wined3d_mutex_lock();
+ count = IWineD3DDevice_GetNumberOfSwapChains(((IDirect3DDevice9Impl *)iface)->WineD3DDevice);
+ wined3d_mutex_unlock();
+
+ return count;
+}
+
static HRESULT WINAPI reset_enum_callback(IWineD3DResource *resource, void *data) {
BOOL *resources_ok = data;
D3DRESOURCETYPE type;
WINED3DPOOL pool;
IDirect3DResource9 *parent;
- IWineD3DResource_GetParent(resource, (IUnknown **) &parent);
+ parent = IWineD3DResource_GetParent(resource);
type = IDirect3DResource9_GetType(parent);
switch(type) {
case D3DRTYPE_SURFACE:
break;
}
- if(pool == WINED3DPOOL_DEFAULT) {
- if(IUnknown_Release(parent) == 0) {
+ if (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;
}
- } else {
- IUnknown_Release(parent);
}
IWineD3DResource_Release(resource);
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetBackBuffer(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 ** ppBackBuffer) {
+static HRESULT WINAPI IDirect3DDevice9Impl_GetBackBuffer(IDirect3DDevice9Ex *iface,
+ UINT iSwapChain, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 **ppBackBuffer)
+{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IWineD3DSurface *retSurface = NULL;
- HRESULT rc = D3D_OK;
+ HRESULT hr;
TRACE("iface %p, swapchain %u, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
iface, iSwapChain, BackBuffer, Type, ppBackBuffer);
wined3d_mutex_lock();
- rc = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, iSwapChain, BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &retSurface);
- if (rc == D3D_OK && NULL != retSurface && NULL != ppBackBuffer) {
- IWineD3DSurface_GetParent(retSurface, (IUnknown **)ppBackBuffer);
+ hr = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, iSwapChain,
+ BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &retSurface);
+ if (SUCCEEDED(hr) && retSurface && ppBackBuffer)
+ {
+ *ppBackBuffer = IWineD3DSurface_GetParent(retSurface);
+ IDirect3DSurface9_AddRef(*ppBackBuffer);
IWineD3DSurface_Release(retSurface);
}
wined3d_mutex_unlock();
- return rc;
+ return hr;
}
static HRESULT WINAPI IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9EX iface, IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) {
+static HRESULT WINAPI IDirect3DDevice9Impl_ColorFill(IDirect3DDevice9Ex *iface,
+ IDirect3DSurface9 *pSurface, const RECT *pRect, D3DCOLOR color)
+{
+ const WINED3DCOLORVALUE c =
+ {
+ ((color >> 16) & 0xff) / 255.0f,
+ ((color >> 8) & 0xff) / 255.0f,
+ (color & 0xff) / 255.0f,
+ ((color >> 24) & 0xff) / 255.0f,
+ };
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DSurface9Impl *surface = (IDirect3DSurface9Impl *)pSurface;
WINED3DPOOL pool;
}
/* Colorfill can only be used on rendertarget surfaces, or offscreen plain surfaces in D3DPOOL_DEFAULT */
- /* Note: D3DRECT is compatible with WINED3DRECT */
- hr = IWineD3DDevice_ColorFill(This->WineD3DDevice, surface->wineD3DSurface, (CONST WINED3DRECT*)pRect, color);
+ hr = IWineD3DDevice_ColorFill(This->WineD3DDevice, surface->wineD3DSurface, pRect, &c);
wined3d_mutex_unlock();
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9EX iface, DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget) {
+static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(IDirect3DDevice9Ex *iface,
+ DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget)
+{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IWineD3DSurface *pRenderTarget;
HRESULT hr;
}
else
{
- IWineD3DSurface_GetParent(pRenderTarget, (IUnknown **)ppRenderTarget);
+ *ppRenderTarget = IWineD3DSurface_GetParent(pRenderTarget);
+ IDirect3DSurface9_AddRef(*ppRenderTarget);
IWineD3DSurface_Release(pRenderTarget);
}
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9EX iface, IDirect3DSurface9 **ppZStencilSurface) {
+static HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(IDirect3DDevice9Ex *iface,
+ IDirect3DSurface9 **ppZStencilSurface)
+{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hr = D3D_OK;
IWineD3DSurface *pZStencilSurface;
+ HRESULT hr;
TRACE("iface %p, depth_stencil %p.\n", iface, ppZStencilSurface);
wined3d_mutex_lock();
hr = IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface);
- if (hr == WINED3D_OK) {
- IWineD3DSurface_GetParent(pZStencilSurface,(IUnknown**)ppZStencilSurface);
+ if (SUCCEEDED(hr))
+ {
+ *ppZStencilSurface = IWineD3DSurface_GetParent(pZStencilSurface);
+ IDirect3DSurface9_AddRef(*ppZStencilSurface);
IWineD3DSurface_Release(pZStencilSurface);
- } else {
+ }
+ else
+ {
if (hr != WINED3DERR_NOTFOUND)
WARN("Call to IWineD3DDevice_GetDepthStencilSurface failed with 0x%08x\n", hr);
*ppZStencilSurface = NULL;
/* Note: D3DRECT is compatible with WINED3DRECT */
wined3d_mutex_lock();
- hr = IWineD3DDevice_Clear(This->WineD3DDevice, Count, (CONST WINED3DRECT*) pRects, Flags, Color, Z, Stencil);
+ hr = IWineD3DDevice_Clear(This->WineD3DDevice, Count, (const RECT *)pRects, Flags, Color, Z, Stencil);
wined3d_mutex_unlock();
return hr;
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9EX iface, DWORD Stage, IDirect3DBaseTexture9 **ppTexture) {
+static HRESULT WINAPI IDirect3DDevice9Impl_GetTexture(IDirect3DDevice9Ex *iface,
+ DWORD Stage, IDirect3DBaseTexture9 **ppTexture)
+{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IWineD3DBaseTexture *retTexture = NULL;
- HRESULT rc = D3D_OK;
+ HRESULT hr;
TRACE("iface %p, stage %u, texture %p.\n", iface, Stage, ppTexture);
}
wined3d_mutex_lock();
- rc = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, &retTexture);
- if (SUCCEEDED(rc) && NULL != retTexture) {
- IWineD3DBaseTexture_GetParent(retTexture, (IUnknown **)ppTexture);
+ hr = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, &retTexture);
+ if (SUCCEEDED(hr) && retTexture)
+ {
+ *ppTexture = IWineD3DBaseTexture_GetParent(retTexture);
+ IWineD3DBaseTexture_AddRef(*ppTexture);
IWineD3DBaseTexture_Release(retTexture);
- } else {
- if(FAILED(rc)) {
+ }
+ else
+ {
+ if (FAILED(hr))
+ {
WARN("Call to get texture (%d) failed (%p)\n", Stage, retTexture);
}
*ppTexture = NULL;
}
wined3d_mutex_unlock();
- return rc;
+ return hr;
}
static HRESULT WINAPI IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9EX iface, DWORD Stage, IDirect3DBaseTexture9* pTexture) {
WINED3DTSS_CONSTANT, /* 32, D3DTSS_CONSTANT */
};
-static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9EX iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) {
+static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9EX iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD *pValue)
+{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr;
TRACE("iface %p, stage %u, state %#x, value %p.\n", iface, Stage, Type, pValue);
+ if (Type >= sizeof(tss_lookup) / sizeof(*tss_lookup))
+ {
+ WARN("Invalid Type %#x passed.\n", Type);
+ return D3D_OK;
+ }
+
wined3d_mutex_lock();
hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, 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(LPDIRECT3DDEVICE9EX iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value)
+{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr;
TRACE("iface %p, stage %u, state %#x, value %#x.\n", iface, Stage, Type, Value);
+ if (Type >= sizeof(tss_lookup) / sizeof(*tss_lookup))
+ {
+ WARN("Invalid Type %#x passed.\n", Type);
+ return D3D_OK;
+ }
+
wined3d_mutex_lock();
hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, tss_lookup[Type], Value);
wined3d_mutex_unlock();
return D3D_OK;
}
+static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(IDirect3DDevice9Ex *iface,
+ IDirect3DVertexDeclaration9 *declaration)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, declaration %p.\n", iface, declaration);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DDevice_SetVertexDeclaration(((IDirect3DDevice9Impl *)iface)->WineD3DDevice,
+ declaration ? ((IDirect3DVertexDeclaration9Impl *)declaration)->wineD3DVertexDeclaration : NULL);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(IDirect3DDevice9Ex *iface,
+ IDirect3DVertexDeclaration9 **declaration)
+{
+ IWineD3DVertexDeclaration *wined3d_declaration = NULL;
+ HRESULT hr;
+
+ TRACE("iface %p, declaration %p.\n", iface, declaration);
+
+ if (!declaration) return D3DERR_INVALIDCALL;
+
+ wined3d_mutex_lock();
+ hr = IWineD3DDevice_GetVertexDeclaration(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, &wined3d_declaration);
+ if (SUCCEEDED(hr) && wined3d_declaration)
+ {
+ *declaration = IWineD3DVertexDeclaration_GetParent(wined3d_declaration);
+ IDirect3DVertexDeclaration9_AddRef(*declaration);
+ IWineD3DVertexDeclaration_Release(wined3d_declaration);
+ }
+ else
+ {
+ *declaration = NULL;
+ }
+ wined3d_mutex_unlock();
+
+ TRACE("Returning %p.\n", *declaration);
+ return hr;
+}
+
static IDirect3DVertexDeclaration9 *getConvertedDecl(IDirect3DDevice9Impl *This, DWORD fvf) {
HRESULT hr;
D3DVERTEXELEMENT9* elements = NULL;
return D3D_OK;
}
+static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(IDirect3DDevice9Ex *iface,
+ IDirect3DVertexShader9 *shader)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, shader %p.\n", iface, shader);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DDevice_SetVertexShader(((IDirect3DDevice9Impl *)iface)->WineD3DDevice,
+ shader ? ((IDirect3DVertexShader9Impl *)shader)->wineD3DVertexShader : NULL);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(IDirect3DDevice9Ex *iface,
+ IDirect3DVertexShader9 **shader)
+{
+ IWineD3DVertexShader *wined3d_shader;
+
+ TRACE("iface %p, shader %p.\n", iface, shader);
+
+ wined3d_mutex_lock();
+ wined3d_shader = IWineD3DDevice_GetVertexShader(((IDirect3DDevice9Impl *)iface)->WineD3DDevice);
+ if (wined3d_shader)
+ {
+ *shader = IWineD3DVertexShader_GetParent(wined3d_shader);
+ IDirect3DVertexShader9_AddRef(*shader);
+ IWineD3DVertexShader_Release(wined3d_shader);
+ }
+ else
+ {
+ *shader = NULL;
+ }
+ wined3d_mutex_unlock();
+
+ TRACE("Returning %p.\n", *shader);
+
+ return D3D_OK;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(IDirect3DDevice9Ex *iface,
+ UINT reg_idx, const float *data, UINT count)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
+
+ if (reg_idx + count > D3D9_MAX_VERTEX_SHADER_CONSTANTF)
+ {
+ WARN("Trying to access %u constants, but d3d9 only supports %u\n",
+ reg_idx + count, D3D9_MAX_VERTEX_SHADER_CONSTANTF);
+ return D3DERR_INVALIDCALL;
+ }
+
+ wined3d_mutex_lock();
+ hr = IWineD3DDevice_SetVertexShaderConstantF(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, reg_idx, data, count);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(IDirect3DDevice9Ex *iface,
+ UINT reg_idx, float *data, UINT count)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
+
+ if (reg_idx + count > D3D9_MAX_VERTEX_SHADER_CONSTANTF)
+ {
+ WARN("Trying to access %u constants, but d3d9 only supports %u\n",
+ reg_idx + count, D3D9_MAX_VERTEX_SHADER_CONSTANTF);
+ return D3DERR_INVALIDCALL;
+ }
+
+ wined3d_mutex_lock();
+ hr = IWineD3DDevice_GetVertexShaderConstantF(((IDirect3DDevice9Impl *)iface)->WineD3DDevice, reg_idx, data, count);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(IDirect3DDevice9Ex *iface,
+ UINT reg_idx, const int *data, UINT count)
+{
+ 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);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(IDirect3DDevice9Ex *iface,
+ UINT reg_idx, int *data, UINT count)
+{
+ 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);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(IDirect3DDevice9Ex *iface,
+ UINT reg_idx, const BOOL *data, UINT count)
+{
+ 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);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(IDirect3DDevice9Ex *iface,
+ UINT reg_idx, BOOL *data, UINT count)
+{
+ 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);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9EX iface, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr;
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9EX iface, UINT StreamNumber, IDirect3DVertexBuffer9 **pStream, UINT* OffsetInBytes, UINT* pStride) {
+static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(IDirect3DDevice9Ex *iface,
+ UINT StreamNumber, IDirect3DVertexBuffer9 **pStream, UINT* OffsetInBytes, UINT* pStride)
+{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IWineD3DBuffer *retStream = NULL;
- HRESULT rc = D3D_OK;
+ HRESULT hr;
TRACE("iface %p, stream_idx %u, buffer %p, offset %p, stride %p.\n",
iface, StreamNumber, pStream, OffsetInBytes, pStride);
}
wined3d_mutex_lock();
- rc = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, &retStream, OffsetInBytes, pStride);
- if (rc == D3D_OK && NULL != retStream) {
- IWineD3DBuffer_GetParent(retStream, (IUnknown **)pStream);
+ hr = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, &retStream, OffsetInBytes, pStride);
+ if (SUCCEEDED(hr) && retStream)
+ {
+ *pStream = IWineD3DBuffer_GetParent(retStream);
+ IDirect3DVertexBuffer9_AddRef(*pStream);
IWineD3DBuffer_Release(retStream);
- }else{
- if (rc != D3D_OK){
+ }
+ else
+ {
+ if (FAILED(hr))
+ {
FIXME("Call to GetStreamSource failed %p %p\n", OffsetInBytes, pStride);
}
*pStream = NULL;
}
wined3d_mutex_unlock();
- return rc;
+ return hr;
}
static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSourceFreq(IDirect3DDevice9Ex *iface, UINT StreamNumber,
return hr;
}
-static HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9EX iface, IDirect3DIndexBuffer9 **ppIndexData) {
+static HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(IDirect3DDevice9Ex *iface, IDirect3DIndexBuffer9 **ppIndexData)
+{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IWineD3DBuffer *retIndexData = NULL;
- HRESULT rc = D3D_OK;
+ HRESULT hr;
TRACE("iface %p, buffer %p.\n", iface, ppIndexData);
}
wined3d_mutex_lock();
- rc = IWineD3DDevice_GetIndexBuffer(This->WineD3DDevice, &retIndexData);
- if (SUCCEEDED(rc) && retIndexData) {
- IWineD3DBuffer_GetParent(retIndexData, (IUnknown **)ppIndexData);
+ hr = IWineD3DDevice_GetIndexBuffer(This->WineD3DDevice, &retIndexData);
+ if (SUCCEEDED(hr) && retIndexData)
+ {
+ *ppIndexData = IWineD3DBuffer_GetParent(retIndexData);
+ IDirect3DIndexBuffer9_AddRef(*ppIndexData);
IWineD3DBuffer_Release(retIndexData);
- } else {
- if (FAILED(rc)) FIXME("Call to GetIndices failed\n");
+ }
+ else
+ {
+ if (FAILED(hr)) FIXME("Call to GetIndices failed\n");
*ppIndexData = NULL;
}
wined3d_mutex_unlock();
- return rc;
+ return hr;
}
static HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(IDirect3DDevice9Ex *iface,
return D3D_OK;
}
+static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(IDirect3DDevice9Ex *iface,
+ IDirect3DPixelShader9 *shader)
+{
+ HRESULT hr;
+
+ TRACE("iface %p, shader %p.\n", iface, shader);
+
+ wined3d_mutex_lock();
+ hr = IWineD3DDevice_SetPixelShader(((IDirect3DDevice9Impl *)iface)->WineD3DDevice,
+ shader ? ((IDirect3DPixelShader9Impl *)shader)->wineD3DPixelShader : NULL);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(IDirect3DDevice9Ex *iface,
+ IDirect3DPixelShader9 **shader)
+{
+ IWineD3DPixelShader *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);
+ if (wined3d_shader)
+ {
+ *shader = IWineD3DPixelShader_GetParent(wined3d_shader);
+ IDirect3DPixelShader9_AddRef(*shader);
+ IWineD3DPixelShader_Release(wined3d_shader);
+ }
+ else
+ {
+ *shader = NULL;
+ }
+ wined3d_mutex_unlock();
+
+ TRACE("Returning %p.\n", *shader);
+
+ return D3D_OK;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(IDirect3DDevice9Ex *iface,
+ UINT reg_idx, const float *data, UINT count)
+{
+ 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);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(IDirect3DDevice9Ex *iface,
+ UINT reg_idx, float *data, UINT count)
+{
+ 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);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(IDirect3DDevice9Ex *iface,
+ UINT reg_idx, const int *data, UINT count)
+{
+ 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);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(IDirect3DDevice9Ex *iface,
+ UINT reg_idx, int *data, UINT count)
+{
+ 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);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(IDirect3DDevice9Ex *iface,
+ UINT reg_idx, const BOOL *data, UINT count)
+{
+ 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);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(IDirect3DDevice9Ex *iface,
+ UINT reg_idx, BOOL *data, UINT count)
+{
+ 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);
+ 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;
HRESULT hr;
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
+ 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);
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateRenderTarget(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
- DWORD multisample_quality, BOOL lockable, IWineD3DSurface **surface)
+ IUnknown *superior, UINT width, UINT height, enum wined3d_format_id format,
+ WINED3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality, BOOL lockable,
+ IWineD3DSurface **surface)
{
struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
IDirect3DSurface9Impl *d3d_surface;
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
+ UINT width, UINT height, enum wined3d_format_id format, WINED3DMULTISAMPLE_TYPE multisample_type,
DWORD multisample_quality, BOOL discard, IWineD3DSurface **surface)
{
struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
IDirect3DSurface9Impl *d3d_surface;
HRESULT hr;
- TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
+ TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x,\n"
"\tmultisample_quality %u, discard %u, surface %p\n",
- iface, superior, width, height, format, multisample_type, multisample_quality, discard, surface);
+ iface, 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,
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent *iface,
- IUnknown *superior, UINT width, UINT height, UINT depth, WINED3DFORMAT format,
+ IUnknown *superior, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
WINED3DPOOL pool, DWORD usage, IWineD3DVolume **volume)
{
struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
static void setup_fpu(void)
{
- WORD cw;
-
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
+ WORD cw;
__asm__ volatile ("fnstcw %0" : "=m" (cw));
cw = (cw & ~0xf3f) | 0x3f;
__asm__ volatile ("fldcw %0" : : "m" (cw));
if (!(flags & D3DCREATE_FPU_PRESERVE)) setup_fpu();
wined3d_mutex_lock();
- hr = IWineD3D_CreateDevice(wined3d, adapter, device_type, focus_window, flags, (IUnknown *)device,
+ hr = IWineD3D_CreateDevice(wined3d, adapter, device_type, focus_window, flags,
(IWineD3DDeviceParent *)&device->device_parent_vtbl, &device->WineD3DDevice);
if (FAILED(hr))
{
+++ /dev/null
-/*
- * IDirect3DIndexBuffer9 implementation
- *
- * Copyright 2002-2004 Jason Edmeades
- * Raphael Junqueira
- *
- * 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 "d3d9_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
-
-/* IDirect3DIndexBuffer9 IUnknown parts follow: */
-static HRESULT WINAPI IDirect3DIndexBuffer9Impl_QueryInterface(LPDIRECT3DINDEXBUFFER9 iface, REFIID riid, LPVOID* ppobj) {
- IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
-
- TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
-
- if (IsEqualGUID(riid, &IID_IUnknown)
- || IsEqualGUID(riid, &IID_IDirect3DResource9)
- || IsEqualGUID(riid, &IID_IDirect3DIndexBuffer9)) {
- IDirect3DIndexBuffer9_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
-
- WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
- *ppobj = NULL;
- return E_NOINTERFACE;
-}
-
-static ULONG WINAPI IDirect3DIndexBuffer9Impl_AddRef(LPDIRECT3DINDEXBUFFER9 iface) {
- IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
- ULONG ref = InterlockedIncrement(&This->ref);
-
- TRACE("%p increasing refcount to %u.\n", iface, ref);
-
- if (ref == 1)
- {
- IDirect3DDevice9Ex_AddRef(This->parentDevice);
- wined3d_mutex_lock();
- IWineD3DBuffer_AddRef(This->wineD3DIndexBuffer);
- wined3d_mutex_unlock();
- }
-
- return ref;
-}
-
-static ULONG WINAPI IDirect3DIndexBuffer9Impl_Release(LPDIRECT3DINDEXBUFFER9 iface) {
- IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
- ULONG ref = InterlockedDecrement(&This->ref);
-
- TRACE("%p decreasing refcount to %u.\n", iface, ref);
-
- if (ref == 0) {
- IDirect3DDevice9Ex *parentDevice = This->parentDevice;
-
- wined3d_mutex_lock();
- IWineD3DBuffer_Release(This->wineD3DIndexBuffer);
- wined3d_mutex_unlock();
-
- /* Release the device last, as it may cause the device to be destroyed. */
- IDirect3DDevice9Ex_Release(parentDevice);
- }
- return ref;
-}
-
-/* IDirect3DIndexBuffer9 IDirect3DResource9 Interface follow: */
-static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDevice(IDirect3DIndexBuffer9 *iface, IDirect3DDevice9 **device)
-{
- IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
-
- TRACE("iface %p, device %p.\n", iface, device);
-
- *device = (IDirect3DDevice9 *)This->parentDevice;
- IDirect3DDevice9_AddRef(*device);
-
- TRACE("Returning device %p.\n", *device);
-
- return D3D_OK;
-}
-
-static HRESULT WINAPI IDirect3DIndexBuffer9Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
- IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)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 = IWineD3DBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
- IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, guid %s, data %p, data_size %p.\n",
- iface, debugstr_guid(refguid), pData, pSizeOfData);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DIndexBuffer9Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid) {
- IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static DWORD WINAPI IDirect3DIndexBuffer9Impl_SetPriority(LPDIRECT3DINDEXBUFFER9 iface, DWORD PriorityNew) {
- IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
- DWORD ret;
-
- TRACE("iface %p, priority %u.\n", iface, PriorityNew);
-
- wined3d_mutex_lock();
- ret = IWineD3DBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew);
- wined3d_mutex_unlock();
-
- return ret;
-}
-
-static DWORD WINAPI IDirect3DIndexBuffer9Impl_GetPriority(LPDIRECT3DINDEXBUFFER9 iface) {
- IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
- DWORD ret;
-
- TRACE("iface %p.\n", iface);
-
- wined3d_mutex_lock();
- ret = IWineD3DBuffer_GetPriority(This->wineD3DIndexBuffer);
- wined3d_mutex_unlock();
-
- return ret;
-}
-
-static void WINAPI IDirect3DIndexBuffer9Impl_PreLoad(LPDIRECT3DINDEXBUFFER9 iface) {
- IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
-
- TRACE("iface %p.\n", iface);
-
- wined3d_mutex_lock();
- IWineD3DBuffer_PreLoad(This->wineD3DIndexBuffer);
- wined3d_mutex_unlock();
-}
-
-static D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer9Impl_GetType(IDirect3DIndexBuffer9 *iface)
-{
- TRACE("iface %p.\n", iface);
-
- return D3DRTYPE_INDEXBUFFER;
-}
-
-/* IDirect3DIndexBuffer9 Interface follow: */
-static HRESULT WINAPI IDirect3DIndexBuffer9Impl_Lock(LPDIRECT3DINDEXBUFFER9 iface, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) {
- IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n",
- iface, OffsetToLock, SizeToLock, ppbData, Flags);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_Map(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DIndexBuffer9Impl_Unlock(LPDIRECT3DINDEXBUFFER9 iface) {
- IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p.\n", iface);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_Unmap(This->wineD3DIndexBuffer);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDesc(LPDIRECT3DINDEXBUFFER9 iface, D3DINDEXBUFFER_DESC *pDesc) {
- IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
- HRESULT hr;
- WINED3DBUFFER_DESC desc;
-
- TRACE("iface %p, desc %p.\n", iface, pDesc);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_GetDesc(This->wineD3DIndexBuffer, &desc);
- wined3d_mutex_unlock();
-
- if (SUCCEEDED(hr)) {
- pDesc->Format = d3dformat_from_wined3dformat(This->format);
- pDesc->Usage = desc.Usage;
- pDesc->Pool = desc.Pool;
- pDesc->Size = desc.Size;
- pDesc->Type = D3DRTYPE_INDEXBUFFER;
- }
-
- return hr;
-}
-
-
-static const IDirect3DIndexBuffer9Vtbl Direct3DIndexBuffer9_Vtbl =
-{
- /* IUnknown */
- IDirect3DIndexBuffer9Impl_QueryInterface,
- IDirect3DIndexBuffer9Impl_AddRef,
- IDirect3DIndexBuffer9Impl_Release,
- /* IDirect3DResource9 */
- IDirect3DIndexBuffer9Impl_GetDevice,
- IDirect3DIndexBuffer9Impl_SetPrivateData,
- IDirect3DIndexBuffer9Impl_GetPrivateData,
- IDirect3DIndexBuffer9Impl_FreePrivateData,
- IDirect3DIndexBuffer9Impl_SetPriority,
- IDirect3DIndexBuffer9Impl_GetPriority,
- IDirect3DIndexBuffer9Impl_PreLoad,
- IDirect3DIndexBuffer9Impl_GetType,
- /* IDirect3DIndexBuffer9 */
- IDirect3DIndexBuffer9Impl_Lock,
- IDirect3DIndexBuffer9Impl_Unlock,
- IDirect3DIndexBuffer9Impl_GetDesc
-};
-
-static void STDMETHODCALLTYPE d3d9_indexbuffer_wined3d_object_destroyed(void *parent)
-{
- HeapFree(GetProcessHeap(), 0, parent);
-}
-
-static const struct wined3d_parent_ops d3d9_indexbuffer_wined3d_parent_ops =
-{
- d3d9_indexbuffer_wined3d_object_destroyed,
-};
-
-HRESULT indexbuffer_init(IDirect3DIndexBuffer9Impl *buffer, IDirect3DDevice9Impl *device,
- UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool)
-{
- HRESULT hr;
-
- buffer->lpVtbl = &Direct3DIndexBuffer9_Vtbl;
- buffer->ref = 1;
- buffer->format = wined3dformat_from_d3dformat(format);
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_CreateIndexBuffer(device->WineD3DDevice, size,
- usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, &buffer->wineD3DIndexBuffer,
- (IUnknown *)buffer, &d3d9_indexbuffer_wined3d_parent_ops);
- wined3d_mutex_unlock();
- if (FAILED(hr))
- {
- WARN("Failed to create wined3d buffer, hr %#x.\n", hr);
- return hr;
- }
-
- buffer->parentDevice = (IDirect3DDevice9Ex *)device;
- IDirect3DDevice9Ex_AddRef(buffer->parentDevice);
-
- return D3D_OK;
-}
+++ /dev/null
-/*
- * IDirect3DPixelShader9 implementation
- *
- * Copyright 2002-2003 Jason Edmeades
- * Raphael Junqueira
- *
- * 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 "d3d9_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
-
-/* IDirect3DPixelShader9 IUnknown parts follow: */
-static HRESULT WINAPI IDirect3DPixelShader9Impl_QueryInterface(LPDIRECT3DPIXELSHADER9 iface, REFIID riid, LPVOID* ppobj) {
- IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
-
- TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
-
- if (IsEqualGUID(riid, &IID_IUnknown)
- || IsEqualGUID(riid, &IID_IDirect3DPixelShader9)) {
- IDirect3DPixelShader9_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
-
- WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
- *ppobj = NULL;
- return E_NOINTERFACE;
-}
-
-static ULONG WINAPI IDirect3DPixelShader9Impl_AddRef(LPDIRECT3DPIXELSHADER9 iface) {
- IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
- ULONG ref = InterlockedIncrement(&This->ref);
-
- TRACE("%p increasing refcount to %u.\n", iface, ref);
-
- if (ref == 1)
- {
- IDirect3DDevice9Ex_AddRef(This->parentDevice);
- wined3d_mutex_lock();
- IWineD3DPixelShader_AddRef(This->wineD3DPixelShader);
- wined3d_mutex_unlock();
- }
-
- return ref;
-}
-
-static ULONG WINAPI IDirect3DPixelShader9Impl_Release(LPDIRECT3DPIXELSHADER9 iface) {
- IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
- ULONG ref = InterlockedDecrement(&This->ref);
-
- TRACE("%p decreasing refcount to %u.\n", iface, ref);
-
- if (ref == 0) {
- IDirect3DDevice9Ex *parentDevice = This->parentDevice;
-
- wined3d_mutex_lock();
- IWineD3DPixelShader_Release(This->wineD3DPixelShader);
- wined3d_mutex_unlock();
-
- /* Release the device last, as it may cause the device to be destroyed. */
- IDirect3DDevice9Ex_Release(parentDevice);
- }
- return ref;
-}
-
-/* IDirect3DPixelShader9 Interface follow: */
-static HRESULT WINAPI IDirect3DPixelShader9Impl_GetDevice(IDirect3DPixelShader9 *iface, IDirect3DDevice9 **device)
-{
- IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
-
- TRACE("iface %p, device %p.\n", iface, device);
-
- *device = (IDirect3DDevice9 *)This->parentDevice;
- IDirect3DDevice9_AddRef(*device);
-
- TRACE("Returning device %p.\n", *device);
-
- return D3D_OK;
-}
-
-static HRESULT WINAPI IDirect3DPixelShader9Impl_GetFunction(LPDIRECT3DPIXELSHADER9 iface, VOID* pData, UINT* pSizeOfData) {
- IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, data %p, data_size %p.\n", iface, pData, pSizeOfData);
-
- wined3d_mutex_lock();
- hr = IWineD3DPixelShader_GetFunction(This->wineD3DPixelShader, pData, pSizeOfData);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-
-static const IDirect3DPixelShader9Vtbl Direct3DPixelShader9_Vtbl =
-{
- /* IUnknown */
- IDirect3DPixelShader9Impl_QueryInterface,
- IDirect3DPixelShader9Impl_AddRef,
- IDirect3DPixelShader9Impl_Release,
- /* IDirect3DPixelShader9 */
- IDirect3DPixelShader9Impl_GetDevice,
- IDirect3DPixelShader9Impl_GetFunction
-};
-
-static void STDMETHODCALLTYPE d3d9_pixelshader_wined3d_object_destroyed(void *parent)
-{
- HeapFree(GetProcessHeap(), 0, parent);
-}
-
-static const struct wined3d_parent_ops d3d9_pixelshader_wined3d_parent_ops =
-{
- d3d9_pixelshader_wined3d_object_destroyed,
-};
-
-HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, IDirect3DDevice9Impl *device, const DWORD *byte_code)
-{
- HRESULT hr;
-
- shader->ref = 1;
- shader->lpVtbl = &Direct3DPixelShader9_Vtbl;
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_CreatePixelShader(device->WineD3DDevice, byte_code,
- NULL, &shader->wineD3DPixelShader, (IUnknown *)shader,
- &d3d9_pixelshader_wined3d_parent_ops);
- wined3d_mutex_unlock();
- if (FAILED(hr))
- {
- WARN("Failed to created wined3d pixel shader, hr %#x.\n", hr);
- return hr;
- }
-
- shader->parentDevice = (IDirect3DDevice9Ex *)device;
- IDirect3DDevice9Ex_AddRef(shader->parentDevice);
-
- return D3D_OK;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9EX iface, IDirect3DPixelShader9* pShader) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- IDirect3DPixelShader9Impl *shader = (IDirect3DPixelShader9Impl *)pShader;
-
- TRACE("iface %p, shader %p.\n", iface, shader);
-
- wined3d_mutex_lock();
- IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader == NULL ? NULL :shader->wineD3DPixelShader);
- wined3d_mutex_unlock();
-
- return D3D_OK;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9EX iface, IDirect3DPixelShader9** ppShader) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- IWineD3DPixelShader *object;
- HRESULT hrc;
-
- TRACE("iface %p, shader %p.\n", iface, ppShader);
-
- if (ppShader == NULL) {
- TRACE("(%p) Invalid call\n", This);
- return D3DERR_INVALIDCALL;
- }
-
- wined3d_mutex_lock();
- hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object);
- if (SUCCEEDED(hrc))
- {
- if (object)
- {
- hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)ppShader);
- IWineD3DPixelShader_Release(object);
- }
- else
- {
- *ppShader = NULL;
- }
- }
- else
- {
- WARN("(%p) : Call to IWineD3DDevice_GetPixelShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
- }
- wined3d_mutex_unlock();
-
- TRACE("(%p) : returning %p\n", This, *ppShader);
- return hrc;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, register %u, data %p, count %u.\n",
- iface, Register, pConstantData, Vector4fCount);
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, register %u, data %p, count %u.\n",
- iface, Register, pConstantData, Vector4fCount);
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, register %u, data %p, count %u.\n",
- iface, Register, pConstantData, Vector4iCount);
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_SetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, register %u, data %p, count %u.\n",
- iface, Register, pConstantData, Vector4iCount);
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_GetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, register %u, data %p, count %u.\n",
- iface, Register, pConstantData, BoolCount);
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_SetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, register %u, data %p, count %u.\n",
- iface, Register, pConstantData, BoolCount);
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_GetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
- wined3d_mutex_unlock();
-
- return hr;
-}
query->ref = 1;
wined3d_mutex_lock();
- hr = IWineD3DDevice_CreateQuery(device->WineD3DDevice, type, &query->wineD3DQuery, (IUnknown *)query);
+ hr = IWineD3DDevice_CreateQuery(device->WineD3DDevice, type, &query->wineD3DQuery);
wined3d_mutex_unlock();
if (FAILED(hr))
{
--- /dev/null
+/*
+ * Copyright 2002-2003 Jason Edmeades
+ * Raphael Junqueira
+ *
+ * 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 "d3d9_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
+
+static HRESULT WINAPI d3d9_vertexshader_QueryInterface(IDirect3DVertexShader9 *iface, REFIID riid, void **object)
+{
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+
+ if (IsEqualGUID(riid, &IID_IDirect3DVertexShader9)
+ || IsEqualGUID(riid, &IID_IUnknown))
+ {
+ IDirect3DVertexShader9_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 d3d9_vertexshader_AddRef(IDirect3DVertexShader9 *iface)
+{
+ IDirect3DVertexShader9Impl *shader = (IDirect3DVertexShader9Impl *)iface;
+ ULONG refcount = InterlockedIncrement(&shader->ref);
+
+ TRACE("%p increasing refcount to %u.\n", iface, refcount);
+
+ if (refcount == 1)
+ {
+ IDirect3DDevice9Ex_AddRef(shader->parentDevice);
+ wined3d_mutex_lock();
+ IWineD3DVertexShader_AddRef(shader->wineD3DVertexShader);
+ wined3d_mutex_unlock();
+ }
+
+ return refcount;
+}
+
+static ULONG WINAPI d3d9_vertexshader_Release(IDirect3DVertexShader9 *iface)
+{
+ IDirect3DVertexShader9Impl *shader = (IDirect3DVertexShader9Impl *)iface;
+ ULONG refcount = InterlockedDecrement(&shader->ref);
+
+ TRACE("%p decreasing refcount to %u.\n", iface, refcount);
+
+ if (!refcount)
+ {
+ IDirect3DDevice9Ex *device = shader->parentDevice;
+
+ wined3d_mutex_lock();
+ IWineD3DVertexShader_Release(shader->wineD3DVertexShader);
+ wined3d_mutex_unlock();
+
+ /* Release the device last, as it may cause the device to be destroyed. */
+ IDirect3DDevice9Ex_Release(device);
+ }
+
+ return refcount;
+}
+
+static HRESULT WINAPI d3d9_vertexshader_GetDevice(IDirect3DVertexShader9 *iface, IDirect3DDevice9 **device)
+{
+ TRACE("iface %p, device %p.\n", iface, device);
+
+ *device = (IDirect3DDevice9 *)((IDirect3DVertexShader9Impl *)iface)->parentDevice;
+ IDirect3DDevice9_AddRef(*device);
+
+ TRACE("Returning device %p.\n", *device);
+
+ return D3D_OK;
+}
+
+static HRESULT WINAPI d3d9_vertexshader_GetFunction(IDirect3DVertexShader9 *iface,
+ void *data, UINT *data_size)
+{
+ HRESULT hr;
+
+ 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);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static const IDirect3DVertexShader9Vtbl d3d9_vertexshader_vtbl =
+{
+ /* IUnknown */
+ d3d9_vertexshader_QueryInterface,
+ d3d9_vertexshader_AddRef,
+ d3d9_vertexshader_Release,
+ /* IDirect3DVertexShader9 */
+ d3d9_vertexshader_GetDevice,
+ d3d9_vertexshader_GetFunction,
+};
+
+static void STDMETHODCALLTYPE d3d9_vertexshader_wined3d_object_destroyed(void *parent)
+{
+ HeapFree(GetProcessHeap(), 0, parent);
+}
+
+static const struct wined3d_parent_ops d3d9_vertexshader_wined3d_parent_ops =
+{
+ d3d9_vertexshader_wined3d_object_destroyed,
+};
+
+HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader, IDirect3DDevice9Impl *device, const DWORD *byte_code)
+{
+ HRESULT hr;
+
+ shader->ref = 1;
+ shader->lpVtbl = &d3d9_vertexshader_vtbl;
+
+ wined3d_mutex_lock();
+ hr = IWineD3DDevice_CreateVertexShader(device->WineD3DDevice, byte_code, NULL,
+ shader, &d3d9_vertexshader_wined3d_parent_ops, &shader->wineD3DVertexShader);
+ wined3d_mutex_unlock();
+ if (FAILED(hr))
+ {
+ WARN("Failed to create wined3d vertex shader, hr %#x.\n", hr);
+ return hr;
+ }
+
+ shader->parentDevice = (IDirect3DDevice9Ex *)device;
+ IDirect3DDevice9Ex_AddRef(shader->parentDevice);
+
+ return D3D_OK;
+}
+
+static HRESULT WINAPI d3d9_pixelshader_QueryInterface(IDirect3DPixelShader9 *iface, REFIID riid, void **object)
+{
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+
+ if (IsEqualGUID(riid, &IID_IDirect3DPixelShader9)
+ || IsEqualGUID(riid, &IID_IUnknown))
+ {
+ IDirect3DPixelShader9_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 d3d9_pixelshader_AddRef(IDirect3DPixelShader9 *iface)
+{
+ IDirect3DPixelShader9Impl *shader = (IDirect3DPixelShader9Impl *)iface;
+ ULONG refcount = InterlockedIncrement(&shader->ref);
+
+ TRACE("%p increasing refcount to %u.\n", iface, refcount);
+
+ if (refcount == 1)
+ {
+ IDirect3DDevice9Ex_AddRef(shader->parentDevice);
+ wined3d_mutex_lock();
+ IWineD3DPixelShader_AddRef(shader->wineD3DPixelShader);
+ wined3d_mutex_unlock();
+ }
+
+ return refcount;
+}
+
+static ULONG WINAPI d3d9_pixelshader_Release(IDirect3DPixelShader9 *iface)
+{
+ IDirect3DPixelShader9Impl *shader = (IDirect3DPixelShader9Impl *)iface;
+ ULONG refcount = InterlockedDecrement(&shader->ref);
+
+ TRACE("%p decreasing refcount to %u.\n", iface, refcount);
+
+ if (!refcount)
+ {
+ IDirect3DDevice9Ex *device = shader->parentDevice;
+
+ wined3d_mutex_lock();
+ IWineD3DPixelShader_Release(shader->wineD3DPixelShader);
+ wined3d_mutex_unlock();
+
+ /* Release the device last, as it may cause the device to be destroyed. */
+ IDirect3DDevice9Ex_Release(device);
+ }
+
+ return refcount;
+}
+
+static HRESULT WINAPI d3d9_pixelshader_GetDevice(IDirect3DPixelShader9 *iface, IDirect3DDevice9 **device)
+{
+ TRACE("iface %p, device %p.\n", iface, device);
+
+ *device = (IDirect3DDevice9 *)((IDirect3DPixelShader9Impl *)iface)->parentDevice;
+ IDirect3DDevice9_AddRef(*device);
+
+ TRACE("Returning device %p.\n", *device);
+
+ return D3D_OK;
+}
+
+static HRESULT WINAPI d3d9_pixelshader_GetFunction(IDirect3DPixelShader9 *iface, void *data, UINT *data_size)
+{
+ HRESULT hr;
+
+ 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);
+ wined3d_mutex_unlock();
+
+ return hr;
+}
+
+static const IDirect3DPixelShader9Vtbl d3d9_pixelshader_vtbl =
+{
+ /* IUnknown */
+ d3d9_pixelshader_QueryInterface,
+ d3d9_pixelshader_AddRef,
+ d3d9_pixelshader_Release,
+ /* IDirect3DPixelShader9 */
+ d3d9_pixelshader_GetDevice,
+ d3d9_pixelshader_GetFunction,
+};
+
+static void STDMETHODCALLTYPE d3d9_pixelshader_wined3d_object_destroyed(void *parent)
+{
+ HeapFree(GetProcessHeap(), 0, parent);
+}
+
+static const struct wined3d_parent_ops d3d9_pixelshader_wined3d_parent_ops =
+{
+ d3d9_pixelshader_wined3d_object_destroyed,
+};
+
+HRESULT pixelshader_init(IDirect3DPixelShader9Impl *shader, IDirect3DDevice9Impl *device, const DWORD *byte_code)
+{
+ HRESULT hr;
+
+ shader->ref = 1;
+ shader->lpVtbl = &d3d9_pixelshader_vtbl;
+
+ wined3d_mutex_lock();
+ hr = IWineD3DDevice_CreatePixelShader(device->WineD3DDevice, byte_code, NULL, shader,
+ &d3d9_pixelshader_wined3d_parent_ops, &shader->wineD3DPixelShader);
+ wined3d_mutex_unlock();
+ if (FAILED(hr))
+ {
+ WARN("Failed to created wined3d pixel shader, hr %#x.\n", hr);
+ return hr;
+ }
+
+ shader->parentDevice = (IDirect3DDevice9Ex *)device;
+ IDirect3DDevice9Ex_AddRef(shader->parentDevice);
+
+ return D3D_OK;
+}
else
{
wined3d_mutex_lock();
- hr = IWineD3DDevice_CreateStateBlock(device->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)type,
- &stateblock->wineD3DStateBlock, (IUnknown *)stateblock);
+ hr = IWineD3DDevice_CreateStateBlock(device->WineD3DDevice,
+ (WINED3DSTATEBLOCKTYPE)type, &stateblock->wineD3DStateBlock);
wined3d_mutex_unlock();
if (FAILED(hr))
{
static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3DSURFACE_DESC* pDesc) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
WINED3DSURFACE_DESC wined3ddesc;
- HRESULT hr;
TRACE("iface %p, desc %p.\n", iface, pDesc);
wined3d_mutex_lock();
- hr = IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
+ IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
wined3d_mutex_unlock();
- if (SUCCEEDED(hr))
- {
- 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;
- }
+ 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;
- return hr;
+ return D3D_OK;
}
static HRESULT WINAPI IDirect3DSurface9Impl_LockRect(LPDIRECT3DSURFACE9 iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateSurface(device->WineD3DDevice, width, height, wined3dformat_from_d3dformat(format),
- lockable, discard, level, &surface->wineD3DSurface, usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool,
- multisample_type, multisample_quality, SURFACE_OPENGL, (IUnknown *)surface,
- &d3d9_surface_wined3d_parent_ops);
+ lockable, discard, level, usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, multisample_type,
+ multisample_quality, SURFACE_OPENGL, surface, &d3d9_surface_wined3d_parent_ops, &surface->wineD3DSurface);
wined3d_mutex_unlock();
if (FAILED(hr))
{
return hr;
}
-static HRESULT WINAPI IDirect3DSwapChain9Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN9 iface, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) {
+static HRESULT WINAPI IDirect3DSwapChain9Impl_GetBackBuffer(IDirect3DSwapChain9 *iface,
+ UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 **ppBackBuffer)
+{
IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
- HRESULT hrc = D3D_OK;
IWineD3DSurface *mySurface = NULL;
+ HRESULT hr;
TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
iface, iBackBuffer, Type, ppBackBuffer);
wined3d_mutex_lock();
- hrc = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &mySurface);
- if (hrc == D3D_OK && NULL != mySurface) {
- IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppBackBuffer);
+ hr = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer,
+ (WINED3DBACKBUFFER_TYPE)Type, &mySurface);
+ if (SUCCEEDED(hr) && mySurface)
+ {
+ *ppBackBuffer = IWineD3DSurface_GetParent(mySurface);
+ IDirect3DSurface9_AddRef(*ppBackBuffer);
IWineD3DSurface_Release(mySurface);
}
wined3d_mutex_unlock();
/* Do not touch the **ppBackBuffer pointer otherwise! (see device test) */
- return hrc;
+ return hr;
}
static HRESULT WINAPI IDirect3DSwapChain9Impl_GetRasterStatus(LPDIRECT3DSWAPCHAIN9 iface, D3DRASTER_STATUS* pRasterStatus) {
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateSwapChain(device->WineD3DDevice, &wined3d_parameters,
- &swapchain->wineD3DSwapChain, (IUnknown *)swapchain, SURFACE_OPENGL);
+ SURFACE_OPENGL, swapchain, &swapchain->wineD3DSwapChain);
wined3d_mutex_unlock();
present_parameters->BackBufferWidth = wined3d_parameters.BackBufferWidth;
return D3D_OK;
}
-
-HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hrc = D3D_OK;
- IWineD3DSwapChain *swapchain = NULL;
-
- TRACE("iface %p, swapchain_idx %u, swapchain %p.\n",
- iface, iSwapChain, pSwapChain);
-
- wined3d_mutex_lock();
- hrc = IWineD3DDevice_GetSwapChain(This->WineD3DDevice, iSwapChain, &swapchain);
- if (hrc == D3D_OK && NULL != swapchain) {
- IWineD3DSwapChain_GetParent(swapchain, (IUnknown **)pSwapChain);
- IWineD3DSwapChain_Release(swapchain);
- } else {
- *pSwapChain = NULL;
- }
- wined3d_mutex_unlock();
-
- return hrc;
-}
-
-UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(LPDIRECT3DDEVICE9EX iface) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- UINT ret;
-
- TRACE("iface %p.\n", iface);
-
- wined3d_mutex_lock();
- ret = IWineD3DDevice_GetNumberOfSwapChains(This->WineD3DDevice);
- wined3d_mutex_unlock();
-
- return ret;
-}
return hr;
}
-static HRESULT WINAPI IDirect3DTexture9Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE9 iface, UINT Level, IDirect3DSurface9** ppSurfaceLevel) {
+static HRESULT WINAPI IDirect3DTexture9Impl_GetSurfaceLevel(IDirect3DTexture9 *iface,
+ UINT Level, IDirect3DSurface9 **ppSurfaceLevel)
+{
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
- HRESULT hrc = D3D_OK;
IWineD3DSurface *mySurface = NULL;
+ HRESULT hr;
TRACE("iface %p, level %u, surface %p.\n", iface, Level, ppSurfaceLevel);
wined3d_mutex_lock();
- hrc = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
- if (hrc == D3D_OK && NULL != ppSurfaceLevel) {
- IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppSurfaceLevel);
- IWineD3DSurface_Release(mySurface);
+ hr = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
+ if (SUCCEEDED(hr) && ppSurfaceLevel)
+ {
+ *ppSurfaceLevel = IWineD3DSurface_GetParent(mySurface);
+ IDirect3DSurface9_AddRef(*ppSurfaceLevel);
+ IWineD3DSurface_Release(mySurface);
}
wined3d_mutex_unlock();
- return hrc;
+ return hr;
}
static HRESULT WINAPI IDirect3DTexture9Impl_LockRect(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateTexture(device->WineD3DDevice, width, height, levels,
usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool,
- &texture->wineD3DTexture, (IUnknown *)texture, &d3d9_texture_wined3d_parent_ops);
+ texture, &d3d9_texture_wined3d_parent_ops, &texture->wineD3DTexture);
wined3d_mutex_unlock();
if (FAILED(hr))
{
+++ /dev/null
-/*
- * IDirect3DVertexBuffer9 implementation
- *
- * Copyright 2002-2004 Jason Edmeades
- * Copyright 2002-2004 Raphael Junqueira
- * Copyright 2005 Oliver Stieber
- *
- * 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 "d3d9_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
-
-/* IDirect3DVertexBuffer9 IUnknown parts follow: */
-static HRESULT WINAPI IDirect3DVertexBuffer9Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER9 iface, REFIID riid, LPVOID* ppobj) {
- IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
-
- TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
-
- if (IsEqualGUID(riid, &IID_IUnknown)
- || IsEqualGUID(riid, &IID_IDirect3DResource9)
- || IsEqualGUID(riid, &IID_IDirect3DVertexBuffer9)) {
- IDirect3DVertexBuffer9_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
-
- WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
- *ppobj = NULL;
- return E_NOINTERFACE;
-}
-
-static ULONG WINAPI IDirect3DVertexBuffer9Impl_AddRef(LPDIRECT3DVERTEXBUFFER9 iface) {
- IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
- ULONG ref = InterlockedIncrement(&This->ref);
-
- TRACE("%p increasing refcount to %u.\n", iface, ref);
-
- if (ref == 1)
- {
- IDirect3DDevice9Ex_AddRef(This->parentDevice);
- wined3d_mutex_lock();
- IWineD3DBuffer_AddRef(This->wineD3DVertexBuffer);
- wined3d_mutex_unlock();
- }
-
- return ref;
-}
-
-static ULONG WINAPI IDirect3DVertexBuffer9Impl_Release(LPDIRECT3DVERTEXBUFFER9 iface) {
- IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
- ULONG ref = InterlockedDecrement(&This->ref);
-
- TRACE("%p decreasing refcount to %u.\n", iface, ref);
-
- if (ref == 0) {
- IDirect3DDevice9Ex *parentDevice = This->parentDevice;
-
- wined3d_mutex_lock();
- IWineD3DBuffer_Release(This->wineD3DVertexBuffer);
- wined3d_mutex_unlock();
-
- /* Release the device last, as it may cause the device to be destroyed. */
- IDirect3DDevice9Ex_Release(parentDevice);
- }
- return ref;
-}
-
-/* IDirect3DVertexBuffer9 IDirect3DResource9 Interface follow: */
-static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDevice(IDirect3DVertexBuffer9 *iface, IDirect3DDevice9 **device)
-{
- IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
-
- TRACE("iface %p, device %p.\n", iface, device);
-
- *device = (IDirect3DDevice9 *)This->parentDevice;
- IDirect3DDevice9_AddRef(*device);
-
- TRACE("Returning device %p.\n", *device);
-
- return D3D_OK;
-}
-
-static HRESULT WINAPI IDirect3DVertexBuffer9Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
- IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)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 = IWineD3DBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
- IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, guid %s, data %p, data_size %p.\n",
- iface, debugstr_guid(refguid), pData, pSizeOfData);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DVertexBuffer9Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid) {
- IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static DWORD WINAPI IDirect3DVertexBuffer9Impl_SetPriority(LPDIRECT3DVERTEXBUFFER9 iface, DWORD PriorityNew) {
- IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, priority %u.\n", iface, PriorityNew);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static DWORD WINAPI IDirect3DVertexBuffer9Impl_GetPriority(LPDIRECT3DVERTEXBUFFER9 iface) {
- IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p.\n", iface);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_GetPriority(This->wineD3DVertexBuffer);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static void WINAPI IDirect3DVertexBuffer9Impl_PreLoad(LPDIRECT3DVERTEXBUFFER9 iface) {
- IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
-
- TRACE("iface %p.\n", iface);
-
- wined3d_mutex_lock();
- IWineD3DBuffer_PreLoad(This->wineD3DVertexBuffer);
- wined3d_mutex_unlock();
-}
-
-static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer9Impl_GetType(IDirect3DVertexBuffer9 *iface)
-{
- TRACE("iface %p.\n", iface);
-
- return D3DRTYPE_VERTEXBUFFER;
-}
-
-/* IDirect3DVertexBuffer9 Interface follow: */
-static HRESULT WINAPI IDirect3DVertexBuffer9Impl_Lock(LPDIRECT3DVERTEXBUFFER9 iface, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) {
- IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n",
- iface, OffsetToLock, SizeToLock, ppbData, Flags);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_Map(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DVertexBuffer9Impl_Unlock(LPDIRECT3DVERTEXBUFFER9 iface) {
- IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p.\n", iface);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_Unmap(This->wineD3DVertexBuffer);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDesc(LPDIRECT3DVERTEXBUFFER9 iface, D3DVERTEXBUFFER_DESC* pDesc) {
- IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
- HRESULT hr;
- WINED3DBUFFER_DESC desc;
-
- TRACE("iface %p, desc %p.\n", iface, pDesc);
-
- wined3d_mutex_lock();
- hr = IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &desc);
- wined3d_mutex_unlock();
-
- if (SUCCEEDED(hr)) {
- pDesc->Format = D3DFMT_VERTEXDATA;
- pDesc->Usage = desc.Usage;
- pDesc->Pool = desc.Pool;
- pDesc->Size = desc.Size;
- pDesc->Type = D3DRTYPE_VERTEXBUFFER;
- pDesc->FVF = This->fvf;
- }
-
-
- return hr;
-}
-
-static const IDirect3DVertexBuffer9Vtbl Direct3DVertexBuffer9_Vtbl =
-{
- /* IUnknown */
- IDirect3DVertexBuffer9Impl_QueryInterface,
- IDirect3DVertexBuffer9Impl_AddRef,
- IDirect3DVertexBuffer9Impl_Release,
- /* IDirect3DResource9 */
- IDirect3DVertexBuffer9Impl_GetDevice,
- IDirect3DVertexBuffer9Impl_SetPrivateData,
- IDirect3DVertexBuffer9Impl_GetPrivateData,
- IDirect3DVertexBuffer9Impl_FreePrivateData,
- IDirect3DVertexBuffer9Impl_SetPriority,
- IDirect3DVertexBuffer9Impl_GetPriority,
- IDirect3DVertexBuffer9Impl_PreLoad,
- IDirect3DVertexBuffer9Impl_GetType,
- /* IDirect3DVertexBuffer9 */
- IDirect3DVertexBuffer9Impl_Lock,
- IDirect3DVertexBuffer9Impl_Unlock,
- IDirect3DVertexBuffer9Impl_GetDesc
-};
-
-static void STDMETHODCALLTYPE d3d9_vertexbuffer_wined3d_object_destroyed(void *parent)
-{
- HeapFree(GetProcessHeap(), 0, parent);
-}
-
-static const struct wined3d_parent_ops d3d9_vertexbuffer_wined3d_parent_ops =
-{
- d3d9_vertexbuffer_wined3d_object_destroyed,
-};
-
-HRESULT vertexbuffer_init(IDirect3DVertexBuffer9Impl *buffer, IDirect3DDevice9Impl *device,
- UINT size, UINT usage, DWORD fvf, D3DPOOL pool)
-{
- HRESULT hr;
-
- buffer->lpVtbl = &Direct3DVertexBuffer9_Vtbl;
- buffer->ref = 1;
- buffer->fvf = fvf;
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_CreateVertexBuffer(device->WineD3DDevice, size,
- usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, &buffer->wineD3DVertexBuffer,
- (IUnknown *)buffer, &d3d9_vertexbuffer_wined3d_parent_ops);
- wined3d_mutex_unlock();
- if (FAILED(hr))
- {
- WARN("Failed to create wined3d buffer, hr %#x.\n", hr);
- return hr;
- }
-
- buffer->parentDevice = (IDirect3DDevice9Ex *)device;
- IDirect3DDevice9Ex_AddRef(buffer->parentDevice);
-
- return D3D_OK;
-}
typedef struct _D3DDECLTYPE_INFO {
D3DDECLTYPE d3dType;
- WINED3DFORMAT format;
+ enum wined3d_format_id format;
int size;
int typesize;
} D3DDECLTYPE_INFO;
declaration->element_count = element_count;
wined3d_mutex_lock();
- hr = IWineD3DDevice_CreateVertexDeclaration(device->WineD3DDevice, &declaration->wineD3DVertexDeclaration,
- (IUnknown *)declaration, &d3d9_vertexdeclaration_wined3d_parent_ops,
- wined3d_elements, wined3d_element_count);
+ hr = IWineD3DDevice_CreateVertexDeclaration(device->WineD3DDevice, wined3d_elements, wined3d_element_count,
+ declaration, &d3d9_vertexdeclaration_wined3d_parent_ops, &declaration->wineD3DVertexDeclaration);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, wined3d_elements);
if (FAILED(hr))
return D3D_OK;
}
-
-HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexDeclaration9* pDecl) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- IDirect3DVertexDeclaration9Impl *pDeclImpl = (IDirect3DVertexDeclaration9Impl *)pDecl;
- HRESULT hr = D3D_OK;
-
- TRACE("iface %p, vertex declaration %p.\n", iface, pDecl);
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice, pDeclImpl == NULL ? NULL : pDeclImpl->wineD3DVertexDeclaration);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexDeclaration9** ppDecl) {
- IDirect3DDevice9Impl* This = (IDirect3DDevice9Impl*) iface;
- IWineD3DVertexDeclaration* pTest = NULL;
- HRESULT hr = D3D_OK;
-
- TRACE("iface %p, declaration %p.\n", iface, ppDecl);
-
- if (NULL == ppDecl) {
- return D3DERR_INVALIDCALL;
- }
-
- *ppDecl = NULL;
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &pTest);
- if (hr == D3D_OK && NULL != pTest) {
- IWineD3DVertexDeclaration_GetParent(pTest, (IUnknown **)ppDecl);
- IWineD3DVertexDeclaration_Release(pTest);
- } else {
- *ppDecl = NULL;
- }
- wined3d_mutex_unlock();
-
- TRACE("(%p) : returning %p\n", This, *ppDecl);
- return hr;
-}
+++ /dev/null
-/*
- * IDirect3DVertexShader9 implementation
- *
- * Copyright 2002-2003 Jason Edmeades
- * Raphael Junqueira
- *
- * 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 "d3d9_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
-
-/* IDirect3DVertexShader9 IUnknown parts follow: */
-static HRESULT WINAPI IDirect3DVertexShader9Impl_QueryInterface(LPDIRECT3DVERTEXSHADER9 iface, REFIID riid, LPVOID* ppobj) {
- IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
-
- TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
-
- if (IsEqualGUID(riid, &IID_IUnknown)
- || IsEqualGUID(riid, &IID_IDirect3DVertexShader9)) {
- IDirect3DVertexShader9_AddRef(iface);
- *ppobj = This;
- return S_OK;
- }
-
- WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
- *ppobj = NULL;
- return E_NOINTERFACE;
-}
-
-static ULONG WINAPI IDirect3DVertexShader9Impl_AddRef(LPDIRECT3DVERTEXSHADER9 iface) {
- IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
- ULONG ref = InterlockedIncrement(&This->ref);
-
- TRACE("%p increasing refcount to %u.\n", iface, ref);
-
- if (ref == 1)
- {
- IDirect3DDevice9Ex_AddRef(This->parentDevice);
- wined3d_mutex_lock();
- IWineD3DVertexShader_AddRef(This->wineD3DVertexShader);
- wined3d_mutex_unlock();
- }
-
- return ref;
-}
-
-static ULONG WINAPI IDirect3DVertexShader9Impl_Release(LPDIRECT3DVERTEXSHADER9 iface) {
- IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
- ULONG ref = InterlockedDecrement(&This->ref);
-
- TRACE("%p decreasing refcount to %u.\n", iface, ref);
-
- if (ref == 0) {
- IDirect3DDevice9Ex *parentDevice = This->parentDevice;
-
- wined3d_mutex_lock();
- IWineD3DVertexShader_Release(This->wineD3DVertexShader);
- wined3d_mutex_unlock();
-
- /* Release the device last, as it may cause the device to be destroyed. */
- IDirect3DDevice9Ex_Release(parentDevice);
- }
- return ref;
-}
-
-/* IDirect3DVertexShader9 Interface follow: */
-static HRESULT WINAPI IDirect3DVertexShader9Impl_GetDevice(IDirect3DVertexShader9 *iface, IDirect3DDevice9 **device)
-{
- IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
-
- TRACE("iface %p, device %p.\n", iface, device);
-
- *device = (IDirect3DDevice9 *)This->parentDevice;
- IDirect3DDevice9_AddRef(*device);
-
- TRACE("Returning device %p.\n", *device);
-
- return D3D_OK;
-}
-
-static HRESULT WINAPI IDirect3DVertexShader9Impl_GetFunction(LPDIRECT3DVERTEXSHADER9 iface, VOID* pData, UINT* pSizeOfData) {
- IDirect3DVertexShader9Impl *This = (IDirect3DVertexShader9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, data %p, data_size %p.\n", iface, pData, pSizeOfData);
-
- wined3d_mutex_lock();
- hr = IWineD3DVertexShader_GetFunction(This->wineD3DVertexShader, pData, pSizeOfData);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-
-static const IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl =
-{
- /* IUnknown */
- IDirect3DVertexShader9Impl_QueryInterface,
- IDirect3DVertexShader9Impl_AddRef,
- IDirect3DVertexShader9Impl_Release,
- /* IDirect3DVertexShader9 */
- IDirect3DVertexShader9Impl_GetDevice,
- IDirect3DVertexShader9Impl_GetFunction
-};
-
-static void STDMETHODCALLTYPE d3d9_vertexshader_wined3d_object_destroyed(void *parent)
-{
- HeapFree(GetProcessHeap(), 0, parent);
-}
-
-static const struct wined3d_parent_ops d3d9_vertexshader_wined3d_parent_ops =
-{
- d3d9_vertexshader_wined3d_object_destroyed,
-};
-
-HRESULT vertexshader_init(IDirect3DVertexShader9Impl *shader, IDirect3DDevice9Impl *device, const DWORD *byte_code)
-{
- HRESULT hr;
-
- shader->ref = 1;
- shader->lpVtbl = &Direct3DVertexShader9_Vtbl;
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_CreateVertexShader(device->WineD3DDevice, byte_code,
- NULL /* output signature */, &shader->wineD3DVertexShader,
- (IUnknown *)shader, &d3d9_vertexshader_wined3d_parent_ops);
- wined3d_mutex_unlock();
- if (FAILED(hr))
- {
- WARN("Failed to create wined3d vertex shader, hr %#x.\n", hr);
- return hr;
- }
-
- shader->parentDevice = (IDirect3DDevice9Ex *)device;
- IDirect3DDevice9Ex_AddRef(shader->parentDevice);
-
- return D3D_OK;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexShader9* pShader) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hrc = D3D_OK;
-
- TRACE("iface %p, shader %p.\n", iface, pShader);
-
- wined3d_mutex_lock();
- hrc = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, pShader==NULL?NULL:((IDirect3DVertexShader9Impl *)pShader)->wineD3DVertexShader);
- wined3d_mutex_unlock();
-
- TRACE("(%p) : returning hr(%u)\n", This, hrc);
- return hrc;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexShader9** ppShader) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- IWineD3DVertexShader *pShader;
- HRESULT hrc = D3D_OK;
-
- TRACE("iface %p, shader %p.\n", iface, ppShader);
-
- wined3d_mutex_lock();
- hrc = IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &pShader);
- if (SUCCEEDED(hrc))
- {
- if (pShader)
- {
- hrc = IWineD3DVertexShader_GetParent(pShader, (IUnknown **)ppShader);
- IWineD3DVertexShader_Release(pShader);
- }
- else
- {
- *ppShader = NULL;
- }
- }
- else
- {
- WARN("(%p) : Call to IWineD3DDevice_GetVertexShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
- }
- wined3d_mutex_unlock();
-
- TRACE("(%p) : returning %p\n", This, *ppShader);
- return hrc;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, register %u, data %p, count %u.\n",
- iface, Register, pConstantData, Vector4fCount);
-
- if(Register + Vector4fCount > D3D9_MAX_VERTEX_SHADER_CONSTANTF) {
- WARN("Trying to access %u constants, but d3d9 only supports %u\n",
- Register + Vector4fCount, D3D9_MAX_VERTEX_SHADER_CONSTANTF);
- return D3DERR_INVALIDCALL;
- }
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(LPDIRECT3DDEVICE9EX iface, UINT Register, float* pConstantData, UINT Vector4fCount) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, register %u, data %p, count %u.\n",
- iface, Register, pConstantData, Vector4fCount);
-
- if(Register + Vector4fCount > D3D9_MAX_VERTEX_SHADER_CONSTANTF) {
- WARN("Trying to access %u constants, but d3d9 only supports %u\n",
- Register + Vector4fCount, D3D9_MAX_VERTEX_SHADER_CONSTANTF);
- return D3DERR_INVALIDCALL;
- }
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, register %u, data %p, count %u.\n",
- iface, Register, pConstantData, Vector4iCount);
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_SetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT Register, int* pConstantData, UINT Vector4iCount) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, register %u, data %p, count %u.\n",
- iface, Register, pConstantData, Vector4iCount);
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_GetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, register %u, data %p, count %u.\n",
- iface, Register, pConstantData, BoolCount);
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_SetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
- wined3d_mutex_unlock();
-
- return hr;
-}
-
-HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT Register, BOOL* pConstantData, UINT BoolCount) {
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hr;
-
- TRACE("iface %p, register %u, data %p, count %u.\n",
- iface, Register, pConstantData, BoolCount);
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_GetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
- wined3d_mutex_unlock();
-
- return hr;
-}
static HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(LPDIRECT3DVOLUME9 iface, D3DVOLUME_DESC* pDesc) {
IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface;
- WINED3DVOLUME_DESC wined3ddesc;
- HRESULT hr;
+ WINED3DVOLUME_DESC wined3ddesc;
TRACE("iface %p, desc %p.\n", iface, pDesc);
wined3d_mutex_lock();
- hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
+ IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
wined3d_mutex_unlock();
- if (SUCCEEDED(hr))
- {
- 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;
- }
+ 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;
- return hr;
+ return D3D_OK;
}
static HRESULT WINAPI IDirect3DVolume9Impl_LockBox(LPDIRECT3DVOLUME9 iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
};
HRESULT volume_init(IDirect3DVolume9Impl *volume, IDirect3DDevice9Impl *device, UINT width, UINT height,
- UINT depth, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool)
+ UINT depth, DWORD usage, enum wined3d_format_id format, WINED3DPOOL pool)
{
HRESULT hr;
volume->ref = 1;
hr = IWineD3DDevice_CreateVolume(device->WineD3DDevice, width, height, depth, usage & WINED3DUSAGE_MASK,
- format, pool, &volume->wineD3DVolume, (IUnknown *)volume, &d3d9_volume_wined3d_parent_ops);
+ format, pool, volume, &d3d9_volume_wined3d_parent_ops, &volume->wineD3DVolume);
if (FAILED(hr))
{
WARN("Failed to create wined3d volume, hr %#x.\n", hr);
return hr;
}
-static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, IDirect3DVolume9** ppVolumeLevel) {
+static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(IDirect3DVolumeTexture9 *iface,
+ UINT Level, IDirect3DVolume9 **ppVolumeLevel)
+{
IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
- HRESULT hrc = D3D_OK;
IWineD3DVolume *myVolume = NULL;
+ HRESULT hr;
TRACE("iface %p, level %u, volume %p.\n", iface, Level, ppVolumeLevel);
wined3d_mutex_lock();
- hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
- if (hrc == D3D_OK && NULL != ppVolumeLevel) {
- IWineD3DVolumeTexture_GetParent(myVolume, (IUnknown **)ppVolumeLevel);
+ hr = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
+ if (SUCCEEDED(hr) && ppVolumeLevel)
+ {
+ *ppVolumeLevel = IWineD3DVolumeTexture_GetParent(myVolume);
+ IDirect3DVolumeTexture9_AddRef(*ppVolumeLevel);
IWineD3DVolumeTexture_Release(myVolume);
}
wined3d_mutex_unlock();
- return hrc;
+ return hr;
}
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_LockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateVolumeTexture(device->WineD3DDevice, width, height, depth, levels,
- usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool,
- &texture->wineD3DVolumeTexture, (IUnknown *)texture, &d3d9_volumetexture_wined3d_parent_ops);
+ usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool, texture,
+ &d3d9_volumetexture_wined3d_parent_ops, &texture->wineD3DVolumeTexture);
wined3d_mutex_unlock();
if (FAILED(hr))
{
*/
#include "config.h"
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define COBJMACROS
-
-#include "windef.h"
-#include "winbase.h"
-#include "wingdi.h"
-#include "ddraw.h"
-#include "winerror.h"
+#include "wine/port.h"
#include "ddraw_private.h"
-#include "wine/debug.h"
-
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/*****************************************************************************
static HRESULT WINAPI IDirectDrawClipperImpl_QueryInterface(
LPDIRECTDRAWCLIPPER iface, REFIID riid, LPVOID* ppvObj
) {
- if (IsEqualGUID(&IID_IUnknown, riid)
- || IsEqualGUID(&IID_IDirectDrawClipper, riid))
+
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppvObj);
+
+ if (IsEqualGUID(&IID_IDirectDrawClipper, riid)
+ || IsEqualGUID(&IID_IUnknown, riid))
{
IUnknown_AddRef(iface);
*ppvObj = iface;
return S_OK;
}
- else
- {
- return E_NOINTERFACE;
- }
+
+ return E_NOINTERFACE;
}
/*****************************************************************************
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
+ TRACE("%p increasing refcount to %u.\n", This, ref);
return ref;
}
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
- TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
+ TRACE("%p decreasing refcount to %u.\n", This, ref);
if (ref == 0)
{
) {
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
HRESULT hr;
- TRACE("(%p)->(%08x,%p)\n", This, dwFlags, hWnd);
+
+ TRACE("iface %p, flags %#x, window %p.\n", iface, dwFlags, hWnd);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DClipper_SetHWnd(This->wineD3DClipper,
{
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
HRESULT hr;
- TRACE("(%p,%p,%p,%p)\n", This, lpRect, lpClipList, lpdwSize);
+
+ TRACE("iface %p, rect %s, clip_list %p, clip_list_size %p.\n",
+ iface, wine_dbgstr_rect(lpRect), lpClipList, lpdwSize);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DClipper_GetClipList(This->wineD3DClipper,
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
HRESULT hr;
+ TRACE("iface %p, clip_list %p, flags %#x.\n", iface, lprgn, dwFlag);
+
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DClipper_SetClipList(This->wineD3DClipper,
lprgn,
) {
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
HRESULT hr;
- TRACE("(%p)->(%p)\n", This, hWndPtr);
+
+ TRACE("iface %p, window %p.\n", iface, hWndPtr);
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DClipper_GetHWnd(This->wineD3DClipper,
static HRESULT WINAPI IDirectDrawClipperImpl_Initialize(
LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD, DWORD dwFlags
) {
- IDirectDrawImpl* pOwner;
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
- TRACE("(%p)->(%p,0x%08x)\n", This, lpDD, dwFlags);
+
+ TRACE("iface %p, ddraw %p, flags %#x.\n", iface, lpDD, dwFlags);
EnterCriticalSection(&ddraw_cs);
- if (This->ddraw_owner != NULL)
+ if (This->initialized)
{
LeaveCriticalSection(&ddraw_cs);
return DDERR_ALREADYINITIALIZED;
}
- pOwner = lpDD ? ddraw_from_ddraw1(lpDD) : NULL;
- This->ddraw_owner = pOwner;
+ This->initialized = TRUE;
LeaveCriticalSection(&ddraw_cs);
return DD_OK;
static HRESULT WINAPI IDirectDrawClipperImpl_IsClipListChanged(
LPDIRECTDRAWCLIPPER iface, BOOL* lpbChanged
) {
- IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
- FIXME("(%p)->(%p),stub!\n",This,lpbChanged);
+ FIXME("iface %p, changed %p stub!\n", iface, lpbChanged);
/* XXX What is safest? */
*lpbChanged = FALSE;
/*****************************************************************************
* The VTable
*****************************************************************************/
-const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl =
+static const struct IDirectDrawClipperVtbl ddraw_clipper_vtbl =
{
IDirectDrawClipperImpl_QueryInterface,
IDirectDrawClipperImpl_AddRef,
IDirectDrawClipperImpl_SetClipList,
IDirectDrawClipperImpl_SetHwnd
};
+
+HRESULT ddraw_clipper_init(IDirectDrawClipperImpl *clipper)
+{
+ clipper->lpVtbl = &ddraw_clipper_vtbl;
+ clipper->ref = 1;
+ clipper->wineD3DClipper = pWineDirect3DCreateClipper();
+ if (!clipper->wineD3DClipper)
+ {
+ WARN("Failed to create wined3d clipper.\n");
+ return E_OUTOFMEMORY;
+ }
+
+ return DD_OK;
+}
#include "config.h"
#include "wine/port.h"
-#include <assert.h>
-#include <stdarg.h>
-#include <string.h>
-#include <stdlib.h>
-
-#define COBJMACROS
-#define NONAMELESSUNION
-
-#include "windef.h"
-#include "winbase.h"
-#include "winerror.h"
-#include "wingdi.h"
-#include "wine/exception.h"
-
-#include "ddraw.h"
-#include "d3d.h"
-
#include "ddraw_private.h"
-#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
-static BOOL IDirectDrawImpl_DDSD_Match(const DDSURFACEDESC2* requested, const DDSURFACEDESC2* provided);
-static HRESULT IDirectDrawImpl_AttachD3DDevice(IDirectDrawImpl *This, IDirectDrawSurfaceImpl *primary);
-static HRESULT IDirectDrawImpl_CreateNewSurface(IDirectDrawImpl *This, DDSURFACEDESC2 *pDDSD, IDirectDrawSurfaceImpl **ppSurf, UINT level);
-static HRESULT IDirectDrawImpl_CreateGDISwapChain(IDirectDrawImpl *This, IDirectDrawSurfaceImpl *primary);
-
/* Device identifier. Don't relay it to WineD3D */
static const DDDEVICEIDENTIFIER2 deviceidentifier =
{
ddraw_null_wined3d_object_destroyed,
};
+static inline IDirectDrawImpl *ddraw_from_ddraw1(IDirectDraw *iface)
+{
+ return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw_vtbl));
+}
+
+static inline IDirectDrawImpl *ddraw_from_ddraw2(IDirectDraw2 *iface)
+{
+ return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw2_vtbl));
+}
+
+static inline IDirectDrawImpl *ddraw_from_ddraw3(IDirectDraw3 *iface)
+{
+ return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw3_vtbl));
+}
+
+static inline IDirectDrawImpl *ddraw_from_ddraw4(IDirectDraw4 *iface)
+{
+ return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw4_vtbl));
+}
+
/*****************************************************************************
* IUnknown Methods
*****************************************************************************/
* E_NOINTERFACE if the requested interface wasn't found
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_QueryInterface(IDirectDraw7 *iface,
- REFIID refiid,
- void **obj)
+static HRESULT WINAPI ddraw7_QueryInterface(IDirectDraw7 *iface, REFIID refiid, void **obj)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
- TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(refiid), obj);
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(refiid), obj);
/* Can change surface impl type */
EnterCriticalSection(&ddraw_cs);
return S_OK;
}
+static HRESULT WINAPI ddraw4_QueryInterface(IDirectDraw4 *iface, REFIID riid, void **object)
+{
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+
+ return ddraw7_QueryInterface((IDirectDraw7 *)ddraw_from_ddraw4(iface), riid, object);
+}
+
+static HRESULT WINAPI ddraw3_QueryInterface(IDirectDraw3 *iface, REFIID riid, void **object)
+{
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+
+ return ddraw7_QueryInterface((IDirectDraw7 *)ddraw_from_ddraw3(iface), riid, object);
+}
+
+static HRESULT WINAPI ddraw2_QueryInterface(IDirectDraw2 *iface, REFIID riid, void **object)
+{
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+
+ return ddraw7_QueryInterface((IDirectDraw7 *)ddraw_from_ddraw2(iface), riid, object);
+}
+
+static HRESULT WINAPI ddraw1_QueryInterface(IDirectDraw *iface, REFIID riid, void **object)
+{
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+
+ return ddraw7_QueryInterface((IDirectDraw7 *)ddraw_from_ddraw1(iface), riid, object);
+}
+
+static HRESULT WINAPI d3d7_QueryInterface(IDirect3D7 *iface, REFIID riid, void **object)
+{
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+
+ return ddraw7_QueryInterface((IDirectDraw7 *)ddraw_from_d3d7(iface), riid, object);
+}
+
+static HRESULT WINAPI d3d3_QueryInterface(IDirect3D3 *iface, REFIID riid, void **object)
+{
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+
+ return ddraw7_QueryInterface((IDirectDraw7 *)ddraw_from_d3d3(iface), riid, object);
+}
+
+static HRESULT WINAPI d3d2_QueryInterface(IDirect3D2 *iface, REFIID riid, void **object)
+{
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+
+ return ddraw7_QueryInterface((IDirectDraw7 *)ddraw_from_d3d2(iface), riid, object);
+}
+
+static HRESULT WINAPI d3d1_QueryInterface(IDirect3D *iface, REFIID riid, void **object)
+{
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+
+ return ddraw7_QueryInterface((IDirectDraw7 *)ddraw_from_d3d1(iface), riid, object);
+}
+
/*****************************************************************************
* IDirectDraw7::AddRef
*
* Returns: The new refcount
*
*****************************************************************************/
-static ULONG WINAPI
-IDirectDrawImpl_AddRef(IDirectDraw7 *iface)
+static ULONG WINAPI ddraw7_AddRef(IDirectDraw7 *iface)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref7);
- TRACE("(%p) : incrementing IDirectDraw7 refcount from %u.\n", This, ref -1);
+ TRACE("%p increasing refcount to %u.\n", This, ref);
if(ref == 1) InterlockedIncrement(&This->numIfaces);
return ref;
}
+static ULONG WINAPI ddraw4_AddRef(IDirectDraw4 *iface)
+{
+ IDirectDrawImpl *ddraw = ddraw_from_ddraw4(iface);
+ ULONG ref = InterlockedIncrement(&ddraw->ref4);
+
+ TRACE("%p increasing refcount to %u.\n", ddraw, ref);
+
+ if (ref == 1) InterlockedIncrement(&ddraw->numIfaces);
+
+ return ref;
+}
+
+static ULONG WINAPI ddraw3_AddRef(IDirectDraw3 *iface)
+{
+ IDirectDrawImpl *ddraw = ddraw_from_ddraw3(iface);
+ ULONG ref = InterlockedIncrement(&ddraw->ref3);
+
+ TRACE("%p increasing refcount to %u.\n", ddraw, ref);
+
+ if (ref == 1) InterlockedIncrement(&ddraw->numIfaces);
+
+ return ref;
+}
+
+static ULONG WINAPI ddraw2_AddRef(IDirectDraw2 *iface)
+{
+ IDirectDrawImpl *ddraw = ddraw_from_ddraw2(iface);
+ ULONG ref = InterlockedIncrement(&ddraw->ref2);
+
+ TRACE("%p increasing refcount to %u.\n", ddraw, ref);
+
+ if (ref == 1) InterlockedIncrement(&ddraw->numIfaces);
+
+ return ref;
+}
+
+static ULONG WINAPI ddraw1_AddRef(IDirectDraw *iface)
+{
+ IDirectDrawImpl *ddraw = ddraw_from_ddraw1(iface);
+ ULONG ref = InterlockedIncrement(&ddraw->ref1);
+
+ TRACE("%p increasing refcount to %u.\n", ddraw, ref);
+
+ if (ref == 1) InterlockedIncrement(&ddraw->numIfaces);
+
+ return ref;
+}
+
+static ULONG WINAPI d3d7_AddRef(IDirect3D7 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw7_AddRef((IDirectDraw7 *)ddraw_from_d3d7(iface));
+}
+
+static ULONG WINAPI d3d3_AddRef(IDirect3D3 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw1_AddRef((IDirectDraw *)&ddraw_from_d3d3(iface)->IDirectDraw_vtbl);
+}
+
+static ULONG WINAPI d3d2_AddRef(IDirect3D2 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw1_AddRef((IDirectDraw *)&ddraw_from_d3d2(iface)->IDirectDraw_vtbl);
+}
+
+static ULONG WINAPI d3d1_AddRef(IDirect3D *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw1_AddRef((IDirectDraw *)&ddraw_from_d3d1(iface)->IDirectDraw_vtbl);
+}
+
/*****************************************************************************
- * IDirectDrawImpl_Destroy
+ * ddraw_destroy
*
* Destroys a ddraw object if all refcounts are 0. This is to share code
* between the IDirectDrawX::Release functions
* This: DirectDraw object to destroy
*
*****************************************************************************/
-void
-IDirectDrawImpl_Destroy(IDirectDrawImpl *This)
+static void ddraw_destroy(IDirectDrawImpl *This)
{
IDirectDraw7_SetCooperativeLevel((IDirectDraw7 *)This, NULL, DDSCL_NORMAL);
IDirectDraw7_RestoreDisplayMode((IDirectDraw7 *)This);
This->devicewindow = 0;
}
- /* Unregister the window class */
- UnregisterClassA(This->classname, 0);
-
EnterCriticalSection(&ddraw_cs);
list_remove(&This->ddraw_list_entry);
LeaveCriticalSection(&ddraw_cs);
*
* Returns: The new refcount
*****************************************************************************/
-static ULONG WINAPI
-IDirectDrawImpl_Release(IDirectDraw7 *iface)
+static ULONG WINAPI ddraw7_Release(IDirectDraw7 *iface)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref7);
- TRACE("(%p)->() decrementing IDirectDraw7 refcount from %u.\n", This, ref +1);
+ TRACE("%p decreasing refcount to %u.\n", This, ref);
- if(ref == 0)
- {
- ULONG ifacecount = InterlockedDecrement(&This->numIfaces);
- if(ifacecount == 0) IDirectDrawImpl_Destroy(This);
- }
+ if (!ref && !InterlockedDecrement(&This->numIfaces))
+ ddraw_destroy(This);
+
+ return ref;
+}
+
+static ULONG WINAPI ddraw4_Release(IDirectDraw4 *iface)
+{
+ IDirectDrawImpl *ddraw = ddraw_from_ddraw4(iface);
+ ULONG ref = InterlockedDecrement(&ddraw->ref4);
+
+ TRACE("%p decreasing refcount to %u.\n", ddraw, ref);
+
+ if (!ref && !InterlockedDecrement(&ddraw->numIfaces))
+ ddraw_destroy(ddraw);
+
+ return ref;
+}
+
+static ULONG WINAPI ddraw3_Release(IDirectDraw3 *iface)
+{
+ IDirectDrawImpl *ddraw = ddraw_from_ddraw3(iface);
+ ULONG ref = InterlockedDecrement(&ddraw->ref3);
+
+ TRACE("%p decreasing refcount to %u.\n", ddraw, ref);
+
+ if (!ref && !InterlockedDecrement(&ddraw->numIfaces))
+ ddraw_destroy(ddraw);
+
+ return ref;
+}
+
+static ULONG WINAPI ddraw2_Release(IDirectDraw2 *iface)
+{
+ IDirectDrawImpl *ddraw = ddraw_from_ddraw2(iface);
+ ULONG ref = InterlockedDecrement(&ddraw->ref2);
+
+ TRACE("%p decreasing refcount to %u.\n", ddraw, ref);
+
+ if (!ref && !InterlockedDecrement(&ddraw->numIfaces))
+ ddraw_destroy(ddraw);
+
+ return ref;
+}
+
+static ULONG WINAPI ddraw1_Release(IDirectDraw *iface)
+{
+ IDirectDrawImpl *ddraw = ddraw_from_ddraw1(iface);
+ ULONG ref = InterlockedDecrement(&ddraw->ref1);
+
+ TRACE("%p decreasing refcount to %u.\n", ddraw, ref);
+
+ if (!ref && !InterlockedDecrement(&ddraw->numIfaces))
+ ddraw_destroy(ddraw);
return ref;
}
+static ULONG WINAPI d3d7_Release(IDirect3D7 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw7_Release((IDirectDraw7 *)ddraw_from_d3d7(iface));
+}
+
+static ULONG WINAPI d3d3_Release(IDirect3D3 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw1_Release((IDirectDraw *)&ddraw_from_d3d3(iface)->IDirectDraw_vtbl);
+}
+
+static ULONG WINAPI d3d2_Release(IDirect3D2 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw1_Release((IDirectDraw *)&ddraw_from_d3d2(iface)->IDirectDraw_vtbl);
+}
+
+static ULONG WINAPI d3d1_Release(IDirect3D *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw1_Release((IDirectDraw *)&ddraw_from_d3d1(iface)->IDirectDraw_vtbl);
+}
+
/*****************************************************************************
* IDirectDraw methods
*****************************************************************************/
* DDSCL_SETDEVICEWINDOW: Sets a window specially used for rendering (I don't
* expect any difference to a normal window for wine)
* DDSCL_CREATEDEVICEWINDOW: Tells ddraw to create its own window for
- * rendering (Possible test case: Half-life)
+ * rendering (Possible test case: Half-Life)
*
* Unsure about these: DDSCL_FPUSETUP DDSCL_FPURESERVE
*
* (Probably others too, have to investigate)
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_SetCooperativeLevel(IDirectDraw7 *iface,
- HWND hwnd,
- DWORD cooplevel)
+static HRESULT WINAPI ddraw7_SetCooperativeLevel(IDirectDraw7 *iface, HWND hwnd, DWORD cooplevel)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
HWND window;
- TRACE("(%p)->(%p,%08x)\n",This,hwnd,cooplevel);
+ TRACE("iface %p, window %p, flags %#x.\n", iface, hwnd, cooplevel);
DDRAW_dump_cooperativelevel(cooplevel);
EnterCriticalSection(&ddraw_cs);
/* Don't create a device window if a focus window is set */
if( !(This->focuswindow) )
{
- HWND devicewindow = CreateWindowExA(0, This->classname, "DDraw device window",
- WS_POPUP, 0, 0,
- GetSystemMetrics(SM_CXSCREEN),
- GetSystemMetrics(SM_CYSCREEN),
- NULL, NULL, GetModuleHandleA(0), NULL);
+ HWND devicewindow = CreateWindowExA(0, DDRAW_WINDOW_CLASS_NAME, "DDraw device window",
+ WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
+ NULL, NULL, NULL, NULL);
+ if (!devicewindow)
+ {
+ ERR("Failed to create window, last error %#x.\n", GetLastError());
+ LeaveCriticalSection(&ddraw_cs);
+ return E_FAIL;
+ }
ShowWindow(devicewindow, SW_SHOW); /* Just to be sure */
TRACE("(%p) Created a DDraw device window. HWND=%p\n", This, devicewindow);
return DD_OK;
}
+static HRESULT WINAPI ddraw4_SetCooperativeLevel(IDirectDraw4 *iface, HWND window, DWORD flags)
+{
+ TRACE("iface %p, window %p, flags %#x.\n", iface, window, flags);
+
+ return ddraw7_SetCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw4(iface), window, flags);
+}
+
+static HRESULT WINAPI ddraw3_SetCooperativeLevel(IDirectDraw3 *iface, HWND window, DWORD flags)
+{
+ TRACE("iface %p, window %p, flags %#x.\n", iface, window, flags);
+
+ return ddraw7_SetCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw3(iface), window, flags);
+}
+
+static HRESULT WINAPI ddraw2_SetCooperativeLevel(IDirectDraw2 *iface, HWND window, DWORD flags)
+{
+ TRACE("iface %p, window %p, flags %#x.\n", iface, window, flags);
+
+ return ddraw7_SetCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw2(iface), window, flags);
+}
+
+static HRESULT WINAPI ddraw1_SetCooperativeLevel(IDirectDraw *iface, HWND window, DWORD flags)
+{
+ TRACE("iface %p, window %p, flags %#x.\n", iface, window, flags);
+
+ return ddraw7_SetCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw1(iface), window, flags);
+}
+
/*****************************************************************************
*
* Helper function for SetDisplayMode and RestoreDisplayMode
*
* Implements DirectDraw's SetDisplayMode, but ignores the value of
* ForceRefreshRate, since it is already handled by
- * IDirectDrawImpl_SetDisplayMode. RestoreDisplayMode can use this function
+ * ddraw7_SetDisplayMode. RestoreDisplayMode can use this function
* without worrying that ForceRefreshRate will override the refresh rate. For
* argument and return value documentation, see
- * IDirectDrawImpl_SetDisplayMode.
+ * ddraw7_SetDisplayMode.
*
*****************************************************************************/
-static HRESULT
-IDirectDrawImpl_SetDisplayModeNoOverride(IDirectDraw7 *iface,
- DWORD Width,
- DWORD Height,
- DWORD BPP,
- DWORD RefreshRate,
- DWORD Flags)
+static HRESULT ddraw_set_display_mode(IDirectDraw7 *iface, DWORD Width, DWORD Height,
+ DWORD BPP, DWORD RefreshRate, DWORD Flags)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
WINED3DDISPLAYMODE Mode;
HRESULT hr;
- TRACE("(%p)->(%d,%d,%d,%d,%x): Relay!\n", This, Width, Height, BPP, RefreshRate, Flags);
+
+ TRACE("iface %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n",
+ iface, Width, Height, BPP, RefreshRate, Flags);
EnterCriticalSection(&ddraw_cs);
if( !Width || !Height )
{
- ERR("Width=%d, Height=%d, what to do?\n", Width, Height);
+ ERR("Width %u, Height %u, what to do?\n", Width, Height);
/* It looks like Need for Speed Porsche Unleashed expects DD_OK here */
LeaveCriticalSection(&ddraw_cs);
return DD_OK;
* DD_OK on success
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_SetDisplayMode(IDirectDraw7 *iface,
- DWORD Width,
- DWORD Height,
- DWORD BPP,
- DWORD RefreshRate,
- DWORD Flags)
+static HRESULT WINAPI ddraw7_SetDisplayMode(IDirectDraw7 *iface, DWORD Width, DWORD Height,
+ DWORD BPP, DWORD RefreshRate, DWORD Flags)
{
+ TRACE("iface %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n",
+ iface, Width, Height, BPP, RefreshRate, Flags);
+
if (force_refresh_rate != 0)
{
- TRACE("ForceRefreshRate overriding passed-in refresh rate (%d Hz) to %d Hz\n", RefreshRate, force_refresh_rate);
+ TRACE("ForceRefreshRate overriding passed-in refresh rate (%u Hz) to %u Hz\n",
+ RefreshRate, force_refresh_rate);
RefreshRate = force_refresh_rate;
}
- return IDirectDrawImpl_SetDisplayModeNoOverride(iface, Width, Height, BPP,
- RefreshRate, Flags);
+ return ddraw_set_display_mode(iface, Width, Height, BPP, RefreshRate, Flags);
+}
+
+static HRESULT WINAPI ddraw4_SetDisplayMode(IDirectDraw4 *iface,
+ DWORD width, DWORD height, DWORD bpp, DWORD refresh_rate, DWORD flags)
+{
+ 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);
+}
+
+static HRESULT WINAPI ddraw3_SetDisplayMode(IDirectDraw3 *iface,
+ DWORD width, DWORD height, DWORD bpp, DWORD refresh_rate, DWORD flags)
+{
+ 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);
+}
+
+static HRESULT WINAPI ddraw2_SetDisplayMode(IDirectDraw2 *iface,
+ DWORD width, DWORD height, DWORD bpp, DWORD refresh_rate, DWORD flags)
+{
+ 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);
+}
+
+static HRESULT WINAPI ddraw1_SetDisplayMode(IDirectDraw *iface, DWORD width, DWORD height, DWORD bpp)
+{
+ 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);
}
/*****************************************************************************
* DDERR_NOEXCLUSIVE mode if the device isn't in fullscreen mode
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_RestoreDisplayMode(IDirectDraw7 *iface)
+static HRESULT WINAPI ddraw7_RestoreDisplayMode(IDirectDraw7 *iface)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
- TRACE("(%p)\n", This);
- return IDirectDrawImpl_SetDisplayModeNoOverride(iface,
- This->orig_width, This->orig_height, This->orig_bpp, 0, 0);
+ TRACE("iface %p.\n", iface);
+
+ return ddraw_set_display_mode(iface, This->orig_width, This->orig_height, This->orig_bpp, 0, 0);
+}
+
+static HRESULT WINAPI ddraw4_RestoreDisplayMode(IDirectDraw4 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw7_RestoreDisplayMode((IDirectDraw7 *)ddraw_from_ddraw4(iface));
+}
+
+static HRESULT WINAPI ddraw3_RestoreDisplayMode(IDirectDraw3 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw7_RestoreDisplayMode((IDirectDraw7 *)ddraw_from_ddraw3(iface));
+}
+
+static HRESULT WINAPI ddraw2_RestoreDisplayMode(IDirectDraw2 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw7_RestoreDisplayMode((IDirectDraw7 *)ddraw_from_ddraw2(iface));
+}
+
+static HRESULT WINAPI ddraw1_RestoreDisplayMode(IDirectDraw *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw7_RestoreDisplayMode((IDirectDraw7 *)ddraw_from_ddraw1(iface));
}
/*****************************************************************************
* This implementation returns DD_OK only
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_GetCaps(IDirectDraw7 *iface,
- DDCAPS *DriverCaps,
- DDCAPS *HELCaps)
+static HRESULT WINAPI ddraw7_GetCaps(IDirectDraw7 *iface, DDCAPS *DriverCaps, DDCAPS *HELCaps)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
DDCAPS caps;
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);
+
/* One structure must be != NULL */
if( (!DriverCaps) && (!HELCaps) )
{
- ERR("(%p) Invalid params to IDirectDrawImpl_GetCaps\n", This);
+ ERR("(%p) Invalid params to ddraw7_GetCaps\n", This);
return DDERR_INVALIDPARAMS;
}
return DD_OK;
}
+static HRESULT WINAPI ddraw4_GetCaps(IDirectDraw4 *iface, DDCAPS *driver_caps, DDCAPS *hel_caps)
+{
+ 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);
+}
+
+static HRESULT WINAPI ddraw3_GetCaps(IDirectDraw3 *iface, DDCAPS *driver_caps, DDCAPS *hel_caps)
+{
+ 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);
+}
+
+static HRESULT WINAPI ddraw2_GetCaps(IDirectDraw2 *iface, DDCAPS *driver_caps, DDCAPS *hel_caps)
+{
+ 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);
+}
+
+static HRESULT WINAPI ddraw1_GetCaps(IDirectDraw *iface, DDCAPS *driver_caps, DDCAPS *hel_caps)
+{
+ 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);
+}
+
/*****************************************************************************
* IDirectDraw7::Compact
*
* DD_OK, but this is unchecked
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_Compact(IDirectDraw7 *iface)
+static HRESULT WINAPI ddraw7_Compact(IDirectDraw7 *iface)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
- TRACE("(%p)\n", This);
+ TRACE("iface %p.\n", iface);
return DD_OK;
}
+static HRESULT WINAPI ddraw4_Compact(IDirectDraw4 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw7_Compact((IDirectDraw7 *)ddraw_from_ddraw4(iface));
+}
+
+static HRESULT WINAPI ddraw3_Compact(IDirectDraw3 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw7_Compact((IDirectDraw7 *)ddraw_from_ddraw3(iface));
+}
+
+static HRESULT WINAPI ddraw2_Compact(IDirectDraw2 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw7_Compact((IDirectDraw7 *)ddraw_from_ddraw2(iface));
+}
+
+static HRESULT WINAPI ddraw1_Compact(IDirectDraw *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw7_Compact((IDirectDraw7 *)ddraw_from_ddraw1(iface));
+}
+
/*****************************************************************************
* IDirectDraw7::GetDisplayMode
*
* DD_OK
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_GetDisplayMode(IDirectDraw7 *iface,
- DDSURFACEDESC2 *DDSD)
+static HRESULT WINAPI ddraw7_GetDisplayMode(IDirectDraw7 *iface, DDSURFACEDESC2 *DDSD)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
HRESULT hr;
WINED3DDISPLAYMODE Mode;
DWORD Size;
- TRACE("(%p)->(%p): Relay\n", This, DDSD);
+
+ TRACE("iface %p, surface_desc %p.\n", iface, DDSD);
EnterCriticalSection(&ddraw_cs);
/* This seems sane */
return DD_OK;
}
-/*****************************************************************************
- * IDirectDraw7::GetFourCCCodes
- *
- * Returns an array of supported FourCC codes.
- *
- * Exists in Version 1, 2, 4 and 7
- *
- * Params:
+static HRESULT WINAPI ddraw4_GetDisplayMode(IDirectDraw4 *iface, DDSURFACEDESC2 *surface_desc)
+{
+ TRACE("iface %p, surface_desc %p.\n", iface, surface_desc);
+
+ return ddraw7_GetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw4(iface), surface_desc);
+}
+
+static HRESULT WINAPI ddraw3_GetDisplayMode(IDirectDraw3 *iface, DDSURFACEDESC *surface_desc)
+{
+ TRACE("iface %p, surface_desc %p.\n", iface, surface_desc);
+
+ return ddraw7_GetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw3(iface), (DDSURFACEDESC2 *)surface_desc);
+}
+
+static HRESULT WINAPI ddraw2_GetDisplayMode(IDirectDraw2 *iface, DDSURFACEDESC *surface_desc)
+{
+ TRACE("iface %p, surface_desc %p.\n", iface, surface_desc);
+
+ return ddraw7_GetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw2(iface), (DDSURFACEDESC2 *)surface_desc);
+}
+
+static HRESULT WINAPI ddraw1_GetDisplayMode(IDirectDraw *iface, DDSURFACEDESC *surface_desc)
+{
+ TRACE("iface %p, surface_desc %p.\n", iface, surface_desc);
+
+ return ddraw7_GetDisplayMode((IDirectDraw7 *)ddraw_from_ddraw1(iface), (DDSURFACEDESC2 *)surface_desc);
+}
+
+/*****************************************************************************
+ * IDirectDraw7::GetFourCCCodes
+ *
+ * Returns an array of supported FourCC codes.
+ *
+ * Exists in Version 1, 2, 4 and 7
+ *
+ * Params:
* NumCodes: Contains the number of Codes that Codes can carry. Returns the number
* of enumerated codes
* Codes: Pointer to an array of DWORDs where the supported codes are written
* Always returns DD_OK, as it's a stub for now
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_GetFourCCCodes(IDirectDraw7 *iface,
- DWORD *NumCodes, DWORD *Codes)
+static HRESULT WINAPI ddraw7_GetFourCCCodes(IDirectDraw7 *iface, DWORD *NumCodes, DWORD *Codes)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
- WINED3DFORMAT formats[] = {
+ static const enum wined3d_format_id formats[] =
+ {
WINED3DFMT_YUY2, WINED3DFMT_UYVY, WINED3DFMT_YV12,
WINED3DFMT_DXT1, WINED3DFMT_DXT2, WINED3DFMT_DXT3, WINED3DFMT_DXT4, WINED3DFMT_DXT5,
WINED3DFMT_ATI2N, WINED3DFMT_NVHU, WINED3DFMT_NVHS
HRESULT hr;
WINED3DDISPLAYMODE d3ddm;
WINED3DSURFTYPE type = This->ImplType;
- TRACE("(%p)->(%p, %p)\n", This, NumCodes, Codes);
+
+ TRACE("iface %p, codes_count %p, codes %p.\n", iface, NumCodes, Codes);
IWineD3DDevice_GetDisplayMode(This->wineD3DDevice,
0 /* swapchain 0 */,
return DD_OK;
}
+static HRESULT WINAPI ddraw4_GetFourCCCodes(IDirectDraw4 *iface, DWORD *codes_count, DWORD *codes)
+{
+ TRACE("iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
+
+ return ddraw7_GetFourCCCodes((IDirectDraw7 *)ddraw_from_ddraw4(iface), codes_count, codes);
+}
+
+static HRESULT WINAPI ddraw3_GetFourCCCodes(IDirectDraw3 *iface, DWORD *codes_count, DWORD *codes)
+{
+ TRACE("iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
+
+ return ddraw7_GetFourCCCodes((IDirectDraw7 *)ddraw_from_ddraw3(iface), codes_count, codes);
+}
+
+static HRESULT WINAPI ddraw2_GetFourCCCodes(IDirectDraw2 *iface, DWORD *codes_count, DWORD *codes)
+{
+ TRACE("iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
+
+ return ddraw7_GetFourCCCodes((IDirectDraw7 *)ddraw_from_ddraw2(iface), codes_count, codes);
+}
+
+static HRESULT WINAPI ddraw1_GetFourCCCodes(IDirectDraw *iface, DWORD *codes_count, DWORD *codes)
+{
+ TRACE("iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
+
+ return ddraw7_GetFourCCCodes((IDirectDraw7 *)ddraw_from_ddraw1(iface), codes_count, codes);
+}
+
/*****************************************************************************
* IDirectDraw7::GetMonitorFrequency
*
* Always returns DD_OK
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_GetMonitorFrequency(IDirectDraw7 *iface,
- DWORD *Freq)
+static HRESULT WINAPI ddraw7_GetMonitorFrequency(IDirectDraw7 *iface, DWORD *Freq)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
- TRACE("(%p)->(%p)\n", This, Freq);
+ FIXME("iface %p, frequency %p stub!\n", iface, Freq);
/* Ideally this should be in WineD3D, as it concerns the screen setup,
* but for now this should make the games happy
return DD_OK;
}
+static HRESULT WINAPI ddraw4_GetMonitorFrequency(IDirectDraw4 *iface, DWORD *frequency)
+{
+ TRACE("iface %p, frequency %p.\n", iface, frequency);
+
+ return ddraw7_GetMonitorFrequency((IDirectDraw7 *)ddraw_from_ddraw4(iface), frequency);
+}
+
+static HRESULT WINAPI ddraw3_GetMonitorFrequency(IDirectDraw3 *iface, DWORD *frequency)
+{
+ TRACE("iface %p, frequency %p.\n", iface, frequency);
+
+ return ddraw7_GetMonitorFrequency((IDirectDraw7 *)ddraw_from_ddraw3(iface), frequency);
+}
+
+static HRESULT WINAPI ddraw2_GetMonitorFrequency(IDirectDraw2 *iface, DWORD *frequency)
+{
+ TRACE("iface %p, frequency %p.\n", iface, frequency);
+
+ return ddraw7_GetMonitorFrequency((IDirectDraw7 *)ddraw_from_ddraw2(iface), frequency);
+}
+
+static HRESULT WINAPI ddraw1_GetMonitorFrequency(IDirectDraw *iface, DWORD *frequency)
+{
+ TRACE("iface %p, frequency %p.\n", iface, frequency);
+
+ return ddraw7_GetMonitorFrequency((IDirectDraw7 *)ddraw_from_ddraw1(iface), frequency);
+}
+
/*****************************************************************************
* IDirectDraw7::GetVerticalBlankStatus
*
* DDERR_INVALIDPARAMS if status is NULL
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_GetVerticalBlankStatus(IDirectDraw7 *iface,
- BOOL *status)
+static HRESULT WINAPI ddraw7_GetVerticalBlankStatus(IDirectDraw7 *iface, BOOL *status)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
- TRACE("(%p)->(%p)\n", This, status);
+
+ TRACE("iface %p, status %p.\n", iface, status);
/* This looks sane, the MSDN suggests it too */
EnterCriticalSection(&ddraw_cs);
return DD_OK;
}
+static HRESULT WINAPI ddraw4_GetVerticalBlankStatus(IDirectDraw4 *iface, BOOL *status)
+{
+ TRACE("iface %p, status %p.\n", iface, status);
+
+ return ddraw7_GetVerticalBlankStatus((IDirectDraw7 *)ddraw_from_ddraw4(iface), status);
+}
+
+static HRESULT WINAPI ddraw3_GetVerticalBlankStatus(IDirectDraw3 *iface, BOOL *status)
+{
+ TRACE("iface %p, status %p.\n", iface, status);
+
+ return ddraw7_GetVerticalBlankStatus((IDirectDraw7 *)ddraw_from_ddraw3(iface), status);
+}
+
+static HRESULT WINAPI ddraw2_GetVerticalBlankStatus(IDirectDraw2 *iface, BOOL *status)
+{
+ TRACE("iface %p, status %p.\n", iface, status);
+
+ return ddraw7_GetVerticalBlankStatus((IDirectDraw7 *)ddraw_from_ddraw2(iface), status);
+}
+
+static HRESULT WINAPI ddraw1_GetVerticalBlankStatus(IDirectDraw *iface, BOOL *status)
+{
+ TRACE("iface %p, status %p.\n", iface, status);
+
+ return ddraw7_GetVerticalBlankStatus((IDirectDraw7 *)ddraw_from_ddraw1(iface), status);
+}
+
/*****************************************************************************
* IDirectDraw7::GetAvailableVidMem
*
* DDERR_INVALIDPARAMS of free and total are NULL
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_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;
- TRACE("(%p)->(%p, %p, %p)\n", This, Caps, total, free);
+
+ TRACE("iface %p, caps %p, total %p, free %p.\n", iface, Caps, total, free);
if(TRACE_ON(ddraw))
{
return DD_OK;
}
+static HRESULT WINAPI ddraw4_GetAvailableVidMem(IDirectDraw4 *iface,
+ DDSCAPS2 *caps, DWORD *total, DWORD *free)
+{
+ 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);
+}
+
+static HRESULT WINAPI ddraw3_GetAvailableVidMem(IDirectDraw3 *iface,
+ DDSCAPS *caps, DWORD *total, DWORD *free)
+{
+ 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);
+}
+
+static HRESULT WINAPI ddraw2_GetAvailableVidMem(IDirectDraw2 *iface,
+ DDSCAPS *caps, DWORD *total, DWORD *free)
+{
+ 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);
+}
+
/*****************************************************************************
* IDirectDraw7::Initialize
*
* DDERR_ALREADYINITIALIZED on repeated calls
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_Initialize(IDirectDraw7 *iface,
- GUID *Guid)
+static HRESULT WINAPI ddraw7_Initialize(IDirectDraw7 *iface, GUID *Guid)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
- TRACE("(%p)->(%s): No-op\n", This, debugstr_guid(Guid));
+
+ TRACE("iface %p, guid %s.\n", iface, debugstr_guid(Guid));
if(This->initialized)
{
}
}
+static HRESULT WINAPI ddraw4_Initialize(IDirectDraw4 *iface, GUID *guid)
+{
+ TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
+
+ return ddraw7_Initialize((IDirectDraw7 *)ddraw_from_ddraw4(iface), guid);
+}
+
+static HRESULT WINAPI ddraw3_Initialize(IDirectDraw3 *iface, GUID *guid)
+{
+ TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
+
+ return ddraw7_Initialize((IDirectDraw7 *)ddraw_from_ddraw3(iface), guid);
+}
+
+static HRESULT WINAPI ddraw2_Initialize(IDirectDraw2 *iface, GUID *guid)
+{
+ TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
+
+ return ddraw7_Initialize((IDirectDraw7 *)ddraw_from_ddraw2(iface), guid);
+}
+
+static HRESULT WINAPI ddraw1_Initialize(IDirectDraw *iface, GUID *guid)
+{
+ TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
+
+ return ddraw7_Initialize((IDirectDraw7 *)ddraw_from_ddraw1(iface), guid);
+}
+
+static HRESULT WINAPI d3d1_Initialize(IDirect3D *iface, REFIID riid)
+{
+ TRACE("iface %p, riid %s.\n", iface, debugstr_guid(riid));
+
+ return D3D_OK;
+}
+
/*****************************************************************************
* IDirectDraw7::FlipToGDISurface
*
* Always returns DD_OK
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_FlipToGDISurface(IDirectDraw7 *iface)
+static HRESULT WINAPI ddraw7_FlipToGDISurface(IDirectDraw7 *iface)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
- TRACE("(%p)\n", This);
+ FIXME("iface %p stub!\n", iface);
return DD_OK;
}
+static HRESULT WINAPI ddraw4_FlipToGDISurface(IDirectDraw4 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw7_FlipToGDISurface((IDirectDraw7 *)ddraw_from_ddraw4(iface));
+}
+
+static HRESULT WINAPI ddraw3_FlipToGDISurface(IDirectDraw3 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw7_FlipToGDISurface((IDirectDraw7 *)ddraw_from_ddraw3(iface));
+}
+
+static HRESULT WINAPI ddraw2_FlipToGDISurface(IDirectDraw2 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw7_FlipToGDISurface((IDirectDraw7 *)ddraw_from_ddraw2(iface));
+}
+
+static HRESULT WINAPI ddraw1_FlipToGDISurface(IDirectDraw *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw7_FlipToGDISurface((IDirectDraw7 *)ddraw_from_ddraw1(iface));
+}
+
/*****************************************************************************
* IDirectDraw7::WaitForVerticalBlank
*
* Always returns DD_OK
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_WaitForVerticalBlank(IDirectDraw7 *iface,
- DWORD Flags,
- HANDLE h)
+static HRESULT WINAPI ddraw7_WaitForVerticalBlank(IDirectDraw7 *iface, DWORD Flags, HANDLE event)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
- static BOOL hide = FALSE;
+ static BOOL hide;
+
+ TRACE("iface %p, flags %#x, event %p.\n", iface, Flags, event);
/* This function is called often, so print the fixme only once */
if(!hide)
{
- FIXME("(%p)->(%x,%p): Stub\n", This, Flags, h);
+ FIXME("iface %p, flags %#x, event %p stub!\n", iface, Flags, event);
hide = TRUE;
}
return DD_OK;
}
+static HRESULT WINAPI ddraw4_WaitForVerticalBlank(IDirectDraw4 *iface, DWORD flags, HANDLE event)
+{
+ TRACE("iface %p, flags %#x, event %p.\n", iface, flags, event);
+
+ return ddraw7_WaitForVerticalBlank((IDirectDraw7 *)ddraw_from_ddraw4(iface), flags, event);
+}
+
+static HRESULT WINAPI ddraw3_WaitForVerticalBlank(IDirectDraw3 *iface, DWORD flags, HANDLE event)
+{
+ TRACE("iface %p, flags %#x, event %p.\n", iface, flags, event);
+
+ return ddraw7_WaitForVerticalBlank((IDirectDraw7 *)ddraw_from_ddraw3(iface), flags, event);
+}
+
+static HRESULT WINAPI ddraw2_WaitForVerticalBlank(IDirectDraw2 *iface, DWORD flags, HANDLE event)
+{
+ TRACE("iface %p, flags %#x, event %p.\n", iface, flags, event);
+
+ return ddraw7_WaitForVerticalBlank((IDirectDraw7 *)ddraw_from_ddraw2(iface), flags, event);
+}
+
+static HRESULT WINAPI ddraw1_WaitForVerticalBlank(IDirectDraw *iface, DWORD flags, HANDLE event)
+{
+ TRACE("iface %p, flags %#x, event %p.\n", iface, flags, event);
+
+ return ddraw7_WaitForVerticalBlank((IDirectDraw7 *)ddraw_from_ddraw1(iface), flags, event);
+}
+
/*****************************************************************************
* IDirectDraw7::GetScanLine
*
* Always returns DD_OK
*
*****************************************************************************/
-static HRESULT WINAPI IDirectDrawImpl_GetScanLine(IDirectDraw7 *iface, DWORD *Scanline)
+static HRESULT WINAPI ddraw7_GetScanLine(IDirectDraw7 *iface, DWORD *Scanline)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
static BOOL hide = FALSE;
WINED3DDISPLAYMODE Mode;
+ TRACE("iface %p, line %p.\n", iface, Scanline);
+
/* This function is called often, so print the fixme only once */
EnterCriticalSection(&ddraw_cs);
if(!hide)
{
- FIXME("(%p)->(%p): Semi-Stub\n", This, Scanline);
+ FIXME("iface %p, line %p partial stub!\n", iface, Scanline);
hide = TRUE;
}
return DD_OK;
}
+static HRESULT WINAPI ddraw4_GetScanLine(IDirectDraw4 *iface, DWORD *line)
+{
+ TRACE("iface %p, line %p.\n", iface, line);
+
+ return ddraw7_GetScanLine((IDirectDraw7 *)ddraw_from_ddraw4(iface), line);
+}
+
+static HRESULT WINAPI ddraw3_GetScanLine(IDirectDraw3 *iface, DWORD *line)
+{
+ TRACE("iface %p, line %p.\n", iface, line);
+
+ return ddraw7_GetScanLine((IDirectDraw7 *)ddraw_from_ddraw3(iface), line);
+}
+
+static HRESULT WINAPI ddraw2_GetScanLine(IDirectDraw2 *iface, DWORD *line)
+{
+ TRACE("iface %p, line %p.\n", iface, line);
+
+ return ddraw7_GetScanLine((IDirectDraw7 *)ddraw_from_ddraw2(iface), line);
+}
+
+static HRESULT WINAPI ddraw1_GetScanLine(IDirectDraw *iface, DWORD *line)
+{
+ TRACE("iface %p, line %p.\n", iface, line);
+
+ return ddraw7_GetScanLine((IDirectDraw7 *)ddraw_from_ddraw1(iface), line);
+}
+
/*****************************************************************************
* IDirectDraw7::TestCooperativeLevel
*
* if the state is not correct(See below)
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_TestCooperativeLevel(IDirectDraw7 *iface)
+static HRESULT WINAPI ddraw7_TestCooperativeLevel(IDirectDraw7 *iface)
{
TRACE("iface %p.\n", iface);
return DD_OK;
}
+static HRESULT WINAPI ddraw4_TestCooperativeLevel(IDirectDraw4 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw7_TestCooperativeLevel((IDirectDraw7 *)ddraw_from_ddraw4(iface));
+}
+
/*****************************************************************************
* IDirectDraw7::GetGDISurface
*
* DDERR_NOTFOUND if the GDI surface wasn't found
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_GetGDISurface(IDirectDraw7 *iface,
- IDirectDrawSurface7 **GDISurface)
+static HRESULT WINAPI ddraw7_GetGDISurface(IDirectDraw7 *iface, IDirectDrawSurface7 **GDISurface)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
IWineD3DSurface *Surf;
IDirectDrawSurface7 *ddsurf;
HRESULT hr;
DDSCAPS2 ddsCaps;
- TRACE("(%p)->(%p)\n", This, GDISurface);
+
+ TRACE("iface %p, surface %p.\n", iface, GDISurface);
/* Get the back buffer from the wineD3DDevice and search its
* attached surfaces for the front buffer
return DDERR_NOTFOUND;
}
- /* GetBackBuffer AddRef()ed the surface, release it */
+ ddsurf = IWineD3DSurface_GetParent(Surf);
IWineD3DSurface_Release(Surf);
- IWineD3DSurface_GetParent(Surf,
- (IUnknown **) &ddsurf);
- IDirectDrawSurface7_Release(ddsurf); /* For the GetParent */
-
/* Find the front buffer */
ddsCaps.dwCaps = DDSCAPS_FRONTBUFFER;
hr = IDirectDrawSurface7_GetAttachedSurface(ddsurf,
return hr;
}
+static HRESULT WINAPI ddraw4_GetGDISurface(IDirectDraw4 *iface, IDirectDrawSurface4 **surface)
+{
+ TRACE("iface %p, surface %p.\n", iface, surface);
+
+ return ddraw7_GetGDISurface((IDirectDraw7 *)ddraw_from_ddraw4(iface), (IDirectDrawSurface7 **)surface);
+}
+
+static HRESULT WINAPI ddraw3_GetGDISurface(IDirectDraw3 *iface, IDirectDrawSurface **surface)
+{
+ IDirectDrawSurface7 *surface7;
+ HRESULT hr;
+
+ TRACE("iface %p, surface %p.\n", iface, surface);
+
+ hr = ddraw7_GetGDISurface((IDirectDraw7 *)ddraw_from_ddraw3(iface), &surface7);
+ *surface = surface7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)surface7)->IDirectDrawSurface3_vtbl : NULL;
+
+ return hr;
+}
+
+static HRESULT WINAPI ddraw2_GetGDISurface(IDirectDraw2 *iface, IDirectDrawSurface **surface)
+{
+ IDirectDrawSurface7 *surface7;
+ HRESULT hr;
+
+ TRACE("iface %p, surface %p.\n", iface, surface);
+
+ hr = ddraw7_GetGDISurface((IDirectDraw7 *)ddraw_from_ddraw2(iface), &surface7);
+ *surface = surface7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)surface7)->IDirectDrawSurface3_vtbl : NULL;
+
+ return hr;
+}
+
+static HRESULT WINAPI ddraw1_GetGDISurface(IDirectDraw *iface, IDirectDrawSurface **surface)
+{
+ IDirectDrawSurface7 *surface7;
+ HRESULT hr;
+
+ TRACE("iface %p, surface %p.\n", iface, surface);
+
+ hr = ddraw7_GetGDISurface((IDirectDraw7 *)ddraw_from_ddraw1(iface), &surface7);
+ *surface = surface7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)surface7)->IDirectDrawSurface3_vtbl : NULL;
+
+ return hr;
+}
+
+struct displaymodescallback_context
+{
+ LPDDENUMMODESCALLBACK func;
+ void *context;
+};
+
+static HRESULT CALLBACK EnumDisplayModesCallbackThunk(DDSURFACEDESC2 *surface_desc, void *context)
+{
+ struct displaymodescallback_context *cbcontext = context;
+ DDSURFACEDESC desc;
+
+ memcpy(&desc, surface_desc, sizeof(desc));
+ desc.dwSize = sizeof(desc);
+
+ return cbcontext->func(&desc, cbcontext->context);
+}
+
/*****************************************************************************
* IDirectDraw7::EnumDisplayModes
*
* DDERR_INVALIDPARAMS if the callback wasn't set
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_EnumDisplayModes(IDirectDraw7 *iface,
- DWORD Flags,
- DDSURFACEDESC2 *DDSD,
- void *Context,
- LPDDENUMMODESCALLBACK2 cb)
+static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags,
+ DDSURFACEDESC2 *DDSD, void *Context, LPDDENUMMODESCALLBACK2 cb)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
unsigned int modenum, fmt;
- WINED3DFORMAT pixelformat = WINED3DFMT_UNKNOWN;
+ 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;
- WINED3DFORMAT checkFormatList[] =
+ static const enum wined3d_format_id checkFormatList[] =
{
WINED3DFMT_B8G8R8X8_UNORM,
WINED3DFMT_B5G6R5_UNORM,
WINED3DFMT_P8_UINT,
};
- TRACE("(%p)->(%p,%p,%p): Relay\n", This, DDSD, Context, cb);
+ TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
+ iface, Flags, DDSD, Context, cb);
EnterCriticalSection(&ddraw_cs);
/* This looks sane */
return DD_OK;
}
+static HRESULT WINAPI ddraw4_EnumDisplayModes(IDirectDraw4 *iface, DWORD flags,
+ DDSURFACEDESC2 *surface_desc, void *context, LPDDENUMMODESCALLBACK2 callback)
+{
+ 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);
+}
+
+static HRESULT WINAPI ddraw3_EnumDisplayModes(IDirectDraw3 *iface, DWORD flags,
+ DDSURFACEDESC *surface_desc, void *context, LPDDENUMMODESCALLBACK callback)
+{
+ struct displaymodescallback_context cbcontext;
+
+ TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
+ iface, flags, surface_desc, context, callback);
+
+ cbcontext.func = callback;
+ cbcontext.context = context;
+
+ return ddraw7_EnumDisplayModes((IDirectDraw7 *)ddraw_from_ddraw3(iface), flags,
+ (DDSURFACEDESC2 *)surface_desc, &cbcontext, EnumDisplayModesCallbackThunk);
+}
+
+static HRESULT WINAPI ddraw2_EnumDisplayModes(IDirectDraw2 *iface, DWORD flags,
+ DDSURFACEDESC *surface_desc, void *context, LPDDENUMMODESCALLBACK callback)
+{
+ struct displaymodescallback_context cbcontext;
+
+ TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
+ iface, flags, surface_desc, context, callback);
+
+ cbcontext.func = callback;
+ cbcontext.context = context;
+
+ return ddraw7_EnumDisplayModes((IDirectDraw7 *)ddraw_from_ddraw2(iface), flags,
+ (DDSURFACEDESC2 *)surface_desc, &cbcontext, EnumDisplayModesCallbackThunk);
+}
+
+static HRESULT WINAPI ddraw1_EnumDisplayModes(IDirectDraw *iface, DWORD flags,
+ DDSURFACEDESC *surface_desc, void *context, LPDDENUMMODESCALLBACK callback)
+{
+ struct displaymodescallback_context cbcontext;
+
+ TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
+ iface, flags, surface_desc, context, callback);
+
+ cbcontext.func = callback;
+ cbcontext.context = context;
+
+ return ddraw7_EnumDisplayModes((IDirectDraw7 *)ddraw_from_ddraw1(iface), flags,
+ (DDSURFACEDESC2 *)surface_desc, &cbcontext, EnumDisplayModesCallbackThunk);
+}
+
/*****************************************************************************
* IDirectDraw7::EvaluateMode
*
* This implementation always DD_OK, because it's a stub
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_EvaluateMode(IDirectDraw7 *iface,
- DWORD Flags,
- DWORD *Timeout)
+static HRESULT WINAPI ddraw7_EvaluateMode(IDirectDraw7 *iface, DWORD Flags, DWORD *Timeout)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
- FIXME("(%p)->(%d,%p): Stub!\n", This, Flags, Timeout);
+ FIXME("iface %p, flags %#x, timeout %p stub!\n", iface, Flags, Timeout);
/* When implementing this, implement it in WineD3D */
* DDERR_INVALIDPARAMS if DDDI is NULL
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_GetDeviceIdentifier(IDirectDraw7 *iface,
- DDDEVICEIDENTIFIER2 *DDDI,
- DWORD Flags)
+static HRESULT WINAPI ddraw7_GetDeviceIdentifier(IDirectDraw7 *iface,
+ DDDEVICEIDENTIFIER2 *DDDI, DWORD Flags)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
- TRACE("(%p)->(%p,%08x)\n", This, DDDI, Flags);
+ TRACE("iface %p, device_identifier %p, flags %#x.\n", iface, DDDI, Flags);
if(!DDDI)
return DDERR_INVALIDPARAMS;
return DD_OK;
}
+static HRESULT WINAPI ddraw4_GetDeviceIdentifier(IDirectDraw4 *iface,
+ DDDEVICEIDENTIFIER *identifier, DWORD flags)
+{
+ 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);
+ DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(&identifier2, identifier);
+
+ return hr;
+}
+
/*****************************************************************************
* IDirectDraw7::GetSurfaceFromDC
*
* Always returns DD_OK because it's a stub
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_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;
return DDERR_NOTFOUND;
}
- IWineD3DSurface_GetParent(wined3d_surface, (IUnknown **)Surface);
+ *Surface = IWineD3DSurface_GetParent(wined3d_surface);
+ IDirectDrawSurface7_AddRef(*Surface);
TRACE("Returning surface %p.\n", Surface);
return DD_OK;
}
-/*****************************************************************************
- * IDirectDraw7::RestoreAllSurfaces
- *
- * Calls the restore method of all surfaces
- *
- * Params:
- *
- * Returns:
- * Always returns DD_OK because it's a stub
- *
+static HRESULT WINAPI ddraw4_GetSurfaceFromDC(IDirectDraw4 *iface, HDC dc, IDirectDrawSurface4 **surface)
+{
+ IDirectDrawSurface7 *surface7;
+ HRESULT hr;
+
+ TRACE("iface %p, dc %p, surface %p.\n", iface, dc, surface);
+
+ if (!surface) return E_INVALIDARG;
+
+ hr = ddraw7_GetSurfaceFromDC((IDirectDraw7 *)ddraw_from_ddraw4(iface), dc, &surface7);
+ *surface = surface7 ? (IDirectDrawSurface4 *)&((IDirectDrawSurfaceImpl *)surface7)->IDirectDrawSurface3_vtbl : NULL;
+
+ return hr;
+}
+
+static HRESULT WINAPI ddraw3_GetSurfaceFromDC(IDirectDraw3 *iface, HDC dc, IDirectDrawSurface **surface)
+{
+ TRACE("iface %p, dc %p, surface %p.\n", iface, dc, surface);
+
+ return ddraw7_GetSurfaceFromDC((IDirectDraw7 *)ddraw_from_ddraw3(iface),
+ dc, (IDirectDrawSurface7 **)surface);
+}
+
+/*****************************************************************************
+ * IDirectDraw7::RestoreAllSurfaces
+ *
+ * Calls the restore method of all surfaces
+ *
+ * Params:
+ *
+ * Returns:
+ * Always returns DD_OK because it's a stub
+ *
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_RestoreAllSurfaces(IDirectDraw7 *iface)
+static HRESULT WINAPI ddraw7_RestoreAllSurfaces(IDirectDraw7 *iface)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
- FIXME("(%p): Stub\n", This);
+ FIXME("iface %p stub!\n", iface);
/* This isn't hard to implement: Enumerate all WineD3D surfaces,
* get their parent and call their restore method. Do not implement
return DD_OK;
}
+static HRESULT WINAPI ddraw4_RestoreAllSurfaces(IDirectDraw4 *iface)
+{
+ TRACE("iface %p.\n", iface);
+
+ return ddraw7_RestoreAllSurfaces((IDirectDraw7 *)ddraw_from_ddraw4(iface));
+}
+
/*****************************************************************************
* IDirectDraw7::StartModeTest
*
* otherwise DD_OK
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_StartModeTest(IDirectDraw7 *iface,
- SIZE *Modes,
- DWORD NumModes,
- DWORD Flags)
+static HRESULT WINAPI ddraw7_StartModeTest(IDirectDraw7 *iface, SIZE *Modes, DWORD NumModes, DWORD Flags)
{
- IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
- WARN("(%p)->(%p, %d, %x): Semi-Stub, most likely harmless\n", This, Modes, NumModes, Flags);
+ FIXME("iface %p, modes %p, mode_count %u, flags %#x partial stub!\n",
+ iface, Modes, NumModes, Flags);
/* This looks sane */
if( (!Modes) || (NumModes == 0) ) return DDERR_INVALIDPARAMS;
}
/*****************************************************************************
- * IDirectDrawImpl_RecreateSurfacesCallback
+ * ddraw_recreate_surfaces_cb
*
- * Enumeration callback for IDirectDrawImpl_RecreateAllSurfaces.
+ * Enumeration callback for ddraw_recreate_surface.
* It re-recreates the WineD3DSurface. It's pretty straightforward
*
*****************************************************************************/
-HRESULT WINAPI
-IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf,
- DDSURFACEDESC2 *desc,
- void *Context)
+HRESULT WINAPI ddraw_recreate_surfaces_cb(IDirectDrawSurface7 *surf, DDSURFACEDESC2 *desc, void *Context)
{
IDirectDrawSurfaceImpl *surfImpl = (IDirectDrawSurfaceImpl *)surf;
IDirectDrawImpl *This = surfImpl->ddraw;
- IUnknown *Parent;
IWineD3DSurface *wineD3DSurface;
IWineD3DSwapChain *swapchain;
+ void *parent;
HRESULT hr;
IWineD3DClipper *clipper = NULL;
WINED3DSURFACE_DESC Desc;
- WINED3DFORMAT Format;
+ enum wined3d_format_id Format;
DWORD Usage;
WINED3DPOOL Pool;
UINT Width;
UINT Height;
- TRACE("(%p): Enumerated Surface %p\n", This, surfImpl);
+ TRACE("surface %p, surface_desc %p, context %p.\n",
+ surf, desc, Context);
/* For the enumeration */
IDirectDrawSurface7_Release(surf);
IWineD3DSurface_GetClipper(wineD3DSurface, &clipper);
/* Get the surface properties */
- hr = IWineD3DSurface_GetDesc(wineD3DSurface, &Desc);
- if(hr != D3D_OK) return hr;
+ IWineD3DSurface_GetDesc(wineD3DSurface, &Desc);
Format = Desc.format;
Usage = Desc.usage;
Width = Desc.width;
Height = Desc.height;
- IWineD3DSurface_GetParent(wineD3DSurface, &Parent);
-
- /* Create the new surface */
- hr = IWineD3DDevice_CreateSurface(This->wineD3DDevice, Width, Height, Format,
- TRUE /* Lockable */, FALSE /* Discard */, surfImpl->mipmap_level, &surfImpl->WineD3DSurface, Usage, Pool,
- MultiSampleType, MultiSampleQuality, This->ImplType, Parent, &ddraw_null_wined3d_parent_ops);
- IUnknown_Release(Parent);
+ 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);
if (FAILED(hr))
{
surfImpl->WineD3DSurface = wineD3DSurface;
}
/*****************************************************************************
- * IDirectDrawImpl_RecreateAllSurfaces
+ * ddraw_recreate_surfaces
*
* A function, that converts all wineD3DSurfaces to the new implementation type
* It enumerates all surfaces with IWineD3DDevice::EnumSurfaces, creates a
* new WineD3DSurface, copies the content and releases the old surface
*
*****************************************************************************/
-static HRESULT
-IDirectDrawImpl_RecreateAllSurfaces(IDirectDrawImpl *This)
+static HRESULT ddraw_recreate_surfaces(IDirectDrawImpl *This)
{
DDSURFACEDESC2 desc;
TRACE("(%p): Switch to implementation %d\n", This, This->ImplType);
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
- return IDirectDraw7_EnumSurfaces((IDirectDraw7 *)This, 0, &desc, This, IDirectDrawImpl_RecreateSurfacesCallback);
+ return IDirectDraw7_EnumSurfaces((IDirectDraw7 *)This, 0, &desc, This, ddraw_recreate_surfaces_cb);
}
-ULONG WINAPI D3D7CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) {
- IUnknown* swapChainParent;
- TRACE("(%p) call back\n", pSwapChain);
+ULONG WINAPI D3D7CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain)
+{
+ IUnknown *swapChainParent;
+
+ TRACE("swapchain %p.\n", pSwapChain);
- IWineD3DSwapChain_GetParent(pSwapChain, &swapChainParent);
- IUnknown_Release(swapChainParent);
+ swapChainParent = IWineD3DSwapChain_GetParent(pSwapChain);
return IUnknown_Release(swapChainParent);
}
/*****************************************************************************
- * IDirectDrawImpl_CreateNewSurface
+ * ddraw_create_surface
*
* A helper function for IDirectDraw7::CreateSurface. It creates a new surface
* with the passed parameters.
* DD_OK on success
*
*****************************************************************************/
-static HRESULT
-IDirectDrawImpl_CreateNewSurface(IDirectDrawImpl *This,
- DDSURFACEDESC2 *pDDSD,
- IDirectDrawSurfaceImpl **ppSurf,
- UINT level)
+static HRESULT ddraw_create_surface(IDirectDrawImpl *This, DDSURFACEDESC2 *pDDSD,
+ IDirectDrawSurfaceImpl **ppSurf, UINT level)
{
- HRESULT hr;
- UINT Width, Height;
- WINED3DFORMAT Format = WINED3DFMT_UNKNOWN;
- DWORD Usage = 0;
WINED3DSURFTYPE ImplType = This->ImplType;
- WINED3DSURFACE_DESC Desc;
- WINED3DPOOL Pool = WINED3DPOOL_DEFAULT;
+ HRESULT hr;
+
+ TRACE("ddraw %p, surface_desc %p, surface %p, level %u.\n",
+ This, pDDSD, ppSurf, level);
if (TRACE_ON(ddraw))
{
ImplType = SURFACE_OPENGL;
This->ImplType = ImplType;
TRACE("(%p) Re-creating all surfaces\n", This);
- IDirectDrawImpl_RecreateAllSurfaces(This);
+ ddraw_recreate_surfaces(This);
TRACE("(%p) Done recreating all surfaces\n", This);
}
else if(This->ImplType != SURFACE_OPENGL && pDDSD->ddsCaps.dwCaps & DDSCAPS_3DDEVICE)
}
}
- if (!(pDDSD->ddsCaps.dwCaps & (DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY)) &&
- !((pDDSD->ddsCaps.dwCaps & DDSCAPS_TEXTURE) && (pDDSD->ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE)) )
- {
- /* Tests show surfaces without memory flags get these flags added right after creation. */
- pDDSD->ddsCaps.dwCaps |= DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY;
- }
- /* Get the correct wined3d usage */
- if (pDDSD->ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE |
- DDSCAPS_3DDEVICE ) )
- {
- Usage |= WINED3DUSAGE_RENDERTARGET;
-
- pDDSD->ddsCaps.dwCaps |= DDSCAPS_VISIBLE;
- }
- if (pDDSD->ddsCaps.dwCaps & (DDSCAPS_OVERLAY))
- {
- Usage |= WINED3DUSAGE_OVERLAY;
- }
- if(This->depthstencil || (pDDSD->ddsCaps.dwCaps & DDSCAPS_ZBUFFER) )
- {
- /* The depth stencil creation callback sets this flag.
- * Set the WineD3D usage to let it know that it's a depth
- * Stencil surface.
- */
- Usage |= WINED3DUSAGE_DEPTHSTENCIL;
- }
- if(pDDSD->ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY)
- {
- Pool = WINED3DPOOL_SYSTEMMEM;
- }
- else if(pDDSD->ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE)
- {
- Pool = WINED3DPOOL_MANAGED;
- /* Managed textures have the system memory flag set */
- pDDSD->ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
- }
- else if(pDDSD->ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)
- {
- /* Videomemory adds localvidmem, this is mutually exclusive with systemmemory
- * and texturemanage
- */
- pDDSD->ddsCaps.dwCaps |= DDSCAPS_LOCALVIDMEM;
- }
-
- Format = PixelFormat_DD2WineD3D(&pDDSD->u4.ddpfPixelFormat);
- if(Format == WINED3DFMT_UNKNOWN)
- {
- ERR("Unsupported / Unknown pixelformat\n");
- return DDERR_INVALIDPIXELFORMAT;
- }
-
/* Create the Surface object */
*ppSurf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectDrawSurfaceImpl));
if(!*ppSurf)
ERR("(%p) Error allocating memory for a surface\n", This);
return DDERR_OUTOFVIDEOMEMORY;
}
- (*ppSurf)->lpVtbl = &IDirectDrawSurface7_Vtbl;
- (*ppSurf)->IDirectDrawSurface3_vtbl = &IDirectDrawSurface3_Vtbl;
- (*ppSurf)->IDirectDrawGammaControl_vtbl = &IDirectDrawGammaControl_Vtbl;
- (*ppSurf)->IDirect3DTexture2_vtbl = &IDirect3DTexture2_Vtbl;
- (*ppSurf)->IDirect3DTexture_vtbl = &IDirect3DTexture1_Vtbl;
- (*ppSurf)->ref = 1;
- (*ppSurf)->version = 7;
- TRACE("%p->version = %d\n", (*ppSurf), (*ppSurf)->version);
- (*ppSurf)->ddraw = This;
- (*ppSurf)->surface_desc.dwSize = sizeof(DDSURFACEDESC2);
- (*ppSurf)->surface_desc.u4.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
- DD_STRUCT_COPY_BYSIZE(&(*ppSurf)->surface_desc, pDDSD);
-
- /* Surface attachments */
- (*ppSurf)->next_attached = NULL;
- (*ppSurf)->first_attached = *ppSurf;
-
- /* Needed to re-create the surface on an implementation change */
- (*ppSurf)->ImplType = ImplType;
-
- /* For D3DDevice creation */
- (*ppSurf)->isRenderTarget = FALSE;
-
- /* A trace message for debugging */
- TRACE("(%p) Created IDirectDrawSurface implementation structure at %p\n", This, *ppSurf);
-
- /* Now create the WineD3D Surface */
- hr = IWineD3DDevice_CreateSurface(This->wineD3DDevice, pDDSD->dwWidth, pDDSD->dwHeight, Format,
- TRUE /* Lockable */, FALSE /* Discard */, level, &(*ppSurf)->WineD3DSurface,
- Usage, Pool, WINED3DMULTISAMPLE_NONE, 0 /* MultiSampleQuality */, ImplType,
- (IUnknown *)*ppSurf, &ddraw_null_wined3d_parent_ops);
-
- if(hr != D3D_OK)
- {
- ERR("IWineD3DDevice::CreateSurface failed. hr = %08x\n", hr);
+
+ hr = ddraw_surface_init(*ppSurf, This, pDDSD, level, ImplType);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize surface, hr %#x.\n", hr);
+ HeapFree(GetProcessHeap(), 0, *ppSurf);
return hr;
}
InterlockedIncrement(&This->surfaces);
list_add_head(&This->surface_list, &(*ppSurf)->surface_list_entry);
- /* Here we could store all created surfaces in the DirectDrawImpl structure,
- * But this could also be delegated to WineDDraw, as it keeps track of all its
- * resources. Not implemented for now, as there are more important things ;)
- */
-
- /* Get the pixel format of the WineD3DSurface and store it.
- * Don't use the Format choosen above, WineD3D might have
- * changed it
- */
- (*ppSurf)->surface_desc.dwFlags |= DDSD_PIXELFORMAT;
- hr = IWineD3DSurface_GetDesc((*ppSurf)->WineD3DSurface, &Desc);
- if(hr != D3D_OK)
- {
- ERR("IWineD3DSurface::GetDesc failed\n");
- IDirectDrawSurface7_Release( (IDirectDrawSurface7 *) *ppSurf);
- return hr;
- }
-
- Format = Desc.format;
- Width = Desc.width;
- Height = Desc.height;
-
- if(Format == WINED3DFMT_UNKNOWN)
- {
- FIXME("IWineD3DSurface::GetDesc returned WINED3DFMT_UNKNOWN\n");
- }
- PixelFormat_WineD3DtoDD( &(*ppSurf)->surface_desc.u4.ddpfPixelFormat, Format);
-
- /* Anno 1602 stores the pitch right after surface creation, so make sure it's there.
- * I can't LockRect() the surface here because if OpenGL surfaces are in use, the
- * WineD3DDevice might not be usable for 3D yet, so an extra method was created.
- * TODO: Test other fourcc formats
- */
- if(Format == WINED3DFMT_DXT1 || Format == WINED3DFMT_DXT2 || Format == WINED3DFMT_DXT3 ||
- Format == WINED3DFMT_DXT4 || Format == WINED3DFMT_DXT5)
- {
- (*ppSurf)->surface_desc.dwFlags |= DDSD_LINEARSIZE;
- if(Format == WINED3DFMT_DXT1)
- {
- (*ppSurf)->surface_desc.u1.dwLinearSize = max(4, Width) * max(4, Height) / 2;
- }
- else
- {
- (*ppSurf)->surface_desc.u1.dwLinearSize = max(4, Width) * max(4, Height);
- }
- }
- else
- {
- (*ppSurf)->surface_desc.dwFlags |= DDSD_PITCH;
- (*ppSurf)->surface_desc.u1.lPitch = IWineD3DSurface_GetPitch((*ppSurf)->WineD3DSurface);
- }
-
- /* Application passed a color key? Set it! */
- if(pDDSD->dwFlags & DDSD_CKDESTOVERLAY)
- {
- IWineD3DSurface_SetColorKey((*ppSurf)->WineD3DSurface,
- DDCKEY_DESTOVERLAY,
- (WINEDDCOLORKEY *) &pDDSD->u3.ddckCKDestOverlay);
- }
- if(pDDSD->dwFlags & DDSD_CKDESTBLT)
- {
- IWineD3DSurface_SetColorKey((*ppSurf)->WineD3DSurface,
- DDCKEY_DESTBLT,
- (WINEDDCOLORKEY *) &pDDSD->ddckCKDestBlt);
- }
- if(pDDSD->dwFlags & DDSD_CKSRCOVERLAY)
- {
- IWineD3DSurface_SetColorKey((*ppSurf)->WineD3DSurface,
- DDCKEY_SRCOVERLAY,
- (WINEDDCOLORKEY *) &pDDSD->ddckCKSrcOverlay);
- }
- if(pDDSD->dwFlags & DDSD_CKSRCBLT)
- {
- IWineD3DSurface_SetColorKey((*ppSurf)->WineD3DSurface,
- DDCKEY_SRCBLT,
- (WINEDDCOLORKEY *) &pDDSD->ddckCKSrcBlt);
- }
- if ( pDDSD->dwFlags & DDSD_LPSURFACE)
- {
- hr = IWineD3DSurface_SetMem((*ppSurf)->WineD3DSurface, pDDSD->lpSurface);
- if(hr != WINED3D_OK)
- {
- /* No need for a trace here, wined3d does that for us */
- IDirectDrawSurface7_Release((IDirectDrawSurface7 *)*ppSurf);
- return hr;
- }
- }
+ TRACE("Created surface %p.\n", *ppSurf);
return DD_OK;
}
}
CubeFaceRoot = FALSE;
- hr = IDirectDrawImpl_CreateNewSurface(This,
- &DDSD,
- &object2,
- level);
+ hr = ddraw_create_surface(This, &DDSD, &object2, level);
if(hr != DD_OK)
{
return hr;
return DD_OK;
}
+/* Must set all attached surfaces (e.g. mipmaps) versions as well */
+static void ddraw_set_surface_version(IDirectDrawSurfaceImpl *surface, UINT version)
+{
+ unsigned int i;
+
+ TRACE("surface %p, version %u -> %u.\n", surface, surface->version, version);
+
+ surface->version = version;
+ for (i = 0; i < MAX_COMPLEX_ATTACHED; ++i)
+ {
+ if (!surface->complex_array[i]) break;
+ ddraw_set_surface_version(surface->complex_array[i], version);
+ }
+ while ((surface = surface->next_attached))
+ {
+ ddraw_set_surface_version(surface, version);
+ }
+}
+
+/*****************************************************************************
+ * ddraw_attach_d3d_device
+ *
+ * Initializes the D3D capabilities of WineD3D
+ *
+ * Params:
+ * primary: The primary surface for D3D
+ *
+ * Returns
+ * DD_OK on success,
+ * DDERR_* otherwise
+ *
+ *****************************************************************************/
+static HRESULT ddraw_attach_d3d_device(IDirectDrawImpl *ddraw, IDirectDrawSurfaceImpl *primary)
+{
+ WINED3DPRESENT_PARAMETERS localParameters;
+ HWND window = ddraw->dest_window;
+ HRESULT hr;
+
+ TRACE("ddraw %p, primary %p.\n", ddraw, primary);
+
+ if (!window || window == GetDesktopWindow())
+ {
+ window = CreateWindowExA(0, DDRAW_WINDOW_CLASS_NAME, "Hidden D3D Window",
+ WS_DISABLED, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
+ NULL, NULL, NULL, NULL);
+ if (!window)
+ {
+ ERR("Failed to create window, last error %#x.\n", GetLastError());
+ return E_FAIL;
+ }
+
+ ShowWindow(window, SW_HIDE); /* Just to be sure */
+ WARN("No window for the Direct3DDevice, created hidden window %p.\n", window);
+ }
+ else
+ {
+ TRACE("Using existing window %p for Direct3D rendering.\n", window);
+ }
+ ddraw->d3d_window = window;
+
+ /* Store the future Render Target surface */
+ ddraw->d3d_target = primary;
+
+ /* Use the surface description for the device parameters, not the device
+ * settings. The application might render to an offscreen surface. */
+ localParameters.BackBufferWidth = primary->surface_desc.dwWidth;
+ localParameters.BackBufferHeight = primary->surface_desc.dwHeight;
+ localParameters.BackBufferFormat = PixelFormat_DD2WineD3D(&primary->surface_desc.u4.ddpfPixelFormat);
+ localParameters.BackBufferCount = (primary->surface_desc.dwFlags & DDSD_BACKBUFFERCOUNT)
+ ? primary->surface_desc.u5.dwBackBufferCount : 0;
+ localParameters.MultiSampleType = WINED3DMULTISAMPLE_NONE;
+ localParameters.MultiSampleQuality = 0;
+ localParameters.SwapEffect = WINED3DSWAPEFFECT_COPY;
+ localParameters.hDeviceWindow = window;
+ localParameters.Windowed = !(ddraw->cooperative_level & DDSCL_FULLSCREEN);
+ localParameters.EnableAutoDepthStencil = TRUE;
+ localParameters.AutoDepthStencilFormat = WINED3DFMT_D16_UNORM;
+ localParameters.Flags = 0;
+ localParameters.FullScreen_RefreshRateInHz = WINED3DPRESENT_RATE_DEFAULT;
+ localParameters.PresentationInterval = WINED3DPRESENT_INTERVAL_DEFAULT;
+
+ /* 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);
+ if (FAILED(hr))
+ {
+ ddraw->d3d_target = NULL;
+ ddraw->d3d_initialized = FALSE;
+ return hr;
+ }
+
+ ddraw->declArraySize = 2;
+ ddraw->decls = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ddraw->decls) * ddraw->declArraySize);
+ if (!ddraw->decls)
+ {
+ ERR("Error allocating an array for the converted vertex decls.\n");
+ ddraw->declArraySize = 0;
+ hr = IWineD3DDevice_Uninit3D(ddraw->wineD3DDevice, D3D7CB_DestroySwapChain);
+ return E_OUTOFMEMORY;
+ }
+
+ TRACE("Successfully initialized 3D.\n");
+
+ return DD_OK;
+}
+
+static HRESULT ddraw_create_gdi_swapchain(IDirectDrawImpl *ddraw, IDirectDrawSurfaceImpl *primary)
+{
+ WINED3DPRESENT_PARAMETERS presentation_parameters;
+ HWND window;
+ HRESULT hr;
+
+ window = ddraw->dest_window;
+
+ memset(&presentation_parameters, 0, sizeof(presentation_parameters));
+
+ /* Use the surface description for the device parameters, not the device
+ * settings. The application might render to an offscreen surface. */
+ presentation_parameters.BackBufferWidth = primary->surface_desc.dwWidth;
+ presentation_parameters.BackBufferHeight = primary->surface_desc.dwHeight;
+ presentation_parameters.BackBufferFormat = PixelFormat_DD2WineD3D(&primary->surface_desc.u4.ddpfPixelFormat);
+ presentation_parameters.BackBufferCount = (primary->surface_desc.dwFlags & DDSD_BACKBUFFERCOUNT)
+ ? primary->surface_desc.u5.dwBackBufferCount : 0;
+ presentation_parameters.MultiSampleType = WINED3DMULTISAMPLE_NONE;
+ presentation_parameters.MultiSampleQuality = 0;
+ presentation_parameters.SwapEffect = WINED3DSWAPEFFECT_FLIP;
+ presentation_parameters.hDeviceWindow = window;
+ presentation_parameters.Windowed = !(ddraw->cooperative_level & DDSCL_FULLSCREEN);
+ presentation_parameters.EnableAutoDepthStencil = FALSE; /* Not on GDI swapchains */
+ presentation_parameters.AutoDepthStencilFormat = 0;
+ presentation_parameters.Flags = 0;
+ presentation_parameters.FullScreen_RefreshRateInHz = WINED3DPRESENT_RATE_DEFAULT;
+ presentation_parameters.PresentationInterval = WINED3DPRESENT_INTERVAL_DEFAULT;
+
+ ddraw->d3d_target = primary;
+ hr = IWineD3DDevice_InitGDI(ddraw->wineD3DDevice, &presentation_parameters);
+ ddraw->d3d_target = NULL;
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize GDI ddraw implementation, hr %#x.\n", hr);
+ primary->wineD3DSwapChain = NULL;
+ }
+
+ return hr;
+}
+
/*****************************************************************************
* IDirectDraw7::CreateSurface
*
* DDERR_* if an error occurs
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_CreateSurface(IDirectDraw7 *iface,
- DDSURFACEDESC2 *DDSD,
- IDirectDrawSurface7 **Surf,
- IUnknown *UnkOuter)
+static HRESULT CreateSurface(IDirectDraw7 *iface,
+ DDSURFACEDESC2 *DDSD, IDirectDrawSurface7 **Surf, IUnknown *UnkOuter)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
IDirectDrawSurfaceImpl *object = NULL;
WINED3DDISPLAYMODE Mode;
const DWORD sysvidmem = DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
- TRACE("(%p)->(%p,%p,%p)\n", This, DDSD, Surf, UnkOuter);
+ TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
+ iface, DDSD, Surf, UnkOuter);
/* Some checks before we start */
if (TRACE_ON(ddraw))
return DDERR_NOEXCLUSIVEMODE;
}
- if(DDSD->ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER)) {
- WARN("Application tried to create an explicit front or back buffer\n");
+ if((DDSD->ddsCaps.dwCaps & (DDSCAPS_BACKBUFFER | DDSCAPS_PRIMARYSURFACE)) == (DDSCAPS_BACKBUFFER | DDSCAPS_PRIMARYSURFACE))
+ {
+ WARN("Application wanted to create back buffer primary surface\n");
LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDCAPS;
}
}
/* Create the first surface */
- hr = IDirectDrawImpl_CreateNewSurface(This, &desc2, &object, 0);
- if( hr != DD_OK)
+ hr = ddraw_create_surface(This, &desc2, &object, 0);
+ if (FAILED(hr))
{
- ERR("IDirectDrawImpl_CreateNewSurface failed with %08x\n", hr);
+ WARN("ddraw_create_surface failed, hr %#x.\n", hr);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
}
TRACE("(%p) Attaching a D3DDevice, rendertarget = %p\n", This, target);
- hr = IDirectDrawImpl_AttachD3DDevice(This, target);
- if(hr != D3D_OK)
+ hr = ddraw_attach_d3d_device(This, target);
+ if (hr != D3D_OK)
{
IDirectDrawSurfaceImpl *release_surf;
- ERR("IDirectDrawImpl_AttachD3DDevice failed, hr = %x\n", hr);
+ ERR("ddraw_attach_d3d_device failed, hr %#x\n", hr);
*Surf = NULL;
/* The before created surface structures are in an incomplete state here.
{
release_surf = object;
object = object->complex_array[0];
- IDirectDrawSurfaceImpl_Destroy(release_surf);
+ ddraw_surface_destroy(release_surf);
}
LeaveCriticalSection(&ddraw_cs);
return hr;
}
- } else if(!(This->d3d_initialized) && desc2.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) {
- IDirectDrawImpl_CreateGDISwapChain(This, object);
+ }
+ else if(!(This->d3d_initialized) && desc2.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
+ {
+ ddraw_create_gdi_swapchain(This, object);
}
/* Addref the ddraw interface to keep an reference for each surface */
/* Create a WineD3DTexture if a texture was requested */
if(desc2.ddsCaps.dwCaps & DDSCAPS_TEXTURE)
{
+ enum wined3d_format_id Format;
UINT levels;
- WINED3DFORMAT Format;
WINED3DPOOL Pool = WINED3DPOOL_DEFAULT;
This->tex_root = object;
*/
if(desc2.ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
{
- hr = IWineD3DDevice_CreateCubeTexture(This->wineD3DDevice, DDSD->dwWidth /* Edgelength */,
- levels, 0 /* usage */, Format, Pool, (IWineD3DCubeTexture **)&object->wineD3DTexture,
- (IUnknown *)object, &ddraw_null_wined3d_parent_ops);
+ 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, (IWineD3DTexture **)&object->wineD3DTexture,
- (IUnknown *)object, &ddraw_null_wined3d_parent_ops);
+ 0 /* usage */, Format, Pool, object, &ddraw_null_wined3d_parent_ops,
+ (IWineD3DTexture **)&object->wineD3DTexture);
}
This->tex_root = NULL;
}
return hr;
}
-#define DDENUMSURFACES_SEARCHTYPE (DDENUMSURFACES_CANBECREATED|DDENUMSURFACES_DOESEXIST)
-#define DDENUMSURFACES_MATCHTYPE (DDENUMSURFACES_ALL|DDENUMSURFACES_MATCH|DDENUMSURFACES_NOMATCH)
-
-static BOOL
-Main_DirectDraw_DDPIXELFORMAT_Match(const DDPIXELFORMAT *requested,
- const DDPIXELFORMAT *provided)
+static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface,
+ DDSURFACEDESC2 *surface_desc, IDirectDrawSurface7 **surface, IUnknown *outer_unknown)
{
- /* Some flags must be present in both or neither for a match. */
- static const DWORD must_match = DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2
- | DDPF_PALETTEINDEXED4 | DDPF_PALETTEINDEXED8 | DDPF_FOURCC
- | DDPF_ZBUFFER | DDPF_STENCILBUFFER;
+ TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
+ iface, surface_desc, surface, outer_unknown);
- if ((requested->dwFlags & provided->dwFlags) != requested->dwFlags)
- return FALSE;
+ if(surface_desc == NULL || surface_desc->dwSize != sizeof(DDSURFACEDESC2))
+ {
+ WARN("Application supplied invalid surface descriptor\n");
+ return DDERR_INVALIDPARAMS;
+ }
- if ((requested->dwFlags & must_match) != (provided->dwFlags & must_match))
- return FALSE;
+ if(surface_desc->ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER))
+ {
+ if (TRACE_ON(ddraw))
+ {
+ TRACE(" (%p) Requesting surface desc :\n", iface);
+ DDRAW_dump_surface_desc(surface_desc);
+ }
- if (requested->dwFlags & DDPF_FOURCC)
- if (requested->dwFourCC != provided->dwFourCC)
- return FALSE;
+ WARN("Application tried to create an explicit front or back buffer\n");
+ return DDERR_INVALIDCAPS;
+ }
- if (requested->dwFlags & (DDPF_RGB|DDPF_YUV|DDPF_ZBUFFER|DDPF_ALPHA
- |DDPF_LUMINANCE|DDPF_BUMPDUDV))
- if (requested->u1.dwRGBBitCount != provided->u1.dwRGBBitCount)
- return FALSE;
+ return CreateSurface(iface, surface_desc, surface, outer_unknown);
+}
- if (requested->dwFlags & (DDPF_RGB|DDPF_YUV|DDPF_STENCILBUFFER
- |DDPF_LUMINANCE|DDPF_BUMPDUDV))
- if (requested->u2.dwRBitMask != provided->u2.dwRBitMask)
- return FALSE;
+static HRESULT WINAPI ddraw4_CreateSurface(IDirectDraw4 *iface,
+ DDSURFACEDESC2 *surface_desc, IDirectDrawSurface4 **surface, IUnknown *outer_unknown)
+{
+ IDirectDrawImpl *ddraw = ddraw_from_ddraw4(iface);
+ IDirectDrawSurfaceImpl *impl;
+ HRESULT hr;
- if (requested->dwFlags & (DDPF_RGB|DDPF_YUV|DDPF_ZBUFFER|DDPF_BUMPDUDV))
- if (requested->u3.dwGBitMask != provided->u3.dwGBitMask)
- return FALSE;
+ TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
+ iface, surface_desc, surface, outer_unknown);
- /* I could be wrong about the bumpmapping. MSDN docs are vague. */
- if (requested->dwFlags & (DDPF_RGB|DDPF_YUV|DDPF_STENCILBUFFER
- |DDPF_BUMPDUDV))
- if (requested->u4.dwBBitMask != provided->u4.dwBBitMask)
- return FALSE;
+ if(surface_desc == NULL || surface_desc->dwSize != sizeof(DDSURFACEDESC2))
+ {
+ WARN("Application supplied invalid surface descriptor\n");
+ return DDERR_INVALIDPARAMS;
+ }
- if (requested->dwFlags & (DDPF_ALPHAPIXELS|DDPF_ZPIXELS))
- if (requested->u5.dwRGBAlphaBitMask != provided->u5.dwRGBAlphaBitMask)
- return FALSE;
+ if(surface_desc->ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER))
+ {
+ if (TRACE_ON(ddraw))
+ {
+ TRACE(" (%p) Requesting surface desc :\n", iface);
+ DDRAW_dump_surface_desc(surface_desc);
+ }
- return TRUE;
+ WARN("Application tried to create an explicit front or back buffer\n");
+ return DDERR_INVALIDCAPS;
+ }
+
+ hr = CreateSurface((IDirectDraw7 *)ddraw, surface_desc, (IDirectDrawSurface7 **)surface, outer_unknown);
+ impl = (IDirectDrawSurfaceImpl *)*surface;
+ if (SUCCEEDED(hr) && impl)
+ {
+ ddraw_set_surface_version(impl, 4);
+ IDirectDraw7_Release((IDirectDraw7 *)ddraw);
+ IDirectDraw4_AddRef(iface);
+ impl->ifaceToRelease = (IUnknown *)iface;
+ }
+
+ return hr;
}
-static BOOL
-IDirectDrawImpl_DDSD_Match(const DDSURFACEDESC2* requested,
- const DDSURFACEDESC2* provided)
+static HRESULT WINAPI ddraw3_CreateSurface(IDirectDraw3 *iface,
+ DDSURFACEDESC *surface_desc, IDirectDrawSurface **surface, IUnknown *outer_unknown)
{
- struct compare_info
- {
- DWORD flag;
- ptrdiff_t offset;
- size_t size;
- };
+ IDirectDrawImpl *ddraw = ddraw_from_ddraw3(iface);
+ IDirectDrawSurface7 *surface7;
+ IDirectDrawSurfaceImpl *impl;
+ HRESULT hr;
-#define CMP(FLAG, FIELD) \
- { DDSD_##FLAG, offsetof(DDSURFACEDESC2, FIELD), \
- sizeof(((DDSURFACEDESC2 *)(NULL))->FIELD) }
+ TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
+ iface, surface_desc, surface, outer_unknown);
- static const struct compare_info compare[] =
+ if(surface_desc == NULL || surface_desc->dwSize != sizeof(DDSURFACEDESC))
{
- CMP(ALPHABITDEPTH, dwAlphaBitDepth),
- CMP(BACKBUFFERCOUNT, u5.dwBackBufferCount),
- CMP(CAPS, ddsCaps),
+ WARN("Application supplied invalid surface descriptor\n");
+ return DDERR_INVALIDPARAMS;
+ }
+
+ if(surface_desc->ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER))
+ {
+ if (TRACE_ON(ddraw))
+ {
+ TRACE(" (%p) Requesting surface desc :\n", iface);
+ DDRAW_dump_surface_desc((LPDDSURFACEDESC2)surface_desc);
+ }
+
+ WARN("Application tried to create an explicit front or back buffer\n");
+ return DDERR_INVALIDCAPS;
+ }
+
+ hr = CreateSurface((IDirectDraw7 *)ddraw, (DDSURFACEDESC2 *)surface_desc, &surface7, outer_unknown);
+ if (FAILED(hr))
+ {
+ *surface = NULL;
+ return hr;
+ }
+
+ impl = (IDirectDrawSurfaceImpl *)surface7;
+ *surface = (IDirectDrawSurface *)&impl->IDirectDrawSurface3_vtbl;
+ ddraw_set_surface_version(impl, 3);
+ IDirectDraw7_Release((IDirectDraw7 *)ddraw);
+ IDirectDraw3_AddRef(iface);
+ impl->ifaceToRelease = (IUnknown *)iface;
+
+ return hr;
+}
+
+static HRESULT WINAPI ddraw2_CreateSurface(IDirectDraw2 *iface,
+ DDSURFACEDESC *surface_desc, IDirectDrawSurface **surface, IUnknown *outer_unknown)
+{
+ IDirectDrawImpl *ddraw = ddraw_from_ddraw2(iface);
+ IDirectDrawSurface7 *surface7;
+ IDirectDrawSurfaceImpl *impl;
+ HRESULT hr;
+
+ TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
+ iface, surface_desc, surface, outer_unknown);
+
+ if(surface_desc == NULL || surface_desc->dwSize != sizeof(DDSURFACEDESC))
+ {
+ WARN("Application supplied invalid surface descriptor\n");
+ return DDERR_INVALIDPARAMS;
+ }
+
+ if(surface_desc->ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER))
+ {
+ if (TRACE_ON(ddraw))
+ {
+ TRACE(" (%p) Requesting surface desc :\n", iface);
+ DDRAW_dump_surface_desc((LPDDSURFACEDESC2)surface_desc);
+ }
+
+ WARN("Application tried to create an explicit front or back buffer\n");
+ return DDERR_INVALIDCAPS;
+ }
+
+ hr = CreateSurface((IDirectDraw7 *)ddraw, (DDSURFACEDESC2 *)surface_desc, &surface7, outer_unknown);
+ if (FAILED(hr))
+ {
+ *surface = NULL;
+ return hr;
+ }
+
+ impl = (IDirectDrawSurfaceImpl *)surface7;
+ *surface = (IDirectDrawSurface *)&impl->IDirectDrawSurface3_vtbl;
+ ddraw_set_surface_version(impl, 2);
+ IDirectDraw7_Release((IDirectDraw7 *)ddraw);
+ impl->ifaceToRelease = NULL;
+
+ return hr;
+}
+
+static HRESULT WINAPI ddraw1_CreateSurface(IDirectDraw *iface,
+ DDSURFACEDESC *surface_desc, IDirectDrawSurface **surface, IUnknown *outer_unknown)
+{
+ IDirectDrawImpl *ddraw = ddraw_from_ddraw1(iface);
+ IDirectDrawSurface7 *surface7;
+ IDirectDrawSurfaceImpl *impl;
+ HRESULT hr;
+
+ TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
+ iface, surface_desc, surface, outer_unknown);
+
+ if(surface_desc == NULL || surface_desc->dwSize != sizeof(DDSURFACEDESC))
+ {
+ WARN("Application supplied invalid surface descriptor\n");
+ return DDERR_INVALIDPARAMS;
+ }
+
+ /* 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);
+ if (FAILED(hr))
+ {
+ *surface = NULL;
+ return hr;
+ }
+
+ impl = (IDirectDrawSurfaceImpl *)surface7;
+ *surface = (IDirectDrawSurface *)&impl->IDirectDrawSurface3_vtbl;
+ ddraw_set_surface_version(impl, 1);
+ IDirectDraw7_Release((IDirectDraw7 *)ddraw);
+ impl->ifaceToRelease = NULL;
+
+ return hr;
+}
+
+#define DDENUMSURFACES_SEARCHTYPE (DDENUMSURFACES_CANBECREATED|DDENUMSURFACES_DOESEXIST)
+#define DDENUMSURFACES_MATCHTYPE (DDENUMSURFACES_ALL|DDENUMSURFACES_MATCH|DDENUMSURFACES_NOMATCH)
+
+static BOOL
+Main_DirectDraw_DDPIXELFORMAT_Match(const DDPIXELFORMAT *requested,
+ const DDPIXELFORMAT *provided)
+{
+ /* Some flags must be present in both or neither for a match. */
+ static const DWORD must_match = DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2
+ | DDPF_PALETTEINDEXED4 | DDPF_PALETTEINDEXED8 | DDPF_FOURCC
+ | DDPF_ZBUFFER | DDPF_STENCILBUFFER;
+
+ if ((requested->dwFlags & provided->dwFlags) != requested->dwFlags)
+ return FALSE;
+
+ if ((requested->dwFlags & must_match) != (provided->dwFlags & must_match))
+ return FALSE;
+
+ if (requested->dwFlags & DDPF_FOURCC)
+ if (requested->dwFourCC != provided->dwFourCC)
+ return FALSE;
+
+ if (requested->dwFlags & (DDPF_RGB|DDPF_YUV|DDPF_ZBUFFER|DDPF_ALPHA
+ |DDPF_LUMINANCE|DDPF_BUMPDUDV))
+ if (requested->u1.dwRGBBitCount != provided->u1.dwRGBBitCount)
+ return FALSE;
+
+ if (requested->dwFlags & (DDPF_RGB|DDPF_YUV|DDPF_STENCILBUFFER
+ |DDPF_LUMINANCE|DDPF_BUMPDUDV))
+ if (requested->u2.dwRBitMask != provided->u2.dwRBitMask)
+ return FALSE;
+
+ if (requested->dwFlags & (DDPF_RGB|DDPF_YUV|DDPF_ZBUFFER|DDPF_BUMPDUDV))
+ if (requested->u3.dwGBitMask != provided->u3.dwGBitMask)
+ return FALSE;
+
+ /* I could be wrong about the bumpmapping. MSDN docs are vague. */
+ if (requested->dwFlags & (DDPF_RGB|DDPF_YUV|DDPF_STENCILBUFFER
+ |DDPF_BUMPDUDV))
+ if (requested->u4.dwBBitMask != provided->u4.dwBBitMask)
+ return FALSE;
+
+ if (requested->dwFlags & (DDPF_ALPHAPIXELS|DDPF_ZPIXELS))
+ if (requested->u5.dwRGBAlphaBitMask != provided->u5.dwRGBAlphaBitMask)
+ return FALSE;
+
+ return TRUE;
+}
+
+static BOOL ddraw_match_surface_desc(const DDSURFACEDESC2 *requested, const DDSURFACEDESC2 *provided)
+{
+ struct compare_info
+ {
+ DWORD flag;
+ ptrdiff_t offset;
+ size_t size;
+ };
+
+#define CMP(FLAG, FIELD) \
+ { DDSD_##FLAG, offsetof(DDSURFACEDESC2, FIELD), \
+ sizeof(((DDSURFACEDESC2 *)(NULL))->FIELD) }
+
+ static const struct compare_info compare[] =
+ {
+ CMP(ALPHABITDEPTH, dwAlphaBitDepth),
+ CMP(BACKBUFFERCOUNT, u5.dwBackBufferCount),
+ CMP(CAPS, ddsCaps),
CMP(CKDESTBLT, ddckCKDestBlt),
CMP(CKDESTOVERLAY, u3 /* ddckCKDestOverlay */),
CMP(CKSRCBLT, ddckCKSrcBlt),
#undef DDENUMSURFACES_SEARCHTYPE
#undef DDENUMSURFACES_MATCHTYPE
+struct surfacescallback_context
+{
+ LPDDENUMSURFACESCALLBACK func;
+ void *context;
+};
+
+static HRESULT CALLBACK EnumSurfacesCallbackThunk(IDirectDrawSurface7 *surface,
+ DDSURFACEDESC2 *surface_desc, void *context)
+{
+ struct surfacescallback_context *cbcontext = context;
+
+ return cbcontext->func((IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)surface)->IDirectDrawSurface3_vtbl,
+ (DDSURFACEDESC *)surface_desc, cbcontext->context);
+}
+
/*****************************************************************************
* IDirectDraw7::EnumSurfaces
*
* DD_OK on success
*
*****************************************************************************/
-static HRESULT WINAPI
-IDirectDrawImpl_EnumSurfaces(IDirectDraw7 *iface,
- DWORD Flags,
- DDSURFACEDESC2 *DDSD,
- void *Context,
- LPDDENUMSURFACESCALLBACK7 Callback)
+static HRESULT WINAPI ddraw7_EnumSurfaces(IDirectDraw7 *iface, DWORD Flags,
+ DDSURFACEDESC2 *DDSD, void *Context, LPDDENUMSURFACESCALLBACK7 Callback)
{
/* The surface enumeration is handled by WineDDraw,
* because it keeps track of all surfaces attached to
DDSURFACEDESC2 desc;
struct list *entry, *entry2;
+ TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
+ iface, Flags, DDSD, Context, Callback);
+
all = Flags & DDENUMSURFACES_ALL;
nomatch = Flags & DDENUMSURFACES_NOMATCH;
- TRACE("(%p)->(%x,%p,%p,%p)\n", This, Flags, DDSD, Context, Callback);
EnterCriticalSection(&ddraw_cs);
if(!Callback)
LIST_FOR_EACH_SAFE(entry, entry2, &This->surface_list)
{
surf = LIST_ENTRY(entry, IDirectDrawSurfaceImpl, surface_list_entry);
- if (all || (nomatch != IDirectDrawImpl_DDSD_Match(DDSD, &surf->surface_desc)))
+ if (all || (nomatch != ddraw_match_surface_desc(DDSD, &surf->surface_desc)))
{
desc = surf->surface_desc;
IDirectDrawSurface7_AddRef((IDirectDrawSurface7 *)surf);
return DD_OK;
}
-static HRESULT WINAPI
-findRenderTarget(IDirectDrawSurface7 *surface,
- DDSURFACEDESC2 *desc,
- void *ctx)
+static HRESULT WINAPI ddraw4_EnumSurfaces(IDirectDraw4 *iface, DWORD flags,
+ DDSURFACEDESC2 *surface_desc, void *context, LPDDENUMSURFACESCALLBACK2 callback)
{
- IDirectDrawSurfaceImpl *surf = (IDirectDrawSurfaceImpl *)surface;
- IDirectDrawSurfaceImpl **target = ctx;
+ TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
+ iface, flags, surface_desc, context, callback);
- if(!surf->isRenderTarget) {
- *target = surf;
- IDirectDrawSurface7_Release(surface);
- return DDENUMRET_CANCEL;
+ return ddraw7_EnumSurfaces((IDirectDraw7 *)ddraw_from_ddraw4(iface),
+ flags, surface_desc, context, (LPDDENUMSURFACESCALLBACK7)callback);
+}
+
+static HRESULT WINAPI ddraw3_EnumSurfaces(IDirectDraw3 *iface, DWORD flags,
+ DDSURFACEDESC *surface_desc, void *context, LPDDENUMSURFACESCALLBACK callback)
+{
+ struct surfacescallback_context cbcontext;
+
+ TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
+ iface, flags, surface_desc, context, callback);
+
+ cbcontext.func = callback;
+ cbcontext.context = context;
+
+ return ddraw7_EnumSurfaces((IDirectDraw7 *)ddraw_from_ddraw3(iface), flags,
+ (DDSURFACEDESC2 *)surface_desc, &cbcontext, EnumSurfacesCallbackThunk);
+}
+
+static HRESULT WINAPI ddraw2_EnumSurfaces(IDirectDraw2 *iface, DWORD flags,
+ DDSURFACEDESC *surface_desc, void *context, LPDDENUMSURFACESCALLBACK callback)
+{
+ struct surfacescallback_context cbcontext;
+
+ TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
+ iface, flags, surface_desc, context, callback);
+
+ cbcontext.func = callback;
+ cbcontext.context = context;
+
+ return ddraw7_EnumSurfaces((IDirectDraw7 *)ddraw_from_ddraw2(iface), flags,
+ (DDSURFACEDESC2 *)surface_desc, &cbcontext, EnumSurfacesCallbackThunk);
+}
+
+static HRESULT WINAPI ddraw1_EnumSurfaces(IDirectDraw *iface, DWORD flags,
+ DDSURFACEDESC *surface_desc, void *context, LPDDENUMSURFACESCALLBACK callback)
+{
+ struct surfacescallback_context cbcontext;
+
+ TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
+ iface, flags, surface_desc, context, callback);
+
+ cbcontext.func = callback;
+ cbcontext.context = context;
+
+ return ddraw7_EnumSurfaces((IDirectDraw7 *)ddraw_from_ddraw1(iface), flags,
+ (DDSURFACEDESC2 *)surface_desc, &cbcontext, EnumSurfacesCallbackThunk);
+}
+
+/*****************************************************************************
+ * DirectDrawCreateClipper (DDRAW.@)
+ *
+ * Creates a new IDirectDrawClipper object.
+ *
+ * Params:
+ * Clipper: Address to write the interface pointer to
+ * UnkOuter: For aggregation support, which ddraw doesn't have. Has to be
+ * NULL
+ *
+ * Returns:
+ * CLASS_E_NOAGGREGATION if UnkOuter != NULL
+ * E_OUTOFMEMORY if allocating the object failed
+ *
+ *****************************************************************************/
+HRESULT WINAPI
+DirectDrawCreateClipper(DWORD Flags,
+ LPDIRECTDRAWCLIPPER *Clipper,
+ IUnknown *UnkOuter)
+{
+ IDirectDrawClipperImpl* object;
+ HRESULT hr;
+
+ TRACE("flags %#x, clipper %p, outer_unknown %p.\n",
+ Flags, Clipper, UnkOuter);
+
+ EnterCriticalSection(&ddraw_cs);
+ if (UnkOuter != NULL)
+ {
+ LeaveCriticalSection(&ddraw_cs);
+ return CLASS_E_NOAGGREGATION;
}
- /* Recurse into the surface tree */
- IDirectDrawSurface7_EnumAttachedSurfaces(surface, ctx, findRenderTarget);
+ if (!LoadWineD3D())
+ {
+ LeaveCriticalSection(&ddraw_cs);
+ return DDERR_NODIRECTDRAWSUPPORT;
+ }
- IDirectDrawSurface7_Release(surface);
- if(*target) return DDENUMRET_CANCEL;
- else return DDENUMRET_OK; /* Continue with the next neighbor surface */
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+ sizeof(IDirectDrawClipperImpl));
+ if (object == NULL)
+ {
+ LeaveCriticalSection(&ddraw_cs);
+ return E_OUTOFMEMORY;
+ }
+
+ hr = ddraw_clipper_init(object);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize clipper, hr %#x.\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ LeaveCriticalSection(&ddraw_cs);
+ return hr;
+ }
+
+ TRACE("Created clipper %p.\n", object);
+ *Clipper = (IDirectDrawClipper *) object;
+ LeaveCriticalSection(&ddraw_cs);
+ return DD_OK;
+}
+
+/*****************************************************************************
+ * IDirectDraw7::CreateClipper
+ *
+ * Creates a DDraw clipper. See DirectDrawCreateClipper for details
+ *
+ *****************************************************************************/
+static HRESULT WINAPI ddraw7_CreateClipper(IDirectDraw7 *iface, DWORD Flags,
+ IDirectDrawClipper **Clipper, IUnknown *UnkOuter)
+{
+ TRACE("iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
+ iface, Flags, Clipper, UnkOuter);
+
+ return DirectDrawCreateClipper(Flags, Clipper, UnkOuter);
+}
+
+static HRESULT WINAPI ddraw4_CreateClipper(IDirectDraw4 *iface,
+ DWORD flags, IDirectDrawClipper **clipper, IUnknown *outer_unknown)
+{
+ 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);
+}
+
+static HRESULT WINAPI ddraw3_CreateClipper(IDirectDraw3 *iface,
+ DWORD flags, IDirectDrawClipper **clipper, IUnknown *outer_unknown)
+{
+ 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);
+}