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 void test_stateblock_mask(void)
30 BYTE expected_disable
[5];
31 BYTE expected_enable
[5];
35 { 8, 4, {0xff, 0xf0, 0xff, 0xff, 0xff}, {0x00, 0x0f, 0x00, 0x00, 0x00}},
36 { 9, 4, {0xff, 0xe1, 0xff, 0xff, 0xff}, {0x00, 0x1e, 0x00, 0x00, 0x00}},
37 {10, 4, {0xff, 0xc3, 0xff, 0xff, 0xff}, {0x00, 0x3c, 0x00, 0x00, 0x00}},
38 {11, 4, {0xff, 0x87, 0xff, 0xff, 0xff}, {0x00, 0x78, 0x00, 0x00, 0x00}},
39 {12, 4, {0xff, 0x0f, 0xff, 0xff, 0xff}, {0x00, 0xf0, 0x00, 0x00, 0x00}},
40 {13, 4, {0xff, 0x1f, 0xfe, 0xff, 0xff}, {0x00, 0xe0, 0x01, 0x00, 0x00}},
41 {14, 4, {0xff, 0x3f, 0xfc, 0xff, 0xff}, {0x00, 0xc0, 0x03, 0x00, 0x00}},
42 {15, 4, {0xff, 0x7f, 0xf8, 0xff, 0xff}, {0x00, 0x80, 0x07, 0x00, 0x00}},
43 { 8, 12, {0xff, 0x00, 0xf0, 0xff, 0xff}, {0x00, 0xff, 0x0f, 0x00, 0x00}},
44 { 9, 12, {0xff, 0x01, 0xe0, 0xff, 0xff}, {0x00, 0xfe, 0x1f, 0x00, 0x00}},
45 {10, 12, {0xff, 0x03, 0xc0, 0xff, 0xff}, {0x00, 0xfc, 0x3f, 0x00, 0x00}},
46 {11, 12, {0xff, 0x07, 0x80, 0xff, 0xff}, {0x00, 0xf8, 0x7f, 0x00, 0x00}},
47 {12, 12, {0xff, 0x0f, 0x00, 0xff, 0xff}, {0x00, 0xf0, 0xff, 0x00, 0x00}},
48 {13, 12, {0xff, 0x1f, 0x00, 0xfe, 0xff}, {0x00, 0xe0, 0xff, 0x01, 0x00}},
49 {14, 12, {0xff, 0x3f, 0x00, 0xfc, 0xff}, {0x00, 0xc0, 0xff, 0x03, 0x00}},
50 {15, 12, {0xff, 0x7f, 0x00, 0xf8, 0xff}, {0x00, 0x80, 0xff, 0x07, 0x00}},
52 D3D10_STATE_BLOCK_MASK mask_x
, mask_y
, result
;
57 memset(&mask_x
, 0, sizeof(mask_x
));
58 memset(&mask_y
, 0, sizeof(mask_y
));
59 memset(&result
, 0, sizeof(result
));
63 mask_x
.Predication
= 0x99;
64 mask_y
.Predication
= 0xaa;
66 hr
= D3D10StateBlockMaskDifference(&mask_x
, &mask_y
, &result
);
67 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskDifference failed, hr %#x.\n", hr
);
68 ok(result
.VS
== 0x66, "Got unexpected result.VS %#x.\n", result
.VS
);
69 ok(result
.Predication
== 0x33, "Got unexpected result.Predication %#x.\n", result
.Predication
);
70 hr
= D3D10StateBlockMaskDifference(NULL
, &mask_y
, &result
);
71 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
72 hr
= D3D10StateBlockMaskDifference(&mask_x
, NULL
, &result
);
73 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
74 hr
= D3D10StateBlockMaskDifference(&mask_x
, &mask_y
, NULL
);
75 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
77 hr
= D3D10StateBlockMaskIntersect(&mask_x
, &mask_y
, &result
);
78 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskIntersect failed, hr %#x.\n", hr
);
79 ok(result
.VS
== 0x11, "Got unexpected result.VS %#x.\n", result
.VS
);
80 ok(result
.Predication
== 0x88, "Got unexpected result.Predication %#x.\n", result
.Predication
);
81 hr
= D3D10StateBlockMaskIntersect(NULL
, &mask_y
, &result
);
82 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
83 hr
= D3D10StateBlockMaskIntersect(&mask_x
, NULL
, &result
);
84 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
85 hr
= D3D10StateBlockMaskIntersect(&mask_x
, &mask_y
, NULL
);
86 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
88 hr
= D3D10StateBlockMaskUnion(&mask_x
, &mask_y
, &result
);
89 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskUnion failed, hr %#x.\n", hr
);
90 ok(result
.VS
== 0x77, "Got unexpected result.VS %#x.\n", result
.VS
);
91 ok(result
.Predication
== 0xbb, "Got unexpected result.Predication %#x.\n", result
.Predication
);
92 hr
= D3D10StateBlockMaskUnion(NULL
, &mask_y
, &result
);
93 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
94 hr
= D3D10StateBlockMaskUnion(&mask_x
, NULL
, &result
);
95 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
96 hr
= D3D10StateBlockMaskUnion(&mask_x
, &mask_y
, NULL
);
97 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
99 memset(&result
, 0xff, sizeof(result
));
100 hr
= D3D10StateBlockMaskDisableAll(&result
);
101 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskDisableAll failed, hr %#x.\n", hr
);
102 ok(!result
.VS
, "Got unexpected result.VS %#x.\n", result
.VS
);
103 ok(!result
.Predication
, "Got unexpected result.Predication %#x.\n", result
.Predication
);
104 hr
= D3D10StateBlockMaskDisableAll(NULL
);
105 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
107 memset(&result
, 0, sizeof(result
));
108 hr
= D3D10StateBlockMaskEnableAll(&result
);
109 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskEnableAll failed, hr %#x.\n", hr
);
110 ok(result
.VS
== 0xff, "Got unexpected result.VS %#x.\n", result
.VS
);
111 ok(result
.Predication
== 0xff, "Got unexpected result.Predication %#x.\n", result
.Predication
);
112 hr
= D3D10StateBlockMaskEnableAll(NULL
);
113 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
116 hr
= D3D10StateBlockMaskDisableCapture(&result
, D3D10_DST_VS
, 0, 1);
117 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskDisableCapture failed, hr %#x.\n", hr
);
118 ok(result
.VS
== 0xfe, "Got unexpected result.VS %#x.\n", result
.VS
);
119 hr
= D3D10StateBlockMaskDisableCapture(&result
, D3D10_DST_VS
, 0, 4);
120 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
121 hr
= D3D10StateBlockMaskDisableCapture(&result
, D3D10_DST_VS
, 1, 1);
122 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
123 hr
= D3D10StateBlockMaskDisableCapture(NULL
, D3D10_DST_VS
, 0, 1);
124 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
126 hr
= D3D10StateBlockMaskEnableCapture(&result
, D3D10_DST_VS
, 0, 1);
127 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskEnableCapture failed, hr %#x.\n", hr
);
128 ok(result
.VS
== 0x01, "Got unexpected result.VS %#x.\n", result
.VS
);
129 hr
= D3D10StateBlockMaskEnableCapture(&result
, D3D10_DST_VS
, 0, 4);
130 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
131 hr
= D3D10StateBlockMaskEnableCapture(&result
, D3D10_DST_VS
, 1, 1);
132 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
133 hr
= D3D10StateBlockMaskEnableCapture(NULL
, D3D10_DST_VS
, 0, 1);
134 ok(hr
== E_INVALIDARG
, "Got unexpect hr %#x.\n", hr
);
135 for (i
= 0; i
< sizeof(capture_test
) / sizeof(*capture_test
); ++i
)
137 memset(&result
, 0xff, sizeof(result
));
138 hr
= D3D10StateBlockMaskDisableCapture(&result
, D3D10_DST_VS_SHADER_RESOURCES
,
139 capture_test
[i
].start_idx
, capture_test
[i
].count
);
140 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskDisableCapture failed, hr %#x.\n", hr
);
142 ok(!memcmp(result
.VSShaderResources
, capture_test
[i
].expected_disable
, 5),
143 "Got unexpect result.VSShaderResources[0..4] {%#x, %#x, %#x, %#x, %#x} for test %u.\n",
144 result
.VSShaderResources
[0], result
.VSShaderResources
[1],
145 result
.VSShaderResources
[2], result
.VSShaderResources
[3],
146 result
.VSShaderResources
[4], i
);
148 memset(&result
, 0, sizeof(result
));
149 hr
= D3D10StateBlockMaskEnableCapture(&result
, D3D10_DST_VS_SHADER_RESOURCES
,
150 capture_test
[i
].start_idx
, capture_test
[i
].count
);
151 ok(SUCCEEDED(hr
), "D3D10StateBlockMaskEnableCapture failed, hr %#x.\n", hr
);
153 ok(!memcmp(result
.VSShaderResources
, capture_test
[i
].expected_enable
, 5),
154 "Got unexpect result.VSShaderResources[0..4] {%#x, %#x, %#x, %#x, %#x} for test %u.\n",
155 result
.VSShaderResources
[0], result
.VSShaderResources
[1],
156 result
.VSShaderResources
[2], result
.VSShaderResources
[3],
157 result
.VSShaderResources
[4], i
);
161 ret
= D3D10StateBlockMaskGetSetting(&result
, D3D10_DST_VS
, 0);
162 ok(ret
== 1, "Got unexpected ret %#x.\n", ret
);
163 ret
= D3D10StateBlockMaskGetSetting(&result
, D3D10_DST_VS
, 1);
164 ok(!ret
, "Got unexpected ret %#x.\n", ret
);
166 ret
= D3D10StateBlockMaskGetSetting(&result
, D3D10_DST_VS
, 0);
167 ok(!ret
, "Got unexpected ret %#x.\n", ret
);
169 ret
= D3D10StateBlockMaskGetSetting(&result
, D3D10_DST_VS
, 0);
170 ok(!ret
, "Got unexpected ret %#x.\n", ret
);
171 memset(&result
, 0xff, sizeof(result
));
172 ret
= D3D10StateBlockMaskGetSetting(&result
, D3D10_DST_VS_SHADER_RESOURCES
, 3);
173 ok(ret
== 8, "Got unexpected ret %#x.\n", ret
);
174 ret
= D3D10StateBlockMaskGetSetting(&result
, D3D10_DST_VS_SHADER_RESOURCES
,
175 D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT
);
176 ok(!ret
, "Got unexpected ret %#x.\n", ret
);
177 memset(&result
, 0, sizeof(result
));
178 ret
= D3D10StateBlockMaskGetSetting(&result
, D3D10_DST_VS_SHADER_RESOURCES
, 3);
179 ok(!ret
, "Got unexpected ret %#x.\n", ret
);
184 test_stateblock_mask();