Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial texture replacement support #8715

Merged
merged 34 commits into from
May 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bf39e61
Setup initial structure for texture replacements.
unknownbrackets Apr 30, 2016
c4e9843
Add config to save or load replaced textures.
unknownbrackets Apr 30, 2016
cf53948
Implement some initial hashing so it's not broken.
unknownbrackets Apr 30, 2016
5dbc2b9
Initial support for saving textures to PNGs.
unknownbrackets Apr 30, 2016
9039dd6
Move TextureReplacer to Core.
unknownbrackets Apr 30, 2016
565653c
Save and load textures using full key.
unknownbrackets Apr 30, 2016
d6e5df6
Save individual mip levels.
unknownbrackets Apr 30, 2016
59ada74
Allow hashes to be ignored explicitly.
unknownbrackets Apr 30, 2016
4f3bac1
Actually load the texture replacement ini file.
unknownbrackets Apr 30, 2016
f039259
Use a same-everywhere quick hash for now.
unknownbrackets Apr 30, 2016
0c357c0
Pass w/h in for replacement lookup.
unknownbrackets Apr 30, 2016
120cd0f
Don't convert pixels we're not going to use anyway.
unknownbrackets Apr 30, 2016
6d0c7a9
Skip gaps in texture replacement hashing.
unknownbrackets May 1, 2016
c1a8edf
Replace textures from PNGs.
unknownbrackets May 1, 2016
149de41
Skip replacements for PPGe textures.
unknownbrackets May 1, 2016
9ffc717
Properly save 16-bit textures for replacements.
unknownbrackets May 1, 2016
f536182
Cache texture replacement lookup info.
unknownbrackets May 1, 2016
7528605
Correct loading replaced upscaled textures.
unknownbrackets May 1, 2016
7a4af06
Save new textures into a separate path.
unknownbrackets May 1, 2016
e1fd6b6
Account for scaleFactor when saving clipped PNG.
unknownbrackets May 1, 2016
223f95f
Allow a short alias for video frames, etc.
unknownbrackets May 1, 2016
bed82da
Make ini case insensitive.
unknownbrackets May 1, 2016
c4b2752
Disable texture replacement on Qt.
unknownbrackets May 1, 2016
f26c032
Check alpha when loading replaced textures.
unknownbrackets May 1, 2016
23ab2cd
Vulkan: Correct check alpha.
unknownbrackets May 1, 2016
cd6f36a
Correct handling of 8 bit and no-alpha PNGs.
unknownbrackets May 1, 2016
4505544
Attempt to buildfix Symbian.
unknownbrackets May 1, 2016
329be68
Fix error when disabled.
unknownbrackets May 1, 2016
99d2935
Track video addresses in texture cache.
unknownbrackets May 1, 2016
f5b93bc
Remove global num videos hack.
unknownbrackets May 1, 2016
c20075b
Pass video info to texture replacements.
unknownbrackets May 1, 2016
994d2dd
Skip video in replacement saving by default.
unknownbrackets May 1, 2016
c30287c
Another buildfix for Qt, linking issue.
unknownbrackets May 1, 2016
2e1986d
Fix a few reorder warnings.
unknownbrackets May 1, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,8 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/Screenshot.h
Core/System.cpp
Core/System.h
Core/TextureReplacer.cpp
Core/TextureReplacer.h
Core/Util/AudioFormat.cpp
Core/Util/AudioFormat.h
Core/Util/GameManager.cpp
Expand Down
33 changes: 33 additions & 0 deletions Common/ColorConv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,39 @@ void ConvertRGBA4444ToRGBA8888(u32 *dst32, const u16 *src, const u32 numPixels)
}
}

void ConvertABGR565ToRGBA8888(u32 *dst32, const u16 *src, const u32 numPixels) {
u8 *dst = (u8 *)dst32;
for (u32 x = 0; x < numPixels; x++) {
u16 col = src[x];
dst[x * 4] = Convert5To8((col >> 11) & 0x1f);
dst[x * 4 + 1] = Convert6To8((col >> 5) & 0x3f);
dst[x * 4 + 2] = Convert5To8((col) & 0x1f);
dst[x * 4 + 3] = 255;
}
}

void ConvertABGR1555ToRGBA8888(u32 *dst32, const u16 *src, const u32 numPixels) {
u8 *dst = (u8 *)dst32;
for (u32 x = 0; x < numPixels; x++) {
u16 col = src[x];
dst[x * 4] = Convert5To8((col >> 11) & 0x1f);
dst[x * 4 + 1] = Convert5To8((col >> 6) & 0x1f);
dst[x * 4 + 2] = Convert5To8((col >> 1) & 0x1f);
dst[x * 4 + 3] = (col & 1) ? 255 : 0;
}
}

void ConvertABGR4444ToRGBA8888(u32 *dst32, const u16 *src, const u32 numPixels) {
u8 *dst = (u8 *)dst32;
for (u32 x = 0; x < numPixels; x++) {
u16 col = src[x];
dst[x * 4] = Convert4To8(col >> 12);
dst[x * 4 + 1] = Convert4To8((col >> 8) & 0xf);
dst[x * 4 + 2] = Convert4To8((col >> 4) & 0xf);
dst[x * 4 + 3] = Convert4To8(col & 0xf);
}
}

void ConvertRGBA4444ToBGRA8888(u32 *dst32, const u16 *src, const u32 numPixels) {
u8 *dst = (u8 *)dst32;
for (u32 x = 0; x < numPixels; x++) {
Expand Down
4 changes: 4 additions & 0 deletions Common/ColorConv.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ void ConvertRGBA565ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);
void ConvertRGBA5551ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);
void ConvertRGBA4444ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);

void ConvertABGR565ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);
void ConvertABGR1555ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);
void ConvertABGR4444ToRGBA8888(u32 *dst, const u16 *src, const u32 numPixels);

