TexCache: remove PC_TexFormat
We only support rgba32 for a while now, so there is no need to have everything in common configureable.
This commit is contained in:
parent
37a770bb9f
commit
615ae9f106
|
@ -81,8 +81,7 @@ void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height,
|
||||||
D3D::ReplaceRGBATexture2D(texture->GetTex(), TextureCache::temp, width, height, expanded_width, level, usage);
|
D3D::ReplaceRGBATexture2D(texture->GetTex(), TextureCache::temp, width, height, expanded_width, level, usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, unsigned int height,
|
TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, unsigned int height, unsigned int tex_levels)
|
||||||
unsigned int tex_levels, PC_TexFormat pcfmt)
|
|
||||||
{
|
{
|
||||||
D3D11_USAGE usage = D3D11_USAGE_DEFAULT;
|
D3D11_USAGE usage = D3D11_USAGE_DEFAULT;
|
||||||
D3D11_CPU_ACCESS_FLAG cpu_access = (D3D11_CPU_ACCESS_FLAG)0;
|
D3D11_CPU_ACCESS_FLAG cpu_access = (D3D11_CPU_ACCESS_FLAG)0;
|
||||||
|
|
|
@ -38,8 +38,7 @@ private:
|
||||||
bool Save(const std::string& filename, unsigned int level) override;
|
bool Save(const std::string& filename, unsigned int level) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
TCacheEntryBase* CreateTexture(unsigned int width, unsigned int height,
|
TCacheEntryBase* CreateTexture(unsigned int width, unsigned int height, unsigned int tex_levels) override;
|
||||||
unsigned int tex_levels, PC_TexFormat pcfmt) override;
|
|
||||||
|
|
||||||
TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h, unsigned int layers) override;
|
TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h, unsigned int layers) override;
|
||||||
u64 EncodeToRamFromTexture(u32 address, void* source_texture, u32 SourceW, u32 SourceH, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source) {return 0;};
|
u64 EncodeToRamFromTexture(u32 address, void* source_texture, u32 SourceW, u32 SourceH, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source) {return 0;};
|
||||||
|
|
|
@ -109,72 +109,14 @@ bool TextureCache::TCacheEntry::Save(const std::string& filename, unsigned int l
|
||||||
return SaveTexture(filename, GL_TEXTURE_2D_ARRAY, texture, config.width, config.height, level);
|
return SaveTexture(filename, GL_TEXTURE_2D_ARRAY, texture, config.width, config.height, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, unsigned int height,
|
TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, unsigned int height, unsigned int tex_levels)
|
||||||
unsigned int tex_levels, PC_TexFormat pcfmt)
|
|
||||||
{
|
{
|
||||||
int gl_format = 0,
|
|
||||||
gl_iformat = 0,
|
|
||||||
gl_type = 0;
|
|
||||||
|
|
||||||
if (pcfmt != PC_TEX_FMT_DXT1)
|
|
||||||
{
|
|
||||||
switch (pcfmt)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case PC_TEX_FMT_NONE:
|
|
||||||
PanicAlert("Invalid PC texture format %i", pcfmt);
|
|
||||||
case PC_TEX_FMT_BGRA32:
|
|
||||||
gl_format = GL_BGRA;
|
|
||||||
gl_iformat = GL_RGBA;
|
|
||||||
gl_type = GL_UNSIGNED_BYTE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PC_TEX_FMT_RGBA32:
|
|
||||||
gl_format = GL_RGBA;
|
|
||||||
gl_iformat = GL_RGBA;
|
|
||||||
gl_type = GL_UNSIGNED_BYTE;
|
|
||||||
break;
|
|
||||||
case PC_TEX_FMT_I4_AS_I8:
|
|
||||||
gl_format = GL_LUMINANCE;
|
|
||||||
gl_iformat = GL_INTENSITY4;
|
|
||||||
gl_type = GL_UNSIGNED_BYTE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PC_TEX_FMT_IA4_AS_IA8:
|
|
||||||
gl_format = GL_LUMINANCE_ALPHA;
|
|
||||||
gl_iformat = GL_LUMINANCE4_ALPHA4;
|
|
||||||
gl_type = GL_UNSIGNED_BYTE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PC_TEX_FMT_I8:
|
|
||||||
gl_format = GL_LUMINANCE;
|
|
||||||
gl_iformat = GL_INTENSITY8;
|
|
||||||
gl_type = GL_UNSIGNED_BYTE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PC_TEX_FMT_IA8:
|
|
||||||
gl_format = GL_LUMINANCE_ALPHA;
|
|
||||||
gl_iformat = GL_LUMINANCE8_ALPHA8;
|
|
||||||
gl_type = GL_UNSIGNED_BYTE;
|
|
||||||
break;
|
|
||||||
case PC_TEX_FMT_RGB565:
|
|
||||||
gl_format = GL_RGB;
|
|
||||||
gl_iformat = GL_RGB;
|
|
||||||
gl_type = GL_UNSIGNED_SHORT_5_6_5;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TCacheEntryConfig config;
|
TCacheEntryConfig config;
|
||||||
config.width = width;
|
config.width = width;
|
||||||
config.height = height;
|
config.height = height;
|
||||||
config.levels = tex_levels;
|
config.levels = tex_levels;
|
||||||
|
|
||||||
TCacheEntry &entry = *new TCacheEntry(config);
|
TCacheEntry &entry = *new TCacheEntry(config);
|
||||||
entry.gl_format = gl_format;
|
|
||||||
entry.gl_iformat = gl_iformat;
|
|
||||||
entry.gl_type = gl_type;
|
|
||||||
entry.pcfmt = pcfmt;
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0+9);
|
glActiveTexture(GL_TEXTURE0+9);
|
||||||
glBindTexture(GL_TEXTURE_2D_ARRAY, entry.texture);
|
glBindTexture(GL_TEXTURE_2D_ARRAY, entry.texture);
|
||||||
|
@ -194,25 +136,17 @@ void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height,
|
||||||
PanicAlert("size of level %d must be %dx%d, but %dx%d requested",
|
PanicAlert("size of level %d must be %dx%d, but %dx%d requested",
|
||||||
level, std::max(1u, config.width >> level), std::max(1u, config.height >> level), width, height);
|
level, std::max(1u, config.width >> level), std::max(1u, config.height >> level), width, height);
|
||||||
|
|
||||||
if (pcfmt != PC_TEX_FMT_DXT1)
|
|
||||||
{
|
|
||||||
glActiveTexture(GL_TEXTURE0+9);
|
glActiveTexture(GL_TEXTURE0+9);
|
||||||
glBindTexture(GL_TEXTURE_2D_ARRAY, texture);
|
glBindTexture(GL_TEXTURE_2D_ARRAY, texture);
|
||||||
|
|
||||||
if (expanded_width != width)
|
if (expanded_width != width)
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, expanded_width);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, expanded_width);
|
||||||
|
|
||||||
glTexImage3D(GL_TEXTURE_2D_ARRAY, level, gl_iformat, width, height, 1, 0, gl_format, gl_type, temp);
|
glTexImage3D(GL_TEXTURE_2D_ARRAY, level, GL_RGBA, width, height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, temp);
|
||||||
|
|
||||||
if (expanded_width != width)
|
if (expanded_width != width)
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PanicAlert("PC_TEX_FMT_DXT1 support disabled");
|
|
||||||
//glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
|
||||||
//width, height, 0, expanded_width * expanded_height/2, temp);
|
|
||||||
}
|
|
||||||
TextureCache::SetStage();
|
TextureCache::SetStage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,13 +163,8 @@ TextureCache::TCacheEntryBase* TextureCache::CreateRenderTargetTexture(
|
||||||
glActiveTexture(GL_TEXTURE0+9);
|
glActiveTexture(GL_TEXTURE0+9);
|
||||||
glBindTexture(GL_TEXTURE_2D_ARRAY, entry->texture);
|
glBindTexture(GL_TEXTURE_2D_ARRAY, entry->texture);
|
||||||
|
|
||||||
const GLenum
|
|
||||||
gl_format = GL_RGBA,
|
|
||||||
gl_iformat = GL_RGBA,
|
|
||||||
gl_type = GL_UNSIGNED_BYTE;
|
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, 0);
|
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, 0);
|
||||||
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, gl_iformat, scaled_tex_w, scaled_tex_h, layers, 0, gl_format, gl_type, nullptr);
|
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, scaled_tex_w, scaled_tex_h, layers, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||||
glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
|
glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
|
||||||
|
|
||||||
glGenFramebuffers(1, &entry->framebuffer);
|
glGenFramebuffers(1, &entry->framebuffer);
|
||||||
|
|
|
@ -27,12 +27,6 @@ private:
|
||||||
GLuint texture;
|
GLuint texture;
|
||||||
GLuint framebuffer;
|
GLuint framebuffer;
|
||||||
|
|
||||||
PC_TexFormat pcfmt;
|
|
||||||
|
|
||||||
int gl_format;
|
|
||||||
int gl_iformat;
|
|
||||||
int gl_type;
|
|
||||||
|
|
||||||
//TexMode0 mode; // current filter and clamp modes that texture is set to
|
//TexMode0 mode; // current filter and clamp modes that texture is set to
|
||||||
//TexMode1 mode1; // current filter and clamp modes that texture is set to
|
//TexMode1 mode1; // current filter and clamp modes that texture is set to
|
||||||
|
|
||||||
|
@ -53,8 +47,7 @@ private:
|
||||||
|
|
||||||
~TextureCache();
|
~TextureCache();
|
||||||
|
|
||||||
TCacheEntryBase* CreateTexture(unsigned int width, unsigned int height,
|
TCacheEntryBase* CreateTexture(unsigned int width, unsigned int height, unsigned int tex_levels) override;
|
||||||
unsigned int tex_levels, PC_TexFormat pcfmt) override;
|
|
||||||
|
|
||||||
TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h, unsigned int layers) override;
|
TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h, unsigned int layers) override;
|
||||||
|
|
||||||
|
|
|
@ -323,7 +323,6 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage)
|
||||||
u64 tlut_hash = TEXHASH_INVALID;
|
u64 tlut_hash = TEXHASH_INVALID;
|
||||||
|
|
||||||
u32 full_format = texformat;
|
u32 full_format = texformat;
|
||||||
PC_TexFormat pcfmt = PC_TEX_FMT_NONE;
|
|
||||||
|
|
||||||
const bool isPaletteTexture = (texformat == GX_TF_C4 || texformat == GX_TF_C8 || texformat == GX_TF_C14X2);
|
const bool isPaletteTexture = (texformat == GX_TF_C4 || texformat == GX_TF_C8 || texformat == GX_TF_C14X2);
|
||||||
if (isPaletteTexture)
|
if (isPaletteTexture)
|
||||||
|
@ -442,7 +441,6 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage)
|
||||||
expandedHeight = l.height;
|
expandedHeight = l.height;
|
||||||
CheckTempSize(l.data_size);
|
CheckTempSize(l.data_size);
|
||||||
memcpy(temp, l.data, l.data_size);
|
memcpy(temp, l.data, l.data_size);
|
||||||
pcfmt = PC_TEX_FMT_RGBA32;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,12 +449,12 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage)
|
||||||
if (!(texformat == GX_TF_RGBA8 && from_tmem))
|
if (!(texformat == GX_TF_RGBA8 && from_tmem))
|
||||||
{
|
{
|
||||||
const u8* tlut = &texMem[tlutaddr];
|
const u8* tlut = &texMem[tlutaddr];
|
||||||
pcfmt = TexDecoder_Decode(temp, src_data, expandedWidth, expandedHeight, texformat, tlut, (TlutFormat) tlutfmt);
|
TexDecoder_Decode(temp, src_data, expandedWidth, expandedHeight, texformat, tlut, (TlutFormat) tlutfmt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u8* src_data_gb = &texMem[bpmem.tex[stage/4].texImage2[stage%4].tmem_odd * TMEM_LINE_SIZE];
|
u8* src_data_gb = &texMem[bpmem.tex[stage/4].texImage2[stage%4].tmem_odd * TMEM_LINE_SIZE];
|
||||||
pcfmt = TexDecoder_DecodeRGBA8FromTmem(temp, src_data, src_data_gb, expandedWidth, expandedHeight);
|
TexDecoder_DecodeRGBA8FromTmem(temp, src_data, src_data_gb, expandedWidth, expandedHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,7 +474,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage)
|
||||||
// create the entry/texture
|
// create the entry/texture
|
||||||
if (nullptr == entry)
|
if (nullptr == entry)
|
||||||
{
|
{
|
||||||
textures[texID] = entry = g_texture_cache->CreateTexture(width, height, texLevels, pcfmt);
|
textures[texID] = entry = g_texture_cache->CreateTexture(width, height, texLevels);
|
||||||
entry->type = TCET_NORMAL;
|
entry->type = TCET_NORMAL;
|
||||||
|
|
||||||
GFX_DEBUGGER_PAUSE_AT(NEXT_NEW_TEXTURE, true);
|
GFX_DEBUGGER_PAUSE_AT(NEXT_NEW_TEXTURE, true);
|
||||||
|
@ -508,8 +506,6 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage)
|
||||||
|
|
||||||
u32 level = 1;
|
u32 level = 1;
|
||||||
// load mips - TODO: Loading mipmaps from tmem is untested!
|
// load mips - TODO: Loading mipmaps from tmem is untested!
|
||||||
if (pcfmt != PC_TEX_FMT_NONE)
|
|
||||||
{
|
|
||||||
if (use_native_mips)
|
if (use_native_mips)
|
||||||
{
|
{
|
||||||
src_data += texture_size;
|
src_data += texture_size;
|
||||||
|
@ -552,7 +548,6 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage)
|
||||||
entry->Load(l.width, l.height, l.width, level);
|
entry->Load(l.width, l.height, l.width, level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
INCSTAT(stats.numTexturesCreated);
|
INCSTAT(stats.numTexturesCreated);
|
||||||
SETSTAT(stats.numTexturesAlive, textures.size());
|
SETSTAT(stats.numTexturesAlive, textures.size());
|
||||||
|
|
|
@ -104,8 +104,7 @@ public:
|
||||||
static void ClearRenderTargets(); // currently only used by OGL
|
static void ClearRenderTargets(); // currently only used by OGL
|
||||||
static bool Find(u32 start_address, u64 hash);
|
static bool Find(u32 start_address, u64 hash);
|
||||||
|
|
||||||
virtual TCacheEntryBase* CreateTexture(unsigned int width, unsigned int height,
|
virtual TCacheEntryBase* CreateTexture(unsigned int width, unsigned int height, unsigned int tex_levels) = 0;
|
||||||
unsigned int tex_levels, PC_TexFormat pcfmt) = 0;
|
|
||||||
virtual TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h, unsigned int layers) = 0;
|
virtual TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h, unsigned int layers) = 0;
|
||||||
|
|
||||||
virtual void CompileShaders() = 0; // currently only implemented by OGL
|
virtual void CompileShaders() = 0; // currently only implemented by OGL
|
||||||
|
|
|
@ -66,25 +66,12 @@ int TexDecoder_GetBlockWidthInTexels(u32 format);
|
||||||
int TexDecoder_GetBlockHeightInTexels(u32 format);
|
int TexDecoder_GetBlockHeightInTexels(u32 format);
|
||||||
int TexDecoder_GetPaletteSize(int fmt);
|
int TexDecoder_GetPaletteSize(int fmt);
|
||||||
|
|
||||||
enum PC_TexFormat
|
void TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, int texformat, const u8* tlut, TlutFormat tlutfmt);
|
||||||
{
|
void TexDecoder_DecodeRGBA8FromTmem(u8* dst, const u8 *src_ar, const u8 *src_gb, int width, int height);
|
||||||
PC_TEX_FMT_NONE = 0,
|
|
||||||
PC_TEX_FMT_BGRA32,
|
|
||||||
PC_TEX_FMT_RGBA32,
|
|
||||||
PC_TEX_FMT_I4_AS_I8,
|
|
||||||
PC_TEX_FMT_IA4_AS_IA8,
|
|
||||||
PC_TEX_FMT_I8,
|
|
||||||
PC_TEX_FMT_IA8,
|
|
||||||
PC_TEX_FMT_RGB565,
|
|
||||||
PC_TEX_FMT_DXT1,
|
|
||||||
};
|
|
||||||
|
|
||||||
PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, int texformat, const u8* tlut, TlutFormat tlutfmt);
|
|
||||||
PC_TexFormat TexDecoder_DecodeRGBA8FromTmem(u8* dst, const u8 *src_ar, const u8 *src_gb, int width, int height);
|
|
||||||
void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth, int texformat, const u8* tlut, TlutFormat tlutfmt);
|
void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth, int texformat, const u8* tlut, TlutFormat tlutfmt);
|
||||||
void TexDecoder_DecodeTexelRGBA8FromTmem(u8 *dst, const u8 *src_ar, const u8* src_gb, int s, int t, int imageWidth);
|
void TexDecoder_DecodeTexelRGBA8FromTmem(u8 *dst, const u8 *src_ar, const u8* src_gb, int s, int t, int imageWidth);
|
||||||
|
|
||||||
void TexDecoder_SetTexFmtOverlayOptions(bool enable, bool center);
|
void TexDecoder_SetTexFmtOverlayOptions(bool enable, bool center);
|
||||||
|
|
||||||
/* Internal method, implemented by TextureDecoder_Generic and TextureDecoder_x64. */
|
/* Internal method, implemented by TextureDecoder_Generic and TextureDecoder_x64. */
|
||||||
PC_TexFormat _TexDecoder_DecodeImpl(u32 * dst, const u8 * src, int width, int height, int texformat, const u8* tlut, TlutFormat tlutfmt);
|
void _TexDecoder_DecodeImpl(u32 * dst, const u8 * src, int width, int height, int texformat, const u8* tlut, TlutFormat tlutfmt);
|
||||||
|
|
|
@ -175,7 +175,7 @@ static const char* texfmt[] = {
|
||||||
"CZ16L", "0x3D", "0x3E", "0x3F",
|
"CZ16L", "0x3D", "0x3E", "0x3F",
|
||||||
};
|
};
|
||||||
|
|
||||||
static void TexDecoder_DrawOverlay(u8 *dst, int width, int height, int texformat, PC_TexFormat pc_texformat)
|
static void TexDecoder_DrawOverlay(u8 *dst, int width, int height, int texformat)
|
||||||
{
|
{
|
||||||
int w = std::min(width, 40);
|
int w = std::min(width, 40);
|
||||||
int h = std::min(height, 10);
|
int h = std::min(height, 10);
|
||||||
|
@ -207,37 +207,9 @@ static void TexDecoder_DrawOverlay(u8 *dst, int width, int height, int texformat
|
||||||
for (int y=0; y < 10; y++)
|
for (int y=0; y < 10; y++)
|
||||||
{
|
{
|
||||||
for (int x=0; x < xcnt; x++)
|
for (int x=0; x < xcnt; x++)
|
||||||
{
|
|
||||||
switch (pc_texformat)
|
|
||||||
{
|
|
||||||
case PC_TEX_FMT_I8:
|
|
||||||
{
|
|
||||||
// TODO: Is this an acceptable way to draw in I8?
|
|
||||||
u8 *dtp = (u8*)dst;
|
|
||||||
dtp[(y + yoff) * width + x + xoff] = ptr[x] ? 0xFF : 0x88;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PC_TEX_FMT_IA8:
|
|
||||||
case PC_TEX_FMT_IA4_AS_IA8:
|
|
||||||
{
|
|
||||||
u16 *dtp = (u16*)dst;
|
|
||||||
dtp[(y + yoff) * width + x + xoff] = ptr[x] ? 0xFFFF : 0xFF00;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PC_TEX_FMT_RGB565:
|
|
||||||
{
|
|
||||||
u16 *dtp = (u16*)dst;
|
|
||||||
dtp[(y + yoff)*width + x + xoff] = ptr[x] ? 0xFFFF : 0x0000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
case PC_TEX_FMT_BGRA32:
|
|
||||||
{
|
{
|
||||||
int *dtp = (int*)dst;
|
int *dtp = (int*)dst;
|
||||||
dtp[(y + yoff) * width + x + xoff] = ptr[x] ? 0xFFFFFFFF : 0xFF000000;
|
dtp[(y + yoff) * width + x + xoff] = ptr[x] ? 0xFFFFFFFF : 0xFF000000;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ptr += 9;
|
ptr += 9;
|
||||||
}
|
}
|
||||||
|
@ -246,14 +218,12 @@ static void TexDecoder_DrawOverlay(u8 *dst, int width, int height, int texformat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, int texformat, const u8* tlut, TlutFormat tlutfmt)
|
void TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, int texformat, const u8* tlut, TlutFormat tlutfmt)
|
||||||
{
|
{
|
||||||
PC_TexFormat pc_texformat = _TexDecoder_DecodeImpl((u32*)dst, src, width, height, texformat, tlut, tlutfmt);
|
_TexDecoder_DecodeImpl((u32*)dst, src, width, height, texformat, tlut, tlutfmt);
|
||||||
|
|
||||||
if (TexFmt_Overlay_Enable && pc_texformat != PC_TEX_FMT_NONE)
|
if (TexFmt_Overlay_Enable)
|
||||||
TexDecoder_DrawOverlay(dst, width, height, texformat, pc_texformat);
|
TexDecoder_DrawOverlay(dst, width, height, texformat);
|
||||||
|
|
||||||
return pc_texformat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32 DecodePixel_IA8(u16 val)
|
static inline u32 DecodePixel_IA8(u16 val)
|
||||||
|
@ -604,15 +574,15 @@ void TexDecoder_DecodeTexelRGBA8FromTmem(u8 *dst, const u8 *src_ar, const u8* sr
|
||||||
dst[2] = val_addr_gb[1]; // B
|
dst[2] = val_addr_gb[1]; // B
|
||||||
}
|
}
|
||||||
|
|
||||||
PC_TexFormat TexDecoder_DecodeRGBA8FromTmem(u8* dst, const u8 *src_ar, const u8 *src_gb, int width, int height)
|
void TexDecoder_DecodeRGBA8FromTmem(u8* dst, const u8 *src_ar, const u8 *src_gb, int width, int height)
|
||||||
{
|
{
|
||||||
// TODO for someone who cares: Make this less slow!
|
// TODO for someone who cares: Make this less slow!
|
||||||
for (int y = 0; y < height; ++y)
|
for (int y = 0; y < height; ++y)
|
||||||
|
{
|
||||||
for (int x = 0; x < width; ++x)
|
for (int x = 0; x < width; ++x)
|
||||||
{
|
{
|
||||||
TexDecoder_DecodeTexelRGBA8FromTmem(dst, src_ar, src_gb, x, y, width-1);
|
TexDecoder_DecodeTexelRGBA8FromTmem(dst, src_ar, src_gb, x, y, width-1);
|
||||||
dst += 4;
|
dst += 4;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return PC_TEX_FMT_RGBA32;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ static void DecodeDXTBlock(u32 *dst, const DXTBlock *src, int pitch)
|
||||||
// TODO: complete SSE2 optimization of less often used texture formats.
|
// TODO: complete SSE2 optimization of less often used texture formats.
|
||||||
// TODO: refactor algorithms using _mm_loadl_epi64 unaligned loads to prefer 128-bit aligned loads.
|
// TODO: refactor algorithms using _mm_loadl_epi64 unaligned loads to prefer 128-bit aligned loads.
|
||||||
|
|
||||||
PC_TexFormat _TexDecoder_DecodeImpl(u32 * dst, const u8 * src, int width, int height, int texformat, const u8* tlut, TlutFormat tlutfmt)
|
void _TexDecoder_DecodeImpl(u32 * dst, const u8 * src, int width, int height, int texformat, const u8* tlut, TlutFormat tlutfmt)
|
||||||
{
|
{
|
||||||
const int Wsteps4 = (width + 3) / 4;
|
const int Wsteps4 = (width + 3) / 4;
|
||||||
const int Wsteps8 = (width + 7) / 8;
|
const int Wsteps8 = (width + 7) / 8;
|
||||||
|
@ -344,7 +344,4 @@ PC_TexFormat _TexDecoder_DecodeImpl(u32 * dst, const u8 * src, int width, int he
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The "copy" texture formats, too?
|
|
||||||
return PC_TEX_FMT_RGBA32;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,7 +236,7 @@ static void DecodeDXTBlock(u32 *dst, const DXTBlock *src, int pitch)
|
||||||
// TODO: complete SSE2 optimization of less often used texture formats.
|
// TODO: complete SSE2 optimization of less often used texture formats.
|
||||||
// TODO: refactor algorithms using _mm_loadl_epi64 unaligned loads to prefer 128-bit aligned loads.
|
// TODO: refactor algorithms using _mm_loadl_epi64 unaligned loads to prefer 128-bit aligned loads.
|
||||||
|
|
||||||
PC_TexFormat _TexDecoder_DecodeImpl(u32 * dst, const u8 * src, int width, int height, int texformat, const u8* tlut, TlutFormat tlutfmt)
|
void _TexDecoder_DecodeImpl(u32 * dst, const u8 * src, int width, int height, int texformat, const u8* tlut, TlutFormat tlutfmt)
|
||||||
{
|
{
|
||||||
const int Wsteps4 = (width + 3) / 4;
|
const int Wsteps4 = (width + 3) / 4;
|
||||||
const int Wsteps8 = (width + 7) / 8;
|
const int Wsteps8 = (width + 7) / 8;
|
||||||
|
@ -1273,7 +1273,4 @@ PC_TexFormat _TexDecoder_DecodeImpl(u32 * dst, const u8 * src, int width, int he
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The "copy" texture formats, too?
|
|
||||||
return PC_TEX_FMT_RGBA32;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue