Wrap azdo check into a function call

This commit is contained in:
Vincent Lejeune 2014-12-09 18:21:07 +01:00
parent d8e6ebbb0e
commit d84d103b03
9 changed files with 40 additions and 35 deletions

View File

@ -46,17 +46,6 @@ debugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei le
return; 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) switch(source)
{ {
case GL_DEBUG_SOURCE_API_ARB: case GL_DEBUG_SOURCE_API_ARB:

View File

@ -534,6 +534,7 @@ void IrrDriver::initDevice()
hasComputeShaders = false; hasComputeShaders = false;
hasTextureStorage = false; hasTextureStorage = false;
hasTextureView = false; hasTextureView = false;
hasBindlessTexture = false;
// Default false value for hasVSLayer if --no-graphics argument is used // Default false value for hasVSLayer if --no-graphics argument is used
#if !defined(__APPLE__) #if !defined(__APPLE__)
if (!ProfileWorld::isNoGraphics()) if (!ProfileWorld::isNoGraphics())
@ -566,6 +567,10 @@ void IrrDriver::initDevice()
hasTextureView = true; hasTextureView = true;
Log::info("GLDriver", "ARB Texture View enabled"); 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; m_support_sdsm = m_support_sdsm && hasComputeShaders && hasBuffserStorage;
std::string driver((char*)(glGetString(GL_VERSION))); std::string driver((char*)(glGetString(GL_VERSION)));

View File

@ -191,6 +191,7 @@ private:
bool hasComputeShaders; bool hasComputeShaders;
bool hasTextureStorage; bool hasTextureStorage;
bool hasTextureView; bool hasTextureView;
bool hasBindlessTexture;
bool m_support_sdsm; bool m_support_sdsm;
bool m_support_texture_compression; bool m_support_texture_compression;
bool m_need_ubo_workaround; bool m_need_ubo_workaround;
@ -297,6 +298,11 @@ public:
return UserConfigParams::m_texture_compression && m_support_texture_compression; return UserConfigParams::m_texture_compression && m_support_texture_compression;
} }
bool useAZDO() const
{
return hasBindlessTexture && UserConfigParams::m_azdo;
}
bool needUBOWorkaround() const bool needUBOWorkaround() const
{ {
return m_need_ubo_workaround; return m_need_ubo_workaround;
@ -347,6 +353,11 @@ public:
return hasTextureView; return hasTextureView;
} }
bool hasARBBindlessTexture() const
{
return hasBindlessTexture;
}
video::SColorf getAmbientLight() const; video::SColorf getAmbientLight() const;
struct GlowData { struct GlowData {

View File

@ -1031,7 +1031,7 @@ void IrrDriver::renderGlow(std::vector<GlowData>& glows)
glUseProgram(MeshShader::InstancedColorizeShader::getInstance()->Program); glUseProgram(MeshShader::InstancedColorizeShader::getInstance()->Program);
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(video::EVT_STANDARD, InstanceTypeGlow)); glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(video::EVT_STANDARD, InstanceTypeGlow));
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
{ {
if (GlowPassCmd::getInstance()->Size) if (GlowPassCmd::getInstance()->Size)
{ {

View File

@ -427,7 +427,7 @@ void renderMeshes1stPass()
continue; continue;
} }
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
HandleExpander<typename T::FirstPassShader>::template Expand(mesh.TextureHandles, T::FirstPassTextures); HandleExpander<typename T::FirstPassShader>::template Expand(mesh.TextureHandles, T::FirstPassTextures);
else else
TexExpander<typename T::FirstPassShader>::template ExpandTex(mesh, T::FirstPassTextures); TexExpander<typename T::FirstPassShader>::template ExpandTex(mesh, T::FirstPassTextures);
@ -500,7 +500,7 @@ void IrrDriver::renderSolidFirstPass()
renderMeshes1stPass<SphereMap, 2, 1>(); renderMeshes1stPass<SphereMap, 2, 1>();
renderMeshes1stPass<DetailMat, 2, 1>(); renderMeshes1stPass<DetailMat, 2, 1>();
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
{ {
multidraw1stPass<DefaultMaterial>(); multidraw1stPass<DefaultMaterial>();
multidraw1stPass<AlphaRef>(); multidraw1stPass<AlphaRef>();
@ -546,7 +546,7 @@ void renderMeshes2ndPass( const std::vector<uint64_t> &Prefilled_Handle,
continue; continue;
} }
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
HandleExpander<typename T::SecondPassShader>::template Expand(mesh.TextureHandles, T::SecondPassTextures, Prefilled_Handle[0], Prefilled_Handle[1], Prefilled_Handle[2]); HandleExpander<typename T::SecondPassShader>::template Expand(mesh.TextureHandles, T::SecondPassTextures, Prefilled_Handle[0], Prefilled_Handle[1], Prefilled_Handle[2]);
else else
TexExpander<typename T::SecondPassShader>::template ExpandTex(mesh, T::SecondPassTextures, Prefilled_Tex[0], Prefilled_Tex[1], Prefilled_Tex[2]); TexExpander<typename T::SecondPassShader>::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; 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]); DiffuseHandle = glGetTextureSamplerHandleARB(m_rtts->getRenderTarget(RTT_DIFFUSE), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(DiffuseHandle)) if (!glIsTextureHandleResidentARB(DiffuseHandle))
@ -633,7 +633,7 @@ void IrrDriver::renderSolidSecondPass()
renderMeshes2ndPass<GrassMat, 3, 1>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex); renderMeshes2ndPass<GrassMat, 3, 1>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderMeshes2ndPass<NormalMat, 3, 1>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex); renderMeshes2ndPass<NormalMat, 3, 1>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
{ {
multidraw2ndPass<DefaultMaterial>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); multidraw2ndPass<DefaultMaterial>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0));
multidraw2ndPass<AlphaRef>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); multidraw2ndPass<AlphaRef>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0));
@ -714,7 +714,7 @@ static void renderMultiMeshNormals()
void IrrDriver::renderNormalsVisualisation() void IrrDriver::renderNormalsVisualisation()
{ {
if (UserConfigParams::m_azdo) { if (irr_driver->useAZDO()) {
renderMultiMeshNormals<DefaultMaterial>(); renderMultiMeshNormals<DefaultMaterial>();
renderMultiMeshNormals<AlphaRef>(); renderMultiMeshNormals<AlphaRef>();
renderMultiMeshNormals<UnlitMat>(); renderMultiMeshNormals<UnlitMat>();
@ -752,7 +752,7 @@ void renderTransparenPass(const std::vector<TexUnit> &TexUnits, std::vector<STK:
continue; continue;
} }
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
Shader::getInstance()->SetTextureHandles(mesh.TextureHandles[0]); Shader::getInstance()->SetTextureHandles(mesh.TextureHandles[0]);
else else
Shader::getInstance()->SetTextureUnits(getTextureGLuint(mesh.textures[0])); Shader::getInstance()->SetTextureUnits(getTextureGLuint(mesh.textures[0]));
@ -932,7 +932,7 @@ void renderShadow(unsigned cascade)
GLMesh *mesh = STK::tuple_get<0>(t.at(i)); GLMesh *mesh = STK::tuple_get<0>(t.at(i));
if (!irr_driver->hasARB_base_instance()) if (!irr_driver->hasARB_base_instance())
glBindVertexArray(mesh->vao); glBindVertexArray(mesh->vao);
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
HandleExpander<typename T::ShadowPassShader>::template Expand(mesh->TextureHandles, T::ShadowTextures); HandleExpander<typename T::ShadowPassShader>::template Expand(mesh->TextureHandles, T::ShadowTextures);
else else
TexExpander<typename T::ShadowPassShader>::template ExpandTex(*mesh, T::ShadowTextures); TexExpander<typename T::ShadowPassShader>::template ExpandTex(*mesh, T::ShadowTextures);
@ -1004,7 +1004,7 @@ void IrrDriver::renderShadows()
if (irr_driver->hasARB_draw_indirect()) if (irr_driver->hasARB_draw_indirect())
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, ShadowPassCmd::getInstance()->drawindirectcmd); glBindBuffer(GL_DRAW_INDIRECT_BUFFER, ShadowPassCmd::getInstance()->drawindirectcmd);
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
{ {
multidrawShadow<DefaultMaterial>(cascade); multidrawShadow<DefaultMaterial>(cascade);
multidrawShadow<DetailMat>(cascade); multidrawShadow<DetailMat>(cascade);
@ -1081,7 +1081,7 @@ void drawRSM(const core::matrix4 & rsm_matrix)
GLMesh *mesh = STK::tuple_get<0>(t.at(i)); GLMesh *mesh = STK::tuple_get<0>(t.at(i));
if (!irr_driver->hasARB_base_instance()) if (!irr_driver->hasARB_base_instance())
glBindVertexArray(mesh->vao); glBindVertexArray(mesh->vao);
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
HandleExpander<typename T::RSMShader>::template Expand(mesh->TextureHandles, T::RSMTextures); HandleExpander<typename T::RSMShader>::template Expand(mesh->TextureHandles, T::RSMTextures);
else else
TexExpander<typename T::RSMShader>::template ExpandTex(*mesh, T::RSMTextures); TexExpander<typename T::RSMShader>::template ExpandTex(*mesh, T::RSMTextures);
@ -1138,7 +1138,7 @@ void IrrDriver::renderRSM()
if (irr_driver->hasARB_draw_indirect()) if (irr_driver->hasARB_draw_indirect())
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, RSMPassCmd::getInstance()->drawindirectcmd); glBindBuffer(GL_DRAW_INDIRECT_BUFFER, RSMPassCmd::getInstance()->drawindirectcmd);
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
{ {
multidrawRSM<DefaultMaterial>(rsm_matrix); multidrawRSM<DefaultMaterial>(rsm_matrix);
multidrawRSM<NormalMat>(rsm_matrix); multidrawRSM<NormalMat>(rsm_matrix);

View File

@ -147,9 +147,9 @@ GLuint LoadShader(const char * file, unsigned type)
char versionString[20]; char versionString[20];
sprintf(versionString, "#version %d\n", irr_driver->getGLSLVersion()); sprintf(versionString, "#version %d\n", irr_driver->getGLSLVersion());
std::string Code = versionString; std::string Code = versionString;
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
Code += "#extension GL_ARB_bindless_texture : enable\n"; Code += "#extension GL_ARB_bindless_texture : enable\n";
else else if (irr_driver->hasARBBindlessTexture())
{ {
Code += "#extension GL_ARB_bindless_texture : disable\n"; Code += "#extension GL_ARB_bindless_texture : disable\n";
Code += "#undef GL_ARB_bindless_texture\n"; Code += "#undef GL_ARB_bindless_texture\n";

View File

@ -286,7 +286,7 @@ SetTexture(GLMesh &mesh, unsigned i, bool isSrgb, const std::string &matname)
return; return;
} }
compressTexture(mesh.textures[i], isSrgb); compressTexture(mesh.textures[i], isSrgb);
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
{ {
if (!mesh.TextureHandles[i]) if (!mesh.TextureHandles[i])
mesh.TextureHandles[i] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[i]), MeshShader::ObjectPass1Shader::getInstance()->SamplersId[0]); mesh.TextureHandles[i] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[i]), MeshShader::ObjectPass1Shader::getInstance()->SamplersId[0]);
@ -359,7 +359,7 @@ void InitTexturesTransparent(GLMesh &mesh)
return; return;
} }
compressTexture(mesh.textures[0], true); compressTexture(mesh.textures[0], true);
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
{ {
if (!mesh.TextureHandles[0]) if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::ObjectPass1Shader::getInstance()->SamplersId[0]); mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::ObjectPass1Shader::getInstance()->SamplersId[0]);

View File

@ -269,7 +269,7 @@ void STKMeshSceneNode::render()
size_t count = mesh.IndexCount; size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true); compressTexture(mesh.textures[0], true);
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
{ {
if (!mesh.TextureHandles[0]) if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::ObjectPass1Shader::getInstance()->SamplersId[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; GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount; 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]); GLuint64 DiffuseHandle = glGetTextureSamplerHandleARB(irr_driver->getRenderTargetTexture(RTT_DIFFUSE), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(DiffuseHandle)) if (!glIsTextureHandleResidentARB(DiffuseHandle))
@ -403,7 +403,7 @@ void STKMeshSceneNode::render()
tmpcol.getBlue() / 255.0f); tmpcol.getBlue() / 255.0f);
compressTexture(mesh.textures[0], true); compressTexture(mesh.textures[0], true);
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
{ {
if (!mesh.TextureHandles[0]) if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentFogShader::getInstance()->SamplersId[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; size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true); compressTexture(mesh.textures[0], true);
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
{ {
if (!mesh.TextureHandles[0]) if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentShader::getInstance()->SamplersId[0]); mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentShader::getInstance()->SamplersId[0]);

View File

@ -143,7 +143,7 @@ void FillInstances(const std::unordered_map<scene::IMeshBuffer *, std::vector<st
for (; It != E; ++It) for (; It != E; ++It)
{ {
FillInstances_impl<T>(It->second, InstanceBuffer, CommandBuffer, InstanceBufferOffset, CommandBufferOffset, Polycount); FillInstances_impl<T>(It->second, InstanceBuffer, CommandBuffer, InstanceBufferOffset, CommandBufferOffset, Polycount);
if (!UserConfigParams::m_azdo) if (!irr_driver->useAZDO())
InstancedList.push_back(It->second.front().first); InstancedList.push_back(It->second.front().first);
} }
} }
@ -527,7 +527,7 @@ GenDrawCalls(unsigned cascade, std::vector<GLMesh *> &InstancedList,
if (irr_driver->hasARB_draw_indirect()) if (irr_driver->hasARB_draw_indirect())
ShadowPassCmd::getInstance()->Offset[cascade][Mat] = CommandBufferOffset; // Store command buffer offset ShadowPassCmd::getInstance()->Offset[cascade][Mat] = CommandBufferOffset; // Store command buffer offset
FillInstances<T>(MeshForShadowPass[Mat][cascade], InstancedList, InstanceBuffer, CommandBuffer, InstanceBufferOffset, CommandBufferOffset, PolyCount); FillInstances<T>(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]; ShadowPassCmd::getInstance()->Size[cascade][Mat] = CommandBufferOffset - ShadowPassCmd::getInstance()->Offset[cascade][Mat];
} }
@ -734,11 +734,11 @@ PROFILER_POP_CPU_MARKER();
{ {
size_t Polycnt = 0; size_t Polycnt = 0;
FillInstances_impl<GlowInstanceData>(It->second, GlowInstanceBuffer, GlowCmdBuffer, offset, current_cmd, Polycnt); FillInstances_impl<GlowInstanceData>(It->second, GlowInstanceBuffer, GlowCmdBuffer, offset, current_cmd, Polycnt);
if (!UserConfigParams::m_azdo) if (!irr_driver->useAZDO())
ListInstancedGlow::getInstance()->push_back(It->second.front().first); ListInstancedGlow::getInstance()->push_back(It->second.front().first);
} }
if (UserConfigParams::m_azdo) if (irr_driver->useAZDO())
GlowPassCmd::getInstance()->Size = current_cmd - GlowPassCmd::getInstance()->Offset; GlowPassCmd::getInstance()->Size = current_cmd - GlowPassCmd::getInstance()->Offset;
if (!irr_driver->hasBufferStorageExtension()) if (!irr_driver->hasBufferStorageExtension())