image: drop optional create flags the driver rejects instead of aborting (#1760)

* image: request extended usage only for storage images

* tests: restore block-texel-view support through the flag check loop order

---------

Co-authored-by: nmzik <Nmzik@mail.ru>
This commit is contained in:
Arda Sahin
2026-10-22 01:56:13 +00:00
committed by GitHub
parent cb8042c5aa
commit 8502d8a77d
2 changed files with 28 additions and 6 deletions
@@ -30,16 +30,18 @@ namespace {
} }
} }
[[nodiscard]] vk::ImageCreateFlags ImageCreateFlags(const GraphicContext& graphics, [[nodiscard]] vk::ImageCreateFlags
const ImageInfo& info) { ImageCreateFlags(const GraphicContext& graphics, const ImageInfo& info, vk::ImageUsageFlags usage) {
vk::ImageCreateFlags flags {}; vk::ImageCreateFlags flags {};
if (DepthAspectTransferFormat(info.pixel_format) == vk::Format::eUndefined) { if (DepthAspectTransferFormat(info.pixel_format) == vk::Format::eUndefined) {
flags |= vk::ImageCreateFlagBits::eMutableFormat; flags |= vk::ImageCreateFlagBits::eMutableFormat;
flags |= vk::ImageCreateFlagBits::eExtendedUsage;
if (info.IsBlock() && graphics.supports_block_texel_view) { if (info.IsBlock() && graphics.supports_block_texel_view) {
flags |= vk::ImageCreateFlagBits::eBlockTexelViewCompatible; flags |= vk::ImageCreateFlagBits::eBlockTexelViewCompatible;
} }
} }
if (usage & vk::ImageUsageFlagBits::eStorage) {
flags |= vk::ImageCreateFlagBits::eExtendedUsage;
}
if (info.IsVolume()) { if (info.IsVolume()) {
flags |= vk::ImageCreateFlagBits::e2DArrayCompatible; flags |= vk::ImageCreateFlagBits::e2DArrayCompatible;
} }
@@ -59,7 +61,7 @@ namespace {
const auto storage = usage | vk::ImageUsageFlagBits::eStorage; const auto storage = usage | vk::ImageUsageFlagBits::eStorage;
if (graphics.GetImageFormatProperties(info.pixel_format, HostImageType(info.type), if (graphics.GetImageFormatProperties(info.pixel_format, HostImageType(info.type),
vk::ImageTiling::eOptimal, storage, vk::ImageTiling::eOptimal, storage,
ImageCreateFlags(graphics, info), ImageCreateFlags(graphics, info, storage),
nullptr) == vk::Result::eSuccess) { nullptr) == vk::Result::eSuccess) {
usage = storage; usage = storage;
} else { } else {
@@ -702,7 +704,8 @@ Image::Image(GraphicContext& graphics, CommandScheduler& scheduler, const ImageI
} }
vk::ImageCreateInfo create {}; vk::ImageCreateInfo create {};
create.flags = ImageCreateFlags(graphics, info); create.usage = ImageUsageFlags(graphics, info);
create.flags = ImageCreateFlags(graphics, info, create.usage);
create.imageType = HostImageType(info.type); create.imageType = HostImageType(info.type);
create.extent = info.extent; create.extent = info.extent;
create.mipLevels = info.resources.levels; create.mipLevels = info.resources.levels;
@@ -710,7 +713,6 @@ Image::Image(GraphicContext& graphics, CommandScheduler& scheduler, const ImageI
create.format = info.pixel_format; create.format = info.pixel_format;
create.tiling = vk::ImageTiling::eOptimal; create.tiling = vk::ImageTiling::eOptimal;
create.initialLayout = vk::ImageLayout::eUndefined; create.initialLayout = vk::ImageLayout::eUndefined;
create.usage = ImageUsageFlags(graphics, info);
create.samples = vulkan_sample_count(info.samples); create.samples = vulkan_sample_count(info.samples);
vk::ImageFormatProperties properties {}; vk::ImageFormatProperties properties {};
+20
View File
@@ -44928,6 +44928,26 @@ void CheckImageTransitionState(RenderContext &renderer) {
ImageTestAccess::CopyRows(copy_capacity + 4, 1, copy_capacity) == 0, ImageTestAccess::CopyRows(copy_capacity + 4, 1, copy_capacity) == 0,
"buffered image copy does not split at the fixed scratch capacity"); "buffered image copy does not split at the fixed scratch capacity");
// RADV rejects 3D 128-bit BC images with block-texel views plus extended usage.
auto volume_info = MakeInfo(vk::Format::eBc7UnormBlock, 1, 1);
volume_info.guest_format = Prospero::BufferFormat::kBc7UNorm;
volume_info.type = Prospero::ImageType::kColor3D;
volume_info.extent.depth = 4;
volume_info.bytes_per_block = 16;
for (const bool supported : {false, context.supports_block_texel_view}) {
context.supports_block_texel_view = supported;
Image volume(context, scheduler, volume_info);
const auto flags = volume.backing.flags;
Require(name, "block volume create flags",
(flags & vk::ImageCreateFlagBits::e2DArrayCompatible) &&
static_cast<bool>(flags & vk::ImageCreateFlagBits::eBlockTexelViewCompatible) ==
supported &&
static_cast<bool>(flags & vk::ImageCreateFlagBits::eExtendedUsage) ==
static_cast<bool>(volume.backing.usage &
vk::ImageUsageFlagBits::eStorage),
"block volume requested extended usage without storage");
}
Image image(context, scheduler, MakeInfo(vk::Format::eR8Unorm, 2, 3)); Image image(context, scheduler, MakeInfo(vk::Format::eR8Unorm, 2, 3));
auto barriers = auto barriers =
image.GetBarriers(vk::ImageLayout::eShaderReadOnlyOptimal, image.GetBarriers(vk::ImageLayout::eShaderReadOnlyOptimal,