From f1fe521c844bf4dd6ec337450ac84c67cf825a2a Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sun, 22 Sep 2019 08:18:53 -0400 Subject: [PATCH] ResolutioRescaling: Correct reading profiles in windows and address other feedback. --- .../renderer_opengl/gl_rasterizer.cpp | 8 +++---- .../renderer_opengl/gl_shader_manager.cpp | 11 +++++----- .../resolution_scaling/database.cpp | 21 +++++++++---------- .../resolution_scaling/database.h | 12 +++++++---- src/video_core/texture_cache/texture_cache.h | 20 +++++++++--------- 5 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 2b5d547ec6..6c784a9ad0 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -1084,10 +1084,10 @@ void RasterizerOpenGL::SyncViewport(OpenGLState& current_state, bool rescaling) auto& viewport = current_state.viewports[i]; const auto& src = regs.viewports[i]; const Common::Rectangle viewport_rect{regs.viewport_transform[i].GetRect()}; - viewport.x = viewport_rect.left * factor; - viewport.y = viewport_rect.bottom * factor; - viewport.width = viewport_rect.GetWidth() * factor; - viewport.height = viewport_rect.GetHeight() * factor; + viewport.x = static_cast(viewport_rect.left * factor); + viewport.y = static_cast(viewport_rect.bottom * factor); + viewport.width = static_cast(viewport_rect.GetWidth() * factor); + viewport.height = static_cast(viewport_rect.GetHeight() * factor); viewport.depth_range_far = src.depth_range_far; viewport.depth_range_near = src.depth_range_near; } diff --git a/src/video_core/renderer_opengl/gl_shader_manager.cpp b/src/video_core/renderer_opengl/gl_shader_manager.cpp index d857f3771c..700bc9eb87 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.cpp +++ b/src/video_core/renderer_opengl/gl_shader_manager.cpp @@ -12,16 +12,15 @@ namespace OpenGL::GLShader { using Maxwell = Tegra::Engines::Maxwell3D::Regs; -enum ProgramLocations : u32 { - CONFIG_PACK = 0, - VIEWPORT_SCALE = 1, -}; - StageProgram::StageProgram() = default; StageProgram::~StageProgram() = default; void StageProgram::UpdateConstants() { + enum ProgramLocations : u32 { + CONFIG_PACK = 0, + VIEWPORT_SCALE = 1, + }; if (state.config_pack != old_state.config_pack) { glProgramUniform4uiv(handle, CONFIG_PACK, 1, state.config_pack.data()); old_state.config_pack = state.config_pack; @@ -65,7 +64,7 @@ void ProgramManager::SetConstants(Tegra::Engines::Maxwell3D& maxwell_3d, bool re const GLfloat rescale_factor = rescaling ? Settings::values.resolution_factor : 1.0f; for (const auto stage : - std::array{current_state.vertex, current_state.geometry, current_state.fragment}) { + {current_state.vertex, current_state.geometry, current_state.fragment}) { if (!stage) { continue; } diff --git a/src/video_core/texture_cache/resolution_scaling/database.cpp b/src/video_core/texture_cache/resolution_scaling/database.cpp index 5cf4921d7c..cb00816d17 100644 --- a/src/video_core/texture_cache/resolution_scaling/database.cpp +++ b/src/video_core/texture_cache/resolution_scaling/database.cpp @@ -23,9 +23,7 @@ std::string GetBaseDir() { return FileUtil::GetUserPath(FileUtil::UserPath::RescalingDir); } -ScalingDatabase::ScalingDatabase(Core::System& system) : database{}, blacklist{}, system{system} { - title_id = 0; -} +ScalingDatabase::ScalingDatabase(Core::System& system) : system{system} {} ScalingDatabase::~ScalingDatabase() { SaveDatabase(); @@ -43,7 +41,8 @@ void ScalingDatabase::LoadDatabase() { if (!exists) { return; } - std::ifstream file(path); + std::ifstream file; + OpenFStream(file, path, std::ios_base::in); json in; file >> in; u32 version = in["version"].get(); @@ -73,7 +72,7 @@ void ScalingDatabase::SaveDatabase() { return; } json out; - out["version"] = DBVersion; + out.emplace("version", DBVersion); auto entries = json::array(); for (const auto& key : database) { entries.push_back({ @@ -82,7 +81,7 @@ void ScalingDatabase::SaveDatabase() { {"height", key.height}, }); } - out["entries"] = std::move(entries); + out.emplace("entries", std::move(entries)); auto blacklist_entries = json::array(); for (const auto& key : blacklist) { blacklist_entries.push_back({ @@ -91,22 +90,22 @@ void ScalingDatabase::SaveDatabase() { {"height", key.height}, }); } - out["blacklist"] = blacklist_entries; + out.emplace("blacklist", std::move(blacklist_entries)); const std::string path = GetProfilePath(); - std::ofstream file(path); + std::ofstream file; + OpenFStream(file, path, std::ios_base::out); file << std::setw(4) << out << std::endl; } void ScalingDatabase::Register(PixelFormat format, u32 width, u32 height) { - ResolutionKey key{format, width, height}; + const ResolutionKey key{format, width, height}; if (blacklist.count(key) == 0) { - ResolutionKey key{format, width, height}; database.insert(key); } } void ScalingDatabase::Unregister(PixelFormat format, u32 width, u32 height) { - ResolutionKey key{format, width, height}; + const ResolutionKey key{format, width, height}; database.erase(key); blacklist.insert(key); } diff --git a/src/video_core/texture_cache/resolution_scaling/database.h b/src/video_core/texture_cache/resolution_scaling/database.h index 6646f954d2..8fb079d50c 100644 --- a/src/video_core/texture_cache/resolution_scaling/database.h +++ b/src/video_core/texture_cache/resolution_scaling/database.h @@ -29,6 +29,10 @@ struct ResolutionKey { bool operator==(const ResolutionKey& ks) const { return std::tie(format, width, height) == std::tie(ks.format, ks.width, ks.height); } + + bool operator!=(const ResolutionKey& ks) const { + return !(*this == ks); + } }; } // namespace VideoCommon::Resolution @@ -55,13 +59,13 @@ public: void LoadDatabase(); void Init(); - bool IsInDatabase(const PixelFormat format, const u32 width, const u32 height) { - ResolutionKey key{format, width, height}; + bool IsInDatabase(const PixelFormat format, const u32 width, const u32 height) const { + const ResolutionKey key{format, width, height}; return database.count(key) > 0; } - bool IsBlacklisted(const PixelFormat format, const u32 width, const u32 height) { - ResolutionKey key{format, width, height}; + bool IsBlacklisted(const PixelFormat format, const u32 width, const u32 height) const { + const ResolutionKey key{format, width, height}; return blacklist.count(key) > 0; } diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 895b4eb2f5..3e95828e6b 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -167,7 +167,7 @@ public: depth_buffer.view = surface_view.second; if (depth_buffer.target) { depth_buffer.target->MarkAsRenderTarget(true, DEPTH_RT); - if (IsResScannerEnabled()) { + if (IsResolutionScannerEnabled()) { MarkScanner(depth_buffer.target); } } @@ -205,7 +205,7 @@ public: render_targets[index].view = surface_view.second; if (render_targets[index].target) { render_targets[index].target->MarkAsRenderTarget(true, static_cast(index)); - if (IsResScannerEnabled()) { + if (IsResolutionScannerEnabled()) { MarkScanner(render_targets[index].target); } } @@ -253,7 +253,7 @@ public: DeduceBestBlit(src_params, dst_params, src_gpu_addr, dst_gpu_addr); std::pair dst_surface = GetSurface(dst_gpu_addr, dst_params, true, false); std::pair src_surface = GetSurface(src_gpu_addr, src_params, true, false); - if (IsResScannerEnabled()) { + if (IsResolutionScannerEnabled()) { bool is_candidate = IsInRSDatabase(src_surface.first); if (is_candidate) { MarkScanner(dst_surface.first); @@ -283,7 +283,7 @@ public: } bool IsResolutionScalingEnabled() { - if (IsResScannerEnabled()) { + if (IsResolutionScannerEnabled()) { return CheckBlackListMatch(); } if (!EnabledRescaling()) { @@ -390,7 +390,7 @@ protected: ManageRenderTargetUnregister(surface); } - if (IsResScannerEnabled()) { + if (IsResolutionScannerEnabled()) { if (reason == UnregisterReason::Restructured) { UnmarkScanner(surface); } @@ -569,7 +569,7 @@ private: ImageCopy(current_surface, new_surface, brick); } } - if (IsResScannerEnabled()) { + if (IsResolutionScannerEnabled()) { if (IsInRSDatabase(current_surface)) { if (IsRSBlacklisted(new_surface)) { UnmarkScanner(current_surface); @@ -966,7 +966,7 @@ private: if (!surface->IsModified()) { return; } - if (IsResScannerEnabled()) { + if (IsResolutionScannerEnabled()) { UnmarkScanner(surface); } staging_cache.GetBuffer(0).resize(surface->GetHostSizeInBytes()); @@ -1043,7 +1043,7 @@ private: return enable_resolution_scaling; } - bool IsResScannerEnabled() const { + bool IsResolutionScannerEnabled() const { return Settings::values.use_resolution_scanner; } @@ -1061,12 +1061,12 @@ private: scaling_database.Register(params.pixel_format, params.width, params.height); } - bool IsRSBlacklisted(const TSurface& surface) { + bool IsRSBlacklisted(const TSurface& surface) const { const auto params = surface->GetSurfaceParams(); return scaling_database.IsBlacklisted(params.pixel_format, params.width, params.height); } - bool IsInRSDatabase(const TSurface& surface) { + bool IsInRSDatabase(const TSurface& surface) const { const auto& params = surface->GetSurfaceParams(); return scaling_database.IsInDatabase(params.pixel_format, params.width, params.height); }