Skip to content

Commit 9843c64

Browse files
azhirnovTheMostDiligent
authored andcommitted
Check if memoryless attachment is used only in one subpass on MacOS/iOS
1 parent e6f5e80 commit 9843c64

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Graphics/GraphicsEngine/src/FramebufferBase.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,42 @@ void ValidateFramebufferDesc(const FramebufferDesc& Desc) noexcept(false)
114114
{
115115
LOG_FRAMEBUFFER_ERROR_AND_THROW("memoryless attachment ", i, " is not compatible with ATTACHMENT_STORE_OP_STORE");
116116
}
117+
118+
#if PLATFORM_MACOS || PLATFORM_IOS
119+
{
120+
Uint32 NumSubpasses = 0;
121+
for (Uint32 s = 0; s < RPDesc.SubpassCount; ++s)
122+
{
123+
const auto& Subpass = RPDesc.pSubpasses[s];
124+
125+
bool UsedInSubpass = false;
126+
for (Uint32 rt_attachment = 0; rt_attachment < Subpass.RenderTargetAttachmentCount; ++rt_attachment)
127+
{
128+
const auto& AttchRef = Subpass.pRenderTargetAttachments[rt_attachment];
129+
if (AttchRef.AttachmentIndex == i)
130+
UsedInSubpass = true;
131+
}
132+
for (Uint32 input_attachment = 0; input_attachment < Subpass.InputAttachmentCount; ++input_attachment)
133+
{
134+
const auto& AttchRef = Subpass.pInputAttachments[input_attachment];
135+
if (AttchRef.AttachmentIndex == i)
136+
UsedInSubpass = true;
137+
}
138+
if (Subpass.pDepthStencilAttachment != nullptr && Subpass.pDepthStencilAttachment->AttachmentIndex == i)
139+
UsedInSubpass = true;
140+
141+
if (UsedInSubpass)
142+
++NumSubpasses;
143+
}
144+
if (NumSubpasses > 1)
145+
{
146+
LOG_FRAMEBUFFER_ERROR_AND_THROW("memoryless attachment ", i,
147+
" is used in more than one subpass, which is not supported on MacOS/iOS "
148+
"as the contents of the attachment can't be preserved between subpasses without "
149+
"storing it in global memory.");
150+
}
151+
}
152+
#endif
117153
}
118154
}
119155

0 commit comments

Comments
 (0)