d3d10_1/tests: Port test_create_shader_resource_view() from d3d10core.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2015-10-20 01:46:41 +02:00 committed by Alexandre Julliard
parent b90215f350
commit 22c05cb59f
4 changed files with 160 additions and 0 deletions

1
configure vendored
View File

@ -17353,6 +17353,7 @@ wine_fn_config_test dlls/d2d1/tests d2d1_test
wine_fn_config_dll d3d10 enable_d3d10 implib wine_fn_config_dll d3d10 enable_d3d10 implib
wine_fn_config_test dlls/d3d10/tests d3d10_test wine_fn_config_test dlls/d3d10/tests d3d10_test
wine_fn_config_dll d3d10_1 enable_d3d10_1 implib wine_fn_config_dll d3d10_1 enable_d3d10_1 implib
wine_fn_config_test dlls/d3d10_1/tests d3d10_1_test
wine_fn_config_dll d3d10core enable_d3d10core implib wine_fn_config_dll d3d10core enable_d3d10core implib
wine_fn_config_test dlls/d3d10core/tests d3d10core_test wine_fn_config_test dlls/d3d10core/tests d3d10core_test
wine_fn_config_dll d3d11 enable_d3d11 implib wine_fn_config_dll d3d11 enable_d3d11 implib

View File

@ -2864,6 +2864,7 @@ WINE_CONFIG_TEST(dlls/d2d1/tests)
WINE_CONFIG_DLL(d3d10,,[implib]) WINE_CONFIG_DLL(d3d10,,[implib])
WINE_CONFIG_TEST(dlls/d3d10/tests) WINE_CONFIG_TEST(dlls/d3d10/tests)
WINE_CONFIG_DLL(d3d10_1,,[implib]) WINE_CONFIG_DLL(d3d10_1,,[implib])
WINE_CONFIG_TEST(dlls/d3d10_1/tests)
WINE_CONFIG_DLL(d3d10core,,[implib]) WINE_CONFIG_DLL(d3d10core,,[implib])
WINE_CONFIG_TEST(dlls/d3d10core/tests) WINE_CONFIG_TEST(dlls/d3d10core/tests)
WINE_CONFIG_DLL(d3d11,,[implib]) WINE_CONFIG_DLL(d3d11,,[implib])

View File

@ -0,0 +1,5 @@
TESTDLL = d3d10_1.dll
IMPORTS = d3d10_1
C_SRCS = \
d3d10_1.c

View File

@ -0,0 +1,153 @@
/*
* Copyright 2008 Henri Verbeet for CodeWeavers
* Copyright 2015 Józef Kucia 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
*/
#define COBJMACROS
#include "initguid.h"
#include "d3d11.h"
#include "wine/test.h"
static ULONG get_refcount(IUnknown *iface)
{
IUnknown_AddRef(iface);
return IUnknown_Release(iface);
}
static ID3D10Device1 *create_device(D3D10_FEATURE_LEVEL1 feature_level)
{
ID3D10Device1 *device;
if (SUCCEEDED(D3D10CreateDevice1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, feature_level, D3D10_1_SDK_VERSION,
&device)))
return device;
if (SUCCEEDED(D3D10CreateDevice1(NULL, D3D10_DRIVER_TYPE_WARP, NULL, 0, feature_level, D3D10_1_SDK_VERSION,
&device)))
return device;
if (SUCCEEDED(D3D10CreateDevice1(NULL, D3D10_DRIVER_TYPE_REFERENCE, NULL, 0, feature_level, D3D10_1_SDK_VERSION,
&device)))
return device;
return NULL;
}
static void test_create_shader_resource_view(void)
{
D3D10_SHADER_RESOURCE_VIEW_DESC1 srv_desc;
D3D10_TEXTURE2D_DESC texture_desc;
ULONG refcount, expected_refcount;
ID3D10ShaderResourceView1 *srview;
D3D10_BUFFER_DESC buffer_desc;
ID3D10Texture2D *texture;
ID3D10Device *tmp_device;
ID3D10Device1 *device;
ID3D10Buffer *buffer;
IUnknown *iface;
HRESULT hr;
if (!(device = create_device(D3D10_FEATURE_LEVEL_10_1)))
{
skip("Failed to create device.\n");
return;
}
buffer_desc.ByteWidth = 1024;
buffer_desc.Usage = D3D10_USAGE_DEFAULT;
buffer_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
buffer_desc.CPUAccessFlags = 0;
buffer_desc.MiscFlags = 0;
hr = ID3D10Device1_CreateBuffer(device, &buffer_desc, NULL, &buffer);
ok(SUCCEEDED(hr), "Failed to create a buffer, hr %#x\n", hr);
hr = ID3D10Device1_CreateShaderResourceView1(device, (ID3D10Resource *)buffer, NULL, &srview);
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
srv_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
srv_desc.ViewDimension = D3D10_1_SRV_DIMENSION_BUFFER;
U(srv_desc).Buffer.ElementOffset = 0;
U(srv_desc).Buffer.ElementWidth = 64;
expected_refcount = get_refcount((IUnknown *)device) + 1;
hr = ID3D10Device1_CreateShaderResourceView1(device, (ID3D10Resource *)buffer, &srv_desc, &srview);
ok(SUCCEEDED(hr), "Failed to create a shader resource view, hr %#x\n", hr);
refcount = get_refcount((IUnknown *)device);
ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
tmp_device = NULL;
expected_refcount = refcount + 1;
ID3D10ShaderResourceView1_GetDevice(srview, &tmp_device);
ok(tmp_device == (ID3D10Device *)device, "Got unexpected device %p, expected %p.\n", tmp_device, device);
refcount = get_refcount((IUnknown *)device);
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
ID3D10Device_Release(tmp_device);
hr = ID3D10ShaderResourceView1_QueryInterface(srview, &IID_ID3D10ShaderResourceView, (void **)&iface);
ok(SUCCEEDED(hr), "Shader resource view should implement ID3D10ShaderResourceView.\n");
IUnknown_Release(iface);
hr = ID3D10ShaderResourceView1_QueryInterface(srview, &IID_ID3D11ShaderResourceView, (void **)&iface);
ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
"Shader resource view should implement ID3D11ShaderResourceView.\n");
if (SUCCEEDED(hr)) IUnknown_Release(iface);
ID3D10ShaderResourceView1_Release(srview);
ID3D10Buffer_Release(buffer);
texture_desc.Width = 512;
texture_desc.Height = 512;
texture_desc.MipLevels = 0;
texture_desc.ArraySize = 1;
texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
texture_desc.SampleDesc.Count = 1;
texture_desc.SampleDesc.Quality = 0;
texture_desc.Usage = D3D10_USAGE_DEFAULT;
texture_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
texture_desc.CPUAccessFlags = 0;
texture_desc.MiscFlags = 0;
hr = ID3D10Device1_CreateTexture2D(device, &texture_desc, NULL, &texture);
ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x\n", hr);
hr = ID3D10Device1_CreateShaderResourceView1(device, (ID3D10Resource *)texture, NULL, &srview);
ok(SUCCEEDED(hr), "Failed to create a shader resource view, hr %#x\n", hr);
ID3D10ShaderResourceView1_GetDesc1(srview, &srv_desc);
ok(srv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", srv_desc.Format);
ok(srv_desc.ViewDimension == D3D10_1_SRV_DIMENSION_TEXTURE2D,
"Got unexpected view dimension %#x.\n", srv_desc.ViewDimension);
ok(U(srv_desc).Texture2D.MostDetailedMip == 0, "Got unexpected MostDetailedMip %u.\n",
U(srv_desc).Texture2D.MostDetailedMip);
ok(U(srv_desc).Texture2D.MipLevels == 10, "Got unexpected MipLevels %u.\n", U(srv_desc).Texture2D.MipLevels);
hr = ID3D10ShaderResourceView1_QueryInterface(srview, &IID_ID3D10ShaderResourceView, (void **)&iface);
ok(SUCCEEDED(hr), "Shader resource view should implement ID3D10ShaderResourceView.\n");
IUnknown_Release(iface);
hr = ID3D10ShaderResourceView1_QueryInterface(srview, &IID_ID3D11ShaderResourceView, (void **)&iface);
ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */,
"Shader resource view should implement ID3D11ShaderResourceView.\n");
if (SUCCEEDED(hr)) IUnknown_Release(iface);
ID3D10ShaderResourceView1_Release(srview);
ID3D10Texture2D_Release(texture);
refcount = ID3D10Device1_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
}
START_TEST(d3d10_1)
{
test_create_shader_resource_view();
}