summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-01-07 17:14:11 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-01-07 17:14:11 +0000
commitf92524a49f7397c26b10109b1cad1cfede7095ff (patch)
treefb03eb91d3325a4464ea18adfec15b7cac19bfc5 /Graphics/GraphicsEngineOpenGL
parentVulkan backend: fixed issues with occlusion and pipeline stats queries if the... (diff)
downloadDiligentCore-f92524a49f7397c26b10109b1cad1cfede7095ff.tar.gz
DiligentCore-f92524a49f7397c26b10109b1cad1cfede7095ff.zip
Improved reporting of device capabilities (fixed https://github.com/DiligentGraphics/DiligentCore/issues/109)
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp67
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/SamplerGLImpl.cpp8
2 files changed, 52 insertions, 23 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
index 091bb33b..727195e8 100644
--- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
@@ -117,6 +117,24 @@ RenderDeviceGLImpl::RenderDeviceGLImpl(IReferenceCounters* pRefCounters,
auto& Features = m_DeviceCaps.Features;
auto& TexCaps = m_DeviceCaps.TexCaps;
+ auto& SamCaps = m_DeviceCaps.SamCaps;
+
+ GLint MaxTextureSize = 0;
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &MaxTextureSize);
+ CHECK_GL_ERROR("Failed to get maximum texture size");
+
+ GLint Max3DTextureSize = 0;
+ glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &Max3DTextureSize);
+ CHECK_GL_ERROR("Failed to get maximum 3d texture size");
+
+ GLint MaxCubeTextureSize = 0;
+ glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &MaxCubeTextureSize);
+ CHECK_GL_ERROR("Failed to get maximum cubemap texture size");
+
+ GLint MaxLayers = 0;
+ glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &MaxLayers);
+ CHECK_GL_ERROR("Failed to get maximum number of texture array layers");
+
if (m_DeviceCaps.DevType == DeviceType::OpenGL)
{
const bool IsGL43OrAbove = MajorVersion >= 5 || MajorVersion == 4 && MinorVersion >= 3;
@@ -134,12 +152,20 @@ RenderDeviceGLImpl::RenderDeviceGLImpl(IReferenceCounters* pRefCounters,
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");
+ TexCaps.MaxTexture1DDimension = MaxTextureSize;
+ TexCaps.MaxTexture1DArraySlices = MaxLayers;
+ TexCaps.MaxTexture2DDimension = MaxTextureSize;
+ TexCaps.MaxTexture2DArraySlices = MaxLayers;
+ TexCaps.MaxTexture3DDimension = Max3DTextureSize;
+ TexCaps.MaxTextureCubeDimension = MaxCubeTextureSize;
+ TexCaps.Texture2DMSSupported = IsGL43OrAbove || CheckExtension("GL_ARB_texture_storage_multisample");
+ TexCaps.Texture2DMSArraySupported = IsGL43OrAbove || CheckExtension("GL_ARB_texture_storage_multisample");
+ TexCaps.TextureViewSupported = IsGL43OrAbove || CheckExtension("GL_ARB_texture_view");
+ TexCaps.CubemapArraysSupported = IsGL43OrAbove || CheckExtension("GL_ARB_texture_cube_map_array");
+
+ SamCaps.BorderSamplingModeSupported = True;
+ SamCaps.AnisotropicFilteringSupported = (MajorVersion >= 5 || MajorVersion == 4 && MinorVersion >= 6) || CheckExtension("GL_ARB_texture_filter_anisotropic");
+ SamCaps.LODBiasSupported = True;
}
else
{
@@ -164,17 +190,20 @@ RenderDeviceGLImpl::RenderDeviceGLImpl(IReferenceCounters* pRefCounters,
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;
+ TexCaps.MaxTexture1DDimension = 0; // Not supported in GLES 3.2
+ TexCaps.MaxTexture1DArraySlices = 0; // Not supported in GLES 3.2
+ TexCaps.MaxTexture2DDimension = MaxTextureSize;
+ TexCaps.MaxTexture2DArraySlices = MaxLayers;
+ TexCaps.MaxTexture3DDimension = Max3DTextureSize;
+ TexCaps.MaxTextureCubeDimension = MaxCubeTextureSize;
+ TexCaps.Texture2DMSSupported = IsGLES31OrAbove || strstr(Extensions, "texture_storage_multisample");
+ TexCaps.Texture2DMSArraySupported = IsGLES32OrAbove || strstr(Extensions, "texture_storage_multisample_2d_array");
+ TexCaps.TextureViewSupported = IsGLES31OrAbove || strstr(Extensions, "texture_view");
+ TexCaps.CubemapArraysSupported = IsGLES32OrAbove || strstr(Extensions, "texture_cube_map_array");
+
+ SamCaps.BorderSamplingModeSupported = GL_TEXTURE_BORDER_COLOR && (IsGLES32OrAbove || strstr(Extensions, "texture_border_clamp"));
+ SamCaps.AnisotropicFilteringSupported = GL_TEXTURE_MAX_ANISOTROPY_EXT && (IsGLES31OrAbove || strstr(Extensions, "texture_filter_anisotropic"));
+ SamCaps.LODBiasSupported = GL_TEXTURE_LOD_BIAS && IsGLES31OrAbove;
}
}
@@ -696,7 +725,7 @@ void RenderDeviceGLImpl::TestTextureFormat(TEXTURE_FORMAT TexFormat)
// Create test texture 1D
TexFormatInfo.Tex1DFmt = false;
- if (m_DeviceCaps.TexCaps.bTexture1DSupported &&
+ if (m_DeviceCaps.TexCaps.MaxTexture1DDimension != 0 &&
TexFormatInfo.ComponentType != COMPONENT_TYPE_COMPRESSED)
{
GLObjectWrappers::GLTextureObj TestGLTex(true);
@@ -809,7 +838,7 @@ void RenderDeviceGLImpl::TestTextureFormat(TEXTURE_FORMAT TexFormat)
TexFormatInfo.SampleCounts = 0x01;
if (TexFormatInfo.ComponentType != COMPONENT_TYPE_COMPRESSED &&
- m_DeviceCaps.TexCaps.bTexture2DMSSupported)
+ m_DeviceCaps.TexCaps.Texture2DMSSupported)
{
#if GL_ARB_texture_storage_multisample
for (GLsizei SampleCount = 2; SampleCount <= 8; SampleCount *= 2)
diff --git a/Graphics/GraphicsEngineOpenGL/src/SamplerGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/SamplerGLImpl.cpp
index 2bfabf29..e45b145d 100644
--- a/Graphics/GraphicsEngineOpenGL/src/SamplerGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/SamplerGLImpl.cpp
@@ -83,7 +83,7 @@ SamplerGLImpl::SamplerGLImpl(IReferenceCounters* pRefCounters, class RenderDevic
{
auto& WrapMode = WrapModes[i];
WrapMode = TexAddressModeToGLAddressMode(AddressModes[i]);
- if (!SamCaps.bBorderSamplingModeSupported && WrapMode == GL_CLAMP_TO_BORDER)
+ if (!SamCaps.BorderSamplingModeSupported && WrapMode == GL_CLAMP_TO_BORDER)
{
LOG_ERROR_MESSAGE("GL_CLAMP_TO_BORDER filtering mode is not supported. Defaulting to GL_CLAMP_TO_EDGE.\n");
WrapMode = GL_CLAMP_TO_EDGE;
@@ -93,7 +93,7 @@ SamplerGLImpl::SamplerGLImpl(IReferenceCounters* pRefCounters, class RenderDevic
glSamplerParameteri(m_GlSampler, GL_TEXTURE_WRAP_T, WrapModes[1]);
glSamplerParameteri(m_GlSampler, GL_TEXTURE_WRAP_R, WrapModes[2]);
- if (SamCaps.bLODBiasSupported) // Can be unsupported
+ if (SamCaps.LODBiasSupported) // Can be unsupported
glSamplerParameterf(m_GlSampler, GL_TEXTURE_LOD_BIAS, SamplerDesc.MipLODBias);
else
{
@@ -101,7 +101,7 @@ SamplerGLImpl::SamplerGLImpl(IReferenceCounters* pRefCounters, class RenderDevic
LOG_WARNING_MESSAGE("Texture LOD bias sampler attribute is not supported\n");
}
- if (SamCaps.bAnisotropicFilteringSupported) // Can be unsupported
+ if (SamCaps.AnisotropicFilteringSupported) // Can be unsupported
glSamplerParameterf(m_GlSampler, GL_TEXTURE_MAX_ANISOTROPY_EXT, bMipAnisotropic ? static_cast<float>(SamplerDesc.MaxAnisotropy) : 1.f);
else
{
@@ -111,7 +111,7 @@ SamplerGLImpl::SamplerGLImpl(IReferenceCounters* pRefCounters, class RenderDevic
glSamplerParameteri(m_GlSampler, GL_TEXTURE_COMPARE_MODE, bMinComparison ? GL_COMPARE_REF_TO_TEXTURE : GL_NONE);
- if (SamCaps.bBorderSamplingModeSupported) // Can be unsupported
+ if (SamCaps.BorderSamplingModeSupported) // Can be unsupported
glSamplerParameterfv(m_GlSampler, GL_TEXTURE_BORDER_COLOR, SamplerDesc.BorderColor);
else
{