summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-04-06 02:50:53 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-04-06 02:50:53 +0000
commitdd56cf89a936c3a1c0a7a9a607c1ef51b1f939cd (patch)
tree34a6cf25cf5190ecfca0ccca642403cd69122ad0 /Graphics/GraphicsEngine
parentFixed Metal back-end (diff)
downloadDiligentCore-dd56cf89a936c3a1c0a7a9a607c1ef51b1f939cd.tar.gz
DiligentCore-dd56cf89a936c3a1c0a7a9a607c1ef51b1f939cd.zip
Added API info query
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/CMakeLists.txt5
-rw-r--r--Graphics/GraphicsEngine/include/EngineFactoryBase.h10
-rw-r--r--Graphics/GraphicsEngine/interface/APIInfo.h99
-rw-r--r--Graphics/GraphicsEngine/interface/EngineFactory.h48
-rw-r--r--Graphics/GraphicsEngine/src/APIInfo.cpp117
5 files changed, 277 insertions, 2 deletions
diff --git a/Graphics/GraphicsEngine/CMakeLists.txt b/Graphics/GraphicsEngine/CMakeLists.txt
index a458d2f3..4eb8d9aa 100644
--- a/Graphics/GraphicsEngine/CMakeLists.txt
+++ b/Graphics/GraphicsEngine/CMakeLists.txt
@@ -27,6 +27,7 @@ set(INCLUDE
)
set(INTERFACE
+ interface/APIInfo.h
interface/BlendState.h
interface/Buffer.h
interface/BufferView.h
@@ -36,6 +37,7 @@ set(INTERFACE
interface/DeviceCaps.h
interface/DeviceContext.h
interface/DeviceObject.h
+ interface/EngineFactory.h
interface/Fence.h
interface/GraphicsTypes.h
interface/InputLayout.h
@@ -53,7 +55,8 @@ set(INTERFACE
interface/TextureView.h
)
-set(SOURCE
+set(SOURCE
+ src/APIInfo.cpp
src/EngineMemory.cpp
src/ResourceMapping.cpp
src/Texture.cpp
diff --git a/Graphics/GraphicsEngine/include/EngineFactoryBase.h b/Graphics/GraphicsEngine/include/EngineFactoryBase.h
index b22e174f..c382afff 100644
--- a/Graphics/GraphicsEngine/include/EngineFactoryBase.h
+++ b/Graphics/GraphicsEngine/include/EngineFactoryBase.h
@@ -27,10 +27,13 @@
/// Implementation of the Diligent::EngineFactoryBase template class
#include "Object.h"
+#include "EngineFactory.h"
namespace Diligent
{
+const APIInfo& GetAPIInfo();
+
/// Template class implementing base functionality for an engine factory
/// \tparam BaseInterface - base interface that this class will inheret
@@ -54,7 +57,7 @@ public:
return;
*ppInterface = nullptr;
- if (IID == IID_Unknown || IID == m_FactoryIID)
+ if (IID == IID_Unknown || IID == m_FactoryIID || IID == IID_EngineFactory)
{
*ppInterface = this;
(*ppInterface)->AddRef();
@@ -76,6 +79,11 @@ public:
return const_cast<IReferenceCounters*>(static_cast<const IReferenceCounters*>(&m_RefCounters));
}
+ virtual const APIInfo& GetAPIInfo() const override final
+ {
+ return Diligent::GetAPIInfo();
+ }
+
private:
class DummyReferenceCounters final : public IReferenceCounters
{
diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h
new file mode 100644
index 00000000..32230be1
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/APIInfo.h
@@ -0,0 +1,99 @@
+/* Copyright 2015-2019 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#pragma once
+
+/// \file
+/// Diligent API information
+
+#define DILIGENT_API_VERSION 240020
+
+#include "../../../Primitives/interface/BasicTypes.h"
+
+namespace Diligent
+{
+
+/// Diligent API Info. This tructure can be used to verify API compatibility.
+struct APIInfo
+{
+ size_t StructSize = 0;
+ int APIVersion = 0;
+ size_t RenderTargetBlendDescSize = 0;
+ size_t BlendStateDescSize = 0;
+ size_t BufferDescSize = 0;
+ size_t BufferDataSize = 0;
+ size_t BufferFormatSize = 0;
+ size_t BufferViewDescSize = 0;
+ size_t StencilOpDescSize = 0;
+ size_t DepthStencilStateDescSize = 0;
+ size_t SamplerCapsSize = 0;
+ size_t TextureCapsSize = 0;
+ size_t DeviceCapsSize = 0;
+ size_t DrawAttribsSize = 0;
+ size_t DispatchComputeAttribsSize = 0;
+ size_t ViewportSize = 0;
+ size_t RectSize = 0;
+ size_t CopyTextureAttribsSize = 0;
+ size_t DeviceObjectAttribsSize = 0;
+ size_t HardwareAdapterAttribsSize = 0;
+ size_t DisplayModeAttribsSize = 0;
+ size_t SwapChainDescSize = 0;
+ size_t FullScreenModeDescSize = 0;
+ size_t EngineCreateInfoSize = 0;
+ size_t EngineGLCreateInfoSize = 0;
+ size_t EngineD3D11CreateInfoSize = 0;
+ size_t EngineD3D12CreateInfoSize = 0;
+ size_t EngineVkCreateInfoSize = 0;
+ size_t EngineMtlCreateInfoSize = 0;
+ size_t BoxSize = 0;
+ size_t TextureFormatAttribsSize = 0;
+ size_t TextureFormatInfoSize = 0;
+ size_t TextureFormatInfoExtSize = 0;
+ size_t StateTransitionDescSize = 0;
+ size_t LayoutElementSize = 0;
+ size_t InputLayoutDescSize = 0;
+ size_t SampleDescSize = 0;
+ size_t ShaderResourceVariableDescSize = 0;
+ size_t StaticSamplerDescSize = 0;
+ size_t PipelineResourceLayoutDescSize = 0;
+ size_t GraphicsPipelineDescSize = 0;
+ size_t ComputePipelineDescSize = 0;
+ size_t PipelineStateDescSize = 0;
+ size_t RasterizerStateDescSize = 0;
+ size_t ResourceMappingEntrySize = 0;
+ size_t ResourceMappingDescSize = 0;
+ size_t SamplerDescSize = 0;
+ size_t ShaderDescSize = 0;
+ size_t ShaderMacroSize = 0;
+ size_t ShaderCreateInfoSize = 0;
+ size_t ShaderResourceDescSize = 0;
+ size_t DepthStencilClearValueSize = 0;
+ size_t OptimizedClearValueSize = 0;
+ size_t TextureDescSize = 0;
+ size_t TextureSubResDataSize = 0;
+ size_t TextureDataSize = 0;
+ size_t MappedTextureSubresourceSize = 0;
+ size_t TextureViewDescSize = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/interface/EngineFactory.h b/Graphics/GraphicsEngine/interface/EngineFactory.h
new file mode 100644
index 00000000..aebb654a
--- /dev/null
+++ b/Graphics/GraphicsEngine/interface/EngineFactory.h
@@ -0,0 +1,48 @@
+/* Copyright 2015-2019 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#pragma once
+
+/// \file
+/// Defines Diligent::IEngineFactory interface
+
+#include "../../../Primitives/interface/Object.h"
+#include "APIInfo.h"
+
+namespace Diligent
+{
+
+// {D932B052-4ED6-4729-A532-F31DEEC100F3}
+static constexpr INTERFACE_ID IID_EngineFactory =
+{ 0xd932b052, 0x4ed6, 0x4729, { 0xa5, 0x32, 0xf3, 0x1d, 0xee, 0xc1, 0x0, 0xf3 } };
+
+
+/// Engine factory base interface
+class IEngineFactory : public IObject
+{
+public:
+ /// Returns API info structure
+ virtual const APIInfo& GetAPIInfo() const = 0;
+};
+
+}
diff --git a/Graphics/GraphicsEngine/src/APIInfo.cpp b/Graphics/GraphicsEngine/src/APIInfo.cpp
new file mode 100644
index 00000000..10fbec54
--- /dev/null
+++ b/Graphics/GraphicsEngine/src/APIInfo.cpp
@@ -0,0 +1,117 @@
+/* Copyright 2015-2019 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#include "APIInfo.h"
+#include "BlendState.h"
+#include "Buffer.h"
+#include "BufferView.h"
+#include "DepthStencilState.h"
+#include "DeviceCaps.h"
+#include "DeviceContext.h"
+#include "InputLayout.h"
+#include "PipelineState.h"
+#include "RasterizerState.h"
+#include "ResourceMapping.h"
+#include "Sampler.h"
+#include "Shader.h"
+#include "Texture.h"
+#include "TextureView.h"
+
+namespace Diligent
+{
+
+static APIInfo InitAPIInfo()
+{
+ APIInfo Info = {};
+ Info.StructSize = sizeof(APIInfo);
+ Info.APIVersion = DILIGENT_API_VERSION;
+
+#define INIT_STRUCTURE_SIZE(Struct) Info.Struct##Size = sizeof(Struct)
+ INIT_STRUCTURE_SIZE(RenderTargetBlendDesc);
+ INIT_STRUCTURE_SIZE(BlendStateDesc);
+ INIT_STRUCTURE_SIZE(BufferDesc);
+ INIT_STRUCTURE_SIZE(BufferData);
+ INIT_STRUCTURE_SIZE(BufferFormat);
+ INIT_STRUCTURE_SIZE(BufferViewDesc);
+ INIT_STRUCTURE_SIZE(StencilOpDesc);
+ INIT_STRUCTURE_SIZE(DepthStencilStateDesc);
+ INIT_STRUCTURE_SIZE(SamplerCaps);
+ INIT_STRUCTURE_SIZE(TextureCaps);
+ INIT_STRUCTURE_SIZE(DeviceCaps);
+ INIT_STRUCTURE_SIZE(DrawAttribs);
+ INIT_STRUCTURE_SIZE(DispatchComputeAttribs);
+ INIT_STRUCTURE_SIZE(Viewport);
+ INIT_STRUCTURE_SIZE(Rect);
+ INIT_STRUCTURE_SIZE(CopyTextureAttribs);
+ INIT_STRUCTURE_SIZE(DeviceObjectAttribs);
+ INIT_STRUCTURE_SIZE(HardwareAdapterAttribs);
+ INIT_STRUCTURE_SIZE(DisplayModeAttribs);
+ INIT_STRUCTURE_SIZE(SwapChainDesc);
+ INIT_STRUCTURE_SIZE(FullScreenModeDesc);
+ INIT_STRUCTURE_SIZE(EngineCreateInfo);
+ INIT_STRUCTURE_SIZE(EngineGLCreateInfo);
+ INIT_STRUCTURE_SIZE(EngineD3D11CreateInfo);
+ INIT_STRUCTURE_SIZE(EngineD3D12CreateInfo);
+ INIT_STRUCTURE_SIZE(EngineVkCreateInfo);
+ INIT_STRUCTURE_SIZE(EngineMtlCreateInfo);
+ INIT_STRUCTURE_SIZE(Box);
+ INIT_STRUCTURE_SIZE(TextureFormatAttribs);
+ INIT_STRUCTURE_SIZE(TextureFormatInfo);
+ INIT_STRUCTURE_SIZE(TextureFormatInfoExt);
+ INIT_STRUCTURE_SIZE(StateTransitionDesc);
+ INIT_STRUCTURE_SIZE(LayoutElement);
+ INIT_STRUCTURE_SIZE(InputLayoutDesc);
+ INIT_STRUCTURE_SIZE(SampleDesc);
+ INIT_STRUCTURE_SIZE(ShaderResourceVariableDesc);
+ INIT_STRUCTURE_SIZE(StaticSamplerDesc);
+ INIT_STRUCTURE_SIZE(PipelineResourceLayoutDesc);
+ INIT_STRUCTURE_SIZE(GraphicsPipelineDesc);
+ INIT_STRUCTURE_SIZE(ComputePipelineDesc);
+ INIT_STRUCTURE_SIZE(PipelineStateDesc);
+ INIT_STRUCTURE_SIZE(RasterizerStateDesc);
+ INIT_STRUCTURE_SIZE(ResourceMappingEntry);
+ INIT_STRUCTURE_SIZE(ResourceMappingDesc);
+ INIT_STRUCTURE_SIZE(SamplerDesc);
+ INIT_STRUCTURE_SIZE(ShaderDesc);
+ INIT_STRUCTURE_SIZE(ShaderMacro);
+ INIT_STRUCTURE_SIZE(ShaderCreateInfo);
+ INIT_STRUCTURE_SIZE(ShaderResourceDesc);
+ INIT_STRUCTURE_SIZE(DepthStencilClearValue);
+ INIT_STRUCTURE_SIZE(OptimizedClearValue);
+ INIT_STRUCTURE_SIZE(TextureDesc);
+ INIT_STRUCTURE_SIZE(TextureSubResData);
+ INIT_STRUCTURE_SIZE(TextureData);
+ INIT_STRUCTURE_SIZE(MappedTextureSubresource);
+ INIT_STRUCTURE_SIZE(TextureViewDesc);
+#undef INIT_STRUCTURE_SIZE
+
+ return Info;
+}
+
+const APIInfo& GetAPIInfo()
+{
+ static const APIInfo Info = InitAPIInfo();
+ return Info;
+}
+
+}