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
22 #include "wine/test.h"
24 static ID3D10Device
*create_device(void)
28 if (SUCCEEDED(D3D10CreateDevice(NULL
, D3D10_DRIVER_TYPE_HARDWARE
, NULL
, 0, D3D10_SDK_VERSION
, &device
)))
30 trace("Created a HW device\n");
34 trace("Failed to create a HW device, trying REF\n");
35 if (SUCCEEDED(D3D10CreateDevice(NULL
, D3D10_DRIVER_TYPE_REFERENCE
, NULL
, 0, D3D10_SDK_VERSION
, &device
)))
37 trace("Created a REF device\n");
41 trace("Failed to create a device, returning NULL\n");
45 static void test_device_interfaces(ID3D10Device
*device
)
50 if (SUCCEEDED(hr
= ID3D10Device_QueryInterface(device
, &IID_IUnknown
, (void **)&obj
)))
51 IUnknown_Release(obj
);
52 ok(SUCCEEDED(hr
), "ID3D10Device does not implement IUnknown (%#x)\n", hr
);
54 if (SUCCEEDED(hr
= ID3D10Device_QueryInterface(device
, &IID_ID3D10Device
, (void **)&obj
)))
55 IUnknown_Release(obj
);
56 ok(SUCCEEDED(hr
), "ID3D10Device does not implement ID3D10Device (%#x)\n", hr
);
58 if (SUCCEEDED(hr
= ID3D10Device_QueryInterface(device
, &IID_IDXGIObject
, (void **)&obj
)))
59 IUnknown_Release(obj
);
60 ok(SUCCEEDED(hr
), "ID3D10Device does not implement IDXGIObject (%#x)\n", hr
);
62 if (SUCCEEDED(hr
= ID3D10Device_QueryInterface(device
, &IID_IDXGIDevice
, (void **)&obj
)))
63 IUnknown_Release(obj
);
64 ok(SUCCEEDED(hr
), "ID3D10Device does not implement IDXGIDevice (%#x)\n", hr
);
67 static void test_stateblock_mask(void)
73 BYTE expected_disable
[5];
74 BYTE expected_enable
[5];
78 { 8, 4, {0xff, 0xf0, 0xff, 0xff, 0xff}, {0x00, 0x0f, 0x00, 0x00, 0x00}},
79 { 9, 4, {0xff, 0xe1, 0xff, 0xff, 0xff}, {0x00, 0x1e, 0x00, 0x00, 0x00}},
80 {10, 4, {0xff, 0xc3, 0xff, 0xff, 0xff}, {0x00, 0x3c, 0x00, 0x00, 0x00}},
81 {11, 4, {0xff, 0x87, 0xff, 0xff, 0xff}, {0x00, 0x78, 0x00, 0x00, 0x00}},
82 {12, 4, {0xff, 0x0f, 0xff, 0xff, 0xff}, {0x00, 0xf0, 0x00, 0x00, 0x00}},
83 {13, 4, {0xff, 0x1f, 0xfe, 0xff, 0xff}, {0x00, 0xe0, 0x01, 0x00, 0x00}},
84 {14, 4, {0xff, 0x3f, 0xfc, 0xff, 0xff}, {0x00, 0xc0, 0x03, 0x00, 0x00}},
85 {15, 4, {0xff, 0x7f, 0xf8, 0xff, 0xff}, {0x00, 0x80, 0x07, 0x00, 0x00}},
86 { 8, 12, {0xff, 0x00, 0xf0, 0xff, 0xff}, {0x00, 0xff, 0x0f, 0x00, 0x00}},
87 { 9, 12, {0xff, 0x01, 0xe0, 0xff, 0xff}, {0x00, 0xfe, 0x1f, 0x00, 0x00}},
88 {10, 12, {0xff, 0x03, 0xc0, 0xff, 0xff}, {0x00, 0xfc, 0x3f, 0x00, 0x00}},
89 {11, 12, {0xff, 0x07, 0x80, 0xff, 0xff}, {0x00, 0xf8, 0x7f, 0x00, 0x00}},
90 {12, 12, {0xff, 0x0f, 0x00, 0xff, 0xff}, {0x00, 0xf0, 0xff, 0x00, 0x00}},
91 {13, 12, {0xff, 0x1f, 0x00, 0xfe, 0xff}, {0x00, 0xe0, 0xff, 0x01, 0x00}},
92 {14, 12, {0xff, 0x3f, 0x00, 0xfc, 0xff}, {0x00, 0xc0, 0xff, 0x03, 0x00}},
93 {15, 12, {0xff, 0x7f, 0x00, 0xf8, 0xff}, {0x00, 0x80, 0xff, 0x07, 0x00}},
95 D3D10_STATE_BLOCK_MASK mask_x
, mask_y
, result
;
100 memset(&mask_x
, 0, sizeof(mask_x
));
101 memset(&mask_y
, 0, sizeof(mask_y
));
102 memset(&result
, 0, sizeof(result
));
106 mask_x
.Predication
= 0x99;
107 mask_y
.Predication
= 0xaa;
109 hr
= D3D10StateBlockMaskDifference(&mask_x
, &mask_y
, &result
);
110 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskDifference failed, hr %#x.\n", hr
);
111 ok(result
.VS
== 0x66, "Got unexpected result.VS %#x.\n", result
.VS
);
112 ok(result
.Predication
== 0x33, "Got unexpected result.Predication %#x.\n", result
.Predication
);
113 hr
= D3D10StateBlockMaskDifference(NULL
, &mask_y
, &result
);
114 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
115 hr
= D3D10StateBlockMaskDifference(&mask_x
, NULL
, &result
);
116 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
117 hr
= D3D10StateBlockMaskDifference(&mask_x
, &mask_y
, NULL
);
118 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
120 hr
= D3D10StateBlockMaskIntersect(&mask_x
, &mask_y
, &result
);
121 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskIntersect failed, hr %#x.\n", hr
);
122 ok(result
.VS
== 0x11, "Got unexpected result.VS %#x.\n", result
.VS
);
123 ok(result
.Predication
== 0x88, "Got unexpected result.Predication %#x.\n", result
.Predication
);
124 hr
= D3D10StateBlockMaskIntersect(NULL
, &mask_y
, &result
);
125 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
126 hr
= D3D10StateBlockMaskIntersect(&mask_x
, NULL
, &result
);
127 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
128 hr
= D3D10StateBlockMaskIntersect(&mask_x
, &mask_y
, NULL
);
129 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
131 hr
= D3D10StateBlockMaskUnion(&mask_x
, &mask_y
, &result
);
132 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskUnion failed, hr %#x.\n", hr
);
133 ok(result
.VS
== 0x77, "Got unexpected result.VS %#x.\n", result
.VS
);
134 ok(result
.Predication
== 0xbb, "Got unexpected result.Predication %#x.\n", result
.Predication
);
135 hr
= D3D10StateBlockMaskUnion(NULL
, &mask_y
, &result
);
136 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
137 hr
= D3D10StateBlockMaskUnion(&mask_x
, NULL
, &result
);
138 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
139 hr
= D3D10StateBlockMaskUnion(&mask_x
, &mask_y
, NULL
);
140 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
142 memset(&result
, 0xff, sizeof(result
));
143 hr
= D3D10StateBlockMaskDisableAll(&result
);
144 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskDisableAll failed, hr %#x.\n", hr
);
145 ok(!result
.VS
, "Got unexpected result.VS %#x.\n", result
.VS
);
146 ok(!result
.Predication
, "Got unexpected result.Predication %#x.\n", result
.Predication
);
147 hr
= D3D10StateBlockMaskDisableAll(NULL
);
148 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
150 memset(&result
, 0, sizeof(result
));
151 hr
= D3D10StateBlockMaskEnableAll(&result
);
152 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskEnableAll failed, hr %#x.\n", hr
);
153 ok(result
.VS
== 0xff, "Got unexpected result.VS %#x.\n", result
.VS
);
154 ok(result
.Predication
== 0xff, "Got unexpected result.Predication %#x.\n", result
.Predication
);
155 hr
= D3D10StateBlockMaskEnableAll(NULL
);
156 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
159 hr
= D3D10StateBlockMaskDisableCapture(&result
, D3D10_DST_VS
, 0, 1);
160 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskDisableCapture failed, hr %#x.\n", hr
);
161 ok(result
.VS
== 0xfe, "Got unexpected result.VS %#x.\n", result
.VS
);
162 hr
= D3D10StateBlockMaskDisableCapture(&result
, D3D10_DST_VS
, 0, 4);
163 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
164 hr
= D3D10StateBlockMaskDisableCapture(&result
, D3D10_DST_VS
, 1, 1);
165 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
166 hr
= D3D10StateBlockMaskDisableCapture(NULL
, D3D10_DST_VS
, 0, 1);
167 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
169 hr
= D3D10StateBlockMaskEnableCapture(&result
, D3D10_DST_VS
, 0, 1);
170 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskEnableCapture failed, hr %#x.\n", hr
);
171 ok(result
.VS
== 0x01, "Got unexpected result.VS %#x.\n", result
.VS
);
172 hr
= D3D10StateBlockMaskEnableCapture(&result
, D3D10_DST_VS
, 0, 4);
173 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
174 hr
= D3D10StateBlockMaskEnableCapture(&result
, D3D10_DST_VS
, 1, 1);
175 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
176 hr
= D3D10StateBlockMaskEnableCapture(NULL
, D3D10_DST_VS
, 0, 1);
177 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
178 for (i
= 0; i
< sizeof(capture_test
) / sizeof(*capture_test
); ++i
)
180 memset(&result
, 0xff, sizeof(result
));
181 hr
= D3D10StateBlockMaskDisableCapture(&result
, D3D10_DST_VS_SHADER_RESOURCES
,
182 capture_test
[i
].start_idx
, capture_test
[i
].count
);
183 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskDisableCapture failed, hr %#x.\n", hr
);
185 ok(!memcmp(result
.VSShaderResources
, capture_test
[i
].expected_disable
, 5),
186 "Got unexpect result.VSShaderResources[0..4] {%#x, %#x, %#x, %#x, %#x} for test %u.\n",
187 result
.VSShaderResources
[0], result
.VSShaderResources
[1],
188 result
.VSShaderResources
[2], result
.VSShaderResources
[3],
189 result
.VSShaderResources
[4], i
);
191 memset(&result
, 0, sizeof(result
));
192 hr
= D3D10StateBlockMaskEnableCapture(&result
, D3D10_DST_VS_SHADER_RESOURCES
,
193 capture_test
[i
].start_idx
, capture_test
[i
].count
);
194 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskEnableCapture failed, hr %#x.\n", hr
);
196 ok(!memcmp(result
.VSShaderResources
, capture_test
[i
].expected_enable
, 5),
197 "Got unexpect result.VSShaderResources[0..4] {%#x, %#x, %#x, %#x, %#x} for test %u.\n",
198 result
.VSShaderResources
[0], result
.VSShaderResources
[1],
199 result
.VSShaderResources
[2], result
.VSShaderResources
[3],
200 result
.VSShaderResources
[4], i
);
204 ret
= D3D10StateBlockMaskGetSetting(&result
, D3D10_DST_VS
, 0);
205 ok(ret
== 1, "Got unexpected ret %#x.\n", ret
);
206 ret
= D3D10StateBlockMaskGetSetting(&result
, D3D10_DST_VS
, 1);
207 ok(!ret
, "Got unexpected ret %#x.\n", ret
);
209 ret
= D3D10StateBlockMaskGetSetting(&result
, D3D10_DST_VS
, 0);
210 ok(!ret
, "Got unexpected ret %#x.\n", ret
);
212 ret
= D3D10StateBlockMaskGetSetting(&result
, D3D10_DST_VS
, 0);
213 ok(!ret
, "Got unexpected ret %#x.\n", ret
);
214 memset(&result
, 0xff, sizeof(result
));
215 ret
= D3D10StateBlockMaskGetSetting(&result
, D3D10_DST_VS_SHADER_RESOURCES
, 3);
216 ok(ret
== 8, "Got unexpected ret %#x.\n", ret
);
217 ret
= D3D10StateBlockMaskGetSetting(&result
, D3D10_DST_VS_SHADER_RESOURCES
,
218 D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
);
219 ok(!ret
, "Got unexpected ret %#x.\n", ret
);
220 memset(&result
, 0, sizeof(result
));
221 ret
= D3D10StateBlockMaskGetSetting(&result
, D3D10_DST_VS_SHADER_RESOURCES
, 3);
222 ok(!ret
, "Got unexpected ret %#x.\n", ret
);
227 ID3D10Device
*device
;
230 device
= create_device();
233 skip("Failed to create device, skipping tests\n");
237 test_device_interfaces(device
);
238 test_stateblock_mask();
240 refcount
= ID3D10Device_Release(device
);
241 ok(!refcount
, "Device has %u references left\n", refcount
);