wined3d: Lighting is calculated for vertices without normals.
It still should be disabled for transformed vertices though.
This commit is contained in:
parent
03bc11fa16
commit
266fc77cf0
@ -123,6 +123,142 @@ static IDirect3DDevice8 *init_d3d8(void)
|
|||||||
return device_ptr;
|
return device_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct vertex
|
||||||
|
{
|
||||||
|
float x, y, z;
|
||||||
|
DWORD diffuse;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct nvertex
|
||||||
|
{
|
||||||
|
float x, y, z;
|
||||||
|
float nx, ny, nz;
|
||||||
|
DWORD diffuse;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void lighting_test(IDirect3DDevice8 *device)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
DWORD fvf = D3DFVF_XYZ | D3DFVF_DIFFUSE;
|
||||||
|
DWORD nfvf = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_NORMAL;
|
||||||
|
DWORD color;
|
||||||
|
|
||||||
|
float mat[16] = { 1.0, 0.0, 0.0, 0.0,
|
||||||
|
0.0, 1.0, 0.0, 0.0,
|
||||||
|
0.0, 0.0, 1.0, 0.0,
|
||||||
|
0.0, 0.0, 0.0, 1.0 };
|
||||||
|
|
||||||
|
struct vertex unlitquad[] =
|
||||||
|
{
|
||||||
|
{-1.0, -1.0, 0.1, 0xffff0000},
|
||||||
|
{-1.0, 0.0, 0.1, 0xffff0000},
|
||||||
|
{ 0.0, 0.0, 0.1, 0xffff0000},
|
||||||
|
{ 0.0, -1.0, 0.1, 0xffff0000},
|
||||||
|
};
|
||||||
|
struct vertex litquad[] =
|
||||||
|
{
|
||||||
|
{-1.0, 0.0, 0.1, 0xff00ff00},
|
||||||
|
{-1.0, 1.0, 0.1, 0xff00ff00},
|
||||||
|
{ 0.0, 1.0, 0.1, 0xff00ff00},
|
||||||
|
{ 0.0, 0.0, 0.1, 0xff00ff00},
|
||||||
|
};
|
||||||
|
struct nvertex unlitnquad[] =
|
||||||
|
{
|
||||||
|
{ 0.0, -1.0, 0.1, 1.0, 1.0, 1.0, 0xff0000ff},
|
||||||
|
{ 0.0, 0.0, 0.1, 1.0, 1.0, 1.0, 0xff0000ff},
|
||||||
|
{ 1.0, 0.0, 0.1, 1.0, 1.0, 1.0, 0xff0000ff},
|
||||||
|
{ 1.0, -1.0, 0.1, 1.0, 1.0, 1.0, 0xff0000ff},
|
||||||
|
};
|
||||||
|
struct nvertex litnquad[] =
|
||||||
|
{
|
||||||
|
{ 0.0, 0.0, 0.1, 1.0, 1.0, 1.0, 0xffffff00},
|
||||||
|
{ 0.0, 1.0, 0.1, 1.0, 1.0, 1.0, 0xffffff00},
|
||||||
|
{ 1.0, 1.0, 0.1, 1.0, 1.0, 1.0, 0xffffff00},
|
||||||
|
{ 1.0, 0.0, 0.1, 1.0, 1.0, 1.0, 0xffffff00},
|
||||||
|
};
|
||||||
|
WORD Indices[] = {0, 1, 2, 2, 3, 0};
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed with %s\n", DXGetErrorString8(hr));
|
||||||
|
|
||||||
|
/* Setup some states that may cause issues */
|
||||||
|
hr = IDirect3DDevice8_SetTransform(device, D3DTS_WORLDMATRIX(0), (D3DMATRIX *) mat);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetTransform returned %s\n", DXGetErrorString8(hr));
|
||||||
|
hr = IDirect3DDevice8_SetTransform(device, D3DTS_VIEW, (D3DMATRIX *)mat);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetTransform returned %s\n", DXGetErrorString8(hr));
|
||||||
|
hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, (D3DMATRIX *) mat);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetTransform returned %s\n", DXGetErrorString8(hr));
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_CLIPPING, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGENABLE, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_STENCILENABLE, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHATESTENABLE, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHABLENDENABLE, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed with %s\n", DXGetErrorString8(hr));
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLED_RED | D3DCOLORWRITEENABLED_GREEN | D3DCOLORWRITEENABLED_BLUE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed with %s\n", DXGetErrorString8(hr));
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_SetVertexShader(device, fvf);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetVertexShader returned %s\n", DXGetErrorString8(hr));
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_BeginScene(device);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene failed with %s\n", DXGetErrorString8(hr));
|
||||||
|
if(hr == D3D_OK)
|
||||||
|
{
|
||||||
|
/* No lights are defined... That means, lit vertices should be entirely black */
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
|
||||||
|
hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
|
||||||
|
2 /*PrimCount */, Indices, D3DFMT_INDEX16, unlitquad, sizeof(unlitquad[0]));
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_DrawIndexedPrimitiveUP failed with %s\n", DXGetErrorString8(hr));
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, TRUE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
|
||||||
|
hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
|
||||||
|
2 /*PrimCount */, Indices, D3DFMT_INDEX16, litquad, sizeof(litquad[0]));
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_DrawIndexedPrimitiveUP failed with %s\n", DXGetErrorString8(hr));
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_SetVertexShader(device, nfvf);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetVertexShader failed with %s\n", DXGetErrorString8(hr));
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
|
||||||
|
hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
|
||||||
|
2 /*PrimCount */, Indices, D3DFMT_INDEX16, unlitnquad, sizeof(unlitnquad[0]));
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_DrawIndexedPrimitiveUP failed with %s\n", DXGetErrorString8(hr));
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, TRUE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
|
||||||
|
hr = IDirect3DDevice8_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
|
||||||
|
2 /*PrimCount */, Indices, D3DFMT_INDEX16, litnquad, sizeof(litnquad[0]));
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_DrawIndexedPrimitiveUP failed with %s\n", DXGetErrorString8(hr));
|
||||||
|
|
||||||
|
IDirect3DDevice8_EndScene(device);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_EndScene failed with %s\n", DXGetErrorString8(hr));
|
||||||
|
}
|
||||||
|
|
||||||
|
IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
color = getPixelColor(device, 160, 360); /* lower left quad - unlit without normals */
|
||||||
|
ok(color == 0x00ff0000, "Unlit quad without normals has color %08x\n", color);
|
||||||
|
color = getPixelColor(device, 160, 120); /* upper left quad - lit without normals */
|
||||||
|
ok(color == 0x00000000, "Lit quad without normals has color %08x\n", color);
|
||||||
|
color = getPixelColor(device, 480, 360); /* lower left quad - unlit width normals */
|
||||||
|
ok(color == 0x000000ff, "Unlit quad width normals has color %08x\n", color);
|
||||||
|
color = getPixelColor(device, 480, 120); /* upper left quad - lit width normals */
|
||||||
|
ok(color == 0x00000000, "Lit quad width normals has color %08x\n", color);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(visual)
|
START_TEST(visual)
|
||||||
{
|
{
|
||||||
IDirect3DDevice8 *device_ptr;
|
IDirect3DDevice8 *device_ptr;
|
||||||
@ -170,6 +306,9 @@ START_TEST(visual)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Now run the real test */
|
||||||
|
lighting_test(device_ptr);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if(device_ptr) IDirect3DDevice8_Release(device_ptr);
|
if(device_ptr) IDirect3DDevice8_Release(device_ptr);
|
||||||
}
|
}
|
||||||
|
@ -123,6 +123,149 @@ static IDirect3DDevice9 *init_d3d9(void)
|
|||||||
return device_ptr;
|
return device_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct vertex
|
||||||
|
{
|
||||||
|
float x, y, z;
|
||||||
|
DWORD diffuse;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct nvertex
|
||||||
|
{
|
||||||
|
float x, y, z;
|
||||||
|
float nx, ny, nz;
|
||||||
|
DWORD diffuse;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void lighting_test(IDirect3DDevice9 *device)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
DWORD fvf = D3DFVF_XYZ | D3DFVF_DIFFUSE;
|
||||||
|
DWORD nfvf = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_NORMAL;
|
||||||
|
DWORD color;
|
||||||
|
|
||||||
|
float mat[16] = { 1.0, 0.0, 0.0, 0.0,
|
||||||
|
0.0, 1.0, 0.0, 0.0,
|
||||||
|
0.0, 0.0, 1.0, 0.0,
|
||||||
|
0.0, 0.0, 0.0, 1.0 };
|
||||||
|
|
||||||
|
struct vertex unlitquad[] =
|
||||||
|
{
|
||||||
|
{-1.0, -1.0, 0.1, 0xffff0000},
|
||||||
|
{-1.0, 0.0, 0.1, 0xffff0000},
|
||||||
|
{ 0.0, 0.0, 0.1, 0xffff0000},
|
||||||
|
{ 0.0, -1.0, 0.1, 0xffff0000},
|
||||||
|
};
|
||||||
|
struct vertex litquad[] =
|
||||||
|
{
|
||||||
|
{-1.0, 0.0, 0.1, 0xff00ff00},
|
||||||
|
{-1.0, 1.0, 0.1, 0xff00ff00},
|
||||||
|
{ 0.0, 1.0, 0.1, 0xff00ff00},
|
||||||
|
{ 0.0, 0.0, 0.1, 0xff00ff00},
|
||||||
|
};
|
||||||
|
struct nvertex unlitnquad[] =
|
||||||
|
{
|
||||||
|
{ 0.0, -1.0, 0.1, 1.0, 1.0, 1.0, 0xff0000ff},
|
||||||
|
{ 0.0, 0.0, 0.1, 1.0, 1.0, 1.0, 0xff0000ff},
|
||||||
|
{ 1.0, 0.0, 0.1, 1.0, 1.0, 1.0, 0xff0000ff},
|
||||||
|
{ 1.0, -1.0, 0.1, 1.0, 1.0, 1.0, 0xff0000ff},
|
||||||
|
};
|
||||||
|
struct nvertex litnquad[] =
|
||||||
|
{
|
||||||
|
{ 0.0, 0.0, 0.1, 1.0, 1.0, 1.0, 0xffffff00},
|
||||||
|
{ 0.0, 1.0, 0.1, 1.0, 1.0, 1.0, 0xffffff00},
|
||||||
|
{ 1.0, 1.0, 0.1, 1.0, 1.0, 1.0, 0xffffff00},
|
||||||
|
{ 1.0, 0.0, 0.1, 1.0, 1.0, 1.0, 0xffffff00},
|
||||||
|
};
|
||||||
|
WORD Indices[] = {0, 1, 2, 2, 3, 0};
|
||||||
|
|
||||||
|
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with %s\n", DXGetErrorString9(hr));
|
||||||
|
|
||||||
|
/* Setup some states that may cause issues */
|
||||||
|
hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLDMATRIX(0), (D3DMATRIX *) mat);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform returned %s\n", DXGetErrorString9(hr));
|
||||||
|
hr = IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, (D3DMATRIX *)mat);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform returned %s\n", DXGetErrorString9(hr));
|
||||||
|
hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, (D3DMATRIX *) mat);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetTransform returned %s\n", DXGetErrorString9(hr));
|
||||||
|
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr));
|
||||||
|
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr));
|
||||||
|
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr));
|
||||||
|
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILENABLE, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr));
|
||||||
|
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHATESTENABLE, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr));
|
||||||
|
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHABLENDENABLE, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr));
|
||||||
|
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SCISSORTESTENABLE, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr));
|
||||||
|
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with %s\n", DXGetErrorString9(hr));
|
||||||
|
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLED_RED | D3DCOLORWRITEENABLED_GREEN | D3DCOLORWRITEENABLED_BLUE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with %s\n", DXGetErrorString9(hr));
|
||||||
|
|
||||||
|
hr = IDirect3DDevice9_SetFVF(device, fvf);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF returned %s\n", DXGetErrorString9(hr));
|
||||||
|
|
||||||
|
hr = IDirect3DDevice9_BeginScene(device);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed with %s\n", DXGetErrorString9(hr));
|
||||||
|
if(hr == D3D_OK)
|
||||||
|
{
|
||||||
|
/* No lights are defined... That means, lit vertices should be entirely black */
|
||||||
|
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr));
|
||||||
|
hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
|
||||||
|
2 /*PrimCount */, Indices, D3DFMT_INDEX16, unlitquad, sizeof(unlitquad[0]));
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_DrawIndexedPrimitiveUP failed with %s\n", DXGetErrorString9(hr));
|
||||||
|
|
||||||
|
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, TRUE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr));
|
||||||
|
hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
|
||||||
|
2 /*PrimCount */, Indices, D3DFMT_INDEX16, litquad, sizeof(litquad[0]));
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_DrawIndexedPrimitiveUP failed with %s\n", DXGetErrorString9(hr));
|
||||||
|
|
||||||
|
hr = IDirect3DDevice9_SetFVF(device, nfvf);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with %s\n", DXGetErrorString9(hr));
|
||||||
|
|
||||||
|
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr));
|
||||||
|
hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
|
||||||
|
2 /*PrimCount */, Indices, D3DFMT_INDEX16, unlitnquad, sizeof(unlitnquad[0]));
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_DrawIndexedPrimitiveUP failed with %s\n", DXGetErrorString9(hr));
|
||||||
|
|
||||||
|
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, TRUE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr));
|
||||||
|
hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLELIST, 0 /* MinIndex */, 4 /* NumVerts */,
|
||||||
|
2 /*PrimCount */, Indices, D3DFMT_INDEX16, litnquad, sizeof(litnquad[0]));
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_DrawIndexedPrimitiveUP failed with %s\n", DXGetErrorString9(hr));
|
||||||
|
|
||||||
|
IDirect3DDevice9_EndScene(device);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_EndScene failed with %s\n", DXGetErrorString9(hr));
|
||||||
|
}
|
||||||
|
|
||||||
|
IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
color = getPixelColor(device, 160, 360); /* lower left quad - unlit without normals */
|
||||||
|
ok(color == 0x00ff0000, "Unlit quad without normals has color %08x\n", color);
|
||||||
|
color = getPixelColor(device, 160, 120); /* upper left quad - lit without normals */
|
||||||
|
ok(color == 0x00000000, "Lit quad without normals has color %08x\n", color);
|
||||||
|
color = getPixelColor(device, 480, 360); /* lower left quad - unlit width normals */
|
||||||
|
ok(color == 0x000000ff, "Unlit quad width normals has color %08x\n", color);
|
||||||
|
color = getPixelColor(device, 480, 120); /* upper left quad - lit width normals */
|
||||||
|
ok(color == 0x00000000, "Lit quad width normals has color %08x\n", color);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr));
|
||||||
|
|
||||||
|
/* Hack for a bug in d3d9: SetFVF creates a converted vertex declaration, with a circular refcount.
|
||||||
|
* This prevents the screen resulution from beeing restored correctly on device release. Unset the vdecl
|
||||||
|
*/
|
||||||
|
IDirect3DDevice9_SetVertexDeclaration(device, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(visual)
|
START_TEST(visual)
|
||||||
{
|
{
|
||||||
IDirect3DDevice9 *device_ptr;
|
IDirect3DDevice9 *device_ptr;
|
||||||
@ -170,6 +313,9 @@ START_TEST(visual)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Now execute the real tests */
|
||||||
|
lighting_test(device_ptr);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if(device_ptr) IDirect3DDevice9_Release(device_ptr);
|
if(device_ptr) IDirect3DDevice9_Release(device_ptr);
|
||||||
}
|
}
|
||||||
|
@ -175,6 +175,132 @@ out:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct vertex
|
||||||
|
{
|
||||||
|
float x, y, z;
|
||||||
|
DWORD diffuse;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct nvertex
|
||||||
|
{
|
||||||
|
float x, y, z;
|
||||||
|
float nx, ny, nz;
|
||||||
|
DWORD diffuse;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void lighting_test(IDirect3DDevice7 *device)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
DWORD fvf = D3DFVF_XYZ | D3DFVF_DIFFUSE;
|
||||||
|
DWORD nfvf = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_NORMAL;
|
||||||
|
DWORD color;
|
||||||
|
|
||||||
|
float mat[16] = { 1.0, 0.0, 0.0, 0.0,
|
||||||
|
0.0, 1.0, 0.0, 0.0,
|
||||||
|
0.0, 0.0, 1.0, 0.0,
|
||||||
|
0.0, 0.0, 0.0, 1.0 };
|
||||||
|
|
||||||
|
struct vertex unlitquad[] =
|
||||||
|
{
|
||||||
|
{-1.0, -1.0, 0.1, 0xffff0000},
|
||||||
|
{-1.0, 0.0, 0.1, 0xffff0000},
|
||||||
|
{ 0.0, 0.0, 0.1, 0xffff0000},
|
||||||
|
{ 0.0, -1.0, 0.1, 0xffff0000},
|
||||||
|
};
|
||||||
|
struct vertex litquad[] =
|
||||||
|
{
|
||||||
|
{-1.0, 0.0, 0.1, 0xff00ff00},
|
||||||
|
{-1.0, 1.0, 0.1, 0xff00ff00},
|
||||||
|
{ 0.0, 1.0, 0.1, 0xff00ff00},
|
||||||
|
{ 0.0, 0.0, 0.1, 0xff00ff00},
|
||||||
|
};
|
||||||
|
struct nvertex unlitnquad[] =
|
||||||
|
{
|
||||||
|
{ 0.0, -1.0, 0.1, 1.0, 1.0, 1.0, 0xff0000ff},
|
||||||
|
{ 0.0, 0.0, 0.1, 1.0, 1.0, 1.0, 0xff0000ff},
|
||||||
|
{ 1.0, 0.0, 0.1, 1.0, 1.0, 1.0, 0xff0000ff},
|
||||||
|
{ 1.0, -1.0, 0.1, 1.0, 1.0, 1.0, 0xff0000ff},
|
||||||
|
};
|
||||||
|
struct nvertex litnquad[] =
|
||||||
|
{
|
||||||
|
{ 0.0, 0.0, 0.1, 1.0, 1.0, 1.0, 0xffffff00},
|
||||||
|
{ 0.0, 1.0, 0.1, 1.0, 1.0, 1.0, 0xffffff00},
|
||||||
|
{ 1.0, 1.0, 0.1, 1.0, 1.0, 1.0, 0xffffff00},
|
||||||
|
{ 1.0, 0.0, 0.1, 1.0, 1.0, 1.0, 0xffffff00},
|
||||||
|
};
|
||||||
|
WORD Indices[] = {0, 1, 2, 2, 3, 0};
|
||||||
|
|
||||||
|
hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_Clear failed with %08x\n", hr);
|
||||||
|
|
||||||
|
/* Setup some states that may cause issues */
|
||||||
|
hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_WORLD, (D3DMATRIX *) mat);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_SetTransform returned %08x\n", hr);
|
||||||
|
hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_VIEW, (D3DMATRIX *)mat);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_SetTransform returned %08x\n", hr);
|
||||||
|
hr = IDirect3DDevice7_SetTransform(device, D3DTRANSFORMSTATE_PROJECTION, (D3DMATRIX *) mat);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_SetTransform returned %08x\n", hr);
|
||||||
|
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CLIPPING, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
|
||||||
|
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
|
||||||
|
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_FOGENABLE, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
|
||||||
|
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_STENCILENABLE, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
|
||||||
|
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHATESTENABLE, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
|
||||||
|
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
|
||||||
|
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed with %08x\n", hr);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice7_BeginScene(device);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_BeginScene failed with %08x\n", hr);
|
||||||
|
if(hr == D3D_OK)
|
||||||
|
{
|
||||||
|
/* No lights are defined... That means, lit vertices should be entirely black */
|
||||||
|
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
|
||||||
|
hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, fvf, unlitquad, 4 /* NumVerts */,
|
||||||
|
Indices, 6 /* Indexcount */, 0 /* flags */);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_DrawIndexedPrimitiveUP failed with %08x\n", hr);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, TRUE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
|
||||||
|
hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, fvf, litquad, 4 /* NumVerts */,
|
||||||
|
Indices, 6 /* Indexcount */, 0 /* flags */);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_DrawIndexedPrimitiveUP failed with %08x\n", hr);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
|
||||||
|
hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, unlitnquad, 4 /* NumVerts */,
|
||||||
|
Indices, 6 /* Indexcount */, 0 /* flags */);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_DrawIndexedPrimitiveUP failed with %08x\n", hr);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, TRUE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
|
||||||
|
hr = IDirect3DDevice7_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, litnquad, 4 /* NumVerts */,
|
||||||
|
Indices, 6 /* Indexcount */, 0 /* flags */);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_DrawIndexedPrimitiveUP failed with %08x\n", hr);
|
||||||
|
|
||||||
|
IDirect3DDevice7_EndScene(device);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed with %08x\n", hr);
|
||||||
|
}
|
||||||
|
|
||||||
|
color = getPixelColor(device, 160, 360); /* lower left quad - unlit without normals */
|
||||||
|
ok(color == 0x00ff0000, "Unlit quad without normals has color %08x\n", color);
|
||||||
|
color = getPixelColor(device, 160, 120); /* upper left quad - lit without normals */
|
||||||
|
ok(color == 0x00000000, "Lit quad without normals has color %08x\n", color);
|
||||||
|
color = getPixelColor(device, 480, 360); /* lower left quad - unlit width normals */
|
||||||
|
ok(color == 0x000000ff, "Unlit quad width normals has color %08x\n", color);
|
||||||
|
color = getPixelColor(device, 480, 120); /* upper left quad - lit width normals */
|
||||||
|
ok(color == 0x00000000, "Lit quad width normals has color %08x\n", color);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE);
|
||||||
|
ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState returned %08x\n", hr);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(visual)
|
START_TEST(visual)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
@ -214,6 +340,9 @@ START_TEST(visual)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Now run the tests */
|
||||||
|
lighting_test(Direct3DDevice);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
releaseObjects();
|
releaseObjects();
|
||||||
}
|
}
|
||||||
|
@ -79,9 +79,9 @@ static void state_fillmode(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void state_lighting(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
|
static void state_lighting(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
|
||||||
BOOL normals;
|
BOOL transformed;
|
||||||
|
|
||||||
/* Lighting is only enabled if Vertex normals are passed by the application,
|
/* Lighting is not enabled if transformed vertices are drawn
|
||||||
* but lighting does not affect the stream sources, so it is not grouped for performance reasons.
|
* but lighting does not affect the stream sources, so it is not grouped for performance reasons.
|
||||||
* This state reads the decoded vertex decl, so if it is dirty don't do anything. The
|
* This state reads the decoded vertex decl, so if it is dirty don't do anything. The
|
||||||
* vertex declaration appplying function calls this function for updating
|
* vertex declaration appplying function calls this function for updating
|
||||||
@ -91,10 +91,11 @@ static void state_lighting(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
normals = stateblock->wineD3DDevice->strided_streams.u.s.normal.lpData != NULL ||
|
transformed = ((stateblock->wineD3DDevice->strided_streams.u.s.position.lpData != NULL ||
|
||||||
stateblock->wineD3DDevice->strided_streams.u.s.normal.VBO != 0;
|
stateblock->wineD3DDevice->strided_streams.u.s.position.VBO != 0) &&
|
||||||
|
stateblock->wineD3DDevice->strided_streams.u.s.position_transformed) ? TRUE : FALSE;
|
||||||
|
|
||||||
if (stateblock->renderState[WINED3DRS_LIGHTING] && normals) {
|
if (stateblock->renderState[WINED3DRS_LIGHTING] && !transformed) {
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
checkGLcall("glEnable GL_LIGHTING");
|
checkGLcall("glEnable GL_LIGHTING");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user