Polymer: upload bucket indices through pinned host memory.

git-svn-id: https://svn.eduke32.com/eduke32@5298 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
Plagman 2015-07-15 08:23:00 +00:00
parent ea2cabb8b3
commit f6d07d48ae
9 changed files with 10415 additions and 9949 deletions

View file

@ -78,6 +78,7 @@ struct glinfo_t {
char occlusionqueries;
char glsl;
char debugoutput;
char bufferstorage;
char dumped;
};

View file

@ -492,6 +492,14 @@ extern bglMapBufferARBProcPtr bglMapBufferARB;
typedef GLboolean (APIENTRY * bglUnmapBufferARBProcPtr)(GLenum target);
extern bglUnmapBufferARBProcPtr bglUnmapBufferARB;
// ARB_buffer_storage
typedef void (APIENTRY * bglBufferStorageProcPtr)(GLenum target, GLintptrARB size, const GLvoid * data, GLbitfield flags);
extern bglBufferStorageProcPtr bglBufferStorage;
// ARB_map_buffer_range
typedef void* (APIENTRY * bglMapBufferRangeProcPtr) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
extern bglMapBufferRangeProcPtr bglMapBufferRange;
// Occlusion queries
typedef void (APIENTRY * bglGenQueriesARBProcPtr)(GLsizei n, GLuint *ids);
extern bglGenQueriesARBProcPtr bglGenQueriesARB;

File diff suppressed because it is too large Load diff

View file

@ -202,6 +202,7 @@ typedef struct s_prbucket {
GLuint* indices;
uint32_t count;
uint32_t buffersize;
GLuint* indiceoffset;
struct s_prbucket* next;
} _prbucket;

View file

@ -435,6 +435,7 @@ int32_t osdcmd_glinfo(const osdfuncparm_t *parm)
" Occlusion queries: %s\n"
" GLSL: %s\n"
" Debug Output: %s\n"
" Buffer Storage: %s\n"
#endif
" Extensions:\n",
glinfo.maxanisotropy, glinfo.maxanisotropy>1.0?"":" (no anisotropic filtering)",
@ -456,7 +457,8 @@ int32_t osdcmd_glinfo(const osdfuncparm_t *parm)
glinfo.sm4 ? "supported": "not supported",
glinfo.occlusionqueries ? "supported": "not supported",
glinfo.glsl ? "supported": "not supported",
glinfo.debugoutput ? "supported": "not supported"
glinfo.debugoutput ? "supported": "not supported",
glinfo.bufferstorage ? "supported" : "not supported"
#endif
);

View file

@ -178,6 +178,12 @@ bglBufferSubDataARBProcPtr bglBufferSubDataARB;
bglMapBufferARBProcPtr bglMapBufferARB;
bglUnmapBufferARBProcPtr bglUnmapBufferARB;
// ARB_buffer_storage
bglBufferStorageProcPtr bglBufferStorage;
// ARB_map_buffer_range
bglMapBufferRangeProcPtr bglMapBufferRange;
// Occlusion queries
bglGenQueriesARBProcPtr bglGenQueriesARB;
bglDeleteQueriesARBProcPtr bglDeleteQueriesARB;
@ -579,6 +585,12 @@ int32_t loadglextensions(void)
bglMapBufferARB = (bglMapBufferARBProcPtr) GETPROCEXTSOFT("glMapBufferARB");
bglUnmapBufferARB = (bglUnmapBufferARBProcPtr) GETPROCEXTSOFT("glUnmapBufferARB");
// ARB_buffer_storage
bglBufferStorage = (bglBufferStorageProcPtr)GETPROCEXTSOFT("glBufferStorage");
// ARB_map_buffer_range
bglMapBufferRange = (bglMapBufferRangeProcPtr)GETPROCEXTSOFT("glMapBufferRange");
// Occlusion queries
bglGenQueriesARB = (bglGenQueriesARBProcPtr) GETPROCEXTSOFT("glGenQueriesARB");
bglDeleteQueriesARB = (bglDeleteQueriesARBProcPtr) GETPROCEXTSOFT("glDeleteQueriesARB");
@ -886,6 +898,12 @@ int32_t unloadgldriver(void)
bglMapBufferARB = (bglMapBufferARBProcPtr) NULL;
bglUnmapBufferARB = (bglUnmapBufferARBProcPtr) NULL;
// ARB_buffer_storage
bglBufferStorage = (bglBufferStorageProcPtr) NULL;
// ARB_map_buffer_range
bglMapBufferRange = (bglMapBufferRangeProcPtr)NULL;
// Occlusion queries
bglGenQueriesARB = (bglGenQueriesARBProcPtr) NULL;
bglDeleteQueriesARB = (bglDeleteQueriesARBProcPtr) NULL;

View file

