mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-12-01 00:12:27 +00:00
- reenabled the flat vertex buffer for GL 3.x NVidia hardware. On AMD and Intel it'll stay off because past tests have shown that it won't improve performance at all.
This commit is contained in:
parent
c1d8f235c2
commit
97341fcb31
4 changed files with 34 additions and 28 deletions
|
@ -96,7 +96,7 @@ 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;
|
mNumReserved = mIndex = mCurIndex = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -109,7 +109,7 @@ FFlatVertexBuffer::FFlatVertexBuffer()
|
||||||
}
|
}
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||||
glBufferData(GL_ARRAY_BUFFER, BUFFER_SIZE * sizeof(FFlatVertex), map, GL_STREAM_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, BUFFER_SIZE * sizeof(FFlatVertex), map, GL_STREAM_DRAW);
|
||||||
mIndex = mCurIndex = 20;
|
mNumReserved = mIndex = mCurIndex = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindVertexArray(vao_id);
|
glBindVertexArray(vao_id);
|
||||||
|
@ -390,6 +390,11 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane)
|
||||||
if (plane == sector_t::floor && sec->transdoor) vt->z -= 1;
|
if (plane == sector_t::floor && sec->transdoor) vt->z -= 1;
|
||||||
mapvt->z = vt->z;
|
mapvt->z = vt->z;
|
||||||
}
|
}
|
||||||
|
if (!(gl.flags & RFL_BUFFER_STORAGE))
|
||||||
|
{
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||||
|
glBufferSubData(GL_ARRAY_BUFFER, startvt * sizeof(FFlatVertex), countvt * sizeof(FFlatVertex), &vbo_shadowdata[startvt]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -400,12 +405,20 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane)
|
||||||
|
|
||||||
void FFlatVertexBuffer::CreateVBO()
|
void FFlatVertexBuffer::CreateVBO()
|
||||||
{
|
{
|
||||||
vbo_shadowdata.Clear();
|
if (!(gl.flags & RFL_NOBUFFER))
|
||||||
if (gl.flags & RFL_BUFFER_STORAGE)
|
|
||||||
{
|
{
|
||||||
|
vbo_shadowdata.Resize(mNumReserved);
|
||||||
CreateFlatVBO();
|
CreateFlatVBO();
|
||||||
memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex));
|
|
||||||
mCurIndex = mIndex = vbo_shadowdata.Size();
|
mCurIndex = mIndex = vbo_shadowdata.Size();
|
||||||
|
if (gl.flags & RFL_BUFFER_STORAGE)
|
||||||
|
{
|
||||||
|
memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||||
|
glBufferSubData(GL_ARRAY_BUFFER, mNumReserved * sizeof(FFlatVertex), (mIndex - mNumReserved) * sizeof(FFlatVertex), &vbo_shadowdata[mNumReserved]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (sectors)
|
else if (sectors)
|
||||||
{
|
{
|
||||||
|
@ -417,6 +430,7 @@ void FFlatVertexBuffer::CreateVBO()
|
||||||
sectors[i].vboheight[1] = sectors[i].vboheight[0] = FIXED_MIN;
|
sectors[i].vboheight[1] = sectors[i].vboheight[0] = FIXED_MIN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -427,39 +441,28 @@ void FFlatVertexBuffer::CreateVBO()
|
||||||
|
|
||||||
void FFlatVertexBuffer::CheckPlanes(sector_t *sector)
|
void FFlatVertexBuffer::CheckPlanes(sector_t *sector)
|
||||||
{
|
{
|
||||||
if (gl.flags & RFL_BUFFER_STORAGE)
|
if (sector->GetPlaneTexZ(sector_t::ceiling) != sector->vboheight[sector_t::ceiling])
|
||||||
{
|
{
|
||||||
if (sector->GetPlaneTexZ(sector_t::ceiling) != sector->vboheight[sector_t::ceiling])
|
UpdatePlaneVertices(sector, sector_t::ceiling);
|
||||||
{
|
sector->vboheight[sector_t::ceiling] = sector->GetPlaneTexZ(sector_t::ceiling);
|
||||||
//if (sector->ceilingdata == NULL) // only update if there's no thinker attached
|
}
|
||||||
{
|
if (sector->GetPlaneTexZ(sector_t::floor) != sector->vboheight[sector_t::floor])
|
||||||
UpdatePlaneVertices(sector, sector_t::ceiling);
|
{
|
||||||
sector->vboheight[sector_t::ceiling] = sector->GetPlaneTexZ(sector_t::ceiling);
|
UpdatePlaneVertices(sector, sector_t::floor);
|
||||||
}
|
sector->vboheight[sector_t::floor] = sector->GetPlaneTexZ(sector_t::floor);
|
||||||
}
|
|
||||||
if (sector->GetPlaneTexZ(sector_t::floor) != sector->vboheight[sector_t::floor])
|
|
||||||
{
|
|
||||||
//if (sector->floordata == NULL) // only update if there's no thinker attached
|
|
||||||
{
|
|
||||||
UpdatePlaneVertices(sector, sector_t::floor);
|
|
||||||
sector->vboheight[sector_t::floor] = sector->GetPlaneTexZ(sector_t::floor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// checks the validity of all planes attached to this sector
|
// checks the validity of all planes attached to this sector
|
||||||
// and updates them if possible. Anything moving will not be
|
// and updates them if possible.
|
||||||
// updated unless it stops. This is to ensure that we never
|
|
||||||
// have to synchronize with the rendering process.
|
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void FFlatVertexBuffer::CheckUpdate(sector_t *sector)
|
void FFlatVertexBuffer::CheckUpdate(sector_t *sector)
|
||||||
{
|
{
|
||||||
if (gl.flags & RFL_BUFFER_STORAGE)
|
if (!(gl.flags & RFL_NOBUFFER))
|
||||||
{
|
{
|
||||||
CheckPlanes(sector);
|
CheckPlanes(sector);
|
||||||
sector_t *hs = sector->GetHeightSec();
|
sector_t *hs = sector->GetHeightSec();
|
||||||
|
|
|
@ -47,6 +47,7 @@ class FFlatVertexBuffer : public FVertexBuffer
|
||||||
FFlatVertex *map;
|
FFlatVertex *map;
|
||||||
unsigned int mIndex;
|
unsigned int mIndex;
|
||||||
unsigned int mCurIndex;
|
unsigned int mCurIndex;
|
||||||
|
unsigned int mNumReserved;
|
||||||
|
|
||||||
void CheckPlanes(sector_t *sector);
|
void CheckPlanes(sector_t *sector);
|
||||||
|
|
||||||
|
|
|
@ -129,8 +129,9 @@ void gl_LoadExtensions()
|
||||||
gl.version = strtod(version, NULL) + 0.01f;
|
gl.version = strtod(version, NULL) + 0.01f;
|
||||||
gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL) + 0.01f;
|
gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL) + 0.01f;
|
||||||
|
|
||||||
gl.vendorstring=(char*)glGetString(GL_VENDOR);
|
gl.vendorstring = (char*)glGetString(GL_VENDOR);
|
||||||
|
|
||||||
|
if (!strstr(gl.vendorstring, "NVIDIA Corporation")); gl.flags |= RFL_NOBUFFER;
|
||||||
if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION;
|
if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION;
|
||||||
if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC;
|
if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC;
|
||||||
if (CheckExtension("GL_ARB_buffer_storage") && !Args->CheckParm("-nopersistentbuffers"))
|
if (CheckExtension("GL_ARB_buffer_storage") && !Args->CheckParm("-nopersistentbuffers"))
|
||||||
|
|
|
@ -14,6 +14,7 @@ enum RenderFlags
|
||||||
RFL_SHADER_STORAGE_BUFFER = 16, // to be used later for a parameter buffer
|
RFL_SHADER_STORAGE_BUFFER = 16, // to be used later for a parameter buffer
|
||||||
RFL_BASEINDEX = 32, // currently unused
|
RFL_BASEINDEX = 32, // currently unused
|
||||||
RFL_COREPROFILE = 64,
|
RFL_COREPROFILE = 64,
|
||||||
|
RFL_NOBUFFER = 128, // the static buffer makes no sense on GL 3.x AMD and Intel hardware, as long as compatibility mode is on
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TexMode
|
enum TexMode
|
||||||
|
|
Loading…
Reference in a new issue