From e96e78defb3faecc1689023f4fedf72588d67bbb Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 28 Sep 2020 12:15:20 -0700 Subject: Updated Metal interfaces plus a number of misc fixes --- Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp | 4 ++-- .../GraphicsEngineOpenGL/src/GLTypeConversions.cpp | 25 +++++++++++++++++----- .../GraphicsEngineOpenGL/src/TextureBaseGL.cpp | 4 ++-- 3 files changed, 24 insertions(+), 9 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') 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(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 + #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 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 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 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(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 : ""), "'"); } } -- cgit v1.2.3