[D3D9 1/3] Test missing light recording
Ivan Gyurdiev
ivg2 at cornell.edu
Tue Jun 6 22:35:38 CDT 2006
When a light does not exist, and the app attempts to capture it in the
stateblock, a disabled light with the default light parameters is
written instead.
-------------- next part --------------
---
dlls/d3d9/tests/stateblock.c | 92 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 91 insertions(+), 1 deletions(-)
9bdc51a8a5241562cb83184f64da06ec42c83e92
diff --git a/dlls/d3d9/tests/stateblock.c b/dlls/d3d9/tests/stateblock.c
index 06cc74f..8744c5d 100644
--- a/dlls/d3d9/tests/stateblock.c
+++ b/dlls/d3d9/tests/stateblock.c
@@ -16,6 +16,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#define COBJMACROS
#include <d3d9.h>
#include "wine/test.h"
@@ -53,7 +54,8 @@ static IDirect3DDevice9 *init_d3d9(void)
present_parameters.hDeviceWindow = create_window();
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
- hres = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
+ hres = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_NULLREF, NULL,
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
ok(hres == D3D_OK, "IDirect3D_CreateDevice returned: 0x%lx\n", hres);
return device_ptr;
@@ -89,6 +91,93 @@ static void test_begin_end_state_block(I
"Expected hret 0x%lx, state_block_ptr 0xdeadbeef.\n", hret, state_block_ptr, D3DERR_INVALIDCALL);
}
+static void test_missing_light_recording(IDirect3DDevice9 *device_ptr)
+{
+
+ D3DLIGHT9 garbage_light = { 1,
+ { 2.0, 2.0, 2.0, 2.0 }, { 3.0, 3.0, 3.0, 3.0 }, { 4.0, 4.0, 4.0, 4.0 },
+ { 5.0, 5.0, 5.0 }, { 6.0, 6.0, 6.0 },
+ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 };
+
+ D3DLIGHT9 expected_light = { D3DLIGHT_DIRECTIONAL,
+ { 1.0, 1.0, 1.0, 0.0 }, { 0.0, 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0, 0.0 },
+ { 0.0, 0.0, 0.0 }, { 0.0, 0.0, 1.0 },
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
+ D3DLIGHT9 result_light;
+ BOOL result_light_enable;
+
+ HRESULT hret = 0;
+ IDirect3DStateBlock9 *state_block_ptr = 0;
+
+ /* Before we make any changes, GetLightEnable should fail, and GetLight should fail */
+ hret = IDirect3DDevice9_GetLightEnable(device_ptr, 0, &result_light_enable);
+ ok(hret == D3DERR_INVALIDCALL, "GetLightEnable returned: hret 0x%lx. Expected hret 0x%lx. Aborting.\n",
+ hret, D3DERR_INVALIDCALL);
+ if (hret != D3DERR_INVALIDCALL) goto cleanup;
+
+ hret = IDirect3DDevice9_GetLight(device_ptr, 0, &result_light);
+ ok(hret == D3DERR_INVALIDCALL, "GetLight returned: hret 0x%lx. Expected hret 0x%lx. Aborting.\n",
+ hret, D3DERR_INVALIDCALL);
+ if (hret != D3DERR_INVALIDCALL) goto cleanup;
+
+ /* Set states to record with garbage data (light, light_enable) */
+ hret = IDirect3DDevice9_BeginStateBlock(device_ptr);
+ ok(hret == D3D_OK, "BeginStateBlock returned: hret 0x%lx. Expected hret 0x%lx. Aborting.\n", hret, D3D_OK);
+ if (hret != D3D_OK) goto cleanup;
+
+ hret = IDirect3DDevice9_SetLight(device_ptr, 0, &garbage_light);
+ ok(hret == D3D_OK, "SetLight returned: hret 0x%lx. Expected hret 0x%lx. Aborting.\n", hret, D3D_OK);
+ if (hret != D3D_OK) goto cleanup;
+
+ hret = IDirect3DDevice9_LightEnable(device_ptr, 0, TRUE);
+ ok(hret == D3D_OK, "SetLightEnable returned: hret 0x%lx, Expected hret 0x%lx. Aborting.\n", hret, D3D_OK);
+ if (hret != D3D_OK) goto cleanup;
+
+ state_block_ptr = (IDirect3DStateBlock9 *)0xdeadbeef;
+ hret = IDirect3DDevice9_EndStateBlock(device_ptr, &state_block_ptr);
+ ok(hret == D3D_OK, "EndStateBlock returned: hret 0x%lx. Expected hret 0x%lx. Aborting.\n", hret, D3D_OK);
+ if (hret != D3D_OK) goto cleanup;
+
+ /* Now capture light data */
+ hret = IDirect3DStateBlock9_Capture(state_block_ptr);
+ ok(hret == D3D_OK, "Capture returned: hret 0x%lx. Expected hret 0x%lx. Aborting.\n", hret, D3D_OK);
+ if (hret != D3D_OK) goto cleanup;
+
+ /* Now apply the resultant stateblock */
+ hret = IDirect3DStateBlock9_Apply(state_block_ptr);
+ ok(hret == D3D_OK, "Apply returned: hret 0x%lx. Expected hret 0x%lx. Aborting.\n", hret, D3D_OK);
+ if (hret != D3D_OK) goto cleanup;
+
+ /* Now try to fetch the light set by the stateblock.
+ * Light enable should have been set to 0, and a default light should have been
+ * created as a side effect of that */
+ hret = IDirect3DDevice9_GetLightEnable(device_ptr, 0, &result_light_enable);
+ ok(hret == D3D_OK, "GetLightEnable returned: hret 0x%lx. Expected hret 0x%lx. Aborting.\n", hret, D3D_OK);
+ if (hret != D3D_OK) goto cleanup;
+ ok(result_light_enable == 0, "Light enabled status was %u, instead of 0", result_light_enable);
+
+ hret = IDirect3DDevice9_GetLight(device_ptr, 0, &result_light);
+ ok(hret == D3D_OK, "GetLight returned: hret 0x%lx. Expected hret 0x%lx. Aborting.\n", hret, D3D_OK);
+ if (hret != D3D_OK) goto cleanup;
+
+ ok (!memcmp(&expected_light, &result_light, sizeof(D3DLIGHT9)),
+ "Light returned = { %u, { %f, %f, %f, %f }, { %f, %f, %f, %f}, { %f, %f, %f, %f }, "
+ "{ %f, %f, %f }, { %f, %f, %f }, %f, %f, %f, %f, %f, %f, %f }\n",
+
+ result_light.Type,
+ result_light.Diffuse.r, result_light.Diffuse.g, result_light.Diffuse.b, result_light.Diffuse.a,
+ result_light.Specular.r, result_light.Specular.g, result_light.Specular.b, result_light.Specular.a,
+ result_light.Ambient.r, result_light.Ambient.g, result_light.Ambient.b, result_light.Ambient.a,
+ result_light.Position.x, result_light.Position.y, result_light.Position.z,
+ result_light.Direction.x, result_light.Direction.y, result_light.Direction.z,
+ result_light.Range, result_light.Falloff,
+ result_light.Attenuation0, result_light.Attenuation1, result_light.Attenuation2,
+ result_light.Theta, result_light.Phi);
+
+ cleanup:
+ if (state_block_ptr) IUnknown_Release( state_block_ptr );
+}
+
START_TEST(stateblock)
{
IDirect3DDevice9 *device_ptr;
@@ -104,4 +193,5 @@ START_TEST(stateblock)
if (!device_ptr) return;
test_begin_end_state_block(device_ptr);
+ test_missing_light_recording(device_ptr);
}
--
1.3.3
More information about the wine-patches
mailing list