Commit d93029dd authored by Libretro-Admin's avatar Libretro-Admin
Browse files
parent 3958873e
Pipeline #16244 passed with stages
in 2 minutes and 27 seconds
......@@ -266,71 +266,6 @@ void libCore_vramlock_Unlock_block(vram_block* block)
}
#ifdef HAVE_TEXUPSCALE
//
// deposterization: smoothes posterized gradients from low-color-depth (e.g. 444, 565, compressed) sources
// Shamelessly stolen from ppsspp
// Copyright (c) 2012- PPSSPP Project.
//
#define BLOCK_SIZE 32
static void deposterizeH(u32* data, u32* out, int w, int l, int u) {
static const int T = 8;
for (int y = l; y < u; ++y) {
for (int x = 0; x < w; ++x) {
int inpos = y*w + x;
u32 center = data[inpos];
if (x == 0 || x == w - 1) {
out[y*w + x] = center;
continue;
}
u32 left = data[inpos - 1];
u32 right = data[inpos + 1];
out[y*w + x] = 0;
for (int c = 0; c < 4; ++c) {
u8 lc = ((left >> c * 8) & 0xFF);
u8 cc = ((center >> c * 8) & 0xFF);
u8 rc = ((right >> c * 8) & 0xFF);
if ((lc != rc) && ((lc == cc && abs((int)((int)rc) - cc) <= T) || (rc == cc && abs((int)((int)lc) - cc) <= T))) {
// blend this component
out[y*w + x] |= ((rc + lc) / 2) << (c * 8);
} else {
// no change for this component
out[y*w + x] |= cc << (c * 8);
}
}
}
}
}
static void deposterizeV(u32* data, u32* out, int w, int h, int l, int u) {
static const int T = 8;
for (int xb = 0; xb < w / BLOCK_SIZE + 1; ++xb) {
for (int y = l; y < u; ++y) {
for (int x = xb*BLOCK_SIZE; x < (xb + 1)*BLOCK_SIZE && x < w; ++x) {
u32 center = data[y * w + x];
if (y == 0 || y == h - 1) {
out[y*w + x] = center;
continue;
}
u32 upper = data[(y - 1) * w + x];
u32 lower = data[(y + 1) * w + x];
out[y*w + x] = 0;
for (int c = 0; c < 4; ++c) {
u8 uc = ((upper >> c * 8) & 0xFF);
u8 cc = ((center >> c * 8) & 0xFF);
u8 lc = ((lower >> c * 8) & 0xFF);
if ((uc != lc) && ((uc == cc && abs((int)((int)lc) - cc) <= T) || (lc == cc && abs((int)((int)uc) - cc) <= T))) {
// blend this component
out[y*w + x] |= ((lc + uc) / 2) << (c * 8);
} else {
// no change for this component
out[y*w + x] |= cc << (c * 8);
}
}
}
}
}
}
#ifndef TARGET_NO_OPENMP
static inline int getThreadCount()
{
......@@ -355,16 +290,6 @@ void parallelize(Func func, int start, int end)
}
}
void DePosterize(u32* source, u32* dest, int width, int height) {
u32 *tmpbuf = (u32 *)malloc(width * height * sizeof(u32));
parallelize([source, tmpbuf, width](int start, int end) { deposterizeH(source, tmpbuf, width, start, end); }, 0, height);
parallelize([tmpbuf, dest, width, height](int start, int end) { deposterizeV(tmpbuf, dest, width, height, start, end); }, 0, height);
parallelize([dest, tmpbuf, width](int start, int end) { deposterizeH(dest, tmpbuf, width, start, end); }, 0, height);
parallelize([tmpbuf, dest, width, height](int start, int end) { deposterizeV(tmpbuf, dest, width, height, start, end); }, 0, height);
free(tmpbuf);
}
#endif
static struct xbrz::ScalerCfg xbrz_cfg;
......@@ -716,17 +641,6 @@ void BaseTextureCacheData::Update()
texconv32(&pb32, (u8*)&vram[sa], stride, h);
#ifdef DEPOSTERIZE
{
// Deposterization
PixelBuffer<u32> tmp_buf;
tmp_buf.init(w, h);
DePosterize(pb32.data(), tmp_buf.data(), w, h);
pb32.steal_data(tmp_buf);
}
#endif
#ifdef HAVE_TEXUPSCALE
// xBRZ scaling
if (textureUpscaling)
......
......@@ -637,7 +637,6 @@ void texture_VQ(PixelBuffer<pixel_type>* pb,u8* p_in,u32 Width,u32 Height)
bool VramLockedWriteOffset(size_t offset);
#ifdef HAVE_TEXUPSCALE
void DePosterize(u32* source, u32* dest, int width, int height);
void UpscalexBRZ(int factor, u32* source, u32* dest, int width, int height, bool has_alpha);
#endif
......@@ -778,6 +777,8 @@ public:
return texture;
}
virtual ~BaseTextureCache() {}
void CollectCleanup()
{
std::vector<u64> list;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment