Module: wine Branch: master Commit: 69b20aeab1828296b3c53ee345e8a56c1e47c599 URL: https://gitlab.winehq.org/wine/wine/-/commit/69b20aeab1828296b3c53ee345e8a56...
Author: Elizabeth Figura zfigura@codeweavers.com Date: Fri Apr 26 15:15:23 2024 -0500
wined3d: Precompute direction and position in wined3d_light_state_set_light().
So that wined3d_device_process_vertices() can just read the stateblock directly.
---
dlls/wined3d/stateblock.c | 114 ++++++++++++++++++++--------------------- dlls/wined3d/wined3d_private.h | 2 - 2 files changed, 57 insertions(+), 59 deletions(-)
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 6c44733c8bb..217ebda743f 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -655,7 +655,7 @@ static void set_light_changed(struct wined3d_stateblock *stateblock, struct wine stateblock->changed.lights = 1; }
-HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, DWORD light_idx, +static HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, unsigned int light_idx, const struct wined3d_light *params, struct wined3d_light_info **light_info) { struct wined3d_light_info *object; @@ -676,6 +676,62 @@ HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, DWORD l
object->OriginalParms = *params;
+ /* Initialize the object. */ + TRACE("Light %u setting to type %#x, diffuse %s, specular %s, ambient %s, " + "position {%.8e, %.8e, %.8e}, direction {%.8e, %.8e, %.8e}, " + "range %.8e, falloff %.8e, theta %.8e, phi %.8e.\n", + light_idx, params->type, debug_color(¶ms->diffuse), + debug_color(¶ms->specular), debug_color(¶ms->ambient), + params->position.x, params->position.y, params->position.z, + params->direction.x, params->direction.y, params->direction.z, + params->range, params->falloff, params->theta, params->phi); + + switch (params->type) + { + case WINED3D_LIGHT_POINT: + /* Position */ + object->position.x = params->position.x; + object->position.y = params->position.y; + object->position.z = params->position.z; + object->position.w = 1.0f; + /* FIXME: Range */ + break; + + case WINED3D_LIGHT_DIRECTIONAL: + /* Direction */ + object->direction.x = -params->direction.x; + object->direction.y = -params->direction.y; + object->direction.z = -params->direction.z; + object->direction.w = 0.0f; + break; + + case WINED3D_LIGHT_SPOT: + /* Position */ + object->position.x = params->position.x; + object->position.y = params->position.y; + object->position.z = params->position.z; + object->position.w = 1.0f; + + /* Direction */ + object->direction.x = params->direction.x; + object->direction.y = params->direction.y; + object->direction.z = params->direction.z; + object->direction.w = 0.0f; + + /* FIXME: Range */ + break; + + case WINED3D_LIGHT_PARALLELPOINT: + object->position.x = params->position.x; + object->position.y = params->position.y; + object->position.z = params->position.z; + object->position.w = 1.0f; + break; + + default: + FIXME("Unrecognized params type %#x.\n", params->type); + } + *light_info = object; return WINED3D_OK; } @@ -2329,62 +2385,6 @@ static void wined3d_device_context_set_light(struct wined3d_device_context *cont if (FAILED(wined3d_light_state_set_light(&context->state->light_state, light_idx, light, &object))) return;
- /* Initialize the object. */ - TRACE("Light %u setting to type %#x, diffuse %s, specular %s, ambient %s, " - "position {%.8e, %.8e, %.8e}, direction {%.8e, %.8e, %.8e}, " - "range %.8e, falloff %.8e, theta %.8e, phi %.8e.\n", - light_idx, light->type, debug_color(&light->diffuse), - debug_color(&light->specular), debug_color(&light->ambient), - light->position.x, light->position.y, light->position.z, - light->direction.x, light->direction.y, light->direction.z, - light->range, light->falloff, light->theta, light->phi); - - switch (light->type) - { - case WINED3D_LIGHT_POINT: - /* Position */ - object->position.x = light->position.x; - object->position.y = light->position.y; - object->position.z = light->position.z; - object->position.w = 1.0f; - /* FIXME: Range */ - break; - - case WINED3D_LIGHT_DIRECTIONAL: - /* Direction */ - object->direction.x = -light->direction.x; - object->direction.y = -light->direction.y; - object->direction.z = -light->direction.z; - object->direction.w = 0.0f; - break; - - case WINED3D_LIGHT_SPOT: - /* Position */ - object->position.x = light->position.x; - object->position.y = light->position.y; - object->position.z = light->position.z; - object->position.w = 1.0f; - - /* Direction */ - object->direction.x = light->direction.x; - object->direction.y = light->direction.y; - object->direction.z = light->direction.z; - object->direction.w = 0.0f; - - /* FIXME: Range */ - break; - - case WINED3D_LIGHT_PARALLELPOINT: - object->position.x = light->position.x; - object->position.y = light->position.y; - object->position.z = light->position.z; - object->position.w = 1.0f; - break; - - default: - FIXME("Unrecognized light type %#x.\n", light->type); - } - wined3d_device_context_emit_set_light(context, object); }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index f49a604422d..8c36a033f6e 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3503,8 +3503,6 @@ bool wined3d_light_state_enable_light(struct wined3d_light_state *state, const s struct wined3d_light_info *light_info, BOOL enable); struct wined3d_light_info *wined3d_light_state_get_light(const struct wined3d_light_state *state, unsigned int idx); -HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, DWORD light_idx, - const struct wined3d_light *params, struct wined3d_light_info **light_info);
enum wined3d_cs_queue_id {