- rewrote vertex buffer code to require GL_ARB_BUFFER_STORAGE extension.

This means it won't work anymore on anything that doesn't support OpenGL 4.0, but I don't think this is a problem. On older NVidia cards performance gains could not be seen and on older AMDs using the vertex buffer was even worse as long as it got mixed with immediate mode rendering.
This commit is contained in:
Christoph Oelckers 2014-05-10 21:47:07 +02:00
commit 7d3beb665b
9 changed files with 99 additions and 134 deletions

View file

@ -155,41 +155,28 @@ void gl_LoadExtensions()
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 (strstr(gl.vendorstring, "NVIDIA")) gl.flags|=RFL_NVIDIA;
else if (strstr(gl.vendorstring, "ATI Technologies")) gl.flags|=RFL_ATI;
if (CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE;
if (strcmp(version, "2.0") >= 0) gl.flags|=RFL_GL_20;
if (strcmp(version, "2.1") >= 0) gl.flags|=RFL_GL_21;
if (strcmp(version, "3.0") >= 0) gl.flags|=RFL_GL_30;
gl.version = strtod((char*)glGetString(GL_VERSION), NULL);
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if (gl.flags & RFL_GL_20)
{
// Rules:
// SM4 will always use shaders. No option to switch them off is needed here.
// SM3 has shaders optional but they are off by default (they will have a performance impact
// SM2 only uses shaders for colormaps on camera textures and has no option to use them in general.
// On SM2 cards the shaders will be too slow and show visual bugs (at least on GF 6800.)
if (strcmp((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION), "1.3") >= 0) gl.shadermodel = 4;
else if (CheckExtension("GL_NV_GPU_shader4")) gl.shadermodel = 4; // for pre-3.0 drivers that support GF8xxx.
else if (CheckExtension("GL_EXT_GPU_shader4")) gl.shadermodel = 4; // for pre-3.0 drivers that support GF8xxx.
else if (CheckExtension("GL_NV_vertex_program3")) gl.shadermodel = 3;
else if (!strstr(gl.vendorstring, "NVIDIA")) gl.shadermodel = 3;
else gl.shadermodel = 2; // Only for older NVidia cards which had notoriously bad shader support.
// Rules:
// SM4 will always use shaders. No option to switch them off is needed here.
// SM3 has shaders optional but they are off by default (they will have a performance impact
// SM2 only uses shaders for colormaps on camera textures and has no option to use them in general.
// On SM2 cards the shaders will be too slow and show visual bugs (at least on GF 6800.)
if (strcmp((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION), "1.3") >= 0) gl.shadermodel = 4;
else if (CheckExtension("GL_NV_vertex_program3")) gl.shadermodel = 3;
else if (!strstr(gl.vendorstring, "NVIDIA")) gl.shadermodel = 3;
else gl.shadermodel = 2; // Only for older NVidia cards which had notoriously bad shader support.
// Command line overrides for testing and problem cases.
if (Args->CheckParm("-sm2") && gl.shadermodel > 2) gl.shadermodel = 2;
else if (Args->CheckParm("-sm3") && gl.shadermodel > 3) gl.shadermodel = 3;
}
// Command line overrides for testing and problem cases.
if (Args->CheckParm("-sm2") && gl.shadermodel > 2) gl.shadermodel = 2;
else if (Args->CheckParm("-sm3") && gl.shadermodel > 3) gl.shadermodel = 3;
if (CheckExtension("GL_ARB_map_buffer_range"))
{
gl.flags|=RFL_MAP_BUFFER_RANGE;
}
if (gl.flags & RFL_GL_30)
if (gl.version >= 3.f)
{
gl.flags|=RFL_FRAMEBUFFER;
}