diff --git a/dlls/d3d10/d3d10.spec b/dlls/d3d10/d3d10.spec index 16d2d5f822b..baa0c10d0b3 100644 --- a/dlls/d3d10/d3d10.spec +++ b/dlls/d3d10/d3d10.spec @@ -19,7 +19,7 @@ @ stub D3D10PreprocessShader @ stdcall D3D10ReflectShader(ptr long ptr) @ stub D3D10RegisterLayers -@ stub D3D10StateBlockMaskDifference +@ stdcall D3D10StateBlockMaskDifference(ptr ptr ptr) @ stub D3D10StateBlockMaskDisableAll @ stub D3D10StateBlockMaskDisableCapture @ stub D3D10StateBlockMaskEnableAll diff --git a/dlls/d3d10/stateblock.c b/dlls/d3d10/stateblock.c index a254704bf8c..f121a5c495a 100644 --- a/dlls/d3d10/stateblock.c +++ b/dlls/d3d10/stateblock.c @@ -143,3 +143,26 @@ HRESULT WINAPI D3D10CreateStateBlock(ID3D10Device *device, return S_OK; } + +HRESULT WINAPI D3D10StateBlockMaskDifference(D3D10_STATE_BLOCK_MASK *mask_x, + D3D10_STATE_BLOCK_MASK *mask_y, D3D10_STATE_BLOCK_MASK *result) +{ + UINT count = sizeof(*result) / sizeof(DWORD); + UINT i; + + TRACE("mask_x %p, mask_y %p, result %p.\n", mask_x, mask_y, result); + + if (!mask_x || !mask_y || !result) + return E_INVALIDARG; + + for (i = 0; i < count; ++i) + { + ((DWORD *)result)[i] = ((DWORD *)mask_x)[i] ^ ((DWORD *)mask_y)[i]; + } + for (i = count * sizeof(DWORD); i < sizeof(*result); ++i) + { + ((BYTE *)result)[i] = ((BYTE *)mask_x)[i] ^ ((BYTE *)mask_y)[i]; + } + + return S_OK; +} diff --git a/dlls/d3d10/tests/device.c b/dlls/d3d10/tests/device.c index 8399cdb7bb2..1fc3a3bc6cb 100644 --- a/dlls/d3d10/tests/device.c +++ b/dlls/d3d10/tests/device.c @@ -64,6 +64,32 @@ static void test_device_interfaces(ID3D10Device *device) ok(SUCCEEDED(hr), "ID3D10Device does not implement IDXGIDevice (%#x)\n", hr); } +static void test_stateblock_mask(void) +{ + D3D10_STATE_BLOCK_MASK mask_x, mask_y, result; + HRESULT hr; + + memset(&mask_x, 0, sizeof(mask_x)); + memset(&mask_y, 0, sizeof(mask_y)); + memset(&result, 0, sizeof(result)); + + mask_x.VS = 0x33; + mask_y.VS = 0x55; + mask_x.Predication = 0x99; + mask_y.Predication = 0xaa; + + hr = D3D10StateBlockMaskDifference(&mask_x, &mask_y, &result); + ok(SUCCEEDED(hr), "D3D10StateBlockMaskDifference failed, hr %#x.\n", hr); + ok(result.VS == 0x66, "Got unexpected result.VS %#x.\n", result.VS); + ok(result.Predication == 0x33, "Got unexpected result.Predication %#x.\n", result.Predication); + hr = D3D10StateBlockMaskDifference(NULL, &mask_y, &result); + ok(hr == E_INVALIDARG, "Got unexpect hr %#x.\n", hr); + hr = D3D10StateBlockMaskDifference(&mask_x, NULL, &result); + ok(hr == E_INVALIDARG, "Got unexpect hr %#x.\n", hr); + hr = D3D10StateBlockMaskDifference(&mask_x, &mask_y, NULL); + ok(hr == E_INVALIDARG, "Got unexpect hr %#x.\n", hr); +} + START_TEST(device) { ID3D10Device *device; @@ -77,6 +103,7 @@ START_TEST(device) } test_device_interfaces(device); + test_stateblock_mask(); refcount = ID3D10Device_Release(device); ok(!refcount, "Device has %u references left\n", refcount); diff --git a/include/d3d10effect.h b/include/d3d10effect.h index 8c5cc63c5a2..d36c3dad4c2 100644 --- a/include/d3d10effect.h +++ b/include/d3d10effect.h @@ -804,6 +804,9 @@ HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT fl HRESULT WINAPI D3D10CreateStateBlock(ID3D10Device *device, D3D10_STATE_BLOCK_MASK *mask, ID3D10StateBlock **stateblock); +HRESULT WINAPI D3D10StateBlockMaskDifference(D3D10_STATE_BLOCK_MASK *mask_x, + D3D10_STATE_BLOCK_MASK *mask_y, D3D10_STATE_BLOCK_MASK *result); + #ifdef __cplusplus } #endif