From 696a3cbb5a5f30d2f5000c0db90125d614ea09ca Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 6 Apr 2019 08:49:17 -0700 Subject: Made IShaderSourceInputStreamFactory derived from IObject (upgraded API Version to 240021) --- Graphics/GraphicsEngine/CMakeLists.txt | 2 + .../include/DefaultShaderSourceStreamFactory.h | 38 +++++++ .../GraphicsEngine/include/EngineFactoryBase.h | 7 ++ Graphics/GraphicsEngine/include/RenderDeviceBase.h | 94 +++++++++++------ Graphics/GraphicsEngine/interface/APIInfo.h | 2 +- Graphics/GraphicsEngine/interface/EngineFactory.h | 8 ++ Graphics/GraphicsEngine/interface/RenderDevice.h | 7 ++ Graphics/GraphicsEngine/interface/Shader.h | 6 +- .../src/DefaultShaderSourceStreamFactory.cpp | 115 +++++++++++++++++++++ .../include/RenderDeviceD3D11Impl.h | 1 + .../GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp | 2 +- .../src/RenderDeviceD3D11Impl.cpp | 23 +++-- .../include/RenderDeviceD3D12Impl.h | 3 +- .../GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp | 2 +- .../src/RenderDeviceD3D12Impl.cpp | 23 +++-- .../include/RenderDeviceD3DBase.h | 19 ++-- .../include/RenderDeviceMtlImpl.h | 1 + .../GraphicsEngineMetal/src/EngineFactoryMtl.mm | 2 +- .../GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm | 23 +++-- .../include/RenderDeviceNextGenBase.h | 39 +++---- .../include/RenderDeviceGLESImpl.h | 1 + .../include/RenderDeviceGLImpl.h | 1 + .../src/EngineFactoryOpenGL.cpp | 4 +- .../src/RenderDeviceGLESImpl.cpp | 3 +- .../src/RenderDeviceGLImpl.cpp | 23 +++-- .../include/RenderDeviceVkImpl.h | 1 + .../GraphicsEngineVulkan/src/EngineFactoryVk.cpp | 2 +- .../src/RenderDeviceVkImpl.cpp | 23 +++-- Graphics/GraphicsTools/CMakeLists.txt | 2 - .../include/BasicShaderSourceStreamFactory.h | 41 -------- .../src/BasicShaderSourceStreamFactory.cpp | 87 ---------------- 31 files changed, 346 insertions(+), 259 deletions(-) create mode 100644 Graphics/GraphicsEngine/include/DefaultShaderSourceStreamFactory.h create mode 100644 Graphics/GraphicsEngine/src/DefaultShaderSourceStreamFactory.cpp delete mode 100644 Graphics/GraphicsTools/include/BasicShaderSourceStreamFactory.h delete mode 100644 Graphics/GraphicsTools/src/BasicShaderSourceStreamFactory.cpp (limited to 'Graphics') diff --git a/Graphics/GraphicsEngine/CMakeLists.txt b/Graphics/GraphicsEngine/CMakeLists.txt index 4eb8d9aa..b7fbc23d 100644 --- a/Graphics/GraphicsEngine/CMakeLists.txt +++ b/Graphics/GraphicsEngine/CMakeLists.txt @@ -6,6 +6,7 @@ set(INCLUDE include/BufferBase.h include/BufferViewBase.h include/CommandListBase.h + include/DefaultShaderSourceStreamFactory.h include/Defines.h include/DeviceContextBase.h include/DeviceObjectBase.h @@ -57,6 +58,7 @@ set(INTERFACE set(SOURCE src/APIInfo.cpp + src/DefaultShaderSourceStreamFactory.cpp src/EngineMemory.cpp src/ResourceMapping.cpp src/Texture.cpp diff --git a/Graphics/GraphicsEngine/include/DefaultShaderSourceStreamFactory.h b/Graphics/GraphicsEngine/include/DefaultShaderSourceStreamFactory.h new file mode 100644 index 00000000..9cd9b8ad --- /dev/null +++ b/Graphics/GraphicsEngine/include/DefaultShaderSourceStreamFactory.h @@ -0,0 +1,38 @@ +/* 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 + +#include "../../../Common/interface/BasicFileStream.h" +#include "../../GraphicsEngine/interface/Shader.h" + +namespace Diligent +{ + +/// Creates default shader source stream factory +/// \param [in] SearchDirectories - Semicolon-seprated list of search directories. +/// \param [out] ppShaderSourceStreamFactory - Memory address where pointer to the shader source stream factory will be written. +void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories, + IShaderSourceInputStreamFactory** ppShaderSourceStreamFactory); + +} diff --git a/Graphics/GraphicsEngine/include/EngineFactoryBase.h b/Graphics/GraphicsEngine/include/EngineFactoryBase.h index c382afff..eb3e6aeb 100644 --- a/Graphics/GraphicsEngine/include/EngineFactoryBase.h +++ b/Graphics/GraphicsEngine/include/EngineFactoryBase.h @@ -28,6 +28,7 @@ #include "Object.h" #include "EngineFactory.h" +#include "DefaultShaderSourceStreamFactory.h" namespace Diligent { @@ -84,6 +85,12 @@ public: return Diligent::GetAPIInfo(); } + virtual void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories, + IShaderSourceInputStreamFactory** ppShaderSourceFactory)const override final + { + Diligent::CreateDefaultShaderSourceStreamFactory(SearchDirectories, ppShaderSourceFactory); + } + private: class DummyReferenceCounters final : public IReferenceCounters { diff --git a/Graphics/GraphicsEngine/include/RenderDeviceBase.h b/Graphics/GraphicsEngine/include/RenderDeviceBase.h index 3ef856e7..ee713c2e 100644 --- a/Graphics/GraphicsEngine/include/RenderDeviceBase.h +++ b/Graphics/GraphicsEngine/include/RenderDeviceBase.h @@ -184,48 +184,67 @@ public: using TObjectBase = ObjectBase; - /// \param pRefCounters - reference counters object that controls the lifetime of this render device - /// \param RawMemAllocator - allocator that will be used to allocate memory for all device objects (including render device itself) + /// Describes the sizes of device objects + struct DeviceObjectSizes + { + /// Size of the texture object (TextureD3D12Impl, TextureVkImpl, etc.), in bytes + const size_t TextureObjSize; + + /// Size of the texture view object (TextureViewD3D12Impl, TextureViewVkImpl, etc.), in bytes + const size_t TexViewObjSize; + + /// Size of the buffer object (BufferD3D12Impl, BufferVkImpl, etc.), in bytes + const size_t BufferObjSize; + + /// Size of the buffer view object (BufferViewD3D12Impl, BufferViewVkImpl, etc.), in bytes + const size_t BuffViewObjSize; + + /// Size of the shader object (ShaderD3D12Impl, ShaderVkImpl, etc.), in bytes + const size_t ShaderObjSize; + + /// Size of the sampler object (SamplerD3D12Impl, SamplerVkImpl, etc.), in bytes + const size_t SamplerObjSize; + + /// Size of the pipeline state object (PipelineStateD3D12Impl, PipelineStateVkImpl, etc.), in bytes + const size_t PSOSize; + + /// Size of the shader resource binding object (ShaderResourceBindingD3D12Impl, ShaderResourceBindingVkImpl, etc.), in bytes + const size_t SRBSize; + + /// Size of the fence object (FenceD3D12Impl, FenceVkImpl, etc.), in bytes + const size_t FenceSize; + }; + + /// \param pRefCounters - reference counters object that controls the lifetime of this render device + /// \param RawMemAllocator - allocator that will be used to allocate memory for all device objects (including render device itself) + /// \param pEngineFactory - engine factory that was used to create this device /// \param NumDeferredContexts - number of deferred device contexts - /// \param TextureObjSize - size of the texture object, in bytes - /// \param TexViewObjSize - size of the texture view object, in bytes - /// \param BufferObjSize - size of the buffer object, in bytes - /// \param BuffViewObjSize - size of the buffer view object, in bytes - /// \param ShaderObjSize - size of the shader object, in bytes - /// \param SamplerObjSize - size of the sampler object, in bytes - /// \param PSOSize - size of the pipeline state object, in bytes - /// \param SRBSize - size of the shader resource binding object, in bytes - /// \param FenceSize - size of the fence object, in bytes + /// \param ObjectSizes - device object sizes + /// /// \remarks Render device uses fixed block allocators (see FixedBlockMemoryAllocator) to allocate memory for /// device objects. The object sizes provided to constructor are used to initialize the allocators. - RenderDeviceBase(IReferenceCounters* pRefCounters, - IMemoryAllocator& RawMemAllocator, - Uint32 NumDeferredContexts, - size_t TextureObjSize, - size_t TexViewObjSize, - size_t BufferObjSize, - size_t BuffViewObjSize, - size_t ShaderObjSize, - size_t SamplerObjSize, - size_t PSOSize, - size_t SRBSize, - size_t FenceSize) : + RenderDeviceBase(IReferenceCounters* pRefCounters, + IMemoryAllocator& RawMemAllocator, + IEngineFactory* pEngineFactory, + Uint32 NumDeferredContexts, + const DeviceObjectSizes& ObjectSizes) : TObjectBase (pRefCounters), + m_pEngineFactory (pEngineFactory), m_SamplersRegistry (RawMemAllocator, "sampler"), m_TextureFormatsInfo (TEX_FORMAT_NUM_FORMATS, TextureFormatInfoExt(), STD_ALLOCATOR_RAW_MEM(TextureFormatInfoExt, RawMemAllocator, "Allocator for vector") ), m_TexFmtInfoInitFlags (TEX_FORMAT_NUM_FORMATS, false, STD_ALLOCATOR_RAW_MEM(bool, RawMemAllocator, "Allocator for vector") ), m_wpDeferredContexts (NumDeferredContexts, RefCntWeakPtr(), STD_ALLOCATOR_RAW_MEM(RefCntWeakPtr, RawMemAllocator, "Allocator for vector< RefCntWeakPtr >")), m_RawMemAllocator (RawMemAllocator), - m_TexObjAllocator (RawMemAllocator, TextureObjSize, 64), - m_TexViewObjAllocator (RawMemAllocator, TexViewObjSize, 64), - m_BufObjAllocator (RawMemAllocator, BufferObjSize, 128), - m_BuffViewObjAllocator (RawMemAllocator, BuffViewObjSize, 128), - m_ShaderObjAllocator (RawMemAllocator, ShaderObjSize, 32), - m_SamplerObjAllocator (RawMemAllocator, SamplerObjSize, 32), - m_PSOAllocator (RawMemAllocator, PSOSize, 128), - m_SRBAllocator (RawMemAllocator, SRBSize, 1024), - m_ResMappingAllocator (RawMemAllocator, sizeof(ResourceMappingImpl), 16), - m_FenceAllocator (RawMemAllocator, FenceSize, 16) + m_TexObjAllocator (RawMemAllocator, ObjectSizes.TextureObjSize, 64), + m_TexViewObjAllocator (RawMemAllocator, ObjectSizes.TexViewObjSize, 64), + m_BufObjAllocator (RawMemAllocator, ObjectSizes.BufferObjSize, 128), + m_BuffViewObjAllocator (RawMemAllocator, ObjectSizes.BuffViewObjSize, 128), + m_ShaderObjAllocator (RawMemAllocator, ObjectSizes.ShaderObjSize, 32), + m_SamplerObjAllocator (RawMemAllocator, ObjectSizes.SamplerObjSize, 32), + m_PSOAllocator (RawMemAllocator, ObjectSizes.PSOSize, 128), + m_SRBAllocator (RawMemAllocator, ObjectSizes.SRBSize, 1024), + m_ResMappingAllocator (RawMemAllocator, sizeof(ResourceMappingImpl), 16), + m_FenceAllocator (RawMemAllocator, ObjectSizes.FenceSize, 16) { // Initialize texture format info for( Uint32 Fmt = TEX_FORMAT_UNKNOWN; Fmt < TEX_FORMAT_NUM_FORMATS; ++Fmt ) @@ -323,7 +342,12 @@ public: return TexFmtInfo; } - void OnCreateDeviceObject( IDeviceObject* pNewObject ) + virtual IEngineFactory* GetEngineFactory() const override final + { + return m_pEngineFactory.RawPtr(); + } + + void OnCreateDeviceObject(IDeviceObject* pNewObject) { } @@ -364,6 +388,8 @@ protected: template void CreateDeviceObject( const Char *ObjectTypeName, const TObjectDescType &Desc, TObjectType **ppObject, TObjectConstructor ConstructObject ); + RefCntAutoPtr m_pEngineFactory; + DeviceCaps m_DeviceCaps; // All state object registries hold raw pointers. diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h index 32230be1..e4db0bf3 100644 --- a/Graphics/GraphicsEngine/interface/APIInfo.h +++ b/Graphics/GraphicsEngine/interface/APIInfo.h @@ -26,7 +26,7 @@ /// \file /// Diligent API information -#define DILIGENT_API_VERSION 240020 +#define DILIGENT_API_VERSION 240021 #include "../../../Primitives/interface/BasicTypes.h" diff --git a/Graphics/GraphicsEngine/interface/EngineFactory.h b/Graphics/GraphicsEngine/interface/EngineFactory.h index aebb654a..5508d841 100644 --- a/Graphics/GraphicsEngine/interface/EngineFactory.h +++ b/Graphics/GraphicsEngine/interface/EngineFactory.h @@ -32,6 +32,8 @@ namespace Diligent { +class IShaderSourceInputStreamFactory; + // {D932B052-4ED6-4729-A532-F31DEEC100F3} static constexpr INTERFACE_ID IID_EngineFactory = { 0xd932b052, 0x4ed6, 0x4729, { 0xa5, 0x32, 0xf3, 0x1d, 0xee, 0xc1, 0x0, 0xf3 } }; @@ -43,6 +45,12 @@ class IEngineFactory : public IObject public: /// Returns API info structure virtual const APIInfo& GetAPIInfo() const = 0; + + /// Creates default shader source input stream factory + /// \param [in] SearchDirectories - Semicolon-seprated list of search directories. + /// \param [out] ppShaderSourceStreamFactory - Memory address where pointer to the shader source stream factory will be written. + virtual void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories, + IShaderSourceInputStreamFactory** ppShaderSourceFactory)const = 0; }; } diff --git a/Graphics/GraphicsEngine/interface/RenderDevice.h b/Graphics/GraphicsEngine/interface/RenderDevice.h index ece8eda3..333263cc 100644 --- a/Graphics/GraphicsEngine/interface/RenderDevice.h +++ b/Graphics/GraphicsEngine/interface/RenderDevice.h @@ -27,6 +27,7 @@ /// Definition of the Diligent::IRenderDevice interface and related data structures #include "../../../Primitives/interface/Object.h" +#include "EngineFactory.h" #include "GraphicsTypes.h" #include "DeviceCaps.h" #include "Constants.h" @@ -188,6 +189,12 @@ public: /// great care only if you are sure the resources are not /// in use by the GPU (such as when the device has just been idled). virtual void ReleaseStaleResources(bool ForceRelease = false) = 0; + + + /// Returns engine factory this device was created from. + /// \remark This method does not increment the reference counter of the returned interface, + /// so the application should not call Release(). + virtual IEngineFactory* GetEngineFactory() const = 0; }; } diff --git a/Graphics/GraphicsEngine/interface/Shader.h b/Graphics/GraphicsEngine/interface/Shader.h index c993bf4a..7b243a38 100644 --- a/Graphics/GraphicsEngine/interface/Shader.h +++ b/Graphics/GraphicsEngine/interface/Shader.h @@ -82,8 +82,12 @@ struct ShaderDesc : DeviceObjectAttribs }; +// {3EA98781-082F-4413-8C30-B9BA6D82DBB7} +static constexpr INTERFACE_ID IID_IShaderSourceInputStreamFactory = +{ 0x3ea98781, 0x82f, 0x4413, { 0x8c, 0x30, 0xb9, 0xba, 0x6d, 0x82, 0xdb, 0xb7 } }; + /// Shader source stream factory interface -class IShaderSourceInputStreamFactory +class IShaderSourceInputStreamFactory : public IObject { public: virtual void CreateInputStream(const Diligent::Char *Name, IFileStream **ppStream) = 0; diff --git a/Graphics/GraphicsEngine/src/DefaultShaderSourceStreamFactory.cpp b/Graphics/GraphicsEngine/src/DefaultShaderSourceStreamFactory.cpp new file mode 100644 index 00000000..d3bfbd77 --- /dev/null +++ b/Graphics/GraphicsEngine/src/DefaultShaderSourceStreamFactory.cpp @@ -0,0 +1,115 @@ +/* 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 "pch.h" +#include "DefaultShaderSourceStreamFactory.h" +#include "ObjectBase.h" +#include "RefCntAutoPtr.h" +#include "EngineMemory.h" + +namespace Diligent +{ + +class DefaultShaderSourceStreamFactory final : public ObjectBase +{ +public: + DefaultShaderSourceStreamFactory(IReferenceCounters* pRefCounters, const Char *SearchDirectories); + + virtual void CreateInputStream(const Char *Name, IFileStream **ppStream)override final; + + IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_IShaderSourceInputStreamFactory, ObjectBase); + +private: + std::vector m_SearchDirectories; +}; + +DefaultShaderSourceStreamFactory::DefaultShaderSourceStreamFactory(IReferenceCounters* pRefCounters, const Char* SearchDirectories) : + ObjectBase(pRefCounters) +{ + while( SearchDirectories ) + { + const char* Semicolon = strchr( SearchDirectories, ';' ); + String SearchPath; + if( Semicolon == nullptr ) + { + SearchPath = SearchDirectories; + SearchDirectories = nullptr; + } + else + { + SearchPath = String( SearchDirectories, Semicolon ); + SearchDirectories = Semicolon + 1; + } + + if( SearchPath.length() > 0 ) + { + if( SearchPath.back() != '\\' && SearchPath.back() != '/' ) + SearchPath.push_back( '\\' ); + m_SearchDirectories.push_back( SearchPath ); + } + } + m_SearchDirectories.push_back( "" ); +} + +void DefaultShaderSourceStreamFactory::CreateInputStream( const Diligent::Char *Name, IFileStream **ppStream ) +{ + bool bFileCreated = false; + Diligent::RefCntAutoPtr pBasicFileStream; + for (const auto &SearchDir : m_SearchDirectories) + { + String FullPath = SearchDir + ( (Name[0] == '\\' || Name[0] == '/') ? Name + 1 : Name); + if (!FileSystem::FileExists(FullPath.c_str())) + continue; + pBasicFileStream = MakeNewRCObj()( FullPath.c_str(), EFileAccessMode::Read ); + if (pBasicFileStream->IsValid()) + { + bFileCreated = true; + break; + } + else + { + pBasicFileStream.Release(); + } + } + if (bFileCreated) + { + pBasicFileStream->QueryInterface( IID_FileStream, reinterpret_cast(ppStream) ); + } + else + { + *ppStream = nullptr; + LOG_ERROR( "Failed to create input stream for source file ", Name ); + } +} + +void CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories, + IShaderSourceInputStreamFactory** ppShaderSourceStreamFactory) +{ + + auto& Allocator = GetRawAllocator(); + DefaultShaderSourceStreamFactory* pStreamFactory = + NEW_RC_OBJ(Allocator, "DefaultShaderSourceStreamFactory instance", DefaultShaderSourceStreamFactory)(SearchDirectories); + pStreamFactory->QueryInterface(IID_IShaderSourceInputStreamFactory, reinterpret_cast(ppShaderSourceStreamFactory)); +} + +} diff --git a/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.h index b325554f..5416d9b1 100644 --- a/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.h @@ -41,6 +41,7 @@ public: RenderDeviceD3D11Impl( IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, + IEngineFactory* pEngineFactory, const EngineD3D11CreateInfo& EngineAttribs, ID3D11Device* pd3d11Device, Uint32 NumDeferredContexts ); diff --git a/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp index 581250f8..7be30f0c 100644 --- a/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp @@ -234,7 +234,7 @@ void EngineFactoryD3D11Impl::AttachToD3D11Device(void* pd SetRawAllocator(EngineCI.pRawMemAllocator); auto &RawAlloctor = GetRawAllocator(); RenderDeviceD3D11Impl *pRenderDeviceD3D11(NEW_RC_OBJ(RawAlloctor, "RenderDeviceD3D11Impl instance", RenderDeviceD3D11Impl) - (RawAlloctor, EngineCI, pd3d11Device, EngineCI.NumDeferredContexts)); + (RawAlloctor, this, EngineCI, pd3d11Device, EngineCI.NumDeferredContexts)); pRenderDeviceD3D11->QueryInterface(IID_RenderDevice, reinterpret_cast(ppDevice)); RefCntAutoPtr pDeviceContextD3D11(NEW_RC_OBJ(RawAlloctor, "DeviceContextD3D11Impl instance", DeviceContextD3D11Impl) diff --git a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp index 04f54ad5..ebae97fc 100644 --- a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp @@ -42,6 +42,7 @@ namespace Diligent RenderDeviceD3D11Impl :: RenderDeviceD3D11Impl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, + IEngineFactory* pEngineFactory, const EngineD3D11CreateInfo& EngineAttribs, ID3D11Device* pd3d11Device, Uint32 NumDeferredContexts) : @@ -49,16 +50,20 @@ RenderDeviceD3D11Impl :: RenderDeviceD3D11Impl(IReferenceCounters* pRef { pRefCounters, RawMemAllocator, + pEngineFactory, NumDeferredContexts, - sizeof(TextureBaseD3D11), - sizeof(TextureViewD3D11Impl), - sizeof(BufferD3D11Impl), - sizeof(BufferViewD3D11Impl), - sizeof(ShaderD3D11Impl), - sizeof(SamplerD3D11Impl), - sizeof(PipelineStateD3D11Impl), - sizeof(ShaderResourceBindingD3D11Impl), - sizeof(FenceD3D11Impl) + DeviceObjectSizes + { + sizeof(TextureBaseD3D11), + sizeof(TextureViewD3D11Impl), + sizeof(BufferD3D11Impl), + sizeof(BufferViewD3D11Impl), + sizeof(ShaderD3D11Impl), + sizeof(SamplerD3D11Impl), + sizeof(PipelineStateD3D11Impl), + sizeof(ShaderResourceBindingD3D11Impl), + sizeof(FenceD3D11Impl) + } }, m_EngineAttribs(EngineAttribs), m_pd3d11Device(pd3d11Device) diff --git a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h index a44d40ff..0551f7d0 100644 --- a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h @@ -46,7 +46,8 @@ public: using TRenderDeviceBase = RenderDeviceNextGenBase< RenderDeviceD3DBase, ICommandQueueD3D12 >; RenderDeviceD3D12Impl(IReferenceCounters* pRefCounters, - IMemoryAllocator& RawMemAllocator, + IMemoryAllocator& RawMemAllocator, + IEngineFactory* pEngineFactory, const EngineD3D12CreateInfo& EngineCI, ID3D12Device* pD3D12Device, size_t CommandQueueCount, diff --git a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp index 6806fafc..53ede9e3 100644 --- a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp @@ -300,7 +300,7 @@ void EngineFactoryD3D12Impl::AttachToD3D12Device(void* pd SetRawAllocator(EngineCI.pRawMemAllocator); auto &RawMemAllocator = GetRawAllocator(); auto d3d12Device = reinterpret_cast(pd3d12NativeDevice); - RenderDeviceD3D12Impl *pRenderDeviceD3D12( NEW_RC_OBJ(RawMemAllocator, "RenderDeviceD3D12Impl instance", RenderDeviceD3D12Impl)(RawMemAllocator, EngineCI, d3d12Device, CommandQueueCount, ppCommandQueues) ); + RenderDeviceD3D12Impl *pRenderDeviceD3D12( NEW_RC_OBJ(RawMemAllocator, "RenderDeviceD3D12Impl instance", RenderDeviceD3D12Impl)(RawMemAllocator, this, EngineCI, d3d12Device, CommandQueueCount, ppCommandQueues) ); pRenderDeviceD3D12->QueryInterface(IID_RenderDevice, reinterpret_cast(ppDevice) ); RefCntAutoPtr pImmediateCtxD3D12( NEW_RC_OBJ(RawMemAllocator, "DeviceContextD3D12Impl instance", DeviceContextD3D12Impl)(pRenderDeviceD3D12, false, EngineCI, 0, 0) ); diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp index 3d35d334..15e48743 100644 --- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp @@ -39,6 +39,7 @@ namespace Diligent RenderDeviceD3D12Impl :: RenderDeviceD3D12Impl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, + IEngineFactory* pEngineFactory, const EngineD3D12CreateInfo& EngineCI, ID3D12Device* pd3d12Device, size_t CommandQueueCount, @@ -47,18 +48,22 @@ RenderDeviceD3D12Impl :: RenderDeviceD3D12Impl(IReferenceCounters* pRe { pRefCounters, RawMemAllocator, + pEngineFactory, CommandQueueCount, ppCmdQueues, EngineCI.NumDeferredContexts, - sizeof(TextureD3D12Impl), - sizeof(TextureViewD3D12Impl), - sizeof(BufferD3D12Impl), - sizeof(BufferViewD3D12Impl), - sizeof(ShaderD3D12Impl), - sizeof(SamplerD3D12Impl), - sizeof(PipelineStateD3D12Impl), - sizeof(ShaderResourceBindingD3D12Impl), - sizeof(FenceD3D12Impl) + DeviceObjectSizes + { + sizeof(TextureD3D12Impl), + sizeof(TextureViewD3D12Impl), + sizeof(BufferD3D12Impl), + sizeof(BufferViewD3D12Impl), + sizeof(ShaderD3D12Impl), + sizeof(SamplerD3D12Impl), + sizeof(PipelineStateD3D12Impl), + sizeof(ShaderResourceBindingD3D12Impl), + sizeof(FenceD3D12Impl) + } }, m_pd3d12Device (pd3d12Device), m_EngineAttribs (EngineCI), diff --git a/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.h b/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.h index 1715cd48..c784bcce 100644 --- a/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.h +++ b/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.h @@ -37,19 +37,12 @@ template class RenderDeviceD3DBase : public RenderDeviceBase { public: - RenderDeviceD3DBase(IReferenceCounters *pRefCounters, - IMemoryAllocator &RawMemAllocator, - Uint32 NumDeferredContexts, - size_t TextureObjSize, - size_t TexViewObjSize, - size_t BufferObjSize, - size_t BuffViewObjSize, - size_t ShaderObjSize, - size_t SamplerObjSize, - size_t PSOSize, - size_t SRBSize, - size_t FenceSize) : - RenderDeviceBase(pRefCounters, RawMemAllocator, NumDeferredContexts, TextureObjSize, TexViewObjSize, BufferObjSize, BuffViewObjSize, ShaderObjSize, SamplerObjSize, PSOSize, SRBSize, FenceSize) + RenderDeviceD3DBase(IReferenceCounters* pRefCounters, + IMemoryAllocator& RawMemAllocator, + IEngineFactory* pEngineFactory, + Uint32 NumDeferredContexts, + const DeviceObjectSizes& ObjectSizes) : + RenderDeviceBase(pRefCounters, RawMemAllocator, pEngineFactory, NumDeferredContexts, ObjectSizes) { // Flag texture formats always supported in D3D11 and D3D12 diff --git a/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h b/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h index 9760c92a..0b10967f 100644 --- a/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h +++ b/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h @@ -41,6 +41,7 @@ public: RenderDeviceMtlImpl( IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, + IEngineFactory* pEngineFactory, const EngineMtlCreateInfo& EngineAttribs, void* pMtlDevice); diff --git a/Graphics/GraphicsEngineMetal/src/EngineFactoryMtl.mm b/Graphics/GraphicsEngineMetal/src/EngineFactoryMtl.mm index ebead420..e87dbc27 100644 --- a/Graphics/GraphicsEngineMetal/src/EngineFactoryMtl.mm +++ b/Graphics/GraphicsEngineMetal/src/EngineFactoryMtl.mm @@ -123,7 +123,7 @@ void EngineFactoryMtlImpl::AttachToMtlDevice(void* pMtlNat SetRawAllocator(EngineCI.pRawMemAllocator); auto& RawAlloctor = GetRawAllocator(); RenderDeviceMtlImpl* pRenderDeviceMtl(NEW_RC_OBJ(RawAlloctor, "RenderDeviceMtlImpl instance", RenderDeviceMtlImpl) - (RawAlloctor, EngineCI, pMtlNativeDevice)); + (RawAlloctor, this, EngineCI, pMtlNativeDevice)); pRenderDeviceMtl->QueryInterface(IID_RenderDevice, reinterpret_cast(ppDevice)); RefCntAutoPtr pDeviceContextMtl(NEW_RC_OBJ(RawAlloctor, "DeviceContextMtlImpl instance", DeviceContextMtlImpl) diff --git a/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm index 55f57208..181314db 100644 --- a/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm +++ b/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm @@ -39,22 +39,27 @@ namespace Diligent RenderDeviceMtlImpl :: RenderDeviceMtlImpl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, + IEngineFactory* pEngineFactory, const EngineMtlCreateInfo& EngineAttribs, void* pMtlDevice) : TRenderDeviceBase { pRefCounters, RawMemAllocator, + pEngineFactory, EngineAttribs.NumDeferredContexts, - sizeof(TextureMtlImpl), - sizeof(TextureViewMtlImpl), - sizeof(BufferMtlImpl), - sizeof(BufferViewMtlImpl), - sizeof(ShaderMtlImpl), - sizeof(SamplerMtlImpl), - sizeof(PipelineStateMtlImpl), - sizeof(ShaderResourceBindingMtlImpl), - sizeof(FenceMtlImpl) + DeviceObjectSizes + { + sizeof(TextureMtlImpl), + sizeof(TextureViewMtlImpl), + sizeof(BufferMtlImpl), + sizeof(BufferViewMtlImpl), + sizeof(ShaderMtlImpl), + sizeof(SamplerMtlImpl), + sizeof(PipelineStateMtlImpl), + sizeof(ShaderResourceBindingMtlImpl), + sizeof(FenceMtlImpl) + } }, m_EngineAttribs(EngineAttribs) { diff --git a/Graphics/GraphicsEngineNextGenBase/include/RenderDeviceNextGenBase.h b/Graphics/GraphicsEngineNextGenBase/include/RenderDeviceNextGenBase.h index c2022c2a..10e2baeb 100644 --- a/Graphics/GraphicsEngineNextGenBase/include/RenderDeviceNextGenBase.h +++ b/Graphics/GraphicsEngineNextGenBase/include/RenderDeviceNextGenBase.h @@ -26,6 +26,7 @@ #include #include +#include "EngineFactory.h" #include "Atomics.h" #include "BasicTypes.h" #include "ReferenceCounters.h" @@ -43,33 +44,17 @@ template class RenderDeviceNextGenBase : public TBase { public: - RenderDeviceNextGenBase(IReferenceCounters* pRefCounters, - IMemoryAllocator& RawMemAllocator, - size_t CmdQueueCount, - CommandQueueType** Queues, - Uint32 NumDeferredContexts, - size_t TextureObjSize, - size_t TexViewObjSize, - size_t BufferObjSize, - size_t BuffViewObjSize, - size_t ShaderObjSize, - size_t SamplerObjSize, - size_t PSOSize, - size_t SRBSize, - size_t FenceSize) : - TBase(pRefCounters, - RawMemAllocator, - NumDeferredContexts, - TextureObjSize, - TexViewObjSize, - BufferObjSize, - BuffViewObjSize, - ShaderObjSize, - SamplerObjSize, - PSOSize, - SRBSize, - FenceSize), - m_CmdQueueCount(CmdQueueCount) + using typename TBase::DeviceObjectSizes; + + RenderDeviceNextGenBase(IReferenceCounters* pRefCounters, + IMemoryAllocator& RawMemAllocator, + IEngineFactory* pEngineFactory, + size_t CmdQueueCount, + CommandQueueType** Queues, + Uint32 NumDeferredContexts, + const DeviceObjectSizes& ObjectSizes) : + TBase (pRefCounters, RawMemAllocator, pEngineFactory, NumDeferredContexts, ObjectSizes), + m_CmdQueueCount (CmdQueueCount) { m_CommandQueues = reinterpret_cast(ALLOCATE(this->m_RawMemAllocator, "Raw memory for the device command/release queues", sizeof(CommandQueue)*m_CmdQueueCount)); for(size_t q=0; q < m_CmdQueueCount; ++q) diff --git a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLESImpl.h b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLESImpl.h index 57a966f2..c8e23561 100644 --- a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLESImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLESImpl.h @@ -33,6 +33,7 @@ class RenderDeviceGLESImpl final : public RenderDeviceGLImpl public: RenderDeviceGLESImpl( IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, + IEngineFactory* pEngineFactory, const EngineGLCreateInfo& InitAttribs, const SwapChainDesc* pSCDesc = nullptr); diff --git a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h index cb278aa8..ce3aaee5 100644 --- a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h @@ -56,6 +56,7 @@ public: RenderDeviceGLImpl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, + IEngineFactory* pEngineFactory, const EngineGLCreateInfo& InitAttribs, const SwapChainDesc* pSCDesc = nullptr); ~RenderDeviceGLImpl(); diff --git a/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp b/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp index c44021d6..1e0c470f 100644 --- a/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp @@ -126,7 +126,7 @@ void EngineFactoryOpenGLImpl::CreateDeviceAndSwapChainGL(const EngineGLCreateInf SetRawAllocator(EngineCI.pRawMemAllocator); auto &RawMemAllocator = GetRawAllocator(); - RenderDeviceGLImpl *pRenderDeviceOpenGL( NEW_RC_OBJ(RawMemAllocator, "TRenderDeviceGLImpl instance", TRenderDeviceGLImpl)(RawMemAllocator, EngineCI, &SCDesc) ); + RenderDeviceGLImpl *pRenderDeviceOpenGL( NEW_RC_OBJ(RawMemAllocator, "TRenderDeviceGLImpl instance", TRenderDeviceGLImpl)(RawMemAllocator, this, EngineCI, &SCDesc) ); pRenderDeviceOpenGL->QueryInterface(IID_RenderDevice, reinterpret_cast(ppDevice) ); DeviceContextGLImpl* pDeviceContextOpenGL( NEW_RC_OBJ(RawMemAllocator, "DeviceContextGLImpl instance", DeviceContextGLImpl)(pRenderDeviceOpenGL, false ) ); @@ -199,7 +199,7 @@ void EngineFactoryOpenGLImpl::AttachToActiveGLContext(const EngineGLCreateInfo& SetRawAllocator(EngineCI.pRawMemAllocator); auto &RawMemAllocator = GetRawAllocator(); - RenderDeviceGLImpl *pRenderDeviceOpenGL( NEW_RC_OBJ(RawMemAllocator, "TRenderDeviceGLImpl instance", TRenderDeviceGLImpl)(RawMemAllocator, EngineCI) ); + RenderDeviceGLImpl *pRenderDeviceOpenGL( NEW_RC_OBJ(RawMemAllocator, "TRenderDeviceGLImpl instance", TRenderDeviceGLImpl)(RawMemAllocator, this, EngineCI) ); pRenderDeviceOpenGL->QueryInterface(IID_RenderDevice, reinterpret_cast(ppDevice) ); DeviceContextGLImpl* pDeviceContextOpenGL( NEW_RC_OBJ(RawMemAllocator, "DeviceContextGLImpl instance", DeviceContextGLImpl)(pRenderDeviceOpenGL, false ) ); diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLESImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLESImpl.cpp index 8edc0fcf..3ee32be7 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLESImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLESImpl.cpp @@ -29,9 +29,10 @@ namespace Diligent { RenderDeviceGLESImpl::RenderDeviceGLESImpl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, + IEngineFactory* pEngineFactory, const EngineGLCreateInfo& InitAttribs, const SwapChainDesc* pSCDesc) : - RenderDeviceGLImpl(pRefCounters, RawMemAllocator, InitAttribs, pSCDesc) + RenderDeviceGLImpl(pRefCounters, RawMemAllocator, pEngineFactory, InitAttribs, pSCDesc) { } diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp index 6e5ba17c..4951be30 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp @@ -49,22 +49,27 @@ namespace Diligent RenderDeviceGLImpl :: RenderDeviceGLImpl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, + IEngineFactory* pEngineFactory, const EngineGLCreateInfo& InitAttribs, const SwapChainDesc* pSCDesc): TRenderDeviceBase { pRefCounters, RawMemAllocator, + pEngineFactory, 0, - sizeof(TextureBaseGL), - sizeof(TextureViewGLImpl), - sizeof(BufferGLImpl), - sizeof(BufferViewGLImpl), - sizeof(ShaderGLImpl), - sizeof(SamplerGLImpl), - sizeof(PipelineStateGLImpl), - sizeof(ShaderResourceBindingGLImpl), - sizeof(FenceGLImpl) + DeviceObjectSizes + { + sizeof(TextureBaseGL), + sizeof(TextureViewGLImpl), + sizeof(BufferGLImpl), + sizeof(BufferViewGLImpl), + sizeof(ShaderGLImpl), + sizeof(SamplerGLImpl), + sizeof(PipelineStateGLImpl), + sizeof(ShaderResourceBindingGLImpl), + sizeof(FenceGLImpl) + } }, // Device caps must be filled in before the constructor of Pipeline Cache is called! m_GLContext(InitAttribs, m_DeviceCaps, pSCDesc), diff --git a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h index ec762ec9..c4cd3210 100644 --- a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h @@ -57,6 +57,7 @@ public: RenderDeviceVkImpl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, + IEngineFactory* pEngineFactory, const EngineVkCreateInfo& EngineCI, size_t CommandQueueCount, ICommandQueueVk** pCmdQueues, diff --git a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp index 40db1ccf..57b36201 100644 --- a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp @@ -251,7 +251,7 @@ void EngineFactoryVkImpl::AttachToVulkanDevice(std::shared_ptrQueryInterface(IID_RenderDevice, reinterpret_cast(ppDevice) ); std::shared_ptr GenerateMipsHelper(new GenerateMipsVkHelper(*pRenderDeviceVk)); diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp index e31acc55..271af6e0 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp @@ -39,6 +39,7 @@ namespace Diligent RenderDeviceVkImpl :: RenderDeviceVkImpl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, + IEngineFactory* pEngineFactory, const EngineVkCreateInfo& EngineCI, size_t CommandQueueCount, ICommandQueueVk** CmdQueues, @@ -49,18 +50,22 @@ RenderDeviceVkImpl :: RenderDeviceVkImpl(IReferenceCounters* { pRefCounters, RawMemAllocator, + pEngineFactory, CommandQueueCount, CmdQueues, EngineCI.NumDeferredContexts, - sizeof(TextureVkImpl), - sizeof(TextureViewVkImpl), - sizeof(BufferVkImpl), - sizeof(BufferViewVkImpl), - sizeof(ShaderVkImpl), - sizeof(SamplerVkImpl), - sizeof(PipelineStateVkImpl), - sizeof(ShaderResourceBindingVkImpl), - sizeof(FenceVkImpl) + DeviceObjectSizes + { + sizeof(TextureVkImpl), + sizeof(TextureViewVkImpl), + sizeof(BufferVkImpl), + sizeof(BufferViewVkImpl), + sizeof(ShaderVkImpl), + sizeof(SamplerVkImpl), + sizeof(PipelineStateVkImpl), + sizeof(ShaderResourceBindingVkImpl), + sizeof(FenceVkImpl) + } }, m_VulkanInstance(Instance), m_PhysicalDevice(std::move(PhysicalDevice)), diff --git a/Graphics/GraphicsTools/CMakeLists.txt b/Graphics/GraphicsTools/CMakeLists.txt index c6f2144e..05061415 100644 --- a/Graphics/GraphicsTools/CMakeLists.txt +++ b/Graphics/GraphicsTools/CMakeLists.txt @@ -3,7 +3,6 @@ cmake_minimum_required (VERSION 3.6) project(GraphicsTools CXX) set(INCLUDE - include/BasicShaderSourceStreamFactory.h include/CommonlyUsedStates.h include/GraphicsUtilities.h include/pch.h @@ -14,7 +13,6 @@ set(INCLUDE ) set(SOURCE - src/BasicShaderSourceStreamFactory.cpp src/GraphicsUtilities.cpp src/ScreenCapture.cpp src/pch.cpp diff --git a/Graphics/GraphicsTools/include/BasicShaderSourceStreamFactory.h b/Graphics/GraphicsTools/include/BasicShaderSourceStreamFactory.h deleted file mode 100644 index 625df71f..00000000 --- a/Graphics/GraphicsTools/include/BasicShaderSourceStreamFactory.h +++ /dev/null @@ -1,41 +0,0 @@ -/* 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 - -#include "../../../Common/interface/BasicFileStream.h" -#include "../../GraphicsEngine/interface/Shader.h" - -namespace Diligent -{ - class BasicShaderSourceStreamFactory : public IShaderSourceInputStreamFactory - { - public: - BasicShaderSourceStreamFactory( const Char *SearchDirectories = nullptr ); - - virtual void CreateInputStream( const Char *Name, IFileStream **ppStream )override; - - private: - std::vector m_SearchDirectories; - }; -} diff --git a/Graphics/GraphicsTools/src/BasicShaderSourceStreamFactory.cpp b/Graphics/GraphicsTools/src/BasicShaderSourceStreamFactory.cpp deleted file mode 100644 index 43c6baae..00000000 --- a/Graphics/GraphicsTools/src/BasicShaderSourceStreamFactory.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* 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 "pch.h" -#include "BasicShaderSourceStreamFactory.h" -#include "RefCntAutoPtr.h" - -namespace Diligent -{ - BasicShaderSourceStreamFactory::BasicShaderSourceStreamFactory( const Char *SearchDirectories ) - { - while( SearchDirectories ) - { - const char* Semicolon = strchr( SearchDirectories, ';' ); - String SearchPath; - if( Semicolon == nullptr ) - { - SearchPath = SearchDirectories; - SearchDirectories = nullptr; - } - else - { - SearchPath = String( SearchDirectories, Semicolon ); - SearchDirectories = Semicolon + 1; - } - - if( SearchPath.length() > 0 ) - { - if( SearchPath.back() != '\\' && SearchPath.back() != '/' ) - SearchPath.push_back( '\\' ); - m_SearchDirectories.push_back( SearchPath ); - } - } - m_SearchDirectories.push_back( "" ); - } - - void BasicShaderSourceStreamFactory::CreateInputStream( const Diligent::Char *Name, IFileStream **ppStream ) - { - bool bFileCreated = false; - Diligent::RefCntAutoPtr pBasicFileStream; - for( const auto &SearchDir : m_SearchDirectories ) - { - String FullPath = SearchDir + ( (Name[0] == '\\' || Name[0] == '/') ? Name + 1 : Name); - if( !FileSystem::FileExists( FullPath.c_str() ) ) - continue; - pBasicFileStream = MakeNewRCObj()( FullPath.c_str(), EFileAccessMode::Read ); - if( pBasicFileStream->IsValid() ) - { - bFileCreated = true; - break; - } - else - { - pBasicFileStream.Release(); - } - } - if( bFileCreated ) - { - pBasicFileStream->QueryInterface( IID_FileStream, reinterpret_cast(ppStream) ); - } - else - { - *ppStream = nullptr; - LOG_ERROR( "Failed to create input stream for source file ", Name ); - } - } -} \ No newline at end of file -- cgit v1.2.3