[Feat] (MG_Backend/DirectGLES): hook up glDrawBuffers

This commit is contained in:
2025-11-14 17:08:55 +08:00
parent 0d3236c3cc
commit 899563165e
3 changed files with 25 additions and 6 deletions
@@ -423,6 +423,23 @@ namespace MobileGL::MG_Backend::DirectGLES {
// TODO
}
}
if (stateFBOObject->DrawBuffersIsDirty()) {
static GLenum drawbufs[MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS];
std::fill(drawbufs, drawbufs + MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS, GL_NONE);
auto& stateDrawBuffers = stateFBOObject->GetDrawBuffers();
GLint i = 0;
for (; i < stateDrawBuffers.size(); ++i) {
if (stateDrawBuffers[i] == FramebufferAttachmentType::None) {
break;
}
drawbufs[i] = MG_Util::ConvertFramebufferAttachmentTypeToGLEnum(stateDrawBuffers[i]);
}
MG_External::GLES::glDrawBuffers(i, drawbufs);
stateFBOObject->ClearDrawBuffersDirtyState();
}
}
UnorderedMap<SharedPtr<MG_State::GLState::FramebufferObject>, SharedPtr<BackendFramebufferObject>>
@@ -72,18 +72,18 @@ namespace MobileGL {
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 {
@@ -143,7 +143,7 @@ namespace MobileGL {
//
// }
const auto& FramebufferObject::GetDrawBuffers() const {
const Array<FramebufferAttachmentType, FramebufferObject::MAX_DRAW_BUFFERS>& FramebufferObject::GetDrawBuffers() const {
return m_drawBuffers;
}
@@ -105,7 +105,9 @@ namespace MobileGL {
Bool CheckCompleteness() const;
// void SetDrawBuffers(const Vector<FramebufferAttachmentType>& buffers);
void SetDrawBuffer(Uint index, FramebufferAttachmentType buffer);
const auto& GetDrawBuffers() const;
bool DrawBuffersIsDirty() const { return m_drawBuffersDirty; }
void ClearDrawBuffersDirtyState() { m_drawBuffersDirty = false; }
const Array<FramebufferAttachmentType, MAX_DRAW_BUFFERS>& GetDrawBuffers() const;
Uint GetExternalIndex() const;
private:
@@ -113,7 +115,7 @@ namespace MobileGL {
Array<FramebufferAttachment,
static_cast<SizeT>(FramebufferAttachmentType::FramebufferAttachmentTypeCount)>
m_attachments;
Bool m_drawBuffersDirty = true;
Bool m_drawBuffersDirty = false;
Array<FramebufferAttachmentType, MAX_DRAW_BUFFERS> m_drawBuffers;
};