mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 12:18:30 +09:00
[Feat] (MG_Backend/DirectGLES): Add cache for backend RBO.
This commit is contained in:
@@ -1048,18 +1048,31 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
MGLOG_D("Syncing RBO with backend ID %u to backend for state ID %u", m_backendRBOId,
|
||||
stateRBOObject->GetExternalIndex());
|
||||
|
||||
if (m_isInitialized && m_cacheInternalFormat == stateRBOObject->GetInternalFormat() &&
|
||||
m_cacheWidth == stateRBOObject->GetWidth() && m_cacheHeight == stateRBOObject->GetHeight()) {
|
||||
MGLOG_D("RBO %u already initialized with matching parameters, skipping re-allocation.",
|
||||
stateRBOObject->GetExternalIndex());
|
||||
return;
|
||||
}
|
||||
|
||||
Bind();
|
||||
|
||||
// Allocate storage
|
||||
TextureInternalFormat internalFormat = stateRBOObject->GetInternalFormat();
|
||||
Int width = static_cast<Int>(stateRBOObject->GetWidth());
|
||||
Int height = static_cast<Int>(stateRBOObject->GetHeight());
|
||||
GLenum glInternalFormat, glType, glFormat;
|
||||
TextureImpl::GenerateTextureFormatInfo(stateRBOObject->GetInternalFormat(), &glInternalFormat, &glType,
|
||||
&glFormat);
|
||||
TextureImpl::GenerateTextureFormatInfo(internalFormat, &glInternalFormat, &glType, &glFormat);
|
||||
|
||||
MG_External::GLES::glRenderbufferStorage(GL_RENDERBUFFER, glInternalFormat,
|
||||
static_cast<GLsizei>(stateRBOObject->GetWidth()),
|
||||
static_cast<GLsizei>(stateRBOObject->GetHeight()));
|
||||
MG_External::GLES::glRenderbufferStorage(GL_RENDERBUFFER, glInternalFormat, static_cast<GLsizei>(width),
|
||||
static_cast<GLsizei>(height));
|
||||
|
||||
m_cacheInternalFormat = internalFormat;
|
||||
m_cacheWidth = width;
|
||||
m_cacheHeight = height;
|
||||
|
||||
m_isInitialized = true;
|
||||
MGLOG_D("RBO %u sync completed. backend ID %u", stateRBOObject->GetExternalIndex(), m_backendRBOId);
|
||||
}
|
||||
|
||||
UnorderedMap<SharedPtr<MG_State::GLState::RenderbufferObject>, SharedPtr<BackendRenderbufferObject>>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <Includes.h>
|
||||
#include "DirectGLES.h"
|
||||
#include "MG_State/GLState/SamplerState/SamplerObject.h"
|
||||
#include "MG_State/GLState/TextureState/TextureEnum.h"
|
||||
#include <MG_State/GLState/TextureState/TextureObject.h>
|
||||
#include <MG_State/GLState/Core.h>
|
||||
|
||||
@@ -185,6 +186,9 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
private:
|
||||
Uint m_backendRBOId = 0;
|
||||
Bool m_isInitialized = false;
|
||||
TextureInternalFormat m_cacheInternalFormat = TextureInternalFormat::Unknown;
|
||||
Int m_cacheWidth = 0;
|
||||
Int m_cacheHeight = 0;
|
||||
};
|
||||
|
||||
extern UnorderedMap<SharedPtr<MG_State::GLState::RenderbufferObject>, SharedPtr<BackendRenderbufferObject>>
|
||||
|
||||
Reference in New Issue
Block a user