[Fix] (MG_Impl/Framebuffer, MG_State/Framebuffer, MG_Backend/DirectGLES): redone fbo attachment management. remap GL -> ES attachment names

This commit is contained in:
2025-11-15 00:39:07 +08:00
parent 899563165e
commit e93dff52dc
6 changed files with 171 additions and 64 deletions
@@ -67,23 +67,24 @@ namespace MobileGL {
m_externalIndex(externalIndex) {
m_attachments.fill(FramebufferAttachment(false));
m_drawBuffers.fill(FramebufferAttachmentType::None);
m_drawBuffers[0] = FramebufferAttachmentType::Color0;
}
void FramebufferObject::AttachTexture(FramebufferAttachmentType type, SharedPtr<ITextureObject> texture,
int level) {
m_attachments[static_cast<SizeT>(type)] = FramebufferAttachment(std::move(texture), level);
// m_drawBuffersDirty = true;
m_drawBuffersDirty = true;
}
void FramebufferObject::AttachRenderbuffer(FramebufferAttachmentType type,
std::shared_ptr<RenderbufferObjectStub> renderbuffer) {
m_attachments[static_cast<SizeT>(type)] = FramebufferAttachment(renderbuffer);
// m_drawBuffersDirty = true;
m_drawBuffersDirty = true;
}
void FramebufferObject::Detach(FramebufferAttachmentType type) {
m_attachments[static_cast<SizeT>(type)] = FramebufferAttachment(false);
// m_drawBuffersDirty = true;
m_drawBuffersDirty = true;
}
const FramebufferAttachment& FramebufferObject::GetAttachment(FramebufferAttachmentType type) const {
@@ -103,11 +103,12 @@ namespace MobileGL {
static_cast<SizeT>(FramebufferAttachmentType::FramebufferAttachmentTypeCount)>&
GetAllAttachments() const;
Bool CheckCompleteness() const;
// void SetDrawBuffers(const Vector<FramebufferAttachmentType>& buffers);
// aka. `buffer` as in glDrawBuffers/glReadBuffers
void SetDrawBuffer(Uint index, FramebufferAttachmentType buffer);
bool DrawBuffersIsDirty() const { return m_drawBuffersDirty; }
void ClearDrawBuffersDirtyState() { m_drawBuffersDirty = false; }
const Array<FramebufferAttachmentType, MAX_DRAW_BUFFERS>& GetDrawBuffers() const;
FramebufferAttachmentType GetReadBuffer() const { return m_readBuffer; }
Uint GetExternalIndex() const;
private:
@@ -117,6 +118,7 @@ namespace MobileGL {
m_attachments;
Bool m_drawBuffersDirty = false;
Array<FramebufferAttachmentType, MAX_DRAW_BUFFERS> m_drawBuffers;
FramebufferAttachmentType m_readBuffer = FramebufferAttachmentType::None;
};
} // namespace GLState