mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-24 08:39:51 +00:00
Remove BGRA path from GLES. Less code to test and support and it does no longer appear to have any benefit. See new comments in #5874
This commit is contained in:
parent
6a88d6c5a4
commit
10f144ef2e
@ -137,17 +137,12 @@ GLuint DepalShaderCacheGLES::GetClutTexture(GEPaletteFormat clutFormat, const u3
|
||||
GLuint dstFmt = getClutDestFormat(clutFormat);
|
||||
int texturePixels = clutFormat == GE_CMODE_32BIT_ABGR8888 ? 256 : 512;
|
||||
|
||||
bool useBGRA = UseBGRA8888() && dstFmt == GL_UNSIGNED_BYTE;
|
||||
|
||||
DepalTexture *tex = new DepalTexture();
|
||||
glGenTextures(1, &tex->texture);
|
||||
glBindTexture(GL_TEXTURE_2D, tex->texture);
|
||||
GLuint components = dstFmt == GL_UNSIGNED_SHORT_5_6_5 ? GL_RGB : GL_RGBA;
|
||||
|
||||
GLuint components2 = components;
|
||||
if (useBGRA) {
|
||||
components2 = GL_BGRA_EXT;
|
||||
}
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, components, texturePixels, 1, 0, components2, dstFmt, (void *)rawClut);
|
||||
|
||||
|
@ -808,12 +808,6 @@ void ConvertFromRGBA8888(u8 *dst, const u8 *src, u32 dstStride, u32 srcStride, u
|
||||
u32 *dst32 = (u32 *)dst;
|
||||
if (src == dst) {
|
||||
return;
|
||||
} else if (UseBGRA8888()) {
|
||||
for (u32 y = 0; y < height; ++y) {
|
||||
ConvertBGRA8888ToRGBA8888(dst32, src32, width);
|
||||
src32 += srcStride;
|
||||
dst32 += dstStride;
|
||||
}
|
||||
} else {
|
||||
// Here let's assume they don't intersect
|
||||
for (u32 y = 0; y < height; ++y) {
|
||||
@ -827,13 +821,7 @@ void ConvertFromRGBA8888(u8 *dst, const u8 *src, u32 dstStride, u32 srcStride, u
|
||||
u16 *dst16 = (u16 *)dst;
|
||||
switch (format) {
|
||||
case GE_FORMAT_565: // BGR 565
|
||||
if (UseBGRA8888()) {
|
||||
for (u32 y = 0; y < height; ++y) {
|
||||
ConvertBGRA8888ToRGB565(dst16, src32, width);
|
||||
src32 += srcStride;
|
||||
dst16 += dstStride;
|
||||
}
|
||||
} else {
|
||||
{
|
||||
for (u32 y = 0; y < height; ++y) {
|
||||
ConvertRGBA8888ToRGB565(dst16, src32, width);
|
||||
src32 += srcStride;
|
||||
@ -842,13 +830,7 @@ void ConvertFromRGBA8888(u8 *dst, const u8 *src, u32 dstStride, u32 srcStride, u
|
||||
}
|
||||
break;
|
||||
case GE_FORMAT_5551: // ABGR 1555
|
||||
if (UseBGRA8888()) {
|
||||
for (u32 y = 0; y < height; ++y) {
|
||||
ConvertBGRA8888ToRGBA5551(dst16, src32, width);
|
||||
src32 += srcStride;
|
||||
dst16 += dstStride;
|
||||
}
|
||||
} else {
|
||||
{
|
||||
for (u32 y = 0; y < height; ++y) {
|
||||
ConvertRGBA8888ToRGBA5551(dst16, src32, width);
|
||||
src32 += srcStride;
|
||||
@ -857,13 +839,7 @@ void ConvertFromRGBA8888(u8 *dst, const u8 *src, u32 dstStride, u32 srcStride, u
|
||||
}
|
||||
break;
|
||||
case GE_FORMAT_4444: // ABGR 4444
|
||||
if (UseBGRA8888()) {
|
||||
for (u32 y = 0; y < height; ++y) {
|
||||
ConvertBGRA8888ToRGBA4444(dst16, src32, width);
|
||||
src32 += srcStride;
|
||||
dst16 += dstStride;
|
||||
}
|
||||
} else {
|
||||
{
|
||||
for (u32 y = 0; y < height; ++y) {
|
||||
ConvertRGBA8888ToRGBA4444(dst16, src32, width);
|
||||
src32 += srcStride;
|
||||
@ -975,7 +951,7 @@ void FramebufferManagerGLES::PackFramebufferAsync_(VirtualFramebuffer *vfb) {
|
||||
DEBUG_LOG(FRAMEBUF, "Reading PBO to memory , bufSize = %u, packed = %p, fb_address = %08x, stride = %u, pbo = %u",
|
||||
pbo.size, packed, pbo.fb_address, pbo.stride, nextPBO);
|
||||
|
||||
if (useCPU || (UseBGRA8888() && pbo.format == GE_FORMAT_8888)) {
|
||||
if (useCPU) {
|
||||
u8 *dst = Memory::GetPointer(pbo.fb_address);
|
||||
ConvertFromRGBA8888(dst, packed, pbo.stride, pbo.stride, pbo.stride, pbo.height, pbo.format);
|
||||
} else {
|
||||
@ -1032,7 +1008,7 @@ void FramebufferManagerGLES::PackFramebufferAsync_(VirtualFramebuffer *vfb) {
|
||||
case GE_FORMAT_8888: // 32 bit RGBA
|
||||
default:
|
||||
pixelType = GL_UNSIGNED_BYTE;
|
||||
pixelFormat = UseBGRA8888() ? GL_BGRA_EXT : GL_RGBA;
|
||||
pixelFormat = GL_RGBA;
|
||||
pixelSize = 4;
|
||||
align = 4;
|
||||
break;
|
||||
@ -1060,7 +1036,7 @@ void FramebufferManagerGLES::PackFramebufferAsync_(VirtualFramebuffer *vfb) {
|
||||
if (useCPU) {
|
||||
// If converting pixel formats on the CPU we'll always request RGBA8888
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
||||
SafeGLReadPixels(0, 0, vfb->fb_stride, vfb->height, UseBGRA8888() ? GL_BGRA_EXT : GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
||||
SafeGLReadPixels(0, 0, vfb->fb_stride, vfb->height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
||||
} else {
|
||||
// Otherwise we'll directly request the format we need and let the GPU sort it out
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, align);
|
||||
@ -1102,7 +1078,7 @@ void FramebufferManagerGLES::PackFramebufferSync_(VirtualFramebuffer *vfb, int x
|
||||
u32 bufSize = vfb->fb_stride * h * 4;
|
||||
u32 fb_address = 0x04000000 | vfb->fb_address;
|
||||
|
||||
bool convert = vfb->format != GE_FORMAT_8888 || UseBGRA8888();
|
||||
bool convert = vfb->format != GE_FORMAT_8888;
|
||||
const int dstBpp = vfb->format == GE_FORMAT_8888 ? 4 : 2;
|
||||
const int packWidth = std::min(vfb->fb_stride, std::min(x + w, (int)vfb->width));
|
||||
|
||||
@ -1127,9 +1103,6 @@ void FramebufferManagerGLES::PackFramebufferSync_(VirtualFramebuffer *vfb, int x
|
||||
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
||||
GLenum glfmt = GL_RGBA;
|
||||
if (UseBGRA8888()) {
|
||||
glfmt = GL_BGRA_EXT;
|
||||
}
|
||||
CHECK_GL_ERROR_IF_DEBUG();
|
||||
|
||||
SafeGLReadPixels(0, y, h == 1 ? packWidth : vfb->fb_stride, h, glfmt, GL_UNSIGNED_BYTE, packed);
|
||||
|
@ -217,13 +217,9 @@ static void ConvertColors(void *dstBuf, const void *srcBuf, GLuint dstFmt, int n
|
||||
ConvertRGB565ToBGR565((u16 *)dst, (const u16 *)src, numPixels);
|
||||
break;
|
||||
default:
|
||||
if (UseBGRA8888()) {
|
||||
ConvertRGBA8888ToBGRA8888(dst, src, numPixels);
|
||||
} else {
|
||||
// No need to convert RGBA8888, right order already
|
||||
if (dst != src)
|
||||
memcpy(dst, src, numPixels * sizeof(u32));
|
||||
}
|
||||
// No need to convert RGBA8888, right order already
|
||||
if (dst != src)
|
||||
memcpy(dst, src, numPixels * sizeof(u32));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -258,7 +254,7 @@ void TextureCacheGLES::UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutBas
|
||||
clutHash_ = DoReliableHash32((const char *)clutBufRaw_, clutExtendedBytes, 0xC0108888);
|
||||
|
||||
// Avoid a copy when we don't need to convert colors.
|
||||
if (UseBGRA8888() || clutFormat != GE_CMODE_32BIT_ABGR8888) {
|
||||
if (clutFormat != GE_CMODE_32BIT_ABGR8888) {
|
||||
const int numColors = clutFormat == GE_CMODE_32BIT_ABGR8888 ? (clutMaxBytes_ / sizeof(u32)) : (clutMaxBytes_ / sizeof(u16));
|
||||
ConvertColors(clutBufConverted_, clutBufRaw_, getClutDestFormat(clutFormat), numColors);
|
||||
clutBuf_ = clutBufConverted_;
|
||||
@ -525,13 +521,13 @@ void TextureCacheGLES::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFram
|
||||
lastBoundTexture = INVALID_TEX;
|
||||
}
|
||||
|
||||
ReplacedTextureFormat FromGLESFormat(GLenum fmt, bool useBGRA = false) {
|
||||
ReplacedTextureFormat FromGLESFormat(GLenum fmt) {
|
||||
// TODO: 16-bit formats are incorrect, since swizzled.
|
||||
switch (fmt) {
|
||||
case GL_UNSIGNED_SHORT_5_6_5: return ReplacedTextureFormat::F_0565_ABGR;
|
||||
case GL_UNSIGNED_SHORT_5_5_5_1: return ReplacedTextureFormat::F_1555_ABGR;
|
||||
case GL_UNSIGNED_SHORT_4_4_4_4: return ReplacedTextureFormat::F_4444_ABGR;
|
||||
case GL_UNSIGNED_BYTE: default: return useBGRA ? ReplacedTextureFormat::F_8888_BGRA : ReplacedTextureFormat::F_8888;
|
||||
case GL_UNSIGNED_BYTE: default: return ReplacedTextureFormat::F_8888;
|
||||
}
|
||||
}
|
||||
|
||||
@ -783,7 +779,7 @@ void *TextureCacheGLES::DecodeTextureLevelOld(GETextureFormat format, GEPaletteF
|
||||
}
|
||||
|
||||
tmpTexBufRearrange_.resize(std::max(w, bufw) * h);
|
||||
DecodeTextureLevel((u8 *)tmpTexBufRearrange_.data(), decPitch, format, clutformat, texaddr, level, bufw, true, UseBGRA8888(), false);
|
||||
DecodeTextureLevel((u8 *)tmpTexBufRearrange_.data(), decPitch, format, clutformat, texaddr, level, bufw, true, false, false);
|
||||
return tmpTexBufRearrange_.data();
|
||||
}
|
||||
|
||||
@ -812,7 +808,6 @@ void TextureCacheGLES::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &r
|
||||
int w = gstate.getTextureWidth(level);
|
||||
int h = gstate.getTextureHeight(level);
|
||||
bool useUnpack = false;
|
||||
bool useBGRA;
|
||||
u32 *pixelData;
|
||||
|
||||
CHECK_GL_ERROR_IF_DEBUG();
|
||||
@ -833,7 +828,6 @@ void TextureCacheGLES::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &r
|
||||
dstFmt = ToGLESFormat(replaced.Format(level));
|
||||
|
||||
texByteAlign = bpp;
|
||||
useBGRA = false;
|
||||
} else {
|
||||
PROFILE_THIS_SCOPE("decodetex");
|
||||
|
||||
@ -852,7 +846,6 @@ void TextureCacheGLES::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &r
|
||||
|
||||
// Textures are always aligned to 16 bytes bufw, so this could safely be 4 always.
|
||||
texByteAlign = dstFmt == GL_UNSIGNED_BYTE ? 4 : 2;
|
||||
useBGRA = UseBGRA8888() && dstFmt == GL_UNSIGNED_BYTE;
|
||||
|
||||
pixelData = (u32 *)finalBuf;
|
||||
if (scaleFactor > 1)
|
||||
@ -873,7 +866,7 @@ void TextureCacheGLES::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &r
|
||||
replacedInfo.isVideo = videos_.find(entry.addr & 0x3FFFFFFF) != videos_.end();
|
||||
replacedInfo.isFinal = (entry.status & TexCacheEntry::STATUS_TO_SCALE) == 0;
|
||||
replacedInfo.scaleFactor = scaleFactor;
|
||||
replacedInfo.fmt = FromGLESFormat(dstFmt, useBGRA);
|
||||
replacedInfo.fmt = FromGLESFormat(dstFmt);
|
||||
|
||||
int bpp = dstFmt == GL_UNSIGNED_BYTE ? 4 : 2;
|
||||
replacer_.NotifyTextureDecoded(replacedInfo, pixelData, (useUnpack ? bufw : w) * bpp, level, w, h);
|
||||
@ -887,9 +880,6 @@ void TextureCacheGLES::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &r
|
||||
GLuint components = dstFmt == GL_UNSIGNED_SHORT_5_6_5 ? GL_RGB : GL_RGBA;
|
||||
|
||||
GLuint components2 = components;
|
||||
if (useBGRA) {
|
||||
components2 = GL_BGRA_EXT;
|
||||
}
|
||||
|
||||
if (replaceImages) {
|
||||
PROFILE_THIS_SCOPE("repltex");
|
||||
|
@ -33,14 +33,6 @@ class DepalShaderCacheGLES;
|
||||
class ShaderManagerGLES;
|
||||
class DrawEngineGLES;
|
||||
|
||||
inline bool UseBGRA8888() {
|
||||
// TODO: Other platforms? May depend on vendor which is faster?
|
||||
#ifdef _WIN32
|
||||
return gl_extensions.EXT_bgra;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
class TextureCacheGLES : public TextureCacheCommon {
|
||||
public:
|
||||
TextureCacheGLES(Draw::DrawContext *draw);
|
||||
|
Loading…
Reference in New Issue
Block a user