mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Don't rely on GL driver to store object name, store ourselves. Refs #509
This commit is contained in:
@@ -873,7 +873,8 @@ void WrappedOpenGL::Initialise(GLInitParams ¶ms)
|
||||
gl.glGenTextures(1, &m_FakeBB_Color);
|
||||
gl.glBindTexture(target, m_FakeBB_Color);
|
||||
|
||||
gl.glObjectLabel(eGL_TEXTURE, m_FakeBB_Color, -1, "Backbuffer Color");
|
||||
GetResourceManager()->SetName(GetResourceManager()->GetID(TextureRes(GetCtx(), m_FakeBB_Color)),
|
||||
"Backbuffer Color");
|
||||
|
||||
if(params.multiSamples > 1)
|
||||
{
|
||||
@@ -929,10 +930,9 @@ void WrappedOpenGL::Initialise(GLInitParams ¶ms)
|
||||
else
|
||||
RDCERR("Unexpected # stencil bits: %d", params.stencilBits);
|
||||
|
||||
if(stencil)
|
||||
gl.glObjectLabel(eGL_TEXTURE, m_FakeBB_DepthStencil, -1, "Backbuffer Depth-stencil");
|
||||
else
|
||||
gl.glObjectLabel(eGL_TEXTURE, m_FakeBB_DepthStencil, -1, "Backbuffer Depth");
|
||||
GetResourceManager()->SetName(
|
||||
GetResourceManager()->GetID(TextureRes(GetCtx(), m_FakeBB_DepthStencil)),
|
||||
stencil ? "Backbuffer Depth-stencil" : "Backbuffer Depth");
|
||||
|
||||
if(params.multiSamples > 1)
|
||||
{
|
||||
|
||||
@@ -197,6 +197,9 @@ public:
|
||||
|
||||
GLsync GetSync(GLuint name) { return m_CurrentSyncs[name]; }
|
||||
ResourceId GetSyncID(GLsync sync) { return m_SyncIDs[sync]; }
|
||||
// KHR_debug storage on replay
|
||||
const std::string &GetName(ResourceId id) { return m_Names[id]; }
|
||||
void SetName(ResourceId id, const std::string &name) { m_Names[id] = name; }
|
||||
// we need to find all the children bound to VAOs/FBOs and mark them referenced. The reason for
|
||||
// this is that say a VAO became high traffic and we stopped serialising buffer binds, but then it
|
||||
// is never modified in a frame and none of the buffers are ever referenced. They would be
|
||||
@@ -229,6 +232,7 @@ private:
|
||||
// We manually give them GLuint names so they're otherwise namespaced as (eResSync, GLuint)
|
||||
map<GLsync, ResourceId> m_SyncIDs;
|
||||
map<GLuint, GLsync> m_CurrentSyncs;
|
||||
map<ResourceId, std::string> m_Names;
|
||||
volatile int64_t m_SyncName;
|
||||
|
||||
WrappedOpenGL *m_GL;
|
||||
|
||||
@@ -492,15 +492,8 @@ void GLReplay::CacheTexture(ResourceId id)
|
||||
|
||||
tex.byteSize = (tex.width * tex.height) * (tex.format.compByteWidth * tex.format.compCount);
|
||||
|
||||
string str = "";
|
||||
|
||||
if(HasExt[KHR_debug])
|
||||
{
|
||||
char name[128] = {0};
|
||||
gl.glGetObjectLabel(eGL_RENDERBUFFER, res.resource.name, 127, NULL, name);
|
||||
str = name;
|
||||
tex.customName = true;
|
||||
}
|
||||
string str = m_pDriver->GetResourceManager()->GetName(tex.ID);
|
||||
tex.customName = true;
|
||||
|
||||
if(str == "")
|
||||
{
|
||||
@@ -649,14 +642,8 @@ void GLReplay::CacheTexture(ResourceId id)
|
||||
if(tex.format.compType == eCompType_Depth)
|
||||
tex.creationFlags |= eTextureCreate_DSV;
|
||||
|
||||
string str = "";
|
||||
if(HasExt[KHR_debug])
|
||||
{
|
||||
char name[128] = {0};
|
||||
gl.glGetObjectLabel(eGL_TEXTURE, res.resource.name, 127, NULL, name);
|
||||
str = name;
|
||||
tex.customName = true;
|
||||
}
|
||||
string str = m_pDriver->GetResourceManager()->GetName(tex.ID);
|
||||
tex.customName = true;
|
||||
|
||||
if(str == "")
|
||||
{
|
||||
@@ -816,14 +803,8 @@ FetchBuffer GLReplay::GetBuffer(ResourceId id)
|
||||
res.size = ret.length;
|
||||
}
|
||||
|
||||
string str = "";
|
||||
if(HasExt[KHR_debug])
|
||||
{
|
||||
char name[128] = {0};
|
||||
gl.glGetObjectLabel(eGL_BUFFER, res.resource.name, 127, NULL, name);
|
||||
str = name;
|
||||
ret.customName = true;
|
||||
}
|
||||
string str = m_pDriver->GetResourceManager()->GetName(ret.ID);
|
||||
ret.customName = true;
|
||||
|
||||
if(str == "")
|
||||
{
|
||||
@@ -1112,13 +1093,7 @@ void GLReplay::SavePipelineState()
|
||||
ResourceId id = rm->GetID(ProgramPipeRes(ctx, curProg));
|
||||
auto &pipeDetails = m_pDriver->m_Pipelines[id];
|
||||
|
||||
string pipelineName;
|
||||
if(HasExt[KHR_debug])
|
||||
{
|
||||
char name[128] = {0};
|
||||
gl.glGetObjectLabel(eGL_PROGRAM_PIPELINE, curProg, 127, NULL, name);
|
||||
pipelineName = name;
|
||||
}
|
||||
string pipelineName = rm->GetName(rm->GetOriginalID(id));
|
||||
|
||||
for(size_t i = 0; i < ARRAY_COUNT(pipeDetails.stageShaders); i++)
|
||||
{
|
||||
@@ -1135,22 +1110,11 @@ void GLReplay::SavePipelineState()
|
||||
stages[i]->BindpointMapping);
|
||||
mappings[i] = &stages[i]->BindpointMapping;
|
||||
|
||||
if(HasExt[KHR_debug])
|
||||
{
|
||||
char name[128] = {0};
|
||||
gl.glGetObjectLabel(eGL_PROGRAM, curProg, 127, NULL, name);
|
||||
stages[i]->ProgramName = name;
|
||||
stages[i]->customProgramName = (name[0] != 0);
|
||||
}
|
||||
stages[i]->ProgramName = rm->GetName(rm->GetOriginalID(pipeDetails.stagePrograms[i]));
|
||||
stages[i]->customProgramName = !stages[i]->ProgramName.empty();
|
||||
|
||||
if(HasExt[KHR_debug])
|
||||
{
|
||||
char name[128] = {0};
|
||||
gl.glGetObjectLabel(eGL_SHADER, rm->GetCurrentResource(pipeDetails.stageShaders[i]).name,
|
||||
127, NULL, name);
|
||||
stages[i]->ShaderName = name;
|
||||
stages[i]->customShaderName = (name[0] != 0);
|
||||
}
|
||||
stages[i]->ShaderName = rm->GetName(rm->GetOriginalID(pipeDetails.stageShaders[i]));
|
||||
stages[i]->customShaderName = !stages[i]->ShaderName.empty();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1161,15 +1125,10 @@ void GLReplay::SavePipelineState()
|
||||
}
|
||||
else
|
||||
{
|
||||
auto &progDetails = m_pDriver->m_Programs[rm->GetID(ProgramRes(ctx, curProg))];
|
||||
ResourceId id = rm->GetID(ProgramRes(ctx, curProg));
|
||||
auto &progDetails = m_pDriver->m_Programs[id];
|
||||
|
||||
string programName;
|
||||
if(HasExt[KHR_debug])
|
||||
{
|
||||
char name[128] = {0};
|
||||
gl.glGetObjectLabel(eGL_PROGRAM, curProg, 127, NULL, name);
|
||||
programName = name;
|
||||
}
|
||||
string programName = rm->GetName(rm->GetOriginalID(id));
|
||||
|
||||
for(size_t i = 0; i < ARRAY_COUNT(progDetails.stageShaders); i++)
|
||||
{
|
||||
@@ -1183,14 +1142,8 @@ void GLReplay::SavePipelineState()
|
||||
GetBindpointMapping(gl.GetHookset(), curProg, (int)i, refls[i], stages[i]->BindpointMapping);
|
||||
mappings[i] = &stages[i]->BindpointMapping;
|
||||
|
||||
if(HasExt[KHR_debug])
|
||||
{
|
||||
char name[128] = {0};
|
||||
gl.glGetObjectLabel(eGL_SHADER, rm->GetCurrentResource(progDetails.stageShaders[i]).name,
|
||||
127, NULL, name);
|
||||
stages[i]->ShaderName = name;
|
||||
stages[i]->customShaderName = (name[0] != 0);
|
||||
}
|
||||
stages[i]->ShaderName = rm->GetName(rm->GetOriginalID(progDetails.stageShaders[i]));
|
||||
stages[i]->customShaderName = !stages[i]->ShaderName.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3036,10 +2989,12 @@ ResourceId GLReplay::CreateProxyTexture(const FetchTexture &templateTex)
|
||||
}
|
||||
}
|
||||
|
||||
if(templateTex.customName && HasExt[KHR_debug])
|
||||
gl.glObjectLabel(eGL_TEXTURE, tex, -1, templateTex.name.elems);
|
||||
ResourceId id = m_pDriver->GetResourceManager()->GetID(TextureRes(m_pDriver->GetCtx(), tex));
|
||||
|
||||
return m_pDriver->GetResourceManager()->GetID(TextureRes(m_pDriver->GetCtx(), tex));
|
||||
if(templateTex.customName)
|
||||
m_pDriver->GetResourceManager()->SetName(id, templateTex.name.c_str());
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void GLReplay::SetProxyTextureData(ResourceId texid, uint32_t arrayIdx, uint32_t mip, byte *data,
|
||||
@@ -3198,10 +3153,12 @@ ResourceId GLReplay::CreateProxyBuffer(const FetchBuffer &templateBuf)
|
||||
gl.glBindBuffer(target, buf);
|
||||
gl.glNamedBufferDataEXT(buf, (GLsizeiptr)templateBuf.length, NULL, eGL_DYNAMIC_DRAW);
|
||||
|
||||
if(templateBuf.customName && HasExt[KHR_debug])
|
||||
gl.glObjectLabel(eGL_BUFFER, buf, -1, templateBuf.name.elems);
|
||||
ResourceId id = m_pDriver->GetResourceManager()->GetID(BufferRes(m_pDriver->GetCtx(), buf));
|
||||
|
||||
return m_pDriver->GetResourceManager()->GetID(BufferRes(m_pDriver->GetCtx(), buf));
|
||||
if(templateBuf.customName)
|
||||
m_pDriver->GetResourceManager()->SetName(id, templateBuf.name.c_str());
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void GLReplay::SetProxyBufferData(ResourceId bufid, byte *data, size_t dataSize)
|
||||
|
||||
@@ -83,14 +83,7 @@ bool WrappedOpenGL::Serialise_glObjectLabel(GLenum identifier, GLuint name, GLsi
|
||||
m_pSerialiser->SerialiseString("label", Label);
|
||||
|
||||
if(m_State == READING && GetResourceManager()->HasLiveResource(id))
|
||||
{
|
||||
GLResource res = GetResourceManager()->GetLiveResource(id);
|
||||
|
||||
if(extvariant && m_Real.glLabelObjectEXT)
|
||||
m_Real.glLabelObjectEXT(Identifier, res.name, Length, HasLabel ? Label.c_str() : NULL);
|
||||
else
|
||||
m_Real.glObjectLabel(Identifier, res.name, Length, HasLabel ? Label.c_str() : NULL);
|
||||
}
|
||||
GetResourceManager()->SetName(id, HasLabel ? Label : "");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user