Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #774 from magcius/texdecode-cleanup
Clean up the TextureDecoder and some related things
  • Loading branch information
shuffle2 committed Sep 5, 2014
2 parents fb3a668 + 76b4dbd commit a9a6270
Show file tree
Hide file tree
Showing 17 changed files with 1,538 additions and 3,883 deletions.
16 changes: 0 additions & 16 deletions Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp
Expand Up @@ -220,22 +220,6 @@ void Interpreter::lwz(UGeckoInstruction _inst)
{
m_GPR[_inst.RD] = temp;
}

// hack to detect SelectThread loop
// should probably run a pass through memory instead before execution
// but that would be dangerous

// Enable idle skipping?
/*
if ((_inst.hex & 0xFFFF0000)==0x800D0000 &&
Memory::ReadUnchecked_U32(PC+4)==0x28000000 &&
Memory::ReadUnchecked_U32(PC+8)==0x4182fff8)
{
if (CommandProcessor::AllowIdleSkipping() && PixelEngine::AllowIdleSkipping())
{
CoreTiming::Idle();
}
}*/
}

void Interpreter::lwzu(UGeckoInstruction _inst)
Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp
Expand Up @@ -94,7 +94,6 @@ void Jit64::lXXx(UGeckoInstruction inst)
// (mb2): I agree,
// IMHO those Idles should always be skipped and replaced by a more controllable "native" Idle methode
// ... maybe the throttle one already do that :p
// if (CommandProcessor::AllowIdleSkipping() && PixelEngine::AllowIdleSkipping())
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bSkipIdle &&
inst.OPCD == 32 &&
(inst.hex & 0xFFFF0000) == 0x800D0000 &&
Expand Down
1 change: 0 additions & 1 deletion Source/Core/VideoBackends/D3D/main.cpp
Expand Up @@ -72,7 +72,6 @@ void InitBackendInfo()
}

