mirror of https://github.com/bkaradzic/bgfx
Fix layout transitions during series of blit (#2640)
This commit is contained in:
parent
ffa66414dc
commit
dd7fb33595
|
@ -7890,43 +7890,42 @@ VK_DESTROY
|
||||||
|
|
||||||
void RendererContextVK::submitBlit(BlitState& _bs, uint16_t _view)
|
void RendererContextVK::submitBlit(BlitState& _bs, uint16_t _view)
|
||||||
{
|
{
|
||||||
TextureHandle currentSrc = { kInvalidHandle };
|
VkImageLayout srcLayouts[BGFX_CONFIG_MAX_BLIT_ITEMS];
|
||||||
TextureHandle currentDst = { kInvalidHandle };
|
VkImageLayout dstLayouts[BGFX_CONFIG_MAX_BLIT_ITEMS];
|
||||||
VkImageLayout oldSrcLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
|
||||||
VkImageLayout oldDstLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
|
||||||
|
|
||||||
while (_bs.hasItem(_view) )
|
BlitState bs0 = _bs;
|
||||||
|
|
||||||
|
while (bs0.hasItem(_view) )
|
||||||
{
|
{
|
||||||
const BlitItem& blit = _bs.advance();
|
uint16_t item = bs0.m_item;
|
||||||
|
|
||||||
|
const BlitItem& blit = bs0.advance();
|
||||||
|
|
||||||
TextureVK& src = m_textures[blit.m_src.idx];
|
TextureVK& src = m_textures[blit.m_src.idx];
|
||||||
TextureVK& dst = m_textures[blit.m_dst.idx];
|
TextureVK& dst = m_textures[blit.m_dst.idx];
|
||||||
|
|
||||||
if (currentSrc.idx != blit.m_src.idx)
|
srcLayouts[item] = VK_NULL_HANDLE != src.m_singleMsaaImage ? src.m_currentSingleMsaaImageLayout : src.m_currentImageLayout;
|
||||||
{
|
dstLayouts[item] = dst.m_currentImageLayout;
|
||||||
if (oldSrcLayout != VK_IMAGE_LAYOUT_UNDEFINED)
|
}
|
||||||
{
|
|
||||||
TextureVK& texture = m_textures[currentSrc.idx];
|
|
||||||
texture.setImageMemoryBarrier(m_commandBuffer, oldSrcLayout, VK_NULL_HANDLE != texture.m_singleMsaaImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
oldSrcLayout = src.setImageMemoryBarrier(
|
bs0 = _bs;
|
||||||
|
|
||||||
|
while (bs0.hasItem(_view) )
|
||||||
|
{
|
||||||
|
const BlitItem& blit = bs0.advance();
|
||||||
|
|
||||||
|
TextureVK& src = m_textures[blit.m_src.idx];
|
||||||
|
TextureVK& dst = m_textures[blit.m_dst.idx];
|
||||||
|
|
||||||
|
src.setImageMemoryBarrier(
|
||||||
m_commandBuffer
|
m_commandBuffer
|
||||||
, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL
|
, blit.m_src.idx == blit.m_dst.idx ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL
|
||||||
, VK_NULL_HANDLE != src.m_singleMsaaImage
|
, VK_NULL_HANDLE != src.m_singleMsaaImage
|
||||||
);
|
);
|
||||||
currentSrc = blit.m_src;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentDst.idx != blit.m_dst.idx)
|
if (blit.m_src.idx != blit.m_dst.idx)
|
||||||
{
|
{
|
||||||
if (oldDstLayout != VK_IMAGE_LAYOUT_UNDEFINED)
|
dst.setImageMemoryBarrier(m_commandBuffer, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||||
{
|
|
||||||
m_textures[currentDst.idx].setImageMemoryBarrier(m_commandBuffer, oldDstLayout);
|
|
||||||
}
|
|
||||||
|
|
||||||
oldDstLayout = dst.setImageMemoryBarrier(m_commandBuffer, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
|
||||||
currentDst = blit.m_dst;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint16_t srcSamples = VK_NULL_HANDLE != src.m_singleMsaaImage ? 1 : src.m_sampler.Count;
|
const uint16_t srcSamples = VK_NULL_HANDLE != src.m_singleMsaaImage ? 1 : src.m_sampler.Count;
|
||||||
|
@ -7994,15 +7993,17 @@ VK_DESTROY
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldSrcLayout != VK_IMAGE_LAYOUT_UNDEFINED)
|
while (_bs.hasItem(_view) )
|
||||||
{
|
{
|
||||||
TextureVK& texture = m_textures[currentSrc.idx];
|
uint16_t item = _bs.m_item;
|
||||||
texture.setImageMemoryBarrier(m_commandBuffer, oldSrcLayout, VK_NULL_HANDLE != texture.m_singleMsaaImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldDstLayout != VK_IMAGE_LAYOUT_UNDEFINED)
|
const BlitItem& blit = _bs.advance();
|
||||||
{
|
|
||||||
m_textures[currentDst.idx].setImageMemoryBarrier(m_commandBuffer, oldDstLayout);
|
TextureVK& src = m_textures[blit.m_src.idx];
|
||||||
|
TextureVK& dst = m_textures[blit.m_dst.idx];
|
||||||
|
|
||||||
|
src.setImageMemoryBarrier(m_commandBuffer, srcLayouts[item], VK_NULL_HANDLE != src.m_singleMsaaImage);
|
||||||
|
dst.setImageMemoryBarrier(m_commandBuffer, dstLayouts[item]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue