|
|
@@ -75,19 +75,9 @@ Error TextureImpl::init(const TextureInitInfo& init_)
|
|
|
|
|
|
m_format = init.m_format;
|
|
|
m_vkFormat = convertFormat(m_format);
|
|
|
- m_depthStencil = formatIsDepthStencil(m_format);
|
|
|
- m_aspect = convertImageAspect(m_format);
|
|
|
+ m_aspect = getImageAspectFromFormat(m_format);
|
|
|
m_usage = init.m_usage;
|
|
|
|
|
|
- if(m_aspect & VK_IMAGE_ASPECT_DEPTH_BIT)
|
|
|
- {
|
|
|
- m_akAspect |= DepthStencilAspectBit::DEPTH;
|
|
|
- }
|
|
|
- if(m_aspect & VK_IMAGE_ASPECT_STENCIL_BIT)
|
|
|
- {
|
|
|
- m_akAspect |= DepthStencilAspectBit::STENCIL;
|
|
|
- }
|
|
|
-
|
|
|
ANKI_CHECK(initImage(init));
|
|
|
|
|
|
// Init the template
|
|
|
@@ -100,7 +90,7 @@ Error TextureImpl::init(const TextureInitInfo& init_)
|
|
|
m_viewCreateInfoTemplate.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
|
|
|
m_viewCreateInfoTemplate.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
|
|
|
m_viewCreateInfoTemplate.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
|
|
|
- m_viewCreateInfoTemplate.subresourceRange.aspectMask = m_aspect;
|
|
|
+ m_viewCreateInfoTemplate.subresourceRange.aspectMask = convertImageAspect(m_aspect);
|
|
|
m_viewCreateInfoTemplate.subresourceRange.baseArrayLayer = 0;
|
|
|
m_viewCreateInfoTemplate.subresourceRange.baseMipLevel = 0;
|
|
|
m_viewCreateInfoTemplate.subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
|
|
|
@@ -117,7 +107,7 @@ Error TextureImpl::init(const TextureInitInfo& init_)
|
|
|
CommandBufferPtr cmdb = getManager().newCommandBuffer(cmdbinit);
|
|
|
|
|
|
VkImageSubresourceRange range;
|
|
|
- range.aspectMask = m_aspect;
|
|
|
+ range.aspectMask = convertImageAspect(m_aspect);
|
|
|
range.baseArrayLayer = 0;
|
|
|
range.baseMipLevel = 0;
|
|
|
range.layerCount = m_layerCount;
|
|
|
@@ -145,7 +135,7 @@ VkFormatFeatureFlags TextureImpl::calcFeatures(const TextureInitInfo& init)
|
|
|
|
|
|
if(!!(init.m_usage & TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ_WRITE))
|
|
|
{
|
|
|
- if(formatIsDepthStencil(init.m_format))
|
|
|
+ if(componentFormatIsDepthStencil(init.m_format.m_components))
|
|
|
{
|
|
|
flags |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
|
|
}
|
|
|
@@ -225,8 +215,6 @@ Error TextureImpl::initImage(const TextureInitInfo& init_)
|
|
|
m_format = init.m_format;
|
|
|
m_vkFormat = convertFormat(m_format);
|
|
|
m_workarounds = TextureImplWorkaround::S8_TO_D24S8;
|
|
|
- m_aspect = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
|
|
- m_akAspect = DepthStencilAspectBit::DEPTH | DepthStencilAspectBit::STENCIL;
|
|
|
}
|
|
|
else if(init.m_format.m_components == ComponentFormat::D24S8)
|
|
|
{
|
|
|
@@ -236,8 +224,6 @@ Error TextureImpl::initImage(const TextureInitInfo& init_)
|
|
|
m_format = init.m_format;
|
|
|
m_vkFormat = convertFormat(m_format);
|
|
|
m_workarounds = TextureImplWorkaround::D24S8_TO_D32S8;
|
|
|
- m_aspect = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
|
|
- m_akAspect = DepthStencilAspectBit::DEPTH | DepthStencilAspectBit::STENCIL;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -384,7 +370,8 @@ void TextureImpl::computeBarrierInfo(TextureUsageBit before,
|
|
|
srcAccesses = 0;
|
|
|
dstStages = 0;
|
|
|
dstAccesses = 0;
|
|
|
- Bool lastLevel = level == m_mipCount - 1u;
|
|
|
+ const Bool lastLevel = level == m_mipCount - 1u;
|
|
|
+ const Bool depthStencil = !!m_aspect;
|
|
|
|
|
|
//
|
|
|
// Before
|
|
|
@@ -433,7 +420,7 @@ void TextureImpl::computeBarrierInfo(TextureUsageBit before,
|
|
|
|
|
|
if(!!(before & TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ))
|
|
|
{
|
|
|
- if(m_depthStencil)
|
|
|
+ if(depthStencil)
|
|
|
{
|
|
|
srcStages |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
|
|
|
srcAccesses |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
|
|
|
@@ -447,7 +434,7 @@ void TextureImpl::computeBarrierInfo(TextureUsageBit before,
|
|
|
|
|
|
if(!!(before & TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE))
|
|
|
{
|
|
|
- if(m_depthStencil)
|
|
|
+ if(depthStencil)
|
|
|
{
|
|
|
srcStages |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
|
|
|
srcAccesses |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
|
|
@@ -537,7 +524,7 @@ void TextureImpl::computeBarrierInfo(TextureUsageBit before,
|
|
|
|
|
|
if(!!(after & TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ))
|
|
|
{
|
|
|
- if(m_depthStencil)
|
|
|
+ if(depthStencil)
|
|
|
{
|
|
|
dstStages |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
|
|
|
dstAccesses |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT;
|
|
|
@@ -551,7 +538,7 @@ void TextureImpl::computeBarrierInfo(TextureUsageBit before,
|
|
|
|
|
|
if(!!(after & TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE))
|
|
|
{
|
|
|
- if(m_depthStencil)
|
|
|
+ if(depthStencil)
|
|
|
{
|
|
|
dstStages |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
|
|
|
dstAccesses |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
|
|
@@ -598,7 +585,8 @@ VkImageLayout TextureImpl::computeLayout(TextureUsageBit usage, U level) const
|
|
|
ANKI_ASSERT(usageValid(usage));
|
|
|
|
|
|
VkImageLayout out = VK_IMAGE_LAYOUT_MAX_ENUM;
|
|
|
- Bool lastLevel = level == m_mipCount - 1u;
|
|
|
+ const Bool lastLevel = level == m_mipCount - 1u;
|
|
|
+ const Bool depthStencil = !!m_aspect;
|
|
|
|
|
|
if(usage == TextureUsageBit::NONE)
|
|
|
{
|
|
|
@@ -617,7 +605,7 @@ VkImageLayout TextureImpl::computeLayout(TextureUsageBit usage, U level) const
|
|
|
else if(!(usage & ~TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ_WRITE))
|
|
|
{
|
|
|
// Only FB access
|
|
|
- if(m_depthStencil)
|
|
|
+ if(depthStencil)
|
|
|
{
|
|
|
out = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
|
|
}
|
|
|
@@ -626,13 +614,13 @@ VkImageLayout TextureImpl::computeLayout(TextureUsageBit usage, U level) const
|
|
|
out = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
|
|
}
|
|
|
}
|
|
|
- else if(m_depthStencil
|
|
|
+ else if(depthStencil
|
|
|
&& !(usage & ~(TextureUsageBit::SAMPLED_ALL_GRAPHICS | TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ)))
|
|
|
{
|
|
|
// FB read & shader read
|
|
|
out = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL;
|
|
|
}
|
|
|
- else if(m_depthStencil
|
|
|
+ else if(depthStencil
|
|
|
&& !(usage & ~(TextureUsageBit::SAMPLED_ALL_GRAPHICS | TextureUsageBit::FRAMEBUFFER_ATTACHMENT_READ_WRITE)))
|
|
|
{
|
|
|
// Wild guess: One aspect is shader read and the other is read write
|
|
|
@@ -653,7 +641,7 @@ VkImageLayout TextureImpl::computeLayout(TextureUsageBit usage, U level) const
|
|
|
{
|
|
|
out = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
|
|
}
|
|
|
- else if(!m_depthStencil && usage == TextureUsageBit::TRANSFER_DESTINATION)
|
|
|
+ else if(!depthStencil && usage == TextureUsageBit::TRANSFER_DESTINATION)
|
|
|
{
|
|
|
out = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
|
|
}
|
|
|
@@ -669,7 +657,7 @@ VkImageView TextureImpl::getOrCreateSingleLevelView(U32 mip, DepthStencilAspectB
|
|
|
VkImageViewCreateInfo ci = m_viewCreateInfoTemplate;
|
|
|
ci.subresourceRange.baseMipLevel = mip;
|
|
|
ci.subresourceRange.levelCount = 1;
|
|
|
- ci.subresourceRange.aspectMask = convertAspect(aspect);
|
|
|
+ ci.subresourceRange.aspectMask = convertImageAspect(aspect);
|
|
|
|
|
|
return getOrCreateView(ci);
|
|
|
}
|
|
|
@@ -689,7 +677,7 @@ VkImageView TextureImpl::getOrCreateSingleSurfaceView(
|
|
|
VkImageView TextureImpl::getOrCreateResourceGroupView(DepthStencilAspectBit aspect) const
|
|
|
{
|
|
|
VkImageViewCreateInfo ci = m_viewCreateInfoTemplate;
|
|
|
- ci.subresourceRange.aspectMask = convertAspect(aspect);
|
|
|
+ ci.subresourceRange.aspectMask = convertImageAspect(aspect);
|
|
|
|
|
|
return getOrCreateView(ci);
|
|
|
}
|