diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 91c7f1c7e..19eb3b9e1 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -298,9 +298,9 @@ void GLFlat::DrawSubsectors(int pass, bool istrans) if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) { if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub); - //drawcalls.Clock(); + drawcalls.Clock(); glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines); - //drawcalls.Unclock(); + drawcalls.Unclock(); flatvertices += sub->numlines; flatprimitives++; } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index b056def8e..db3e68298 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -293,8 +293,18 @@ FShader *FShaderManager::Compile (const char *ShaderName, const char *ShaderPath void FShader::ApplyMatrices(VSMatrix *proj, VSMatrix *view) { - glProgramUniformMatrix4fv(hShader, projectionmatrix_index, 1, false, proj->get()); - glProgramUniformMatrix4fv(hShader, viewmatrix_index, 1, false, view->get()); + + if (gl.flags & RFL_SEPARATE_SHADER_OBJECTS) + { + glProgramUniformMatrix4fv(hShader, projectionmatrix_index, 1, false, proj->get()); + glProgramUniformMatrix4fv(hShader, viewmatrix_index, 1, false, view->get()); + } + else + { + Bind(); + glUniformMatrix4fv(projectionmatrix_index, 1, false, proj->get()); + glUniformMatrix4fv(viewmatrix_index, 1, false, view->get()); + } } @@ -486,7 +496,16 @@ void FShaderManager::SetWarpSpeed(unsigned int eff, float speed) FShader *sh = mTextureEffects[eff]; float warpphase = gl_frameMS * speed / 1000.f; - glProgramUniform1f(sh->GetHandle(), sh->timer_index, warpphase); + if (gl.flags & RFL_SEPARATE_SHADER_OBJECTS) + { + glProgramUniform1f(sh->GetHandle(), sh->timer_index, warpphase); + } + else + { + // not so pretty... + sh->Bind(); + glUniform1f(sh->timer_index, warpphase); + } } } diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index e1c70b14a..f00202fd8 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -133,6 +133,8 @@ 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 (CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE; + if (CheckExtension("GL_ARB_separate_shader_objects")) gl.flags |= RFL_SEPARATE_SHADER_OBJECTS; + glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 74beb72a4..0f569d2c4 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -9,9 +9,10 @@ enum RenderFlags RFL_TEXTURE_COMPRESSION=1, RFL_TEXTURE_COMPRESSION_S3TC=2, - RFL_BUFFER_STORAGE = 8, - RFL_SHADER_STORAGE_BUFFER = 16, - RFL_BASEINDEX = 32, + RFL_SEPARATE_SHADER_OBJECTS = 4, // we need this extension for glProgramUniform. On hardware not supporting it we need some rather clumsy workarounds + RFL_BUFFER_STORAGE = 8, // allows persistently mapped buffers, which are the only efficient way to actually use a dynamic vertex buffer. If this isn't present, a workaround with uniform arrays is used. + RFL_SHADER_STORAGE_BUFFER = 16, // to be used later for a parameter buffer + RFL_BASEINDEX = 32, // currently unused }; enum TexMode