summaryrefslogtreecommitdiffstats
path: root/Graphics
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
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')
-rw-r--r--Graphics/GraphicsEngine/include/RenderDeviceBase.hpp4
-rw-r--r--Graphics/GraphicsEngineMetal/interface/BufferMtl.h2
-rw-r--r--Graphics/GraphicsEngineMetal/interface/PipelineStateMtl.h5
-rw-r--r--Graphics/GraphicsEngineMetal/interface/RenderDeviceMtl.h2
-rw-r--r--Graphics/GraphicsEngineMetal/interface/ShaderMtl.h2
-rw-r--r--Graphics/GraphicsEngineMetal/interface/TextureViewMtl.h2
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp4
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/GLTypeConversions.cpp25
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp4
9 files changed, 39 insertions, 11 deletions
diff --git a/Graphics/GraphicsEngine/include/RenderDeviceBase.hpp b/Graphics/GraphicsEngine/include/RenderDeviceBase.hpp
index a0ffeda6..f406bf4e 100644
--- a/Graphics/GraphicsEngine/include/RenderDeviceBase.hpp
+++ b/Graphics/GraphicsEngine/include/RenderDeviceBase.hpp
@@ -500,11 +500,11 @@ void RenderDeviceBase<BaseInterface>::CreateDeviceObject(const Char* ObjectTypeN
auto ObjectDescString = GetObjectDescString(Desc);
if (ObjectDescString.length())
{
- LOG_ERROR("Failed to create ", ObjectTypeName, " object '", Desc.Name ? Desc.Name : "", "'\n", ObjectDescString);
+ LOG_ERROR("Failed to create ", ObjectTypeName, " object '", (Desc.Name ? Desc.Name : ""), "'\n", ObjectDescString);
}
else
{
- LOG_ERROR("Failed to create ", ObjectTypeName, " object '", Desc.Name ? Desc.Name : "", "'");
+ LOG_ERROR("Failed to create ", ObjectTypeName, " object '", (Desc.Name ? Desc.Name : ""), "'");
}
}
}
diff --git a/Graphics/GraphicsEngineMetal/interface/BufferMtl.h b/Graphics/GraphicsEngineMetal/interface/BufferMtl.h
index 8cbb04d1..1ed88a5c 100644
--- a/Graphics/GraphicsEngineMetal/interface/BufferMtl.h
+++ b/Graphics/GraphicsEngineMetal/interface/BufferMtl.h
@@ -41,6 +41,8 @@ static const INTERFACE_ID IID_BufferMtl =
class IBufferMtl : public IBuffer
{
public:
+ /// Returns a pointer to Metal buffer (MTLBuffer)
+ virtual void* GetMtlBuffer() const = 0;
};
} // namespace Diligent
diff --git a/Graphics/GraphicsEngineMetal/interface/PipelineStateMtl.h b/Graphics/GraphicsEngineMetal/interface/PipelineStateMtl.h
index f9b3d4a5..aaea6a0d 100644
--- a/Graphics/GraphicsEngineMetal/interface/PipelineStateMtl.h
+++ b/Graphics/GraphicsEngineMetal/interface/PipelineStateMtl.h
@@ -41,6 +41,11 @@ static const INTERFACE_ID IID_PipelineStateMtl =
class IPipelineStateMtl : public IPipelineState
{
public:
+ /// Returns a pointer to Metal render or compute pipeline (MTLRenderPipelineState or MTLComputePipelineState)
+ virtual void* GetMtlPipeline() const = 0;
+
+ /// Returns a pointer to Metal depth-stencil state (MTLDepthStencilState)
+ virtual void* GetMtlDepthStencilState() const = 0;
};
} // namespace Diligent
diff --git a/Graphics/GraphicsEngineMetal/interface/RenderDeviceMtl.h b/Graphics/GraphicsEngineMetal/interface/RenderDeviceMtl.h
index 115ae68e..11fe4199 100644
--- a/Graphics/GraphicsEngineMetal/interface/RenderDeviceMtl.h
+++ b/Graphics/GraphicsEngineMetal/interface/RenderDeviceMtl.h
@@ -41,6 +41,8 @@ static const INTERFACE_ID IID_RenderDeviceMtl =
class IRenderDeviceMtl : public IRenderDevice
{
public:
+ /// Returns the pointer to MTLDevice object
+ virtual void* GetMtlDevice() const = 0;
};
} // namespace Diligent
diff --git a/Graphics/GraphicsEngineMetal/interface/ShaderMtl.h b/Graphics/GraphicsEngineMetal/interface/ShaderMtl.h
index d07561e1..0f3da174 100644
--- a/Graphics/GraphicsEngineMetal/interface/ShaderMtl.h
+++ b/Graphics/GraphicsEngineMetal/interface/ShaderMtl.h
@@ -41,6 +41,8 @@ static const INTERFACE_ID IID_ShaderMtl =
class IShaderMtl : public IShader
{
public:
+ /// Returns the point to Metal shader function (MTLFunction)
+ virtual void* GetMtlShaderFunction() const = 0;
};
} // namespace Diligent
diff --git a/Graphics/GraphicsEngineMetal/interface/TextureViewMtl.h b/Graphics/GraphicsEngineMetal/interface/TextureViewMtl.h
index 988327b9..07453e6d 100644
--- a/Graphics/GraphicsEngineMetal/interface/TextureViewMtl.h
+++ b/Graphics/GraphicsEngineMetal/interface/TextureViewMtl.h
@@ -41,6 +41,8 @@ static const INTERFACE_ID IID_TextureViewMtl =
class ITextureViewMtl : public ITextureView
{
public:
+ /// Returns a pointer to Metal texture view (MTLTexture)
+ virtual void* GetMtlTexture() const = 0;
};
} // namespace Diligent
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 : ""), "'");
}
}