mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-02 22:28:45 +00:00
image: Convert usage to feature flags for format support checks.
This commit is contained in:
parent
b57bbe72ee
commit
c0d0e00c1d
3 changed files with 28 additions and 5 deletions
|
@ -86,6 +86,28 @@ static vk::ImageUsageFlags ImageUsageFlags(const ImageInfo& info) {
|
||||||
return usage;
|
return usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static vk::FormatFeatureFlags2 FormatFeatureFlags(const vk::ImageUsageFlags usage_flags) {
|
||||||
|
vk::FormatFeatureFlags2 feature_flags{};
|
||||||
|
if (usage_flags & vk::ImageUsageFlagBits::eTransferSrc) {
|
||||||
|
feature_flags |= vk::FormatFeatureFlagBits2::eTransferSrc;
|
||||||
|
}
|
||||||
|
if (usage_flags & vk::ImageUsageFlagBits::eTransferDst) {
|
||||||
|
feature_flags |= vk::FormatFeatureFlagBits2::eTransferDst;
|
||||||
|
}
|
||||||
|
if (usage_flags & vk::ImageUsageFlagBits::eSampled) {
|
||||||
|
feature_flags |= vk::FormatFeatureFlagBits2::eSampledImage;
|
||||||
|
}
|
||||||
|
if (usage_flags & vk::ImageUsageFlagBits::eColorAttachment) {
|
||||||
|
feature_flags |= vk::FormatFeatureFlagBits2::eColorAttachment;
|
||||||
|
}
|
||||||
|
if (usage_flags & vk::ImageUsageFlagBits::eDepthStencilAttachment) {
|
||||||
|
feature_flags |= vk::FormatFeatureFlagBits2::eDepthStencilAttachment;
|
||||||
|
}
|
||||||
|
// Note: StorageImage is intentionally ignored for now since it is always set, and can mess up
|
||||||
|
// compatibility checks.
|
||||||
|
return feature_flags;
|
||||||
|
}
|
||||||
|
|
||||||
UniqueImage::UniqueImage(vk::Device device_, VmaAllocator allocator_)
|
UniqueImage::UniqueImage(vk::Device device_, VmaAllocator allocator_)
|
||||||
: device{device_}, allocator{allocator_} {}
|
: device{device_}, allocator{allocator_} {}
|
||||||
|
|
||||||
|
@ -132,6 +154,7 @@ Image::Image(const Vulkan::Instance& instance_, Vulkan::Scheduler& scheduler_,
|
||||||
}
|
}
|
||||||
|
|
||||||
usage = ImageUsageFlags(info);
|
usage = ImageUsageFlags(info);
|
||||||
|
format_features = FormatFeatureFlags(usage);
|
||||||
|
|
||||||
switch (info.pixel_format) {
|
switch (info.pixel_format) {
|
||||||
case vk::Format::eD16Unorm:
|
case vk::Format::eD16Unorm:
|
||||||
|
@ -149,8 +172,7 @@ Image::Image(const Vulkan::Instance& instance_, Vulkan::Scheduler& scheduler_,
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto tiling = vk::ImageTiling::eOptimal;
|
constexpr auto tiling = vk::ImageTiling::eOptimal;
|
||||||
const auto supported_format =
|
const auto supported_format = instance->GetSupportedFormat(info.pixel_format, format_features);
|
||||||
instance->GetSupportedFormat(info.pixel_format, vk::FormatFeatureFlagBits2::eSampledImage);
|
|
||||||
const auto properties = instance->GetPhysicalDevice().getImageFormatProperties(
|
const auto properties = instance->GetPhysicalDevice().getImageFormatProperties(
|
||||||
supported_format, info.type, tiling, usage, flags);
|
supported_format, info.type, tiling, usage, flags);
|
||||||
const auto supported_samples = properties.result == vk::Result::eSuccess
|
const auto supported_samples = properties.result == vk::Result::eSuccess
|
||||||
|
|
|
@ -114,6 +114,7 @@ struct Image {
|
||||||
|
|
||||||
// Resource state tracking
|
// Resource state tracking
|
||||||
vk::ImageUsageFlags usage;
|
vk::ImageUsageFlags usage;
|
||||||
|
vk::FormatFeatureFlags2 format_features;
|
||||||
struct State {
|
struct State {
|
||||||
vk::Flags<vk::PipelineStageFlagBits2> pl_stage = vk::PipelineStageFlagBits2::eAllCommands;
|
vk::Flags<vk::PipelineStageFlagBits2> pl_stage = vk::PipelineStageFlagBits2::eAllCommands;
|
||||||
vk::Flags<vk::AccessFlagBits2> access_mask = vk::AccessFlagBits2::eNone;
|
vk::Flags<vk::AccessFlagBits2> access_mask = vk::AccessFlagBits2::eNone;
|
||||||
|
|
|
@ -164,9 +164,9 @@ ImageView::ImageView(const Vulkan::Instance& instance, const ImageViewInfo& info
|
||||||
.pNext = &usage_ci,
|
.pNext = &usage_ci,
|
||||||
.image = image.image,
|
.image = image.image,
|
||||||
.viewType = info.type,
|
.viewType = info.type,
|
||||||
.format = instance.GetSupportedFormat(format, vk::FormatFeatureFlagBits2::eSampledImage),
|
.format = instance.GetSupportedFormat(format, image.format_features),
|
||||||
.components = instance.GetSupportedComponentSwizzle(
|
.components =
|
||||||
format, info.mapping, vk::FormatFeatureFlagBits2::eSampledImage),
|
instance.GetSupportedComponentSwizzle(format, info.mapping, image.format_features),
|
||||||
.subresourceRange{
|
.subresourceRange{
|
||||||
.aspectMask = aspect,
|
.aspectMask = aspect,
|
||||||
.baseMipLevel = info.range.base.level,
|
.baseMipLevel = info.range.base.level,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue