mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-26 00:16:45 +00:00
fixed the problem of glClear not displaying its output fbo
This commit is contained in:
committed by
Baldur Karlsson
parent
1758b32045
commit
99cace95cb
@@ -738,6 +738,8 @@ public:
|
||||
FillReflectionArray(GetResourceManager()->GetID(program), stages);
|
||||
}
|
||||
|
||||
ResourceId ExtractFBOAttachment(GLenum target, GLenum attachment);
|
||||
|
||||
struct TextureData
|
||||
{
|
||||
TextureData()
|
||||
|
||||
@@ -4445,51 +4445,29 @@ bool WrappedOpenGL::Serialise_glClear(SerialiserType &ser, GLbitfield mask)
|
||||
if(mask & (eGL_DEPTH_BUFFER_BIT | eGL_STENCIL_BUFFER_BIT))
|
||||
draw.flags |= DrawFlags::ClearDepthStencil;
|
||||
|
||||
AddDrawcall(draw, true);
|
||||
|
||||
GLuint attachment = 0;
|
||||
GLenum type = eGL_TEXTURE;
|
||||
ResourceId dstId;
|
||||
|
||||
if(mask & GL_DEPTH_BUFFER_BIT)
|
||||
{
|
||||
GL.glGetFramebufferAttachmentParameteriv(eGL_DRAW_FRAMEBUFFER, eGL_DEPTH_ATTACHMENT,
|
||||
eGL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
|
||||
(GLint *)&attachment);
|
||||
GL.glGetFramebufferAttachmentParameteriv(eGL_DRAW_FRAMEBUFFER, eGL_DEPTH_ATTACHMENT,
|
||||
eGL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
|
||||
(GLint *)&type);
|
||||
ResourceId res_id = ExtractFBOAttachment(eGL_DRAW_FRAMEBUFFER, eGL_DEPTH_ATTACHMENT);
|
||||
|
||||
if(attachment)
|
||||
if(res_id != ResourceId())
|
||||
{
|
||||
if(type == eGL_TEXTURE)
|
||||
m_ResourceUses[GetResourceManager()->GetID(TextureRes(GetCtx(), attachment))].push_back(
|
||||
EventUsage(m_CurEventID, ResourceUsage::Clear));
|
||||
else
|
||||
m_ResourceUses[GetResourceManager()->GetID(RenderbufferRes(GetCtx(), attachment))].push_back(
|
||||
EventUsage(m_CurEventID, ResourceUsage::Clear));
|
||||
m_ResourceUses[res_id].push_back(EventUsage(m_CurEventID, ResourceUsage::Clear));
|
||||
|
||||
dstId = res_id;
|
||||
}
|
||||
}
|
||||
|
||||
attachment = 0;
|
||||
type = eGL_TEXTURE;
|
||||
|
||||
if(mask & GL_STENCIL_BUFFER_BIT)
|
||||
{
|
||||
GL.glGetFramebufferAttachmentParameteriv(eGL_DRAW_FRAMEBUFFER, eGL_STENCIL_ATTACHMENT,
|
||||
eGL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
|
||||
(GLint *)&attachment);
|
||||
GL.glGetFramebufferAttachmentParameteriv(eGL_DRAW_FRAMEBUFFER, eGL_STENCIL_ATTACHMENT,
|
||||
eGL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
|
||||
(GLint *)&type);
|
||||
ResourceId res_id = ExtractFBOAttachment(eGL_DRAW_FRAMEBUFFER, eGL_STENCIL_ATTACHMENT);
|
||||
|
||||
if(attachment)
|
||||
if(res_id != ResourceId())
|
||||
{
|
||||
if(type == eGL_TEXTURE)
|
||||
m_ResourceUses[GetResourceManager()->GetID(TextureRes(GetCtx(), attachment))].push_back(
|
||||
EventUsage(m_CurEventID, ResourceUsage::Clear));
|
||||
else
|
||||
m_ResourceUses[GetResourceManager()->GetID(RenderbufferRes(GetCtx(), attachment))].push_back(
|
||||
EventUsage(m_CurEventID, ResourceUsage::Clear));
|
||||
m_ResourceUses[res_id].push_back(EventUsage(m_CurEventID, ResourceUsage::Clear));
|
||||
|
||||
dstId = res_id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4498,32 +4476,25 @@ bool WrappedOpenGL::Serialise_glClear(SerialiserType &ser, GLbitfield mask)
|
||||
GLint numCols = 8;
|
||||
GL.glGetIntegerv(eGL_MAX_COLOR_ATTACHMENTS, &numCols);
|
||||
|
||||
for(int i = 0; i < numCols; i++)
|
||||
for(int i = numCols - 1; i >= 0; --i)
|
||||
{
|
||||
attachment = 0;
|
||||
type = eGL_TEXTURE;
|
||||
ResourceId res_id =
|
||||
ExtractFBOAttachment(eGL_DRAW_FRAMEBUFFER, GLenum(eGL_COLOR_ATTACHMENT0 + i));
|
||||
|
||||
GL.glGetFramebufferAttachmentParameteriv(
|
||||
eGL_DRAW_FRAMEBUFFER, GLenum(eGL_COLOR_ATTACHMENT0 + i),
|
||||
eGL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, (GLint *)&attachment);
|
||||
GL.glGetFramebufferAttachmentParameteriv(
|
||||
eGL_DRAW_FRAMEBUFFER, GLenum(eGL_COLOR_ATTACHMENT0 + i),
|
||||
eGL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, (GLint *)&type);
|
||||
|
||||
if(attachment)
|
||||
if(res_id != ResourceId())
|
||||
{
|
||||
if(type == eGL_TEXTURE)
|
||||
m_ResourceUses[GetResourceManager()->GetID(TextureRes(GetCtx(), attachment))].push_back(
|
||||
EventUsage(m_CurEventID, ResourceUsage::Clear));
|
||||
else
|
||||
m_ResourceUses[GetResourceManager()->GetID(RenderbufferRes(GetCtx(), attachment))]
|
||||
.push_back(EventUsage(m_CurEventID, ResourceUsage::Clear));
|
||||
m_ResourceUses[res_id].push_back(EventUsage(m_CurEventID, ResourceUsage::Clear));
|
||||
|
||||
dstId = res_id;
|
||||
}
|
||||
}
|
||||
|
||||
draw.copyDestination = GetResourceManager()->GetOriginalID(dstId);
|
||||
|
||||
AddDrawcall(draw, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4542,6 +4513,10 @@ void WrappedOpenGL::glClear(GLbitfield mask)
|
||||
Serialise_glClear(ser, mask);
|
||||
|
||||
GetContextRecord()->AddChunk(scope.Get());
|
||||
|
||||
GLint fbo;
|
||||
GL.glGetIntegerv(eGL_DRAW_FRAMEBUFFER_BINDING, &fbo);
|
||||
GetResourceManager()->MarkFBOReferenced(FramebufferRes(GetCtx(), fbo), eFrameRef_CompleteWrite);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,30 @@
|
||||
#include "common/common.h"
|
||||
#include "strings/string_utils.h"
|
||||
|
||||
ResourceId WrappedOpenGL::ExtractFBOAttachment(GLenum target, GLenum attachment)
|
||||
{
|
||||
GLint name = 0;
|
||||
GLint type = eGL_TEXTURE;
|
||||
|
||||
GL.glGetFramebufferAttachmentParameteriv(target, attachment,
|
||||
eGL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &name);
|
||||
GL.glGetFramebufferAttachmentParameteriv(target, attachment,
|
||||
eGL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &type);
|
||||
|
||||
GLResource res;
|
||||
|
||||
if(type == eGL_TEXTURE)
|
||||
{
|
||||
res = TextureRes(GetCtx(), name);
|
||||
}
|
||||
else if(type == eGL_RENDERBUFFER)
|
||||
{
|
||||
res = RenderbufferRes(GetCtx(), name);
|
||||
}
|
||||
|
||||
return GetResourceManager()->GetID(res);
|
||||
}
|
||||
|
||||
template <typename SerialiserType>
|
||||
bool WrappedOpenGL::Serialise_glGenFramebuffers(SerialiserType &ser, GLsizei n, GLuint *framebuffers)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user