Skip to content

Commit

Permalink
GL: Deleting textures is allowed from non-main threads
Browse files Browse the repository at this point in the history
glDeleteTextures() is now deferred, so functions that delete
textures don't need the main thread assertion any more.
  • Loading branch information
skyjake committed Feb 8, 2012
1 parent cda9247 commit 639c80d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 12 deletions.
6 changes: 4 additions & 2 deletions doomsday/engine/portable/include/gl_defer.h
Expand Up @@ -73,8 +73,10 @@ void GL_ReleaseReservedNames(void);
void GL_DeferTextureUpload(const struct texturecontent_s* content);

// Deferring functions for various function signatures.
#define LIBDENG_GL_DEFER1(form, x) void GL_Defer_##form(void (GL_CALL *ptr)(x), x)
#define LIBDENG_GL_DEFER2(form, x, y) void GL_Defer_##form(void (GL_CALL* ptr)(x, y), x, y)
#define LIBDENG_GL_DEFER1(form, x) void GL_Defer_##form(void (GL_CALL *ptr)(x), x)
#define LIBDENG_GL_DEFER2(form, x, y) void GL_Defer_##form(void (GL_CALL* ptr)(x, y), x, y)
#define LIBDENG_GL_DEFER3(form, x, y, z) void GL_Defer_##form(void (GL_CALL* ptr)(x, y, z), x, y, z)
#define LIBDENG_GL_DEFER4(form, x, y, z, w) void GL_Defer_##form(void (GL_CALL* ptr)(x, y, z, w), x, y, z, w)

LIBDENG_GL_DEFER1(e, GLenum e);
LIBDENG_GL_DEFER2(uintArray, GLsizei count, const GLuint* values);
Expand Down
3 changes: 3 additions & 0 deletions doomsday/engine/portable/include/gl_deferredapi.h
Expand Up @@ -5,6 +5,9 @@
* Redefines GL API functions so that they're replaced with ones that defer the
* call when needed.
*
* @note Only the GL API functions declared in this file are safe to call from
* outside the main thread!
*
* @authors Copyright © 2012 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2012 Daniel Swanson <danij@dengine.net>
*
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/gl_defer.c
Expand Up @@ -45,10 +45,10 @@ typedef enum {
DTT_FUNC_PTR_UINT_ARRAY,
DTT_FUNC_PTR_END,

DEFERREDTASK_TYPES_COUNT
DEFERREDTASK_TYPES_LAST
} deferredtask_type_t;

#define VALID_DEFERREDTASK_TYPE(t) ((t) >= DEFERREDTASK_TYPES_FIRST || (t) < DEFERREDTASK_TYPES_COUNT)
#define VALID_DEFERREDTASK_TYPE(t) ((t) >= DEFERREDTASK_TYPES_FIRST || (t) < DEFERREDTASK_TYPES_LAST)

typedef struct deferredtask_s {
struct deferredtask_s* next;
Expand Down
2 changes: 0 additions & 2 deletions doomsday/engine/portable/src/gl_texmanager.c
Expand Up @@ -1315,8 +1315,6 @@ void GL_ReleaseSystemTextures(void)

VERBOSE( Con_Message("Releasing System textures...\n") )

LIBDENG_ASSERT_IN_MAIN_THREAD();

// The rendering lists contain persistent references to texture names.
// Which, obviously, can't persist any longer...
RL_DeleteLists();
Expand Down
4 changes: 0 additions & 4 deletions doomsday/engine/portable/src/rend_particle.c
Expand Up @@ -204,8 +204,6 @@ void Rend_ParticleReleaseSystemTextures(void)
{
if(novideo) return;

LIBDENG_ASSERT_IN_MAIN_THREAD();

glDeleteTextures(1, (const GLuint*) &pointTex);
pointTex = 0;
}
Expand All @@ -214,8 +212,6 @@ void Rend_ParticleReleaseExtraTextures(void)
{
if(novideo) return;

LIBDENG_ASSERT_IN_MAIN_THREAD();

glDeleteTextures(NUM_TEX_NAMES, (const GLuint*) ptctexname);
memset(ptctexname, 0, sizeof(ptctexname));
}
Expand Down
2 changes: 0 additions & 2 deletions doomsday/engine/portable/src/ui_main.c
Expand Up @@ -291,8 +291,6 @@ void UI_LoadTextures(void)

void UI_ReleaseTextures(void)
{
LIBDENG_ASSERT_IN_MAIN_THREAD();

glDeleteTextures(NUM_UITEXTURES, (const GLuint*) uiTextures);
memset(uiTextures, 0, sizeof(uiTextures));
}
Expand Down

0 comments on commit 639c80d

Please sign in to comment.