2020-09-21 22:10:50 +08:00
|
|
|
#pragma once
|
|
|
|
#include "../RenderTarget.h"
|
|
|
|
#include "CommandBufferMTL.h"
|
|
|
|
|
|
|
|
CC_BACKEND_BEGIN
|
|
|
|
|
|
|
|
class RenderTargetMTL : public RenderTarget
|
|
|
|
{
|
|
|
|
public:
|
2021-12-25 10:04:45 +08:00
|
|
|
struct Attachment
|
|
|
|
{
|
2020-09-21 22:10:50 +08:00
|
|
|
id<MTLTexture> texture = nil;
|
2021-12-25 10:04:45 +08:00
|
|
|
int level = 0;
|
|
|
|
explicit operator bool() const { return texture != nullptr; }
|
2020-09-21 22:10:50 +08:00
|
|
|
};
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2020-09-21 22:10:50 +08:00
|
|
|
/*
|
2021-12-25 10:04:45 +08:00
|
|
|
* generateFBO, false, use for screen framebuffer
|
|
|
|
*/
|
2020-09-21 22:10:50 +08:00
|
|
|
RenderTargetMTL(bool defaultRenderTarget);
|
|
|
|
~RenderTargetMTL();
|
|
|
|
|
2021-04-22 22:01:47 +08:00
|
|
|
void applyRenderPassAttachments(const RenderPassDescriptor&, MTLRenderPassDescriptor*) const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2020-09-21 22:10:50 +08:00
|
|
|
Attachment getColorAttachment(int index) const;
|
|
|
|
Attachment getDepthAttachment() const;
|
|
|
|
Attachment getStencilAttachment() const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2020-09-21 22:10:50 +08:00
|
|
|
PixelFormat getColorAttachmentPixelFormat(int index) const;
|
|
|
|
PixelFormat getDepthAttachmentPixelFormat() const;
|
|
|
|
PixelFormat getStencilAttachmentPixelFormat() const;
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
public:
|
2020-09-21 22:10:50 +08:00
|
|
|
// "Sidecar" textures used to implement automatic MSAA resolve.
|
|
|
|
// id<MTLTexture> multisampledColor[MRT::TARGET_COUNT] = { 0 };
|
|
|
|
// id<MTLTexture> multisampledDepth = nil;
|
|
|
|
// MetalContext*, DeviceMTL*
|
|
|
|
};
|
|
|
|
|
|
|
|
CC_BACKEND_END
|