Commit 8a8b57ce authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Send shader resource view destruction through the command stream.

parent 4afc7470
......@@ -52,6 +52,7 @@ enum wined3d_cs_op
WINED3D_CS_OP_SET_COLOR_KEY,
WINED3D_CS_OP_SET_MATERIAL,
WINED3D_CS_OP_RESET_STATE,
WINED3D_CS_OP_DESTROY_OBJECT,
};
struct wined3d_cs_present
......@@ -252,6 +253,13 @@ struct wined3d_cs_reset_state
enum wined3d_cs_op opcode;
};
struct wined3d_cs_destroy_object
{
enum wined3d_cs_op opcode;
void (*callback)(void *object);
void *object;
};
static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_present *op = data;
......@@ -1029,6 +1037,25 @@ void wined3d_cs_emit_reset_state(struct wined3d_cs *cs)
cs->ops->submit(cs);
}
static void wined3d_cs_exec_destroy_object(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_destroy_object *op = data;
op->callback(op->object);
}
void wined3d_cs_emit_destroy_object(struct wined3d_cs *cs, void (*callback)(void *object), void *object)
{
struct wined3d_cs_destroy_object *op;
op = cs->ops->require_space(cs, sizeof(*op));
op->opcode = WINED3D_CS_OP_DESTROY_OBJECT;
op->callback = callback;
op->object = object;
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,
......@@ -1057,6 +1084,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_RESET_STATE */ wined3d_cs_exec_reset_state,
/* WINED3D_CS_OP_DESTROY_OBJECT */ wined3d_cs_exec_destroy_object,
};
static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size)
......
......@@ -194,6 +194,25 @@ ULONG CDECL wined3d_shader_resource_view_incref(struct wined3d_shader_resource_v
return refcount;
}
static void wined3d_shader_resource_view_destroy_object(void *object)
{
struct wined3d_shader_resource_view *view = object;
if (view->object)
{
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
context = context_acquire(view->resource->device, NULL);
gl_info = context->gl_info;
gl_info->gl_ops.gl.p_glDeleteTextures(1, &view->object);
checkGLcall("glDeleteTextures");
context_release(context);
}
HeapFree(GetProcessHeap(), 0, view);
}
ULONG CDECL wined3d_shader_resource_view_decref(struct wined3d_shader_resource_view *view)
{
ULONG refcount = InterlockedDecrement(&view->refcount);
......@@ -202,22 +221,13 @@ ULONG CDECL wined3d_shader_resource_view_decref(struct wined3d_shader_resource_v
if (!refcount)
{
if (view->object)
{
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
context = context_acquire(view->resource->device, NULL);
gl_info = context->gl_info;
gl_info->gl_ops.gl.p_glDeleteTextures(1, &view->object);
checkGLcall("glDeleteTextures");
context_release(context);
}
struct wined3d_device *device = view->resource->device;
/* Call wined3d_object_destroyed() before releasing the resource,
* since releasing the resource may end up destroying the parent. */
view->parent_ops->wined3d_object_destroyed(view->parent);
wined3d_resource_decref(view->resource);
HeapFree(GetProcessHeap(), 0, view);
wined3d_cs_emit_destroy_object(device->cs, wined3d_shader_resource_view_destroy_object, view);
}
return refcount;
......
......@@ -2916,6 +2916,8 @@ void wined3d_cs_destroy(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT *rects,
DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
void wined3d_cs_emit_destroy_object(struct wined3d_cs *cs,
void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
void wined3d_cs_emit_draw(struct wined3d_cs *cs, int base_vertex_idx, unsigned int start_idx, unsigned int index_count,
unsigned int start_instance, unsigned int instance_count, BOOL indexed) DECLSPEC_HIDDEN;
void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain,
......
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