Skip to content

Commit

Permalink
Merge branch 'master' of ssh://deng.git.sourceforge.net/gitroot/deng/…
Browse files Browse the repository at this point in the history
…deng
  • Loading branch information
danij-deng committed Feb 13, 2012
2 parents b162493 + 18a0fbe commit ff34e0f
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 13 deletions.
3 changes: 3 additions & 0 deletions doomsday/engine/portable/include/gl_defer.h
Expand Up @@ -79,6 +79,9 @@ void GL_DeferTextureUpload(const struct texturecontent_s* content);
#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(i, GLenum e, GLint i);
LIBDENG_GL_DEFER2(f, GLenum e, GLfloat f);
LIBDENG_GL_DEFER2(fv4, GLenum e, const GLfloat* floatArrayFourValues);
LIBDENG_GL_DEFER2(uintArray, GLsizei count, const GLuint* values);

#endif /* LIBDENG_GL_DEFERRED_H */
6 changes: 6 additions & 0 deletions doomsday/engine/portable/include/gl_deferredapi.h
Expand Up @@ -41,10 +41,16 @@
#define glEnable(x) Deferred_glEnable(x)
#define glDisable(x) Deferred_glDisable(x)
#define glDeleteTextures(x, y) Deferred_glDeleteTextures(x, y)
#define glFogi(x, y) Deferred_glFogi(x, y)
#define glFogf(x, y) Deferred_glFogf(x, y)
#define glFogfv(x, y) Deferred_glFogfv(x, y)

void Deferred_glEnable(GLenum e);
void Deferred_glDisable(GLenum e);
void Deferred_glDeleteTextures(GLsizei num, const GLuint* names);
void Deferred_glFogi(GLenum p, GLint v);
void Deferred_glFogf(GLenum p, GLfloat v);
void Deferred_glFogfv(GLenum p, const GLfloat* v);

#endif

Expand Down
1 change: 0 additions & 1 deletion doomsday/engine/portable/src/bitmapfont.c
Expand Up @@ -406,7 +406,6 @@ void BitmapFont_DeleteGLTexture(font_t* font)
if(Con_IsBusy()) return;
if(bf->_tex)
{
LIBDENG_ASSERT_IN_MAIN_THREAD();
glDeleteTextures(1, (const GLuint*) &bf->_tex);
}
bf->_tex = 0;
Expand Down
4 changes: 0 additions & 4 deletions doomsday/engine/portable/src/con_busy.c
Expand Up @@ -362,8 +362,6 @@ static void Con_BusyDeleteTextures(void)
if(isDedicated)
return;

LIBDENG_ASSERT_IN_MAIN_THREAD();

glDeleteTextures(2, (const GLuint*) texLoading);
texLoading[0] = texLoading[1] = 0;

Expand Down Expand Up @@ -411,8 +409,6 @@ void Con_AcquireScreenshotTexture(void)

void Con_ReleaseScreenshotTexture(void)
{
LIBDENG_ASSERT_IN_MAIN_THREAD();

glDeleteTextures(1, (const GLuint*) &texScreenshot);
texScreenshot = 0;
}
Expand Down
2 changes: 0 additions & 2 deletions doomsday/engine/portable/src/dgl_common.c
Expand Up @@ -790,8 +790,6 @@ void DGL_DeleteTextures(int num, const DGLuint *names)
if(!num || !names)
return;

LIBDENG_ASSERT_IN_MAIN_THREAD();

glDeleteTextures(num, (const GLuint*) names);
}

Expand Down
59 changes: 58 additions & 1 deletion doomsday/engine/portable/src/gl_defer.c
Expand Up @@ -43,6 +43,9 @@ typedef enum {

DTT_FUNC_PTR_BEGIN,
DTT_FUNC_PTR_E = DTT_FUNC_PTR_BEGIN,
DTT_FUNC_PTR_EI,
DTT_FUNC_PTR_EF,
DTT_FUNC_PTR_EFV4,
DTT_FUNC_PTR_UINT_ARRAY,
DTT_FUNC_PTR_END,

Expand All @@ -60,10 +63,25 @@ typedef struct deferredtask_s {
typedef struct apifunc_s {
union {
void (GL_CALL *ptr_e)(GLenum);
void (GL_CALL *ptr_ei)(GLenum, GLint i);
void (GL_CALL *ptr_ef)(GLenum, GLfloat f);
void (GL_CALL *ptr_efv4)(GLenum, const GLfloat* fv4);
void (GL_CALL *ptr_uintArray)(GLsizei, const GLuint*);
} func;
union {
GLenum e;
struct {
GLenum e;
GLint i;
} ei;
struct {
GLenum e;
GLfloat f;
} ef;
struct {
GLenum e;
GLfloat fv4[4];
} efv4;
struct {
GLsizei count;
GLuint* values;
Expand Down Expand Up @@ -145,6 +163,33 @@ LIBDENG_GL_DEFER1(e, GLenum e)
enqueueTask(DTT_FUNC_PTR_E, api);
}

LIBDENG_GL_DEFER2(i, GLenum e, GLint i)
{
apifunc_t* api = malloc(sizeof(apifunc_t));
api->func.ptr_ei = ptr;
api->param.ei.e = e;
api->param.ei.i = i;
enqueueTask(DTT_FUNC_PTR_EI, api);
}

LIBDENG_GL_DEFER2(f, GLenum e, GLfloat f)
{
apifunc_t* api = malloc(sizeof(apifunc_t));
api->func.ptr_ef = ptr;
api->param.ef.e = e;
api->param.ef.f = f;
enqueueTask(DTT_FUNC_PTR_EF, api);
}

LIBDENG_GL_DEFER2(fv4, GLenum e, const GLfloat* floatArrayWithFourValues)
{
apifunc_t* api = malloc(sizeof(apifunc_t));
api->func.ptr_efv4 = ptr;
api->param.efv4.e = e;
memcpy(api->param.efv4.fv4, floatArrayWithFourValues, sizeof(GLfloat) * 4);
enqueueTask(DTT_FUNC_PTR_EFV4, api);
}

LIBDENG_GL_DEFER2(uintArray, GLsizei s, const GLuint* v)
{
apifunc_t* api = malloc(sizeof(apifunc_t));
Expand All @@ -171,6 +216,18 @@ static void processTask(deferredtask_t* task)
api->func.ptr_e(api->param.e);
break;

case DTT_FUNC_PTR_EI:
api->func.ptr_ei(api->param.ei.e, api->param.ei.i);
break;

case DTT_FUNC_PTR_EF:
api->func.ptr_ef(api->param.ef.e, api->param.ef.f);
break;

case DTT_FUNC_PTR_EFV4:
api->func.ptr_efv4(api->param.efv4.e, api->param.efv4.fv4);
break;

case DTT_FUNC_PTR_UINT_ARRAY:
api->func.ptr_uintArray(api->param.uintArray.count, api->param.uintArray.values);
break;
Expand Down Expand Up @@ -274,7 +331,7 @@ void GL_ReleaseReservedNames(void)
if(!inited)
return; // Just ignore.

LIBDENG_ASSERT_IN_MAIN_THREAD();
LIBDENG_ASSERT_IN_MAIN_THREAD(); // not deferring here

Sys_Lock(deferredMutex);
glDeleteTextures(reservedCount, (const GLuint*) reservedTextureNames);
Expand Down
15 changes: 15 additions & 0 deletions doomsday/engine/portable/src/gl_deferredapi.c
Expand Up @@ -49,3 +49,18 @@ void Deferred_glDeleteTextures(GLsizei num, const GLuint* names)
{
GL_CALL2(uintArray, glDeleteTextures, num, names);
}

void Deferred_glFogi(GLenum p, GLint v)
{
GL_CALL2(i, glFogi, p, v);
}

void Deferred_glFogf(GLenum p, GLfloat v)
{
GL_CALL2(f, glFogf, p, v);
}

void Deferred_glFogfv(GLenum p, const GLfloat* v)
{
GL_CALL2(fv4, glFogfv, p, v);
}
3 changes: 1 addition & 2 deletions doomsday/engine/portable/src/gl_main.c
Expand Up @@ -1341,8 +1341,6 @@ D_CMD(Fog)
return true;
}

LIBDENG_ASSERT_IN_MAIN_THREAD();

if(!stricmp(argv[1], "on"))
{
GL_UseFog(true);
Expand Down Expand Up @@ -1398,6 +1396,7 @@ D_CMD(Fog)
}
else
return false;

// Exit with a success.
return true;
}
3 changes: 0 additions & 3 deletions doomsday/engine/portable/src/gl_texmanager.c
Expand Up @@ -641,7 +641,6 @@ static int releaseVariantGLTexture(TextureVariant* variant, void* paramaters)
{
// Delete and mark it not-loaded.
DGLuint glName = TextureVariant_GLName(variant);
LIBDENG_ASSERT_IN_MAIN_THREAD();
glDeleteTextures(1, (const GLuint*) &glName);
TextureVariant_SetGLName(variant, 0);
TextureVariant_FlagUploaded(variant, false);
Expand Down Expand Up @@ -2970,8 +2969,6 @@ void GL_ReleaseTexturesForRawImages(void)
rawtex_t* r = (*ptr);
if(r->tex)
{
LIBDENG_ASSERT_IN_MAIN_THREAD();

glDeleteTextures(1, (const GLuint*) &r->tex);
r->tex = 0;
}
Expand Down

0 comments on commit ff34e0f

Please sign in to comment.