d3d10core: Implement device_parent_CreateSurface().
Henri Verbeet
hverbeet at gmail.com
Mon Jan 19 03:39:05 CST 2009
---
dlls/d3d10core/d3d10core_private.h | 3 ++
dlls/d3d10core/device.c | 64 ++++++++++++++++++++++++++++++++-
dlls/d3d10core/texture2d.c | 6 +++
dlls/dxgi/Makefile.in | 2 -
dlls/dxgi/device.c | 48 ++++++++++++++++++-------
dlls/dxgi/dxgi_private.h | 6 ++--
dlls/dxgi/dxgi_private_interface.idl | 39 --------------------
include/wine/winedxgi.idl | 49 ++++++++++++++++++++++++++
tools/make_makefiles | 1 +
9 files changed, 158 insertions(+), 60 deletions(-)
delete mode 100644 dlls/dxgi/dxgi_private_interface.idl
create mode 100644 include/wine/winedxgi.idl
diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h
index fa645cc..1b28d5e 100644
--- a/dlls/d3d10core/d3d10core_private.h
+++ b/dlls/d3d10core/d3d10core_private.h
@@ -32,6 +32,7 @@
#include "initguid.h"
#endif
#include "wine/wined3d.h"
+#include "wine/winedxgi.h"
/* TRACE helper functions */
const char *debug_d3d10_primitive_topology(D3D10_PRIMITIVE_TOPOLOGY topology);
@@ -56,6 +57,8 @@ struct d3d10_texture2d
{
const struct ID3D10Texture2DVtbl *vtbl;
LONG refcount;
+
+ IWineD3DSurface *wined3d_surface;
};
/* Layered device */
diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index 132b70a..965bd49 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -575,6 +575,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device *ifac
const D3D10_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture2D **texture)
{
struct d3d10_texture2d *object;
+ HRESULT hr;
FIXME("iface %p, desc %p, data %p, texture %p partial stub!\n", iface, desc, data, texture);
@@ -587,6 +588,37 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device *ifac
object->vtbl = &d3d10_texture2d_vtbl;
object->refcount = 1;
+
+ if (desc->MipLevels == 1 && desc->ArraySize == 1)
+ {
+ IWineD3DDevice *wined3d_device;
+ IWineDXGIDevice *wine_device;
+
+ hr = ID3D10Device_QueryInterface(iface, &IID_IWineDXGIDevice, (void **)&wine_device);
+ if (FAILED(hr))
+ {
+ ERR("Device should implement IWineDXGIDevice\n");
+ HeapFree(GetProcessHeap(), 0, object);
+ return E_FAIL;
+ }
+
+ wined3d_device = IWineDXGIDevice_get_wined3d_device(wine_device);
+ IWineDXGIDevice_Release(wine_device);
+
+ FIXME("Implement DXGI<->wined3d format and usage conversion\n");
+
+ hr = IWineD3DDevice_CreateSurface(wined3d_device, desc->Width, desc->Height, desc->Format, FALSE,
+ FALSE, 0, &object->wined3d_surface, WINED3DRTYPE_SURFACE, desc->Usage, WINED3DPOOL_DEFAULT,
+ desc->SampleDesc.Count, desc->SampleDesc.Quality, NULL, SURFACE_OPENGL, (IUnknown *)object);
+ IWineD3DDevice_Release(wined3d_device);
+ if (FAILED(hr))
+ {
+ ERR("CreateSurface failed, returning %#x\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ return hr;
+ }
+ }
+
*texture = (ID3D10Texture2D *)object;
TRACE("Created ID3D10Texture2D %p\n", object);
@@ -937,11 +969,39 @@ static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParen
IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
{
+ struct d3d10_device *This = device_from_device_parent(iface);
+ struct d3d10_texture2d *texture;
+ D3D10_TEXTURE2D_DESC desc;
+ HRESULT hr;
+
FIXME("iface %p, superior %p, width %u, height %u, format %#x, usage %#x,\n"
- "\tpool %#x, level %u, face %u, surface %p stub!\n",
+ "\tpool %#x, level %u, face %u, surface %p partial stub!\n",
iface, superior, width, height, format, usage, pool, level, face, surface);
- return E_NOTIMPL;
+ FIXME("Implement DXGI<->wined3d format and usage conversion\n");
+
+ desc.Width = width;
+ desc.Height = height;
+ desc.MipLevels = 1;
+ desc.ArraySize = 1;
+ desc.Format = format;
+ desc.SampleDesc.Count = 1;
+ desc.SampleDesc.Quality = 0;
+ desc.Usage = usage;
+ desc.BindFlags = 0;
+ desc.CPUAccessFlags = 0;
+ desc.MiscFlags = 0;
+
+ hr = d3d10_device_CreateTexture2D((ID3D10Device *)This, &desc, NULL, (ID3D10Texture2D **)&texture);
+ if (FAILED(hr))
+ {
+ ERR("CreateTexture2D failed, returning %#x\n", hr);
+ return hr;
+ }
+
+ *surface = texture->wined3d_surface;
+
+ return S_OK;
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateRenderTarget(IWineD3DDeviceParent *iface,
diff --git a/dlls/d3d10core/texture2d.c b/dlls/d3d10core/texture2d.c
index 9b57c61..d0fb0f5 100644
--- a/dlls/d3d10core/texture2d.c
+++ b/dlls/d3d10core/texture2d.c
@@ -63,6 +63,12 @@ static ULONG STDMETHODCALLTYPE d3d10_texture2d_Release(ID3D10Texture2D *iface)
TRACE("%p decreasing refcount to %u\n", This, refcount);
+ if (!refcount)
+ {
+ if (This->wined3d_surface) IWineD3DSurface_Release(This->wined3d_surface);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
return refcount;
}
diff --git a/dlls/dxgi/Makefile.in b/dlls/dxgi/Makefile.in
index 9215e61..d340b6f 100644
--- a/dlls/dxgi/Makefile.in
+++ b/dlls/dxgi/Makefile.in
@@ -17,8 +17,6 @@ C_SRCS = \
RC_SRCS = version.rc
-IDL_H_SRCS = dxgi_private_interface.idl
-
@MAKE_DLL_RULES@
@DEPENDENCIES@ # everything below this line is overwritten by make depend
diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c
index 69ba3e5..28bc9be 100644
--- a/dlls/dxgi/device.c
+++ b/dlls/dxgi/device.c
@@ -26,7 +26,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
/* IUnknown methods */
-static HRESULT STDMETHODCALLTYPE dxgi_device_QueryInterface(IDXGIDevice *iface, REFIID riid, void **object)
+static HRESULT STDMETHODCALLTYPE dxgi_device_QueryInterface(IWineDXGIDevice *iface, REFIID riid, void **object)
{
struct dxgi_device *This = (struct dxgi_device *)iface;
@@ -34,7 +34,8 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_QueryInterface(IDXGIDevice *iface,
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDXGIObject)
- || IsEqualGUID(riid, &IID_IDXGIDevice))
+ || IsEqualGUID(riid, &IID_IDXGIDevice)
+ || IsEqualGUID(riid, &IID_IWineDXGIDevice))
{
IUnknown_AddRef(iface);
*object = iface;
@@ -53,7 +54,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_QueryInterface(IDXGIDevice *iface,
return E_NOINTERFACE;
}
-static ULONG STDMETHODCALLTYPE dxgi_device_AddRef(IDXGIDevice *iface)
+static ULONG STDMETHODCALLTYPE dxgi_device_AddRef(IWineDXGIDevice *iface)
{
struct dxgi_device *This = (struct dxgi_device *)iface;
ULONG refcount = InterlockedIncrement(&This->refcount);
@@ -63,7 +64,7 @@ static ULONG STDMETHODCALLTYPE dxgi_device_AddRef(IDXGIDevice *iface)
return refcount;
}
-static ULONG STDMETHODCALLTYPE dxgi_device_Release(IDXGIDevice *iface)
+static ULONG STDMETHODCALLTYPE dxgi_device_Release(IWineDXGIDevice *iface)
{
struct dxgi_device *This = (struct dxgi_device *)iface;
ULONG refcount = InterlockedDecrement(&This->refcount);
@@ -85,28 +86,31 @@ static ULONG STDMETHODCALLTYPE dxgi_device_Release(IDXGIDevice *iface)
/* IDXGIObject methods */
-static HRESULT STDMETHODCALLTYPE dxgi_device_SetPrivateData(IDXGIDevice *iface, REFGUID guid, UINT data_size, const void *data)
+static HRESULT STDMETHODCALLTYPE dxgi_device_SetPrivateData(IWineDXGIDevice *iface,
+ REFGUID guid, UINT data_size, const void *data)
{
FIXME("iface %p, guid %s, data_size %u, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
return E_NOTIMPL;
}
-static HRESULT STDMETHODCALLTYPE dxgi_device_SetPrivateDataInterface(IDXGIDevice *iface, REFGUID guid, const IUnknown *object)
+static HRESULT STDMETHODCALLTYPE dxgi_device_SetPrivateDataInterface(IWineDXGIDevice *iface,
+ REFGUID guid, const IUnknown *object)
{
FIXME("iface %p, guid %s, object %p stub!\n", iface, debugstr_guid(guid), object);
return E_NOTIMPL;
}
-static HRESULT STDMETHODCALLTYPE dxgi_device_GetPrivateData(IDXGIDevice *iface, REFGUID guid, UINT *data_size, void *data)
+static HRESULT STDMETHODCALLTYPE dxgi_device_GetPrivateData(IWineDXGIDevice *iface,
+ REFGUID guid, UINT *data_size, void *data)
{
FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface, debugstr_guid(guid), data_size, data);
return E_NOTIMPL;
}
-static HRESULT STDMETHODCALLTYPE dxgi_device_GetParent(IDXGIDevice *iface, REFIID riid, void **parent)
+static HRESULT STDMETHODCALLTYPE dxgi_device_GetParent(IWineDXGIDevice *iface, REFIID riid, void **parent)
{
FIXME("iface %p, riid %s, parent %p stub!\n", iface, debugstr_guid(riid), parent);
@@ -115,7 +119,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_GetParent(IDXGIDevice *iface, REFII
/* IDXGIDevice methods */
-static HRESULT STDMETHODCALLTYPE dxgi_device_GetAdapter(IDXGIDevice *iface, IDXGIAdapter **adapter)
+static HRESULT STDMETHODCALLTYPE dxgi_device_GetAdapter(IWineDXGIDevice *iface, IDXGIAdapter **adapter)
{
struct dxgi_device *This = (struct dxgi_device *)iface;
WINED3DDEVICE_CREATION_PARAMETERS create_parameters;
@@ -137,7 +141,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_GetAdapter(IDXGIDevice *iface, IDXG
return IWineDXGIFactory_EnumAdapters(This->factory, create_parameters.AdapterOrdinal, adapter);
}
-static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IDXGIDevice *iface,
+static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *iface,
const DXGI_SURFACE_DESC *desc, UINT surface_count, DXGI_USAGE usage,
const DXGI_SHARED_RESOURCE *shared_resource, IDXGISurface **surface)
{
@@ -176,7 +180,7 @@ fail:
return hr;
}
-static HRESULT STDMETHODCALLTYPE dxgi_device_QueryResourceResidency(IDXGIDevice *iface,
+static HRESULT STDMETHODCALLTYPE dxgi_device_QueryResourceResidency(IWineDXGIDevice *iface,
IUnknown *const *resources, DXGI_RESIDENCY *residency, UINT resource_count)
{
FIXME("iface %p, resources %p, residency %p, resource_count %u stub!\n",
@@ -185,21 +189,35 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_QueryResourceResidency(IDXGIDevice
return E_NOTIMPL;
}
-static HRESULT STDMETHODCALLTYPE dxgi_device_SetGPUThreadPriority(IDXGIDevice *iface, INT priority)
+static HRESULT STDMETHODCALLTYPE dxgi_device_SetGPUThreadPriority(IWineDXGIDevice *iface, INT priority)
{
FIXME("iface %p, priority %d stub!\n", iface, priority);
return E_NOTIMPL;
}
-static HRESULT STDMETHODCALLTYPE dxgi_device_GetGPUThreadPriority(IDXGIDevice *iface, INT *priority)
+static HRESULT STDMETHODCALLTYPE dxgi_device_GetGPUThreadPriority(IWineDXGIDevice *iface, INT *priority)
{
FIXME("iface %p, priority %p stub!\n", iface, priority);
return E_NOTIMPL;
}
-const struct IDXGIDeviceVtbl dxgi_device_vtbl =
+/* IWineDXGIDevice methods */
+
+static IWineD3DDevice * STDMETHODCALLTYPE dxgi_device_get_wined3d_device(IWineDXGIDevice *iface)
+{
+ struct dxgi_device *This = (struct dxgi_device *)iface;
+
+ TRACE("iface %p\n", iface);
+
+ EnterCriticalSection(&dxgi_cs);
+ IWineD3DDevice_AddRef(This->wined3d_device);
+ LeaveCriticalSection(&dxgi_cs);
+ return This->wined3d_device;
+}
+
+const struct IWineDXGIDeviceVtbl dxgi_device_vtbl =
{
/* IUnknown methods */
dxgi_device_QueryInterface,
@@ -216,4 +234,6 @@ const struct IDXGIDeviceVtbl dxgi_device_vtbl =
dxgi_device_QueryResourceResidency,
dxgi_device_SetGPUThreadPriority,
dxgi_device_GetGPUThreadPriority,
+ /* IWineDXGIAdapter methods */
+ dxgi_device_get_wined3d_device,
};
diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h
index c7ed875..d19b9b1 100644
--- a/dlls/dxgi/dxgi_private.h
+++ b/dlls/dxgi/dxgi_private.h
@@ -32,7 +32,7 @@
#include "initguid.h"
#endif
#include "wine/wined3d.h"
-#include "dxgi_private_interface.h"
+#include "wine/winedxgi.h"
extern CRITICAL_SECTION dxgi_cs;
@@ -51,10 +51,10 @@ struct dxgi_factory
};
/* IDXGIDevice */
-extern const struct IDXGIDeviceVtbl dxgi_device_vtbl;
+extern const struct IWineDXGIDeviceVtbl dxgi_device_vtbl;
struct dxgi_device
{
- const struct IDXGIDeviceVtbl *vtbl;
+ const struct IWineDXGIDeviceVtbl *vtbl;
IUnknown *child_layer;
LONG refcount;
IWineD3DDevice *wined3d_device;
diff --git a/dlls/dxgi/dxgi_private_interface.idl b/dlls/dxgi/dxgi_private_interface.idl
deleted file mode 100644
index 2bb8b43..0000000
--- a/dlls/dxgi/dxgi_private_interface.idl
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2008 Henri Verbeet for CodeWeavers
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-import "dxgi.idl";
-
-[
- object,
- local,
- uuid(a07ad9ab-fb01-4574-8bfb-0a70a7373f04)
-]
-interface IWineDXGIFactory : IDXGIFactory
-{
- struct IWineD3D *get_wined3d();
-}
-
-[
- object,
- local,
- uuid(ab1de34c-2963-4ffd-8493-40f580e510e5)
-]
-interface IWineDXGIAdapter : IDXGIAdapter
-{
- UINT get_ordinal();
-}
diff --git a/include/wine/winedxgi.idl b/include/wine/winedxgi.idl
new file mode 100644
index 0000000..860b695
--- /dev/null
+++ b/include/wine/winedxgi.idl
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2008-2009 Henri Verbeet for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+import "dxgi.idl";
+
+[
+ object,
+ local,
+ uuid(a07ad9ab-fb01-4574-8bfb-0a70a7373f04)
+]
+interface IWineDXGIFactory : IDXGIFactory
+{
+ struct IWineD3D *get_wined3d();
+}
+
+[
+ object,
+ local,
+ uuid(ab1de34c-2963-4ffd-8493-40f580e510e5)
+]
+interface IWineDXGIAdapter : IDXGIAdapter
+{
+ UINT get_ordinal();
+}
+
+[
+ object,
+ local,
+ uuid(3e1ff30b-c951-48c3-b010-0fb49f3dca71)
+]
+interface IWineDXGIDevice : IDXGIDevice
+{
+ struct IWineD3DDevice *get_wined3d_device();
+}
diff --git a/tools/make_makefiles b/tools/make_makefiles
index 86dcd4c..d134d8e 100755
--- a/tools/make_makefiles
+++ b/tools/make_makefiles
@@ -116,6 +116,7 @@ my %private_idl_headers = (
"dyngraph.idl" => 1,
"vmrender.idl" => 1,
"wine/wined3d.idl" => 1,
+ "wine/winedxgi.idl" => 1,
);
my (@makefiles, %makefiles);
--
1.6.0.6
--------------020201060609080607060609--
More information about the wine-patches
mailing list