wined3d: Send sampler GL initialisation through the command stream.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2017-02-16 00:58:53 +01:00 committed by Alexandre Julliard
parent 325d415ea4
commit 9e2498f25e
12 changed files with 49 additions and 31 deletions

View File

@ -797,7 +797,7 @@ ULONG CDECL wined3d_buffer_decref(struct wined3d_buffer *buffer)
{
buffer->resource.parent_ops->wined3d_object_destroyed(buffer->resource.parent);
resource_cleanup(&buffer->resource);
wined3d_cs_emit_destroy_object(buffer->resource.device->cs, wined3d_buffer_destroy_object, buffer);
wined3d_cs_destroy_object(buffer->resource.device->cs, wined3d_buffer_destroy_object, buffer);
}
return refcount;

View File

@ -55,7 +55,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,
WINED3D_CS_OP_CALLBACK,
WINED3D_CS_OP_QUERY_ISSUE,
WINED3D_CS_OP_PRELOAD_RESOURCE,
WINED3D_CS_OP_UNLOAD_RESOURCE,
@ -283,7 +283,7 @@ struct wined3d_cs_reset_state
enum wined3d_cs_op opcode;
};
struct wined3d_cs_destroy_object
struct wined3d_cs_callback
{
enum wined3d_cs_op opcode;
void (*callback)(void *object);
@ -1389,25 +1389,35 @@ 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)
static void wined3d_cs_exec_callback(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_destroy_object *op = data;
const struct wined3d_cs_callback *op = data;
op->callback(op->object);
}
void wined3d_cs_emit_destroy_object(struct wined3d_cs *cs, void (*callback)(void *object), void *object)
static void wined3d_cs_emit_callback(struct wined3d_cs *cs, void (*callback)(void *object), void *object)
{
struct wined3d_cs_destroy_object *op;
struct wined3d_cs_callback *op;
op = cs->ops->require_space(cs, sizeof(*op));
op->opcode = WINED3D_CS_OP_DESTROY_OBJECT;
op->opcode = WINED3D_CS_OP_CALLBACK;
op->callback = callback;
op->object = object;
cs->ops->submit(cs);
}
void wined3d_cs_destroy_object(struct wined3d_cs *cs, void (*callback)(void *object), void *object)
{
wined3d_cs_emit_callback(cs, callback, object);
}
void wined3d_cs_init_object(struct wined3d_cs *cs, void (*callback)(void *object), void *object)
{
wined3d_cs_emit_callback(cs, callback, object);
}
static void wined3d_cs_exec_query_issue(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_query_issue *op = data;
@ -1556,7 +1566,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,
/* WINED3D_CS_OP_CALLBACK */ wined3d_cs_exec_callback,
/* WINED3D_CS_OP_QUERY_ISSUE */ wined3d_cs_exec_query_issue,
/* WINED3D_CS_OP_PRELOAD_RESOURCE */ wined3d_cs_exec_preload_resource,
/* WINED3D_CS_OP_UNLOAD_RESOURCE */ wined3d_cs_exec_unload_resource,

View File

@ -45,7 +45,7 @@ ULONG CDECL wined3d_palette_decref(struct wined3d_palette *palette)
TRACE("%p decreasing refcount to %u.\n", palette, refcount);
if (!refcount)
wined3d_cs_emit_destroy_object(palette->device->cs, wined3d_palette_destroy_object, palette);
wined3d_cs_destroy_object(palette->device->cs, wined3d_palette_destroy_object, palette);
return refcount;
}

View File

@ -312,7 +312,7 @@ ULONG CDECL wined3d_query_decref(struct wined3d_query *query)
TRACE("%p decreasing refcount to %u.\n", query, refcount);
if (!refcount)
wined3d_cs_emit_destroy_object(query->device->cs, wined3d_query_destroy_object, query);
wined3d_cs_destroy_object(query->device->cs, wined3d_query_destroy_object, query);
return refcount;
}

View File

@ -256,7 +256,7 @@ void resource_cleanup(struct wined3d_resource *resource)
device_resource_released(resource->device, resource);
wined3d_resource_acquire(resource);
wined3d_cs_emit_destroy_object(resource->device->cs, wined3d_resource_destroy_object, resource);
wined3d_cs_destroy_object(resource->device->cs, wined3d_resource_destroy_object, resource);
}
void resource_unload(struct wined3d_resource *resource)

View File

