[PATCH 3/5] d3d10: Implement D3D10StateBlockMaskDifference().
Henri Verbeet
hverbeet at codeweavers.com
Mon Nov 14 14:11:41 CST 2011
In practice the compiler will always throw away the second loop because the
structure size is going to be at least DWORD aligned.
---
dlls/d3d10/d3d10.spec | 2 +-
dlls/d3d10/stateblock.c | 23 +++++++++++++++++++++++
dlls/d3d10/tests/device.c | 27 +++++++++++++++++++++++++++
include/d3d10effect.h | 3 +++
4 files changed, 54 insertions(+), 1 deletions(-)
diff --git a/dlls/d3d10/d3d10.spec b/dlls/d3d10/d3d10.spec
index 16d2d5f..baa0c10 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 e66524c..55c26cb 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 8399cdb..1fc3a3b 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 8c5cc63..d36c3da 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
--
1.7.3.4
More information about the wine-patches
mailing list