mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 23:32:04 +00:00
- allow different render modes if persistent buffers are not available (untested!)
This commit is contained in:
parent
e0b756e511
commit
6c9a818220
2 changed files with 28 additions and 6 deletions
|
@ -96,21 +96,21 @@ FFlatVertexBuffer::FFlatVertexBuffer()
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||||
glBufferStorage(GL_ARRAY_BUFFER, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
|
glBufferStorage(GL_ARRAY_BUFFER, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
|
||||||
map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
|
map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
|
||||||
|
mIndex = mCurIndex = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vbo_shadowdata.Reserve(BUFFER_SIZE);
|
vbo_shadowdata.Reserve(BUFFER_SIZE);
|
||||||
map = &vbo_shadowdata[0];
|
map = &vbo_shadowdata[0];
|
||||||
|
|
||||||
FFlatVertex fill[20];
|
|
||||||
for (int i = 0; i < 20; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
fill[i].Set(0, 0, 0, 100001.f, i);
|
map[i].Set(0, 0, 0, 100001.f, i);
|
||||||
}
|
}
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||||
glBufferData(GL_ARRAY_BUFFER, 20 * sizeof(FFlatVertex), fill, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, BUFFER_SIZE * sizeof(FFlatVertex), map, GL_STREAM_DRAW);
|
||||||
|
mIndex = mCurIndex = 20;
|
||||||
}
|
}
|
||||||
mIndex = mCurIndex = 0;
|
|
||||||
|
|
||||||
glBindVertexArray(vao_id);
|
glBindVertexArray(vao_id);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||||
|
@ -136,15 +136,23 @@ FFlatVertexBuffer::~FFlatVertexBuffer()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
CUSTOM_CVAR(Int, gl_rendermethod, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
CUSTOM_CVAR(Int, gl_rendermethod, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||||
{
|
{
|
||||||
|
int newself = self;
|
||||||
|
if (newself < 0) newself = 0;
|
||||||
|
if (newself == 0 && (gl.flags & RFL_COREPROFILE)) newself = 1;
|
||||||
|
if (newself > 3) newself = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count)
|
void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count)
|
||||||
{
|
{
|
||||||
|
// this will only get called if we can't acquire a persistently mapped buffer.
|
||||||
|
// Any of the provided methods are rather shitty, with immediate mode being the most reliable across different hardware.
|
||||||
|
// Still, allow this to be set per CVAR, just in case. Fortunately for newer hardware all this nonsense is not needed anymore.
|
||||||
switch (gl_rendermethod)
|
switch (gl_rendermethod)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
// trusty old immediate mode
|
||||||
#ifndef CORE_PROFILE
|
#ifndef CORE_PROFILE
|
||||||
if (!(gl.flags & RFL_COREPROFILE))
|
if (!(gl.flags & RFL_COREPROFILE))
|
||||||
{
|
{
|
||||||
|
@ -159,6 +167,7 @@ void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offs
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
case 1:
|
case 1:
|
||||||
|
// uniform array
|
||||||
if (count > 20)
|
if (count > 20)
|
||||||
{
|
{
|
||||||
int start = offset;
|
int start = offset;
|
||||||
|
@ -195,9 +204,21 @@ void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offs
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
// glBufferSubData
|
// glBufferSubData
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||||
|
glBufferSubData(GL_ARRAY_BUFFER, offset * sizeof(FFlatVertex), count * sizeof(FFlatVertex), &vbo_shadowdata[offset]);
|
||||||
|
glDrawArrays(primtype, offset, count);
|
||||||
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
// glMapBufferRange
|
// glMapBufferRange
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||||
|
void *p = glMapBufferRange(GL_ARRAY_BUFFER, offset * sizeof(FFlatVertex), count * sizeof(FFlatVertex), GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT);
|
||||||
|
if (p != NULL)
|
||||||
|
{
|
||||||
|
memcpy(p, &vbo_shadowdata[offset], count * sizeof(FFlatVertex));
|
||||||
|
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||||
|
glDrawArrays(primtype, offset, count);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ class FFlatVertexBuffer : public FVertexBuffer
|
||||||
void CheckPlanes(sector_t *sector);
|
void CheckPlanes(sector_t *sector);
|
||||||
|
|
||||||
const unsigned int BUFFER_SIZE = 2000000;
|
const unsigned int BUFFER_SIZE = 2000000;
|
||||||
|
const unsigned int BUFFER_SIZE_TO_USE = 1999500;
|
||||||
|
|
||||||
void ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count);
|
void ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count);
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ public:
|
||||||
unsigned int diff = newofs - mCurIndex;
|
unsigned int diff = newofs - mCurIndex;
|
||||||
*poffset = mCurIndex;
|
*poffset = mCurIndex;
|
||||||
mCurIndex = newofs;
|
mCurIndex = newofs;
|
||||||
if (mCurIndex >= BUFFER_SIZE) mCurIndex = mIndex;
|
if (mCurIndex >= BUFFER_SIZE_TO_USE) mCurIndex = mIndex;
|
||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
#ifdef __GL_PCH_H // we need the system includes for this but we cannot include them ourselves without creating #define clashes. The affected files wouldn't try to draw anyway.
|
#ifdef __GL_PCH_H // we need the system includes for this but we cannot include them ourselves without creating #define clashes. The affected files wouldn't try to draw anyway.
|
||||||
|
|
Loading…
Reference in a new issue