chore: make yuzu REUSE compliant
[REUSE] is a specification that aims at making file copyright
information consistent, so that it can be both human and machine
readable. It basically requires that all files have a header containing
copyright and licensing information. When this isn't possible, like
when dealing with binary assets, generated files or embedded third-party
dependencies, it is permitted to insert copyright information in the
`.reuse/dep5` file.
Oh, and it also requires that all the licenses used in the project are
present in the `LICENSES` folder, that's why the diff is so huge.
This can be done automatically with `reuse download --all`.
The `reuse` tool also contains a handy subcommand that analyzes the
project and tells whether or not the project is (still) compliant,
`reuse lint`.
Following REUSE has a few advantages over the current approach:
- Copyright information is easy to access for users / downstream
- Files like `dist/license.md` do not need to exist anymore, as
`.reuse/dep5` is used instead
- `reuse lint` makes it easy to ensure that copyright information of
files like binary assets / images is always accurate and up to date
To add copyright information of files that didn't have it I looked up
who committed what and when, for each file. As yuzu contributors do not
have to sign a CLA or similar I couldn't assume that copyright ownership
was of the "yuzu Emulator Project", so I used the name and/or email of
the commit author instead.
[REUSE]: https://reuse.software
Follow-up to 01cf05bc75b1e47beb08937439f3ed9339e7b254
2022-05-14 19:06:02 -05:00
|
|
|
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-10-28 20:14:25 -05:00
|
|
|
|
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "common/math_util.h"
|
|
|
|
#include "video_core/surface.h"
|
|
|
|
|
|
|
|
namespace VideoCore::Surface {
|
|
|
|
|
|
|
|
SurfaceTarget SurfaceTargetFromTextureType(Tegra::Texture::TextureType texture_type) {
|
|
|
|
switch (texture_type) {
|
|
|
|
case Tegra::Texture::TextureType::Texture1D:
|
|
|
|
return SurfaceTarget::Texture1D;
|
2019-04-27 23:01:22 -05:00
|
|
|
case Tegra::Texture::TextureType::Texture1DBuffer:
|
2019-04-28 16:03:41 -05:00
|
|
|
return SurfaceTarget::TextureBuffer;
|
2018-10-28 20:14:25 -05:00
|
|
|
case Tegra::Texture::TextureType::Texture2D:
|
|
|
|
case Tegra::Texture::TextureType::Texture2DNoMipmap:
|
|
|
|
return SurfaceTarget::Texture2D;
|
|
|
|
case Tegra::Texture::TextureType::Texture3D:
|
|
|
|
return SurfaceTarget::Texture3D;
|
|
|
|
case Tegra::Texture::TextureType::TextureCubemap:
|
|
|
|
return SurfaceTarget::TextureCubemap;
|
2018-10-18 19:04:43 -05:00
|
|
|
case Tegra::Texture::TextureType::TextureCubeArray:
|
|
|
|
return SurfaceTarget::TextureCubeArray;
|
2018-10-28 20:14:25 -05:00
|
|
|
case Tegra::Texture::TextureType::Texture1DArray:
|
|
|
|
return SurfaceTarget::Texture1DArray;
|
|
|
|
case Tegra::Texture::TextureType::Texture2DArray:
|
|
|
|
return SurfaceTarget::Texture2DArray;
|
|
|
|
default:
|
2020-12-06 23:41:47 -06:00
|
|
|
LOG_CRITICAL(HW_GPU, "Unimplemented texture_type={}", texture_type);
|
2022-06-07 16:02:29 -05:00
|
|
|
ASSERT(false);
|
2018-10-28 20:14:25 -05:00
|
|
|
return SurfaceTarget::Texture2D;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SurfaceTargetIsLayered(SurfaceTarget target) {
|
|
|
|
switch (target) {
|
|
|
|
case SurfaceTarget::Texture1D:
|
2019-04-28 16:03:41 -05:00
|
|
|
case SurfaceTarget::TextureBuffer:
|
2018-10-28 20:14:25 -05:00
|
|
|
case SurfaceTarget::Texture2D:
|
|
|
|
case SurfaceTarget::Texture3D:
|
|
|
|
return false;
|
|
|
|
case SurfaceTarget::Texture1DArray:
|
|
|
|
case SurfaceTarget::Texture2DArray:
|
|
|
|
case SurfaceTarget::TextureCubemap:
|
2018-10-18 19:04:43 -05:00
|
|
|
case SurfaceTarget::TextureCubeArray:
|
2018-10-28 20:14:25 -05:00
|
|
|
return true;
|
2019-01-29 17:33:56 -06:00
|
|
|
default:
|
2020-12-06 23:41:47 -06:00
|
|
|
LOG_CRITICAL(HW_GPU, "Unimplemented surface_target={}", target);
|
2022-06-07 16:02:29 -05:00
|
|
|
ASSERT(false);
|
2019-01-29 17:33:56 -06:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SurfaceTargetIsArray(SurfaceTarget target) {
|
|
|
|
switch (target) {
|
|
|
|
case SurfaceTarget::Texture1D:
|
2019-04-28 16:03:41 -05:00
|
|
|
case SurfaceTarget::TextureBuffer:
|
2019-01-29 17:33:56 -06:00
|
|
|
case SurfaceTarget::Texture2D:
|
|
|
|
case SurfaceTarget::Texture3D:
|
|
|
|
case SurfaceTarget::TextureCubemap:
|
|
|
|
return false;
|
|
|
|
case SurfaceTarget::Texture1DArray:
|
|
|
|
case SurfaceTarget::Texture2DArray:
|
|
|
|
case SurfaceTarget::TextureCubeArray:
|
|
|
|
return true;
|
2018-10-28 20:14:25 -05:00
|
|
|
default:
|
2020-12-06 23:41:47 -06:00
|
|
|
LOG_CRITICAL(HW_GPU, "Unimplemented surface_target={}", target);
|
2022-06-07 16:02:29 -05:00
|
|
|
ASSERT(false);
|
2018-10-28 20:14:25 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PixelFormat PixelFormatFromDepthFormat(Tegra::DepthFormat format) {
|
|
|
|
switch (format) {
|
2022-08-12 04:58:09 -05:00
|
|
|
case Tegra::DepthFormat::Z24_UNORM_S8_UINT:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::S8_UINT_D24_UNORM;
|
2022-08-12 04:58:09 -05:00
|
|
|
case Tegra::DepthFormat::S8Z24_UNORM:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::D24_UNORM_S8_UINT;
|
2022-08-12 04:58:09 -05:00
|
|
|
case Tegra::DepthFormat::Z32_FLOAT:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::D32_FLOAT;
|
2022-08-12 04:58:09 -05:00
|
|
|
case Tegra::DepthFormat::Z16_UNORM:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::D16_UNORM;
|
2021-11-17 14:04:38 -06:00
|
|
|
case Tegra::DepthFormat::S8_UINT:
|
|
|
|
return PixelFormat::S8_UINT;
|
2022-08-12 04:58:09 -05:00
|
|
|
case Tegra::DepthFormat::Z32_FLOAT_X24S8_UINT:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::D32_FLOAT_S8_UINT;
|
2018-10-28 20:14:25 -05:00
|
|
|
default:
|
2020-12-06 23:41:47 -06:00
|
|
|
UNIMPLEMENTED_MSG("Unimplemented format={}", format);
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::S8_UINT_D24_UNORM;
|
2018-10-28 20:14:25 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format) {
|
|
|
|
switch (format) {
|
2022-11-06 08:19:08 -06:00
|
|
|
case Tegra::RenderTargetFormat::R32G32B32A32_FLOAT:
|
|
|
|
case Tegra::RenderTargetFormat::R32G32B32X32_FLOAT:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::R32G32B32A32_FLOAT;
|
|
|
|
case Tegra::RenderTargetFormat::R32G32B32A32_SINT:
|
2022-11-06 08:19:08 -06:00
|
|
|
case Tegra::RenderTargetFormat::R32G32B32X32_SINT:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::R32G32B32A32_SINT;
|
|
|
|
case Tegra::RenderTargetFormat::R32G32B32A32_UINT:
|
2022-11-06 08:19:08 -06:00
|
|
|
case Tegra::RenderTargetFormat::R32G32B32X32_UINT:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::R32G32B32A32_UINT;
|
|
|
|
case Tegra::RenderTargetFormat::R16G16B16A16_UNORM:
|
|
|
|
return PixelFormat::R16G16B16A16_UNORM;
|
|
|
|
case Tegra::RenderTargetFormat::R16G16B16A16_SNORM:
|
|
|
|
return PixelFormat::R16G16B16A16_SNORM;
|
|
|
|
case Tegra::RenderTargetFormat::R16G16B16A16_SINT:
|
|
|
|
return PixelFormat::R16G16B16A16_SINT;
|
|
|
|
case Tegra::RenderTargetFormat::R16G16B16A16_UINT:
|
|
|
|
return PixelFormat::R16G16B16A16_UINT;
|
|
|
|
case Tegra::RenderTargetFormat::R16G16B16A16_FLOAT:
|
|
|
|
return PixelFormat::R16G16B16A16_FLOAT;
|
|
|
|
case Tegra::RenderTargetFormat::R32G32_FLOAT:
|
|
|
|
return PixelFormat::R32G32_FLOAT;
|
|
|
|
case Tegra::RenderTargetFormat::R32G32_SINT:
|
|
|
|
return PixelFormat::R32G32_SINT;
|
|
|
|
case Tegra::RenderTargetFormat::R32G32_UINT:
|
|
|
|
return PixelFormat::R32G32_UINT;
|
|
|
|
case Tegra::RenderTargetFormat::R16G16B16X16_FLOAT:
|
|
|
|
return PixelFormat::R16G16B16X16_FLOAT;
|
2022-08-12 04:58:09 -05:00
|
|
|
case Tegra::RenderTargetFormat::A8R8G8B8_UNORM:
|
2022-11-06 04:08:22 -06:00
|
|
|
case Tegra::RenderTargetFormat::X8R8G8B8_UNORM:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::B8G8R8A8_UNORM;
|
2022-08-12 04:58:09 -05:00
|
|
|
case Tegra::RenderTargetFormat::A8R8G8B8_SRGB:
|
2022-11-06 04:08:22 -06:00
|
|
|
case Tegra::RenderTargetFormat::X8R8G8B8_SRGB:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::B8G8R8A8_SRGB;
|
|
|
|
case Tegra::RenderTargetFormat::A2B10G10R10_UNORM:
|
|
|
|
return PixelFormat::A2B10G10R10_UNORM;
|
|
|
|
case Tegra::RenderTargetFormat::A2B10G10R10_UINT:
|
|
|
|
return PixelFormat::A2B10G10R10_UINT;
|
2022-11-06 08:19:08 -06:00
|
|
|
case Tegra::RenderTargetFormat::A2R10G10B10_UNORM:
|
|
|
|
return PixelFormat::A2R10G10B10_UNORM;
|
2020-07-01 00:28:53 -05:00
|
|
|
case Tegra::RenderTargetFormat::A8B8G8R8_UNORM:
|
2022-11-06 08:19:08 -06:00
|
|
|
case Tegra::RenderTargetFormat::X8B8G8R8_UNORM:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::A8B8G8R8_UNORM;
|
|
|
|
case Tegra::RenderTargetFormat::A8B8G8R8_SRGB:
|
2022-11-06 08:19:08 -06:00
|
|
|
case Tegra::RenderTargetFormat::X8B8G8R8_SRGB:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::A8B8G8R8_SRGB;
|
|
|
|
case Tegra::RenderTargetFormat::A8B8G8R8_SNORM:
|
|
|
|
return PixelFormat::A8B8G8R8_SNORM;
|
|
|
|
case Tegra::RenderTargetFormat::A8B8G8R8_SINT:
|
|
|
|
return PixelFormat::A8B8G8R8_SINT;
|
|
|
|
case Tegra::RenderTargetFormat::A8B8G8R8_UINT:
|
|
|
|
return PixelFormat::A8B8G8R8_UINT;
|
|
|
|
case Tegra::RenderTargetFormat::R16G16_UNORM:
|
|
|
|
return PixelFormat::R16G16_UNORM;
|
|
|
|
case Tegra::RenderTargetFormat::R16G16_SNORM:
|
|
|
|
return PixelFormat::R16G16_SNORM;
|
|
|
|
case Tegra::RenderTargetFormat::R16G16_SINT:
|
|
|
|
return PixelFormat::R16G16_SINT;
|
|
|
|
case Tegra::RenderTargetFormat::R16G16_UINT:
|
|
|
|
return PixelFormat::R16G16_UINT;
|
|
|
|
case Tegra::RenderTargetFormat::R16G16_FLOAT:
|
|
|
|
return PixelFormat::R16G16_FLOAT;
|
|
|
|
case Tegra::RenderTargetFormat::B10G11R11_FLOAT:
|
|
|
|
return PixelFormat::B10G11R11_FLOAT;
|
2020-06-30 01:34:10 -05:00
|
|
|
case Tegra::RenderTargetFormat::R32_SINT:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::R32_SINT;
|
2020-06-30 01:34:10 -05:00
|
|
|
case Tegra::RenderTargetFormat::R32_UINT:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::R32_UINT;
|
2020-06-30 01:34:10 -05:00
|
|
|
case Tegra::RenderTargetFormat::R32_FLOAT:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::R32_FLOAT;
|
|
|
|
case Tegra::RenderTargetFormat::R5G6B5_UNORM:
|
|
|
|
return PixelFormat::R5G6B5_UNORM;
|
|
|
|
case Tegra::RenderTargetFormat::A1R5G5B5_UNORM:
|
2022-11-06 08:19:08 -06:00
|
|
|
case Tegra::RenderTargetFormat::X1R5G5B5_UNORM:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::A1R5G5B5_UNORM;
|
|
|
|
case Tegra::RenderTargetFormat::R8G8_UNORM:
|
|
|
|
return PixelFormat::R8G8_UNORM;
|
|
|
|
case Tegra::RenderTargetFormat::R8G8_SNORM:
|
|
|
|
return PixelFormat::R8G8_SNORM;
|
|
|
|
case Tegra::RenderTargetFormat::R8G8_SINT:
|
|
|
|
return PixelFormat::R8G8_SINT;
|
|
|
|
case Tegra::RenderTargetFormat::R8G8_UINT:
|
|
|
|
return PixelFormat::R8G8_UINT;
|
2018-10-28 20:14:25 -05:00
|
|
|
case Tegra::RenderTargetFormat::R16_UNORM:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::R16_UNORM;
|
2018-10-28 20:14:25 -05:00
|
|
|
case Tegra::RenderTargetFormat::R16_SNORM:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::R16_SNORM;
|
2018-10-28 20:14:25 -05:00
|
|
|
case Tegra::RenderTargetFormat::R16_SINT:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::R16_SINT;
|
2020-06-30 01:34:10 -05:00
|
|
|
case Tegra::RenderTargetFormat::R16_UINT:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::R16_UINT;
|
2020-06-30 01:34:10 -05:00
|
|
|
case Tegra::RenderTargetFormat::R16_FLOAT:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::R16_FLOAT;
|
2020-06-30 01:34:10 -05:00
|
|
|
case Tegra::RenderTargetFormat::R8_UNORM:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::R8_UNORM;
|
2020-06-30 01:51:42 -05:00
|
|
|
case Tegra::RenderTargetFormat::R8_SNORM:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::R8_SNORM;
|
2020-06-30 02:00:23 -05:00
|
|
|
case Tegra::RenderTargetFormat::R8_SINT:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::R8_SINT;
|
2020-06-30 01:34:10 -05:00
|
|
|
case Tegra::RenderTargetFormat::R8_UINT:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::R8_UINT;
|
2018-10-28 20:14:25 -05:00
|
|
|
default:
|
2020-12-06 23:41:47 -06:00
|
|
|
UNIMPLEMENTED_MSG("Unimplemented format={}", format);
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::A8B8G8R8_UNORM;
|
2018-10-28 20:14:25 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-19 23:51:16 -05:00
|
|
|
PixelFormat PixelFormatFromGPUPixelFormat(Service::android::PixelFormat format) {
|
2018-10-28 20:14:25 -05:00
|
|
|
switch (format) {
|
2022-03-19 23:51:16 -05:00
|
|
|
case Service::android::PixelFormat::Rgba8888:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::A8B8G8R8_UNORM;
|
2022-03-19 23:51:16 -05:00
|
|
|
case Service::android::PixelFormat::Rgb565:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::R5G6B5_UNORM;
|
2022-03-19 23:51:16 -05:00
|
|
|
case Service::android::PixelFormat::Bgra8888:
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::B8G8R8A8_UNORM;
|
2018-10-28 20:14:25 -05:00
|
|
|
default:
|
2020-12-06 23:41:47 -06:00
|
|
|
UNIMPLEMENTED_MSG("Unimplemented format={}", format);
|
2020-07-01 00:28:53 -05:00
|
|
|
return PixelFormat::A8B8G8R8_UNORM;
|
2018-10-28 20:14:25 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SurfaceType GetFormatType(PixelFormat pixel_format) {
|
2022-11-28 19:25:41 -06:00
|
|
|
if (pixel_format < PixelFormat::MaxColorFormat) {
|
2018-10-28 20:14:25 -05:00
|
|
|
return SurfaceType::ColorTexture;
|
|
|
|
}
|
2022-11-28 19:25:41 -06:00
|
|
|
if (pixel_format < PixelFormat::MaxDepthFormat) {
|
2018-10-28 20:14:25 -05:00
|
|
|
return SurfaceType::Depth;
|
|
|
|
}
|
2022-11-28 19:25:41 -06:00
|
|
|
if (pixel_format < PixelFormat::MaxStencilFormat) {
|
2021-11-17 14:04:38 -06:00
|
|
|
return SurfaceType::Stencil;
|
|
|
|
}
|
2022-11-28 19:25:41 -06:00
|
|
|
if (pixel_format < PixelFormat::MaxDepthStencilFormat) {
|
2018-10-28 20:14:25 -05:00
|
|
|
return SurfaceType::DepthStencil;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(Subv): Implement the other formats
|
|
|
|
ASSERT(false);
|
|
|
|
|
|
|
|
return SurfaceType::Invalid;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsPixelFormatASTC(PixelFormat format) {
|
|
|
|
switch (format) {
|
2020-07-01 00:28:53 -05:00
|
|
|
case PixelFormat::ASTC_2D_4X4_UNORM:
|
|
|
|
case PixelFormat::ASTC_2D_5X4_UNORM:
|
|
|
|
case PixelFormat::ASTC_2D_5X5_UNORM:
|
|
|
|
case PixelFormat::ASTC_2D_8X8_UNORM:
|
|
|
|
case PixelFormat::ASTC_2D_8X5_UNORM:
|
2018-10-28 20:14:25 -05:00
|
|
|
case PixelFormat::ASTC_2D_4X4_SRGB:
|
|
|
|
case PixelFormat::ASTC_2D_5X4_SRGB:
|
2018-10-29 21:46:09 -05:00
|
|
|
case PixelFormat::ASTC_2D_5X5_SRGB:
|
2018-10-28 20:14:25 -05:00
|
|
|
case PixelFormat::ASTC_2D_8X8_SRGB:
|
|
|
|
case PixelFormat::ASTC_2D_8X5_SRGB:
|
2020-07-01 00:28:53 -05:00
|
|
|
case PixelFormat::ASTC_2D_10X8_UNORM:
|
2018-11-12 20:34:54 -06:00
|
|
|
case PixelFormat::ASTC_2D_10X8_SRGB:
|
2020-07-01 00:28:53 -05:00
|
|
|
case PixelFormat::ASTC_2D_6X6_UNORM:
|
2019-10-02 18:00:16 -05:00
|
|
|
case PixelFormat::ASTC_2D_6X6_SRGB:
|
2022-06-30 21:04:23 -05:00
|
|
|
case PixelFormat::ASTC_2D_10X6_UNORM:
|
2023-05-02 14:43:24 -05:00
|
|
|
case PixelFormat::ASTC_2D_10X6_SRGB:
|
2022-10-06 09:45:40 -05:00
|
|
|
case PixelFormat::ASTC_2D_10X5_UNORM:
|
|
|
|
case PixelFormat::ASTC_2D_10X5_SRGB:
|
2020-07-01 00:28:53 -05:00
|
|
|
case PixelFormat::ASTC_2D_10X10_UNORM:
|
2019-10-02 18:00:16 -05:00
|
|
|
case PixelFormat::ASTC_2D_10X10_SRGB:
|
2023-05-02 14:43:24 -05:00
|
|
|
case PixelFormat::ASTC_2D_12X10_UNORM:
|
|
|
|
case PixelFormat::ASTC_2D_12X10_SRGB:
|
2020-07-01 00:28:53 -05:00
|
|
|
case PixelFormat::ASTC_2D_12X12_UNORM:
|
2019-10-02 18:00:16 -05:00
|
|
|
case PixelFormat::ASTC_2D_12X12_SRGB:
|
2020-07-01 00:28:53 -05:00
|
|
|
case PixelFormat::ASTC_2D_8X6_UNORM:
|
2019-10-02 18:00:16 -05:00
|
|
|
case PixelFormat::ASTC_2D_8X6_SRGB:
|
2020-07-01 00:28:53 -05:00
|
|
|
case PixelFormat::ASTC_2D_6X5_UNORM:
|
2019-10-02 18:00:16 -05:00
|
|
|
case PixelFormat::ASTC_2D_6X5_SRGB:
|
2018-10-28 20:14:25 -05:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-12 22:17:26 -05:00
|
|
|
bool IsPixelFormatSRGB(PixelFormat format) {
|
|
|
|
switch (format) {
|
2020-07-01 00:28:53 -05:00
|
|
|
case PixelFormat::A8B8G8R8_SRGB:
|
|
|
|
case PixelFormat::B8G8R8A8_SRGB:
|
|
|
|
case PixelFormat::BC1_RGBA_SRGB:
|
|
|
|
case PixelFormat::BC2_SRGB:
|
|
|
|
case PixelFormat::BC3_SRGB:
|
|
|
|
case PixelFormat::BC7_SRGB:
|
2019-09-12 22:17:26 -05:00
|
|
|
case PixelFormat::ASTC_2D_4X4_SRGB:
|
|
|
|
case PixelFormat::ASTC_2D_8X8_SRGB:
|
|
|
|
case PixelFormat::ASTC_2D_8X5_SRGB:
|
|
|
|
case PixelFormat::ASTC_2D_5X4_SRGB:
|
|
|
|
case PixelFormat::ASTC_2D_5X5_SRGB:
|
2023-05-02 14:43:24 -05:00
|
|
|
case PixelFormat::ASTC_2D_10X6_SRGB:
|
2019-09-12 22:17:26 -05:00
|
|
|
case PixelFormat::ASTC_2D_10X8_SRGB:
|
2019-10-02 18:00:16 -05:00
|
|
|
case PixelFormat::ASTC_2D_6X6_SRGB:
|
2022-10-06 09:45:40 -05:00
|
|
|
case PixelFormat::ASTC_2D_10X5_SRGB:
|
2019-10-02 18:00:16 -05:00
|
|
|
case PixelFormat::ASTC_2D_10X10_SRGB:
|
|
|
|
case PixelFormat::ASTC_2D_12X12_SRGB:
|
2023-05-02 14:43:24 -05:00
|
|
|
case PixelFormat::ASTC_2D_12X10_SRGB:
|
2019-10-02 18:00:16 -05:00
|
|
|
case PixelFormat::ASTC_2D_8X6_SRGB:
|
|
|
|
case PixelFormat::ASTC_2D_6X5_SRGB:
|
2019-09-12 22:17:26 -05:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-18 19:50:00 -05:00
|
|
|
bool IsPixelFormatInteger(PixelFormat format) {
|
|
|
|
switch (format) {
|
|
|
|
case PixelFormat::A8B8G8R8_SINT:
|
|
|
|
case PixelFormat::A8B8G8R8_UINT:
|
|
|
|
case PixelFormat::A2B10G10R10_UINT:
|
|
|
|
case PixelFormat::R8_SINT:
|
|
|
|
case PixelFormat::R8_UINT:
|
|
|
|
case PixelFormat::R16G16B16A16_SINT:
|
|
|
|
case PixelFormat::R16G16B16A16_UINT:
|
|
|
|
case PixelFormat::R32G32B32A32_UINT:
|
|
|
|
case PixelFormat::R32G32B32A32_SINT:
|
|
|
|
case PixelFormat::R32G32_SINT:
|
|
|
|
case PixelFormat::R16_UINT:
|
|
|
|
case PixelFormat::R16_SINT:
|
|
|
|
case PixelFormat::R16G16_UINT:
|
|
|
|
case PixelFormat::R16G16_SINT:
|
|
|
|
case PixelFormat::R8G8_SINT:
|
|
|
|
case PixelFormat::R8G8_UINT:
|
|
|
|
case PixelFormat::R32G32_UINT:
|
|
|
|
case PixelFormat::R32_UINT:
|
|
|
|
case PixelFormat::R32_SINT:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-19 12:41:57 -05:00
|
|
|
bool IsPixelFormatSignedInteger(PixelFormat format) {
|
|
|
|
switch (format) {
|
|
|
|
case PixelFormat::A8B8G8R8_SINT:
|
|
|
|
case PixelFormat::R8_SINT:
|
|
|
|
case PixelFormat::R16G16B16A16_SINT:
|
|
|
|
case PixelFormat::R32G32B32A32_SINT:
|
|
|
|
case PixelFormat::R32G32_SINT:
|
|
|
|
case PixelFormat::R16_SINT:
|
|
|
|
case PixelFormat::R16G16_SINT:
|
|
|
|
case PixelFormat::R8G8_SINT:
|
|
|
|
case PixelFormat::R32_SINT:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t PixelComponentSizeBitsInteger(PixelFormat format) {
|
|
|
|
switch (format) {
|
|
|
|
case PixelFormat::A8B8G8R8_SINT:
|
|
|
|
case PixelFormat::A8B8G8R8_UINT:
|
|
|
|
case PixelFormat::R8_SINT:
|
|
|
|
case PixelFormat::R8_UINT:
|
|
|
|
case PixelFormat::R8G8_SINT:
|
|
|
|
case PixelFormat::R8G8_UINT:
|
|
|
|
return 8;
|
|
|
|
case PixelFormat::A2B10G10R10_UINT:
|
|
|
|
return 10;
|
|
|
|
case PixelFormat::R16G16B16A16_SINT:
|
|
|
|
case PixelFormat::R16G16B16A16_UINT:
|
|
|
|
case PixelFormat::R16_UINT:
|
|
|
|
case PixelFormat::R16_SINT:
|
|
|
|
case PixelFormat::R16G16_UINT:
|
|
|
|
case PixelFormat::R16G16_SINT:
|
|
|
|
return 16;
|
|
|
|
case PixelFormat::R32G32B32A32_UINT:
|
|
|
|
case PixelFormat::R32G32B32A32_SINT:
|
|
|
|
case PixelFormat::R32G32_SINT:
|
|
|
|
case PixelFormat::R32G32_UINT:
|
|
|
|
case PixelFormat::R32_UINT:
|
|
|
|
case PixelFormat::R32_SINT:
|
|
|
|
return 32;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-28 20:14:25 -05:00
|
|
|
std::pair<u32, u32> GetASTCBlockSize(PixelFormat format) {
|
2020-12-29 23:25:23 -06:00
|
|
|
return {DefaultBlockWidth(format), DefaultBlockHeight(format)};
|
2018-10-28 20:14:25 -05:00
|
|
|
}
|
|
|
|
|
2021-06-14 06:42:22 -05:00
|
|
|
u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format) {
|
|
|
|
constexpr u64 RGBA8_PIXEL_SIZE = 4;
|
|
|
|
const u64 base_block_size = static_cast<u64>(DefaultBlockWidth(format)) *
|
|
|
|
static_cast<u64>(DefaultBlockHeight(format)) * RGBA8_PIXEL_SIZE;
|
|
|
|
return (base_size * base_block_size) / BytesPerBlock(format);
|
|
|
|
}
|
|
|
|
|
2018-10-28 20:14:25 -05:00
|
|
|
} // namespace VideoCore::Surface
|