mirror of https://github.com/AxioDL/boo.git
Add clearDepth parameter to resolveBindTexture()
This commit is contained in:
parent
ed618fa8cb
commit
db82ba674b
|
@ -33,7 +33,7 @@ struct IGraphicsCommandQueue
|
|||
virtual void drawInstancesIndexed(size_t start, size_t count, size_t instCount)=0;
|
||||
|
||||
virtual void resolveBindTexture(const ObjToken<ITextureR>& texture, const SWindowRect& rect,
|
||||
bool tlOrigin, int bindIdx, bool color, bool depth)=0;
|
||||
bool tlOrigin, int bindIdx, bool color, bool depth, bool clearDepth=false)=0;
|
||||
virtual void resolveDisplay(const ObjToken<ITextureR>& source)=0;
|
||||
virtual void execute()=0;
|
||||
|
||||
|
|
|
@ -1112,7 +1112,7 @@ struct D3D11CommandQueue : IGraphicsCommandQueue
|
|||
}
|
||||
|
||||
void resolveBindTexture(const boo::ObjToken<ITextureR>& texture, const SWindowRect& rect,
|
||||
bool tlOrigin, int bindIdx, bool color, bool depth)
|
||||
bool tlOrigin, int bindIdx, bool color, bool depth, bool clearDepth)
|
||||
{
|
||||
const D3D11TextureR* tex = texture.cast<D3D11TextureR>();
|
||||
if (color && tex->m_colorBindCount)
|
||||
|
@ -1135,6 +1135,9 @@ struct D3D11CommandQueue : IGraphicsCommandQueue
|
|||
{
|
||||
m_deferredCtx->CopyResource(tex->m_depthBindTex[bindIdx].Get(), tex->m_depthTex.Get());
|
||||
}
|
||||
|
||||
if (clearDepth)
|
||||
m_deferredCtx->ClearDepthStencilView(tex->m_dsv.Get(), D3D11_CLEAR_DEPTH, 0.0f, 0);
|
||||
}
|
||||
|
||||
boo::ObjToken<ITextureR> m_doPresent;
|
||||
|
|
|
@ -1404,7 +1404,7 @@ struct D3D12CommandQueue : IGraphicsCommandQueue
|
|||
|
||||
void resolveBindTexture(const boo::ObjToken<ITextureR>& texture,
|
||||
const SWindowRect& rect, bool tlOrigin,
|
||||
int bindIdx, bool color, bool depth)
|
||||
int bindIdx, bool color, bool depth, bool clearDepth)
|
||||
{
|
||||
D3D12TextureR* tex = texture.cast<D3D12TextureR>();
|
||||
|
||||
|
@ -1468,6 +1468,12 @@ struct D3D12CommandQueue : IGraphicsCommandQueue
|
|||
};
|
||||
m_cmdList->ResourceBarrier(2, copyTeardown);
|
||||
}
|
||||
|
||||
if (clearDepth)
|
||||
{
|
||||
CD3DX12_CPU_DESCRIPTOR_HANDLE handle(tex->m_dsvHeap->GetCPUDescriptorHandleForHeapStart());
|
||||
m_cmdList->ClearDepthStencilView(handle, D3D12_CLEAR_FLAG_DEPTH, 0.0f, 0, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
bool m_doPresent = false;
|
||||
|
|
|
@ -1076,6 +1076,7 @@ struct GLCommandQueue : IGraphicsCommandQueue
|
|||
int bindIdx;
|
||||
bool resolveColor : 1;
|
||||
bool resolveDepth : 1;
|
||||
bool clearDepth : 1;
|
||||
Command(Op op) : m_op(op) {}
|
||||
Command(const Command&) = delete;
|
||||
Command& operator=(const Command&) = delete;
|
||||
|
@ -1308,6 +1309,12 @@ struct GLCommandQueue : IGraphicsCommandQueue
|
|||
cmd.viewport.rect.location[0], cmd.viewport.rect.location[1],
|
||||
cmd.viewport.rect.size[0], cmd.viewport.rect.size[1]);
|
||||
}
|
||||
if (cmd.clearDepth)
|
||||
{
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, tex->m_fbo);
|
||||
glDepthMask(GL_TRUE);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Command::Op::Present:
|
||||
|
@ -1456,7 +1463,7 @@ struct GLCommandQueue : IGraphicsCommandQueue
|
|||
}
|
||||
|
||||
void resolveBindTexture(const ObjToken<ITextureR>& texture, const SWindowRect& rect, bool tlOrigin,
|
||||
int bindIdx, bool color, bool depth)
|
||||
int bindIdx, bool color, bool depth, bool clearDepth)
|
||||
{
|
||||
GLTextureR* tex = texture.cast<GLTextureR>();
|
||||
std::vector<Command>& cmds = m_cmdBufs[m_fillBuf];
|
||||
|
@ -1465,6 +1472,7 @@ struct GLCommandQueue : IGraphicsCommandQueue
|
|||
cmds.back().bindIdx = bindIdx;
|
||||
cmds.back().resolveColor = color;
|
||||
cmds.back().resolveDepth = depth;
|
||||
cmds.back().clearDepth = clearDepth;
|
||||
SWindowRect intersectRect = rect.intersect(SWindowRect(0, 0, tex->m_width, tex->m_height));
|
||||
SWindowRect& targetRect = cmds.back().viewport.rect;
|
||||
targetRect.location[0] = intersectRect.location[0];
|
||||
|
|
|
@ -1169,7 +1169,7 @@ struct MetalCommandQueue : IGraphicsCommandQueue
|
|||
}
|
||||
|
||||
void resolveBindTexture(const ObjToken<ITextureR>& texture, const SWindowRect& rect, bool tlOrigin,
|
||||
int bindIdx, bool color, bool depth)
|
||||
int bindIdx, bool color, bool depth, bool clearDepth)
|
||||
{
|
||||
MetalTextureR* tex = texture.cast<MetalTextureR>();
|
||||
@autoreleasepool
|
||||
|
@ -1208,7 +1208,7 @@ struct MetalCommandQueue : IGraphicsCommandQueue
|
|||
}
|
||||
|
||||
[blitEnc endEncoding];
|
||||
m_enc = [m_cmdBuf renderCommandEncoderWithDescriptor:tex->m_passDesc];
|
||||
m_enc = [m_cmdBuf renderCommandEncoderWithDescriptor:clearDepth ? tex->m_clearDepthPassDesc : tex->m_passDesc];
|
||||
[m_enc setFrontFacingWinding:MTLWindingCounterClockwise];
|
||||
|
||||
if (m_boundVp.width || m_boundVp.height)
|
||||
|
|
|
@ -2791,7 +2791,7 @@ struct VulkanCommandQueue : IGraphicsCommandQueue
|
|||
|
||||
void resolveBindTexture(const boo::ObjToken<ITextureR>& texture,
|
||||
const SWindowRect& rect, bool tlOrigin,
|
||||
int bindIdx, bool color, bool depth)
|
||||
int bindIdx, bool color, bool depth, bool clearDepth)
|
||||
{
|
||||
VkCommandBuffer cmdBuf = m_cmdBufs[m_fillBuf];
|
||||
VulkanTextureR* ctexture = texture.cast<VulkanTextureR>();
|
||||
|
@ -2867,6 +2867,19 @@ struct VulkanCommandQueue : IGraphicsCommandQueue
|
|||
}
|
||||
|
||||
vk::CmdBeginRenderPass(cmdBuf, &m_boundTarget.cast<VulkanTextureR>()->m_passBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
||||
|
||||
if (clearDepth)
|
||||
{
|
||||
VkClearAttachment clr = {};
|
||||
VkClearRect rect = {};
|
||||
rect.layerCount = 1;
|
||||
rect.rect.extent.width = ctexture->m_width;
|
||||
rect.rect.extent.height = ctexture->m_height;
|
||||
|
||||
clr.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
clr.clearValue.depthStencil.depth = 1.f;
|
||||
vk::CmdClearAttachments(cmdBuf, 1, &clr, 1, &rect);
|
||||
}
|
||||
}
|
||||
|
||||
void execute();
|
||||
|
|
Loading…
Reference in New Issue