Compare commits
21 Commits
__refs_pul
...
__refs_pul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b131b62b0 | ||
|
|
8a2e96de2e | ||
|
|
c4a99944f2 | ||
|
|
867e1db287 | ||
|
|
0ba7055873 | ||
|
|
3f52bb5677 | ||
|
|
ab8d122384 | ||
|
|
3e5790de79 | ||
|
|
da07373599 | ||
|
|
f926230ab1 | ||
|
|
25bfaffdff | ||
|
|
376f1a4432 | ||
|
|
2f5545f8de | ||
|
|
921dae5e83 | ||
|
|
15805f4e01 | ||
|
|
851c5d67ae | ||
|
|
14248685af | ||
|
|
cc3db2aa43 | ||
|
|
44000971e2 | ||
|
|
675f23aedc | ||
|
|
4de0f1e1c8 |
41
.ci/scripts/merge/apply-patches-by-label-private.py
Normal file
41
.ci/scripts/merge/apply-patches-by-label-private.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# 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,7 +1,9 @@
|
||||
# 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
|
||||
import requests, sys, json, urllib3.request, shutil, subprocess, os
|
||||
|
||||
tagline = os.getenv("MergeTaglinePublic".upper(), "")
|
||||
|
||||
http = urllib3.PoolManager()
|
||||
dl_list = {}
|
||||
@@ -23,6 +25,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 PR %s\"" % pn]))
|
||||
print(subprocess.check_output(["git", "commit", "-m\"Merge %s PR %s\"" % (tagline, pn)]))
|
||||
except:
|
||||
sys.exit(-1)
|
||||
|
||||
5
.ci/templates/build-mock.yml
Normal file
5
.ci/templates/build-mock.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
steps:
|
||||
- script: mkdir artifacts || echo 'X' > artifacts/T1.txt
|
||||
- publish: artifacts
|
||||
artifact: 'yuzu-$(BuildName)-$(BuildSuffix)'
|
||||
displayName: 'Upload Artifacts'
|
||||
@@ -3,17 +3,18 @@ parameters:
|
||||
cache: 'false'
|
||||
|
||||
steps:
|
||||
- script: export DATE=`date '+%Y.%m.%d'` && export CI=true && AZURE_REPO_NAME=yuzu-emu/yuzu-$(BuildName) && AZURE_REPO_TAG=$(BuildName)-$DATE
|
||||
displayName: 'Determine Build Name'
|
||||
- task: DockerInstaller@0
|
||||
displayName: 'Prepare Environment'
|
||||
inputs:
|
||||
dockerVersion: '17.09.0-ce'
|
||||
- ${{ if eq(parameters.cache, 'true') }}:
|
||||
- task: CacheBeta@0
|
||||
displayName: 'Cache Build System'
|
||||
inputs:
|
||||
key: yuzu-v1-$(BuildName)-$(BuildSuffix)-$(CacheSuffix)
|
||||
path: $(System.DefaultWorkingDirectory)/ccache
|
||||
cacheHitVar: CACHE_RESTORED
|
||||
- task: CacheBeta@0
|
||||
displayName: 'Cache Build System'
|
||||
inputs:
|
||||
key: yuzu-v1-$(BuildName)-$(BuildSuffix)-$(CacheSuffix)
|
||||
path: $(System.DefaultWorkingDirectory)/ccache
|
||||
cacheHitVar: CACHE_RESTORED
|
||||
- script: chmod a+x ./.ci/scripts/$(ScriptFolder)/exec.sh && ./.ci/scripts/$(ScriptFolder)/exec.sh
|
||||
displayName: 'Build'
|
||||
- script: chmod a+x ./.ci/scripts/$(ScriptFolder)/upload.sh && RELEASE_NAME=$(BuildName) ./.ci/scripts/$(ScriptFolder)/upload.sh
|
||||
|
||||
47
.ci/templates/merge-private.yml
Normal file
47
.ci/templates/merge-private.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
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
|
||||
23
.ci/templates/mergebot-private.yml
Normal file
23
.ci/templates/mergebot-private.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
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)'
|
||||
13
.ci/templates/release-download.yml
Normal file
13
.ci/templates/release-download.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
steps:
|
||||
- task: DownloadPipelineArtifact@2
|
||||
displayName: 'Download Windows Release'
|
||||
inputs:
|
||||
artifactName: 'yuzu-$(BuildName)-windows-mingw'
|
||||
buildType: 'current'
|
||||
targetPath: '$(Build.ArtifactStagingDirectory)'
|
||||
- task: DownloadPipelineArtifact@2
|
||||
displayName: 'Download Linux Release'
|
||||
inputs:
|
||||
artifactName: 'yuzu-$(BuildName)-linux'
|
||||
buildType: 'current'
|
||||
targetPath: '$(Build.ArtifactStagingDirectory)'
|
||||
11
.ci/templates/release-github.yml
Normal file
11
.ci/templates/release-github.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
steps:
|
||||
- template: ./release-download.yml
|
||||
- task: GitHubRelease@0
|
||||
inputs:
|
||||
action: 'create'
|
||||
title: 'yuzu $(BuildName) #$(Build.BuildId)'
|
||||
assets: '$(Build.ArtifactStagingDirectory)/*'
|
||||
gitHubConnection: $(GitHubReleaseConnectionName)
|
||||
repositoryName: '$(Build.Repository.Name)'
|
||||
target: '$(Build.SourceVersion)'
|
||||
tagSource: 'auto'
|
||||
10
.ci/templates/release-universal.yml
Normal file
10
.ci/templates/release-universal.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
steps:
|
||||
- template: ./release-download.yml
|
||||
- task: UniversalPackages@0
|
||||
displayName: Publish Artifacts
|
||||
inputs:
|
||||
command: publish
|
||||
publishDirectory: '$(Build.ArtifactStagingDirectory)'
|
||||
vstsFeedPublish: 'yuzu-$(BuildName)'
|
||||
vstsFeedPackagePublish: 'main'
|
||||
packagePublishDescription: 'Yuzu Windows and Linux Executable Packages'
|
||||
8
.ci/yuzu-mainline-step1.yml
Normal file
8
.ci/yuzu-mainline-step1.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
trigger:
|
||||
- master
|
||||
|
||||
stages:
|
||||
- stage: merge
|
||||
displayName: 'merge'
|
||||
jobs:
|
||||
- template: ./templates/merge.yml
|
||||
28
.ci/yuzu-mainline-step2.yml
Normal file
28
.ci/yuzu-mainline-step2.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
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: github
|
||||
displayName: 'GitHub Release'
|
||||
steps:
|
||||
- template: ./templates/release-github.yml
|
||||
8
.ci/yuzu-patreon-step1.yml
Normal file
8
.ci/yuzu-patreon-step1.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
trigger:
|
||||
- master
|
||||
|
||||
stages:
|
||||
- stage: merge
|
||||
displayName: 'merge'
|
||||
jobs:
|
||||
- template: ./templates/merge-private.yml
|
||||
@@ -2,12 +2,7 @@ trigger:
|
||||
- master
|
||||
|
||||
stages:
|
||||
- stage: merge
|
||||
displayName: 'merge'
|
||||
jobs:
|
||||
- template: ./templates/merge.yml
|
||||
- stage: format
|
||||
dependsOn: merge
|
||||
displayName: 'format'
|
||||
jobs:
|
||||
- job: format
|
||||
@@ -17,9 +12,17 @@ stages:
|
||||
steps:
|
||||
- template: ./templates/format-check.yml
|
||||
- stage: build
|
||||
displayName: '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
|
||||
@@ -1,19 +0,0 @@
|
||||
# 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'
|
||||
@@ -2,7 +2,7 @@ yuzu emulator
|
||||
=============
|
||||
[](https://travis-ci.org/yuzu-emu/yuzu)
|
||||
[](https://ci.appveyor.com/project/bunnei/yuzu)
|
||||
[](https://dev.azure.com/yuzu-emu/yuzu/)
|
||||
[](https://dev.azure.com/yuzu-emu/yuzu/) test
|
||||
|
||||
yuzu is an experimental open-source emulator for the Nintendo Switch from the creators of [Citra](https://citra-emu.org/).
|
||||
|
||||
|
||||
2
externals/fmt
vendored
2
externals/fmt
vendored
Submodule externals/fmt updated: 7512a55aa3...4b8f8fac96
@@ -10,6 +10,9 @@ if (DEFINED ENV{CI})
|
||||
elseif(DEFINED ENV{APPVEYOR})
|
||||
set(BUILD_REPOSITORY $ENV{APPVEYOR_REPO_NAME})
|
||||
set(BUILD_TAG $ENV{APPVEYOR_REPO_TAG_NAME})
|
||||
elseif(DEFINED ENV{AZURE})
|
||||
set(BUILD_REPOSITORY $ENV{AZURE_REPO_NAME})
|
||||
set(BUILD_TAG $ENV{AZURE_REPO_TAG})
|
||||
endif()
|
||||
endif()
|
||||
add_custom_command(OUTPUT scm_rev.cpp
|
||||
|
||||
@@ -324,8 +324,6 @@ add_library(core STATIC
|
||||
hle/service/ldr/ldr.h
|
||||
hle/service/lm/lm.cpp
|
||||
hle/service/lm/lm.h
|
||||
hle/service/lm/manager.cpp
|
||||
hle/service/lm/manager.h
|
||||
hle/service/mig/mig.cpp
|
||||
hle/service/mig/mig.h
|
||||
hle/service/mii/mii.cpp
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "core/hle/service/apm/controller.h"
|
||||
#include "core/hle/service/filesystem/filesystem.h"
|
||||
#include "core/hle/service/glue/manager.h"
|
||||
#include "core/hle/service/lm/manager.h"
|
||||
#include "core/hle/service/service.h"
|
||||
#include "core/hle/service/sm/sm.h"
|
||||
#include "core/loader/loader.h"
|
||||
@@ -250,8 +249,6 @@ struct System::Impl {
|
||||
telemetry_session->AddField(Telemetry::FieldType::Performance, "Mean_Frametime_MS",
|
||||
perf_stats->GetMeanFrametime());
|
||||
|
||||
lm_manager.Flush();
|
||||
|
||||
is_powered_on = false;
|
||||
exit_lock = false;
|
||||
|
||||
@@ -340,7 +337,6 @@ struct System::Impl {
|
||||
bool is_powered_on = false;
|
||||
bool exit_lock = false;
|
||||
|
||||
Reporter reporter;
|
||||
std::unique_ptr<Memory::CheatEngine> cheat_engine;
|
||||
std::unique_ptr<Tools::Freezer> memory_freezer;
|
||||
|
||||
@@ -350,9 +346,8 @@ struct System::Impl {
|
||||
/// APM (Performance) services
|
||||
Service::APM::Controller apm_controller{core_timing};
|
||||
|
||||
/// Service State
|
||||
/// Glue services
|
||||
Service::Glue::ARPManager arp_manager;
|
||||
Service::LM::Manager lm_manager{reporter};
|
||||
|
||||
/// Service manager
|
||||
std::shared_ptr<Service::SM::ServiceManager> service_manager;
|
||||
@@ -360,6 +355,8 @@ struct System::Impl {
|
||||
/// Telemetry session for this emulation session
|
||||
std::unique_ptr<Core::TelemetrySession> telemetry_session;
|
||||
|
||||
Reporter reporter;
|
||||
|
||||
ResultStatus status = ResultStatus::Success;
|
||||
std::string status_details = "";
|
||||
|
||||
@@ -635,14 +632,6 @@ const Service::APM::Controller& System::GetAPMController() const {
|
||||
return impl->apm_controller;
|
||||
}
|
||||
|
||||
Service::LM::Manager& System::GetLogManager() {
|
||||
return impl->lm_manager;
|
||||
}
|
||||
|
||||
const Service::LM::Manager& System::GetLogManager() const {
|
||||
return impl->lm_manager;
|
||||
}
|
||||
|
||||
void System::SetExitLock(bool locked) {
|
||||
impl->exit_lock = locked;
|
||||
}
|
||||
|
||||
@@ -58,10 +58,6 @@ namespace Glue {
|
||||
class ARPManager;
|
||||
}
|
||||
|
||||
namespace LM {
|
||||
class Manager;
|
||||
} // namespace LM
|
||||
|
||||
namespace SM {
|
||||
class ServiceManager;
|
||||
} // namespace SM
|
||||
@@ -330,10 +326,6 @@ public:
|
||||
|
||||
const Service::APM::Controller& GetAPMController() const;
|
||||
|
||||
Service::LM::Manager& GetLogManager();
|
||||
|
||||
const Service::LM::Manager& GetLogManager() const;
|
||||
|
||||
void SetExitLock(bool locked);
|
||||
|
||||
bool GetExitLock() const;
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
#include <string>
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "common/scope_exit.h"
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/service/lm/lm.h"
|
||||
#include "core/hle/service/lm/manager.h"
|
||||
#include "core/hle/service/service.h"
|
||||
#include "core/memory.h"
|
||||
|
||||
@@ -17,16 +15,65 @@ namespace Service::LM {
|
||||
|
||||
class ILogger final : public ServiceFramework<ILogger> {
|
||||
public:
|
||||
ILogger(Manager& manager) : ServiceFramework("ILogger"), manager(manager) {
|
||||
ILogger() : ServiceFramework("ILogger") {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &ILogger::Log, "Log"},
|
||||
{1, &ILogger::SetDestination, "SetDestination"},
|
||||
{0x00000000, &ILogger::Initialize, "Initialize"},
|
||||
{0x00000001, &ILogger::SetDestination, "SetDestination"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
private:
|
||||
void Log(Kernel::HLERequestContext& ctx) {
|
||||
struct MessageHeader {
|
||||
enum Flags : u32_le {
|
||||
IsHead = 1,
|
||||
IsTail = 2,
|
||||
};
|
||||
enum Severity : u32_le {
|
||||
Trace,
|
||||
Info,
|
||||
Warning,
|
||||
Error,
|
||||
Critical,
|
||||
};
|
||||
|
||||
u64_le pid;
|
||||
u64_le threadContext;
|
||||
union {
|
||||
BitField<0, 16, Flags> flags;
|
||||
BitField<16, 8, Severity> severity;
|
||||
BitField<24, 8, u32> verbosity;
|
||||
};
|
||||
u32_le payload_size;
|
||||
|
||||
bool IsHeadLog() const {
|
||||
return flags & Flags::IsHead;
|
||||
}
|
||||
bool IsTailLog() const {
|
||||
return flags & Flags::IsTail;
|
||||
}
|
||||
};
|
||||
static_assert(sizeof(MessageHeader) == 0x18, "MessageHeader is incorrect size");
|
||||
|
||||
/// Log field type
|
||||
enum class Field : u8 {
|
||||
Skip = 1,
|
||||
Message = 2,
|
||||
Line = 3,
|
||||
Filename = 4,
|
||||
Function = 5,
|
||||
Module = 6,
|
||||
Thread = 7,
|
||||
};
|
||||
|
||||
/**
|
||||
* ILogger::Initialize service function
|
||||
* Inputs:
|
||||
* 0: 0x00000000
|
||||
* Outputs:
|
||||
* 0: ResultCode
|
||||
*/
|
||||
void Initialize(Kernel::HLERequestContext& ctx) {
|
||||
// This function only succeeds - Get that out of the way
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
@@ -38,70 +85,140 @@ private:
|
||||
Memory::ReadBlock(addr, &header, sizeof(MessageHeader));
|
||||
addr += sizeof(MessageHeader);
|
||||
|
||||
FieldMap fields;
|
||||
if (header.IsHeadLog()) {
|
||||
log_stream.str("");
|
||||
log_stream.clear();
|
||||
}
|
||||
|
||||
// Parse out log metadata
|
||||
u32 line{};
|
||||
std::string module;
|
||||
std::string message;
|
||||
std::string filename;
|
||||
std::string function;
|
||||
std::string thread;
|
||||
while (addr < end_addr) {
|
||||
const auto field = static_cast<Field>(Memory::Read8(addr++));
|
||||
const auto length = Memory::Read8(addr++);
|
||||
const Field field{static_cast<Field>(Memory::Read8(addr++))};
|
||||
const std::size_t length{Memory::Read8(addr++)};
|
||||
|
||||
if (static_cast<Field>(Memory::Read8(addr)) == Field::Skip) {
|
||||
++addr;
|
||||
}
|
||||
|
||||
SCOPE_EXIT({ addr += length; });
|
||||
|
||||
if (field == Field::Skip) {
|
||||
continue;
|
||||
switch (field) {
|
||||
case Field::Skip:
|
||||
break;
|
||||
case Field::Message:
|
||||
message = Memory::ReadCString(addr, length);
|
||||
break;
|
||||
case Field::Line:
|
||||
line = Memory::Read32(addr);
|
||||
break;
|
||||
case Field::Filename:
|
||||
filename = Memory::ReadCString(addr, length);
|
||||
break;
|
||||
case Field::Function:
|
||||
function = Memory::ReadCString(addr, length);
|
||||
break;
|
||||
case Field::Module:
|
||||
module = Memory::ReadCString(addr, length);
|
||||
break;
|
||||
case Field::Thread:
|
||||
thread = Memory::ReadCString(addr, length);
|
||||
break;
|
||||
}
|
||||
|
||||
std::vector<u8> data(length);
|
||||
Memory::ReadBlock(addr, data.data(), length);
|
||||
fields.emplace(field, std::move(data));
|
||||
addr += length;
|
||||
}
|
||||
|
||||
manager.Log({header, std::move(fields)});
|
||||
// Empty log - nothing to do here
|
||||
if (log_stream.str().empty() && message.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Format a nicely printable string out of the log metadata
|
||||
if (!filename.empty()) {
|
||||
log_stream << filename << ':';
|
||||
}
|
||||
if (!module.empty()) {
|
||||
log_stream << module << ':';
|
||||
}
|
||||
if (!function.empty()) {
|
||||
log_stream << function << ':';
|
||||
}
|
||||
if (line) {
|
||||
log_stream << std::to_string(line) << ':';
|
||||
}
|
||||
if (!thread.empty()) {
|
||||
log_stream << thread << ':';
|
||||
}
|
||||
if (log_stream.str().length() > 0 && log_stream.str().back() == ':') {
|
||||
log_stream << ' ';
|
||||
}
|
||||
log_stream << message;
|
||||
|
||||
if (header.IsTailLog()) {
|
||||
switch (header.severity) {
|
||||
case MessageHeader::Severity::Trace:
|
||||
LOG_DEBUG(Debug_Emulated, "{}", log_stream.str());
|
||||
break;
|
||||
case MessageHeader::Severity::Info:
|
||||
LOG_INFO(Debug_Emulated, "{}", log_stream.str());
|
||||
break;
|
||||
case MessageHeader::Severity::Warning:
|
||||
LOG_WARNING(Debug_Emulated, "{}", log_stream.str());
|
||||
break;
|
||||
case MessageHeader::Severity::Error:
|
||||
LOG_ERROR(Debug_Emulated, "{}", log_stream.str());
|
||||
break;
|
||||
case MessageHeader::Severity::Critical:
|
||||
LOG_CRITICAL(Debug_Emulated, "{}", log_stream.str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This service function is intended to be used as a way to
|
||||
// redirect logging output to different destinations, however,
|
||||
// given we always want to see the logging output, it's sufficient
|
||||
// to do nothing and return success here.
|
||||
void SetDestination(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto destination = rp.PopEnum<DestinationFlag>();
|
||||
|
||||
LOG_DEBUG(Service_LM, "called, destination={:08X}", static_cast<u32>(destination));
|
||||
|
||||
manager.SetDestination(destination);
|
||||
LOG_DEBUG(Service_LM, "called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
Manager& manager;
|
||||
std::ostringstream log_stream;
|
||||
};
|
||||
|
||||
class LM final : public ServiceFramework<LM> {
|
||||
public:
|
||||
explicit LM(Manager& manager) : ServiceFramework{"lm"}, manager(manager) {
|
||||
// clang-format off
|
||||
explicit LM() : ServiceFramework{"lm"} {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &LM::OpenLogger, "OpenLogger"},
|
||||
{0x00000000, &LM::OpenLogger, "OpenLogger"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* LM::OpenLogger service function
|
||||
* Inputs:
|
||||
* 0: 0x00000000
|
||||
* Outputs:
|
||||
* 0: ResultCode
|
||||
*/
|
||||
void OpenLogger(Kernel::HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_LM, "called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<ILogger>(manager);
|
||||
rb.PushIpcInterface<ILogger>();
|
||||
}
|
||||
|
||||
Manager& manager;
|
||||
};
|
||||
|
||||
void InstallInterfaces(Core::System& system) {
|
||||
std::make_shared<LM>(system.GetLogManager())->InstallAsService(system.ServiceManager());
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
||||
std::make_shared<LM>()->InstallAsService(service_manager);
|
||||
}
|
||||
|
||||
} // namespace Service::LM
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
namespace Service::SM {
|
||||
class ServiceManager;
|
||||
}
|
||||
|
||||
namespace Service::LM {
|
||||
|
||||
/// Registers all LM services with the specified service manager.
|
||||
void InstallInterfaces(Core::System& system);
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager);
|
||||
|
||||
} // namespace Service::LM
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
// Copyright 2019 yuzu emulator team
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/hle/service/lm/manager.h"
|
||||
#include "core/reporter.h"
|
||||
|
||||
namespace Service::LM {
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, DestinationFlag dest) {
|
||||
std::vector<std::string> array;
|
||||
const auto check_single_flag = [dest, &array](DestinationFlag check, std::string name) {
|
||||
if ((static_cast<u32>(check) & static_cast<u32>(dest)) != 0) {
|
||||
array.emplace_back(std::move(name));
|
||||
}
|
||||
};
|
||||
|
||||
check_single_flag(DestinationFlag::Default, "Default");
|
||||
check_single_flag(DestinationFlag::UART, "UART");
|
||||
check_single_flag(DestinationFlag::UARTSleeping, "UART (Sleeping)");
|
||||
|
||||
os << "[";
|
||||
for (const auto& entry : array) {
|
||||
os << entry << ", ";
|
||||
}
|
||||
return os << "]";
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, MessageHeader::Severity severity) {
|
||||
switch (severity) {
|
||||
case MessageHeader::Severity::Trace:
|
||||
return os << "Trace";
|
||||
case MessageHeader::Severity::Info:
|
||||
return os << "Info";
|
||||
case MessageHeader::Severity::Warning:
|
||||
return os << "Warning";
|
||||
case MessageHeader::Severity::Error:
|
||||
return os << "Error";
|
||||
case MessageHeader::Severity::Critical:
|
||||
return os << "Critical";
|
||||
default:
|
||||
return os << fmt::format("{:08X}", static_cast<u32>(severity));
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, Field field) {
|
||||
switch (field) {
|
||||
case Field::Skip:
|
||||
return os << "Skip";
|
||||
case Field::Message:
|
||||
return os << "Message";
|
||||
case Field::Line:
|
||||
return os << "Line";
|
||||
case Field::Filename:
|
||||
return os << "Filename";
|
||||
case Field::Function:
|
||||
return os << "Function";
|
||||
case Field::Module:
|
||||
return os << "Module";
|
||||
case Field::Thread:
|
||||
return os << "Thread";
|
||||
default:
|
||||
return os << fmt::format("{:08X}", static_cast<u32>(field));
|
||||
}
|
||||
}
|
||||
|
||||
std::string FormatField(Field type, const std::vector<u8>& data) {
|
||||
switch (type) {
|
||||
case Field::Skip:
|
||||
return "";
|
||||
case Field::Line:
|
||||
if (data.size() >= sizeof(u32)) {
|
||||
u32 line;
|
||||
std::memcpy(&line, data.data(), sizeof(u32));
|
||||
return fmt::format("{}", line);
|
||||
}
|
||||
return "[ERROR DECODING LINE NUMBER]";
|
||||
case Field::Message:
|
||||
case Field::Filename:
|
||||
case Field::Function:
|
||||
case Field::Module:
|
||||
case Field::Thread:
|
||||
return Common::StringFromFixedZeroTerminatedBuffer(
|
||||
reinterpret_cast<const char*>(data.data()), data.size());
|
||||
default:
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
}
|
||||
|
||||
Manager::Manager(Core::Reporter& reporter) : reporter(reporter) {}
|
||||
|
||||
Manager::~Manager() = default;
|
||||
|
||||
void Manager::SetEnabled(bool enabled) {
|
||||
this->enabled = enabled;
|
||||
}
|
||||
|
||||
void Manager::SetDestination(DestinationFlag destination) {
|
||||
this->destination = destination;
|
||||
}
|
||||
|
||||
void Manager::Log(LogMessage message) {
|
||||
if (message.header.IsHeadLog()) {
|
||||
InitializeLog();
|
||||
}
|
||||
|
||||
current_log.emplace_back(std::move(message));
|
||||
|
||||
if (current_log.back().header.IsTailLog()) {
|
||||
FinalizeLog();
|
||||
}
|
||||
}
|
||||
|
||||
void Manager::Flush() {
|
||||
FinalizeLog();
|
||||
}
|
||||
|
||||
void Manager::InitializeLog() {
|
||||
current_log.clear();
|
||||
|
||||
LOG_INFO(Service_LM, "Initialized new log session");
|
||||
}
|
||||
|
||||
void Manager::FinalizeLog() {
|
||||
reporter.SaveLogReport(static_cast<u32>(destination), std::move(current_log));
|
||||
|
||||
LOG_INFO(Service_LM, "Finalized current log session");
|
||||
}
|
||||
|
||||
} // namespace Service::LM
|
||||
@@ -1,106 +0,0 @@
|
||||
// Copyright 2019 yuzu emulator team
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/swap.h"
|
||||
|
||||
namespace Core {
|
||||
class Reporter;
|
||||
}
|
||||
|
||||
namespace Service::LM {
|
||||
|
||||
enum class DestinationFlag : u32 {
|
||||
Default = 1,
|
||||
UART = 2,
|
||||
UARTSleeping = 4,
|
||||
|
||||
All = 0xFFFF,
|
||||
};
|
||||
|
||||
struct MessageHeader {
|
||||
enum Flags : u32_le {
|
||||
IsHead = 1,
|
||||
IsTail = 2,
|
||||
};
|
||||
enum Severity : u32_le {
|
||||
Trace,
|
||||
Info,
|
||||
Warning,
|
||||
Error,
|
||||
Critical,
|
||||
};
|
||||
|
||||
u64_le pid;
|
||||
u64_le thread_context;
|
||||
union {
|
||||
BitField<0, 16, Flags> flags;
|
||||
BitField<16, 8, Severity> severity;
|
||||
BitField<24, 8, u32> verbosity;
|
||||
};
|
||||
u32_le payload_size;
|
||||
|
||||
bool IsHeadLog() const {
|
||||
return flags & IsHead;
|
||||
}
|
||||
bool IsTailLog() const {
|
||||
return flags & IsTail;
|
||||
}
|
||||
};
|
||||
static_assert(sizeof(MessageHeader) == 0x18, "MessageHeader is incorrect size");
|
||||
|
||||
enum class Field : u8 {
|
||||
Skip = 1,
|
||||
Message = 2,
|
||||
Line = 3,
|
||||
Filename = 4,
|
||||
Function = 5,
|
||||
Module = 6,
|
||||
Thread = 7,
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, DestinationFlag dest);
|
||||
std::ostream& operator<<(std::ostream& os, MessageHeader::Severity severity);
|
||||
std::ostream& operator<<(std::ostream& os, Field field);
|
||||
|
||||
using FieldMap = std::map<Field, std::vector<u8>>;
|
||||
|
||||
struct LogMessage {
|
||||
MessageHeader header;
|
||||
FieldMap fields;
|
||||
};
|
||||
|
||||
std::string FormatField(Field type, const std::vector<u8>& data);
|
||||
|
||||
class Manager {
|
||||
public:
|
||||
explicit Manager(Core::Reporter& reporter);
|
||||
~Manager();
|
||||
|
||||
void SetEnabled(bool enabled);
|
||||
void SetDestination(DestinationFlag destination);
|
||||
|
||||
void Log(LogMessage message);
|
||||
|
||||
void Flush();
|
||||
|
||||
private:
|
||||
void InitializeLog();
|
||||
void FinalizeLog();
|
||||
|
||||
bool enabled = true;
|
||||
DestinationFlag destination = DestinationFlag::All;
|
||||
|
||||
std::vector<LogMessage> current_log;
|
||||
|
||||
Core::Reporter& reporter;
|
||||
};
|
||||
|
||||
} // namespace Service::LM
|
||||
@@ -226,7 +226,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system) {
|
||||
LBL::InstallInterfaces(*sm);
|
||||
LDN::InstallInterfaces(*sm);
|
||||
LDR::InstallInterfaces(*sm, system);
|
||||
LM::InstallInterfaces(system);
|
||||
LM::InstallInterfaces(*sm);
|
||||
Migration::InstallInterfaces(*sm);
|
||||
Mii::InstallInterfaces(*sm);
|
||||
MM::InstallInterfaces(*sm);
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include <fmt/chrono.h>
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/ostream.h>
|
||||
#include <json.hpp>
|
||||
|
||||
#include "common/file_util.h"
|
||||
@@ -18,7 +17,6 @@
|
||||
#include "core/hle/kernel/hle_ipc.h"
|
||||
#include "core/hle/kernel/process.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/hle/service/lm/manager.h"
|
||||
#include "core/reporter.h"
|
||||
#include "core/settings.h"
|
||||
|
||||
@@ -356,55 +354,6 @@ void Reporter::SaveErrorReport(u64 title_id, ResultCode result,
|
||||
SaveToFile(std::move(out), GetPath("error_report", title_id, timestamp));
|
||||
}
|
||||
|
||||
void Reporter::SaveLogReport(u32 destination, std::vector<Service::LM::LogMessage> messages) const {
|
||||
if (!IsReportingEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto timestamp = GetTimestamp();
|
||||
json out;
|
||||
|
||||
out["yuzu_version"] = GetYuzuVersionData();
|
||||
out["report_common"] =
|
||||
GetReportCommonData(system.CurrentProcess()->GetTitleID(), RESULT_SUCCESS, timestamp);
|
||||
|
||||
out["log_destination"] =
|
||||
fmt::format("{}", static_cast<Service::LM::DestinationFlag>(destination));
|
||||
|
||||
auto json_messages = json::array();
|
||||
std::transform(messages.begin(), messages.end(), std::back_inserter(json_messages),
|
||||
[](const Service::LM::LogMessage& message) {
|
||||
json out;
|
||||
out["is_head"] = fmt::format("{}", message.header.IsHeadLog());
|
||||
out["is_tail"] = fmt::format("{}", message.header.IsTailLog());
|
||||
out["pid"] = fmt::format("{:016X}", message.header.pid);
|
||||
out["thread_context"] =
|
||||
fmt::format("{:016X}", message.header.thread_context);
|
||||
out["payload_size"] = fmt::format("{:016X}", message.header.payload_size);
|
||||
out["flags"] = fmt::format("{:04X}", message.header.flags.Value());
|
||||
out["severity"] = fmt::format("{}", message.header.severity.Value());
|
||||
out["verbosity"] = fmt::format("{:02X}", message.header.verbosity);
|
||||
|
||||
auto fields = json::array();
|
||||
std::transform(message.fields.begin(), message.fields.end(),
|
||||
std::back_inserter(fields), [](const auto& kv) {
|
||||
json out;
|
||||
out["type"] = fmt::format("{}", kv.first);
|
||||
out["data"] =
|
||||
Service::LM::FormatField(kv.first, kv.second);
|
||||
return out;
|
||||
});
|
||||
|
||||
out["fields"] = std::move(fields);
|
||||
return out;
|
||||
});
|
||||
|
||||
out["log_messages"] = std::move(json_messages);
|
||||
|
||||
SaveToFile(std::move(out),
|
||||
GetPath("log_report", system.CurrentProcess()->GetTitleID(), timestamp));
|
||||
}
|
||||
|
||||
void Reporter::SaveFilesystemAccessReport(Service::FileSystem::LogMode log_mode,
|
||||
std::string log_message) const {
|
||||
if (!IsReportingEnabled())
|
||||
|
||||
@@ -20,10 +20,6 @@ namespace Service::FileSystem {
|
||||
enum class LogMode : u32;
|
||||
}
|
||||
|
||||
namespace Service::LM {
|
||||
struct LogMessage;
|
||||
} // namespace Service::LM
|
||||
|
||||
namespace Core {
|
||||
|
||||
class System;
|
||||
@@ -33,22 +29,18 @@ public:
|
||||
explicit Reporter(System& system);
|
||||
~Reporter();
|
||||
|
||||
// Used by fatal services
|
||||
void SaveCrashReport(u64 title_id, ResultCode result, u64 set_flags, u64 entry_point, u64 sp,
|
||||
u64 pc, u64 pstate, u64 afsr0, u64 afsr1, u64 esr, u64 far,
|
||||
const std::array<u64, 31>& registers, const std::array<u64, 32>& backtrace,
|
||||
u32 backtrace_size, const std::string& arch, u32 unk10) const;
|
||||
|
||||
// Used by syscall svcBreak
|
||||
void SaveSvcBreakReport(u32 type, bool signal_debugger, u64 info1, u64 info2,
|
||||
std::optional<std::vector<u8>> resolved_buffer = {}) const;
|
||||
|
||||
// Used by HLE service handler
|
||||
void SaveUnimplementedFunctionReport(Kernel::HLERequestContext& ctx, u32 command_id,
|
||||
const std::string& name,
|
||||
const std::string& service_name) const;
|
||||
|
||||
// Used by stub applet implementation
|
||||
void SaveUnimplementedAppletReport(u32 applet_id, u32 common_args_version, u32 library_version,
|
||||
u32 theme_color, bool startup_sound, u64 system_tick,
|
||||
std::vector<std::vector<u8>> normal_channel,
|
||||
@@ -63,7 +55,6 @@ public:
|
||||
void SavePlayReport(PlayReportType type, u64 title_id, std::vector<std::vector<u8>> data,
|
||||
std::optional<u64> process_id = {}, std::optional<u128> user_id = {}) const;
|
||||
|
||||
// Used by error applet
|
||||
void SaveErrorReport(u64 title_id, ResultCode result,
|
||||
std::optional<std::string> custom_text_main = {},
|
||||
std::optional<std::string> custom_text_detail = {}) const;
|
||||
@@ -71,11 +62,6 @@ public:
|
||||
void SaveFilesystemAccessReport(Service::FileSystem::LogMode log_mode,
|
||||
std::string log_message) const;
|
||||
|
||||
// Used by lm services
|
||||
void SaveLogReport(u32 destination, std::vector<Service::LM::LogMessage> messages) const;
|
||||
|
||||
// Can be used anywhere to generate a backtrace and general info report at any point during
|
||||
// execution. Not intended to be used for anything other than debugging or testing.
|
||||
void SaveUserReport() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -544,7 +544,7 @@ enum class VoteOperation : u64 {
|
||||
Eq = 2, // allThreadsEqualNV
|
||||
};
|
||||
|
||||
enum class ImageAtomicSize : u64 {
|
||||
enum class ImageAtomicOperationType : u64 {
|
||||
U32 = 0,
|
||||
S32 = 1,
|
||||
U64 = 2,
|
||||
@@ -1432,11 +1432,11 @@ union Instruction {
|
||||
ASSERT(mode == SurfaceDataMode::D_BA);
|
||||
return store_data_layout;
|
||||
}
|
||||
} sust;
|
||||
} suldst;
|
||||
|
||||
union {
|
||||
BitField<28, 1, u64> is_ba;
|
||||
BitField<51, 3, ImageAtomicSize> size;
|
||||
BitField<51, 3, ImageAtomicOperationType> operation_type;
|
||||
BitField<33, 3, ImageType> image_type;
|
||||
BitField<29, 4, ImageAtomicOperation> operation;
|
||||
BitField<49, 2, OutOfBoundsStore> out_of_bounds_store;
|
||||
@@ -1595,6 +1595,7 @@ public:
|
||||
TMML_B, // Texture Mip Map Level
|
||||
TMML, // Texture Mip Map Level
|
||||
SUST, // Surface Store
|
||||
SULD, // Surface Load
|
||||
SUATOM, // Surface Atomic Operation
|
||||
EXIT,
|
||||
NOP,
|
||||
@@ -1884,6 +1885,7 @@ private:
|
||||
INST("110111110110----", Id::TMML_B, Type::Texture, "TMML_B"),
|
||||
INST("1101111101011---", Id::TMML, Type::Texture, "TMML"),
|
||||
INST("11101011001-----", Id::SUST, Type::Image, "SUST"),
|
||||
INST("11101011000-----", Id::SULD, Type::Image, "SULD"),
|
||||
INST("1110101000------", Id::SUATOM, Type::Image, "SUATOM_D"),
|
||||
INST("0101000010110---", Id::NOP, Type::Trivial, "NOP"),
|
||||
INST("11100000--------", Id::IPA, Type::Trivial, "IPA"),
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include <glad/glad.h>
|
||||
|
||||
#include "common/logging/log.h"
|
||||
@@ -30,9 +32,27 @@ bool TestProgram(const GLchar* glsl) {
|
||||
return link_status == GL_TRUE;
|
||||
}
|
||||
|
||||
std::vector<std::string_view> GetExtensions() {
|
||||
GLint num_extensions;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
|
||||
std::vector<std::string_view> extensions;
|
||||
extensions.reserve(num_extensions);
|
||||
for (GLint index = 0; index < num_extensions; ++index) {
|
||||
extensions.push_back(
|
||||
reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS, static_cast<GLuint>(index))));
|
||||
}
|
||||
return extensions;
|
||||
}
|
||||
|
||||
bool HasExtension(const std::vector<std::string_view>& images, std::string_view extension) {
|
||||
return std::find(images.begin(), images.end(), extension) != images.end();
|
||||
}
|
||||
|
||||
} // Anonymous namespace
|
||||
|
||||
Device::Device() {
|
||||
const std::vector extensions = GetExtensions();
|
||||
|
||||
uniform_buffer_alignment = GetInteger<std::size_t>(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT);
|
||||
shader_storage_alignment = GetInteger<std::size_t>(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT);
|
||||
max_vertex_attributes = GetInteger<u32>(GL_MAX_VERTEX_ATTRIBS);
|
||||
@@ -40,6 +60,7 @@ Device::Device() {
|
||||
has_warp_intrinsics = GLAD_GL_NV_gpu_shader5 && GLAD_GL_NV_shader_thread_group &&
|
||||
GLAD_GL_NV_shader_thread_shuffle;
|
||||
has_vertex_viewport_layer = GLAD_GL_ARB_shader_viewport_layer_array;
|
||||
has_image_load_formatted = HasExtension(extensions, "GL_EXT_shader_image_load_formatted");
|
||||
has_variable_aoffi = TestVariableAoffi();
|
||||
has_component_indexing_bug = TestComponentIndexingBug();
|
||||
has_precise_bug = TestPreciseBug();
|
||||
@@ -55,6 +76,7 @@ Device::Device(std::nullptr_t) {
|
||||
max_varyings = 15;
|
||||
has_warp_intrinsics = true;
|
||||
has_vertex_viewport_layer = true;
|
||||
has_image_load_formatted = true;
|
||||
has_variable_aoffi = true;
|
||||
has_component_indexing_bug = false;
|
||||
has_precise_bug = false;
|
||||
|
||||
@@ -38,6 +38,10 @@ public:
|
||||
return has_vertex_viewport_layer;
|
||||
}
|
||||
|
||||
bool HasImageLoadFormatted() const {
|
||||
return has_image_load_formatted;
|
||||
}
|
||||
|
||||
bool HasVariableAoffi() const {
|
||||
return has_variable_aoffi;
|
||||
}
|
||||
@@ -61,6 +65,7 @@ private:
|
||||
u32 max_varyings{};
|
||||
bool has_warp_intrinsics{};
|
||||
bool has_vertex_viewport_layer{};
|
||||
bool has_image_load_formatted{};
|
||||
bool has_variable_aoffi{};
|
||||
bool has_component_indexing_bug{};
|
||||
bool has_precise_bug{};
|
||||
|
||||
@@ -211,14 +211,14 @@ CachedProgram SpecializeShader(const std::string& code, const GLShader::ShaderEn
|
||||
const auto primitive_mode{variant.primitive_mode};
|
||||
const auto texture_buffer_usage{variant.texture_buffer_usage};
|
||||
|
||||
std::string source = "#version 430 core\n"
|
||||
"#extension GL_ARB_separate_shader_objects : enable\n"
|
||||
"#extension GL_NV_gpu_shader5 : enable\n"
|
||||
"#extension GL_NV_shader_thread_group : enable\n"
|
||||
"#extension GL_NV_shader_thread_shuffle : enable\n";
|
||||
if (entries.shader_viewport_layer_array) {
|
||||
source += "#extension GL_ARB_shader_viewport_layer_array : enable\n";
|
||||
}
|
||||
std::string source = R"(#version 430 core
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shader_viewport_layer_array : enable
|
||||
#extension GL_EXT_shader_image_load_formatted : enable
|
||||
#extension GL_NV_gpu_shader5 : enable
|
||||
#extension GL_NV_shader_thread_group : enable
|
||||
#extension GL_NV_shader_thread_shuffle : enable
|
||||
)";
|
||||
if (program_type == ProgramType::Compute) {
|
||||
source += "#extension GL_ARB_compute_variable_group_size : require\n";
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "video_core/renderer_opengl/gl_device.h"
|
||||
#include "video_core/renderer_opengl/gl_rasterizer.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_decompiler.h"
|
||||
#include "video_core/shader/node.h"
|
||||
#include "video_core/shader/shader_ir.h"
|
||||
|
||||
namespace OpenGL::GLShader {
|
||||
@@ -241,6 +242,26 @@ 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"};
|
||||
@@ -398,8 +419,6 @@ public:
|
||||
usage.is_read, usage.is_written);
|
||||
}
|
||||
entries.clip_distances = ir.GetClipDistances();
|
||||
entries.shader_viewport_layer_array =
|
||||
IsVertexShader(stage) && (ir.UsesLayer() || ir.UsesViewportIndex());
|
||||
entries.shader_length = ir.GetLength();
|
||||
return entries;
|
||||
}
|
||||
@@ -722,42 +741,6 @@ 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 "image1D";
|
||||
case Tegra::Shader::ImageType::TextureBuffer:
|
||||
return "imageBuffer";
|
||||
case Tegra::Shader::ImageType::Texture1DArray:
|
||||
return "image1DArray";
|
||||
case Tegra::Shader::ImageType::Texture2D:
|
||||
return "image2D";
|
||||
case Tegra::Shader::ImageType::Texture2DArray:
|
||||
return "image2DArray";
|
||||
case Tegra::Shader::ImageType::Texture3D:
|
||||
return "image3D";
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return "image1D";
|
||||
}
|
||||
}();
|
||||
|
||||
const auto [type_prefix, format] = [&]() -> std::pair<const char*, const char*> {
|
||||
if (!image.IsSizeKnown()) {
|
||||
return {"", ""};
|
||||
}
|
||||
switch (image.GetSize()) {
|
||||
case Tegra::Shader::ImageAtomicSize::U32:
|
||||
return {"u", "r32ui, "};
|
||||
case Tegra::Shader::ImageAtomicSize::S32:
|
||||
return {"i", "r32i, "};
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unimplemented atomic size={}",
|
||||
static_cast<u32>(image.GetSize()));
|
||||
return {"", ""};
|
||||
}
|
||||
}();
|
||||
|
||||
std::string qualifier = "coherent volatile";
|
||||
if (image.IsRead() && !image.IsWritten()) {
|
||||
qualifier += " readonly";
|
||||
@@ -765,9 +748,10 @@ private:
|
||||
qualifier += " writeonly";
|
||||
}
|
||||
|
||||
code.AddLine("layout (binding = IMAGE_BINDING_{}) {} uniform "
|
||||
"{} {};",
|
||||
image.GetIndex(), qualifier, image_type, GetImage(image));
|
||||
const char* format = image.IsAtomic() ? "r32ui, " : "";
|
||||
const char* type_declaration = GetImageTypeDeclaration(image.GetType());
|
||||
code.AddLine("layout ({}binding = IMAGE_BINDING_{}) {} uniform uimage{} {};", format,
|
||||
image.GetIndex(), qualifier, type_declaration, GetImage(image));
|
||||
}
|
||||
if (!images.empty()) {
|
||||
code.AddNewLine();
|
||||
@@ -1234,28 +1218,13 @@ private:
|
||||
}
|
||||
|
||||
std::string BuildImageValues(Operation operation) {
|
||||
constexpr std::array constructors{"uint", "uvec2", "uvec3", "uvec4"};
|
||||
const auto meta{std::get<MetaImage>(operation.GetMeta())};
|
||||
const auto [constructors, type] = [&]() -> std::pair<std::array<const char*, 4>, Type> {
|
||||
constexpr std::array float_constructors{"float", "vec2", "vec3", "vec4"};
|
||||
if (!meta.image.IsSizeKnown()) {
|
||||
return {float_constructors, Type::Float};
|
||||
}
|
||||
switch (meta.image.GetSize()) {
|
||||
case Tegra::Shader::ImageAtomicSize::U32:
|
||||
return {{"uint", "uvec2", "uvec3", "uvec4"}, Type::Uint};
|
||||
case Tegra::Shader::ImageAtomicSize::S32:
|
||||
return {{"int", "ivec2", "ivec3", "ivec4"}, Type::Uint};
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unimplemented image size={}",
|
||||
static_cast<u32>(meta.image.GetSize()));
|
||||
return {float_constructors, Type::Float};
|
||||
}
|
||||
}();
|
||||
|
||||
const std::size_t values_count{meta.values.size()};
|
||||
std::string expr = fmt::format("{}(", constructors.at(values_count - 1));
|
||||
for (std::size_t i = 0; i < values_count; ++i) {
|
||||
expr += Visit(meta.values.at(i)).As(type);
|
||||
expr += Visit(meta.values.at(i)).AsUint();
|
||||
if (i + 1 < values_count) {
|
||||
expr += ", ";
|
||||
}
|
||||
@@ -1264,29 +1233,6 @@ private:
|
||||
return expr;
|
||||
}
|
||||
|
||||
Expression AtomicImage(Operation operation, const char* opname) {
|
||||
constexpr std::array constructors{"int(", "ivec2(", "ivec3(", "ivec4("};
|
||||
const auto meta{std::get<MetaImage>(operation.GetMeta())};
|
||||
ASSERT(meta.values.size() == 1);
|
||||
ASSERT(meta.image.IsSizeKnown());
|
||||
|
||||
const auto type = [&]() {
|
||||
switch (const auto size = meta.image.GetSize()) {
|
||||
case Tegra::Shader::ImageAtomicSize::U32:
|
||||
return Type::Uint;
|
||||
case Tegra::Shader::ImageAtomicSize::S32:
|
||||
return Type::Int;
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unimplemented image size={}", static_cast<u32>(size));
|
||||
return Type::Uint;
|
||||
}
|
||||
}();
|
||||
|
||||
return {fmt::format("{}({}, {}, {})", opname, GetImage(meta.image),
|
||||
BuildIntegerCoordinates(operation), Visit(meta.values[0]).As(type)),
|
||||
type};
|
||||
}
|
||||
|
||||
Expression Assign(Operation operation) {
|
||||
const Node& dest = operation[0];
|
||||
const Node& src = operation[1];
|
||||
@@ -1545,6 +1491,8 @@ 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) {
|
||||
@@ -1809,6 +1757,19 @@ private:
|
||||
return {tmp, Type::Float};
|
||||
}
|
||||
|
||||
Expression ImageLoad(Operation operation) {
|
||||
if (!device.HasImageLoadFormatted()) {
|
||||
LOG_ERROR(Render_OpenGL,
|
||||
"Device lacks GL_EXT_shader_image_load_formatted, stubbing image load");
|
||||
return {"0", Type::Int};
|
||||
}
|
||||
|
||||
const auto meta{std::get<MetaImage>(operation.GetMeta())};
|
||||
return {fmt::format("imageLoad({}, {}){}", GetImage(meta.image),
|
||||
BuildIntegerCoordinates(operation), GetSwizzle(meta.element)),
|
||||
Type::Uint};
|
||||
}
|
||||
|
||||
Expression ImageStore(Operation operation) {
|
||||
const auto meta{std::get<MetaImage>(operation.GetMeta())};
|
||||
code.AddLine("imageStore({}, {}, {});", GetImage(meta.image),
|
||||
@@ -1816,31 +1777,14 @@ private:
|
||||
return {};
|
||||
}
|
||||
|
||||
Expression AtomicImageAdd(Operation operation) {
|
||||
return AtomicImage(operation, "imageAtomicAdd");
|
||||
}
|
||||
template <const std::string_view& opname>
|
||||
Expression AtomicImage(Operation operation) {
|
||||
const auto meta{std::get<MetaImage>(operation.GetMeta())};
|
||||
ASSERT(meta.values.size() == 1);
|
||||
|
||||
Expression AtomicImageMin(Operation operation) {
|
||||
return AtomicImage(operation, "imageAtomicMin");
|
||||
}
|
||||
|
||||
Expression AtomicImageMax(Operation operation) {
|
||||
return AtomicImage(operation, "imageAtomicMax");
|
||||
}
|
||||
Expression AtomicImageAnd(Operation operation) {
|
||||
return AtomicImage(operation, "imageAtomicAnd");
|
||||
}
|
||||
|
||||
Expression AtomicImageOr(Operation operation) {
|
||||
return AtomicImage(operation, "imageAtomicOr");
|
||||
}
|
||||
|
||||
Expression AtomicImageXor(Operation operation) {
|
||||
return AtomicImage(operation, "imageAtomicXor");
|
||||
}
|
||||
|
||||
Expression AtomicImageExchange(Operation operation) {
|
||||
return AtomicImage(operation, "imageAtomicExchange");
|
||||
return {fmt::format("imageAtomic{}({}, {}, {})", opname, GetImage(meta.image),
|
||||
BuildIntegerCoordinates(operation), Visit(meta.values[0]).AsUint()),
|
||||
Type::Uint};
|
||||
}
|
||||
|
||||
Expression Branch(Operation operation) {
|
||||
@@ -2035,6 +1979,12 @@ private:
|
||||
Func() = delete;
|
||||
~Func() = delete;
|
||||
|
||||
static constexpr std::string_view Add = "Add";
|
||||
static constexpr std::string_view And = "And";
|
||||
static constexpr std::string_view Or = "Or";
|
||||
static constexpr std::string_view Xor = "Xor";
|
||||
static constexpr std::string_view Exchange = "Exchange";
|
||||
|
||||
static constexpr std::string_view ShuffleIndexed = "shuffleNV";
|
||||
static constexpr std::string_view ShuffleUp = "shuffleUpNV";
|
||||
static constexpr std::string_view ShuffleDown = "shuffleDownNV";
|
||||
@@ -2172,14 +2122,14 @@ private:
|
||||
&GLSLDecompiler::TextureQueryLod,
|
||||
&GLSLDecompiler::TexelFetch,
|
||||
|
||||
&GLSLDecompiler::ImageLoad,
|
||||
&GLSLDecompiler::ImageStore,
|
||||
&GLSLDecompiler::AtomicImageAdd,
|
||||
&GLSLDecompiler::AtomicImageMin,
|
||||
&GLSLDecompiler::AtomicImageMax,
|
||||
&GLSLDecompiler::AtomicImageAnd,
|
||||
&GLSLDecompiler::AtomicImageOr,
|
||||
&GLSLDecompiler::AtomicImageXor,
|
||||
&GLSLDecompiler::AtomicImageExchange,
|
||||
|
||||
&GLSLDecompiler::AtomicImage<Func::Add>,
|
||||
&GLSLDecompiler::AtomicImage<Func::And>,
|
||||
&GLSLDecompiler::AtomicImage<Func::Or>,
|
||||
&GLSLDecompiler::AtomicImage<Func::Xor>,
|
||||
&GLSLDecompiler::AtomicImage<Func::Exchange>,
|
||||
|
||||
&GLSLDecompiler::Branch,
|
||||
&GLSLDecompiler::BranchIndirect,
|
||||
|
||||
@@ -90,7 +90,6 @@ struct ShaderEntries {
|
||||
std::vector<ImageEntry> images;
|
||||
std::vector<GlobalMemoryEntry> global_memory_entries;
|
||||
std::array<bool, Maxwell::NumClipDistances> clip_distances{};
|
||||
bool shader_viewport_layer_array{};
|
||||
std::size_t shader_length{};
|
||||
};
|
||||
|
||||
|
||||
@@ -343,20 +343,17 @@ std::optional<ShaderDiskCacheDecompiled> ShaderDiskCacheOpenGL::LoadDecompiledEn
|
||||
u8 is_bindless{};
|
||||
u8 is_written{};
|
||||
u8 is_read{};
|
||||
u8 is_size_known{};
|
||||
u32 size{};
|
||||
u8 is_atomic{};
|
||||
if (!LoadObjectFromPrecompiled(offset) || !LoadObjectFromPrecompiled(index) ||
|
||||
!LoadObjectFromPrecompiled(type) || !LoadObjectFromPrecompiled(is_bindless) ||
|
||||
!LoadObjectFromPrecompiled(is_written) || !LoadObjectFromPrecompiled(is_read) ||
|
||||
!LoadObjectFromPrecompiled(is_size_known) || !LoadObjectFromPrecompiled(size)) {
|
||||
!LoadObjectFromPrecompiled(is_atomic)) {
|
||||
return {};
|
||||
}
|
||||
entry.entries.images.emplace_back(
|
||||
static_cast<std::size_t>(offset), static_cast<std::size_t>(index),
|
||||
static_cast<Tegra::Shader::ImageType>(type), is_bindless != 0, is_written != 0,
|
||||
is_read != 0,
|
||||
is_size_known ? std::make_optional(static_cast<Tegra::Shader::ImageAtomicSize>(size))
|
||||
: std::nullopt);
|
||||
is_read != 0, is_atomic != 0);
|
||||
}
|
||||
|
||||
u32 global_memory_count{};
|
||||
@@ -382,12 +379,6 @@ std::optional<ShaderDiskCacheDecompiled> ShaderDiskCacheOpenGL::LoadDecompiledEn
|
||||
}
|
||||
}
|
||||
|
||||
bool shader_viewport_layer_array{};
|
||||
if (!LoadObjectFromPrecompiled(shader_viewport_layer_array)) {
|
||||
return {};
|
||||
}
|
||||
entry.entries.shader_viewport_layer_array = shader_viewport_layer_array;
|
||||
|
||||
u64 shader_length{};
|
||||
if (!LoadObjectFromPrecompiled(shader_length)) {
|
||||
return {};
|
||||
@@ -435,14 +426,13 @@ bool ShaderDiskCacheOpenGL::SaveDecompiledFile(u64 unique_identifier, const std:
|
||||
return false;
|
||||
}
|
||||
for (const auto& image : entries.images) {
|
||||
const u32 size = image.IsSizeKnown() ? static_cast<u32>(image.GetSize()) : 0U;
|
||||
if (!SaveObjectToPrecompiled(static_cast<u64>(image.GetOffset())) ||
|
||||
!SaveObjectToPrecompiled(static_cast<u64>(image.GetIndex())) ||
|
||||
!SaveObjectToPrecompiled(static_cast<u32>(image.GetType())) ||
|
||||
!SaveObjectToPrecompiled(static_cast<u8>(image.IsBindless() ? 1 : 0)) ||
|
||||
!SaveObjectToPrecompiled(static_cast<u8>(image.IsWritten() ? 1 : 0)) ||
|
||||
!SaveObjectToPrecompiled(static_cast<u8>(image.IsRead() ? 1 : 0)) ||
|
||||
!SaveObjectToPrecompiled(image.IsSizeKnown()) || !SaveObjectToPrecompiled(size)) {
|
||||
!SaveObjectToPrecompiled(static_cast<u8>(image.IsAtomic() ? 1 : 0))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -464,10 +454,6 @@ bool ShaderDiskCacheOpenGL::SaveDecompiledFile(u64 unique_identifier, const std:
|
||||
}
|
||||
}
|
||||
|
||||
if (!SaveObjectToPrecompiled(entries.shader_viewport_layer_array)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SaveObjectToPrecompiled(static_cast<u64>(entries.shader_length))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "video_core/engines/shader_header.h"
|
||||
#include "video_core/renderer_vulkan/vk_device.h"
|
||||
#include "video_core/renderer_vulkan/vk_shader_decompiler.h"
|
||||
#include "video_core/shader/node.h"
|
||||
#include "video_core/shader/shader_ir.h"
|
||||
|
||||
namespace Vulkan::VKShader {
|
||||
@@ -939,6 +940,11 @@ private:
|
||||
return {};
|
||||
}
|
||||
|
||||
Id ImageLoad(Operation operation) {
|
||||
UNIMPLEMENTED();
|
||||
return {};
|
||||
}
|
||||
|
||||
Id ImageStore(Operation operation) {
|
||||
UNIMPLEMENTED();
|
||||
return {};
|
||||
@@ -949,16 +955,6 @@ private:
|
||||
return {};
|
||||
}
|
||||
|
||||
Id AtomicImageMin(Operation operation) {
|
||||
UNIMPLEMENTED();
|
||||
return {};
|
||||
}
|
||||
|
||||
Id AtomicImageMax(Operation operation) {
|
||||
UNIMPLEMENTED();
|
||||
return {};
|
||||
}
|
||||
|
||||
Id AtomicImageAnd(Operation operation) {
|
||||
UNIMPLEMENTED();
|
||||
return {};
|
||||
@@ -1440,10 +1436,9 @@ private:
|
||||
&SPIRVDecompiler::TextureQueryLod,
|
||||
&SPIRVDecompiler::TexelFetch,
|
||||
|
||||
&SPIRVDecompiler::ImageLoad,
|
||||
&SPIRVDecompiler::ImageStore,
|
||||
&SPIRVDecompiler::AtomicImageAdd,
|
||||
&SPIRVDecompiler::AtomicImageMin,
|
||||
&SPIRVDecompiler::AtomicImageMax,
|
||||
&SPIRVDecompiler::AtomicImageAnd,
|
||||
&SPIRVDecompiler::AtomicImageOr,
|
||||
&SPIRVDecompiler::AtomicImageXor,
|
||||
|
||||
@@ -41,11 +41,46 @@ u32 ShaderIR::DecodeImage(NodeBlock& bb, u32 pc) {
|
||||
const Instruction instr = {program_code[pc]};
|
||||
const auto opcode = OpCode::Decode(instr);
|
||||
|
||||
const auto GetCoordinates = [this, instr](Tegra::Shader::ImageType image_type) {
|
||||
std::vector<Node> coords;
|
||||
const std::size_t num_coords{GetImageTypeNumCoordinates(image_type)};
|
||||
coords.reserve(num_coords);
|
||||
for (std::size_t i = 0; i < num_coords; ++i) {
|
||||
coords.push_back(GetRegister(instr.gpr8.Value() + i));
|
||||
}
|
||||
return coords;
|
||||
};
|
||||
|
||||
switch (opcode->get().GetId()) {
|
||||
case OpCode::Id::SULD: {
|
||||
UNIMPLEMENTED_IF(instr.suldst.mode != Tegra::Shader::SurfaceDataMode::P);
|
||||
UNIMPLEMENTED_IF(instr.suldst.out_of_bounds_store !=
|
||||
Tegra::Shader::OutOfBoundsStore::Ignore);
|
||||
|
||||
const auto type{instr.suldst.image_type};
|
||||
auto& image{instr.suldst.is_immediate ? GetImage(instr.image, type)
|
||||
: GetBindlessImage(instr.gpr39, type)};
|
||||
image.MarkRead();
|
||||
|
||||
u32 indexer = 0;
|
||||
for (u32 element = 0; element < 4; ++element) {
|
||||
if (!instr.suldst.IsComponentEnabled(element)) {
|
||||
continue;
|
||||
}
|
||||
MetaImage meta{image, {}, element};
|
||||
Node value = Operation(OperationCode::ImageLoad, meta, GetCoordinates(type));
|
||||
SetTemporary(bb, indexer++, std::move(value));
|
||||
}
|
||||
for (u32 i = 0; i < indexer; ++i) {
|
||||
SetRegister(bb, instr.gpr0.Value() + i, GetTemporary(i));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OpCode::Id::SUST: {
|
||||
UNIMPLEMENTED_IF(instr.sust.mode != Tegra::Shader::SurfaceDataMode::P);
|
||||
UNIMPLEMENTED_IF(instr.sust.out_of_bounds_store != Tegra::Shader::OutOfBoundsStore::Ignore);
|
||||
UNIMPLEMENTED_IF(instr.sust.component_mask_selector != 0xf); // Ensure we have an RGBA store
|
||||
UNIMPLEMENTED_IF(instr.suldst.mode != Tegra::Shader::SurfaceDataMode::P);
|
||||
UNIMPLEMENTED_IF(instr.suldst.out_of_bounds_store !=
|
||||
Tegra::Shader::OutOfBoundsStore::Ignore);
|
||||
UNIMPLEMENTED_IF(instr.suldst.component_mask_selector != 0xf); // Ensure we have RGBA
|
||||
|
||||
std::vector<Node> values;
|
||||
constexpr std::size_t hardcoded_size{4};
|
||||
@@ -53,58 +88,51 @@ u32 ShaderIR::DecodeImage(NodeBlock& bb, u32 pc) {
|
||||
values.push_back(GetRegister(instr.gpr0.Value() + i));
|
||||
}
|
||||
|
||||
std::vector<Node> coords;
|
||||
const std::size_t num_coords{GetImageTypeNumCoordinates(instr.sust.image_type)};
|
||||
for (std::size_t i = 0; i < num_coords; ++i) {
|
||||
coords.push_back(GetRegister(instr.gpr8.Value() + i));
|
||||
}
|
||||
|
||||
const auto type{instr.sust.image_type};
|
||||
auto& image{instr.sust.is_immediate ? GetImage(instr.image, type)
|
||||
: GetBindlessImage(instr.gpr39, type)};
|
||||
const auto type{instr.suldst.image_type};
|
||||
auto& image{instr.suldst.is_immediate ? GetImage(instr.image, type)
|
||||
: GetBindlessImage(instr.gpr39, type)};
|
||||
image.MarkWrite();
|
||||
|
||||
MetaImage meta{image, values};
|
||||
bb.push_back(Operation(OperationCode::ImageStore, meta, std::move(coords)));
|
||||
MetaImage meta{image, std::move(values)};
|
||||
bb.push_back(Operation(OperationCode::ImageStore, meta, GetCoordinates(type)));
|
||||
break;
|
||||
}
|
||||
case OpCode::Id::SUATOM: {
|
||||
UNIMPLEMENTED_IF(instr.suatom_d.is_ba != 0);
|
||||
|
||||
Node value = GetRegister(instr.gpr0);
|
||||
|
||||
std::vector<Node> coords;
|
||||
const std::size_t num_coords{GetImageTypeNumCoordinates(instr.sust.image_type)};
|
||||
for (std::size_t i = 0; i < num_coords; ++i) {
|
||||
coords.push_back(GetRegister(instr.gpr8.Value() + i));
|
||||
}
|
||||
|
||||
const OperationCode operation_code = [instr] {
|
||||
switch (instr.suatom_d.operation) {
|
||||
case Tegra::Shader::ImageAtomicOperation::Add:
|
||||
return OperationCode::AtomicImageAdd;
|
||||
case Tegra::Shader::ImageAtomicOperation::Min:
|
||||
return OperationCode::AtomicImageMin;
|
||||
case Tegra::Shader::ImageAtomicOperation::Max:
|
||||
return OperationCode::AtomicImageMax;
|
||||
case Tegra::Shader::ImageAtomicOperation::And:
|
||||
return OperationCode::AtomicImageAnd;
|
||||
case Tegra::Shader::ImageAtomicOperation::Or:
|
||||
return OperationCode::AtomicImageOr;
|
||||
case Tegra::Shader::ImageAtomicOperation::Xor:
|
||||
return OperationCode::AtomicImageXor;
|
||||
case Tegra::Shader::ImageAtomicOperation::Exch:
|
||||
return OperationCode::AtomicImageExchange;
|
||||
switch (instr.suatom_d.operation_type) {
|
||||
case Tegra::Shader::ImageAtomicOperationType::S32:
|
||||
case Tegra::Shader::ImageAtomicOperationType::U32:
|
||||
switch (instr.suatom_d.operation) {
|
||||
case Tegra::Shader::ImageAtomicOperation::Add:
|
||||
return OperationCode::AtomicImageAdd;
|
||||
case Tegra::Shader::ImageAtomicOperation::And:
|
||||
return OperationCode::AtomicImageAnd;
|
||||
case Tegra::Shader::ImageAtomicOperation::Or:
|
||||
return OperationCode::AtomicImageOr;
|
||||
case Tegra::Shader::ImageAtomicOperation::Xor:
|
||||
return OperationCode::AtomicImageXor;
|
||||
case Tegra::Shader::ImageAtomicOperation::Exch:
|
||||
return OperationCode::AtomicImageExchange;
|
||||
}
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unimplemented operation={}",
|
||||
static_cast<u32>(instr.suatom_d.operation.Value()));
|
||||
return OperationCode::AtomicImageAdd;
|
||||
break;
|
||||
}
|
||||
UNIMPLEMENTED_MSG("Unimplemented operation={} type={}",
|
||||
static_cast<u64>(instr.suatom_d.operation.Value()),
|
||||
static_cast<u64>(instr.suatom_d.operation_type.Value()));
|
||||
return OperationCode::AtomicImageAdd;
|
||||
}();
|
||||
|
||||
const auto& image{GetImage(instr.image, instr.suatom_d.image_type, instr.suatom_d.size)};
|
||||
Node value = GetRegister(instr.gpr0);
|
||||
|
||||
const auto type = instr.suatom_d.image_type;
|
||||
auto& image = GetImage(instr.image, type);
|
||||
image.MarkAtomic();
|
||||
|
||||
MetaImage meta{image, {std::move(value)}};
|
||||
SetRegister(bb, instr.gpr0, Operation(operation_code, meta, std::move(coords)));
|
||||
SetRegister(bb, instr.gpr0, Operation(operation_code, meta, GetCoordinates(type)));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -114,35 +142,32 @@ u32 ShaderIR::DecodeImage(NodeBlock& bb, u32 pc) {
|
||||
return pc;
|
||||
}
|
||||
|
||||
Image& ShaderIR::GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type,
|
||||
std::optional<Tegra::Shader::ImageAtomicSize> size) {
|
||||
Image& ShaderIR::GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type) {
|
||||
const auto offset{static_cast<std::size_t>(image.index.Value())};
|
||||
if (const auto image = TryUseExistingImage(offset, type, size)) {
|
||||
if (const auto image = TryUseExistingImage(offset, type)) {
|
||||
return *image;
|
||||
}
|
||||
|
||||
const std::size_t next_index{used_images.size()};
|
||||
return used_images.emplace(offset, Image{offset, next_index, type, size}).first->second;
|
||||
return used_images.emplace(offset, Image{offset, next_index, type}).first->second;
|
||||
}
|
||||
|
||||
Image& ShaderIR::GetBindlessImage(Tegra::Shader::Register reg, Tegra::Shader::ImageType type,
|
||||
std::optional<Tegra::Shader::ImageAtomicSize> size) {
|
||||
Image& ShaderIR::GetBindlessImage(Tegra::Shader::Register reg, Tegra::Shader::ImageType type) {
|
||||
const Node image_register{GetRegister(reg)};
|
||||
const auto [base_image, cbuf_index, cbuf_offset]{
|
||||
TrackCbuf(image_register, global_code, static_cast<s64>(global_code.size()))};
|
||||
const auto cbuf_key{(static_cast<u64>(cbuf_index) << 32) | static_cast<u64>(cbuf_offset)};
|
||||
|
||||
if (const auto image = TryUseExistingImage(cbuf_key, type, size)) {
|
||||
if (const auto image = TryUseExistingImage(cbuf_key, type)) {
|
||||
return *image;
|
||||
}
|
||||
|
||||
const std::size_t next_index{used_images.size()};
|
||||
return used_images.emplace(cbuf_key, Image{cbuf_index, cbuf_offset, next_index, type, size})
|
||||
return used_images.emplace(cbuf_key, Image{cbuf_index, cbuf_offset, next_index, type})
|
||||
.first->second;
|
||||
}
|
||||
|
||||
Image* ShaderIR::TryUseExistingImage(u64 offset, Tegra::Shader::ImageType type,
|
||||
std::optional<Tegra::Shader::ImageAtomicSize> size) {
|
||||
Image* ShaderIR::TryUseExistingImage(u64 offset, Tegra::Shader::ImageType type) {
|
||||
auto it = used_images.find(offset);
|
||||
if (it == used_images.end()) {
|
||||
return nullptr;
|
||||
@@ -150,14 +175,6 @@ Image* ShaderIR::TryUseExistingImage(u64 offset, Tegra::Shader::ImageType type,
|
||||
auto& image = it->second;
|
||||
ASSERT(image.GetType() == type);
|
||||
|
||||
if (size) {
|
||||
// We know the size, if it's known it has to be the same as before, otherwise we can set it.
|
||||
if (image.IsSizeKnown()) {
|
||||
ASSERT(image.GetSize() == size);
|
||||
} else {
|
||||
image.SetSize(*size);
|
||||
}
|
||||
}
|
||||
return ℑ
|
||||
}
|
||||
|
||||
|
||||
@@ -149,10 +149,10 @@ enum class OperationCode {
|
||||
TextureQueryLod, /// (MetaTexture, float[N] coords) -> float4
|
||||
TexelFetch, /// (MetaTexture, int[N], int) -> float4
|
||||
|
||||
ImageStore, /// (MetaImage, int[N] values) -> void
|
||||
ImageLoad, /// (MetaImage, int[N] coords) -> void
|
||||
ImageStore, /// (MetaImage, int[N] coords) -> void
|
||||
|
||||
AtomicImageAdd, /// (MetaImage, int[N] coords) -> void
|
||||
AtomicImageMin, /// (MetaImage, int[N] coords) -> void
|
||||
AtomicImageMax, /// (MetaImage, int[N] coords) -> void
|
||||
AtomicImageAnd, /// (MetaImage, int[N] coords) -> void
|
||||
AtomicImageOr, /// (MetaImage, int[N] coords) -> void
|
||||
AtomicImageXor, /// (MetaImage, int[N] coords) -> void
|
||||
@@ -294,21 +294,18 @@ private:
|
||||
|
||||
class Image final {
|
||||
public:
|
||||
constexpr explicit Image(std::size_t offset, std::size_t index, Tegra::Shader::ImageType type,
|
||||
std::optional<Tegra::Shader::ImageAtomicSize> size)
|
||||
: offset{offset}, index{index}, type{type}, is_bindless{false}, size{size} {}
|
||||
constexpr explicit Image(std::size_t offset, std::size_t index, Tegra::Shader::ImageType type)
|
||||
: offset{offset}, index{index}, type{type}, is_bindless{false} {}
|
||||
|
||||
constexpr explicit Image(u32 cbuf_index, u32 cbuf_offset, std::size_t index,
|
||||
Tegra::Shader::ImageType type,
|
||||
std::optional<Tegra::Shader::ImageAtomicSize> size)
|
||||
Tegra::Shader::ImageType type)
|
||||
: offset{(static_cast<u64>(cbuf_index) << 32) | cbuf_offset}, index{index}, type{type},
|
||||
is_bindless{true}, size{size} {}
|
||||
is_bindless{true} {}
|
||||
|
||||
constexpr explicit Image(std::size_t offset, std::size_t index, Tegra::Shader::ImageType type,
|
||||
bool is_bindless, bool is_written, bool is_read,
|
||||
std::optional<Tegra::Shader::ImageAtomicSize> size)
|
||||
bool is_bindless, bool is_written, bool is_read, bool is_atomic)
|
||||
: offset{offset}, index{index}, type{type}, is_bindless{is_bindless},
|
||||
is_written{is_written}, is_read{is_read}, size{size} {}
|
||||
is_written{is_written}, is_read{is_read}, is_atomic{is_atomic} {}
|
||||
|
||||
void MarkWrite() {
|
||||
is_written = true;
|
||||
@@ -318,8 +315,10 @@ public:
|
||||
is_read = true;
|
||||
}
|
||||
|
||||
void SetSize(Tegra::Shader::ImageAtomicSize size_) {
|
||||
size = size_;
|
||||
void MarkAtomic() {
|
||||
MarkWrite();
|
||||
MarkRead();
|
||||
is_atomic = true;
|
||||
}
|
||||
|
||||
constexpr std::size_t GetOffset() const {
|
||||
@@ -346,21 +345,17 @@ public:
|
||||
return is_read;
|
||||
}
|
||||
|
||||
constexpr bool IsAtomic() const {
|
||||
return is_atomic;
|
||||
}
|
||||
|
||||
constexpr std::pair<u32, u32> GetBindlessCBuf() const {
|
||||
return {static_cast<u32>(offset >> 32), static_cast<u32>(offset)};
|
||||
}
|
||||
|
||||
constexpr bool IsSizeKnown() const {
|
||||
return size.has_value();
|
||||
}
|
||||
|
||||
constexpr Tegra::Shader::ImageAtomicSize GetSize() const {
|
||||
return size.value();
|
||||
}
|
||||
|
||||
constexpr bool operator<(const Image& rhs) const {
|
||||
return std::tie(offset, index, type, size, is_bindless) <
|
||||
std::tie(rhs.offset, rhs.index, rhs.type, rhs.size, rhs.is_bindless);
|
||||
return std::tie(offset, index, type, is_bindless) <
|
||||
std::tie(rhs.offset, rhs.index, rhs.type, rhs.is_bindless);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -370,7 +365,7 @@ private:
|
||||
bool is_bindless{};
|
||||
bool is_written{};
|
||||
bool is_read{};
|
||||
std::optional<Tegra::Shader::ImageAtomicSize> size{};
|
||||
bool is_atomic{};
|
||||
};
|
||||
|
||||
struct GlobalMemoryBase {
|
||||
@@ -402,6 +397,7 @@ struct MetaTexture {
|
||||
struct MetaImage {
|
||||
const Image& image;
|
||||
std::vector<Node> values;
|
||||
u32 element{};
|
||||
};
|
||||
|
||||
/// Parameters that modify an operation but are not part of any particular operand
|
||||
|
||||
@@ -284,16 +284,13 @@ private:
|
||||
bool is_shadow);
|
||||
|
||||
/// Accesses an image.
|
||||
Image& GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type,
|
||||
std::optional<Tegra::Shader::ImageAtomicSize> size = {});
|
||||
Image& GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type);
|
||||
|
||||
/// Access a bindless image sampler.
|
||||
Image& GetBindlessImage(Tegra::Shader::Register reg, Tegra::Shader::ImageType type,
|
||||
std::optional<Tegra::Shader::ImageAtomicSize> size = {});
|
||||
Image& GetBindlessImage(Tegra::Shader::Register reg, Tegra::Shader::ImageType type);
|
||||
|
||||
/// Tries to access an existing image, updating it's state as needed
|
||||
Image* TryUseExistingImage(u64 offset, Tegra::Shader::ImageType type,
|
||||
std::optional<Tegra::Shader::ImageAtomicSize> size);
|
||||
Image* TryUseExistingImage(u64 offset, Tegra::Shader::ImageType type);
|
||||
|
||||
/// Extracts a sequence of bits from a node
|
||||
Node BitfieldExtract(Node value, u32 offset, u32 bits);
|
||||
|
||||
Reference in New Issue
Block a user