From d84d103b03a5f4c84f8acac6807c21ba1912149e Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Tue, 9 Dec 2014 18:21:07 +0100 Subject: [PATCH] Wrap azdo check into a function call --- src/graphics/glwrap.cpp | 11 ----------- src/graphics/irr_driver.cpp | 5 +++++ src/graphics/irr_driver.hpp | 11 +++++++++++ src/graphics/render.cpp | 2 +- src/graphics/render_geometry.cpp | 22 +++++++++++----------- src/graphics/shaders.cpp | 4 ++-- src/graphics/stkmesh.cpp | 4 ++-- src/graphics/stkmeshscenenode.cpp | 8 ++++---- src/graphics/stkscenemanager.cpp | 8 ++++---- 9 files changed, 40 insertions(+), 35 deletions(-) diff --git a/src/graphics/glwrap.cpp b/src/graphics/glwrap.cpp index c86f005f2..ad55cf9df 100644 --- a/src/graphics/glwrap.cpp +++ b/src/graphics/glwrap.cpp @@ -46,17 +46,6 @@ debugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei le return; } - // Suppress warnings about GL_ARB_bindless_texture not being supported - // when we're not even using it - if (UserConfigParams::m_azdo == false && - source == GL_DEBUG_SOURCE_SHADER_COMPILER_ARB && msg != NULL && - std::string(msg).find("GL_ARB_bindless_texture") != std::string::npos) - { - Log::debug("GLWrap", "Suppressed warning: %s", msg); - return; - } - - switch(source) { case GL_DEBUG_SOURCE_API_ARB: diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 5869cb7a3..202ff660e 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -534,6 +534,7 @@ void IrrDriver::initDevice() hasComputeShaders = false; hasTextureStorage = false; hasTextureView = false; + hasBindlessTexture = false; // Default false value for hasVSLayer if --no-graphics argument is used #if !defined(__APPLE__) if (!ProfileWorld::isNoGraphics()) @@ -566,6 +567,10 @@ void IrrDriver::initDevice() hasTextureView = true; Log::info("GLDriver", "ARB Texture View enabled"); } + if (hasGLExtension("GL_ARB_bindless_texture")) { + hasBindlessTexture = true; + Log::info("GLDriver", "ARB Bindless Texture enabled"); + } m_support_sdsm = m_support_sdsm && hasComputeShaders && hasBuffserStorage; std::string driver((char*)(glGetString(GL_VERSION))); diff --git a/src/graphics/irr_driver.hpp b/src/graphics/irr_driver.hpp index 4a61355b8..04c5bd8a5 100644 --- a/src/graphics/irr_driver.hpp +++ b/src/graphics/irr_driver.hpp @@ -191,6 +191,7 @@ private: bool hasComputeShaders; bool hasTextureStorage; bool hasTextureView; + bool hasBindlessTexture; bool m_support_sdsm; bool m_support_texture_compression; bool m_need_ubo_workaround; @@ -297,6 +298,11 @@ public: return UserConfigParams::m_texture_compression && m_support_texture_compression; } + bool useAZDO() const + { + return hasBindlessTexture && UserConfigParams::m_azdo; + } + bool needUBOWorkaround() const { return m_need_ubo_workaround; @@ -347,6 +353,11 @@ public: return hasTextureView; } + bool hasARBBindlessTexture() const + { + return hasBindlessTexture; + } + video::SColorf getAmbientLight() const; struct GlowData { diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp index ee278aa9f..4afb5e1b1 100644 --- a/src/graphics/render.cpp +++ b/src/graphics/render.cpp @@ -1031,7 +1031,7 @@ void IrrDriver::renderGlow(std::vector& glows) glUseProgram(MeshShader::InstancedColorizeShader::getInstance()->Program); glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(video::EVT_STANDARD, InstanceTypeGlow)); - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) { if (GlowPassCmd::getInstance()->Size) { diff --git a/src/graphics/render_geometry.cpp b/src/graphics/render_geometry.cpp index 37089a38a..51527bd13 100644 --- a/src/graphics/render_geometry.cpp +++ b/src/graphics/render_geometry.cpp @@ -427,7 +427,7 @@ void renderMeshes1stPass() continue; } - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) HandleExpander::template Expand(mesh.TextureHandles, T::FirstPassTextures); else TexExpander::template ExpandTex(mesh, T::FirstPassTextures); @@ -500,7 +500,7 @@ void IrrDriver::renderSolidFirstPass() renderMeshes1stPass(); renderMeshes1stPass(); - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) { multidraw1stPass(); multidraw1stPass(); @@ -546,7 +546,7 @@ void renderMeshes2ndPass( const std::vector &Prefilled_Handle, continue; } - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) HandleExpander::template Expand(mesh.TextureHandles, T::SecondPassTextures, Prefilled_Handle[0], Prefilled_Handle[1], Prefilled_Handle[2]); else TexExpander::template ExpandTex(mesh, T::SecondPassTextures, Prefilled_Tex[0], Prefilled_Tex[1], Prefilled_Tex[2]); @@ -595,7 +595,7 @@ void IrrDriver::renderSolidSecondPass() uint64_t DiffuseHandle = 0, SpecularHandle = 0, SSAOHandle = 0, DepthHandle = 0; - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) { DiffuseHandle = glGetTextureSamplerHandleARB(m_rtts->getRenderTarget(RTT_DIFFUSE), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[0]); if (!glIsTextureHandleResidentARB(DiffuseHandle)) @@ -633,7 +633,7 @@ void IrrDriver::renderSolidSecondPass() renderMeshes2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex); renderMeshes2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex); - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) { multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); @@ -714,7 +714,7 @@ static void renderMultiMeshNormals() void IrrDriver::renderNormalsVisualisation() { - if (UserConfigParams::m_azdo) { + if (irr_driver->useAZDO()) { renderMultiMeshNormals(); renderMultiMeshNormals(); renderMultiMeshNormals(); @@ -752,7 +752,7 @@ void renderTransparenPass(const std::vector &TexUnits, std::vectoruseAZDO()) Shader::getInstance()->SetTextureHandles(mesh.TextureHandles[0]); else Shader::getInstance()->SetTextureUnits(getTextureGLuint(mesh.textures[0])); @@ -932,7 +932,7 @@ void renderShadow(unsigned cascade) GLMesh *mesh = STK::tuple_get<0>(t.at(i)); if (!irr_driver->hasARB_base_instance()) glBindVertexArray(mesh->vao); - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) HandleExpander::template Expand(mesh->TextureHandles, T::ShadowTextures); else TexExpander::template ExpandTex(*mesh, T::ShadowTextures); @@ -1004,7 +1004,7 @@ void IrrDriver::renderShadows() if (irr_driver->hasARB_draw_indirect()) glBindBuffer(GL_DRAW_INDIRECT_BUFFER, ShadowPassCmd::getInstance()->drawindirectcmd); - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) { multidrawShadow(cascade); multidrawShadow(cascade); @@ -1081,7 +1081,7 @@ void drawRSM(const core::matrix4 & rsm_matrix) GLMesh *mesh = STK::tuple_get<0>(t.at(i)); if (!irr_driver->hasARB_base_instance()) glBindVertexArray(mesh->vao); - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) HandleExpander::template Expand(mesh->TextureHandles, T::RSMTextures); else TexExpander::template ExpandTex(*mesh, T::RSMTextures); @@ -1138,7 +1138,7 @@ void IrrDriver::renderRSM() if (irr_driver->hasARB_draw_indirect()) glBindBuffer(GL_DRAW_INDIRECT_BUFFER, RSMPassCmd::getInstance()->drawindirectcmd); - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) { multidrawRSM(rsm_matrix); multidrawRSM(rsm_matrix); diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index 661f86966..9b4bf7cc9 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -147,9 +147,9 @@ GLuint LoadShader(const char * file, unsigned type) char versionString[20]; sprintf(versionString, "#version %d\n", irr_driver->getGLSLVersion()); std::string Code = versionString; - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) Code += "#extension GL_ARB_bindless_texture : enable\n"; - else + else if (irr_driver->hasARBBindlessTexture()) { Code += "#extension GL_ARB_bindless_texture : disable\n"; Code += "#undef GL_ARB_bindless_texture\n"; diff --git a/src/graphics/stkmesh.cpp b/src/graphics/stkmesh.cpp index 3047c0876..b9be53e98 100644 --- a/src/graphics/stkmesh.cpp +++ b/src/graphics/stkmesh.cpp @@ -286,7 +286,7 @@ SetTexture(GLMesh &mesh, unsigned i, bool isSrgb, const std::string &matname) return; } compressTexture(mesh.textures[i], isSrgb); - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) { if (!mesh.TextureHandles[i]) mesh.TextureHandles[i] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[i]), MeshShader::ObjectPass1Shader::getInstance()->SamplersId[0]); @@ -359,7 +359,7 @@ void InitTexturesTransparent(GLMesh &mesh) return; } compressTexture(mesh.textures[0], true); - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) { if (!mesh.TextureHandles[0]) mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::ObjectPass1Shader::getInstance()->SamplersId[0]); diff --git a/src/graphics/stkmeshscenenode.cpp b/src/graphics/stkmeshscenenode.cpp index d609dd6bd..7dd7b1130 100644 --- a/src/graphics/stkmeshscenenode.cpp +++ b/src/graphics/stkmeshscenenode.cpp @@ -269,7 +269,7 @@ void STKMeshSceneNode::render() size_t count = mesh.IndexCount; compressTexture(mesh.textures[0], true); - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) { if (!mesh.TextureHandles[0]) mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::ObjectPass1Shader::getInstance()->SamplersId[0]); @@ -307,7 +307,7 @@ void STKMeshSceneNode::render() GLenum itype = mesh.IndexType; size_t count = mesh.IndexCount; - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) { GLuint64 DiffuseHandle = glGetTextureSamplerHandleARB(irr_driver->getRenderTargetTexture(RTT_DIFFUSE), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[0]); if (!glIsTextureHandleResidentARB(DiffuseHandle)) @@ -403,7 +403,7 @@ void STKMeshSceneNode::render() tmpcol.getBlue() / 255.0f); compressTexture(mesh.textures[0], true); - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) { if (!mesh.TextureHandles[0]) mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentFogShader::getInstance()->SamplersId[0]); @@ -433,7 +433,7 @@ void STKMeshSceneNode::render() size_t count = mesh.IndexCount; compressTexture(mesh.textures[0], true); - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) { if (!mesh.TextureHandles[0]) mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentShader::getInstance()->SamplersId[0]); diff --git a/src/graphics/stkscenemanager.cpp b/src/graphics/stkscenemanager.cpp index 5589ed039..9cc7eb46f 100644 --- a/src/graphics/stkscenemanager.cpp +++ b/src/graphics/stkscenemanager.cpp @@ -143,7 +143,7 @@ void FillInstances(const std::unordered_map(It->second, InstanceBuffer, CommandBuffer, InstanceBufferOffset, CommandBufferOffset, Polycount); - if (!UserConfigParams::m_azdo) + if (!irr_driver->useAZDO()) InstancedList.push_back(It->second.front().first); } } @@ -527,7 +527,7 @@ GenDrawCalls(unsigned cascade, std::vector &InstancedList, if (irr_driver->hasARB_draw_indirect()) ShadowPassCmd::getInstance()->Offset[cascade][Mat] = CommandBufferOffset; // Store command buffer offset FillInstances(MeshForShadowPass[Mat][cascade], InstancedList, InstanceBuffer, CommandBuffer, InstanceBufferOffset, CommandBufferOffset, PolyCount); - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) ShadowPassCmd::getInstance()->Size[cascade][Mat] = CommandBufferOffset - ShadowPassCmd::getInstance()->Offset[cascade][Mat]; } @@ -734,11 +734,11 @@ PROFILER_POP_CPU_MARKER(); { size_t Polycnt = 0; FillInstances_impl(It->second, GlowInstanceBuffer, GlowCmdBuffer, offset, current_cmd, Polycnt); - if (!UserConfigParams::m_azdo) + if (!irr_driver->useAZDO()) ListInstancedGlow::getInstance()->push_back(It->second.front().first); } - if (UserConfigParams::m_azdo) + if (irr_driver->useAZDO()) GlowPassCmd::getInstance()->Size = current_cmd - GlowPassCmd::getInstance()->Offset; if (!irr_driver->hasBufferStorageExtension())