[WINED3D 2/3] Fix missing light recording
Ivan Gyurdiev
ivg2 at cornell.edu
Tue Jun 6 22:37:05 CDT 2006
Write a light with the default parameters in disabled state if capturing
a missing light.
This makes Need For Speed: Most Wanted proceed further before crashing
again in shaders.
-------------- next part --------------
>From nobody Mon Sep 17 00:00:00 2001
---
dlls/wined3d/device.c | 48 +++++++++++++++-------------------------
dlls/wined3d/stateblock.c | 31 +++++++++++++-------------
dlls/wined3d/wined3d_private.h | 3 +++
3 files changed, 36 insertions(+), 46 deletions(-)
32615f8a2150aa7dec577e9e3091a2d4c29d6df1
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index ed3f6bc..1d7bf90 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -32,6 +32,22 @@ #include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info
+/* Define the default light parameters as specified by MSDN */
+WINED3DLIGHT WINED3D_DEFAULT_LIGHT = {
+
+ D3DLIGHT_DIRECTIONAL, /* Type */
+ { 1.0, 1.0, 1.0, 0.0 }, /* Diffuse r,g,b,a */
+ { 0.0, 0.0, 0.0, 0.0 }, /* Specular r,g,b,a */
+ { 0.0, 0.0, 0.0, 0.0 }, /* Ambient r,g,b,a, */
+ { 0.0, 0.0, 0.0 }, /* Position x,y,z */
+ { 0.0, 0.0, 1.0 }, /* Direction x,y,z */
+ 0.0, /* Range */
+ 0.0, /* Falloff */
+ 0.0, 0.0, 0.0, /* Attenuation 0,1,2 */
+ 0.0, /* Theta */
+ 0.0 /* Phi */
+};
+
/* x11drv GDI escapes */
#define X11DRV_ESCAPE 6789
enum x11drv_escape_codes
@@ -2515,37 +2531,9 @@ HRESULT WINAPI IWineD3DDeviceImpl_SetLig
/* Special case - enabling an undefined light creates one with a strict set of parms! */
if (lightInfo == NULL) {
- D3DLIGHT9 lightParms;
- /* Warning - untested code :-) Prob safe to change fixme to a trace but
- wait until someone confirms it seems to work! */
+
TRACE("Light enabled requested but light not defined, so defining one!\n");
- lightParms.Type = D3DLIGHT_DIRECTIONAL;
- lightParms.Diffuse.r = 1.0;
- lightParms.Diffuse.g = 1.0;
- lightParms.Diffuse.b = 1.0;
- lightParms.Diffuse.a = 0.0;
- lightParms.Specular.r = 0.0;
- lightParms.Specular.g = 0.0;
- lightParms.Specular.b = 0.0;
- lightParms.Specular.a = 0.0;
- lightParms.Ambient.r = 0.0;
- lightParms.Ambient.g = 0.0;
- lightParms.Ambient.b = 0.0;
- lightParms.Ambient.a = 0.0;
- lightParms.Position.x = 0.0;
- lightParms.Position.y = 0.0;
- lightParms.Position.z = 0.0;
- lightParms.Direction.x = 0.0;
- lightParms.Direction.y = 0.0;
- lightParms.Direction.z = 1.0;
- lightParms.Range = 0.0;
- lightParms.Falloff = 0.0;
- lightParms.Attenuation0 = 0.0;
- lightParms.Attenuation1 = 0.0;
- lightParms.Attenuation2 = 0.0;
- lightParms.Theta = 0.0;
- lightParms.Phi = 0.0;
- IWineD3DDeviceImpl_SetLight(iface, Index, &lightParms);
+ IWineD3DDeviceImpl_SetLight(iface, Index, &WINED3D_DEFAULT_LIGHT);
/* Search for it again! Should be fairly quick as near head of list */
lightInfo = This->stateBlock->lights;
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index c694f44..d08c96d 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -213,24 +213,23 @@ HRESULT WINAPI IWineD3DStateBlockImpl_Ca
realLight = targetStateBlock->lights;
while (realLight != NULL && realLight->OriginalIndex != src->OriginalIndex) realLight = realLight->next;
- if (realLight == NULL) {
- FIXME("A captured light no longer exists...?\n");
- } else {
-
- /* If 'changed' then its a SetLight command. Rather than comparing to see
- if the OriginalParms have changed and then copy them (twice through
- memory) just do the copy */
- if (src->changed) {
- TRACE("Updating lights for light %ld\n", src->OriginalIndex);
- memcpy(&src->OriginalParms, &realLight->OriginalParms, sizeof(src->OriginalParms));
- }
+ /* If 'changed' then its a SetLight command. Rather than comparing to see
+ if the OriginalParms have changed and then copy them (twice through
+ memory) just do the copy */
+ if (src->changed) {
- /* If 'enabledchanged' then its a LightEnable command */
- if (src->enabledChanged) {
- TRACE("Updating lightEnabled for light %ld\n", src->OriginalIndex);
- src->lightEnabled = realLight->lightEnabled;
- }
+ /* If the light exists, copy its parameters, otherwise copy the default parameters */
+ WINED3DLIGHT* params = realLight? &realLight->OriginalParms: &WINED3D_DEFAULT_LIGHT;
+ TRACE("Updating lights for light %ld\n", src->OriginalIndex);
+ memcpy(&src->OriginalParms, params, sizeof(*params));
+ }
+
+ /* If 'enabledchanged' then its a LightEnable command */
+ if (src->enabledChanged) {
+ /* If the light exists, check if it's enabled, otherwise default is disabled state */
+ TRACE("Updating lightEnabled for light %ld\n", src->OriginalIndex);
+ src->lightEnabled = realLight? realLight->lightEnabled: FALSE;
}
src = src->next;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index d9c7406..d09ced8 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -393,6 +393,9 @@ struct PLIGHTINFOEL {
PLIGHTINFOEL *prev;
};
+/* The default light parameters */
+extern WINED3DLIGHT WINED3D_DEFAULT_LIGHT;
+
/*****************************************************************************
* IWineD3D implementation structure
*/
--
1.3.3
More information about the wine-patches
mailing list