When first rendering to output window backbuffer, clear it.

* This fixes a validation error which complains (rightly) that our
  renderpass writing to the backbuffer is LOAD_OP_LOAD but we haven't
  initialised the memory. So just clear to black - the contents don't
  matter as we'll just be overwriting it entirely.
This commit is contained in:
baldurk
2016-04-16 17:30:40 +02:00
parent 01a17281a9
commit 7263f97e82
2 changed files with 23 additions and 0 deletions
+21
View File
@@ -44,6 +44,8 @@ VulkanReplay::OutputWindow::OutputWindow() : wnd(NULL_WND_HANDLE), width(0), hei
for(size_t i=0; i < ARRAY_COUNT(colimg); i++)
colimg[i] = VK_NULL_HANDLE;
fresh = true;
bb = VK_NULL_HANDLE;
bbview = VK_NULL_HANDLE;
fb = VK_NULL_HANDLE;
@@ -168,6 +170,8 @@ void VulkanReplay::OutputWindow::Create(WrappedVulkan *driver, VkDevice device,
surface = oldsurf;
fresh = true;
if(surface == VK_NULL_HANDLE)
{
CreateSurface(inst);
@@ -2565,6 +2569,23 @@ void VulkanReplay::BindOutputWindow(uint64_t id, bool depth)
outw.depthBarrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
// first time rendering to the backbuffer, clear it, since our typical render pass
// is set to LOAD_OP_LOAD
if(outw.fresh)
{
outw.bbBarrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
outw.bbBarrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
DoPipelineBarrier(cmd, 1, &outw.bbBarrier);
float black[] = { 0.0f, 0.0f, 0.0f, 0.0f };
vt->CmdClearColorImage(Unwrap(cmd), Unwrap(outw.bb), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (VkClearColorValue *)black, 1, &outw.bbBarrier.subresourceRange);
outw.bbBarrier.oldLayout = outw.bbBarrier.newLayout;
outw.bbBarrier.srcAccessMask = outw.bbBarrier.dstAccessMask;
outw.fresh = false;
}
outw.bbBarrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
outw.bbBarrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
outw.colBarrier[outw.curidx].newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
+2
View File
@@ -193,6 +193,8 @@ class VulkanReplay : public IReplayDriver
WINDOW_HANDLE_DECL
bool fresh;
uint32_t width, height;
VkSurfaceKHR surface;