VulkanRenderer: Improve ImageAspectFlags handling
This commit is contained in:
parent
07bf924092
commit
38b143ce8f
|
|
@ -30,6 +30,7 @@ namespace Nz
|
||||||
inline VkPipelineStageFlagBits ToVulkan(PipelineStage pipelineStage);
|
inline VkPipelineStageFlagBits ToVulkan(PipelineStage pipelineStage);
|
||||||
inline VkPipelineStageFlags ToVulkan(PipelineStageFlags pipelineStages);
|
inline VkPipelineStageFlags ToVulkan(PipelineStageFlags pipelineStages);
|
||||||
inline VkFormat ToVulkan(PixelFormat pixelFormat);
|
inline VkFormat ToVulkan(PixelFormat pixelFormat);
|
||||||
|
inline VkImageAspectFlags ToVulkan(PixelFormatContent pixelFormatContent);
|
||||||
inline VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode);
|
inline VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode);
|
||||||
inline VkCompareOp ToVulkan(RendererComparison comparison);
|
inline VkCompareOp ToVulkan(RendererComparison comparison);
|
||||||
inline VkFilter ToVulkan(SamplerFilter samplerFilter);
|
inline VkFilter ToVulkan(SamplerFilter samplerFilter);
|
||||||
|
|
|
||||||
|
|
@ -272,6 +272,23 @@ namespace Nz
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VkImageAspectFlags ToVulkan(PixelFormatContent pixelFormatContent)
|
||||||
|
{
|
||||||
|
switch (pixelFormatContent)
|
||||||
|
{
|
||||||
|
case PixelFormatContent::Undefined:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PixelFormatContent::ColorRGBA: return VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
|
case PixelFormatContent::Depth: return VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||||
|
case PixelFormatContent::DepthStencil: return VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||||
|
case PixelFormatContent::Stencil: return VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
NazaraError("Unhandled PixelFormatContent 0x" + NumberToString(UnderlyingCast(pixelFormatContent), 16));
|
||||||
|
return VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
inline VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode)
|
inline VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode)
|
||||||
{
|
{
|
||||||
switch (primitiveMode)
|
switch (primitiveMode)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <Nazara/VulkanRenderer/VulkanCommandBufferBuilder.hpp>
|
#include <Nazara/VulkanRenderer/VulkanCommandBufferBuilder.hpp>
|
||||||
#include <Nazara/Core/StackArray.hpp>
|
#include <Nazara/Core/StackArray.hpp>
|
||||||
|
#include <Nazara/Utility/PixelFormat.hpp>
|
||||||
#include <Nazara/VulkanRenderer/VulkanBuffer.hpp>
|
#include <Nazara/VulkanRenderer/VulkanBuffer.hpp>
|
||||||
#include <Nazara/VulkanRenderer/VulkanRenderPass.hpp>
|
#include <Nazara/VulkanRenderer/VulkanRenderPass.hpp>
|
||||||
#include <Nazara/VulkanRenderer/VulkanRenderPipeline.hpp>
|
#include <Nazara/VulkanRenderer/VulkanRenderPipeline.hpp>
|
||||||
|
|
@ -255,6 +256,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
const VulkanTexture& vkTexture = static_cast<const VulkanTexture&>(texture);
|
const VulkanTexture& vkTexture = static_cast<const VulkanTexture&>(texture);
|
||||||
|
|
||||||
m_commandBuffer.ImageBarrier(ToVulkan(srcStageMask), ToVulkan(dstStageMask), VkDependencyFlags(0), ToVulkan(srcAccessMask), ToVulkan(dstAccessMask), ToVulkan(oldLayout), ToVulkan(newLayout), vkTexture.GetImage(), VK_IMAGE_ASPECT_COLOR_BIT);
|
VkImageAspectFlags aspectFlags = ToVulkan(PixelFormatInfo::GetContent(vkTexture.GetFormat()));
|
||||||
|
m_commandBuffer.ImageBarrier(ToVulkan(srcStageMask), ToVulkan(dstStageMask), VkDependencyFlags(0), ToVulkan(srcAccessMask), ToVulkan(dstAccessMask), ToVulkan(oldLayout), ToVulkan(newLayout), vkTexture.GetImage(), aspectFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace Nz
|
||||||
|
|
||||||
VkImageViewCreateInfo createInfoView = { VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO };
|
VkImageViewCreateInfo createInfoView = { VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO };
|
||||||
createInfoView.subresourceRange = {
|
createInfoView.subresourceRange = {
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
ToVulkan(PixelFormatInfo::GetContent(params.pixelFormat)),
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
|
|
@ -350,6 +350,29 @@ namespace Nz
|
||||||
// TODO: Fill this switch
|
// TODO: Fill this switch
|
||||||
switch (pixelFormat)
|
switch (pixelFormat)
|
||||||
{
|
{
|
||||||
|
// Regular formats
|
||||||
|
case PixelFormat::BGR8:
|
||||||
|
case PixelFormat::BGR8_SRGB:
|
||||||
|
case PixelFormat::BGRA8:
|
||||||
|
case PixelFormat::BGRA8_SRGB:
|
||||||
|
case PixelFormat::Depth16:
|
||||||
|
case PixelFormat::Depth16Stencil8:
|
||||||
|
case PixelFormat::Depth24Stencil8:
|
||||||
|
case PixelFormat::Depth32F:
|
||||||
|
case PixelFormat::Depth32FStencil8:
|
||||||
|
case PixelFormat::RGB8:
|
||||||
|
case PixelFormat::RGB8_SRGB:
|
||||||
|
case PixelFormat::RGBA8:
|
||||||
|
case PixelFormat::RGBA8_SRGB:
|
||||||
|
case PixelFormat::RGBA16F:
|
||||||
|
case PixelFormat::RGBA32F:
|
||||||
|
{
|
||||||
|
createImage.format = ToVulkan(pixelFormat);
|
||||||
|
createImageView.format = createImage.format;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// "emulated" formats
|
||||||
case PixelFormat::A8:
|
case PixelFormat::A8:
|
||||||
{
|
{
|
||||||
createImage.format = VK_FORMAT_R8_UNORM;
|
createImage.format = VK_FORMAT_R8_UNORM;
|
||||||
|
|
@ -363,62 +386,6 @@ namespace Nz
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case PixelFormat::BGR8:
|
|
||||||
case PixelFormat::BGR8_SRGB:
|
|
||||||
case PixelFormat::BGRA8:
|
|
||||||
case PixelFormat::BGRA8_SRGB:
|
|
||||||
case PixelFormat::RGB8:
|
|
||||||
case PixelFormat::RGB8_SRGB:
|
|
||||||
case PixelFormat::RGBA8:
|
|
||||||
case PixelFormat::RGBA8_SRGB:
|
|
||||||
case PixelFormat::RGBA16F:
|
|
||||||
case PixelFormat::RGBA32F:
|
|
||||||
{
|
|
||||||
createImage.format = ToVulkan(pixelFormat);
|
|
||||||
createImageView.format = createImage.format;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PixelFormat::Depth16:
|
|
||||||
{
|
|
||||||
createImage.format = VK_FORMAT_D16_UNORM;
|
|
||||||
createImageView.format = createImage.format;
|
|
||||||
createImageView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PixelFormat::Depth16Stencil8:
|
|
||||||
{
|
|
||||||
createImage.format = VK_FORMAT_D16_UNORM_S8_UINT;
|
|
||||||
createImageView.format = createImage.format;
|
|
||||||
createImageView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PixelFormat::Depth24Stencil8:
|
|
||||||
{
|
|
||||||
createImage.format = VK_FORMAT_D24_UNORM_S8_UINT;
|
|
||||||
createImageView.format = createImage.format;
|
|
||||||
createImageView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PixelFormat::Depth32F:
|
|
||||||
{
|
|
||||||
createImage.format = VK_FORMAT_D32_SFLOAT;
|
|
||||||
createImageView.format = createImage.format;
|
|
||||||
createImageView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PixelFormat::Depth32FStencil8:
|
|
||||||
{
|
|
||||||
createImage.format = VK_FORMAT_D32_SFLOAT_S8_UINT;
|
|
||||||
createImageView.format = createImage.format;
|
|
||||||
createImageView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case PixelFormat::L8:
|
case PixelFormat::L8:
|
||||||
{
|
{
|
||||||
createImage.format = VK_FORMAT_R8_UNORM;
|
createImage.format = VK_FORMAT_R8_UNORM;
|
||||||
|
|
@ -427,7 +394,7 @@ namespace Nz
|
||||||
VK_COMPONENT_SWIZZLE_R,
|
VK_COMPONENT_SWIZZLE_R,
|
||||||
VK_COMPONENT_SWIZZLE_R,
|
VK_COMPONENT_SWIZZLE_R,
|
||||||
VK_COMPONENT_SWIZZLE_R,
|
VK_COMPONENT_SWIZZLE_R,
|
||||||
VK_COMPONENT_SWIZZLE_A
|
VK_COMPONENT_SWIZZLE_ONE
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue