wined3d: Cleanup sub-resource buffer objects in wined3d_texture_cleanup().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Stefan Dösinger 2016-03-02 19:24:19 +01:00 committed by Alexandre Julliard
parent fbe2737537
commit 45fa5b6471
3 changed files with 28 additions and 13 deletions

View File

@ -48,13 +48,10 @@ static unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *s
void wined3d_surface_cleanup(struct wined3d_surface *surface) void wined3d_surface_cleanup(struct wined3d_surface *surface)
{ {
struct wined3d_surface *overlay, *cur; struct wined3d_surface *overlay, *cur;
GLuint buffer_object;
TRACE("surface %p.\n", surface); TRACE("surface %p.\n", surface);
buffer_object = surface->container->sub_resources[surface_get_sub_resource_idx(surface)].buffer_object; if (surface->rb_multisample || surface->rb_resolved || !list_empty(&surface->renderbuffers))
if (buffer_object || surface->rb_multisample
|| surface->rb_resolved || !list_empty(&surface->renderbuffers))
{ {
struct wined3d_renderbuffer_entry *entry, *entry2; struct wined3d_renderbuffer_entry *entry, *entry2;
const struct wined3d_gl_info *gl_info; const struct wined3d_gl_info *gl_info;
@ -64,12 +61,6 @@ void wined3d_surface_cleanup(struct wined3d_surface *surface)
context = context_acquire(device, NULL); context = context_acquire(device, NULL);
gl_info = context->gl_info; gl_info = context->gl_info;
if (buffer_object)
{
TRACE("Deleting buffer object %u.\n", buffer_object);
GL_EXTCALL(glDeleteBuffers(1, &buffer_object));
}
if (surface->rb_multisample) if (surface->rb_multisample)
{ {
TRACE("Deleting multisample renderbuffer %u.\n", surface->rb_multisample); TRACE("Deleting multisample renderbuffer %u.\n", surface->rb_multisample);

View File

@ -108,8 +108,35 @@ static void wined3d_texture_unload_gl_texture(struct wined3d_texture *texture)
static void wined3d_texture_cleanup(struct wined3d_texture *texture) static void wined3d_texture_cleanup(struct wined3d_texture *texture)
{ {
unsigned int sub_count = texture->level_count * texture->layer_count;
struct wined3d_device *device = texture->resource.device;
struct wined3d_context *context = NULL;
const struct wined3d_gl_info *gl_info;
GLuint buffer_object;
unsigned int i;
TRACE("texture %p.\n", texture); TRACE("texture %p.\n", texture);
for (i = 0; i < sub_count; ++i)
{
if (!(buffer_object = texture->sub_resources[i].buffer_object))
continue;
TRACE("Deleting buffer object %u.\n", buffer_object);
/* We may not be able to get a context in wined3d_texture_cleanup() in
* general, but if a buffer object was previously created we can. */
if (!context)
{
context = context_acquire(device, NULL);
gl_info = context->gl_info;
}
GL_EXTCALL(glDeleteBuffers(1, &buffer_object));
}
if (context)
context_release(context);
texture->texture_ops->texture_cleanup_sub_resources(texture); texture->texture_ops->texture_cleanup_sub_resources(texture);
wined3d_texture_unload_gl_texture(texture); wined3d_texture_unload_gl_texture(texture);
resource_cleanup(&texture->resource); resource_cleanup(&texture->resource);

View File

@ -397,9 +397,6 @@ void wined3d_volume_cleanup(struct wined3d_volume *volume)
{ {
TRACE("volume %p.\n", volume); TRACE("volume %p.\n", volume);
if (volume->container->sub_resources[volume->texture_level].buffer_object)
wined3d_volume_free_pbo(volume);
resource_cleanup(&volume->resource); resource_cleanup(&volume->resource);
} }