summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-09-28 19:15:20 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-09-28 19:15:20 +0000
commite96e78defb3faecc1689023f4fedf72588d67bbb (patch)
treed72fe25266a0079d1812270218e8caf1618b4b0f /Graphics/GraphicsEngineOpenGL
parentVulkan backend: few fixes to (diff)
downloadDiligentCore-e96e78defb3faecc1689023f4fedf72588d67bbb.tar.gz
DiligentCore-e96e78defb3faecc1689023f4fedf72588d67bbb.zip
Updated Metal interfaces plus a number of misc fixes
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp4
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/GLTypeConversions.cpp25
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp4
3 files changed, 24 insertions, 9 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp
index 6aa1dd3e..4bba7d46 100644
--- a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp
@@ -385,7 +385,7 @@ void BufferGLImpl::CreateViewInternal(const BufferViewDesc& OrigViewDesc, IBuffe
auto ViewDesc = OrigViewDesc;
CorrectBufferViewDesc(ViewDesc);
- auto* pDeviceGLImpl = ValidatedCast<RenderDeviceGLImpl>(GetDevice());
+ auto* pDeviceGLImpl = GetDevice();
auto& BuffViewAllocator = pDeviceGLImpl->GetBuffViewObjAllocator();
VERIFY(&BuffViewAllocator == &m_dbgBuffViewAllocator, "Buff view allocator does not match allocator provided at buffer initialization");
@@ -400,7 +400,7 @@ void BufferGLImpl::CreateViewInternal(const BufferViewDesc& OrigViewDesc, IBuffe
catch (const std::runtime_error&)
{
const auto* ViewTypeName = GetBufferViewTypeLiteralName(OrigViewDesc.ViewType);
- LOG_ERROR("Failed to create view \"", OrigViewDesc.Name ? OrigViewDesc.Name : "", "\" (", ViewTypeName, ") for buffer \"", m_Desc.Name ? m_Desc.Name : "", "\"");
+ LOG_ERROR("Failed to create view '", (OrigViewDesc.Name ? OrigViewDesc.Name : ""), "' (", ViewTypeName, ") for buffer '", (m_Desc.Name ? m_Desc.Name : ""), "'");
}
}
diff --git a/Graphics/GraphicsEngineOpenGL/src/GLTypeConversions.cpp b/Graphics/GraphicsEngineOpenGL/src/GLTypeConversions.cpp
index 27893ed8..59f790c4 100644
--- a/Graphics/GraphicsEngineOpenGL/src/GLTypeConversions.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/GLTypeConversions.cpp
@@ -26,12 +26,17 @@
*/
#include "pch.h"
+#include <array>
+
#include "GLTypeConversions.hpp"
#include "GraphicsAccessories.hpp"
namespace Diligent
{
+namespace
+{
+
class FormatToGLInternalTexFormatMap
{
public:
@@ -158,18 +163,22 @@ public:
m_FmtToGLFmtMap[TEX_FORMAT_BC7_UNORM] = GL_COMPRESSED_RGBA_BPTC_UNORM;
m_FmtToGLFmtMap[TEX_FORMAT_BC7_UNORM_SRGB] = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM;
// clang-format on
+
+ static_assert(TEX_FORMAT_NUM_FORMATS == 100, "Please enter the new format information above");
}
GLenum operator[](TEXTURE_FORMAT TexFormat) const
{
- VERIFY_EXPR(TexFormat < _countof(m_FmtToGLFmtMap));
+ VERIFY_EXPR(TexFormat < m_FmtToGLFmtMap.size());
return m_FmtToGLFmtMap[TexFormat];
}
private:
- GLenum m_FmtToGLFmtMap[TEX_FORMAT_NUM_FORMATS] = {0};
+ std::array<GLenum, TEX_FORMAT_NUM_FORMATS> m_FmtToGLFmtMap = {};
};
+} // namespace
+
GLenum TexFormatToGLInternalTexFormat(TEXTURE_FORMAT TexFormat, Uint32 BindFlags)
{
static const FormatToGLInternalTexFormatMap FormatMap;
@@ -182,11 +191,14 @@ GLenum TexFormatToGLInternalTexFormat(TEXTURE_FORMAT TexFormat, Uint32 BindFlags
}
else
{
- UNEXPECTED("Texture format (", int{TexFormat}, ") out of allowed range [0, ", int{TEX_FORMAT_NUM_FORMATS} - 1, "]");
+ UNEXPECTED("Texture format (", int{TexFormat}, ") is out of allowed range [0, ", int{TEX_FORMAT_NUM_FORMATS} - 1, "]");
return 0;
}
}
+namespace
+{
+
class InternalTexFormatToTexFormatMap
{
public:
@@ -238,6 +250,8 @@ private:
std::unordered_map<GLenum, TEXTURE_FORMAT> m_FormatMap;
};
+} // namespace
+
TEXTURE_FORMAT GLInternalTexFormatToTexFormat(GLenum GlFormat)
{
static const InternalTexFormatToTexFormatMap FormatMap;
@@ -248,8 +262,9 @@ NativePixelAttribs GetNativePixelTransferAttribs(TEXTURE_FORMAT TexFormat)
{
// http://www.opengl.org/wiki/Pixel_Transfer
- static Bool bAttribsMapIntialized = false;
- static NativePixelAttribs FmtToGLPixelFmt[TEX_FORMAT_NUM_FORMATS];
+ static std::array<NativePixelAttribs, TEX_FORMAT_NUM_FORMATS> FmtToGLPixelFmt;
+
+ static bool bAttribsMapIntialized = false;
if (!bAttribsMapIntialized)
{
// clang-format off
diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp
index 0f2600e9..af63e560 100644
--- a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp
@@ -393,7 +393,7 @@ void TextureBaseGL::CreateViewInternal(const struct TextureViewDesc& OrigViewDes
auto ViewDesc = OrigViewDesc;
CorrectTextureViewDesc(ViewDesc);
- auto* pDeviceGLImpl = ValidatedCast<RenderDeviceGLImpl>(GetDevice());
+ auto* pDeviceGLImpl = GetDevice();
auto& TexViewAllocator = pDeviceGLImpl->GetTexViewObjAllocator();
VERIFY(&TexViewAllocator == &m_dbgTexViewObjAllocator, "Texture view allocator does not match allocator provided during texture initialization");
@@ -522,7 +522,7 @@ void TextureBaseGL::CreateViewInternal(const struct TextureViewDesc& OrigViewDes
catch (const std::runtime_error&)
{
const auto* ViewTypeName = GetTexViewTypeLiteralName(OrigViewDesc.ViewType);
- LOG_ERROR("Failed to create view \"", OrigViewDesc.Name ? OrigViewDesc.Name : "", "\" (", ViewTypeName, ") for texture \"", m_Desc.Name ? m_Desc.Name : "", "\"");
+ LOG_ERROR("Failed to create view '", (OrigViewDesc.Name ? OrigViewDesc.Name : ""), "' (", ViewTypeName, ") for texture '", (m_Desc.Name ? m_Desc.Name : ""), "'");
}
}