From 6cc36f7296836a8c8da46441edb252a1a5672de4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Tue, 26 Mar 2019 18:29:46 +0100 Subject: [PATCH] wined3d: Pass context to vp_free() and free_private(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid using "adapter->gl_info". Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/arb_program_shader.c | 20 +++++++------- dlls/wined3d/ati_fragment_shader.c | 10 ++++--- dlls/wined3d/device.c | 4 +-- dlls/wined3d/glsl_shader.c | 40 +++++++++++++++------------- dlls/wined3d/nvidia_texture_shader.c | 2 +- dlls/wined3d/shader.c | 8 +++--- dlls/wined3d/state.c | 4 +-- dlls/wined3d/wined3d_private.h | 6 ++--- 8 files changed, 50 insertions(+), 44 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index aab047cc023..05bd55a89bd 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -4798,7 +4798,7 @@ static HRESULT shader_arb_alloc(struct wined3d_device *device, const struct wine if (!(fragment_priv = fragment_pipe->alloc_private(&arb_program_shader_backend, priv))) { ERR("Failed to initialize fragment pipe.\n"); - vertex_pipe->vp_free(device); + vertex_pipe->vp_free(device, NULL); heap_free(priv); return E_FAIL; } @@ -4836,13 +4836,13 @@ static void release_signature(struct wine_rb_entry *entry, void *context) } /* Context activation is done by the caller. */ -static void shader_arb_free(struct wined3d_device *device) +static void shader_arb_free(struct wined3d_device *device, struct wined3d_context *context) { struct shader_arb_priv *priv = device->shader_priv; wine_rb_destroy(&priv->signature_tree, release_signature, NULL); - priv->fragment_pipe->free_private(device); - priv->vertex_pipe->vp_free(device); + priv->fragment_pipe->free_private(device, context); + priv->vertex_pipe->vp_free(device, context); heap_free(device->shader_priv); } @@ -5710,22 +5710,24 @@ static void *arbfp_alloc(const struct wined3d_shader_backend_ops *shader_backend } /* Context activation is done by the caller. */ -static void arbfp_free_ffpshader(struct wine_rb_entry *entry, void *context) +static void arbfp_free_ffpshader(struct wine_rb_entry *entry, void *param) { - const struct wined3d_gl_info *gl_info = context; struct arbfp_ffp_desc *entry_arb = WINE_RB_ENTRY_VALUE(entry, struct arbfp_ffp_desc, parent.entry); + struct wined3d_context *context = param; + const struct wined3d_gl_info *gl_info; + gl_info = context->gl_info; GL_EXTCALL(glDeleteProgramsARB(1, &entry_arb->shader)); - checkGLcall("glDeleteProgramsARB(1, &entry_arb->shader)"); + checkGLcall("delete ffp program"); heap_free(entry_arb); } /* Context activation is done by the caller. */ -static void arbfp_free(struct wined3d_device *device) +static void arbfp_free(struct wined3d_device *device, struct wined3d_context *context) { struct shader_arb_priv *priv = device->fragment_priv; - wine_rb_destroy(&priv->fragment_shaders, arbfp_free_ffpshader, &device->adapter->gl_info); + wine_rb_destroy(&priv->fragment_shaders, arbfp_free_ffpshader, context); priv->use_arbfp_fixed_func = FALSE; if (device->shader_backend != &arb_program_shader_backend) diff --git a/dlls/wined3d/ati_fragment_shader.c b/dlls/wined3d/ati_fragment_shader.c index 05ec44a0cf3..283732299d1 100644 --- a/dlls/wined3d/ati_fragment_shader.c +++ b/dlls/wined3d/ati_fragment_shader.c @@ -1329,22 +1329,24 @@ static void *atifs_alloc(const struct wined3d_shader_backend_ops *shader_backend } /* Context activation is done by the caller. */ -static void atifs_free_ffpshader(struct wine_rb_entry *entry, void *cb_ctx) +static void atifs_free_ffpshader(struct wine_rb_entry *entry, void *param) { - const struct wined3d_gl_info *gl_info = cb_ctx; struct atifs_ffp_desc *entry_ati = WINE_RB_ENTRY_VALUE(entry, struct atifs_ffp_desc, parent.entry); + struct wined3d_context *context = param; + const struct wined3d_gl_info *gl_info; + gl_info = context->gl_info; GL_EXTCALL(glDeleteFragmentShaderATI(entry_ati->shader)); checkGLcall("glDeleteFragmentShaderATI(entry->shader)"); heap_free(entry_ati); } /* Context activation is done by the caller. */ -static void atifs_free(struct wined3d_device *device) +static void atifs_free(struct wined3d_device *device, struct wined3d_context *context) { struct atifs_private_data *priv = device->fragment_priv; - wine_rb_destroy(&priv->fragment_shaders, atifs_free_ffpshader, &device->adapter->gl_info); + wine_rb_destroy(&priv->fragment_shaders, atifs_free_ffpshader, context); heap_free(priv); device->fragment_priv = NULL; diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 5039e0a81ef..978d9ac5201 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1002,7 +1002,7 @@ static void wined3d_device_delete_opengl_contexts_cs(void *object) context = context_acquire(device, NULL, 0); device->blitter->ops->blitter_destroy(device->blitter, context); - device->shader_backend->shader_free_private(device); + device->shader_backend->shader_free_private(device, context); destroy_dummy_textures(device, context); destroy_default_samplers(device, context); context_release(context); @@ -1040,7 +1040,7 @@ static void wined3d_device_create_primary_opengl_context_cs(void *object) if (!(device->blitter = wined3d_cpu_blitter_create())) { ERR("Failed to create CPU blitter.\n"); - device->shader_backend->shader_free_private(device); + device->shader_backend->shader_free_private(device, NULL); return; } wined3d_ffp_blitter_create(&device->blitter, &device->adapter->gl_info); diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index ebc01595778..55d99abd589 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -352,7 +352,7 @@ struct glsl_ffp_fragment_shader struct glsl_ffp_destroy_ctx { struct shader_glsl_priv *priv; - const struct wined3d_gl_info *gl_info; + const struct wined3d_context *context; }; static void shader_glsl_generate_shader_epilogue(const struct wined3d_shader_context *ctx); @@ -11208,7 +11208,7 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win if (!(fragment_priv = fragment_pipe->alloc_private(&glsl_shader_backend, priv))) { ERR("Failed to initialize fragment pipe.\n"); - vertex_pipe->vp_free(device); + vertex_pipe->vp_free(device, NULL); heap_free(priv); return E_FAIL; } @@ -11257,14 +11257,14 @@ fail: constant_heap_free(&priv->vconst_heap); heap_free(priv->stack); string_buffer_free(&priv->shader_buffer); - fragment_pipe->free_private(device); - vertex_pipe->vp_free(device); + fragment_pipe->free_private(device, NULL); + vertex_pipe->vp_free(device, NULL); heap_free(priv); return E_OUTOFMEMORY; } /* Context activation is done by the caller. */ -static void shader_glsl_free(struct wined3d_device *device) +static void shader_glsl_free(struct wined3d_device *device, struct wined3d_context *context) { struct shader_glsl_priv *priv = device->shader_priv; @@ -11274,8 +11274,8 @@ static void shader_glsl_free(struct wined3d_device *device) heap_free(priv->stack); string_buffer_list_cleanup(&priv->string_buffers); string_buffer_free(&priv->shader_buffer); - priv->fragment_pipe->free_private(device); - priv->vertex_pipe->vp_free(device); + priv->fragment_pipe->free_private(device, context); + priv->vertex_pipe->vp_free(device, context); heap_free(device->shader_priv); device->shader_priv = NULL; @@ -11718,30 +11718,31 @@ static void *glsl_vertex_pipe_vp_alloc(const struct wined3d_shader_backend_ops * return NULL; } -static void shader_glsl_free_ffp_vertex_shader(struct wine_rb_entry *entry, void *context) +static void shader_glsl_free_ffp_vertex_shader(struct wine_rb_entry *entry, void *param) { struct glsl_ffp_vertex_shader *shader = WINE_RB_ENTRY_VALUE(entry, struct glsl_ffp_vertex_shader, desc.entry); struct glsl_shader_prog_link *program, *program2; - struct glsl_ffp_destroy_ctx *ctx = context; + struct glsl_ffp_destroy_ctx *ctx = param; + const struct wined3d_gl_info *gl_info = ctx->context->gl_info; LIST_FOR_EACH_ENTRY_SAFE(program, program2, &shader->linked_programs, struct glsl_shader_prog_link, vs.shader_entry) { - delete_glsl_program_entry(ctx->priv, ctx->gl_info, program); + delete_glsl_program_entry(ctx->priv, gl_info, program); } - ctx->gl_info->gl_ops.ext.p_glDeleteShader(shader->id); + GL_EXTCALL(glDeleteShader(shader->id)); heap_free(shader); } /* Context activation is done by the caller. */ -static void glsl_vertex_pipe_vp_free(struct wined3d_device *device) +static void glsl_vertex_pipe_vp_free(struct wined3d_device *device, struct wined3d_context *context) { struct shader_glsl_priv *priv = device->vertex_priv; struct glsl_ffp_destroy_ctx ctx; ctx.priv = priv; - ctx.gl_info = &device->adapter->gl_info; + ctx.context = context; wine_rb_destroy(&priv->ffp_vertex_shaders, shader_glsl_free_ffp_vertex_shader, &ctx); } @@ -12225,30 +12226,31 @@ static void *glsl_fragment_pipe_alloc(const struct wined3d_shader_backend_ops *s return NULL; } -static void shader_glsl_free_ffp_fragment_shader(struct wine_rb_entry *entry, void *context) +static void shader_glsl_free_ffp_fragment_shader(struct wine_rb_entry *entry, void *param) { struct glsl_ffp_fragment_shader *shader = WINE_RB_ENTRY_VALUE(entry, struct glsl_ffp_fragment_shader, entry.entry); struct glsl_shader_prog_link *program, *program2; - struct glsl_ffp_destroy_ctx *ctx = context; + struct glsl_ffp_destroy_ctx *ctx = param; + const struct wined3d_gl_info *gl_info = ctx->context->gl_info; LIST_FOR_EACH_ENTRY_SAFE(program, program2, &shader->linked_programs, struct glsl_shader_prog_link, ps.shader_entry) { - delete_glsl_program_entry(ctx->priv, ctx->gl_info, program); + delete_glsl_program_entry(ctx->priv, gl_info, program); } - ctx->gl_info->gl_ops.ext.p_glDeleteShader(shader->id); + GL_EXTCALL(glDeleteShader(shader->id)); heap_free(shader); } /* Context activation is done by the caller. */ -static void glsl_fragment_pipe_free(struct wined3d_device *device) +static void glsl_fragment_pipe_free(struct wined3d_device *device, struct wined3d_context *context) { struct shader_glsl_priv *priv = device->fragment_priv; struct glsl_ffp_destroy_ctx ctx; ctx.priv = priv; - ctx.gl_info = &device->adapter->gl_info; + ctx.context = context; wine_rb_destroy(&priv->ffp_fragment_shaders, shader_glsl_free_ffp_fragment_shader, &ctx); } diff --git a/dlls/wined3d/nvidia_texture_shader.c b/dlls/wined3d/nvidia_texture_shader.c index 323484ab43b..f5dbb254fb9 100644 --- a/dlls/wined3d/nvidia_texture_shader.c +++ b/dlls/wined3d/nvidia_texture_shader.c @@ -754,7 +754,7 @@ static void *nvrc_fragment_alloc(const struct wined3d_shader_backend_ops *shader } /* Context activation is done by the caller. */ -static void nvrc_fragment_free(struct wined3d_device *device) {} +static void nvrc_fragment_free(struct wined3d_device *device, struct wined3d_context *context) {} /* Two fixed function pipeline implementations using GL_NV_register_combiners and * GL_NV_texture_shader. The nvts_fragment_pipeline assumes that both extensions diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 83a793d5229..379ca63d2cc 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -3229,7 +3229,7 @@ static HRESULT shader_none_alloc(struct wined3d_device *device, const struct win if (!(fragment_priv = fragment_pipe->alloc_private(&none_shader_backend, priv))) { ERR("Failed to initialize fragment pipe.\n"); - vertex_pipe->vp_free(device); + vertex_pipe->vp_free(device, NULL); heap_free(priv); return E_FAIL; } @@ -3246,12 +3246,12 @@ static HRESULT shader_none_alloc(struct wined3d_device *device, const struct win return WINED3D_OK; } -static void shader_none_free(struct wined3d_device *device) +static void shader_none_free(struct wined3d_device *device, struct wined3d_context *context) { struct shader_none_priv *priv = device->shader_priv; - priv->fragment_pipe->free_private(device); - priv->vertex_pipe->vp_free(device); + priv->fragment_pipe->free_private(device, context); + priv->vertex_pipe->vp_free(device, context); heap_free(priv); } diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index f071f30b575..fcad10f7a19 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -5198,7 +5198,7 @@ static void *ffp_alloc(const struct wined3d_shader_backend_ops *shader_backend, return shader_priv; } -static void ffp_free(struct wined3d_device *device) {} +static void ffp_free(struct wined3d_device *device, struct wined3d_context *context) {} static void vp_ffp_get_caps(const struct wined3d_gl_info *gl_info, struct wined3d_vertex_caps *caps) { @@ -5316,7 +5316,7 @@ static void *none_alloc(const struct wined3d_shader_backend_ops *shader_backend, return shader_priv; } -static void none_free(struct wined3d_device *device) {} +static void none_free(struct wined3d_device *device, struct wined3d_context *context) {} static void vp_none_get_caps(const struct wined3d_gl_info *gl_info, struct wined3d_vertex_caps *caps) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 785ee2a3c3e..22e7441ced8 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1431,7 +1431,7 @@ struct wined3d_shader_backend_ops void (*shader_destroy)(struct wined3d_shader *shader); HRESULT (*shader_alloc_private)(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe, const struct fragment_pipeline *fragment_pipe); - void (*shader_free_private)(struct wined3d_device *device); + void (*shader_free_private)(struct wined3d_device *device, struct wined3d_context *context); BOOL (*shader_allocate_context_data)(struct wined3d_context *context); void (*shader_free_context_data)(struct wined3d_context *context); void (*shader_init_context_state)(struct wined3d_context *context); @@ -2063,7 +2063,7 @@ struct fragment_pipeline void (*get_caps)(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps); DWORD (*get_emul_mask)(const struct wined3d_gl_info *gl_info); void *(*alloc_private)(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv); - void (*free_private)(struct wined3d_device *device); + void (*free_private)(struct wined3d_device *device, struct wined3d_context *context); BOOL (*allocate_context_data)(struct wined3d_context *context); void (*free_context_data)(struct wined3d_context *context); BOOL (*color_fixup_supported)(struct color_fixup_desc fixup); @@ -2090,7 +2090,7 @@ struct wined3d_vertex_pipe_ops void (*vp_get_caps)(const struct wined3d_gl_info *gl_info, struct wined3d_vertex_caps *caps); DWORD (*vp_get_emul_mask)(const struct wined3d_gl_info *gl_info); void *(*vp_alloc)(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv); - void (*vp_free)(struct wined3d_device *device); + void (*vp_free)(struct wined3d_device *device, struct wined3d_context *context); const struct wined3d_state_entry_template *vp_states; };