windowscodecs/tests: Use BOOL type where appropriate.
[wine.git] / dlls / d3d10 / stateblock.c
blobef6fe3f8e20576a4a0f9e8c3af489ac6c090a6f9
1 /*
2 * Copyright 2011 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
20 #include "config.h"
21 #include "wine/port.h"
23 #include "d3d10_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
27 struct d3d10_stateblock
29 ID3D10StateBlock ID3D10StateBlock_iface;
30 LONG refcount;
33 static inline struct d3d10_stateblock *impl_from_ID3D10StateBlock(ID3D10StateBlock *iface)
35 return CONTAINING_RECORD(iface, struct d3d10_stateblock, ID3D10StateBlock_iface);
38 static HRESULT STDMETHODCALLTYPE d3d10_stateblock_QueryInterface(ID3D10StateBlock *iface, REFIID iid, void **object)
40 struct d3d10_stateblock *stateblock;
42 TRACE("iface %p, iid %s, object %p.\n", iface, debugstr_guid(iid), object);
44 stateblock = impl_from_ID3D10StateBlock(iface);
46 if (IsEqualGUID(iid, &IID_ID3D10StateBlock)
47 || IsEqualGUID(iid, &IID_IUnknown))
49 IUnknown_AddRef(&stateblock->ID3D10StateBlock_iface);
50 *object = &stateblock->ID3D10StateBlock_iface;
51 return S_OK;
54 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
55 *object = NULL;
57 return E_NOINTERFACE;
60 static ULONG STDMETHODCALLTYPE d3d10_stateblock_AddRef(ID3D10StateBlock *iface)
62 struct d3d10_stateblock *stateblock = impl_from_ID3D10StateBlock(iface);
63 ULONG refcount = InterlockedIncrement(&stateblock->refcount);
65 TRACE("%p increasing refcount to %u.\n", stateblock, refcount);
67 return refcount;
70 static ULONG STDMETHODCALLTYPE d3d10_stateblock_Release(ID3D10StateBlock *iface)
72 struct d3d10_stateblock *stateblock = impl_from_ID3D10StateBlock(iface);
73 ULONG refcount = InterlockedDecrement(&stateblock->refcount);
75 TRACE("%p decreasing refcount to %u.\n", stateblock, refcount);
77 if (!refcount)
78 HeapFree(GetProcessHeap(), 0, stateblock);
80 return refcount;
83 static HRESULT STDMETHODCALLTYPE d3d10_stateblock_Capture(ID3D10StateBlock *iface)
85 FIXME("iface %p stub!\n", iface);
87 return E_NOTIMPL;
90 static HRESULT STDMETHODCALLTYPE d3d10_stateblock_Apply(ID3D10StateBlock *iface)
92 FIXME("iface %p stub!\n", iface);
94 return E_NOTIMPL;
97 static HRESULT STDMETHODCALLTYPE d3d10_stateblock_ReleaseAllDeviceObjects(ID3D10StateBlock *iface)
99 FIXME("iface %p stub!\n", iface);
101 return E_NOTIMPL;
104 static HRESULT STDMETHODCALLTYPE d3d10_stateblock_GetDevice(ID3D10StateBlock *iface, ID3D10Device **device)
106 FIXME("iface %p, device %p stub!\n", iface, device);
108 return E_NOTIMPL;
111 static const struct ID3D10StateBlockVtbl d3d10_stateblock_vtbl =
113 /* IUnknown methods */
114 d3d10_stateblock_QueryInterface,
115 d3d10_stateblock_AddRef,
116 d3d10_stateblock_Release,
117 /* ID3D10StateBlock methods */
118 d3d10_stateblock_Capture,
119 d3d10_stateblock_Apply,
120 d3d10_stateblock_ReleaseAllDeviceObjects,
121 d3d10_stateblock_GetDevice,
124 HRESULT WINAPI D3D10CreateStateBlock(ID3D10Device *device,
125 D3D10_STATE_BLOCK_MASK *mask, ID3D10StateBlock **stateblock)
127 struct d3d10_stateblock *object;
129 FIXME("device %p, mask %p, stateblock %p stub!\n", device, mask, stateblock);
131 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
132 if (!object)
134 ERR("Failed to allocate D3D10 stateblock object memory.\n");
135 return E_OUTOFMEMORY;
138 object->ID3D10StateBlock_iface.lpVtbl = &d3d10_stateblock_vtbl;
139 object->refcount = 1;
141 TRACE("Created stateblock %p.\n", object);
142 *stateblock = &object->ID3D10StateBlock_iface;
144 return S_OK;
147 static BOOL stateblock_mask_get_bit(BYTE *field, UINT field_size, UINT idx)
149 if (idx >= field_size)
150 return FALSE;
152 return field[idx >> 3] & (1 << (idx & 7));
155 static HRESULT stateblock_mask_set_bits(BYTE *field, UINT field_size, UINT start_bit, UINT count)
157 UINT end_bit = start_bit + count;
158 BYTE start_mask = 0xff << (start_bit & 7);
159 BYTE end_mask = 0x7f >> (~end_bit & 7);
160 UINT start_idx = start_bit >> 3;
161 UINT end_idx = end_bit >> 3;
163 if (start_bit >= field_size || field_size - start_bit < count)
164 return E_INVALIDARG;
166 if (start_idx == end_idx)
168 field[start_idx] |= start_mask & end_mask;
169 return S_OK;
172 if (start_bit & 7)
174 field[start_idx] |= start_mask;
175 ++start_idx;
178 memset(&field[start_idx], 0xff, end_idx - start_idx);
180 if (end_bit & 7)
181 field[end_idx] |= end_mask;
183 return S_OK;
186 static HRESULT stateblock_mask_clear_bits(BYTE *field, UINT field_size, UINT start_bit, UINT count)
188 UINT end_bit = start_bit + count;
189 BYTE start_mask = 0x7f >> (~start_bit & 7);
190 BYTE end_mask = 0xff << (end_bit & 7);
191 UINT start_idx = start_bit >> 3;
192 UINT end_idx = end_bit >> 3;
194 if (start_bit >= field_size || field_size - start_bit < count)
195 return E_INVALIDARG;
197 if (start_idx == end_idx)
199 field[start_idx] &= start_mask | end_mask;
200 return S_OK;
203 if (start_bit & 7)
205 field[start_idx] &= start_mask;
206 ++start_idx;
209 memset(&field[start_idx], 0, end_idx - start_idx);
211 if (end_bit & 7)
212 field[end_idx] &= end_mask;
214 return S_OK;
217 HRESULT WINAPI D3D10StateBlockMaskDifference(D3D10_STATE_BLOCK_MASK *mask_x,
218 D3D10_STATE_BLOCK_MASK *mask_y, D3D10_STATE_BLOCK_MASK *result)
220 UINT count = sizeof(*result) / sizeof(DWORD);
221 UINT i;
223 TRACE("mask_x %p, mask_y %p, result %p.\n", mask_x, mask_y, result);
225 if (!mask_x || !mask_y || !result)
226 return E_INVALIDARG;
228 for (i = 0; i < count; ++i)
230 ((DWORD *)result)[i] = ((DWORD *)mask_x)[i] ^ ((DWORD *)mask_y)[i];
232 for (i = count * sizeof(DWORD); i < sizeof(*result); ++i)
234 ((BYTE *)result)[i] = ((BYTE *)mask_x)[i] ^ ((BYTE *)mask_y)[i];
237 return S_OK;
240 HRESULT WINAPI D3D10StateBlockMaskDisableAll(D3D10_STATE_BLOCK_MASK *mask)
242 TRACE("mask %p.\n", mask);
244 if (!mask)
245 return E_INVALIDARG;
247 memset(mask, 0, sizeof(*mask));
249 return S_OK;
252 HRESULT WINAPI D3D10StateBlockMaskDisableCapture(D3D10_STATE_BLOCK_MASK *mask,
253 D3D10_DEVICE_STATE_TYPES state_type, UINT start_idx, UINT count)
255 TRACE("mask %p state_type %s, start_idx %u, count %u.\n",
256 mask, debug_d3d10_device_state_types(state_type), start_idx, count);
258 if (!mask)
259 return E_INVALIDARG;
261 switch (state_type)
263 case D3D10_DST_SO_BUFFERS:
264 return stateblock_mask_clear_bits(&mask->SOBuffers, 1, start_idx, count);
265 case D3D10_DST_OM_RENDER_TARGETS:
266 return stateblock_mask_clear_bits(&mask->OMRenderTargets, 1, start_idx, count);
267 case D3D10_DST_DEPTH_STENCIL_STATE:
268 return stateblock_mask_clear_bits(&mask->OMDepthStencilState, 1, start_idx, count);
269 case D3D10_DST_BLEND_STATE:
270 return stateblock_mask_clear_bits(&mask->OMBlendState, 1, start_idx, count);
271 case D3D10_DST_VS:
272 return stateblock_mask_clear_bits(&mask->VS, 1, start_idx, count);
273 case D3D10_DST_VS_SAMPLERS:
274 return stateblock_mask_clear_bits(mask->VSSamplers,
275 D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, start_idx, count);
276 case D3D10_DST_VS_SHADER_RESOURCES:
277 return stateblock_mask_clear_bits(mask->VSShaderResources,
278 D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, start_idx, count);
279 case D3D10_DST_VS_CONSTANT_BUFFERS:
280 return stateblock_mask_clear_bits(mask->VSConstantBuffers,
281 D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, start_idx, count);
282 case D3D10_DST_GS:
283 return stateblock_mask_clear_bits(&mask->GS, 1, start_idx, count);
284 case D3D10_DST_GS_SAMPLERS:
285 return stateblock_mask_clear_bits(mask->GSSamplers,
286 D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, start_idx, count);
287 case D3D10_DST_GS_SHADER_RESOURCES:
288 return stateblock_mask_clear_bits(mask->GSShaderResources,
289 D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, start_idx, count);
290 case D3D10_DST_GS_CONSTANT_BUFFERS:
291 return stateblock_mask_clear_bits(mask->GSConstantBuffers,
292 D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, start_idx, count);
293 case D3D10_DST_PS:
294 return stateblock_mask_clear_bits(&mask->PS, 1, start_idx, count);
295 case D3D10_DST_PS_SAMPLERS:
296 return stateblock_mask_clear_bits(mask->PSSamplers,
297 D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, start_idx, count);
298 case D3D10_DST_PS_SHADER_RESOURCES:
299 return stateblock_mask_clear_bits(mask->PSShaderResources,
300 D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, start_idx, count);
301 case D3D10_DST_PS_CONSTANT_BUFFERS:
302 return stateblock_mask_clear_bits(mask->PSConstantBuffers,
303 D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, start_idx, count);
304 case D3D10_DST_IA_VERTEX_BUFFERS:
305 return stateblock_mask_clear_bits(mask->IAVertexBuffers,
306 D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, start_idx, count);
307 case D3D10_DST_IA_INDEX_BUFFER:
308 return stateblock_mask_clear_bits(&mask->IAIndexBuffer, 1, start_idx, count);
309 case D3D10_DST_IA_INPUT_LAYOUT:
310 return stateblock_mask_clear_bits(&mask->IAInputLayout, 1, start_idx, count);
311 case D3D10_DST_IA_PRIMITIVE_TOPOLOGY:
312 return stateblock_mask_clear_bits(&mask->IAPrimitiveTopology, 1, start_idx, count);
313 case D3D10_DST_RS_VIEWPORTS:
314 return stateblock_mask_clear_bits(&mask->RSViewports, 1, start_idx, count);
315 case D3D10_DST_RS_SCISSOR_RECTS:
316 return stateblock_mask_clear_bits(&mask->RSScissorRects, 1, start_idx, count);
317 case D3D10_DST_RS_RASTERIZER_STATE:
318 return stateblock_mask_clear_bits(&mask->RSRasterizerState, 1, start_idx, count);
319 case D3D10_DST_PREDICATION:
320 return stateblock_mask_clear_bits(&mask->Predication, 1, start_idx, count);
321 default:
322 FIXME("Unhandled state_type %#x.\n", state_type);
323 return E_INVALIDARG;
327 HRESULT WINAPI D3D10StateBlockMaskEnableAll(D3D10_STATE_BLOCK_MASK *mask)
329 TRACE("mask %p.\n", mask);
331 if (!mask)
332 return E_INVALIDARG;
334 memset(mask, 0xff, sizeof(*mask));
336 return S_OK;
339 HRESULT WINAPI D3D10StateBlockMaskEnableCapture(D3D10_STATE_BLOCK_MASK *mask,
340 D3D10_DEVICE_STATE_TYPES state_type, UINT start_idx, UINT count)
342 TRACE("mask %p state_type %s, start_idx %u, count %u.\n",
343 mask, debug_d3d10_device_state_types(state_type), start_idx, count);
345 if (!mask)
346 return E_INVALIDARG;
348 switch (state_type)
350 case D3D10_DST_SO_BUFFERS:
351 return stateblock_mask_set_bits(&mask->SOBuffers, 1, start_idx, count);
352 case D3D10_DST_OM_RENDER_TARGETS:
353 return stateblock_mask_set_bits(&mask->OMRenderTargets, 1, start_idx, count);
354 case D3D10_DST_DEPTH_STENCIL_STATE:
355 return stateblock_mask_set_bits(&mask->OMDepthStencilState, 1, start_idx, count);
356 case D3D10_DST_BLEND_STATE:
357 return stateblock_mask_set_bits(&mask->OMBlendState, 1, start_idx, count);
358 case D3D10_DST_VS:
359 return stateblock_mask_set_bits(&mask->VS, 1, start_idx, count);
360 case D3D10_DST_VS_SAMPLERS:
361 return stateblock_mask_set_bits(mask->VSSamplers,
362 D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, start_idx, count);
363 case D3D10_DST_VS_SHADER_RESOURCES:
364 return stateblock_mask_set_bits(mask->VSShaderResources,
365 D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, start_idx, count);
366 case D3D10_DST_VS_CONSTANT_BUFFERS:
367 return stateblock_mask_set_bits(mask->VSConstantBuffers,
368 D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, start_idx, count);
369 case D3D10_DST_GS:
370 return stateblock_mask_set_bits(&mask->GS, 1, start_idx, count);
371 case D3D10_DST_GS_SAMPLERS:
372 return stateblock_mask_set_bits(mask->GSSamplers,
373 D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, start_idx, count);
374 case D3D10_DST_GS_SHADER_RESOURCES:
375 return stateblock_mask_set_bits(mask->GSShaderResources,
376 D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, start_idx, count);
377 case D3D10_DST_GS_CONSTANT_BUFFERS:
378 return stateblock_mask_set_bits(mask->GSConstantBuffers,
379 D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, start_idx, count);
380 case D3D10_DST_PS:
381 return stateblock_mask_set_bits(&mask->PS, 1, start_idx, count);
382 case D3D10_DST_PS_SAMPLERS:
383 return stateblock_mask_set_bits(mask->PSSamplers,
384 D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, start_idx, count);
385 case D3D10_DST_PS_SHADER_RESOURCES:
386 return stateblock_mask_set_bits(mask->PSShaderResources,
387 D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, start_idx, count);
388 case D3D10_DST_PS_CONSTANT_BUFFERS:
389 return stateblock_mask_set_bits(mask->PSConstantBuffers,
390 D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, start_idx, count);
391 case D3D10_DST_IA_VERTEX_BUFFERS:
392 return stateblock_mask_set_bits(mask->IAVertexBuffers,
393 D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, start_idx, count);
394 case D3D10_DST_IA_INDEX_BUFFER:
395 return stateblock_mask_set_bits(&mask->IAIndexBuffer, 1, start_idx, count);
396 case D3D10_DST_IA_INPUT_LAYOUT:
397 return stateblock_mask_set_bits(&mask->IAInputLayout, 1, start_idx, count);
398 case D3D10_DST_IA_PRIMITIVE_TOPOLOGY:
399 return stateblock_mask_set_bits(&mask->IAPrimitiveTopology, 1, start_idx, count);
400 case D3D10_DST_RS_VIEWPORTS:
401 return stateblock_mask_set_bits(&mask->RSViewports, 1, start_idx, count);
402 case D3D10_DST_RS_SCISSOR_RECTS:
403 return stateblock_mask_set_bits(&mask->RSScissorRects, 1, start_idx, count);
404 case D3D10_DST_RS_RASTERIZER_STATE:
405 return stateblock_mask_set_bits(&mask->RSRasterizerState, 1, start_idx, count);
406 case D3D10_DST_PREDICATION:
407 return stateblock_mask_set_bits(&mask->Predication, 1, start_idx, count);
408 default:
409 FIXME("Unhandled state_type %#x.\n", state_type);
410 return E_INVALIDARG;
414 BOOL WINAPI D3D10StateBlockMaskGetSetting(D3D10_STATE_BLOCK_MASK *mask,
415 D3D10_DEVICE_STATE_TYPES state_type, UINT idx)
417 TRACE("mask %p state_type %s, idx %u.\n",
418 mask, debug_d3d10_device_state_types(state_type), idx);
420 if (!mask)
421 return FALSE;
423 switch (state_type)
425 case D3D10_DST_SO_BUFFERS:
426 return stateblock_mask_get_bit(&mask->SOBuffers, 1, idx);
427 case D3D10_DST_OM_RENDER_TARGETS:
428 return stateblock_mask_get_bit(&mask->OMRenderTargets, 1, idx);
429 case D3D10_DST_DEPTH_STENCIL_STATE:
430 return stateblock_mask_get_bit(&mask->OMDepthStencilState, 1, idx);
431 case D3D10_DST_BLEND_STATE:
432 return stateblock_mask_get_bit(&mask->OMBlendState, 1, idx);
433 case D3D10_DST_VS:
434 return stateblock_mask_get_bit(&mask->VS, 1, idx);
435 case D3D10_DST_VS_SAMPLERS:
436 return stateblock_mask_get_bit(mask->VSSamplers,
437 D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, idx);
438 case D3D10_DST_VS_SHADER_RESOURCES:
439 return stateblock_mask_get_bit(mask->VSShaderResources,
440 D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, idx);
441 case D3D10_DST_VS_CONSTANT_BUFFERS:
442 return stateblock_mask_get_bit(mask->VSConstantBuffers,
443 D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, idx);
444 case D3D10_DST_GS:
445 return stateblock_mask_get_bit(&mask->GS, 1, idx);
446 case D3D10_DST_GS_SAMPLERS:
447 return stateblock_mask_get_bit(mask->GSSamplers,
448 D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, idx);
449 case D3D10_DST_GS_SHADER_RESOURCES:
450 return stateblock_mask_get_bit(mask->GSShaderResources,
451 D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, idx);
452 case D3D10_DST_GS_CONSTANT_BUFFERS:
453 return stateblock_mask_get_bit(mask->GSConstantBuffers,
454 D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, idx);
455 case D3D10_DST_PS:
456 return stateblock_mask_get_bit(&mask->PS, 1, idx);
457 case D3D10_DST_PS_SAMPLERS:
458 return stateblock_mask_get_bit(mask->PSSamplers,
459 D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, idx);
460 case D3D10_DST_PS_SHADER_RESOURCES:
461 return stateblock_mask_get_bit(mask->PSShaderResources,
462 D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, idx);
463 case D3D10_DST_PS_CONSTANT_BUFFERS:
464 return stateblock_mask_get_bit(mask->PSConstantBuffers,
465 D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, idx);
466 case D3D10_DST_IA_VERTEX_BUFFERS:
467 return stateblock_mask_get_bit(mask->IAVertexBuffers,
468 D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, idx);
469 case D3D10_DST_IA_INDEX_BUFFER:
470 return stateblock_mask_get_bit(&mask->IAIndexBuffer, 1, idx);
471 case D3D10_DST_IA_INPUT_LAYOUT:
472 return stateblock_mask_get_bit(&mask->IAInputLayout, 1, idx);
473 case D3D10_DST_IA_PRIMITIVE_TOPOLOGY:
474 return stateblock_mask_get_bit(&mask->IAPrimitiveTopology, 1, idx);
475 case D3D10_DST_RS_VIEWPORTS:
476 return stateblock_mask_get_bit(&mask->RSViewports, 1, idx);
477 case D3D10_DST_RS_SCISSOR_RECTS:
478 return stateblock_mask_get_bit(&mask->RSScissorRects, 1, idx);
479 case D3D10_DST_RS_RASTERIZER_STATE:
480 return stateblock_mask_get_bit(&mask->RSRasterizerState, 1, idx);
481 case D3D10_DST_PREDICATION:
482 return stateblock_mask_get_bit(&mask->Predication, 1, idx);
483 default:
484 FIXME("Unhandled state_type %#x.\n", state_type);
485 return FALSE;
489 HRESULT WINAPI D3D10StateBlockMaskIntersect(D3D10_STATE_BLOCK_MASK *mask_x,
490 D3D10_STATE_BLOCK_MASK *mask_y, D3D10_STATE_BLOCK_MASK *result)
492 UINT count = sizeof(*result) / sizeof(DWORD);
493 UINT i;
495 TRACE("mask_x %p, mask_y %p, result %p.\n", mask_x, mask_y, result);
497 if (!mask_x || !mask_y || !result)
498 return E_INVALIDARG;
500 for (i = 0; i < count; ++i)
502 ((DWORD *)result)[i] = ((DWORD *)mask_x)[i] & ((DWORD *)mask_y)[i];
504 for (i = count * sizeof(DWORD); i < sizeof(*result); ++i)
506 ((BYTE *)result)[i] = ((BYTE *)mask_x)[i] & ((BYTE *)mask_y)[i];
509 return S_OK;
512 HRESULT WINAPI D3D10StateBlockMaskUnion(D3D10_STATE_BLOCK_MASK *mask_x,
513 D3D10_STATE_BLOCK_MASK *mask_y, D3D10_STATE_BLOCK_MASK *result)
515 UINT count = sizeof(*result) / sizeof(DWORD);
516 UINT i;
518 TRACE("mask_x %p, mask_y %p, result %p.\n", mask_x, mask_y, result);
520 if (!mask_x || !mask_y || !result)
521 return E_INVALIDARG;
523 for (i = 0; i < count; ++i)
525 ((DWORD *)result)[i] = ((DWORD *)mask_x)[i] | ((DWORD *)mask_y)[i];
527 for (i = count * sizeof(DWORD); i < sizeof(*result); ++i)
529 ((BYTE *)result)[i] = ((BYTE *)mask_x)[i] | ((BYTE *)mask_y)[i];
532 return S_OK;