diff --git a/Source/Plugins/Plugin_VideoDX11/Src/DlgSettings.cpp b/Source/Plugins/Plugin_VideoDX11/Src/DlgSettings.cpp index e861eec9a4..fa136dcb83 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/DlgSettings.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/DlgSettings.cpp @@ -200,6 +200,9 @@ struct TabAdvanced : public W32Util::Tab Button_SetCheck(GetDlgItem(hDlg, IDC_FORCEANISOTROPY),g_Config.iMaxAnisotropy > 1); Button_SetCheck(GetDlgItem(hDlg, IDC_EFBSCALEDCOPY), g_Config.bCopyEFBScaled); + Button_SetCheck(GetDlgItem(hDlg, IDC_LOADHIRESTEXTURE),g_Config.bHiresTextures); + Button_SetCheck(GetDlgItem(hDlg, IDC_DUMPTEXTURES),g_Config.bDumpTextures); + if (Button_GetCheck(GetDlgItem(hDlg, IDC_ENABLEEFBCOPY))) Button_Enable(GetDlgItem(hDlg,IDC_EFBSCALEDCOPY), true); else Button_Enable(GetDlgItem(hDlg, IDC_EFBSCALEDCOPY), false); } @@ -232,14 +235,14 @@ struct TabAdvanced : public W32Util::Tab g_Config.bDisableFog = Button_GetCheck(GetDlgItem(hDlg, IDC_DISABLEFOG)) ? true : false; g_Config.bEFBCopyDisable = Button_GetCheck(GetDlgItem(hDlg, IDC_ENABLEEFBCOPY)) ? false : true; g_Config.bCopyEFBToTexture = !g_Config.bEFBCopyDisable; - g_Config.bDumpTextures = false; g_Config.bDumpFrames = false; g_Config.bShowShaderErrors = true; g_Config.bUseNativeMips = true; g_Config.iMaxAnisotropy = Button_GetCheck(GetDlgItem(hDlg, IDC_FORCEANISOTROPY)) ? 16 : 1; g_Config.bForceFiltering = false; - g_Config.bHiresTextures = false; + g_Config.bHiresTextures = Button_GetCheck(GetDlgItem(hDlg, IDC_LOADHIRESTEXTURE)) ? true : false; + g_Config.bDumpTextures = Button_GetCheck(GetDlgItem(hDlg, IDC_DUMPTEXTURES)) ? true : false; g_Config.bCopyEFBScaled = Button_GetCheck(GetDlgItem(hDlg, IDC_EFBSCALEDCOPY)) ? true : false; g_Config.Save((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_dx11.ini").c_str()); } diff --git a/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp index bce7ba6664..448d7a6975 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp @@ -50,7 +50,7 @@ TextureCache::TexCache TextureCache::textures; extern int frameCount; -#define TEMP_SIZE (1024*1024*4) +#define TEMP_SIZE (2048*2048*4) #define TEXTURE_KILL_THRESHOLD 200 void TextureCache::TCacheEntry::Destroy(bool shutdown) @@ -231,8 +231,8 @@ TextureCache::TCacheEntry* TextureCache::Load(unsigned int stage, u32 address, u if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2)) FullFormat = (tex_format | (tlutfmt << 16)); - // hires textures and texture dumping not supported, yet - if (g_ActiveConfig.bSafeTextureCache/* || g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures*/) + // hires texture loading and texture dumping require accurate hashes + if (g_ActiveConfig.bSafeTextureCache || g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures) { texHash = GetHash64(ptr,TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format),g_ActiveConfig.iSafeTextureCache_ColorSamples); if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2)) @@ -293,9 +293,29 @@ TextureCache::TCacheEntry* TextureCache::Load(unsigned int stage, u32 address, u // Make an entry in the table TCacheEntry& entry = textures[texID]; + entry.Realw = width; + entry.Realh = height; PC_TexFormat pcfmt = PC_TEX_FMT_NONE; pcfmt = TexDecoder_Decode(temp, ptr, expandedWidth, expandedHeight, tex_format, tlutaddr, tlutfmt, true); + if (g_ActiveConfig.bHiresTextures) + { + // Load Custom textures + char texPathTemp[MAX_PATH]; + int newWidth = width; + int newHeight = height; + + sprintf(texPathTemp, "%s_%08x_%i", globals->unique_id, texHash, tex_format); + pcfmt = HiresTextures::GetHiresTex(texPathTemp, &newWidth, &newHeight, GX_TF_RGBA8, temp); + if (pcfmt != PC_TEX_FMT_NONE) + { + expandedWidth = width = newWidth; + expandedHeight = height = newHeight; + } + } + + if (pcfmt == PC_TEX_FMT_NONE) + pcfmt = TexDecoder_Decode(temp, ptr, expandedWidth, expandedHeight, tex_format, tlutaddr, tlutfmt, true); entry.oldpixel = ((u32*)ptr)[0]; if (g_ActiveConfig.bSafeTextureCache) entry.hash = hash_value; @@ -327,6 +347,7 @@ TextureCache::TCacheEntry* TextureCache::Load(unsigned int stage, u32 address, u D3D::SetDebugObjectName((ID3D11DeviceChild*)entry.texture->GetSRV(), "shader resource view of a texture of the TextureCache"); SAFE_RELEASE(pTexture); + // if (TexLevels == 1), we already loaded the data into our texture upon creation if (TexLevels != 1) D3D::ReplaceRGBATexture2D(entry.texture->GetTex(), temp, width, height, expandedWidth, 0, usage); } else @@ -365,8 +386,26 @@ TextureCache::TCacheEntry* TextureCache::Load(unsigned int stage, u32 address, u entry.frameCount = frameCount; entry.w = width; entry.h = height; + entry.Scaledw = width; + entry.Scaledh = height; entry.fmt = FullFormat; + // dump texture to file + if (g_ActiveConfig.bDumpTextures) + { + char szTemp[MAX_PATH]; + char szDir[MAX_PATH]; + + // make sure that the directory exists + sprintf(szDir, "%s%s", File::GetUserPath(D_DUMPTEXTURES_IDX), globals->unique_id); + if (!File::Exists(szDir) || !File::IsDirectory(szDir)) + File::CreateDir(szDir); + + sprintf(szTemp, "%s/%s_%08x_%i.png", szDir, globals->unique_id, texHash, tex_format); + if (!File::Exists(szTemp)) + if(FAILED(PD3DX11SaveTextureToFileA(D3D::context, entry.texture->GetTex(), D3DX11_IFF_PNG, szTemp))) PanicAlert("!!!"); + } + INCSTAT(stats.numTexturesCreated); SETSTAT(stats.numTexturesAlive, textures.size()); @@ -410,8 +449,8 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo entry.isRenderTarget = true; entry.hash = 0; entry.frameCount = frameCount; - entry.w = tex_w; - entry.h = tex_h; + entry.w = entry.Realw = tex_w; + entry.h = entry.Realh = tex_h; entry.Scaledw = Scaledtex_w; entry.Scaledh = Scaledtex_h; entry.fmt = copyfmt; diff --git a/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.h b/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.h index d3c7fe85b5..e1d4d97c6e 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.h @@ -39,13 +39,13 @@ public: int frameCount; unsigned int w, h, fmt, MipLevels; - int Scaledw, Scaledh; + int Realw, Realh, Scaledw, Scaledh; bool isRenderTarget; bool isNonPow2; TCacheEntry() : texture(NULL), addr(0), size_in_bytes(0), hash(0), paletteHash(0), oldpixel(0), - frameCount(0), w(0), h(0), fmt(0), MipLevels(0), Scaledw(0), Scaledh(0), + frameCount(0), w(0), h(0), fmt(0), MipLevels(0), Realw(0), Realh(0), Scaledw(0), Scaledh(0), isRenderTarget(false), isNonPow2(true) {} void Destroy(bool shutdown); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp index 630eff7184..8280887dd7 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp @@ -225,7 +225,7 @@ void VertexManager::vFlush() if (tentry) { // 0s are probably for no manual wrapping needed. - PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, 0, 0); + PixelShaderManager::SetTexDims(i, tentry->Realw, tentry->Realh, 0, 0); } else ERROR_LOG(VIDEO, "error loading texture"); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/resource.h b/Source/Plugins/Plugin_VideoDX11/Src/resource.h index c4d464ef1b..fda3150de9 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/resource.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/resource.h @@ -24,14 +24,14 @@ #define IDC_FORCEANISOTROPY 1027 #define IDC_EFBSCALEDCOPY 1029 #define IDC_OSDHOTKEY 1030 -#define IDC_COMBO2 1040 #define IDC_ASPECTRATIO 1040 #define IDC_SAFE_TEXTURE_CACHE_SAFE 1041 #define IDC_SAFE_TEXTURE_CACHE_NORMAL 1042 -#define IDC_RADIO3 1043 #define IDC_SAFE_TEXTURE_CACHE_FAST 1043 #define IDC_DLIST_CACHING 1044 #define IDC_ENABLEPIXELLIGHTING 1045 +#define IDC_LOADHIRESTEXTURE 1046 +#define IDC_DUMPTEXTURES 1047 #define IDC_STATIC -1 // Next default values for new objects diff --git a/Source/Plugins/Plugin_VideoDX11/Src/resource.rc b/Source/Plugins/Plugin_VideoDX11/Src/resource.rc index 22fbdd0240..c36405f745 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/resource.rc +++ b/Source/Plugins/Plugin_VideoDX11/Src/resource.rc @@ -59,15 +59,17 @@ IDD_ADVANCED DIALOGEX 0, 0, 244, 200 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_BORDER | WS_SYSMENU FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - GROUPBOX "&Settings",IDC_STATIC,6,7,228,74 + GROUPBOX "&Settings",IDC_STATIC,6,7,228,102 CONTROL "Overlay FPS counter",IDC_OVERLAYFPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,18,82,8 CONTROL "Disable Fog",IDC_DISABLEFOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,18,78,8 CONTROL "Enable Hotkey",IDC_OSDHOTKEY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,33,87,8 CONTROL "Enable EFB copy",IDC_ENABLEEFBCOPY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,33,81,8 CONTROL "EFB Scaled Copy",IDC_EFBSCALEDCOPY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,48,64,8 CONTROL "Enable &Wireframe",IDC_WIREFRAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,48,87,8 - CONTROL "Enable 16x &anisotropy filtering",IDC_FORCEANISOTROPY, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,63,110,8 + CONTROL "Enable 16x &anisotropy filtering",IDC_FORCEANISOTROPY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,63,110,8 + CONTROL "Enable hires texture loading",IDC_LOADHIRESTEXTURE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,78,112,8 + CONTROL "Dump textures",IDC_DUMPTEXTURES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,93,60,8 + GROUPBOX "Debugging Tools",IDC_STATIC,7,148,228,46 CONTROL "&Overlay some statistics",IDC_OVERLAYSTATS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,159,90,8 CONTROL "Enable TexFmt Overlay",IDC_TEXFMT_OVERLAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,174,92,10