GPUDevice: Rename RGBA5551 to RGB5A1

And fix the incorrect format for Vulkan.
This commit is contained in:
Stenzek 2024-11-30 14:31:50 +10:00
parent dfacf9e8db
commit fa4dc381ed
No known key found for this signature in database
10 changed files with 76 additions and 76 deletions

View File

@ -41,10 +41,10 @@ bool GPU_SW::Initialize(Error* error)
if (!GPU::Initialize(error) || !m_backend.Initialize(g_settings.gpu_use_thread))
return false;
static constexpr const std::array formats_for_16bit = {GPUTexture::Format::RGB565, GPUTexture::Format::RGBA5551,
static constexpr const std::array formats_for_16bit = {GPUTexture::Format::RGB565, GPUTexture::Format::RGB5A1,
GPUTexture::Format::RGBA8, GPUTexture::Format::BGRA8};
static constexpr const std::array formats_for_24bit = {GPUTexture::Format::RGBA8, GPUTexture::Format::BGRA8,
GPUTexture::Format::RGB565, GPUTexture::Format::RGBA5551};
GPUTexture::Format::RGB565, GPUTexture::Format::RGB5A1};
for (const GPUTexture::Format format : formats_for_16bit)
{
if (g_gpu_device->SupportsTextureFormat(format))
@ -115,7 +115,7 @@ template<GPUTexture::Format out_format, typename out_type>
static out_type VRAM16ToOutput(u16 value);
template<>
ALWAYS_INLINE u16 VRAM16ToOutput<GPUTexture::Format::RGBA5551, u16>(u16 value)
ALWAYS_INLINE u16 VRAM16ToOutput<GPUTexture::Format::RGB5A1, u16>(u16 value)
{
return (value & 0x3E0) | ((value >> 10) & 0x1F) | ((value & 0x1F) << 10);
}
@ -148,7 +148,7 @@ ALWAYS_INLINE u32 VRAM16ToOutput<GPUTexture::Format::BGRA8, u32>(u16 value)
}
template<>
ALWAYS_INLINE void CopyOutRow16<GPUTexture::Format::RGBA5551, u16>(const u16* src_ptr, u16* dst_ptr, u32 width)
ALWAYS_INLINE void CopyOutRow16<GPUTexture::Format::RGB5A1, u16>(const u16* src_ptr, u16* dst_ptr, u32 width)
{
u32 col = 0;
@ -167,7 +167,7 @@ ALWAYS_INLINE void CopyOutRow16<GPUTexture::Format::RGBA5551, u16>(const u16* sr
}
for (; col < width; col++)
*(dst_ptr++) = VRAM16ToOutput<GPUTexture::Format::RGBA5551, u16>(*(src_ptr++));
*(dst_ptr++) = VRAM16ToOutput<GPUTexture::Format::RGB5A1, u16>(*(src_ptr++));
}
template<>
@ -317,7 +317,7 @@ ALWAYS_INLINE_RELEASE bool GPU_SW::CopyOut24Bit(u32 src_x, u32 src_y, u32 skip_x
src_row_ptr += 3;
}
}
else if constexpr (display_format == GPUTexture::Format::RGBA5551)
else if constexpr (display_format == GPUTexture::Format::RGB5A1)
{
const u8* src_row_ptr = src_ptr;
u16* dst_row_ptr = reinterpret_cast<u16*>(dst_ptr);
@ -362,7 +362,7 @@ ALWAYS_INLINE_RELEASE bool GPU_SW::CopyOut24Bit(u32 src_x, u32 src_y, u32 skip_x
{
*(dst_row_ptr++) = ((rgb >> 3) & 0x1F) | (((rgb >> 10) << 5) & 0x7E0) | (((rgb >> 19) << 11) & 0x3E0000);
}
else if constexpr (display_format == GPUTexture::Format::RGBA5551)
else if constexpr (display_format == GPUTexture::Format::RGB5A1)
{
*(dst_row_ptr++) = ((rgb >> 3) & 0x1F) | (((rgb >> 11) << 5) & 0x3E0) | (((rgb >> 19) << 10) & 0x1F0000);
}
@ -389,8 +389,8 @@ bool GPU_SW::CopyOut(u32 src_x, u32 src_y, u32 skip_x, u32 width, u32 height, u3
switch (m_16bit_display_format)
{
case GPUTexture::Format::RGBA5551:
return CopyOut15Bit<GPUTexture::Format::RGBA5551>(src_x, src_y, width, height, line_skip);
case GPUTexture::Format::RGB5A1:
return CopyOut15Bit<GPUTexture::Format::RGB5A1>(src_x, src_y, width, height, line_skip);
case GPUTexture::Format::RGB565:
return CopyOut15Bit<GPUTexture::Format::RGB565>(src_x, src_y, width, height, line_skip);
@ -409,8 +409,8 @@ bool GPU_SW::CopyOut(u32 src_x, u32 src_y, u32 skip_x, u32 width, u32 height, u3
{
switch (m_24bit_display_format)
{
case GPUTexture::Format::RGBA5551:
return CopyOut24Bit<GPUTexture::Format::RGBA5551>(src_x, src_y, skip_x, width, height, line_skip);
case GPUTexture::Format::RGB5A1:
return CopyOut24Bit<GPUTexture::Format::RGB5A1>(src_x, src_y, skip_x, width, height, line_skip);
case GPUTexture::Format::RGB565:
return CopyOut24Bit<GPUTexture::Format::RGB565>(src_x, src_y, skip_x, width, height, line_skip);

View File

@ -629,7 +629,7 @@ static constexpr std::array<D3DCommon::DXGIFormatMapping, static_cast<int>(GPUTe
{DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN }, // RGBA8
{DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN }, // BGRA8
{DXGI_FORMAT_B5G6R5_UNORM, DXGI_FORMAT_B5G6R5_UNORM, DXGI_FORMAT_B5G6R5_UNORM, DXGI_FORMAT_UNKNOWN }, // RGB565
{DXGI_FORMAT_B5G5R5A1_UNORM, DXGI_FORMAT_B5G5R5A1_UNORM, DXGI_FORMAT_B5G5R5A1_UNORM, DXGI_FORMAT_UNKNOWN }, // RGBA5551
{DXGI_FORMAT_B5G5R5A1_UNORM, DXGI_FORMAT_B5G5R5A1_UNORM, DXGI_FORMAT_B5G5R5A1_UNORM, DXGI_FORMAT_UNKNOWN }, // RGB5A1
{DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_UNKNOWN }, // R8
{DXGI_FORMAT_R16_TYPELESS, DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D16_UNORM }, // D16
{DXGI_FORMAT_R24G8_TYPELESS, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, DXGI_FORMAT_R24_UNORM_X8_TYPELESS, DXGI_FORMAT_D24_UNORM_S8_UINT }, // D24S8

View File

@ -30,7 +30,7 @@ const char* GPUTexture::GetFormatName(Format format)
"RGBA8", // RGBA8
"BGRA8", // BGRA8
"RGB565", // RGB565
"RGB5551", // RGBA5551
"RGB5A1", // RGB5A1
"R8", // R8
"D16", // D16
"D24S8", // D24S8
@ -151,7 +151,7 @@ GPUTexture::Format GPUTexture::GetTextureFormatForImageFormat(ImageFormat format
Format::RGBA8, // RGBA8
Format::BGRA8, // BGRA8
Format::RGB565, // RGB565
Format::RGBA5551, // RGBA5551
Format::RGB5A1, // RGB5A1
Format::Unknown, // BGR8
Format::BC1, // BC1
Format::BC2, // BC2
@ -170,7 +170,7 @@ ImageFormat GPUTexture::GetImageFormatForTextureFormat(Format format)
ImageFormat::RGBA8, // RGBA8
ImageFormat::BGRA8, // BGRA8
ImageFormat::RGB565, // RGB565
ImageFormat::RGBA5551, // RGBA5551
ImageFormat::RGB5A1, // RGB5A1
ImageFormat::None, // R8
ImageFormat::None, // D16
ImageFormat::None, // D24S8
@ -252,7 +252,7 @@ u32 GPUTexture::GetPixelSize(GPUTexture::Format format)
4, // RGBA8
4, // BGRA8
2, // RGB565
2, // RGBA5551
2, // RGB5A1
1, // R8
2, // D16
4, // D24S8

View File

@ -40,7 +40,7 @@ public:
RGBA8,
BGRA8,
RGB565,
RGBA5551,
RGB5A1,
R8,
D16,
D24S8,

View File

@ -167,7 +167,7 @@ const char* Image::GetFormatName(ImageFormat format)
"RGBA8", // RGBA8
"BGRA8", // BGRA8
"RGB565", // RGB565
"RGB5551", // RGBA5551
"RGB5A1", // RGB5A1
"BGR8", // BGR8
"BC1", // BC1
"BC2", // BC2
@ -186,7 +186,7 @@ u32 Image::GetPixelSize(ImageFormat format)
4, // RGBA8
4, // BGRA8
2, // RGB565
2, // RGBA5551
2, // RGB5A1
3, // BGR8
8, // BC1 - 16 pixels in 64 bits
16, // BC2 - 16 pixels in 128 bits
@ -298,7 +298,7 @@ bool Image::SetAllPixelsOpaque()
return true;
}
else if (m_format == ImageFormat::RGBA5551)
else if (m_format == ImageFormat::RGB5A1)
{
for (u32 y = 0; y < m_height; y++)
{
@ -604,7 +604,7 @@ std::optional<Image> Image::ConvertToRGBA8(Error* error) const
}
break;
case ImageFormat::RGBA5551:
case ImageFormat::RGB5A1:
{
ret = Image(m_width, m_height, ImageFormat::RGBA8);
for (u32 y = 0; y < m_height; y++)
@ -614,7 +614,7 @@ std::optional<Image> Image::ConvertToRGBA8(Error* error) const
for (u32 x = 0; x < m_width; x++)
{
// RGBA5551 -> RGBA8
// RGB5A1 -> RGBA8
u16 pixel_in;
std::memcpy(&pixel_in, pixels_in, sizeof(u16));
pixels_in += sizeof(u16);

View File

@ -20,7 +20,7 @@ enum class ImageFormat : u8
RGBA8,
BGRA8,
RGB565,
RGBA5551,
RGB5A1,
BGR8,
BC1,
BC2,

View File

@ -50,7 +50,7 @@ static constexpr std::array<MTLPixelFormat, static_cast<u32>(GPUTexture::Format:
MTLPixelFormatRGBA8Unorm, // RGBA8
MTLPixelFormatBGRA8Unorm, // BGRA8
MTLPixelFormatB5G6R5Unorm, // RGB565
MTLPixelFormatA1BGR5Unorm, // RGBA5551
MTLPixelFormatA1BGR5Unorm, // RGB5A1
MTLPixelFormatR8Unorm, // R8
MTLPixelFormatDepth16Unorm, // D16
MTLPixelFormatDepth24Unorm_Stencil8, // D24S8
@ -1490,7 +1490,7 @@ std::unique_ptr<GPUSampler> MetalDevice::CreateSampler(const GPUSampler::Config&
bool MetalDevice::SupportsTextureFormat(GPUTexture::Format format) const
{
if (format == GPUTexture::Format::RGB565 || format == GPUTexture::Format::RGBA5551)
if (format == GPUTexture::Format::RGB565 || format == GPUTexture::Format::RGB5A1)
{
// These formats require an Apple Silicon GPU.
// See https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf

View File

@ -423,7 +423,7 @@ bool OpenGLContextEGL::CheckConfigSurfaceFormat(EGLConfig config, GPUTexture::Fo
case GPUTexture::Format::RGB565:
return (red_size == 5 && green_size == 6 && blue_size == 5);
case GPUTexture::Format::RGBA5551:
case GPUTexture::Format::RGB5A1:
return (red_size == 5 && green_size == 5 && blue_size == 5 && alpha_size == 1);
case GPUTexture::Format::Unknown:
@ -461,7 +461,7 @@ void OpenGLContextEGL::UpdateWindowInfoSize(WindowInfo& wi, EGLSurface surface)
}
else if (red_size == 5 && green_size == 5 && blue_size == 5 && alpha_size == 1)
{
wi.surface_format = GPUTexture::Format::RGBA5551;
wi.surface_format = GPUTexture::Format::RGB5A1;
}
else if (red_size == 8 && green_size == 8 && blue_size == 8 && alpha_size == 8)
{

View File

@ -37,7 +37,7 @@ const std::tuple<GLenum, GLenum, GLenum>& OpenGLTexture::GetPixelFormatMapping(G
{GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE}, // RGBA8
{GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE}, // BGRA8
{GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5}, // RGB565
{GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV}, // RGBA5551
{GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV}, // RGB5A1
{GL_R8, GL_RED, GL_UNSIGNED_BYTE}, // R8
{GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_SHORT}, // D16
{GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT}, // D24S8
@ -71,7 +71,7 @@ const std::tuple<GLenum, GLenum, GLenum>& OpenGLTexture::GetPixelFormatMapping(G
{GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE}, // RGBA8
{GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE}, // BGRA8
{GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5}, // RGB565
{GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV}, // RGBA5551
{GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV}, // RGB5A1
{GL_R8, GL_RED, GL_UNSIGNED_BYTE}, // R8
{GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_SHORT}, // D16
{GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT}, // D24S8

View File

@ -75,7 +75,7 @@ const std::array<VkFormat, static_cast<u32>(GPUTexture::Format::MaxCount)> Vulka
VK_FORMAT_R8G8B8A8_UNORM, // RGBA8
VK_FORMAT_B8G8R8A8_UNORM, // BGRA8
VK_FORMAT_R5G6B5_UNORM_PACK16, // RGB565
VK_FORMAT_R5G5B5A1_UNORM_PACK16, // RGBA5551
VK_FORMAT_A1R5G5B5_UNORM_PACK16, // RGB5A1
VK_FORMAT_R8_UNORM, // R8
VK_FORMAT_D16_UNORM, // D16
VK_FORMAT_D24_UNORM_S8_UINT, // D24S8