|
|
@@ -112,6 +112,7 @@ void CommandBufferImpl::commandCommon()
|
|
|
|
|
|
ANKI_ASSERT(!m_finalized);
|
|
|
ANKI_ASSERT(m_handle);
|
|
|
+ m_empty = false;
|
|
|
}
|
|
|
|
|
|
//==============================================================================
|
|
|
@@ -130,7 +131,6 @@ void CommandBufferImpl::beginRenderPass(FramebufferPtr fb)
|
|
|
{
|
|
|
commandCommon();
|
|
|
ANKI_ASSERT(!insideRenderPass());
|
|
|
- m_empty = false;
|
|
|
|
|
|
m_firstRpassDrawcall = true;
|
|
|
m_activeFb = fb;
|
|
|
@@ -269,4 +269,81 @@ void CommandBufferImpl::bindResourceGroup(
|
|
|
m_rcList.pushBack(m_alloc, rc);
|
|
|
}
|
|
|
|
|
|
+//==============================================================================
|
|
|
+void CommandBufferImpl::uploadTextureSurface(TexturePtr tex,
|
|
|
+ const TextureSurfaceInfo& surf,
|
|
|
+ const TransientMemoryToken& token)
|
|
|
+{
|
|
|
+ commandCommon();
|
|
|
+ TextureImpl& impl = tex->getImplementation();
|
|
|
+
|
|
|
+ // First transition to transfer layout
|
|
|
+ VkImageSubresourceRange range;
|
|
|
+ range.aspectMask = impl.m_aspect;
|
|
|
+ switch(impl.m_type)
|
|
|
+ {
|
|
|
+ case TextureType::CUBE:
|
|
|
+ range.baseArrayLayer = surf.m_face;
|
|
|
+ break;
|
|
|
+ case TextureType::CUBE_ARRAY:
|
|
|
+ range.baseArrayLayer = surf.m_depth * impl.m_layerCount + surf.m_face;
|
|
|
+ break;
|
|
|
+ case TextureType::_2D:
|
|
|
+ range.baseArrayLayer = 0;
|
|
|
+ break;
|
|
|
+ case TextureType::_2D_ARRAY:
|
|
|
+ range.baseArrayLayer = surf.m_depth;
|
|
|
+ break;
|
|
|
+ case TextureType::_3D:
|
|
|
+ range.baseArrayLayer = surf.m_depth;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ ANKI_ASSERT(0);
|
|
|
+ }
|
|
|
+ range.baseMipLevel = surf.m_level;
|
|
|
+ range.layerCount = 1;
|
|
|
+ range.levelCount = 1;
|
|
|
+
|
|
|
+ setImageBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
|
|
+ VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT,
|
|
|
+ impl.m_optimalLayout,
|
|
|
+ VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
|
|
+ VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT,
|
|
|
+ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
|
|
+ tex,
|
|
|
+ range);
|
|
|
+
|
|
|
+ // Copy
|
|
|
+ VkBufferImageCopy region;
|
|
|
+ region.imageSubresource.aspectMask = impl.m_aspect;
|
|
|
+ region.imageSubresource.baseArrayLayer = range.baseArrayLayer;
|
|
|
+ region.imageSubresource.layerCount = 1;
|
|
|
+ region.imageSubresource.mipLevel = range.baseMipLevel;
|
|
|
+ region.imageOffset = {0, 0, 0};
|
|
|
+ region.imageExtent.width = impl.m_width;
|
|
|
+ region.imageExtent.height = impl.m_height;
|
|
|
+ region.imageExtent.depth = 0; // XXX
|
|
|
+ region.bufferOffset = token.m_offset;
|
|
|
+ region.bufferImageHeight = 0; // XXX
|
|
|
+ region.bufferRowLength = 0; // XXX
|
|
|
+
|
|
|
+ vkCmdCopyBufferToImage(m_handle,
|
|
|
+ getGrManagerImpl().getTransientMemoryManager().getBufferHandle(token),
|
|
|
+ impl.m_imageHandle,
|
|
|
+ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
|
|
+ 1,
|
|
|
+ ®ion);
|
|
|
+
|
|
|
+ // Transition back. Use the "impl.m_imageHandle" since we already hold a
|
|
|
+ // reference
|
|
|
+ setImageBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
|
|
+ VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT,
|
|
|
+ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
|
|
+ VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
|
|
+ VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT,
|
|
|
+ impl.m_optimalLayout,
|
|
|
+ impl.m_imageHandle,
|
|
|
+ range);
|
|
|
+}
|
|
|
+
|
|
|
} // end namespace anki
|