diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-01-07 04:53:34 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-01-07 04:53:34 +0000 |
| commit | 0c99ee543ef936ef770f4b11fa77e08c2f736c1b (patch) | |
| tree | 9ca3812fd317e3366f975b74e8c67b8cb928fc89 /Graphics | |
| parent | Added workaround for inteface type mismatch error in GS references VK (diff) | |
| download | DiligentCore-0c99ee543ef936ef770f4b11fa77e08c2f736c1b.tar.gz DiligentCore-0c99ee543ef936ef770f4b11fa77e08c2f736c1b.zip | |
Improved device feature reporting; added flags for query support
Diffstat (limited to 'Graphics')
19 files changed, 218 insertions, 140 deletions
diff --git a/Graphics/GLSLTools/src/GLSLSourceBuilder.cpp b/Graphics/GLSLTools/src/GLSLSourceBuilder.cpp index 000f660a..8d5f62bd 100644 --- a/Graphics/GLSLTools/src/GLSLSourceBuilder.cpp +++ b/Graphics/GLSLTools/src/GLSLSourceBuilder.cpp @@ -94,7 +94,7 @@ String BuildGLSLSourceString(const ShaderCreateInfo& CreationAttribs, UNEXPECTED("Unexpected device type"); } - if (deviceCaps.bSeparableProgramSupported && !IsES31OrAbove) + if (deviceCaps.Features.SeparablePrograms && !IsES31OrAbove) GLSLSource.append("#extension GL_EXT_separate_shader_objects : enable\n"); if (deviceCaps.TexCaps.bCubemapArraysSupported && !IsES32OrAbove) @@ -172,7 +172,7 @@ String BuildGLSLSourceString(const ShaderCreateInfo& CreationAttribs, ); // clang-format on } - if (deviceCaps.bComputeShadersSupported) + if (deviceCaps.Features.ComputeShaders) { GLSLSource.append( "precision highp image2D;\n" @@ -200,7 +200,7 @@ String BuildGLSLSourceString(const ShaderCreateInfo& CreationAttribs, } } - if (IsES30 && deviceCaps.bSeparableProgramSupported && ShaderType == SHADER_TYPE_VERTEX) + if (IsES30 && deviceCaps.Features.SeparablePrograms && ShaderType == SHADER_TYPE_VERTEX) { // From https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_separate_shader_objects.gles.txt: // @@ -325,7 +325,7 @@ String BuildGLSLSourceString(const ShaderCreateInfo& CreationAttribs, // all shader stages. // https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_separate_shader_objects.txt // (search for "Input Layout Qualifiers" and "Output Layout Qualifiers"). - Attribs.UseInOutLocationQualifiers = deviceCaps.bSeparableProgramSupported; + Attribs.UseInOutLocationQualifiers = deviceCaps.Features.SeparablePrograms; auto ConvertedSource = Converter.Convert(Attribs); GLSLSource.append(ConvertedSource); diff --git a/Graphics/GraphicsEngine/include/QueryBase.h b/Graphics/GraphicsEngine/include/QueryBase.h index 2d506ad4..f32c7455 100644 --- a/Graphics/GraphicsEngine/include/QueryBase.h +++ b/Graphics/GraphicsEngine/include/QueryBase.h @@ -67,7 +67,34 @@ public: const QueryDesc& Desc, bool bIsDeviceInternal = false) : TDeviceObjectBase{pRefCounters, pDevice, Desc, bIsDeviceInternal} - {} + { + const auto& deviceFeatures = pDevice->GetDeviceCaps().Features; + switch (Desc.Type) + { + case QUERY_TYPE_OCCLUSION: + if (!deviceFeatures.OcclusionQueries) + LOG_ERROR_AND_THROW("Occlusion queries are not supported by this device"); + break; + + case QUERY_TYPE_BINARY_OCCLUSION: + if (!deviceFeatures.BinaryOcclusionQueries) + LOG_ERROR_AND_THROW("Binary occlusion queries are not supported by this device"); + break; + + case QUERY_TYPE_TIMESTAMP: + if (!deviceFeatures.TimestampQueries) + LOG_ERROR_AND_THROW("Timestamp queries are not supported by this device"); + break; + + case QUERY_TYPE_PIPELINE_STATISTICS: + if (!deviceFeatures.PipelineStatisticsQueries) + LOG_ERROR_AND_THROW("Pipeline statistics queries are not supported by this device"); + break; + + default: + UNEXPECTED("Unexpected device type"); + } + } ~QueryBase() { diff --git a/Graphics/GraphicsEngine/include/ShaderBase.h b/Graphics/GraphicsEngine/include/ShaderBase.h index 01e6ab4f..cf99cdc0 100644 --- a/Graphics/GraphicsEngine/include/ShaderBase.h +++ b/Graphics/GraphicsEngine/include/ShaderBase.h @@ -99,9 +99,21 @@ public: /// \param ShdrDesc - shader description. /// \param bIsDeviceInternal - flag indicating if the shader is an internal device object and /// must not keep a strong reference to the device. - ShaderBase(IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, const ShaderDesc& ShdrDesc, bool bIsDeviceInternal = false) : + ShaderBase(IReferenceCounters* pRefCounters, + RenderDeviceImplType* pDevice, + const ShaderDesc& ShdrDesc, + bool bIsDeviceInternal = false) : TDeviceObjectBase{pRefCounters, pDevice, ShdrDesc, bIsDeviceInternal} { + const auto& deviceFeatures = pDevice->GetDeviceCaps().Features; + if (ShdrDesc.ShaderType == SHADER_TYPE_GEOMETRY && !deviceFeatures.GeometryShaders) + LOG_ERROR_AND_THROW("Geometry shaders are not supported by this device"); + + if ((ShdrDesc.ShaderType == SHADER_TYPE_DOMAIN || ShdrDesc.ShaderType == SHADER_TYPE_HULL) && !deviceFeatures.Tessellation) + LOG_ERROR_AND_THROW("Tessellation shaders are not supported by this device"); + + if (ShdrDesc.ShaderType == SHADER_TYPE_COMPUTE && !deviceFeatures.ComputeShaders) + LOG_ERROR_AND_THROW("Compute shaders are not supported by this device"); } IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_Shader, TDeviceObjectBase) diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h index 1686e3f7..00fb32f7 100644 --- a/Graphics/GraphicsEngine/interface/APIInfo.h +++ b/Graphics/GraphicsEngine/interface/APIInfo.h @@ -30,7 +30,7 @@ /// \file /// Diligent API information -#define DILIGENT_API_VERSION 240049 +#define DILIGENT_API_VERSION 240050 #include "../../../Primitives/interface/BasicTypes.h" diff --git a/Graphics/GraphicsEngine/interface/DeviceCaps.h b/Graphics/GraphicsEngine/interface/DeviceCaps.h index 1a433468..ebde692e 100644 --- a/Graphics/GraphicsEngine/interface/DeviceCaps.h +++ b/Graphics/GraphicsEngine/interface/DeviceCaps.h @@ -83,6 +83,46 @@ namespace Diligent Bool bCubemapArraysSupported = True; }; + /// Describes supported device features + struct DeviceFeatures + { + /// Indicates if device supports separable programs + Bool SeparablePrograms = False; + + /// Indicates if device supports indirect draw commands + Bool IndirectRendering = False; + + /// Indicates if device supports wireframe fill mode + Bool WireframeFill = False; + + /// Indicates if device supports multithreaded resource creation + Bool MultithreadedResourceCreation = False; + + /// Indicates if device supports compute shaders + Bool ComputeShaders = False; + + /// Indicates if device supports geometry shaders + Bool GeometryShaders = False; + + /// Indicates if device supports tessellation + Bool Tessellation = False; + + /// Indicates if device supports bindless resources + Bool BindlessResources = False; + + /// Indicates if device supports occlusion queries (see Diligent::QUERY_TYPE_OCCLUSION). + Bool OcclusionQueries = False; + + /// Indicates if device supports binary occlusion queries (see Diligent::QUERY_TYPE_BINARY_OCCLUSION). + Bool BinaryOcclusionQueries = False; + + /// Indicates if device supports timestamp queries (see Diligent::QUERY_TYPE_TIMESTAMP). + Bool TimestampQueries = False; + + /// Indicates if device supports timestamp queries (see Diligent::QUERY_TYPE_PIPELINE_STATISTICS). + Bool PipelineStatisticsQueries = False; + }; + /// Device capabilities struct DeviceCaps { @@ -102,36 +142,15 @@ namespace Diligent /// Adapter type. See Diligent::ADAPTER_TYPE. ADAPTER_TYPE AdaterType = ADAPTER_TYPE_UNKNOWN; - /// Indicates if device supports separable programs - Bool bSeparableProgramSupported = True; - - /// Indicates if device supports indirect draw commands - Bool bIndirectRenderingSupported = True; - - /// Indicates if device supports wireframe fill mode - Bool bWireframeFillSupported = True; - - /// Indicates if device supports multithreaded resource creation - Bool bMultithreadedResourceCreationSupported = False; - - /// Indicates if device supports compute shaders - Bool bComputeShadersSupported = True; - - /// Indicates if device supports geometry shaders - Bool bGeometryShadersSupported = True; - - /// Indicates if device supports tessellation - Bool bTessellationSupported = True; - - /// Indicates if device supports bindless resources - Bool bBindlessSupported = False; - /// Texture sampling capabilities. See Diligent::SamplerCaps. SamplerCaps SamCaps; /// Texture capabilities. See Diligent::TextureCaps. TextureCaps TexCaps; + /// Device features. See Diligent::DeviceFeatures. + DeviceFeatures Features; + bool IsGLDevice()const { return DevType == DeviceType::OpenGL || DevType == DeviceType::OpenGLES; diff --git a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp index 8475a402..1b072658 100644 --- a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp @@ -123,13 +123,11 @@ RenderDeviceD3D11Impl::RenderDeviceD3D11Impl(IReferenceCounters* pRefCo default: UNEXPECTED("Unexpected D3D feature level"); } - m_DeviceCaps.bSeparableProgramSupported = True; - m_DeviceCaps.bMultithreadedResourceCreationSupported = True; // Direct3D11 only supports shader model 5.0 even if the device feature level is // above 11.0 (for example, 11.1 or 12.0), so bindless resources are never available. // https://docs.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-devices-downlevel-intro#overview-for-each-feature-level - m_DeviceCaps.bBindlessSupported = False; + m_DeviceCaps.Features.BindlessResources = False; if (auto pDXGIAdapter1 = DXGIAdapterFromD3D11Device(pd3d11Device)) { diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp index ea00a31e..09313177 100644 --- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp @@ -139,9 +139,8 @@ RenderDeviceD3D12Impl::RenderDeviceD3D12Impl(IReferenceCounters* pRefCo { case D3D_FEATURE_LEVEL_12_0: case D3D_FEATURE_LEVEL_12_1: - m_DeviceCaps.MajorVersion = 12; - m_DeviceCaps.MinorVersion = FeatureLevel == D3D_FEATURE_LEVEL_12_1 ? 1 : 0; - m_DeviceCaps.bBindlessSupported = true; + m_DeviceCaps.MajorVersion = 12; + m_DeviceCaps.MinorVersion = FeatureLevel == D3D_FEATURE_LEVEL_12_1 ? 1 : 0; break; case D3D_FEATURE_LEVEL_11_0: @@ -159,13 +158,11 @@ RenderDeviceD3D12Impl::RenderDeviceD3D12Impl(IReferenceCounters* pRefCo default: UNEXPECTED("Unexpected D3D feature level"); } - m_DeviceCaps.bSeparableProgramSupported = True; - m_DeviceCaps.bMultithreadedResourceCreationSupported = True; // Direct3D12 supports shader model 5.1 on all feature levels (even on 11.0), // so bindless resources are always available. // https://docs.microsoft.com/en-us/windows/win32/direct3d12/hardware-feature-levels#feature-level-support - m_DeviceCaps.bBindlessSupported = True; + m_DeviceCaps.Features.BindlessResources = True; if (auto pDXGIAdapter1 = DXGIAdapterFromD3D12Device(pd3d12Device)) { diff --git a/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.h b/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.h index a6b2a3c4..143ce33d 100644 --- a/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.h +++ b/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.h @@ -154,6 +154,20 @@ public: FLAG_FORMAT(TEX_FORMAT_BC7_UNORM_SRGB, true); #undef FLAG_FORMAT // clang-format on + + auto& Features = this->m_DeviceCaps.Features; + + Features.SeparablePrograms = True; + Features.IndirectRendering = True; + Features.WireframeFill = True; + Features.MultithreadedResourceCreation = True; + Features.ComputeShaders = True; + Features.GeometryShaders = True; + Features.Tessellation = True; + Features.OcclusionQueries = True; + Features.BinaryOcclusionQueries = True; + Features.TimestampQueries = True; + Features.PipelineStatisticsQueries = True; } }; diff --git a/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm index 4ca20f2e..2a64917a 100644 --- a/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm +++ b/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm @@ -66,10 +66,10 @@ RenderDeviceMtlImpl :: RenderDeviceMtlImpl(IReferenceCounters* pRefCounte m_DeviceCaps.DevType = DeviceType::Metal; m_DeviceCaps.MajorVersion = 11; m_DeviceCaps.MinorVersion = 0; - m_DeviceCaps.bSeparableProgramSupported = True; - m_DeviceCaps.bMultithreadedResourceCreationSupported = True; - m_DeviceCaps.bGeometryShadersSupported = False; - m_DeviceCaps.bTessellationSupported = False; + m_DeviceCaps.Features.SeparablePrograms = True; + m_DeviceCaps.Features.MultithreadedResourceCreation = True; + m_DeviceCaps.Features.GeometryShaders = False; + m_DeviceCaps.Features.Tessellation = False; } void RenderDeviceMtlImpl::TestTextureFormat( TEXTURE_FORMAT TexFormat ) 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); diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp index 8b6c93da..b1daf423 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp @@ -147,18 +147,28 @@ RenderDeviceVkImpl::RenderDeviceVkImpl(IReferenceCounters* } // clang-format on { - m_DeviceCaps.DevType = DeviceType::Vulkan; - m_DeviceCaps.MajorVersion = 1; - m_DeviceCaps.MinorVersion = 0; - m_DeviceCaps.AdaterType = ADAPTER_TYPE_HARDWARE; - m_DeviceCaps.bSeparableProgramSupported = True; - m_DeviceCaps.bMultithreadedResourceCreationSupported = True; + m_DeviceCaps.DevType = DeviceType::Vulkan; + m_DeviceCaps.MajorVersion = 1; + m_DeviceCaps.MinorVersion = 0; + m_DeviceCaps.AdaterType = ADAPTER_TYPE_HARDWARE; for (Uint32 fmt = 1; fmt < m_TextureFormatsInfo.size(); ++fmt) m_TextureFormatsInfo[fmt].Supported = true; // We will test every format on a specific hardware device - m_DeviceCaps.bGeometryShadersSupported = EngineCI.EnabledFeatures.geometryShader; - m_DeviceCaps.bTessellationSupported = EngineCI.EnabledFeatures.tessellationShader; - m_DeviceCaps.bBindlessSupported = True; + auto& Features = m_DeviceCaps.Features; + const auto& vkDeviceFeatures = m_PhysicalDevice->GetFeatures(); + + Features.SeparablePrograms = True; + Features.IndirectRendering = True; + Features.WireframeFill = True; + Features.MultithreadedResourceCreation = True; + Features.ComputeShaders = True; + Features.GeometryShaders = vkDeviceFeatures.geometryShader != VK_FALSE; + Features.Tessellation = vkDeviceFeatures.tessellationShader != VK_FALSE; + Features.BindlessResources = True; + Features.OcclusionQueries = vkDeviceFeatures.occlusionQueryPrecise != VK_FALSE; + Features.BinaryOcclusionQueries = True; + Features.TimestampQueries = True; + Features.PipelineStatisticsQueries = vkDeviceFeatures.pipelineStatisticsQuery != VK_FALSE; } RenderDeviceVkImpl::~RenderDeviceVkImpl() |
