Commit bf8171a3 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d3d11/tests: Add some tests for IDXGIResource support.

parent 76a0108c
...@@ -2499,6 +2499,63 @@ static void test_create_texture1d(void) ...@@ -2499,6 +2499,63 @@ static void test_create_texture1d(void)
ok(!refcount, "Device has %lu references left.\n", refcount); ok(!refcount, "Device has %lu references left.\n", refcount);
} }
#define test_dxgi_resource(a) test_dxgi_resource_(__LINE__, a)
static void test_dxgi_resource_(unsigned int line, void *iface)
{
IDXGIResource *resource, *resource2;
IDXGISurface *surface, *surface2;
IUnknown *object = iface, *unk;
DWORD data;
HRESULT hr;
UINT size;
hr = IUnknown_QueryInterface(object, &IID_IDXGIResource, (void **)&resource);
ok_(__FILE__, line)(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
if (FAILED(hr)) return;
if (SUCCEEDED(IUnknown_QueryInterface(object, &IID_IDXGISurface, (void **)&surface)))
{
hr = IDXGISurface_QueryInterface(surface, &IID_IDXGIDeviceSubObject, (void **)&unk);
ok_(__FILE__, line)(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
ok_(__FILE__, line)((IUnknown *)resource == unk, "Unexpected interface pointer.\n");
IUnknown_Release(unk);
hr = IDXGISurface_QueryInterface(surface, &IID_IDXGIObject, (void **)&unk);
ok_(__FILE__, line)(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
ok_(__FILE__, line)((IUnknown *)resource == unk, "Unexpected interface pointer.\n");
IUnknown_Release(unk);
hr = IDXGISurface_QueryInterface(surface, &IID_IDXGIResource, (void **)&resource2);
ok_(__FILE__, line)(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
ok_(__FILE__, line)(resource2 == resource, "Unexpected resource pointer.\n");
IDXGIResource_Release(resource2);
hr = IDXGIResource_QueryInterface(resource, &IID_IDXGISurface, (void **)&surface2);
ok_(__FILE__, line)(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
ok_(__FILE__, line)(surface2 == surface, "Unexpected surface pointer.\n");
IDXGISurface_Release(surface2);
hr = IDXGISurface_GetParent(surface, &IID_IDXGIResource, (void **)&resource2);
ok_(__FILE__, line)(hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
hr = IDXGIResource_GetParent(resource, &IID_IDXGISurface, (void **)&surface2);
ok_(__FILE__, line)(hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
data = 123;
hr = IDXGIResource_SetPrivateData(resource, &IID_IUnknown, sizeof(data), &data);
ok_(__FILE__, line)(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
size = sizeof(data);
data = 0;
hr = IDXGISurface_GetPrivateData(surface, &IID_IUnknown, &size, &data);
ok_(__FILE__, line)(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
ok_(__FILE__, line)(data == 123, "Unexpected data %#lx.\n", data);
IDXGISurface_Release(surface);
}
IDXGIResource_Release(resource);
}
static void test_texture1d_interfaces(void) static void test_texture1d_interfaces(void)
{ {
ID3D10Texture1D *d3d10_texture; ID3D10Texture1D *d3d10_texture;
...@@ -2548,7 +2605,7 @@ static void test_texture1d_interfaces(void) ...@@ -2548,7 +2605,7 @@ static void test_texture1d_interfaces(void)
} }
desc.Width = 512; desc.Width = 512;
desc.MipLevels = 0; desc.MipLevels = 1;
desc.ArraySize = 1; desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.Usage = D3D11_USAGE_DEFAULT; desc.Usage = D3D11_USAGE_DEFAULT;
...@@ -2558,7 +2615,18 @@ static void test_texture1d_interfaces(void) ...@@ -2558,7 +2615,18 @@ static void test_texture1d_interfaces(void)
hr = ID3D11Device_CreateTexture1D(device, &desc, NULL, &texture); hr = ID3D11Device_CreateTexture1D(device, &desc, NULL, &texture);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
todo_wine
test_dxgi_resource(texture);
ID3D11Texture1D_Release(texture);
desc.MipLevels = 0;
hr = ID3D11Device_CreateTexture1D(device, &desc, NULL, &texture);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
todo_wine
test_dxgi_resource(texture);
check_interface(texture, &IID_IDXGISurface, FALSE, FALSE); check_interface(texture, &IID_IDXGISurface, FALSE, FALSE);
todo_wine
check_interface(texture, &IID_IDXGIResource, TRUE, FALSE);
hr = check_interface(texture, &IID_ID3D10Texture1D, TRUE, TRUE); /* Not available on all Windows versions. */ hr = check_interface(texture, &IID_ID3D10Texture1D, TRUE, TRUE); /* Not available on all Windows versions. */
ID3D11Texture1D_Release(texture); ID3D11Texture1D_Release(texture);
if (FAILED(hr)) if (FAILED(hr))
...@@ -2934,7 +3002,7 @@ static void test_texture2d_interfaces(void) ...@@ -2934,7 +3002,7 @@ static void test_texture2d_interfaces(void)
desc.Width = 512; desc.Width = 512;
desc.Height = 512; desc.Height = 512;
desc.MipLevels = 0; desc.MipLevels = 1;
desc.ArraySize = 1; desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.SampleDesc.Count = 1; desc.SampleDesc.Count = 1;
...@@ -2946,7 +3014,21 @@ static void test_texture2d_interfaces(void) ...@@ -2946,7 +3014,21 @@ static void test_texture2d_interfaces(void)
hr = ID3D11Device_CreateTexture2D(device, &desc, NULL, &texture); hr = ID3D11Device_CreateTexture2D(device, &desc, NULL, &texture);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
check_interface(texture, &IID_IDXGISurface, TRUE, FALSE);
todo_wine
check_interface(texture, &IID_IDXGIResource, TRUE, FALSE);
todo_wine
test_dxgi_resource(texture);
ID3D11Texture2D_Release(texture);
desc.MipLevels = 0;
hr = ID3D11Device_CreateTexture2D(device, &desc, NULL, &texture);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
check_interface(texture, &IID_IDXGISurface, FALSE, FALSE); check_interface(texture, &IID_IDXGISurface, FALSE, FALSE);
todo_wine
check_interface(texture, &IID_IDXGIResource, TRUE, FALSE);
todo_wine
test_dxgi_resource(texture);
hr = check_interface(texture, &IID_ID3D10Texture2D, TRUE, TRUE); /* Not available on all Windows versions. */ hr = check_interface(texture, &IID_ID3D10Texture2D, TRUE, TRUE); /* Not available on all Windows versions. */
ID3D11Texture2D_Release(texture); ID3D11Texture2D_Release(texture);
if (FAILED(hr)) if (FAILED(hr))
...@@ -3211,6 +3293,10 @@ static void test_texture3d_interfaces(void) ...@@ -3211,6 +3293,10 @@ static void test_texture3d_interfaces(void)
hr = ID3D11Device_CreateTexture3D(device, &desc, NULL, &texture); hr = ID3D11Device_CreateTexture3D(device, &desc, NULL, &texture);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
check_interface(texture, &IID_IDXGISurface, FALSE, FALSE); check_interface(texture, &IID_IDXGISurface, FALSE, FALSE);
todo_wine
check_interface(texture, &IID_IDXGIResource, TRUE, FALSE);
todo_wine
test_dxgi_resource(texture);
hr = check_interface(texture, &IID_ID3D10Texture3D, TRUE, TRUE); /* Not available on all Windows versions. */ hr = check_interface(texture, &IID_ID3D10Texture3D, TRUE, TRUE); /* Not available on all Windows versions. */
ID3D11Texture3D_Release(texture); ID3D11Texture3D_Release(texture);
if (FAILED(hr)) if (FAILED(hr))
...@@ -3526,6 +3612,9 @@ static void test_create_buffer(void) ...@@ -3526,6 +3612,9 @@ static void test_create_buffer(void)
continue; continue;
} }
todo_wine
check_interface(buffer, &IID_IDXGIResource, TRUE, FALSE);
if (!(desc.MiscFlags & D3D11_RESOURCE_MISC_BUFFER_STRUCTURED)) if (!(desc.MiscFlags & D3D11_RESOURCE_MISC_BUFFER_STRUCTURED))
desc.StructureByteStride = 0; desc.StructureByteStride = 0;
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