mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Add hires texture support to OpenGL
Currently still only dumps files as .tga but supports loading as .png, .bmp,.tga , .dds This is by baby.lueshi git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3166 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -60,6 +60,7 @@ void Config::Load()
|
||||
iniFile.Get("Settings", "ShowEFBCopyRegions", &bShowEFBCopyRegions, false);
|
||||
iniFile.Get("Settings", "DLOptimize", &iCompileDLsLevel, 0);
|
||||
iniFile.Get("Settings", "DumpTextures", &bDumpTextures, 0);
|
||||
iniFile.Get("Settings", "HiresTextures", &bHiresTextures, 0);
|
||||
iniFile.Get("Settings", "DumpEFBTarget", &bDumpEFBTarget, 0);
|
||||
iniFile.Get("Settings", "DumpFrames", &bDumpFrames, 0);
|
||||
iniFile.Get("Settings", "FreeLook", &bFreeLook, 0);
|
||||
@ -110,6 +111,9 @@ void Config::GameIniLoad() {
|
||||
if (iniFile->Exists("Video", "SafeTextureCache"))
|
||||
iniFile->Get("Video", "SafeTextureCache", &bSafeTextureCache, false);
|
||||
|
||||
if (iniFile->Exists("Video", "SMGhack"))
|
||||
iniFile->Get("Video", "SMGhack", &bSMGhack, false);
|
||||
|
||||
if (iniFile->Exists("Video", "MSAA"))
|
||||
iniFile->Get("Video", "MSAA", &iMultisampleMode, 0);
|
||||
|
||||
@ -146,6 +150,7 @@ void Config::Save()
|
||||
iniFile.Set("Settings", "DLOptimize", iCompileDLsLevel);
|
||||
iniFile.Set("Settings", "Show", iCompileDLsLevel);
|
||||
iniFile.Set("Settings", "DumpTextures", bDumpTextures);
|
||||
iniFile.Set("Settings", "HiresTextures", bHiresTextures);
|
||||
iniFile.Set("Settings", "DumpEFBTarget", bDumpEFBTarget);
|
||||
iniFile.Set("Settings", "DumpFrames", bDumpFrames);
|
||||
iniFile.Set("Settings", "FreeLook", bFreeLook);
|
||||
@ -167,6 +172,7 @@ void Config::Save()
|
||||
iniFile.Set("Hacks", "EFBCopyDisableHotKey", bEFBCopyDisableHotKey);
|
||||
iniFile.Set("Hacks", "ProjectionHax1", bProjectionHax1);
|
||||
iniFile.Set("Hacks", "EFBToTextureEnable", bCopyEFBToRAM);
|
||||
iniFile.Set("Hacks", "SMGhack", bSMGhack);
|
||||
|
||||
iniFile.Save(FULL_CONFIG_DIR "gfx_opengl.ini");
|
||||
}
|
||||
|
@ -84,6 +84,8 @@ struct Config
|
||||
|
||||
// Utility
|
||||
bool bDumpTextures;
|
||||
bool bHiresTextures;
|
||||
bool bHiresTextures;
|
||||
bool bDumpEFBTarget;
|
||||
bool bDumpFrames;
|
||||
bool bFreeLook;
|
||||
|
@ -54,6 +54,7 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog)
|
||||
EVT_CHECKBOX(ID_TEXFMTOVERLAY, ConfigDialog::AdvancedSettingsChanged)
|
||||
EVT_CHECKBOX(ID_TEXFMTCENTER, ConfigDialog::AdvancedSettingsChanged)
|
||||
EVT_CHECKBOX(ID_DUMPTEXTURES, ConfigDialog::AdvancedSettingsChanged)
|
||||
EVT_CHECKBOX(ID_HIRESTEXTURES, ConfigDialog::AdvancedSettingsChanged)
|
||||
EVT_CHECKBOX(ID_DUMPEFBTARGET, ConfigDialog::AdvancedSettingsChanged)
|
||||
EVT_CHECKBOX(ID_DUMPFRAMES, ConfigDialog::AdvancedSettingsChanged)
|
||||
EVT_CHECKBOX(ID_FREELOOK, ConfigDialog::AdvancedSettingsChanged)
|
||||
@ -339,6 +340,8 @@ void ConfigDialog::CreateGUIControls()
|
||||
sbUtilities = new wxStaticBoxSizer(wxVERTICAL, m_PageAdvanced, wxT("Utilities"));
|
||||
m_DumpTextures = new wxCheckBox(m_PageAdvanced, ID_DUMPTEXTURES, wxT("Dump textures"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
m_DumpTextures->SetValue(g_Config.bDumpTextures);
|
||||
m_HiresTextures = new wxCheckBox(m_PageAdvanced, ID_HIRESTEXTURES, wxT("Load Hires textures"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
m_HiresTextures->SetValue(g_Config.bHiresTextures);
|
||||
m_DumpEFBTarget = new wxCheckBox(m_PageAdvanced, ID_DUMPEFBTARGET, wxT("Dump EFB Target"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
m_DumpEFBTarget->SetValue(g_Config.bDumpEFBTarget);
|
||||
m_DumpFrames = new wxCheckBox(m_PageAdvanced, ID_DUMPFRAMES, wxT("Dump Rendered Frames"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||
@ -374,6 +377,7 @@ void ConfigDialog::CreateGUIControls()
|
||||
m_DstAlphaPass->SetToolTip(wxT("This renders a second time to set alpha to a constant value,"
|
||||
"\nDisabling it may speed up some games, but could also cause glitches."));
|
||||
m_DisableFog->SetToolTip(wxT("This option should not require a restart."));
|
||||
m_SMGh->SetToolTip(wxT("SMG hack for Super Mario Galaxy, Mario Kart Wii and other game probably it will be disable for other game and during SMG ending sequence or movies use the M key to turn this option on or off"));
|
||||
|
||||
// Sizers
|
||||
sHacks = new wxGridBagSizer(0, 0);
|
||||
@ -418,7 +422,8 @@ void ConfigDialog::CreateGUIControls()
|
||||
//sUtilities = new wxBoxSizer(wxHORIZONTAL);
|
||||
sUtilities = new wxGridBagSizer(0, 0);
|
||||
sUtilities->Add(m_DumpTextures, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
sUtilities->Add(m_DumpEFBTarget, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
sUtilities->Add(m_HiresTextures, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
sUtilities->Add(m_DumpEFBTarget, wxGBPosition(0, 2), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
sUtilities->Add(m_DumpFrames, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
sUtilities->Add(m_FreeLook, wxGBPosition(1, 1), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
||||
sbUtilities->Add(sUtilities, 1, wxEXPAND);
|
||||
@ -554,6 +559,9 @@ void ConfigDialog::AdvancedSettingsChanged(wxCommandEvent& event)
|
||||
case ID_DUMPTEXTURES:
|
||||
g_Config.bDumpTextures = m_DumpTextures->IsChecked();
|
||||
break;
|
||||
case ID_HIRESTEXTURES:
|
||||
g_Config.bHiresTextures = m_HiresTextures->IsChecked();
|
||||
break;
|
||||
case ID_DUMPEFBTARGET:
|
||||
g_Config.bDumpEFBTarget = m_DumpEFBTarget->IsChecked();
|
||||
break;
|
||||
|
@ -106,6 +106,8 @@ class ConfigDialog : public wxDialog
|
||||
wxCheckBox *m_DisableFog;
|
||||
wxCheckBox *m_DstAlphaPass;
|
||||
wxCheckBox *m_DumpTextures;
|
||||
wxCheckBox *m_HiresTextures;
|
||||
wxCheckBox *m_HiresTextures;
|
||||
wxCheckBox *m_DumpEFBTarget;
|
||||
wxCheckBox *m_DumpFrames;
|
||||
wxCheckBox *m_FreeLook;
|
||||
@ -167,6 +169,8 @@ class ConfigDialog : public wxDialog
|
||||
ID_SMGHACK,
|
||||
|
||||
ID_DUMPTEXTURES,
|
||||
ID_HIRESTEXTURES,
|
||||
ID_HIRESTEXTURES,
|
||||
ID_DUMPEFBTARGET,
|
||||
ID_DUMPFRAMES,
|
||||
ID_FREELOOK,
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "Globals.h"
|
||||
#include "CommonPaths.h"
|
||||
#include "StringUtil.h"
|
||||
|
||||
#include <fstream>
|
||||
#ifdef _WIN32
|
||||
#define _interlockedbittestandset workaround_ms_header_bug_platform_sdk6_set
|
||||
#define _interlockedbittestandreset workaround_ms_header_bug_platform_sdk6_reset
|
||||
@ -34,6 +34,7 @@
|
||||
#endif
|
||||
|
||||
#include "Config.h"
|
||||
#include "Hash.h"
|
||||
#include "Statistics.h"
|
||||
#include "Profiler.h"
|
||||
#include "ImageWrite.h"
|
||||
@ -47,6 +48,10 @@
|
||||
#include "PixelShaderCache.h"
|
||||
#include "PixelShaderManager.h"
|
||||
#include "VertexShaderManager.h"
|
||||
#include "FileUtil.h"
|
||||
#include "HiresTextures.h"
|
||||
|
||||
#include "../../../Core/Core/Src/ConfigManager.h" // FIXME
|
||||
|
||||
u8 *TextureMngr::temp = NULL;
|
||||
TextureMngr::TexCache TextureMngr::textures;
|
||||
@ -156,6 +161,7 @@ void TextureMngr::Init()
|
||||
{
|
||||
temp = (u8*)AllocateMemoryPages(TEMP_SIZE);
|
||||
TexDecoder_SetTexFmtOverlayOptions(g_Config.bTexFmtOverlayEnable, g_Config.bTexFmtOverlayCenter);
|
||||
HiresTextures::Init(((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID().c_str());
|
||||
}
|
||||
|
||||
void TextureMngr::Invalidate(bool shutdown)
|
||||
@ -163,6 +169,7 @@ void TextureMngr::Invalidate(bool shutdown)
|
||||
for (TexCache::iterator iter = textures.begin(); iter != textures.end(); ++iter)
|
||||
iter->second.Destroy(shutdown);
|
||||
textures.clear();
|
||||
HiresTextures::Shutdown();
|
||||
}
|
||||
|
||||
void TextureMngr::Shutdown()
|
||||
@ -237,25 +244,25 @@ void TextureMngr::InvalidateRange(u32 start_address, u32 size) {
|
||||
|
||||
TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width, int height, int tex_format, int tlutaddr, int tlutfmt)
|
||||
{
|
||||
/* notes (about "UNsafe texture cache"):
|
||||
* Have to be removed soon.
|
||||
* But we keep it until the "safe" way became rock solid
|
||||
* pros: it has an unique ID held by the texture data itself (@address) once cached.
|
||||
* cons: it writes this unique ID in the gc RAM <- very dangerous (break MP1) and ugly
|
||||
*/
|
||||
/* notes (about "safe texture cache"):
|
||||
* Metroids text issue (character table):
|
||||
* Same addr, same GX_TF_C4 texture data but different TLUT (hence different outputs).
|
||||
* That's why we have to hash the TLUT too for TLUT tex_format dependent textures (ie. GX_TF_C4, GX_TF_C8, GX_TF_C14X2).
|
||||
* And since the address and tex data don't change, the key index in the cacheEntry map can't be the address but
|
||||
* have to be a real unique ID.
|
||||
* DONE but not satifiying yet -> may break copyEFBToTexture sometimes.
|
||||
*
|
||||
* Pokemon Colosseum text issue (plain text):
|
||||
* Use a GX_TF_I4 512x512 text-flush-texture at a const address.
|
||||
* The problem here was just the sparse hash on the texture. This texture is partly overwrited (what is needed only)
|
||||
* so lot's of remaning old text. Thin white chars on black bg too.
|
||||
*/
|
||||
// notes (about "UNsafe texture cache"):
|
||||
// Have to be removed soon.
|
||||
// But we keep it until the "safe" way became rock solid
|
||||
// pros: it has an unique ID held by the texture data itself (@address) once cached.
|
||||
// cons: it writes this unique ID in the gc RAM <- very dangerous (break MP1) and ugly
|
||||
|
||||
// notes (about "safe texture cache"):
|
||||
// Metroids text issue (character table):
|
||||
// Same addr, same GX_TF_C4 texture data but different TLUT (hence different outputs).
|
||||
// That's why we have to hash the TLUT too for TLUT tex_format dependent textures (ie. GX_TF_C4, GX_TF_C8, GX_TF_C14X2).
|
||||
// And since the address and tex data don't change, the key index in the cacheEntry map can't be the address but
|
||||
// have to be a real unique ID.
|
||||
// DONE but not satifiying yet -> may break copyEFBToTexture sometimes.
|
||||
|
||||
// Pokemon Colosseum text issue (plain text):
|
||||
// Use a GX_TF_I4 512x512 text-flush-texture at a const address.
|
||||
// The problem here was just the sparse hash on the texture. This texture is partly overwrited (what is needed only)
|
||||
// so lot's of remaning old text. Thin white chars on black bg too.
|
||||
|
||||
// TODO: - clean this up when ready to kill old "unsafe texture cache"
|
||||
// - fix the key index situation with CopyRenderTargetToTexture.
|
||||
// Could happen only for GX_TF_C4, GX_TF_C8 and GX_TF_C14X2 fmt.
|
||||
@ -366,6 +373,26 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||
if (expandedWidth != width)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, expandedWidth);
|
||||
|
||||
u32 texHash = HashFNV(temp, entry.size_in_bytes);
|
||||
if (g_Config.bHiresTextures)
|
||||
{
|
||||
//Load Custom textures
|
||||
char texPathTemp[MAX_PATH];
|
||||
int oldWidth = width;
|
||||
int oldHeight = height;
|
||||
sprintf(texPathTemp, "%s_%08x_%i", ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID().c_str(), texHash, tex_format);
|
||||
PC_TexFormat customTex = HiresTextures::GetHiresTex(texPathTemp, &width, &height, temp);
|
||||
|
||||
if (customTex != PC_TEX_FMT_NONE)
|
||||
{
|
||||
entry.size_in_bytes = sizeof(temp);
|
||||
entry.scaleX = (float) width / oldWidth;
|
||||
entry.scaleY = (float) height / oldHeight;
|
||||
INFO_LOG(VIDEO, "loading custom texture from %s", texPathTemp);
|
||||
dfmt = customTex;
|
||||
}
|
||||
}
|
||||
|
||||
if (dfmt != PC_TEX_FMT_DXT1)
|
||||
{
|
||||
int gl_format;
|
||||
@ -381,6 +408,11 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||
gl_iformat = 4;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case PC_TEX_FMT_RGBA32:
|
||||
gl_format = GL_RGBA;
|
||||
gl_iformat = 4;
|
||||
gl_type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case PC_TEX_FMT_I8:
|
||||
gl_format = GL_LUMINANCE;
|
||||
gl_iformat = GL_INTENSITY;
|
||||
@ -434,10 +466,13 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||
|
||||
if (g_Config.bDumpTextures) // dump texture to file
|
||||
{
|
||||
static int counter = 0;
|
||||
char szTemp[MAX_PATH];
|
||||
sprintf(szTemp, "%s/txt_%04i_%i.tga", FULL_DUMP_TEXTURES_DIR, counter++, tex_format);
|
||||
SaveTexture(szTemp,target, entry.texture, width, height);
|
||||
|
||||
sprintf(szTemp, "%s/%s_%08x_%i.tga", FULL_DUMP_TEXTURES_DIR, ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID().c_str(), texHash, tex_format);
|
||||
if (!File::Exists(szTemp))
|
||||
{
|
||||
SaveTexture(szTemp, target, entry.texture, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
INCSTAT(stats.numTexturesCreated);
|
||||
|
@ -29,7 +29,7 @@ class TextureMngr
|
||||
public:
|
||||
struct TCacheEntry
|
||||
{
|
||||
TCacheEntry() : texture(0), addr(0), size_in_bytes(0), hash(0), w(0), h(0), isRenderTarget(false), isUpsideDown(false), isNonPow2(true), bHaveMipMaps(false) { mode.hex = 0xFCFCFCFC; }
|
||||
TCacheEntry() : texture(0), addr(0), size_in_bytes(0), hash(0), w(0), h(0), scaleX(1.0f), scaleY(1.0f), isRenderTarget(false), isUpsideDown(false), isNonPow2(true), bHaveMipMaps(false) { mode.hex = 0xFCFCFCFC; }
|
||||
|
||||
GLuint texture;
|
||||
u32 addr;
|
||||
@ -43,6 +43,8 @@ public:
|
||||
int frameCount;
|
||||
int w, h, fmt;
|
||||
|
||||
float scaleX, scaleY; // Hires texutres need this
|
||||
|
||||
bool isRenderTarget; // if render texture, then rendertex is filled with the direct copy of the render target
|
||||
// later conversions would have to convert properly from rendertexfmt to texfmt
|
||||
bool isUpsideDown;
|
||||
|
@ -236,6 +236,9 @@ void Flush()
|
||||
// 0s are probably for no manual wrapping needed.
|
||||
PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, 0, 0);
|
||||
}
|
||||
// texture is hires - pass the scaling size
|
||||
if (tentry->scaleX != 1.0f && tentry->scaleY != 1.0f)
|
||||
PixelShaderManager::SetCustomTexScale(i, tentry->scaleX, tentry->scaleY);
|
||||
if (g_Config.iLog & CONF_SAVETEXTURES)
|
||||
{
|
||||
// save the textures
|
||||
|
Reference in New Issue
Block a user