You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Gems/Atom/RHI/Metal/Code/Source/RHI/SwapChain.h

63 lines
2.5 KiB
Objective-C

/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <Atom/RHI/SwapChain.h>
#include <RHI/Device.h>
#import <QuartzCore/CAMetalLayer.h>
namespace AZ
{
namespace Metal
{
class Device;
class Image;
class SwapChain
: public RHI::SwapChain
{
using Base = RHI::SwapChain;
public:
AZ_RTTI(SwapChain, "{2ECD01DB-BD24-4FD1-BA21-370B20071F02}", Base);
AZ_CLASS_ALLOCATOR(SwapChain, AZ::SystemAllocator, 0);
static RHI::Ptr<SwapChain> Create();
Device& GetDevice() const;
void SetCommandBuffer(id <MTLCommandBuffer> mtlCommandBuffer);
id<MTLTexture> RequestDrawable(bool isFrameCaptureEnabled);
private:
SwapChain() = default;
//////////////////////////////////////////////////////////////////////////
// RHI::SwapChain
RHI::ResultCode InitInternal(RHI::Device& deviceBase, const RHI::SwapChainDescriptor& descriptor, RHI::SwapChainDimensions* nativeDimensions) override;
void ShutdownInternal() override;
uint32_t PresentInternal() override;
RHI::ResultCode InitImageInternal(const InitImageRequest& request) override;
void ShutdownResourceInternal(RHI::Resource& resourceBase) override;
RHI::ResultCode ResizeInternal(const RHI::SwapChainDimensions& dimensions, RHI::SwapChainDimensions* nativeDimensions) override;
//////////////////////////////////////////////////////////////////////////
void AddSubView();
id <MTLCommandBuffer> m_mtlCommandBuffer;
RHIMetalView* m_metalView = nullptr;
NativeViewControllerType* m_viewController = nullptr;
id<MTLDevice> m_mtlDevice = nil;
NativeWindowType* m_nativeWindow = nullptr;
AZStd::vector<id<CAMetalDrawable>> m_drawables;
};
}
}