Commit f3840daf authored by Sven Hesse's avatar Sven Hesse Committed by Alexandre Julliard

d3d11: Implement d3d11_device_CreateTexture1D().

parent ca9d03a7
......@@ -112,6 +112,21 @@ void skip_dword_unknown(const char **ptr, unsigned int count) DECLSPEC_HIDDEN;
HRESULT parse_dxbc(const char *data, SIZE_T data_size,
HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) DECLSPEC_HIDDEN;
/* ID3D11Texture1D, ID3D10Texture1D */
struct d3d_texture1d
{
ID3D11Texture1D ID3D11Texture1D_iface;
ID3D10Texture1D ID3D10Texture1D_iface;
LONG refcount;
struct wined3d_private_store private_store;
D3D11_TEXTURE1D_DESC desc;
ID3D11Device *device;
};
HRESULT d3d_texture1d_create(struct d3d_device *device, const D3D11_TEXTURE1D_DESC *desc,
const D3D11_SUBRESOURCE_DATA *data, struct d3d_texture1d **texture) DECLSPEC_HIDDEN;
/* ID3D11Texture2D, ID3D10Texture2D */
struct d3d_texture2d
{
......
......@@ -2764,9 +2764,18 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBuffer(ID3D11Device *iface,
static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture1D(ID3D11Device *iface,
const D3D11_TEXTURE1D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture1D **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 d3d_texture1d *object;
HRESULT hr;
return E_NOTIMPL;
TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
if (FAILED(hr = d3d_texture1d_create(device, desc, data, &object)))
return hr;
*texture = &object->ID3D11Texture1D_iface;
return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture2D(ID3D11Device *iface,
......
......@@ -1825,6 +1825,97 @@ static void test_get_immediate_context(void)
ok(!refcount, "Device has %u references left.\n", refcount);
}
static void test_create_texture1d(void)
{
ULONG refcount, expected_refcount;
ID3D11Device *device, *tmp;
D3D11_TEXTURE1D_DESC desc;
ID3D11Texture1D *texture;
unsigned int i;
HRESULT hr;
if (!(device = create_device(NULL)))
{
skip("Failed to create device.\n");
return;
}
desc.Width = 512;
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
desc.CPUAccessFlags = 0;
desc.MiscFlags = 0;
expected_refcount = get_refcount(device) + 1;
hr = ID3D11Device_CreateTexture1D(device, &desc, NULL, &texture);
ok(SUCCEEDED(hr), "Failed to create a 1d texture, hr %#x.\n", hr);
refcount = get_refcount(device);
ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
tmp = NULL;
expected_refcount = refcount + 1;
ID3D11Texture1D_GetDevice(texture, &tmp);
ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
refcount = get_refcount(device);
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
ID3D11Device_Release(tmp);
ID3D11Texture1D_Release(texture);
desc.MipLevels = 0;
expected_refcount = get_refcount(device) + 1;
hr = ID3D11Device_CreateTexture1D(device, &desc, NULL, &texture);
ok(SUCCEEDED(hr), "Failed to create a 1d texture, hr %#x.\n", hr);
refcount = get_refcount(device);
ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
tmp = NULL;
expected_refcount = refcount + 1;
ID3D11Texture1D_GetDevice(texture, &tmp);
ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
refcount = get_refcount(device);
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
ID3D11Device_Release(tmp);
ID3D11Texture1D_GetDesc(texture, &desc);
ok(desc.Width == 512, "Got unexpected Width %u.\n", desc.Width);
ok(desc.MipLevels == 10, "Got unexpected MipLevels %u.\n", desc.MipLevels);
ok(desc.ArraySize == 1, "Got unexpected ArraySize %u.\n", desc.ArraySize);
ok(desc.Format == DXGI_FORMAT_R8G8B8A8_UNORM, "Got unexpected Format %#x.\n", desc.Format);
ok(desc.Usage == D3D11_USAGE_DEFAULT, "Got unexpected Usage %u.\n", desc.Usage);
ok(desc.BindFlags == D3D11_BIND_SHADER_RESOURCE, "Got unexpected BindFlags %#x.\n", desc.BindFlags);
ok(desc.CPUAccessFlags == 0, "Got unexpected CPUAccessFlags %#x.\n", desc.CPUAccessFlags);
ok(desc.MiscFlags == 0, "Got unexpected MiscFlags %#x.\n", desc.MiscFlags);
check_interface(texture, &IID_IDXGISurface, FALSE, FALSE);
ID3D11Texture1D_Release(texture);
desc.MipLevels = 1;
desc.ArraySize = 2;
hr = ID3D11Device_CreateTexture1D(device, &desc, NULL, &texture);
ok(SUCCEEDED(hr), "Failed to create a 1d texture, hr %#x.\n", hr);
check_interface(texture, &IID_IDXGISurface, FALSE, FALSE);
ID3D11Texture1D_Release(texture);
for (i = 0; i < 4; ++i)
{
desc.ArraySize = i;
desc.Format = DXGI_FORMAT_R32G32B32A32_TYPELESS;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
desc.MiscFlags = 0;
hr = ID3D11Device_CreateTexture1D(device, &desc, NULL, (ID3D11Texture1D **)&texture);
todo_wine_if(!i)
ok(hr == (i ? S_OK : E_INVALIDARG), "Test %u: Got unexpected hr %#x.\n", i, hr);
if (SUCCEEDED(hr))
ID3D11Texture1D_Release(texture);
}
refcount = ID3D11Device_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
}
static void test_create_texture2d(void)
{
ULONG refcount, expected_refcount;
......@@ -25114,6 +25205,7 @@ START_TEST(d3d11)
test_create_device();
run_for_each_feature_level(test_device_interfaces);
test_get_immediate_context();
test_create_texture1d();
test_create_texture2d();
test_texture2d_interfaces();
test_create_texture3d();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment