makefiles: Explicitly create destination dirs when installing symlinks.
[wine/zf.git] / dlls / d3d10 / tests / device.c
blobbb4bff51bdbfe3f79df6d67f4a7decefa5a6db0e
1 /*
2 * Copyright 2008 Henri Verbeet for CodeWeavers
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.
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.
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
19 #define COBJMACROS
20 #include "d3d10.h"
21 #include "wine/test.h"
23 static void test_create_device(void)
25 ID3D10Device *device;
26 unsigned int i;
27 HRESULT hr;
29 if (FAILED(hr = D3D10CreateDevice(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, D3D10_SDK_VERSION, &device)))
31 skip("Failed to create HAL device.\n");
32 return;
34 ID3D10Device_Release(device);
36 for (i = 0; i < 100; ++i)
38 if (i == D3D10_SDK_VERSION)
39 continue;
40 hr = D3D10CreateDevice(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, i, &device);
41 ok(hr == E_INVALIDARG, "Got unexpected hr %#x for SDK version %#x.\n", hr, i);
45 static void test_stateblock_mask(void)
47 static const struct
49 UINT start_idx;
50 UINT count;
51 BYTE expected_disable[5];
52 BYTE expected_enable[5];
54 capture_test[] =
56 { 8, 4, {0xff, 0xf0, 0xff, 0xff, 0xff}, {0x00, 0x0f, 0x00, 0x00, 0x00}},
57 { 9, 4, {0xff, 0xe1, 0xff, 0xff, 0xff}, {0x00, 0x1e, 0x00, 0x00, 0x00}},
58 {10, 4, {0xff, 0xc3, 0xff, 0xff, 0xff}, {0x00, 0x3c, 0x00, 0x00, 0x00}},
59 {11, 4, {0xff, 0x87, 0xff, 0xff, 0xff}, {0x00, 0x78, 0x00, 0x00, 0x00}},
60 {12, 4, {0xff, 0x0f, 0xff, 0xff, 0xff}, {0x00, 0xf0, 0x00, 0x00, 0x00}},
61 {13, 4, {0xff, 0x1f, 0xfe, 0xff, 0xff}, {0x00, 0xe0, 0x01, 0x00, 0x00}},
62 {14, 4, {0xff, 0x3f, 0xfc, 0xff, 0xff}, {0x00, 0xc0, 0x03, 0x00, 0x00}},
63 {15, 4, {0xff, 0x7f, 0xf8, 0xff, 0xff}, {0x00, 0x80, 0x07, 0x00, 0x00}},
64 { 8, 12, {0xff, 0x00, 0xf0, 0xff, 0xff}, {0x00, 0xff, 0x0f, 0x00, 0x00}},
65 { 9, 12, {0xff, 0x01, 0xe0, 0xff, 0xff}, {0x00, 0xfe, 0x1f, 0x00, 0x00}},
66 {10, 12, {0xff, 0x03, 0xc0, 0xff, 0xff}, {0x00, 0xfc, 0x3f, 0x00, 0x00}},
67 {11, 12, {0xff, 0x07, 0x80, 0xff, 0xff}, {0x00, 0xf8, 0x7f, 0x00, 0x00}},
68 {12, 12, {0xff, 0x0f, 0x00, 0xff, 0xff}, {0x00, 0xf0, 0xff, 0x00, 0x00}},
69 {13, 12, {0xff, 0x1f, 0x00, 0xfe, 0xff}, {0x00, 0xe0, 0xff, 0x01, 0x00}},
70 {14, 12, {0xff, 0x3f, 0x00, 0xfc, 0xff}, {0x00, 0xc0, 0xff, 0x03, 0x00}},
71 {15, 12, {0xff, 0x7f, 0x00, 0xf8, 0xff}, {0x00, 0x80, 0xff, 0x07, 0x00}},
73 D3D10_STATE_BLOCK_MASK mask_x, mask_y, result;
74 HRESULT hr;
75 BOOL ret;
76 UINT i;
78 memset(&mask_x, 0, sizeof(mask_x));
79 memset(&mask_y, 0, sizeof(mask_y));
80 memset(&result, 0, sizeof(result));
82 mask_x.VS = 0x33;
83 mask_y.VS = 0x55;
84 mask_x.Predication = 0x99;
85 mask_y.Predication = 0xaa;
87 hr = D3D10StateBlockMaskDifference(&mask_x, &mask_y, &result);
88 ok(SUCCEEDED(hr), "D3D10StateBlockMaskDifference failed, hr %#x.\n", hr);
89 ok(result.VS == 0x66, "Got unexpected result.VS %#x.\n", result.VS);
90 ok(result.Predication == 0x33, "Got unexpected result.Predication %#x.\n", result.Predication);
91 hr = D3D10StateBlockMaskDifference(NULL, &mask_y, &result);
92 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
93 hr = D3D10StateBlockMaskDifference(&mask_x, NULL, &result);
94 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
95 hr = D3D10StateBlockMaskDifference(&mask_x, &mask_y, NULL);
96 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
98 hr = D3D10StateBlockMaskIntersect(&mask_x, &mask_y, &result);
99 ok(SUCCEEDED(hr), "D3D10StateBlockMaskIntersect failed, hr %#x.\n", hr);
100 ok(result.VS == 0x11, "Got unexpected result.VS %#x.\n", result.VS);
101 ok(result.Predication == 0x88, "Got unexpected result.Predication %#x.\n", result.Predication);
102 hr = D3D10StateBlockMaskIntersect(NULL, &mask_y, &result);
103 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
104 hr = D3D10StateBlockMaskIntersect(&mask_x, NULL, &result);
105 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
106 hr = D3D10StateBlockMaskIntersect(&mask_x, &mask_y, NULL);
107 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
109 hr = D3D10StateBlockMaskUnion(&mask_x, &mask_y, &result);
110 ok(SUCCEEDED(hr), "D3D10StateBlockMaskUnion failed, hr %#x.\n", hr);
111 ok(result.VS == 0x77, "Got unexpected result.VS %#x.\n", result.VS);
112 ok(result.Predication == 0xbb, "Got unexpected result.Predication %#x.\n", result.Predication);
113 hr = D3D10StateBlockMaskUnion(NULL, &mask_y, &result);
114 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
115 hr = D3D10StateBlockMaskUnion(&mask_x, NULL, &result);
116 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
117 hr = D3D10StateBlockMaskUnion(&mask_x, &mask_y, NULL);
118 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
120 memset(&result, 0xff, sizeof(result));
121 hr = D3D10StateBlockMaskDisableAll(&result);
122 ok(SUCCEEDED(hr), "D3D10StateBlockMaskDisableAll failed, hr %#x.\n", hr);
123 ok(!result.VS, "Got unexpected result.VS %#x.\n", result.VS);
124 ok(!result.Predication, "Got unexpected result.Predication %#x.\n", result.Predication);
125 hr = D3D10StateBlockMaskDisableAll(NULL);
126 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
128 memset(&result, 0, sizeof(result));
129 hr = D3D10StateBlockMaskEnableAll(&result);
130 ok(SUCCEEDED(hr), "D3D10StateBlockMaskEnableAll failed, hr %#x.\n", hr);
131 ok(result.VS == 0xff, "Got unexpected result.VS %#x.\n", result.VS);
132 ok(result.Predication == 0xff, "Got unexpected result.Predication %#x.\n", result.Predication);
133 hr = D3D10StateBlockMaskEnableAll(NULL);
134 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
136 result.VS = 0xff;
137 hr = D3D10StateBlockMaskDisableCapture(&result, D3D10_DST_VS, 0, 1);
138 ok(SUCCEEDED(hr), "D3D10StateBlockMaskDisableCapture failed, hr %#x.\n", hr);
139 ok(result.VS == 0xfe, "Got unexpected result.VS %#x.\n", result.VS);
140 hr = D3D10StateBlockMaskDisableCapture(&result, D3D10_DST_VS, 0, 4);
141 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
142 hr = D3D10StateBlockMaskDisableCapture(&result, D3D10_DST_VS, 1, 1);
143 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
144 hr = D3D10StateBlockMaskDisableCapture(NULL, D3D10_DST_VS, 0, 1);
145 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
146 result.VS = 0;
147 hr = D3D10StateBlockMaskEnableCapture(&result, D3D10_DST_VS, 0, 1);
148 ok(SUCCEEDED(hr), "D3D10StateBlockMaskEnableCapture failed, hr %#x.\n", hr);
149 ok(result.VS == 0x01, "Got unexpected result.VS %#x.\n", result.VS);
150 hr = D3D10StateBlockMaskEnableCapture(&result, D3D10_DST_VS, 0, 4);
151 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
152 hr = D3D10StateBlockMaskEnableCapture(&result, D3D10_DST_VS, 1, 1);
153 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
154 hr = D3D10StateBlockMaskEnableCapture(NULL, D3D10_DST_VS, 0, 1);
155 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
156 for (i = 0; i < ARRAY_SIZE(capture_test); ++i)
158 memset(&result, 0xff, sizeof(result));
159 hr = D3D10StateBlockMaskDisableCapture(&result, D3D10_DST_VS_SHADER_RESOURCES,
160 capture_test[i].start_idx, capture_test[i].count);
161 ok(SUCCEEDED(hr), "D3D10StateBlockMaskDisableCapture failed, hr %#x.\n", hr);
163 ok(!memcmp(result.VSShaderResources, capture_test[i].expected_disable, 5),
164 "Got unexpected result.VSShaderResources[0..4] {%#x, %#x, %#x, %#x, %#x} for test %u.\n",
165 result.VSShaderResources[0], result.VSShaderResources[1],
166 result.VSShaderResources[2], result.VSShaderResources[3],
167 result.VSShaderResources[4], i);
169 memset(&result, 0, sizeof(result));
170 hr = D3D10StateBlockMaskEnableCapture(&result, D3D10_DST_VS_SHADER_RESOURCES,
171 capture_test[i].start_idx, capture_test[i].count);
172 ok(SUCCEEDED(hr), "D3D10StateBlockMaskEnableCapture failed, hr %#x.\n", hr);
174 ok(!memcmp(result.VSShaderResources, capture_test[i].expected_enable, 5),
175 "Got unexpected result.VSShaderResources[0..4] {%#x, %#x, %#x, %#x, %#x} for test %u.\n",
176 result.VSShaderResources[0], result.VSShaderResources[1],
177 result.VSShaderResources[2], result.VSShaderResources[3],
178 result.VSShaderResources[4], i);
181 result.VS = 0xff;
182 ret = D3D10StateBlockMaskGetSetting(&result, D3D10_DST_VS, 0);
183 ok(ret == 1, "Got unexpected ret %#x.\n", ret);
184 ret = D3D10StateBlockMaskGetSetting(&result, D3D10_DST_VS, 1);
185 ok(!ret, "Got unexpected ret %#x.\n", ret);
186 result.VS = 0xfe;
187 ret = D3D10StateBlockMaskGetSetting(&result, D3D10_DST_VS, 0);
188 ok(!ret, "Got unexpected ret %#x.\n", ret);
189 result.VS = 0;
190 ret = D3D10StateBlockMaskGetSetting(&result, D3D10_DST_VS, 0);
191 ok(!ret, "Got unexpected ret %#x.\n", ret);
192 memset(&result, 0xff, sizeof(result));
193 ret = D3D10StateBlockMaskGetSetting(&result, D3D10_DST_VS_SHADER_RESOURCES, 3);
194 ok(ret == 8, "Got unexpected ret %#x.\n", ret);
195 ret = D3D10StateBlockMaskGetSetting(&result, D3D10_DST_VS_SHADER_RESOURCES,
196 D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
197 ok(!ret, "Got unexpected ret %#x.\n", ret);
198 memset(&result, 0, sizeof(result));
199 ret = D3D10StateBlockMaskGetSetting(&result, D3D10_DST_VS_SHADER_RESOURCES, 3);
200 ok(!ret, "Got unexpected ret %#x.\n", ret);
203 START_TEST(device)
205 test_create_device();
206 test_stateblock_mask();