d3d11: Implement d3d11_device_CreateTexture2D().

This commit is contained in:
Józef Kucia 2015-08-30 22:44:42 +02:00 committed by Alexandre Julliard
parent a24ff27386
commit e0e72d284a
3 changed files with 38 additions and 17 deletions

View File

@ -112,8 +112,8 @@ static inline struct d3d10_texture2d *impl_from_ID3D10Texture2D(ID3D10Texture2D
return CONTAINING_RECORD(iface, struct d3d10_texture2d, ID3D10Texture2D_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;
HRESULT d3d_texture2d_create(struct d3d_device *device, const D3D11_TEXTURE2D_DESC *desc,
const D3D11_SUBRESOURCE_DATA *data, struct d3d10_texture2d **texture) DECLSPEC_HIDDEN;
struct d3d10_texture2d *unsafe_impl_from_ID3D10Texture2D(ID3D10Texture2D *iface) DECLSPEC_HIDDEN;
/* ID3D10Texture3D */

View File

@ -75,9 +75,18 @@ 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);
if (FAILED(hr = d3d_texture2d_create(device, desc, data, &object)))
return hr;
*texture = &object->ID3D11Texture2D_iface;
return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture3D(ID3D11Device *iface,
@ -2011,10 +2020,6 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *ifa
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,17 +2031,11 @@ 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 = d3d_texture2d_create(device, &d3d11_desc, (const D3D11_SUBRESOURCE_DATA *)data, &object)))
return hr;
}
*texture = &object->ID3D10Texture2D_iface;
TRACE("Created ID3D10Texture2D %p\n", object);
return S_OK;
}

View File

@ -444,8 +444,8 @@ static const struct wined3d_parent_ops d3d10_texture2d_wined3d_parent_ops =
d3d10_texture2d_wined3d_object_released,
};
HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d_device *device,
const D3D11_TEXTURE2D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data)
static HRESULT d3d_texture2d_init(struct d3d10_texture2d *texture, struct d3d_device *device,
const D3D11_TEXTURE2D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data)
{
struct wined3d_resource_desc wined3d_desc;
unsigned int levels;
@ -520,6 +520,28 @@ HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d_device
return S_OK;
}
HRESULT d3d_texture2d_create(struct d3d_device *device, const D3D11_TEXTURE2D_DESC *desc,
const D3D11_SUBRESOURCE_DATA *data, struct d3d10_texture2d **texture)
{
struct d3d10_texture2d *object;
HRESULT hr;
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d3d_texture2d_init(object, device, desc, data)))
{
WARN("Failed to initialize texture, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created texture %p.\n", object);
*texture = object;
return S_OK;
}
static inline struct d3d10_texture3d *impl_from_ID3D10Texture3D(ID3D10Texture3D *iface)
{
return CONTAINING_RECORD(iface, struct d3d10_texture3d, ID3D10Texture3D_iface);