mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 14:18:31 +09:00
[Optimization] (MG_Backend/DirectGLES): add more tracy zones
This commit is contained in:
@@ -409,6 +409,10 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
|
||||
BindCurrentFBO(FramebufferTarget::Draw);
|
||||
|
||||
{
|
||||
#ifdef TRACY_ENABLE
|
||||
ZoneScopedNC("BindCurrentVAO", TRACY_ZONECOLOR_BACKEND);
|
||||
#endif
|
||||
const auto& currentVAO = MG_State::pGLContext->GetBoundVertexArray();
|
||||
if (currentVAO) {
|
||||
const auto& backendVAOIt = VertexArrayImpl::g_backendVertexArrayObjects.find(currentVAO);
|
||||
@@ -418,7 +422,12 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
} else {
|
||||
MG_External::GLES::glBindVertexArray(0);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
#ifdef TRACY_ENABLE
|
||||
ZoneScopedNC("BindCurrentTextures", TRACY_ZONECOLOR_BACKEND);
|
||||
#endif
|
||||
Int maxTextureUnits = MG_State::GLState::TextureState::MAX_TEXTURE_IMAGE_UNITS;
|
||||
for (Int unit = 0; unit < maxTextureUnits; ++unit) {
|
||||
auto& textureUnit = MG_State::pGLContext->GetTextureUnitObject(unit);
|
||||
@@ -457,15 +466,22 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
MG_External::GLES::glBindSampler(unit, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const auto& currentProgram = MG_State::pGLContext->GetCurrentProgram();
|
||||
if (currentProgram && currentProgram->GetLinkStatus()) {
|
||||
#ifdef TRACY_ENABLE
|
||||
ZoneScopedNC("BindCurrentProgram", TRACY_ZONECOLOR_BACKEND);
|
||||
#endif
|
||||
const auto& backendProgramIt = PrgramImpl::g_backendProgramObjects.find(currentProgram);
|
||||
if (backendProgramIt != PrgramImpl::g_backendProgramObjects.end()) {
|
||||
backendProgramIt->second->Use();
|
||||
auto backendProgramId = backendProgramIt->second->GetBackendProgramId();
|
||||
// Global UBO
|
||||
if (currentProgram->GetUBOSize() > 0) {
|
||||
#ifdef TRACY_ENABLE
|
||||
ZoneScopedNC("UpdateGlobalUBO", TRACY_ZONECOLOR_BACKEND);
|
||||
#endif
|
||||
MG_External::GLES::glBindBuffer(GL_UNIFORM_BUFFER,
|
||||
backendProgramIt->second->GetBackendGlobalUBOId());
|
||||
MG_External::GLES::glBufferSubData(GL_UNIFORM_BUFFER, 0, currentProgram->GetUBOSize(),
|
||||
@@ -480,6 +496,11 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
MG_External::GLES::glBindBufferBase(GL_UNIFORM_BUFFER, 0,
|
||||
backendProgramIt->second->GetBackendGlobalUBOId());
|
||||
}
|
||||
|
||||
{
|
||||
#ifdef TRACY_ENABLE
|
||||
ZoneScopedNC("UpdateUBO", TRACY_ZONECOLOR_BACKEND);
|
||||
#endif
|
||||
// Normal UBO
|
||||
auto uboCount = currentProgram->GetActiveUniformBlocksCount();
|
||||
Uint lastUBOBinding = 0; // to prevent overlapping bindings between global UBO and normal UBOs
|
||||
@@ -516,7 +537,12 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
#ifdef TRACY_ENABLE
|
||||
ZoneScopedNC("BindSamplerUnit", TRACY_ZONECOLOR_BACKEND);
|
||||
#endif
|
||||
// Sampler unit binding
|
||||
auto maxUniformLoc = currentProgram->GetMaxUniformLocation();
|
||||
for (int loc = 0; loc < maxUniformLoc; ++loc) {
|
||||
@@ -543,6 +569,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
MG_External::GLES::glBindSampler(unit, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
MG_External::GLES::glUseProgram(0);
|
||||
MGLOG_E("No backend program found (maybe not synced) for current program, cannot use program.");
|
||||
|
||||
Reference in New Issue
Block a user