diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-12-30 02:45:15 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-12-30 02:45:15 +0000 |
| commit | fb014bd8176eb739ba3273120d0653f1fda0a533 (patch) | |
| tree | 75eea02e86998e6189a99293282ae019a8202e30 /Graphics/GraphicsEngineMetal | |
| parent | Minor fix in cmake file (diff) | |
| download | DiligentCore-fb014bd8176eb739ba3273120d0653f1fda0a533.tar.gz DiligentCore-fb014bd8176eb739ba3273120d0653f1fda0a533.zip | |
Added Metal backend stub
Diffstat (limited to 'Graphics/GraphicsEngineMetal')
45 files changed, 3313 insertions, 0 deletions
diff --git a/Graphics/GraphicsEngineMetal/CMakeLists.txt b/Graphics/GraphicsEngineMetal/CMakeLists.txt new file mode 100644 index 00000000..e3373c53 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/CMakeLists.txt @@ -0,0 +1,121 @@ +cmake_minimum_required (VERSION 3.10) + +project(GraphicsEngineMetal CXX) + + +set(INCLUDE + include/BufferMtlImpl.h + include/BufferViewMtlImpl.h + include/CommandListMtlImpl.h + include/MtlTypeConversions.h + include/DeviceContextMtlImpl.h + include/FenceMtlImpl.h + include/PipelineStateMtlImpl.h + include/RenderDeviceMtlImpl.h + include/SamplerMtlImpl.h + include/ShaderMtlImpl.h + include/ShaderResourceBindingMtlImpl.h + include/SwapChainMtlImpl.h + include/TextureMtlImpl.h + include/TextureViewMtlImpl.h +) + +set(INTERFACE + interface/BufferMtl.h + interface/BufferViewMtl.h + interface/DeviceContextMtl.h + interface/EngineMtlAttribs.h + interface/FenceMtl.h + interface/PipelineStateMtl.h + interface/RenderDeviceMtl.h + interface/RenderDeviceFactoryMtl.h + interface/SamplerMtl.h + interface/ShaderMtl.h + interface/ShaderResourceBindingMtl.h + interface/SwapChainMtl.h + interface/TextureMtl.h + interface/TextureViewMtl.h +) + + +set(SRC + src/BufferMtlImpl.mm + src/BufferViewMtlImpl.mm + src/CommandListMtlImpl.mm + src/MtlTypeConversions.mm + src/DeviceContextMtlImpl.mm + src/FenceMtlImpl.mm + src/PipelineStateMtlImpl.mm + src/RenderDeviceMtlImpl.mm + src/RenderDeviceFactoryMtl.mm + src/SamplerMtlImpl.mm + src/ShaderMtlImpl.mm + src/ShaderResourceBindingMtlImpl.mm + src/SwapChainMtlImpl.mm + src/TextureMtlImpl.mm + src/TextureViewMtlImpl.mm +) + +add_library(GraphicsEngineMetalInterface INTERFACE) +target_include_directories(GraphicsEngineMetalInterface +INTERFACE + interface +) +target_link_libraries(GraphicsEngineMetalInterface +INTERFACE + GraphicsEngineInterface +) + + +add_library(GraphicsEngineMetal-static STATIC + ${SRC} ${INTERFACE} ${INCLUDE} + readme.md +) + +add_library(GraphicsEngineMetal-shared SHARED + readme.md +) + +# Set output name to GraphicsEngineMetal_{32|64}{r|d} +set_dll_output_name(GraphicsEngineMetal-shared GraphicsEngineMetal) + +set_common_target_properties(GraphicsEngineMetal-shared) +set_common_target_properties(GraphicsEngineMetal-static) + +target_include_directories(GraphicsEngineMetal-static +PRIVATE + include +) + +target_link_libraries(GraphicsEngineMetal-static +PRIVATE + BuildSettings + TargetPlatform + Common + GraphicsEngine +PUBLIC + GraphicsEngineMetalInterface +) + +target_link_libraries(GraphicsEngineMetal-shared PUBLIC GraphicsEngineMetal-static) +target_compile_definitions(GraphicsEngineMetal-shared PUBLIC ENGINE_DLL=1) + +source_group("src" FILES ${SRC} ) +source_group("include" FILES ${INCLUDE}) +source_group("interface" FILES ${INTERFACE}) + +set_target_properties(GraphicsEngineMetal-static PROPERTIES + FOLDER Core/Graphics +) +set_target_properties(GraphicsEngineMetal-shared PROPERTIES + FOLDER Core/Graphics +) + +set_source_files_properties( + readme.md PROPERTIES HEADER_FILE_ONLY TRUE +) + +if(INSTALL_DILIGENT_CORE) + install_core_lib(GraphicsEngineMetal-shared) + install_core_lib(GraphicsEngineMetal-static) +endif() diff --git a/Graphics/GraphicsEngineMetal/include/BufferMtlImpl.h b/Graphics/GraphicsEngineMetal/include/BufferMtlImpl.h new file mode 100644 index 00000000..843cd120 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/include/BufferMtlImpl.h @@ -0,0 +1,76 @@ +/* Copyright 2015-2018 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 Diligent::BufferMtlImpl class + +#include "BufferMtl.h" +#include "RenderDeviceMtl.h" +#include "BufferBase.h" +#include "BufferViewMtlImpl.h" +#include "RenderDeviceMtlImpl.h" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Implementation of the Diligent::IBufferMtl interface +class BufferMtlImpl final : public BufferBase<IBufferMtl, RenderDeviceMtlImpl, BufferViewMtlImpl, FixedBlockMemoryAllocator> +{ +public: + using TBufferBase = BufferBase<IBufferMtl, RenderDeviceMtlImpl, BufferViewMtlImpl, FixedBlockMemoryAllocator>; + + BufferMtlImpl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& BuffViewObjMemAllocator, + class RenderDeviceMtlImpl* pDeviceMtl, + const BufferDesc& BuffDesc, + const BufferData& BuffData = BufferData()); + + BufferMtlImpl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& BuffViewObjMemAllocator, + class RenderDeviceMtlImpl* pDeviceMtl, + const BufferDesc& BuffDesc, + RESOURCE_STATE InitialState, + void* pMetalBuffer); + + ~BufferMtlImpl(); + + virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; + + virtual void* GetNativeHandle()override final + { + LOG_ERROR_MESSAGE("BufferMtlImpl::GetNativeHandle() is not implemented"); + return nullptr; + } + +private: + friend class DeviceContextMtlImpl; + + virtual void CreateViewInternal( const struct BufferViewDesc &ViewDesc, IBufferView **ppView, bool bIsDefaultView )override; + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/include/BufferViewMtlImpl.h b/Graphics/GraphicsEngineMetal/include/BufferViewMtlImpl.h new file mode 100644 index 00000000..97d2d6a2 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/include/BufferViewMtlImpl.h @@ -0,0 +1,57 @@ +/* Copyright 2015-2018 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 Diligent::BufferViewMtlImpl class + +#include "BufferViewMtl.h" +#include "RenderDeviceMtl.h" +#include "BufferViewBase.h" +#include "RenderDeviceMtlImpl.h" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; +/// Implementation of the Diligent::IBufferViewMtl interface +class BufferViewMtlImpl final : public BufferViewBase<IBufferViewMtl, RenderDeviceMtlImpl> +{ +public: + using TBufferViewBase = BufferViewBase<IBufferViewMtl, RenderDeviceMtlImpl>; + + BufferViewMtlImpl( IReferenceCounters* pRefCounters, + RenderDeviceMtlImpl* pDevice, + const BufferViewDesc& ViewDesc, + class IBuffer* pBuffer, + void* pMtlView, + bool bIsDefaultView); + + virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) final; + +protected: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/include/CommandListMtlImpl.h b/Graphics/GraphicsEngineMetal/include/CommandListMtlImpl.h new file mode 100644 index 00000000..18ccf829 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/include/CommandListMtlImpl.h @@ -0,0 +1,53 @@ +/* Copyright 2015-2018 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 Diligent::CommandListMtlImpl class + +#include "RenderDeviceMtl.h" +#include "CommandListBase.h" +#include "RenderDeviceMtlImpl.h" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Implementation of the Diligent::ICommandListMtl interface +class CommandListMtlImpl final : public CommandListBase<ICommandList, RenderDeviceMtlImpl> +{ +public: + using TCommandListBase = CommandListBase<ICommandList, RenderDeviceMtlImpl>; + + CommandListMtlImpl(IReferenceCounters* pRefCounters, + RenderDeviceMtlImpl* pDevice, + void* pMtlCommandList); + ~CommandListMtlImpl(); + +private: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/include/DeviceContextMtlImpl.h b/Graphics/GraphicsEngineMetal/include/DeviceContextMtlImpl.h new file mode 100644 index 00000000..10e1fdc9 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/include/DeviceContextMtlImpl.h @@ -0,0 +1,159 @@ +/* Copyright 2015-2018 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 Diligent::DeviceContextMtlImpl class + +#include "DeviceContextMtl.h" +#include "DeviceContextBase.h" +#include "ShaderMtlImpl.h" +#include "BufferMtlImpl.h" +#include "TextureMtlImpl.h" +#include "PipelineStateMtlImpl.h" + +namespace Diligent +{ + +struct DeviceContextMtlImplTraits +{ + using BufferType = BufferMtlImpl; + using TextureType = TextureMtlImpl; + using PipelineStateType = PipelineStateMtlImpl; +}; + +/// Implementation of the Diligent::IDeviceContextMtl interface +class DeviceContextMtlImpl final : public DeviceContextBase<IDeviceContextMtl, DeviceContextMtlImplTraits> +{ +public: + using TDeviceContextBase = DeviceContextBase<IDeviceContextMtl, DeviceContextMtlImplTraits>; + + DeviceContextMtlImpl(IReferenceCounters* pRefCounters, + IMemoryAllocator& Allocator, + IRenderDevice* pDevice, + const struct EngineMtlAttribs& EngineAttribs, + bool bIsDeferred); + + virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; + + virtual void SetPipelineState(IPipelineState* pPipelineState)override final; + + virtual void TransitionShaderResources(IPipelineState* pPipelineState, IShaderResourceBinding* pShaderResourceBinding)override final; + + virtual void CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final; + + virtual void SetStencilRef(Uint32 StencilRef)override final; + + virtual void SetBlendFactors(const float* pBlendFactors = nullptr)override final; + + virtual void SetVertexBuffers(Uint32 StartSlot, + Uint32 NumBuffersSet, + IBuffer** ppBuffers, + Uint32* pOffsets, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, + SET_VERTEX_BUFFERS_FLAGS Flags)override final; + + virtual void InvalidateState()override final; + + virtual void SetIndexBuffer(IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final; + + virtual void SetViewports(Uint32 NumViewports, const Viewport* pViewports, Uint32 RTWidth, Uint32 RTHeight)override final; + + virtual void SetScissorRects(Uint32 NumRects, const Rect* pRects, Uint32 RTWidth, Uint32 RTHeight)override final; + + virtual void SetRenderTargets(Uint32 NumRenderTargets, + ITextureView* ppRenderTargets[], + ITextureView* pDepthStencil, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final; + + virtual void Draw(DrawAttribs& DrawAttribs)override final; + + virtual void DispatchCompute(const DispatchComputeAttribs& DispatchAttrs)override final; + + virtual void ClearDepthStencil(ITextureView* pView, + CLEAR_DEPTH_STENCIL_FLAGS ClearFlags, + float fDepth, + Uint8 Stencil, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final; + + virtual void ClearRenderTarget(ITextureView* pView, const float* RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final; + + virtual void Flush()override final; + + virtual void UpdateBuffer(IBuffer* pBuffer, + Uint32 Offset, + Uint32 Size, + const PVoid pData, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final; + + virtual void CopyBuffer(IBuffer* pSrcBuffer, + Uint32 SrcOffset, + RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, + IBuffer* pDstBuffer, + Uint32 DstOffset, + Uint32 Size, + RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode)override final; + + virtual void MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData)override final; + + virtual void UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType)override final; + + virtual void UpdateTexture(ITexture* pTexture, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData, + RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)override final; + + virtual void CopyTexture(const CopyTextureAttribs& CopyAttribs)override final; + + virtual void MapTextureSubresource( ITexture* pTexture, + Uint32 MipLevel, + Uint32 ArraySlice, + MAP_TYPE MapType, + MAP_FLAGS MapFlags, + const Box* pMapRegion, + MappedTextureSubresource& MappedData )override final; + + + virtual void UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice)override final; + + virtual void GenerateMips(ITextureView* pTextureView)override final; + + virtual void FinishFrame()override final; + + virtual void TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers)override final; + + void FinishCommandList(class ICommandList** ppCommandList)override final; + + virtual void ExecuteCommandList(class ICommandList* pCommandList)override final; + + virtual void SignalFence(IFence* pFence, Uint64 Value)override final; + +private: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/include/FenceMtlImpl.h b/Graphics/GraphicsEngineMetal/include/FenceMtlImpl.h new file mode 100644 index 00000000..308cacc5 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/include/FenceMtlImpl.h @@ -0,0 +1,60 @@ +/* Copyright 2015-2018 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 Diligent::FenceMtlImpl class + +#include <deque> +#include "FenceMtl.h" +#include "RenderDeviceMtl.h" +#include "FenceBase.h" +#include "RenderDeviceMtlImpl.h" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Implementation of the Diligent::IFenceMtl interface +class FenceMtlImpl final : public FenceBase<IFenceMtl, RenderDeviceMtlImpl> +{ +public: + using TFenceBase = FenceBase<IFenceMtl, RenderDeviceMtlImpl>; + + FenceMtlImpl(IReferenceCounters* pRefCounters, + RenderDeviceMtlImpl* pDevice, + const FenceDesc& Desc); + ~FenceMtlImpl(); + + virtual Uint64 GetCompletedValue()override final; + + /// Resets the fence to the specified value. + virtual void Reset(Uint64 Value)override final; + +private: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/include/MtlTypeConversions.h b/Graphics/GraphicsEngineMetal/include/MtlTypeConversions.h new file mode 100644 index 00000000..c9608b91 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/include/MtlTypeConversions.h @@ -0,0 +1,34 @@ +/* Copyright 2015-2018 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 +/// Type conversion routines + +#include "GraphicsTypes.h" + +namespace Diligent +{ + +} diff --git a/Graphics/GraphicsEngineMetal/include/PipelineStateMtlImpl.h b/Graphics/GraphicsEngineMetal/include/PipelineStateMtlImpl.h new file mode 100644 index 00000000..bfd50b4c --- /dev/null +++ b/Graphics/GraphicsEngineMetal/include/PipelineStateMtlImpl.h @@ -0,0 +1,61 @@ +/* Copyright 2015-2018 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 Diligent::PipelineStateMtlImpl class + +#include "PipelineStateMtl.h" +#include "RenderDeviceMtl.h" +#include "PipelineStateBase.h" +#include "ShaderMtlImpl.h" +#include "SRBMemoryAllocator.h" +#include "RenderDeviceMtlImpl.h" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; +/// Implementation of the Diligent::IPipelineStateMtl interface +class PipelineStateMtlImpl final : public PipelineStateBase<IPipelineStateMtl, RenderDeviceMtlImpl> +{ +public: + using TPipelineStateBase = PipelineStateBase<IPipelineStateMtl, RenderDeviceMtlImpl>; + + PipelineStateMtlImpl(IReferenceCounters* pRefCounters, + class RenderDeviceMtlImpl* pDeviceMtl, + const PipelineStateDesc& PipelineDesc); + ~PipelineStateMtlImpl(); + + virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; + + virtual void CreateShaderResourceBinding( IShaderResourceBinding **ppShaderResourceBinding, bool InitStaticResources )override final; + + virtual bool IsCompatibleWith(const IPipelineState *pPSO)const override final; + +private: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h b/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h new file mode 100644 index 00000000..d16e449c --- /dev/null +++ b/Graphics/GraphicsEngineMetal/include/RenderDeviceMtlImpl.h @@ -0,0 +1,74 @@ +/* Copyright 2015-2018 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 Diligent::RenderDeviceMtlImpl class + +#include "RenderDeviceMtl.h" +#include "RenderDeviceBase.h" +#include "DeviceContextMtl.h" +#include "EngineMtlAttribs.h" + +namespace Diligent +{ + +/// Implementation of the Diligent::IRenderDeviceMtl interface +class RenderDeviceMtlImpl final : public RenderDeviceBase<IRenderDeviceMtl> +{ +public: + using TRenderDeviceBase = RenderDeviceBase<IRenderDeviceMtl>; + + RenderDeviceMtlImpl( IReferenceCounters* pRefCounters, + IMemoryAllocator& RawMemAllocator, + const EngineMtlAttribs& EngineAttribs, + void* pMtlDevice, + Uint32 NumDeferredContexts ); + virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; + + virtual void CreateBuffer(const BufferDesc& BuffDesc, const BufferData& BuffData, IBuffer** ppBuffer)override final; + + virtual void CreateShader(const ShaderCreationAttribs& ShaderCreationAttribs, IShader** ppShader)override final; + + virtual void CreateTexture(const TextureDesc& TexDesc, const TextureData& Data, ITexture** ppTexture)override final; + + virtual void CreateSampler(const SamplerDesc& SamplerDesc, ISampler** ppSampler)override final; + + virtual void CreatePipelineState(const PipelineStateDesc &PipelineDesc, IPipelineState **ppPipelineState)override final; + + virtual void CreateFence(const FenceDesc& Desc, IFence** ppFence)override final; + + virtual void ReleaseStaleResources(bool ForceRelease = false)override final {} + + size_t GetCommandQueueCount()const { return 1; } + Uint64 GetCommandQueueMask()const { return Uint64{1};} + +private: + virtual void TestTextureFormat( TEXTURE_FORMAT TexFormat )override final; + + EngineMtlAttribs m_EngineAttribs; + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/include/SamplerMtlImpl.h b/Graphics/GraphicsEngineMetal/include/SamplerMtlImpl.h new file mode 100644 index 00000000..ac06c1e3 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/include/SamplerMtlImpl.h @@ -0,0 +1,55 @@ +/* Copyright 2015-2018 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 Diligent::SamplerMtlImpl class + +#include "SamplerMtl.h" +#include "RenderDeviceMtl.h" +#include "SamplerBase.h" +#include "RenderDeviceMtlImpl.h" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; +/// Implementation of the Diligent::ISamplerMtl interface +class SamplerMtlImpl final : public SamplerBase<ISamplerMtl, RenderDeviceMtlImpl> +{ +public: + using TSamplerBase = SamplerBase<ISamplerMtl, RenderDeviceMtlImpl>; + + SamplerMtlImpl(IReferenceCounters* pRefCounters, + class RenderDeviceMtlImpl* pRenderDeviceMtl, + const SamplerDesc& SamplerDesc); + ~SamplerMtlImpl(); + + virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject** ppInterface ) final; + +private: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h b/Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h new file mode 100644 index 00000000..8608cd27 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h @@ -0,0 +1,79 @@ +/* Copyright 2015-2018 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 Diligent::ShaderMtlImpl class + +#include "ShaderMtl.h" +#include "RenderDeviceMtl.h" +#include "ShaderBase.h" +#include "ShaderBase.h" +#include "RenderDeviceMtlImpl.h" + +namespace Diligent +{ + + +/// Implementation of the Diligent::IShaderMtl interface +class ShaderMtlImpl final : public ShaderBase<IShaderMtl, RenderDeviceMtlImpl> +{ +public: + using TShaderBase = ShaderBase<IShaderMtl, RenderDeviceMtlImpl>; + + ShaderMtlImpl(IReferenceCounters* pRefCounters, + class RenderDeviceMtlImpl* pRenderDeviceMtl, + const ShaderCreationAttribs& CreationAttribs); + ~ShaderMtlImpl(); + + virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject** ppInterface )override final; + + virtual void BindResources( IResourceMapping* pResourceMapping, Uint32 Flags )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"); + return 0; + } + + virtual IShaderVariable* GetShaderVariable(Uint32 Index)override final + { + LOG_ERROR_MESSAGE("ShaderMtlImpl::GetShaderVariable() is not implemented"); + return nullptr; + } + +private: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/include/ShaderResourceBindingMtlImpl.h b/Graphics/GraphicsEngineMetal/include/ShaderResourceBindingMtlImpl.h new file mode 100644 index 00000000..ab214cb9 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/include/ShaderResourceBindingMtlImpl.h @@ -0,0 +1,65 @@ +/* Copyright 2015-2018 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 Diligent::ShaderResourceBindingMtlImpl class + +#include "ShaderResourceBindingMtl.h" +#include "RenderDeviceMtl.h" +#include "ShaderResourceBindingBase.h" +#include "STDAllocator.h" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; +/// Implementation of the Diligent::IShaderResourceBindingMtl interface +class ShaderResourceBindingMtlImpl final : public ShaderResourceBindingBase<IShaderResourceBindingMtl> +{ +public: + using TBase = ShaderResourceBindingBase<IShaderResourceBindingMtl>; + + ShaderResourceBindingMtlImpl(IReferenceCounters* pRefCounters, + class PipelineStateMtlImpl* pPSO, + bool IsInternal); + ~ShaderResourceBindingMtlImpl(); + + virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject** ppInterface )override final; + + virtual void BindResources(Uint32 ShaderFlags, IResourceMapping* pResMapping, Uint32 Flags)override final; + + virtual IShaderVariable* 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 void InitializeStaticResources(const IPipelineState* pPipelineState)override final; + +private: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/include/SwapChainMtlImpl.h b/Graphics/GraphicsEngineMetal/include/SwapChainMtlImpl.h new file mode 100644 index 00000000..95d89e07 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/include/SwapChainMtlImpl.h @@ -0,0 +1,66 @@ +/* Copyright 2015-2018 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 Diligent::SwapChainMtlImpl class + +#include "SwapChainMtl.h" +#include "SwapChainBase.h" + +namespace Diligent +{ + +class IMemoryAllocator; +/// Implementation of the Diligent::ISwapChainMtl interface +class SwapChainMtlImpl final : public SwapChainBase<ISwapChainMtl> +{ +public: + using TSwapChainBase = SwapChainBase<ISwapChainMtl>; + + SwapChainMtlImpl(IReferenceCounters* pRefCounters, + const SwapChainDesc& SCDesc, + const FullScreenModeDesc& FSDesc, + class RenderDeviceMtlImpl* pRenderDeviceMtl, + class DeviceContextMtlImpl* pDeviceContextMtl, + void* pView); + ~SwapChainMtlImpl(); + + virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; + + virtual void Present(Uint32 SyncInterval)override final; + virtual void Resize( Uint32 NewWidth, Uint32 NewHeight )override final; + + virtual void SetFullscreenMode(const DisplayModeAttribs &DisplayMode)override final; + + virtual void SetWindowedMode()override final; + + virtual ITextureView* GetCurrentBackBufferRTV()override final; + virtual ITextureView* GetDepthBufferDSV()override final; + +private: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/include/TextureMtlImpl.h b/Graphics/GraphicsEngineMetal/include/TextureMtlImpl.h new file mode 100644 index 00000000..8fbef9bf --- /dev/null +++ b/Graphics/GraphicsEngineMetal/include/TextureMtlImpl.h @@ -0,0 +1,67 @@ +/* Copyright 2015-2018 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 Diligent::TextureMtlImpl class + +#include "TextureMtl.h" +#include "RenderDeviceMtl.h" +#include "TextureBase.h" +#include "TextureViewMtlImpl.h" +#include "RenderDeviceMtlImpl.h" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Base implementation of the Diligent::ITextureMtl interface +class TextureMtlImpl : public TextureBase<ITextureMtl, RenderDeviceMtlImpl, TextureViewMtlImpl, FixedBlockMemoryAllocator> +{ +public: + using TTextureBase = TextureBase<ITextureMtl, RenderDeviceMtlImpl, TextureViewMtlImpl, FixedBlockMemoryAllocator>; + using ViewImplType = TextureViewMtlImpl; + + TextureMtlImpl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceMtlImpl* pDeviceMtl, + const TextureDesc& TexDesc, + const TextureData& InitData = TextureData()); + ~TextureMtlImpl(); + + virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; + + virtual void* GetNativeHandle()override final + { + LOG_ERROR_MESSAGE("TextureMtlImpl::GetNativeHandle() is not implemented"); + return nullptr; + } + +protected: + void CreateViewInternal( const struct TextureViewDesc &ViewDesc, ITextureView **ppView, bool bIsDefaultView )override final; + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/include/TextureViewMtlImpl.h b/Graphics/GraphicsEngineMetal/include/TextureViewMtlImpl.h new file mode 100644 index 00000000..4fbf1e12 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/include/TextureViewMtlImpl.h @@ -0,0 +1,59 @@ +/* Copyright 2015-2018 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 Diligent::TextureViewMtlImpl class + +#include "TextureViewMtl.h" +#include "RenderDeviceMtl.h" +#include "TextureViewBase.h" +#include "RenderDeviceMtlImpl.h" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Implementation of the Diligent::ITextureViewMtl interface +class TextureViewMtlImpl final : public TextureViewBase<ITextureViewMtl, RenderDeviceMtlImpl> +{ +public: + using TTextureViewBase = TextureViewBase<ITextureViewMtl, RenderDeviceMtlImpl>; + + TextureViewMtlImpl( IReferenceCounters* pRefCounters, + RenderDeviceMtlImpl* pDevice, + const TextureViewDesc& ViewDesc, + class ITexture* pTexture, + void* pMtlView, + bool bIsDefaultView); + + virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; + + +protected: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/interface/BufferMtl.h b/Graphics/GraphicsEngineMetal/interface/BufferMtl.h new file mode 100644 index 00000000..e8d361ba --- /dev/null +++ b/Graphics/GraphicsEngineMetal/interface/BufferMtl.h @@ -0,0 +1,45 @@ +/* Copyright 2015-2018 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 Diligent::IBufferMtl interface + +#include "../../GraphicsEngine/interface/Buffer.h" + +namespace Diligent +{ + +// {F8A1A3AC-923A-419D-AB9D-FE9E35DC654B} +static const INTERFACE_ID IID_BufferMtl = +{ 0xf8a1a3ac, 0x923a, 0x419d, { 0xab, 0x9d, 0xfe, 0x9e, 0x35, 0xdc, 0x65, 0x4b } }; + +/// Interface to the buffer object implemented in Mtl +class IBufferMtl : public IBuffer +{ +public: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/interface/BufferViewMtl.h b/Graphics/GraphicsEngineMetal/interface/BufferViewMtl.h new file mode 100644 index 00000000..a866a9fd --- /dev/null +++ b/Graphics/GraphicsEngineMetal/interface/BufferViewMtl.h @@ -0,0 +1,45 @@ +/* Copyright 2015-2018 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 Diligent::IBufferViewMtl interface + +#include "../../GraphicsEngine/interface/BufferView.h" + +namespace Diligent +{ + +// {6D8B8199-1011-42B6-80DF-A9FA8B4F33FF} +static const INTERFACE_ID IID_BufferViewMtl = +{ 0x6d8b8199, 0x1011, 0x42b6, { 0x80, 0xdf, 0xa9, 0xfa, 0x8b, 0x4f, 0x33, 0xff } }; + +/// Interface to the buffer view object implemented in Mtl +class IBufferViewMtl : public IBufferView +{ +public: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/interface/DeviceContextMtl.h b/Graphics/GraphicsEngineMetal/interface/DeviceContextMtl.h new file mode 100644 index 00000000..a69ceb07 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/interface/DeviceContextMtl.h @@ -0,0 +1,45 @@ +/* Copyright 2015-2018 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 Diligent::IDeviceContextMtl interface + +#include "../../GraphicsEngine/interface/DeviceContext.h" + +namespace Diligent +{ + +// {2DEA7704-C586-4BA7-B938-93B239DFA268} +static const INTERFACE_ID IID_DeviceContextMtl = +{ 0x2dea7704, 0xc586, 0x4ba7, { 0xb9, 0x38, 0x93, 0xb2, 0x39, 0xdf, 0xa2, 0x68 } }; + +/// Interface to the device context object implemented in Mtl +class IDeviceContextMtl : public IDeviceContext +{ +public: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/interface/EngineMtlAttribs.h b/Graphics/GraphicsEngineMetal/interface/EngineMtlAttribs.h new file mode 100644 index 00000000..bdeab5c5 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/interface/EngineMtlAttribs.h @@ -0,0 +1,38 @@ +/* Copyright 2015-2018 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/FenceMtl.h b/Graphics/GraphicsEngineMetal/interface/FenceMtl.h new file mode 100644 index 00000000..5143fc0f --- /dev/null +++ b/Graphics/GraphicsEngineMetal/interface/FenceMtl.h @@ -0,0 +1,45 @@ +/* Copyright 2015-2018 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 Diligent::IFenceMtl interface + +#include "../../GraphicsEngine/interface/Fence.h" + +namespace Diligent +{ + +// {54FE9F8F-FBBF-4ABB-8280-D980982DA364} +static const INTERFACE_ID IID_FenceMtl = +{ 0x54fe9f8f, 0xfbbf, 0x4abb, { 0x82, 0x80, 0xd9, 0x80, 0x98, 0x2d, 0xa3, 0x64 } }; + +/// Interface to the fence object implemented in Mtl +class IFenceMtl : public IFence +{ +public: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/interface/PipelineStateMtl.h b/Graphics/GraphicsEngineMetal/interface/PipelineStateMtl.h new file mode 100644 index 00000000..cc5633c0 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/interface/PipelineStateMtl.h @@ -0,0 +1,45 @@ +/* Copyright 2015-2018 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 Diligent::IPipeplineStateMtl interface + +#include "../../GraphicsEngine/interface/PipelineState.h" + +namespace Diligent +{ + +// {B6A17C51-CCA9-44E1-A2DC-5DE250CF85AD} +static const INTERFACE_ID IID_PipelineStateMtl = +{ 0xb6a17c51, 0xcca9, 0x44e1, { 0xa2, 0xdc, 0x5d, 0xe2, 0x50, 0xcf, 0x85, 0xad } }; + +/// Interface to the blend state object implemented in Mtl +class IPipelineStateMtl : public IPipelineState +{ +public: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/interface/RenderDeviceFactoryMtl.h b/Graphics/GraphicsEngineMetal/interface/RenderDeviceFactoryMtl.h new file mode 100644 index 00000000..1cad56e9 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/interface/RenderDeviceFactoryMtl.h @@ -0,0 +1,67 @@ +/* Copyright 2015-2018 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 Direct3D11-based engine implementation + +#include <sstream> + +#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, + const FullScreenModeDesc& FSDesc, + 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/interface/RenderDeviceMtl.h b/Graphics/GraphicsEngineMetal/interface/RenderDeviceMtl.h new file mode 100644 index 00000000..5ac68af1 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/interface/RenderDeviceMtl.h @@ -0,0 +1,45 @@ +/* Copyright 2015-2018 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 Diligent::IRenderDeviceMtl interface + +#include "../../GraphicsEngine/interface/RenderDevice.h" + +namespace Diligent +{ + +// {8D483E4A-2D53-47B2-B8D7-276F4CE57F68} +static const INTERFACE_ID IID_RenderDeviceMtl = +{ 0x8d483e4a, 0x2d53, 0x47b2, { 0xb8, 0xd7, 0x27, 0x6f, 0x4c, 0xe5, 0x7f, 0x68 } }; + +/// Interface to the render device object implemented in Mtl +class IRenderDeviceMtl : public IRenderDevice +{ +public: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/interface/SamplerMtl.h b/Graphics/GraphicsEngineMetal/interface/SamplerMtl.h new file mode 100644 index 00000000..ce3f6143 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/interface/SamplerMtl.h @@ -0,0 +1,45 @@ +/* Copyright 2015-2018 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 Diligent::ISamplerMtl interface + +#include "../../GraphicsEngine/interface/Sampler.h" + +namespace Diligent +{ + +// {73F8C099-049B-4C81-AD19-C98963AC7FEB} +static const INTERFACE_ID IID_SamplerMtl = +{ 0x73f8c099, 0x49b, 0x4c81, { 0xad, 0x19, 0xc9, 0x89, 0x63, 0xac, 0x7f, 0xeb } }; + +/// Interface to the sampler object implemented in Mtl +class ISamplerMtl : public ISampler +{ +public: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/interface/ShaderMtl.h b/Graphics/GraphicsEngineMetal/interface/ShaderMtl.h new file mode 100644 index 00000000..16803554 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/interface/ShaderMtl.h @@ -0,0 +1,45 @@ +/* Copyright 2015-2018 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 Diligent::IShaderMtl interface + +#include "../../GraphicsEngine/interface/Shader.h" + +namespace Diligent +{ + +// {07182C29-CC3B-43B2-99D8-A77F6FECBA82} +static const INTERFACE_ID IID_ShaderMtl = +{ 0x7182c29, 0xcc3b, 0x43b2, { 0x99, 0xd8, 0xa7, 0x7f, 0x6f, 0xec, 0xba, 0x82 } }; + +/// Interface to the shader object implemented in Mtl +class IShaderMtl : public IShader +{ +public: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/interface/ShaderResourceBindingMtl.h b/Graphics/GraphicsEngineMetal/interface/ShaderResourceBindingMtl.h new file mode 100644 index 00000000..cbda8715 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/interface/ShaderResourceBindingMtl.h @@ -0,0 +1,45 @@ +/* Copyright 2015-2018 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 Diligent::IShaderResourceBindingMtl interface and related data structures + +#include "../../GraphicsEngine/interface/ShaderResourceBinding.h" + +namespace Diligent +{ + +// {4D7AF38E-4650-4A11-B33B-FFC70A8CD68B} +static const INTERFACE_ID IID_ShaderResourceBindingMtl = +{ 0x4d7af38e, 0x4650, 0x4a11, { 0xb3, 0x3b, 0xff, 0xc7, 0xa, 0x8c, 0xd6, 0x8b } }; + +/// Shader resource binding interface +class IShaderResourceBindingMtl : public IShaderResourceBinding +{ +public: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/interface/SwapChainMtl.h b/Graphics/GraphicsEngineMetal/interface/SwapChainMtl.h new file mode 100644 index 00000000..dbfde097 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/interface/SwapChainMtl.h @@ -0,0 +1,46 @@ +/* Copyright 2015-2018 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 Diligent::ISwapChainMtl interface + +#include "../../GraphicsEngine/interface/SwapChain.h" +#include "TextureViewMtl.h" + +namespace Diligent +{ + +// {8ACDD0D9-FF1C-4A78-9866-924459A0D456} +static const INTERFACE_ID IID_SwapChainMtl = +{ 0x8acdd0d9, 0xff1c, 0x4a78, { 0x98, 0x66, 0x92, 0x44, 0x59, 0xa0, 0xd4, 0x56 } }; + +/// Interface to the swap chain object implemented in Mtl +class ISwapChainMtl : public ISwapChain +{ +public: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/interface/TextureMtl.h b/Graphics/GraphicsEngineMetal/interface/TextureMtl.h new file mode 100644 index 00000000..8a7479af --- /dev/null +++ b/Graphics/GraphicsEngineMetal/interface/TextureMtl.h @@ -0,0 +1,45 @@ +/* Copyright 2015-2018 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 Diligent::ITextureMtl interface + +#include "../../GraphicsEngine/interface/Texture.h" + +namespace Diligent +{ + +// {D3A85032-224D-45E5-9825-3AABD61A5EA5} +static const INTERFACE_ID IID_TextureMtl = +{ 0xd3a85032, 0x224d, 0x45e5, { 0x98, 0x25, 0x3a, 0xab, 0xd6, 0x1a, 0x5e, 0xa5 } }; + +/// Interface to the texture object implemented in Mtl +class ITextureMtl : public ITexture +{ +public: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/interface/TextureViewMtl.h b/Graphics/GraphicsEngineMetal/interface/TextureViewMtl.h new file mode 100644 index 00000000..6d75c167 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/interface/TextureViewMtl.h @@ -0,0 +1,45 @@ +/* Copyright 2015-2018 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 Diligent::ITextureViewMtl interface + +#include "../../GraphicsEngine/interface/TextureView.h" + +namespace Diligent +{ + +// {94C0D9C3-61E7-4358-AB9F-066EAD84D6F1} +static const INTERFACE_ID IID_TextureViewMtl = +{ 0x94c0d9c3, 0x61e7, 0x4358, { 0xab, 0x9f, 0x6, 0x6e, 0xad, 0x84, 0xd6, 0xf1 } }; + +/// Interface to the texture view object implemented in Mtl +class ITextureViewMtl : public ITextureView +{ +public: + +}; + +} diff --git a/Graphics/GraphicsEngineMetal/readme.md b/Graphics/GraphicsEngineMetal/readme.md new file mode 100644 index 00000000..343880b4 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/readme.md @@ -0,0 +1,6 @@ + +# GraphicsEngineMetal + +Implementation of Diligent Engine API using Metal. + +This backend is not yet implemented.
\ No newline at end of file diff --git a/Graphics/GraphicsEngineMetal/src/BufferMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/BufferMtlImpl.mm new file mode 100644 index 00000000..9db9bc3c --- /dev/null +++ b/Graphics/GraphicsEngineMetal/src/BufferMtlImpl.mm @@ -0,0 +1,87 @@ +/* Copyright 2015-2018 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 "BufferMtlImpl.h" +#include "RenderDeviceMtlImpl.h" +#include "DeviceContextMtlImpl.h" +#include "MtlTypeConversions.h" +#include "BufferViewMtlImpl.h" +#include "GraphicsAccessories.h" +#include "EngineMemory.h" + +namespace Diligent +{ + +BufferMtlImpl :: BufferMtlImpl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& BuffViewObjMemAllocator, + RenderDeviceMtlImpl* pRenderDeviceMtl, + const BufferDesc& BuffDesc, + const BufferData& BuffData /*= BufferData()*/) : + TBufferBase(pRefCounters, BuffViewObjMemAllocator, pRenderDeviceMtl, BuffDesc, false) +{ + LOG_ERROR_AND_THROW("Buffers are not implemented in Metal backend"); +} + +BufferDesc BuffDescFromMtlBuffer(void* pMtlBuffer, const BufferDesc& Desc) +{ + UNSUPPORTED("Not implemented"); + return BufferDesc{}; +} + +BufferMtlImpl :: BufferMtlImpl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& BuffViewObjMemAllocator, + class RenderDeviceMtlImpl* pDeviceMtl, + const BufferDesc& BuffDesc, + RESOURCE_STATE InitialState, + void* pMtlBuffer) : + TBufferBase(pRefCounters, BuffViewObjMemAllocator, pDeviceMtl, BuffDescFromMtlBuffer(pMtlBuffer, BuffDesc), false) +{ + SetState(InitialState); +} + +BufferMtlImpl :: ~BufferMtlImpl() +{ +} + +IMPLEMENT_QUERY_INTERFACE( BufferMtlImpl, IID_BufferMtl, TBufferBase ) + +void BufferMtlImpl::CreateViewInternal( const BufferViewDesc& OrigViewDesc, IBufferView** ppView, bool bIsDefaultView ) +{ + VERIFY( ppView != nullptr, "Null pointer provided" ); + if( !ppView )return; + VERIFY( *ppView == nullptr, "Overwriting reference to existing object may cause memory leaks" ); + + *ppView = nullptr; + + try + { + LOG_ERROR_MESSAGE("BufferD3D11Impl::CreateViewInternal() is not implemented"); + } + catch( const std::runtime_error & ) + { + const auto *ViewTypeName = GetBufferViewTypeLiteralName(OrigViewDesc.ViewType); + LOG_ERROR("Failed to create view '", OrigViewDesc.Name ? OrigViewDesc.Name : "", "' (", ViewTypeName, ") for buffer '", m_Desc.Name, "'" ); + } +} + +} diff --git a/Graphics/GraphicsEngineMetal/src/BufferViewMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/BufferViewMtlImpl.mm new file mode 100644 index 00000000..2842ea8b --- /dev/null +++ b/Graphics/GraphicsEngineMetal/src/BufferViewMtlImpl.mm @@ -0,0 +1,43 @@ +/* Copyright 2015-2018 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 "BufferViewMtlImpl.h" + +namespace Diligent +{ + +BufferViewMtlImpl::BufferViewMtlImpl( IReferenceCounters* pRefCounters, + RenderDeviceMtlImpl* pDevice, + const BufferViewDesc& ViewDesc, + IBuffer* pBuffer, + void* pMtlView, + bool bIsDefaultView ) : + TBufferViewBase( pRefCounters, pDevice, ViewDesc, pBuffer, bIsDefaultView ) +{ + LOG_ERROR_AND_THROW("Buffer views are not implemented in Metal backend"); +} + +IMPLEMENT_QUERY_INTERFACE( BufferViewMtlImpl, IID_BufferViewMtl, TBufferViewBase ) + +} diff --git a/Graphics/GraphicsEngineMetal/src/CommandListMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/CommandListMtlImpl.mm new file mode 100644 index 00000000..1b59f293 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/src/CommandListMtlImpl.mm @@ -0,0 +1,41 @@ +/* Copyright 2015-2018 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 "CommandListMtlImpl.h" +#include "EngineMemory.h" + +namespace Diligent +{ + +CommandListMtlImpl :: CommandListMtlImpl(IReferenceCounters* pRefCounters, + RenderDeviceMtlImpl* pDevice, + void* pMtlCommandList) : + TCommandListBase(pRefCounters, pDevice) +{ +} + +CommandListMtlImpl :: ~CommandListMtlImpl() +{ +} + +} diff --git a/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm new file mode 100644 index 00000000..bcd1a6ce --- /dev/null +++ b/Graphics/GraphicsEngineMetal/src/DeviceContextMtlImpl.mm @@ -0,0 +1,456 @@ +/* Copyright 2015-2018 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 "DeviceContextMtlImpl.h" +#include "BufferMtlImpl.h" +#include "ShaderMtlImpl.h" +#include "SamplerMtlImpl.h" +#include "MtlTypeConversions.h" +#include "TextureViewMtlImpl.h" +#include "PipelineStateMtlImpl.h" +#include "SwapChainMtl.h" +#include "ShaderResourceBindingMtlImpl.h" +#include "EngineMtlAttribs.h" +#include "CommandListMtlImpl.h" +#include "RenderDeviceMtlImpl.h" +#include "FenceMtlImpl.h" + +namespace Diligent +{ + DeviceContextMtlImpl::DeviceContextMtlImpl( IReferenceCounters* pRefCounters, + IMemoryAllocator& Allocator, + IRenderDevice* pDevice, + const struct EngineMtlAttribs& EngineAttribs, + bool bIsDeferred ) : + TDeviceContextBase(pRefCounters, pDevice, bIsDeferred) + { + } + + IMPLEMENT_QUERY_INTERFACE( DeviceContextMtlImpl, IID_DeviceContextMtl, TDeviceContextBase ) + + void DeviceContextMtlImpl::SetPipelineState(IPipelineState* pPipelineState) + { + auto* pPipelineStateMtl = ValidatedCast<PipelineStateMtlImpl>(pPipelineState); + TDeviceContextBase::SetPipelineState( pPipelineStateMtl, 0 /*Dummy*/ ); + + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::SetPipelineState() is not implemented"); + + auto& Desc = pPipelineStateMtl->GetDesc(); + if (Desc.IsComputePipeline) + { + + } + else + { + + } + } + + void DeviceContextMtlImpl::TransitionShaderResources(IPipelineState* pPipelineState, IShaderResourceBinding* pShaderResourceBinding) + { + DEV_CHECK_ERR(pPipelineState != nullptr, "Pipeline state must not be null"); + DEV_CHECK_ERR(pShaderResourceBinding != nullptr, "Shader resource binding must not be null"); + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::TransitionShaderResources() is not implemented"); + } + + void DeviceContextMtlImpl::CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) + { + if (!DeviceContextBase::CommitShaderResources(pShaderResourceBinding, StateTransitionMode, 0 /*Dummy*/)) + return; + + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::CommitShaderResources() is not implemented"); + } + + void DeviceContextMtlImpl::SetStencilRef(Uint32 StencilRef) + { + if (TDeviceContextBase::SetStencilRef(StencilRef, 0)) + { + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::SetStencilRef() is not implemented"); + } + } + + + void DeviceContextMtlImpl::SetBlendFactors(const float* pBlendFactors) + { + if (TDeviceContextBase::SetBlendFactors(pBlendFactors, 0)) + { + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::SetBlendFactors() is not implemented"); + } + } + + void DeviceContextMtlImpl::Draw( DrawAttribs &drawAttribs ) + { +#ifdef DEVELOPMENT + if (!DvpVerifyDrawArguments(drawAttribs)) + return; +#endif + + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::Draw() is not implemented"); + } + + void DeviceContextMtlImpl::DispatchCompute( const DispatchComputeAttribs &DispatchAttrs ) + { +#ifdef DEVELOPMENT + if (!DvpVerifyDispatchArguments(DispatchAttrs)) + return; +#endif + + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::DispatchCompute() is not implemented"); + } + + void DeviceContextMtlImpl::ClearDepthStencil(ITextureView* pView, + CLEAR_DEPTH_STENCIL_FLAGS ClearFlags, + float fDepth, + Uint8 Stencil, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) + { + if (pView == nullptr) + { + if (m_pSwapChain) + { + pView = m_pSwapChain->GetDepthBufferDSV(); + } + else + { + LOG_ERROR("Failed to clear default depth stencil buffer: swap chain is not initialized in the device context"); + return; + } + } + + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::ClearDepthStencil() is not implemented"); + } + + void DeviceContextMtlImpl::ClearRenderTarget( ITextureView* pView, const float *RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode ) + { + if (pView == nullptr) + { + if (m_pSwapChain != nullptr) + { + pView = m_pSwapChain->GetCurrentBackBufferRTV(); + } + else + { + LOG_ERROR("Failed to clear default render target: swap chain is not initialized in the device context"); + return; + } + } + + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::ClearRenderTarget() is not implemented"); + } + + void DeviceContextMtlImpl::Flush() + { + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::Flush() is not implemented"); + } + + void DeviceContextMtlImpl::UpdateBuffer(IBuffer* pBuffer, + Uint32 Offset, + Uint32 Size, + const PVoid pData, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) + { + TDeviceContextBase::UpdateBuffer(pBuffer, Offset, Size, pData, StateTransitionMode); + + auto* pBufferMtlImpl = ValidatedCast<BufferMtlImpl>( pBuffer ); + + (void)pBufferMtlImpl; + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::UpdateBuffer() is not implemented"); + } + + void DeviceContextMtlImpl::CopyBuffer(IBuffer* pSrcBuffer, + Uint32 SrcOffset, + RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, + IBuffer* pDstBuffer, + Uint32 DstOffset, + Uint32 Size, + RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode) + { + TDeviceContextBase::CopyBuffer(pSrcBuffer, SrcOffset, SrcBufferTransitionMode, pDstBuffer, DstOffset, Size, DstBufferTransitionMode); + + auto* pSrcBufferMtlImpl = ValidatedCast<BufferMtlImpl>( pSrcBuffer ); + auto* pDstBufferMtlImpl = ValidatedCast<BufferMtlImpl>( pDstBuffer ); + + (void)pSrcBufferMtlImpl; + (void)pDstBufferMtlImpl; + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::CopyBuffer() is not implemented"); + } + + + void DeviceContextMtlImpl::MapBuffer(IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid& pMappedData) + { + TDeviceContextBase::MapBuffer(pBuffer, MapType, MapFlags, pMappedData); + + auto* pBufferMtl = ValidatedCast<BufferMtlImpl>(pBuffer); + + (void)pBufferMtl; + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::MapBuffer() is not implemented"); + } + + void DeviceContextMtlImpl::UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType) + { + TDeviceContextBase::UnmapBuffer(pBuffer, MapType); + auto* pBufferMtl = ValidatedCast<BufferMtlImpl>(pBuffer); + + (void)pBufferMtl; + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::UnmapBuffer() is not implemented"); + } + + void DeviceContextMtlImpl::UpdateTexture(ITexture* pTexture, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData, + RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, + RESOURCE_STATE_TRANSITION_MODE DstTextureTransitionMode) + { + TDeviceContextBase::UpdateTexture( pTexture, MipLevel, Slice, DstBox, SubresData, SrcBufferTransitionMode, DstTextureTransitionMode ); + + auto* pTexMtl = ValidatedCast<TextureMtlImpl>(pTexture); + const auto& Desc = pTexMtl->GetDesc(); + + (void)Desc; + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::UpdateTexture() is not implemented"); + } + + void DeviceContextMtlImpl::CopyTexture(const CopyTextureAttribs& CopyAttribs) + { + TDeviceContextBase::CopyTexture( CopyAttribs ); + + auto* pSrcTexMtl = ValidatedCast<TextureMtlImpl>( CopyAttribs.pSrcTexture ); + auto* pDstTexMtl = ValidatedCast<TextureMtlImpl>( CopyAttribs.pDstTexture ); + + (void)pSrcTexMtl; + (void)pDstTexMtl; + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::CopyTexture() is not implemented"); + } + + + void DeviceContextMtlImpl::MapTextureSubresource( ITexture* pTexture, + Uint32 MipLevel, + Uint32 ArraySlice, + MAP_TYPE MapType, + MAP_FLAGS MapFlags, + const Box* pMapRegion, + MappedTextureSubresource& MappedData ) + { + TDeviceContextBase::MapTextureSubresource(pTexture, MipLevel, ArraySlice, MapType, MapFlags, pMapRegion, MappedData); + + auto* pTexMtl = ValidatedCast<TextureMtlImpl>(pTexture); + const auto& TexDesc = pTexMtl->GetDesc(); + + (void)TexDesc; + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::MapTextureSubresource() is not implemented"); + } + + void DeviceContextMtlImpl::UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice) + { + TDeviceContextBase::UnmapTextureSubresource( pTexture, MipLevel, ArraySlice); + + auto* pTexMtl = ValidatedCast<TextureMtlImpl>(pTexture); + const auto& TexDesc = pTexMtl->GetDesc(); + + (void)TexDesc; + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::UnmapTextureSubresource() is not implemented"); + } + + void DeviceContextMtlImpl::GenerateMips(ITextureView* pTextureView) + { + TDeviceContextBase::GenerateMips(pTextureView); + auto& TexViewMtl = *ValidatedCast<TextureViewMtlImpl>(pTextureView); + + (void)TexViewMtl; + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::GenerateMips() is not implemented"); + } + + void DeviceContextMtlImpl::FinishFrame() + { + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::FinishFrame() is not implemented"); + } + + void DeviceContextMtlImpl::SetVertexBuffers( Uint32 StartSlot, + Uint32 NumBuffersSet, + IBuffer** ppBuffers, + Uint32* pOffsets, + RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, + SET_VERTEX_BUFFERS_FLAGS Flags ) + { + TDeviceContextBase::SetVertexBuffers( StartSlot, NumBuffersSet, ppBuffers, pOffsets, StateTransitionMode, Flags ); + + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::SetVertexBuffers() is not implemented"); + for (Uint32 Slot = 0; Slot < m_NumVertexStreams; ++Slot) + { + auto& CurrStream = m_VertexStreams[Slot]; + if (auto* pBuffMtlImpl = CurrStream.pBuffer.RawPtr()) + { + + } + } + } + + void DeviceContextMtlImpl::SetIndexBuffer( IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode ) + { + TDeviceContextBase::SetIndexBuffer( pIndexBuffer, ByteOffset, StateTransitionMode ); + + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::SetIndexBuffer() is not implemented"); + if (m_pIndexBuffer) + { + + } + + } + + void DeviceContextMtlImpl::SetViewports( Uint32 NumViewports, const Viewport* pViewports, Uint32 RTWidth, Uint32 RTHeight ) + { + TDeviceContextBase::SetViewports( NumViewports, pViewports, RTWidth, RTHeight ); + + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::SetViewports() is not implemented"); + } + + void DeviceContextMtlImpl::SetScissorRects( Uint32 NumRects, const Rect* pRects, Uint32 RTWidth, Uint32 RTHeight ) + { + TDeviceContextBase::SetScissorRects(NumRects, pRects, RTWidth, RTHeight); + + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::SetScissorRects() is not implemented"); + } + + void DeviceContextMtlImpl::FinishCommandList(ICommandList **ppCommandList) + { + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::FinishCommandList() is not implemented"); + } + + void DeviceContextMtlImpl::ExecuteCommandList(ICommandList* pCommandList) + { + if (m_bIsDeferred) + { + LOG_ERROR("Only immediate context can execute command list"); + return; + } + + CommandListMtlImpl* pCmdListMtl = ValidatedCast<CommandListMtlImpl>(pCommandList); + + (void)pCmdListMtl; + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::ExecuteCommandList() is not implemented"); + } + + void DeviceContextMtlImpl::SignalFence(IFence* pFence, Uint64 Value) + { + VERIFY(!m_bIsDeferred, "Fence can only be signalled from immediate context"); + + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::SignalFence() is not implemented"); + }; + + void DeviceContextMtlImpl::TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers) + { + LOG_ERROR_MESSAGE("DeviceContextMtlImpl::TransitionResourceStates() is not implemented"); + + for (Uint32 i=0; i < BarrierCount; ++i) + { + const auto& Barrier = pResourceBarriers[i]; +#ifdef DEVELOPMENT + DvpVerifyStateTransitionDesc(Barrier); +#endif + DEV_CHECK_ERR((Barrier.pTexture != nullptr) ^ (Barrier.pBuffer != nullptr), "Exactly one of pTexture or pBuffer must not be null"); + DEV_CHECK_ERR(Barrier.NewState != RESOURCE_STATE_UNKNOWN, "New resource state can't be unknown"); + + if (Barrier.TransitionType == STATE_TRANSITION_TYPE_BEGIN) + { + // Skip begin-split barriers + VERIFY(!Barrier.UpdateResourceState, "Resource state can't be updated in begin-split barrier"); + continue; + } + VERIFY(Barrier.TransitionType == STATE_TRANSITION_TYPE_IMMEDIATE || Barrier.TransitionType == STATE_TRANSITION_TYPE_END, "Unexpected barrier type"); + + if (Barrier.pTexture) + { + auto* pTextureMtlImpl = ValidatedCast<TextureMtlImpl>(Barrier.pTexture); + auto OldState = Barrier.OldState; + if (OldState == RESOURCE_STATE_UNKNOWN) + { + if (pTextureMtlImpl->IsInKnownState()) + { + OldState = pTextureMtlImpl->GetState(); + } + else + { + LOG_ERROR_MESSAGE("Failed to transition the state of texture '", pTextureMtlImpl->GetDesc().Name, "' because the buffer state is unknown and is not explicitly specified"); + continue; + } + } + else + { + if (pTextureMtlImpl->IsInKnownState() && pTextureMtlImpl->GetState() != OldState) + { + LOG_ERROR_MESSAGE("The state ", GetResourceStateString(pTextureMtlImpl->GetState()), " of texture '", + pTextureMtlImpl->GetDesc().Name, "' does not match the old state ", GetResourceStateString(OldState), + " specified by the barrier"); + } + } + + + // Actual barrier code goes here + + + if (Barrier.UpdateResourceState) + { + pTextureMtlImpl->SetState(Barrier.NewState); + } + } + else + { + VERIFY_EXPR(Barrier.pBuffer); + auto* pBufferMtlImpl = ValidatedCast<BufferMtlImpl>(Barrier.pBuffer); + auto OldState = Barrier.OldState; + if (OldState == RESOURCE_STATE_UNKNOWN) + { + if (pBufferMtlImpl->IsInKnownState()) + { + OldState = pBufferMtlImpl->GetState(); + } + else + { + LOG_ERROR_MESSAGE("Failed to transition the state of buffer '", pBufferMtlImpl->GetDesc().Name, "' because the buffer state is unknown and is not explicitly specified"); + continue; + } + } + else + { + if (pBufferMtlImpl->IsInKnownState() && pBufferMtlImpl->GetState() != OldState) + { + LOG_ERROR_MESSAGE("The state ", GetResourceStateString(pBufferMtlImpl->GetState()), " of buffer '", + pBufferMtlImpl->GetDesc().Name, "' does not match the old state ", GetResourceStateString(OldState), + " specified by the barrier"); + } + } + + + // Actual barrier code goes here + + + if (Barrier.UpdateResourceState) + { + pBufferMtlImpl->SetState(Barrier.NewState); + } + } + } + } +} diff --git a/Graphics/GraphicsEngineMetal/src/FenceMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/FenceMtlImpl.mm new file mode 100644 index 00000000..b181c9e7 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/src/FenceMtlImpl.mm @@ -0,0 +1,52 @@ +/* Copyright 2015-2018 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 "FenceMtlImpl.h" +#include "EngineMemory.h" + +namespace Diligent +{ + +FenceMtlImpl :: FenceMtlImpl(IReferenceCounters* pRefCounters, + RenderDeviceMtlImpl* pDevice, + const FenceDesc& Desc) : + TFenceBase(pRefCounters, pDevice, Desc) +{ +} + +FenceMtlImpl :: ~FenceMtlImpl() +{ +} + +Uint64 FenceMtlImpl :: GetCompletedValue() +{ + LOG_ERROR_MESSAGE("FenceMtlImpl::GetCompletedValue() is not implemented"); + return 0; +} + +void FenceMtlImpl :: Reset(Uint64 Value) +{ + LOG_ERROR_MESSAGE("FenceMtlImpl::Reset() is not implemented"); +} + +} diff --git a/Graphics/GraphicsEngineMetal/src/MtlTypeConversions.mm b/Graphics/GraphicsEngineMetal/src/MtlTypeConversions.mm new file mode 100644 index 00000000..57aebe01 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/src/MtlTypeConversions.mm @@ -0,0 +1,29 @@ +/* Copyright 2015-2018 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 "MtlTypeConversions.h" + +namespace Diligent +{ + +} diff --git a/Graphics/GraphicsEngineMetal/src/PipelineStateMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/PipelineStateMtlImpl.mm new file mode 100644 index 00000000..fb107c96 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/src/PipelineStateMtlImpl.mm @@ -0,0 +1,79 @@ +/* Copyright 2015-2018 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 "PipelineStateMtlImpl.h" +#include "RenderDeviceMtlImpl.h" +#include "ShaderResourceBindingMtlImpl.h" +#include "EngineMemory.h" + +namespace Diligent +{ + +PipelineStateMtlImpl::PipelineStateMtlImpl(IReferenceCounters* pRefCounters, + RenderDeviceMtlImpl* pRenderDeviceMtl, + const PipelineStateDesc& PipelineDesc) : + TPipelineStateBase(pRefCounters, pRenderDeviceMtl, PipelineDesc) +{ + LOG_ERROR_AND_THROW("Pipeline states are not implemented in Metal backend"); + if (PipelineDesc.IsComputePipeline) + { + + } + else + { + + } +} + + +PipelineStateMtlImpl::~PipelineStateMtlImpl() +{ +} + +IMPLEMENT_QUERY_INTERFACE( PipelineStateMtlImpl, IID_PipelineStateMtl, TPipelineStateBase ) + + +void PipelineStateMtlImpl::CreateShaderResourceBinding(IShaderResourceBinding** ppShaderResourceBinding, bool InitStaticResources) +{ + auto* pRenderDeviceMtl = ValidatedCast<RenderDeviceMtlImpl>( GetDevice() ); + + (void)pRenderDeviceMtl; + LOG_ERROR_MESSAGE("PipelineStateMtlImpl::CreateShaderResourceBinding() is not implemented"); +} + +bool PipelineStateMtlImpl::IsCompatibleWith(const IPipelineState* pPSO)const +{ + VERIFY_EXPR(pPSO != nullptr); + + if (pPSO == this) + return true; + + const PipelineStateMtlImpl* pPSOMtl = ValidatedCast<const PipelineStateMtlImpl>(pPSO); + + (void)pPSOMtl; + LOG_ERROR_MESSAGE("PipelineStateMtlImpl::IsCompatibleWith() is not implemented"); + + return false; +} + +} diff --git a/Graphics/GraphicsEngineMetal/src/RenderDeviceFactoryMtl.mm b/Graphics/GraphicsEngineMetal/src/RenderDeviceFactoryMtl.mm new file mode 100644 index 00000000..e5735aed --- /dev/null +++ b/Graphics/GraphicsEngineMetal/src/RenderDeviceFactoryMtl.mm @@ -0,0 +1,251 @@ +/* Copyright 2015-2018 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, + const FullScreenModeDesc& FSDesc, + 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<IObject**>(ppDevice)); + + RefCntAutoPtr<DeviceContextMtlImpl> 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<IObject**>(ppContexts)); + pRenderDeviceMtl->SetImmediateContext(pDeviceContextMtl); + + for (Uint32 DeferredCtx = 0; DeferredCtx < NumDeferredContexts; ++DeferredCtx) + { + RefCntAutoPtr<DeviceContextMtlImpl> 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<IObject**>(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, + const FullScreenModeDesc& FSDesc, + void* pView, + ISwapChain** ppSwapChain ) +{ + VERIFY( ppSwapChain, "Null pointer provided" ); + if( !ppSwapChain ) + return; + + *ppSwapChain = nullptr; + + try + { + auto *pDeviceMtl = ValidatedCast<RenderDeviceMtlImpl>( pDevice ); + auto *pDeviceContextMtl = ValidatedCast<DeviceContextMtlImpl>(pImmediateContext); + auto &RawMemAllocator = GetRawAllocator(); + + auto *pSwapChainMtl = NEW_RC_OBJ(RawMemAllocator, "SwapChainMtlImpl instance", SwapChainMtlImpl) + (SCDesc, FSDesc, pDeviceMtl, pDeviceContextMtl, pView); + pSwapChainMtl->QueryInterface( IID_SwapChain, reinterpret_cast<IObject**>(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<DeviceContextMtlImpl>(); + 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/RenderDeviceMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm new file mode 100644 index 00000000..01aca14e --- /dev/null +++ b/Graphics/GraphicsEngineMetal/src/RenderDeviceMtlImpl.mm @@ -0,0 +1,170 @@ +/* Copyright 2015-2018 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 "RenderDeviceMtlImpl.h" +#include "DeviceContextMtlImpl.h" +#include "BufferMtlImpl.h" +#include "ShaderMtlImpl.h" +#include "TextureMtlImpl.h" +#include "SamplerMtlImpl.h" +#include "MtlTypeConversions.h" +#include "TextureViewMtlImpl.h" +#include "PipelineStateMtlImpl.h" +#include "ShaderResourceBindingMtlImpl.h" +#include "FenceMtlImpl.h" +#include "EngineMemory.h" + +namespace Diligent +{ + +RenderDeviceMtlImpl :: RenderDeviceMtlImpl(IReferenceCounters* pRefCounters, + IMemoryAllocator& RawMemAllocator, + const EngineMtlAttribs& EngineAttribs, + void* pMtlDevice, + Uint32 NumDeferredContexts) : + TRenderDeviceBase + { + pRefCounters, + RawMemAllocator, + NumDeferredContexts, + sizeof(TextureMtlImpl), + sizeof(TextureViewMtlImpl), + sizeof(BufferMtlImpl), + sizeof(BufferViewMtlImpl), + sizeof(ShaderMtlImpl), + sizeof(SamplerMtlImpl), + sizeof(PipelineStateMtlImpl), + sizeof(ShaderResourceBindingMtlImpl), + sizeof(FenceMtlImpl) + }, + m_EngineAttribs(EngineAttribs) +{ + m_DeviceCaps.DevType = DeviceType::Metal; + m_DeviceCaps.MajorVersion = 11; + m_DeviceCaps.MinorVersion = 0; + m_DeviceCaps.bSeparableProgramSupported = True; + m_DeviceCaps.bMultithreadedResourceCreationSupported = True; + m_DeviceCaps.bGeometryShadersSupported = False; + m_DeviceCaps.bTessellationSupported = False; +} + +void RenderDeviceMtlImpl::TestTextureFormat( TEXTURE_FORMAT TexFormat ) +{ + auto &TexFormatInfo = m_TextureFormatsInfo[TexFormat]; + VERIFY( TexFormatInfo.Supported, "Texture format is not supported" ); + + LOG_ERROR_MESSAGE("RenderDeviceMtlImpl::TestTextureFormat() is not implemented"); +} + +IMPLEMENT_QUERY_INTERFACE( RenderDeviceMtlImpl, IID_RenderDeviceMtl, TRenderDeviceBase ) + +void RenderDeviceMtlImpl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData& BuffData, IBuffer** ppBuffer) +{ + CreateDeviceObject("buffer", BuffDesc, ppBuffer, + [&]() + { + BufferMtlImpl* pBufferMtl( NEW_RC_OBJ(m_BufObjAllocator, "BufferMtlImpl instance", BufferMtlImpl) + (m_BuffViewObjAllocator, this, BuffDesc, BuffData ) ); + pBufferMtl->QueryInterface( IID_Buffer, reinterpret_cast<IObject**>(ppBuffer) ); + pBufferMtl->CreateDefaultViews(); + OnCreateDeviceObject( pBufferMtl ); + } + ); +} + +void RenderDeviceMtlImpl :: CreateShader(const ShaderCreationAttribs& ShaderCreationAttribs, IShader** ppShader) +{ + CreateDeviceObject( "shader", ShaderCreationAttribs.Desc, ppShader, + [&]() + { + ShaderMtlImpl* pShaderMtl( NEW_RC_OBJ(m_ShaderObjAllocator, "ShaderMtlImpl instance", ShaderMtlImpl) + (this, ShaderCreationAttribs ) ); + pShaderMtl->QueryInterface( IID_Shader, reinterpret_cast<IObject**>(ppShader) ); + + OnCreateDeviceObject( pShaderMtl ); + } + ); +} + + + +void RenderDeviceMtlImpl :: CreateTexture(const TextureDesc& TexDesc, const TextureData& Data, ITexture** ppTexture) +{ + CreateDeviceObject( "texture", TexDesc, ppTexture, + [&]() + { + TextureMtlImpl *pTextureMtl = NEW_RC_OBJ(m_TexObjAllocator, "TextureMtlImpl instance", TextureMtlImpl)(m_TexViewObjAllocator, this, TexDesc, Data ); + + pTextureMtl->QueryInterface( IID_Texture, reinterpret_cast<IObject**>(ppTexture) ); + pTextureMtl->CreateDefaultViews(); + OnCreateDeviceObject( pTextureMtl ); + } + ); +} + +void RenderDeviceMtlImpl :: CreateSampler(const SamplerDesc& SamplerDesc, ISampler** ppSampler) +{ + CreateDeviceObject( "sampler", SamplerDesc, ppSampler, + [&]() + { + m_SamplersRegistry.Find( SamplerDesc, reinterpret_cast<IDeviceObject**>(ppSampler) ); + if(* ppSampler == nullptr ) + { + SamplerMtlImpl* pSamplerMtl( NEW_RC_OBJ(m_SamplerObjAllocator, "SamplerMtlImpl instance", SamplerMtlImpl) + (this, SamplerDesc ) ); + pSamplerMtl->QueryInterface( IID_Sampler, reinterpret_cast<IObject**>(ppSampler) ); + OnCreateDeviceObject( pSamplerMtl ); + m_SamplersRegistry.Add( SamplerDesc,* ppSampler ); + } + } + ); +} + + +void RenderDeviceMtlImpl::CreatePipelineState(const PipelineStateDesc& PipelineDesc, IPipelineState** ppPipelineState) +{ + CreateDeviceObject( "Pipeline state", PipelineDesc, ppPipelineState, + [&]() + { + PipelineStateMtlImpl* pPipelineStateMtl( NEW_RC_OBJ(m_PSOAllocator, "PipelineStateMtlImpl instance", PipelineStateMtlImpl) + (this, PipelineDesc ) ); + pPipelineStateMtl->QueryInterface( IID_PipelineState, reinterpret_cast<IObject**>(ppPipelineState) ); + OnCreateDeviceObject( pPipelineStateMtl ); + } + ); +} + +void RenderDeviceMtlImpl::CreateFence(const FenceDesc& Desc, IFence** ppFence) +{ + CreateDeviceObject( "Fence", Desc, ppFence, + [&]() + { + FenceMtlImpl* pFenceMtl( NEW_RC_OBJ(m_FenceAllocator, "FenceMtlImpl instance", FenceMtlImpl) + (this, Desc) ); + pFenceMtl->QueryInterface( IID_Fence, reinterpret_cast<IObject**>(ppFence) ); + OnCreateDeviceObject( pFenceMtl ); + } + ); +} + +} diff --git a/Graphics/GraphicsEngineMetal/src/SamplerMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/SamplerMtlImpl.mm new file mode 100644 index 00000000..320f947b --- /dev/null +++ b/Graphics/GraphicsEngineMetal/src/SamplerMtlImpl.mm @@ -0,0 +1,46 @@ +/* Copyright 2015-2018 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 "SamplerMtlImpl.h" +#include "RenderDeviceMtlImpl.h" +#include "MtlTypeConversions.h" + +namespace Diligent +{ + +SamplerMtlImpl::SamplerMtlImpl(IReferenceCounters* pRefCounters, + RenderDeviceMtlImpl* pRenderDeviceMtl, + const SamplerDesc& SamplerDesc) : + TSamplerBase(pRefCounters, pRenderDeviceMtl, SamplerDesc) +{ + LOG_ERROR_AND_THROW("Samplers are not implemented in Metal backend"); +} + +SamplerMtlImpl::~SamplerMtlImpl() +{ + +} + +IMPLEMENT_QUERY_INTERFACE( SamplerMtlImpl, IID_SamplerMtl, TSamplerBase ) + +} diff --git a/Graphics/GraphicsEngineMetal/src/ShaderMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/ShaderMtlImpl.mm new file mode 100644 index 00000000..c3fc398b --- /dev/null +++ b/Graphics/GraphicsEngineMetal/src/ShaderMtlImpl.mm @@ -0,0 +1,45 @@ +/* Copyright 2015-2018 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 "ShaderMtlImpl.h" +#include "RenderDeviceMtlImpl.h" +#include "ResourceMapping.h" + +namespace Diligent +{ + +ShaderMtlImpl::ShaderMtlImpl(IReferenceCounters* pRefCounters, + RenderDeviceMtlImpl* pRenderDeviceMtl, + const ShaderCreationAttribs& CreationAttribs) : + TShaderBase(pRefCounters, pRenderDeviceMtl, CreationAttribs.Desc) +{ + LOG_ERROR_AND_THROW("Shaders are not implemented in Metal backend"); +} + +ShaderMtlImpl::~ShaderMtlImpl() +{ +} + +IMPLEMENT_QUERY_INTERFACE( ShaderMtlImpl, IID_ShaderMtl, TShaderBase ) + +} diff --git a/Graphics/GraphicsEngineMetal/src/ShaderResourceBindingMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/ShaderResourceBindingMtlImpl.mm new file mode 100644 index 00000000..48083950 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/src/ShaderResourceBindingMtlImpl.mm @@ -0,0 +1,76 @@ +/* Copyright 2015-2018 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 "ShaderResourceBindingMtlImpl.h" +#include "PipelineStateMtlImpl.h" +#include "DeviceContextMtlImpl.h" +#include "RenderDeviceMtlImpl.h" + +namespace Diligent +{ + + +ShaderResourceBindingMtlImpl::ShaderResourceBindingMtlImpl( IReferenceCounters* pRefCounters, + PipelineStateMtlImpl* pPSO, + bool IsInternal) : + TBase( pRefCounters, pPSO, IsInternal ) +{ + LOG_ERROR_AND_THROW("Shader resource binding is not implemented in Metal backend"); +} + +ShaderResourceBindingMtlImpl::~ShaderResourceBindingMtlImpl() +{ + +} + +IMPLEMENT_QUERY_INTERFACE( ShaderResourceBindingMtlImpl, IID_ShaderResourceBindingMtl, TBase ) + +void ShaderResourceBindingMtlImpl::BindResources(Uint32 ShaderFlags, IResourceMapping *pResMapping, Uint32 Flags) +{ + LOG_ERROR_MESSAGE("ShaderResourceBindingMtlImpl::BindResources() is not implemented"); +} + +void ShaderResourceBindingMtlImpl::InitializeStaticResources(const IPipelineState* pPipelineState) +{ + LOG_ERROR_MESSAGE("ShaderResourceBindingMtlImpl::InitializeStaticResources() is not implemented"); +} + +IShaderVariable* ShaderResourceBindingMtlImpl::GetVariable(SHADER_TYPE ShaderType, const char* Name) +{ + LOG_ERROR_MESSAGE("ShaderResourceBindingMtlImpl::GetVariable() is not implemented"); + return nullptr; +} + +Uint32 ShaderResourceBindingMtlImpl::GetVariableCount(SHADER_TYPE ShaderType) const +{ + LOG_ERROR_MESSAGE("ShaderResourceBindingMtlImpl::GetVariableCount() is not implemented"); + return 0; +} + +IShaderVariable* ShaderResourceBindingMtlImpl::GetVariable(SHADER_TYPE ShaderType, Uint32 Index) +{ + LOG_ERROR_MESSAGE("ShaderResourceBindingMtlImpl::GetVariable() is not implemented"); + return nullptr; +} + +} diff --git a/Graphics/GraphicsEngineMetal/src/SwapChainMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/SwapChainMtlImpl.mm new file mode 100644 index 00000000..3a49d912 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/src/SwapChainMtlImpl.mm @@ -0,0 +1,84 @@ +/* Copyright 2015-2018 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 "SwapChainMtlImpl.h" +#include "RenderDeviceMtlImpl.h" +#include "DeviceContextMtlImpl.h" + +namespace Diligent +{ + +SwapChainMtlImpl::SwapChainMtlImpl(IReferenceCounters* pRefCounters, + const SwapChainDesc& SCDesc, + const FullScreenModeDesc& FSDesc, + RenderDeviceMtlImpl* pRenderDeviceMtl, + DeviceContextMtlImpl* pDeviceContextMtl, + void* pNativeWndHandle) : + TSwapChainBase(pRefCounters, pRenderDeviceMtl, pDeviceContextMtl, SCDesc) +{ + LOG_ERROR_AND_THROW("Swap chain is not implemented in Metal backend"); +} + +SwapChainMtlImpl::~SwapChainMtlImpl() +{ +} + +IMPLEMENT_QUERY_INTERFACE( SwapChainMtlImpl, IID_SwapChainMtl, TSwapChainBase ) + +void SwapChainMtlImpl::Present(Uint32 SyncInterval) +{ + LOG_ERROR_MESSAGE("SwapChainMtlImpl::Present() is not implemented"); +} + + +void SwapChainMtlImpl::Resize( Uint32 NewWidth, Uint32 NewHeight ) +{ + if( TSwapChainBase::Resize(NewWidth, NewHeight) ) + { + LOG_ERROR_MESSAGE("SwapChainMtlImpl::Resize() is not implemented"); + } +} + +void SwapChainMtlImpl::SetFullscreenMode(const DisplayModeAttribs &DisplayMode) +{ + LOG_ERROR_MESSAGE("SwapChainMtlImpl::SetFullscreenMode() is not implemented"); +} + +void SwapChainMtlImpl::SetWindowedMode() +{ + LOG_ERROR_MESSAGE("SwapChainMtlImpl::SetWindowedMode() is not implemented"); +} + +ITextureView* GetCurrentBackBufferRTV() +{ + LOG_ERROR_MESSAGE("SwapChainMtlImpl::GetCurrentBackBufferRTV() is not implemented"); + return nullptr; +} + +ITextureView* GetDepthBufferDSV() +{ + LOG_ERROR_MESSAGE("SwapChainMtlImpl::GetDepthBufferDSV() is not implemented"); + return nullptr; +} + +} diff --git a/Graphics/GraphicsEngineMetal/src/TextureMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/TextureMtlImpl.mm new file mode 100644 index 00000000..ca36c472 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/src/TextureMtlImpl.mm @@ -0,0 +1,73 @@ +/* Copyright 2015-2018 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 "TextureMtlImpl.h" +#include "RenderDeviceMtlImpl.h" +#include "DeviceContextMtlImpl.h" +#include "MtlTypeConversions.h" +#include "TextureViewMtlImpl.h" +#include "EngineMemory.h" + +namespace Diligent +{ + +TextureMtlImpl :: TextureMtlImpl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + RenderDeviceMtlImpl* pRenderDeviceMtl, + const TextureDesc& TexDesc, + const TextureData& InitData /*= TextureData()*/) : + TTextureBase(pRefCounters, TexViewObjAllocator, pRenderDeviceMtl, TexDesc) +{ + LOG_ERROR_AND_THROW("Textures are not implemented in Metal backend"); + + if( TexDesc.Usage == USAGE_STATIC && InitData.pSubResources == nullptr ) + LOG_ERROR_AND_THROW("Static Texture must be initialized with data at creation time"); + SetState(RESOURCE_STATE_UNDEFINED); +} + +IMPLEMENT_QUERY_INTERFACE( TextureMtlImpl, IID_TextureMtl, TTextureBase ) + +TextureMtlImpl :: ~TextureMtlImpl() +{ +} + +void TextureMtlImpl::CreateViewInternal( const TextureViewDesc &ViewDesc, ITextureView **ppView, bool bIsDefaultView ) +{ + VERIFY( ppView != nullptr, "View pointer address is null" ); + if( !ppView )return; + VERIFY( *ppView == nullptr, "Overwriting reference to existing object may cause memory leaks" ); + + *ppView = nullptr; + + try + { + LOG_ERROR_MESSAGE("TextureMtlImpl::CreateViewInternal() is not implemented"); + } + catch( const std::runtime_error & ) + { + const auto *ViewTypeName = GetTexViewTypeLiteralName(ViewDesc.ViewType); + LOG_ERROR("Failed to create view \"", ViewDesc.Name ? ViewDesc.Name : "", "\" (", ViewTypeName, ") for texture \"", m_Desc.Name ? m_Desc.Name : "", "\"" ); + } +} + +} diff --git a/Graphics/GraphicsEngineMetal/src/TextureViewMtlImpl.mm b/Graphics/GraphicsEngineMetal/src/TextureViewMtlImpl.mm new file mode 100644 index 00000000..8a4ee4f3 --- /dev/null +++ b/Graphics/GraphicsEngineMetal/src/TextureViewMtlImpl.mm @@ -0,0 +1,43 @@ +/* Copyright 2015-2018 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 "TextureViewMtlImpl.h" +#include "DeviceContextMtlImpl.h" + +namespace Diligent +{ + +TextureViewMtlImpl::TextureViewMtlImpl( IReferenceCounters* pRefCounters, + RenderDeviceMtlImpl* pDevice, + const TextureViewDesc& ViewDesc, + ITexture* pTexture, + void* pMtlView, + bool bIsDefaultView ) : + TTextureViewBase( pRefCounters, pDevice, ViewDesc, pTexture, bIsDefaultView ) +{ + LOG_ERROR_AND_THROW("Texture views are not implemented in Metal backend"); +} + +IMPLEMENT_QUERY_INTERFACE( TextureViewMtlImpl, IID_TextureViewMtl, TTextureViewBase ) + +} |
