mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
VideoBackends:Metal: Multi render target support
This commit is contained in:
@ -189,13 +189,56 @@ void Metal::StagingTexture::Flush()
|
||||
m_wait_buffer = nullptr;
|
||||
}
|
||||
|
||||
Metal::Framebuffer::Framebuffer(AbstractTexture* color, AbstractTexture* depth, //
|
||||
static void InitDesc(id desc, AbstractTexture* tex)
|
||||
{
|
||||
[desc setTexture:static_cast<Metal::Texture*>(tex)->GetMTLTexture()];
|
||||
[desc setLoadAction:MTLLoadActionLoad];
|
||||
[desc setStoreAction:MTLStoreActionStore];
|
||||
}
|
||||
|
||||
static void InitStencilDesc(MTLRenderPassStencilAttachmentDescriptor* desc, AbstractTexture* tex)
|
||||
{
|
||||
InitDesc(desc, tex);
|
||||
[desc setClearStencil:0];
|
||||
}
|
||||
|
||||
Metal::Framebuffer::Framebuffer(AbstractTexture* color, AbstractTexture* depth,
|
||||
std::vector<AbstractTexture*> additonal_color_textures, //
|
||||
u32 width, u32 height, u32 layers, u32 samples)
|
||||
: AbstractFramebuffer(color, depth, {},
|
||||
color ? color->GetFormat() : AbstractTextureFormat::Undefined, //
|
||||
depth ? depth->GetFormat() : AbstractTextureFormat::Undefined, //
|
||||
width, height, layers, samples)
|
||||
width, height, layers, samples),
|
||||
m_additional_color_textures(std::move(additonal_color_textures))
|
||||
{
|
||||
m_pass_descriptor = MRCTransfer([MTLRenderPassDescriptor new]);
|
||||
MTLRenderPassDescriptor* desc = m_pass_descriptor;
|
||||
if (color)
|
||||
InitDesc(desc.colorAttachments[0], color);
|
||||
if (depth)
|
||||
{
|
||||
InitDesc(desc.depthAttachment, depth);
|
||||
if (Util::HasStencil(depth->GetFormat()))
|
||||
InitStencilDesc(desc.stencilAttachment, depth);
|
||||
}
|
||||
for (size_t i = 0; i < m_additional_color_textures.size(); i++)
|
||||
InitDesc(desc.colorAttachments[i + 1], m_additional_color_textures[i]);
|
||||
}
|
||||
|
||||
Metal::Framebuffer::~Framebuffer() = default;
|
||||
|
||||
void Metal::Framebuffer::ActualSetLoadAction(MTLLoadAction action)
|
||||
{
|
||||
m_current_load_action = action;
|
||||
AbstractTextureFormat depth_fmt = GetDepthFormat();
|
||||
MTLRenderPassDescriptor* desc = m_pass_descriptor;
|
||||
desc.colorAttachments[0].loadAction = action;
|
||||
if (depth_fmt != AbstractTextureFormat::Undefined)
|
||||
{
|
||||
desc.depthAttachment.loadAction = action;
|
||||
if (Util::HasStencil(depth_fmt))
|
||||
desc.stencilAttachment.loadAction = action;
|
||||
}
|
||||
for (size_t i = 0; i < NumAdditionalColorTextures(); i++)
|
||||
desc.colorAttachments[i + 1].loadAction = action;
|
||||
}
|
||||
|
Reference in New Issue
Block a user