mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-26 16:36:31 +00:00
Handle calls to bind 0 object (unbinding)
This commit is contained in:
@@ -108,20 +108,28 @@ size_t WrappedOpenGL::BufferIdx(GLenum buf)
|
||||
bool WrappedOpenGL::Serialise_glBindBuffer(GLenum target, GLuint buffer)
|
||||
{
|
||||
SERIALISE_ELEMENT(GLenum, Target, target);
|
||||
SERIALISE_ELEMENT(ResourceId, Id, GetResourceManager()->GetID(BufferRes(buffer)));
|
||||
SERIALISE_ELEMENT(ResourceId, Id, (buffer ? GetResourceManager()->GetID(BufferRes(buffer)) : ResourceId()));
|
||||
|
||||
if(m_State >= WRITING)
|
||||
{
|
||||
size_t idx = BufferIdx(target);
|
||||
|
||||
m_BufferRecord[idx]->datatype = Target;
|
||||
if(buffer != 0)
|
||||
m_BufferRecord[idx]->datatype = Target;
|
||||
}
|
||||
else if(m_State < WRITING)
|
||||
{
|
||||
GLResource res = GetResourceManager()->GetLiveResource(Id);
|
||||
m_Real.glBindBuffer(Target, res.name);
|
||||
if(Id == ResourceId())
|
||||
{
|
||||
m_Real.glBindBuffer(Target, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLResource res = GetResourceManager()->GetLiveResource(Id);
|
||||
m_Real.glBindBuffer(Target, res.name);
|
||||
|
||||
m_Buffers[GetResourceManager()->GetLiveID(Id)].curType = Target;
|
||||
m_Buffers[GetResourceManager()->GetLiveID(Id)].curType = Target;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -131,9 +139,16 @@ void WrappedOpenGL::glBindBuffer(GLenum target, GLuint buffer)
|
||||
{
|
||||
m_Real.glBindBuffer(target, buffer);
|
||||
|
||||
size_t idx = BufferIdx(target);
|
||||
|
||||
if(m_State == WRITING_CAPFRAME)
|
||||
{
|
||||
Chunk *chunk = NULL;
|
||||
|
||||
if(buffer == 0)
|
||||
m_BufferRecord[idx] = NULL;
|
||||
else
|
||||
m_BufferRecord[idx] = GetResourceManager()->GetResourceRecord(BufferRes(buffer));
|
||||
|
||||
{
|
||||
SCOPED_SERIALISE_CONTEXT(BIND_BUFFER);
|
||||
@@ -145,8 +160,6 @@ void WrappedOpenGL::glBindBuffer(GLenum target, GLuint buffer)
|
||||
m_ContextRecord->AddChunk(chunk);
|
||||
}
|
||||
|
||||
size_t idx = BufferIdx(target);
|
||||
|
||||
if(buffer == 0)
|
||||
{
|
||||
m_BufferRecord[idx] = NULL;
|
||||
@@ -505,12 +518,19 @@ bool WrappedOpenGL::Serialise_glBindBufferBase(GLenum target, GLuint index, GLui
|
||||
{
|
||||
SERIALISE_ELEMENT(GLenum, Target, target);
|
||||
SERIALISE_ELEMENT(uint32_t, Index, index);
|
||||
SERIALISE_ELEMENT(ResourceId, id, m_BufferRecord[BufferIdx(target)]->GetResourceID());
|
||||
SERIALISE_ELEMENT(ResourceId, id, (buffer ? GetResourceManager()->GetID(BufferRes(buffer)) : ResourceId()));
|
||||
|
||||
if(m_State < WRITING)
|
||||
{
|
||||
GLResource res = GetResourceManager()->GetLiveResource(id);
|
||||
m_Real.glBindBufferBase(Target, Index, res.name);
|
||||
if(id == ResourceId())
|
||||
{
|
||||
m_Real.glBindBuffer(Target, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLResource res = GetResourceManager()->GetLiveResource(id);
|
||||
m_Real.glBindBufferBase(Target, Index, res.name);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -543,14 +563,21 @@ bool WrappedOpenGL::Serialise_glBindBufferRange(GLenum target, GLuint index, GLu
|
||||
{
|
||||
SERIALISE_ELEMENT(GLenum, Target, target);
|
||||
SERIALISE_ELEMENT(uint32_t, Index, index);
|
||||
SERIALISE_ELEMENT(ResourceId, id, m_BufferRecord[BufferIdx(target)]->GetResourceID());
|
||||
SERIALISE_ELEMENT(ResourceId, id, (buffer ? GetResourceManager()->GetID(BufferRes(buffer)) : ResourceId()));
|
||||
SERIALISE_ELEMENT(uint64_t, Offset, (uint64_t)offset);
|
||||
SERIALISE_ELEMENT(uint64_t, Size, (uint64_t)size);
|
||||
|
||||
if(m_State < WRITING)
|
||||
{
|
||||
GLResource res = GetResourceManager()->GetLiveResource(id);
|
||||
m_Real.glBindBufferRange(Target, Index, res.name, (GLintptr)Offset, (GLsizeiptr)Size);
|
||||
if(id == ResourceId())
|
||||
{
|
||||
m_Real.glBindBuffer(Target, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLResource res = GetResourceManager()->GetLiveResource(id);
|
||||
m_Real.glBindBufferRange(Target, Index, res.name, (GLintptr)Offset, (GLsizeiptr)Size);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1077,11 +1104,19 @@ void WrappedOpenGL::glGenVertexArrays(GLsizei n, GLuint *arrays)
|
||||
|
||||
bool WrappedOpenGL::Serialise_glBindVertexArray(GLuint array)
|
||||
{
|
||||
SERIALISE_ELEMENT(ResourceId, id, GetResourceManager()->GetID(VertexArrayRes(array)));
|
||||
SERIALISE_ELEMENT(ResourceId, id, (array ? GetResourceManager()->GetID(VertexArrayRes(array)) : ResourceId()));
|
||||
|
||||
if(m_State <= EXECUTING)
|
||||
{
|
||||
m_Real.glBindVertexArray(GetResourceManager()->GetLiveResource(id).name);
|
||||
if(id == ResourceId())
|
||||
{
|
||||
m_Real.glBindVertexArray(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLuint live = GetResourceManager()->GetLiveResource(id).name;
|
||||
m_Real.glBindVertexArray(live);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -335,7 +335,7 @@ void WrappedOpenGL::glReadBuffer(GLenum mode)
|
||||
bool WrappedOpenGL::Serialise_glBindFramebuffer(GLenum target, GLuint framebuffer)
|
||||
{
|
||||
SERIALISE_ELEMENT(GLenum, Target, target);
|
||||
SERIALISE_ELEMENT(ResourceId, Id, GetResourceManager()->GetID(FramebufferRes(framebuffer)));
|
||||
SERIALISE_ELEMENT(ResourceId, Id, (framebuffer ? GetResourceManager()->GetID(FramebufferRes(framebuffer)) : ResourceId()));
|
||||
|
||||
if(m_State <= EXECUTING)
|
||||
{
|
||||
|
||||
@@ -79,12 +79,19 @@ void WrappedOpenGL::glGenSamplers(GLsizei count, GLuint *samplers)
|
||||
bool WrappedOpenGL::Serialise_glBindSampler(GLuint unit, GLuint sampler)
|
||||
{
|
||||
SERIALISE_ELEMENT(uint32_t, Unit, unit);
|
||||
SERIALISE_ELEMENT(ResourceId, id, GetResourceManager()->GetID(SamplerRes(sampler)));
|
||||
SERIALISE_ELEMENT(ResourceId, id, sampler ? GetResourceManager()->GetID(SamplerRes(sampler)) : ResourceId());
|
||||
|
||||
if(m_State < WRITING)
|
||||
{
|
||||
GLResource res = GetResourceManager()->GetLiveResource(id);
|
||||
glBindSampler(Unit, res.name);
|
||||
if(id == ResourceId())
|
||||
{
|
||||
m_Real.glBindSampler(Unit, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLResource res = GetResourceManager()->GetLiveResource(id);
|
||||
m_Real.glBindSampler(Unit, res.name);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -636,11 +636,19 @@ void WrappedOpenGL::glGenProgramPipelines(GLsizei n, GLuint *pipelines)
|
||||
|
||||
bool WrappedOpenGL::Serialise_glBindProgramPipeline(GLuint pipeline)
|
||||
{
|
||||
SERIALISE_ELEMENT(ResourceId, id, GetResourceManager()->GetID(ProgramPipeRes(pipeline)));
|
||||
SERIALISE_ELEMENT(ResourceId, id, (pipeline ? GetResourceManager()->GetID(ProgramPipeRes(pipeline)) : ResourceId()));
|
||||
|
||||
if(m_State <= EXECUTING)
|
||||
{
|
||||
m_Real.glBindProgramPipeline(GetResourceManager()->GetLiveResource(id).name);
|
||||
if(id == ResourceId())
|
||||
{
|
||||
m_Real.glBindProgramPipeline(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLuint live = GetResourceManager()->GetLiveResource(id).name;
|
||||
m_Real.glBindProgramPipeline(live);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -92,7 +92,7 @@ void WrappedOpenGL::glDeleteTextures(GLsizei n, const GLuint *textures)
|
||||
bool WrappedOpenGL::Serialise_glBindTexture(GLenum target, GLuint texture)
|
||||
{
|
||||
SERIALISE_ELEMENT(GLenum, Target, target);
|
||||
SERIALISE_ELEMENT(ResourceId, Id, GetResourceManager()->GetID(TextureRes(texture)));
|
||||
SERIALISE_ELEMENT(ResourceId, Id, (texture ? GetResourceManager()->GetID(TextureRes(texture)) : ResourceId()));
|
||||
|
||||
if(m_State == WRITING_IDLE)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user