d3d11/tests: Port test_create_shader() from d3d10core.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
This commit is contained in:
parent
3c8635c8d7
commit
dc54d70207
|
@ -22,6 +22,17 @@
|
||||||
#include "d3d11.h"
|
#include "d3d11.h"
|
||||||
#include "wine/test.h"
|
#include "wine/test.h"
|
||||||
|
|
||||||
|
static const D3D_FEATURE_LEVEL d3d11_feature_levels[] =
|
||||||
|
{
|
||||||
|
D3D_FEATURE_LEVEL_11_1,
|
||||||
|
D3D_FEATURE_LEVEL_11_0,
|
||||||
|
D3D_FEATURE_LEVEL_10_1,
|
||||||
|
D3D_FEATURE_LEVEL_10_0,
|
||||||
|
D3D_FEATURE_LEVEL_9_3,
|
||||||
|
D3D_FEATURE_LEVEL_9_2,
|
||||||
|
D3D_FEATURE_LEVEL_9_1
|
||||||
|
};
|
||||||
|
|
||||||
static ULONG get_refcount(IUnknown *iface)
|
static ULONG get_refcount(IUnknown *iface)
|
||||||
{
|
{
|
||||||
IUnknown_AddRef(iface);
|
IUnknown_AddRef(iface);
|
||||||
|
@ -240,27 +251,17 @@ static void test_create_device(void)
|
||||||
|
|
||||||
static void test_device_interfaces(void)
|
static void test_device_interfaces(void)
|
||||||
{
|
{
|
||||||
static const D3D_FEATURE_LEVEL feature_levels[] =
|
|
||||||
{
|
|
||||||
D3D_FEATURE_LEVEL_11_1,
|
|
||||||
D3D_FEATURE_LEVEL_11_0,
|
|
||||||
D3D_FEATURE_LEVEL_10_1,
|
|
||||||
D3D_FEATURE_LEVEL_10_0,
|
|
||||||
D3D_FEATURE_LEVEL_9_3,
|
|
||||||
D3D_FEATURE_LEVEL_9_2,
|
|
||||||
D3D_FEATURE_LEVEL_9_1
|
|
||||||
};
|
|
||||||
ID3D11Device *device;
|
ID3D11Device *device;
|
||||||
IUnknown *iface;
|
IUnknown *iface;
|
||||||
ULONG refcount;
|
ULONG refcount;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
for (i = 0; i < sizeof(feature_levels) / sizeof(*feature_levels); i++)
|
for (i = 0; i < sizeof(d3d11_feature_levels) / sizeof(*d3d11_feature_levels); ++i)
|
||||||
{
|
{
|
||||||
if (!(device = create_device(&feature_levels[i])))
|
if (!(device = create_device(&d3d11_feature_levels[i])))
|
||||||
{
|
{
|
||||||
skip("Failed to create device for feature level %#x, skipping tests.\n", feature_levels[i]);
|
skip("Failed to create device for feature level %#x.\n", d3d11_feature_levels[i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1289,6 +1290,185 @@ static void test_create_shader_resource_view(void)
|
||||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_create_shader(void)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
float4 light;
|
||||||
|
float4x4 mat;
|
||||||
|
|
||||||
|
struct input
|
||||||
|
{
|
||||||
|
float4 position : POSITION;
|
||||||
|
float3 normal : NORMAL;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct output
|
||||||
|
{
|
||||||
|
float4 position : POSITION;
|
||||||
|
float4 diffuse : COLOR;
|
||||||
|
};
|
||||||
|
|
||||||
|
output main(const input v)
|
||||||
|
{
|
||||||
|
output o;
|
||||||
|
|
||||||
|
o.position = mul(v.position, mat);
|
||||||
|
o.diffuse = dot((float3)light, v.normal);
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
static const DWORD vs_4_0[] =
|
||||||
|
{
|
||||||
|
0x43425844, 0x3ae813ca, 0x0f034b91, 0x790f3226, 0x6b4a718a, 0x00000001, 0x000001c0,
|
||||||
|
0x00000003, 0x0000002c, 0x0000007c, 0x000000cc, 0x4e475349, 0x00000048, 0x00000002,
|
||||||
|
0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f,
|
||||||
|
0x00000041, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000707, 0x49534f50,
|
||||||
|
0x4e4f4954, 0x524f4e00, 0x004c414d, 0x4e47534f, 0x00000048, 0x00000002, 0x00000008,
|
||||||
|
0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000041,
|
||||||
|
0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x49534f50, 0x4e4f4954,
|
||||||
|
0x4c4f4300, 0xab00524f, 0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x04000059,
|
||||||
|
0x00208e46, 0x00000000, 0x00000005, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f,
|
||||||
|
0x00101072, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2,
|
||||||
|
0x00000001, 0x08000011, 0x00102012, 0x00000000, 0x00101e46, 0x00000000, 0x00208e46,
|
||||||
|
0x00000000, 0x00000001, 0x08000011, 0x00102022, 0x00000000, 0x00101e46, 0x00000000,
|
||||||
|
0x00208e46, 0x00000000, 0x00000002, 0x08000011, 0x00102042, 0x00000000, 0x00101e46,
|
||||||
|
0x00000000, 0x00208e46, 0x00000000, 0x00000003, 0x08000011, 0x00102082, 0x00000000,
|
||||||
|
0x00101e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x08000010, 0x001020f2,
|
||||||
|
0x00000001, 0x00208246, 0x00000000, 0x00000000, 0x00101246, 0x00000001, 0x0100003e,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const DWORD vs_2_0[] =
|
||||||
|
{
|
||||||
|
0xfffe0200, 0x002bfffe, 0x42415443, 0x0000001c, 0x00000077, 0xfffe0200, 0x00000002,
|
||||||
|
0x0000001c, 0x00000100, 0x00000070, 0x00000044, 0x00040002, 0x00000001, 0x0000004c,
|
||||||
|
0x00000000, 0x0000005c, 0x00000002, 0x00000004, 0x00000060, 0x00000000, 0x6867696c,
|
||||||
|
0xabab0074, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x0074616d, 0x00030003,
|
||||||
|
0x00040004, 0x00000001, 0x00000000, 0x325f7376, 0x4d00305f, 0x6f726369, 0x74666f73,
|
||||||
|
0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072,
|
||||||
|
0x392e3932, 0x332e3235, 0x00313131, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f,
|
||||||
|
0x80000003, 0x900f0001, 0x03000009, 0xc0010000, 0x90e40000, 0xa0e40000, 0x03000009,
|
||||||
|
0xc0020000, 0x90e40000, 0xa0e40001, 0x03000009, 0xc0040000, 0x90e40000, 0xa0e40002,
|
||||||
|
0x03000009, 0xc0080000, 0x90e40000, 0xa0e40003, 0x03000008, 0xd00f0000, 0xa0e40004,
|
||||||
|
0x90e40001, 0x0000ffff,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const DWORD vs_3_0[] =
|
||||||
|
{
|
||||||
|
0xfffe0300, 0x002bfffe, 0x42415443, 0x0000001c, 0x00000077, 0xfffe0300, 0x00000002,
|
||||||
|
0x0000001c, 0x00000100, 0x00000070, 0x00000044, 0x00040002, 0x00000001, 0x0000004c,
|
||||||
|
0x00000000, 0x0000005c, 0x00000002, 0x00000004, 0x00000060, 0x00000000, 0x6867696c,
|
||||||
|
0xabab0074, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x0074616d, 0x00030003,
|
||||||
|
0x00040004, 0x00000001, 0x00000000, 0x335f7376, 0x4d00305f, 0x6f726369, 0x74666f73,
|
||||||
|
0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072,
|
||||||
|
0x392e3932, 0x332e3235, 0x00313131, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f,
|
||||||
|
0x80000003, 0x900f0001, 0x0200001f, 0x80000000, 0xe00f0000, 0x0200001f, 0x8000000a,
|
||||||
|
0xe00f0001, 0x03000009, 0xe0010000, 0x90e40000, 0xa0e40000, 0x03000009, 0xe0020000,
|
||||||
|
0x90e40000, 0xa0e40001, 0x03000009, 0xe0040000, 0x90e40000, 0xa0e40002, 0x03000009,
|
||||||
|
0xe0080000, 0x90e40000, 0xa0e40003, 0x03000008, 0xe00f0001, 0xa0e40004, 0x90e40001,
|
||||||
|
0x0000ffff,
|
||||||
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
float4 main(const float4 color : COLOR) : SV_TARGET
|
||||||
|
{
|
||||||
|
float4 o;
|
||||||
|
|
||||||
|
o = color;
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
static const DWORD ps_4_0[] =
|
||||||
|
{
|
||||||
|
0x43425844, 0x4da9446f, 0xfbe1f259, 0x3fdb3009, 0x517521fa, 0x00000001, 0x000001ac,
|
||||||
|
0x00000005, 0x00000034, 0x0000008c, 0x000000bc, 0x000000f0, 0x00000130, 0x46454452,
|
||||||
|
0x00000050, 0x00000000, 0x00000000, 0x00000000, 0x0000001c, 0xffff0400, 0x00000100,
|
||||||
|
0x0000001c, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168,
|
||||||
|
0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e, 0x2e323539, 0x31313133, 0xababab00,
|
||||||
|
0x4e475349, 0x00000028, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
|
||||||
|
0x00000003, 0x00000000, 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c,
|
||||||
|
0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
|
||||||
|
0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
|
||||||
|
0x0000000e, 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000,
|
||||||
|
0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x54415453,
|
||||||
|
0x00000074, 0x00000002, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000,
|
||||||
|
0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
|
||||||
|
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0x00000000, 0x00000000,
|
||||||
|
};
|
||||||
|
|
||||||
|
ULONG refcount, expected_refcount;
|
||||||
|
ID3D11Device *device, *tmp;
|
||||||
|
ID3D11VertexShader *vs;
|
||||||
|
ID3D11PixelShader *ps;
|
||||||
|
unsigned int i;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(d3d11_feature_levels) / sizeof(*d3d11_feature_levels); ++i)
|
||||||
|
{
|
||||||
|
D3D_FEATURE_LEVEL feature_level = d3d11_feature_levels[i];
|
||||||
|
if (!(device = create_device(&feature_level)))
|
||||||
|
{
|
||||||
|
skip("Failed to create device for feature level %#x.\n", feature_level);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = ID3D11Device_CreateVertexShader(device, vs_2_0, sizeof(vs_2_0), NULL, &vs);
|
||||||
|
ok(hr == E_INVALIDARG, "Created a SM2 vertex shader, hr %#x, feature level %#x.\n", hr, feature_level);
|
||||||
|
|
||||||
|
hr = ID3D11Device_CreateVertexShader(device, vs_3_0, sizeof(vs_3_0), NULL, &vs);
|
||||||
|
ok(hr == E_INVALIDARG, "Created a SM3 vertex shader, hr %#x, feature level %#x.\n", hr, feature_level);
|
||||||
|
|
||||||
|
hr = ID3D11Device_CreateVertexShader(device, ps_4_0, sizeof(ps_4_0), NULL, &vs);
|
||||||
|
ok(hr == E_INVALIDARG, "Created a SM4 vertex shader from a pixel shader source, hr %#x, feature level %#x.\n",
|
||||||
|
hr, feature_level);
|
||||||
|
|
||||||
|
if (feature_level < D3D_FEATURE_LEVEL_10_0)
|
||||||
|
{
|
||||||
|
refcount = ID3D11Device_Release(device);
|
||||||
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_refcount = get_refcount((IUnknown *)device) + 1;
|
||||||
|
hr = ID3D11Device_CreateVertexShader(device, vs_4_0, sizeof(vs_4_0), NULL, &vs);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to create SM4 vertex shader, hr %#x, feature level %#x.\n", hr, feature_level);
|
||||||
|
refcount = get_refcount((IUnknown *)device);
|
||||||
|
ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n",
|
||||||
|
refcount, expected_refcount);
|
||||||
|
tmp = NULL;
|
||||||
|
expected_refcount = refcount + 1;
|
||||||
|
ID3D11VertexShader_GetDevice(vs, &tmp);
|
||||||
|
ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
|
||||||
|
refcount = get_refcount((IUnknown *)device);
|
||||||
|
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
|
||||||
|
refcount, expected_refcount);
|
||||||
|
ID3D11Device_Release(tmp);
|
||||||
|
ID3D11VertexShader_Release(vs);
|
||||||
|
|
||||||
|
expected_refcount = get_refcount((IUnknown *)device) + 1;
|
||||||
|
hr = ID3D11Device_CreatePixelShader(device, ps_4_0, sizeof(ps_4_0), NULL, &ps);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to create SM4 vertex shader, hr %#x, feature level %#x.\n", hr, feature_level);
|
||||||
|
refcount = get_refcount((IUnknown *)device);
|
||||||
|
ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n",
|
||||||
|
refcount, expected_refcount);
|
||||||
|
tmp = NULL;
|
||||||
|
expected_refcount = refcount + 1;
|
||||||
|
ID3D11PixelShader_GetDevice(ps, &tmp);
|
||||||
|
ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
|
||||||
|
refcount = get_refcount((IUnknown *)device);
|
||||||
|
ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n",
|
||||||
|
refcount, expected_refcount);
|
||||||
|
ID3D11Device_Release(tmp);
|
||||||
|
ID3D11PixelShader_Release(ps);
|
||||||
|
|
||||||
|
refcount = ID3D11Device_Release(device);
|
||||||
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(d3d11)
|
START_TEST(d3d11)
|
||||||
{
|
{
|
||||||
test_create_device();
|
test_create_device();
|
||||||
|
@ -1302,4 +1482,5 @@ START_TEST(d3d11)
|
||||||
test_depthstencil_view_interfaces();
|
test_depthstencil_view_interfaces();
|
||||||
test_create_rendertarget_view();
|
test_create_rendertarget_view();
|
||||||
test_create_shader_resource_view();
|
test_create_shader_resource_view();
|
||||||
|
test_create_shader();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue