d3d10core/tests: Add some shader creation tests.
This commit is contained in:
parent
f87483c307
commit
7c65ab91ad
|
@ -237,6 +237,139 @@ static void test_create_rendertarget_view(ID3D10Device *device)
|
|||
ID3D10Texture2D_Release(texture);
|
||||
}
|
||||
|
||||
static void test_create_shader(ID3D10Device *device)
|
||||
{
|
||||
#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,
|
||||
};
|
||||
|
||||
ID3D10VertexShader *vs = NULL;
|
||||
ID3D10PixelShader *ps = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
hr = ID3D10Device_CreateVertexShader(device, vs_4_0, sizeof(vs_4_0), &vs);
|
||||
ok(SUCCEEDED(hr), "Failed to create SM4 vertex shader, hr %#x\n", hr);
|
||||
if (vs)
|
||||
ID3D10VertexShader_Release(vs);
|
||||
|
||||
hr = ID3D10Device_CreateVertexShader(device, vs_2_0, sizeof(vs_2_0), &vs);
|
||||
ok(hr == E_INVALIDARG, "Created a SM2 vertex shader, hr %#x\n", hr);
|
||||
|
||||
hr = ID3D10Device_CreateVertexShader(device, vs_3_0, sizeof(vs_3_0), &vs);
|
||||
ok(hr == E_INVALIDARG, "Created a SM3 vertex shader, hr %#x\n", hr);
|
||||
|
||||
hr = ID3D10Device_CreateVertexShader(device, ps_4_0, sizeof(ps_4_0), &vs);
|
||||
ok(hr == E_INVALIDARG, "Created a SM4 vertex shader from a pixel shader source, hr %#x\n", hr);
|
||||
|
||||
hr = ID3D10Device_CreatePixelShader(device, ps_4_0, sizeof(ps_4_0), &ps);
|
||||
ok(SUCCEEDED(hr), "Failed to create SM4 vertex shader, hr %#x\n", hr);
|
||||
if (ps)
|
||||
ID3D10VertexShader_Release(ps);
|
||||
}
|
||||
|
||||
START_TEST(device)
|
||||
{
|
||||
ID3D10Device *device;
|
||||
|
@ -253,6 +386,7 @@ START_TEST(device)
|
|||
test_create_texture2d(device);
|
||||
test_create_texture3d(device);
|
||||
test_create_rendertarget_view(device);
|
||||
test_create_shader(device);
|
||||
|
||||
refcount = ID3D10Device_Release(device);
|
||||
ok(!refcount, "Device has %u references left\n", refcount);
|
||||
|
|
Loading…
Reference in New Issue