From 21576c5f5926b61fb8848b03d29783ec7992e618 Mon Sep 17 00:00:00 2001 From: andon Date: Sun, 19 Feb 2017 10:50:43 -0500 Subject: [PATCH] Separable post-processing resolutions --- include/DLL_VERSION.H | 4 +- include/config.h | 33 +++++---- include/render.h | 3 + include/textures.h | 8 ++- src/ImGui/control_panel.cpp | 67 +++++++++++++----- src/config.cpp | 46 +++++++++++-- src/render.cpp | 73 +++++++++++++++++--- src/textures.cpp | 133 +++++++++++++++++++----------------- version.ini | Bin 16630 -> 16766 bytes 9 files changed, 251 insertions(+), 116 deletions(-) diff --git a/include/DLL_VERSION.H b/include/DLL_VERSION.H index 76015cd..d735c6a 100644 --- a/include/DLL_VERSION.H +++ b/include/DLL_VERSION.H @@ -3,8 +3,8 @@ #define TBF_MAJOR 0 #define TBF_MINOR 9 -#define TBF_BUILD 8 -#define TBF_REV 6 +#define TBF_BUILD 9 +#define TBF_REV 0 diff --git a/include/config.h b/include/config.h index 993119e..809615c 100644 --- a/include/config.h +++ b/include/config.h @@ -70,21 +70,24 @@ struct tbf_config_t } steam; struct { - float fovy = 0.785398f; - float aspect_ratio = 1.777778f; - uintptr_t aspect_addr = 0x00D56494ULL;//0x00D52398; - uintptr_t fovy_addr = 0x00D56498ULL;//0x00D5239C; - bool blackbar_videos = false; // OBSOLETE - bool aspect_correction = false; - float postproc_ratio = 0.5f; - bool clear_blackbars = false; - int32_t shadow_rescale = -2; - int32_t env_shadow_rescale = 1; - bool half_float_shadows = false; - bool dump_shaders = false; - bool fix_map_res = false; - bool osd_disclaimer = true; - bool auto_apply_changes = false; + float fovy = 0.785398f; + float aspect_ratio = 1.777778f; + uintptr_t aspect_addr = 0x00D56494ULL;//0x00D52398; + uintptr_t fovy_addr = 0x00D56498ULL;//0x00D5239C; + bool blackbar_videos = false; // OBSOLETE + bool aspect_correction = false; + float postproc_ratio = 0.5f; + bool clear_blackbars = false; + int32_t shadow_rescale = -2; + int32_t env_shadow_rescale = 1; + bool half_float_shadows = false; + bool dump_shaders = false; + bool force_post_mips = false; // Mipmap generation on post-processing + bool fix_map_res = true; + bool high_res_reflection = false; + bool high_res_bloom = false; + bool osd_disclaimer = true; + bool auto_apply_changes = false; struct { int quality_preset = 3; diff --git a/include/render.h b/include/render.h index a460e84..f58f646 100644 --- a/include/render.h +++ b/include/render.h @@ -478,6 +478,9 @@ namespace tbf std::string code; std::string footer; }; + + extern std::unordered_set ui_map_rts; + extern bool ui_map_active; } } diff --git a/include/textures.h b/include/textures.h index 82f37a0..4cb2ce1 100644 --- a/include/textures.h +++ b/include/textures.h @@ -208,6 +208,8 @@ namespace RenderFix { std::vector getUsedRenderTargets (void); + uint32_t getRenderTargetCreationTime + (IDirect3DBaseTexture9* rt); void trackRenderTarget (IDirect3DBaseTexture9* rt); bool isRenderTarget (IDirect3DBaseTexture9* rt); bool isUsedRenderTarget (IDirect3DBaseTexture9* rt); @@ -236,11 +238,13 @@ namespace RenderFix { private: struct { - std::unordered_set render_targets; + // In lieu of actually wrapping render targets with a COM interface, just add the creation time + // as the mapped parameter + std::unordered_map render_targets; } known; struct { - std::unordered_set render_targets; + std::unordered_set render_targets; } used; std::unordered_map textures; diff --git a/src/ImGui/control_panel.cpp b/src/ImGui/control_panel.cpp index f0e11d9..fb6b0d1 100644 --- a/src/ImGui/control_panel.cpp +++ b/src/ImGui/control_panel.cpp @@ -633,17 +633,6 @@ TBFix_DrawConfigUI (void) { ImGui::TreePush (""); - tbf::RenderFix::need_reset.graphics |= - ImGui::Checkbox ("Enable map menu resolution fix", &config.render.fix_map_res); - - if (ImGui::IsItemHovered ()) - { - ImGui::BeginTooltip (); - ImGui::Text ( "This feature is experimental and only works at 16:9 resolutions, I am not positive that it" - " will not break something unrelated." ); - ImGui::EndTooltip (); - } - ImGui::Checkbox ("Clamp Non-Power-Of-Two Texture Coordinates", &config.textures.clamp_npot_coords); if (ImGui::IsItemHovered ()) @@ -652,8 +641,8 @@ TBFix_DrawConfigUI (void) } ImGui::Checkbox ("Clamp Skit Texture Coordinates", &config.textures.clamp_skit_coords); ImGui::SameLine (); - ImGui::Checkbox ("Clamp Map Texture Coordinates", &config.textures.clamp_map_coords); ImGui::SameLine (); - ImGui::Checkbox ("Clamp Text Texture Coordinates", &config.textures.clamp_text_coords); + //ImGui::Checkbox ("Clamp Map Texture Coordinates", &config.textures.clamp_map_coords); ImGui::SameLine (); + //ImGui::Checkbox ("Clamp Text Texture Coordinates", &config.textures.clamp_text_coords); ImGui::Checkbox ("Keep UI Textures Sharp", &config.textures.keep_ui_sharp); @@ -1057,11 +1046,11 @@ TBFix_DrawConfigUI (void) sel = 3; } - if ( ImGui::Combo ( "Post-Processing Resolution", &sel, - " Game Default -- Will cause shimmering\0" - " 50% Screen Resolution\0" - " 100% Screen Resolution\0" - " 200% Screen Resolution\0\0", 4 ) ) + if ( ImGui::Combo ( "Depth of Field", &sel, + " Normal (Game Default: Variable) -- Will cause shimmering\0" + " Low ( 50% Screen Resolution)\0" + " Medium (100% Screen Resolution)\0" + " High (200% Screen Resolution)\0\0", 4 ) ) { switch (sel) { case 0: @@ -1095,6 +1084,48 @@ TBFix_DrawConfigUI (void) ImGui::EndTooltip (); } + sel = config.render.high_res_bloom ? 1 : 0; + + if ( ImGui::Combo ( "Bloom", &sel, + " Normal ( 25% Screen Resolution) -- May Flicker\0" + " High ( 50% Screen Resolution)\0\0", 2 ) ) + { + config.render.high_res_bloom = (sel == 1); + tbf::RenderFix::need_reset.textures = true; + } + + sel = config.render.high_res_reflection ? 1 : 0; + + if ( ImGui::Combo ( "Reflection", &sel, + " Normal ( 50% Screen Resolution)\0" + " High (100% Screen Resolution)\0\0", 2 ) ) + { + config.render.high_res_reflection = (sel == 1); + tbf::RenderFix::need_reset.textures = true; + } + + tbf::RenderFix::need_reset.graphics |= + ImGui::Checkbox ("Fix Blocky Map Menu", &config.render.fix_map_res); + + if (ImGui::IsItemHovered ()) + { + ImGui::BeginTooltip (); + ImGui::Text ("This feature is a work-in-progress and generally only works at 16:9 resolutions."); + ImGui::EndTooltip (); + } + + tbf::RenderFix::need_reset.graphics |= + ImGui::Checkbox ("Force Mipmap Filtering on Post-Processed Render Passes", &config.render.force_post_mips); + + if (ImGui::IsItemHovered ()) + { + ImGui::BeginTooltip (); + ImGui::Text ("Reduce Aliasing AND Increase Performance on Post-Processing"); + ImGui::BulletText ("Slight performance gain assuming drivers / third-party software / untested render passes do not explode."); + ImGui::BulletText ("Still extremely experimental; not saved in config file."); + ImGui::EndTooltip (); + } + ImGui::TreePop (); } diff --git a/src/config.cpp b/src/config.cpp index 2d0814e..96df5d2 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -71,15 +71,18 @@ struct { tbf::ParameterFloat* aspect_ratio; tbf::ParameterBool* aspect_correct_vids; tbf::ParameterBool* aspect_correction; - tbf::ParameterFloat* postproc_ratio; tbf::ParameterBool* clear_blackbars; + tbf::ParameterFloat* postproc_ratio; + tbf::ParameterBool* fix_map_res; + tbf::ParameterBool* high_res_bloom; + tbf::ParameterBool* high_res_reflection; + tbf::ParameterInt* rescale_shadows; tbf::ParameterInt* rescale_env_shadows; tbf::ParameterBool* half_precision_shadows; tbf::ParameterBool* dump_shaders; - tbf::ParameterBool* fix_map_res; tbf::ParameterBool* pause_on_ui; tbf::ParameterBool* show_osd_disclaimer; tbf::ParameterFloat* ui_scale; @@ -435,9 +438,29 @@ TBF_LoadConfig (std::wstring name) ); render.fix_map_res->register_to_ini ( render_ini, - L"Resolution.Experimental", + L"Resolution.PostProcess", L"FixMap" ); + render.high_res_bloom = + static_cast + (g_ParameterFactory.create_parameter ( + L"Increase Resolution of Bloom Effects") + ); + render.high_res_bloom->register_to_ini ( + render_ini, + L"Resolution.PostProcess", + L"HighResBloom" ); + + render.high_res_reflection = + static_cast + (g_ParameterFactory.create_parameter ( + L"Increase Resolution of Reflections") + ); + render.high_res_reflection->register_to_ini ( + render_ini, + L"Resolution.PostProcess", + L"HighResReflection" ); + render.postproc_ratio = static_cast (g_ParameterFactory.create_parameter ( @@ -445,8 +468,8 @@ TBF_LoadConfig (std::wstring name) ); render.postproc_ratio->register_to_ini ( render_ini, - L"Resolution.Experimental", - L"PostProcessRatio" ); + L"Resolution.PostProcess", + L"DepthOfField" ); render.pause_on_ui = static_cast @@ -820,6 +843,8 @@ TBF_LoadConfig (std::wstring name) render.dump_shaders->load (config.render.dump_shaders); render.fix_map_res->load (config.render.fix_map_res); + render.high_res_bloom->load (config.render.high_res_bloom); + render.high_res_reflection->load (config.render.high_res_reflection); render.postproc_ratio->load (config.render.postproc_ratio); render.pause_on_ui->load (config.input.ui.pause); render.show_osd_disclaimer->load (config.render.osd_disclaimer); @@ -840,6 +865,9 @@ TBF_LoadConfig (std::wstring name) std::wstring sgssaa; + int original_sgssaa = config.render.nv.sgssaa_mode; + std::wstring original_bits = config.render.nv.compat_bits; + render.nvidia_sgssaa->load (sgssaa); render.nvidia_aa_compat_bits->load (config.render.nv.compat_bits ); @@ -858,7 +886,11 @@ TBF_LoadConfig (std::wstring name) else if (sgssaa == L"off") config.render.nv.sgssaa_mode = 0; - tbf::RenderFix::InstallSGSSAA (); + // Only change the driver profile if settings change in-game or + // if a non-off mode is selected. + if ( config.render.nv.sgssaa_mode != 0 || + config.render.nv.sgssaa_mode != config.render.nv.sgssaa_mode ) + tbf::RenderFix::InstallSGSSAA (); } config.input.ui.scale = std::min (std::max (1.0f, config.input.ui.scale), 3.0f); @@ -913,6 +945,8 @@ TBF_SaveConfig (std::wstring name, bool close_config) render.rescale_env_shadows->store (config.render.env_shadow_rescale); render.half_precision_shadows->store (config.render.half_float_shadows); render.fix_map_res->store (config.render.fix_map_res); + render.high_res_bloom->store (config.render.high_res_bloom); + render.high_res_reflection->store (config.render.high_res_reflection); render.postproc_ratio->store (config.render.postproc_ratio); render.pause_on_ui->store (config.input.ui.pause); render.show_osd_disclaimer->store (config.render.osd_disclaimer); diff --git a/src/render.cpp b/src/render.cpp index 4f6c363..cf24691 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -454,10 +454,10 @@ D3D9SetVertexShader_Detour (IDirect3DDevice9* This, if (vs_checksum != 0x00) { - tbf::RenderFix::last_frame.vertex_shaders.insert (vs_checksum); + tbf::RenderFix::last_frame.vertex_shaders.emplace (vs_checksum); if (tbf::RenderFix::tracked_rt.active) - tbf::RenderFix::tracked_rt.vertex_shaders.insert (vs_checksum); + tbf::RenderFix::tracked_rt.vertex_shaders.emplace (vs_checksum); if (vs_checksum == tbf::RenderFix::tracked_vs.crc32) { @@ -537,10 +537,10 @@ D3D9SetPixelShader_Detour (IDirect3DDevice9* This, if (ps_checksum != 0x00) { - tbf::RenderFix::last_frame.pixel_shaders.insert (ps_checksum); + tbf::RenderFix::last_frame.pixel_shaders.emplace (ps_checksum); if (tbf::RenderFix::tracked_rt.active) - tbf::RenderFix::tracked_rt.pixel_shaders.insert (ps_checksum); + tbf::RenderFix::tracked_rt.pixel_shaders.emplace (ps_checksum); if (ps_checksum == tbf::RenderFix::tracked_ps.crc32) { @@ -997,13 +997,63 @@ D3D9SetViewport_Detour (IDirect3DDevice9* This, if (This != tbf::RenderFix::pDevice) return D3D9SetViewport_Original (This, pViewport); + auto PostProcessMipmaps = [](void) -> + void { + if (config.render.force_post_mips) + { + CComPtr pBaseTex0 = nullptr; + CComPtr pBaseTex1 = nullptr; + + tbf::RenderFix::pDevice->GetTexture (0, &pBaseTex0); if (pBaseTex0) pBaseTex0->GenerateMipSubLevels (); + tbf::RenderFix::pDevice->GetTexture (1, &pBaseTex1); if (pBaseTex1) pBaseTex1->GenerateMipSubLevels (); + + tbf::RenderFix::pDevice->SetSamplerState (0, D3DSAMP_MAGFILTER, D3DTEXF_ANISOTROPIC); + tbf::RenderFix::pDevice->SetSamplerState (0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); + tbf::RenderFix::pDevice->SetSamplerState (0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR); + + tbf::RenderFix::pDevice->SetSamplerState (1, D3DSAMP_MAGFILTER, D3DTEXF_ANISOTROPIC); + tbf::RenderFix::pDevice->SetSamplerState (1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); + tbf::RenderFix::pDevice->SetSamplerState (1, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR); + } + }; + + // Bloom (only?) + // + // + if ( config.render.high_res_reflection && ( + ( pViewport->Width == tbf::RenderFix::width/2 && pViewport->Height == tbf::RenderFix::height/2 ) ) ) + { + D3DVIEWPORT9 rescaled_map = *pViewport; + + rescaled_map.Width *= 2; + rescaled_map.Height *= 2; + + PostProcessMipmaps (); + + return D3D9SetViewport_Original (This, &rescaled_map); + } + + // Bloom (only?) + // + // + if ( config.render.high_res_bloom && ( + ( pViewport->Width == tbf::RenderFix::width/4 && pViewport->Height == tbf::RenderFix::height/4 ) ) ) + { + D3DVIEWPORT9 rescaled_map = *pViewport; + + rescaled_map.Width *= 2; + rescaled_map.Height *= 2; + + PostProcessMipmaps (); + + return D3D9SetViewport_Original (This, &rescaled_map); + } + // In-Game Map // // if ( config.render.fix_map_res && ( - ( pViewport->Width == tbf::RenderFix::width/2 && pViewport->Height == tbf::RenderFix::height/2 ) || - ( pViewport->Width == tbf::RenderFix::width/3 && pViewport->Height == tbf::RenderFix::height/3 ) || - ( pViewport->Width == tbf::RenderFix::width/4 && pViewport->Height == tbf::RenderFix::height/4 ) || + ( pViewport->Width == tbf::RenderFix::width/3 && pViewport->Height == tbf::RenderFix::height/3 ) || ( pViewport->Width == tbf::RenderFix::width/5 && pViewport->Height == tbf::RenderFix::height/5 ) || ( pViewport->Width == tbf::RenderFix::width/6 && pViewport->Height == tbf::RenderFix::height/6 ) || ( pViewport->Width == tbf::RenderFix::width/7 && pViewport->Height == tbf::RenderFix::height/7 ) || @@ -1013,8 +1063,9 @@ D3D9SetViewport_Detour (IDirect3DDevice9* This, { D3DVIEWPORT9 rescaled_map = *pViewport; - rescaled_map.Width *= 2;//tbf::RenderFix::width; - rescaled_map.Height *= 2;//tbf::RenderFix::height; + rescaled_map.Width = tbf::RenderFix::width; rescaled_map.Height = tbf::RenderFix::height; + + PostProcessMipmaps (); return D3D9SetViewport_Original (This, &rescaled_map); } @@ -1053,7 +1104,7 @@ D3D9SetViewport_Detour (IDirect3DDevice9* This, } // - // Adjust Post-Processing + // Adjust Post-Processing (Depth of Field) // else if ( ( ( pViewport->Width == 2048 && pViewport->Height == 1024 ) || @@ -1074,6 +1125,8 @@ D3D9SetViewport_Detour (IDirect3DDevice9* This, rescaled_post_proc.X += (DWORD)x_off; rescaled_post_proc.Y += (DWORD)y_off; + PostProcessMipmaps (); + return D3D9SetViewport_Original (This, &rescaled_post_proc); } diff --git a/src/textures.cpp b/src/textures.cpp index 2b1c4f5..2c9f77f 100644 --- a/src/textures.cpp +++ b/src/textures.cpp @@ -144,11 +144,11 @@ class TBF_HashSet DeleteCriticalSection (&cs_); } - void insert (_T item) + void emplace (_T item) { TBF_AutoCritSection auto_crit (&cs_); - container_.insert (item); + container_.emplace (item); } void erase (_T item) @@ -758,7 +758,8 @@ tbf::RenderFix::TextureManager::isRenderTarget (IDirect3DBaseTexture9* pTex) void tbf::RenderFix::TextureManager::trackRenderTarget (IDirect3DBaseTexture9* pTex) { - known.render_targets.emplace (pTex); + if (! known.render_targets.count (pTex)) + known.render_targets.try_emplace (pTex, (uint32_t)known.render_targets.size ()); } void @@ -786,6 +787,15 @@ tbf::RenderFix::TextureManager::getUsedRenderTargets (void) return std::vector (used.render_targets.begin (), used.render_targets.end ()); } +uint32_t +tbf::RenderFix::TextureManager::getRenderTargetCreationTime (IDirect3DBaseTexture9* pTex) +{ + if (known.render_targets.count (pTex)) + return known.render_targets [pTex]; + + return 0xFFFFFFFFUL; +} + COM_DECLSPEC_NOTHROW __declspec (noinline) HRESULT @@ -860,8 +870,8 @@ D3D9SetTexture_Detour ( if (tbf::RenderFix::tracked_rt.active) { - tbf::RenderFix::tracked_rt.vertex_shaders.insert (vs_checksum); - tbf::RenderFix::tracked_rt.pixel_shaders.insert (ps_checksum); + tbf::RenderFix::tracked_rt.vertex_shaders.emplace (vs_checksum); + tbf::RenderFix::tracked_rt.pixel_shaders.emplace (ps_checksum); } @@ -1071,60 +1081,61 @@ D3D9CreateTexture_Detour (IDirect3DDevice9 *This, Width = (UINT)(tbf::RenderFix::width * config.render.postproc_ratio); Height = (UINT)(tbf::RenderFix::height * config.render.postproc_ratio); + if (config.render.force_post_mips) + Levels = 1 + (UINT)floor (log2 (std::max (Width, Height))); + tex_log->Log (L"[ PostProc ] (Post-Resolution: (%lu x %lu)", Width, Height); } } - else if ( config.render.fix_map_res && + else if ( ( config.render.fix_map_res || + config.render.high_res_bloom || + config.render.high_res_reflection ) && ( Usage == D3DUSAGE_RENDERTARGET || Usage == D3DUSAGE_DEPTHSTENCIL ) ) { - if (Width == tbf::RenderFix::width / 11 && Height == tbf::RenderFix::height / 11) { - Width *= 2; Height *= 2; - } - else if (Width == tbf::RenderFix::width / 10 && Height == tbf::RenderFix::height / 10) { - Width *= 2; Height *= 2; - } - else if (Width == tbf::RenderFix::width / 9 && Height == tbf::RenderFix::height / 9) { - Width *= 2; Height *= 2; - } - else if (Width == tbf::RenderFix::width / 8 && Height == tbf::RenderFix::height / 8) { - Width *= 2; Height *= 2; - } - else if (Width == tbf::RenderFix::width / 7 && Height == tbf::RenderFix::height / 7) { - Width *= 2; Height *= 2; - } - else if (Width == tbf::RenderFix::width / 6 && Height == tbf::RenderFix::height / 6) { - Width *= 2; Height *= 2; - } - else if (Width == tbf::RenderFix::width / 5 && Height == tbf::RenderFix::height / 5) { - Width *= 2; Height *= 2; - } - else if (Width == tbf::RenderFix::width / 4 && Height == tbf::RenderFix::height / 4) { - Width *= 2; Height *= 2; - } - else if (Width == tbf::RenderFix::width / 3 && Height == tbf::RenderFix::height / 3) { - Width *= 2; Height *= 2; + UINT Original_Width = Width; + UINT Original_Height = Height; + + if (config.render.high_res_reflection) + { + if ( Original_Width == tbf::RenderFix::width / 2 && + Original_Height == tbf::RenderFix::height / 2 ) { + Width *= 2; Height *= 2; + + if (config.render.force_post_mips) + Levels = 1 + (UINT)floor (log2 (std::max (Width, Height))); + } } - else if (Width == tbf::RenderFix::width / 2 && Height == tbf::RenderFix::height / 2) + + if (config.render.high_res_bloom) { - Width *= 2; Height *= 2; + if ( Original_Width == tbf::RenderFix::width / 4 && + Original_Height == tbf::RenderFix::height / 4 ) { + Width *= 2; Height *= 2; + + if (config.render.force_post_mips) + Levels = 1 + (UINT)floor (log2 (std::max (Width, Height))); + } } - int levels = Levels; + if (config.render.fix_map_res) + { + if ( (Original_Width < tbf::RenderFix::width / 4 && + Original_Height < tbf::RenderFix::height / 4) || + (Original_Width == tbf::RenderFix::width / 3 && + Original_Height == tbf::RenderFix::height / 3) ) + { + Width = tbf::RenderFix::width; Height = tbf::RenderFix::height; - // ASSERT: Levels == 1 + if (config.render.force_post_mips) + Levels = 1 + (UINT)floor (log2 (std::max (Width, Height))); + } + } } int levels = Levels; -#if 0 - if (Width == 66 && Height == 33) { - Width = tbf::RenderFix::width; - Height = tbf::RenderFix::height; - } -#endif - if ( config.render.half_float_shadows && (Usage & D3DUSAGE_RENDERTARGET ) && Format == D3DFMT_R32F ) @@ -2544,8 +2555,7 @@ TBFix_ReloadPadButtons (void) else { - textures_in_flight.insert ( std::make_pair ( load_op->checksum, - load_op ) ); + textures_in_flight.try_emplace ( load_op->checksum, load_op ); resample_pool->postJob (load_op); } @@ -2612,8 +2622,8 @@ D3DXCreateTextureFromFileInMemoryEx_Detour ( if (resample_blacklist_init == false) { // Do Not Resample Logos - resample_blacklist.insert (0xfa3d03df); - resample_blacklist.insert (0x545908bb); + resample_blacklist.emplace (0xfa3d03df); + resample_blacklist.emplace (0x545908bb); resample_blacklist_init = true; } @@ -2671,7 +2681,7 @@ D3DXCreateTextureFromFileInMemoryEx_Detour ( // Textures that would be incorrectly filtered if resampled if (power_of_two_in_one_way) - non_power_of_two_textures.insert (checksum); + non_power_of_two_textures.emplace (checksum); // Generate complete mipmap chains for best image quality @@ -2839,7 +2849,7 @@ D3DXCreateTextureFromFileInMemoryEx_Detour ( rec.method = Blocking; if (! injectable_textures.count (checksum)) - injectable_textures.insert (std::make_pair (checksum, rec)); + injectable_textures.try_emplace ( checksum, rec ); else { injectable_textures [checksum] = rec; } @@ -2898,8 +2908,7 @@ D3DXCreateTextureFromFileInMemoryEx_Detour ( } else { - textures_in_flight.insert ( std::make_pair ( load_op->checksum, - load_op ) ); + textures_in_flight.try_emplace ( load_op->checksum, load_op ); stream_pool.postJob (load_op); //resample_pool->postJob (load_op); @@ -3119,7 +3128,7 @@ TBF_DumpTexture (D3DFORMAT fmt, uint32_t checksum, IDirect3DTexture9* pTex) HRESULT hr = D3DXSaveTextureToFile (wszFileName, D3DXIFF_DDS, pTex, NULL); if (SUCCEEDED (hr)) - dumped_textures.insert (checksum); + dumped_textures.emplace (checksum); return hr; } @@ -3350,7 +3359,7 @@ tbf::RenderFix::TextureManager::Init (void) liSize.QuadPart += fsize.QuadPart; - dumped_textures.insert (checksum); + dumped_textures.emplace (checksum); } } while (FindNextFileW (hSubFind, &fd_sub) != 0); @@ -4014,7 +4023,7 @@ SK_TextureWorkerThread::ThreadProc (LPVOID user) else { tex_log->Log ( L"[ Tex. Mgr ] Texture Resample Failure (hr=%x) for texture %x, blacklisting from future resamples...", hr, pStream->checksum ); - resample_blacklist.insert (pStream->checksum); + resample_blacklist.emplace (pStream->checksum); pStream->pDest->Release (); pStream->pSrc = pStream->pDest; @@ -4265,7 +4274,7 @@ TBF_RefreshDataSources (void) rec.archive = std::numeric_limits ::max (); rec.method = Blocking; - injectable_textures.insert (std::make_pair (checksum, rec)); + injectable_textures.try_emplace ( checksum, rec ); } } } while (FindNextFileW (hFind, &fd) != 0); @@ -4300,7 +4309,7 @@ TBF_RefreshDataSources (void) rec.archive = std::numeric_limits ::max (); rec.method = Streaming; - injectable_textures.insert (std::make_pair (checksum, rec)); + injectable_textures.try_emplace (checksum, rec); } } } while (FindNextFileW (hFind, &fd) != 0); @@ -4335,8 +4344,7 @@ TBF_RefreshDataSources (void) rec.archive = std::numeric_limits ::max (); rec.method = DontCare; - if (! injectable_textures.count (checksum)) - injectable_textures.insert (std::make_pair (checksum, rec)); + injectable_textures.try_emplace (checksum, rec); } } } while (FindNextFileW (hFind, &fd) != 0); @@ -4444,7 +4452,7 @@ TBF_RefreshDataSources (void) rec.fileno = i; rec.method = method; - injectable_textures.insert (std::make_pair (checksum, rec)); + injectable_textures.try_emplace (checksum, rec); ++tex_count; ++files; @@ -4581,8 +4589,7 @@ tbf::RenderFix::TextureManager::reloadTexture (uint32_t checksum) else { - textures_in_flight.insert ( std::make_pair ( load_op->checksum, - load_op ) ); + textures_in_flight.try_emplace ( load_op->checksum, load_op ); stream_pool.postJob (load_op); } @@ -4692,7 +4699,7 @@ tbf::RenderFix::TextureManager::takeScreenshot (IDirect3DSurface9* pSurf) ) ) { - outstanding_screenshots.insert (pSurfScreenshot); + outstanding_screenshots.emplace (pSurfScreenshot); struct screenshot_params_s { D3DSURFACE_DESC desc; @@ -4739,7 +4746,7 @@ tbf::RenderFix::TextureManager::takeScreenshot (IDirect3DSurface9* pSurf) ) ) { - outstanding_screenshots.insert (pSurfThumb); + outstanding_screenshots.emplace (pSurfThumb); // Slightly higher quality filtering than if we just used StretchRect with a linear filter,+ // (200 x ...) pixels still sucks, but we can make it suck just a little bit less. diff --git a/version.ini b/version.ini index b2a226b20b474ec1e43ed4f6306598e2497dd429..1df88fc8332f23ee155f4341104921bff722f85b 100644 GIT binary patch delta 243 zcmXv|I|{-;6r5dRD>^V*B|L7YR;Qcr0lmxoZcA?t{F#VDc6P8&6%4m|)a6Exa;n?B`&C)aOc>ethyVu05Ljc61M2}+ zL@t(C5C!ZSm}113qR(T%!!}j8RM_aT6Hyg1pWu+&vJ#vZL@sOP?!Ue_ya+$~Yg(iavWL*|RQZ Kdj8oh4m%%$U_I;r