ResolutioRescaling: Correct reading profiles in windows and address other feedback.
This commit is contained in:
committed by
FernandoS27
parent
b2676f7724
commit
f1fe521c84
@@ -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<s32> 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<GLint>(viewport_rect.left * factor);
|
||||
viewport.y = static_cast<GLint>(viewport_rect.bottom * factor);
|
||||
viewport.width = static_cast<GLint>(viewport_rect.GetWidth() * factor);
|
||||
viewport.height = static_cast<GLint>(viewport_rect.GetHeight() * factor);
|
||||
viewport.depth_range_far = src.depth_range_far;
|
||||
viewport.depth_range_near = src.depth_range_near;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<u32>();
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<u32>(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<TSurface, TView> dst_surface = GetSurface(dst_gpu_addr, dst_params, true, false);
|
||||
std::pair<TSurface, TView> 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user