mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 14:18:31 +09:00
[Perf] (MG_Backend/DirectGLES): Remove binding state protectors.
This commit is contained in:
@@ -844,16 +844,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
||||||
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
||||||
});
|
});
|
||||||
FramebufferImpl::BackendFramebufferBindingProtector drawFboProtector(GL_DRAW_FRAMEBUFFER);
|
|
||||||
FramebufferImpl::BackendFramebufferBindingProtector readFboProtector(GL_READ_FRAMEBUFFER);
|
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
|
||||||
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
|
||||||
});
|
|
||||||
|
|
||||||
FramebufferImpl::BackendFramebufferBindingProtector::BindTempFBO(FramebufferTarget::Draw);
|
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
|
||||||
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
|
||||||
});
|
|
||||||
|
|
||||||
GLint currentTex;
|
GLint currentTex;
|
||||||
MG_External::GLES::glGetIntegerv(Utils::GetBindingQuery(target, false), ¤tTex);
|
MG_External::GLES::glGetIntegerv(Utils::GetBindingQuery(target, false), ¤tTex);
|
||||||
@@ -925,15 +915,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
MGLOG_D("%s: Backend depth", __func__);
|
MGLOG_D("%s: Backend depth", __func__);
|
||||||
FramebufferImpl::BackendFramebufferBindingProtector drawFboProtector(GL_DRAW_FRAMEBUFFER);
|
|
||||||
FramebufferImpl::BackendFramebufferBindingProtector readFboProtector(GL_READ_FRAMEBUFFER);
|
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
|
||||||
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
|
||||||
});
|
|
||||||
FramebufferImpl::BackendFramebufferBindingProtector::BindTempFBO(FramebufferTarget::Draw);
|
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
|
||||||
MGLOG_D("ES error (%s:%d): %s", file, line, MG_Util::ConvertGLEnumToString(err).c_str());
|
|
||||||
});
|
|
||||||
GLint currentTex;
|
GLint currentTex;
|
||||||
MG_External::GLES::glGetIntegerv(Utils::GetBindingQuery(target, false), ¤tTex);
|
MG_External::GLES::glGetIntegerv(Utils::GetBindingQuery(target, false), ¤tTex);
|
||||||
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
errorLopper.Loop([file = __FILE__, line = __LINE__](auto err) {
|
||||||
@@ -971,7 +952,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
auto texture = slot.GetBoundObject();
|
auto texture = slot.GetBoundObject();
|
||||||
auto backendTexture = TextureImpl::SyncTextureObjectToBackend(texture);
|
auto backendTexture = TextureImpl::SyncTextureObjectToBackend(texture);
|
||||||
|
|
||||||
TextureImpl::BackendTextureBindingProtector protector(target);
|
|
||||||
backendTexture->Bind(target);
|
backendTexture->Bind(target);
|
||||||
MG_External::GLES::glGenerateMipmap(target);
|
MG_External::GLES::glGenerateMipmap(target);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
BackendBufferBindingProtector backendBufferBindingProtector(TempBufferTarget);
|
|
||||||
|
|
||||||
MGLOG_D("Syncing buffer data (glBufferData) for object with ID : %u", m_backendBufferId);
|
MGLOG_D("Syncing buffer data (glBufferData) for object with ID : %u", m_backendBufferId);
|
||||||
|
|
||||||
@@ -122,7 +121,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
BackendBufferBindingProtector backendBufferBindingProtector(TempBufferTarget);
|
|
||||||
|
|
||||||
MGLOG_D("Syncing buffer sub-data (glBufferSubData) for object with ID : %u", m_backendBufferId);
|
MGLOG_D("Syncing buffer sub-data (glBufferSubData) for object with ID : %u", m_backendBufferId);
|
||||||
|
|
||||||
@@ -146,7 +144,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
||||||
#endif
|
#endif
|
||||||
BackendBufferBindingProtector backendBufferBindingProtector(TempBufferTarget);
|
|
||||||
|
|
||||||
MGLOG_D("Syncing buffer map (glMapBuffer) for object with ID : %u", m_backendBufferId);
|
MGLOG_D("Syncing buffer map (glMapBuffer) for object with ID : %u", m_backendBufferId);
|
||||||
MGLOG_D("Mapping buffer with ID: %u", m_backendBufferId);
|
MGLOG_D("Mapping buffer with ID: %u", m_backendBufferId);
|
||||||
@@ -228,9 +225,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
MGLOG_D("Syncing VAO with backend ID %u to backend for state ID %u", m_backendVAOId,
|
MGLOG_D("Syncing VAO with backend ID %u to backend for state ID %u", m_backendVAOId,
|
||||||
stateVAOObject->GetExternalIndex());
|
stateVAOObject->GetExternalIndex());
|
||||||
|
|
||||||
BufferImpl::BackendBufferBindingProtector backendBufferBindingProtector(BufferImpl::TempBufferTarget);
|
|
||||||
BackendVertexArrayBindingProtector backendVAOBindingProtector;
|
|
||||||
|
|
||||||
Bind();
|
Bind();
|
||||||
|
|
||||||
for (const auto& attribIndex : stateVAOObject->GetDirtyAttributeIndices()) {
|
for (const auto& attribIndex : stateVAOObject->GetDirtyAttributeIndices()) {
|
||||||
@@ -759,7 +753,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
MGLOG_D("Syncing FBO with backend ID %u to backend for state ID %u, as %s FBO", m_backendFBOId,
|
MGLOG_D("Syncing FBO with backend ID %u to backend for state ID %u, as %s FBO", m_backendFBOId,
|
||||||
stateFBOObject->GetExternalIndex(), (asTarget == FramebufferTarget::Draw ? "DRAW" : "READ"));
|
stateFBOObject->GetExternalIndex(), (asTarget == FramebufferTarget::Draw ? "DRAW" : "READ"));
|
||||||
GLenum glFBOTarget = MG_Util::ConvertFramebufferTargetToGLEnum(asTarget);
|
GLenum glFBOTarget = MG_Util::ConvertFramebufferTargetToGLEnum(asTarget);
|
||||||
BackendFramebufferBindingProtector backendFBOBindingProtector(glFBOTarget);
|
|
||||||
Bind(asTarget);
|
Bind(asTarget);
|
||||||
|
|
||||||
// Handle all attachments
|
// Handle all attachments
|
||||||
|
|||||||
@@ -19,55 +19,11 @@
|
|||||||
#include <MG_Util/Converters/MGToGL/FramebufferEnumConverter.h>
|
#include <MG_Util/Converters/MGToGL/FramebufferEnumConverter.h>
|
||||||
|
|
||||||
namespace MobileGL::MG_Backend::DirectGLES {
|
namespace MobileGL::MG_Backend::DirectGLES {
|
||||||
namespace BufferImpl {
|
namespace BufferImpl {} // namespace BufferImpl
|
||||||
BackendBufferBindingProtector::BackendBufferBindingProtector(GLenum target) {
|
|
||||||
#ifdef TRACY_ENABLE
|
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
|
||||||
#endif
|
|
||||||
m_target = target;
|
|
||||||
MG_External::GLES::glGetIntegerv(Utils::GetBindingQuery(target, false), &m_previousBinding);
|
|
||||||
}
|
|
||||||
|
|
||||||
BackendBufferBindingProtector::~BackendBufferBindingProtector() {
|
namespace VertexArrayImpl {} // namespace VertexArrayImpl
|
||||||
#ifdef TRACY_ENABLE
|
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
|
||||||
#endif
|
|
||||||
MG_External::GLES::glBindBuffer(m_target, m_previousBinding);
|
|
||||||
}
|
|
||||||
} // namespace BufferImpl
|
|
||||||
|
|
||||||
namespace VertexArrayImpl {
|
|
||||||
BackendVertexArrayBindingProtector::BackendVertexArrayBindingProtector() {
|
|
||||||
#ifdef TRACY_ENABLE
|
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
|
||||||
#endif
|
|
||||||
MG_External::GLES::glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &m_previousBinding);
|
|
||||||
}
|
|
||||||
|
|
||||||
BackendVertexArrayBindingProtector::~BackendVertexArrayBindingProtector() {
|
|
||||||
#ifdef TRACY_ENABLE
|
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
|
||||||
#endif
|
|
||||||
MG_External::GLES::glBindVertexArray(m_previousBinding);
|
|
||||||
}
|
|
||||||
} // namespace VertexArrayImpl
|
|
||||||
|
|
||||||
namespace TextureImpl {
|
namespace TextureImpl {
|
||||||
BackendTextureBindingProtector::BackendTextureBindingProtector(GLenum target) {
|
|
||||||
#ifdef TRACY_ENABLE
|
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
|
||||||
#endif
|
|
||||||
m_target = target;
|
|
||||||
MG_External::GLES::glGetIntegerv(Utils::GetBindingQuery(target, true), &m_previousBinding);
|
|
||||||
}
|
|
||||||
|
|
||||||
BackendTextureBindingProtector::~BackendTextureBindingProtector() {
|
|
||||||
#ifdef TRACY_ENABLE
|
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
|
||||||
#endif
|
|
||||||
MG_External::GLES::glBindTexture(m_target, m_previousBinding);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GenerateTextureFormatInfo(TextureInternalFormat internalFormat, GLenum* outInternalFormat,
|
void GenerateTextureFormatInfo(TextureInternalFormat internalFormat, GLenum* outInternalFormat,
|
||||||
GLenum* outFormat, GLenum* outType) {
|
GLenum* outFormat, GLenum* outType) {
|
||||||
#ifdef TRACY_ENABLE
|
#ifdef TRACY_ENABLE
|
||||||
@@ -81,43 +37,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
}
|
}
|
||||||
} // namespace TextureImpl
|
} // namespace TextureImpl
|
||||||
|
|
||||||
namespace FramebufferImpl {
|
namespace FramebufferImpl {} // namespace FramebufferImpl
|
||||||
BackendFramebufferBindingProtector::BackendFramebufferBindingProtector(GLenum target) {
|
|
||||||
#ifdef TRACY_ENABLE
|
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
|
||||||
#endif
|
|
||||||
m_target = target;
|
|
||||||
MG_External::GLES::glGetIntegerv(Utils::GetBindingQuery(target, false), &m_previousBinding);
|
|
||||||
}
|
|
||||||
|
|
||||||
BackendFramebufferBindingProtector::~BackendFramebufferBindingProtector() {
|
|
||||||
#ifdef TRACY_ENABLE
|
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
|
||||||
#endif
|
|
||||||
MG_External::GLES::glBindFramebuffer(m_target, m_previousBinding);
|
|
||||||
}
|
|
||||||
|
|
||||||
GLuint BackendFramebufferBindingProtector::GetTempFBO(FramebufferTarget target) {
|
|
||||||
#ifdef TRACY_ENABLE
|
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
|
||||||
#endif
|
|
||||||
GLenum glTarget = MG_Util::ConvertFramebufferTargetToGLEnum(target);
|
|
||||||
GLuint& fbo = (glTarget == GL_DRAW_FRAMEBUFFER) ? s_tempDrawFBO : s_tempReadFBO;
|
|
||||||
if (fbo == 0) {
|
|
||||||
MG_External::GLES::glGenFramebuffers(1, &fbo);
|
|
||||||
}
|
|
||||||
return fbo;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BackendFramebufferBindingProtector::BindTempFBO(MobileGL::FramebufferTarget target) {
|
|
||||||
#ifdef TRACY_ENABLE
|
|
||||||
ZoneScopedC(TRACY_ZONECOLOR_BACKEND);
|
|
||||||
#endif
|
|
||||||
GLuint fbo = GetTempFBO(target);
|
|
||||||
GLenum glTarget = MG_Util::ConvertFramebufferTargetToGLEnum(target);
|
|
||||||
MG_External::GLES::glBindFramebuffer(glTarget, fbo);
|
|
||||||
}
|
|
||||||
} // namespace FramebufferImpl
|
|
||||||
|
|
||||||
namespace PrgramImpl {
|
namespace PrgramImpl {
|
||||||
String ProcessOutColorLocations(const String& glslCode) {
|
String ProcessOutColorLocations(const String& glslCode) {
|
||||||
|
|||||||
@@ -27,66 +27,18 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
|||||||
};
|
};
|
||||||
} // namespace DebugImpl
|
} // namespace DebugImpl
|
||||||
|
|
||||||
namespace BufferImpl {
|
namespace BufferImpl {} // namespace BufferImpl
|
||||||
class BackendBufferBindingProtector {
|
|
||||||
public:
|
|
||||||
BackendBufferBindingProtector(GLenum target);
|
|
||||||
|
|
||||||
~BackendBufferBindingProtector();
|
|
||||||
|
|
||||||
private:
|
|
||||||
GLenum m_target;
|
|
||||||
GLint m_previousBinding = 0;
|
|
||||||
};
|
|
||||||
} // namespace BufferImpl
|
|
||||||
|
|
||||||
namespace VertexArrayImpl {
|
namespace VertexArrayImpl {
|
||||||
GLenum GetBindingQuery(GLenum target, bool isTexture);
|
GLenum GetBindingQuery(GLenum target, bool isTexture);
|
||||||
|
|
||||||
class BackendVertexArrayBindingProtector {
|
|
||||||
public:
|
|
||||||
BackendVertexArrayBindingProtector();
|
|
||||||
|
|
||||||
~BackendVertexArrayBindingProtector();
|
|
||||||
|
|
||||||
private:
|
|
||||||
GLint m_previousBinding = 0;
|
|
||||||
};
|
|
||||||
} // namespace VertexArrayImpl
|
} // namespace VertexArrayImpl
|
||||||
|
|
||||||
namespace TextureImpl {
|
namespace TextureImpl {
|
||||||
class BackendTextureBindingProtector {
|
|
||||||
public:
|
|
||||||
BackendTextureBindingProtector(GLenum target);
|
|
||||||
|
|
||||||
~BackendTextureBindingProtector();
|
|
||||||
|
|
||||||
private:
|
|
||||||
GLenum m_target;
|
|
||||||
GLint m_previousBinding = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
void GenerateTextureFormatInfo(TextureInternalFormat internalFormat, GLenum* outInternalFormat,
|
void GenerateTextureFormatInfo(TextureInternalFormat internalFormat, GLenum* outInternalFormat,
|
||||||
GLenum* outFormat, GLenum* outType);
|
GLenum* outFormat, GLenum* outType);
|
||||||
} // namespace TextureImpl
|
} // namespace TextureImpl
|
||||||
|
|
||||||
namespace FramebufferImpl {
|
namespace FramebufferImpl {} // namespace FramebufferImpl
|
||||||
class BackendFramebufferBindingProtector {
|
|
||||||
public:
|
|
||||||
BackendFramebufferBindingProtector(GLenum target);
|
|
||||||
|
|
||||||
~BackendFramebufferBindingProtector();
|
|
||||||
|
|
||||||
static GLuint GetTempFBO(FramebufferTarget target);
|
|
||||||
static void BindTempFBO(FramebufferTarget target);
|
|
||||||
|
|
||||||
private:
|
|
||||||
GLenum m_target;
|
|
||||||
GLint m_previousBinding = 0;
|
|
||||||
inline static GLuint s_tempReadFBO = 0;
|
|
||||||
inline static GLuint s_tempDrawFBO = 0;
|
|
||||||
};
|
|
||||||
} // namespace FramebufferImpl
|
|
||||||
|
|
||||||
namespace PrgramImpl {
|
namespace PrgramImpl {
|
||||||
String ProcessOutColorLocations(const String& glslCode);
|
String ProcessOutColorLocations(const String& glslCode);
|
||||||
|
|||||||
Reference in New Issue
Block a user