@ -74,6 +74,13 @@ const GLsizeiptrARB proneplanesize = sizeof(_prvert) * 4;
const GLintptrARB prwalldatasize = sizeof(_prvert)* 4 * 3; // wall, over and mask planes for every wall
GLintptrARB prwalldataoffset;
GLuint prindexringvbo;
GLuint *prindexring;
const GLsizeiptrARB prindexringsize = 65535;
GLintptrARB prindexringoffset;
const GLbitfield prindexringmapflags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT;
_prbucket *prbuckethead;
int32_t prcanbucket;
@ -846,7 +853,7 @@ int32_t polymer_init(void)
if (glinfo.debugoutput) {
// Enable everything.
bglDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
bglDebugMessageCallbackARB(polymer_debugoutputcallback, NULL);
bglDebugMessageCallbackARB((GLDEBUGPROCARB)polymer_debugoutputcallback, NULL);
bglEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
}
#endif
@ -1023,6 +1030,14 @@ void polymer_loadboard(void)
bglBufferDataARB(GL_ARRAY_BUFFER_ARB, prwalldataoffset + (numwalls * prwalldatasize), NULL, mapvbousage);
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
bglGenBuffersARB(1, &prindexringvbo);
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, prindexringvbo);
bglBufferStorage(GL_ELEMENT_ARRAY_BUFFER, prindexringsize * sizeof(GLuint), NULL, prindexringmapflags | GL_DYNAMIC_STORAGE_BIT);
prindexring = (GLuint*)bglMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, prindexringsize * sizeof(GLuint), prindexringmapflags);
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
i = 0;
while (i < numsectors)
{
@ -1815,7 +1830,7 @@ static void polymer_displayrooms(const int16_t dacursectnum)
{
// if we have a level boundary somewhere in the sector,
// consider these walls as visportals
if (wall[sec->wallptr + i].nextsector < 0)
if (wall[sec->wallptr + i].nextsector < 0 && pr_buckets == 0)
doquery = 1;
}
while (--i >= 0);
@ -2123,6 +2138,46 @@ static void polymer_emptybuckets(void)
bglVertexPointer(3, GL_FLOAT, sizeof(_prvert), NULL);
bglTexCoordPointer(2, GL_FLOAT, sizeof(_prvert), (GLvoid *)(3 * sizeof(GLfloat)));
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, prindexringvbo);
uint32_t indexcount = 0;
while (bucket != NULL)
{
indexcount += bucket->count;
bucket = bucket->next;
}
// ensure space in index ring, wrap otherwise
if (indexcount + prindexringoffset >= prindexringsize)
{
bglUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER);
prindexring = (GLuint *)bglMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, prindexringsize * sizeof(GLuint), GL_MAP_INVALIDATE_BUFFER_BIT | prindexringmapflags);
prindexringoffset = 0;
}
// put indices in the ring, all at once
bucket = prbuckethead;
while (bucket != NULL)
{
if (bucket->count == 0)
{
bucket = bucket->next;
continue;
}
memcpy(&prindexring[prindexringoffset], bucket->indices, bucket->count * sizeof(GLuint));
bucket->indiceoffset = (GLuint*)(prindexringoffset * sizeof(GLuint));
prindexringoffset += bucket->count;
bucket = bucket->next;
}
bucket = prbuckethead;
while (bucket != NULL)
{
if (bucket->count == 0)
@ -2133,7 +2188,7 @@ static void polymer_emptybuckets(void)
int32_t materialbits = polymer_bindmaterial(&bucket->material, NULL, 0);
bglDrawElements(GL_TRIANGLES, bucket->count, GL_UNSIGNED_INT, bucket->indices);
bglDrawElements(GL_TRIANGLES, bucket->count, GL_UNSIGNED_INT, bucket->indiceoffset);
polymer_unbindmaterial(materialbits);
@ -2142,6 +2197,7 @@ static void polymer_emptybuckets(void)
bucket = bucket->next;
}
bglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
prcanbucket = 0;

View file

@ -1318,6 +1318,7 @@ void sdlayer_setvideomode_opengl(void)
glinfo.occlusionqueries = !!Bstrstr(glinfo.extensions, "GL_ARB_occlusion_query");
glinfo.glsl = !!Bstrstr(glinfo.extensions, "GL_ARB_shader_objects");
glinfo.debugoutput = !!Bstrstr(glinfo.extensions, "GL_ARB_debug_output");
glinfo.bufferstorage = !!Bstrstr(glinfo.extensions, "GL_ARB_buffer_storage");
if (Bstrstr(glinfo.extensions, "WGL_3DFX_gamma_control"))
{

View file

@ -2939,6 +2939,10 @@ static int32_t SetupOpenGL(int32_t width, int32_t height, int32_t bitspp)
{
glinfo.debugoutput = 1;
}
else if (!Bstrcmp((char *)p2, "GL_ARB_buffer_storage"))
{
glinfo.bufferstorage = 1;
}
}
Bfree(p);
}