mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Draw: Optimize GL A1R5G5B5 conversion.
This seems to be enough to trigger SIMD in x86_64 at least.
This commit is contained in:
parent
8a8328c431
commit
915265e531
@ -637,6 +637,21 @@ void ConvertRGB565ToBGR565Basic(u16 *dst, const u16 *src, u32 numPixels) {
|
||||
}
|
||||
}
|
||||
|
||||
void ConvertBGRA5551ToABGR1555(u16 *dst, const u16 *src, u32 numPixels) {
|
||||
const u32 *src32 = (const u32 *)src;
|
||||
u32 *dst32 = (u32 *)dst;
|
||||
for (u32 i = 0; i < numPixels / 2; i++) {
|
||||
const u32 c = src32[i];
|
||||
dst32[i] = ((c >> 15) & 0x00010001) | ((c << 1) & 0xFFFEFFFE);
|
||||
}
|
||||
|
||||
if (numPixels & 1) {
|
||||
const u32 i = numPixels - 1;
|
||||
const u16 c = src[i];
|
||||
dst[i] = (c >> 15) | (c << 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Reuse the logic from the header - if these aren't defined, we need externs.
|
||||
#ifndef ConvertRGBA4444ToABGR4444
|
||||
Convert16bppTo16bppFunc ConvertRGBA4444ToABGR4444 = &ConvertRGBA4444ToABGR4444Basic;
|
||||
|
@ -134,6 +134,7 @@ void ConvertRGB565ToBGRA8888(u32 *dst, const u16 *src, u32 numPixels);
|
||||
void ConvertRGBA4444ToABGR4444Basic(u16 *dst, const u16 *src, u32 numPixels);
|
||||
void ConvertRGBA5551ToABGR1555Basic(u16 *dst, const u16 *src, u32 numPixels);
|
||||
void ConvertRGB565ToBGR565Basic(u16 *dst, const u16 *src, u32 numPixels);
|
||||
void ConvertBGRA5551ToABGR1555(u16 *dst, const u16 *src, u32 numPixels);
|
||||
|
||||
#if PPSSPP_ARCH(ARM64)
|
||||
#define ConvertRGBA4444ToABGR4444 ConvertRGBA4444ToABGR4444NEON
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
|
||||
#include "Common/Data/Convert/ColorConv.h"
|
||||
#include "Common/Data/Convert/SmallDataConvert.h"
|
||||
#include "Common/Math/math_util.h"
|
||||
#include "Common/Math/lin/matrix4x4.h"
|
||||
@ -812,15 +813,6 @@ public:
|
||||
GLRFramebuffer *framebuffer_ = nullptr;
|
||||
};
|
||||
|
||||
// TODO: SSE/NEON optimize, and move to ColorConv.cpp.
|
||||
void MoveABit(u16 *dest, const u16 *src, size_t count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
u16 data = src[i];
|
||||
data = (data >> 15) | (data << 1);
|
||||
dest[i] = data;
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLTexture::SetImageData(int x, int y, int z, int width, int height, int depth, int level, int stride, const uint8_t *data, TextureCallback callback) {
|
||||
if ((width != width_ || height != height_ || depth != depth_) && level == 0) {
|
||||
// When switching to texStorage we need to handle this correctly.
|
||||
@ -843,14 +835,14 @@ void OpenGLTexture::SetImageData(int x, int y, int z, int width, int height, int
|
||||
if (texDataPopulated) {
|
||||
if (format_ == DataFormat::A1R5G5B5_UNORM_PACK16) {
|
||||
format_ = DataFormat::R5G5B5A1_UNORM_PACK16;
|
||||
MoveABit((u16 *)texData, (const u16 *)texData, width * height * depth);
|
||||
ConvertBGRA5551ToABGR1555((u16 *)texData, (const u16 *)texData, width * height * depth);
|
||||
}
|
||||
} else {
|
||||
// Emulate support for DataFormat::A1R5G5B5_UNORM_PACK16.
|
||||
if (format_ == DataFormat::A1R5G5B5_UNORM_PACK16) {
|
||||
format_ = DataFormat::R5G5B5A1_UNORM_PACK16;
|
||||
for (int y = 0; y < height; y++) {
|
||||
MoveABit((u16 *)(texData + y * width * alignment), (const u16 *)(data + y * stride * alignment), width);
|
||||
ConvertBGRA5551ToABGR1555((u16 *)(texData + y * width * alignment), (const u16 *)(data + y * stride * alignment), width);
|
||||
}
|
||||
} else {
|
||||
for (int y = 0; y < height; y++) {
|
||||
|
Loading…
Reference in New Issue
Block a user