Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e397cf57b5 | ||
|
|
e51659c11e | ||
|
|
782f9248c2 | ||
|
|
b4613f538a | ||
|
|
440a1d8de0 | ||
|
|
89e1819037 | ||
|
|
4427f8b29a | ||
|
|
1d86b7557a | ||
|
|
78304982fe |
No files matched your search
@@ -1,41 +0,0 @@
|
||||
# Download all pull requests as patches that match a specific label
|
||||
# Usage: python download-patches-by-label.py <Label to Match> <Root Path Folder to DL to>
|
||||
|
||||
import requests, sys, json, urllib3.request, shutil, subprocess, os, traceback
|
||||
|
||||
org = os.getenv("PrivateMergeOrg".upper(), "yuzu-emu")
|
||||
repo = os.getenv("PrivateMergeRepo".upper(), "yuzu-private")
|
||||
tagline = os.getenv("MergeTaglinePrivate".upper(), "")
|
||||
user = sys.argv[1]
|
||||
|
||||
http = urllib3.PoolManager()
|
||||
dl_list = {}
|
||||
|
||||
def check_individual(repo_id, pr_id):
|
||||
url = 'https://%sdev.azure.com/%s/%s/_apis/git/repositories/%s/pullRequests/%s/labels?api-version=5.1-preview.1' % (user, org, repo, repo_id, pr_id)
|
||||
response = requests.get(url)
|
||||
if (response.ok):
|
||||
j = json.loads(response.content)
|
||||
for tg in j['value']:
|
||||
if (tg['name'] == sys.argv[2]):
|
||||
return True
|
||||
return False
|
||||
|
||||
try:
|
||||
url = 'https://%sdev.azure.com/%s/%s/_apis/git/pullrequests?api-version=5.1' % (user, org, repo)
|
||||
response = requests.get(url)
|
||||
if (response.ok):
|
||||
j = json.loads(response.content)
|
||||
for pr in j["value"]:
|
||||
repo_id = pr['repository']['id']
|
||||
pr_id = pr['pullRequestId']
|
||||
if (check_individual(repo_id, pr_id)):
|
||||
pn = pr_id
|
||||
ref = pr['sourceRefName']
|
||||
print("Matched PR# %s" % pn)
|
||||
print(subprocess.check_output(["git", "fetch", "https://%sdev.azure.com/%s/_git/%s" % (user, org, repo), ref, "-f"]))
|
||||
print(subprocess.check_output(["git", "merge", "--squash", 'origin/' + ref.replace('refs/heads/','')]))
|
||||
print(subprocess.check_output(["git", "commit", "-m\"Merge %s PR %s\"" % (tagline, pn)]))
|
||||
except:
|
||||
traceback.print_exc(file=sys.stdout)
|
||||
sys.exit(-1)
|
||||
@@ -1,9 +1,7 @@
|
||||
# Download all pull requests as patches that match a specific label
|
||||
# Usage: python download-patches-by-label.py <Label to Match> <Root Path Folder to DL to>
|
||||
|
||||
import requests, sys, json, urllib3.request, shutil, subprocess, os
|
||||
|
||||
tagline = os.getenv("MergeTaglinePublic".upper(), "")
|
||||
import requests, sys, json, urllib3.request, shutil, subprocess
|
||||
|
||||
http = urllib3.PoolManager()
|
||||
dl_list = {}
|
||||
@@ -25,6 +23,6 @@ try:
|
||||
print("Matched PR# %s" % pn)
|
||||
print(subprocess.check_output(["git", "fetch", "https://github.com/yuzu-emu/yuzu.git", "pull/%s/head:pr-%s" % (pn, pn), "-f"]))
|
||||
print(subprocess.check_output(["git", "merge", "--squash", "pr-%s" % pn]))
|
||||
print(subprocess.check_output(["git", "commit", "-m\"Merge %s PR %s\"" % (tagline, pn)]))
|
||||
print(subprocess.check_output(["git", "commit", "-m\"Merge PR %s\"" % pn]))
|
||||
except:
|
||||
sys.exit(-1)
|
||||
@@ -1,47 +0,0 @@
|
||||
jobs:
|
||||
- job: merge
|
||||
displayName: 'pull requests'
|
||||
steps:
|
||||
- checkout: self
|
||||
submodules: recursive
|
||||
- template: ./mergebot-private.yml
|
||||
parameters:
|
||||
matchLabel: '$(BuildName)-merge'
|
||||
matchLabelPublic: '$(PublicBuildName)-merge'
|
||||
- task: ArchiveFiles@2
|
||||
displayName: 'Package Source'
|
||||
inputs:
|
||||
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
|
||||
includeRootFolder: false
|
||||
archiveType: '7z'
|
||||
archiveFile: '$(Build.ArtifactStagingDirectory)/yuzu-$(BuildName)-source.7z'
|
||||
- task: PublishPipelineArtifact@1
|
||||
displayName: 'Upload Artifacts'
|
||||
inputs:
|
||||
targetPath: '$(Build.ArtifactStagingDirectory)/yuzu-$(BuildName)-source.7z'
|
||||
artifact: 'yuzu-$(BuildName)-source'
|
||||
replaceExistingArchive: true
|
||||
- job: upload_source
|
||||
displayName: 'upload'
|
||||
dependsOn: merge
|
||||
steps:
|
||||
- template: ./sync-source.yml
|
||||
parameters:
|
||||
artifactSource: 'true'
|
||||
needSubmodules: 'true'
|
||||
- script: chmod a+x $(System.DefaultWorkingDirectory)/.ci/scripts/merge/yuzubot-git-config.sh && $(System.DefaultWorkingDirectory)/.ci/scripts/merge/yuzubot-git-config.sh
|
||||
displayName: 'Apply Git Configuration'
|
||||
- script: git tag -a $(BuildName)-$(Build.BuildId) -m "yuzu $(BuildName) $(Build.BuildNumber) $(Build.DefinitionName)"
|
||||
displayName: 'Tag Source'
|
||||
- script: git remote add other $(GitRepoPushChangesURL)
|
||||
displayName: 'Register Repository'
|
||||
- script: git push --follow-tags --force other HEAD:$(GitPushBranch)
|
||||
displayName: 'Update Code'
|
||||
- script: git rev-list -n 1 $(BuildName)-$(Build.BuildId) > $(Build.ArtifactStagingDirectory)/tag-commit.sha
|
||||
displayName: 'Calculate Release Point'
|
||||
- task: PublishPipelineArtifact@1
|
||||
displayName: 'Upload Release Point'
|
||||
inputs:
|
||||
targetPath: '$(Build.ArtifactStagingDirectory)/tag-commit.sha'
|
||||
artifact: 'yuzu-$(BuildName)-release-point'
|
||||
replaceExistingArchive: true
|
||||
@@ -1,23 +0,0 @@
|
||||
parameters:
|
||||
matchLabel: 'dummy-merge'
|
||||
matchLabelPublic: 'dummy-merge'
|
||||
|
||||
steps:
|
||||
- script: mkdir $(System.DefaultWorkingDirectory)/patches && pip install requests urllib3
|
||||
displayName: 'Prepare Environment'
|
||||
- script: chmod a+x $(System.DefaultWorkingDirectory)/.ci/scripts/merge/yuzubot-git-config.sh && $(System.DefaultWorkingDirectory)/.ci/scripts/merge/yuzubot-git-config.sh
|
||||
displayName: 'Apply Git Configuration'
|
||||
- task: PythonScript@0
|
||||
displayName: 'Discover, Download, and Apply Patches'
|
||||
inputs:
|
||||
scriptSource: 'filePath'
|
||||
scriptPath: '.ci/scripts/merge/apply-patches-by-label.py'
|
||||
arguments: '${{ parameters.matchLabelPublic }} patches-public'
|
||||
workingDirectory: '$(System.DefaultWorkingDirectory)'
|
||||
- task: PythonScript@0
|
||||
displayName: 'Discover, Download, and Apply Patches'
|
||||
inputs:
|
||||
scriptSource: 'filePath'
|
||||
scriptPath: '.ci/scripts/merge/apply-patches-by-label-private.py'
|
||||
arguments: '$(PrivateMergeUser) ${{ parameters.matchLabel }} patches-private'
|
||||
workingDirectory: '$(System.DefaultWorkingDirectory)'
|
||||
@@ -1,8 +0,0 @@
|
||||
trigger:
|
||||
- master
|
||||
|
||||
stages:
|
||||
- stage: merge
|
||||
displayName: 'merge'
|
||||
jobs:
|
||||
- template: ./templates/merge-private.yml
|
||||
@@ -1,28 +0,0 @@
|
||||
trigger:
|
||||
- master
|
||||
|
||||
stages:
|
||||
- stage: format
|
||||
displayName: 'format'
|
||||
jobs:
|
||||
- job: format
|
||||
displayName: 'clang'
|
||||
pool:
|
||||
vmImage: ubuntu-latest
|
||||
steps:
|
||||
- template: ./templates/format-check.yml
|
||||
- stage: build
|
||||
dependsOn: format
|
||||
displayName: 'build'
|
||||
jobs:
|
||||
- template: ./templates/build-standard.yml
|
||||
parameters:
|
||||
cache: 'true'
|
||||
- stage: release
|
||||
displayName: 'release'
|
||||
dependsOn: build
|
||||
jobs:
|
||||
- job: azure
|
||||
displayName: 'azure'
|
||||
steps:
|
||||
- template: ./templates/release-universal.yml
|
||||
@@ -0,0 +1,19 @@
|
||||
# Starter pipeline
|
||||
# Start with a minimal pipeline that you can customize to build and deploy your code.
|
||||
# Add steps that build, run tests, deploy, and more:
|
||||
# https://aka.ms/yaml
|
||||
|
||||
trigger:
|
||||
- master
|
||||
|
||||
pool:
|
||||
vmImage: 'ubuntu-latest'
|
||||
|
||||
steps:
|
||||
- script: echo Hello, world!
|
||||
displayName: 'Run a one-line script'
|
||||
|
||||
- script: |
|
||||
echo Add other tasks to build, test, and deploy your project.
|
||||
echo See https://aka.ms/yaml
|
||||
displayName: 'Run a multi-line script'
|
||||
@@ -36,6 +36,7 @@
|
||||
#define LOAD_DIR "load"
|
||||
#define DUMP_DIR "dump"
|
||||
#define SHADER_DIR "shader"
|
||||
#define RESCALING_DIR "rescaling"
|
||||
#define LOG_DIR "log"
|
||||
|
||||
// Filenames
|
||||
|
||||
@@ -695,6 +695,7 @@ const std::string& GetUserPath(UserPath path, const std::string& new_path) {
|
||||
paths.emplace(UserPath::LoadDir, user_path + LOAD_DIR DIR_SEP);
|
||||
paths.emplace(UserPath::DumpDir, user_path + DUMP_DIR DIR_SEP);
|
||||
paths.emplace(UserPath::ShaderDir, user_path + SHADER_DIR DIR_SEP);
|
||||
paths.emplace(UserPath::RescalingDir, user_path + RESCALING_DIR DIR_SEP);
|
||||
paths.emplace(UserPath::SysDataDir, user_path + SYSDATA_DIR DIR_SEP);
|
||||
paths.emplace(UserPath::KeysDir, user_path + KEYS_DIR DIR_SEP);
|
||||
// TODO: Put the logs in a better location for each OS
|
||||
|
||||
@@ -33,6 +33,7 @@ enum class UserPath {
|
||||
LoadDir,
|
||||
DumpDir,
|
||||
ShaderDir,
|
||||
RescalingDir,
|
||||
SysDataDir,
|
||||
UserDir,
|
||||
};
|
||||
|
||||
@@ -165,14 +165,13 @@ void Controller_NPad::InitNewlyAddedControler(std::size_t controller_idx) {
|
||||
controller.battery_level[0] = BATTERY_FULL;
|
||||
controller.battery_level[1] = BATTERY_FULL;
|
||||
controller.battery_level[2] = BATTERY_FULL;
|
||||
styleset_changed_events[controller_idx].writable->Signal();
|
||||
}
|
||||
|
||||
void Controller_NPad::OnInit() {
|
||||
auto& kernel = system.Kernel();
|
||||
for (std::size_t i = 0; i < styleset_changed_events.size(); i++) {
|
||||
styleset_changed_events[i] = Kernel::WritableEvent::CreateEventPair(
|
||||
kernel, Kernel::ResetType::Manual, fmt::format("npad:NpadStyleSetChanged_{}", i));
|
||||
kernel, Kernel::ResetType::Automatic, fmt::format("npad:NpadStyleSetChanged_{}", i));
|
||||
}
|
||||
|
||||
if (!IsControllerActivated()) {
|
||||
@@ -434,6 +433,7 @@ void Controller_NPad::SetSupportedNPadIdTypes(u8* data, std::size_t length) {
|
||||
supported_npad_id_types.clear();
|
||||
supported_npad_id_types.resize(length / sizeof(u32));
|
||||
std::memcpy(supported_npad_id_types.data(), data, length);
|
||||
bool had_controller_update = false;
|
||||
for (std::size_t i = 0; i < connected_controllers.size(); i++) {
|
||||
auto& controller = connected_controllers[i];
|
||||
if (!controller.is_connected) {
|
||||
@@ -452,6 +452,10 @@ void Controller_NPad::SetSupportedNPadIdTypes(u8* data, std::size_t length) {
|
||||
controller.type = requested_controller;
|
||||
InitNewlyAddedControler(i);
|
||||
}
|
||||
had_controller_update = true;
|
||||
}
|
||||
if (had_controller_update) {
|
||||
styleset_changed_events[i].writable->Signal();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -477,6 +481,7 @@ void Controller_NPad::SetNpadMode(u32 npad_id, NPadAssignments assignment_mode)
|
||||
const std::size_t npad_index = NPadIdToIndex(npad_id);
|
||||
ASSERT(npad_index < shared_memory_entries.size());
|
||||
if (shared_memory_entries[npad_index].pad_assignment != assignment_mode) {
|
||||
styleset_changed_events[npad_index].writable->Signal();
|
||||
shared_memory_entries[npad_index].pad_assignment = assignment_mode;
|
||||
}
|
||||
}
|
||||
@@ -502,6 +507,7 @@ Kernel::SharedPtr<Kernel::ReadableEvent> Controller_NPad::GetStyleSetChangedEven
|
||||
// TODO(ogniK): Figure out the best time to signal this event. This event seems that it should
|
||||
// be signalled at least once, and signaled after a new controller is connected?
|
||||
const auto& styleset_event = styleset_changed_events[NPadIdToIndex(npad_id)];
|
||||
styleset_event.writable->Signal();
|
||||
return styleset_event.readable;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ void LogSettings() {
|
||||
LogSetting("Renderer_UseAccurateGpuEmulation", Settings::values.use_accurate_gpu_emulation);
|
||||
LogSetting("Renderer_UseAsynchronousGpuEmulation",
|
||||
Settings::values.use_asynchronous_gpu_emulation);
|
||||
LogSetting("Renderer_UseResolutionScanner", Settings::values.use_resolution_scanner);
|
||||
LogSetting("Audio_OutputEngine", Settings::values.sink_id);
|
||||
LogSetting("Audio_EnableAudioStretching", Settings::values.enable_audio_stretching);
|
||||
LogSetting("Audio_OutputDevice", Settings::values.audio_device_id);
|
||||
|
||||
@@ -423,6 +423,7 @@ struct Values {
|
||||
bool use_accurate_gpu_emulation;
|
||||
bool use_asynchronous_gpu_emulation;
|
||||
bool force_30fps_mode;
|
||||
bool use_resolution_scanner;
|
||||
|
||||
float bg_red;
|
||||
float bg_green;
|
||||
|
||||
@@ -116,6 +116,8 @@ add_library(video_core STATIC
|
||||
shader/track.cpp
|
||||
surface.cpp
|
||||
surface.h
|
||||
texture_cache/resolution_scaling/database.cpp
|
||||
texture_cache/resolution_scaling/database.h
|
||||
texture_cache/surface_base.cpp
|
||||
texture_cache/surface_base.h
|
||||
texture_cache/surface_params.cpp
|
||||
@@ -165,7 +167,7 @@ endif()
|
||||
create_target_directory_groups(video_core)
|
||||
|
||||
target_link_libraries(video_core PUBLIC common core)
|
||||
target_link_libraries(video_core PRIVATE glad)
|
||||
target_link_libraries(video_core PRIVATE glad json-headers)
|
||||
if (ENABLE_VULKAN)
|
||||
target_link_libraries(video_core PRIVATE sirit)
|
||||
endif()
|
||||
@@ -251,7 +251,10 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
|
||||
if (!gpu.regs.IsShaderConfigEnabled(index)) {
|
||||
switch (program) {
|
||||
case Maxwell::ShaderProgram::Geometry:
|
||||
shader_program_manager->UseTrivialGeometryShader();
|
||||
shader_program_manager->BindGeometryShader(nullptr);
|
||||
break;
|
||||
case Maxwell::ShaderProgram::Fragment:
|
||||
shader_program_manager->BindFragmentShader(nullptr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -261,14 +264,6 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
|
||||
|
||||
const std::size_t stage{index == 0 ? 0 : index - 1}; // Stage indices are 0 - 5
|
||||
|
||||
GLShader::MaxwellUniformData ubo{};
|
||||
ubo.SetFromRegs(gpu, stage);
|
||||
const auto [buffer, offset] =
|
||||
buffer_cache.UploadHostMemory(&ubo, sizeof(ubo), device.GetUniformBufferAlignment());
|
||||
|
||||
// Bind the emulation info buffer
|
||||
bind_ubo_pushbuffer.Push(buffer, offset, static_cast<GLsizeiptr>(sizeof(ubo)));
|
||||
|
||||
Shader shader{shader_cache.GetStageProgram(program)};
|
||||
|
||||
const auto stage_enum = static_cast<Maxwell::ShaderStage>(stage);
|
||||
@@ -282,13 +277,13 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
|
||||
switch (program) {
|
||||
case Maxwell::ShaderProgram::VertexA:
|
||||
case Maxwell::ShaderProgram::VertexB:
|
||||
shader_program_manager->UseProgrammableVertexShader(program_handle);
|
||||
shader_program_manager->BindVertexShader(&program_handle);
|
||||
break;
|
||||
case Maxwell::ShaderProgram::Geometry:
|
||||
shader_program_manager->UseProgrammableGeometryShader(program_handle);
|
||||
shader_program_manager->BindGeometryShader(&program_handle);
|
||||
break;
|
||||
case Maxwell::ShaderProgram::Fragment:
|
||||
shader_program_manager->UseProgrammableFragmentShader(program_handle);
|
||||
shader_program_manager->BindFragmentShader(&program_handle);
|
||||
break;
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unimplemented shader index={}, enable={}, offset=0x{:08X}", index,
|
||||
@@ -380,6 +375,7 @@ void RasterizerOpenGL::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) {
|
||||
void RasterizerOpenGL::LoadDiskResources(const std::atomic_bool& stop_loading,
|
||||
const VideoCore::DiskResourceLoadCallback& callback) {
|
||||
shader_cache.LoadDiskCache(stop_loading, callback);
|
||||
texture_cache.LoadResources();
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::ConfigureFramebuffers() {
|
||||
@@ -426,7 +422,6 @@ void RasterizerOpenGL::ConfigureFramebuffers() {
|
||||
texture_cache.GuardRenderTargets(false);
|
||||
|
||||
state.draw.draw_framebuffer = framebuffer_cache.GetFramebuffer(fbkey);
|
||||
SyncViewport(state);
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::ConfigureClearFramebuffer(OpenGLState& current_state, bool using_color_fb,
|
||||
@@ -552,9 +547,16 @@ void RasterizerOpenGL::Clear() {
|
||||
|
||||
ConfigureClearFramebuffer(clear_state, use_color, use_depth, use_stencil);
|
||||
|
||||
SyncViewport(clear_state);
|
||||
bool res_scaling;
|
||||
if (use_color) {
|
||||
res_scaling = texture_cache.IsResolutionScalingEnabledRT(regs.clear_buffers.RT);
|
||||
} else {
|
||||
res_scaling = texture_cache.IsResolutionScalingEnabledDB();
|
||||
}
|
||||
|
||||
SyncViewport(clear_state, res_scaling);
|
||||
if (regs.clear_flags.scissor) {
|
||||
SyncScissorTest(clear_state);
|
||||
SyncScissorTest(clear_state, res_scaling);
|
||||
}
|
||||
|
||||
if (regs.clear_flags.viewport) {
|
||||
@@ -589,7 +591,6 @@ void RasterizerOpenGL::DrawPrelude() {
|
||||
SyncLogicOpState();
|
||||
SyncCullMode();
|
||||
SyncPrimitiveRestart();
|
||||
SyncScissorTest(state);
|
||||
SyncTransformFeedback();
|
||||
SyncPointState();
|
||||
SyncPolygonOffset();
|
||||
@@ -605,11 +606,6 @@ void RasterizerOpenGL::DrawPrelude() {
|
||||
buffer_size = Common::AlignUp(buffer_size, 4) + CalculateIndexBufferSize();
|
||||
}
|
||||
|
||||
// Uniform space for the 5 shader stages
|
||||
buffer_size = Common::AlignUp<std::size_t>(buffer_size, 4) +
|
||||
(sizeof(GLShader::MaxwellUniformData) + device.GetUniformBufferAlignment()) *
|
||||
Maxwell::MaxShaderStage;
|
||||
|
||||
// Add space for at least 18 constant buffers
|
||||
buffer_size += Maxwell::MaxConstBuffers *
|
||||
(Maxwell::MaxConstBufferSize + device.GetUniformBufferAlignment());
|
||||
@@ -651,6 +647,11 @@ void RasterizerOpenGL::DrawPrelude() {
|
||||
gpu.dirty.ResetVertexArrays();
|
||||
}
|
||||
|
||||
const bool res_scaling = texture_cache.IsResolutionScalingEnabled();
|
||||
SyncViewport(state, res_scaling);
|
||||
SyncScissorTest(state, res_scaling);
|
||||
|
||||
shader_program_manager->SetConstants(gpu, res_scaling);
|
||||
shader_program_manager->ApplyTo(state);
|
||||
state.Apply();
|
||||
|
||||
@@ -773,7 +774,7 @@ void RasterizerOpenGL::DispatchCompute(GPUVAddr code_addr) {
|
||||
SetupComputeImages(kernel);
|
||||
|
||||
const auto [program, next_bindings] = kernel->GetProgramHandle(variant);
|
||||
state.draw.shader_program = program;
|
||||
state.draw.shader_program = program.handle;
|
||||
state.draw.program_pipeline = 0;
|
||||
|
||||
const std::size_t buffer_size =
|
||||
@@ -1072,20 +1073,21 @@ void RasterizerOpenGL::SetupImage(u32 binding, const Tegra::Texture::TICEntry& t
|
||||
state.images[binding] = view->GetTexture();
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) {
|
||||
void RasterizerOpenGL::SyncViewport(OpenGLState& current_state, bool rescaling) {
|
||||
const auto& regs = system.GPU().Maxwell3D().regs;
|
||||
const bool geometry_shaders_enabled =
|
||||
regs.IsShaderConfigEnabled(static_cast<size_t>(Maxwell::ShaderProgram::Geometry));
|
||||
const std::size_t viewport_count =
|
||||
geometry_shaders_enabled ? Tegra::Engines::Maxwell3D::Regs::NumViewports : 1;
|
||||
const float factor = rescaling ? Settings::values.resolution_factor : 1.0f;
|
||||
for (std::size_t i = 0; i < viewport_count; i++) {
|
||||
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;
|
||||
viewport.y = viewport_rect.bottom;
|
||||
viewport.width = viewport_rect.GetWidth();
|
||||
viewport.height = viewport_rect.GetHeight();
|
||||
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;
|
||||
}
|
||||
@@ -1296,12 +1298,13 @@ void RasterizerOpenGL::SyncLogicOpState() {
|
||||
state.logic_op.operation = MaxwellToGL::LogicOp(regs.logic_op.operation);
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncScissorTest(OpenGLState& current_state) {
|
||||
void RasterizerOpenGL::SyncScissorTest(OpenGLState& current_state, bool rescaling) {
|
||||
const auto& regs = system.GPU().Maxwell3D().regs;
|
||||
const bool geometry_shaders_enabled =
|
||||
regs.IsShaderConfigEnabled(static_cast<size_t>(Maxwell::ShaderProgram::Geometry));
|
||||
const std::size_t viewport_count =
|
||||
geometry_shaders_enabled ? Tegra::Engines::Maxwell3D::Regs::NumViewports : 1;
|
||||
const float factor = rescaling ? Settings::values.resolution_factor : 1.0f;
|
||||
for (std::size_t i = 0; i < viewport_count; i++) {
|
||||
const auto& src = regs.scissor_test[i];
|
||||
auto& dst = current_state.viewports[i].scissor;
|
||||
@@ -1311,10 +1314,10 @@ void RasterizerOpenGL::SyncScissorTest(OpenGLState& current_state) {
|
||||
}
|
||||
const u32 width = src.max_x - src.min_x;
|
||||
const u32 height = src.max_y - src.min_y;
|
||||
dst.x = src.min_x;
|
||||
dst.y = src.min_y;
|
||||
dst.width = width;
|
||||
dst.height = height;
|
||||
dst.x = static_cast<u32>(src.min_x * factor);
|
||||
dst.y = static_cast<u32>(src.min_y * factor);
|
||||
dst.width = static_cast<u32>(width * factor);
|
||||
dst.height = static_cast<u32>(height * factor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ private:
|
||||
const GLShader::ImageEntry& entry);
|
||||
|
||||
/// Syncs the viewport and depth range to match the guest state
|
||||
void SyncViewport(OpenGLState& current_state);
|
||||
void SyncViewport(OpenGLState& current_state, bool rescaling);
|
||||
|
||||
/// Syncs the clip enabled status to match the guest state
|
||||
void SyncClipEnabled(
|
||||
@@ -162,7 +162,7 @@ private:
|
||||
void SyncMultiSampleState();
|
||||
|
||||
/// Syncs the scissor test state to match the guest state
|
||||
void SyncScissorTest(OpenGLState& current_state);
|
||||
void SyncScissorTest(OpenGLState& current_state, bool rescaling);
|
||||
|
||||
/// Syncs the transform feedback state to match the guest state
|
||||
void SyncTransformFeedback();
|
||||
|
||||
@@ -23,9 +23,6 @@ namespace OpenGL {
|
||||
|
||||
using VideoCommon::Shader::ProgramCode;
|
||||
|
||||
// One UBO is always reserved for emulation values on staged shaders
|
||||
constexpr u32 STAGE_RESERVED_UBOS = 1;
|
||||
|
||||
struct UnspecializedShader {
|
||||
std::string code;
|
||||
GLShader::ShaderEntries entries;
|
||||
@@ -224,10 +221,6 @@ CachedProgram SpecializeShader(const std::string& code, const GLShader::ShaderEn
|
||||
}
|
||||
source += '\n';
|
||||
|
||||
if (program_type != ProgramType::Compute) {
|
||||
source += fmt::format("#define EMULATION_UBO_BINDING {}\n", base_bindings.cbuf++);
|
||||
}
|
||||
|
||||
for (const auto& cbuf : entries.const_buffers) {
|
||||
source +=
|
||||
fmt::format("#define CBUF_BINDING_{} {}\n", cbuf.GetIndex(), base_bindings.cbuf++);
|
||||
@@ -273,7 +266,7 @@ CachedProgram SpecializeShader(const std::string& code, const GLShader::ShaderEn
|
||||
OGLShader shader;
|
||||
shader.Create(source.c_str(), GetShaderType(program_type));
|
||||
|
||||
auto program = std::make_shared<OGLProgram>();
|
||||
auto program = std::make_shared<GLShader::StageProgram>();
|
||||
program->Create(true, hint_retrievable, shader.handle);
|
||||
return program;
|
||||
}
|
||||
@@ -348,28 +341,26 @@ Shader CachedShader::CreateKernelFromCache(const ShaderParameters& params,
|
||||
new CachedShader(params, ProgramType::Compute, std::move(result)));
|
||||
}
|
||||
|
||||
std::tuple<GLuint, BaseBindings> CachedShader::GetProgramHandle(const ProgramVariant& variant) {
|
||||
std::tuple<GLShader::StageProgram&, BaseBindings> CachedShader::GetProgramHandle(
|
||||
const ProgramVariant& variant) {
|
||||
const auto [entry, is_cache_miss] = programs.try_emplace(variant);
|
||||
auto& program = entry->second;
|
||||
auto& stage_program = entry->second;
|
||||
if (is_cache_miss) {
|
||||
program = TryLoadProgram(variant);
|
||||
if (!program) {
|
||||
program = SpecializeShader(code, entries, program_type, variant);
|
||||
stage_program = TryLoadProgram(variant);
|
||||
if (!stage_program) {
|
||||
stage_program = SpecializeShader(code, entries, program_type, variant);
|
||||
disk_cache.SaveUsage(GetUsage(variant));
|
||||
}
|
||||
|
||||
LabelGLObject(GL_PROGRAM, program->handle, cpu_addr);
|
||||
LabelGLObject(GL_PROGRAM, stage_program->handle, cpu_addr);
|
||||
}
|
||||
|
||||
auto base_bindings = variant.base_bindings;
|
||||
auto base_bindings{variant.base_bindings};
|
||||
base_bindings.cbuf += static_cast<u32>(entries.const_buffers.size());
|
||||
if (program_type != ProgramType::Compute) {
|
||||
base_bindings.cbuf += STAGE_RESERVED_UBOS;
|
||||
}
|
||||
base_bindings.gmem += static_cast<u32>(entries.global_memory_entries.size());
|
||||
base_bindings.sampler += static_cast<u32>(entries.samplers.size());
|
||||
|
||||
return {program->handle, base_bindings};
|
||||
return {*stage_program, base_bindings};
|
||||
}
|
||||
|
||||
CachedProgram CachedShader::TryLoadProgram(const ProgramVariant& variant) const {
|
||||
@@ -516,7 +507,7 @@ CachedProgram ShaderCacheOpenGL::GeneratePrecompiledProgram(
|
||||
return {};
|
||||
}
|
||||
|
||||
CachedProgram shader = std::make_shared<OGLProgram>();
|
||||
CachedProgram shader = std::make_shared<GLShader::StageProgram>();
|
||||
shader->handle = glCreateProgram();
|
||||
glProgramParameteri(shader->handle, GL_PROGRAM_SEPARABLE, GL_TRUE);
|
||||
glProgramBinary(shader->handle, dump.binary_format, dump.binary.data(),
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_decompiler.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_disk_cache.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
@@ -37,7 +38,7 @@ class RasterizerOpenGL;
|
||||
struct UnspecializedShader;
|
||||
|
||||
using Shader = std::shared_ptr<CachedShader>;
|
||||
using CachedProgram = std::shared_ptr<OGLProgram>;
|
||||
using CachedProgram = std::shared_ptr<GLShader::StageProgram>;
|
||||
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
|
||||
using PrecompiledPrograms = std::unordered_map<ShaderDiskCacheUsage, CachedProgram>;
|
||||
using PrecompiledShaders = std::unordered_map<u64, GLShader::ProgramResult>;
|
||||
@@ -80,7 +81,8 @@ public:
|
||||
}
|
||||
|
||||
/// Gets the GL program handle for the shader
|
||||
std::tuple<GLuint, BaseBindings> GetProgramHandle(const ProgramVariant& variant);
|
||||
std::tuple<GLShader::StageProgram&, BaseBindings> GetProgramHandle(
|
||||
const ProgramVariant& variant);
|
||||
|
||||
private:
|
||||
explicit CachedShader(const ShaderParameters& params, ProgramType program_type,
|
||||
|
||||
@@ -242,26 +242,6 @@ constexpr const char* GetTypeString(Type type) {
|
||||
}
|
||||
}
|
||||
|
||||
constexpr const char* GetImageTypeDeclaration(Tegra::Shader::ImageType image_type) {
|
||||
switch (image_type) {
|
||||
case Tegra::Shader::ImageType::Texture1D:
|
||||
return "1D";
|
||||
case Tegra::Shader::ImageType::TextureBuffer:
|
||||
return "Buffer";
|
||||
case Tegra::Shader::ImageType::Texture1DArray:
|
||||
return "1DArray";
|
||||
case Tegra::Shader::ImageType::Texture2D:
|
||||
return "2D";
|
||||
case Tegra::Shader::ImageType::Texture2DArray:
|
||||
return "2DArray";
|
||||
case Tegra::Shader::ImageType::Texture3D:
|
||||
return "3D";
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return "1D";
|
||||
}
|
||||
}
|
||||
|
||||
/// Generates code to use for a swizzle operation.
|
||||
constexpr const char* GetSwizzle(u32 element) {
|
||||
constexpr std::array swizzle = {".x", ".y", ".z", ".w"};
|
||||
@@ -741,6 +721,26 @@ private:
|
||||
void DeclareImages() {
|
||||
const auto& images{ir.GetImages()};
|
||||
for (const auto& [offset, image] : images) {
|
||||
const char* image_type = [&] {
|
||||
switch (image.GetType()) {
|
||||
case Tegra::Shader::ImageType::Texture1D:
|
||||
return "1D";
|
||||
case Tegra::Shader::ImageType::TextureBuffer:
|
||||
return "Buffer";
|
||||
case Tegra::Shader::ImageType::Texture1DArray:
|
||||
return "1DArray";
|
||||
case Tegra::Shader::ImageType::Texture2D:
|
||||
return "2D";
|
||||
case Tegra::Shader::ImageType::Texture2DArray:
|
||||
return "2DArray";
|
||||
case Tegra::Shader::ImageType::Texture3D:
|
||||
return "3D";
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return "1D";
|
||||
}
|
||||
}();
|
||||
|
||||
std::string qualifier = "coherent volatile";
|
||||
if (image.IsRead() && !image.IsWritten()) {
|
||||
qualifier += " readonly";
|
||||
@@ -748,10 +748,13 @@ private:
|
||||
qualifier += " writeonly";
|
||||
}
|
||||
|
||||
const char* format = image.IsAtomic() ? "r32ui, " : "";
|
||||
const char* type_declaration = GetImageTypeDeclaration(image.GetType());
|
||||
std::string format;
|
||||
if (image.IsAtomic()) {
|
||||
format = "r32ui, ";
|
||||
}
|
||||
|
||||
code.AddLine("layout ({}binding = IMAGE_BINDING_{}) {} uniform uimage{} {};", format,
|
||||
image.GetIndex(), qualifier, type_declaration, GetImage(image));
|
||||
image.GetIndex(), qualifier, image_type, GetImage(image));
|
||||
}
|
||||
if (!images.empty()) {
|
||||
code.AddNewLine();
|
||||
@@ -930,9 +933,18 @@ private:
|
||||
return {fmt::format("gl_in[{}].gl_Position{}", Visit(buffer).AsUint(),
|
||||
GetSwizzle(element)),
|
||||
Type::Float};
|
||||
case ProgramType::Fragment:
|
||||
return {element == 3 ? "1.0f" : ("gl_FragCoord"s + GetSwizzle(element)),
|
||||
Type::Float};
|
||||
case ProgramType::Fragment: {
|
||||
switch (element) {
|
||||
case 0:
|
||||
return {"(gl_FragCoord.x / utof(config_pack[3]))", Type::Float};
|
||||
case 1:
|
||||
return {"(gl_FragCoord.y / utof(config_pack[3]))", Type::Float};
|
||||
case 2:
|
||||
return {"gl_FragCoord.z", Type::Float};
|
||||
case 3:
|
||||
return {"1.0f", Type::Float};
|
||||
}
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
@@ -1491,8 +1503,6 @@ private:
|
||||
case Tegra::Shader::HalfType::H1_H1:
|
||||
return {fmt::format("vec2({}[1])", operand.AsHalfFloat()), Type::HalfFloat};
|
||||
}
|
||||
UNREACHABLE();
|
||||
return {"0", Type::Int};
|
||||
}
|
||||
|
||||
Expression HMergeF32(Operation operation) {
|
||||
@@ -2266,7 +2276,10 @@ std::string GetCommonDeclarations() {
|
||||
" bvec2 is_nan2 = isnan(pair2);\n"
|
||||
" return bvec2(comparison.x || is_nan1.x || is_nan2.x, comparison.y || is_nan1.y || "
|
||||
"is_nan2.y);\n"
|
||||
"}}\n\n");
|
||||
"}}\n\n"
|
||||
"layout(location = 0) uniform uvec4 config_pack; // instance_id, flip_stage, y_direction, "
|
||||
"padding\n"
|
||||
"layout(location = 1) uniform vec2 viewport_flip;\n\n");
|
||||
}
|
||||
|
||||
ProgramResult Decompile(const Device& device, const ShaderIR& ir, ProgramType stage,
|
||||
|
||||
@@ -23,14 +23,6 @@ ProgramResult GenerateVertexShader(const Device& device, const ShaderSetup& setu
|
||||
std::string out = "// Shader Unique Id: VS" + id + "\n\n";
|
||||
out += GetCommonDeclarations();
|
||||
|
||||
out += R"(
|
||||
layout (std140, binding = EMULATION_UBO_BINDING) uniform vs_config {
|
||||
vec4 viewport_flip;
|
||||
uvec4 config_pack; // instance_id, flip_stage, y_direction, padding
|
||||
};
|
||||
|
||||
)";
|
||||
|
||||
const ShaderIR program_ir(setup.program.code, PROGRAM_OFFSET, setup.program.size_a);
|
||||
const auto stage = setup.IsDualProgram() ? ProgramType::VertexA : ProgramType::VertexB;
|
||||
ProgramResult program = Decompile(device, program_ir, stage, "vertex");
|
||||
@@ -72,14 +64,6 @@ ProgramResult GenerateGeometryShader(const Device& device, const ShaderSetup& se
|
||||
std::string out = "// Shader Unique Id: GS" + id + "\n\n";
|
||||
out += GetCommonDeclarations();
|
||||
|
||||
out += R"(
|
||||
layout (std140, binding = EMULATION_UBO_BINDING) uniform gs_config {
|
||||
vec4 viewport_flip;
|
||||
uvec4 config_pack; // instance_id, flip_stage, y_direction, padding
|
||||
};
|
||||
|
||||
)";
|
||||
|
||||
const ShaderIR program_ir(setup.program.code, PROGRAM_OFFSET, setup.program.size_a);
|
||||
ProgramResult program = Decompile(device, program_ir, ProgramType::Geometry, "geometry");
|
||||
out += program.first;
|
||||
@@ -87,7 +71,7 @@ layout (std140, binding = EMULATION_UBO_BINDING) uniform gs_config {
|
||||
out += R"(
|
||||
void main() {
|
||||
execute_geometry();
|
||||
};)";
|
||||
})";
|
||||
|
||||
return {std::move(out), std::move(program.second)};
|
||||
}
|
||||
@@ -108,11 +92,6 @@ layout (location = 5) out vec4 FragColor5;
|
||||
layout (location = 6) out vec4 FragColor6;
|
||||
layout (location = 7) out vec4 FragColor7;
|
||||
|
||||
layout (std140, binding = EMULATION_UBO_BINDING) uniform fs_config {
|
||||
vec4 viewport_flip;
|
||||
uvec4 config_pack; // instance_id, flip_stage, y_direction, padding
|
||||
};
|
||||
|
||||
)";
|
||||
const ShaderIR program_ir(setup.program.code, PROGRAM_OFFSET, setup.program.size_a);
|
||||
ProgramResult program = Decompile(device, program_ir, ProgramType::Fragment, "fragment");
|
||||
|
||||
@@ -2,13 +2,34 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <array>
|
||||
#include "common/common_types.h"
|
||||
#include "core/settings.h"
|
||||
#include "video_core/engines/maxwell_3d.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
||||
|
||||
namespace OpenGL::GLShader {
|
||||
|
||||
using Tegra::Engines::Maxwell3D;
|
||||
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
|
||||
|
||||
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;
|
||||
}
|
||||
if (state.viewport_scale != old_state.viewport_scale) {
|
||||
glProgramUniform2fv(handle, VIEWPORT_SCALE, 1, state.viewport_scale.data());
|
||||
old_state.viewport_scale = state.viewport_scale;
|
||||
}
|
||||
}
|
||||
|
||||
ProgramManager::ProgramManager() {
|
||||
pipeline.Create();
|
||||
@@ -16,12 +37,59 @@ ProgramManager::ProgramManager() {
|
||||
|
||||
ProgramManager::~ProgramManager() = default;
|
||||
|
||||
void ProgramManager::SetConstants(Tegra::Engines::Maxwell3D& maxwell_3d, bool rescaling) {
|
||||
const auto& regs = maxwell_3d.regs;
|
||||
const auto& state = maxwell_3d.state;
|
||||
|
||||
// TODO(bunnei): Support more than one viewport
|
||||
const GLfloat flip_x = regs.viewport_transform[0].scale_x < 0.0 ? -1.0f : 1.0f;
|
||||
const GLfloat flip_y = regs.viewport_transform[0].scale_y < 0.0 ? -1.0f : 1.0f;
|
||||
|
||||
const GLuint instance_id = state.current_instance;
|
||||
|
||||
// Assign in which stage the position has to be flipped (the last stage before the fragment
|
||||
// shader).
|
||||
const GLuint flip_stage = [&]() {
|
||||
constexpr u32 geometry_index = static_cast<u32>(Maxwell::ShaderProgram::Geometry);
|
||||
if (regs.shader_config[geometry_index].enable) {
|
||||
return geometry_index;
|
||||
} else {
|
||||
return static_cast<u32>(Maxwell::ShaderProgram::VertexB);
|
||||
}
|
||||
}();
|
||||
|
||||
// Y_NEGATE controls what value S2R returns for the Y_DIRECTION system value.
|
||||
const GLfloat y_direction = regs.screen_y_control.y_negate == 0 ? 1.0f : -1.0f;
|
||||
|
||||
const GLfloat rescale_factor = rescaling ? Settings::values.resolution_factor : 1.0f;
|
||||
|
||||
for (const auto stage :
|
||||
{current_state.vertex, current_state.geometry, current_state.fragment}) {
|
||||
if (!stage) {
|
||||
continue;
|
||||
}
|
||||
stage->SetInstanceID(instance_id);
|
||||
stage->SetFlipStage(flip_stage);
|
||||
stage->SetYDirection(y_direction);
|
||||
stage->SetViewportScale(flip_x, flip_y);
|
||||
stage->SetRescalingFactor(rescale_factor);
|
||||
stage->UpdateConstants();
|
||||
}
|
||||
}
|
||||
|
||||
void ProgramManager::ApplyTo(OpenGLState& state) {
|
||||
UpdatePipeline();
|
||||
state.draw.shader_program = 0;
|
||||
state.draw.program_pipeline = pipeline.handle;
|
||||
}
|
||||
|
||||
GLuint GetHandle(StageProgram* program) {
|
||||
if (!program) {
|
||||
return 0;
|
||||
}
|
||||
return program->handle;
|
||||
}
|
||||
|
||||
void ProgramManager::UpdatePipeline() {
|
||||
// Avoid updating the pipeline when values have no changed
|
||||
if (old_state == current_state) {
|
||||
@@ -33,34 +101,11 @@ void ProgramManager::UpdatePipeline() {
|
||||
GL_FRAGMENT_SHADER_BIT};
|
||||
glUseProgramStages(pipeline.handle, all_used_stages, 0);
|
||||
|
||||
glUseProgramStages(pipeline.handle, GL_VERTEX_SHADER_BIT, current_state.vertex_shader);
|
||||
glUseProgramStages(pipeline.handle, GL_GEOMETRY_SHADER_BIT, current_state.geometry_shader);
|
||||
glUseProgramStages(pipeline.handle, GL_FRAGMENT_SHADER_BIT, current_state.fragment_shader);
|
||||
glUseProgramStages(pipeline.handle, GL_VERTEX_SHADER_BIT, GetHandle(current_state.vertex));
|
||||
glUseProgramStages(pipeline.handle, GL_GEOMETRY_SHADER_BIT, GetHandle(current_state.geometry));
|
||||
glUseProgramStages(pipeline.handle, GL_FRAGMENT_SHADER_BIT, GetHandle(current_state.fragment));
|
||||
|
||||
old_state = current_state;
|
||||
}
|
||||
|
||||
void MaxwellUniformData::SetFromRegs(const Maxwell3D& maxwell, std::size_t shader_stage) {
|
||||
const auto& regs = maxwell.regs;
|
||||
const auto& state = maxwell.state;
|
||||
|
||||
// TODO(bunnei): Support more than one viewport
|
||||
viewport_flip[0] = regs.viewport_transform[0].scale_x < 0.0 ? -1.0f : 1.0f;
|
||||
viewport_flip[1] = regs.viewport_transform[0].scale_y < 0.0 ? -1.0f : 1.0f;
|
||||
|
||||
instance_id = state.current_instance;
|
||||
|
||||
// Assign in which stage the position has to be flipped
|
||||
// (the last stage before the fragment shader).
|
||||
constexpr u32 geometry_index = static_cast<u32>(Maxwell3D::Regs::ShaderProgram::Geometry);
|
||||
if (maxwell.regs.shader_config[geometry_index].enable) {
|
||||
flip_stage = geometry_index;
|
||||
} else {
|
||||
flip_stage = static_cast<u32>(Maxwell3D::Regs::ShaderProgram::VertexB);
|
||||
}
|
||||
|
||||
// Y_NEGATE controls what value S2R returns for the Y_DIRECTION system value.
|
||||
y_direction = regs.screen_y_control.y_negate == 0 ? 1.f : -1.f;
|
||||
}
|
||||
|
||||
} // namespace OpenGL::GLShader
|
||||
@@ -4,71 +4,103 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <tuple>
|
||||
|
||||
#include <glad/glad.h>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
||||
#include "video_core/renderer_opengl/gl_state.h"
|
||||
#include "video_core/renderer_opengl/maxwell_to_gl.h"
|
||||
|
||||
namespace Tegra::Engines {
|
||||
class Maxwell3D;
|
||||
}
|
||||
|
||||
namespace OpenGL::GLShader {
|
||||
|
||||
/// Uniform structure for the Uniform Buffer Object, all vectors must be 16-byte aligned
|
||||
/// @note Always keep a vec4 at the end. The GL spec is not clear whether the alignment at
|
||||
/// the end of a uniform block is included in UNIFORM_BLOCK_DATA_SIZE or not.
|
||||
/// Not following that rule will cause problems on some AMD drivers.
|
||||
struct MaxwellUniformData {
|
||||
void SetFromRegs(const Tegra::Engines::Maxwell3D& maxwell, std::size_t shader_stage);
|
||||
class StageProgram final : public OGLProgram {
|
||||
public:
|
||||
explicit StageProgram();
|
||||
~StageProgram();
|
||||
|
||||
alignas(16) GLvec4 viewport_flip;
|
||||
struct alignas(16) {
|
||||
GLuint instance_id;
|
||||
GLuint flip_stage;
|
||||
GLfloat y_direction;
|
||||
void UpdateConstants();
|
||||
|
||||
void SetInstanceID(GLuint instance_id) {
|
||||
state.instance_id = instance_id;
|
||||
}
|
||||
|
||||
void SetFlipStage(GLuint flip_stage) {
|
||||
state.flip_stage = flip_stage;
|
||||
}
|
||||
|
||||
void SetYDirection(GLfloat y_direction) {
|
||||
state.y_direction = y_direction;
|
||||
}
|
||||
|
||||
void SetRescalingFactor(GLfloat rescaling_factor) {
|
||||
state.rescaling_factor = rescaling_factor;
|
||||
}
|
||||
|
||||
void SetViewportScale(GLfloat x, GLfloat y) {
|
||||
state.viewport_scale = {x, y};
|
||||
}
|
||||
|
||||
private:
|
||||
struct State {
|
||||
union {
|
||||
std::array<GLuint, 4> config_pack{};
|
||||
struct {
|
||||
GLuint instance_id;
|
||||
GLuint flip_stage;
|
||||
GLfloat y_direction;
|
||||
GLfloat rescaling_factor;
|
||||
};
|
||||
};
|
||||
|
||||
std::array<GLfloat, 2> viewport_scale{};
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(MaxwellUniformData) == 32, "MaxwellUniformData structure size is incorrect");
|
||||
static_assert(sizeof(MaxwellUniformData) < 16384,
|
||||
"MaxwellUniformData structure must be less than 16kb as per the OpenGL spec");
|
||||
|
||||
class ProgramManager {
|
||||
State state;
|
||||
State old_state;
|
||||
};
|
||||
|
||||
class ProgramManager final {
|
||||
public:
|
||||
explicit ProgramManager();
|
||||
~ProgramManager();
|
||||
|
||||
void SetConstants(Tegra::Engines::Maxwell3D& maxwell_3d, bool rescaling);
|
||||
|
||||
void ApplyTo(OpenGLState& state);
|
||||
|
||||
void UseProgrammableVertexShader(GLuint program) {
|
||||
current_state.vertex_shader = program;
|
||||
void BindVertexShader(StageProgram* program) {
|
||||
current_state.vertex = program;
|
||||
}
|
||||
|
||||
void UseProgrammableGeometryShader(GLuint program) {
|
||||
current_state.geometry_shader = program;
|
||||
void BindGeometryShader(StageProgram* program) {
|
||||
current_state.geometry = program;
|
||||
}
|
||||
|
||||
void UseProgrammableFragmentShader(GLuint program) {
|
||||
current_state.fragment_shader = program;
|
||||
}
|
||||
|
||||
void UseTrivialGeometryShader() {
|
||||
current_state.geometry_shader = 0;
|
||||
void BindFragmentShader(StageProgram* program) {
|
||||
current_state.fragment = program;
|
||||
}
|
||||
|
||||
private:
|
||||
struct PipelineState {
|
||||
bool operator==(const PipelineState& rhs) const {
|
||||
return vertex_shader == rhs.vertex_shader && fragment_shader == rhs.fragment_shader &&
|
||||
geometry_shader == rhs.geometry_shader;
|
||||
return vertex == rhs.vertex && fragment == rhs.fragment && geometry == rhs.geometry;
|
||||
}
|
||||
|
||||
bool operator!=(const PipelineState& rhs) const {
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
GLuint vertex_shader{};
|
||||
GLuint fragment_shader{};
|
||||
GLuint geometry_shader{};
|
||||
StageProgram* vertex{};
|
||||
StageProgram* fragment{};
|
||||
StageProgram* geometry{};
|
||||
};
|
||||
|
||||
void UpdatePipeline();
|
||||
|
||||
@@ -199,7 +199,7 @@ void ApplyTextureDefaults(const SurfaceParams& params, GLuint texture) {
|
||||
}
|
||||
|
||||
OGLTexture CreateTexture(const SurfaceParams& params, GLenum target, GLenum internal_format,
|
||||
OGLBuffer& texture_buffer) {
|
||||
OGLBuffer& texture_buffer, u32 resolution_factor) {
|
||||
OGLTexture texture;
|
||||
texture.Create(target);
|
||||
|
||||
@@ -214,6 +214,9 @@ OGLTexture CreateTexture(const SurfaceParams& params, GLenum target, GLenum inte
|
||||
glTextureBuffer(texture.handle, internal_format, texture_buffer.handle);
|
||||
break;
|
||||
case SurfaceTarget::Texture2D:
|
||||
glTextureStorage2D(texture.handle, params.emulated_levels, internal_format,
|
||||
params.width * resolution_factor, params.height * resolution_factor);
|
||||
break;
|
||||
case SurfaceTarget::TextureCubemap:
|
||||
glTextureStorage2D(texture.handle, params.emulated_levels, internal_format, params.width,
|
||||
params.height);
|
||||
@@ -242,8 +245,13 @@ CachedSurface::CachedSurface(const GPUVAddr gpu_addr, const SurfaceParams& param
|
||||
format = tuple.format;
|
||||
type = tuple.type;
|
||||
is_compressed = tuple.compressed;
|
||||
}
|
||||
|
||||
void CachedSurface::Init() {
|
||||
target = GetTextureTarget(params.target);
|
||||
texture = CreateTexture(params, target, internal_format, texture_buffer);
|
||||
const u32 resolution_factor =
|
||||
IsRescaled() ? static_cast<u32>(Settings::values.resolution_factor) : 1;
|
||||
texture = CreateTexture(params, target, internal_format, texture_buffer, resolution_factor);
|
||||
DecorateSurfaceName();
|
||||
main_view = CreateViewInner(
|
||||
ViewParams(params.target, 0, params.is_layered ? params.depth : 1, 0, params.num_levels),
|
||||
@@ -461,7 +469,10 @@ TextureCacheOpenGL::TextureCacheOpenGL(Core::System& system,
|
||||
TextureCacheOpenGL::~TextureCacheOpenGL() = default;
|
||||
|
||||
Surface TextureCacheOpenGL::CreateSurface(GPUVAddr gpu_addr, const SurfaceParams& params) {
|
||||
return std::make_shared<CachedSurface>(gpu_addr, params);
|
||||
Surface new_surface = std::make_shared<CachedSurface>(gpu_addr, params);
|
||||
SignalCreatedSurface(new_surface);
|
||||
new_surface->Init();
|
||||
return new_surface;
|
||||
}
|
||||
|
||||
void TextureCacheOpenGL::ImageCopy(Surface& src_surface, Surface& dst_surface,
|
||||
@@ -472,15 +483,21 @@ void TextureCacheOpenGL::ImageCopy(Surface& src_surface, Surface& dst_surface,
|
||||
// A fallback is needed
|
||||
return;
|
||||
}
|
||||
const bool src_rescaled = src_surface->IsRescaled();
|
||||
const bool dst_rescaled = dst_surface->IsRescaled();
|
||||
if (src_rescaled != dst_rescaled) {
|
||||
LOG_CRITICAL(HW_GPU, "Rescaling Database is incorrectly set! Rescan the database!.");
|
||||
}
|
||||
const u32 factor = src_rescaled ? static_cast<u32>(Settings::values.resolution_factor) : 1U;
|
||||
const auto src_handle = src_surface->GetTexture();
|
||||
const auto src_target = src_surface->GetTarget();
|
||||
const auto dst_handle = dst_surface->GetTexture();
|
||||
const auto dst_target = dst_surface->GetTarget();
|
||||
glCopyImageSubData(src_handle, src_target, copy_params.source_level, copy_params.source_x,
|
||||
copy_params.source_y, copy_params.source_z, dst_handle, dst_target,
|
||||
copy_params.dest_level, copy_params.dest_x, copy_params.dest_y,
|
||||
copy_params.dest_z, copy_params.width, copy_params.height,
|
||||
copy_params.depth);
|
||||
glCopyImageSubData(src_handle, src_target, copy_params.source_level,
|
||||
copy_params.source_x * factor, copy_params.source_y * factor,
|
||||
copy_params.source_z, dst_handle, dst_target, copy_params.dest_level,
|
||||
copy_params.dest_x * factor, copy_params.dest_y * factor, copy_params.dest_z,
|
||||
copy_params.width * factor, copy_params.height * factor, copy_params.depth);
|
||||
}
|
||||
|
||||
void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view,
|
||||
@@ -539,8 +556,14 @@ void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view,
|
||||
const Common::Rectangle<u32>& dst_rect = copy_config.dst_rect;
|
||||
const bool is_linear = copy_config.filter == Tegra::Engines::Fermi2D::Filter::Linear;
|
||||
|
||||
glBlitFramebuffer(src_rect.left, src_rect.top, src_rect.right, src_rect.bottom, dst_rect.left,
|
||||
dst_rect.top, dst_rect.right, dst_rect.bottom, buffers,
|
||||
const bool src_rescaled = src_view->GetParent().IsRescaled();
|
||||
const bool dst_rescaled = dst_view->GetParent().IsRescaled();
|
||||
const u32 factor1 = src_rescaled ? static_cast<u32>(Settings::values.resolution_factor) : 1U;
|
||||
const u32 factor2 = dst_rescaled ? static_cast<u32>(Settings::values.resolution_factor) : 1U;
|
||||
|
||||
glBlitFramebuffer(src_rect.left * factor1, src_rect.top * factor1, src_rect.right * factor1,
|
||||
src_rect.bottom * factor1, dst_rect.left * factor2, dst_rect.top * factor2,
|
||||
dst_rect.right * factor2, dst_rect.bottom * factor2, buffers,
|
||||
is_linear && (buffers == GL_COLOR_BUFFER_BIT) ? GL_LINEAR : GL_NEAREST);
|
||||
}
|
||||
|
||||
@@ -553,8 +576,15 @@ void TextureCacheOpenGL::BufferCopy(Surface& src_surface, Surface& dst_surface)
|
||||
const auto source_format = GetFormatTuple(src_params.pixel_format, src_params.component_type);
|
||||
const auto dest_format = GetFormatTuple(dst_params.pixel_format, dst_params.component_type);
|
||||
|
||||
const std::size_t source_size = src_surface->GetHostSizeInBytes();
|
||||
const std::size_t dest_size = dst_surface->GetHostSizeInBytes();
|
||||
const bool src_rescaled = src_surface->IsRescaled();
|
||||
const bool dst_rescaled = dst_surface->IsRescaled();
|
||||
if (src_rescaled != dst_rescaled) {
|
||||
LOG_CRITICAL(HW_GPU, "Rescaling Database is incorrectly set! Rescan the database!.");
|
||||
}
|
||||
const u32 factor = src_rescaled ? static_cast<u32>(Settings::values.resolution_factor) : 1U;
|
||||
|
||||
const std::size_t source_size = src_surface->GetHostSizeInBytes() * factor * factor;
|
||||
const std::size_t dest_size = dst_surface->GetHostSizeInBytes() * factor * factor;
|
||||
|
||||
const std::size_t buffer_size = std::max(source_size, dest_size);
|
||||
|
||||
@@ -573,8 +603,8 @@ void TextureCacheOpenGL::BufferCopy(Surface& src_surface, Surface& dst_surface)
|
||||
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, copy_pbo_handle);
|
||||
|
||||
const GLsizei width = static_cast<GLsizei>(dst_params.width);
|
||||
const GLsizei height = static_cast<GLsizei>(dst_params.height);
|
||||
const GLsizei width = static_cast<GLsizei>(dst_params.width * factor);
|
||||
const GLsizei height = static_cast<GLsizei>(dst_params.height * factor);
|
||||
const GLsizei depth = static_cast<GLsizei>(dst_params.depth);
|
||||
if (dest_format.compressed) {
|
||||
LOG_CRITICAL(HW_GPU, "Compressed buffer copy is unimplemented!");
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
explicit CachedSurface(GPUVAddr gpu_addr, const SurfaceParams& params);
|
||||
~CachedSurface();
|
||||
|
||||
void Init();
|
||||
|
||||
void UploadTexture(const std::vector<u8>& staging_buffer) override;
|
||||
void DownloadTexture(std::vector<u8>& staging_buffer) override;
|
||||
|
||||
@@ -96,6 +98,10 @@ public:
|
||||
return texture_view.handle;
|
||||
}
|
||||
|
||||
const CachedSurface& GetParent() const {
|
||||
return surface;
|
||||
}
|
||||
|
||||
const SurfaceParams& GetSurfaceParams() const {
|
||||
return surface.GetSurfaceParams();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
// Copyright 2019 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <fmt/format.h>
|
||||
#include <json.hpp>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/common_paths.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/file_util.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/kernel/process.h"
|
||||
#include "video_core/texture_cache/resolution_scaling/database.h"
|
||||
|
||||
namespace VideoCommon::Resolution {
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
std::string GetBaseDir() {
|
||||
return FileUtil::GetUserPath(FileUtil::UserPath::RescalingDir);
|
||||
}
|
||||
|
||||
ScalingDatabase::ScalingDatabase(Core::System& system) : system{system} {}
|
||||
|
||||
ScalingDatabase::~ScalingDatabase() {
|
||||
SaveDatabase();
|
||||
}
|
||||
|
||||
void ScalingDatabase::Init() {
|
||||
title_id = system.CurrentProcess()->GetTitleID();
|
||||
LoadDatabase();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
void ScalingDatabase::LoadDatabase() {
|
||||
const std::string path = GetProfilePath();
|
||||
const bool exists = FileUtil::Exists(path);
|
||||
if (!exists) {
|
||||
return;
|
||||
}
|
||||
std::ifstream file;
|
||||
OpenFStream(file, path, std::ios_base::in);
|
||||
json in;
|
||||
file >> in;
|
||||
u32 version = in["version"].get<u32>();
|
||||
if (version != DBVersion) {
|
||||
return;
|
||||
}
|
||||
for (const auto& entry : in["entries"]) {
|
||||
ResolutionKey key{};
|
||||
key.format = static_cast<PixelFormat>(entry["format"].get<u32>());
|
||||
key.width = entry["width"].get<u32>();
|
||||
key.height = entry["height"].get<u32>();
|
||||
database.insert(key);
|
||||
}
|
||||
for (const auto& entry : in["blacklist"]) {
|
||||
ResolutionKey key{};
|
||||
key.format = static_cast<PixelFormat>(entry["format"].get<u32>());
|
||||
key.width = entry["width"].get<u32>();
|
||||
key.height = entry["height"].get<u32>();
|
||||
blacklist.insert(key);
|
||||
}
|
||||
}
|
||||
|
||||
void ScalingDatabase::SaveDatabase() {
|
||||
const std::string dir = GetBaseDir();
|
||||
if (!FileUtil::CreateDir(dir)) {
|
||||
LOG_ERROR(HW_GPU, "Failed to create directory={}", dir);
|
||||
return;
|
||||
}
|
||||
json out;
|
||||
out.emplace("version", DBVersion);
|
||||
auto entries = json::array();
|
||||
for (const auto& key : database) {
|
||||
entries.push_back({
|
||||
{"format", static_cast<u32>(key.format)},
|
||||
{"width", key.width},
|
||||
{"height", key.height},
|
||||
});
|
||||
}
|
||||
out.emplace("entries", std::move(entries));
|
||||
auto blacklist_entries = json::array();
|
||||
for (const auto& key : blacklist) {
|
||||
blacklist_entries.push_back({
|
||||
{"format", static_cast<u32>(key.format)},
|
||||
{"width", key.width},
|
||||
{"height", key.height},
|
||||
});
|
||||
}
|
||||
out.emplace("blacklist", std::move(blacklist_entries));
|
||||
const std::string path = GetProfilePath();
|
||||
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) {
|
||||
const ResolutionKey key{format, width, height};
|
||||
if (blacklist.count(key) == 0) {
|
||||
database.insert(key);
|
||||
}
|
||||
}
|
||||
|
||||
void ScalingDatabase::Unregister(PixelFormat format, u32 width, u32 height) {
|
||||
const ResolutionKey key{format, width, height};
|
||||
database.erase(key);
|
||||
blacklist.insert(key);
|
||||
}
|
||||
|
||||
std::string ScalingDatabase::GetTitleID() const {
|
||||
return fmt::format("{:016X}", title_id);
|
||||
}
|
||||
|
||||
std::string ScalingDatabase::GetProfilePath() const {
|
||||
return FileUtil::SanitizePath(GetBaseDir() + DIR_SEP_CHR + GetTitleID() + ".json");
|
||||
}
|
||||
|
||||
} // namespace VideoCommon::Resolution
|
||||
@@ -0,0 +1,88 @@
|
||||
// Copyright 2019 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <unordered_set>
|
||||
#include "video_core/surface.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace VideoCommon::Resolution {
|
||||
|
||||
using VideoCore::Surface::PixelFormat;
|
||||
|
||||
struct ResolutionKey {
|
||||
PixelFormat format;
|
||||
u32 width;
|
||||
u32 height;
|
||||
std::size_t Hash() const {
|
||||
const std::size_t comp1 = static_cast<std::size_t>(format) << 44;
|
||||
const std::size_t comp2 = static_cast<std::size_t>(height) << 24;
|
||||
const std::size_t comp3 = static_cast<std::size_t>(width);
|
||||
return comp1 | comp2 | comp3;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
namespace std {
|
||||
|
||||
template <>
|
||||
struct hash<VideoCommon::Resolution::ResolutionKey> {
|
||||
std::size_t operator()(const VideoCommon::Resolution::ResolutionKey& k) const {
|
||||
return k.Hash();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
namespace VideoCommon::Resolution {
|
||||
|
||||
class ScalingDatabase {
|
||||
public:
|
||||
explicit ScalingDatabase(Core::System& system);
|
||||
~ScalingDatabase();
|
||||
|
||||
void SaveDatabase();
|
||||
void LoadDatabase();
|
||||
void Init();
|
||||
|
||||
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) const {
|
||||
const ResolutionKey key{format, width, height};
|
||||
return blacklist.count(key) > 0;
|
||||
}
|
||||
|
||||
void Register(const PixelFormat format, const u32 width, const u32 height);
|
||||
void Unregister(const PixelFormat format, const u32 width, const u32 height);
|
||||
|
||||
std::string GetTitleID() const;
|
||||
std::string GetProfilePath() const;
|
||||
|
||||
private:
|
||||
std::unordered_set<ResolutionKey> database{};
|
||||
std::unordered_set<ResolutionKey> blacklist{};
|
||||
bool initialized{};
|
||||
u64 title_id{};
|
||||
Core::System& system;
|
||||
|
||||
static constexpr u32 DBVersion = 1;
|
||||
};
|
||||
|
||||
} // namespace VideoCommon::Resolution
|
||||
@@ -205,6 +205,10 @@ public:
|
||||
index = index_;
|
||||
}
|
||||
|
||||
void MarkAsRescaled(const bool is_rescaled) {
|
||||
this->is_rescaled = is_rescaled;
|
||||
}
|
||||
|
||||
void MarkAsPicked(bool is_picked_) {
|
||||
is_picked = is_picked_;
|
||||
}
|
||||
@@ -226,6 +230,10 @@ public:
|
||||
return index;
|
||||
}
|
||||
|
||||
bool IsRescaled() const {
|
||||
return is_rescaled;
|
||||
}
|
||||
|
||||
bool IsRegistered() const {
|
||||
return is_registered;
|
||||
}
|
||||
@@ -318,6 +326,7 @@ private:
|
||||
bool is_target{};
|
||||
bool is_registered{};
|
||||
bool is_picked{};
|
||||
bool is_rescaled{};
|
||||
u32 index{NO_RT};
|
||||
u64 modification_tick{};
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <tuple>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <boost/icl/interval_map.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
@@ -29,6 +30,7 @@
|
||||
#include "video_core/rasterizer_interface.h"
|
||||
#include "video_core/surface.h"
|
||||
#include "video_core/texture_cache/copy_params.h"
|
||||
#include "video_core/texture_cache/resolution_scaling/database.h"
|
||||
#include "video_core/texture_cache/surface_base.h"
|
||||
#include "video_core/texture_cache/surface_params.h"
|
||||
#include "video_core/texture_cache/surface_view.h"
|
||||
@@ -53,15 +55,27 @@ class TextureCache {
|
||||
using IntervalMap = boost::icl::interval_map<CacheAddr, std::set<TSurface>>;
|
||||
using IntervalType = typename IntervalMap::interval_type;
|
||||
|
||||
private:
|
||||
enum class UnregisterReason : u32 {
|
||||
Invalidated,
|
||||
Recycled,
|
||||
Rebuilt,
|
||||
Restructured,
|
||||
};
|
||||
|
||||
public:
|
||||
void InvalidateRegion(CacheAddr addr, std::size_t size) {
|
||||
std::lock_guard lock{mutex};
|
||||
|
||||
for (const auto& surface : GetSurfacesInRegion(addr, size)) {
|
||||
Unregister(surface);
|
||||
Unregister(surface, UnregisterReason::Invalidated);
|
||||
}
|
||||
}
|
||||
|
||||
void LoadResources() {
|
||||
scaling_database.Init();
|
||||
}
|
||||
|
||||
/***
|
||||
* `Guard` guarantees that rendertargets don't unregister themselves if the
|
||||
* collide. Protection is currently only done on 3D slices.
|
||||
@@ -151,8 +165,12 @@ public:
|
||||
depth_buffer.target->MarkAsRenderTarget(false, NO_RT);
|
||||
depth_buffer.target = surface_view.first;
|
||||
depth_buffer.view = surface_view.second;
|
||||
if (depth_buffer.target)
|
||||
if (depth_buffer.target) {
|
||||
depth_buffer.target->MarkAsRenderTarget(true, DEPTH_RT);
|
||||
if (IsResolutionScannerEnabled()) {
|
||||
MarkScanner(depth_buffer.target);
|
||||
}
|
||||
}
|
||||
return surface_view.second;
|
||||
}
|
||||
|
||||
@@ -185,8 +203,12 @@ public:
|
||||
render_targets[index].target->MarkAsRenderTarget(false, NO_RT);
|
||||
render_targets[index].target = surface_view.first;
|
||||
render_targets[index].view = surface_view.second;
|
||||
if (render_targets[index].target)
|
||||
if (render_targets[index].target) {
|
||||
render_targets[index].target->MarkAsRenderTarget(true, static_cast<u32>(index));
|
||||
if (IsResolutionScannerEnabled()) {
|
||||
MarkScanner(render_targets[index].target);
|
||||
}
|
||||
}
|
||||
return surface_view.second;
|
||||
}
|
||||
|
||||
@@ -226,6 +248,12 @@ public:
|
||||
std::lock_guard lock{mutex};
|
||||
std::pair<TSurface, TView> dst_surface = GetFermiSurface(dst_config);
|
||||
std::pair<TSurface, TView> src_surface = GetFermiSurface(src_config);
|
||||
if (IsResolutionScannerEnabled()) {
|
||||
bool is_candidate = IsInRSDatabase(src_surface.first);
|
||||
if (is_candidate) {
|
||||
MarkScanner(dst_surface.first);
|
||||
}
|
||||
}
|
||||
ImageBlit(src_surface.second, dst_surface.second, copy_config);
|
||||
dst_surface.first->MarkAsModified(true, Tick());
|
||||
}
|
||||
@@ -249,13 +277,46 @@ public:
|
||||
return ++ticks;
|
||||
}
|
||||
|
||||
bool IsResolutionScalingEnabled() {
|
||||
if (IsResolutionScannerEnabled()) {
|
||||
return CheckBlackListMatch();
|
||||
}
|
||||
if (!EnabledRescaling()) {
|
||||
return false;
|
||||
}
|
||||
return CheckResolutionScalingEnabled();
|
||||
}
|
||||
|
||||
bool IsResolutionScalingEnabledRT(const std::size_t index) {
|
||||
if (!EnabledRescaling()) {
|
||||
return false;
|
||||
}
|
||||
if (render_targets[index].target) {
|
||||
return render_targets[index].target->IsRescaled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsResolutionScalingEnabledDB() {
|
||||
if (!EnabledRescaling()) {
|
||||
return false;
|
||||
}
|
||||
if (depth_buffer.target) {
|
||||
return depth_buffer.target->IsRescaled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
TextureCache(Core::System& system, VideoCore::RasterizerInterface& rasterizer)
|
||||
: system{system}, rasterizer{rasterizer} {
|
||||
: system{system}, rasterizer{rasterizer}, scaling_database{system} {
|
||||
for (std::size_t i = 0; i < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets; i++) {
|
||||
SetEmptyColorBuffer(i);
|
||||
}
|
||||
|
||||
enable_resolution_scaling =
|
||||
Settings::values.resolution_factor != 1.0f && !Settings::values.use_resolution_scanner;
|
||||
|
||||
SetEmptyDepthBuffer();
|
||||
staging_cache.SetSize(2);
|
||||
|
||||
@@ -316,13 +377,19 @@ protected:
|
||||
rasterizer.UpdatePagesCachedCount(*cpu_addr, size, 1);
|
||||
}
|
||||
|
||||
void Unregister(TSurface surface) {
|
||||
void Unregister(TSurface surface, UnregisterReason reason) {
|
||||
if (guard_render_targets && surface->IsProtected()) {
|
||||
return;
|
||||
}
|
||||
if (!guard_render_targets && surface->IsRenderTarget()) {
|
||||
ManageRenderTargetUnregister(surface);
|
||||
}
|
||||
|
||||
if (IsResolutionScannerEnabled()) {
|
||||
if (reason == UnregisterReason::Restructured) {
|
||||
UnmarkScanner(surface);
|
||||
}
|
||||
}
|
||||
const std::size_t size = surface->GetSizeInBytes();
|
||||
const VAddr cpu_addr = surface->GetCpuAddr();
|
||||
rasterizer.UpdatePagesCachedCount(cpu_addr, size, -1);
|
||||
@@ -348,6 +415,13 @@ protected:
|
||||
return GetSurface(gpu_addr, params, true, false);
|
||||
}
|
||||
|
||||
// Must be called by child's create surface
|
||||
void SignalCreatedSurface(TSurface& new_surface) {
|
||||
if (EnabledRescaling() && IsInRSDatabase(new_surface)) {
|
||||
new_surface->MarkAsRescaled(true);
|
||||
}
|
||||
}
|
||||
|
||||
Core::System& system;
|
||||
|
||||
private:
|
||||
@@ -408,7 +482,7 @@ private:
|
||||
const MatchTopologyResult untopological) {
|
||||
const bool do_load = preserve_contents && Settings::values.use_accurate_gpu_emulation;
|
||||
for (auto& surface : overlaps) {
|
||||
Unregister(surface);
|
||||
Unregister(surface, UnregisterReason::Recycled);
|
||||
}
|
||||
switch (PickStrategy(overlaps, params, gpu_addr, untopological)) {
|
||||
case RecycleStrategy::Ignore: {
|
||||
@@ -467,7 +541,22 @@ private:
|
||||
ImageCopy(current_surface, new_surface, brick);
|
||||
}
|
||||
}
|
||||
Unregister(current_surface);
|
||||
if (IsResolutionScannerEnabled()) {
|
||||
if (IsInRSDatabase(current_surface)) {
|
||||
if (IsRSBlacklisted(new_surface)) {
|
||||
UnmarkScanner(current_surface);
|
||||
} else {
|
||||
MarkScanner(new_surface);
|
||||
}
|
||||
} else if (IsInRSDatabase(new_surface)) {
|
||||
if (IsRSBlacklisted(current_surface)) {
|
||||
UnmarkScanner(new_surface);
|
||||
} else {
|
||||
MarkScanner(current_surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
Unregister(current_surface, UnregisterReason::Rebuilt);
|
||||
Register(new_surface);
|
||||
new_surface->MarkAsModified(current_surface->IsModified(), Tick());
|
||||
return {new_surface, new_surface->GetMainView()};
|
||||
@@ -548,7 +637,7 @@ private:
|
||||
return {};
|
||||
}
|
||||
for (auto surface : overlaps) {
|
||||
Unregister(surface);
|
||||
Unregister(surface, UnregisterReason::Restructured);
|
||||
}
|
||||
new_surface->MarkAsModified(modified, Tick());
|
||||
Register(new_surface);
|
||||
@@ -701,7 +790,30 @@ private:
|
||||
return {new_surface, new_surface->GetMainView()};
|
||||
}
|
||||
|
||||
void LoadSurface(const TSurface& surface) {
|
||||
void LoadSurfaceRescaled(TSurface& surface) {
|
||||
const auto& params = surface->GetSurfaceParams();
|
||||
enable_resolution_scaling = false;
|
||||
TSurface proxy = CreateSurface(surface->GetGpuAddr(), params);
|
||||
enable_resolution_scaling = true;
|
||||
staging_cache.GetBuffer(0).resize(proxy->GetHostSizeInBytes());
|
||||
proxy->LoadBuffer(system.GPU().MemoryManager(), staging_cache);
|
||||
proxy->UploadTexture(staging_cache.GetBuffer(0));
|
||||
Tegra::Engines::Fermi2D::Config copy_config;
|
||||
const Common::Rectangle<u32> rect{0, 0, params.width, params.height};
|
||||
copy_config.operation = Tegra::Engines::Fermi2D::Operation::SrcCopy;
|
||||
copy_config.filter = Tegra::Engines::Fermi2D::Filter::Linear;
|
||||
copy_config.src_rect = rect;
|
||||
copy_config.dst_rect = rect;
|
||||
TView src_view = proxy->GetMainView();
|
||||
TView dst_view = surface->GetMainView();
|
||||
ImageBlit(src_view, dst_view, copy_config);
|
||||
}
|
||||
|
||||
void LoadSurface(TSurface& surface) {
|
||||
if (surface->IsRescaled()) {
|
||||
LoadSurfaceRescaled(surface);
|
||||
return;
|
||||
}
|
||||
staging_cache.GetBuffer(0).resize(surface->GetHostSizeInBytes());
|
||||
surface->LoadBuffer(system.GPU().MemoryManager(), staging_cache);
|
||||
surface->UploadTexture(staging_cache.GetBuffer(0));
|
||||
@@ -712,6 +824,9 @@ private:
|
||||
if (!surface->IsModified()) {
|
||||
return;
|
||||
}
|
||||
if (IsResolutionScannerEnabled()) {
|
||||
UnmarkScanner(surface);
|
||||
}
|
||||
staging_cache.GetBuffer(0).resize(surface->GetHostSizeInBytes());
|
||||
surface->DownloadTexture(staging_cache.GetBuffer(0));
|
||||
surface->FlushBuffer(system.GPU().MemoryManager(), staging_cache);
|
||||
@@ -782,6 +897,115 @@ private:
|
||||
return {};
|
||||
}
|
||||
|
||||
bool EnabledRescaling() const {
|
||||
return enable_resolution_scaling;
|
||||
}
|
||||
|
||||
bool IsResolutionScannerEnabled() const {
|
||||
return Settings::values.use_resolution_scanner;
|
||||
}
|
||||
|
||||
void UnmarkScanner(const TSurface& surface) {
|
||||
const auto params = surface->GetSurfaceParams();
|
||||
scaling_database.Unregister(params.pixel_format, params.width, params.height);
|
||||
}
|
||||
|
||||
void MarkScanner(const TSurface& surface) {
|
||||
const auto params = surface->GetSurfaceParams();
|
||||
if (params.target != SurfaceTarget::Texture2D || params.num_levels > 1 ||
|
||||
params.IsCompressed() || params.block_depth > 1) {
|
||||
return;
|
||||
}
|
||||
scaling_database.Register(params.pixel_format, params.width, params.height);
|
||||
}
|
||||
|
||||
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) const {
|
||||
const auto& params = surface->GetSurfaceParams();
|
||||
return scaling_database.IsInDatabase(params.pixel_format, params.width, params.height);
|
||||
}
|
||||
|
||||
bool CheckBlackListMatch() {
|
||||
u32 enabled_targets = 0;
|
||||
u32 black_listed = 0;
|
||||
bool black_list = false;
|
||||
for (const auto& target : render_targets) {
|
||||
if (target.target) {
|
||||
enabled_targets++;
|
||||
if (IsRSBlacklisted(target.target)) {
|
||||
black_list = true;
|
||||
black_listed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (depth_buffer.target) {
|
||||
enabled_targets++;
|
||||
if (IsRSBlacklisted(depth_buffer.target)) {
|
||||
black_list = true;
|
||||
black_listed++;
|
||||
}
|
||||
}
|
||||
if (black_list) {
|
||||
if (black_listed != enabled_targets) {
|
||||
std::string blacklist_msg{};
|
||||
for (const auto& target : render_targets) {
|
||||
if (target.target) {
|
||||
UnmarkScanner(target.target);
|
||||
const auto& params = target.target->GetSurfaceParams();
|
||||
blacklist_msg += fmt::format("Format:{}, Height:{}, Width:{}\n",
|
||||
static_cast<u32>(params.pixel_format),
|
||||
params.height, params.width);
|
||||
}
|
||||
}
|
||||
if (depth_buffer.target) {
|
||||
UnmarkScanner(depth_buffer.target);
|
||||
const auto& params = depth_buffer.target->GetSurfaceParams();
|
||||
blacklist_msg += fmt::format("Format:{}, Height:{}, Width:{}\n",
|
||||
static_cast<u32>(params.pixel_format),
|
||||
params.height, params.width);
|
||||
}
|
||||
LOG_CRITICAL(HW_GPU, "Scan detected a conflict:\n{}\nBlacklisting all",
|
||||
blacklist_msg);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CheckResolutionScalingEnabled() {
|
||||
u32 enabled_targets = 0;
|
||||
u32 rescaled_targets = 0;
|
||||
bool rescaling = false;
|
||||
for (const auto& target : render_targets) {
|
||||
if (target.target) {
|
||||
enabled_targets++;
|
||||
if (target.target->IsRescaled()) {
|
||||
rescaling = true;
|
||||
rescaled_targets++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (depth_buffer.target) {
|
||||
enabled_targets++;
|
||||
if (depth_buffer.target->IsRescaled()) {
|
||||
rescaling = true;
|
||||
rescaled_targets++;
|
||||
}
|
||||
}
|
||||
if (rescaling) {
|
||||
if (rescaled_targets != enabled_targets) {
|
||||
LOG_CRITICAL(HW_GPU,
|
||||
"Rescaling Database is incorrectly set! Rescan the database!.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
constexpr PixelFormat GetSiblingFormat(PixelFormat format) const {
|
||||
return siblings_table[static_cast<std::size_t>(format)];
|
||||
}
|
||||
@@ -798,6 +1022,7 @@ private:
|
||||
// Guards the cache for protection conflicts.
|
||||
bool guard_render_targets{};
|
||||
bool guard_samplers{};
|
||||
bool enable_resolution_scaling{};
|
||||
|
||||
// The siblings table is for formats that can inter exchange with one another
|
||||
// without causing issues. This is only valid when a conflict occurs on a non
|
||||
@@ -830,6 +1055,8 @@ private:
|
||||
|
||||
StagingCache staging_cache;
|
||||
std::recursive_mutex mutex;
|
||||
|
||||
Resolution::ScalingDatabase scaling_database;
|
||||
};
|
||||
|
||||
} // namespace VideoCommon
|
||||
@@ -613,6 +613,8 @@ void Config::ReadRendererValues() {
|
||||
ReadSetting(QStringLiteral("use_accurate_gpu_emulation"), false).toBool();
|
||||
Settings::values.use_asynchronous_gpu_emulation =
|
||||
ReadSetting(QStringLiteral("use_asynchronous_gpu_emulation"), false).toBool();
|
||||
Settings::values.use_resolution_scanner =
|
||||
ReadSetting(QStringLiteral("use_resolution_scanner"), false).toBool();
|
||||
Settings::values.force_30fps_mode =
|
||||
ReadSetting(QStringLiteral("force_30fps_mode"), false).toBool();
|
||||
|
||||
@@ -1026,6 +1028,8 @@ void Config::SaveRendererValues() {
|
||||
Settings::values.use_accurate_gpu_emulation, false);
|
||||
WriteSetting(QStringLiteral("use_asynchronous_gpu_emulation"),
|
||||
Settings::values.use_asynchronous_gpu_emulation, false);
|
||||
WriteSetting(QStringLiteral("use_resolution_scanner"), Settings::values.use_resolution_scanner,
|
||||
false);
|
||||
WriteSetting(QStringLiteral("force_30fps_mode"), Settings::values.force_30fps_mode, false);
|
||||
|
||||
// Cast to double because Qt's written float values are not human-readable
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace {
|
||||
enum class Resolution : int {
|
||||
Auto,
|
||||
Scanner,
|
||||
Scale1x,
|
||||
Scale2x,
|
||||
Scale3x,
|
||||
@@ -19,8 +19,8 @@ enum class Resolution : int {
|
||||
|
||||
float ToResolutionFactor(Resolution option) {
|
||||
switch (option) {
|
||||
case Resolution::Auto:
|
||||
return 0.f;
|
||||
case Resolution::Scanner:
|
||||
return 1.f;
|
||||
case Resolution::Scale1x:
|
||||
return 1.f;
|
||||
case Resolution::Scale2x:
|
||||
@@ -30,12 +30,12 @@ float ToResolutionFactor(Resolution option) {
|
||||
case Resolution::Scale4x:
|
||||
return 4.f;
|
||||
}
|
||||
return 0.f;
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
Resolution FromResolutionFactor(float factor) {
|
||||
if (factor == 0.f) {
|
||||
return Resolution::Auto;
|
||||
Resolution FromResolutionFactor(float factor, bool scanner_on) {
|
||||
if (scanner_on) {
|
||||
return Resolution::Scanner;
|
||||
} else if (factor == 1.f) {
|
||||
return Resolution::Scale1x;
|
||||
} else if (factor == 2.f) {
|
||||
@@ -45,7 +45,7 @@ Resolution FromResolutionFactor(float factor) {
|
||||
} else if (factor == 4.f) {
|
||||
return Resolution::Scale4x;
|
||||
}
|
||||
return Resolution::Auto;
|
||||
return Resolution::Scale1x;
|
||||
}
|
||||
} // Anonymous namespace
|
||||
|
||||
@@ -71,8 +71,9 @@ ConfigureGraphics::~ConfigureGraphics() = default;
|
||||
void ConfigureGraphics::SetConfiguration() {
|
||||
const bool runtime_lock = !Core::System::GetInstance().IsPoweredOn();
|
||||
|
||||
ui->resolution_factor_combobox->setCurrentIndex(
|
||||
static_cast<int>(FromResolutionFactor(Settings::values.resolution_factor)));
|
||||
ui->resolution_factor_combobox->setEnabled(runtime_lock);
|
||||
ui->resolution_factor_combobox->setCurrentIndex(static_cast<int>(FromResolutionFactor(
|
||||
Settings::values.resolution_factor, Settings::values.use_resolution_scanner)));
|
||||
ui->use_disk_shader_cache->setEnabled(runtime_lock);
|
||||
ui->use_disk_shader_cache->setChecked(Settings::values.use_disk_shader_cache);
|
||||
ui->use_accurate_gpu_emulation->setChecked(Settings::values.use_accurate_gpu_emulation);
|
||||
@@ -86,12 +87,13 @@ void ConfigureGraphics::SetConfiguration() {
|
||||
}
|
||||
|
||||
void ConfigureGraphics::ApplyConfiguration() {
|
||||
Settings::values.resolution_factor =
|
||||
ToResolutionFactor(static_cast<Resolution>(ui->resolution_factor_combobox->currentIndex()));
|
||||
const auto resolution = static_cast<Resolution>(ui->resolution_factor_combobox->currentIndex());
|
||||
Settings::values.resolution_factor = ToResolutionFactor(resolution);
|
||||
Settings::values.use_disk_shader_cache = ui->use_disk_shader_cache->isChecked();
|
||||
Settings::values.use_accurate_gpu_emulation = ui->use_accurate_gpu_emulation->isChecked();
|
||||
Settings::values.use_asynchronous_gpu_emulation =
|
||||
ui->use_asynchronous_gpu_emulation->isChecked();
|
||||
Settings::values.use_resolution_scanner = resolution == Resolution::Scanner;
|
||||
Settings::values.force_30fps_mode = ui->force_30fps_mode->isChecked();
|
||||
Settings::values.bg_red = static_cast<float>(bg_color.redF());
|
||||
Settings::values.bg_green = static_cast<float>(bg_color.greenF());
|
||||
|
||||
@@ -63,27 +63,27 @@
|
||||
<widget class="QComboBox" name="resolution_factor_combobox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Auto (Window Size)</string>
|
||||
<string>Profile Scanner (Native)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Native (1280x720)</string>
|
||||
<string>Native (1280x720/1920x1080)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2x Native (2560x1440)</string>
|
||||
<string>2x Native (2560x1440/3840x2160)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3x Native (3840x2160)</string>
|
||||
<string>3x Native (3840x2160/5760x3240)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>4x Native (5120x2880)</string>
|
||||
<string>4x Native (5120x2880/7680x4320)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
|
||||
@@ -471,6 +471,7 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, std::string pat
|
||||
QAction* open_lfs_location = context_menu.addAction(tr("Open Mod Data Location"));
|
||||
QAction* open_transferable_shader_cache =
|
||||
context_menu.addAction(tr("Open Transferable Shader Cache"));
|
||||
QAction* open_rescaling_profile_cache = context_menu.addAction(tr("Open Rescaling Profile"));
|
||||
context_menu.addSeparator();
|
||||
QAction* dump_romfs = context_menu.addAction(tr("Dump RomFS"));
|
||||
QAction* copy_tid = context_menu.addAction(tr("Copy Title ID to Clipboard"));
|
||||
@@ -490,6 +491,8 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, std::string pat
|
||||
});
|
||||
connect(open_transferable_shader_cache, &QAction::triggered,
|
||||
[this, program_id]() { emit OpenTransferableShaderCacheRequested(program_id); });
|
||||
connect(open_rescaling_profile_cache, &QAction::triggered,
|
||||
[this, program_id]() { emit OpenResolutionProfileRequested(program_id); });
|
||||
connect(dump_romfs, &QAction::triggered,
|
||||
[this, program_id, path]() { emit DumpRomFSRequested(program_id, path); });
|
||||
connect(copy_tid, &QAction::triggered,
|
||||
|
||||
@@ -75,6 +75,7 @@ signals:
|
||||
void ShouldCancelWorker();
|
||||
void OpenFolderRequested(u64 program_id, GameListOpenTarget target);
|
||||
void OpenTransferableShaderCacheRequested(u64 program_id);
|
||||
void OpenResolutionProfileRequested(u64 program_id);
|
||||
void DumpRomFSRequested(u64 program_id, const std::string& game_path);
|
||||
void CopyTIDRequested(u64 program_id);
|
||||
void NavigateToGamedbEntryRequested(u64 program_id,
|
||||
|
||||
+36
-13
@@ -681,6 +681,8 @@ void GMainWindow::ConnectWidgetEvents() {
|
||||
connect(game_list, &GameList::OpenFolderRequested, this, &GMainWindow::OnGameListOpenFolder);
|
||||
connect(game_list, &GameList::OpenTransferableShaderCacheRequested, this,
|
||||
&GMainWindow::OnTransferableShaderCacheOpenFile);
|
||||
connect(game_list, &GameList::OpenResolutionProfileRequested, this,
|
||||
&GMainWindow::OnResolutionProfileOpenFile);
|
||||
connect(game_list, &GameList::DumpRomFSRequested, this, &GMainWindow::OnGameListDumpRomFS);
|
||||
connect(game_list, &GameList::CopyTIDRequested, this, &GMainWindow::OnGameListCopyTID);
|
||||
connect(game_list, &GameList::NavigateToGamedbEntryRequested, this,
|
||||
@@ -1147,6 +1149,23 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(qpath));
|
||||
}
|
||||
|
||||
void DisplayOrSelect(const QString& folder_path, const QString& file_path) {
|
||||
// Windows supports opening a folder with selecting a specified file in explorer. On every other
|
||||
// OS we just open the transferable shader cache folder without preselecting the transferable
|
||||
// shader cache file for the selected game.
|
||||
#if defined(Q_OS_WIN)
|
||||
const QString explorer = QStringLiteral("explorer");
|
||||
QStringList param;
|
||||
if (!QFileInfo(file_path).isDir()) {
|
||||
param << QStringLiteral("/select,");
|
||||
}
|
||||
param << QDir::toNativeSeparators(file_path);
|
||||
QProcess::startDetached(explorer, param);
|
||||
#else
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(folder_path));
|
||||
#endif
|
||||
}
|
||||
|
||||
void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) {
|
||||
ASSERT(program_id != 0);
|
||||
|
||||
@@ -1164,20 +1183,24 @@ void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Windows supports opening a folder with selecting a specified file in explorer. On every other
|
||||
// OS we just open the transferable shader cache folder without preselecting the transferable
|
||||
// shader cache file for the selected game.
|
||||
#if defined(Q_OS_WIN)
|
||||
const QString explorer = QStringLiteral("explorer");
|
||||
QStringList param;
|
||||
if (!QFileInfo(transferable_shader_cache_file_path).isDir()) {
|
||||
param << QStringLiteral("/select,");
|
||||
DisplayOrSelect(tranferable_shader_cache_folder_path, transferable_shader_cache_file_path);
|
||||
}
|
||||
|
||||
void GMainWindow::OnResolutionProfileOpenFile(u64 program_id) {
|
||||
ASSERT(program_id != 0);
|
||||
|
||||
const QString rescaling_dir =
|
||||
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::RescalingDir));
|
||||
const QString rescaling_profile_file_path =
|
||||
rescaling_dir + QString::fromStdString(fmt::format("{:016X}.json", program_id));
|
||||
|
||||
if (!QFile::exists(rescaling_profile_file_path)) {
|
||||
QMessageBox::warning(this, tr("Error Opening Rescaling Profile"),
|
||||
tr("A rescaling profile for this title does not exist."));
|
||||
return;
|
||||
}
|
||||
param << QDir::toNativeSeparators(transferable_shader_cache_file_path);
|
||||
QProcess::startDetached(explorer, param);
|
||||
#else
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(tranferable_shader_cache_folder_path));
|
||||
#endif
|
||||
|
||||
DisplayOrSelect(rescaling_dir, rescaling_profile_file_path);
|
||||
}
|
||||
|
||||
static std::size_t CalculateRomFSEntrySize(const FileSys::VirtualDir& dir, bool full) {
|
||||
|
||||
@@ -185,6 +185,7 @@ private slots:
|
||||
void OnGameListLoadFile(QString game_path);
|
||||
void OnGameListOpenFolder(u64 program_id, GameListOpenTarget target);
|
||||
void OnTransferableShaderCacheOpenFile(u64 program_id);
|
||||
void OnResolutionProfileOpenFile(u64 program_id);
|
||||
void OnGameListDumpRomFS(u64 program_id, const std::string& game_path);
|
||||
void OnGameListCopyTID(u64 program_id);
|
||||
void OnGameListNavigateToGamedbEntry(u64 program_id,
|
||||
|
||||
Reference in new issue
Block a user