g_Config.backend_info.APIType = API_D3D;
g_Config.backend_info.bUseRGBATextures = true; // the GX formats barely match any D3D11 formats
g_Config.backend_info.bUseMinimalMipCount = true;
g_Config.backend_info.bSupportsExclusiveFullscreen = true;
g_Config.backend_info.bSupportsDualSourceBlend = true;
Expand Down
1 change: 0 additions & 1 deletion Source/Core/VideoBackends/OGL/main.cpp
Expand Up @@ -132,7 +132,6 @@ static void GetShaders(std::vector<std::string> &shaders)
static void InitBackendInfo()
{
g_Config.backend_info.APIType = API_OPENGL;
g_Config.backend_info.bUseRGBATextures = true;
g_Config.backend_info.bUseMinimalMipCount = false;
g_Config.backend_info.bSupportsExclusiveFullscreen = false;
//g_Config.backend_info.bSupportsDualSourceBlend = true; // is gpu dependent and must be set in renderer
Expand Down
12 changes: 7 additions & 5 deletions Source/Core/VideoBackends/Software/TextureSampler.cpp
Expand Up @@ -106,6 +106,7 @@ void SampleMip(s32 s, s32 t, s32 mip, bool linear, u8 texmap, u8 *sample)
TexMode0& tm0 = texUnit.texMode0[subTexmap];
TexImage0& ti0 = texUnit.texImage0[subTexmap];
TexTLUT& texTlut = texUnit.texTlut[subTexmap];
TlutFormat tlutfmt = (TlutFormat) texTlut.tlut_format;

u8 *imageSrc, *imageSrcOdd = nullptr;
if (texUnit.texImage1[subTexmap].image_type)
Expand All @@ -124,6 +125,7 @@ void SampleMip(s32 s, s32 t, s32 mip, bool linear, u8 texmap, u8 *sample)
int imageHeight = ti0.height;

int tlutAddress = texTlut.tmem_offset << 9;
const u8* tlut = &texMem[tlutAddress];

// reduce sample location and texture size to mip level
// move texture pointer to mip location
Expand Down Expand Up @@ -181,16 +183,16 @@ void SampleMip(s32 s, s32 t, s32 mip, bool linear, u8 texmap, u8 *sample)

if (!(ti0.format == GX_TF_RGBA8 && texUnit.texImage1[subTexmap].image_type))
{
TexDecoder_DecodeTexel(sampledTex, imageSrc, imageS, imageT, imageWidth, ti0.format, tlutAddress, texTlut.tlut_format);
TexDecoder_DecodeTexel(sampledTex, imageSrc, imageS, imageT, imageWidth, ti0.format, tlut, tlutfmt);
SetTexel(sampledTex, texel, (128 - fractS) * (128 - fractT));

TexDecoder_DecodeTexel(sampledTex, imageSrc, imageSPlus1, imageT, imageWidth, ti0.format, tlutAddress, texTlut.tlut_format);
TexDecoder_DecodeTexel(sampledTex, imageSrc, imageSPlus1, imageT, imageWidth, ti0.format, tlut, tlutfmt);
AddTexel(sampledTex, texel, (fractS) * (128 - fractT));

TexDecoder_DecodeTexel(sampledTex, imageSrc, imageS, imageTPlus1, imageWidth, ti0.format, tlutAddress, texTlut.tlut_format);
TexDecoder_DecodeTexel(sampledTex, imageSrc, imageS, imageTPlus1, imageWidth, ti0.format, tlut, tlutfmt);
AddTexel(sampledTex, texel, (128 - fractS) * (fractT));

TexDecoder_DecodeTexel(sampledTex, imageSrc, imageSPlus1, imageTPlus1, imageWidth, ti0.format, tlutAddress, texTlut.tlut_format);
TexDecoder_DecodeTexel(sampledTex, imageSrc, imageSPlus1, imageTPlus1, imageWidth, ti0.format, tlut, tlutfmt);
AddTexel(sampledTex, texel, (fractS) * (fractT));
}
else
Expand Down Expand Up @@ -224,7 +226,7 @@ void SampleMip(s32 s, s32 t, s32 mip, bool linear, u8 texmap, u8 *sample)
WrapCoord(imageT, tm0.wrap_t, imageHeight);

if (!(ti0.format == GX_TF_RGBA8 && texUnit.texImage1[subTexmap].image_type))
TexDecoder_DecodeTexel(sample, imageSrc, imageS, imageT, imageWidth, ti0.format, tlutAddress, texTlut.tlut_format);
TexDecoder_DecodeTexel(sample, imageSrc, imageS, imageT, imageWidth, ti0.format, tlut, tlutfmt);
else
TexDecoder_DecodeTexelRGBA8FromTmem(sample, imageSrc, imageSrcOdd, imageS, imageT, imageWidth);
}
Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoCommon/CMakeLists.txt
Expand Up @@ -23,6 +23,7 @@ set(SRCS BPFunctions.cpp
Statistics.cpp
TextureCacheBase.cpp
TextureConversionShader.cpp
TextureDecoder_Common.cpp
VertexLoader.cpp
VertexLoaderManager.cpp
VertexLoader_Color.cpp
Expand Down
2 changes: 0 additions & 2 deletions Source/Core/VideoCommon/CommandProcessor.h
Expand Up @@ -141,8 +141,6 @@ void GatherPipeBursted();
void UpdateInterrupts(u64 userdata);
void UpdateInterruptsFromVideoBackend(u64 userdata);

bool AllowIdleSkipping();

void SetCpClearRegister();
void SetCpControlRegister();
void SetCpStatusRegister();
Expand Down
7 changes: 4 additions & 3 deletions Source/Core/VideoCommon/TextureCacheBase.cpp
Expand Up @@ -490,8 +490,8 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int const stage,
{
if (!(texformat == GX_TF_RGBA8 && from_tmem))
{
pcfmt = TexDecoder_Decode(temp, src_data, expandedWidth,
expandedHeight, texformat, tlutaddr, tlutfmt, g_ActiveConfig.backend_info.bUseRGBATextures);
const u8* tlut = &texMem[tlutaddr];
pcfmt = TexDecoder_Decode(temp, src_data, expandedWidth, expandedHeight, texformat, tlut, (TlutFormat) tlutfmt);
}
else
{
Expand Down Expand Up @@ -567,7 +567,8 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int const stage,
const u8*& mip_src_data = from_tmem
? ((level % 2) ? ptr_odd : ptr_even)
: src_data;
TexDecoder_Decode(temp, mip_src_data, expanded_mip_width, expanded_mip_height, texformat, tlutaddr, tlutfmt, g_ActiveConfig.backend_info.bUseRGBATextures);
const u8* tlut = &texMem[tlutaddr];
TexDecoder_Decode(temp, mip_src_data, expanded_mip_width, expanded_mip_height, texformat, tlut, (TlutFormat) tlutfmt);
mip_src_data += TexDecoder_GetTextureSizeInBytes(expanded_mip_width, expanded_mip_height, texformat);

entry->Load(mip_width, mip_height, expanded_mip_width, level);
Expand Down
20 changes: 13 additions & 7 deletions Source/Core/VideoCommon/TextureDecoder.h
Expand Up @@ -52,9 +52,12 @@ enum TextureFormat
GX_CTF_Z16L = 0xC | _GX_TF_ZTF | _GX_TF_CTF,
};

extern const char* texfmt[];
extern const unsigned char sfont_map[];
extern const unsigned char sfont_raw[][9*10];
enum TlutFormat
{
GX_TL_IA8 = 0x0,
GX_TL_RGB565 = 0x1,
GX_TL_RGB5A3 = 0x2,
};

int TexDecoder_GetTexelSizeInNibbles(int format);
int TexDecoder_GetTextureSizeInBytes(int width, int height, int format);
Expand All @@ -75,9 +78,12 @@ enum PC_TexFormat
PC_TEX_FMT_DXT1,
};

PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, int texformat, int tlutaddr, int tlutfmt,bool rgbaOnly = false);
PC_TexFormat GetPC_TexFormat(int texformat, int tlutfmt);
void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth, int texformat, int tlutaddr, int tlutfmt);
void TexDecoder_DecodeTexelRGBA8FromTmem(u8 *dst, const u8 *src_ar, const u8* src_gb, int s, int t, int imageWidth);
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_DecodeTexelRGBA8FromTmem(u8 *dst, const u8 *src_ar, const u8* src_gb, int s, int t, int imageWidth);

void TexDecoder_SetTexFmtOverlayOptions(bool enable, bool center);

/* 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);

0 comments on commit a9a6270

Please sign in to comment.