[PATCH 3/5] d3d11: Implement d3d11_device_CreateTexture2D().

Józef Kucia jkucia at codeweavers.com
Thu Aug 27 17:39:17 CDT 2015


---
 dlls/d3d11/d3d11_private.h |  7 ++++++-
 dlls/d3d11/device.c        | 38 ++++++++++++++++++++++++++------------
 dlls/d3d11/texture.c       |  7 +------
 3 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h
index baff284..89b1108 100644
--- a/dlls/d3d11/d3d11_private.h
+++ b/dlls/d3d11/d3d11_private.h
@@ -112,8 +112,13 @@ static inline struct d3d10_texture2d *impl_from_ID3D10Texture2D(ID3D10Texture2D
     return CONTAINING_RECORD(iface, struct d3d10_texture2d, ID3D10Texture2D_iface);
 }
 
+static inline struct d3d10_texture2d *impl_from_ID3D11Texture2D(ID3D11Texture2D *iface)
+{
+    return CONTAINING_RECORD(iface, struct d3d10_texture2d, ID3D11Texture2D_iface);
+}
+
 HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d_device *device,
-        const D3D11_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *initial_data) DECLSPEC_HIDDEN;
+        const D3D11_TEXTURE2D_DESC *desc, const D3D11_SUBRESOURCE_DATA *initial_data) DECLSPEC_HIDDEN;
 struct d3d10_texture2d *unsafe_impl_from_ID3D10Texture2D(ID3D10Texture2D *iface) DECLSPEC_HIDDEN;
 
 /* ID3D10Texture3D */
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 9067de9..6a46614 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -75,9 +75,28 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture1D(ID3D11Device *ifac
 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture2D(ID3D11Device *iface,
         const D3D11_TEXTURE2D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture2D **texture)
 {
-    FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
+    struct d3d_device *device = impl_from_ID3D11Device(iface);
+    struct d3d10_texture2d *object;
+    HRESULT hr;
 
-    return E_NOTIMPL;
+    TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
+
+    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+    if (!object)
+        return E_OUTOFMEMORY;
+
+    if (FAILED(hr = d3d10_texture2d_init(object, device, desc, data)))
+    {
+        WARN("Failed to initialize texture, hr %#x.\n", hr);
+        HeapFree(GetProcessHeap(), 0, object);
+        return hr;
+    }
+
+    *texture = &object->ID3D11Texture2D_iface;
+
+    TRACE("Created ID3D11Texture2D %p.\n", object);
+
+    return S_OK;
 }
 
 static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture3D(ID3D11Device *iface,
@@ -2006,15 +2025,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *ifa
 {
     struct d3d_device *device = impl_from_ID3D10Device(iface);
     D3D11_TEXTURE2D_DESC d3d11_desc;
+    ID3D11Texture2D *d3d11_texture;
     struct d3d10_texture2d *object;
     HRESULT hr;
 
     TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
 
-    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
-    if (!object)
-        return E_OUTOFMEMORY;
-
     d3d11_desc.Width = desc->Width;
     d3d11_desc.Height = desc->Height;
     d3d11_desc.MipLevels = desc->MipLevels;
@@ -2026,16 +2042,14 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *ifa
     d3d11_desc.CPUAccessFlags = d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc->CPUAccessFlags);
     d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags);
 
-    if (FAILED(hr = d3d10_texture2d_init(object, device, &d3d11_desc, data)))
-    {
-        WARN("Failed to initialize texture, hr %#x.\n", hr);
-        HeapFree(GetProcessHeap(), 0, object);
+    if (FAILED(hr = d3d11_device_CreateTexture2D(&device->ID3D11Device_iface, &d3d11_desc,
+            (const D3D11_SUBRESOURCE_DATA *)data, &d3d11_texture)))
         return hr;
-    }
 
+    object = impl_from_ID3D11Texture2D(d3d11_texture);
     *texture = &object->ID3D10Texture2D_iface;
 
-    TRACE("Created ID3D10Texture2D %p\n", object);
+    TRACE("Created ID3D10Texture2D %p.\n", object);
 
     return S_OK;
 }
diff --git a/dlls/d3d11/texture.c b/dlls/d3d11/texture.c
index eac1569..dbe02ff 100644
--- a/dlls/d3d11/texture.c
+++ b/dlls/d3d11/texture.c
@@ -26,11 +26,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d11);
 
 /* ID3D11Texture2D methods */
 
-static inline struct d3d10_texture2d *impl_from_ID3D11Texture2D(ID3D11Texture2D *iface)
-{
-    return CONTAINING_RECORD(iface, struct d3d10_texture2d, ID3D11Texture2D_iface);
-}
-
 static HRESULT STDMETHODCALLTYPE d3d11_texture2d_QueryInterface(ID3D11Texture2D *iface, REFIID riid, void **object)
 {
     struct d3d10_texture2d *texture = impl_from_ID3D11Texture2D(iface);
@@ -445,7 +440,7 @@ static const struct wined3d_parent_ops d3d10_texture2d_wined3d_parent_ops =
 };
 
 HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d_device *device,
-        const D3D11_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data)
+        const D3D11_TEXTURE2D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data)
 {
     struct wined3d_resource_desc wined3d_desc;
     unsigned int levels;
-- 
2.4.6




More information about the wine-patches mailing list