mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #12972 from unknownbrackets/gl-step-debug
Label steps using GL debug groups
This commit is contained in:
commit
406c06ccaf
2 changed files with 85 additions and 34 deletions
|
@ -56,6 +56,8 @@ void GLQueueRunner::CreateDeviceObjects() {
|
||||||
populate(GL_EXTENSIONS);
|
populate(GL_EXTENSIONS);
|
||||||
}
|
}
|
||||||
CHECK_GL_ERROR_IF_DEBUG();
|
CHECK_GL_ERROR_IF_DEBUG();
|
||||||
|
|
||||||
|
useDebugGroups_ = !gl_extensions.IsGLES && gl_extensions.VersionGEThan(4, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLQueueRunner::DestroyDeviceObjects() {
|
void GLQueueRunner::DestroyDeviceObjects() {
|
||||||
|
@ -132,6 +134,11 @@ void GLQueueRunner::RunInitSteps(const std::vector<GLRInitStep> &steps, bool ski
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(USING_GLES2)
|
||||||
|
if (useDebugGroups_)
|
||||||
|
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, -1, "InitSteps");
|
||||||
|
#endif
|
||||||
|
|
||||||
CHECK_GL_ERROR_IF_DEBUG();
|
CHECK_GL_ERROR_IF_DEBUG();
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
GLuint boundTexture = (GLuint)-1;
|
GLuint boundTexture = (GLuint)-1;
|
||||||
|
@ -379,6 +386,14 @@ void GLQueueRunner::RunInitSteps(const std::vector<GLRInitStep> &steps, bool ski
|
||||||
WARN_LOG(G3D, "Got an error after init: %08x (%s)", err, GLEnumToString(err).c_str());
|
WARN_LOG(G3D, "Got an error after init: %08x (%s)", err, GLEnumToString(err).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
|
#if !defined(USING_GLES2)
|
||||||
|
if (useDebugGroups_)
|
||||||
|
glPopDebugGroup();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLQueueRunner::InitCreateFramebuffer(const GLRInitStep &step) {
|
void GLQueueRunner::InitCreateFramebuffer(const GLRInitStep &step) {
|
||||||
|
@ -582,12 +597,32 @@ void GLQueueRunner::RunSteps(const std::vector<GLRStep *> &steps, bool skipGLCal
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t totalRenderCount = 0;
|
||||||
|
for (auto &step : steps) {
|
||||||
|
if (step->stepType == GLRStepType::RENDER) {
|
||||||
|
// Skip empty render steps.
|
||||||
|
if (step->commands.empty()) {
|
||||||
|
step->stepType = GLRStepType::RENDER_SKIP;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
totalRenderCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CHECK_GL_ERROR_IF_DEBUG();
|
CHECK_GL_ERROR_IF_DEBUG();
|
||||||
|
size_t renderCount = 0;
|
||||||
for (size_t i = 0; i < steps.size(); i++) {
|
for (size_t i = 0; i < steps.size(); i++) {
|
||||||
const GLRStep &step = *steps[i];
|
const GLRStep &step = *steps[i];
|
||||||
|
|
||||||
|
#if !defined(USING_GLES2)
|
||||||
|
if (useDebugGroups_)
|
||||||
|
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, (GLuint)i + 10000, -1, step.tag);
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (step.stepType) {
|
switch (step.stepType) {
|
||||||
case GLRStepType::RENDER:
|
case GLRStepType::RENDER:
|
||||||
PerformRenderPass(step);
|
renderCount++;
|
||||||
|
PerformRenderPass(step, renderCount == 1, renderCount == totalRenderCount);
|
||||||
break;
|
break;
|
||||||
case GLRStepType::COPY:
|
case GLRStepType::COPY:
|
||||||
PerformCopy(step);
|
PerformCopy(step);
|
||||||
|
@ -601,10 +636,18 @@ void GLQueueRunner::RunSteps(const std::vector<GLRStep *> &steps, bool skipGLCal
|
||||||
case GLRStepType::READBACK_IMAGE:
|
case GLRStepType::READBACK_IMAGE:
|
||||||
PerformReadbackImage(step);
|
PerformReadbackImage(step);
|
||||||
break;
|
break;
|
||||||
|
case GLRStepType::RENDER_SKIP:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Crash();
|
Crash();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(USING_GLES2)
|
||||||
|
if (useDebugGroups_)
|
||||||
|
glPopDebugGroup();
|
||||||
|
#endif
|
||||||
|
|
||||||
delete steps[i];
|
delete steps[i];
|
||||||
}
|
}
|
||||||
CHECK_GL_ERROR_IF_DEBUG();
|
CHECK_GL_ERROR_IF_DEBUG();
|
||||||
|
@ -644,16 +687,12 @@ void GLQueueRunner::PerformBlit(const GLRStep &step) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLQueueRunner::PerformRenderPass(const GLRStep &step) {
|
void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last) {
|
||||||
CHECK_GL_ERROR_IF_DEBUG();
|
CHECK_GL_ERROR_IF_DEBUG();
|
||||||
// Don't execute empty renderpasses.
|
|
||||||
if (step.commands.empty()) {
|
|
||||||
// Nothing to do.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PerformBindFramebufferAsRenderTarget(step);
|
PerformBindFramebufferAsRenderTarget(step);
|
||||||
|
|
||||||
|
if (first) {
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
@ -665,6 +704,7 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step) {
|
||||||
glDisable(GL_COLOR_LOGIC_OP);
|
glDisable(GL_COLOR_LOGIC_OP);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#ifndef USING_GLES2
|
#ifndef USING_GLES2
|
||||||
|
@ -678,12 +718,13 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step) {
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (gl_extensions.ARB_vertex_array_object) {
|
if (first && gl_extensions.ARB_vertex_array_object) {
|
||||||
glBindVertexArray(globalVAO_);
|
glBindVertexArray(globalVAO_);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLRProgram *curProgram = nullptr;
|
GLRProgram *curProgram = nullptr;
|
||||||
int activeSlot = 0;
|
int activeSlot = 0;
|
||||||
|
if (first)
|
||||||
glActiveTexture(GL_TEXTURE0 + activeSlot);
|
glActiveTexture(GL_TEXTURE0 + activeSlot);
|
||||||
|
|
||||||
// State filtering tracking.
|
// State filtering tracking.
|
||||||
|
@ -691,8 +732,8 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step) {
|
||||||
int colorMask = -1;
|
int colorMask = -1;
|
||||||
int depthMask = -1;
|
int depthMask = -1;
|
||||||
int depthFunc = -1;
|
int depthFunc = -1;
|
||||||
GLuint curArrayBuffer = (GLuint)-1;
|
GLuint curArrayBuffer = (GLuint)0;
|
||||||
GLuint curElemArrayBuffer = (GLuint)-1;
|
GLuint curElemArrayBuffer = (GLuint)0;
|
||||||
bool depthEnabled = false;
|
bool depthEnabled = false;
|
||||||
bool stencilEnabled = false;
|
bool stencilEnabled = false;
|
||||||
bool blendEnabled = false;
|
bool blendEnabled = false;
|
||||||
|
@ -929,9 +970,9 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step) {
|
||||||
case GLRRenderCommand::UNIFORMMATRIX:
|
case GLRRenderCommand::UNIFORMMATRIX:
|
||||||
{
|
{
|
||||||
assert(curProgram);
|
assert(curProgram);
|
||||||
int loc = c.uniform4.loc ? *c.uniform4.loc : -1;
|
int loc = c.uniformMatrix4.loc ? *c.uniformMatrix4.loc : -1;
|
||||||
if (c.uniform4.name) {
|
if (c.uniformMatrix4.name) {
|
||||||
loc = curProgram->GetUniformLoc(c.uniform4.name);
|
loc = curProgram->GetUniformLoc(c.uniformMatrix4.name);
|
||||||
}
|
}
|
||||||
if (loc >= 0) {
|
if (loc >= 0) {
|
||||||
glUniformMatrix4fv(loc, 1, false, c.uniformMatrix4.m);
|
glUniformMatrix4fv(loc, 1, false, c.uniformMatrix4.m);
|
||||||
|
@ -1179,21 +1220,29 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step) {
|
||||||
CHECK_GL_ERROR_IF_DEBUG();
|
CHECK_GL_ERROR_IF_DEBUG();
|
||||||
|
|
||||||
// Wipe out the current state.
|
// Wipe out the current state.
|
||||||
|
if (curArrayBuffer != 0)
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
if (curElemArrayBuffer != 0)
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
if (gl_extensions.ARB_vertex_array_object) {
|
if (last && gl_extensions.ARB_vertex_array_object) {
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
if (last)
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
if (depthEnabled)
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
if (stencilEnabled)
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
|
if (blendEnabled)
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
if (cullEnabled)
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
#ifndef USING_GLES2
|
#ifndef USING_GLES2
|
||||||
if (!gl_extensions.IsGLES) {
|
if (!gl_extensions.IsGLES && logicEnabled) {
|
||||||
glDisable(GL_COLOR_LOGIC_OP);
|
glDisable(GL_COLOR_LOGIC_OP);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if ((colorMask & 15) != 15)
|
||||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
CHECK_GL_ERROR_IF_DEBUG();
|
CHECK_GL_ERROR_IF_DEBUG();
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,6 +276,7 @@ enum class GLRStepType : uint8_t {
|
||||||
BLIT,
|
BLIT,
|
||||||
READBACK,
|
READBACK,
|
||||||
READBACK_IMAGE,
|
READBACK_IMAGE,
|
||||||
|
RENDER_SKIP,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class GLRRenderPassAction {
|
enum class GLRRenderPassAction {
|
||||||
|
@ -372,7 +373,7 @@ private:
|
||||||
void InitCreateFramebuffer(const GLRInitStep &step);
|
void InitCreateFramebuffer(const GLRInitStep &step);
|
||||||
|
|
||||||
void PerformBindFramebufferAsRenderTarget(const GLRStep &pass);
|
void PerformBindFramebufferAsRenderTarget(const GLRStep &pass);
|
||||||
void PerformRenderPass(const GLRStep &pass);
|
void PerformRenderPass(const GLRStep &pass, bool first, bool last);
|
||||||
void PerformCopy(const GLRStep &pass);
|
void PerformCopy(const GLRStep &pass);
|
||||||
void PerformBlit(const GLRStep &pass);
|
void PerformBlit(const GLRStep &pass);
|
||||||
void PerformReadback(const GLRStep &pass);
|
void PerformReadback(const GLRStep &pass);
|
||||||
|
@ -420,4 +421,5 @@ private:
|
||||||
std::unordered_map<int, std::string> glStrings_;
|
std::unordered_map<int, std::string> glStrings_;
|
||||||
|
|
||||||
bool sawOutOfMemory_ = false;
|
bool sawOutOfMemory_ = false;
|
||||||
|
bool useDebugGroups_ = false;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue