From 0c99ee543ef936ef770f4b11fa77e08c2f736c1b Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 6 Jan 2020 20:53:34 -0800 Subject: Improved device feature reporting; added flags for query support --- .../GraphicsEngineOpenGL/src/GLContextAndroid.cpp | 32 +-------- Graphics/GraphicsEngineOpenGL/src/GLContextIOS.mm | 17 ----- .../GraphicsEngineOpenGL/src/GLContextLinux.cpp | 13 +--- .../GraphicsEngineOpenGL/src/GLContextMacOS.mm | 9 --- .../GraphicsEngineOpenGL/src/GLContextState.cpp | 2 +- .../GraphicsEngineOpenGL/src/GLContextWindows.cpp | 13 +--- .../src/PipelineStateGLImpl.cpp | 4 +- .../src/RenderDeviceGLImpl.cpp | 75 ++++++++++++++++++++-- Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp | 10 +-- 9 files changed, 88 insertions(+), 87 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp b/Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp index bc61774a..f222c43e 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp @@ -386,35 +386,9 @@ bool GLContext::Invalidate() void GLContext::FillDeviceCaps(DeviceCaps& deviceCaps) { - const auto* Extensions = (char*)glGetString(GL_EXTENSIONS); - LOG_INFO_MESSAGE("Supported extensions: \n", Extensions); - - deviceCaps.DevType = DeviceType::OpenGLES; - deviceCaps.MajorVersion = major_version_; - deviceCaps.MinorVersion = minor_version_; - bool IsGLES31OrAbove = (major_version_ >= 4 || (major_version_ == 3 && minor_version_ >= 1)); - bool IsGLES32OrAbove = (major_version_ >= 4 || (major_version_ == 3 && minor_version_ >= 2)); - deviceCaps.bSeparableProgramSupported = IsGLES31OrAbove || strstr(Extensions, "separate_shader_objects"); - deviceCaps.bIndirectRenderingSupported = IsGLES31OrAbove || strstr(Extensions, "draw_indirect"); - - deviceCaps.bComputeShadersSupported = IsGLES31OrAbove || strstr(Extensions, "compute_shader"); - deviceCaps.bGeometryShadersSupported = IsGLES32OrAbove || strstr(Extensions, "geometry_shader"); - deviceCaps.bTessellationSupported = IsGLES32OrAbove || strstr(Extensions, "tessellation_shader"); - - auto& SamCaps = deviceCaps.SamCaps; - SamCaps.bBorderSamplingModeSupported = GL_TEXTURE_BORDER_COLOR && (IsGLES32OrAbove || strstr(Extensions, "texture_border_clamp")); - SamCaps.bAnisotropicFilteringSupported = GL_TEXTURE_MAX_ANISOTROPY_EXT && (IsGLES31OrAbove || strstr(Extensions, "texture_filter_anisotropic")); - SamCaps.bLODBiasSupported = GL_TEXTURE_LOD_BIAS && IsGLES31OrAbove; - - auto& TexCaps = deviceCaps.TexCaps; - TexCaps.bTexture1DSupported = False; // Not supported in GLES 3.2 - TexCaps.bTexture1DArraySupported = False; // Not supported in GLES 3.2 - TexCaps.bTexture2DMSSupported = IsGLES31OrAbove || strstr(Extensions, "texture_storage_multisample"); - TexCaps.bTexture2DMSArraySupported = IsGLES32OrAbove || strstr(Extensions, "texture_storage_multisample_2d_array"); - TexCaps.bTextureViewSupported = IsGLES31OrAbove || strstr(Extensions, "texture_view"); - TexCaps.bCubemapArraysSupported = IsGLES32OrAbove || strstr(Extensions, "texture_cube_map_array"); - - deviceCaps.bMultithreadedResourceCreationSupported = False; + deviceCaps.DevType = DeviceType::OpenGLES; + deviceCaps.MajorVersion = major_version_; + deviceCaps.MinorVersion = minor_version_; } } // namespace Diligent diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextIOS.mm b/Graphics/GraphicsEngineOpenGL/src/GLContextIOS.mm index 812041c9..8001df5f 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLContextIOS.mm +++ b/Graphics/GraphicsEngineOpenGL/src/GLContextIOS.mm @@ -68,23 +68,6 @@ namespace Diligent deviceCaps.DevType = DeviceType::OpenGLES; deviceCaps.MajorVersion = MajorVersion; deviceCaps.MinorVersion = MinorVersion; - deviceCaps.bMultithreadedResourceCreationSupported = False; - deviceCaps.bIndirectRenderingSupported = False; - deviceCaps.bGeometryShadersSupported = False; - deviceCaps.bTessellationSupported = False; - deviceCaps.bWireframeFillSupported = False; - deviceCaps.bComputeShadersSupported = False; - - deviceCaps.SamCaps.bLODBiasSupported = False; - deviceCaps.SamCaps.bBorderSamplingModeSupported = False; - - deviceCaps.TexCaps.bTexture1DSupported = False; - deviceCaps.TexCaps.bCubemapArraysSupported = False; - deviceCaps.TexCaps.bTexture1DSupported = False; - deviceCaps.TexCaps.bTexture1DArraySupported = False; - deviceCaps.TexCaps.bTextureViewSupported = False; - deviceCaps.TexCaps.bTexture2DMSSupported = False; - deviceCaps.TexCaps.bTexture2DMSArraySupported = False; } GLContext::NativeGLContextType GLContext::GetCurrentNativeGLContext() diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextLinux.cpp b/Graphics/GraphicsEngineOpenGL/src/GLContextLinux.cpp index c67ec50b..df2b2617 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLContextLinux.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/GLContextLinux.cpp @@ -146,16 +146,9 @@ GLContext::GLContext(const EngineGLCreateInfo& InitAttribs, DeviceCaps& deviceCa if (glGetError() != GL_NO_ERROR) LOG_ERROR_MESSAGE("Failed to enable SRGB framebuffers"); - deviceCaps.DevType = DeviceType::OpenGL; - deviceCaps.MajorVersion = MajorVersion; - deviceCaps.MinorVersion = MinorVersion; - bool IsGL43OrAbove = MajorVersion >= 5 || MajorVersion == 4 && MinorVersion >= 3; - auto& TexCaps = deviceCaps.TexCaps; - TexCaps.bTexture2DMSSupported = IsGL43OrAbove; - TexCaps.bTexture2DMSArraySupported = IsGL43OrAbove; - TexCaps.bTextureViewSupported = IsGL43OrAbove; - TexCaps.bCubemapArraysSupported = IsGL43OrAbove; - deviceCaps.bMultithreadedResourceCreationSupported = False; + deviceCaps.DevType = DeviceType::OpenGL; + deviceCaps.MajorVersion = MajorVersion; + deviceCaps.MinorVersion = MinorVersion; } GLContext::~GLContext() diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm b/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm index c12609fc..2d592b6d 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm +++ b/Graphics/GraphicsEngineOpenGL/src/GLContextMacOS.mm @@ -96,15 +96,6 @@ namespace Diligent DeviceCaps.DevType = DeviceType::OpenGL; DeviceCaps.MajorVersion = MajorVersion; DeviceCaps.MinorVersion = MinorVersion; - bool IsGL43OrAbove = MajorVersion >= 5 || (MajorVersion == 4 && MinorVersion >= 3); - bool IsGL42OrAbove = MajorVersion >= 5 || (MajorVersion == 4 && MinorVersion >= 2); - DeviceCaps.bComputeShadersSupported = IsGL42OrAbove; - auto &TexCaps = DeviceCaps.TexCaps; - TexCaps.bTexture2DMSSupported = IsGL43OrAbove; - TexCaps.bTexture2DMSArraySupported = IsGL43OrAbove; - TexCaps.bTextureViewSupported = IsGL43OrAbove; - TexCaps.bCubemapArraysSupported = IsGL43OrAbove; - DeviceCaps.bMultithreadedResourceCreationSupported = False; } GLContext::NativeGLContextType GLContext::GetCurrentNativeGLContext() diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp b/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp index 55b45a02..76a1a623 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp @@ -43,7 +43,7 @@ namespace Diligent GLContextState::GLContextState(RenderDeviceGLImpl* pDeviceGL) { const DeviceCaps& DeviceCaps = pDeviceGL->GetDeviceCaps(); - m_Caps.bFillModeSelectionSupported = DeviceCaps.bWireframeFillSupported; + m_Caps.bFillModeSelectionSupported = DeviceCaps.Features.WireframeFill; { m_Caps.m_iMaxCombinedTexUnits = 0; diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextWindows.cpp b/Graphics/GraphicsEngineOpenGL/src/GLContextWindows.cpp index b3c66afd..4dfdfc4e 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLContextWindows.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/GLContextWindows.cpp @@ -292,16 +292,9 @@ GLContext::GLContext(const EngineGLCreateInfo& InitAttribs, DeviceCaps& deviceCa if (glGetError() != GL_NO_ERROR) LOG_ERROR_MESSAGE("Failed to enable SRGB framebuffers"); - deviceCaps.DevType = DeviceType::OpenGL; - deviceCaps.MajorVersion = MajorVersion; - deviceCaps.MinorVersion = MinorVersion; - bool IsGL43OrAbove = MajorVersion >= 5 || MajorVersion == 4 && MinorVersion >= 3; - auto& TexCaps = deviceCaps.TexCaps; - TexCaps.bTexture2DMSSupported = IsGL43OrAbove; - TexCaps.bTexture2DMSArraySupported = IsGL43OrAbove; - TexCaps.bTextureViewSupported = IsGL43OrAbove; - TexCaps.bCubemapArraysSupported = IsGL43OrAbove; - deviceCaps.bMultithreadedResourceCreationSupported = False; + deviceCaps.DevType = DeviceType::OpenGL; + deviceCaps.MajorVersion = MajorVersion; + deviceCaps.MinorVersion = MinorVersion; } GLContext::~GLContext() diff --git a/Graphics/GraphicsEngineOpenGL/src/PipelineStateGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/PipelineStateGLImpl.cpp index f5f0cf4d..7e50c158 100644 --- a/Graphics/GraphicsEngineOpenGL/src/PipelineStateGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/PipelineStateGLImpl.cpp @@ -78,7 +78,7 @@ PipelineStateGLImpl::PipelineStateGLImpl(IReferenceCounters* pRefCounters, m_TotalSamplerBindings = 0; m_TotalImageBindings = 0; m_TotalStorageBufferBindings = 0; - if (DeviceCaps.bSeparableProgramSupported) + if (DeviceCaps.Features.SeparablePrograms) { // Program pipelines are not shared between GL contexts, so we cannot create // it now @@ -182,7 +182,7 @@ bool PipelineStateGLImpl::IsCompatibleWith(const IPipelineState* pPSO) const void PipelineStateGLImpl::CommitProgram(GLContextState& State) { - auto ProgramPipelineSupported = m_pDevice->GetDeviceCaps().bSeparableProgramSupported; + auto ProgramPipelineSupported = m_pDevice->GetDeviceCaps().Features.SeparablePrograms; if (ProgramPipelineSupported) { diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp index 6ee33d9c..091bb33b 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp @@ -111,6 +111,71 @@ RenderDeviceGLImpl::RenderDeviceGLImpl(IReferenceCounters* pRefCounters, m_GPUInfo.Vendor = GPU_VENDOR::QUALCOMM; m_DeviceCaps.AdaterType = ADAPTER_TYPE_HARDWARE; + + auto MajorVersion = m_DeviceCaps.MajorVersion; + auto MinorVersion = m_DeviceCaps.MinorVersion; + + auto& Features = m_DeviceCaps.Features; + auto& TexCaps = m_DeviceCaps.TexCaps; + if (m_DeviceCaps.DevType == DeviceType::OpenGL) + { + const bool IsGL43OrAbove = MajorVersion >= 5 || MajorVersion == 4 && MinorVersion >= 3; + + Features.SeparablePrograms = True; + Features.IndirectRendering = True; + Features.WireframeFill = True; + Features.MultithreadedResourceCreation = False; + Features.ComputeShaders = IsGL43OrAbove || CheckExtension("GL_ARB_compute_shader"); + Features.GeometryShaders = MajorVersion >= 4 || CheckExtension("GL_ARB_geometry_shader4"); + Features.Tessellation = MajorVersion >= 4 || CheckExtension("GL_ARB_tessellation_shader"); + Features.BindlessResources = False; + Features.OcclusionQueries = True; + Features.BinaryOcclusionQueries = True; + Features.TimestampQueries = True; + Features.PipelineStatisticsQueries = True; + + TexCaps.bTexture1DSupported = True; + TexCaps.bTexture1DArraySupported = True; + TexCaps.bTexture2DMSSupported = IsGL43OrAbove || CheckExtension("GL_ARB_texture_storage_multisample"); + TexCaps.bTexture2DMSArraySupported = IsGL43OrAbove || CheckExtension("GL_ARB_texture_storage_multisample"); + TexCaps.bTextureViewSupported = IsGL43OrAbove || CheckExtension("GL_ARB_texture_view"); + TexCaps.bCubemapArraysSupported = IsGL43OrAbove || CheckExtension("GL_ARB_texture_cube_map_array"); + } + else + { + const auto* Extensions = (char*)glGetString(GL_EXTENSIONS); + LOG_INFO_MESSAGE("Supported extensions: \n", Extensions); + + VERIFY(m_DeviceCaps.DevType == DeviceType::OpenGLES, "Unexpected device type: OpenGLES expected"); + + bool IsGLES31OrAbove = (MajorVersion >= 4 || (MajorVersion == 3 && MinorVersion >= 1)); + bool IsGLES32OrAbove = (MajorVersion >= 4 || (MajorVersion == 3 && MinorVersion >= 2)); + + Features.SeparablePrograms = IsGLES31OrAbove || strstr(Extensions, "separate_shader_objects"); + Features.IndirectRendering = IsGLES31OrAbove || strstr(Extensions, "draw_indirect"); + Features.WireframeFill = False; + Features.MultithreadedResourceCreation = False; + Features.ComputeShaders = IsGLES31OrAbove || strstr(Extensions, "compute_shader"); + Features.GeometryShaders = IsGLES32OrAbove || strstr(Extensions, "geometry_shader"); + Features.Tessellation = IsGLES32OrAbove || strstr(Extensions, "tessellation_shader"); + Features.BindlessResources = False; + Features.OcclusionQueries = False; + Features.BinaryOcclusionQueries = False; + Features.TimestampQueries = False; + Features.PipelineStatisticsQueries = False; + + TexCaps.bTexture1DSupported = False; // Not supported in GLES 3.2 + TexCaps.bTexture1DArraySupported = False; // Not supported in GLES 3.2 + TexCaps.bTexture2DMSSupported = IsGLES31OrAbove || strstr(Extensions, "texture_storage_multisample"); + TexCaps.bTexture2DMSArraySupported = IsGLES32OrAbove || strstr(Extensions, "texture_storage_multisample_2d_array"); + TexCaps.bTextureViewSupported = IsGLES31OrAbove || strstr(Extensions, "texture_view"); + TexCaps.bCubemapArraysSupported = IsGLES32OrAbove || strstr(Extensions, "texture_cube_map_array"); + + auto& SamCaps = m_DeviceCaps.SamCaps; + SamCaps.bBorderSamplingModeSupported = GL_TEXTURE_BORDER_COLOR && (IsGLES32OrAbove || strstr(Extensions, "texture_border_clamp")); + SamCaps.bAnisotropicFilteringSupported = GL_TEXTURE_MAX_ANISOTROPY_EXT && (IsGLES31OrAbove || strstr(Extensions, "texture_filter_anisotropic")); + SamCaps.bLODBiasSupported = GL_TEXTURE_LOD_BIAS && IsGLES31OrAbove; + } } RenderDeviceGLImpl::~RenderDeviceGLImpl() @@ -784,21 +849,21 @@ void RenderDeviceGLImpl::TestTextureFormat(TEXTURE_FORMAT TexFormat) void RenderDeviceGLImpl::QueryDeviceCaps() { if (glPolygonMode == nullptr) - m_DeviceCaps.bWireframeFillSupported = false; + m_DeviceCaps.Features.WireframeFill = false; - if (m_DeviceCaps.bWireframeFillSupported) + if (m_DeviceCaps.Features.WireframeFill) { // Test glPolygonMode() function to check if it fails // (It does fail on NVidia Shield tablet, but works fine // on Intel hw) VERIFY(glGetError() == GL_NO_ERROR, "Unhandled gl error encountered"); - m_DeviceCaps.bWireframeFillSupported = True; + m_DeviceCaps.Features.WireframeFill = True; glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); if (glGetError() != GL_NO_ERROR) - m_DeviceCaps.bWireframeFillSupported = False; + m_DeviceCaps.Features.WireframeFill = False; glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); if (glGetError() != GL_NO_ERROR) - m_DeviceCaps.bWireframeFillSupported = False; + m_DeviceCaps.Features.WireframeFill = False; } } diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp index e8fc1694..0479e80f 100644 --- a/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp @@ -53,7 +53,9 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters* pRefCounters, m_GLShaderObj{true, GLObjectWrappers::GLShaderObjCreateReleaseHelper{GetGLShaderType(m_Desc.ShaderType)}} // clang-format on { - auto GLSLSource = BuildGLSLSourceString(CreationAttribs, pDeviceGL->GetDeviceCaps(), TargetGLSLCompiler::driver); + const auto& deviceCaps = pDeviceGL->GetDeviceCaps(); + + auto GLSLSource = BuildGLSLSourceString(CreationAttribs, deviceCaps, TargetGLSLCompiler::driver); // Note: there is a simpler way to create the program: //m_uiShaderSeparateProg = glCreateShaderProgramv(GL_VERTEX_SHADER, _countof(ShaderStrings), ShaderStrings); @@ -125,7 +127,7 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters* pRefCounters, LOG_ERROR_AND_THROW(ErrorMsgSS.str().c_str()); } - if (pDeviceGL->GetDeviceCaps().bSeparableProgramSupported) + if (deviceCaps.Features.SeparablePrograms) { IShader* ThisShader[] = {this}; GLObjectWrappers::GLProgramObj Program = LinkProgram(ThisShader, 1, true); @@ -208,7 +210,7 @@ GLObjectWrappers::GLProgramObj ShaderGLImpl::LinkProgram(IShader** ppShaders, Ui Uint32 ShaderGLImpl::GetResourceCount() const { - if (m_pDevice->GetDeviceCaps().bSeparableProgramSupported) + if (m_pDevice->GetDeviceCaps().Features.SeparablePrograms) { return m_Resources.GetVariableCount(); } @@ -222,7 +224,7 @@ Uint32 ShaderGLImpl::GetResourceCount() const ShaderResourceDesc ShaderGLImpl::GetResource(Uint32 Index) const { ShaderResourceDesc ResourceDesc; - if (m_pDevice->GetDeviceCaps().bSeparableProgramSupported) + if (m_pDevice->GetDeviceCaps().Features.SeparablePrograms) { DEV_CHECK_ERR(Index < GetResourceCount(), "Index is out of range"); ResourceDesc = m_Resources.GetResourceDesc(Index); -- cgit v1.2.3