mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Correct the wrong GL DataFormat enums
This commit is contained in:
parent
9e607fdeb1
commit
46447c9e90
6 changed files with 33 additions and 28 deletions
|
@ -107,6 +107,9 @@ void convert5551_dx9(u16* data, u32* out, int width, int l, int u);
|
|||
|
||||
// "Complete" set of color conversion functions between the usual formats.
|
||||
|
||||
// TODO: Need to revisit the naming convention of these. Seems totally backwards
|
||||
// now that we've standardized on Draw::DataFormat.
|
||||
|
||||
typedef void (*Convert16bppTo16bppFunc)(u16 *dst, const u16 *src, u32 numPixels);
|
||||
typedef void (*Convert16bppTo32bppFunc)(u32 *dst, const u16 *src, u32 numPixels);
|
||||
typedef void (*Convert32bppTo16bppFunc)(u16 *dst, const u32 *src, u32 numPixels);
|
||||
|
|
|
@ -89,11 +89,11 @@ void TextureCacheGLES::Clear(bool delete_them) {
|
|||
Draw::DataFormat getClutDestFormat(GEPaletteFormat format) {
|
||||
switch (format) {
|
||||
case GE_CMODE_16BIT_ABGR4444:
|
||||
return Draw::DataFormat::B4G4R4A4_UNORM_PACK16;
|
||||
return Draw::DataFormat::R4G4B4A4_UNORM_PACK16;
|
||||
case GE_CMODE_16BIT_ABGR5551:
|
||||
return Draw::DataFormat::B5G5R5A1_UNORM_PACK16;
|
||||
return Draw::DataFormat::R5G5B5A1_UNORM_PACK16;
|
||||
case GE_CMODE_16BIT_BGR5650:
|
||||
return Draw::DataFormat::B5G6R5_UNORM_PACK16;
|
||||
return Draw::DataFormat::R5G6B5_UNORM_PACK16;
|
||||
case GE_CMODE_32BIT_ABGR8888:
|
||||
return Draw::DataFormat::R8G8B8A8_UNORM;
|
||||
}
|
||||
|
@ -192,14 +192,14 @@ static void ConvertColors(void *dstBuf, const void *srcBuf, Draw::DataFormat dst
|
|||
const u32 *src = (const u32 *)srcBuf;
|
||||
u32 *dst = (u32 *)dstBuf;
|
||||
switch (dstFmt) {
|
||||
case Draw::DataFormat::B4G4R4A4_UNORM_PACK16:
|
||||
case Draw::DataFormat::R4G4B4A4_UNORM_PACK16:
|
||||
ConvertRGBA4444ToABGR4444((u16 *)dst, (const u16 *)src, numPixels);
|
||||
break;
|
||||
// Final Fantasy 2 uses this heavily in animated textures.
|
||||
case Draw::DataFormat::B5G5R5A1_UNORM_PACK16:
|
||||
case Draw::DataFormat::R5G5B5A1_UNORM_PACK16:
|
||||
ConvertRGBA5551ToABGR1555((u16 *)dst, (const u16 *)src, numPixels);
|
||||
break;
|
||||
case Draw::DataFormat::B5G6R5_UNORM_PACK16:
|
||||
case Draw::DataFormat::R5G6B5_UNORM_PACK16:
|
||||
ConvertRGB565ToBGR565((u16 *)dst, (const u16 *)src, numPixels);
|
||||
break;
|
||||
default:
|
||||
|
@ -517,18 +517,18 @@ void TextureCacheGLES::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFram
|
|||
ReplacedTextureFormat FromDataFormat(Draw::DataFormat fmt) {
|
||||
// TODO: 16-bit formats are incorrect, since swizzled.
|
||||
switch (fmt) {
|
||||
case Draw::DataFormat::B5G6R5_UNORM_PACK16: return ReplacedTextureFormat::F_0565_ABGR;
|
||||
case Draw::DataFormat::B5G5R5A1_UNORM_PACK16: return ReplacedTextureFormat::F_1555_ABGR;
|
||||
case Draw::DataFormat::B4G4R4A4_UNORM_PACK16: return ReplacedTextureFormat::F_4444_ABGR;
|
||||
case Draw::DataFormat::R5G6B5_UNORM_PACK16: return ReplacedTextureFormat::F_0565_ABGR;
|
||||
case Draw::DataFormat::R5G5B5A1_UNORM_PACK16: return ReplacedTextureFormat::F_1555_ABGR;
|
||||
case Draw::DataFormat::R4G4B4A4_UNORM_PACK16: return ReplacedTextureFormat::F_4444_ABGR;
|
||||
case Draw::DataFormat::R8G8B8A8_UNORM: default: return ReplacedTextureFormat::F_8888;
|
||||
}
|
||||
}
|
||||
|
||||
Draw::DataFormat ToDataFormat(ReplacedTextureFormat fmt) {
|
||||
switch (fmt) {
|
||||
case ReplacedTextureFormat::F_5650: return Draw::DataFormat::B5G6R5_UNORM_PACK16;
|
||||
case ReplacedTextureFormat::F_5551: return Draw::DataFormat::B5G5R5A1_UNORM_PACK16;
|
||||
case ReplacedTextureFormat::F_4444: return Draw::DataFormat::B4G4R4A4_UNORM_PACK16;
|
||||
case ReplacedTextureFormat::F_5650: return Draw::DataFormat::R5G6B5_UNORM_PACK16;
|
||||
case ReplacedTextureFormat::F_5551: return Draw::DataFormat::R5G5B5A1_UNORM_PACK16;
|
||||
case ReplacedTextureFormat::F_4444: return Draw::DataFormat::R4G4B4A4_UNORM_PACK16;
|
||||
case ReplacedTextureFormat::F_8888: default: return Draw::DataFormat::R8G8B8A8_UNORM;
|
||||
}
|
||||
}
|
||||
|
@ -708,11 +708,11 @@ Draw::DataFormat TextureCacheGLES::GetDestFormat(GETextureFormat format, GEPalet
|
|||
case GE_TFMT_CLUT32:
|
||||
return getClutDestFormat(clutFormat);
|
||||
case GE_TFMT_4444:
|
||||
return Draw::DataFormat::B4G4R4A4_UNORM_PACK16;
|
||||
return Draw::DataFormat::R4G4B4A4_UNORM_PACK16;
|
||||
case GE_TFMT_5551:
|
||||
return Draw::DataFormat::B5G5R5A1_UNORM_PACK16;
|
||||
return Draw::DataFormat::R5G5B5A1_UNORM_PACK16;
|
||||
case GE_TFMT_5650:
|
||||
return Draw::DataFormat::B5G6R5_UNORM_PACK16;
|
||||
return Draw::DataFormat::R5G6B5_UNORM_PACK16;
|
||||
case GE_TFMT_8888:
|
||||
case GE_TFMT_DXT1:
|
||||
case GE_TFMT_DXT3:
|
||||
|
@ -725,13 +725,13 @@ Draw::DataFormat TextureCacheGLES::GetDestFormat(GETextureFormat format, GEPalet
|
|||
TexCacheEntry::TexStatus TextureCacheGLES::CheckAlpha(const uint8_t *pixelData, Draw::DataFormat dstFmt, int stride, int w, int h) {
|
||||
CheckAlphaResult res;
|
||||
switch (dstFmt) {
|
||||
case Draw::DataFormat::B4G4R4A4_UNORM_PACK16:
|
||||
case Draw::DataFormat::R4G4B4A4_UNORM_PACK16:
|
||||
res = CheckAlphaABGR4444Basic((const uint32_t *)pixelData, stride, w, h);
|
||||
break;
|
||||
case Draw::DataFormat::B5G5R5A1_UNORM_PACK16:
|
||||
case Draw::DataFormat::R5G5B5A1_UNORM_PACK16:
|
||||
res = CheckAlphaABGR1555Basic((const uint32_t *)pixelData, stride, w, h);
|
||||
break;
|
||||
case Draw::DataFormat::B5G6R5_UNORM_PACK16:
|
||||
case Draw::DataFormat::R5G6B5_UNORM_PACK16:
|
||||
// Never has any alpha.
|
||||
res = CHECKALPHA_FULL;
|
||||
break;
|
||||
|
|
|
@ -45,15 +45,15 @@ void TextureScalerGLES::ConvertTo8888(u32 format, u32* source, u32* &dest, int w
|
|||
dest = source; // already fine
|
||||
break;
|
||||
|
||||
case Draw::DataFormat::B4G4R4A4_UNORM_PACK16:
|
||||
case Draw::DataFormat::R4G4B4A4_UNORM_PACK16:
|
||||
GlobalThreadPool::Loop(std::bind(&convert4444_gl, (u16*)source, dest, width, std::placeholders::_1, std::placeholders::_2), 0, height);
|
||||
break;
|
||||
|
||||
case Draw::DataFormat::B5G6R5_UNORM_PACK16:
|
||||
case Draw::DataFormat::R5G6B5_UNORM_PACK16:
|
||||
GlobalThreadPool::Loop(std::bind(&convert565_gl, (u16*)source, dest, width, std::placeholders::_1, std::placeholders::_2), 0, height);
|
||||
break;
|
||||
|
||||
case Draw::DataFormat::B5G5R5A1_UNORM_PACK16:
|
||||
case Draw::DataFormat::R5G5B5A1_UNORM_PACK16:
|
||||
GlobalThreadPool::Loop(std::bind(&convert5551_gl, (u16*)source, dest, width, std::placeholders::_1, std::placeholders::_2), 0, height);
|
||||
break;
|
||||
|
||||
|
|
|
@ -258,6 +258,8 @@ void TextDrawerWin32::DrawString(DrawBuffer &target, const char *str, float x, f
|
|||
texFormat = Draw::DataFormat::A4R4G4B4_UNORM_PACK16;
|
||||
else if (draw_->GetDataFormatSupport(Draw::DataFormat::B4G4R4A4_UNORM_PACK16) & FMT_TEXTURE)
|
||||
texFormat = Draw::DataFormat::B4G4R4A4_UNORM_PACK16;
|
||||
else if (draw_->GetDataFormatSupport(Draw::DataFormat::R4G4B4A4_UNORM_PACK16) & FMT_TEXTURE)
|
||||
texFormat = Draw::DataFormat::R4G4B4A4_UNORM_PACK16;
|
||||
else
|
||||
texFormat = Draw::DataFormat::R8G8B8A8_UNORM;
|
||||
|
||||
|
@ -275,7 +277,7 @@ void TextDrawerWin32::DrawString(DrawBuffer &target, const char *str, float x, f
|
|||
}
|
||||
}
|
||||
desc.initData.push_back((uint8_t *)bitmapData32);
|
||||
} else if (texFormat == Draw::DataFormat::B4G4R4A4_UNORM_PACK16) {
|
||||
} else if (texFormat == Draw::DataFormat::B4G4R4A4_UNORM_PACK16 || texFormat == Draw::DataFormat::R4G4B4A4_UNORM_PACK16) {
|
||||
bitmapData16 = new uint16_t[entry->bmWidth * entry->bmHeight];
|
||||
for (int y = 0; y < entry->bmHeight; y++) {
|
||||
for (int x = 0; x < entry->bmWidth; x++) {
|
||||
|
|
|
@ -36,21 +36,21 @@ bool Thin3DFormatToFormatAndType(DataFormat fmt, GLuint &internalFormat, GLuint
|
|||
alignment = 1;
|
||||
break;
|
||||
|
||||
case DataFormat::B4G4R4A4_UNORM_PACK16:
|
||||
case DataFormat::R4G4B4A4_UNORM_PACK16:
|
||||
internalFormat = GL_RGBA;
|
||||
format = GL_RGBA;
|
||||
type = GL_UNSIGNED_SHORT_4_4_4_4;
|
||||
alignment = 2;
|
||||
break;
|
||||
|
||||
case DataFormat::B5G6R5_UNORM_PACK16:
|
||||
case DataFormat::R5G6B5_UNORM_PACK16:
|
||||
internalFormat = GL_RGB;
|
||||
format = GL_RGB;
|
||||
type = GL_UNSIGNED_SHORT_5_6_5;
|
||||
alignment = 2;
|
||||
break;
|
||||
|
||||
case DataFormat::B5G5R5A1_UNORM_PACK16:
|
||||
case DataFormat::R5G5B5A1_UNORM_PACK16:
|
||||
internalFormat = GL_RGBA;
|
||||
format = GL_RGBA;
|
||||
type = GL_UNSIGNED_SHORT_5_5_5_1;
|
||||
|
|
|
@ -1212,9 +1212,9 @@ void OpenGLContext::GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h) {
|
|||
|
||||
uint32_t OpenGLContext::GetDataFormatSupport(DataFormat fmt) const {
|
||||
switch (fmt) {
|
||||
case DataFormat::B4G4R4A4_UNORM_PACK16:
|
||||
case DataFormat::B5G6R5_UNORM_PACK16:
|
||||
case DataFormat::B5G5R5A1_UNORM_PACK16:
|
||||
case DataFormat::R4G4B4A4_UNORM_PACK16:
|
||||
case DataFormat::R5G6B5_UNORM_PACK16:
|
||||
case DataFormat::R5G5B5A1_UNORM_PACK16:
|
||||
return FMT_RENDERTARGET | FMT_TEXTURE | FMT_AUTOGEN_MIPS; // native support
|
||||
|
||||
case DataFormat::R8G8B8A8_UNORM:
|
||||
|
|
Loading…
Add table
Reference in a new issue