Save target of clear calls that don't clear currently bound targets

* This prevents the UI from showing confusing results when the currently
  bound state doesn't match what's being cleared.
This commit is contained in:
baldurk
2017-07-17 11:33:50 +01:00
parent 1676f2698e
commit 8adde662fd
8 changed files with 186 additions and 109 deletions
+28 -26
View File
@@ -85,10 +85,11 @@ bool Following::operator==(const Following &o)
return Type == o.Type && Stage == o.Stage && index == o.index;
}
void Following::GetDrawContext(ICaptureContext &ctx, bool &copy, bool &compute)
void Following::GetDrawContext(ICaptureContext &ctx, bool &copy, bool &clear, bool &compute)
{
const DrawcallDescription *curDraw = ctx.CurDrawcall();
copy = curDraw != NULL && (curDraw->flags & (DrawFlags::Copy | DrawFlags::Resolve));
clear = curDraw != NULL && (curDraw->flags & DrawFlags::Clear);
compute = curDraw != NULL && (curDraw->flags & DrawFlags::Dispatch) &&
ctx.CurPipelineState().GetShader(ShaderStage::Compute) != ResourceId();
}
@@ -163,10 +164,10 @@ BoundResource Following::GetBoundResource(ICaptureContext &ctx, int arrayIdx)
QVector<BoundResource> Following::GetOutputTargets(ICaptureContext &ctx)
{
const DrawcallDescription *curDraw = ctx.CurDrawcall();
bool copy = false, compute = false;
GetDrawContext(ctx, copy, compute);
bool copy = false, clear = false, compute = false;
GetDrawContext(ctx, copy, clear, compute);
if(copy)
if(copy || clear)
{
return {BoundResource(curDraw->copyDestination)};
}
@@ -196,10 +197,10 @@ QVector<BoundResource> Following::GetOutputTargets(ICaptureContext &ctx)
BoundResource Following::GetDepthTarget(ICaptureContext &ctx)
{
bool copy = false, compute = false;
GetDrawContext(ctx, copy, compute);
bool copy = false, clear = false, compute = false;
GetDrawContext(ctx, copy, clear, compute);
if(copy || compute)
if(copy || clear || compute)
return BoundResource(ResourceId());
else
return ctx.CurPipelineState().GetDepthTarget();
@@ -208,10 +209,10 @@ BoundResource Following::GetDepthTarget(ICaptureContext &ctx)
QMap<BindpointMap, QVector<BoundResource>> Following::GetReadWriteResources(ICaptureContext &ctx,
ShaderStage stage)
{
bool copy = false, compute = false;
GetDrawContext(ctx, copy, compute);
bool copy = false, clear = false, compute = false;
GetDrawContext(ctx, copy, clear, compute);
if(copy)
if(copy || clear)
{
return QMap<BindpointMap, QVector<BoundResource>>();
}
@@ -238,15 +239,15 @@ QMap<BindpointMap, QVector<BoundResource>> Following::GetReadOnlyResources(ICapt
ShaderStage stage)
{
const DrawcallDescription *curDraw = ctx.CurDrawcall();
bool copy = false, compute = false;
GetDrawContext(ctx, copy, compute);
bool copy = false, clear = false, compute = false;
GetDrawContext(ctx, copy, clear, compute);
if(copy)
if(copy || clear)
{
QMap<BindpointMap, QVector<BoundResource>> ret;
// only return copy source for one stage
if(stage == ShaderStage::Pixel)
if(copy && stage == ShaderStage::Pixel)
ret[BindpointMap(0, 0)] = {BoundResource(curDraw->copySource)};
return ret;
@@ -272,10 +273,10 @@ QMap<BindpointMap, QVector<BoundResource>> Following::GetReadOnlyResources(ICapt
const ShaderReflection *Following::GetReflection(ICaptureContext &ctx, ShaderStage stage)
{
bool copy = false, compute = false;
GetDrawContext(ctx, copy, compute);
bool copy = false, clear = false, compute = false;
GetDrawContext(ctx, copy, clear, compute);
if(copy)
if(copy || clear)
return NULL;
else if(compute)
return ctx.CurPipelineState().GetShaderReflection(ShaderStage::Compute);
@@ -290,15 +291,15 @@ const ShaderReflection *Following::GetReflection(ICaptureContext &ctx)
const ShaderBindpointMapping &Following::GetMapping(ICaptureContext &ctx, ShaderStage stage)
{
bool copy = false, compute = false;
GetDrawContext(ctx, copy, compute);
bool copy = false, clear = false, compute = false;
GetDrawContext(ctx, copy, clear, compute);
if(copy)
if(copy || clear)
{
static ShaderBindpointMapping mapping;
// for PS only add a single mapping to get the copy source
if(stage == ShaderStage::Pixel)
if(copy && stage == ShaderStage::Pixel)
mapping.ReadOnlyResources = {BindpointMap(0, 0)};
else
mapping.ReadOnlyResources.clear();
@@ -2609,8 +2610,8 @@ void TextureViewer::OnEventChanged(uint32_t eventID)
int outIndex = 0;
int inIndex = 0;
bool copy = false, compute = false;
Following::GetDrawContext(m_Ctx, copy, compute);
bool copy = false, clear = false, compute = false;
Following::GetDrawContext(m_Ctx, copy, clear, compute);
for(int rt = 0; rt < RTs.size(); rt++)
{
@@ -2624,9 +2625,10 @@ void TextureViewer::OnEventChanged(uint32_t eventID)
outIndex++;
Following follow(FollowType::OutputColour, ShaderStage::Pixel, rt, 0);
QString bindName = copy ? tr("Destination") : QString();
QString slotName =
copy ? tr("DST") : (m_Ctx.CurPipelineState().OutputAbbrev() + QString::number(rt));
QString bindName = (copy || clear) ? tr("Destination") : QString();
QString slotName = (copy || clear)
? tr("DST")
: (m_Ctx.CurPipelineState().OutputAbbrev() + QString::number(rt));
InitResourcePreview(prev, RTs[rt].Id, RTs[rt].typeHint, false, follow, bindName, slotName);
}
+1 -1
View File
@@ -62,7 +62,7 @@ struct Following
bool operator==(const Following &o);
bool operator!=(const Following &o);
static void GetDrawContext(ICaptureContext &ctx, bool &copy, bool &compute);
static void GetDrawContext(ICaptureContext &ctx, bool &copy, bool &clear, bool &compute);
int GetHighestMip(ICaptureContext &ctx);
int GetFirstArraySlice(ICaptureContext &ctx);
+61 -13
View File
@@ -480,6 +480,26 @@ bool WrappedID3D11DeviceContext::Serialise_ClearView(ID3D11View *pView, const FL
draw.flags |= DrawFlags::Clear;
if(m_pDevice->GetResourceManager()->HasLiveResource(View))
{
ID3D11View *wrapped = (ID3D11View *)m_pDevice->GetResourceManager()->GetLiveResource(View);
ResourceId resid;
if(WrappedID3D11RenderTargetView1::IsAlloc(wrapped))
resid = ((WrappedID3D11RenderTargetView1 *)wrapped)->GetResourceID();
else if(WrappedID3D11DepthStencilView::IsAlloc(wrapped))
resid = ((WrappedID3D11DepthStencilView *)wrapped)->GetResourceID();
else if(WrappedID3D11ShaderResourceView1::IsAlloc(wrapped))
resid = ((WrappedID3D11ShaderResourceView1 *)wrapped)->GetResourceID();
else if(WrappedID3D11UnorderedAccessView1::IsAlloc(wrapped))
resid = ((WrappedID3D11UnorderedAccessView1 *)wrapped)->GetResourceID();
m_ResourceUses[resid].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear, GetIDForResource(wrapped)));
draw.copyDestination = m_pDevice->GetResourceManager()->GetOriginalID(resid);
}
AddDrawcall(draw, true);
}
@@ -1710,8 +1730,8 @@ bool WrappedID3D11DeviceContext::Serialise_DiscardResource(ID3D11Resource *pReso
DrawcallDescription draw;
draw.name = "DiscardResource()";
draw.flags |= DrawFlags::Clear;
draw.copyDestination = res;
AddDrawcall(draw, true);
@@ -1796,8 +1816,6 @@ bool WrappedID3D11DeviceContext::Serialise_DiscardView(ID3D11View *pResourceView
draw.flags |= DrawFlags::Clear;
AddDrawcall(draw, true);
if(m_pDevice->GetResourceManager()->HasLiveResource(View))
{
ID3D11DeviceChild *pLiveView = m_pDevice->GetResourceManager()->GetLiveResource(View);
@@ -1807,26 +1825,36 @@ bool WrappedID3D11DeviceContext::Serialise_DiscardView(ID3D11View *pResourceView
WrappedID3D11RenderTargetView1 *view = (WrappedID3D11RenderTargetView1 *)pLiveView;
m_ResourceUses[view->GetResourceResID()].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear, view->GetResourceID()));
draw.copyDestination =
m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID());
}
else if(WrappedID3D11DepthStencilView::IsAlloc(pLiveView))
{
WrappedID3D11DepthStencilView *view = (WrappedID3D11DepthStencilView *)pLiveView;
m_ResourceUses[view->GetResourceResID()].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear, view->GetResourceID()));
draw.copyDestination =
m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID());
}
else if(WrappedID3D11ShaderResourceView1::IsAlloc(pLiveView))
{
WrappedID3D11ShaderResourceView1 *view = (WrappedID3D11ShaderResourceView1 *)pLiveView;
m_ResourceUses[view->GetResourceResID()].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear, view->GetResourceID()));
draw.copyDestination =
m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID());
}
else if(WrappedID3D11UnorderedAccessView1::IsAlloc(pLiveView))
{
WrappedID3D11UnorderedAccessView1 *view = (WrappedID3D11UnorderedAccessView1 *)pLiveView;
m_ResourceUses[view->GetResourceResID()].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear, view->GetResourceID()));
draw.copyDestination =
m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID());
}
}
AddDrawcall(draw, true);
}
return true;
@@ -1921,25 +1949,45 @@ bool WrappedID3D11DeviceContext::Serialise_DiscardView1(ID3D11View *pResourceVie
draw.flags |= DrawFlags::Clear;
AddDrawcall(draw, true);
if(m_pDevice->GetResourceManager()->HasLiveResource(View))
{
ID3D11DeviceChild *pLiveView = m_pDevice->GetResourceManager()->GetLiveResource(View);
if(WrappedID3D11RenderTargetView1::IsAlloc(pLiveView))
m_ResourceUses[((WrappedID3D11RenderTargetView1 *)pLiveView)->GetResourceResID()].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear));
{
WrappedID3D11RenderTargetView1 *view = (WrappedID3D11RenderTargetView1 *)pLiveView;
m_ResourceUses[view->GetResourceResID()].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear, view->GetResourceID()));
draw.copyDestination =
m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID());
}
else if(WrappedID3D11DepthStencilView::IsAlloc(pLiveView))
m_ResourceUses[((WrappedID3D11DepthStencilView *)pLiveView)->GetResourceResID()].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear));
{
WrappedID3D11DepthStencilView *view = (WrappedID3D11DepthStencilView *)pLiveView;
m_ResourceUses[view->GetResourceResID()].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear, view->GetResourceID()));
draw.copyDestination =
m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID());
}
else if(WrappedID3D11ShaderResourceView1::IsAlloc(pLiveView))
m_ResourceUses[((WrappedID3D11ShaderResourceView1 *)pLiveView)->GetResourceResID()].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear));
{
WrappedID3D11ShaderResourceView1 *view = (WrappedID3D11ShaderResourceView1 *)pLiveView;
m_ResourceUses[view->GetResourceResID()].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear, view->GetResourceID()));
draw.copyDestination =
m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID());
}
else if(WrappedID3D11UnorderedAccessView1::IsAlloc(pLiveView))
m_ResourceUses[((WrappedID3D11UnorderedAccessView1 *)pLiveView)->GetResourceResID()].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear));
{
WrappedID3D11UnorderedAccessView1 *view = (WrappedID3D11UnorderedAccessView1 *)pLiveView;
m_ResourceUses[view->GetResourceResID()].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear, view->GetResourceID()));
draw.copyDestination =
m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID());
}
}
AddDrawcall(draw, true);
}
SAFE_DELETE_ARRAY(rects);
+16 -7
View File
@@ -6408,7 +6408,7 @@ bool WrappedID3D11DeviceContext::Serialise_ClearRenderTargetView(
draw.name = name;
draw.flags |= DrawFlags::Clear | DrawFlags::ClearColor;
AddDrawcall(draw, true);
draw.copyDestination = resID;
if(m_pDevice->GetResourceManager()->HasLiveResource(View))
{
@@ -6416,7 +6416,10 @@ bool WrappedID3D11DeviceContext::Serialise_ClearRenderTargetView(
(WrappedID3D11RenderTargetView1 *)m_pDevice->GetResourceManager()->GetLiveResource(View);
m_ResourceUses[view->GetResourceResID()].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear, view->GetResourceID()));
draw.copyDestination = m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID());
}
AddDrawcall(draw, true);
}
return true;
@@ -6589,8 +6592,7 @@ bool WrappedID3D11DeviceContext::Serialise_ClearUnorderedAccessViewUint(
draw.name = name;
draw.flags |= DrawFlags::Clear;
AddDrawcall(draw, true);
draw.copyDestination = resID;
if(m_pDevice->GetResourceManager()->HasLiveResource(View))
{
@@ -6598,7 +6600,10 @@ bool WrappedID3D11DeviceContext::Serialise_ClearUnorderedAccessViewUint(
(WrappedID3D11UnorderedAccessView1 *)m_pDevice->GetResourceManager()->GetLiveResource(View);
m_ResourceUses[view->GetResourceResID()].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear, view->GetResourceID()));
draw.copyDestination = m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID());
}
AddDrawcall(draw, true);
}
return true;
@@ -6761,8 +6766,7 @@ bool WrappedID3D11DeviceContext::Serialise_ClearUnorderedAccessViewFloat(
DrawcallDescription draw;
draw.name = (name);
draw.flags |= DrawFlags::Clear;
AddDrawcall(draw, true);
draw.copyDestination = resID;
if(m_pDevice->GetResourceManager()->HasLiveResource(View))
{
@@ -6770,7 +6774,10 @@ bool WrappedID3D11DeviceContext::Serialise_ClearUnorderedAccessViewFloat(
(WrappedID3D11UnorderedAccessView1 *)m_pDevice->GetResourceManager()->GetLiveResource(View);
m_ResourceUses[view->GetResourceResID()].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear, view->GetResourceID()));
draw.copyDestination = m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID());
}
AddDrawcall(draw, true);
}
return true;
@@ -6919,8 +6926,7 @@ bool WrappedID3D11DeviceContext::Serialise_ClearDepthStencilView(
DrawcallDescription draw;
draw.name = name;
draw.flags |= DrawFlags::Clear | DrawFlags::ClearDepthStencil;
AddDrawcall(draw, true);
draw.copyDestination = resID;
if(m_pDevice->GetResourceManager()->HasLiveResource(View))
{
@@ -6928,7 +6934,10 @@ bool WrappedID3D11DeviceContext::Serialise_ClearDepthStencilView(
(WrappedID3D11DepthStencilView *)m_pDevice->GetResourceManager()->GetLiveResource(View);
m_ResourceUses[view->GetResourceResID()].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear, view->GetResourceID()));
draw.copyDestination = m_pDevice->GetResourceManager()->GetOriginalID(view->GetResourceResID());
}
AddDrawcall(draw, true);
}
return true;
@@ -4136,14 +4136,16 @@ bool WrappedID3D12GraphicsCommandList::Serialise_ClearDepthStencilView(
m_Cmd->AddEvent(desc);
string name = "ClearDepthStencilView(" + ToStr::Get(d) + "," + ToStr::Get(s) + ")";
D3D12Descriptor *descriptor = DescriptorFromPortableHandle(GetResourceManager(), dsv);
DrawcallDescription draw;
draw.name = name;
draw.flags |= DrawFlags::Clear | DrawFlags::ClearDepthStencil;
draw.copyDestination =
GetResourceManager()->GetOriginalID(GetResID(descriptor->nonsamp.resource));
m_Cmd->AddDrawcall(draw, true);
D3D12Descriptor *descriptor = DescriptorFromPortableHandle(GetResourceManager(), dsv);
D3D12DrawcallTreeNode &drawNode = m_Cmd->GetDrawcallStack().back()->children.back();
drawNode.resourceUsage.push_back(
@@ -4223,14 +4225,16 @@ bool WrappedID3D12GraphicsCommandList::Serialise_ClearRenderTargetView(
string name = "ClearRenderTargetView(" + ToStr::Get(Color[0]) + "," + ToStr::Get(Color[1]) +
"," + ToStr::Get(Color[2]) + "," + ToStr::Get(Color[3]) + ")";
D3D12Descriptor *descriptor = DescriptorFromPortableHandle(GetResourceManager(), rtv);
DrawcallDescription draw;
draw.name = name;
draw.flags |= DrawFlags::Clear | DrawFlags::ClearColor;
draw.copyDestination =
GetResourceManager()->GetOriginalID(GetResID(descriptor->nonsamp.resource));
m_Cmd->AddDrawcall(draw, true);
D3D12Descriptor *descriptor = DescriptorFromPortableHandle(GetResourceManager(), rtv);
D3D12DrawcallTreeNode &drawNode = m_Cmd->GetDrawcallStack().back()->children.back();
drawNode.resourceUsage.push_back(
@@ -4324,6 +4328,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_ClearUnorderedAccessViewUint(
DrawcallDescription draw;
draw.name = name;
draw.flags |= DrawFlags::Clear;
draw.copyDestination = res;
m_Cmd->AddDrawcall(draw, true);
@@ -4427,6 +4432,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_ClearUnorderedAccessViewFloat(
DrawcallDescription draw;
draw.name = name;
draw.flags |= DrawFlags::Clear;
draw.copyDestination = res;
m_Cmd->AddDrawcall(draw, true);
+36 -24
View File
@@ -3100,8 +3100,6 @@ bool WrappedOpenGL::Serialise_glClearNamedFramebufferfv(GLuint framebuffer, GLen
else
draw.flags |= DrawFlags::ClearDepthStencil;
AddDrawcall(draw, true);
GLuint attachment = 0;
GLenum attachName =
buf == eGL_COLOR ? GLenum(eGL_COLOR_ATTACHMENT0 + drawbuf) : eGL_DEPTH_ATTACHMENT;
@@ -3113,13 +3111,18 @@ bool WrappedOpenGL::Serialise_glClearNamedFramebufferfv(GLuint framebuffer, GLen
if(attachment)
{
ResourceId id;
if(type == eGL_TEXTURE)
m_ResourceUses[GetResourceManager()->GetID(TextureRes(GetCtx(), attachment))].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear));
id = GetResourceManager()->GetID(TextureRes(GetCtx(), attachment));
else
m_ResourceUses[GetResourceManager()->GetID(RenderbufferRes(GetCtx(), attachment))].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear));
id = GetResourceManager()->GetID(RenderbufferRes(GetCtx(), attachment));
m_ResourceUses[id].push_back(EventUsage(m_CurEventID, ResourceUsage::Clear));
draw.copyDestination = GetResourceManager()->GetOriginalID(id);
}
AddDrawcall(draw, true);
}
return true;
@@ -3238,8 +3241,6 @@ bool WrappedOpenGL::Serialise_glClearNamedFramebufferiv(GLuint framebuffer, GLen
else
draw.flags |= DrawFlags::ClearDepthStencil;
AddDrawcall(draw, true);
GLuint attachment = 0;
GLenum attachName =
buf == eGL_COLOR ? GLenum(eGL_COLOR_ATTACHMENT0 + drawbuf) : eGL_STENCIL_ATTACHMENT;
@@ -3251,13 +3252,18 @@ bool WrappedOpenGL::Serialise_glClearNamedFramebufferiv(GLuint framebuffer, GLen
if(attachment)
{
ResourceId id;
if(type == eGL_TEXTURE)
m_ResourceUses[GetResourceManager()->GetID(TextureRes(GetCtx(), attachment))].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear));
id = GetResourceManager()->GetID(TextureRes(GetCtx(), attachment));
else
m_ResourceUses[GetResourceManager()->GetID(RenderbufferRes(GetCtx(), attachment))].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear));
id = GetResourceManager()->GetID(RenderbufferRes(GetCtx(), attachment));
m_ResourceUses[id].push_back(EventUsage(m_CurEventID, ResourceUsage::Clear));
draw.copyDestination = GetResourceManager()->GetOriginalID(id);
}
AddDrawcall(draw, true);
}
return true;
@@ -3351,8 +3357,6 @@ bool WrappedOpenGL::Serialise_glClearNamedFramebufferuiv(GLuint framebuffer, GLe
draw.name = name;
draw.flags |= DrawFlags::Clear | DrawFlags::ClearColor;
AddDrawcall(draw, true);
GLuint attachment = 0;
GLenum attachName = GLenum(eGL_COLOR_ATTACHMENT0 + drawbuf);
GLenum type = eGL_TEXTURE;
@@ -3363,13 +3367,18 @@ bool WrappedOpenGL::Serialise_glClearNamedFramebufferuiv(GLuint framebuffer, GLe
if(attachment)
{
ResourceId id;
if(type == eGL_TEXTURE)
m_ResourceUses[GetResourceManager()->GetID(TextureRes(GetCtx(), attachment))].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear));
id = GetResourceManager()->GetID(TextureRes(GetCtx(), attachment));
else
m_ResourceUses[GetResourceManager()->GetID(RenderbufferRes(GetCtx(), attachment))].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear));
id = GetResourceManager()->GetID(RenderbufferRes(GetCtx(), attachment));
m_ResourceUses[id].push_back(EventUsage(m_CurEventID, ResourceUsage::Clear));
draw.copyDestination = GetResourceManager()->GetOriginalID(id);
}
AddDrawcall(draw, true);
}
return true;
@@ -3449,8 +3458,6 @@ bool WrappedOpenGL::Serialise_glClearNamedFramebufferfi(GLuint framebuffer, GLen
draw.name = name;
draw.flags |= DrawFlags::Clear | DrawFlags::ClearDepthStencil;
AddDrawcall(draw, true);
GLuint attachment = 0;
GLenum type = eGL_TEXTURE;
m_Real.glGetNamedFramebufferAttachmentParameterivEXT(framebuffer, eGL_DEPTH_ATTACHMENT,
@@ -3461,14 +3468,19 @@ bool WrappedOpenGL::Serialise_glClearNamedFramebufferfi(GLuint framebuffer, GLen
if(attachment)
{
ResourceId id;
if(type == eGL_TEXTURE)
m_ResourceUses[GetResourceManager()->GetID(TextureRes(GetCtx(), attachment))].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear));
id = GetResourceManager()->GetID(TextureRes(GetCtx(), attachment));
else
m_ResourceUses[GetResourceManager()->GetID(RenderbufferRes(GetCtx(), attachment))].push_back(
EventUsage(m_CurEventID, ResourceUsage::Clear));
id = GetResourceManager()->GetID(RenderbufferRes(GetCtx(), attachment));
m_ResourceUses[id].push_back(EventUsage(m_CurEventID, ResourceUsage::Clear));
draw.copyDestination = GetResourceManager()->GetOriginalID(id);
}
AddDrawcall(draw, true);
attachment = 0;
type = eGL_TEXTURE;
m_Real.glGetNamedFramebufferAttachmentParameterivEXT(framebuffer, eGL_STENCIL_ATTACHMENT,
@@ -1822,6 +1822,7 @@ bool WrappedVulkan::Serialise_vkCmdClearColorImage(Serialiser *localSerialiser,
DrawcallDescription draw;
draw.name = name;
draw.flags |= DrawFlags::Clear | DrawFlags::ClearColor;
draw.copyDestination = imgid;
AddDrawcall(draw, true);
@@ -1926,6 +1927,7 @@ bool WrappedVulkan::Serialise_vkCmdClearDepthStencilImage(
DrawcallDescription draw;
draw.name = name;
draw.flags |= DrawFlags::Clear | DrawFlags::ClearDepthStencil;
draw.copyDestination = imgid;
AddDrawcall(draw, true);
+32 -34
View File
@@ -95,38 +95,27 @@ namespace renderdocui.Windows
return !(s1 == s2);
}
public static void GetDrawContext(Core core, out bool copy, out bool compute)
public static void GetDrawContext(Core core, out bool copy, out bool clear, out bool compute)
{
var curDraw = core.CurDrawcall;
copy = curDraw != null && (curDraw.flags & (DrawcallFlags.Copy | DrawcallFlags.Resolve | DrawcallFlags.Present)) != 0;
clear = curDraw != null && (curDraw.flags & DrawcallFlags.Clear) != 0;
compute = curDraw != null && (curDraw.flags & DrawcallFlags.Dispatch) != 0 &&
core.CurPipelineState.GetShader(ShaderStageType.Compute) != ResourceId.Null;
}
public int GetHighestMip(Core core)
{
var curDraw = core.CurDrawcall;
bool copy, compute;
GetDrawContext(core, out copy, out compute);
return GetBoundResource(core, arrayEl).HighestMip;
}
public int GetFirstArraySlice(Core core)
{
var curDraw = core.CurDrawcall;
bool copy, compute;
GetDrawContext(core, out copy, out compute);
return GetBoundResource(core, arrayEl).FirstSlice;
}
public FormatComponentType GetTypeHint(Core core)
{
var curDraw = core.CurDrawcall;
bool copy, compute;
GetDrawContext(core, out copy, out compute);
return GetBoundResource(core, arrayEl).typeHint;
}
@@ -185,13 +174,17 @@ namespace renderdocui.Windows
public static BoundResource[] GetOutputTargets(Core core)
{
var curDraw = core.CurDrawcall;
bool copy, compute;
GetDrawContext(core, out copy, out compute);
bool copy, clear, compute;
GetDrawContext(core, out copy, out clear, out compute);
if (copy)
if (copy || clear)
{
return new BoundResource[] { new BoundResource(curDraw.copyDestination) };
else if(compute)
}
else if (compute)
{
return new BoundResource[0];
}
else
{
var ret = core.CurPipelineState.GetOutputTargets();
@@ -213,10 +206,10 @@ namespace renderdocui.Windows
public static BoundResource GetDepthTarget(Core core)
{
var curDraw = core.CurDrawcall;
bool copy, compute;
GetDrawContext(core, out copy, out compute);
bool copy, clear, compute;
GetDrawContext(core, out copy, out clear, out compute);
if (copy || compute)
if (copy || clear || compute)
return new BoundResource(ResourceId.Null);
else
return core.CurPipelineState.GetDepthTarget();
@@ -230,10 +223,10 @@ namespace renderdocui.Windows
public static Dictionary<BindpointMap, BoundResource[]> GetReadWriteResources(Core core, ShaderStageType stage)
{
var curDraw = core.CurDrawcall;
bool copy, compute;
GetDrawContext(core, out copy, out compute);
bool copy, clear, compute;
GetDrawContext(core, out copy, out clear, out compute);
if (copy)
if (copy || clear)
{
return new Dictionary<BindpointMap, BoundResource[]>();
}
@@ -259,10 +252,15 @@ namespace renderdocui.Windows
public static Dictionary<BindpointMap, BoundResource[]> GetReadOnlyResources(Core core, ShaderStageType stage)
{
var curDraw = core.CurDrawcall;
bool copy, compute;
GetDrawContext(core, out copy, out compute);
bool copy, clear, compute;
GetDrawContext(core, out copy, out clear, out compute);
if (copy)
if (clear)
{
// no inputs for a clear
return new Dictionary<BindpointMap, BoundResource[]>();
}
else if (copy)
{
var ret = new Dictionary<BindpointMap, BoundResource[]>();
@@ -294,10 +292,10 @@ namespace renderdocui.Windows
public static ShaderReflection GetReflection(Core core, ShaderStageType stage)
{
var curDraw = core.CurDrawcall;
bool copy, compute;
GetDrawContext(core, out copy, out compute);
bool copy, clear, compute;
GetDrawContext(core, out copy, out clear, out compute);
if (copy)
if (copy || clear)
return null;
else if (compute)
return core.CurPipelineState.GetShaderReflection(ShaderStageType.Compute);
@@ -313,18 +311,18 @@ namespace renderdocui.Windows
public static ShaderBindpointMapping GetMapping(Core core, ShaderStageType stage)
{
var curDraw = core.CurDrawcall;
bool copy, compute;
GetDrawContext(core, out copy, out compute);
bool copy, clear, compute;
GetDrawContext(core, out copy, out clear, out compute);
if (copy)
if (copy || clear)
{
ShaderBindpointMapping mapping = new ShaderBindpointMapping();
mapping.ConstantBlocks = new BindpointMap[0];
mapping.ReadWriteResources = new BindpointMap[0];
mapping.InputAttributes = new int[0];
// for PS only add a single mapping to get the copy source
if (stage == ShaderStageType.Pixel)
// for copy, in PS only, add a single mapping to get the copy source
if (copy && stage == ShaderStageType.Pixel)
mapping.ReadOnlyResources = new BindpointMap[] { new BindpointMap(0, 0) };
else
mapping.ReadOnlyResources = new BindpointMap[0];