mstask: Implement GetTargetComputer.
[wine] / dlls / d3d10core / tests / device.c
1 /*
2  * Copyright 2008 Henri Verbeet for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #define COBJMACROS
20 #include "initguid.h"
21 #include "d3d10.h"
22 #include "wine/test.h"
23
24 HRESULT WINAPI D3D10CoreCreateDevice(IDXGIFactory *factory, IDXGIAdapter *adapter,
25         UINT flags, void *unknown0, ID3D10Device **device);
26
27 static ID3D10Device *create_device(void)
28 {
29     IDXGIFactory *factory = NULL;
30     IDXGIAdapter *adapter = NULL;
31     ID3D10Device *device = NULL;
32     HRESULT hr;
33
34     hr = CreateDXGIFactory(&IID_IDXGIFactory, (void *)&factory);
35     if (FAILED(hr)) goto cleanup;
36
37     hr = IDXGIFactory_EnumAdapters(factory, 0, &adapter);
38     ok(SUCCEEDED(hr) || hr == DXGI_ERROR_NOT_FOUND, /* Some VMware and VirtualBox */
39             "EnumAdapters failed, hr %#x.\n", hr);
40     if (SUCCEEDED(hr))
41     {
42         hr = D3D10CoreCreateDevice(factory, adapter, 0, NULL, &device);
43     }
44
45     if (FAILED(hr))
46     {
47         HMODULE d3d10ref;
48
49         trace("Failed to create a HW device, trying REF\n");
50         if (adapter) IDXGIAdapter_Release(adapter);
51         adapter = NULL;
52
53         d3d10ref = LoadLibraryA("d3d10ref.dll");
54         if (!d3d10ref)
55         {
56             trace("d3d10ref.dll not available, unable to create a REF device\n");
57             goto cleanup;
58         }
59
60         hr = IDXGIFactory_CreateSoftwareAdapter(factory, d3d10ref, &adapter);
61         FreeLibrary(d3d10ref);
62         ok(SUCCEEDED(hr), "CreateSoftwareAdapter failed, hr %#x\n", hr);
63         if (FAILED(hr)) goto cleanup;
64
65         hr = D3D10CoreCreateDevice(factory, adapter, 0, NULL, &device);
66         ok(SUCCEEDED(hr), "Failed to create a REF device, hr %#x\n", hr);
67         if (FAILED(hr)) goto cleanup;
68     }
69
70 cleanup:
71     if (adapter) IDXGIAdapter_Release(adapter);
72     if (factory) IDXGIFactory_Release(factory);
73
74     return device;
75 }
76
77 static void test_device_interfaces(ID3D10Device *device)
78 {
79     IUnknown *obj;
80     HRESULT hr;
81
82     if (SUCCEEDED(hr = ID3D10Device_QueryInterface(device, &IID_IUnknown, (void **)&obj)))
83         IUnknown_Release(obj);
84     ok(SUCCEEDED(hr), "ID3D10Device does not implement IUnknown\n");
85
86     if (SUCCEEDED(hr = ID3D10Device_QueryInterface(device, &IID_IDXGIObject, (void **)&obj)))
87         IUnknown_Release(obj);
88     ok(SUCCEEDED(hr), "ID3D10Device does not implement IDXGIObject\n");
89
90     if (SUCCEEDED(hr = ID3D10Device_QueryInterface(device, &IID_IDXGIDevice, (void **)&obj)))
91         IUnknown_Release(obj);
92     ok(SUCCEEDED(hr), "ID3D10Device does not implement IDXGIDevice\n");
93
94     if (SUCCEEDED(hr = ID3D10Device_QueryInterface(device, &IID_ID3D10Device, (void **)&obj)))
95         IUnknown_Release(obj);
96     ok(SUCCEEDED(hr), "ID3D10Device does not implement ID3D10Device\n");
97 }
98
99 static void test_create_texture2d(ID3D10Device *device)
100 {
101     D3D10_TEXTURE2D_DESC desc;
102     ID3D10Texture2D *texture;
103     IDXGISurface *surface;
104     HRESULT hr;
105
106     desc.Width = 512;
107     desc.Height = 512;
108     desc.MipLevels = 1;
109     desc.ArraySize = 1;
110     desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
111     desc.SampleDesc.Count = 1;
112     desc.SampleDesc.Quality = 0;
113     desc.Usage = D3D10_USAGE_DEFAULT;
114     desc.BindFlags = D3D10_BIND_RENDER_TARGET;
115     desc.CPUAccessFlags = 0;
116     desc.MiscFlags = 0;
117
118     hr = ID3D10Device_CreateTexture2D(device, &desc, NULL, &texture);
119     ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x\n", hr);
120
121     hr = ID3D10Texture2D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
122     ok(SUCCEEDED(hr), "Texture should implement IDXGISurface\n");
123     if (SUCCEEDED(hr)) IDXGISurface_Release(surface);
124     ID3D10Texture2D_Release(texture);
125
126     desc.MipLevels = 0;
127     hr = ID3D10Device_CreateTexture2D(device, &desc, NULL, &texture);
128     ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x\n", hr);
129
130     ID3D10Texture2D_GetDesc(texture, &desc);
131     ok(desc.Width == 512, "Got unexpected Width %u.\n", desc.Width);
132     ok(desc.Height == 512, "Got unexpected Height %u.\n", desc.Height);
133     ok(desc.MipLevels == 10, "Got unexpected MipLevels %u.\n", desc.MipLevels);
134     ok(desc.ArraySize == 1, "Got unexpected ArraySize %u.\n", desc.ArraySize);
135     ok(desc.Format == DXGI_FORMAT_R8G8B8A8_UNORM, "Got unexpected Format %#x.\n", desc.Format);
136     ok(desc.SampleDesc.Count == 1, "Got unexpected SampleDesc.Count %u.\n", desc.SampleDesc.Count);
137     ok(desc.SampleDesc.Quality == 0, "Got unexpected SampleDesc.Quality %u.\n", desc.SampleDesc.Quality);
138     ok(desc.Usage == D3D10_USAGE_DEFAULT, "Got unexpected MipLevels %u.\n", desc.Usage);
139     ok(desc.BindFlags == D3D10_BIND_RENDER_TARGET, "Got unexpected BindFlags %u.\n", desc.BindFlags);
140     ok(desc.CPUAccessFlags == 0, "Got unexpected CPUAccessFlags %u.\n", desc.CPUAccessFlags);
141     ok(desc.MiscFlags == 0, "Got unexpected MiscFlags %u.\n", desc.MiscFlags);
142
143     hr = ID3D10Texture2D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
144     ok(FAILED(hr), "Texture should not implement IDXGISurface\n");
145     if (SUCCEEDED(hr)) IDXGISurface_Release(surface);
146     ID3D10Texture2D_Release(texture);
147
148     desc.MipLevels = 1;
149     desc.ArraySize = 2;
150     hr = ID3D10Device_CreateTexture2D(device, &desc, NULL, &texture);
151     ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x\n", hr);
152
153     hr = ID3D10Texture2D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
154     ok(FAILED(hr), "Texture should not implement IDXGISurface\n");
155     if (SUCCEEDED(hr)) IDXGISurface_Release(surface);
156     ID3D10Texture2D_Release(texture);
157 }
158
159 static void test_create_texture3d(ID3D10Device *device)
160 {
161     D3D10_TEXTURE3D_DESC desc;
162     ID3D10Texture3D *texture;
163     IDXGISurface *surface;
164     HRESULT hr;
165
166     desc.Width = 64;
167     desc.Height = 64;
168     desc.Depth = 64;
169     desc.MipLevels = 1;
170     desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
171     desc.Usage = D3D10_USAGE_DEFAULT;
172     desc.BindFlags = D3D10_BIND_RENDER_TARGET;
173     desc.CPUAccessFlags = 0;
174     desc.MiscFlags = 0;
175
176     hr = ID3D10Device_CreateTexture3D(device, &desc, NULL, &texture);
177     ok(SUCCEEDED(hr), "Failed to create a 3d texture, hr %#x.\n", hr);
178
179     hr = ID3D10Texture3D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
180     ok(FAILED(hr), "Texture should not implement IDXGISurface.\n");
181     if (SUCCEEDED(hr)) IDXGISurface_Release(surface);
182     ID3D10Texture3D_Release(texture);
183
184     desc.MipLevels = 0;
185     hr = ID3D10Device_CreateTexture3D(device, &desc, NULL, &texture);
186     ok(SUCCEEDED(hr), "Failed to create a 3d texture, hr %#x.\n", hr);
187
188     ID3D10Texture3D_GetDesc(texture, &desc);
189     ok(desc.Width == 64, "Got unexpected Width %u.\n", desc.Width);
190     ok(desc.Height == 64, "Got unexpected Height %u.\n", desc.Height);
191     ok(desc.Depth == 64, "Got unexpected Depth %u.\n", desc.Depth);
192     ok(desc.MipLevels == 7, "Got unexpected MipLevels %u.\n", desc.MipLevels);
193     ok(desc.Format == DXGI_FORMAT_R8G8B8A8_UNORM, "Got unexpected Format %#x.\n", desc.Format);
194     ok(desc.Usage == D3D10_USAGE_DEFAULT, "Got unexpected MipLevels %u.\n", desc.Usage);
195     ok(desc.BindFlags == D3D10_BIND_RENDER_TARGET, "Got unexpected BindFlags %u.\n", desc.BindFlags);
196     ok(desc.CPUAccessFlags == 0, "Got unexpected CPUAccessFlags %u.\n", desc.CPUAccessFlags);
197     ok(desc.MiscFlags == 0, "Got unexpected MiscFlags %u.\n", desc.MiscFlags);
198
199     hr = ID3D10Texture3D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
200     ok(FAILED(hr), "Texture should not implement IDXGISurface.\n");
201     if (SUCCEEDED(hr)) IDXGISurface_Release(surface);
202     ID3D10Texture3D_Release(texture);
203 }
204
205 static void test_create_depthstencil_view(ID3D10Device *device)
206 {
207     D3D10_DEPTH_STENCIL_VIEW_DESC dsv_desc;
208     D3D10_TEXTURE2D_DESC texture_desc;
209     ID3D10DepthStencilView *dsview;
210     ID3D10Texture2D *texture;
211     HRESULT hr;
212
213     texture_desc.Width = 512;
214     texture_desc.Height = 512;
215     texture_desc.MipLevels = 1;
216     texture_desc.ArraySize = 1;
217     texture_desc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
218     texture_desc.SampleDesc.Count = 1;
219     texture_desc.SampleDesc.Quality = 0;
220     texture_desc.Usage = D3D10_USAGE_DEFAULT;
221     texture_desc.BindFlags = D3D10_BIND_DEPTH_STENCIL;
222     texture_desc.CPUAccessFlags = 0;
223     texture_desc.MiscFlags = 0;
224
225     hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
226     ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x\n", hr);
227
228     hr = ID3D10Device_CreateDepthStencilView(device, (ID3D10Resource *)texture, NULL, &dsview);
229     ok(SUCCEEDED(hr), "Failed to create a depthstencil view, hr %#x\n", hr);
230
231     ID3D10DepthStencilView_GetDesc(dsview, &dsv_desc);
232     ok(dsv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", dsv_desc.Format);
233     ok(dsv_desc.ViewDimension == D3D10_DSV_DIMENSION_TEXTURE2D,
234             "Got unexpected view dimension %#x.\n", dsv_desc.ViewDimension);
235     ok(U(dsv_desc).Texture2D.MipSlice == 0, "Got Unexpected mip slice %u.\n", U(dsv_desc).Texture2D.MipSlice);
236
237     ID3D10DepthStencilView_Release(dsview);
238     ID3D10Texture2D_Release(texture);
239 }
240
241 static void test_create_rendertarget_view(ID3D10Device *device)
242 {
243     D3D10_RENDER_TARGET_VIEW_DESC rtv_desc;
244     D3D10_TEXTURE2D_DESC texture_desc;
245     D3D10_BUFFER_DESC buffer_desc;
246     ID3D10RenderTargetView *rtview;
247     ID3D10Texture2D *texture;
248     ID3D10Buffer *buffer;
249     HRESULT hr;
250
251     buffer_desc.ByteWidth = 1024;
252     buffer_desc.Usage = D3D10_USAGE_DEFAULT;
253     buffer_desc.BindFlags = D3D10_BIND_RENDER_TARGET;
254     buffer_desc.CPUAccessFlags = 0;
255     buffer_desc.MiscFlags = 0;
256
257     hr = ID3D10Device_CreateBuffer(device, &buffer_desc, NULL, &buffer);
258     ok(SUCCEEDED(hr), "Failed to create a buffer, hr %#x\n", hr);
259
260     rtv_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
261     rtv_desc.ViewDimension = D3D10_RTV_DIMENSION_BUFFER;
262     U(rtv_desc).Buffer.ElementOffset = 0;
263     U(rtv_desc).Buffer.ElementWidth = 64;
264
265     hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)buffer, &rtv_desc, &rtview);
266     ok(SUCCEEDED(hr), "Failed to create a rendertarget view, hr %#x\n", hr);
267
268     ID3D10RenderTargetView_Release(rtview);
269     ID3D10Buffer_Release(buffer);
270
271     texture_desc.Width = 512;
272     texture_desc.Height = 512;
273     texture_desc.MipLevels = 1;
274     texture_desc.ArraySize = 1;
275     texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
276     texture_desc.SampleDesc.Count = 1;
277     texture_desc.SampleDesc.Quality = 0;
278     texture_desc.Usage = D3D10_USAGE_DEFAULT;
279     texture_desc.BindFlags = D3D10_BIND_RENDER_TARGET;
280     texture_desc.CPUAccessFlags = 0;
281     texture_desc.MiscFlags = 0;
282
283     hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
284     ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x\n", hr);
285
286     /* For texture resources it's allowed to specify NULL as desc */
287     hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)texture, NULL, &rtview);
288     ok(SUCCEEDED(hr), "Failed to create a rendertarget view, hr %#x\n", hr);
289
290     ID3D10RenderTargetView_GetDesc(rtview, &rtv_desc);
291     ok(rtv_desc.Format == texture_desc.Format, "Expected format %#x, got %#x\n", texture_desc.Format, rtv_desc.Format);
292     ok(rtv_desc.ViewDimension == D3D10_RTV_DIMENSION_TEXTURE2D,
293             "Expected view dimension D3D10_RTV_DIMENSION_TEXTURE2D, got %#x\n", rtv_desc.ViewDimension);
294     ok(U(rtv_desc).Texture2D.MipSlice == 0, "Expected mip slice 0, got %#x\n", U(rtv_desc).Texture2D.MipSlice);
295
296     ID3D10RenderTargetView_Release(rtview);
297     ID3D10Texture2D_Release(texture);
298 }
299
300 static void test_create_shader_resource_view(ID3D10Device *device)
301 {
302     D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc;
303     D3D10_TEXTURE2D_DESC texture_desc;
304     ID3D10ShaderResourceView *srview;
305     D3D10_BUFFER_DESC buffer_desc;
306     ID3D10Texture2D *texture;
307     ID3D10Buffer *buffer;
308     HRESULT hr;
309
310     buffer_desc.ByteWidth = 1024;
311     buffer_desc.Usage = D3D10_USAGE_DEFAULT;
312     buffer_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
313     buffer_desc.CPUAccessFlags = 0;
314     buffer_desc.MiscFlags = 0;
315
316     hr = ID3D10Device_CreateBuffer(device, &buffer_desc, NULL, &buffer);
317     ok(SUCCEEDED(hr), "Failed to create a buffer, hr %#x\n", hr);
318
319     hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)buffer, NULL, &srview);
320     ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
321
322     srv_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
323     srv_desc.ViewDimension = D3D10_RTV_DIMENSION_BUFFER;
324     U(srv_desc).Buffer.ElementOffset = 0;
325     U(srv_desc).Buffer.ElementWidth = 64;
326
327     hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)buffer, &srv_desc, &srview);
328     ok(SUCCEEDED(hr), "Failed to create a shader resource view, hr %#x\n", hr);
329
330     ID3D10ShaderResourceView_Release(srview);
331     ID3D10Buffer_Release(buffer);
332
333     texture_desc.Width = 512;
334     texture_desc.Height = 512;
335     texture_desc.MipLevels = 0;
336     texture_desc.ArraySize = 1;
337     texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
338     texture_desc.SampleDesc.Count = 1;
339     texture_desc.SampleDesc.Quality = 0;
340     texture_desc.Usage = D3D10_USAGE_DEFAULT;
341     texture_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
342     texture_desc.CPUAccessFlags = 0;
343     texture_desc.MiscFlags = 0;
344
345     hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
346     ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x\n", hr);
347
348     hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)texture, NULL, &srview);
349     ok(SUCCEEDED(hr), "Failed to create a shader resource view, hr %#x\n", hr);
350
351     ID3D10ShaderResourceView_GetDesc(srview, &srv_desc);
352     ok(srv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", srv_desc.Format);
353     ok(srv_desc.ViewDimension == D3D10_SRV_DIMENSION_TEXTURE2D,
354             "Got unexpected view dimension %#x.\n", srv_desc.ViewDimension);
355     ok(U(srv_desc).Texture2D.MostDetailedMip == 0, "Got unexpected MostDetailedMip %u.\n",
356             U(srv_desc).Texture2D.MostDetailedMip);
357     ok(U(srv_desc).Texture2D.MipLevels == 10, "Got unexpected MipLevels %u.\n", U(srv_desc).Texture2D.MipLevels);
358
359     ID3D10ShaderResourceView_Release(srview);
360     ID3D10Texture2D_Release(texture);
361 }
362
363 static void test_create_shader(ID3D10Device *device)
364 {
365 #if 0
366 float4 light;
367 float4x4 mat;
368
369 struct input
370 {
371     float4 position : POSITION;
372     float3 normal : NORMAL;
373 };
374
375 struct output
376 {
377     float4 position : POSITION;
378     float4 diffuse : COLOR;
379 };
380
381 output main(const input v)
382 {
383     output o;
384
385     o.position = mul(v.position, mat);
386     o.diffuse = dot((float3)light, v.normal);
387
388     return o;
389 }
390 #endif
391     static const DWORD vs_4_0[] =
392     {
393         0x43425844, 0x3ae813ca, 0x0f034b91, 0x790f3226, 0x6b4a718a, 0x00000001, 0x000001c0,
394         0x00000003, 0x0000002c, 0x0000007c, 0x000000cc, 0x4e475349, 0x00000048, 0x00000002,
395         0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f,
396         0x00000041, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000707, 0x49534f50,
397         0x4e4f4954, 0x524f4e00, 0x004c414d, 0x4e47534f, 0x00000048, 0x00000002, 0x00000008,
398         0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x00000041,
399         0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x49534f50, 0x4e4f4954,
400         0x4c4f4300, 0xab00524f, 0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x04000059,
401         0x00208e46, 0x00000000, 0x00000005, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f,
402         0x00101072, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2,
403         0x00000001, 0x08000011, 0x00102012, 0x00000000, 0x00101e46, 0x00000000, 0x00208e46,
404         0x00000000, 0x00000001, 0x08000011, 0x00102022, 0x00000000, 0x00101e46, 0x00000000,
405         0x00208e46, 0x00000000, 0x00000002, 0x08000011, 0x00102042, 0x00000000, 0x00101e46,
406         0x00000000, 0x00208e46, 0x00000000, 0x00000003, 0x08000011, 0x00102082, 0x00000000,
407         0x00101e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x08000010, 0x001020f2,
408         0x00000001, 0x00208246, 0x00000000, 0x00000000, 0x00101246, 0x00000001, 0x0100003e,
409     };
410
411     static const DWORD vs_2_0[] =
412     {
413         0xfffe0200, 0x002bfffe, 0x42415443, 0x0000001c, 0x00000077, 0xfffe0200, 0x00000002,
414         0x0000001c, 0x00000100, 0x00000070, 0x00000044, 0x00040002, 0x00000001, 0x0000004c,
415         0x00000000, 0x0000005c, 0x00000002, 0x00000004, 0x00000060, 0x00000000, 0x6867696c,
416         0xabab0074, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x0074616d, 0x00030003,
417         0x00040004, 0x00000001, 0x00000000, 0x325f7376, 0x4d00305f, 0x6f726369, 0x74666f73,
418         0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072,
419         0x392e3932, 0x332e3235, 0x00313131, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f,
420         0x80000003, 0x900f0001, 0x03000009, 0xc0010000, 0x90e40000, 0xa0e40000, 0x03000009,
421         0xc0020000, 0x90e40000, 0xa0e40001, 0x03000009, 0xc0040000, 0x90e40000, 0xa0e40002,
422         0x03000009, 0xc0080000, 0x90e40000, 0xa0e40003, 0x03000008, 0xd00f0000, 0xa0e40004,
423         0x90e40001, 0x0000ffff,
424     };
425
426     static const DWORD vs_3_0[] =
427     {
428         0xfffe0300, 0x002bfffe, 0x42415443, 0x0000001c, 0x00000077, 0xfffe0300, 0x00000002,
429         0x0000001c, 0x00000100, 0x00000070, 0x00000044, 0x00040002, 0x00000001, 0x0000004c,
430         0x00000000, 0x0000005c, 0x00000002, 0x00000004, 0x00000060, 0x00000000, 0x6867696c,
431         0xabab0074, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x0074616d, 0x00030003,
432         0x00040004, 0x00000001, 0x00000000, 0x335f7376, 0x4d00305f, 0x6f726369, 0x74666f73,
433         0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072,
434         0x392e3932, 0x332e3235, 0x00313131, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f,
435         0x80000003, 0x900f0001, 0x0200001f, 0x80000000, 0xe00f0000, 0x0200001f, 0x8000000a,
436         0xe00f0001, 0x03000009, 0xe0010000, 0x90e40000, 0xa0e40000, 0x03000009, 0xe0020000,
437         0x90e40000, 0xa0e40001, 0x03000009, 0xe0040000, 0x90e40000, 0xa0e40002, 0x03000009,
438         0xe0080000, 0x90e40000, 0xa0e40003, 0x03000008, 0xe00f0001, 0xa0e40004, 0x90e40001,
439         0x0000ffff,
440     };
441
442 #if 0
443 float4 main(const float4 color : COLOR) : SV_TARGET
444 {
445     float4 o;
446
447     o = color;
448
449     return o;
450 }
451 #endif
452     static const DWORD ps_4_0[] =
453     {
454         0x43425844, 0x4da9446f, 0xfbe1f259, 0x3fdb3009, 0x517521fa, 0x00000001, 0x000001ac,
455         0x00000005, 0x00000034, 0x0000008c, 0x000000bc, 0x000000f0, 0x00000130, 0x46454452,
456         0x00000050, 0x00000000, 0x00000000, 0x00000000, 0x0000001c, 0xffff0400, 0x00000100,
457         0x0000001c, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168,
458         0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e, 0x2e323539, 0x31313133, 0xababab00,
459         0x4e475349, 0x00000028, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
460         0x00000003, 0x00000000, 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f, 0x0000002c,
461         0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
462         0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
463         0x0000000e, 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000,
464         0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x54415453,
465         0x00000074, 0x00000002, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000,
466         0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
467         0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
468         0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
469         0x00000000, 0x00000000,
470     };
471
472     ID3D10VertexShader *vs = NULL;
473     ID3D10PixelShader *ps = NULL;
474     HRESULT hr;
475
476     hr = ID3D10Device_CreateVertexShader(device, vs_4_0, sizeof(vs_4_0), &vs);
477     ok(SUCCEEDED(hr), "Failed to create SM4 vertex shader, hr %#x\n", hr);
478     if (vs)
479         ID3D10VertexShader_Release(vs);
480
481     hr = ID3D10Device_CreateVertexShader(device, vs_2_0, sizeof(vs_2_0), &vs);
482     ok(hr == E_INVALIDARG, "Created a SM2 vertex shader, hr %#x\n", hr);
483
484     hr = ID3D10Device_CreateVertexShader(device, vs_3_0, sizeof(vs_3_0), &vs);
485     ok(hr == E_INVALIDARG, "Created a SM3 vertex shader, hr %#x\n", hr);
486
487     hr = ID3D10Device_CreateVertexShader(device, ps_4_0, sizeof(ps_4_0), &vs);
488     ok(hr == E_INVALIDARG, "Created a SM4 vertex shader from a pixel shader source, hr %#x\n", hr);
489
490     hr = ID3D10Device_CreatePixelShader(device, ps_4_0, sizeof(ps_4_0), &ps);
491     ok(SUCCEEDED(hr), "Failed to create SM4 vertex shader, hr %#x\n", hr);
492     if (ps)
493         ID3D10PixelShader_Release(ps);
494 }
495
496 START_TEST(device)
497 {
498     ID3D10Device *device;
499     ULONG refcount;
500
501     device = create_device();
502     if (!device)
503     {
504         skip("Failed to create device, skipping tests\n");
505         return;
506     }
507
508     test_device_interfaces(device);
509     test_create_texture2d(device);
510     test_create_texture3d(device);
511     test_create_depthstencil_view(device);
512     test_create_rendertarget_view(device);
513     test_create_shader_resource_view(device);
514     test_create_shader(device);
515
516     refcount = ID3D10Device_Release(device);
517     ok(!refcount, "Device has %u references left\n", refcount);
518 }