Module: wine Branch: master Commit: 1881bad4ddfc5d73337b8f09528c3b8131d3bc74 URL: http://source.winehq.org/git/wine.git/?a=commit;h=1881bad4ddfc5d73337b8f0952...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Sun Feb 19 18:16:36 2017 +0100
wined3d: Send light enable updates through the command stream.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/wined3d/cs.c | 50 ++++++++++++++++++++++++++++++++++++++++++ dlls/wined3d/device.c | 17 ++------------ dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 53 insertions(+), 15 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index a3ea648..ca851da 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -55,6 +55,7 @@ enum wined3d_cs_op WINED3D_CS_OP_SET_COLOR_KEY, WINED3D_CS_OP_SET_MATERIAL, WINED3D_CS_OP_SET_LIGHT, + WINED3D_CS_OP_SET_LIGHT_ENABLE, WINED3D_CS_OP_RESET_STATE, WINED3D_CS_OP_CALLBACK, WINED3D_CS_OP_QUERY_ISSUE, @@ -285,6 +286,13 @@ struct wined3d_cs_set_light struct wined3d_light_info light; };
+struct wined3d_cs_set_light_enable +{ + enum wined3d_cs_op opcode; + unsigned int idx; + BOOL enable; +}; + struct wined3d_cs_reset_state { enum wined3d_cs_op opcode; @@ -1399,6 +1407,13 @@ static void wined3d_cs_exec_set_light(struct wined3d_cs *cs, const void *data) light_info->OriginalIndex = light_idx; }
+ if (light_info->glIndex != -1) + { + if (light_info->OriginalParms.type != op->light.OriginalParms.type) + device_invalidate_state(cs->device, STATE_LIGHT_TYPE); + device_invalidate_state(cs->device, STATE_ACTIVELIGHT(light_info->glIndex)); + } + light_info->OriginalParms = op->light.OriginalParms; light_info->position = op->light.position; light_info->direction = op->light.direction; @@ -1417,6 +1432,40 @@ void wined3d_cs_emit_set_light(struct wined3d_cs *cs, const struct wined3d_light cs->ops->submit(cs); }
+static void wined3d_cs_exec_set_light_enable(struct wined3d_cs *cs, const void *data) +{ + const struct wined3d_cs_set_light_enable *op = data; + struct wined3d_device *device = cs->device; + struct wined3d_light_info *light_info; + int prev_idx; + + if (!(light_info = wined3d_state_get_light(&cs->state, op->idx))) + { + ERR("Light doesn't exist.\n"); + return; + } + + prev_idx = light_info->glIndex; + wined3d_state_enable_light(&cs->state, &device->adapter->d3d_info, light_info, op->enable); + if (light_info->glIndex != prev_idx) + { + device_invalidate_state(device, STATE_LIGHT_TYPE); + device_invalidate_state(device, STATE_ACTIVELIGHT(op->enable ? light_info->glIndex : prev_idx)); + } +} + +void wined3d_cs_emit_set_light_enable(struct wined3d_cs *cs, unsigned int idx, BOOL enable) +{ + struct wined3d_cs_set_light_enable *op; + + op = cs->ops->require_space(cs, sizeof(*op)); + op->opcode = WINED3D_CS_OP_SET_LIGHT_ENABLE; + op->idx = idx; + op->enable = enable; + + cs->ops->submit(cs); +} + static void wined3d_cs_exec_reset_state(struct wined3d_cs *cs, const void *data) { struct wined3d_adapter *adapter = cs->device->adapter; @@ -1614,6 +1663,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_SET_COLOR_KEY */ wined3d_cs_exec_set_color_key, /* WINED3D_CS_OP_SET_MATERIAL */ wined3d_cs_exec_set_material, /* WINED3D_CS_OP_SET_LIGHT */ wined3d_cs_exec_set_light, + /* WINED3D_CS_OP_SET_LIGHT_ENABLE */ wined3d_cs_exec_set_light_enable, /* WINED3D_CS_OP_RESET_STATE */ wined3d_cs_exec_reset_state, /* WINED3D_CS_OP_CALLBACK */ wined3d_cs_exec_callback, /* WINED3D_CS_OP_QUERY_ISSUE */ wined3d_cs_exec_query_issue, diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 4c10f99..2005341 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1568,14 +1568,6 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, light->direction.x, light->direction.y, light->direction.z, light->range, light->falloff, light->theta, light->phi);
- /* Update the live definitions if the light is currently assigned a glIndex. */ - if (object->glIndex != -1 && !device->recording) - { - if (object->OriginalParms.type != light->type) - device_invalidate_state(device, STATE_LIGHT_TYPE); - device_invalidate_state(device, STATE_ACTIVELIGHT(object->glIndex)); - } - /* Save away the information. */ object->OriginalParms = *light;
@@ -1681,7 +1673,6 @@ HRESULT CDECL wined3d_device_get_light(const struct wined3d_device *device, HRESULT CDECL wined3d_device_set_light_enable(struct wined3d_device *device, UINT light_idx, BOOL enable) { struct wined3d_light_info *light_info; - int prev_idx;
TRACE("device %p, light_idx %u, enable %#x.\n", device, light_idx, enable);
@@ -1698,13 +1689,9 @@ HRESULT CDECL wined3d_device_set_light_enable(struct wined3d_device *device, UIN } }
- prev_idx = light_info->glIndex; wined3d_state_enable_light(device->update_state, &device->adapter->d3d_info, light_info, enable); - if (!device->recording && light_info->glIndex != prev_idx) - { - device_invalidate_state(device, STATE_LIGHT_TYPE); - device_invalidate_state(device, STATE_ACTIVELIGHT(enable ? light_info->glIndex : prev_idx)); - } + if (!device->recording) + wined3d_cs_emit_set_light_enable(device->cs, light_idx, enable);
return WINED3D_OK; } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 23f15df..3190d87 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3204,6 +3204,7 @@ void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs, void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buffer *buffer, enum wined3d_format_id format_id, unsigned int offset) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_light(struct wined3d_cs *cs, const struct wined3d_light_info *light) DECLSPEC_HIDDEN; +void wined3d_cs_emit_set_light_enable(struct wined3d_cs *cs, unsigned int idx, BOOL enable) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_material(struct wined3d_cs *cs, const struct wined3d_material *material) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_predication(struct wined3d_cs *cs, struct wined3d_query *predicate, BOOL value) DECLSPEC_HIDDEN;