@ -54,7 +54,7 @@ ULONG CDECL wined3d_sampler_decref(struct wined3d_sampler *sampler)
TRACE("%p decreasing refcount to %u.\n", sampler, refcount);
if (!refcount)
wined3d_cs_emit_destroy_object(sampler->device->cs, wined3d_sampler_destroy_object, sampler);
wined3d_cs_destroy_object(sampler->device->cs, wined3d_sampler_destroy_object, sampler);
return refcount;
}
@ -66,20 +66,17 @@ void * CDECL wined3d_sampler_get_parent(const struct wined3d_sampler *sampler)
return sampler->parent;
}
static void wined3d_sampler_init(struct wined3d_sampler *sampler, struct wined3d_device *device,
const struct wined3d_sampler_desc *desc, void *parent)
static void wined3d_sampler_cs_init(void *object)
{
struct wined3d_sampler *sampler = object;
const struct wined3d_sampler_desc *desc;
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
sampler->refcount = 1;
sampler->device = device;
sampler->parent = parent;
sampler->desc = *desc;
context = context_acquire(device, NULL, 0);
context = context_acquire(sampler->device, NULL, 0);
gl_info = context->gl_info;
desc = &sampler->desc;
GL_EXTCALL(glGenSamplers(1, &sampler->name));
GL_EXTCALL(glSamplerParameteri(sampler->name, GL_TEXTURE_WRAP_S,
gl_info->wrap_lookup[desc->address_u - WINED3D_TADDRESS_WRAP]));
@ -111,6 +108,16 @@ static void wined3d_sampler_init(struct wined3d_sampler *sampler, struct wined3d
context_release(context);
}
static void wined3d_sampler_init(struct wined3d_sampler *sampler, struct wined3d_device *device,
const struct wined3d_sampler_desc *desc, void *parent)
{
sampler->refcount = 1;
sampler->device = device;
sampler->parent = parent;
sampler->desc = *desc;
wined3d_cs_init_object(device->cs, wined3d_sampler_cs_init, sampler);
}
HRESULT CDECL wined3d_sampler_create(struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
void *parent, struct wined3d_sampler **sampler)
{

View File

@ -2964,7 +2964,7 @@ ULONG CDECL wined3d_shader_decref(struct wined3d_shader *shader)
if (!refcount)
{
shader->parent_ops->wined3d_object_destroyed(shader->parent);
wined3d_cs_emit_destroy_object(shader->device->cs, wined3d_shader_destroy_object, shader);
wined3d_cs_destroy_object(shader->device->cs, wined3d_shader_destroy_object, shader);
}
return refcount;

View File

@ -60,7 +60,7 @@ ULONG CDECL wined3d_rasterizer_state_decref(struct wined3d_rasterizer_state *sta
TRACE("%p decreasing refcount to %u.\n", state, refcount);
if (!refcount)
wined3d_cs_emit_destroy_object(device->cs, wined3d_rasterizer_state_destroy_object, state);
wined3d_cs_destroy_object(device->cs, wined3d_rasterizer_state_destroy_object, state);
return refcount;
}

View File

@ -929,7 +929,7 @@ ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
wined3d_texture_sub_resources_destroyed(texture);
texture->resource.parent_ops->wined3d_object_destroyed(texture->resource.parent);
resource_cleanup(&texture->resource);
wined3d_cs_emit_destroy_object(texture->resource.device->cs, wined3d_texture_destroy_object, texture);
wined3d_cs_destroy_object(texture->resource.device->cs, wined3d_texture_destroy_object, texture);
}
return refcount;

View File

@ -67,7 +67,7 @@ ULONG CDECL wined3d_vertex_declaration_decref(struct wined3d_vertex_declaration
if (!refcount)
{
declaration->parent_ops->wined3d_object_destroyed(declaration->parent);
wined3d_cs_emit_destroy_object(declaration->device->cs,
wined3d_cs_destroy_object(declaration->device->cs,
wined3d_vertex_declaration_destroy_object, declaration);
}

View File

@ -232,7 +232,7 @@ ULONG CDECL wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *v
/* 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_cs_emit_destroy_object(device->cs, wined3d_rendertarget_view_destroy_object, view);
wined3d_cs_destroy_object(device->cs, wined3d_rendertarget_view_destroy_object, view);
wined3d_resource_decref(resource);
}
@ -462,7 +462,7 @@ ULONG CDECL wined3d_shader_resource_view_decref(struct wined3d_shader_resource_v
/* 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_cs_emit_destroy_object(device->cs, wined3d_shader_resource_view_destroy_object, view);
wined3d_cs_destroy_object(device->cs, wined3d_shader_resource_view_destroy_object, view);
wined3d_resource_decref(resource);
}
@ -630,7 +630,7 @@ ULONG CDECL wined3d_unordered_access_view_decref(struct wined3d_unordered_access
/* 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_cs_emit_destroy_object(device->cs, wined3d_unordered_access_view_destroy_object, view);
wined3d_cs_destroy_object(device->cs, wined3d_unordered_access_view_destroy_object, view);
wined3d_resource_decref(resource);
}

View File

@ -3174,11 +3174,10 @@ struct wined3d_cs
struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) DECLSPEC_HIDDEN;
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_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_dispatch(struct wined3d_cs *cs,
unsigned int group_count_x, unsigned int group_count_y, unsigned int group_count_z) DECLSPEC_HIDDEN;
void wined3d_cs_emit_draw(struct wined3d_cs *cs, int base_vertex_idx, unsigned int start_idx, unsigned int index_count,
@ -3233,6 +3232,8 @@ void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs,
struct wined3d_vertex_declaration *declaration) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_viewport(struct wined3d_cs *cs, const struct wined3d_viewport *viewport) DECLSPEC_HIDDEN;
void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void wined3d_cs_init_object(struct wined3d_cs *cs,
void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource, unsigned int sub_resource_idx,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags) DECLSPEC_HIDDEN;
HRESULT wined3d_cs_unmap(struct wined3d_cs *cs, struct wined3d_resource *resource,