[surface, vk, pipeline, texture_cache] Refactor image view handling and add normalized compatible format utility

This commit is contained in:
CamilleLaVey 2025-11-24 14:18:04 -04:00
parent 18dabbaaff
commit 6a230bec1a
5 changed files with 113 additions and 9 deletions

View file

@ -4,6 +4,8 @@
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <optional>
#include "common/common_types.h"
#include "common/math_util.h"
#include "common/settings.h"
@ -408,6 +410,39 @@ bool IsPixelFormatSignedInteger(PixelFormat format) {
}
}
std::optional<PixelFormat> NormalizedCompatibleFormat(PixelFormat format) {
switch (format) {
case PixelFormat::A8B8G8R8_UINT:
return PixelFormat::A8B8G8R8_UNORM;
case PixelFormat::A8B8G8R8_SINT:
return PixelFormat::A8B8G8R8_SNORM;
case PixelFormat::A2B10G10R10_UINT:
return PixelFormat::A2B10G10R10_UNORM;
case PixelFormat::R8_UINT:
return PixelFormat::R8_UNORM;
case PixelFormat::R8_SINT:
return PixelFormat::R8_SNORM;
case PixelFormat::R8G8_UINT:
return PixelFormat::R8G8_UNORM;
case PixelFormat::R8G8_SINT:
return PixelFormat::R8G8_SNORM;
case PixelFormat::R16_UINT:
return PixelFormat::R16_UNORM;
case PixelFormat::R16_SINT:
return PixelFormat::R16_SNORM;
case PixelFormat::R16G16_UINT:
return PixelFormat::R16G16_UNORM;
case PixelFormat::R16G16_SINT:
return PixelFormat::R16G16_SNORM;
case PixelFormat::R16G16B16A16_UINT:
return PixelFormat::R16G16B16A16_UNORM;
case PixelFormat::R16G16B16A16_SINT:
return PixelFormat::R16G16B16A16_SNORM;
default:
return std::nullopt;
}
}
size_t PixelComponentSizeBitsInteger(PixelFormat format) {
switch (format) {
case PixelFormat::A8B8G8R8_SINT: