Commit d6557e81 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Send texture dirty region updates through the command stream.

parent 6302d5ed
......@@ -65,6 +65,7 @@ enum wined3d_cs_op
WINED3D_CS_OP_UNMAP,
WINED3D_CS_OP_BLT_SUB_RESOURCE,
WINED3D_CS_OP_UPDATE_SUB_RESOURCE,
WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION,
};
struct wined3d_cs_present
......@@ -372,6 +373,13 @@ struct wined3d_cs_update_sub_resource
struct wined3d_sub_resource_data data;
};
struct wined3d_cs_add_dirty_texture_region
{
enum wined3d_cs_op opcode;
struct wined3d_texture *texture;
unsigned int layer;
};
static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_present *op = data;
......@@ -1957,6 +1965,42 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r
cs->ops->submit(cs);
}
static void wined3d_cs_exec_add_dirty_texture_region(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_add_dirty_texture_region *op = data;
struct wined3d_texture *texture = op->texture;
unsigned int sub_resource_idx, i;
struct wined3d_context *context;
context = context_acquire(cs->device, NULL, 0);
sub_resource_idx = op->layer * texture->level_count;
for (i = 0; i < texture->level_count; ++i, ++sub_resource_idx)
{
if (wined3d_texture_load_location(texture, sub_resource_idx, context, texture->resource.map_binding))
wined3d_texture_invalidate_location(texture, sub_resource_idx, ~texture->resource.map_binding);
else
ERR("Failed to load location %s.\n", wined3d_debug_location(texture->resource.map_binding));
}
context_release(context);
wined3d_resource_release(&texture->resource);
}
void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs,
struct wined3d_texture *texture, unsigned int layer)
{
struct wined3d_cs_add_dirty_texture_region *op;
op = cs->ops->require_space(cs, sizeof(*op));
op->opcode = WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION;
op->texture = texture;
op->layer = layer;
wined3d_resource_acquire(&texture->resource);
cs->ops->submit(cs);
}
static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) =
{
/* WINED3D_CS_OP_PRESENT */ wined3d_cs_exec_present,
......@@ -1998,6 +2042,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void
/* WINED3D_CS_OP_UNMAP */ wined3d_cs_exec_unmap,
/* WINED3D_CS_OP_BLT_SUB_RESOURCE */ wined3d_cs_exec_blt_sub_resource,
/* WINED3D_CS_OP_UPDATE_SUB_RESOURCE */ wined3d_cs_exec_update_sub_resource,
/* WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION */ wined3d_cs_exec_add_dirty_texture_region,
};
static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size)
......
......@@ -1639,9 +1639,6 @@ static struct wined3d_texture_sub_resource *wined3d_texture_get_sub_resource(str
HRESULT CDECL wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
UINT layer, const struct wined3d_box *dirty_region)
{
unsigned int sub_resource_idx, i;
struct wined3d_context *context;
TRACE("texture %p, layer %u, dirty_region %s.\n", texture, layer, debug_box(dirty_region));
if (layer >= texture->layer_count)
......@@ -1653,19 +1650,7 @@ HRESULT CDECL wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
if (dirty_region)
FIXME("Ignoring dirty_region %s.\n", debug_box(dirty_region));
context = context_acquire(texture->resource.device, NULL, 0);
sub_resource_idx = layer * texture->level_count;
for (i = 0; i < texture->level_count; ++i, ++sub_resource_idx)
{
if (!wined3d_texture_load_location(texture, sub_resource_idx, context, texture->resource.map_binding))
{
ERR("Failed to load location %s.\n", wined3d_debug_location(texture->resource.map_binding));
context_release(context);
return E_OUTOFMEMORY;
}
wined3d_texture_invalidate_location(texture, sub_resource_idx, ~texture->resource.map_binding);
}
context_release(context);
wined3d_cs_emit_add_dirty_texture_region(texture->resource.device->cs, texture, layer);
return WINED3D_OK;
}
......
......@@ -3243,6 +3243,8 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) DECLSPEC_HID
void wined3d_cs_destroy(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
void wined3d_cs_destroy_object(struct wined3d_cs *cs,
void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs,
struct wined3d_texture *texture, unsigned int layer) DECLSPEC_HIDDEN;
void wined3d_cs_emit_blt_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *dst_resource,
unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box, struct wined3d_resource *src_resource,
unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, DWORD flags,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment