diff --git a/src/graphics/host_gpu/graphicContext.h b/src/graphics/host_gpu/graphicContext.h index d852c613d..5fa8d00fa 100644 --- a/src/graphics/host_gpu/graphicContext.h +++ b/src/graphics/host_gpu/graphicContext.h @@ -32,6 +32,7 @@ struct GraphicContext { bool compute_subgroup_size_control_enabled = false; bool sample_rate_shading_enabled = false; bool attachment_feedback_loop_enabled = false; + bool supports_block_texel_view = false; bool mesh_shader_enabled = false; vk::PhysicalDeviceMeshShaderPropertiesEXT mesh_shader_properties = {}; uint32_t subgroup_size = 0; diff --git a/src/graphics/host_gpu/renderer/image/image.cpp b/src/graphics/host_gpu/renderer/image/image.cpp index ade7f35ff..5b1a7bc15 100644 --- a/src/graphics/host_gpu/renderer/image/image.cpp +++ b/src/graphics/host_gpu/renderer/image/image.cpp @@ -26,12 +26,13 @@ namespace { } } -[[nodiscard]] vk::ImageCreateFlags ImageCreateFlags(const ImageInfo& info) { +[[nodiscard]] vk::ImageCreateFlags ImageCreateFlags(const GraphicContext& graphics, + const ImageInfo& info) { vk::ImageCreateFlags flags {}; if (DepthAspectTransferFormat(info.pixel_format) == vk::Format::eUndefined) { flags |= vk::ImageCreateFlagBits::eMutableFormat; flags |= vk::ImageCreateFlagBits::eExtendedUsage; - if (Prospero::BlockCompressedBytesPerBlock(info.guest_format) != 0) { + if (info.IsBlock() && graphics.supports_block_texel_view) { flags |= vk::ImageCreateFlagBits::eBlockTexelViewCompatible; } } @@ -47,6 +48,10 @@ namespace { } [[nodiscard]] vk::ImageUsageFlags ImageUsageFlags(GraphicContext& graphics, const ImageInfo& info) { + if (info.IsBlock()) { + return vk::ImageUsageFlagBits::eTransferSrc | vk::ImageUsageFlagBits::eTransferDst | + vk::ImageUsageFlagBits::eSampled; + } const auto properties = graphics.GetFormatProperties(info.pixel_format); auto usage = vk::ImageUsageFlagBits::eTransferSrc | vk::ImageUsageFlagBits::eTransferDst; if (HasFormatFeature(properties, vk::FormatFeatureFlagBits::eSampledImage)) { @@ -662,7 +667,7 @@ Image::Image(GraphicContext& graphics, CommandScheduler& scheduler, const ImageI backing.layers = info.IsVolume() ? 1u : info.resources.layers; backing.mip_levels = info.resources.levels; backing.samples = info.samples; - backing.flags = ImageCreateFlags(info); + backing.flags = ImageCreateFlags(graphics, info); backing.usage = ImageUsageFlags(graphics, info); vk::ImageCreateInfo create {}; diff --git a/src/graphics/presentation/window/vulkanWindow.cpp b/src/graphics/presentation/window/vulkanWindow.cpp index 601a3da4b..fac48fd3a 100644 --- a/src/graphics/presentation/window/vulkanWindow.cpp +++ b/src/graphics/presentation/window/vulkanWindow.cpp @@ -1120,6 +1120,18 @@ void WindowContext::CreateVulkan() { LOGF("Select device: %s\n", device_properties.deviceName.data()); + const vk::PhysicalDeviceImageFormatInfo2 block_texel_view_info { + .format = vk::Format::eBc1RgbaUnormBlock, + .type = vk::ImageType::e2D, + .tiling = vk::ImageTiling::eOptimal, + .usage = vk::ImageUsageFlagBits::eSampled, + .flags = vk::ImageCreateFlagBits::eBlockTexelViewCompatible, + }; + const auto block_texel_view_props = + graphic_ctx.physical_device.getImageFormatProperties2(block_texel_view_info); + graphic_ctx.supports_block_texel_view = block_texel_view_props.result == vk::Result::eSuccess; + LOGF("Block Texel View support: %s\n", graphic_ctx.supports_block_texel_view ? "Yes" : "No"); + { auto available_extensions = EnumerateVulkan( "vkEnumerateDeviceExtensionProperties",