wined3d: Introduce wined3d_context_gl_destroy_bo().

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Matteo Bruni 2020-11-30 18:11:21 +03:30 committed by Alexandre Julliard
parent 111540ebc7
commit 0638d50b22
5 changed files with 20 additions and 14 deletions

View File

@ -4778,7 +4778,7 @@ static void wined3d_view_gl_destroy_object(void *object)
gl_info->gl_ops.gl.p_glDeleteTextures(1, &ctx->gl_view->name);
}
if (counter_id)
GL_EXTCALL(glDeleteBuffers(1, &counter_id));
wined3d_context_gl_destroy_bo(wined3d_context_gl(context), ctx->counter_bo);
checkGLcall("delete resources");
context_release(context);
}

View File

@ -142,7 +142,6 @@ static void wined3d_buffer_gl_bind(struct wined3d_buffer_gl *buffer_gl, struct w
static void wined3d_buffer_gl_destroy_buffer_object(struct wined3d_buffer_gl *buffer_gl,
struct wined3d_context_gl *context_gl)
{
const struct wined3d_gl_info *gl_info = context_gl->gl_info;
struct wined3d_resource *resource = &buffer_gl->b.resource;
struct wined3d_buffer *buffer = &buffer_gl->b;
struct wined3d_cs *cs = resource->device->cs;
@ -185,10 +184,8 @@ static void wined3d_buffer_gl_destroy_buffer_object(struct wined3d_buffer_gl *bu
}
}
GL_EXTCALL(glDeleteBuffers(1, &buffer_gl->bo.id));
checkGLcall("glDeleteBuffers");
wined3d_context_gl_destroy_bo(context_gl, &buffer_gl->bo);
buffer_gl->b.buffer_object = 0;
buffer_gl->bo.id = 0;
if (buffer_gl->b.fence)
{

View File

@ -2681,6 +2681,18 @@ void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl,
}
}
void wined3d_context_gl_destroy_bo(struct wined3d_context_gl *context_gl, struct wined3d_bo_gl *bo)
{
const struct wined3d_gl_info *gl_info = context_gl->gl_info;
TRACE("context_gl %p, bo %p.\n", context_gl, bo);
TRACE("Destroying GL buffer %u.\n", bo->id);
GL_EXTCALL(glDeleteBuffers(1, &bo->id));
checkGLcall("buffer object destruction");
bo->id = 0;
}
static void wined3d_context_gl_set_render_offscreen(struct wined3d_context_gl *context_gl, BOOL offscreen)
{
if (context_gl->c.render_offscreen == offscreen)

View File

@ -751,18 +751,14 @@ void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int su
/* Context activation is done by the caller. */
static void wined3d_texture_remove_buffer_object(struct wined3d_texture *texture,
unsigned int sub_resource_idx, const struct wined3d_gl_info *gl_info)
unsigned int sub_resource_idx, struct wined3d_context_gl *context_gl)
{
struct wined3d_bo_gl *bo = &texture->sub_resources[sub_resource_idx].bo;
GL_EXTCALL(glDeleteBuffers(1, &bo->id));
checkGLcall("glDeleteBuffers");
TRACE("Deleted buffer object %u for texture %p, sub-resource %u.\n",
bo->id, texture, sub_resource_idx);
TRACE("texture %p, sub_resource_idx %u, context_gl %p.\n", texture, sub_resource_idx, context_gl);
wined3d_context_gl_destroy_bo(context_gl, bo);
wined3d_texture_invalidate_location(texture, sub_resource_idx, WINED3D_LOCATION_BUFFER);
bo->id = 0;
}
static void wined3d_texture_update_map_binding(struct wined3d_texture *texture)
@ -781,7 +777,7 @@ static void wined3d_texture_update_map_binding(struct wined3d_texture *texture)
&& !wined3d_texture_load_location(texture, i, context, map_binding))
ERR("Failed to load location %s.\n", wined3d_debug_location(map_binding));
if (texture->resource.map_binding == WINED3D_LOCATION_BUFFER)
wined3d_texture_remove_buffer_object(texture, i, wined3d_context_gl(context)->gl_info);
wined3d_texture_remove_buffer_object(texture, i, wined3d_context_gl(context));
}
context_release(context);
@ -3223,7 +3219,7 @@ static void wined3d_texture_gl_unload_location(struct wined3d_texture *texture,
for (i = 0; i < sub_count; ++i)
{
if (texture_gl->t.sub_resources[i].bo.id)
wined3d_texture_remove_buffer_object(&texture_gl->t, i, context_gl->gl_info);
wined3d_texture_remove_buffer_object(&texture_gl->t, i, context_gl);
}
break;

View File

@ -2256,6 +2256,7 @@ void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl *contex
void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl,
const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) DECLSPEC_HIDDEN;
void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
void wined3d_context_gl_destroy_bo(struct wined3d_context_gl *context_gl, struct wined3d_bo_gl *bo) DECLSPEC_HIDDEN;
void wined3d_context_gl_draw_shaded_quad(struct wined3d_context_gl *context_gl, struct wined3d_texture_gl *texture_gl,
unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect,
enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;