[PATCH 3/4] ddraw: Device2 and Device3 do not have a lighting render state
Stefan Dösinger
stefan at codeweavers.com
Thu Jun 20 05:17:07 CDT 2013
Instead, lighting is enabled / disabled with D3DDP_DONOTLIGHT and the
presence or absence of vertex normals.
This fixes bug 29052.
---
dlls/ddraw/ddraw_private.h | 1 +
dlls/ddraw/device.c | 42 +++++++++++++++++++++++++++++++++++++++++-
dlls/ddraw/tests/ddraw2.c | 15 ++-------------
3 files changed, 44 insertions(+), 14 deletions(-)
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index 84f90c4..3896d8f 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -295,6 +295,7 @@ struct d3d_device
/* Light state */
DWORD material;
+ DWORD dummy_rs_lighting;
/* Rendering functions to wrap D3D(1-3) to D3D7 */
D3DPRIMITIVETYPE primitive_type;
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 0b20413..bfa9246 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -1,7 +1,7 @@
/*
* Copyright (c) 1998-2004 Lionel Ulmer
* Copyright (c) 2002-2005 Christian Costa
- * Copyright (c) 2006-2009, 2011-2012 Stefan Dösinger
+ * Copyright (c) 2006-2009, 2011-2013 Stefan Dösinger
* Copyright (c) 2008 Alexander Dorofeyev
*
* This library is free software; you can redistribute it and/or
@@ -2482,6 +2482,12 @@ static HRESULT WINAPI d3d_device3_GetRenderState(IDirect3DDevice3 *iface,
return D3D_OK;
}
+ case D3DRENDERSTATE_LIGHTING:
+ wined3d_mutex_lock();
+ *value = device->dummy_rs_lighting;
+ wined3d_mutex_unlock();
+ return D3D_OK;
+
default:
return IDirect3DDevice7_GetRenderState(&device->IDirect3DDevice7_iface, state, value);
}
@@ -2837,6 +2843,11 @@ static HRESULT WINAPI d3d_device3_SetRenderState(IDirect3DDevice3 *iface,
break;
}
+ case D3DRENDERSTATE_LIGHTING:
+ device->dummy_rs_lighting = value;
+ hr = D3D_OK;
+ break;
+
default:
hr = IDirect3DDevice7_SetRenderState(&device->IDirect3DDevice7_iface, state, value);
break;
@@ -3512,6 +3523,22 @@ static HRESULT WINAPI d3d_device7_DrawPrimitive_FPUPreserve(IDirect3DDevice7 *if
return hr;
}
+static void setup_lighting(const struct d3d_device *device, DWORD fvf, DWORD flags)
+{
+ BOOL enable;
+
+ /* Ignore the D3DFVF_XYZRHW case here, wined3d takes care of that */
+ if (flags & D3DDP_DONOTLIGHT)
+ enable = FALSE;
+ else if (!(fvf & D3DFVF_NORMAL))
+ enable = FALSE;
+ else
+ enable = TRUE;
+
+ wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_LIGHTING, enable);
+}
+
+
static HRESULT WINAPI d3d_device3_DrawPrimitive(IDirect3DDevice3 *iface,
D3DPRIMITIVETYPE primitive_type, DWORD fvf, void *vertices, DWORD vertex_count,
DWORD flags)
@@ -3521,6 +3548,8 @@ static HRESULT WINAPI d3d_device3_DrawPrimitive(IDirect3DDevice3 *iface,
TRACE("iface %p, primitive_type %#x, fvf %#x, vertices %p, vertex_count %u, flags %#x.\n",
iface, primitive_type, fvf, vertices, vertex_count, flags);
+ setup_lighting(device, fvf, flags);
+
return IDirect3DDevice7_DrawPrimitive(&device->IDirect3DDevice7_iface,
primitive_type, fvf, vertices, vertex_count, flags);
}
@@ -3703,6 +3732,8 @@ static HRESULT WINAPI d3d_device3_DrawIndexedPrimitive(IDirect3DDevice3 *iface,
"indices %p, index_count %u, flags %#x.\n",
iface, primitive_type, fvf, vertices, vertex_count, indices, index_count, flags);
+ setup_lighting(device, fvf, flags);
+
return IDirect3DDevice7_DrawIndexedPrimitive(&device->IDirect3DDevice7_iface,
primitive_type, fvf, vertices, vertex_count, indices, index_count, flags);
}
@@ -3972,6 +4003,8 @@ static HRESULT WINAPI d3d_device3_DrawPrimitiveStrided(IDirect3DDevice3 *iface,
TRACE("iface %p, primitive_type %#x, FVF %#x, strided_data %p, vertex_count %u, flags %#x.\n",
iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
+ setup_lighting(device, VertexType, Flags);
+
return IDirect3DDevice7_DrawPrimitiveStrided(&device->IDirect3DDevice7_iface,
PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
}
@@ -4097,6 +4130,8 @@ static HRESULT WINAPI d3d_device3_DrawIndexedPrimitiveStrided(IDirect3DDevice3 *
TRACE("iface %p, primitive_type %#x, FVF %#x, strided_data %p, vertex_count %u, indices %p, index_count %u, flags %#x.\n",
iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
+ setup_lighting(device, VertexType, Flags);
+
return IDirect3DDevice7_DrawIndexedPrimitiveStrided(&device->IDirect3DDevice7_iface,
PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
}
@@ -4189,6 +4224,8 @@ static HRESULT WINAPI d3d_device3_DrawPrimitiveVB(IDirect3DDevice3 *iface, D3DPR
TRACE("iface %p, primitive_type %#x, vb %p, start_vertex %u, vertex_count %u, flags %#x.\n",
iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Flags);
+ setup_lighting(device, vb->fvf, Flags);
+
return IDirect3DDevice7_DrawPrimitiveVB(&device->IDirect3DDevice7_iface,
PrimitiveType, &vb->IDirect3DVertexBuffer7_iface, StartVertex, NumVertices, Flags);
}
@@ -4320,6 +4357,8 @@ static HRESULT WINAPI d3d_device3_DrawIndexedPrimitiveVB(IDirect3DDevice3 *iface
TRACE("iface %p, primitive_type %#x, vb %p, indices %p, index_count %u, flags %#x.\n",
iface, PrimitiveType, D3DVertexBuf, Indices, IndexCount, Flags);
+ setup_lighting(device, vb->fvf, Flags);
+
return IDirect3DDevice7_DrawIndexedPrimitiveVB(&device->IDirect3DDevice7_iface, PrimitiveType,
&vb->IDirect3DVertexBuffer7_iface, 0, IndexCount, Indices, IndexCount, Flags);
}
@@ -6696,6 +6735,7 @@ static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw,
device->legacyTextureBlending = FALSE;
device->legacy_projection = ident;
device->legacy_clipspace = ident;
+ device->dummy_rs_lighting = 0xffffffff;
/* This is for convenience. */
device->wined3d_device = ddraw->wined3d_device;
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 80a2b27..178900f 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -902,13 +902,6 @@ static void test_depth_blit(void)
{0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00},
{0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00},
};
- static const BOOL todo[4][4] =
- {
- {FALSE, FALSE, TRUE, TRUE},
- {FALSE, FALSE, TRUE, TRUE},
- {TRUE, TRUE, TRUE, TRUE},
- {TRUE, TRUE, TRUE, TRUE},
- };
DDSURFACEDESC ddsd_new, ddsd_existing;
IDirect3DDevice2 *device;
@@ -1056,12 +1049,8 @@ static void test_depth_blit(void)
unsigned int x = 80 * ((2 * j) + 1);
unsigned int y = 60 * ((2 * i) + 1);
color = get_surface_color(rt, x, y);
- if (todo[i][j])
- todo_wine ok(compare_color(color, expected_colors[i][j], 1),
- "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected_colors[i][j], x, y, color);
- else
- ok(compare_color(color, expected_colors[i][j], 1),
- "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected_colors[i][j], x, y, color);
+ ok(compare_color(color, expected_colors[i][j], 1),
+ "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected_colors[i][j], x, y, color);
}
}
IDirectDrawSurface_Release(rt);
--
1.8.1.5
More information about the wine-patches
mailing list