mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-10-22 01:21:00 +02:00
Some reviews on storage views
This commit is contained in:
parent
3cabafc06a
commit
51d64c298d
1 changed files with 32 additions and 3 deletions
|
|
@ -180,7 +180,7 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
|
|||
!device.IsStorageBuffer16BitAccessSupported()) {
|
||||
return false;
|
||||
}
|
||||
if (IsPixelFormatASTC(format) || VideoCore::Surface::IsPixelFormatBCn(format)) {
|
||||
if (DefaultBlockWidth(format) != 1 || DefaultBlockHeight(format) != 1) {
|
||||
return false;
|
||||
}
|
||||
if (VideoCore::Surface::GetFormatType(format) != SurfaceType::ColorTexture) {
|
||||
|
|
@ -204,6 +204,29 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
|
|||
return IsUnswizzleAcceleratedFormat(device, info.format);
|
||||
}
|
||||
|
||||
[[nodiscard]] std::array<VkFormat, 2> ShaderStorageViewFormats(PixelFormat format) {
|
||||
if (VideoCore::Surface::GetFormatType(format) != SurfaceType::ColorTexture) {
|
||||
return {};
|
||||
}
|
||||
if (DefaultBlockWidth(format) != 1 || DefaultBlockHeight(format) != 1) {
|
||||
return {};
|
||||
}
|
||||
switch (BytesPerBlock(format)) {
|
||||
case 1:
|
||||
return {VK_FORMAT_R8_UINT, VK_FORMAT_R8_SINT};
|
||||
case 2:
|
||||
return {VK_FORMAT_R16_UINT, VK_FORMAT_R16_SINT};
|
||||
case 4:
|
||||
return {VK_FORMAT_R32_UINT, VK_FORMAT_UNDEFINED};
|
||||
case 8:
|
||||
return {VK_FORMAT_R32G32_UINT, VK_FORMAT_UNDEFINED};
|
||||
case 16:
|
||||
return {VK_FORMAT_R32G32B32A32_UINT, VK_FORMAT_UNDEFINED};
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] VkImageCreateInfo MakeImageCreateInfo(const Device& device, const ImageInfo& info,
|
||||
std::optional<VkFormat> format_override = {}) {
|
||||
auto format_info =
|
||||
|
|
@ -1002,8 +1025,6 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, Scheduler& sched
|
|||
const auto image_format = static_cast<PixelFormat>(index_a);
|
||||
if (IsPixelFormatASTC(image_format) && !device.IsOptimalAstcSupported()) {
|
||||
view_formats[index_a].push_back(VK_FORMAT_A8B8G8R8_UNORM_PACK32);
|
||||
} else if (IsUnswizzleAcceleratedFormat(device, image_format)) {
|
||||
view_formats[index_a].push_back(UnswizzleStorageFormat(BytesPerBlock(image_format)));
|
||||
}
|
||||
for (size_t index_b = 0; index_b < VideoCore::Surface::MaxPixelFormat; index_b++) {
|
||||
const auto view_format = static_cast<PixelFormat>(index_b);
|
||||
|
|
@ -1013,6 +1034,14 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, Scheduler& sched
|
|||
view_formats[index_a].push_back(view_info.format);
|
||||
}
|
||||
}
|
||||
auto& formats = view_formats[index_a];
|
||||
for (const VkFormat storage_format : ShaderStorageViewFormats(image_format)) {
|
||||
if (storage_format == VK_FORMAT_UNDEFINED ||
|
||||
std::ranges::find(formats, storage_format) != formats.end()) {
|
||||
continue;
|
||||
}
|
||||
formats.push_back(storage_format);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue