Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup|Refactor: Cleaned up the GL deferred tasks module
Getting it ready for deferred GL API calls.
- Loading branch information
Showing
3 changed files
with
100 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,73 @@ | ||
/**\file gl_defer.h | ||
*\section License | ||
* License: GPL | ||
* Online License Link: http://www.gnu.org/licenses/gpl.html | ||
/** | ||
* @file gl_defer.h | ||
* Deferred GL tasks. @ingroup gl | ||
* | ||
*\author Copyright © 2003-2012 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
*\author Copyright © 2006-2012 Daniel Swanson <danij@dengine.net> | ||
* GL is only available from the main thread. When accessed from other threads, | ||
* the operations need to be deferred for processing later in the main thread. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* @authors Copyright © 2003-2012 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* @authors Copyright © 2006-2012 Daniel Swanson <danij@dengine.net> | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
/** | ||
* Deferred GL Tasks. | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA</small> | ||
*/ | ||
|
||
#ifndef LIBDENG_GL_DEFERRED_H | ||
#define LIBDENG_GL_DEFERRED_H | ||
|
||
typedef enum { | ||
DEFERREDTASK_TYPES_FIRST = 0, | ||
DTT_UPLOAD_TEXTURECONTENT = DEFERREDTASK_TYPES_FIRST, | ||
DEFERREDTASK_TYPES_COUNT | ||
} deferredtask_type_t; | ||
struct texturecontent_s; | ||
|
||
#define VALID_DEFERREDTASK_TYPE(t) ((t) >= DEFERREDTASK_TYPES_FIRST || (t) < DEFERREDTASK_TYPES_COUNT) | ||
|
||
/// Initialize this module. | ||
/** | ||
* Initializes the deferred tasks module. | ||
*/ | ||
void GL_InitDeferredTask(void); | ||
|
||
/// Shutdown this module. | ||
/** | ||
* Shuts down the deferred tasks. | ||
*/ | ||
void GL_ShutdownDeferredTask(void); | ||
|
||
/// @return Number of waiting tasks else @c 0 | ||
int GL_DeferredTaskCount(void); | ||
|
||
/** | ||
* @param timeOutMilliSeconds Zero for no timeout. | ||
* Clears the currently queued GL tasks. They will not be executed. | ||
*/ | ||
void GL_ProcessDeferredTasks(uint timeOutMilliSeconds); | ||
|
||
void GL_PurgeDeferredTasks(void); | ||
|
||
/** | ||
* @param type Type of task to add. | ||
* @param data Caller-supplied additional data ptr, linked with the task. | ||
* @return Number of GL tasks waiting to be carried out. | ||
*/ | ||
void GL_EnqueueDeferredTask(deferredtask_type_t type, void* data); | ||
int GL_DeferredTaskCount(void); | ||
|
||
/** | ||
* Processes deferred GL tasks. This must be called from the main thread. | ||
* | ||
* @param timeOutMilliSeconds Processing will continue until this timeout expires. | ||
* Use zero for no timeout. | ||
*/ | ||
void GL_ProcessDeferredTasks(uint timeOutMilliSeconds); | ||
|
||
DGLuint GL_GetReservedTextureName(void); | ||
|
||
void GL_ReserveNames(void); | ||
|
||
void GL_ReleaseReservedNames(void); | ||
|
||
/** | ||
* Adds a new deferred texture upload task to the queue. | ||
* | ||
* @param content Texture content to upload. Caller can free its copy of the content; | ||
* a copy is made for the deferred task. | ||
*/ | ||
void GL_DeferTextureUpload(const struct texturecontent_s* content); | ||
|
||
#endif /* LIBDENG_GL_DEFERRED_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters