From 261869609fc566e74bc989919d5a204c76421f66 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 5 Mar 2019 20:01:30 -0800 Subject: Fixed Metal backend stub --- Graphics/GraphicsEngineMetal/CMakeLists.txt | 7 +- .../interface/EngineFactoryMtl.h | 66 ++++++ .../interface/EngineMtlAttribs.h | 38 ---- .../interface/RenderDeviceFactoryMtl.h | 66 ------ .../GraphicsEngineMetal/src/EngineFactoryMtl.mm | 249 +++++++++++++++++++++ .../src/RenderDeviceFactoryMtl.mm | 249 --------------------- 6 files changed, 318 insertions(+), 357 deletions(-) create mode 100644 Graphics/GraphicsEngineMetal/interface/EngineFactoryMtl.h delete mode 100644 Graphics/GraphicsEngineMetal/interface/EngineMtlAttribs.h delete mode 100644 Graphics/GraphicsEngineMetal/interface/RenderDeviceFactoryMtl.h create mode 100644 Graphics/GraphicsEngineMetal/src/EngineFactoryMtl.mm delete mode 100644 Graphics/GraphicsEngineMetal/src/RenderDeviceFactoryMtl.mm (limited to 'Graphics/GraphicsEngineMetal') diff --git a/Graphics/GraphicsEngineMetal/CMakeLists.txt b/Graphics/GraphicsEngineMetal/CMakeLists.txt index 6a2bb29d..294d7276 100644 --- a/Graphics/GraphicsEngineMetal/CMakeLists.txt +++ b/Graphics/GraphicsEngineMetal/CMakeLists.txt @@ -9,7 +9,7 @@ set(INCLUDE include/CommandListMtlImpl.h include/MtlTypeConversions.h include/DeviceContextMtlImpl.h - include/FenceMtlImpl.h + include/FenceMtlImpl.h include/PipelineStateMtlImpl.h include/RenderDeviceMtlImpl.h include/SamplerMtlImpl.h @@ -24,11 +24,10 @@ set(INTERFACE interface/BufferMtl.h interface/BufferViewMtl.h interface/DeviceContextMtl.h - interface/EngineMtlAttribs.h + interface/EngineFactoryMtl.h interface/FenceMtl.h interface/PipelineStateMtl.h interface/RenderDeviceMtl.h - interface/RenderDeviceFactoryMtl.h interface/SamplerMtl.h interface/ShaderMtl.h interface/ShaderResourceBindingMtl.h @@ -44,10 +43,10 @@ set(SRC src/CommandListMtlImpl.mm src/MtlTypeConversions.mm src/DeviceContextMtlImpl.mm + src/EngineFactoryMtl.mm src/FenceMtlImpl.mm src/PipelineStateMtlImpl.mm src/RenderDeviceMtlImpl.mm - src/RenderDeviceFactoryMtl.mm src/SamplerMtlImpl.mm src/ShaderMtlImpl.mm src/ShaderResourceBindingMtlImpl.mm diff --git a/Graphics/GraphicsEngineMetal/interface/EngineFactoryMtl.h b/Graphics/GraphicsEngineMetal/interface/EngineFactoryMtl.h new file mode 100644 index 00000000..01888518 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/interface/EngineFactoryMtl.h @@ -0,0 +1,66 @@ +/* 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 +/// Declaration of functions that initialize Vulkan-based engine implementation + +#include + +#include "../../GraphicsEngine/interface/RenderDevice.h" +#include "../../GraphicsEngine/interface/DeviceContext.h" +#include "../../GraphicsEngine/interface/SwapChain.h" +#include "EngineMtlAttribs.h" + +// https://gcc.gnu.org/wiki/Visibility +#define API_QUALIFIER __attribute__((visibility("default"))) + +namespace Diligent +{ + +class IEngineFactoryMtl +{ +public: + virtual void CreateDeviceAndContextsMtl(const EngineMtlCreateInfo& Attribs, + IRenderDevice** ppDevice, + IDeviceContext** ppContexts, + Uint32 NumDeferredContexts ) = 0; + + virtual void CreateSwapChainMtl( IRenderDevice* pDevice, + IDeviceContext* pImmediateContext, + const SwapChainDesc& SCDesc, + void* pView, + ISwapChain** ppSwapChain ) = 0; + + virtual void AttachToMtlDevice(void* pMtlNativeDevice, + const EngineMtlCreateInfo& EngineAttribs, + IRenderDevice** ppDevice, + IDeviceContext** ppContexts, + Uint32 NumDeferredContexts) = 0; +}; + + +API_QUALIFIER IEngineFactoryMtl* GetEngineFactoryMtl(); + +} diff --git a/Graphics/GraphicsEngineMetal/interface/EngineMtlAttribs.h b/Graphics/GraphicsEngineMetal/interface/EngineMtlAttribs.h deleted file mode 100644 index 935716df..00000000 --- a/Graphics/GraphicsEngineMetal/interface/EngineMtlAttribs.h +++ /dev/null @@ -1,38 +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 - -/// \file -/// Definition of the Engine Mtl attribs - -#include "../../GraphicsEngine/interface/GraphicsTypes.h" - -namespace Diligent -{ - /// Attributes of the Metal-based engine implementation - struct EngineMtlAttribs : public EngineCreationAttribs - { - - }; -} diff --git a/Graphics/GraphicsEngineMetal/interface/RenderDeviceFactoryMtl.h b/Graphics/GraphicsEngineMetal/interface/RenderDeviceFactoryMtl.h deleted file mode 100644 index e0e9bffc..00000000 --- a/Graphics/GraphicsEngineMetal/interface/RenderDeviceFactoryMtl.h +++ /dev/null @@ -1,66 +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 - -/// \file -/// Declaration of functions that initialize Vulkan-based engine implementation - -#include - -#include "../../GraphicsEngine/interface/RenderDevice.h" -#include "../../GraphicsEngine/interface/DeviceContext.h" -#include "../../GraphicsEngine/interface/SwapChain.h" -#include "EngineMtlAttribs.h" - -// https://gcc.gnu.org/wiki/Visibility -#define API_QUALIFIER __attribute__((visibility("default"))) - -namespace Diligent -{ - -class IEngineFactoryMtl -{ -public: - virtual void CreateDeviceAndContextsMtl( const EngineMtlAttribs& Attribs, - IRenderDevice** ppDevice, - IDeviceContext** ppContexts, - Uint32 NumDeferredContexts ) = 0; - - virtual void CreateSwapChainMtl( IRenderDevice* pDevice, - IDeviceContext* pImmediateContext, - const SwapChainDesc& SCDesc, - void* pView, - ISwapChain** ppSwapChain ) = 0; - - virtual void AttachToMtlDevice(void* pMtlNativeDevice, - const EngineMtlAttribs& EngineAttribs, - IRenderDevice** ppDevice, - IDeviceContext** ppContexts, - Uint32 NumDeferredContexts) = 0; -}; - - -API_QUALIFIER IEngineFactoryMtl* GetEngineFactoryMtl(); - -} diff --git a/Graphics/GraphicsEngineMetal/src/EngineFactoryMtl.mm b/Graphics/GraphicsEngineMetal/src/EngineFactoryMtl.mm new file mode 100644 index 00000000..7516d45e --- /dev/null +++ b/Graphics/GraphicsEngineMetal/src/EngineFactoryMtl.mm @@ -0,0 +1,249 @@ +/* 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. + */ + +/// \file +/// Routines that initialize Mtl-based engine implementation + +#include "EngineFactoryMtl.h" +#include "RenderDeviceMtlImpl.h" +#include "DeviceContextMtlImpl.h" +#include "SwapChainMtlImpl.h" +#include "MtlTypeConversions.h" +#include "EngineMemory.h" + +namespace Diligent +{ + +/// Engine factory for Mtl implementation +class EngineFactoryMtlImpl : public IEngineFactoryMtl +{ +public: + static EngineFactoryMtlImpl* GetInstance() + { + static EngineFactoryMtlImpl TheFactory; + return &TheFactory; + } + + void CreateDeviceAndContextsMtl(const EngineMtlCreateInfo& EngineAttribs, + IRenderDevice** ppDevice, + IDeviceContext** ppContexts, + Uint32 NumDeferredContexts )override final; + + void CreateSwapChainMtl( IRenderDevice* pDevice, + IDeviceContext* pImmediateContext, + const SwapChainDesc& SCDesc, + void* pView, + ISwapChain** ppSwapChain )override final; + + void AttachToMtlDevice(void* pMtlNativeDevice, + const EngineMtlCreateInfo& EngineAttribs, + IRenderDevice** ppDevice, + IDeviceContext** ppContexts, + Uint32 NumDeferredContexts)override final; +}; + + +/// Creates render device and device contexts for Metal-based engine implementation + +/// \param [in] EngineAttribs - Engine creation attributes. +/// \param [out] ppDevice - Address of the memory location where pointer to +/// the created device will be written +/// \param [out] ppContexts - Address of the memory location where pointers to +/// the contexts will be written. Pointer to the immediate +/// context goes at position 0. If NumDeferredContexts > 0, +/// pointers to the deferred contexts go afterwards. +/// \param [in] NumDeferredContexts - Number of deferred contexts. If non-zero number +/// of deferred contexts is requested, pointers to the +/// contexts are written to ppContexts array starting +/// at position 1 +void EngineFactoryMtlImpl::CreateDeviceAndContextsMtl(const EngineMtlCreateInfo& EngineAttribs, + IRenderDevice** ppDevice, + IDeviceContext** ppContexts, + Uint32 NumDeferredContexts ) +{ + if (EngineAttribs.DebugMessageCallback != nullptr) + SetDebugMessageCallback(EngineAttribs.DebugMessageCallback); + + VERIFY( ppDevice && ppContexts, "Null pointer provided" ); + if( !ppDevice || !ppContexts ) + return; + + *ppDevice = nullptr; + memset(ppContexts, 0, sizeof(*ppContexts) * (1+NumDeferredContexts)); + + void* pMtlDevice = nullptr; + AttachToMtlDevice(pMtlDevice, EngineAttribs, ppDevice, ppContexts, NumDeferredContexts); +} + + +/// Attaches to existing Mtl render device and immediate context + +/// \param [in] pMtlNativeDevice - pointer to native Mtl device +/// \param [in] pMtlImmediateContext - pointer to native Mtl immediate context +/// \param [in] EngineAttribs - Engine creation attributes. +/// \param [out] ppDevice - Address of the memory location where pointer to +/// the created device will be written +/// \param [out] ppContexts - Address of the memory location where pointers to +/// the contexts will be written. Pointer to the immediate +/// context goes at position 0. If NumDeferredContexts > 0, +/// pointers to deferred contexts go afterwards. +/// \param [in] NumDeferredContexts - Number of deferred contexts. If non-zero number +/// of deferred contexts is requested, pointers to the +/// contexts are written to ppContexts array starting +/// at position 1 +void EngineFactoryMtlImpl::AttachToMtlDevice(void* pMtlNativeDevice, + const EngineMtlCreateInfo& EngineAttribs, + IRenderDevice** ppDevice, + IDeviceContext** ppContexts, + Uint32 NumDeferredContexts) +{ + if (EngineAttribs.DebugMessageCallback != nullptr) + SetDebugMessageCallback(EngineAttribs.DebugMessageCallback); + + VERIFY( ppDevice && ppContexts, "Null pointer provided" ); + if( !ppDevice || !ppContexts ) + return; + + try + { + SetRawAllocator(EngineAttribs.pRawMemAllocator); + auto &RawAlloctor = GetRawAllocator(); + RenderDeviceMtlImpl *pRenderDeviceMtl(NEW_RC_OBJ(RawAlloctor, "RenderDeviceMtlImpl instance", RenderDeviceMtlImpl) + (RawAlloctor, EngineAttribs, pMtlNativeDevice, NumDeferredContexts)); + pRenderDeviceMtl->QueryInterface(IID_RenderDevice, reinterpret_cast(ppDevice)); + + RefCntAutoPtr pDeviceContextMtl(NEW_RC_OBJ(RawAlloctor, "DeviceContextMtlImpl instance", DeviceContextMtlImpl) + (RawAlloctor, pRenderDeviceMtl, EngineAttribs, false)); + + // We must call AddRef() (implicitly through QueryInterface()) because pRenderDeviceMtl will + // keep a weak reference to the context + pDeviceContextMtl->QueryInterface(IID_DeviceContext, reinterpret_cast(ppContexts)); + pRenderDeviceMtl->SetImmediateContext(pDeviceContextMtl); + + for (Uint32 DeferredCtx = 0; DeferredCtx < NumDeferredContexts; ++DeferredCtx) + { + RefCntAutoPtr pDeferredCtxMtl( + NEW_RC_OBJ(RawAlloctor, "DeviceContextMtlImpl instance", DeviceContextMtlImpl) + (RawAlloctor, pRenderDeviceMtl, EngineAttribs, true)); + // We must call AddRef() (implicitly through QueryInterface()) because pRenderDeviceD3D12 will + // keep a weak reference to the context + pDeferredCtxMtl->QueryInterface(IID_DeviceContext, reinterpret_cast(ppContexts + 1 + DeferredCtx)); + pRenderDeviceMtl->SetDeferredContext(DeferredCtx, pDeferredCtxMtl); + } + } + catch( const std::runtime_error & ) + { + if( *ppDevice ) + { + (*ppDevice)->Release(); + *ppDevice = nullptr; + } + for(Uint32 ctx=0; ctx < 1 + NumDeferredContexts; ++ctx) + { + if( ppContexts[ctx] != nullptr ) + { + ppContexts[ctx]->Release(); + ppContexts[ctx] = nullptr; + } + } + + LOG_ERROR( "Failed to initialize Mtl device and contexts" ); + } +} + +/// Creates a swap chain for Direct3D11-based engine implementation + +/// \param [in] pDevice - Pointer to the render device +/// \param [in] pImmediateContext - Pointer to the immediate device context +/// \param [in] SCDesc - Swap chain description +/// \param [in] FSDesc - Fullscreen mode description +/// \param [in] pNativeWndHandle - Platform-specific native handle of the window +/// the swap chain will be associated with: +/// * On Win32 platform, this should be window handle (HWND) +/// * On Universal Windows Platform, this should be reference to the +/// core window (Windows::UI::Core::CoreWindow) +/// +/// \param [out] ppSwapChain - Address of the memory location where pointer to the new +/// swap chain will be written +void EngineFactoryMtlImpl::CreateSwapChainMtl(IRenderDevice* pDevice, + IDeviceContext* pImmediateContext, + const SwapChainDesc& SCDesc, + void* pView, + ISwapChain** ppSwapChain ) +{ + VERIFY( ppSwapChain, "Null pointer provided" ); + if( !ppSwapChain ) + return; + + *ppSwapChain = nullptr; + + try + { + auto *pDeviceMtl = ValidatedCast( pDevice ); + auto *pDeviceContextMtl = ValidatedCast(pImmediateContext); + auto &RawMemAllocator = GetRawAllocator(); + + auto *pSwapChainMtl = NEW_RC_OBJ(RawMemAllocator, "SwapChainMtlImpl instance", SwapChainMtlImpl) + (SCDesc, pDeviceMtl, pDeviceContextMtl, pView); + pSwapChainMtl->QueryInterface( IID_SwapChain, reinterpret_cast(ppSwapChain) ); + + pDeviceContextMtl->SetSwapChain(pSwapChainMtl); + // Bind default render target + pDeviceContextMtl->SetRenderTargets( 0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION ); + // Set default viewport + pDeviceContextMtl->SetViewports( 1, nullptr, 0, 0 ); + + auto NumDeferredCtx = pDeviceMtl->GetNumDeferredContexts(); + for (size_t ctx = 0; ctx < NumDeferredCtx; ++ctx) + { + if (auto pDeferredCtx = pDeviceMtl->GetDeferredContext(ctx)) + { + auto *pDeferredCtxMtl = pDeferredCtx.RawPtr(); + pDeferredCtxMtl->SetSwapChain(pSwapChainMtl); + // Do not bind default render target and viewport to be + // consistent with D3D12 + //// Bind default render target + //pDeferredCtxMtl->SetRenderTargets( 0, nullptr, nullptr ); + //// Set default viewport + //pDeferredCtxMtl->SetViewports( 1, nullptr, 0, 0 ); + } + } + } + catch( const std::runtime_error & ) + { + if( *ppSwapChain ) + { + (*ppSwapChain)->Release(); + *ppSwapChain = nullptr; + } + + LOG_ERROR( "Failed to create the swap chain" ); + } +} + +IEngineFactoryMtl* GetEngineFactoryMtl() +{ + return EngineFactoryMtlImpl::GetInstance(); +} + +} diff --git a/Graphics/GraphicsEngineMetal/src/RenderDeviceFactoryMtl.mm b/Graphics/GraphicsEngineMetal/src/RenderDeviceFactoryMtl.mm deleted file mode 100644 index 900a288b..00000000 --- a/Graphics/GraphicsEngineMetal/src/RenderDeviceFactoryMtl.mm +++ /dev/null @@ -1,249 +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. - */ - -/// \file -/// Routines that initialize Mtl-based engine implementation - -#include "RenderDeviceFactoryMtl.h" -#include "RenderDeviceMtlImpl.h" -#include "DeviceContextMtlImpl.h" -#include "SwapChainMtlImpl.h" -#include "MtlTypeConversions.h" -#include "EngineMemory.h" - -namespace Diligent -{ - -/// Engine factory for Mtl implementation -class EngineFactoryMtlImpl : public IEngineFactoryMtl -{ -public: - static EngineFactoryMtlImpl* GetInstance() - { - static EngineFactoryMtlImpl TheFactory; - return &TheFactory; - } - - void CreateDeviceAndContextsMtl( const EngineMtlAttribs& EngineAttribs, - IRenderDevice** ppDevice, - IDeviceContext** ppContexts, - Uint32 NumDeferredContexts )override final; - - void CreateSwapChainMtl( IRenderDevice* pDevice, - IDeviceContext* pImmediateContext, - const SwapChainDesc& SCDesc, - void* pView, - ISwapChain** ppSwapChain )override final; - - void AttachToMtlDevice(void* pMtlNativeDevice, - const EngineMtlAttribs& EngineAttribs, - IRenderDevice** ppDevice, - IDeviceContext** ppContexts, - Uint32 NumDeferredContexts)override final; -}; - - -/// Creates render device and device contexts for Metal-based engine implementation - -/// \param [in] EngineAttribs - Engine creation attributes. -/// \param [out] ppDevice - Address of the memory location where pointer to -/// the created device will be written -/// \param [out] ppContexts - Address of the memory location where pointers to -/// the contexts will be written. Pointer to the immediate -/// context goes at position 0. If NumDeferredContexts > 0, -/// pointers to the deferred contexts go afterwards. -/// \param [in] NumDeferredContexts - Number of deferred contexts. If non-zero number -/// of deferred contexts is requested, pointers to the -/// contexts are written to ppContexts array starting -/// at position 1 -void EngineFactoryMtlImpl::CreateDeviceAndContextsMtl( const EngineMtlAttribs& EngineAttribs, - IRenderDevice** ppDevice, - IDeviceContext** ppContexts, - Uint32 NumDeferredContexts ) -{ - if (EngineAttribs.DebugMessageCallback != nullptr) - SetDebugMessageCallback(EngineAttribs.DebugMessageCallback); - - VERIFY( ppDevice && ppContexts, "Null pointer provided" ); - if( !ppDevice || !ppContexts ) - return; - - *ppDevice = nullptr; - memset(ppContexts, 0, sizeof(*ppContexts) * (1+NumDeferredContexts)); - - void* pMtlDevice = nullptr; - AttachToMtlDevice(pMtlDevice, EngineAttribs, ppDevice, ppContexts, NumDeferredContexts); -} - - -/// Attaches to existing Mtl render device and immediate context - -/// \param [in] pMtlNativeDevice - pointer to native Mtl device -/// \param [in] pMtlImmediateContext - pointer to native Mtl immediate context -/// \param [in] EngineAttribs - Engine creation attributes. -/// \param [out] ppDevice - Address of the memory location where pointer to -/// the created device will be written -/// \param [out] ppContexts - Address of the memory location where pointers to -/// the contexts will be written. Pointer to the immediate -/// context goes at position 0. If NumDeferredContexts > 0, -/// pointers to deferred contexts go afterwards. -/// \param [in] NumDeferredContexts - Number of deferred contexts. If non-zero number -/// of deferred contexts is requested, pointers to the -/// contexts are written to ppContexts array starting -/// at position 1 -void EngineFactoryMtlImpl::AttachToMtlDevice(void* pMtlNativeDevice, - const EngineMtlAttribs& EngineAttribs, - IRenderDevice** ppDevice, - IDeviceContext** ppContexts, - Uint32 NumDeferredContexts) -{ - if (EngineAttribs.DebugMessageCallback != nullptr) - SetDebugMessageCallback(EngineAttribs.DebugMessageCallback); - - VERIFY( ppDevice && ppContexts, "Null pointer provided" ); - if( !ppDevice || !ppContexts ) - return; - - try - { - SetRawAllocator(EngineAttribs.pRawMemAllocator); - auto &RawAlloctor = GetRawAllocator(); - RenderDeviceMtlImpl *pRenderDeviceMtl(NEW_RC_OBJ(RawAlloctor, "RenderDeviceMtlImpl instance", RenderDeviceMtlImpl) - (RawAlloctor, EngineAttribs, pMtlNativeDevice, NumDeferredContexts)); - pRenderDeviceMtl->QueryInterface(IID_RenderDevice, reinterpret_cast(ppDevice)); - - RefCntAutoPtr pDeviceContextMtl(NEW_RC_OBJ(RawAlloctor, "DeviceContextMtlImpl instance", DeviceContextMtlImpl) - (RawAlloctor, pRenderDeviceMtl, EngineAttribs, false)); - - // We must call AddRef() (implicitly through QueryInterface()) because pRenderDeviceMtl will - // keep a weak reference to the context - pDeviceContextMtl->QueryInterface(IID_DeviceContext, reinterpret_cast(ppContexts)); - pRenderDeviceMtl->SetImmediateContext(pDeviceContextMtl); - - for (Uint32 DeferredCtx = 0; DeferredCtx < NumDeferredContexts; ++DeferredCtx) - { - RefCntAutoPtr pDeferredCtxMtl( - NEW_RC_OBJ(RawAlloctor, "DeviceContextMtlImpl instance", DeviceContextMtlImpl) - (RawAlloctor, pRenderDeviceMtl, EngineAttribs, true)); - // We must call AddRef() (implicitly through QueryInterface()) because pRenderDeviceD3D12 will - // keep a weak reference to the context - pDeferredCtxMtl->QueryInterface(IID_DeviceContext, reinterpret_cast(ppContexts + 1 + DeferredCtx)); - pRenderDeviceMtl->SetDeferredContext(DeferredCtx, pDeferredCtxMtl); - } - } - catch( const std::runtime_error & ) - { - if( *ppDevice ) - { - (*ppDevice)->Release(); - *ppDevice = nullptr; - } - for(Uint32 ctx=0; ctx < 1 + NumDeferredContexts; ++ctx) - { - if( ppContexts[ctx] != nullptr ) - { - ppContexts[ctx]->Release(); - ppContexts[ctx] = nullptr; - } - } - - LOG_ERROR( "Failed to initialize Mtl device and contexts" ); - } -} - -/// Creates a swap chain for Direct3D11-based engine implementation - -/// \param [in] pDevice - Pointer to the render device -/// \param [in] pImmediateContext - Pointer to the immediate device context -/// \param [in] SCDesc - Swap chain description -/// \param [in] FSDesc - Fullscreen mode description -/// \param [in] pNativeWndHandle - Platform-specific native handle of the window -/// the swap chain will be associated with: -/// * On Win32 platform, this should be window handle (HWND) -/// * On Universal Windows Platform, this should be reference to the -/// core window (Windows::UI::Core::CoreWindow) -/// -/// \param [out] ppSwapChain - Address of the memory location where pointer to the new -/// swap chain will be written -void EngineFactoryMtlImpl::CreateSwapChainMtl( IRenderDevice* pDevice, - IDeviceContext* pImmediateContext, - const SwapChainDesc& SCDesc, - void* pView, - ISwapChain** ppSwapChain ) -{ - VERIFY( ppSwapChain, "Null pointer provided" ); - if( !ppSwapChain ) - return; - - *ppSwapChain = nullptr; - - try - { - auto *pDeviceMtl = ValidatedCast( pDevice ); - auto *pDeviceContextMtl = ValidatedCast(pImmediateContext); - auto &RawMemAllocator = GetRawAllocator(); - - auto *pSwapChainMtl = NEW_RC_OBJ(RawMemAllocator, "SwapChainMtlImpl instance", SwapChainMtlImpl) - (SCDesc, pDeviceMtl, pDeviceContextMtl, pView); - pSwapChainMtl->QueryInterface( IID_SwapChain, reinterpret_cast(ppSwapChain) ); - - pDeviceContextMtl->SetSwapChain(pSwapChainMtl); - // Bind default render target - pDeviceContextMtl->SetRenderTargets( 0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION ); - // Set default viewport - pDeviceContextMtl->SetViewports( 1, nullptr, 0, 0 ); - - auto NumDeferredCtx = pDeviceMtl->GetNumDeferredContexts(); - for (size_t ctx = 0; ctx < NumDeferredCtx; ++ctx) - { - if (auto pDeferredCtx = pDeviceMtl->GetDeferredContext(ctx)) - { - auto *pDeferredCtxMtl = pDeferredCtx.RawPtr(); - pDeferredCtxMtl->SetSwapChain(pSwapChainMtl); - // Do not bind default render target and viewport to be - // consistent with D3D12 - //// Bind default render target - //pDeferredCtxMtl->SetRenderTargets( 0, nullptr, nullptr ); - //// Set default viewport - //pDeferredCtxMtl->SetViewports( 1, nullptr, 0, 0 ); - } - } - } - catch( const std::runtime_error & ) - { - if( *ppSwapChain ) - { - (*ppSwapChain)->Release(); - *ppSwapChain = nullptr; - } - - LOG_ERROR( "Failed to create the swap chain" ); - } -} - -IEngineFactoryMtl* GetEngineFactoryMtl() -{ - return EngineFactoryMtlImpl::GetInstance(); -} - -} -- cgit v1.2.3 From 859717ac93f8f72f34765df32396ba56e0d6a885 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 5 Mar 2019 20:14:11 -0800 Subject: Fixed one more issue with Metal back-end --- Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h | 1 - 1 file changed, 1 deletion(-) (limited to 'Graphics/GraphicsEngineMetal') diff --git a/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h b/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h index 05a3e8d4..109958d6 100644 --- a/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h +++ b/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h @@ -29,7 +29,6 @@ #include "RenderDeviceMtl.h" #include "RenderDeviceBase.h" #include "DeviceContextMtl.h" -#include "EngineMtlAttribs.h" namespace Diligent { -- cgit v1.2.3 From b9c210a8df72e620500509ed5243bef18a4390ec Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 5 Mar 2019 20:32:21 -0800 Subject: Fixed yet few another issues with Metal backend --- .../GraphicsEngineMetal/include/RenderDeviceMtlImpl.h | 12 ++++++------ Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'Graphics/GraphicsEngineMetal') diff --git a/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h b/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h index 109958d6..fbc40a0c 100644 --- a/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h +++ b/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h @@ -39,16 +39,16 @@ class RenderDeviceMtlImpl final : public RenderDeviceBase public: using TRenderDeviceBase = RenderDeviceBase; - RenderDeviceMtlImpl( IReferenceCounters* pRefCounters, - IMemoryAllocator& RawMemAllocator, - const EngineMtlAttribs& EngineAttribs, - void* pMtlDevice, - Uint32 NumDeferredContexts ); + RenderDeviceMtlImpl( IReferenceCounters* pRefCounters, + IMemoryAllocator& RawMemAllocator, + const EngineMtlCreateInfo& EngineAttribs, + void* pMtlDevice, + Uint32 NumDeferredContexts ); virtual void QueryInterface( const INTERFACE_ID& IID, IObject **ppInterface )override final; virtual void CreateBuffer(const BufferDesc& BuffDesc, const BufferData* pBuffData, IBuffer** ppBuffer)override final; - virtual void CreateShader(const ShaderCreationAttribs& ShaderCreationAttribs, IShader** ppShader)override final; + virtual void CreateShader(const ShaderCreateInfo& ShaderCI, IShader** ppShader)override final; virtual void CreateTexture(const TextureDesc& TexDesc, const TextureData* pData, ITexture** ppTexture)override final; diff --git a/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm index df94eb0f..99ab0240 100644 --- a/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm +++ b/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm @@ -37,11 +37,11 @@ namespace Diligent { -RenderDeviceMtlImpl :: RenderDeviceMtlImpl(IReferenceCounters* pRefCounters, - IMemoryAllocator& RawMemAllocator, - const EngineMtlAttribs& EngineAttribs, - void* pMtlDevice, - Uint32 NumDeferredContexts) : +RenderDeviceMtlImpl :: RenderDeviceMtlImpl(IReferenceCounters* pRefCounters, + IMemoryAllocator& RawMemAllocator, + const EngineMtlCreateInfo& EngineAttribs, + void* pMtlDevice, + Uint32 NumDeferredContexts) : TRenderDeviceBase { pRefCounters, @@ -92,13 +92,13 @@ void RenderDeviceMtlImpl :: CreateBuffer(const BufferDesc& BuffDesc, const Buffe ); } -void RenderDeviceMtlImpl :: CreateShader(const ShaderCreationAttribs& ShaderCreationAttribs, IShader** ppShader) +void RenderDeviceMtlImpl :: CreateShader(const ShaderCreateInfo& ShaderCI, IShader** ppShader) { - CreateDeviceObject( "shader", ShaderCreationAttribs.Desc, ppShader, + CreateDeviceObject( "shader", ShaderCI.Desc, ppShader, [&]() { ShaderMtlImpl* pShaderMtl( NEW_RC_OBJ(m_ShaderObjAllocator, "ShaderMtlImpl instance", ShaderMtlImpl) - (this, ShaderCreationAttribs ) ); + (this, ShaderCI ) ); pShaderMtl->QueryInterface( IID_Shader, reinterpret_cast(ppShader) ); OnCreateDeviceObject( pShaderMtl ); -- cgit v1.2.3 From 33e1dca8e674e5e5a05c97151a4a8e1644f6b174 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 5 Mar 2019 21:22:48 -0800 Subject: Keep fixing metal backend --- .../include/PipelineStateMtlImpl.h | 24 +++++++++++++++++++++ .../include/RenderDeviceMtlImpl.h | 3 +-- .../GraphicsEngineMetal/include/ShaderMtlImpl.h | 25 ++++++---------------- Graphics/GraphicsEngineMetal/src/ShaderMtlImpl.mm | 8 +++---- 4 files changed, 36 insertions(+), 24 deletions(-) (limited to 'Graphics/GraphicsEngineMetal') diff --git a/Graphics/GraphicsEngineMetal/include/PipelineStateMtlImpl.h b/Graphics/GraphicsEngineMetal/include/PipelineStateMtlImpl.h index 5117cf28..49550369 100644 --- a/Graphics/GraphicsEngineMetal/include/PipelineStateMtlImpl.h +++ b/Graphics/GraphicsEngineMetal/include/PipelineStateMtlImpl.h @@ -54,6 +54,30 @@ public: virtual bool IsCompatibleWith(const IPipelineState *pPSO)const override final; + virtual void BindStaticResources(Uint32 ShaderFlags, IResourceMapping* pResourceMapping, Uint32 Flags)override final + { + LOG_ERROR_MESSAGE("PipelineStateMtlImpl::BindStaticResources() is not implemented"); + } + + virtual Uint32 GetStaticVariableCount(SHADER_TYPE ShaderType) const override final + { + LOG_ERROR_MESSAGE("PipelineStateMtlImpl::GetStaticVariableCount() is not implemented"); + return 0; + } + + virtual IShaderResourceVariable* GetStaticShaderVariable(SHADER_TYPE ShaderType, const Char* Name) override final; + { + LOG_ERROR_MESSAGE("PipelineStateMtlImpl::GetStaticShaderVariable() is not implemented"); + return nullptr; + } + + virtual IShaderResourceVariable* GetStaticShaderVariable(SHADER_TYPE ShaderType, Uint32 Index) override final; + { + LOG_ERROR_MESSAGE("PipelineStateMtlImpl::GetStaticShaderVariable() is not implemented"); + return nullptr; + } + + private: }; diff --git a/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h b/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h index fbc40a0c..0f49380f 100644 --- a/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h +++ b/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h @@ -66,8 +66,7 @@ public: private: virtual void TestTextureFormat( TEXTURE_FORMAT TexFormat )override final; - EngineMtlAttribs m_EngineAttribs; - + EngineMtlCreateInfo m_EngineAttribs; }; } diff --git a/Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h b/Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h index 8d3f09a2..8b73035c 100644 --- a/Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h +++ b/Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h @@ -44,34 +44,23 @@ public: ShaderMtlImpl(IReferenceCounters* pRefCounters, class RenderDeviceMtlImpl* pRenderDeviceMtl, - const ShaderCreationAttribs& CreationAttribs); + const ShaderCreateInfo& ShaderCI); ~ShaderMtlImpl(); - virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject** ppInterface )override final; + virtual void QueryInterface( const INTERFACE_ID& IID, IObject** ppInterface )override final; - virtual void BindResources( IResourceMapping* pResourceMapping, Uint32 Flags )override final + virtual Uint32 GetResourceCount()const override final { - LOG_ERROR_MESSAGE("ShaderMtlImpl::BindResources() is not implemented"); - } - - virtual IShaderVariable* GetShaderVariable( const Char* Name )override final - { - LOG_ERROR_MESSAGE("ShaderMtlImpl::GetShaderVariable() is not implemented"); - return nullptr; - } - - virtual Uint32 GetVariableCount() const override final - { - LOG_ERROR_MESSAGE("ShaderMtlImpl::GetVariableCount() is not implemented"); + LOG_ERROR_MESSAGE("ShaderMtlImpl::GetResourceCount() is not implemented"); return 0; } - virtual IShaderVariable* GetShaderVariable(Uint32 Index)override final + virtual ShaderResourceDesc GetResource(Uint32 Index)const override final { - LOG_ERROR_MESSAGE("ShaderMtlImpl::GetShaderVariable() is not implemented"); + LOG_ERROR_MESSAGE("ShaderMtlImpl::GetResource() is not implemented"); return nullptr; } - + private: }; diff --git a/Graphics/GraphicsEngineMetal/src/ShaderMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/ShaderMtlImpl.mm index 489c3004..7f9f04f6 100644 --- a/Graphics/GraphicsEngineMetal/src/ShaderMtlImpl.mm +++ b/Graphics/GraphicsEngineMetal/src/ShaderMtlImpl.mm @@ -28,10 +28,10 @@ namespace Diligent { -ShaderMtlImpl::ShaderMtlImpl(IReferenceCounters* pRefCounters, - RenderDeviceMtlImpl* pRenderDeviceMtl, - const ShaderCreationAttribs& CreationAttribs) : - TShaderBase(pRefCounters, pRenderDeviceMtl, CreationAttribs.Desc) +ShaderMtlImpl::ShaderMtlImpl(IReferenceCounters* pRefCounters, + RenderDeviceMtlImpl* pRenderDeviceMtl, + const ShaderCreateInfo& ShaderCI) : + TShaderBase(pRefCounters, pRenderDeviceMtl, ShaderCI.Desc) { LOG_ERROR_AND_THROW("Shaders are not implemented in Metal backend"); } -- cgit v1.2.3 From 75ceee9c24284c7c564e4c8f82069406184506e5 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 5 Mar 2019 21:37:35 -0800 Subject: Keep fixing metal back-end --- Graphics/GraphicsEngineMetal/include/PipelineStateMtlImpl.h | 4 ++-- Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Graphics/GraphicsEngineMetal') diff --git a/Graphics/GraphicsEngineMetal/include/PipelineStateMtlImpl.h b/Graphics/GraphicsEngineMetal/include/PipelineStateMtlImpl.h index 49550369..94a3a943 100644 --- a/Graphics/GraphicsEngineMetal/include/PipelineStateMtlImpl.h +++ b/Graphics/GraphicsEngineMetal/include/PipelineStateMtlImpl.h @@ -65,13 +65,13 @@ public: return 0; } - virtual IShaderResourceVariable* GetStaticShaderVariable(SHADER_TYPE ShaderType, const Char* Name) override final; + virtual IShaderResourceVariable* GetStaticShaderVariable(SHADER_TYPE ShaderType, const Char* Name) override final { LOG_ERROR_MESSAGE("PipelineStateMtlImpl::GetStaticShaderVariable() is not implemented"); return nullptr; } - virtual IShaderResourceVariable* GetStaticShaderVariable(SHADER_TYPE ShaderType, Uint32 Index) override final; + virtual IShaderResourceVariable* GetStaticShaderVariable(SHADER_TYPE ShaderType, Uint32 Index) override final { LOG_ERROR_MESSAGE("PipelineStateMtlImpl::GetStaticShaderVariable() is not implemented"); return nullptr; diff --git a/Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h b/Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h index 8b73035c..1752f59b 100644 --- a/Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h +++ b/Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h @@ -58,7 +58,7 @@ public: virtual ShaderResourceDesc GetResource(Uint32 Index)const override final { LOG_ERROR_MESSAGE("ShaderMtlImpl::GetResource() is not implemented"); - return nullptr; + return ShaderResourceDesc{}; } private: -- cgit v1.2.3 From 772ef0e6cfbb218814ad4e7d25dd94b697a6b4f3 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 5 Mar 2019 22:05:17 -0800 Subject: Keep fixing Metal backend + few other minor changes --- Graphics/GraphicsEngineMetal/include/ShaderResourceBindingMtlImpl.h | 4 ++-- Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'Graphics/GraphicsEngineMetal') diff --git a/Graphics/GraphicsEngineMetal/include/ShaderResourceBindingMtlImpl.h b/Graphics/GraphicsEngineMetal/include/ShaderResourceBindingMtlImpl.h index 95642031..89431cee 100644 --- a/Graphics/GraphicsEngineMetal/include/ShaderResourceBindingMtlImpl.h +++ b/Graphics/GraphicsEngineMetal/include/ShaderResourceBindingMtlImpl.h @@ -50,11 +50,11 @@ public: virtual void BindResources(Uint32 ShaderFlags, IResourceMapping* pResMapping, Uint32 Flags)override final; - virtual IShaderVariable* GetVariable(SHADER_TYPE ShaderType, const char *Name)override final; + virtual IShaderResourceVariable* GetVariable(SHADER_TYPE ShaderType, const char *Name)override final; virtual Uint32 GetVariableCount(SHADER_TYPE ShaderType) const override final; - virtual IShaderVariable* GetVariable(SHADER_TYPE ShaderType, Uint32 Index)override final; + virtual IShaderResourceVariable* GetVariable(SHADER_TYPE ShaderType, Uint32 Index)override final; virtual void InitializeStaticResources(const IPipelineState* pPipelineState)override final; diff --git a/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm index 93532ab0..c861002b 100644 --- a/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm +++ b/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm @@ -30,7 +30,6 @@ #include "PipelineStateMtlImpl.h" #include "SwapChainMtl.h" #include "ShaderResourceBindingMtlImpl.h" -#include "EngineMtlAttribs.h" #include "CommandListMtlImpl.h" #include "RenderDeviceMtlImpl.h" #include "FenceMtlImpl.h" -- cgit v1.2.3 From cfb2cf3022ba3beacc3fb6a196ea72524cef55d6 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 5 Mar 2019 22:42:25 -0800 Subject: Still fixing metal back-end --- Graphics/GraphicsEngineMetal/interface/EngineFactoryMtl.h | 1 - 1 file changed, 1 deletion(-) (limited to 'Graphics/GraphicsEngineMetal') diff --git a/Graphics/GraphicsEngineMetal/interface/EngineFactoryMtl.h b/Graphics/GraphicsEngineMetal/interface/EngineFactoryMtl.h index 01888518..ca6088b6 100644 --- a/Graphics/GraphicsEngineMetal/interface/EngineFactoryMtl.h +++ b/Graphics/GraphicsEngineMetal/interface/EngineFactoryMtl.h @@ -31,7 +31,6 @@ #include "../../GraphicsEngine/interface/RenderDevice.h" #include "../../GraphicsEngine/interface/DeviceContext.h" #include "../../GraphicsEngine/interface/SwapChain.h" -#include "EngineMtlAttribs.h" // https://gcc.gnu.org/wiki/Visibility #define API_QUALIFIER __attribute__((visibility("default"))) -- cgit v1.2.3 From 03da14aa28a60c3275196dadfb3766f73097bd95 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 5 Mar 2019 23:03:49 -0800 Subject: Still keep fixing metal back-end --- Graphics/GraphicsEngineMetal/include/DeviceContextMtlImpl.h | 12 ++++++------ Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'Graphics/GraphicsEngineMetal') diff --git a/Graphics/GraphicsEngineMetal/include/DeviceContextMtlImpl.h b/Graphics/GraphicsEngineMetal/include/DeviceContextMtlImpl.h index b6f26154..f3d711a2 100644 --- a/Graphics/GraphicsEngineMetal/include/DeviceContextMtlImpl.h +++ b/Graphics/GraphicsEngineMetal/include/DeviceContextMtlImpl.h @@ -49,13 +49,13 @@ class DeviceContextMtlImpl final : public DeviceContextBase; - DeviceContextMtlImpl(IReferenceCounters* pRefCounters, - IMemoryAllocator& Allocator, - IRenderDevice* pDevice, - const struct EngineMtlAttribs& EngineAttribs, - bool bIsDeferred); + DeviceContextMtlImpl(IReferenceCounters* pRefCounters, + IMemoryAllocator& Allocator, + IRenderDevice* pDevice, + const struct EngineMtlCreateInfo& EngineAttribs, + bool bIsDeferred); - virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; + virtual void QueryInterface( const INTERFACE_ID &IID, IObject **ppInterface )override final; virtual void SetPipelineState(IPipelineState* pPipelineState)override final; diff --git a/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm index c861002b..978fccf7 100644 --- a/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm +++ b/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm @@ -36,11 +36,11 @@ namespace Diligent { - DeviceContextMtlImpl::DeviceContextMtlImpl( IReferenceCounters* pRefCounters, - IMemoryAllocator& Allocator, - IRenderDevice* pDevice, - const struct EngineMtlAttribs& EngineAttribs, - bool bIsDeferred ) : + DeviceContextMtlImpl::DeviceContextMtlImpl( IReferenceCounters* pRefCounters, + IMemoryAllocator& Allocator, + IRenderDevice* pDevice, + const struct EngineMtlCreateInfo& EngineAttribs, + bool bIsDeferred ) : TDeviceContextBase(pRefCounters, pDevice, bIsDeferred) { } -- cgit v1.2.3 From 87efb65472e80af337ed6545851da9bcb8d5fdee Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 5 Mar 2019 23:19:14 -0800 Subject: Keep fixing metal back-end --- Graphics/GraphicsEngineMetal/src/ShaderResourceBindingMtlImpl.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Graphics/GraphicsEngineMetal') diff --git a/Graphics/GraphicsEngineMetal/src/ShaderResourceBindingMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/ShaderResourceBindingMtlImpl.mm index 1206c528..aa9cc788 100644 --- a/Graphics/GraphicsEngineMetal/src/ShaderResourceBindingMtlImpl.mm +++ b/Graphics/GraphicsEngineMetal/src/ShaderResourceBindingMtlImpl.mm @@ -55,7 +55,7 @@ void ShaderResourceBindingMtlImpl::InitializeStaticResources(const IPipelineStat LOG_ERROR_MESSAGE("ShaderResourceBindingMtlImpl::InitializeStaticResources() is not implemented"); } -IShaderVariable* ShaderResourceBindingMtlImpl::GetVariable(SHADER_TYPE ShaderType, const char* Name) +IShaderResourceVariable* ShaderResourceBindingMtlImpl::GetVariable(SHADER_TYPE ShaderType, const char* Name) { LOG_ERROR_MESSAGE("ShaderResourceBindingMtlImpl::GetVariable() is not implemented"); return nullptr; @@ -67,7 +67,7 @@ Uint32 ShaderResourceBindingMtlImpl::GetVariableCount(SHADER_TYPE ShaderType) co return 0; } -IShaderVariable* ShaderResourceBindingMtlImpl::GetVariable(SHADER_TYPE ShaderType, Uint32 Index) +IShaderResourceVariable* ShaderResourceBindingMtlImpl::GetVariable(SHADER_TYPE ShaderType, Uint32 Index) { LOG_ERROR_MESSAGE("ShaderResourceBindingMtlImpl::GetVariable() is not implemented"); return nullptr; -- cgit v1.2.3 From 76a1a90ee26e3f2e78fab018bbbfc43ddc85d849 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Wed, 6 Mar 2019 10:03:57 -0800 Subject: Removed unused m_ResourceLayout member from ShaderVariableManagerVk and ShaderVariableManagerD3D12 plus a bunch of minor updates to fix clang warnings --- Graphics/GraphicsEngineMetal/src/TextureMtlImpl.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Graphics/GraphicsEngineMetal') diff --git a/Graphics/GraphicsEngineMetal/src/TextureMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/TextureMtlImpl.mm index 70f54ac8..b89b0c35 100644 --- a/Graphics/GraphicsEngineMetal/src/TextureMtlImpl.mm +++ b/Graphics/GraphicsEngineMetal/src/TextureMtlImpl.mm @@ -40,7 +40,7 @@ TextureMtlImpl :: TextureMtlImpl(IReferenceCounters* pRefCounters, { LOG_ERROR_AND_THROW("Textures are not implemented in Metal backend"); - if( TexDesc.Usage == USAGE_STATIC && pInitData == nullptr || pInitData->pSubResources == nullptr ) + if( (TexDesc.Usage == USAGE_STATIC && pInitData == nullptr) || pInitData->pSubResources == nullptr ) LOG_ERROR_AND_THROW("Static Texture must be initialized with data at creation time"); SetState(RESOURCE_STATE_UNDEFINED); } -- cgit v1.2.3