void ConvertRGBA4444ToBGRA8888(u32 *dst, const u16 *src, const u32 numPixels);
void ConvertRGBA5551ToBGRA8888(u32 *dst, const u16 *src, const u32 numPixels);
void ConvertRGB565ToBGRA8888(u32 *dst, const u16 *src, const u32 numPixels);
Expand Down
3 changes: 2 additions & 1 deletion Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,9 @@ static ConfigSetting graphicsSettings[] = {
ConfigSetting("ImmersiveMode", &g_Config.bImmersiveMode, false, true, true),

ReportedConfigSetting("TrueColor", &g_Config.bTrueColor, true, true, true),

ReportedConfigSetting("MipMap", &g_Config.bMipMap, true, true, true),
ReportedConfigSetting("ReplaceTextures", &g_Config.bReplaceTextures, true, true, true),
ReportedConfigSetting("SaveNewTextures", &g_Config.bSaveNewTextures, false, true, true),

ReportedConfigSetting("TexScalingLevel", &g_Config.iTexScalingLevel, 1, true, true),
ReportedConfigSetting("TexScalingType", &g_Config.iTexScalingType, 0, true, true),
Expand Down
2 changes: 2 additions & 0 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ struct Config {
int bHighQualityDepth;
bool bTrueColor;
bool bMipMap;
bool bReplaceTextures;
bool bSaveNewTextures;
int iTexScalingLevel; // 1 = off, 2 = 2x, ..., 5 = 5x
int iTexScalingType; // 0 = xBRZ, 1 = Hybrid
bool bTexDeposterize;
Expand Down
2 changes: 2 additions & 0 deletions Core/Core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
<ClCompile Include="..\ext\udis86\syn-intel.c" />
<ClCompile Include="..\ext\udis86\syn.c" />
<ClCompile Include="..\ext\udis86\udis86.c" />
<ClCompile Include="TextureReplacer.cpp" />
<ClCompile Include="Compatibility.cpp" />
<ClCompile Include="Config.cpp" />
<ClCompile Include="Core.cpp" />
Expand Down Expand Up @@ -506,6 +507,7 @@
<ClInclude Include="..\ext\udis86\types.h" />
<ClInclude Include="..\ext\udis86\udint.h" />
<ClInclude Include="..\ext\udis86\udis86.h" />
<ClInclude Include="TextureReplacer.h" />
<ClInclude Include="Compatibility.h" />
<ClInclude Include="Config.h" />
<ClInclude Include="Core.h" />
Expand Down
6 changes: 6 additions & 0 deletions Core/Core.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,9 @@
<ClCompile Include="FileLoaders\RamCachingFileLoader.cpp">
<Filter>FileLoaders</Filter>
</ClCompile>
<ClCompile Include="TextureReplacer.cpp">
<Filter>Core</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ELF\ElfReader.h">
Expand Down Expand Up @@ -1176,6 +1179,9 @@
<ClInclude Include="FileLoaders\RamCachingFileLoader.h">
<Filter>FileLoaders</Filter>
</ClInclude>
<ClInclude Include="TextureReplacer.h">
<Filter>Core</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
Expand Down
2 changes: 1 addition & 1 deletion Core/HLE/sceAtrac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ struct Atrac {
channels_(0), outputChannels_(2), bitrate_(64), bytesPerFrame_(0), bufferMaxSize_(0), jointStereo_(0),
currentSample_(0), endSample_(0), firstSampleOffset_(0), dataOff_(0),
loopStartSample_(-1), loopEndSample_(-1), loopNum_(0),
failedDecode_(false), codecType_(0), ignoreDataBuf_(false),
failedDecode_(false), ignoreDataBuf_(false), codecType_(0),
bufferState_(ATRAC_STATUS_NO_DATA) {
memset(&first_, 0, sizeof(first_));
memset(&second_, 0, sizeof(second_));
Expand Down
4 changes: 0 additions & 4 deletions Core/HW/MediaEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ extern "C" {
}
#endif // USE_FFMPEG

int g_iNumVideos = 0;

#ifdef USE_FFMPEG
static AVPixelFormat getSwsFormat(int pspFormat)
{
Expand Down Expand Up @@ -149,12 +147,10 @@ MediaEngine::MediaEngine(): m_pdata(0) {
m_ringbuffersize = 0;
m_mpegheaderReadPos = 0;
m_audioType = PSP_CODEC_AT3PLUS; // in movie, we use only AT3+ audio
g_iNumVideos++;
}

MediaEngine::~MediaEngine() {
closeMedia();
g_iNumVideos--;
}

void MediaEngine::closeMedia() {
Expand Down
2 changes: 1 addition & 1 deletion Core/HW/SasReverb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void SasReverb::SetPreset(int preset) {
template<int bufsize>
class BufferWrapper {
public:
BufferWrapper(int16_t *buffer, int position, int usedSize) : buf_(buffer), pos_(position), base_(bufsize - usedSize), end_(bufsize), size_(usedSize) {}
BufferWrapper(int16_t *buffer, int position, int usedSize) : buf_(buffer), pos_(position), end_(bufsize), base_(bufsize - usedSize), size_(usedSize) {}
int16_t &operator [](int index) {
int addr = pos_ + index;
if (addr >= end_) { addr -= size_; }
Expand Down
2 changes: 2 additions & 0 deletions Core/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,8 @@ std::string GetSysDirectory(PSPDirectories directoryType) {
return g_Config.memStickDirectory + "PSP/PPSSPP_STATE/";
case DIRECTORY_CACHE:
return g_Config.memStickDirectory + "PSP/SYSTEM/CACHE/";
case DIRECTORY_TEXTURES:
return g_Config.memStickDirectory + "PSP/TEXTURES/";
case DIRECTORY_APP_CACHE:
if (!g_Config.appCacheDirectory.empty()) {
return g_Config.appCacheDirectory;
Expand Down
1 change: 1 addition & 0 deletions Core/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum PSPDirectories {
DIRECTORY_DUMP,
DIRECTORY_SAVESTATE,
DIRECTORY_CACHE,
DIRECTORY_TEXTURES,
DIRECTORY_APP_CACHE, // Use the OS app cache if available
};

Expand Down
Loading