Merge main into feat/shader-nested-sampler-tables

This commit is contained in:
Yunus Shaikh committed 2026-11-06 20:01:29 -08:00
commit 0ce8d173a3
1662 files changed
+129513 -19472

No files matched your search

+1
View File
@@ -10,6 +10,7 @@ permissions: {}
jobs:
label:
runs-on: ubuntu-latest
timeout-minutes: 120
permissions:
contents: read
pull-requests: write
+32 -9
View File
@@ -143,17 +143,17 @@ jobs:
edgeWatch: edits('edge-watch') || touches('core/libs/tests/edge_watch/', 'core/libs/tests/EdgeWatch.cpp',
'core/libs/prx/libkernel/Equeue/src/EdgeWatch.cpp', 'core/libs/prx/libkernel/Equeue/include/EdgeWatch.hpp', libc),
mingwHostTests: edits('eligibility') || edits('windows') || touches(
'core/CMakeLists.txt', 'core/libs/', 'cmake/', '3rdparty/', '.gitmodules', 'tools/build_mingw_host_only_tests.py',
'core/libs/', 'cmake/', '3rdparty/', '.gitmodules', 'tools/build_mingw_host_only_tests.py',
'tools/build_changed_guest_tests.py', 'tools/configure_seed.py', 'tools/select_tests.py',
'tools/tests/test_build_changed_guest_tests.py', 'tools/tests/test_mingw_host_only_test_targets.py', 'CMakeLists.txt'
),
};
};
const relinkerHosts = (full, linux) => JSON.stringify([
const relinkerHosts = (full, linux, intelMac = true) => JSON.stringify([
...(full && linux ? [] : [{ os: 'ubuntu-latest', compiler: 'g++' }]),
...(full ? [] : [{ os: 'windows-latest', compiler: 'g++' }]),
{ os: 'macos-latest', compiler: 'clang++' },
{ os: 'macos-latest', compiler: 'clang++', architectures: 'x86_64' },
...(intelMac ? [{ os: 'macos-latest', compiler: 'clang++', architectures: 'x86_64' }] : []),
]);
if (context.eventName === 'push') {
if (context.ref !== 'refs/heads/main') {
@@ -275,7 +275,7 @@ jobs:
core.setOutput('edge-watch', run.edgeWatch);
core.setOutput('mingw-host-tests', !manual && run.mingwHostTests);
core.setOutput('full', full);
core.setOutput('relinker-hosts', relinkerHosts(full, linux));
core.setOutput('relinker-hosts', relinkerHosts(full, linux, manual));
const merged = pulls.map((pull) => `PR #${pull.number} at ${pull.head} merged into main at ${main.commit.sha}`);
merged.forEach((line) => core.info(line));
await core.summary.addRaw(
@@ -296,6 +296,7 @@ jobs:
env:
WINLIBS_RELEASE: 15.2.0posix-14.0.0-ucrt-r7
WINLIBS_ZIP: winlibs-x86_64-posix-seh-gcc-15.2.0-mingw-w64ucrt-14.0.0-r7.zip
WINLIBS_SHA256: cb2fbad6162540cdf5e1facdce08d4dac359e8cf64f7f696a99274291763b815
defaults:
run:
shell: bash
@@ -329,6 +330,7 @@ jobs:
- if: runner.os == 'Windows' && steps.toolchain.outputs.cache-hit != 'true'
run: |
curl -sSfL -o "$RUNNER_TEMP/winlibs.zip" "https://github.com/brechtsanders/winlibs_mingw/releases/download/$WINLIBS_RELEASE/$WINLIBS_ZIP"
echo "$WINLIBS_SHA256 $RUNNER_TEMP/winlibs.zip" | sha256sum -c -
7z x "$RUNNER_TEMP/winlibs.zip" -oC:/winlibs > /dev/null
- if: runner.os == 'Windows'
run: echo 'C:\winlibs\mingw64\bin' >> "$GITHUB_PATH"
@@ -375,8 +377,19 @@ jobs:
matrix:
os: [ubuntu-latest, macos-15-intel]
configuration: [Debug, Release]
architectures: ['']
include:
- os: macos-15
configuration: Debug
architectures: x86_64
- os: macos-15
configuration: Release
architectures: x86_64
exclude:
- os: macos-15-intel
configuration: ${{ github.event_name == 'pull_request' && 'Debug' || 'none' }}
runs-on: ${{ matrix.os }}
timeout-minutes: 5
timeout-minutes: ${{ matrix.architectures == 'x86_64' && 15 || 5 }}
steps:
- uses: actions/checkout@v7
with:
@@ -398,7 +411,9 @@ jobs:
if [ "$(git rev-parse "refs/remotes/pull/${numbers[i]}")" != "${heads[i]}" ]; then echo "::error::Pull request #${numbers[i]} has newer commits; start a new build"; exit 1; fi
if ! git -c user.name=ci -c user.email=ci@localhost merge --no-ff --no-edit "refs/remotes/pull/${numbers[i]}"; then echo "::error::Pull request #${numbers[i]} does not merge cleanly into main and the pull requests before it; rebase it first"; exit 1; fi
done
- run: cmake -S core/libs/tests/register_context -B build/register-context -DCMAKE_BUILD_TYPE=${{ matrix.configuration }}
- if: ${{ matrix.architectures == 'x86_64' }}
run: sudo softwareupdate --install-rosetta --agree-to-license
- run: cmake -S core/libs/tests/register_context -B build/register-context -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_OSX_ARCHITECTURES=${{ matrix.architectures }}
- run: cmake --build build/register-context --parallel
- run: ctest --test-dir build/register-context --output-on-failure --repeat until-fail:3 --no-tests=error
@@ -408,9 +423,13 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-15-intel, macos-15]
os: ${{ github.event_name == 'pull_request' && fromJSON('["macos-15"]') || fromJSON('["macos-15-intel", "macos-15"]') }}
architectures: ['']
include:
- os: macos-15
architectures: x86_64
runs-on: ${{ matrix.os }}
timeout-minutes: 5
timeout-minutes: ${{ matrix.architectures == 'x86_64' && 15 || 5 }}
steps:
- uses: actions/checkout@v7
with:
@@ -432,7 +451,9 @@ jobs:
if [ "$(git rev-parse "refs/remotes/pull/${numbers[i]}")" != "${heads[i]}" ]; then echo "::error::Pull request #${numbers[i]} has newer commits; start a new build"; exit 1; fi
if ! git -c user.name=ci -c user.email=ci@localhost merge --no-ff --no-edit "refs/remotes/pull/${numbers[i]}"; then echo "::error::Pull request #${numbers[i]} does not merge cleanly into main and the pull requests before it; rebase it first"; exit 1; fi
done
- run: cmake -S core/libs/tests/write_watch -B build/write-watch -DCMAKE_BUILD_TYPE=Release
- if: ${{ matrix.architectures == 'x86_64' }}
run: sudo softwareupdate --install-rosetta --agree-to-license
- run: cmake -S core/libs/tests/write_watch -B build/write-watch -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=${{ matrix.architectures }}
- run: cmake --build build/write-watch --parallel
- run: ctest --test-dir build/write-watch --output-on-failure --repeat until-fail:3 --no-tests=error
@@ -580,6 +601,7 @@ jobs:
env:
WINLIBS_RELEASE: 15.2.0posix-14.0.0-ucrt-r7
WINLIBS_ZIP: winlibs-x86_64-posix-seh-gcc-15.2.0-mingw-w64ucrt-14.0.0-r7.zip
WINLIBS_SHA256: cb2fbad6162540cdf5e1facdce08d4dac359e8cf64f7f696a99274291763b815
defaults:
run:
shell: bash
@@ -641,6 +663,7 @@ jobs:
- if: steps.toolchain.outputs.cache-hit != 'true'
run: |
curl -sSfL -o "$RUNNER_TEMP/winlibs.zip" "https://github.com/brechtsanders/winlibs_mingw/releases/download/$WINLIBS_RELEASE/$WINLIBS_ZIP"
echo "$WINLIBS_SHA256 $RUNNER_TEMP/winlibs.zip" | sha256sum -c -
7z x "$RUNNER_TEMP/winlibs.zip" -oC:/winlibs > /dev/null
- run: echo 'C:\winlibs\mingw64\bin' >> "$GITHUB_PATH"
- uses: hendrikmuhs/ccache-action@v1.2.24
+1
View File
@@ -16,6 +16,7 @@ concurrency:
jobs:
label:
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
pull-requests: write
steps:
+1 -1
View File
@@ -34,7 +34,7 @@ jobs:
shell: bash
run: |
ANYPS5_TEST_NODE="$(command -v node)"
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "$RUNNER_TEMP/emsdk"
git clone --depth 1 --branch 6.0.12 https://github.com/emscripten-core/emsdk.git "$RUNNER_TEMP/emsdk"
"$RUNNER_TEMP/emsdk/emsdk" install 6.0.12
"$RUNNER_TEMP/emsdk/emsdk" activate 6.0.12
source "$RUNNER_TEMP/emsdk/emsdk_env.sh"
+1
View File
@@ -14,6 +14,7 @@ concurrency:
jobs:
label:
runs-on: ubuntu-latest
timeout-minutes: 90
permissions:
issues: read
pull-requests: write
+17 -8
View File
@@ -23,6 +23,16 @@ jobs:
script: |
const { owner, repo } = context.repo;
const pull_number = context.payload.pull_request.number;
const reopened = context.payload.action === 'reopened';
const removeLimitLabel = async () => {
try {
await github.rest.issues.removeLabel({ owner, repo, issue_number: pull_number, name: 'open PR limit' });
} catch (error) {
if (error.status !== 404) {
core.warning(`Could not remove the open PR limit label: ${error.message}`);
}
}
};
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number });
if (pr.state !== 'open' || pr.base.ref !== 'main') {
return;
@@ -38,13 +48,7 @@ jobs:
core.warning(`Could not check the permission of ${context.payload.sender.login}, so the open PR limit applies: ${error.message}`);
}
if (maintainer) {
try {
await github.rest.issues.removeLabel({ owner, repo, issue_number: pull_number, name: 'open PR limit' });
} catch (error) {
if (error.status !== 404) {
core.warning(`Could not remove the open PR limit label: ${error.message}`);
}
}
await removeLimitLabel();
return;
}
}
@@ -57,18 +61,23 @@ jobs:
}
const merged = mergedPRs.total_count;
if (merged >= 20) {
if (reopened) {
await removeLimitLabel();
}
return;
}
const allowedOpen = merged >= 1 ? 20 : 1;
const openPRs = await github.paginate(github.rest.pulls.list, {
owner, repo, state: 'open', base: 'main', per_page: 100
});
const reopened = context.payload.action === 'reopened';
const open = new Set(openPRs
.filter((p) => p.user.login === pr.user.login && (reopened || p.number < pull_number))
.map((p) => p.number));
open.add(pull_number);
if (open.size <= allowedOpen) {
if (reopened) {
await removeLimitLabel();
}
return;
}
const name = 'open PR limit';
+8 -1
View File
@@ -13,6 +13,10 @@ jobs:
comment:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
concurrency:
group: progress-comment-${{ github.event.workflow_run.head_sha }}-${{ github.event.workflow_run.pull_requests[0].number || github.event.workflow_run.id }}
cancel-in-progress: true
timeout-minutes: 15
steps:
- uses: actions/download-artifact@v8
with:
@@ -23,10 +27,13 @@ jobs:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RUN_SHA: ${{ github.event.workflow_run.head_sha }}
RUN_REF: ${{ github.event.workflow_run.head_branch }}
RUN_REPO: ${{ github.event.workflow_run.head_repository.full_name }}
run: |
pr=$(cat pr)
[[ $pr =~ ^[0-9]+$ ]] || exit 1
[ "$(gh pr view "$pr" --json headRefOid --jq .headRefOid)" = "$RUN_SHA" ] || exit 0
identity=$(gh pr view "$pr" --json headRefOid,headRefName,headRepositoryOwner,headRepository --jq '[.headRefOid, .headRefName, .headRepositoryOwner.login + "/" + .headRepository.name] | @tsv') || identity=""
[ "$identity" = "$(printf '%s\t%s\t%s' "$RUN_SHA" "$RUN_REF" "$RUN_REPO")" ] || exit 0
marker='<!-- progress-report -->'
id=$(gh api "repos/$GH_REPO/issues/$pr/comments" --paginate \
--jq ".[] | select(.user.login == \"github-actions[bot]\" and (.body | startswith(\"$marker\"))) | .id" | head -n1)
+4
View File
@@ -13,6 +13,10 @@ on:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
report:
runs-on: ubuntu-latest
+5 -3
View File
@@ -19,6 +19,7 @@ env:
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
WINLIBS_RELEASE: 15.2.0posix-14.0.0-ucrt-r7
WINLIBS_ZIP: winlibs-x86_64-posix-seh-gcc-15.2.0-mingw-w64ucrt-14.0.0-r7.zip
WINLIBS_SHA256: cb2fbad6162540cdf5e1facdce08d4dac359e8cf64f7f696a99274291763b815
jobs:
build:
@@ -61,6 +62,7 @@ jobs:
- if: matrix.platform == 'windows' && steps.toolchain.outputs.cache-hit != 'true'
run: |
curl -sSfL -o "$RUNNER_TEMP/winlibs.zip" "https://github.com/brechtsanders/winlibs_mingw/releases/download/$WINLIBS_RELEASE/$WINLIBS_ZIP"
echo "$WINLIBS_SHA256 $RUNNER_TEMP/winlibs.zip" | sha256sum -c -
7z x "$RUNNER_TEMP/winlibs.zip" -oC:/winlibs
- if: matrix.platform == 'windows'
run: echo 'C:\winlibs\mingw64\bin' >> "$GITHUB_PATH"
@@ -122,9 +124,9 @@ jobs:
- name: Build web converter
shell: bash
run: |
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "$RUNNER_TEMP/emsdk"
"$RUNNER_TEMP/emsdk/emsdk" install 6.0.3
"$RUNNER_TEMP/emsdk/emsdk" activate 6.0.3
git clone --depth 1 --branch 6.0.12 https://github.com/emscripten-core/emsdk.git "$RUNNER_TEMP/emsdk"
"$RUNNER_TEMP/emsdk/emsdk" install 6.0.12
"$RUNNER_TEMP/emsdk/emsdk" activate 6.0.12
source "$RUNNER_TEMP/emsdk/emsdk_env.sh"
emcmake cmake -S . -B build-wasm -DANYPS5_BUILD_WASM=ON -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release
cmake --build build-wasm --target relinker_web --parallel 2
+5
View File
@@ -8,6 +8,9 @@ on:
- docs/run-report-fixtures/**
- tools/requirements-run-report.txt
- tools/tests/test_run_report_schema.py
- tools/tests/test_run_report_docs.py
- docs/user/USAGE.md
- docs/user/run-report.md
permissions:
contents: read
@@ -30,3 +33,5 @@ jobs:
"$RUNNER_TEMP/venv/bin/python" -m pip install --require-virtualenv -r tools/requirements-run-report.txt
- name: Validate the fixtures against the schema
run: '"$RUNNER_TEMP/venv/bin/python" tools/tests/test_run_report_schema.py'
- name: Check the run report docs
run: python3 tools/tests/test_run_report_docs.py
+1
View File
@@ -10,6 +10,7 @@ permissions: {}
jobs:
warn:
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
issues: write
pull-requests: write
+1
View File
@@ -103,6 +103,7 @@ downloads/
!demo/web/i18n/*.json
!/docs/run-report.schema.json
!/docs/run-report-fixtures/*.json
!tools/titles.json
!/assets/*.jpg
!/assets/*.png
+6
View File
@@ -37,6 +37,9 @@
[submodule "3rdparty/freetype"]
path = 3rdparty/freetype
url = https://github.com/freetype/freetype.git
[submodule "3rdparty/harfbuzz"]
path = 3rdparty/harfbuzz
url = https://github.com/harfbuzz/harfbuzz.git
[submodule "3rdparty/stb"]
path = 3rdparty/stb
url = https://github.com/nothings/stb.git
@@ -76,3 +79,6 @@
[submodule "3rdparty/quickjs"]
path = 3rdparty/quickjs
url = https://github.com/quickjs-ng/quickjs.git
[submodule "3rdparty/sqlite"]
path = 3rdparty/sqlite
url = https://github.com/sqlite/sqlite.git
+1 -1
Vendored Submodule
+1
Submodule 3rdparty/harfbuzz added at a1d9bfe628.
Vendored Submodule
+1
Submodule 3rdparty/sqlite added at 57520227c9.
+91 -12
View File
@@ -73,6 +73,9 @@ include(cmake/SystemDeps.cmake)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=>)
endif()
include(CheckCXXSourceCompiles)
function(anyps5_check_cxx_links_standard_library)
@@ -220,6 +223,9 @@ if(BUILD_TESTING)
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_pr_overlap.py)
add_test(NAME pr_labels COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_pr_labels.py)
add_test(NAME progress_history_date_window COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_progress_history.py HistoryDateWindowTests)
set_tests_properties(progress_history_date_window PROPERTIES TIMEOUT 20)
add_test(NAME pr_ready COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_pr_ready.py)
add_test(NAME progress_history COMMAND ${Python3_EXECUTABLE}
@@ -235,6 +241,8 @@ if(BUILD_TESTING)
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_progress_report_inputs.py)
add_test(NAME tools_compdb_inventory COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/tests/test_compile_database_inventory.py)
set_tests_properties(tools_compdb_inventory PROPERTIES TIMEOUT 20)
add_test(NAME compile_slot COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/tests/test_compile_slot.py)
set_tests_properties(compile_slot PROPERTIES TIMEOUT 60)
add_test(NAME progress_encoding COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_progress_encoding.py)
add_test(NAME progress_render_sliver COMMAND ${Python3_EXECUTABLE}
@@ -243,16 +251,43 @@ if(BUILD_TESTING)
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_progress_wrappers.py)
add_test(NAME progress_read_encoding COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_progress_read_encoding.py)
add_test(NAME tools_audit_strict_partial COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_audit_strict_partial.py)
set_tests_properties(tools_audit_strict_partial PROPERTIES TIMEOUT 20)
add_test(NAME import_audit COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_import_audit.py)
add_test(NAME guest_pointer_audit COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_guest_pointer_audit.py)
if(Python3_VERSION VERSION_GREATER_EQUAL 3.11)
add_test(NAME tools_catalog_json COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_catalog_json.py)
set_tests_properties(tools_catalog_json PROPERTIES TIMEOUT 20)
add_test(NAME validate_patch_catalog COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_validate_patch_catalog.py)
endif()
if(NOT APPLE)
add_test(NAME annotate_module COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_annotate_module.py)
set_tests_properties(annotate_module PROPERTIES TIMEOUT 20)
set(annotate_module_test_source "${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_annotate_module.py")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${annotate_module_test_source}")
file(STRINGS "${annotate_module_test_source}" annotate_module_cases REGEX "^class |^ def test_")
set(annotate_module_first TRUE)
foreach(test_case IN LISTS annotate_module_cases)
if(test_case MATCHES "^class ([A-Za-z0-9_]+)")
set(annotate_module_class "${CMAKE_MATCH_1}")
else()
string(REGEX REPLACE "^ def (test_[A-Za-z0-9_]+).*" "\\1" test_case "${test_case}")
if(annotate_module_first)
set_tests_properties(annotate_module PROPERTIES
ENVIRONMENT "ANNOTATE_MODULE_TEST=${annotate_module_class}.${test_case}" TIMEOUT 20)
set(annotate_module_first FALSE)
else()
add_test(NAME annotate_module_${annotate_module_class}_${test_case} COMMAND ${Python3_EXECUTABLE}
"${annotate_module_test_source}" "${annotate_module_class}.${test_case}")
set_tests_properties(annotate_module_${annotate_module_class}_${test_case} PROPERTIES TIMEOUT 20)
endif()
endif()
endforeach()
endif()
add_test(NAME unwrap_self COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_unwrap_self.py)
@@ -260,6 +295,12 @@ if(BUILD_TESTING)
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_audit_dump.py)
add_test(NAME ffmpeg_cache_keys COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_ffmpeg_cache_keys.py)
add_test(NAME winlibs_digest COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_winlibs_digest.py)
add_test(NAME progress_comment_concurrency COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_progress_comment_concurrency.py)
add_test(NAME eligibility_paths COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_eligibility_paths.py)
foreach(shard RANGE 0 11)
if(shard EQUAL 0)
set(conventions_test_name conventions_function_bodies)
@@ -273,17 +314,26 @@ if(BUILD_TESTING)
add_test(NAME performance_csv COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_performance_csv.py)
set_tests_properties(performance_csv PROPERTIES TIMEOUT 20)
add_test(NAME conventions_wrapped_declarations COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_check_conventions_wrapped_declarations.py WrappedDeclarationTests)
set_tests_properties(conventions_wrapped_declarations PROPERTIES TIMEOUT 30)
add_test(NAME emsdk_pin COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_emsdk_pin.py)
set(conventions_wrapped_declarations_source "${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_check_conventions_wrapped_declarations.py")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${conventions_wrapped_declarations_source}")
file(STRINGS "${conventions_wrapped_declarations_source}" conventions_wrapped_declarations_classes REGEX "^class [A-Za-z0-9_]*Tests\\(")
foreach(test_class IN LISTS conventions_wrapped_declarations_classes)
string(REGEX REPLACE "^class ([A-Za-z0-9_]+).*" "\\1" test_class "${test_class}")
if(NOT test_class STREQUAL "WrappedDeclarationTests")
add_test(NAME conventions_wrapped_declarations_${test_class} COMMAND ${Python3_EXECUTABLE} "${conventions_wrapped_declarations_source}" ${test_class})
set_tests_properties(conventions_wrapped_declarations_${test_class} PROPERTIES TIMEOUT 30)
file(STRINGS "${conventions_wrapped_declarations_source}" conventions_wrapped_declarations_cases REGEX "^class [A-Za-z0-9_]*Tests\\(|^ def test_")
set(conventions_wrapped_declarations_class "")
set(conventions_wrapped_declarations_first TRUE)
foreach(test_case IN LISTS conventions_wrapped_declarations_cases)
if(test_case MATCHES "^class ([A-Za-z0-9_]+)")
set(conventions_wrapped_declarations_class "${CMAKE_MATCH_1}")
elseif(test_case MATCHES "^ def (test_[A-Za-z0-9_]+)")
if(conventions_wrapped_declarations_first)
set(conventions_wrapped_declarations_name conventions_wrapped_declarations)
set(conventions_wrapped_declarations_first FALSE)
else()
set(conventions_wrapped_declarations_name conventions_wrapped_declarations_${conventions_wrapped_declarations_class}_${CMAKE_MATCH_1})
endif()
add_test(NAME ${conventions_wrapped_declarations_name} COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_check_conventions_wrapped_declarations.py "${conventions_wrapped_declarations_class}.${CMAKE_MATCH_1}")
set_tests_properties(${conventions_wrapped_declarations_name} PROPERTIES TIMEOUT 20)
endif()
endforeach()
add_test(NAME conventions_ci_gate COMMAND ${Python3_EXECUTABLE}
@@ -322,10 +372,16 @@ if(BUILD_TESTING)
add_test(NAME check_skips_ctest COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_check_skips_ctest.py)
set_tests_properties(check_skips_ctest PROPERTIES TIMEOUT 30)
add_test(NAME pr_intake_reopen COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_pr_intake_workflow.py)
set_tests_properties(pr_intake_reopen PROPERTIES TIMEOUT 60)
add_test(NAME tools_pe_inventory COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/tests/test_pe_symbol_inventory.py)
set_tests_properties(tools_pe_inventory PROPERTIES TIMEOUT 20)
add_test(NAME check_skips COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_check_skips.py)
add_test(NAME relinker_seed_manifest COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_relinker_seed_manifest.py)
set_tests_properties(relinker_seed_manifest PROPERTIES TIMEOUT 20)
add_test(NAME sanitizer_report COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_sanitizer_report.py)
add_test(NAME relinker_fuzz_fixture_warnings COMMAND ${Python3_EXECUTABLE}
@@ -367,14 +423,29 @@ if(BUILD_TESTING)
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_configure_seed.py ConfigureSeedPathTests)
add_test(NAME configure_seed_round_trips COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_configure_seed.py ConfigureSeedRoundTripTests)
add_test(NAME configure_seed_stdout COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_configure_seed.py ConfigureSeedStdoutTests)
set_tests_properties(configure_seed_stdout PROPERTIES TIMEOUT 20)
add_test(NAME configure_seed_parsing COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_configure_seed.py ChecksParsingTests)
add_test(NAME vulkan_validation_gate_reports COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_vulkan_validation_gate.py ReportTests)
add_test(NAME vulkan_validation_gate_integration COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_vulkan_validation_gate.py IntegrationTests)
add_test(NAME vulkan_validation_gate_timeouts COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_vulkan_validation_gate.py TimeoutTests)
add_test(NAME vulkan_validation_gate_validation COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_vulkan_validation_gate.py ValidationTests)
add_test(NAME vulkan_validation_gate_layers COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_vulkan_validation_gate.py LayerTests)
add_test(NAME vulkan_validation_gate_output COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_vulkan_validation_gate.py OutputTests)
add_test(NAME vulkan_validation_gate_attribution COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_vulkan_validation_gate.py AttributionTests)
add_test(NAME vulkan_validation_gate_setup COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_vulkan_validation_gate.py SetupTests)
add_test(NAME vulkan_validation_gate_commands COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_vulkan_validation_gate.py CommandTests)
add_test(NAME stubgen COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_stubgen.py)
add_test(NAME debt_split COMMAND ${Python3_EXECUTABLE}
@@ -413,6 +484,8 @@ if(BUILD_TESTING)
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_pr_overlap_progress.py)
add_test(NAME pr_overlap_pages COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_pr_overlap_pages.py)
add_test(NAME pr_overlap_merge_bases COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_pr_overlap_merge_bases.py)
add_test(NAME pr_overlap_export_cache COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_pr_overlap_export_cache.py)
add_test(NAME pr_overlap_fail_closed COMMAND ${Python3_EXECUTABLE}
@@ -423,7 +496,7 @@ if(BUILD_TESTING)
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_package_release.py)
add_test(NAME web_release COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_web_release.py)
set_tests_properties(web_release PROPERTIES TIMEOUT 20)
set_tests_properties(web_release PROPERTIES TIMEOUT 120)
add_test(NAME web_library_assets COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_build_web.py)
set_tests_properties(web_library_assets PROPERTIES TIMEOUT 20)
@@ -567,6 +640,9 @@ if(BUILD_TESTING)
add_test(NAME performance_compare COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_performance_compare.py)
set_tests_properties(performance_compare PROPERTIES TIMEOUT 20)
add_test(NAME title_run COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_title_run.py)
set_tests_properties(title_run PROPERTIES TIMEOUT 60)
endif()
endif()
@@ -657,7 +733,8 @@ set_target_properties(usb-1.0 PROPERTIES POSITION_INDEPENDENT_CODE ON)
include(cmake/ZArchive.cmake)
include(cmake/Opus.cmake)
if(WIN32 OR APPLE)
include(cmake/Sqlite.cmake)
if(WIN32 OR APPLE OR (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT ANYPS5_ENABLE_ASAN AND NOT ANYPS5_ENABLE_TSAN))
set(MI_BUILD_SHARED ON CACHE BOOL "" FORCE)
set(MI_BUILD_STATIC OFF CACHE BOOL "" FORCE)
set(MI_BUILD_OBJECT OFF CACHE BOOL "" FORCE)
@@ -671,6 +748,8 @@ if(WIN32 OR APPLE)
target_link_options(mimalloc PRIVATE -static
LINKER:--wrap=malloc,--wrap=calloc,--wrap=realloc,--wrap=free,--wrap=strdup,--wrap=_strdup)
target_sources(mimalloc PRIVATE ${CMAKE_SOURCE_DIR}/core/libs/allocator/RuntimeHeap.c)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_options(mimalloc PRIVATE LINKER:--as-needed)
endif()
endif()
+1 -1
View File
@@ -40,7 +40,7 @@ For pull requests, full Linux and Windows builds and tests run only when a colla
gh workflow run build.yml --repo boykopovar/AnyPS5 --ref main --field pr=1234
```
This manual run also builds and tests the relinker on Linux, Windows and macOS when the pull request changes a file the relinker-only build uses, regardless of the author's previous contributions. The relinker matrix also runs automatically when a pull request targeting `main` is opened, updated or reopened, if its author already has a commit or a merged pull request in `main` and it changes a file the relinker-only build uses; full builds never run automatically for pull requests. Every job that runs automatically for pull requests runs only when the pull request changes its files: a `paths` filter on the `pull_request` trigger, or `needs: eligibility` with an `if` on the files output it sets in `build.yml`. The Conventions check fails a workflow change that adds a job without one. All build jobs check out the current `main` and merge the head of each selected pull request into it with `git merge --no-ff`, so a pull request that no longer merges cleanly must be rebased first. New commits require another manual run for full builds.
This manual run also builds and tests the relinker on Linux, Windows and macOS when the pull request changes a file the relinker-only build uses, regardless of the author's previous contributions. The relinker matrix also runs automatically when a pull request targeting `main` is opened, updated or reopened, if its author already has a commit or a merged pull request in `main` and it changes a file the relinker-only build uses; there it runs on macOS for arm64 only, the register context tests run on macOS Intel in Release only and the write watch tests on macOS arm64 only, both also under Rosetta on arm64, and the other macOS jobs run on the manual run and on the push to `main`. Full builds never run automatically for pull requests. Every job that runs automatically for pull requests runs only when the pull request changes its files: a `paths` filter on the `pull_request` trigger, or `needs: eligibility` with an `if` on the files output it sets in `build.yml`. The Conventions check fails a workflow change that adds a job without one. All build jobs check out the current `main` and merge the head of each selected pull request into it with `git merge --no-ff`, so a pull request that no longer merges cleanly must be rebased first. New commits require another manual run for full builds.
With `--field full=false`, the manual run skips the full builds and runs only the relinker matrix on Linux, Windows and macOS, if the pull request changes a file the relinker-only build uses, such as the Python tools and their tests in `tools/`.
+2 -2
View File
@@ -1,4 +1,4 @@
**English** | [Português (Brasil)](docs/user/README.pt-BR.md) | [Español](docs/user/README.es.md) | [Italiano](docs/user/README.it.md) | [简体中文](docs/user/README.zh-CN.md) | [Русский](docs/user/README.ru.md)
**English** | [Português (Brasil)](docs/user/README.pt-BR.md) | [Español](docs/user/README.es.md) | [Italiano](docs/user/README.it.md) | [简体中文](docs/user/README.zh-CN.md) | [Русский](docs/user/README.ru.md) | [Bahasa Indonesia](docs/user/README.id.md)
# About
@@ -12,7 +12,7 @@ The relinker-only build runs on macOS, including Apple silicon.
Includes a [relinker](core/relinker) that converts executable to the target system's native format and implementations of [system prx libraries](core/libs/prx) suitable for dynamic linking. No emulation or separate runtime process.
[**Discord**](https://discord.gg/BHFztBPUe), [Usage](docs/user/USAGE.md), [Build instructions](docs/dev/BUILD.md), [Architecture](docs/dev/ARCHITECTURE.md), [Technical debt of the project](docs/dev/TechnicalDebt.md), [code style conventions](docs/dev/CONVENTIONS.md), [contributing](CONTRIBUTING.md)
[**Discord**](https://discord.gg/x9naWVzC6A), [Usage](docs/user/USAGE.md), [Build instructions](docs/dev/BUILD.md), [Architecture](docs/dev/ARCHITECTURE.md), [Technical debt of the project](docs/dev/TechnicalDebt.md), [code style conventions](docs/dev/CONVENTIONS.md), [contributing](CONTRIBUTING.md)
## Status
+2
View File
@@ -39,6 +39,8 @@ add_library(jxr STATIC EXCLUDE_FROM_ALL
${JXR_SOURCE_DIR}/jxrgluelib/JXRGluePFC.c
${JXR_SOURCE_DIR}/jxrgluelib/JXRMeta.c)
configure_jxr_native(jxr)
set_source_files_properties(${JXR_SOURCE_DIR}/image/sys/strcodec.c ${JXR_SOURCE_DIR}/image/decode/segdec.c
PROPERTIES COMPILE_DEFINITIONS _M_IA64)
if(UNIX)
target_link_libraries(jxr PRIVATE m)
endif()
+68
View File
@@ -0,0 +1,68 @@
enable_language(C)
set(SQLITE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/3rdparty/sqlite)
set(sqliteGen ${CMAKE_BINARY_DIR}/sqlite)
file(MAKE_DIRECTORY ${sqliteGen})
foreach(tool IN ITEMS lemon mkkeywordhash mksourceid)
add_executable(sqlite_${tool} EXCLUDE_FROM_ALL ${SQLITE_SOURCE_DIR}/tool/${tool}.c)
set_target_properties(sqlite_${tool} PROPERTIES OUTPUT_NAME ${tool} RUNTIME_OUTPUT_DIRECTORY ${sqliteGen})
endforeach()
add_executable(sqlite_jimsh EXCLUDE_FROM_ALL ${SQLITE_SOURCE_DIR}/autosetup/jimsh0.c)
if(WIN32)
target_compile_definitions(sqlite_jimsh PRIVATE HAVE__FULLPATH)
else()
target_compile_definitions(sqlite_jimsh PRIVATE HAVE_REALPATH)
endif()
set_target_properties(sqlite_jimsh PROPERTIES OUTPUT_NAME jimsh RUNTIME_OUTPUT_DIRECTORY ${sqliteGen})
set(sqliteTcl $<TARGET_FILE:sqlite_jimsh>)
add_custom_command(OUTPUT ${sqliteGen}/sqlite3.h
COMMAND ${sqliteTcl} ${SQLITE_SOURCE_DIR}/tool/mksqlite3h.tcl ${SQLITE_SOURCE_DIR} -o ${sqliteGen}/sqlite3.h
WORKING_DIRECTORY ${sqliteGen}
DEPENDS sqlite_jimsh sqlite_mksourceid ${SQLITE_SOURCE_DIR}/src/sqlite.h.in ${SQLITE_SOURCE_DIR}/VERSION)
add_custom_command(OUTPUT ${sqliteGen}/parse.c ${sqliteGen}/parse.h
COMMAND ${CMAKE_COMMAND} -E copy ${SQLITE_SOURCE_DIR}/src/parse.y ${SQLITE_SOURCE_DIR}/tool/lempar.c ${sqliteGen}
COMMAND $<TARGET_FILE:sqlite_lemon> -S parse.y
WORKING_DIRECTORY ${sqliteGen}
DEPENDS sqlite_lemon ${SQLITE_SOURCE_DIR}/src/parse.y ${SQLITE_SOURCE_DIR}/tool/lempar.c)
add_custom_command(OUTPUT ${sqliteGen}/opcodes.h
COMMAND ${CMAKE_COMMAND} -E cat ${sqliteGen}/parse.h ${SQLITE_SOURCE_DIR}/src/vdbe.c > ${sqliteGen}/opcodes.in
COMMAND ${sqliteTcl} ${SQLITE_SOURCE_DIR}/tool/mkopcodeh.tcl < ${sqliteGen}/opcodes.in > ${sqliteGen}/opcodes.h
WORKING_DIRECTORY ${sqliteGen}
DEPENDS sqlite_jimsh ${sqliteGen}/parse.h ${SQLITE_SOURCE_DIR}/src/vdbe.c)
add_custom_command(OUTPUT ${sqliteGen}/opcodes.c
COMMAND ${sqliteTcl} ${SQLITE_SOURCE_DIR}/tool/mkopcodec.tcl ${sqliteGen}/opcodes.h > ${sqliteGen}/opcodes.c
WORKING_DIRECTORY ${sqliteGen}
DEPENDS sqlite_jimsh ${sqliteGen}/opcodes.h)
add_custom_command(OUTPUT ${sqliteGen}/keywordhash.h
COMMAND $<TARGET_FILE:sqlite_mkkeywordhash> > ${sqliteGen}/keywordhash.h
WORKING_DIRECTORY ${sqliteGen}
DEPENDS sqlite_mkkeywordhash)
add_custom_command(OUTPUT ${sqliteGen}/pragma.h
COMMAND ${sqliteTcl} ${SQLITE_SOURCE_DIR}/tool/mkpragmatab.tcl ${sqliteGen}/pragma.h
WORKING_DIRECTORY ${sqliteGen}
DEPENDS sqlite_jimsh ${SQLITE_SOURCE_DIR}/tool/mkpragmatab.tcl)
add_custom_command(OUTPUT ${sqliteGen}/ctime.c
COMMAND ${sqliteTcl} ${SQLITE_SOURCE_DIR}/tool/mkctimec.tcl ${sqliteGen}/ctime.c
WORKING_DIRECTORY ${sqliteGen}
DEPENDS sqlite_jimsh ${SQLITE_SOURCE_DIR}/tool/mkctimec.tcl)
set(sqliteSources)
foreach(name IN ITEMS alter analyze attach auth backup bitvec btmutex btree build callback carray complete date dbpage
dbstat delete expr fault fkey func global hash insert json legacy loadext main malloc mem0 mem1 mem2 mem3
mem5 memdb memjournal mutex mutex_noop mutex_unix mutex_w32 notify os os_kv os_unix os_win pager pcache
pcache1 pragma prepare printf random resolve rowset select status table threads tokenize treeview trigger
utf update upsert util vacuum vdbe vdbeapi vdbeaux vdbeblob vdbemem vdbesort vdbetrace vdbevtab vtab wal
walker where wherecode whereexpr window)
list(APPEND sqliteSources ${SQLITE_SOURCE_DIR}/src/${name}.c)
endforeach()
add_library(sqlite3 STATIC EXCLUDE_FROM_ALL ${sqliteSources} ${sqliteGen}/parse.c ${sqliteGen}/opcodes.c
${sqliteGen}/ctime.c ${sqliteGen}/sqlite3.h ${sqliteGen}/keywordhash.h ${sqliteGen}/pragma.h ${sqliteGen}/opcodes.h)
target_include_directories(sqlite3 PRIVATE ${sqliteGen} ${SQLITE_SOURCE_DIR}/src)
target_include_directories(sqlite3 SYSTEM INTERFACE ${sqliteGen})
target_compile_definitions(sqlite3 PRIVATE SQLITE_THREADSAFE=1 SQLITE_OMIT_LOAD_EXTENSION SQLITE_CORE)
set_target_properties(sqlite3 PROPERTIES C_STANDARD 99 POSITION_INDEPENDENT_CODE ON C_VISIBILITY_PRESET hidden)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(sqlite3 PRIVATE m pthread)
endif()
+177 -40
View File
@@ -152,7 +152,8 @@ add_custom_command(
COMMENT "Patching NIDs for libc"
)
file(GLOB LIBS_DIRS LIST_DIRECTORIES true ${CMAKE_CURRENT_SOURCE_DIR}/prx/*)
file(GLOB LIBS_DIRS LIST_DIRECTORIES true CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/prx/*)
file(GLOB LIBS_CMAKE_LISTS CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/prx/*/CMakeLists.txt)
list(REMOVE_ITEM LIBS_DIRS ${LIBC_DIR})
set(PATCHED_OUTPUTS ${LIBC_PATCHED})
@@ -235,6 +236,16 @@ if(MINGW OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
endif()
if(BUILD_TESTING)
add_test_executable(guest_system_logger_tests ${CMAKE_CURRENT_SOURCE_DIR}/tests/GuestSystemLogger.cpp)
target_include_directories(guest_system_logger_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_system_logger_tests PRIVATE libSceSystemLogger libc libkernel)
configure_windows_unwind(guest_system_logger_tests)
add_test(NAME guest_system_logger COMMAND guest_system_logger_tests)
if(WIN32)
set_tests_properties(guest_system_logger PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceSystemLogger>")
endif()
add_test_executable(guest_webrtc_vad_tests ${CMAKE_CURRENT_SOURCE_DIR}/tests/GuestWebrtcVad.cpp)
target_include_directories(guest_webrtc_vad_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_webrtc_vad_tests PRIVATE libwebrtc fvad)
@@ -289,13 +300,14 @@ if(TARGET mimalloc AND WIN32)
)
list(APPEND PATCHED_OUTPUTS ${PATCHED_DIR}/mimalloc.dll ${PATCHED_DIR}/mimalloc-redirect.dll)
elseif(TARGET mimalloc)
set(MIMALLOC_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}mimalloc${CMAKE_SHARED_LIBRARY_SUFFIX})
add_custom_command(
OUTPUT ${PATCHED_DIR}/libmimalloc.dylib
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:mimalloc> ${PATCHED_DIR}/libmimalloc.dylib
OUTPUT ${PATCHED_DIR}/${MIMALLOC_NAME}
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:mimalloc> ${PATCHED_DIR}/${MIMALLOC_NAME}
DEPENDS mimalloc
COMMENT "Copying libmimalloc.dylib beside the libraries"
COMMENT "Copying ${MIMALLOC_NAME} beside the libraries"
)
list(APPEND PATCHED_OUTPUTS ${PATCHED_DIR}/libmimalloc.dylib)
list(APPEND PATCHED_OUTPUTS ${PATCHED_DIR}/${MIMALLOC_NAME})
endif()
include(prx/libSceFreeType/BuildInfo.cmake)
@@ -335,6 +347,16 @@ if(BUILD_TESTING)
set_tests_properties(guest_kernel_sys_sdk_version PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel_sys>")
endif()
add_test_executable(guest_kernel_sys_app_category_tests tests/GuestKernelSysAppCategory.cpp)
target_include_directories(guest_kernel_sys_app_category_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_sys_app_category_tests PRIVATE libkernel_sys libkernel libc)
configure_windows_unwind(guest_kernel_sys_app_category_tests)
add_test(NAME guest_kernel_sys_app_category COMMAND guest_kernel_sys_app_category_tests)
if(WIN32)
set_tests_properties(guest_kernel_sys_app_category PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel_sys>")
endif()
add_test_executable(guest_kernel_sys_console_identity_tests tests/GuestKernelSysConsoleIdentity.cpp)
target_include_directories(guest_kernel_sys_console_identity_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_sys_console_identity_tests PRIVATE libkernel_sys libkernel libc)
@@ -443,7 +465,7 @@ if(BUILD_TESTING)
set(public_header_manifest "${CMAKE_CURRENT_BINARY_DIR}/public_headers.json")
add_test(NAME public_headers COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_public_headers.py --audit-only --manifest "${public_header_manifest}")
set_tests_properties(public_headers PROPERTIES TIMEOUT 90 RUN_SERIAL TRUE FIXTURES_SETUP public_headers_manifest)
set_tests_properties(public_headers PROPERTIES TIMEOUT 300 RUN_SERIAL TRUE FIXTURES_SETUP public_headers_manifest)
foreach(batch RANGE 0 63)
add_test(NAME public_headers_compile_${batch} COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_public_headers.py --compiler ${CMAKE_CXX_COMPILER} ${public_header_compiler_args}
@@ -488,6 +510,21 @@ if(BUILD_TESTING)
add_test(NAME nid_elf_layout COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/nid/tests/test_elf_layout.py $<TARGET_FILE:nid_patcher>)
endif()
add_test_executable(guest_kernel_sys_pwrite_tests tests/GuestKernelSysPwrite.cpp
nid/src/NidCompute.cpp nid/src/Sha1.cpp)
target_include_directories(guest_kernel_sys_pwrite_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/nid/include)
target_link_libraries(guest_kernel_sys_pwrite_tests PRIVATE ${CMAKE_DL_LIBS})
add_custom_target(guest_kernel_sys_pwrite_libraries DEPENDS
${PATCHED_DIR}/libkernel_sys.prx ${PATCHED_DIR}/libkernel.prx ${LIBC_PATCHED})
add_dependencies(guest_kernel_sys_pwrite_tests guest_kernel_sys_pwrite_libraries)
configure_windows_unwind(guest_kernel_sys_pwrite_tests)
if(MINGW)
target_compile_options(guest_kernel_sys_pwrite_tests PRIVATE -fasynchronous-unwind-tables)
target_link_options(guest_kernel_sys_pwrite_tests PRIVATE -static -static-libgcc -static-libstdc++)
endif()
add_test(NAME guest_kernel_sys_pwrite COMMAND guest_kernel_sys_pwrite_tests ${UNPATCHED_DIR} unpatched)
add_test(NAME guest_kernel_sys_pwrite_patched COMMAND guest_kernel_sys_pwrite_tests ${PATCHED_DIR} patched)
set_tests_properties(guest_kernel_sys_pwrite guest_kernel_sys_pwrite_patched PROPERTIES TIMEOUT 20)
add_test_executable(guest_kernel_sys_tests tests/GuestKernelSys.cpp)
target_include_directories(guest_kernel_sys_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_sys_tests PRIVATE libkernel_sys libSceNet libSceAmpr libkernel libc)
@@ -520,6 +557,46 @@ if(BUILD_TESTING)
configure_windows_unwind(guest_kernel_sys_barrier_tests)
add_test(NAME guest_kernel_sys_barrier COMMAND guest_kernel_sys_barrier_tests)
set_tests_properties(guest_kernel_sys_barrier PROPERTIES TIMEOUT 20)
add_test_executable(guest_kernel_sys_execve_tests tests/GuestKernelSysExecve.cpp)
target_include_directories(guest_kernel_sys_execve_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_sys_execve_tests PRIVATE libkernel_sys libkernel libc)
configure_windows_unwind(guest_kernel_sys_execve_tests)
add_test(NAME guest_kernel_sys_execve COMMAND guest_kernel_sys_execve_tests)
set_tests_properties(guest_kernel_sys_execve PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_kernel_sys_execve PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel_sys>")
endif()
add_test_executable(guest_kernel_sys_execvpe_tests tests/GuestKernelSysExecvpe.cpp)
target_include_directories(guest_kernel_sys_execvpe_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_sys_execvpe_tests PRIVATE libkernel_sys libkernel libc)
configure_windows_unwind(guest_kernel_sys_execvpe_tests)
add_test(NAME guest_kernel_sys_execvpe COMMAND guest_kernel_sys_execvpe_tests)
set_tests_properties(guest_kernel_sys_execvpe PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_kernel_sys_execvpe PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel_sys>")
endif()
add_test_executable(guest_kernel_sys_nanosleep_tests tests/GuestKernelSysNanosleep.cpp)
target_include_directories(guest_kernel_sys_nanosleep_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_sys_nanosleep_tests PRIVATE libkernel_sys libkernel libc)
configure_windows_unwind(guest_kernel_sys_nanosleep_tests)
add_test(NAME guest_kernel_sys_nanosleep COMMAND guest_kernel_sys_nanosleep_tests)
set_tests_properties(guest_kernel_sys_nanosleep PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_kernel_sys_nanosleep PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel_sys>")
endif()
add_test_executable(guest_kernel_sys_adjtime_tests tests/GuestKernelSysAdjtime.cpp)
target_include_directories(guest_kernel_sys_adjtime_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_sys_adjtime_tests PRIVATE libkernel_sys libkernel libc)
configure_windows_unwind(guest_kernel_sys_adjtime_tests)
add_test(NAME guest_kernel_sys_adjtime COMMAND guest_kernel_sys_adjtime_tests)
set_tests_properties(guest_kernel_sys_adjtime PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_kernel_sys_adjtime PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel_sys>")
endif()
add_test_executable(guest_kernel_sys_pthread_tests tests/GuestKernelSysPthread.cpp)
target_include_directories(guest_kernel_sys_pthread_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_sys_pthread_tests PRIVATE libkernel_sys libkernel libc)
@@ -531,6 +608,16 @@ if(BUILD_TESTING)
configure_windows_unwind(guest_kernel_sys_constants_tests)
add_test(NAME guest_kernel_sys_constants COMMAND guest_kernel_sys_constants_tests)
set_tests_properties(guest_kernel_sys_constants PROPERTIES TIMEOUT 20)
add_test_executable(guest_kernel_sys_dup_tests tests/GuestKernelSysDup.cpp)
target_include_directories(guest_kernel_sys_dup_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_sys_dup_tests PRIVATE libkernel_sys libkernel libc)
configure_windows_unwind(guest_kernel_sys_dup_tests)
add_test(NAME guest_kernel_sys_dup COMMAND guest_kernel_sys_dup_tests)
set_tests_properties(guest_kernel_sys_dup PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_kernel_sys_dup PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel_sys>")
endif()
add_test_executable(guest_firmware_constant_returns_tests tests/GuestFirmwareConstantReturns.cpp)
target_include_directories(guest_firmware_constant_returns_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_firmware_constant_returns_tests PRIVATE libSceAvSetting libSceComposite libSceFsInternalForVsh libSceHttpCache libScePlayReady libSceSdma libSceSsl libSceVisionManager libmdbg_syscore libkernel libc)
@@ -541,6 +628,16 @@ if(BUILD_TESTING)
set_tests_properties(guest_firmware_constant_returns PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceAvSetting>;PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceComposite>;PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceFsInternalForVsh>;PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceHttpCache>;PATH=path_list_prepend:$<TARGET_FILE_DIR:libScePlayReady>;PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceSdma>;PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceSsl>;PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceVisionManager>;PATH=path_list_prepend:$<TARGET_FILE_DIR:libmdbg_syscore>")
endif()
add_test_executable(guest_bemp2sys_tests tests/GuestBemp2sys.cpp)
target_include_directories(guest_bemp2sys_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_bemp2sys_tests PRIVATE libSceBemp2sys libkernel libc)
configure_windows_unwind(guest_bemp2sys_tests)
add_test(NAME guest_bemp2sys COMMAND guest_bemp2sys_tests)
set_tests_properties(guest_bemp2sys PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_bemp2sys PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceBemp2sys>")
endif()
add_test_executable(guest_playready_tests tests/GuestPlayReady.cpp)
target_include_directories(guest_playready_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_playready_tests PRIVATE libScePlayReady libkernel libc)
@@ -774,6 +871,15 @@ if(BUILD_TESTING)
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceVrTracker>")
endif()
add_test_executable(guest_tts_core_g3_bc_unknown_returns_tests tests/GuestTtsCoreG3BcUnknownReturns.cpp)
target_include_directories(guest_tts_core_g3_bc_unknown_returns_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_tts_core_g3_bc_unknown_returns_tests PRIVATE libSceTtsCoreG3Bc libc)
configure_windows_unwind(guest_tts_core_g3_bc_unknown_returns_tests)
add_test(NAME guest_tts_core_g3_bc_unknown_returns COMMAND guest_tts_core_g3_bc_unknown_returns_tests)
if(WIN32)
set_tests_properties(guest_tts_core_g3_bc_unknown_returns PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceTtsCoreG3Bc>")
endif()
add_test_executable(guest_move_tests tests/GuestMove.cpp)
target_include_directories(guest_move_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_move_tests PRIVATE libSceMove libc)
@@ -850,6 +956,17 @@ if(BUILD_TESTING)
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceXml>")
endif()
add_test_executable(guest_xml_initializer_tests tests/GuestXmlInitializer.cpp)
target_include_directories(guest_xml_initializer_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_xml_initializer_tests PRIVATE libSceXml libkernel libc)
configure_windows_unwind(guest_xml_initializer_tests)
add_test(NAME guest_xml_initializer COMMAND guest_xml_initializer_tests)
set_tests_properties(guest_xml_initializer PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_xml_initializer PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceXml>")
endif()
add_test_executable(guest_offline_imports_tests tests/GuestOfflineImports.cpp)
target_include_directories(guest_offline_imports_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_offline_imports_tests PRIVATE libSceHttp libSceNpEntitlementAccess libSceRudp libSceVideoRecordingP libc)
@@ -915,6 +1032,17 @@ if(BUILD_TESTING)
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceGameLiveStreaming>")
endif()
add_test_executable(guest_kernel_sys_revoke_tests tests/GuestKernelSysRevoke.cpp)
target_include_directories(guest_kernel_sys_revoke_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_sys_revoke_tests PRIVATE libkernel_sys libkernel libc)
configure_windows_unwind(guest_kernel_sys_revoke_tests)
add_test(NAME guest_kernel_sys_revoke COMMAND guest_kernel_sys_revoke_tests)
set_tests_properties(guest_kernel_sys_revoke PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_kernel_sys_revoke PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel_sys>")
endif()
add_test_executable(guest_netctl_ap_tests tests/GuestNetCtlAp.cpp)
target_include_directories(guest_netctl_ap_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_netctl_ap_tests PRIVATE libSceNetCtlAp libc)
@@ -1036,16 +1164,6 @@ if(BUILD_TESTING)
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceSystemGesture>")
endif()
add_test_executable(guest_sys_util_notification_tests tests/GuestSysUtilNotification.cpp)
target_include_directories(guest_sys_util_notification_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_sys_util_notification_tests PRIVATE libSceSysUtil libkernel libc)
configure_windows_unwind(guest_sys_util_notification_tests)
add_test(NAME guest_sys_util_notification COMMAND guest_sys_util_notification_tests)
if(WIN32)
set_tests_properties(guest_sys_util_notification PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceSysUtil>")
endif()
if(UNIX AND (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)$" OR CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64"))
add_subdirectory(tests/register_context)
endif()
@@ -1122,6 +1240,16 @@ if(BUILD_TESTING)
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceNpCppWebApi>")
endif()
add_test_executable(guest_np_cpp_web_api_friends_tests tests/GuestNpCppWebApiFriends.cpp)
target_include_directories(guest_np_cpp_web_api_friends_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_np_cpp_web_api_friends_tests PRIVATE libSceNpCppWebApi libc)
configure_windows_unwind(guest_np_cpp_web_api_friends_tests)
add_test(NAME guest_np_cpp_web_api_friends COMMAND guest_np_cpp_web_api_friends_tests)
if(WIN32)
set_tests_properties(guest_np_cpp_web_api_friends PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceNpCppWebApi>")
endif()
add_test_executable(guest_np_cpp_web_api_signed_out_tests tests/GuestNpCppWebApiSignedOut.cpp)
target_include_directories(guest_np_cpp_web_api_signed_out_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_np_cpp_web_api_signed_out_tests PRIVATE libSceNpCppWebApi libc)
@@ -1216,13 +1344,29 @@ if(BUILD_TESTING)
add_test_executable(guest_kernel_sys_cpuset_tests tests/GuestKernelSysCpuset.cpp)
target_include_directories(guest_kernel_sys_cpuset_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_sys_cpuset_tests PRIVATE libkernel_sys libkernel libc)
target_link_libraries(guest_kernel_sys_cpuset_tests PRIVATE libkernel libc)
configure_windows_unwind(guest_kernel_sys_cpuset_tests)
add_test(NAME guest_kernel_sys_cpuset COMMAND guest_kernel_sys_cpuset_tests)
set_tests_properties(guest_kernel_sys_cpuset PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_kernel_sys_cpuset PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel_sys>")
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
add_test_executable(guest_kernel_process_exports_tests tests/GuestKernelProcessExports.cpp)
target_include_directories(guest_kernel_process_exports_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_process_exports_tests PRIVATE ${CMAKE_DL_LIBS})
configure_host_test_executable(guest_kernel_process_exports_tests)
add_custom_target(guest_kernel_process_exports_libraries DEPENDS libkernel ${PATCHED_DIR}/libkernel.prx ${LIBC_PATCHED})
add_dependencies(guest_kernel_process_exports_tests guest_kernel_process_exports_libraries)
add_test(NAME guest_kernel_process_exports COMMAND guest_kernel_process_exports_tests ${UNPATCHED_DIR} unpatched)
add_test(NAME guest_kernel_process_exports_patched COMMAND guest_kernel_process_exports_tests ${PATCHED_DIR} patched)
set_tests_properties(guest_kernel_process_exports guest_kernel_process_exports_patched PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_kernel_process_exports PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:${UNPATCHED_DIR}")
set_tests_properties(guest_kernel_process_exports_patched PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:${PATCHED_DIR}")
endif()
add_test_executable(guest_posix_random_tests tests/GuestPosixRandom.cpp)
@@ -1269,16 +1413,6 @@ if(BUILD_TESTING)
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceAcm>")
endif()
add_test_executable(guest_voice_chat_tests tests/GuestVoiceChat.cpp)
target_include_directories(guest_voice_chat_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_voice_chat_tests PRIVATE libSceVoiceChat libc)
configure_windows_unwind(guest_voice_chat_tests)
add_test(NAME guest_voice_chat COMMAND guest_voice_chat_tests)
if(WIN32)
set_tests_properties(guest_voice_chat PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceVoiceChat>")
endif()
add_test_executable(guest_gnm_neo_embedded_tests tests/GuestGnmNeoEmbedded.cpp)
target_include_directories(guest_gnm_neo_embedded_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_gnm_neo_embedded_tests PRIVATE libSceGnmDriverForNeoMode libc)
@@ -1319,18 +1453,6 @@ if(BUILD_TESTING)
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceGnmDriverForNeoMode>")
endif()
add_test_executable(guest_vorbis_dec_tests tests/GuestVorbisDec.cpp)
target_include_directories(guest_vorbis_dec_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(guest_vorbis_dec_tests PRIVATE OV_EXCLUDE_STATIC_CALLBACKS)
target_link_libraries(guest_vorbis_dec_tests PRIVATE libSceVorbisDec vorbisenc vorbisfile vorbis ogg libc)
configure_windows_unwind(guest_vorbis_dec_tests)
add_test(NAME guest_vorbis_dec COMMAND guest_vorbis_dec_tests)
set_tests_properties(guest_vorbis_dec PROPERTIES TIMEOUT 30)
if(WIN32)
set_tests_properties(guest_vorbis_dec PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceVorbisDec>")
endif()
add_test_executable(guest_gnm_neo_default_state_tests tests/GuestGnmNeoDefaultState.cpp)
target_include_directories(guest_gnm_neo_default_state_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_gnm_neo_default_state_tests PRIVATE libSceGnmDriverForNeoMode libc)
@@ -1352,4 +1474,19 @@ if(BUILD_TESTING)
endif()
include(prx/libSceFreeType/CurveBounds.cmake)
target_sources(libwebrtc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/prx/libwebrtc/src/FileWrapper.cpp)
if(BUILD_TESTING)
add_test_executable(guest_webrtc_file_wrapper_tests ${CMAKE_CURRENT_SOURCE_DIR}/tests/GuestWebrtcFileWrapper.cpp)
target_include_directories(guest_webrtc_file_wrapper_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_webrtc_file_wrapper_tests PRIVATE libwebrtc libc)
configure_windows_unwind(guest_webrtc_file_wrapper_tests)
add_test(NAME guest_webrtc_file_wrapper COMMAND guest_webrtc_file_wrapper_tests)
set_tests_properties(guest_webrtc_file_wrapper PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_webrtc_file_wrapper PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libwebrtc>")
endif()
endif()
include(prx/libSceBeisobmf/Tests.cmake)
+26
View File
@@ -2027,6 +2027,32 @@ struct PngDecImageInfo {
std::uint32_t image_flag;
};
struct PngDecInputChunk {
const void* data;
std::uint32_t size;
std::uint32_t reserved;
};
using PngDecInputCallback = std::int32_t (APS5_VABI *)(PngDecInputChunk*, void*);
struct PngDecInputControlParam {
PngDecInputCallback input;
void* input_argument;
void* image_mem_addr;
std::uint32_t image_mem_size;
std::uint16_t operation;
std::uint16_t pixel_format;
std::uint16_t alpha_value;
std::uint16_t reserved;
std::uint32_t image_pitch;
};
struct SystemLoggerLogData {
std::uint8_t data[0x40];
std::uint32_t size;
std::uint8_t reserved[0x20];
};
struct JpegEncCreateParam {
std::uint32_t size;
std::uint32_t attr;
@@ -153,6 +153,18 @@ void failsWithoutTouchingTheFile(const std::filesystem::path& directory, const s
throw std::runtime_error(what + ": the move did not fail");
}
void failsWithoutTouchingTheImage(const std::string& what, const std::vector<unsigned char>& bytes, const std::string& expected) {
auto copy = bytes;
try {
Allocator::MoveImportFirst(copy, "mimalloc-redirect.dll");
} catch (const std::exception& error) {
require(std::string(error.what()).find(expected) != std::string::npos, what + ": failed with another error: " + error.what());
require(copy == bytes, what + ": the image changed although the move failed");
return;
}
throw std::runtime_error(what + ": the move did not fail");
}
}
int main() {
@@ -166,27 +178,27 @@ int main() {
failsWithoutTouchingTheFile(directory, "missing-import", image({"kernel32.dll", "ucrtbase.dll"}), "does not import mimalloc-redirect.dll");
auto truncated = image({"kernel32.dll", "mimalloc-redirect.dll", "ucrtbase.dll"});
truncated.resize(SectionOffset + DescriptorBytes + DescriptorBytes / 2);
failsWithoutTouchingTheFile(directory, "truncated-directory", truncated, "truncated import directory");
failsWithoutTouchingTheFile(directory, "pe32", image({"kernel32.dll", "mimalloc-redirect.dll"}, 0x10b), "not a PE32+ image");
failsWithoutTouchingTheImage("truncated-directory", truncated, "truncated import directory");
failsWithoutTouchingTheImage("pe32", image({"kernel32.dll", "mimalloc-redirect.dll"}, 0x10b), "not a PE32+ image");
auto undeclared = image({"kernel32.dll", "mimalloc-redirect.dll"});
put32(undeclared, OptionalOffset + 108, 0);
failsWithoutTouchingTheFile(directory, "directory-count-zero", undeclared, "the image has no imports");
failsWithoutTouchingTheImage("directory-count-zero", undeclared, "the image has no imports");
auto oneDirectory = image({"kernel32.dll", "mimalloc-redirect.dll"});
put32(oneDirectory, OptionalOffset + 108, 1);
failsWithoutTouchingTheFile(directory, "directory-count-one", oneDirectory, "the image has no imports");
failsWithoutTouchingTheImage("directory-count-one", oneDirectory, "the image has no imports");
auto shortHeader = image({"kernel32.dll", "mimalloc-redirect.dll"});
put16(shortHeader, PeOffset + 20, 112);
failsWithoutTouchingTheFile(directory, "optional-header-without-imports", shortHeader, "the image has no imports");
failsWithoutTouchingTheImage("optional-header-without-imports", shortHeader, "the image has no imports");
auto incompleteEntry = image({"kernel32.dll", "mimalloc-redirect.dll"}, 0x20b, 2, 128);
put16(incompleteEntry, PeOffset + 20, 127);
failsWithoutTouchingTheFile(directory, "optional-header-incomplete-import-entry", incompleteEntry, "the image has no imports");
failsWithoutTouchingTheImage("optional-header-incomplete-import-entry", incompleteEntry, "the image has no imports");
auto unterminated = image({"kernel32.dll", "mimalloc-redirect.dll"});
unterminated.resize(SectionOffset + 3 * DescriptorBytes + 13 + 21);
failsWithoutTouchingTheFile(directory, "unterminated-name", unterminated, "unterminated import name");
failsWithoutTouchingTheImage("unterminated-name", unterminated, "unterminated import name");
auto outsideFile = image({"kernel32.dll", "mimalloc-redirect.dll", "ucrtbase.dll"});
put32(outsideFile, SectionOffset + 2 * DescriptorBytes + 12, static_cast<std::uint32_t>(SectionRva + 0x1ff));
outsideFile.resize(0x300);
failsWithoutTouchingTheFile(directory, "name-past-the-file", outsideFile, "RVA outside the file data");
failsWithoutTouchingTheImage("name-past-the-file", outsideFile, "RVA outside the file data");
} catch (const std::exception& error) {
std::cerr << error.what() << '\n';
std::error_code ignored;
+32 -15
View File
@@ -99,10 +99,20 @@ void ReorderDynSymForGnuHash(
std::uint32_t symOffset,
std::uint32_t bucketCount,
std::vector<std::string>& symbolNames,
std::vector<std::uint32_t>& oldToNewIndex
std::vector<std::uint32_t>& oldToNewIndex,
std::size_t versymOffset
) {
using namespace Internal;
std::vector<std::uint16_t> oldVersions;
std::vector<std::uint16_t> reorderedVersions;
if (versymOffset != 0u) {
oldVersions.resize(symCount);
reorderedVersions.resize(symCount);
for (std::size_t i = 0u; i < symCount; ++i)
oldVersions[i] = Read<std::uint16_t>(elf, versymOffset + i * sizeof(std::uint16_t));
}
std::vector<std::uint32_t> movableIndices;
for (std::uint32_t i = symOffset; i < symCount; ++i)
movableIndices.push_back(i);
@@ -121,6 +131,7 @@ void ReorderDynSymForGnuHash(
reorderedSyms[i] = Read<Elf64_Sym>(elf, dynSymOffset + i * sizeof(Elf64_Sym));
reorderedNames[i] = symbolNames[i];
oldToNewIndex[i] = i;
if (versymOffset != 0u) reorderedVersions[i] = oldVersions[i];
}
for (std::size_t position = 0u; position < movableIndices.size(); ++position) {
@@ -129,10 +140,13 @@ void ReorderDynSymForGnuHash(
reorderedSyms[newIndex] = Read<Elf64_Sym>(elf, dynSymOffset + oldIndex * sizeof(Elf64_Sym));
reorderedNames[newIndex] = symbolNames[oldIndex];
oldToNewIndex[oldIndex] = newIndex;
if (versymOffset != 0u) reorderedVersions[newIndex] = oldVersions[oldIndex];
}
for (std::size_t i = 0u; i < symCount; ++i)
Write(elf, dynSymOffset + i * sizeof(Elf64_Sym), reorderedSyms[i]);
for (std::size_t i = 0u; versymOffset != 0u && i < symCount; ++i)
Write(elf, versymOffset + i * sizeof(std::uint16_t), reorderedVersions[i]);
symbolNames = std::move(reorderedNames);
}
@@ -369,9 +383,11 @@ void ElfNidPatcher::PatchNids(std::vector<std::uint8_t>& elf, const std::string&
std::size_t gnuHashOffset = 0u, gnuHashSize = 0u;
std::size_t sysvHashOffset = 0u, sysvHashSize = 0u;
std::uint32_t sysvHashLink = 0u;
std::size_t versymOffset = 0u;
std::size_t versymOffset = 0u, versymSize = 0u;
bool hasDynamic = false;
std::uint32_t dynSymSectionIndex = 0u;
std::uint32_t dynSymSectionLink = 0u;
bool hasDynSym = false;
std::uint32_t gnuHashSymOffset = 0u;
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
@@ -380,10 +396,13 @@ void ElfNidPatcher::PatchNids(std::vector<std::uint8_t>& elf, const std::string&
if (shdr.sh_type == kShtDynsym) {
if (shdr.sh_entsize != sizeof(Elf64_Sym) || shdr.sh_size % sizeof(Elf64_Sym) || shdr.sh_link >= ehdr.e_shnum)
throw std::runtime_error("invalid ELF dynsym layout");
if (hasDynSym) throw std::runtime_error("multiple ELF dynsym sections");
RequireElfRange(elf, shdr.sh_offset, shdr.sh_size, "dynsym");
dynSymOffset = static_cast<std::size_t>(shdr.sh_offset);
dynSymSize = static_cast<std::size_t>(shdr.sh_size);
dynSymSectionIndex = i;
dynSymSectionLink = shdr.sh_link;
hasDynSym = true;
}
if (shdr.sh_type == kShtGnuHash) {
gnuHashOffset = static_cast<std::size_t>(shdr.sh_offset);
@@ -394,8 +413,10 @@ void ElfNidPatcher::PatchNids(std::vector<std::uint8_t>& elf, const std::string&
sysvHashSize = static_cast<std::size_t>(shdr.sh_size);
sysvHashLink = shdr.sh_link;
}
if (shdr.sh_type == kShtGnuVersym)
if (shdr.sh_type == kShtGnuVersym) {
versymOffset = static_cast<std::size_t>(shdr.sh_offset);
versymSize = static_cast<std::size_t>(shdr.sh_size);
}
if (shdr.sh_type == kShtGnuVerdef)
throw std::runtime_error("unsupported .gnu.version_d section: symbol version definitions cannot be preserved");
}
@@ -417,6 +438,11 @@ void ElfNidPatcher::PatchNids(std::vector<std::uint8_t>& elf, const std::string&
const std::size_t symCount = dynSymSize / sizeof(Elf64_Sym);
if (symCount == 0u) throw std::runtime_error(".dynsym is empty");
if (versymOffset != 0u) {
RequireElfRange(elf, versymOffset, versymSize, "versym");
if (versymSize < symCount * sizeof(std::uint16_t))
throw std::runtime_error("invalid ELF version symbol table size");
}
if (sysvHashOffset != 0u) {
if (sysvHashLink != dynSymSectionIndex) throw std::runtime_error("invalid ELF hash symbol table link");
ValidateSysvHash(elf, sysvHashOffset, sysvHashSize, symCount);
@@ -426,18 +452,9 @@ void ElfNidPatcher::PatchNids(std::vector<std::uint8_t>& elf, const std::string&
gnuHashSymOffset = Read<std::uint32_t>(elf, gnuHashOffset + 4u);
}
const std::size_t dynStrSectionLink = [&]() -> std::size_t {
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
if (shdr.sh_type == kShtDynsym) return static_cast<std::size_t>(shdr.sh_link);
}
throw std::runtime_error("cannot find dynsym sh_link");
}();
std::size_t dynStrOffset = 0u, dynStrSize = 0u;
{
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + dynStrSectionLink * sizeof(Elf64_Shdr);
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + dynSymSectionLink * sizeof(Elf64_Shdr);
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
if (shdr.sh_type != 3) throw std::runtime_error("invalid ELF dynstr section type");
RequireElfRange(elf, shdr.sh_offset, shdr.sh_size, "dynstr");
@@ -596,7 +613,7 @@ void ElfNidPatcher::PatchNids(std::vector<std::uint8_t>& elf, const std::string&
dynStrOffset = static_cast<std::size_t>(fileOffset + tableSize);
dynStrSize = newDynStr.size();
const auto stringAddress = address + tableSize;
const auto sectionOffset = ehdr.e_shoff + dynStrSectionLink * sizeof(Elf64_Shdr);
const auto sectionOffset = ehdr.e_shoff + dynSymSectionLink * sizeof(Elf64_Shdr);
auto strings = Read<Elf64_Shdr>(elf, sectionOffset);
strings.sh_offset = dynStrOffset;
strings.sh_addr = stringAddress;
@@ -637,7 +654,7 @@ void ElfNidPatcher::PatchNids(std::vector<std::uint8_t>& elf, const std::string&
if (gnuHashOffset != 0u) {
const auto bucketCount = Read<std::uint32_t>(elf, gnuHashOffset);
std::vector<std::uint32_t> oldToNewIndex(symCount);
ReorderDynSymForGnuHash(elf, dynSymOffset, symCount, gnuHashSymOffset, bucketCount, newSymbolNames, oldToNewIndex);
ReorderDynSymForGnuHash(elf, dynSymOffset, symCount, gnuHashSymOffset, bucketCount, newSymbolNames, oldToNewIndex, versymOffset);
FixupRelocationSymbolIndices(elf, ehdr, dynSymSectionIndex, oldToNewIndex);
RebuildGnuHash(elf, gnuHashOffset, gnuHashSize, symCount, newSymbolNames);
}
+20 -1
View File
@@ -3,7 +3,7 @@ import sys
import unittest
from pathlib import Path
from test_symbol_versions import build_image, symbols, patch, HASH_OFFSET, SHOFF, read_dynsym, gnu_hash, sections, PATCHER
from test_symbol_versions import build_image, symbols, patch, HASH_OFFSET, SHOFF, VERSYM_OFFSET, read_dynsym, gnu_hash, sections, PATCHER
def sysv_hash(name):
@@ -95,6 +95,25 @@ class GnuHashTests(unittest.TestCase):
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(struct.unpack_from("<I", after, HASH_OFFSET)[0], 0)
def test_version_symbols_follow_reordered_symbols(self):
image = self.image()
count = len(symbols(False))
versions = [1, 1, 1] + [2 + index for index in range(count - 3)]
for index, version in enumerate(versions):
struct.pack_into("<H", image, VERSYM_OFFSET + index * 2, version)
struct.pack_into("<IIQQQQIIQQ", image, SHOFF + 4 * 64, 0, 0x6FFFFFFF, 2, 0, VERSYM_OFFSET, count * 2, 1, 0, 2, 2)
struct.pack_into("<H", image, 0x3C, 5)
before = read_dynsym(image)
result, after = patch(PATCHER, image, "versym.so")
self.assertEqual(result.returncode, 0, result.stderr)
renamed = read_dynsym(after)
self.assertNotEqual([entry[2] for entry in renamed], [entry[2] for entry in before], "the symbols were not reordered")
version_of = {entry[2]: versions[index] for index, entry in enumerate(before) if entry[1] == 9}
after_versions = [struct.unpack_from("<H", after, VERSYM_OFFSET + index * 2)[0] for index in range(count)]
for index, (name, shndx, value) in enumerate(renamed):
if shndx == 9:
self.assertEqual(after_versions[index], version_of[value], (index, name))
@unittest.skipUnless(PATCHER is not None and PATCHER.is_file(), "nid_patcher executable required")
class SysvHashTests(unittest.TestCase):
@@ -199,6 +199,44 @@ def test_unversioned_library_is_still_patched(patcher):
assert len({entry[0] for entry in after if entry[0]}) == len([entry for entry in after if entry[0]])
def sysv_only_image(entries):
image = bytearray(build_image(entries, False))
struct.pack_into("<I", image, SHOFF + 3 * 64 + 4, 1)
return image
def test_version_table_smaller_than_symbols_is_rejected(patcher):
image = sysv_only_image(symbols(False))
for index in range(len(symbols(False))):
struct.pack_into("<H", image, VERSYM_OFFSET + index * 2, 2)
struct.pack_into("<IIQQQQIIQQ", image, SHOFF + 4 * 64, 0, SHT_GNU_VERSYM, 2, 0, VERSYM_OFFSET, 0, 1, 0, 2, 2)
struct.pack_into("<H", image, 0x3C, 5)
image = bytes(image)
assert not any(section[1] == SHT_GNU_HASH for section in sections(image))
result, on_disk = patch(patcher, image, SONAME)
assert result.returncode != 0, result.stdout
message = result.stderr.decode("utf-8", errors="replace")
assert "version symbol table" in message, message
assert on_disk == image, "the rejected library was written back modified"
def test_two_dynsym_sections_are_rejected(patcher):
entries = symbols(False)
image = bytearray(build_image(entries, False))
struct.pack_into("<I", image, SHOFF + 1 * 64 + 40, 5)
struct.pack_into("<IIQQQQIIQQ", image, SHOFF + 4 * 64, 0, SHT_DYNSYM, 2, 0, DYNSYM_OFFSET, len(entries) * 24, 2, 1, 8, 24)
struct.pack_into("<IIQQQQIIQQ", image, SHOFF + 5 * 64, 0, SHT_STRTAB, 2, 0, 0xA00, 0x100, 0, 0, 1, 0)
struct.pack_into("<H", image, 0x3C, 6)
image = bytes(image)
result, on_disk = patch(patcher, image, SONAME)
assert result.returncode != 0, result.stdout
message = result.stderr.decode("utf-8", errors="replace")
assert "multiple ELF dynsym" in message, message
assert on_disk == image, "the rejected library was written back modified"
def find_patcher():
for index, argument in enumerate(sys.argv[1:], 1):
candidate = Path(argument)
@@ -231,6 +269,8 @@ def main():
sys.exit(0)
test_versioned_library_is_rejected(patcher)
test_unversioned_library_is_still_patched(patcher)
test_version_table_smaller_than_symbols_is_rejected(patcher)
test_two_dynsym_sections_are_rejected(patcher)
print("NID patcher symbol version tests passed")
+350 -1
View File
@@ -5,6 +5,355 @@
extern "C" {
APS5_DUMMY_FUN
int APS5_VABI sceAbstractLocalUnknown_FEu1f3FzXEs_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("FEu1f3FzXEs", sceAbstractLocalUnknown_FEu1f3FzXEs_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_Sggzq_yDkN4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Sggzq+yDkN4", sceAbstractLocalUnknown_Sggzq_yDkN4_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_G85xANoQtwY_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("G85xANoQtwY", sceAbstractLocalUnknown_G85xANoQtwY_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown__hzeczmXprY_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("-hzeczmXprY", sceAbstractLocalUnknown__hzeczmXprY_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_NWB_BVBCHxk_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("NWB-BVBCHxk", sceAbstractLocalUnknown_NWB_BVBCHxk_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_aZaT3Nyab30_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("aZaT3Nyab30", sceAbstractLocalUnknown_aZaT3Nyab30_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_LOS4KcdYH4U_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("LOS4KcdYH4U", sceAbstractLocalUnknown_LOS4KcdYH4U_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_G2Ny4kfT__U_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("G2Ny4kfT-+U", sceAbstractLocalUnknown_G2Ny4kfT__U_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_TrIn0pwP01Y_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("TrIn0pwP01Y", sceAbstractLocalUnknown_TrIn0pwP01Y_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_8PcGryCtIyc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("8PcGryCtIyc", sceAbstractLocalUnknown_8PcGryCtIyc_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_uISRjQQphhM_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("uISRjQQphhM", sceAbstractLocalUnknown_uISRjQQphhM_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_boWydF6kfCg_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("boWydF6kfCg", sceAbstractLocalUnknown_boWydF6kfCg_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_P0nRNq2s9yM_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("P0nRNq2s9yM", sceAbstractLocalUnknown_P0nRNq2s9yM_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_EUEJ9ApMPBI_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("EUEJ9ApMPBI", sceAbstractLocalUnknown_EUEJ9ApMPBI_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown__FKZylBFj8Y_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("-FKZylBFj8Y", sceAbstractLocalUnknown__FKZylBFj8Y_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_CGjnAIJU2b4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("CGjnAIJU2b4", sceAbstractLocalUnknown_CGjnAIJU2b4_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_XArRxgQY_cg_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("XArRxgQY+cg", sceAbstractLocalUnknown_XArRxgQY_cg_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_mv0DAYhVdT8_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("mv0DAYhVdT8", sceAbstractLocalUnknown_mv0DAYhVdT8_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_TyTI4dfrUpk_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("TyTI4dfrUpk", sceAbstractLocalUnknown_TyTI4dfrUpk_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown__A0_F3ASPXQ_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("+A0+F3ASPXQ", sceAbstractLocalUnknown__A0_F3ASPXQ_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_KtO3l4R5GP8_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("KtO3l4R5GP8", sceAbstractLocalUnknown_KtO3l4R5GP8_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_7_OxGuuZnkM_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("7-OxGuuZnkM", sceAbstractLocalUnknown_7_OxGuuZnkM_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_5EbtsmF7TSc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("5EbtsmF7TSc", sceAbstractLocalUnknown_5EbtsmF7TSc_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown__5ID5YbnNjM_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("+5ID5YbnNjM", sceAbstractLocalUnknown__5ID5YbnNjM_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_wa7RuAVTdZw_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("wa7RuAVTdZw", sceAbstractLocalUnknown_wa7RuAVTdZw_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_7IQ862KCLk0_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("7IQ862KCLk0", sceAbstractLocalUnknown_7IQ862KCLk0_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_uaiGNR0Sbvc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("uaiGNR0Sbvc", sceAbstractLocalUnknown_uaiGNR0Sbvc_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_DGU0Qg_6p8M_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("DGU0Qg+6p8M", sceAbstractLocalUnknown_DGU0Qg_6p8M_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_HbbM72T9icI_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("HbbM72T9icI", sceAbstractLocalUnknown_HbbM72T9icI_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_VpVK5yiU1UE_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("VpVK5yiU1UE", sceAbstractLocalUnknown_VpVK5yiU1UE_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_Px3PC4lV3pc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Px3PC4lV3pc", sceAbstractLocalUnknown_Px3PC4lV3pc_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_JI2n0DRLfBM_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("JI2n0DRLfBM", sceAbstractLocalUnknown_JI2n0DRLfBM_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_21w78rpNbjY_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("21w78rpNbjY", sceAbstractLocalUnknown_21w78rpNbjY_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_Dj2WuKEtKsw_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Dj2WuKEtKsw", sceAbstractLocalUnknown_Dj2WuKEtKsw_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown__zhp5N_79Zo_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("-zhp5N+79Zo", sceAbstractLocalUnknown__zhp5N_79Zo_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_5GqRsNdzwwQ_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("5GqRsNdzwwQ", sceAbstractLocalUnknown_5GqRsNdzwwQ_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_xpT59kwSjy0_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("xpT59kwSjy0", sceAbstractLocalUnknown_xpT59kwSjy0_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_S_EGYMBGJq8_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("S+EGYMBGJq8", sceAbstractLocalUnknown_S_EGYMBGJq8_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_eTtdKzNrbjc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("eTtdKzNrbjc", sceAbstractLocalUnknown_eTtdKzNrbjc_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_c8RVn1N_Agc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("c8RVn1N-Agc", sceAbstractLocalUnknown_c8RVn1N_Agc_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_yvJjv5jHQdE_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("yvJjv5jHQdE", sceAbstractLocalUnknown_yvJjv5jHQdE_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_HrVr0FDsbc8_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("HrVr0FDsbc8", sceAbstractLocalUnknown_HrVr0FDsbc8_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_XmZD0up1Q8Q_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("XmZD0up1Q8Q", sceAbstractLocalUnknown_XmZD0up1Q8Q_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_vPzTqyJy2cE_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("vPzTqyJy2cE", sceAbstractLocalUnknown_vPzTqyJy2cE_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_grDD8PABX2g_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("grDD8PABX2g", sceAbstractLocalUnknown_grDD8PABX2g_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_SnBiExt9JLs_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("SnBiExt9JLs", sceAbstractLocalUnknown_SnBiExt9JLs_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_sHRmbEWM4rM_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("sHRmbEWM4rM", sceAbstractLocalUnknown_sHRmbEWM4rM_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_zLrVvtCBBuk_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("zLrVvtCBBuk", sceAbstractLocalUnknown_zLrVvtCBBuk_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_VxXBo11wZ68_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("VxXBo11wZ68", sceAbstractLocalUnknown_VxXBo11wZ68_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_FLD7Rf5nyE4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("FLD7Rf5nyE4", sceAbstractLocalUnknown_FLD7Rf5nyE4_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_QRUnq01DRc0_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("QRUnq01DRc0", sceAbstractLocalUnknown_QRUnq01DRc0_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_N0CijQdB1Jc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("N0CijQdB1Jc", sceAbstractLocalUnknown_N0CijQdB1Jc_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_h6txl_QaLvA_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("h6txl+QaLvA", sceAbstractLocalUnknown_h6txl_QaLvA_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_u_6z_j2wdjk_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("u+6z-j2wdjk", sceAbstractLocalUnknown_u_6z_j2wdjk_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_WPyTFrUZMxQ_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("WPyTFrUZMxQ", sceAbstractLocalUnknown_WPyTFrUZMxQ_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_yy12gayUXxw_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("yy12gayUXxw", sceAbstractLocalUnknown_yy12gayUXxw_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_5yChmiUJqt4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("5yChmiUJqt4", sceAbstractLocalUnknown_5yChmiUJqt4_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_GxYlcKD_B44_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("GxYlcKD-B44", sceAbstractLocalUnknown_GxYlcKD_B44_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_gSe1f2ITi7E_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("gSe1f2ITi7E", sceAbstractLocalUnknown_gSe1f2ITi7E_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_8QOmy_K3L2k_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("8QOmy+K3L2k", sceAbstractLocalUnknown_8QOmy_K3L2k_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_IrZg5RHoLGQ_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("IrZg5RHoLGQ", sceAbstractLocalUnknown_IrZg5RHoLGQ_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_Ul2GZtxXdTk_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Ul2GZtxXdTk", sceAbstractLocalUnknown_Ul2GZtxXdTk_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_2HZf301Pl98_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("2HZf301Pl98", sceAbstractLocalUnknown_2HZf301Pl98_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_e65fXqnAlg4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("e65fXqnAlg4", sceAbstractLocalUnknown_e65fXqnAlg4_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_RdHTTOCg41s_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("RdHTTOCg41s", sceAbstractLocalUnknown_RdHTTOCg41s_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_P3BsMTTfmZU_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("P3BsMTTfmZU", sceAbstractLocalUnknown_P3BsMTTfmZU_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_oTaaYntc8RM_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("oTaaYntc8RM", sceAbstractLocalUnknown_oTaaYntc8RM_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_5AL8k9c6Poc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("5AL8k9c6Poc", sceAbstractLocalUnknown_5AL8k9c6Poc_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_c72L8ORqV60_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("c72L8ORqV60", sceAbstractLocalUnknown_c72L8ORqV60_nid_no_patch);
int APS5_VABI sceAbstractLocalUnknown_rQhzp0Mu5m0_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("rQhzp0Mu5m0", sceAbstractLocalUnknown_rQhzp0Mu5m0_nid_no_patch);
}
+340 -1
View File
@@ -5,6 +5,345 @@
extern "C" {
APS5_DUMMY_FUN
int APS5_VABI sceAbstractTwitterUnknown_JMPK_1KGVfo_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("JMPK-1KGVfo", sceAbstractTwitterUnknown_JMPK_1KGVfo_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_p73mqupCtos_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("p73mqupCtos", sceAbstractTwitterUnknown_p73mqupCtos_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_gf3h8ObDkuI_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("gf3h8ObDkuI", sceAbstractTwitterUnknown_gf3h8ObDkuI_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_uW4bk_mPlM8_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("uW4bk+mPlM8", sceAbstractTwitterUnknown_uW4bk_mPlM8_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_bXW4ce_oHPA_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("bXW4ce-oHPA", sceAbstractTwitterUnknown_bXW4ce_oHPA_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_DWJep6U_MYQ_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("DWJep6U-MYQ", sceAbstractTwitterUnknown_DWJep6U_MYQ_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_y1e_omRUMhY_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("y1e+omRUMhY", sceAbstractTwitterUnknown_y1e_omRUMhY_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_EBRKLWTYXy4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("EBRKLWTYXy4", sceAbstractTwitterUnknown_EBRKLWTYXy4_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_oPzukphzAys_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("oPzukphzAys", sceAbstractTwitterUnknown_oPzukphzAys_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_p8qZEIwpBmM_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("p8qZEIwpBmM", sceAbstractTwitterUnknown_p8qZEIwpBmM_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_AMzjf2brlcw_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("AMzjf2brlcw", sceAbstractTwitterUnknown_AMzjf2brlcw_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_lfQMRAQl6kI_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("lfQMRAQl6kI", sceAbstractTwitterUnknown_lfQMRAQl6kI_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_kslGRG0HVL4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("kslGRG0HVL4", sceAbstractTwitterUnknown_kslGRG0HVL4_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_Dkk29mw5RF4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Dkk29mw5RF4", sceAbstractTwitterUnknown_Dkk29mw5RF4_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_1rt9PQJV64k_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("1rt9PQJV64k", sceAbstractTwitterUnknown_1rt9PQJV64k_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_ye4sPvqyPfM_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("ye4sPvqyPfM", sceAbstractTwitterUnknown_ye4sPvqyPfM_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_4VD0OuFSW04_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("4VD0OuFSW04", sceAbstractTwitterUnknown_4VD0OuFSW04_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_eVXr2Uj_TA0_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("eVXr2Uj+TA0", sceAbstractTwitterUnknown_eVXr2Uj_TA0_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_hRba2mQ9fss_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("hRba2mQ9fss", sceAbstractTwitterUnknown_hRba2mQ9fss_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_iA282fSjF30_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("iA282fSjF30", sceAbstractTwitterUnknown_iA282fSjF30_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_BEGvI6L3BqI_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("BEGvI6L3BqI", sceAbstractTwitterUnknown_BEGvI6L3BqI_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_0soubDsGzXw_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("0soubDsGzXw", sceAbstractTwitterUnknown_0soubDsGzXw_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_Bof69eeNCCw_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Bof69eeNCCw", sceAbstractTwitterUnknown_Bof69eeNCCw_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_qwFemTBSZnY_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("qwFemTBSZnY", sceAbstractTwitterUnknown_qwFemTBSZnY_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_2EoYjMBr3xs_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("2EoYjMBr3xs", sceAbstractTwitterUnknown_2EoYjMBr3xs_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_d2kMlNVjxC8_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("d2kMlNVjxC8", sceAbstractTwitterUnknown_d2kMlNVjxC8_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_exxKr58F43o_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("exxKr58F43o", sceAbstractTwitterUnknown_exxKr58F43o_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_Mnf5YJkQX7s_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Mnf5YJkQX7s", sceAbstractTwitterUnknown_Mnf5YJkQX7s_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_z0b3IxfaSbI_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("z0b3IxfaSbI", sceAbstractTwitterUnknown_z0b3IxfaSbI_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_ZIM7XSHmna4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("ZIM7XSHmna4", sceAbstractTwitterUnknown_ZIM7XSHmna4_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown__7Gi8U_26XU_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("-7Gi8U+26XU", sceAbstractTwitterUnknown__7Gi8U_26XU_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_ki9Tj7Fyq90_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("ki9Tj7Fyq90", sceAbstractTwitterUnknown_ki9Tj7Fyq90_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_Q2sTPN_hnYw_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Q2sTPN-hnYw", sceAbstractTwitterUnknown_Q2sTPN_hnYw_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_MBi5D9Wuwqo_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("MBi5D9Wuwqo", sceAbstractTwitterUnknown_MBi5D9Wuwqo_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_NvSKi_AG__g_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("NvSKi+AG++g", sceAbstractTwitterUnknown_NvSKi_AG__g_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_J_Z0oLcpiv8_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("J+Z0oLcpiv8", sceAbstractTwitterUnknown_J_Z0oLcpiv8_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_o7r_wKZNjw0_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("o7r+wKZNjw0", sceAbstractTwitterUnknown_o7r_wKZNjw0_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_TiDaUZArrIc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("TiDaUZArrIc", sceAbstractTwitterUnknown_TiDaUZArrIc_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_YVerJp_GbDc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("YVerJp-GbDc", sceAbstractTwitterUnknown_YVerJp_GbDc_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_eEr7LIMuChY_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("eEr7LIMuChY", sceAbstractTwitterUnknown_eEr7LIMuChY_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_RghnEC6_6KE_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("RghnEC6-6KE", sceAbstractTwitterUnknown_RghnEC6_6KE_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_4YOnvHQco2w_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("4YOnvHQco2w", sceAbstractTwitterUnknown_4YOnvHQco2w_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_E_bNjlNe1DU_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("E+bNjlNe1DU", sceAbstractTwitterUnknown_E_bNjlNe1DU_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_PkOxC__b9aM_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("PkOxC--b9aM", sceAbstractTwitterUnknown_PkOxC__b9aM_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_7EkyOOXfgDo_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("7EkyOOXfgDo", sceAbstractTwitterUnknown_7EkyOOXfgDo_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_G8VIS1QkWg4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("G8VIS1QkWg4", sceAbstractTwitterUnknown_G8VIS1QkWg4_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_b7klmKCsFQk_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("b7klmKCsFQk", sceAbstractTwitterUnknown_b7klmKCsFQk_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_osMzBigeiAM_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("osMzBigeiAM", sceAbstractTwitterUnknown_osMzBigeiAM_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_3wCEN9TNBU4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("3wCEN9TNBU4", sceAbstractTwitterUnknown_3wCEN9TNBU4_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_gERQO7gDxhs_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("gERQO7gDxhs", sceAbstractTwitterUnknown_gERQO7gDxhs_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown__dPfbWlRgmU_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("+dPfbWlRgmU", sceAbstractTwitterUnknown__dPfbWlRgmU_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_DutvlYFO68Y_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("DutvlYFO68Y", sceAbstractTwitterUnknown_DutvlYFO68Y_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_wLljjEtN3vY_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("wLljjEtN3vY", sceAbstractTwitterUnknown_wLljjEtN3vY_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_QLzJT6sH5nI_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("QLzJT6sH5nI", sceAbstractTwitterUnknown_QLzJT6sH5nI_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_IqK5rvqsy9A_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("IqK5rvqsy9A", sceAbstractTwitterUnknown_IqK5rvqsy9A_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_5ovK_oroKlY_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("5ovK+oroKlY", sceAbstractTwitterUnknown_5ovK_oroKlY_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_I7rDjJe4Eok_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("I7rDjJe4Eok", sceAbstractTwitterUnknown_I7rDjJe4Eok_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_5KhQZQnPN50_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("5KhQZQnPN50", sceAbstractTwitterUnknown_5KhQZQnPN50_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_fTfAEGjfLoQ_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("fTfAEGjfLoQ", sceAbstractTwitterUnknown_fTfAEGjfLoQ_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_dwASDRq1150_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("dwASDRq1150", sceAbstractTwitterUnknown_dwASDRq1150_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_nLOlVSvvxRc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("nLOlVSvvxRc", sceAbstractTwitterUnknown_nLOlVSvvxRc_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_4d9S8jMy6Ac_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("4d9S8jMy6Ac", sceAbstractTwitterUnknown_4d9S8jMy6Ac_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_MljG2BSqkMY_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("MljG2BSqkMY", sceAbstractTwitterUnknown_MljG2BSqkMY_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_Jzj9ZTh5m1I_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Jzj9ZTh5m1I", sceAbstractTwitterUnknown_Jzj9ZTh5m1I_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_M8XjMzOr1aY_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("M8XjMzOr1aY", sceAbstractTwitterUnknown_M8XjMzOr1aY_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_PUV6qvRaqCE_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("PUV6qvRaqCE", sceAbstractTwitterUnknown_PUV6qvRaqCE_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_wzzIp0t1OzU_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("wzzIp0t1OzU", sceAbstractTwitterUnknown_wzzIp0t1OzU_nid_no_patch);
int APS5_VABI sceAbstractTwitterUnknown_dP_3UFf8BBw_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("dP+3UFf8BBw", sceAbstractTwitterUnknown_dP_3UFf8BBw_nid_no_patch);
}
+220
View File
@@ -452,4 +452,224 @@ int APS5_VABI libSceAcmUnknown_ngDRON91_plus__minus_Y_nid_no_patch() {
}
APS5_EXPORT("ngDRON91+-Y", libSceAcmUnknown_ngDRON91_plus__minus_Y_nid_no_patch);
int APS5_VABI libSceAcmUnknown__plus_GEfQURRfNQ_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("+GEfQURRfNQ", libSceAcmUnknown__plus_GEfQURRfNQ_nid_no_patch);
int APS5_VABI libSceAcmUnknown__plus_v8StWu8ce0_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("+v8StWu8ce0", libSceAcmUnknown__plus_v8StWu8ce0_nid_no_patch);
int APS5_VABI libSceAcmUnknown_05vZ_minus_d35iOU_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("05vZ-d35iOU", libSceAcmUnknown_05vZ_minus_d35iOU_nid_no_patch);
int APS5_VABI libSceAcmUnknown_29f5DNJTpME_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("29f5DNJTpME", libSceAcmUnknown_29f5DNJTpME_nid_no_patch);
int APS5_VABI libSceAcmUnknown_2IuXRVnP_plus_E4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("2IuXRVnP+E4", libSceAcmUnknown_2IuXRVnP_plus_E4_nid_no_patch);
int APS5_VABI libSceAcmUnknown_3odf3m8_minus_sTA_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("3odf3m8-sTA", libSceAcmUnknown_3odf3m8_minus_sTA_nid_no_patch);
int APS5_VABI libSceAcmUnknown_3ukt3_minus_zPLo4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("3ukt3-zPLo4", libSceAcmUnknown_3ukt3_minus_zPLo4_nid_no_patch);
int APS5_VABI libSceAcmUnknown_3v8OJlWuVoI_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("3v8OJlWuVoI", libSceAcmUnknown_3v8OJlWuVoI_nid_no_patch);
int APS5_VABI libSceAcmUnknown_7aoLbYKdti0_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("7aoLbYKdti0", libSceAcmUnknown_7aoLbYKdti0_nid_no_patch);
int APS5_VABI libSceAcmUnknown_ADVHzAQRzvI_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("ADVHzAQRzvI", libSceAcmUnknown_ADVHzAQRzvI_nid_no_patch);
int APS5_VABI libSceAcmUnknown_BKv16PL_plus_en4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("BKv16PL+en4", libSceAcmUnknown_BKv16PL_plus_en4_nid_no_patch);
int APS5_VABI libSceAcmUnknown_FcV33YZNrZY_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("FcV33YZNrZY", libSceAcmUnknown_FcV33YZNrZY_nid_no_patch);
int APS5_VABI libSceAcmUnknown_HRzaZ03MB4c_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("HRzaZ03MB4c", libSceAcmUnknown_HRzaZ03MB4c_nid_no_patch);
int APS5_VABI libSceAcmUnknown_Jd95if4IDsc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Jd95if4IDsc", libSceAcmUnknown_Jd95if4IDsc_nid_no_patch);
int APS5_VABI libSceAcmUnknown_KUQB9006te4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("KUQB9006te4", libSceAcmUnknown_KUQB9006te4_nid_no_patch);
int APS5_VABI libSceAcmUnknown_KeUzwnv2znk_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("KeUzwnv2znk", libSceAcmUnknown_KeUzwnv2znk_nid_no_patch);
int APS5_VABI libSceAcmUnknown_LOAWrRdCsuI_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("LOAWrRdCsuI", libSceAcmUnknown_LOAWrRdCsuI_nid_no_patch);
int APS5_VABI libSceAcmUnknown_NLMqc049bmY_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("NLMqc049bmY", libSceAcmUnknown_NLMqc049bmY_nid_no_patch);
int APS5_VABI libSceAcmUnknown_Nir1S45p_plus_k0_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Nir1S45p+k0", libSceAcmUnknown_Nir1S45p_plus_k0_nid_no_patch);
int APS5_VABI libSceAcmUnknown_OXsTjBOwUcs_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("OXsTjBOwUcs", libSceAcmUnknown_OXsTjBOwUcs_nid_no_patch);
int APS5_VABI libSceAcmUnknown_QGrI0Du9IYs_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("QGrI0Du9IYs", libSceAcmUnknown_QGrI0Du9IYs_nid_no_patch);
int APS5_VABI libSceAcmUnknown_RJGnXst7vUQ_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("RJGnXst7vUQ", libSceAcmUnknown_RJGnXst7vUQ_nid_no_patch);
int APS5_VABI libSceAcmUnknown_RbJwbKtBy48_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("RbJwbKtBy48", libSceAcmUnknown_RbJwbKtBy48_nid_no_patch);
int APS5_VABI libSceAcmUnknown_S_plus_W03U2x0VU_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("S+W03U2x0VU", libSceAcmUnknown_S_plus_W03U2x0VU_nid_no_patch);
int APS5_VABI libSceAcmUnknown_UK03t9UoOWU_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("UK03t9UoOWU", libSceAcmUnknown_UK03t9UoOWU_nid_no_patch);
int APS5_VABI libSceAcmUnknown_UnPujhtY1e4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("UnPujhtY1e4", libSceAcmUnknown_UnPujhtY1e4_nid_no_patch);
int APS5_VABI libSceAcmUnknown_VG31URxchBE_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("VG31URxchBE", libSceAcmUnknown_VG31URxchBE_nid_no_patch);
int APS5_VABI libSceAcmUnknown_Zea6TpIIcuw_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Zea6TpIIcuw", libSceAcmUnknown_Zea6TpIIcuw_nid_no_patch);
int APS5_VABI libSceAcmUnknown_cMDARlsd0IU_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("cMDARlsd0IU", libSceAcmUnknown_cMDARlsd0IU_nid_no_patch);
int APS5_VABI libSceAcmUnknown_cQlAR2dYW1U_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("cQlAR2dYW1U", libSceAcmUnknown_cQlAR2dYW1U_nid_no_patch);
int APS5_VABI libSceAcmUnknown_dLDAIKe6QPI_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("dLDAIKe6QPI", libSceAcmUnknown_dLDAIKe6QPI_nid_no_patch);
int APS5_VABI libSceAcmUnknown_l2XvCIV50_minus_Q_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("l2XvCIV50-Q", libSceAcmUnknown_l2XvCIV50_minus_Q_nid_no_patch);
int APS5_VABI libSceAcmUnknown_lbezsUkPojs_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("lbezsUkPojs", libSceAcmUnknown_lbezsUkPojs_nid_no_patch);
int APS5_VABI libSceAcmUnknown_mXntN6cqsj4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("mXntN6cqsj4", libSceAcmUnknown_mXntN6cqsj4_nid_no_patch);
int APS5_VABI libSceAcmUnknown_n4spvEiudjI_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("n4spvEiudjI", libSceAcmUnknown_n4spvEiudjI_nid_no_patch);
int APS5_VABI libSceAcmUnknown_ozmQIEUnkNE_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("ozmQIEUnkNE", libSceAcmUnknown_ozmQIEUnkNE_nid_no_patch);
int APS5_VABI libSceAcmUnknown_p8H6QiaoXnY_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("p8H6QiaoXnY", libSceAcmUnknown_p8H6QiaoXnY_nid_no_patch);
int APS5_VABI libSceAcmUnknown_reqnnLJj9lo_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("reqnnLJj9lo", libSceAcmUnknown_reqnnLJj9lo_nid_no_patch);
int APS5_VABI libSceAcmUnknown_sAxJPDwmsBg_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("sAxJPDwmsBg", libSceAcmUnknown_sAxJPDwmsBg_nid_no_patch);
int APS5_VABI libSceAcmUnknown_sSI1ZHQh9as_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("sSI1ZHQh9as", libSceAcmUnknown_sSI1ZHQh9as_nid_no_patch);
int APS5_VABI libSceAcmUnknown_sYPAONMjsz4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("sYPAONMjsz4", libSceAcmUnknown_sYPAONMjsz4_nid_no_patch);
int APS5_VABI libSceAcmUnknown_sn178_plus_KL4FI_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("sn178+KL4FI", libSceAcmUnknown_sn178_plus_KL4FI_nid_no_patch);
int APS5_VABI libSceAcmUnknown_vsxwtmT9mbY_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("vsxwtmT9mbY", libSceAcmUnknown_vsxwtmT9mbY_nid_no_patch);
int APS5_VABI libSceAcmUnknown_zzN06JMvPFc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("zzN06JMvPFc", libSceAcmUnknown_zzN06JMvPFc_nid_no_patch);
}
@@ -9,5 +9,49 @@ int APS5_VABI libSceAcmUnknown_DvsnlQr4yyk_nid_no_patch();
int APS5_VABI libSceAcmUnknown_PLNywpi1zR4_nid_no_patch();
int APS5_VABI libSceAcmUnknown_YpYvibqaqz0_nid_no_patch();
int APS5_VABI libSceAcmUnknown_ngDRON91_plus__minus_Y_nid_no_patch();
int APS5_VABI libSceAcmUnknown__plus_GEfQURRfNQ_nid_no_patch();
int APS5_VABI libSceAcmUnknown__plus_v8StWu8ce0_nid_no_patch();
int APS5_VABI libSceAcmUnknown_05vZ_minus_d35iOU_nid_no_patch();
int APS5_VABI libSceAcmUnknown_29f5DNJTpME_nid_no_patch();
int APS5_VABI libSceAcmUnknown_2IuXRVnP_plus_E4_nid_no_patch();
int APS5_VABI libSceAcmUnknown_3odf3m8_minus_sTA_nid_no_patch();
int APS5_VABI libSceAcmUnknown_3ukt3_minus_zPLo4_nid_no_patch();
int APS5_VABI libSceAcmUnknown_3v8OJlWuVoI_nid_no_patch();
int APS5_VABI libSceAcmUnknown_7aoLbYKdti0_nid_no_patch();
int APS5_VABI libSceAcmUnknown_ADVHzAQRzvI_nid_no_patch();
int APS5_VABI libSceAcmUnknown_BKv16PL_plus_en4_nid_no_patch();
int APS5_VABI libSceAcmUnknown_FcV33YZNrZY_nid_no_patch();
int APS5_VABI libSceAcmUnknown_HRzaZ03MB4c_nid_no_patch();
int APS5_VABI libSceAcmUnknown_Jd95if4IDsc_nid_no_patch();
int APS5_VABI libSceAcmUnknown_KUQB9006te4_nid_no_patch();
int APS5_VABI libSceAcmUnknown_KeUzwnv2znk_nid_no_patch();
int APS5_VABI libSceAcmUnknown_LOAWrRdCsuI_nid_no_patch();
int APS5_VABI libSceAcmUnknown_NLMqc049bmY_nid_no_patch();
int APS5_VABI libSceAcmUnknown_Nir1S45p_plus_k0_nid_no_patch();
int APS5_VABI libSceAcmUnknown_OXsTjBOwUcs_nid_no_patch();
int APS5_VABI libSceAcmUnknown_QGrI0Du9IYs_nid_no_patch();
int APS5_VABI libSceAcmUnknown_RJGnXst7vUQ_nid_no_patch();
int APS5_VABI libSceAcmUnknown_RbJwbKtBy48_nid_no_patch();
int APS5_VABI libSceAcmUnknown_S_plus_W03U2x0VU_nid_no_patch();
int APS5_VABI libSceAcmUnknown_UK03t9UoOWU_nid_no_patch();
int APS5_VABI libSceAcmUnknown_UnPujhtY1e4_nid_no_patch();
int APS5_VABI libSceAcmUnknown_VG31URxchBE_nid_no_patch();
int APS5_VABI libSceAcmUnknown_Zea6TpIIcuw_nid_no_patch();
int APS5_VABI libSceAcmUnknown_cMDARlsd0IU_nid_no_patch();
int APS5_VABI libSceAcmUnknown_cQlAR2dYW1U_nid_no_patch();
int APS5_VABI libSceAcmUnknown_dLDAIKe6QPI_nid_no_patch();
int APS5_VABI libSceAcmUnknown_l2XvCIV50_minus_Q_nid_no_patch();
int APS5_VABI libSceAcmUnknown_lbezsUkPojs_nid_no_patch();
int APS5_VABI libSceAcmUnknown_mXntN6cqsj4_nid_no_patch();
int APS5_VABI libSceAcmUnknown_n4spvEiudjI_nid_no_patch();
int APS5_VABI libSceAcmUnknown_ozmQIEUnkNE_nid_no_patch();
int APS5_VABI libSceAcmUnknown_p8H6QiaoXnY_nid_no_patch();
int APS5_VABI libSceAcmUnknown_reqnnLJj9lo_nid_no_patch();
int APS5_VABI libSceAcmUnknown_sAxJPDwmsBg_nid_no_patch();
int APS5_VABI libSceAcmUnknown_sSI1ZHQh9as_nid_no_patch();
int APS5_VABI libSceAcmUnknown_sYPAONMjsz4_nid_no_patch();
int APS5_VABI libSceAcmUnknown_sn178_plus_KL4FI_nid_no_patch();
int APS5_VABI libSceAcmUnknown_vsxwtmT9mbY_nid_no_patch();
int APS5_VABI libSceAcmUnknown_zzN06JMvPFc_nid_no_patch();
}
@@ -6,13 +6,13 @@
#include <cstddef>
#include <cstring>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
namespace {
constexpr std::uint32_t OpcodeNop = 0x10;
constexpr std::uint32_t ActivePacketWords = 18;
constexpr std::uint32_t CompletePacketWords = 12;
constexpr std::uint32_t InactivePacketWords = 9;
constexpr std::uint32_t MaxWorkloadId = 63;
constexpr std::uint32_t MaxActiveCount = 63;
@@ -57,8 +57,9 @@ uint32_t* APS5_VABI sceAgcDcbSetWorkloadsActive(CommandBuffer* buf, uint32_t str
uint32_t* APS5_VABI sceAgcDcbSetWorkloadStreamInactive(CommandBuffer* buf, uint32_t streamId) {
if (buf == nullptr || !AgcDriverWorkloadStreamRegistered_nid_postfix(streamId)) return nullptr;
NotImplemented_nid_no_patch(__func__);
return nullptr;
auto* packet = NewPacket(buf, InactivePacketWords, __func__);
packet[1] = streamId;
return packet;
}
}
@@ -6,9 +6,11 @@
#include <map>
#include <mutex>
#include <stdexcept>
#include <span>
#include <string>
#include <cstdint>
#include <cstddef>
#include <utility>
#include <vector>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
@@ -28,6 +30,8 @@ constexpr std::uint32_t SPI_SHADER_PGM_RSRC1_HS = 0x10Au;
constexpr std::uint32_t SPI_SHADER_PGM_RSRC2_HS = 0x10Bu;
constexpr std::uint32_t SCodeEnd = 0xbf9f0000u;
constexpr std::uint32_t SNop = 0xbf800000u;
constexpr std::uint32_t SGetpcMask = 0xff80ff00u;
constexpr std::uint32_t SGetpc = 0xbe801f00u;
constexpr std::uint32_t SSetpcS6 = 0xbe802006u;
constexpr std::uint32_t SSwappcNullS6 = 0xbefd2106u;
constexpr std::size_t FusedCodeAlignment = 256;
@@ -62,6 +66,10 @@ void MergeMax(ShaderRegister& dst, const ShaderRegister& src, std::uint32_t shif
struct GeometryLayout {
std::uint32_t frontBytes;
std::size_t constantsOffset;
std::size_t constantsBytes;
std::size_t constantsSource;
std::vector<std::pair<std::size_t, std::uint32_t>> literals;
std::size_t backOffset;
std::size_t codeBytes;
std::vector<ShaderRegister> sh;
@@ -89,11 +97,16 @@ std::size_t AlignUp(std::size_t value, std::size_t alignment) {
void ValidateGeometryHalf(const char* function, const Shader* shader) {
if (shader->file_header != SHADER_FILE_HEADER_MAGIC || shader->version != SHADER_VERSION) Fail(function, "invalid shader header or version");
if (shader->code == nullptr || shader->shader_size == 0 || (shader->shader_size & 3u) != 0) Fail(function, "invalid shader half code");
if (shader->embedded_constant_buffer_size_dqw != 0) Fail(function, "fusing halves with an embedded constant buffer is not implemented");
if ((shader->num_sh_registers != 0 && shader->sh_registers == nullptr) || (shader->num_cx_registers != 0 && shader->cx_registers == nullptr)) Fail(function, "shader half registers missing");
}
std::uint32_t FrontProgramBytes(const char* function, const Shader* front) {
struct FrontProgram {
std::uint32_t programBytes;
std::uint32_t codeBytes;
std::size_t trailer;
};
FrontProgram FrontProgramBytes(const char* function, const Shader* front) {
const auto* bytes = static_cast<const std::uint8_t*>(const_cast<const void*>(front->code));
const std::size_t size = front->shader_size;
if (size < TrailerCodeBytesOffset + sizeof(std::uint32_t)) Fail(function, "front half has no program trailer");
@@ -116,7 +129,36 @@ std::uint32_t FrontProgramBytes(const char* function, const Shader* front) {
};
while (end > 0 && word(end - 1) == SCodeEnd) --end;
if (end == 0 || (word(end - 1) != SSetpcS6 && word(end - 1) != SSwappcNullS6)) Fail(function, "front half does not end with s_setpc_b64 s[6:7] or s_swappc_b64 null, s[6:7]");
return static_cast<std::uint32_t>((end - 1) * 4);
return {static_cast<std::uint32_t>((end - 1) * 4), codeBytes, trailer};
}
std::vector<std::pair<std::size_t, std::uint32_t>> ConstantLiterals(const char* function, const Shader* front, std::uint32_t programBytes, std::size_t constants, std::size_t constantsBytes, std::size_t moved) {
const auto* bytes = static_cast<const std::uint8_t*>(const_cast<const void*>(front->code));
const auto word = [&](std::size_t index) {
std::uint32_t value = 0;
std::memcpy(&value, bytes + index * 4, sizeof(value));
return value;
};
std::vector<std::pair<std::size_t, std::uint32_t>> literals;
const std::size_t words = programBytes / 4;
const std::span<const std::uint32_t> code(reinterpret_cast<const std::uint32_t*>(bytes), words);
const auto length = [&](std::size_t index) -> std::size_t {
const auto count = AgcDriverInstructionWords_nid_postfix(code, static_cast<std::uint32_t>(index));
if (count == 0) Fail(function, "front half with an embedded constant buffer holds an instruction that cannot be decoded at word " + std::to_string(index));
return count;
};
for (std::size_t i = 0; i < words; i += length(i)) {
if ((word(i) & SGetpcMask) != SGetpc) continue;
const auto reg = (word(i) >> 16u) & 0x7fu;
if (i + 3 >= words || word(i + 1) != (0x80000000u | (reg << 16u) | (reg << 8u) | 0xffu) || word(i + 3) != (0x82000000u | ((reg + 1u) << 16u) | ((reg + 1u) << 8u) | 0x80u)) {
Fail(function, "front half reads its embedded constant buffer through an s_getpc_b64 not followed by s_add_u32 with a literal and s_addc_u32 0");
}
const auto target = (i + 1) * 4 + std::size_t{word(i + 2)};
if (target < programBytes) continue;
if (target < constants || target >= constants + constantsBytes) Fail(function, "front half's s_getpc_b64 offset points outside its program and embedded constant buffer");
literals.emplace_back((i + 2) * 4, static_cast<std::uint32_t>(word(i + 2) + (moved - constants)));
}
return literals;
}
std::array<std::uint32_t, 2> mergeGeometryResources(std::uint32_t frontRsrc1, std::uint32_t frontRsrc2, std::uint32_t backRsrc1, std::uint32_t backRsrc2) {
@@ -145,9 +187,19 @@ GeometryLayout ComputeGeometryLayout(const char* function, const Shader* front,
ValidateGeometryHalf(function, back);
ValidateGeometryHalf(function, front);
GeometryLayout layout{};
layout.frontBytes = FrontProgramBytes(function, front);
if (back->embedded_constant_buffer_size_dqw != 0) Fail(function, "fusing a back half with an embedded constant buffer is not implemented");
const auto program = FrontProgramBytes(function, front);
layout.frontBytes = program.programBytes;
layout.backOffset = AlignUp(layout.frontBytes, FusedCodeAlignment);
layout.codeBytes = layout.backOffset + back->shader_size;
layout.constantsBytes = std::size_t{front->embedded_constant_buffer_size_dqw} * 16u;
if (layout.constantsBytes != 0) {
layout.constantsSource = program.codeBytes;
if (layout.constantsSource + layout.constantsBytes > program.trailer) Fail(function, "front half's embedded constant buffer runs into its program trailer");
layout.constantsOffset = AlignUp(layout.codeBytes, 16);
layout.literals = ConstantLiterals(function, front, layout.frontBytes, layout.constantsSource, layout.constantsBytes, layout.constantsOffset);
layout.codeBytes = layout.constantsOffset + layout.constantsBytes;
}
const auto* frontRsrc1 = FindHalfRegister(front, SPI_SHADER_PGM_RSRC1_GS);
const auto* frontRsrc2 = FindHalfRegister(front, SPI_SHADER_PGM_RSRC2_GS);
if (frontRsrc1 == nullptr || frontRsrc2 == nullptr) Fail(function, "front half has no GS resource registers");
@@ -211,6 +263,7 @@ std::vector<std::uint8_t> FusionKey(const Shader* front, const Shader* back, con
AppendBytes(key, back, headerBytes);
AppendBytes(key, const_cast<const void*>(front->code), layout.frontBytes);
AppendBytes(key, const_cast<const void*>(back->code), back->shader_size);
if (layout.constantsBytes != 0) AppendBytes(key, static_cast<const std::uint8_t*>(const_cast<const void*>(front->code)) + layout.constantsSource, layout.constantsBytes);
AppendBytes(key, layout.sh.data(), layout.sh.size() * sizeof(ShaderRegister));
AppendBytes(key, layout.cx.data(), layout.cx.size() * sizeof(ShaderRegister));
AppendBytes(key, back->specials, back->special_sizes_bytes);
@@ -232,6 +285,11 @@ FusedProgram BuildFusedProgram(const char* fn, const Shader* front, const Shader
std::memcpy(memory, const_cast<const void*>(front->code), layout.frontBytes);
for (std::size_t offset = layout.frontBytes; offset < layout.backOffset; offset += sizeof(SNop)) std::memcpy(memory + offset, &SNop, sizeof(SNop));
std::memcpy(memory + layout.backOffset, const_cast<const void*>(back->code), back->shader_size);
if (layout.constantsBytes != 0) {
for (std::size_t offset = layout.backOffset + back->shader_size; offset < layout.constantsOffset; ++offset) memory[offset] = 0;
std::memcpy(memory + layout.constantsOffset, static_cast<const std::uint8_t*>(const_cast<const void*>(front->code)) + layout.constantsSource, layout.constantsBytes);
for (const auto& [offset, literal] : layout.literals) std::memcpy(memory + offset, &literal, sizeof(literal));
}
SetProgramAddress(layout.sh, SPI_SHADER_PGM_LO_GS, base + layout.backOffset);
if (PatchProgramAddressRegister(layout.sh.data(), static_cast<std::uint32_t>(layout.sh.size()), static_cast<std::uint8_t>(ShaderBinaryType::Gs), base) != 0) Fail(fn, "fused program address patch failed");
auto* sh = reinterpret_cast<ShaderRegister*>(memory + layout.shOffset);
@@ -11,6 +11,7 @@ constexpr int GRAPHICS5_ERROR_INVALID_STATIC_BUFFER = static_cast<int>(0x8a6c000
constexpr std::uint32_t StaticBufferCount = 6;
constexpr std::size_t StaticBufferBytes = 16;
constexpr std::size_t StaticQwordOffset = 16;
constexpr std::uint32_t StaticQwordCount = static_cast<std::uint32_t>((StaticBufferCount * StaticBufferBytes - StaticQwordOffset) / sizeof(std::uint64_t));
std::uint8_t* StaticTable() {
return static_cast<std::uint8_t*>(AgcDriverStaticTable_nid_postfix());
@@ -33,11 +34,13 @@ int APS5_VABI sceAgcGetStaticBuffer(std::uint32_t index, void* buffer) {
}
int APS5_VABI sceAgcSetStaticQword(std::uint32_t index, std::uint64_t value) {
if (index >= StaticQwordCount) return GRAPHICS5_ERROR_INVALID_STATIC_BUFFER;
std::memcpy(StaticTable() + StaticQwordOffset + std::size_t{index} * sizeof(value), &value, sizeof(value));
return 0;
}
int APS5_VABI sceAgcGetStaticQword(std::uint32_t index, std::uint64_t* value) {
if (index >= StaticQwordCount) return GRAPHICS5_ERROR_INVALID_STATIC_BUFFER;
std::memcpy(value, StaticTable() + StaticQwordOffset + std::size_t{index} * sizeof(*value), sizeof(*value));
return 0;
}
@@ -1,4 +1,5 @@
#include "prx/libSceAgc/Patch/include/WaitRegMem.hpp"
#include "prx/libSceAgc/include/Agc.hpp"
#include "prx/libSceAgc/Command/include/Memory.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
@@ -95,4 +96,13 @@ int APS5_VABI sceAgcAsyncWriteDataPatchSetCachePolicy(std::uint32_t* cmd, std::u
return SetWriteDataCachePolicy(cmd, cachePolicy, __func__);
}
int APS5_VABI sceAgcAcquireMemSetEngine(std::uint32_t* packet, std::uint8_t engine) {
Agc::Command::CheckAddress(reinterpret_cast<std::uintptr_t>(packet), 4, __func__);
if (((packet[0] >> 8u) & 0xffu) != 0x58u) {
return static_cast<int>(0x8a6c000c);
}
packet[1] = (packet[1] & 0x7fffffffu) | (static_cast<std::uint32_t>(engine) << 31u);
return 0;
}
}
@@ -6,11 +6,6 @@
extern "C" {
int APS5_VABI sceAgcAcquireMemSetEngine(std::uint32_t* packet, std::uint8_t engine) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcCbMemsetExclusive(CommandBuffer* buffer, void* destination, const void* pattern, std::uint64_t size) {
NotImplemented_nid_no_patch(__func__);
return 0;
+88 -1
View File
@@ -324,7 +324,10 @@ void testWorkloads() {
const auto* complete = sceAgcDcbSetWorkloadComplete(&dcb.buffer, 1, 33);
check(complete == dcb.words.data() + 18 && complete[0] == Agc::Command::Header(0x10, 12, 0) && complete[1] == 1 && complete[2] == 33 && complete[3] == 0xffffffffu && complete[4] == 0xfffffffdu, "workload complete packet");
for (std::uint32_t word = 5; word < 12; ++word) check(complete[word] == 0, "workload complete packet tail is not zero");
check(dcb.buffer.cursor_up == dcb.words.data() + 30, "incorrect workload cursor advance");
const auto* inactive = sceAgcDcbSetWorkloadStreamInactive(&dcb.buffer, 1);
check(inactive == dcb.words.data() + 30 && inactive[0] == Agc::Command::Header(0x10, 9, 0) && inactive[1] == 1, "workload stream inactive packet");
for (std::uint32_t word = 2; word < 9; ++word) check(inactive[word] == 0, "workload stream inactive packet tail is not zero");
check(dcb.buffer.cursor_up == dcb.words.data() + 39, "incorrect workload cursor advance");
const std::uint32_t duplicate[2] = {5, 5};
const std::uint32_t outOfRange[1] = {64};
const std::uint32_t top[1] = {63};
@@ -412,6 +415,45 @@ void testWorkloadStreams() {
check(sceAgcAcbSetWorkloadComplete(&registered.buffer, 1, 3) == nullptr, "ACB workload complete packet after unregistration");
}
void testDrawPackets() {
Storage indirect;
const auto* draw = sceAgcDcbDrawIndirect(&indirect.buffer, 0x40, 0);
const std::array<std::uint32_t, 5> indirectExpected{0xc0032400u, 0x40, 0x280, 0x280, 2};
check(draw == indirect.words.data() && std::equal(indirectExpected.begin(), indirectExpected.end(), indirect.words.begin()), "DRAW_INDIRECT packet mismatch");
Storage flagged;
sceAgcDcbDrawIndirect(&flagged.buffer, 0, 0x100);
sceAgcDcbDrawIndirect(&flagged.buffer, 0, 0x100000100ull);
check(flagged.words[4] == 0x22u && flagged.words[9] == 2, "DRAW_INDIRECT initiator flags mismatch");
Storage offset;
sceAgcDcbDrawIndexOffset(&offset.buffer, 16, 0, 0);
sceAgcDcbDrawIndexOffset(&offset.buffer, 16, 9, 0);
const std::array<std::uint32_t, 10> offsetExpected{0xc0033500u, 1, 16, 0, 0, 0xc0033500u, 9, 16, 9, 0};
check(std::equal(offsetExpected.begin(), offsetExpected.end(), offset.words.begin()), "DRAW_INDEX_OFFSET_2 packet mismatch");
Storage instances;
sceAgcDcbSetNumInstances(&instances.buffer, 3);
check(instances.words[0] == 0xc0002f00u && instances.words[1] == 3, "NUM_INSTANCES packet mismatch");
Storage size;
sceAgcDcbSetIndexSize(&size.buffer, 1, 2);
sceAgcDcbSetIndexSize_0600(&size.buffer, 2, 3, 1);
const std::array<std::uint32_t, 6> sizeExpected{0xc0017a00u, 0x20000243u, 0x481u, 0xc0017a00u, 0x20000243u, 0x44c2u};
check(std::equal(sizeExpected.begin(), sizeExpected.end(), size.words.begin()), "index size packet mismatch");
Storage rejected;
rejected.words.fill(0xa5a5a5a5u);
const auto rejectedWords = rejected.words;
const auto* rejectedCursor = rejected.buffer.cursor_up;
expectFailure([&] { sceAgcDcbDrawIndirect(&rejected.buffer, 2, 0); });
check(rejected.words == rejectedWords && rejected.buffer.cursor_up == rejectedCursor, "a refused packet changed the command buffer");
expectFailure([&] { sceAgcDcbDrawIndirect(&rejected.buffer, 0, 0x200000000ull); });
check(rejected.words == rejectedWords && rejected.buffer.cursor_up == rejectedCursor, "a refused packet changed the command buffer");
expectFailure([&] { sceAgcDcbSetIndexSize(&rejected.buffer, 3, 0); });
check(rejected.words == rejectedWords && rejected.buffer.cursor_up == rejectedCursor, "a refused packet changed the command buffer");
expectFailure([&] { sceAgcDcbSetIndexSize(&rejected.buffer, 0, 4); });
check(rejected.words == rejectedWords && rejected.buffer.cursor_up == rejectedCursor, "a refused packet changed the command buffer");
expectFailure([&] { sceAgcDcbSetIndexSize_0600(&rejected.buffer, 0, 0, 2); });
check(rejected.words == rejectedWords && rejected.buffer.cursor_up == rejectedCursor, "a refused packet changed the command buffer");
check(sceAgcDcbDrawIndirectGetSize() == 20 && sceAgcDcbDrawIndexOffsetGetSize() == 20 && sceAgcDcbSetNumInstancesGetSize() == 8 && sceAgcDcbSetIndexSizeGetSize() == 12, "draw packet sizes");
}
void testIndexBuffer() {
Storage storage;
alignas(4) std::uint16_t indices[2]{};
@@ -714,6 +756,50 @@ void testMemory() {
const auto beforeMask = storage.words;
expectFailure([&] { sceAgcWaitRegMemPatchMask(packet + 4, 1); });
check(storage.words == beforeMask, "invalid mask patch modified packet memory");
Storage acquireStorage;
auto* acquire = sceAgcDcbAcquireMem(&acquireStorage.buffer, 0, 0x1234u, 0x567u, nullptr, 0x1000, 0);
check(acquire[0] == Agc::Command::Header(0x58u, 8), "acquire mem header mismatch");
check(acquire[1] == 0x1234u, "acquire mem engine bit was set");
check(sceAgcAcquireMemSetEngine(acquire, 1) == 0, "sceAgcAcquireMemSetEngine failed");
check(acquire[1] == 0x80001234u, "acquire mem engine bit was not set to 1");
check(sceAgcAcquireMemSetEngine(acquire, 0) == 0, "sceAgcAcquireMemSetEngine failed");
check(acquire[1] == 0x1234u, "acquire mem engine bit was not cleared to 0");
check(sceAgcAcquireMemSetEngine(acquire, 1) == 0, "sceAgcAcquireMemSetEngine failed");
check(acquire[1] == 0x80001234u, "acquire mem engine bit was not set to 1");
check(sceAgcAcquireMemSetEngine(acquire, 2) == 0, "sceAgcAcquireMemSetEngine failed with engine 2");
check(acquire[1] == 0x1234u, "engine 2 did not clear the engine bit");
check(sceAgcAcquireMemSetEngine(acquire, 3) == 0, "sceAgcAcquireMemSetEngine failed with engine 3");
check(acquire[1] == 0x80001234u, "engine 3 did not set the engine bit");
check(sceAgcAcquireMemSetEngine(acquire, 4) == 0, "sceAgcAcquireMemSetEngine failed with engine 4");
check(acquire[1] == 0x1234u, "engine 4 did not clear the engine bit");
check(sceAgcAcquireMemSetEngine(acquire, static_cast<std::uint8_t>(0xffffffffu)) == 0, "sceAgcAcquireMemSetEngine failed with 0xffffffff");
check(acquire[1] == 0x80001234u, "0xffffffff did not set the engine bit");
check(sceAgcAcquireMemSetEngine(acquire, 0) == 0, "sceAgcAcquireMemSetEngine failed");
check(acquire[1] == 0x1234u, "acquire mem engine bit was not cleared to 0");
check(sceAgcAcquireMemSetEngine(acquire, 0xffu) == 0, "sceAgcAcquireMemSetEngine failed with 0xff");
check(acquire[1] == 0x80001234u, "0xff did not set the engine bit");
check(sceAgcAcquireMemSetEngine(acquire, 0) == 0, "sceAgcAcquireMemSetEngine failed");
check(acquire[1] == 0x1234u, "acquire mem engine bit was not cleared to 0");
const auto beforeAcquire = acquireStorage.words;
expectFailure([&] { sceAgcAcquireMemSetEngine(nullptr, 0); });
auto* misalignedAcquire = reinterpret_cast<std::uint32_t*>(reinterpret_cast<unsigned char*>(acquire) + 1);
expectFailure([&] { sceAgcAcquireMemSetEngine(misalignedAcquire, 0); });
check(acquireStorage.words == beforeAcquire, "invalid acquire engine patch modified packet memory");
std::uint32_t wrongAcquire[8] = {0xc0065000u, 0x12345678u};
check(sceAgcAcquireMemSetEngine(wrongAcquire, 0) == static_cast<int>(0x8a6c000c), "non-ACQUIRE_MEM packet did not return 0x8a6c000c");
check(wrongAcquire[0] == 0xc0065000u && wrongAcquire[1] == 0x12345678u, "non-ACQUIRE_MEM packet was modified");
check(sceAgcAcquireMemSetEngine(wrongAcquire, 1) == static_cast<int>(0x8a6c000c), "non-ACQUIRE_MEM packet did not return 0x8a6c000c with engine 1");
check(wrongAcquire[0] == 0xc0065000u && wrongAcquire[1] == 0x12345678u, "non-ACQUIRE_MEM packet was modified with engine 1");
std::uint32_t customLengthAcquire[4] = {Agc::Command::Header(0x58u, 4), 0x4321u, 0, 0};
check(sceAgcAcquireMemSetEngine(customLengthAcquire, 1) == 0, "custom length acquire mem failed");
check(customLengthAcquire[1] == 0x80004321u, "custom length acquire mem engine bit was not set");
auto* acbAcquire = sceAgcAcbAcquireMem(&acquireStorage.buffer, 0x567u, nullptr, 0x1000, 0);
check(acbAcquire[1] == 0x80000000u, "ACB acquire mem engine bit was not default 1");
check(sceAgcAcquireMemSetEngine(acbAcquire, 0) == 0, "sceAgcAcquireMemSetEngine failed on ACB acquire");
check(acbAcquire[1] == 0u, "ACB acquire mem engine bit was not cleared to 0");
}
void testEndOfPipePatches() {
@@ -1108,6 +1194,7 @@ int main(int argc, char** argv) {
testEndOfPipeAddressPatch();
testWorkloadStreams();
testIndexBuffer();
testDrawPackets();
testIndexIndirectArgs();
testIndirectBase();
testContextState();
@@ -15,6 +15,10 @@ namespace {
constexpr std::uint32_t SCodeEnd = 0xbf9f0000u;
constexpr std::uint32_t SNop = 0xbf800000u;
constexpr std::uint32_t SGetpcS60 = 0xbebc1f00u;
constexpr std::uint32_t SMovS0Literal = 0xbe8003ffu;
constexpr std::uint32_t SAddS60Literal = 0x803c3cffu;
constexpr std::uint32_t SAddcS61Zero = 0x823d3d80u;
constexpr std::uint32_t SSetpcS6 = 0xbe802006u;
constexpr std::uint32_t SSwappcNullS6 = 0xbefd2106u;
constexpr std::uint32_t SMovS0 = 0xbe800380u;
@@ -288,6 +292,63 @@ void testRejections() {
}
}
void setFrontConstants(Halves& halves, std::uint32_t seed, std::uint32_t constantsDqw = 2, bool addAfterGetpc = true) {
halves.frontCode = {SMovS0, SGetpcS60, addAfterGetpc ? SAddS60Literal : SMovS0, 24u, SAddcS61Zero, VMovV0, SSetpcS6, SCodeEnd};
const auto codeBytes = static_cast<std::uint32_t>(halves.frontCode.size() * 4);
for (std::uint32_t i = 0; i < 8; ++i) halves.frontCode.push_back(seed + i);
std::array<std::uint32_t, 2> magic{};
std::memcpy(magic.data(), "barefoot", 8);
halves.frontCode.insert(halves.frontCode.end(), {magic[0], magic[1], 0xabcdu, 0u, 1u, codeBytes, 0u});
halves.front.code = halves.frontCode.data();
halves.front.shader_size = static_cast<std::uint32_t>(halves.frontCode.size() * 4);
halves.front.embedded_constant_buffer_size_dqw = constantsDqw;
}
void testFrontConstantBuffer() {
Halves halves;
setFrontConstants(halves, 0x11110000u);
SizeAlign size{};
check(sceAgcGetFusedShaderSize_0080(&size, &halves.front, &halves.back) == 0, "size query refused a front half with an embedded constant buffer");
std::vector<std::uint8_t> scratch(size.m_size);
Shader fused{};
check(sceAgcFuseShaderHalves_0200(&fused, &halves.front, &halves.back, scratch.data()) == 0, "fusion refused a front half with an embedded constant buffer");
const auto* memory = static_cast<const std::uint8_t*>(const_cast<const void*>(fused.code));
check(word(memory, 0) == SMovS0 && word(memory, 1) == SGetpcS60 && word(memory, 2) == SAddS60Literal && word(memory, 4) == SAddcS61Zero && word(memory, 5) == VMovV0, "front program was not copied");
for (std::size_t i = 6; i < 64; ++i) check(word(memory, i) == SNop, "front program does not fall through to the back half");
check(std::memcmp(memory + 256, halves.backCode.data(), halves.back.shader_size) == 0, "back program was not copied");
check(fused.shader_size == 272 + 32, "fused code does not end after the moved constants");
for (std::uint32_t i = 0; i < 8; ++i) check(word(memory, 68 + i) == 0x11110000u + i, "front constants were not moved after the back program");
check(8 + word(memory, 3) == 272, "front s_getpc_b64 offset does not point at the moved constants");
check(halves.frontCode[3] == 24u, "fusion changed the title's front half");
Halves other;
setFrontConstants(other, 0x22220000u);
Shader otherFused{};
check(sceAgcFuseShaderHalves_0200(&otherFused, &other.front, &other.back, scratch.data()) == 0, "second fusion failed");
const auto* otherMemory = static_cast<const std::uint8_t*>(const_cast<const void*>(otherFused.code));
check(otherMemory != memory && word(otherMemory, 68) == 0x22220000u && word(memory, 68) == 0x11110000u, "halves that differ only in front constants share a fused program");
Halves overrun;
setFrontConstants(overrun, 0x33330000u, 3);
expectFailure([&] { sceAgcGetFusedShaderSize_0080(&size, &overrun.front, &overrun.back); });
Halves unpatched;
setFrontConstants(unpatched, 0x44440000u, 2, false);
expectFailure([&] { sceAgcGetFusedShaderSize_0080(&size, &unpatched.front, &unpatched.back); });
Halves gap;
setFrontConstants(gap, 0x66660000u);
gap.frontCode[3] = 20u;
expectFailure([&] { sceAgcGetFusedShaderSize_0080(&size, &gap.front, &gap.back); });
Halves backConstants;
setFrontConstants(backConstants, 0x77770000u);
backConstants.back.embedded_constant_buffer_size_dqw = 1;
expectFailure([&] { sceAgcGetFusedShaderSize_0080(&size, &backConstants.front, &backConstants.back); });
Halves literal;
setFrontConstants(literal, 0x55550000u);
literal.frontCode[0] = SMovS0Literal;
Shader literalFused{};
check(sceAgcFuseShaderHalves_0200(&literalFused, &literal.front, &literal.back, scratch.data()) == 0, "fusion refused a front half whose literal looks like s_getpc_b64");
const auto* literalMemory = static_cast<const std::uint8_t*>(const_cast<const void*>(literalFused.code));
check(word(literalMemory, 0) == SMovS0Literal && word(literalMemory, 1) == SGetpcS60 && word(literalMemory, 3) == 24u, "a literal that looks like s_getpc_b64 was relocated as one");
}
void testHullHalves() {
std::array<std::uint32_t, 2> frontCode{SEndpgm, SCodeEnd};
std::array<std::uint32_t, 2> backCode{SEndpgm, SCodeEnd};
@@ -334,6 +395,7 @@ int main() {
testOffchipLdsEnable();
testResourceMerging();
testRejections();
testFrontConstantBuffer();
testHullHalves();
LibcRunShutdown_nid_postfix();
std::puts("AGC shader fusion tests passed");
@@ -51,6 +51,15 @@ void testQwords() {
check(sceAgcGetStaticQword(3, &value) == 0 && value == 0xfedcba9876543210ull, "static qword 3 did not read back");
std::array<std::uint64_t, 2> buffer{};
check(sceAgcGetStaticBuffer(1, buffer.data()) == 0 && buffer[0] == 0x0123456789abcdefull, "static qword 0 is not the first half of static buffer 1");
std::uint64_t routine = 0;
std::memcpy(&routine, reinterpret_cast<const void*>(StaticTable + 96u), sizeof(routine));
check(sceAgcSetStaticQword(9, 0x5a5a5a5a5a5a5a5aull) == 0, "static qword 9, the last one inside the table, was rejected");
check(sceAgcSetStaticQword(10, 0xa5a5a5a5a5a5a5a5ull) == InvalidStaticBuffer, "static qword index 10 was accepted");
check(sceAgcGetStaticQword(10, &value) == InvalidStaticBuffer, "static qword index 10 was read");
check(sceAgcSetStaticQword(0xffffffffu, 0) == InvalidStaticBuffer, "static qword index 0xffffffff was accepted");
std::uint64_t after = 0;
std::memcpy(&after, reinterpret_cast<const void*>(StaticTable + 96u), sizeof(after));
check(after == routine, "rejected static qword writes changed the FS routine table");
}
}
@@ -412,6 +412,8 @@ set(agcDriverSources
${CMAKE_CURRENT_SOURCE_DIR}/Execution/src/FrameRecorder.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Execution/src/VulkanDevice.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Execution/src/FloatFlushProbe.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Execution/src/FloatProbeTolerance.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Execution/src/Float16ConversionProbe.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Execution/src/AspectFit.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Execution/src/PresentationScaler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Execution/src/PresentationPass.cpp
@@ -1062,4 +1064,19 @@ if(BUILD_TESTING)
set_property(TEST ${agcRegisteredTests} APPEND PROPERTY ENVIRONMENT "APS5_NO_PIPELINE_JOURNAL=1")
endif()
add_test_executable(agc_run_report_shader_failure_tests EXCLUDE_FROM_ALL tests/RunReportShaderFailure.cpp)
target_link_libraries(agc_run_report_shader_failure_tests PRIVATE shader_recompiler_agc_driver libc)
target_include_directories(agc_run_report_shader_failure_tests PRIVATE ${LIBS_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/3rdparty/Vulkan-Headers/include)
set_target_properties(agc_run_report_shader_failure_tests PROPERTIES CXX_EXTENSIONS OFF)
configure_windows_unwind(agc_run_report_shader_failure_tests)
if(BUILD_TESTING)
set_target_properties(agc_run_report_shader_failure_tests PROPERTIES EXCLUDE_FROM_ALL OFF)
add_test(NAME agc_run_report_shader_failure COMMAND agc_run_report_shader_failure_tests)
set_tests_properties(agc_run_report_shader_failure PROPERTIES ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1")
if(WIN32)
set_tests_properties(agc_run_report_shader_failure PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
endif()
target_sources(agc_driver_scattered_runs_tests PRIVATE tests/AllocationFailure.cpp)
@@ -4,7 +4,7 @@
#include <cstdint>
#include "SceTypes.hpp"
bool AgcDriverDeliverEopInterrupt(std::uint32_t queue);
void AgcDriverDeliverEopInterrupt(std::uint32_t queue, std::uint32_t context);
extern "C" int APS5_VABI sceAgcDriverAddEqEvent(KernelEqueue eq, int id, void* udata);
extern "C" int APS5_VABI sceAgcDriverDeleteEqEvent(KernelEqueue eq, int id);
@@ -33,9 +33,11 @@ int AddEvent(KernelEqueue eq, std::uint32_t queue, std::uintptr_t ident, void* u
event.event.ident = ident;
event.event.filter = EvfiltGraphicsCore;
event.event.flags = EV_ADD | EV_CLEAR;
event.event.data = static_cast<intptr_t>(queue);
event.event.udata = udata;
event.filter.triggerFunc = [](KernelEqueueEvent* e, void*) {
e->event.data = e->triggered ? e->event.data + 1 : 1;
event.filter.triggerFunc = [](KernelEqueueEvent* e, void* data) {
if (data == nullptr) throw std::runtime_error("graphics event triggered without its interrupt data");
e->event.data = static_cast<intptr_t>(*static_cast<const std::uint64_t*>(data));
e->triggered = true;
};
event.filter.resetFunc = [](KernelEqueueEvent* e) {
@@ -67,20 +69,17 @@ int DeleteEvent(KernelEqueue eq, std::uintptr_t ident, const char* caller) {
}
bool AgcDriverDeliverEopInterrupt(std::uint32_t queue) {
void AgcDriverDeliverEopInterrupt(std::uint32_t queue, std::uint32_t context) {
std::vector<Registration> registrations;
{
std::lock_guard lock(g_mutex);
registrations = g_registrations;
}
bool delivered = false;
for (const auto& registration : registrations) {
if (registration.queue == queue) {
EqueueTriggerEvent_nid_postfix(registration.eq, registration.ident, EvfiltGraphicsCore, nullptr);
delivered = true;
}
if (registration.queue != queue) continue;
std::uint64_t data = static_cast<std::uint64_t>(static_cast<std::uint8_t>(registration.queue)) | (static_cast<std::uint64_t>(context) << 16u);
EqueueTriggerEvent_nid_postfix(registration.eq, registration.ident, EvfiltGraphicsCore, &data);
}
return delivered;
}
extern "C" {
+2 -10
View File
@@ -17,22 +17,14 @@ uint32_t APS5_VABI sceAgcDriverGetEqContextId(const KernelEvent* ev) {
if (ev->filter != -14) {
throw std::runtime_error(std::string(__func__) + ": not a graphics event");
}
if (ev->ident > std::numeric_limits<uint32_t>::max()) {
throw std::runtime_error(std::string(__func__) + ": context id overflow");
}
return static_cast<uint32_t>(ev->ident);
return static_cast<uint32_t>(static_cast<std::uint64_t>(ev->data) >> 16u);
}
int APS5_VABI sceAgcDriverGetEqEventType(const KernelEvent* ev) {
if (ev == nullptr || reinterpret_cast<std::uintptr_t>(ev) % alignof(KernelEvent) != 0) {
throw std::runtime_error(std::string(__func__) + ": null or misaligned event");
}
if (ev->filter == -14) {
if (ev->ident > static_cast<std::uintptr_t>(std::numeric_limits<int>::max())) {
throw std::runtime_error(std::string(__func__) + ": graphics event type overflow");
}
return static_cast<int>(ev->ident);
}
if (ev->filter == -14) return static_cast<int>(static_cast<std::uint32_t>(static_cast<std::uint64_t>(ev->data)));
if (ev->data < std::numeric_limits<int>::min() || ev->data > std::numeric_limits<int>::max()) {
throw std::runtime_error(std::string(__func__) + ": event type overflow");
}
@@ -5,12 +5,15 @@
#define VK_NO_PROTOTYPES
#endif
#include <vulkan/vulkan.h>
#include "SubmissionSnapshots.hpp"
#include <algorithm>
#include <array>
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <mutex>
#include <string>
#include <vector>
@@ -44,7 +47,219 @@ inline std::string DeviceFaultText(const char (&text)[VK_MAX_DESCRIPTION_SIZE])
return std::string(text, strnlen(text, VK_MAX_DESCRIPTION_SIZE));
}
inline std::vector<std::string> DeviceFaultReport(VkDevice device, PFN_vkGetDeviceFaultInfoEXT faultInfo, VkQueue queue, PFN_vkGetQueueCheckpointDataNV checkpointData) {
inline std::uint64_t DeviceFaultRangeLow(std::uint64_t address, std::uint64_t precision) {
return precision == 0 ? address : address & ~(precision - 1);
}
inline std::uint64_t DeviceFaultRangeHigh(std::uint64_t address, std::uint64_t precision) {
return precision == 0 ? address : address | (precision - 1);
}
inline const char* DeviceFaultRangePermissions(std::uint32_t permissions) {
constexpr std::uint32_t readWrite = ShaderRecompiler::BdaAbi::Read | ShaderRecompiler::BdaAbi::Write;
if ((permissions & readWrite) == readWrite) return "read write";
if ((permissions & ShaderRecompiler::BdaAbi::Write) != 0) return "write";
if ((permissions & ShaderRecompiler::BdaAbi::Read) != 0) return "read";
return "none";
}
inline std::vector<std::string> DeviceFaultRangeLines(VkDeviceFaultAddressTypeEXT type, std::uint64_t address, std::uint64_t precision, const std::vector<ShaderRecompiler::BdaAbi::Range>& snapshot, std::uint64_t submitSerial, std::uint64_t spaceSerial) {
std::vector<std::string> lines;
char line[320];
const std::uint64_t low = DeviceFaultRangeLow(address, precision);
const std::uint64_t high = DeviceFaultRangeHigh(address, precision);
const ShaderRecompiler::BdaAbi::Range* owner = nullptr;
const ShaderRecompiler::BdaAbi::Range* before = nullptr;
const ShaderRecompiler::BdaAbi::Range* after = nullptr;
for (const auto& range : snapshot) {
if (owner == nullptr && range.begin <= low && high < range.end) owner = &range;
if (range.end <= low && (before == nullptr || before->end < range.end)) before = &range;
if (range.begin > high && (after == nullptr || range.begin < after->begin)) after = &range;
}
if (owner != nullptr) {
std::snprintf(line, sizeof(line), "[device-fault] %s at 0x%llx (precision 0x%llx) in guest range [0x%llx, 0x%llx) %s (batch %llu, space %llu)", DeviceFaultAddressKind(type), static_cast<unsigned long long>(address), static_cast<unsigned long long>(precision), static_cast<unsigned long long>(owner->begin), static_cast<unsigned long long>(owner->end), DeviceFaultRangePermissions(owner->permissions), static_cast<unsigned long long>(submitSerial), static_cast<unsigned long long>(spaceSerial));
lines.emplace_back(line);
return lines;
}
std::snprintf(line, sizeof(line), "[device-fault] %s at 0x%llx (precision 0x%llx) has no guest owner in batch %llu (internal or unmapped)", DeviceFaultAddressKind(type), static_cast<unsigned long long>(address), static_cast<unsigned long long>(precision), static_cast<unsigned long long>(submitSerial));
lines.emplace_back(line);
if (before != nullptr) {
std::snprintf(line, sizeof(line), "[device-fault] previous guest range [0x%llx, 0x%llx) %s ends 0x%llx before the fault range", static_cast<unsigned long long>(before->begin), static_cast<unsigned long long>(before->end), DeviceFaultRangePermissions(before->permissions), static_cast<unsigned long long>(low - before->end));
lines.emplace_back(line);
}
if (after != nullptr) {
std::snprintf(line, sizeof(line), "[device-fault] next guest range [0x%llx, 0x%llx) %s starts 0x%llx after the fault range", static_cast<unsigned long long>(after->begin), static_cast<unsigned long long>(after->end), DeviceFaultRangePermissions(after->permissions), static_cast<unsigned long long>(after->begin - high));
lines.emplace_back(line);
}
return lines;
}
inline std::vector<std::string> DeviceFaultBatchLines(VkDeviceFaultAddressTypeEXT type, std::uint64_t address, std::uint64_t precision, std::uint64_t submitSerial, const SubmissionSnapshots& snapshots) {
if (submitSerial == 0) return {};
const auto found = snapshots.Find(submitSerial);
if (!found.has_value()) {
char line[128];
std::snprintf(line, sizeof(line), "[device-fault] no guest snapshot for batch %llu", static_cast<unsigned long long>(submitSerial));
return {line};
}
return DeviceFaultRangeLines(type, address, precision, *found->ranges, found->submitSerial, found->spaceSerial);
}
inline constexpr std::uint32_t DeviceFaultBracketTokensListed = 8;
inline constexpr std::uint32_t DeviceFaultMaxInfos = 64;
inline constexpr std::uint32_t DeviceFaultMaxLiveResources = 4;
inline constexpr std::size_t DeviceFaultLiveResourceCapacity = 128;
class LiveResourceRing {
public:
static LiveResourceRing& Instance() noexcept {
static LiveResourceRing store;
return store;
}
LiveResourceRing() = default;
LiveResourceRing(const LiveResourceRing&) = delete;
LiveResourceRing& operator=(const LiveResourceRing&) = delete;
void Note(std::uint64_t address, std::uint64_t size, const char* kind) noexcept {
try {
if (address == 0 || size == 0 || kind == nullptr || *kind == '\0') return;
std::lock_guard<std::mutex> lock(mutex);
const std::uint64_t slot = next.fetch_add(1, std::memory_order_relaxed) % DeviceFaultLiveResourceCapacity;
Entry& entry = entries[static_cast<std::size_t>(slot)];
std::size_t length = 0;
while (length + 1 < sizeof(entry.kind) && kind[length] != '\0') {
entry.kind[length] = kind[length];
++length;
}
entry.kind[length] = '\0';
entry.size.store(size, std::memory_order_relaxed);
entry.address.store(address, std::memory_order_release);
} catch (...) {
}
}
std::vector<std::string> LinesFor(std::uint64_t va) const noexcept {
std::vector<std::string> lines;
try {
struct Candidate {
std::uint64_t distance;
std::uint64_t address;
std::uint64_t size;
char kind[16];
};
Candidate found[DeviceFaultLiveResourceCapacity];
std::size_t count = 0;
{
std::lock_guard<std::mutex> lock(mutex);
for (std::size_t i = 0; i < DeviceFaultLiveResourceCapacity; ++i) {
const std::uint64_t address = entries[i].address.load(std::memory_order_acquire);
if (address == 0) continue;
const std::uint64_t size = entries[i].size.load(std::memory_order_relaxed);
if (size == 0) continue;
std::uint64_t distance = 0;
if (va < address) distance = address - va;
else if (va - address >= size) distance = va - address - size;
char kind[16]{};
const char* stored = entries[i].kind;
std::size_t length = 0;
while (length + 1 < sizeof(kind) && stored[length] != '\0') {
kind[length] = stored[length];
++length;
}
kind[length] = '\0';
found[count].distance = distance;
found[count].address = address;
found[count].size = size;
for (std::size_t k = 0; k < sizeof(kind); ++k) found[count].kind[k] = kind[k];
++count;
}
}
for (std::size_t i = 0; i < count; ++i) {
for (std::size_t j = i + 1; j < count; ++j) {
if (found[j].distance < found[i].distance) {
Candidate tmp = found[i];
found[i] = found[j];
found[j] = tmp;
}
}
}
const std::size_t listed = count < DeviceFaultMaxLiveResources ? count : DeviceFaultMaxLiveResources;
for (std::size_t i = 0; i < listed; ++i) {
char line[128];
std::snprintf(line, sizeof(line), "[device-fault] live resource 0x%llx size 0x%llx %s", static_cast<unsigned long long>(found[i].address), static_cast<unsigned long long>(found[i].size), found[i].kind);
lines.emplace_back(line);
}
} catch (...) {
}
return lines;
}
private:
struct Entry {
std::atomic<std::uint64_t> address{0};
std::atomic<std::uint64_t> size{0};
char kind[16]{};
};
std::atomic<std::uint64_t> next{0};
Entry entries[DeviceFaultLiveResourceCapacity]{};
mutable std::mutex mutex;
};
inline void DeviceFaultAppendStage(char* line, std::size_t size, std::uint32_t stage) noexcept {
const std::size_t used = strnlen(line, size);
if (used + 1 >= size) return;
if (stage == static_cast<std::uint32_t>(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT)) std::snprintf(line + used, size - used, " observed at bottom-of-pipe");
else std::snprintf(line + used, size - used, " at stage 0x%x", static_cast<unsigned>(stage));
}
inline std::vector<std::string> DeviceFaultBracketLines(const SubmitBracket& bracket, const FaultTokenRing& ring, VkQueue queue = VK_NULL_HANDLE) noexcept {
std::vector<std::string> lines;
try {
if (bracket.submitSerial == 0) return lines;
char line[256];
if (queue == VK_NULL_HANDLE) std::snprintf(line, sizeof(line), "[device-fault] bracket: last completed %llu, in flight %llu, first not started %llu", static_cast<unsigned long long>(bracket.lastCompleted), static_cast<unsigned long long>(bracket.submitSerial), static_cast<unsigned long long>(bracket.submitSerial + 1));
else std::snprintf(line, sizeof(line), "[device-fault] bracket: last completed %llu, in flight %llu, first not started %llu, queue 0x%llx", static_cast<unsigned long long>(bracket.lastCompleted), static_cast<unsigned long long>(bracket.submitSerial), static_cast<unsigned long long>(bracket.submitSerial + 1), static_cast<unsigned long long>(reinterpret_cast<std::uintptr_t>(queue)));
lines.emplace_back(line);
if (bracket.firstToken == 0) return lines;
if (bracket.lastToken < bracket.firstToken) return lines;
const std::uint64_t tokens = static_cast<std::uint64_t>(bracket.lastToken) - static_cast<std::uint64_t>(bracket.firstToken) + 1;
const std::uint64_t listed = tokens < DeviceFaultBracketTokensListed ? tokens : DeviceFaultBracketTokensListed;
const std::uint64_t start = static_cast<std::uint64_t>(bracket.firstToken) + (tokens > listed ? tokens - listed : 0);
for (std::uint64_t i = 0; i < listed; ++i) {
const FaultToken token = static_cast<FaultToken>(start + i);
const auto found = ring.Find(token);
if (!found.has_value()) {
if (queue == VK_NULL_HANDLE) std::snprintf(line, sizeof(line), "[device-fault] unknown token %u in batch %llu", static_cast<unsigned>(token), static_cast<unsigned long long>(bracket.submitSerial));
else std::snprintf(line, sizeof(line), "[device-fault] unknown token %u in batch %llu queue 0x%llx", static_cast<unsigned>(token), static_cast<unsigned long long>(bracket.submitSerial), static_cast<unsigned long long>(reinterpret_cast<std::uintptr_t>(queue)));
lines.emplace_back(line);
continue;
}
const std::size_t descLength = strnlen(found->desc, sizeof(found->desc));
if (queue == VK_NULL_HANDLE) {
if (descLength == 0) std::snprintf(line, sizeof(line), "[device-fault] token %u in batch %llu: program 0x%llx variant %llu", static_cast<unsigned>(token), static_cast<unsigned long long>(found->submitSerial), static_cast<unsigned long long>(found->programAddress), static_cast<unsigned long long>(found->variantId));
else std::snprintf(line, sizeof(line), "[device-fault] token %u in batch %llu: program 0x%llx variant %llu %.*s", static_cast<unsigned>(token), static_cast<unsigned long long>(found->submitSerial), static_cast<unsigned long long>(found->programAddress), static_cast<unsigned long long>(found->variantId), static_cast<int>(descLength), found->desc);
} else if (descLength == 0) std::snprintf(line, sizeof(line), "[device-fault] token %u in batch %llu queue 0x%llx: program 0x%llx variant %llu", static_cast<unsigned>(token), static_cast<unsigned long long>(found->submitSerial), static_cast<unsigned long long>(reinterpret_cast<std::uintptr_t>(queue)), static_cast<unsigned long long>(found->programAddress), static_cast<unsigned long long>(found->variantId));
else std::snprintf(line, sizeof(line), "[device-fault] token %u in batch %llu queue 0x%llx: program 0x%llx variant %llu %.*s", static_cast<unsigned>(token), static_cast<unsigned long long>(found->submitSerial), static_cast<unsigned long long>(reinterpret_cast<std::uintptr_t>(queue)), static_cast<unsigned long long>(found->programAddress), static_cast<unsigned long long>(found->variantId), static_cast<int>(descLength), found->desc);
lines.emplace_back(line);
}
if (tokens > listed) {
std::snprintf(line, sizeof(line), "[device-fault] %llu more bracket tokens", static_cast<unsigned long long>(tokens - listed));
lines.emplace_back(line);
}
} catch (...) {
}
return lines;
}
inline std::vector<std::string> DeviceFaultBatchLines(VkDeviceFaultAddressTypeEXT type, std::uint64_t address, std::uint64_t precision, std::uint64_t submitSerial, const SubmissionSnapshots& snapshots, const SubmitBracket& bracket, const FaultTokenRing& ring, VkQueue queue = VK_NULL_HANDLE) noexcept {
std::vector<std::string> lines;
try {
lines = DeviceFaultBatchLines(type, address, precision, submitSerial, snapshots);
const auto window = DeviceFaultBracketLines(bracket, ring, queue);
lines.insert(lines.end(), window.begin(), window.end());
} catch (...) {
}
return lines;
}
inline std::vector<std::string> DeviceFaultReport(VkDevice device, PFN_vkGetDeviceFaultInfoEXT faultInfo, VkQueue queue, PFN_vkGetQueueCheckpointDataNV checkpointData, std::uint64_t submitSerial = 0, const SubmissionSnapshots* snapshots = nullptr) {
std::vector<std::string> lines;
char line[VK_MAX_DESCRIPTION_SIZE + 128];
if (checkpointData != nullptr && queue != VK_NULL_HANDLE) {
@@ -72,6 +287,10 @@ inline std::vector<std::string> DeviceFaultReport(VkDevice device, PFN_vkGetDevi
info.pAddressInfos = addresses.empty() ? nullptr : addresses.data();
info.pVendorInfos = vendors.empty() ? nullptr : vendors.data();
const auto result = faultInfo(device, &counts, &info);
if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
lines.emplace_back("[device-fault] vkGetDeviceFaultInfoEXT reported nothing");
return lines;
}
addresses.resize(std::min<std::size_t>(addresses.size(), counts.addressInfoCount));
vendors.resize(std::min<std::size_t>(vendors.size(), counts.vendorInfoCount));
std::snprintf(line, sizeof(line), "[device-fault] result %d: %s", static_cast<int>(result), DeviceFaultText(info.description).c_str());
@@ -79,6 +298,10 @@ inline std::vector<std::string> DeviceFaultReport(VkDevice device, PFN_vkGetDevi
for (const auto& address : addresses) {
std::snprintf(line, sizeof(line), "[device-fault] %s at 0x%llx (precision 0x%llx)", DeviceFaultAddressKind(address.addressType), static_cast<unsigned long long>(address.reportedAddress), static_cast<unsigned long long>(address.addressPrecision));
lines.emplace_back(line);
if (snapshots != nullptr) {
const auto correlated = DeviceFaultBatchLines(address.addressType, address.reportedAddress, address.addressPrecision, submitSerial, *snapshots);
lines.insert(lines.end(), correlated.begin(), correlated.end());
}
}
for (const auto& vendor : vendors) {
std::snprintf(line, sizeof(line), "[device-fault] vendor: %s (code 0x%llx, data 0x%llx)", DeviceFaultText(vendor.description).c_str(), static_cast<unsigned long long>(vendor.vendorFaultCode), static_cast<unsigned long long>(vendor.vendorFaultData));
@@ -87,61 +310,95 @@ inline std::vector<std::string> DeviceFaultReport(VkDevice device, PFN_vkGetDevi
return lines;
}
class BufferMarkerLog {
public:
static constexpr std::uint32_t Capacity = 4096;
static constexpr std::uint32_t Listed = 8;
std::uint32_t Next(std::uint64_t program) {
std::uint32_t id = 0;
while (id == 0) id = next.fetch_add(1, std::memory_order_relaxed) + 1;
auto& slot = slots[id % Capacity];
slot.program.store(program, std::memory_order_relaxed);
slot.id.store(id, std::memory_order_release);
return id;
}
std::vector<std::string> Report(std::uint32_t reached, std::uint32_t finished) const {
std::vector<std::string> lines;
if (reached == 0 && finished == 0) {
lines.emplace_back("[device-fault] no buffer marker reached");
inline std::vector<std::string> DeviceFaultReport(VkDevice device, PFN_vkGetDeviceFaultInfoEXT faultInfo, VkQueue queue, PFN_vkGetQueueCheckpointDataNV checkpointData, std::uint64_t submitSerial, const SubmissionSnapshots* snapshots, const SubmitBracket& bracket, const FaultTokenRing& ring) noexcept {
std::vector<std::string> lines;
try {
std::vector<VkCheckpointDataNV> points;
std::uint64_t tokenSerial = 0;
if (checkpointData != nullptr && queue != VK_NULL_HANDLE) {
std::uint32_t count = 0;
checkpointData(queue, &count, nullptr);
if (count > DeviceFaultMaxInfos) count = DeviceFaultMaxInfos;
points.assign(count, VkCheckpointDataNV{VK_STRUCTURE_TYPE_CHECKPOINT_DATA_NV});
if (count != 0) checkpointData(queue, &count, points.data());
points.resize(count);
for (const auto& point : points) {
const FaultToken token = static_cast<FaultToken>(reinterpret_cast<std::uintptr_t>(point.pCheckpointMarker));
const auto found = ring.Find(token);
if (found.has_value() && found->submitSerial != 0) tokenSerial = found->submitSerial;
}
}
const std::uint64_t effectiveSerial = submitSerial != 0 ? submitSerial : tokenSerial;
SubmitBracket effectiveBracket = bracket;
if (effectiveBracket.submitSerial == 0 && effectiveSerial != 0 && snapshots != nullptr) {
if (const auto found = snapshots->FindBracket(effectiveSerial)) effectiveBracket = *found;
}
const auto window = DeviceFaultBracketLines(effectiveBracket, ring, queue);
lines.insert(lines.end(), window.begin(), window.end());
if (effectiveSerial == 0 && device != VK_NULL_HANDLE) lines.emplace_back("[device-fault] no per-submit marker (submit serial unknown; markers need APS5_GPU_CHECKPOINTS on the main queue)");
if (checkpointData != nullptr && queue != VK_NULL_HANDLE) {
if (points.empty()) lines.emplace_back("[device-fault] no checkpoint reached");
char checkpoint[256];
for (const auto& point : points) {
const FaultToken token = static_cast<FaultToken>(reinterpret_cast<std::uintptr_t>(point.pCheckpointMarker));
const auto found = ring.Find(token);
if (!found.has_value()) {
std::snprintf(checkpoint, sizeof(checkpoint), "[device-fault] checkpoint: unknown token %u queue 0x%llx", static_cast<unsigned>(token), static_cast<unsigned long long>(reinterpret_cast<std::uintptr_t>(queue)));
} else {
const std::size_t descLength = strnlen(found->desc, sizeof(found->desc));
if (descLength == 0) std::snprintf(checkpoint, sizeof(checkpoint), "[device-fault] checkpoint: token %u batch %llu queue 0x%llx program 0x%llx variant %llu", static_cast<unsigned>(token), static_cast<unsigned long long>(found->submitSerial), static_cast<unsigned long long>(reinterpret_cast<std::uintptr_t>(queue)), static_cast<unsigned long long>(found->programAddress), static_cast<unsigned long long>(found->variantId));
else std::snprintf(checkpoint, sizeof(checkpoint), "[device-fault] checkpoint: token %u batch %llu queue 0x%llx program 0x%llx variant %llu %.*s", static_cast<unsigned>(token), static_cast<unsigned long long>(found->submitSerial), static_cast<unsigned long long>(reinterpret_cast<std::uintptr_t>(queue)), static_cast<unsigned long long>(found->programAddress), static_cast<unsigned long long>(found->variantId), static_cast<int>(descLength), found->desc);
}
DeviceFaultAppendStage(checkpoint, sizeof(checkpoint), point.stage);
lines.emplace_back(checkpoint);
}
}
if (faultInfo == nullptr || device == VK_NULL_HANDLE) {
if (points.empty() && effectiveBracket.submitSerial != 0) lines.emplace_back("[device-fault] no device-side fault data; CPU-side bracket only");
return lines;
}
lines.push_back(Line("last dispatch reached", reached));
if (finished == 0) lines.emplace_back("[device-fault] no dispatch finished");
else lines.push_back(Line("last dispatch finished", finished));
const std::uint32_t pending = reached - finished;
if (pending == 0 || pending > Capacity) return lines;
const auto listed = std::min(pending, Listed);
for (std::uint32_t i = 1; i <= listed; ++i) lines.push_back(Line("unfinished dispatch", finished + i));
if (pending > listed) {
char line[96];
std::snprintf(line, sizeof(line), "[device-fault] %u more unfinished dispatches", pending - listed);
char line[VK_MAX_DESCRIPTION_SIZE + 128];
VkDeviceFaultCountsEXT counts{VK_STRUCTURE_TYPE_DEVICE_FAULT_COUNTS_EXT};
if (faultInfo(device, &counts, nullptr) != VK_SUCCESS) {
lines.emplace_back("[device-fault] vkGetDeviceFaultInfoEXT reported nothing");
return lines;
}
if (counts.addressInfoCount > DeviceFaultMaxInfos) counts.addressInfoCount = DeviceFaultMaxInfos;
if (counts.vendorInfoCount > DeviceFaultMaxInfos) counts.vendorInfoCount = DeviceFaultMaxInfos;
std::vector<VkDeviceFaultAddressInfoEXT> addresses(counts.addressInfoCount);
std::vector<VkDeviceFaultVendorInfoEXT> vendors(counts.vendorInfoCount);
counts.vendorBinarySize = 0;
VkDeviceFaultInfoEXT info{VK_STRUCTURE_TYPE_DEVICE_FAULT_INFO_EXT};
info.pAddressInfos = addresses.empty() ? nullptr : addresses.data();
info.pVendorInfos = vendors.empty() ? nullptr : vendors.data();
const auto result = faultInfo(device, &counts, &info);
if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
lines.emplace_back("[device-fault] vkGetDeviceFaultInfoEXT reported nothing");
return lines;
}
addresses.resize(std::min<std::size_t>(addresses.size(), counts.addressInfoCount));
vendors.resize(std::min<std::size_t>(vendors.size(), counts.vendorInfoCount));
std::snprintf(line, sizeof(line), "[device-fault] result %d: %s", static_cast<int>(result), DeviceFaultText(info.description).c_str());
lines.emplace_back(line);
for (const auto& address : addresses) {
std::snprintf(line, sizeof(line), "[device-fault] %s at 0x%llx (precision 0x%llx)", DeviceFaultAddressKind(address.addressType), static_cast<unsigned long long>(address.reportedAddress), static_cast<unsigned long long>(address.addressPrecision));
lines.emplace_back(line);
if (snapshots != nullptr) {
const auto correlated = DeviceFaultBatchLines(address.addressType, address.reportedAddress, address.addressPrecision, effectiveSerial, *snapshots);
lines.insert(lines.end(), correlated.begin(), correlated.end());
}
const auto live = LiveResourceRing::Instance().LinesFor(address.reportedAddress);
lines.insert(lines.end(), live.begin(), live.end());
}
for (const auto& vendor : vendors) {
std::snprintf(line, sizeof(line), "[device-fault] vendor: %s (code 0x%llx, data 0x%llx)", DeviceFaultText(vendor.description).c_str(), static_cast<unsigned long long>(vendor.vendorFaultCode), static_cast<unsigned long long>(vendor.vendorFaultData));
lines.emplace_back(line);
}
return lines;
if (addresses.empty() && points.empty() && effectiveBracket.submitSerial != 0) lines.emplace_back("[device-fault] no device-side fault data; CPU-side bracket only");
} catch (...) {
}
private:
struct Slot {
std::atomic<std::uint32_t> id{0};
std::atomic<std::uint64_t> program{0};
};
std::string Line(const char* what, std::uint32_t id) const {
char line[128];
const auto& slot = slots[id % Capacity];
if (id != 0 && slot.id.load(std::memory_order_acquire) == id) {
std::snprintf(line, sizeof(line), "[device-fault] %s: marker %u, program 0x%llx", what, id, static_cast<unsigned long long>(slot.program.load(std::memory_order_relaxed)));
} else {
std::snprintf(line, sizeof(line), "[device-fault] %s: marker %u, program not in the log", what, id);
}
return line;
}
std::atomic<std::uint32_t> next{0};
std::array<Slot, Capacity> slots{};
};
return lines;
}
}
@@ -34,10 +34,12 @@ extern "C" void AgcDriverRequestScreenshot_nid_postfix();
extern "C" void AgcDriverSuspendPoint_nid_postfix();
extern "C" void AgcDriverSerialProgress_nid_postfix(std::uint64_t* accepted, std::uint64_t* completed);
extern "C" std::size_t AgcDriverAwaitedWaits_nid_postfix(AgcDriver::AwaitedWait* waits, std::size_t capacity);
extern "C" void AgcDriverWaitForPipelineJournal_nid_postfix();
extern "C" std::uint64_t AgcDriverDispatchesAdoptedAhead_nid_postfix();
extern "C" std::uint64_t AgcDriverDispatchesRejectedAhead_nid_postfix();
extern "C" void AgcDriverSetAheadAdoptHook_nid_postfix(void (*hook)());
extern "C" void AgcDriverRegisterShader_nid_postfix(const Shader* shader);
extern "C" std::uint32_t AgcDriverInstructionWords_nid_postfix(std::span<const std::uint32_t> code, std::uint32_t index);
extern "C" void AgcDriverResolveShaderAbi_nid_postfix(const Shader* shader, std::span<const ShaderRegister> context, std::span<const ShaderRegister> primitive);
extern "C" void AgcDriverResolveGraphicsStagesAbi_nid_postfix(std::span<const Shader* const> stages, std::span<const ShaderRegister> context, std::span<const ShaderRegister> primitive);
extern "C" void AgcDriverResolveGraphicsAbi_nid_postfix(const Shader* vertex, const Shader* pixel, std::uint32_t primitiveType);
@@ -26,23 +26,18 @@ namespace AgcDriver::DriverDetail {
inline bool CaptureRegisteredViewsCurrent(std::span<const ShaderRecompiler::RegisteredImageView> views) {
if (views.empty()) return true;
for (std::uint32_t attempt = 0; attempt < 2u; ++attempt) {
const auto before = GuestAllocations::GuestAllocationsGeneration_nid_postfix();
bool current = true;
for (const auto& view : views) {
const auto range = GuestAllocations::GuestAllocationsLookup_nid_postfix(static_cast<std::uintptr_t>(view.address), false);
if (view.hasRange != (range != nullptr)) {
current = false;
break;
}
if (range != nullptr && (range->address != view.rangeAddress || range->bytes != view.rangeBytes || range->allocationAddress != view.allocationAddress || range->allocationBytes != view.allocationBytes || range->backingSerial != view.backingSerial || range->readable != view.readable || range->writable != view.writable || range->gpu != view.gpu)) {
current = false;
break;
}
}
if (before == GuestAllocations::GuestAllocationsGeneration_nid_postfix()) return current;
std::vector<std::uintptr_t> addresses;
addresses.reserve(views.size());
for (const auto& view : views) addresses.push_back(static_cast<std::uintptr_t>(view.address));
std::vector<std::shared_ptr<const GuestAllocations::Range>> ranges(views.size());
GuestAllocations::GuestAllocationsLookupEach_nid_postfix(addresses.data(), addresses.size(), ranges.data());
for (std::size_t index = 0; index < views.size(); ++index) {
const auto& view = views[index];
const auto& range = ranges[index];
if (view.hasRange != (range != nullptr)) return false;
if (range != nullptr && (range->address != view.rangeAddress || range->bytes != view.rangeBytes || range->allocationAddress != view.allocationAddress || range->allocationBytes != view.allocationBytes || range->backingSerial != view.backingSerial || range->readable != view.readable || range->writable != view.writable || range->gpu != view.gpu)) return false;
}
return false;
return true;
}
inline constexpr std::size_t MaxDispatchVariants = 8;
@@ -78,6 +78,7 @@ public:
std::pair<std::uint64_t, std::uint64_t> SerialProgress();
std::uint64_t FlipSubmissions() const;
std::vector<AwaitedWait> AwaitedWaits();
void WaitForPipelineJournal();
bool WaitIdleFor(std::chrono::milliseconds timeout);
void RegisterVideoOutput(std::uint32_t handle, const std::shared_ptr<IVideoOutput>& output);
void UnregisterVideoOutput(std::uint32_t handle, const std::shared_ptr<IVideoOutput>& output);
@@ -145,10 +146,13 @@ private:
static bool copySegment(Submission& submission, const std::uint32_t* guest, std::size_t words, std::size_t& budget);
static void readRegisterLists(Submission& submission);
void waitForFlipRoom(const Submission& submission);
void holdFlipBehindWorker(const Submission& submission);
void holdFlipBehindWorker(const Submission& submission, bool cpuFlip);
bool awaitsTitle(std::uint64_t awaited) const;
void noteAwaitingTitle(std::uint32_t queue, std::uint64_t awaited);
void releaseFlipHold();
void finishFlipWork(std::uint64_t workSerial);
std::uint64_t submitFlipWork(std::uint32_t queue);
void waitFlipWork(std::uint64_t workSerial);
void reserveOutputs(Submission& submission);
void executeRewindTail(const Submission& stalled);
void enqueue(Submission submission);
@@ -159,7 +163,7 @@ private:
void deferCompletion(const Submission& submission);
void submitOpenWork(const std::shared_ptr<SubmissionProgress>& progress = {});
void wakeQueueZeroForCompletions();
void completeSubmission(std::uint64_t serial, std::uint64_t received, std::span<const std::uint64_t> labelWrites, const std::shared_ptr<SubmissionProgress>& progress);
void completeSubmission(std::uint64_t serial, std::uint64_t received, std::span<const std::uint64_t> labelWrites, const std::shared_ptr<SubmissionProgress>& progress, bool holdsFlip);
static bool waitFree(const Submission& submission);
bool queue0Before(std::uint64_t received) const;
bool waitFreeBefore(std::uint64_t received) const;
@@ -231,6 +235,7 @@ private:
void noteLabelPass(std::span<const std::uint32_t> packet, std::uint32_t queue);
void noteLabelIssue(std::span<const std::uint32_t> packet, std::uint32_t queue);
void retireLabelTakes(std::uint32_t queue, std::uint64_t received);
bool findWaitProducer(std::uint64_t address, std::size_t bytes, std::uint64_t& token);
bool storedSince(std::span<const std::uint32_t> packet, std::uint64_t address, std::size_t bytes, std::uint64_t received, std::uint32_t queue, std::uint32_t* writer = nullptr);
static void traceLabel(std::span<const std::uint32_t> packet, std::uint32_t queue);
static std::array<WriteRecord, 16384>& writeHistory();
@@ -266,7 +271,8 @@ private:
static IndirectSource& indirectSource();
static std::string describeIndirectSource();
std::array<std::uint32_t, 5> readDispatchArguments(std::uint32_t queue, std::uint64_t arguments, std::uint32_t initiator);
static bool& sampledRead();
static bool sampledRead();
static void setSampledRead(bool sampled);
static bool writeEvidenceEnabled();
static bool writerKeyedEvidence();
static bool foreignWriters();
@@ -298,11 +304,12 @@ private:
static std::vector<std::pair<std::uint64_t, std::uint64_t>> drawWriteRanges(const Graphics::State& graphics, std::span<const Graphics::CompiledShader> stages);
void commitDraw(std::shared_ptr<VulkanDevice> localDevice, std::uint32_t queue, const Graphics::State& graphics, const Pm4::DrawParameters& drawParameters, std::span<const Graphics::CompiledShader> stages, std::span<const Graphics::GuestMemorySnapshot> snapshots, const std::shared_ptr<const DrawRecipe>& recipe, const std::vector<std::shared_ptr<DispatchVariant>>& recipeStages, std::uint64_t drawKey, VulkanDevice::DrawTraceContext trace = {}, std::uint64_t shape = 0);
bool labelPacketQueues(std::span<const std::uint32_t> packet, std::uint32_t opcode);
bool enqueueLabelPacket(std::span<const std::uint32_t> packet, std::uint32_t opcode, std::uint32_t queue);
bool enqueueLabelPacket(std::span<const std::uint32_t> packet, std::uint32_t opcode, std::uint32_t queue, std::optional<std::uint32_t> interrupt);
bool enqueueDmaPacket(std::span<const std::uint32_t> packet, std::uint32_t opcode, std::uint32_t queue, const QueueState& state);
bool enqueueSampleDumpPacket(std::span<const std::uint32_t> packet, std::uint32_t opcode, std::uint32_t queue);
bool enqueueConstantRamDump(std::span<const std::uint32_t> packet, std::uint32_t opcode, std::uint32_t queue, const QueueState& state);
void commitStore(std::uint32_t queue, std::uint64_t address, std::span<const std::byte> bytes);
void commitLabel(std::uint32_t queue, std::uint64_t address, std::span<const std::byte> bytes, bool endOfPipeInterrupt);
void commitLabel(std::uint32_t queue, std::uint64_t address, std::span<const std::byte> bytes, std::optional<std::uint32_t> interrupt);
void submitDueAfterCommit(VulkanDevice* localDevice);
std::optional<WrittenBuffer> newestWriterLocked(std::uint64_t begin, std::uint64_t end) const;
std::optional<WrittenBuffer> newestWriter(std::uint64_t begin, std::uint64_t end);
@@ -382,17 +389,18 @@ private:
void recordQueuedLabelsByTry(std::uint32_t queue, std::atomic<std::uint64_t>& counter);
static void recordQueuedLabelsFromHook();
void flushBetweenPackets(std::uint32_t queue, std::uint32_t header, bool labelPacket);
bool preparePacketMemory(const Submission& submission, QueueState& queue, std::span<const std::uint32_t> packet, std::uint32_t header, std::uint32_t opcode, bool& wroteOnGpu, bool& endOfPipeInterrupt, bool& interruptDeferred, bool& drawPacket, bool& sampleDump);
bool preparePacketMemory(const Submission& submission, QueueState& queue, std::span<const std::uint32_t> packet, std::uint32_t header, std::uint32_t opcode, std::optional<std::uint32_t> interrupt, bool& wroteOnGpu, bool& endOfPipeInterrupt, bool& interruptDeferred, bool& drawPacket, bool& sampleDump);
void dumpSampleCounters(std::uint64_t address);
template <typename TWork>
static void timed(double WorkerProfile::*bucket, TWork&& work);
FrameTiming* frameTiming();
FrameTiming* includeTimingSubmission(const Submission& submission, bool firstSegment);
void execute(const Submission& submission);
void deliverGuestEopInterrupt(std::uint32_t queue);
void deliverFlipEopInterrupt(std::uint32_t queue);
void deliverGuestEopInterrupt(std::uint32_t queue, std::uint32_t context);
static std::optional<std::uint32_t> releaseInterrupt(std::span<const std::uint32_t> packet, std::uint32_t opcode, bool carriesFlip);
void markCompleted(std::uint64_t serial);
static const std::atomic<std::uint64_t>*& workerQueued();
static std::atomic<std::uint64_t>*& workerPacket();
void reapCompletionLabels();
void run(std::uint32_t id) noexcept;
@@ -416,9 +424,6 @@ private:
std::atomic<std::uint64_t> flipSerial{0};
std::atomic<std::uint64_t> flipBatchesUnsignaled{0};
std::mutex eopSelfSignalMutex;
std::unordered_map<std::uint32_t, std::uint32_t> eopSelfSignalFlips;
alignas(64) std::atomic<int> packetsInFlight{0};
std::atomic<std::uint64_t> packetsDone{0};
@@ -468,7 +473,7 @@ private:
std::map<std::uint32_t, QueueState> queues;
std::map<std::uint32_t, std::shared_ptr<IVideoOutput>> outputs;
struct EopFlip {
std::uint32_t handle;
FlipInfo info;
std::shared_ptr<IFlipRequest> request;
};
std::map<std::uint32_t, EopFlip> eopFlips;
@@ -501,6 +506,8 @@ private:
std::atomic<std::uint64_t> queue0Awaited{0};
std::atomic<std::uint32_t> flipsAhead{0};
std::atomic<std::uint32_t> flipHolders{0};
std::atomic<std::uint32_t> flipWorkOpen{0};
std::atomic<std::uint64_t> flipWorkSerial{0};
std::atomic<bool> queue0AwaitsTitle{false};
std::atomic<std::uint64_t> evidenceReads{0};
@@ -55,6 +55,7 @@ struct QueueWorker {
std::unordered_map<std::uint64_t, std::uint32_t> unfinishedWrites;
std::uint64_t executingWaitFree = 0;
bool executingWaits = false;
alignas(64) std::atomic<std::uint64_t> executingPacket{0};
std::thread thread;
};
@@ -323,6 +323,7 @@ ShaderSnapshot PrepareNullPixelProgram(const VulkanDevice& device);
std::uint64_t DepthCopyPixelProgramAddress(bool multisampled);
std::uint32_t DepthCopyPixelUserWords(bool multisampled);
ShaderSnapshot PrepareDepthCopyPixelProgram(bool multisampled);
bool DriverOwnedProgram(std::uint64_t codeAddress);
std::optional<ShaderRecompiler::ShaderFloatMode> RegisteredFloatMode(const ShaderSnapshot& snapshot);
std::optional<ShaderRecompiler::ShaderFloatMode> DispatchFloatMode(const ShaderSnapshot& snapshot, const Registers& live);
std::shared_ptr<const ShaderSnapshot> RegisteredHeader(const ShaderRegistry& registry, const Shader* shader);
@@ -30,7 +30,7 @@ enum TrySite { TryLabel = 0, TryFlush, TryReap, TryPoll, TryIdle, TryCapture, Tr
extern std::atomic<std::uint64_t> triesFailed[TrySites];
extern std::atomic<std::uint64_t> storesOnGpu, storesBehindCompletions, storesOnCpu, storesDrained, dmaFills, copiesToHostMemory, copiesBehindPendingSources;
extern std::atomic<std::uint64_t> storesOnGpu, storesBehindCompletions, storesOnCpu, storesDrained, dmaFills, copiesToHostMemory, copiesBehindPendingSources, sampleDumpsQueued;
extern std::map<std::uint32_t, std::uint64_t> drainCounts;
@@ -0,0 +1,38 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGCDRIVER_EXECUTION_INCLUDE_FLOAT16CONVERSIONPROBE_HPP
#define CORE_LIBS_PRX_LIBSCEAGCDRIVER_EXECUTION_INCLUDE_FLOAT16CONVERSIONPROBE_HPP
#include "Recompiler.hpp"
#include <cstdint>
#include <optional>
#include <vector>
namespace AgcDriver {
class VulkanDevice;
struct Float16ConversionMismatch {
std::uint32_t input = 0;
std::uint32_t emulated = 0;
std::uint32_t native = 0;
};
struct Float16ConversionProbeDirection {
bool probed = false;
std::uint32_t mismatches = 0;
std::uint32_t compared = 0;
std::optional<Float16ConversionMismatch> first;
};
struct Float16ConversionProbeResult {
Float16ConversionProbeDirection widen;
Float16ConversionProbeDirection narrow;
};
std::vector<std::uint32_t> Float16NarrowProbeInputs();
Float16ConversionProbeResult ProbeFloat16Conversions(VulkanDevice& device, const ShaderRecompiler::SpirvTarget& target);
}
#endif
@@ -15,6 +15,7 @@ struct FloatFlushProbeResult {
};
FloatFlushProbeResult ProbeFloat32FlushToZero(VulkanDevice& device, const ShaderRecompiler::SpirvTarget& target);
FloatFlushProbeResult ProbeFloat32DenormPreserve(VulkanDevice& device, const ShaderRecompiler::SpirvTarget& target);
}
@@ -0,0 +1,14 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGCDRIVER_EXECUTION_INCLUDE_FLOATPROBETOLERANCE_HPP
#define CORE_LIBS_PRX_LIBSCEAGCDRIVER_EXECUTION_INCLUDE_FLOATPROBETOLERANCE_HPP
#include <cstdint>
namespace AgcDriver {
enum class Float32ProbeOp : std::uint8_t { Log2, Sqrt, Rsq, Rcp, Exp2 };
bool Float32ResultsAgree(Float32ProbeOp op, std::uint32_t input, std::uint32_t first, std::uint32_t second);
}
#endif
@@ -12,6 +12,7 @@
#include <cstdlib>
#include <condition_variable>
#include <exception>
#include <filesystem>
#include <functional>
#include <limits>
#include <map>
@@ -43,7 +44,32 @@ public:
using Clock = std::chrono::steady_clock;
enum class Edge { None, Open, Close };
static std::optional<TraceWindow> Parse(const char* frames, const char* seconds) {
static bool TriggerConfigured() {
#ifdef _WIN32
return _wgetenv(L"APS5_TRACE_TRIGGER_FILE") != nullptr;
#else
return std::getenv("APS5_TRACE_TRIGGER_FILE") != nullptr;
#endif
}
static std::optional<TraceWindow> FromEnvironment() {
auto window = Parse(std::getenv("APS5_TRACE_FRAMES"), std::getenv("APS5_TRACE_SECONDS"));
#ifdef _WIN32
const auto* trigger = _wgetenv(L"APS5_TRACE_TRIGGER_FILE");
#else
const auto* trigger = std::getenv("APS5_TRACE_TRIGGER_FILE");
#endif
if (trigger != nullptr) {
if (trigger[0] == 0 || !window)
throw std::invalid_argument("APS5_TRACE_TRIGGER_FILE requires a nonempty path and APS5_TRACE_FRAMES or APS5_TRACE_SECONDS");
window->trigger = std::filesystem::path(trigger);
}
return window;
}
static std::optional<TraceWindow> Parse(const char* frames, const char* seconds, const char* trigger = nullptr) {
if (trigger != nullptr && (trigger[0] == '\0' || (frames == nullptr && seconds == nullptr)))
throw std::invalid_argument("APS5_TRACE_TRIGGER_FILE requires a nonempty path and APS5_TRACE_FRAMES or APS5_TRACE_SECONDS");
if (frames == nullptr && seconds == nullptr) return std::nullopt;
if (frames != nullptr && seconds != nullptr) throw std::invalid_argument("APS5_TRACE_FRAMES and APS5_TRACE_SECONDS cannot be set together");
const std::string_view name = frames != nullptr ? "APS5_TRACE_FRAMES" : "APS5_TRACE_SECONDS";
@@ -53,13 +79,24 @@ public:
std::uint64_t length = 0;
if (colon == std::string_view::npos || !number(text.substr(0, colon), start) || !number(text.substr(colon + 1), length) || length == 0)
throw std::invalid_argument(std::string(name) + "=" + std::string(text) + " is not <start>:<length> with a length above 0");
return TraceWindow(frames != nullptr, start, length);
return TraceWindow(frames != nullptr, start, length, trigger);
}
Edge Present(std::uint64_t present, Clock::duration elapsed) {
if (state == State::Closed) return Edge::None;
if (state == State::Waiting) {
if (frames ? present < start : wholeSeconds(elapsed) < start) return Edge::None;
if (trigger) {
if (elapsed < nextTriggerCheck) return Edge::None;
nextTriggerCheck = elapsed + std::chrono::milliseconds(250);
std::error_code error;
const auto status = std::filesystem::status(*trigger, error);
if (error && error != std::errc::no_such_file_or_directory)
throw std::filesystem::filesystem_error("APS5_TRACE_TRIGGER_FILE", *trigger, error);
if (!std::filesystem::exists(status)) return Edge::None;
if (!std::filesystem::is_regular_file(status))
throw std::invalid_argument("APS5_TRACE_TRIGGER_FILE is not a regular file");
}
state = State::Open;
openedPresent = present;
openedAt = elapsed;
@@ -77,7 +114,9 @@ public:
private:
enum class State { Waiting, Open, Closed };
TraceWindow(bool frames, std::uint64_t start, std::uint64_t length) : frames(frames), start(start), length(length) {}
TraceWindow(bool frames, std::uint64_t start, std::uint64_t length, const char* trigger) : frames(frames), start(start), length(length) {
if (trigger != nullptr) this->trigger = std::filesystem::path(std::u8string_view(reinterpret_cast<const char8_t*>(trigger)));
}
static bool number(std::string_view text, std::uint64_t& value) {
const auto end = text.data() + text.size();
@@ -95,6 +134,8 @@ private:
State state = State::Waiting;
std::uint64_t openedPresent = 0;
Clock::duration openedAt{};
std::optional<std::filesystem::path> trigger;
Clock::duration nextTriggerCheck{};
};
class TraceInterval {
@@ -815,7 +856,7 @@ public:
static constexpr const char* RenderPassScope = "Graphics.RenderPass";
static bool Configured() {
static const bool configured = std::getenv("APS5_TRACE_FRAMES") != nullptr || std::getenv("APS5_TRACE_SECONDS") != nullptr || std::getenv("APS5_TRACE_SUMMARY_EVERY") != nullptr || std::getenv("APS5_TRACE_BENCH") != nullptr;
static const bool configured = std::getenv("APS5_TRACE_FRAMES") != nullptr || std::getenv("APS5_TRACE_SECONDS") != nullptr || TraceWindow::TriggerConfigured() || std::getenv("APS5_TRACE_SUMMARY_EVERY") != nullptr || std::getenv("APS5_TRACE_BENCH") != nullptr;
return configured;
}
@@ -172,6 +172,7 @@ private:
PendingWriteObserver observe = nullptr;
HookWaitCounter hookWaits = nullptr;
PendingWriteQuery pendingSpan = nullptr;
bool spanQuery = false;
std::size_t descriptorSpanBytes = 0;
std::uint64_t rawInvalidations = 0;
std::uint32_t forceSync = 0;
@@ -0,0 +1,166 @@
#ifndef CORE_LIBS_PRX_LIBSCeAgcDriver_EXECUTION_INCLUDE_SUBMISSIONSNAPSHOTS_HPP
#define CORE_LIBS_PRX_LIBSCeAgcDriver_EXECUTION_INCLUDE_SUBMISSIONSNAPSHOTS_HPP
#include "../../../../../shader/recompiler/BdaAbi.hpp"
#include <array>
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <mutex>
#include <optional>
#include <vector>
namespace AgcDriver {
using FaultToken = std::uint32_t;
struct FaultTokenEntry {
alignas(std::atomic_ref<FaultToken>::required_alignment) mutable FaultToken token = 0;
std::uint64_t submitSerial = 0;
std::uint64_t programAddress = 0;
std::uint64_t variantId = 0;
char desc[48]{};
};
struct SubmitBracket {
std::uint64_t submitSerial = 0;
std::uint64_t lastCompleted = 0;
FaultToken firstToken = 0;
FaultToken lastToken = 0;
};
class FaultTokenRing {
public:
static constexpr std::size_t Capacity = 4096;
static FaultTokenRing& Instance() noexcept {
static FaultTokenRing store;
return store;
}
FaultTokenRing() = default;
FaultTokenRing(const FaultTokenRing&) = delete;
FaultTokenRing& operator=(const FaultTokenRing&) = delete;
FaultToken Claim() noexcept {
for (;;) {
FaultToken candidate = next.fetch_add(1, std::memory_order_relaxed);
if (candidate == 0) continue;
std::atomic_ref<FaultToken>(entries[static_cast<std::size_t>(candidate) % Capacity].token).store(0, std::memory_order_release);
return candidate;
}
}
FaultTokenEntry* Mutable(FaultToken token) noexcept {
if (token == 0) return nullptr;
return &entries[static_cast<std::size_t>(token) % Capacity];
}
std::optional<FaultTokenEntry> Find(FaultToken token) const noexcept {
try {
if (token == 0) return std::nullopt;
const FaultTokenEntry& slot = entries[static_cast<std::size_t>(token) % Capacity];
if (std::atomic_ref<FaultToken>(slot.token).load(std::memory_order_acquire) != token) return std::nullopt;
FaultTokenEntry copy;
copy.submitSerial = slot.submitSerial;
copy.programAddress = slot.programAddress;
copy.variantId = slot.variantId;
for (std::size_t i = 0; i < 48; ++i) copy.desc[i] = slot.desc[i];
if (std::atomic_ref<FaultToken>(slot.token).load(std::memory_order_acquire) != token) return std::nullopt;
copy.token = token;
return copy;
} catch (...) {
return std::nullopt;
}
}
private:
std::atomic<FaultToken> next{1};
std::array<FaultTokenEntry, Capacity> entries{};
};
struct SubmissionSnapshot {
std::uint64_t submitSerial = 0;
std::uint64_t spaceSerial = 0;
std::shared_ptr<const std::vector<ShaderRecompiler::BdaAbi::Range>> ranges;
SubmitBracket bracket{};
};
class SubmissionSnapshots {
public:
static constexpr std::size_t Capacity = 64;
static SubmissionSnapshots& DeviceSnapshots() {
static SubmissionSnapshots store;
return store;
}
SubmissionSnapshots() = default;
SubmissionSnapshots(const SubmissionSnapshots&) = delete;
SubmissionSnapshots& operator=(const SubmissionSnapshots&) = delete;
void NoteSubmit(std::uint64_t submitSerial, std::uint64_t spaceSerial, std::shared_ptr<const std::vector<ShaderRecompiler::BdaAbi::Range>> ranges, SubmitBracket bracket = {}) noexcept {
try {
if (submitSerial == 0 || ranges == nullptr) return;
std::lock_guard<std::mutex> lock(mutex);
Slot& slot = slots[submitSerial % Capacity];
slot.serial = submitSerial;
slot.spaceSerial = spaceSerial;
slot.ranges = std::move(ranges);
slot.bracket = bracket;
} catch (...) {
}
}
void Reset() noexcept {
try {
std::lock_guard<std::mutex> lock(mutex);
for (auto& slot : slots) {
slot.serial = 0;
slot.spaceSerial = 0;
slot.ranges.reset();
slot.bracket = {};
}
} catch (...) {
}
}
std::optional<SubmissionSnapshot> Find(std::uint64_t submitSerial) const noexcept {
try {
if (submitSerial == 0) return std::nullopt;
std::lock_guard<std::mutex> lock(mutex);
const Slot& slot = slots[submitSerial % Capacity];
if (slot.serial != submitSerial || slot.ranges == nullptr) return std::nullopt;
SubmissionSnapshot found;
found.submitSerial = slot.serial;
found.spaceSerial = slot.spaceSerial;
found.ranges = slot.ranges;
found.bracket = slot.bracket;
return found;
} catch (...) {
return std::nullopt;
}
}
std::optional<SubmitBracket> FindBracket(std::uint64_t submitSerial) const noexcept {
try {
if (submitSerial == 0) return std::nullopt;
std::lock_guard<std::mutex> lock(mutex);
const Slot& slot = slots[submitSerial % Capacity];
if (slot.serial != submitSerial) return std::nullopt;
return slot.bracket;
} catch (...) {
return std::nullopt;
}
}
private:
struct Slot {
std::uint64_t serial = 0;
std::uint64_t spaceSerial = 0;
std::shared_ptr<const std::vector<ShaderRecompiler::BdaAbi::Range>> ranges;
SubmitBracket bracket{};
};
mutable std::mutex mutex;
std::array<Slot, Capacity> slots{};
};
}
#endif
@@ -0,0 +1,21 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGCDRIVER_EXECUTION_INCLUDE_THREADSCRATCH_HPP
#define CORE_LIBS_PRX_LIBSCEAGCDRIVER_EXECUTION_INCLUDE_THREADSCRATCH_HPP
#include "prx/libc/include/HostThreadSlot.hpp"
#include "ThreadOwned.hpp"
namespace AgcDriver {
template<typename T, typename Tag>
T& ThreadScratch() {
auto* object = HostThreadSlot<T*, Tag>::Get();
if (object == nullptr) {
ShaderRecompiler::ThreadOwned(object);
HostThreadSlot<T*, Tag>::Set(object);
}
return *object;
}
}
#endif
@@ -32,6 +32,11 @@ struct FlipInfo {
std::int64_t argument;
};
class EopFlipAlreadyReserved final : public std::runtime_error {
public:
EopFlipAlreadyReserved() : std::runtime_error("EOP flip token is already reserved for this flip") {}
};
class IFlipRequest {
public:
virtual ~IFlipRequest() = default;
@@ -235,6 +235,7 @@ public:
bool DualSrcBlend() const;
bool PrimitiveListRestart() const;
bool SamplerFilterMinmax() const;
bool SamplerMirrorClampToEdge() const;
bool ConservativeRasterization() const;
VkShaderStageFlags SubgroupStages() const;
bool ProvokingVertexLast() const;
@@ -4,6 +4,7 @@
#include "prx/libSceAgcDriver/Execution/include/Driver/Draw/DrawPipeline.hpp"
#include "prx/libSceAgcDriver/Execution/include/GuestMemory.hpp"
#include <algorithm>
#include <array>
#include <spirv/unified1/spirv.hpp>
namespace AgcDriver::DriverDetail {
@@ -114,12 +115,13 @@ void DecodeGraphicsPrograms(DrawDecode& decoded, const QueueState& queue, const
require(snapshot.header.empty() || snapshot.type == type, "graphics program refers to an incompatible shader binary type");
if (!nullPixel && snapshot.header.empty()) NoteRawGraphicsDraw(snapshot);
const auto codeOffset = static_cast<std::size_t>((address - snapshot.codeAddress) / sizeof(std::uint32_t));
const auto memory = nullPixel || DriverOwnedProgram(snapshot.codeAddress) ? std::array<ShaderRecompiler::MemoryRegion, 2>{} : std::array<ShaderRecompiler::MemoryRegion, 2>{{{snapshot.codeAddress, std::as_bytes(std::span(snapshot.code))}, {snapshot.headerAddress, snapshot.header}}};
DrawProgram result{
{stage, address, std::span(snapshot.code).subspan(codeOffset), snapshot.headerAddress, snapshot.header},
userDataBase,
stage == Stage::Fragment || userDataBase == 0x04cu ? 0u : 8u,
{},
{{{snapshot.codeAddress, std::as_bytes(std::span(snapshot.code))}, {snapshot.headerAddress, snapshot.header}}},
memory,
program,
codeOffset
};
@@ -252,7 +252,7 @@ bool Driver::sameDecode(const DrawDecode& a, const DrawDecode& b) {
for (std::size_t i = 0; i < s.blends.size(); ++i) {
if (!sameBlend(s.blends[i], t.blends[i])) return false;
}
if (s.colorRop != t.colorRop || s.hasColorTarget != t.hasColorTarget || s.rectList != t.rectList || s.renderExtent.width != t.renderExtent.width || s.renderExtent.height != t.renderExtent.height || s.topology != t.topology || s.negativeOneToOne != t.negativeOneToOne || s.depthClamp != t.depthClamp || s.conservativeRasterization != t.conservativeRasterization || s.perSampleShading != t.perSampleShading || s.cullMode != t.cullMode || s.polygonMode != t.polygonMode || s.frontFace != t.frontFace || !sameBlend(s.blend, t.blend) || s.blendConstants != t.blendConstants) return false;
if (s.colorRop != t.colorRop || s.hasColorTarget != t.hasColorTarget || s.rectList != t.rectList || s.renderExtent.width != t.renderExtent.width || s.renderExtent.height != t.renderExtent.height || s.topology != t.topology || s.negativeOneToOne != t.negativeOneToOne || s.depthClamp != t.depthClamp || s.conservativeRasterization != t.conservativeRasterization || s.perSampleShading != t.perSampleShading || s.cullMode != t.cullMode || s.polygonMode != t.polygonMode || s.lineWidth != t.lineWidth || s.frontFace != t.frontFace || !sameBlend(s.blend, t.blend) || s.blendConstants != t.blendConstants) return false;
if (std::memcmp(&s.viewport, &t.viewport, sizeof(VkViewport)) != 0 || std::memcmp(&s.scissor, &t.scissor, sizeof(VkRect2D)) != 0) return false;
const auto& p = a.pixel;
const auto& q = b.pixel;
@@ -6,6 +6,7 @@
#include "prx/libSceAgcDriver/Execution/include/Screenshot.hpp"
#include "prx/libkernel/Time/include/SleepWake.hpp"
#include <algorithm>
#include <cstdio>
#include <mutex>
#include "RdnaDecoder/RdnaInstructionDecoder.hpp"
@@ -128,6 +129,15 @@ extern "C" void AgcDriverRegisterShader_nid_postfix(const Shader* shader) try {
LibcAwaitExit_nid_postfix();
}
extern "C" std::uint32_t AgcDriverInstructionWords_nid_postfix(std::span<const std::uint32_t> code, std::uint32_t index) {
try {
return ShaderRecompiler::DecodeRdnaInstruction(index * 4u, code, index).wordCount;
} catch (const std::exception& error) {
std::fprintf(stderr, "[agc] instruction at word %u of a fused front half cannot be decoded: %s\n", index, error.what());
return 0;
}
}
extern "C" void AgcDriverSuspendPoint_nid_postfix() try {
AgcDriver::SuspendPoint();
} catch (const ProcessShutdown&) {
@@ -151,6 +161,10 @@ extern "C" std::size_t AgcDriverAwaitedWaits_nid_postfix(AgcDriver::AwaitedWait*
return count;
}
extern "C" void AgcDriverWaitForPipelineJournal_nid_postfix() {
AgcDriver::DriverDetail::Driver::Get().WaitForPipelineJournal();
}
extern "C" void AgcDriverSerialProgress_nid_postfix(std::uint64_t* accepted, std::uint64_t* completed) {
const auto [submitted, done] = AgcDriver::DriverDetail::Driver::Get().SerialProgress();
*accepted = submitted;
@@ -297,6 +297,16 @@ std::vector<AwaitedWait> Driver::AwaitedWaits() {
return result;
}
void Driver::WaitForPipelineJournal() {
std::shared_ptr<VulkanDevice> localDevice = device.Load();
if (localDevice == nullptr) {
std::lock_guard gpuLock(GuestMemory::GpuMutex());
if (device == nullptr) device = std::make_shared<VulkanDevice>();
localDevice = device;
}
localDevice->WaitForPipelineJournalReplay();
}
std::pair<std::uint64_t, std::uint64_t> Driver::SerialProgress() {
std::lock_guard lock(mutex);
return {accepted, completed};
@@ -376,6 +376,9 @@ void Driver::storeBufferFill(std::uint32_t queueId, std::uint64_t base, std::siz
Graphics::StorageTexture::ClearByKeysFill(base, bytes, static_cast<std::uint8_t>(pattern[0]));
}
const bool uniform = pattern[0] == pattern[1] && pattern[1] == pattern[2] && pattern[2] == pattern[3];
const bool absorbable = uniform && coverage.cover == Graphics::StorageTexture::FillCover::None && Graphics::MultisampledColorFillAbsorbs(base, bytes, pattern[0]);
if (uniform && !absorbable) static_cast<void>(Graphics::DiscardFilledDepthPlanes(base, bytes, pattern[0]));
const auto discarded = fillClearEnabled() ? Graphics::StorageTexture::DiscardPendingInside(base, bytes) : 0u;
phase(FillDiscard);
const char* refusal = nullptr;
@@ -395,8 +398,7 @@ void Driver::storeBufferFill(std::uint32_t queueId, std::uint64_t base, std::siz
fillClearCount(coverage, bytes, pattern, discarded, cleared, refusal);
noteForeignWriter(base, base + bytes, queueId);
const bool uniform = pattern[0] == pattern[1] && pattern[1] == pattern[2] && pattern[2] == pattern[3];
const bool absorbed = !cleared && uniform && coverage.cover == Graphics::StorageTexture::FillCover::None && Graphics::MultisampledColorFillAbsorbs(base, bytes, pattern[0]);
const bool absorbed = !cleared && absorbable;
if (absorbed) {
++absorbedFills;
absorbedBytes += bytes;
@@ -2,16 +2,17 @@
#include "prx/libSceAgcDriver/Execution/include/Driver/Draw/DrawPipeline.hpp"
#include "prx/libSceAgcDriver/Execution/include/Driver/Memory/WriteEvidence.hpp"
#include "prx/libSceAgcDriver/Execution/include/GuestMemory.hpp"
#include "prx/libc/include/HostThreadSlot.hpp"
#include <cstdlib>
#include <cstring>
namespace AgcDriver::DriverDetail {
SampledReadScope::SampledReadScope(std::atomic<std::uint64_t>& reads) : previous(Driver::sampledRead()) {
Driver::sampledRead() = Driver::writeEvidenceEnabled() && reads.fetch_add(1, std::memory_order_relaxed) % Driver::writeEvidenceSampleEvery() == 0;
Driver::setSampledRead(Driver::writeEvidenceEnabled() && reads.fetch_add(1, std::memory_order_relaxed) % Driver::writeEvidenceSampleEvery() == 0);
}
SampledReadScope::~SampledReadScope() { Driver::sampledRead() = previous; }
SampledReadScope::~SampledReadScope() { Driver::setSampledRead(previous); }
void PendingView::Load() {
if (Driver::validateLegacy()) return;
@@ -26,9 +27,18 @@ bool PendingView::Overlaps(std::uint64_t address, std::size_t bytes) const {
return Driver::validateLegacy() ? Graphics::Recorder::SnapshotWriteOverlaps(address, bytes) : Graphics::Recorder::SnapshotOverlaps(snapshot.get(), address, bytes);
}
bool& Driver::sampledRead() {
static thread_local bool sampled = false;
return sampled;
namespace {
struct SampledReadTag;
}
bool Driver::sampledRead() {
return HostThreadSlot<bool, SampledReadTag>::Get();
}
void Driver::setSampledRead(bool sampled) {
HostThreadSlot<bool, SampledReadTag>::Set(sampled);
}
bool Driver::writeEvidenceEnabled() {
@@ -19,13 +19,14 @@
#include <cstdlib>
#include <functional>
#include <shared_mutex>
#include <stdexcept>
#include <string>
#include <utility>
namespace AgcDriver::DriverDetail {
namespace {
constexpr std::uint32_t eopSelfSignalFlipLimit = 4;
struct RingOrder {
std::uint32_t queue = 0xffffffffu;
@@ -121,22 +122,18 @@ bool& drawnSinceSeal() {
}
void Driver::deliverGuestEopInterrupt(std::uint32_t queue) {
if (!AgcDriverDeliverEopInterrupt(queue)) return;
std::lock_guard<std::mutex> lock(eopSelfSignalMutex);
eopSelfSignalFlips[queue] = 0;
void Driver::deliverGuestEopInterrupt(std::uint32_t queue, std::uint32_t context) {
AgcDriverDeliverEopInterrupt(queue, context);
}
void Driver::deliverFlipEopInterrupt(std::uint32_t queue) {
{
std::lock_guard<std::mutex> lock(eopSelfSignalMutex);
const auto latched = eopSelfSignalFlips.find(queue);
if (latched != eopSelfSignalFlips.end()) {
if (++latched->second <= eopSelfSignalFlipLimit) return;
eopSelfSignalFlips.erase(latched);
}
}
AgcDriverDeliverEopInterrupt(queue);
std::optional<std::uint32_t> Driver::releaseInterrupt(std::span<const std::uint32_t> packet, std::uint32_t opcode, bool carriesFlip) {
if (opcode != 0x49 || carriesFlip || packet.size() < 3) return std::nullopt;
const auto interruptSelect = (packet[2] >> 24u) & 7u;
if (interruptSelect == 0 || interruptSelect == 3) return std::nullopt;
if (packet.size() < 8) throw std::runtime_error("AGC: an interrupting release has no interrupt context dword");
const auto context = packet[7] & 0x0fffffffu;
if ((context & 0x08000000u) != 0) throw std::runtime_error("AGC: a release asks for typed interrupt context " + std::to_string(context) + ", which is not delivered as a graphics end-of-pipe event; not implemented");
return context;
}
template <typename TWork>
@@ -162,14 +159,25 @@ void Driver::execute(const Submission& submission) {
auto* submissionTiming = includeTimingSubmission(submission, true);
struct FlipHold {
Driver& driver;
std::uint32_t queue;
bool held;
bool working;
void Release() {
if (!held) return;
held = false;
driver.releaseFlipHold();
}
~FlipHold() { Release(); }
} flipHold{*this, submission.holdsFlip};
void Finish() {
if (!working) return;
const auto workSerial = driver.submitFlipWork(queue);
working = false;
driver.finishFlipWork(workSerial);
}
~FlipHold() {
Release();
if (working) driver.finishFlipWork(0);
}
} flipHold{*this, submission.queue, submission.holdsFlip, submission.holdsFlip};
const bool pipelined = submission.queue == 0 && DrawPipeline::Depth() != 0;
static const bool orderedWaits = std::getenv("APS5_PIPELINE_DRAIN_LABELS") == nullptr;
DrawPipeline::Active() = pipelined;
@@ -269,6 +277,7 @@ void Driver::execute(const Submission& submission) {
if (queue0) DrawFinisher::Get().Settle();
}
} settleFinisher{submission.queue == 0};
auto* const executingPacket = workerPacket();
for (std::size_t cursor = 0; cursor < submission.commands.size();) {
if (packetEpoch()) bumpEpoch(&EpochBumps::packets);
CheckFailure();
@@ -277,6 +286,7 @@ void Driver::execute(const Submission& submission) {
const auto count = Pm4::PacketWords(header);
const auto packet = std::span(submission.commands).subspan(cursor, count);
const auto opcode = (header >> 8u) & 0xffu;
if (executingPacket != nullptr) executingPacket->store((static_cast<std::uint64_t>(cursor + 1) << 8u) | opcode, std::memory_order_relaxed);
auto nextCursor = cursor + count;
const bool predicated = Pm4::Predicated(header) && queue.predication.operation != 0;
if (submission.queue == 0 && DrawFinisher::Busy() && !keepsDrawFinisher(header, opcode)) {
@@ -294,7 +304,7 @@ void Driver::execute(const Submission& submission) {
if (submission.queue != 0 && Graphics::Recorder::DispatchOverlapEnabled()) noteRingPacket(submission.queue, submission.serial, opcode, header);
PerformanceTimer timing("Driver.Packet");
if (!predicated) noteLabelIssue(packet, submission.queue);
if (pipelined && !predicated && header != FlipPacketHeader && header != RenderingWaitPacketHeader && !submission.flips.contains(cursor) && (enqueueLabelPacket(packet, opcode, submission.queue) || enqueueDmaPacket(packet, opcode, submission.queue, queue) || enqueueConstantRamDump(packet, opcode, submission.queue, queue))) {
if (pipelined && !predicated && header != FlipPacketHeader && header != RenderingWaitPacketHeader && !submission.flips.contains(cursor) && (enqueueLabelPacket(packet, opcode, submission.queue, releaseInterrupt(packet, opcode, false)) || enqueueDmaPacket(packet, opcode, submission.queue, queue) || enqueueConstantRamDump(packet, opcode, submission.queue, queue) || enqueueSampleDumpPacket(packet, opcode, submission.queue))) {
traceLabel(packet, submission.queue);
recent.Record(cursor);
cursor = nextCursor;
@@ -385,7 +395,7 @@ void Driver::execute(const Submission& submission) {
if (profilePackets) packetProfile.flushMs += std::chrono::duration<double, std::milli>(packetTimer.start - flushStart).count();
bool wroteOnGpu = false, endOfPipeInterrupt = false, interruptDeferred = false, drawPacket = false, sampleDump = false;
const bool drains = preparePacketMemory(submission, queue, packet, header, opcode, wroteOnGpu, endOfPipeInterrupt, interruptDeferred, drawPacket, sampleDump);
const bool drains = preparePacketMemory(submission, queue, packet, header, opcode, releaseInterrupt(packet, opcode, submission.flips.contains(cursor)), wroteOnGpu, endOfPipeInterrupt, interruptDeferred, drawPacket, sampleDump);
traceLabel(packet, submission.queue);
timing.Mark("prepare_memory");
@@ -409,12 +419,10 @@ void Driver::execute(const Submission& submission) {
Pm4::Execute(packet, queue);
if (const auto label = Pm4::DecodeLabelWrite(packet)) noteLabelStore(label->address, label->Bytes(), ++eventSerial, submission.queue);
}
if (endOfPipeInterrupt && !interruptDeferred) deliverGuestEopInterrupt(submission.queue);
}
if (deviceUse.owns_lock()) deviceUse.unlock();
CheckFailure();
std::uint64_t batchesAtFlip = 0, unsignaledAtFlip = 0;
bool flipInterruptDeferred = false;
Graphics::StorageTexture::NoteFlip();
if (!drains) {
@@ -424,13 +432,8 @@ void Driver::execute(const Submission& submission) {
if (localDevice != nullptr) static_cast<void>(Graphics::StorageTexture::StoreDrawnLinear("flip"));
if (!recordLabelsForPacket(localDevice.get(), submission.queue) && localDevice != nullptr) localDevice->SubmitRecorded(submission.queue == 0);
if (localDevice != nullptr) {
localDevice->FlipBatches(batchesAtFlip, unsignaledAtFlip);
const auto queueId = submission.queue;
flipInterruptDeferred = localDevice->AfterRecordedWork([this, queueId] { deliverFlipEopInterrupt(queueId); }, false);
}
if (localDevice != nullptr) localDevice->FlipBatches(batchesAtFlip, unsignaledAtFlip);
}
if (!flipInterruptDeferred) deliverFlipEopInterrupt(submission.queue);
++flipsCounted;
Graphics::NoteHostImportFrame();
if (batchesAtFlip != 0) flipSerial = batchesAtFlip;
@@ -593,7 +596,7 @@ void Driver::execute(const Submission& submission) {
if (const auto label = Pm4::DecodeLabelWrite(packet)) noteLabelStore(label->address, label->Bytes(), ++eventSerial, submission.queue);
}
}
if (endOfPipeInterrupt && !interruptDeferred) deliverGuestEopInterrupt(submission.queue);
if (endOfPipeInterrupt && !interruptDeferred) deliverGuestEopInterrupt(submission.queue, packet[7] & 0x0fffffffu);
}
if (drawPacket || (sampleDump && wroteOnGpu)) Graphics::Recorder::CountRecordedWork();
timing.Mark(header == RenderingWaitPacketHeader ? "rendering_wait" : opcode == 0x3c || opcode == 0x93 ? "memory_wait" : opcode == 0x15 || opcode == 0x16 ? "dispatch" : drawPacket ? "draw" : "execute");
@@ -608,12 +611,15 @@ void Driver::execute(const Submission& submission) {
static const bool submitAtEnd = std::getenv("APS5_SUBMIT_AT_END") != nullptr;
if (pipelined && orderedCompletion && deferredLabels().labels.empty()) {
if (submission.rewindTail == nullptr) {
flipHold.working = false;
deferCompletion(submission);
return;
}
if ((std::atomic_ref<std::uint32_t>(*const_cast<std::uint32_t*>(submission.rewindTail - 1)).load(std::memory_order_acquire) & 0x80000000u) != 0) {
DrawPipeline::Queue0().Enqueue([this, progress = submission.progress] {
submitOpenWork(progress);
const bool holdsFlip = std::exchange(flipHold.working, false);
DrawPipeline::Queue0().Enqueue([this, holdsFlip, progress = submission.progress] {
if (holdsFlip) finishFlipWork(submitFlipWork(0));
else submitOpenWork(progress);
wakeQueueZeroForCompletions();
}, {});
endTiming.Finish();
@@ -626,6 +632,7 @@ void Driver::execute(const Submission& submission) {
auto& costs = submissionCosts(submission.queue);
if (!submitAtEnd && submission.rewindTail == nullptr && submission.queue == 0 && workerQueued() != nullptr && workerQueued()->load(std::memory_order_acquire) != 0) {
++costs.endSkipped;
flipHold.Finish();
return;
}
++costs.endSubmits;
@@ -636,6 +643,7 @@ void Driver::execute(const Submission& submission) {
recordDeferredLabels(localDevice.get(), submission.queue);
if (localDevice != nullptr) localDevice->SubmitRecorded(submission.queue == 0);
}
flipHold.Finish();
endTiming.Finish();
if (submission.rewindTail != nullptr) {
if (submission.progress) submitOpenWork(submission.progress);
@@ -54,15 +54,14 @@ std::optional<Pm4::MemoryCopy> decodeCopy(std::span<const std::uint32_t> packet)
}
bool Driver::preparePacketMemory(const Submission& submission, QueueState& queue, std::span<const std::uint32_t> packet, std::uint32_t header, std::uint32_t opcode, bool& wroteOnGpu, bool& endOfPipeInterrupt, bool& interruptDeferred, bool& drawPacket, bool& sampleDump) {
bool Driver::preparePacketMemory(const Submission& submission, QueueState& queue, std::span<const std::uint32_t> packet, std::uint32_t header, std::uint32_t opcode, std::optional<std::uint32_t> interrupt, bool& wroteOnGpu, bool& endOfPipeInterrupt, bool& interruptDeferred, bool& drawPacket, bool& sampleDump) {
static const bool drainAll = std::getenv("APS5_DRAIN_ALL") != nullptr;
static const bool profile = std::getenv("APS5_PROFILE_DRAW") != nullptr;
wroteOnGpu = false;
bool orderedAlready = false;
const auto interruptSelect = opcode == 0x49 ? (packet[2] >> 24u) & 7u : 0u;
endOfPipeInterrupt = interruptSelect != 0 && interruptSelect != 3;
endOfPipeInterrupt = interrupt.has_value();
interruptDeferred = false;
if (!drainAll && endOfPipeInterrupt) {
const auto label = Pm4::DecodeLabelWrite(packet);
@@ -94,7 +93,8 @@ bool Driver::preparePacketMemory(const Submission& submission, QueueState& queue
}
if (reason == 0 || reason == 5) {
const auto queueId = submission.queue;
interruptDeferred = localDevice->AfterRecordedWork([this, queueId] { deliverGuestEopInterrupt(queueId); }, submission.queue == 0);
const auto context = *interrupt;
interruptDeferred = localDevice->AfterRecordedWork([this, queueId, context] { deliverGuestEopInterrupt(queueId, context); }, submission.queue == 0);
if (interruptDeferred && workOpen) localDevice->SubmitRecorded(submission.queue == 0);
wroteOnGpu = true;
} else if (reason == 1) {
@@ -338,6 +338,30 @@ void Driver::dumpSampleCounters(std::uint64_t address) {
}
}
bool Driver::enqueueSampleDumpPacket(std::span<const std::uint32_t> packet, std::uint32_t opcode, std::uint32_t queue) {
static const bool ordered = std::getenv("APS5_PIPELINE_DRAIN_SAMPLE_DUMPS") == nullptr;
if (!ordered || opcode != 0x46 || queue != 0 || packet.size() < 4 || !Pm4::SampleDump(packet) || !DrawPipeline::Active() || !deferredLabels().labels.empty()) return false;
const auto address = Pm4::SampleDumpAddress(packet);
if (address == 0 || !GuestMemory::Accessible(reinterpret_cast<const void*>(address), Pm4::SampleDumpBytes, true)) return false;
DrawPipeline::Queue0().Enqueue([this, queue, address] {
GuestMemory::SetCurrentPacket(0x46, queue);
bool wrote = false;
{
GuestMemory::TagGpuLockSite(GuestMemory::GpuLockSite::Label);
std::lock_guard gpuLock(GuestMemory::GpuMutex());
if (const auto localDevice = device.Load()) {
recordDeferredLabels(localDevice.get(), queue);
wrote = localDevice->DumpSamplesOnGpu(address);
if (!wrote) localDevice->WaitIdle();
}
}
if (!wrote) dumpSampleCounters(address);
}, {{address, address + Pm4::SampleDumpBytes}});
++sampleDumpsQueued;
Graphics::Recorder::CountRecordedWork();
return true;
}
bool Driver::enqueueDmaPacket(std::span<const std::uint32_t> packet, std::uint32_t opcode, std::uint32_t queue, const QueueState& state) {
if (opcode != 0x50 || queue != 0 || packet.size() < 7 || !DrawPipeline::Active() || !deferredLabels().labels.empty()) return false;
const auto source = ((packet[1] >> 29u) & 3u) | ((packet[6] >> 24u) & 4u) | ((packet[6] >> 25u) & 8u);
@@ -463,10 +487,9 @@ bool Driver::labelPacketQueues(std::span<const std::uint32_t> packet, std::uint3
return opcode == 0x49 && ((packet[2] >> 29u) == 0 || (packet[3] | (static_cast<std::uint64_t>(packet[4]) << 32u)) == 0);
}
bool Driver::enqueueLabelPacket(std::span<const std::uint32_t> packet, std::uint32_t opcode, std::uint32_t queue) {
bool Driver::enqueueLabelPacket(std::span<const std::uint32_t> packet, std::uint32_t opcode, std::uint32_t queue, std::optional<std::uint32_t> interrupt) {
if (!labelPacketQueues(packet, opcode)) return false;
const auto interruptSelect = opcode == 0x49 ? (packet[2] >> 24u) & 7u : 0u;
const bool endOfPipeInterrupt = interruptSelect != 0 && interruptSelect != 3;
const bool endOfPipeInterrupt = interrupt.has_value();
const auto label = Pm4::DecodeLabelWrite(packet);
if (!label.has_value()) {
if (opcode != 0x49) return false;
@@ -489,10 +512,10 @@ bool Driver::enqueueLabelPacket(std::span<const std::uint32_t> packet, std::uint
if (endOfPipeInterrupt) bumpEpoch(&EpochBumps::drains);
auto stored = bytes;
auto labelBytes = bytes;
auto enqueue =[this, queue, opcode, address, bytes = std::move(bytes), endOfPipeInterrupt, writes, stored = std::move(stored)]() mutable {
DrawPipeline::Queue0().Enqueue([this, queue, opcode, address, bytes = std::move(bytes), endOfPipeInterrupt] {
auto enqueue =[this, queue, opcode, address, bytes = std::move(bytes), interrupt, writes, stored = std::move(stored)]() mutable {
DrawPipeline::Queue0().Enqueue([this, queue, opcode, address, bytes = std::move(bytes), interrupt] {
GuestMemory::SetCurrentPacket(opcode, queue);
commitLabel(queue, address, bytes, endOfPipeInterrupt);
commitLabel(queue, address, bytes, interrupt);
}, std::move(writes), address, std::move(stored));
};
if (queue == 0 && DrawFinisher::Overlap() && DrawFinisher::Busy()) {
@@ -508,7 +531,7 @@ bool Driver::enqueueLabelPacket(std::span<const std::uint32_t> packet, std::uint
return true;
}
void Driver::commitLabel(std::uint32_t queue, std::uint64_t address, std::span<const std::byte> bytes, bool endOfPipeInterrupt) {
void Driver::commitLabel(std::uint32_t queue, std::uint64_t address, std::span<const std::byte> bytes, std::optional<std::uint32_t> interrupt) {
GuestMemory::TagGpuLockSite(GuestMemory::GpuLockSite::Label);
std::lock_guard gpuLock(GuestMemory::GpuMutex());
const auto localDevice = device.Load();
@@ -530,14 +553,15 @@ void Driver::commitLabel(std::uint32_t queue, std::uint64_t address, std::span<c
} else {
++noOpLabels;
}
if (endOfPipeInterrupt) {
if (interrupt.has_value()) {
const auto context = *interrupt;
bool deferred = false;
if (bytes.empty() && localDevice != nullptr && queue == 0 && Graphics::StorageTexture::StoreDrawnLinear("interrupt") != 0) workOpen = true;
if (localDevice != nullptr && (reason == 0 || reason == 5 || reason == 6)) {
deferred = localDevice->AfterRecordedWork([this, queue] { deliverGuestEopInterrupt(queue); }, queue == 0);
deferred = localDevice->AfterRecordedWork([this, queue, context] { deliverGuestEopInterrupt(queue, context); }, queue == 0);
if (deferred && workOpen) localDevice->SubmitRecorded(queue == 0);
}
if (!deferred) deliverGuestEopInterrupt(queue);
if (!deferred) deliverGuestEopInterrupt(queue, context);
}
submitDueAfterCommit(localDevice.get());
}
@@ -24,12 +24,17 @@ std::uint32_t Driver::ReserveEopFlipAt(const FlipInfo& info, std::uint32_t token
std::uint32_t Driver::reserveEopFlip(const FlipInfo& info, std::uint32_t token) {
rethrowFailure();
checkStopping();
require(token >= EopFlipTokenBase && token <= EopFlipTokenLimit && !eopFlips.contains(token), "EOP flip token is not free");
require(token >= EopFlipTokenBase && token <= EopFlipTokenLimit, "EOP flip token is out of range");
const auto output = outputs.find(info.handle);
require(output != outputs.end(), "EOP flip references an unregistered video output");
if (const auto found = eopFlips.find(token); found != eopFlips.end()) {
const auto& reserved = found->second.info;
require(reserved.handle == info.handle && reserved.index == info.index && reserved.mode == info.mode && reserved.argument == info.argument, "EOP flip token is reserved for a different flip");
throw EopFlipAlreadyReserved{};
}
auto request = output->second->TryReserve(info);
if (!request) return 0;
eopFlips.emplace(token, EopFlip{info.handle, std::move(request)});
eopFlips.emplace(token, EopFlip{info, std::move(request)});
nextEopToken = std::max(nextEopToken, token + 1);
return token;
}
@@ -53,7 +58,7 @@ void Driver::UnregisterVideoOutput(std::uint32_t handle, const std::shared_ptr<I
std::lock_guard lock(mutex);
const auto it = outputs.find(handle);
require(it != outputs.end() && it->second == output, "video output registration mismatch");
std::erase_if(eopFlips, [handle](const auto& entry) { return entry.second.handle == handle; });
std::erase_if(eopFlips, [handle](const auto& entry) { return entry.second.info.handle == handle; });
outputs.erase(it);
}
@@ -61,13 +66,17 @@ void Driver::AttachWindow(const PresentationWindow& window) {
CheckFailure();
std::unique_lock replacing(deviceReplacement);
GuestMemory::TagGpuLockSite(GuestMemory::GpuLockSite::Present);
PerformanceTimer timing("Driver.AttachWindow");
std::lock_guard lock(GuestMemory::GpuMutex());
timing.Mark("gpu_mutex_wait");
if (device) {
require(device->Window() == nullptr, "a window is already attached to the device");
device->PrepareForReplacement();
replacedDevices.push_back(device);
timing.Mark("device_replacement");
}
device = std::make_shared<VulkanDevice>(&window);
timing.Mark("vulkan_device_create");
}
void Driver::Present(const PresentationWindow& window, const DisplayBuffer* buffer, const DisplayBuffer* plane, bool opaque, void (*gpuReady)(void*), void* context) {
@@ -50,6 +50,8 @@ FrameTiming* Driver::includeTimingSubmission(const Submission& submission, bool
}
void Driver::markCompleted(std::uint64_t serial) {
static const bool traceGpu = std::getenv("APS5_TRACE_GPU") != nullptr;
if (traceGpu) std::fprintf(stderr, "[gpu] %.1f completed serial=%llu (in order up to %llu)\n", TraceMs(), static_cast<unsigned long long>(serial), static_cast<unsigned long long>(completed));
completedOutOfOrder.insert(serial);
while (!completedOutOfOrder.empty() && *completedOutOfOrder.begin() == completed + 1) {
completed = *completedOutOfOrder.begin();
@@ -70,8 +72,10 @@ void Driver::deferCompletion(const Submission& submission) {
queue0Uncommitted.push_back(received);
}
completionDeferred() = true;
DrawPipeline::Queue0().Enqueue([this, serial = submission.serial, received, labelWrites = submission.labelWrites, progress = submission.progress] {
completeSubmission(serial, received, labelWrites, progress);
static const bool traceGpu = std::getenv("APS5_TRACE_GPU") != nullptr;
if (traceGpu) std::fprintf(stderr, "[gpu] %.1f deferred completion serial=%llu to the draw pipeline\n", TraceMs(), static_cast<unsigned long long>(submission.serial));
DrawPipeline::Queue0().Enqueue([this, serial = submission.serial, received, labelWrites = submission.labelWrites, progress = submission.progress, holdsFlip = submission.holdsFlip] {
completeSubmission(serial, received, labelWrites, progress, holdsFlip);
}, {});
}
@@ -95,7 +99,15 @@ void Driver::wakeQueueZeroForCompletions() {
changed.notify_all();
}
void Driver::completeSubmission(std::uint64_t serial, std::uint64_t received, std::span<const std::uint64_t> labelWrites, const std::shared_ptr<SubmissionProgress>& progress) {
std::uint64_t Driver::submitFlipWork(std::uint32_t queue) {
GuestMemory::TagGpuLockSite(GuestMemory::GpuLockSite::End);
std::lock_guard gpuLock(GuestMemory::GpuMutex());
const auto localDevice = device.Load();
recordDeferredLabels(localDevice.get(), queue);
return localDevice != nullptr ? localDevice->SubmitAndEpoch() : 0;
}
void Driver::completeSubmission(std::uint64_t serial, std::uint64_t received, std::span<const std::uint64_t> labelWrites, const std::shared_ptr<SubmissionProgress>& progress, bool holdsFlip) {
struct Complete {
Driver& driver;
std::uint64_t serial, received;
@@ -113,7 +125,8 @@ void Driver::completeSubmission(std::uint64_t serial, std::uint64_t received, st
if (notify) driver.changed.notify_all();
}
} complete{*this, serial, received, labelWrites};
submitOpenWork(progress);
if (holdsFlip) finishFlipWork(submitFlipWork(0));
else submitOpenWork(progress);
}
const std::atomic<std::uint64_t>*& Driver::workerQueued() {
@@ -121,6 +134,11 @@ const std::atomic<std::uint64_t>*& Driver::workerQueued() {
return queued;
}
std::atomic<std::uint64_t>*& Driver::workerPacket() {
static thread_local std::atomic<std::uint64_t>* packet = nullptr;
return packet;
}
void Driver::reapCompletionLabels() {
std::unique_lock gpuLock(GuestMemory::GpuMutex(), std::try_to_lock);
if (!gpuLock.owns_lock()) {
@@ -177,6 +195,7 @@ void Driver::run(std::uint32_t id) noexcept {
auto& worker = workers.at(id);
auto& pending = worker.pending;
workerQueued() = &worker.queued;
workerPacket() = &worker.executingPacket;
if (traceGpu && pending.empty()) std::fprintf(stderr, "[gpu] %.1f idle queue=0x%x\n", TraceMs(), id);
const auto ready = [&] { return failure || stopping || !pending.empty(); };
const auto allQueuesIdle = [&] {
@@ -241,6 +260,7 @@ void Driver::run(std::uint32_t id) noexcept {
}
submission = std::move(pending.front());
pending.pop_front();
worker.executingPacket.store(0, std::memory_order_relaxed);
if (APS5_ENABLE_TIMING_LOG) submission.dequeuedAt = std::chrono::steady_clock::now();
if (id == 0) queue0Executing = submission.suspend ? 0 : submission.received;
struct OrderHold {
@@ -263,7 +263,7 @@ void Driver::noteAwaitingTitle(std::uint32_t queue, std::uint64_t awaited) {
changed.notify_all();
}
void Driver::holdFlipBehindWorker(const Submission& submission) {
void Driver::holdFlipBehindWorker(const Submission& submission, bool cpuFlip) {
if (submission.queue != 0 || onWorkerThread()) return;
bool candidate = false;
for (std::size_t cursor = 0; cursor < submission.commands.size() && !candidate; cursor += Pm4::PacketWords(submission.commands[cursor])) {
@@ -281,6 +281,39 @@ void Driver::holdFlipBehindWorker(const Submission& submission) {
flipHolders.fetch_add(1, std::memory_order_acq_rel);
changed.wait(lock, [&] { return failure != nullptr || stopping.load(std::memory_order_acquire) || shutdownToken.stop_requested() || flipsAhead.load(std::memory_order_acquire) == 0 || queue0AwaitsTitle.load(std::memory_order_acquire); });
flipHolders.fetch_sub(1, std::memory_order_acq_rel);
if (cpuFlip || failure != nullptr || stopping.load(std::memory_order_acquire) || shutdownToken.stop_requested() || flipsAhead.load(std::memory_order_acquire) != 0) return;
flipHolders.fetch_add(1, std::memory_order_acq_rel);
changed.wait(lock, [&] { return failure != nullptr || stopping.load(std::memory_order_acquire) || shutdownToken.stop_requested() || flipWorkOpen.load(std::memory_order_acquire) == 0 || queue0AwaitsTitle.load(std::memory_order_acquire); });
flipHolders.fetch_sub(1, std::memory_order_acq_rel);
if (failure != nullptr || stopping.load(std::memory_order_acquire) || shutdownToken.stop_requested() || flipWorkOpen.load(std::memory_order_acquire) != 0) return;
const auto workSerial = flipWorkSerial.load(std::memory_order_acquire);
lock.unlock();
waitFlipWork(workSerial);
}
void Driver::waitFlipWork(std::uint64_t workSerial) {
if (workSerial == 0) return;
auto localDevice = device.Load();
if (localDevice == nullptr) return;
if (localDevice->CanWaitUnlocked()) {
try {
localDevice->WaitRecorded(workSerial);
} catch (...) {
GuestMemory::TagGpuLockSite(GuestMemory::GpuLockSite::Wait);
std::lock_guard gpuLock(GuestMemory::GpuMutex());
localDevice.reset();
throw;
}
GuestMemory::TagGpuLockSite(GuestMemory::GpuLockSite::Wait);
std::lock_guard gpuLock(GuestMemory::GpuMutex());
localDevice->ReapRecorded(workSerial);
localDevice.reset();
return;
}
GuestMemory::TagGpuLockSite(GuestMemory::GpuLockSite::Wait);
std::lock_guard gpuLock(GuestMemory::GpuMutex());
localDevice->WaitIdle();
localDevice.reset();
}
void Driver::releaseFlipHold() {
@@ -289,6 +322,13 @@ void Driver::releaseFlipHold() {
if (flipHolders.load(std::memory_order_acquire) != 0) changed.notify_all();
}
void Driver::finishFlipWork(std::uint64_t workSerial) {
std::lock_guard lock(mutex);
if (workSerial > flipWorkSerial.load(std::memory_order_relaxed)) flipWorkSerial.store(workSerial, std::memory_order_release);
flipWorkOpen.fetch_sub(1, std::memory_order_acq_rel);
if (flipHolders.load(std::memory_order_acquire) != 0) changed.notify_all();
}
void Driver::reserveOutputs(Submission& submission) {
std::set<std::uint32_t> eopTokens;
for (std::size_t cursor = 0; cursor < submission.commands.size();) {
@@ -470,7 +510,7 @@ void Driver::Submit(const Packet* packet, std::uint32_t queue, bool cpuFlip) {
readRegisterLists(submission);
if (APS5_ENABLE_TIMING_LOG) submission.validatedAt = std::chrono::steady_clock::now();
waitForFlipRoom(submission);
holdFlipBehindWorker(submission);
holdFlipBehindWorker(submission, cpuFlip);
AwaitRegistrationPreparation();
if (LibraryPrebuildsWaiting()) PrioritizeLibraryPrebuilds(BoundGraphicsPrograms(submission));
if (APS5_ENABLE_TIMING_LOG) submission.roomReadyAt = std::chrono::steady_clock::now();
@@ -498,11 +538,12 @@ void Driver::Submit(const Packet* packet, std::uint32_t queue, bool cpuFlip) {
submission.flips.begin()->second->GpuReady(frame);
lock.unlock();
Graphics::NoteHostImportFrame();
AgcDriverDeliverEopInterrupt(0);
return;
}
submission.shaders = shaders;
submission.serial = accepted + 1;
if (trace) std::fprintf(stderr, "[gpu] %.1f accepted serial=%llu queue=0x%x dwords=%zu at %p%s\n", TraceMs(), static_cast<unsigned long long>(submission.serial), queue, submission.commands.size(),
static_cast<const void*>(descriptor.addr), cpuFlip ? " (cpu flip)" : "");
submission.received = ++eventSerial;
const auto now = std::chrono::steady_clock::now();
@@ -518,6 +559,7 @@ void Driver::Submit(const Packet* packet, std::uint32_t queue, bool cpuFlip) {
if (queue == 0 && !submission.flips.empty()) {
submission.holdsFlip = true;
flipsAhead.fetch_add(1, std::memory_order_acq_rel);
flipWorkOpen.fetch_add(1, std::memory_order_acq_rel);
}
if (!submission.flips.empty()) ++flipSubmissionsOfThread();
enqueue(std::move(submission));
@@ -559,6 +601,8 @@ void Driver::SuspendPoint() {
Submission boundary{};
boundary.serial = accepted + 1;
boundary.suspend = true;
static const bool trace = std::getenv("APS5_TRACE_GPU") != nullptr;
if (trace) std::fprintf(stderr, "[gpu] %.1f accepted serial=%llu suspend point\n", TraceMs(), static_cast<unsigned long long>(boundary.serial));
boundary.queue = 0;
boundary.receivedAt = receivedAt;
@@ -2317,6 +2317,10 @@ std::uint32_t DepthCopyPixelUserWords(bool multisampled) {
return multisampled ? 9u : 8u;
}
bool DriverOwnedProgram(std::uint64_t codeAddress) {
return codeAddress == NullPixelProgramAddress() || codeAddress == DepthCopyPixelProgramAddress(false) || codeAddress == DepthCopyPixelProgramAddress(true);
}
void Driver::ResolveGraphicsAbi(const Shader* vertex, const Shader* pixel, std::uint32_t primitiveType) {
BindTitleThread();
PerformanceContext timingContext(FrameTiming::Preparation());
@@ -63,6 +63,44 @@ void Driver::noteLabelIssue(std::span<const std::uint32_t> packet, std::uint32_t
for (const auto& store : stores) take(store.address, store.bytes);
}
bool Driver::findWaitProducer(std::uint64_t address, std::size_t bytes, std::uint64_t& token) {
std::lock_guard lock(mutex);
token = 0;
std::vector<std::uint64_t> frontier{address};
std::unordered_set<std::uint32_t> visited;
bool found = false;
for (std::size_t depth = 0; depth < 8 && !frontier.empty(); ++depth) {
const std::size_t span = depth == 0 ? bytes : 8;
std::vector<std::uint64_t> next;
for (const auto current : frontier) {
for (const auto& [queue, worker] : workers) {
bool holds = false;
for (std::size_t offset = 0; offset < span; offset += 4) {
if (worker.unfinishedWrites.contains(current + offset)) {
holds = true;
break;
}
}
if (!holds || !visited.insert(queue).second) continue;
found = true;
std::uint64_t motion = worker.executingPacket.load(std::memory_order_relaxed) & 0xffffffffull;
motion |= static_cast<std::uint64_t>(worker.pending.size() & 0xffu) << 32;
motion |= static_cast<std::uint64_t>(queue & 0xffu) << 40;
motion *= 0x9e3779b97f4a7c15ull + 2ull * queue;
const auto shift = depth * 8;
token ^= shift == 0 ? motion : ((motion << shift) | (motion >> (64 - shift)));
if (queue != 0 && (queue < 0x20 || queue > SubmissionQueueEnd)) continue;
const auto slot = queue == 0 ? 0 : queue - 0x20 + 1;
if (const auto awaited = awaitedSlots[slot].address.load(std::memory_order_acquire); awaited != 0) next.push_back(awaited);
}
}
std::sort(next.begin(), next.end());
next.erase(std::unique(next.begin(), next.end()), next.end());
frontier = std::move(next);
}
return found;
}
bool Driver::storedSince(std::span<const std::uint32_t> packet, std::uint64_t address, std::size_t bytes, std::uint64_t received, std::uint32_t queue, std::uint32_t* writer) {
std::lock_guard lock(labelStoresMutex);
const auto low = labelStores.find(address);
@@ -21,7 +21,7 @@ std::atomic<std::uint64_t> packetLockRecordUs{0}, packetLockSubmitUs{0};
std::atomic<std::uint64_t> triesFailed[TrySites] = {};
std::atomic<std::uint64_t> storesOnGpu{0}, storesBehindCompletions{0}, storesOnCpu{0}, storesDrained{0}, dmaFills{0}, copiesToHostMemory{0}, copiesBehindPendingSources{0};
std::atomic<std::uint64_t> storesOnGpu{0}, storesBehindCompletions{0}, storesOnCpu{0}, storesDrained{0}, dmaFills{0}, copiesToHostMemory{0}, copiesBehindPendingSources{0}, sampleDumpsQueued{0};
std::map<std::uint32_t, std::uint64_t> drainCounts;
@@ -39,7 +39,7 @@ SubmissionCosts& submissionCosts(std::uint32_t queue) {
void reportSync() {
std::string report;
for (const auto& [code, count] : drainCounts) report += " " + (code == 0xffffu ? std::string("flip") : Pm4::Name(code << 8u)) + "=" + std::to_string(count);
AgcDriver::ProfilePrint_nid_no_patch("[sync] %llu device drains by packet:%s (%llu waited without the GPU mutex); %llu labels written on the GPU, %llu deferred behind completions, %llu no-op, fallbacks: idle %llu, completions %llu, not imported %llu, undecodable %llu; %llu labels queued per worker, recorded in %llu groups, %llu recorded at once; stores: %llu recorded on the GPU, %llu behind completions, %llu on the CPU (idle), %llu synced (drained), %llu DMA fills stored as buffer fills; %llu copies into host memory synced on their source; %llu copies of up to 64 KiB recorded on the GPU behind their source's pending stores\n", static_cast<unsigned long long>(drainTotal), report.c_str(), static_cast<unsigned long long>(unlockedDrains.load()), static_cast<unsigned long long>(gpuLabels.load()), static_cast<unsigned long long>(completionLabels.load()), static_cast<unsigned long long>(noOpLabels.load()), static_cast<unsigned long long>(labelFallbacks[1].load()), static_cast<unsigned long long>(labelFallbacks[2].load()), static_cast<unsigned long long>(labelFallbacks[3].load()), static_cast<unsigned long long>(labelFallbacks[4].load()), static_cast<unsigned long long>(queuedLabels.load()), static_cast<unsigned long long>(labelGroups.load()), static_cast<unsigned long long>(immediateLabels.load()), static_cast<unsigned long long>(storesOnGpu.load()), static_cast<unsigned long long>(storesBehindCompletions.load()), static_cast<unsigned long long>(storesOnCpu.load()), static_cast<unsigned long long>(storesDrained.load()), static_cast<unsigned long long>(dmaFills.load()), static_cast<unsigned long long>(copiesToHostMemory.load()), static_cast<unsigned long long>(copiesBehindPendingSources.load()));
AgcDriver::ProfilePrint_nid_no_patch("[sync] %llu device drains by packet:%s (%llu waited without the GPU mutex); %llu labels written on the GPU, %llu deferred behind completions, %llu no-op, fallbacks: idle %llu, completions %llu, not imported %llu, undecodable %llu; %llu labels queued per worker, recorded in %llu groups, %llu recorded at once; stores: %llu recorded on the GPU, %llu behind completions, %llu on the CPU (idle), %llu synced (drained), %llu DMA fills stored as buffer fills; %llu copies into host memory synced on their source; %llu copies of up to 64 KiB recorded on the GPU behind their source's pending stores; %llu occlusion counter dumps queued behind pipelined draws\n", static_cast<unsigned long long>(drainTotal), report.c_str(), static_cast<unsigned long long>(unlockedDrains.load()), static_cast<unsigned long long>(gpuLabels.load()), static_cast<unsigned long long>(completionLabels.load()), static_cast<unsigned long long>(noOpLabels.load()), static_cast<unsigned long long>(labelFallbacks[1].load()), static_cast<unsigned long long>(labelFallbacks[2].load()), static_cast<unsigned long long>(labelFallbacks[3].load()), static_cast<unsigned long long>(labelFallbacks[4].load()), static_cast<unsigned long long>(queuedLabels.load()), static_cast<unsigned long long>(labelGroups.load()), static_cast<unsigned long long>(immediateLabels.load()), static_cast<unsigned long long>(storesOnGpu.load()), static_cast<unsigned long long>(storesBehindCompletions.load()), static_cast<unsigned long long>(storesOnCpu.load()), static_cast<unsigned long long>(storesDrained.load()), static_cast<unsigned long long>(dmaFills.load()), static_cast<unsigned long long>(copiesToHostMemory.load()), static_cast<unsigned long long>(copiesBehindPendingSources.load()), static_cast<unsigned long long>(sampleDumpsQueued.load()));
}
void countLabelOutcome(int reason) {
@@ -356,6 +356,8 @@ void Driver::waitMemory(std::span<const std::uint32_t> packet, std::uint32_t que
bool spinning = pauseSpin;
std::uint32_t polls = 0;
StallWatch stall(queue);
std::uint64_t producerToken = 0;
auto lastProducerScan = std::chrono::steady_clock::now() - std::chrono::milliseconds(100);
while (!memorySatisfied()) {
if (std::uint32_t writer = queue; !requireMemory && storedSince(packet, awaited, awaitedBytes, received, queue, &writer)) {
if (writer != queue) notePendingWait(packet, queue, received);
@@ -386,6 +388,13 @@ void Driver::waitMemory(std::span<const std::uint32_t> packet, std::uint32_t que
lastDone = done;
start = std::chrono::steady_clock::now();
stall.Progressed();
} else if (const auto now = std::chrono::steady_clock::now(); now - lastProducerScan >= std::chrono::milliseconds(100)) {
lastProducerScan = now;
if (std::uint64_t token = 0; findWaitProducer(awaited, awaitedBytes, token) && token != producerToken) {
producerToken = token;
start = now;
stall.Progressed();
}
}
stall.Check(((packet[0] >> 8u) & 0xffu) == 0x93u ? "WAIT_REG_MEM_64 at" : "WAIT_REG_MEM at", awaited);
@@ -0,0 +1,135 @@
#include "prx/libSceAgcDriver/Execution/include/Float16ConversionProbe.hpp"
#include "prx/libSceAgcDriver/Execution/include/VulkanDevice.hpp"
#include <spirv/unified1/spirv.hpp>
#include <algorithm>
#include <array>
#include <span>
#include <vector>
namespace AgcDriver {
namespace {
using ShaderRecompiler::ShaderStage;
constexpr std::uint32_t Threads = 32;
constexpr std::uint32_t Halves = 1u << 16u;
alignas(256) constexpr std::array<std::uint32_t, 10> WidenCode{
0x34020082u, 0x8f098708u, 0x4a020209u, 0xe0301000u, 0x80000401u, 0xbf8c3f70u, 0x7e0a1704u, 0xe0701000u,
0x80010501u, 0xbf810000u,
};
alignas(256) constexpr std::array<std::uint32_t, 10> NarrowCode{
0x34020082u, 0x8f098708u, 0x4a020209u, 0xe0301000u, 0x80000401u, 0xbf8c3f70u, 0x7e0a1504u, 0xe0701000u,
0x80010501u, 0xbf810000u,
};
alignas(256) constexpr std::array<std::uint32_t, 11> RoundTripCode{
0x34020082u, 0x8f098708u, 0x4a020209u, 0xe0301000u, 0x80000401u, 0xbf8c3f70u, 0x7e0a1504u, 0x7e0c1705u,
0xe0701000u, 0x80010601u, 0xbf810000u,
};
alignas(256) constexpr std::array<std::uint32_t, 10> NarrowTowardZeroCode{
0x34020082u, 0x8f098708u, 0x4a020209u, 0xe0301000u, 0x80000401u, 0xbf8c3f70u, 0x5e0a0904u, 0xe0701000u,
0x80010501u, 0xbf810000u,
};
std::array<std::uint32_t, 4> BufferDescriptor(const void* data, std::uint32_t bytes) {
const auto address = reinterpret_cast<std::uintptr_t>(data);
return {static_cast<std::uint32_t>(address), static_cast<std::uint32_t>((address >> 32u) & 0xffffu), bytes, 0x31016facu};
}
bool Supported(const ShaderRecompiler::SpirvTarget& target, spv::Capability capability) {
return std::find(target.supportedCapabilities.begin(), target.supportedCapabilities.end(), static_cast<std::uint32_t>(capability)) != target.supportedCapabilities.end();
}
}
std::vector<std::uint32_t> Float16NarrowProbeInputs() {
std::vector<std::uint32_t> inputs;
constexpr std::array<std::uint32_t, 4> nanLow{0x0000u, 0x0001u, 0x1000u, 0x1fffu};
constexpr std::array<std::uint32_t, 16> mantissas{0x000000u, 0x000001u, 0x000fffu, 0x001000u, 0x001001u, 0x001fffu, 0x002000u, 0x003000u, 0x400000u, 0x7fe000u, 0x7ff000u, 0x7fefffu, 0x7ff001u, 0x7fffffu, 0x155555u, 0x2aaaaau};
for (const std::uint32_t sign : {0u, 0x80000000u}) {
for (std::uint32_t top = 0; top < 1024u; ++top) {
for (const std::uint32_t low : nanLow) {
if (top != 0u || low != 0u) inputs.push_back(sign | 0x7f800000u | (top << 13u) | low);
}
}
for (std::uint32_t exponent = 0; exponent < 256u; ++exponent) {
for (const std::uint32_t mantissa : mantissas) inputs.push_back(sign | (exponent << 23u) | mantissa);
}
for (std::uint32_t exponent = 100u; exponent < 114u; ++exponent) {
for (std::uint32_t bit = 0; bit < 23u; ++bit) {
for (const std::uint32_t mantissa : {1u << bit, (3u << bit) & 0x7fffffu, (1u << bit) - 1u}) inputs.push_back(sign | (exponent << 23u) | mantissa);
}
}
}
inputs.resize((inputs.size() + Threads - 1u) / Threads * Threads, 0u);
return inputs;
}
namespace {
std::vector<std::uint32_t> Run(VulkanDevice& device, ShaderRecompiler::SpirvTarget target, bool widen, bool narrow, const std::optional<ShaderRecompiler::ShaderFloatMode>& floatMode, std::span<const std::uint32_t> code, std::span<const std::uint32_t> input) {
std::vector<std::uint32_t> output(input.size(), 0xdeadbeefu);
std::vector<std::uint32_t> userData(8, 0u);
const auto inputDescriptor = BufferDescriptor(input.data(), static_cast<std::uint32_t>(input.size_bytes()));
const auto outputDescriptor = BufferDescriptor(output.data(), static_cast<std::uint32_t>(output.size() * 4u));
std::copy(inputDescriptor.begin(), inputDescriptor.end(), userData.begin());
std::copy(outputDescriptor.begin(), outputDescriptor.end(), userData.begin() + 4);
const std::array<ShaderRecompiler::MemoryRegion, 1> memory{{{reinterpret_cast<std::uintptr_t>(code.data()), std::as_bytes(code)}}};
const ShaderRecompiler::ShaderComputeStageInfo compute{{Threads, 1, 1}, 0u, {true, false, false}, false, 1};
target.float16WidenNans = widen;
target.float16NarrowNans = narrow;
ShaderRecompiler::RecompileRequest request{
{ShaderStage::Compute, reinterpret_cast<std::uintptr_t>(code.data()), code, 0, {}},
{32, 0, userData, compute, std::nullopt, std::nullopt, memory},
target,
{0, 0, 0, 128}
};
request.useCache = false;
request.context.floatMode = floatMode;
const auto result = ShaderRecompiler::Recompile(request);
device.Dispatch(result, static_cast<std::uint32_t>(input.size() / Threads), 1, 1, {}, reinterpret_cast<std::uintptr_t>(code.data()));
device.WaitIdle();
return output;
}
void Compare(Float16ConversionProbeDirection& direction, VulkanDevice& device, const ShaderRecompiler::SpirvTarget& target, bool widen, bool narrow, std::span<const std::uint32_t> code, std::span<const std::uint32_t> input) {
const std::array<std::optional<ShaderRecompiler::ShaderFloatMode>, 4> modes{std::nullopt, ShaderRecompiler::ShaderFloatMode{0xf0u, true, false, false}, ShaderRecompiler::ShaderFloatMode{0x00u, false, true, false}, ShaderRecompiler::ShaderFloatMode{0xf4u, true, false, true}};
for (const auto& mode : modes) {
const auto emulated = Run(device, target, false, false, mode, code, input);
const auto native = Run(device, target, widen, narrow, mode, code, input);
for (std::size_t lane = 0; lane < input.size(); ++lane) {
++direction.compared;
if (emulated[lane] == native[lane]) continue;
++direction.mismatches;
if (!direction.first) direction.first = Float16ConversionMismatch{input[lane], emulated[lane], native[lane]};
}
}
}
}
Float16ConversionProbeResult ProbeFloat16Conversions(VulkanDevice& device, const ShaderRecompiler::SpirvTarget& target) {
Float16ConversionProbeResult result;
if (target.float16DenormPreserve) {
result.widen.probed = true;
std::vector<std::uint32_t> halves(Halves);
for (std::uint32_t lane = 0; lane < Halves; ++lane) halves[lane] = lane | ((lane ^ 0xa5a5u) << 16u);
Compare(result.widen, device, target, true, false, WidenCode, halves);
}
if (Supported(target, spv::CapabilityFloat16) && Supported(target, spv::CapabilityRoundingModeRTE) && Supported(target, spv::CapabilityDenormPreserve)) {
result.narrow.probed = true;
const bool widen = result.widen.probed && result.widen.mismatches == 0u;
const auto singles = Float16NarrowProbeInputs();
Compare(result.narrow, device, target, widen, true, NarrowCode, singles);
Compare(result.narrow, device, target, widen, true, NarrowTowardZeroCode, singles);
Compare(result.narrow, device, target, widen, true, RoundTripCode, singles);
}
return result;
}
}
@@ -1,10 +1,12 @@
#include "prx/libSceAgcDriver/Execution/include/FloatFlushProbe.hpp"
#include "prx/libSceAgcDriver/Execution/include/FloatProbeTolerance.hpp"
#include "prx/libSceAgcDriver/Execution/include/VulkanDevice.hpp"
#include <algorithm>
#include <array>
#include <optional>
#include <span>
#include <utility>
#include <vector>
namespace AgcDriver {
@@ -130,6 +132,53 @@ constexpr std::uint32_t MixedTinyRows[Threads][Inputs] = {
{0x80800001u, 0x3bff3bffu, 0x80000000u, 0x80008000u},
};
alignas(256) constexpr std::array<std::uint32_t, 18> TranscendentalCode{
0x34020084u, 0x34040086u, 0xe0381000u, 0x80000401u, 0xbf8c3f70u, 0x7e144f04u, 0x7e166704u, 0x7e185d04u,
0x7e1a5504u, 0x7e1c4b05u, 0x7e1e4f05u, 0x7e206705u, 0x7e225505u, 0xe0781000u, 0x80010a02u, 0xe0781010u,
0x80010e02u, 0xbf810000u,
};
constexpr std::uint32_t TranscendentalStride = 16;
constexpr std::array<std::pair<Float32ProbeOp, std::uint32_t>, 8> TranscendentalResults{{
{Float32ProbeOp::Log2, 0u}, {Float32ProbeOp::Sqrt, 0u}, {Float32ProbeOp::Rsq, 0u}, {Float32ProbeOp::Rcp, 0u},
{Float32ProbeOp::Exp2, 1u}, {Float32ProbeOp::Log2, 1u}, {Float32ProbeOp::Sqrt, 1u}, {Float32ProbeOp::Rcp, 1u},
}};
constexpr std::uint32_t TranscendentalRows[Threads][Inputs] = {
{0x40000000u, 0x3f800000u, 0x00000000u, 0x00000000u},
{0x3f000000u, 0xbf800000u, 0x00000000u, 0x00000000u},
{0x3f800000u, 0x3f000000u, 0x00000000u, 0x00000000u},
{0x40400000u, 0xbf000000u, 0x00000000u, 0x00000000u},
{0x41200000u, 0x41200000u, 0x00000000u, 0x00000000u},
{0x3dcccccdu, 0xc1200000u, 0x00000000u, 0x00000000u},
{0x0da24260u, 0x42480000u, 0x00000000u, 0x00000000u},
{0x7149f2cau, 0xc2480000u, 0x00000000u, 0x00000000u},
{0x3fc00000u, 0x42c80000u, 0x00000000u, 0x00000000u},
{0x40e00000u, 0xc2c80000u, 0x00000000u, 0x00000000u},
{0x3f400000u, 0x40000000u, 0x00000000u, 0x00000000u},
{0x42c80000u, 0x40400000u, 0x00000000u, 0x00000000u},
{0x2edbe6ffu, 0x3dcccccdu, 0x00000000u, 0x00000000u},
{0x501502f9u, 0xbdcccccdu, 0x00000000u, 0x00000000u},
{0x40490fdbu, 0x40e00000u, 0x00000000u, 0x00000000u},
{0x402df854u, 0xc0e00000u, 0x00000000u, 0x00000000u},
{0x3f800001u, 0x3a83126fu, 0x00000000u, 0x00000000u},
{0x3f7fffffu, 0x41a00000u, 0x00000000u, 0x00000000u},
{0x0d800000u, 0xc1a00000u, 0x00000000u, 0x00000000u},
{0x71800000u, 0x3fc00000u, 0x00000000u, 0x00000000u},
{0x3e99999au, 0xbfc00000u, 0x00000000u, 0x00000000u},
{0x40a00000u, 0x41f00000u, 0x00000000u, 0x00000000u},
{0x42800000u, 0xc1f00000u, 0x00000000u, 0x00000000u},
{0x3c800000u, 0x42800000u, 0x00000000u, 0x00000000u},
{0x3f8ccccdu, 0x3e800000u, 0x00000000u, 0x00000000u},
{0x3f666666u, 0x40800000u, 0x00000000u, 0x00000000u},
{0x60ad78ecu, 0x40a00000u, 0x00000000u, 0x00000000u},
{0x1e3ce508u, 0x40490fdbu, 0x00000000u, 0x00000000u},
{0x4640e6b7u, 0x402df854u, 0x00000000u, 0x00000000u},
{0x3a83126fu, 0x3e99999au, 0x00000000u, 0x00000000u},
{0x40800000u, 0x3f666666u, 0x00000000u, 0x00000000u},
{0x3e800000u, 0x3f8ccccdu, 0x00000000u, 0x00000000u}
};
std::array<std::uint32_t, 4> BufferDescriptor(const void* data, std::uint32_t bytes) {
const auto address = reinterpret_cast<std::uintptr_t>(data);
return {static_cast<std::uint32_t>(address), static_cast<std::uint32_t>((address >> 32u) & 0xffffu), bytes, 0x31016facu};
@@ -139,7 +188,7 @@ bool IsNan(std::uint32_t value) {
return (value & 0x7fffffffu) > 0x7f800000u;
}
std::vector<std::uint32_t> Run(VulkanDevice& device, ShaderRecompiler::SpirvTarget target, bool hardwareFlush, const std::optional<ShaderRecompiler::ShaderFloatMode>& floatMode, std::span<const std::uint32_t> code, const std::uint32_t (*rows)[Inputs]) {
std::vector<std::uint32_t> Run(VulkanDevice& device, const ShaderRecompiler::SpirvTarget& target, const std::optional<ShaderRecompiler::ShaderFloatMode>& floatMode, std::span<const std::uint32_t> code, const std::uint32_t (*rows)[Inputs]) {
for (std::uint32_t tid = 0; tid < Threads; ++tid) std::copy(std::begin(rows[tid]), std::end(rows[tid]), &Input[tid * Inputs]);
Output.fill(0xdeadbeefu);
std::vector<std::uint32_t> userData(8, 0u);
@@ -149,7 +198,6 @@ std::vector<std::uint32_t> Run(VulkanDevice& device, ShaderRecompiler::SpirvTarg
std::copy(output.begin(), output.end(), userData.begin() + 4);
const std::array<ShaderRecompiler::MemoryRegion, 1> memory{{{reinterpret_cast<std::uintptr_t>(code.data()), std::as_bytes(code)}}};
const ShaderRecompiler::ShaderComputeStageInfo compute{{Threads, 1, 1}, 0u, {false, false, false}, false, 1};
target.float32FlushToZero = hardwareFlush;
ShaderRecompiler::RecompileRequest request{
{ShaderStage::Compute, reinterpret_cast<std::uintptr_t>(code.data()), code, 0, {}},
{32, 0, userData, compute, std::nullopt, std::nullopt, memory},
@@ -164,6 +212,24 @@ std::vector<std::uint32_t> Run(VulkanDevice& device, ShaderRecompiler::SpirvTarg
return {Output.begin(), Output.end()};
}
void Compare(FloatFlushProbeResult& result, const std::vector<std::uint32_t>& expected, const std::vector<std::uint32_t>& actual) {
for (std::size_t index = 0; index < expected.size(); ++index) {
++result.compared;
if (expected[index] != actual[index] && !(IsNan(expected[index]) && IsNan(actual[index]))) ++result.mismatches;
}
}
void CompareTranscendental(FloatFlushProbeResult& result, const std::vector<std::uint32_t>& expected, const std::vector<std::uint32_t>& actual) {
for (std::uint32_t tid = 0; tid < Threads; ++tid) {
for (std::uint32_t slot = 0; slot < TranscendentalResults.size(); ++slot) {
const auto [op, input] = TranscendentalResults[slot];
const auto index = tid * TranscendentalStride + slot;
++result.compared;
if (!Float32ResultsAgree(op, TranscendentalRows[tid][input], expected[index], actual[index])) ++result.mismatches;
}
}
}
}
FloatFlushProbeResult ProbeFloat32FlushToZero(VulkanDevice& device, const ShaderRecompiler::SpirvTarget& target) {
@@ -172,15 +238,25 @@ FloatFlushProbeResult ProbeFloat32FlushToZero(VulkanDevice& device, const Shader
const std::array<std::pair<std::span<const std::uint32_t>, const std::uint32_t (*)[Inputs]>, 3> programs{{{MixedCode, MixedRows}, {TinyCode, TinyRows}, {MixedTinyCode, MixedTinyRows}}};
for (const auto& mode : modes) {
for (const auto& [code, rows] : programs) {
const auto software = Run(device, target, false, mode, code, rows);
const auto hardware = Run(device, target, true, mode, code, rows);
for (std::size_t index = 0; index < software.size(); ++index) {
++result.compared;
if (software[index] != hardware[index] && !(IsNan(software[index]) && IsNan(hardware[index]))) ++result.mismatches;
}
auto software = target;
software.float32FlushToZero = false;
auto hardware = target;
hardware.float32FlushToZero = true;
Compare(result, Run(device, software, mode, code, rows), Run(device, hardware, mode, code, rows));
}
}
return result;
}
FloatFlushProbeResult ProbeFloat32DenormPreserve(VulkanDevice& device, const ShaderRecompiler::SpirvTarget& target) {
FloatFlushProbeResult result;
auto preserved = target;
preserved.float32FlushToZero = false;
preserved.float32DenormPreserve = true;
auto unpreserved = preserved;
unpreserved.float32DenormPreserve = false;
CompareTranscendental(result, Run(device, unpreserved, std::nullopt, TranscendentalCode, TranscendentalRows), Run(device, preserved, std::nullopt, TranscendentalCode, TranscendentalRows));
return result;
}
}
@@ -0,0 +1,56 @@
#include "prx/libSceAgcDriver/Execution/include/FloatProbeTolerance.hpp"
#include <algorithm>
#include <bit>
#include <cmath>
namespace AgcDriver {
namespace {
struct Interval {
double low;
double high;
};
bool IsNan(std::uint32_t value) {
return (value & 0x7fffffffu) > 0x7f800000u;
}
double Ulp(double value) {
int exponent = 0;
std::frexp(value, &exponent);
return std::ldexp(1.0, std::max(exponent - 24, -149));
}
Interval Around(double exact, double ulps) {
const auto error = ulps * Ulp(exact);
return {exact - error, exact + error};
}
Interval Allowed(Float32ProbeOp op, double input) {
switch (op) {
case Float32ProbeOp::Log2:
if (input >= 0.5 && input <= 2.0) return {std::log2(input) - std::ldexp(1.0, -21), std::log2(input) + std::ldexp(1.0, -21)};
return Around(std::log2(input), 3.0);
case Float32ProbeOp::Sqrt: {
const auto inverse = Around(1.0 / std::sqrt(input), 2.0);
return {Around(1.0 / inverse.high, 2.5).low, Around(1.0 / inverse.low, 2.5).high};
}
case Float32ProbeOp::Rsq: return Around(1.0 / std::sqrt(input), 2.0);
case Float32ProbeOp::Rcp: return Around(1.0 / input, 2.5);
case Float32ProbeOp::Exp2: return Around(std::exp2(input), 3.0 + 2.0 * std::fabs(input));
}
return {0.0, 0.0};
}
}
bool Float32ResultsAgree(Float32ProbeOp op, std::uint32_t input, std::uint32_t first, std::uint32_t second) {
if (IsNan(first) || IsNan(second)) return IsNan(first) && IsNan(second);
const auto allowed = Allowed(op, static_cast<double>(std::bit_cast<float>(input)));
if (!std::isfinite(allowed.low) || !std::isfinite(allowed.high)) return first == second;
const auto difference = std::fabs(static_cast<double>(std::bit_cast<float>(first)) - static_cast<double>(std::bit_cast<float>(second)));
return difference <= allowed.high - allowed.low;
}
}
@@ -325,7 +325,7 @@ void PerformanceTrace::Present(std::uint32_t width, std::uint32_t height, const
auto& state = session();
std::lock_guard lock(state.mutex);
if (!state.started) {
state.window = TraceWindow::Parse(std::getenv("APS5_TRACE_FRAMES"), std::getenv("APS5_TRACE_SECONDS"));
state.window = TraceWindow::FromEnvironment();
state.interval = TraceInterval::Parse(std::getenv("APS5_TRACE_SUMMARY_EVERY"));
state.bench = TraceBench::Parse(std::getenv("APS5_TRACE_BENCH"), state.interval.has_value());
state.first = now;
@@ -358,7 +358,11 @@ void Validate(std::span<const std::uint32_t> packet, std::uint32_t queue) {
}
case 0x3f: size(4); break;
case 0x13: case 0x2f: graphics(); size(2); break;
case 0x26: graphics(); size(3); break;
case 0x26:
graphics();
size(3);
require((packet[1] & 1u) == 0 && packet[2] <= 0xffffu, "unsupported index base alignment or address bits");
break;
case 0x27:
graphics();
size(6);
@@ -400,7 +404,7 @@ void Validate(std::span<const std::uint32_t> packet, std::uint32_t queue) {
require((packet[2] >> 16u) == 0 && (packet[3] >> 16u) == 0, "start-index location semantics are not implemented");
require(drawLocation(packet[2]) && drawLocation(packet[3]) && drawLocation(packet[4] & 0xffffu), "invalid indirect draw register location");
require((packet[4] & ~(0xffffu | (1u << 30u) | (1u << 31u))) == 0, "indirect multi-draw control bits are not implemented");
if ((packet[4] & (1u << 30u)) != 0) require((packet[6] & 3u) == 0 && address(packet[6], packet[7]) != 0, "invalid indirect draw count address");
if ((packet[4] & (1u << 30u)) != 0) require((packet[6] & 3u) == 0 && address(packet[6], packet[7]) != 0 && packet[7] <= 0xffffu, "invalid indirect draw count address");
else require(address(packet[6], packet[7]) == 0, "count address without an indirect draw count");
require((packet[8] & 3u) == 0 && packet[8] >= (opcode == 0x2c ? 16u : 20u), "invalid indirect draw stride");
require((packet[9] & ~0x20u) == (opcode == 0x2c ? 2u : 0u), "unsupported indirect draw initiator");
@@ -542,10 +546,12 @@ void Validate(std::span<const std::uint32_t> packet, std::uint32_t queue) {
const auto destination = (packet[1] >> 8u) & 0xfu;
if (destination == 0) {
const auto count = (packet[1] & 0x10000u) != 0 ? 1u : packet.size() - 4;
require(packet[3] == 0 && packet[2] >= 0xc340u && packet[2] <= 0xc347u && count <= 0xc348u - packet[2], "WRITE_DATA register destination outside the thread-trace user-data registers is not implemented");
require(packet[3] == 0 && packet[2] < 0x10000u && count <= 0x10000u - packet[2], "WRITE_DATA register destination outside the register space");
require(packet[2] >= 0xc340u && packet[2] <= 0xc347u && count <= 0xc348u - packet[2], "WRITE_DATA register destination outside the thread-trace user-data registers is not implemented");
break;
}
require(destination == 1 || destination == 2 || destination == 3 || destination == 5, "WRITE_DATA register destination is not implemented");
require(destination <= 5, "invalid WRITE_DATA destination");
require(destination != 4, "reserved WRITE_DATA destination");
require((packet[2] & 3u) == 0, "misaligned WRITE_DATA destination");
break;
}
@@ -557,9 +563,11 @@ void Validate(std::span<const std::uint32_t> packet, std::uint32_t queue) {
if (CopyDataToRegister(packet)) {
require(source == 2 || source == 4, "COPY_DATA to a register from a register, GDS, immediate or clock source is not implemented");
require((packet[2] & 3u) == 0, "misaligned COPY_DATA source");
require(packet[5] == 0 && packet[4] >= ContextRegisterBase && packet[4] - ContextRegisterBase <= 0x400u - copyDataCount(packet), "COPY_DATA to a register outside the context registers is not implemented");
require(packet[5] == 0 && packet[4] < 0x10000u && copyDataCount(packet) <= 0x10000u - packet[4], "COPY_DATA register destination outside the register space");
require(packet[4] >= ContextRegisterBase && packet[4] - ContextRegisterBase <= 0x400u - copyDataCount(packet), "COPY_DATA to a register outside the context registers is not implemented");
break;
}
require(destination <= 10, "invalid COPY_DATA destination");
require(destination == 2 || destination == 4 || destination == 10, "COPY_DATA GDS or performance-counter destination is not implemented");
require(source == 2 || source == 4 || source == 5 || source == 10 || source == 11 || source == CopyDataGpuClockSource || source == CopyDataRegisterSource, "COPY_DATA GDS or reference-clock source is not implemented");
require(source != CopyDataRegisterSource || (packet[3] == 0 && registerBankBase(packet[2]) != 0 && registerBankBase(packet[2]) == registerBankBase(packet[2] + copyDataCount(packet) - 1)), "COPY_DATA from a register outside the shader, context and user config registers is not implemented");
@@ -671,7 +679,8 @@ std::optional<LabelWrite> DecodeLabelWrite(std::span<const std::uint32_t> packet
return label;
}
if (opcode == 0x37 && packet.size() > 4) {
if (((packet[1] >> 8u) & 0xfu) == 0) return std::nullopt;
const auto destinationSelect = (packet[1] >> 8u) & 0xfu;
if (destinationSelect == 0 || destinationSelect == 4 || destinationSelect > 5) return std::nullopt;
const auto destination = address(packet[2], packet[3]);
if (destination == 0) return std::nullopt;
// WR_ONE_ADDR stores every value at the same address: the last one remains.
@@ -689,6 +698,8 @@ std::optional<StoreWrite> ResolveStore(std::span<const std::uint32_t> packet, co
switch ((packet[0] >> 8u) & 0xffu) {
case 0x40: {
if (packet.size() < 6 || CopyDataToRegister(packet)) return std::nullopt;
const auto dstSelect = (packet[1] >> 8u) & 0xfu;
if (dstSelect != 1 && dstSelect != 2 && dstSelect != 5) return std::nullopt;
if (CopyDataSource(packet) == CopyDataRegisterSource) return std::nullopt;
const std::size_t bytes = CopyDataBytes(packet);
const auto destination = address(packet[4], packet[5]);
@@ -770,6 +781,8 @@ std::vector<PacketStore> DecodeStores(std::span<const std::uint32_t> packet) {
case 0x40: {
require(packet.size() == 6, "invalid COPY_DATA size");
if (CopyDataToRegister(packet)) return {};
const auto dstSelect = (packet[1] >> 8u) & 0xfu;
if (dstSelect != 1 && dstSelect != 2 && dstSelect != 5) return {};
const auto destination = address(packet[4], packet[5]);
if (CopyDataImmediate(CopyDataSource(packet))) return {pattern(destination, CopyDataBytes(packet), packet[2])};
return {runTime(destination, CopyDataBytes(packet))};
@@ -3,14 +3,24 @@
#include "SDL_filesystem.h"
#include "SDL_error.h"
#include <atomic>
#include <cerrno>
#include <climits>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <memory>
#include <stdexcept>
#include <string>
#include <vector>
#ifdef _WIN32
#include <fcntl.h>
#include <io.h>
#include <sys/stat.h>
#else
#include <fcntl.h>
#include <unistd.h>
#endif
namespace {
std::atomic<bool> requested{false};
@@ -40,10 +50,52 @@ std::string localTimestamp() {
return text;
}
std::filesystem::path unusedPath(const std::filesystem::path& folder, const std::string& stem) {
int createExclusive(const std::filesystem::path& path) {
#ifdef _WIN32
return ::_wopen(path.c_str(), _O_WRONLY | _O_CREAT | _O_EXCL | _O_BINARY | _O_NOINHERIT, _S_IREAD | _S_IWRITE);
#else
return ::open(path.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0666);
#endif
}
bool writeAll(int descriptor, const std::uint8_t* data, std::size_t size) {
while (size != 0) {
#ifdef _WIN32
const unsigned int chunk = size > INT_MAX ? INT_MAX : static_cast<unsigned int>(size);
const int written = ::_write(descriptor, data, chunk);
#else
const auto written = ::write(descriptor, data, size);
#endif
if (written < 0 && errno == EINTR) continue;
if (written <= 0) return false;
data += written;
size -= static_cast<std::size_t>(written);
}
return true;
}
bool closeFile(int descriptor) {
#ifdef _WIN32
return ::_close(descriptor) == 0;
#else
return ::close(descriptor) == 0;
#endif
}
std::filesystem::path writeUnusedPng(const std::filesystem::path& folder, const std::string& stem, const std::vector<std::uint8_t>& png) {
for (int index = 0; index < 1000; ++index) {
const auto path = folder / (index == 0 ? stem + ".png" : stem + "-" + std::to_string(index) + ".png");
if (!std::filesystem::exists(path)) return path;
const int descriptor = createExclusive(path);
if (descriptor < 0) {
if (errno == EEXIST) continue;
throw std::runtime_error("Screenshot: cannot create output file");
}
const bool written = writeAll(descriptor, png.data(), png.size());
const bool closed = closeFile(descriptor);
if (written && closed) return path;
std::error_code error;
std::filesystem::remove(path, error);
throw std::runtime_error("Screenshot: cannot write output file");
}
throw std::runtime_error("Screenshot: no unused file name for " + stem + " in " + folder.string());
}
@@ -71,11 +123,5 @@ std::filesystem::path AgcDriver::Screenshot::Write(std::string_view titleId, std
const auto png = Decoder::Png::Encode(rgb, width, height, 3);
const auto folder = directory();
std::filesystem::create_directories(folder);
const auto path = unusedPath(folder, std::string(titleId) + "-" + localTimestamp());
std::ofstream file;
file.exceptions(std::ios::failbit | std::ios::badbit);
file.open(path, std::ios::binary);
file.write(reinterpret_cast<const char*>(png.data()), static_cast<std::streamsize>(png.size()));
file.close();
return path;
return writeUnusedPng(folder, std::string(titleId) + "-" + localTimestamp(), png);
}
@@ -233,7 +233,7 @@ void ShaderMemory::SetWaitedMsProvider(WaitedMsProvider provider) {
waitedMsProvider.store(provider, std::memory_order_release);
}
ShaderMemory::ShaderMemory(std::span<const ShaderRecompiler::MemoryRegion> regions, PendingWriteQuery pendingWrite, PendingWriteObserver observe, HookWaitCounter hookWaits, PendingWriteQuery pendingSpan) : pendingWrite(pendingWrite), observe(observe), hookWaits(hookWaits), pendingSpan(pendingSpan != nullptr ? pendingSpan : pendingWrite) {
ShaderMemory::ShaderMemory(std::span<const ShaderRecompiler::MemoryRegion> regions, PendingWriteQuery pendingWrite, PendingWriteObserver observe, HookWaitCounter hookWaits, PendingWriteQuery pendingSpan) : pendingWrite(pendingWrite), observe(observe), hookWaits(hookWaits), pendingSpan(pendingSpan != nullptr ? pendingSpan : pendingWrite), spanQuery(pendingSpan != nullptr) {
const ShaderRecompiler::RequestMemoryView validated(regions);
initial.reserve(regions.size());
for (const auto& region : regions) initial.emplace_back(region.guestAddress, region.bytes);
@@ -662,12 +662,23 @@ ShaderRecompiler::SrtWriteStamp ShaderMemory::stampWrites(void* context, std::ui
const auto& self = *static_cast<const ShaderMemory*>(context);
if (bytes == 0 || address > std::numeric_limits<std::uint64_t>::max() - bytes || self.overlapsInitial(address, address + bytes)) return {};
const auto fetched = self.pageAtOrAfter(address & ~static_cast<std::uint64_t>(PageBytes - 1));
if (fetched != self.pages.size() && self.pages[fetched].first < address + bytes) return {};
const bool anyFetched = fetched != self.pages.size() && self.pages[fetched].first < address + bytes;
if (anyFetched && !self.spanQuery) return {};
GuestMemory::FlushGpuWrites(address, static_cast<std::size_t>(bytes));
const auto layout = GuestAllocations::GuestAllocationsGeneration_nid_postfix();
const auto generation = GuestMemory::CollectWrites(address, static_cast<std::size_t>(bytes));
if (generation == 0) return {};
if (self.pendingSpan != nullptr && self.pendingSpan(address, static_cast<std::size_t>(bytes), {}) != PendingWrite::None) return {};
if (anyFetched) {
std::array<std::uint32_t, PageWords> current{};
for (auto index = fetched; index < self.pages.size() && self.pages[index].first < address + bytes; ++index) {
const auto& page = *self.pages[index].second;
if (page.wordwise || GuestMemory::CopyMapped(self.pages[index].first, std::as_writable_bytes(std::span(current))) != GuestMemory::Compare::Equal) return {};
for (std::size_t word = 0; word < PageWords; ++word) {
if (page.valid.Test(word) && page.words[word] != current[word]) return {};
}
}
}
return {generation, layout};
}
@@ -12,6 +12,7 @@
#include "prx/libSceAgcDriver/Graphics/include/DeferredDestruction.hpp"
#include "prx/libSceAgcDriver/Execution/include/VulkanDevice.hpp"
#include "prx/libSceAgcDriver/Graphics/include/MemoryAccounting.hpp"
#include "prx/libSceAgcDriver/Execution/include/Float16ConversionProbe.hpp"
#include "prx/libSceAgcDriver/Execution/include/FloatFlushProbe.hpp"
#include "prx/libSceAgcDriver/Execution/include/Driver.hpp"
#include "prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hpp"
@@ -39,6 +40,8 @@
#include "prx/libSceAgcDriver/Execution/include/PresentationPass.hpp"
#include "prx/libSceAgcDriver/Execution/include/PresentationScaler.hpp"
#include "prx/libSceAgcDriver/Execution/include/Screenshot.hpp"
#include "prx/libSceAgcDriver/Execution/include/SubmissionSnapshots.hpp"
#include "prx/libSceAgcDriver/TraceRevision.hpp"
#include "prx/libkernel/AppMetadata/include/AppMetadata.hpp"
#include "prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp"
#include "prx/libSceAgcDriver/Graphics/include/Draw.hpp"
@@ -62,8 +65,13 @@
#include "prx/libSceAgcDriver/Graphics/include/TextureFormat.hpp"
#include "prx/libSceAgcDriver/Execution/include/GuestMemory.hpp"
#include "prx/libc/include/General.hpp"
#include "prx/libc/include/RunReport.hpp"
#include "prx/libc/include/RunReportComponent.hpp"
#include "RdnaDecoder/DiagnosticSink.hpp"
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#include <atomic>
#include <chrono>
@@ -85,6 +93,13 @@
#include <bit>
#include <cstring>
#include <deque>
namespace AgcDriver::Graphics {
std::uint32_t LastCheckpointMarkerSerial() noexcept;
std::uint32_t LastCheckpointMarkerToken() noexcept;
void TeardownCheckpointMarkers() noexcept;
void ResetCheckpointSnapshots() noexcept;
}
#include <limits>
#include <list>
#include <stdexcept>
@@ -141,8 +156,81 @@ DeviceQueuePlan PlanDeviceQueues(std::span<const VkQueueFamilyProperties> famili
return plan;
}
bool ChooseDeviceFaultVendorBinary(bool requested, bool faultSupported, bool vendorBinarySupported) noexcept {
return requested && faultSupported && vendorBinarySupported;
}
const char* DeviceFaultVendorDumpPath() noexcept {
const char* path = std::getenv("APS5_DUMP_DEVICE_FAULT");
return path != nullptr && *path != '\0' ? path : nullptr;
}
bool WriteDeviceFaultVendorBinary(const char* path, const void* data, std::size_t size) noexcept {
try {
if (path == nullptr || *path == '\0' || (data == nullptr && size != 0)) return false;
std::ofstream dump(path, std::ios::binary | std::ios::trunc);
if (!dump) return false;
if (size != 0) {
dump.write(static_cast<const char*>(data), static_cast<std::streamsize>(size));
if (!dump) return false;
}
dump.close();
return static_cast<bool>(dump);
} catch (...) {
return false;
}
}
void DumpDeviceFaultVendorBinary(VkDevice device, PFN_vkGetDeviceFaultInfoEXT faultInfo, const char* path) noexcept {
try {
constexpr VkDeviceSize DeviceFaultVendorBinaryLimit = 64u * 1024u * 1024u;
if (device == VK_NULL_HANDLE || faultInfo == nullptr || path == nullptr || *path == '\0') return;
VkDeviceFaultCountsEXT counts{VK_STRUCTURE_TYPE_DEVICE_FAULT_COUNTS_EXT};
if (faultInfo(device, &counts, nullptr) != VK_SUCCESS) return;
if (counts.vendorBinarySize == 0) return;
if (counts.vendorBinarySize > DeviceFaultVendorBinaryLimit) {
std::fprintf(stderr, "[device-fault] vendor binary of %llu bytes exceeds the 64 MiB dump bound\n", static_cast<unsigned long long>(counts.vendorBinarySize));
return;
}
std::vector<std::byte> binary(static_cast<std::size_t>(counts.vendorBinarySize));
VkDeviceFaultInfoEXT info{VK_STRUCTURE_TYPE_DEVICE_FAULT_INFO_EXT};
info.pVendorBinaryData = binary.data();
counts.addressInfoCount = 0;
counts.vendorInfoCount = 0;
counts.vendorBinarySize = static_cast<VkDeviceSize>(binary.size());
const auto result = faultInfo(device, &counts, &info);
if (result != VK_SUCCESS && result != VK_INCOMPLETE) return;
const auto bytes = static_cast<std::size_t>(std::min<VkDeviceSize>(counts.vendorBinarySize, binary.size()));
if (!WriteDeviceFaultVendorBinary(path, binary.data(), bytes)) {
std::fprintf(stderr, "[device-fault] vendor binary dump to %s failed\n", path);
return;
}
std::fprintf(stderr, "[device-fault] vendor binary: %zu bytes written to %s\n", bytes, path);
} catch (...) {
}
}
APS5_RUN_REPORT_COMPONENT("libSceAgcDriver")
namespace {
std::atomic<unsigned long long> descriptorUse[7 * 4];
void CountDescriptor(int type, int, int usage) {
if (!LibcRunReportEnabled_nid_no_patch()) return;
if (type >= 0 && type < 7 && usage >= 0 && usage < 4) descriptorUse[type * 4 + usage].fetch_add(1, std::memory_order_relaxed);
}
const ShaderRecompiler::DiagnosticSink runReportSink{
.enabled = LibcRunReportEnabled_nid_no_patch,
.shader = LibcRunReportShader_nid_no_patch,
.unsupportedInstruction = LibcRunReportUnsupportedInstruction_nid_no_patch,
.imageFormat = LibcRunReportImageFormat_nid_no_patch,
.descriptor = CountDescriptor,
};
[[maybe_unused]] const bool runReportSinkInstalled = (LibcRunReportSetDescriptorCounters_nid_no_patch(descriptorUse), ShaderRecompiler::SetDiagnosticSink(&runReportSink), true);
std::uint64_t fillCompletionSyncs = 0;
void check(VkResult result, const char* operation) {
@@ -455,8 +543,9 @@ struct VulkanDevice::State {
VkBuffer markerBuffer = VK_NULL_HANDLE;
VkDeviceMemory markerMemory = VK_NULL_HANDLE;
void* markerMapping = nullptr;
BufferMarkerLog markerLog;
bool deviceLostHook = false;
std::atomic<bool> hookRetired{false};
std::atomic<unsigned> hookActive{0};
bool deferDestruction = false;
PFN_vkGetDeviceProcAddr contextDeviceProc = nullptr;
VkTimeDomainKHR hostTimeDomain = VK_TIME_DOMAIN_DEVICE_KHR;
@@ -484,6 +573,8 @@ struct VulkanDevice::State {
bool float16DenormPreserve = false;
bool float32FlushToZeroCandidate = false;
bool float32FlushToZero = false;
bool float16WidenNans = false;
bool float16NarrowNans = false;
bool float32DenormPreserve = false;
bool probingFloatControls = false;
bool demoteToHelperInvocation = false;
@@ -506,6 +597,7 @@ struct VulkanDevice::State {
bool bufferInt64Atomics = false;
bool viewportIndexLayer = false;
bool imageFormatList = false;
bool fmaFloat16 = false;
bool primitiveListRestart = false;
bool depthClipControl = false;
bool graphicsPipelineLibrary = false;
@@ -518,6 +610,7 @@ struct VulkanDevice::State {
bool pushDescriptors = false;
bool maintenance5 = false;
bool fillModeNonSolid = false;
bool wideLines = false;
std::uint32_t srgbDecodeFormats = 0;
std::uint32_t srgbCopyFormats = 0;
bool storageImageWithoutFormat = false;
@@ -537,6 +630,7 @@ struct VulkanDevice::State {
bool sparseBinding = false;
bool sparseResidencyBuffer = false;
bool sparseResidencyAliased = false;
bool sparseResidencyImage2D = false;
std::uint32_t queueFamily = 0;
std::uint32_t sparseFamily = VK_QUEUE_FAMILY_IGNORED;
std::uint32_t sparseIndex = 0;
@@ -553,6 +647,7 @@ struct VulkanDevice::State {
bool samplerAnisotropy = false;
bool textureCompressionBC = false;
bool samplerFilterMinmax = false;
bool samplerMirrorClampToEdge = false;
bool nonSeamlessCubeMap = false;
VkSampleCountFlags mergedCoverageSampleCounts = 0;
VkSampleCountFlags truncatedCoverageSampleCounts = 0;
@@ -690,6 +785,8 @@ struct VulkanDevice::State {
AgcDriver::Mutex presentMutex;
// The presentation present() submitted and QueuePresent has not handed to the swapchain.
bool queuePending = false;
bool queueGuestFrame = false;
bool presentingGuestFrame = false;
std::uint32_t queueIndex = 0;
int nextDumpIndex = 0;
bool nextDumpScreenshot = false;
@@ -1029,7 +1126,10 @@ struct VulkanDevice::State {
if (deviceLostHook && Graphics::DeviceLostOwner() == this) {
Graphics::DeviceLostHook() = nullptr;
Graphics::DeviceLostOwner() = nullptr;
hookRetired.store(true, std::memory_order_release);
while (hookActive.load(std::memory_order_acquire) != 0) std::this_thread::yield();
}
Graphics::ResetCheckpointSnapshots();
if (compileOnly && device != VK_NULL_HANDLE) {
reinterpret_cast<PFN_vkDestroyDevice>(deviceProc(device, "vkDestroyDevice"))(device, nullptr);
device = VK_NULL_HANDLE;
@@ -1077,6 +1177,7 @@ struct VulkanDevice::State {
// sets and samplers they borrowed can go.
copiedWriters->clear();
resourceCache.Clear();
Graphics::ClearRetainedSpaces(device);
Graphics::ClearCachedTextures(device);
Graphics::ClearSnapshotCopies(device);
Graphics::ClearImageMirrors(device);
@@ -1123,6 +1224,7 @@ struct VulkanDevice::State {
if (markerMapping) reinterpret_cast<PFN_vkUnmapMemory>(deviceProc(device, "vkUnmapMemory"))(device, markerMemory);
if (markerBuffer) reinterpret_cast<PFN_vkDestroyBuffer>(deviceProc(device, "vkDestroyBuffer"))(device, markerBuffer, nullptr);
if (markerMemory) Graphics::MemoryAccounting::Free(reinterpret_cast<PFN_vkFreeMemory>(deviceProc(device, "vkFreeMemory")), device, markerMemory);
Graphics::TeardownCheckpointMarkers();
if (swapchain) reinterpret_cast<PFN_vkDestroySwapchainKHR>(deviceProc(device, "vkDestroySwapchainKHR"))(device, swapchain, nullptr);
const auto destroyPool = reinterpret_cast<PFN_vkDestroyCommandPool>(deviceProc(device, "vkDestroyCommandPool"));
const auto destroyDevice = reinterpret_cast<PFN_vkDestroyDevice>(deviceProc(device, "vkDestroyDevice"));
@@ -1495,6 +1597,8 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window, bool compileOnly) :
state->ldsLockFences = LdsLockFencesRequired(driver.driverID);
}
{
const auto driverText = state->driverInfo.empty() ? std::to_string(state->properties.driverVersion) : state->driverInfo;
LibcRunReportSetGpu_nid_no_patch(state->properties.vendorID, state->properties.deviceName, driverText.c_str(), state->properties.apiVersion);
HostGpuQuery hostQuery;
hostQuery.instanceProc = state->instanceProc;
hostQuery.instance = state->instance;
@@ -1681,6 +1785,20 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window, bool compileOnly) :
if (state->float32FlushToZeroCandidate && float32Flush.declared) state->capabilities.push_back(spv::CapabilityDenormFlushToZero);
state->float32DenormPreserve = floatControls.shaderDenormPreserveFloat32 == VK_TRUE && floatControls.denormBehaviorIndependence != VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE && std::getenv("APS5_NO_HW_F32_PRESERVE") == nullptr;
if ((state->float16DenormPreserve || state->float32DenormPreserve) && std::find(state->capabilities.begin(), state->capabilities.end(), static_cast<std::uint32_t>(spv::CapabilityDenormPreserve)) == state->capabilities.end()) state->capabilities.push_back(spv::CapabilityDenormPreserve);
VkPhysicalDeviceShaderFmaFeaturesKHR fmaFeatures{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FMA_FEATURES_KHR};
if (float16Rte && hasExtension(VK_KHR_SHADER_FMA_EXTENSION_NAME)) {
VkPhysicalDeviceFeatures2 features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &fmaFeatures};
state->InstanceFunction<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(selected, &features);
}
const bool float16Fma = float16Rte && fmaFeatures.shaderFmaFloat16 == VK_TRUE;
fmaFeatures = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FMA_FEATURES_KHR};
fmaFeatures.shaderFmaFloat16 = VK_TRUE;
state->fmaFloat16 = float16Fma;
if (float16Fma) {
deviceExtensions.push_back(VK_KHR_SHADER_FMA_EXTENSION_NAME);
state->capabilities.push_back(spv::CapabilityFMAKHR);
state->spirvExtensions.push_back("SPV_KHR_fma");
}
deviceExtensions.push_back(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME);
deviceExtensions.push_back(VK_KHR_8BIT_STORAGE_EXTENSION_NAME);
state->capabilities.push_back(4448);
@@ -1732,6 +1850,8 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window, bool compileOnly) :
state->samplerFilterMinmax = minmaxProperties.filterMinmaxSingleComponentFormats == VK_TRUE && minmaxProperties.filterMinmaxImageComponentMapping == VK_TRUE;
if (state->samplerFilterMinmax) deviceExtensions.push_back(VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
}
state->samplerMirrorClampToEdge = hasExtension(VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
if (state->samplerMirrorClampToEdge) deviceExtensions.push_back(VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
if (hasExtension(VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME)) {
VkPhysicalDeviceConservativeRasterizationPropertiesEXT conservativeProperties{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT};
VkPhysicalDeviceProperties2 properties{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &conservativeProperties};
@@ -1992,6 +2112,8 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window, bool compileOnly) :
enabled.sparseResidencyAliased = state->sparseBinding ? available.sparseResidencyAliased : VK_FALSE;
state->sparseResidencyBuffer = enabled.sparseResidencyBuffer == VK_TRUE;
state->sparseResidencyAliased = enabled.sparseResidencyAliased == VK_TRUE;
enabled.sparseResidencyImage2D = state->sparseBinding ? available.sparseResidencyImage2D : VK_FALSE;
state->sparseResidencyImage2D = enabled.sparseResidencyImage2D == VK_TRUE;
// Indirect draw records with a non-zero first instance, and several records per call.
enabled.drawIndirectFirstInstance = available.drawIndirectFirstInstance;
enabled.multiDrawIndirect = available.multiDrawIndirect;
@@ -2002,6 +2124,8 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window, bool compileOnly) :
state->depthClamp = enabled.depthClamp == VK_TRUE;
enabled.fillModeNonSolid = available.fillModeNonSolid;
state->fillModeNonSolid = enabled.fillModeNonSolid == VK_TRUE;
enabled.wideLines = available.wideLines;
state->wideLines = enabled.wideLines == VK_TRUE;
enabled.depthBounds = available.depthBounds;
state->depthBounds = enabled.depthBounds == VK_TRUE;
enabled.depthBiasClamp = available.depthBiasClamp;
@@ -2164,6 +2288,10 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window, bool compileOnly) :
float16Features.pNext = byteFeatures.pNext;
byteFeatures.pNext = &float16Features;
}
if (float16Fma) {
fmaFeatures.pNext = byteFeatures.pNext;
byteFeatures.pNext = &fmaFeatures;
}
if (bufferInt64Atomics) {
atomicInt64Features.pNext = byteFeatures.pNext;
byteFeatures.pNext = &atomicInt64Features;
@@ -2255,16 +2383,23 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window, bool compileOnly) :
VkPhysicalDeviceFeatures2 features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &faultFeatures};
state->InstanceFunction<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(selected, &features);
}
const char* vendorDumpPath = DeviceFaultVendorDumpPath();
const bool vendorDumpRequested = vendorDumpPath != nullptr;
const bool vendorBinarySupported = faultFeatures.deviceFaultVendorBinary == VK_TRUE;
const bool deviceFault = faultFeatures.deviceFault == VK_TRUE;
const bool vendorBinary = ChooseDeviceFaultVendorBinary(vendorDumpRequested, deviceFault, vendorBinarySupported);
if (deviceFault) {
faultFeatures = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FAULT_FEATURES_EXT};
faultFeatures.deviceFault = VK_TRUE;
faultFeatures.deviceFaultVendorBinary = vendorBinary ? VK_TRUE : VK_FALSE;
deviceExtensions.push_back(VK_EXT_DEVICE_FAULT_EXTENSION_NAME);
deviceInfo.enabledExtensionCount = static_cast<std::uint32_t>(deviceExtensions.size());
deviceInfo.ppEnabledExtensionNames = deviceExtensions.data();
faultFeatures.pNext = byteFeatures.pNext;
byteFeatures.pNext = &faultFeatures;
}
if (vendorBinary) std::fprintf(stderr, "[gpu] APS5_DUMP_DEVICE_FAULT: deviceFaultVendorBinary enabled, vendor binary will be written to %s\n", vendorDumpPath);
else if (vendorDumpRequested) std::fprintf(stderr, "[gpu] APS5_DUMP_DEVICE_FAULT: the device does not support deviceFaultVendorBinary, no vendor binary will be written\n");
const bool checkpointsRequested = std::getenv("APS5_GPU_CHECKPOINTS") != nullptr;
const bool checkpoints = checkpointsRequested && hasExtension(VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME);
const bool bufferMarkers = checkpointsRequested && !checkpoints && hasExtension(VK_AMD_BUFFER_MARKER_EXTENSION_NAME);
@@ -2296,6 +2431,7 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window, bool compileOnly) :
} else if (diagnosticsRequested) {
std::fprintf(stderr, "[gpu] APS5_NV_DIAGNOSTICS: the device does not support VK_NV_device_diagnostics_config\n");
}
const bool diagnosticCheckpoints = diagnostics.config && diagnostics.checkpoints;
bdaFeatures.pNext = &byteFeatures;
VkPhysicalDeviceRobustness2FeaturesEXT robustness2{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT};
if (hasExtension(VK_EXT_ROBUSTNESS_2_EXTENSION_NAME)) {
@@ -2359,16 +2495,91 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window, bool compileOnly) :
if (state->sparseFamily != VK_QUEUE_FAMILY_IGNORED) state->DeviceFunction<PFN_vkGetDeviceQueue>("vkGetDeviceQueue")(state->device, state->sparseFamily, state->sparseIndex, &state->sparseQueue);
if (checkpoints) state->checkpointMarker = state->DeviceFunction<PFN_vkCmdSetCheckpointNV>("vkCmdSetCheckpointNV");
if (bufferMarkers) state->CreateMarkerBuffer();
if (deviceFault || checkpoints || bufferMarkers) {
const bool queueCheckpoints = checkpoints || diagnosticCheckpoints;
if (deviceFault || queueCheckpoints || bufferMarkers) {
const auto faultInfo = deviceFault ? state->DeviceFunction<PFN_vkGetDeviceFaultInfoEXT>("vkGetDeviceFaultInfoEXT") : nullptr;
const auto checkpointData = checkpoints ? state->DeviceFunction<PFN_vkGetQueueCheckpointDataNV>("vkGetQueueCheckpointDataNV") : nullptr;
Graphics::DeviceLostHook() = [device = state->device, queue = state->queue, faultInfo, checkpointData, owner = state.get()] {
if (owner->markerMapping != nullptr) {
std::uint32_t words[2];
std::memcpy(words, owner->markerMapping, sizeof(words));
for (const auto& line : owner->markerLog.Report(words[0], words[1])) std::fprintf(stderr, "%s\n", line.c_str());
const auto checkpointData = queueCheckpoints ? state->DeviceFunction<PFN_vkGetQueueCheckpointDataNV>("vkGetQueueCheckpointDataNV") : nullptr;
Graphics::DeviceLostHook() = [device = state->device, queue = state->queue, present = state->presentQueue, settle = state->settleQueue, sparse = state->sparseQueue, faultInfo, checkpointData, vendorDump = vendorBinary, owner = state.get()] noexcept {
owner->hookActive.fetch_add(1, std::memory_order_acq_rel);
try {
if (!owner->hookRetired.load(std::memory_order_acquire)) {
bool stateZero = owner->markerMapping == nullptr;
if (owner->markerMapping != nullptr) {
std::uint32_t words[2];
std::memcpy(words, owner->markerMapping, sizeof(words));
stateZero = words[0] == 0 && words[1] == 0;
if (stateZero) {
std::fprintf(stderr, "[device-fault] no buffer marker reached\n");
} else {
const AgcDriver::FaultTokenRing& ring = AgcDriver::FaultTokenRing::Instance();
for (std::size_t i = 0; i < 2; ++i) {
if (words[i] == 0) {
if (i == 1) std::fprintf(stderr, "[device-fault] no dispatch finished\n");
continue;
}
char tokenLine[192];
if (const auto found = ring.Find(static_cast<AgcDriver::FaultToken>(words[i]))) {
std::snprintf(tokenLine, sizeof(tokenLine), "[device-fault] last dispatch %s: token %u, batch %llu, program 0x%llx, variant 0x%llx (%.47s)", i == 0 ? "reached" : "finished", static_cast<unsigned>(found->token), static_cast<unsigned long long>(found->submitSerial), static_cast<unsigned long long>(found->programAddress), static_cast<unsigned long long>(found->variantId), found->desc);
} else {
std::snprintf(tokenLine, sizeof(tokenLine), "[device-fault] last dispatch %s: token %u not in the ring", i == 0 ? "reached" : "finished", static_cast<unsigned>(words[i]));
}
std::fprintf(stderr, "%s\n", tokenLine);
}
}
}
if (stateZero) {
const std::uint32_t recorderToken = Graphics::LastCheckpointMarkerToken();
if (recorderToken != 0) {
const AgcDriver::FaultTokenRing& ring = AgcDriver::FaultTokenRing::Instance();
char tokenLine[192];
if (const auto found = ring.Find(static_cast<AgcDriver::FaultToken>(recorderToken))) {
std::snprintf(tokenLine, sizeof(tokenLine), "[device-fault] last dispatch %s: token %u, batch %llu, program 0x%llx, variant 0x%llx (%.47s)", "reached", static_cast<unsigned>(found->token), static_cast<unsigned long long>(found->submitSerial), static_cast<unsigned long long>(found->programAddress), static_cast<unsigned long long>(found->variantId), found->desc);
} else {
std::snprintf(tokenLine, sizeof(tokenLine), "[device-fault] last dispatch %s: token %u not in the ring", "reached", static_cast<unsigned>(recorderToken));
}
std::fprintf(stderr, "%s\n", tokenLine);
}
}
std::fprintf(stderr, "[device-fault] gpu %.256s vendor 0x%x device 0x%x driver %.256s commit %.12s%s\n", owner->properties.deviceName, static_cast<unsigned>(owner->properties.vendorID), static_cast<unsigned>(owner->properties.deviceID), owner->driverInfo.c_str(), APS5_TRACE_COMMIT, APS5_TRACE_DIRTY != 0 ? " dirty" : "");
{
std::uint32_t printedEnvs = 0;
const std::uint32_t maxEnvs = 32;
std::uint32_t scannedEnvs = 0;
const std::uint32_t maxScannedEnvs = 512;
#ifdef _WIN32
char** entries = _environ;
#else
char** entries = ::environ;
#endif
for (; entries != nullptr && *entries != nullptr && printedEnvs < maxEnvs && scannedEnvs < maxScannedEnvs; ++entries) {
++scannedEnvs;
const char* entry = *entries;
if (std::strncmp(entry, "APS5_", 5) != 0) continue;
std::fprintf(stderr, "[device-fault] env %.256s\n", entry);
++printedEnvs;
}
}
const std::uint64_t submitSerial = Graphics::LastCheckpointMarkerSerial();
AgcDriver::SubmitBracket bracket{};
if (submitSerial != 0) {
if (const auto found = AgcDriver::SubmissionSnapshots::DeviceSnapshots().FindBracket(submitSerial)) {
bracket = *found;
}
}
std::fprintf(stderr, "[device-fault] queue main\n");
for (const auto& line : DeviceFaultReport(device, faultInfo, queue, checkpointData, submitSerial, &AgcDriver::SubmissionSnapshots::DeviceSnapshots(), bracket, AgcDriver::FaultTokenRing::Instance())) std::fprintf(stderr, "%s\n", line.c_str());
const VkQueue extraQueues[] = {present, settle, sparse};
for (VkQueue extra : extraQueues) {
if (extra == VK_NULL_HANDLE || extra == queue) continue;
const char* role = extra == present ? "present" : extra == settle ? "settle" : "sparse";
std::fprintf(stderr, "[device-fault] queue %s\n", role);
for (const auto& line : DeviceFaultReport(VK_NULL_HANDLE, nullptr, extra, checkpointData, 0, nullptr, AgcDriver::SubmitBracket{}, AgcDriver::FaultTokenRing::Instance())) std::fprintf(stderr, "%s\n", line.c_str());
}
if (vendorDump) DumpDeviceFaultVendorBinary(device, faultInfo, DeviceFaultVendorDumpPath());
}
} catch (...) {
}
for (const auto& line : DeviceFaultReport(device, faultInfo, queue, checkpointData)) std::fprintf(stderr, "%s\n", line.c_str());
owner->hookActive.fetch_sub(1, std::memory_order_acq_rel);
};
Graphics::DeviceLostOwner() = state.get();
state->deviceLostHook = true;
@@ -2395,7 +2606,8 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window, bool compileOnly) :
state->oversizedBuffer = std::make_unique<Graphics::Buffer>(graphicsContext(), Graphics::EmptyBufferBytes, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
std::ranges::fill(state->oversizedBuffer->Bytes(), std::byte{0});
if (!compileOnly && Pm4::GdsImportable() && Graphics::HostImportFor(graphicsContext(), Pm4::GdsAddress(), Pm4::GdsBytes, Graphics::ImportRequester::Map) == nullptr) Pm4::RejectGdsImport();
state->pipelineCache = std::make_unique<Graphics::PipelineCache>(graphicsContext(), state->properties, window != nullptr || compileOnly);
static const bool headlessPipelineCache = std::getenv("APS5_HEADLESS_PIPELINE_CACHE") != nullptr;
state->pipelineCache = std::make_unique<Graphics::PipelineCache>(graphicsContext(), state->properties, window != nullptr || compileOnly || headlessPipelineCache);
state->detiler = std::make_unique<Graphics::TextureDetiler>(graphicsContext());
state->textureCache = std::make_unique<Graphics::TextureCache>(graphicsContext());
state->colorTransfer = std::make_unique<Graphics::GpuColorTransfer>(graphicsContext());
@@ -2489,6 +2701,33 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window, bool compileOnly) :
state->float32FlushToZero = probe.mismatches == 0u;
std::fprintf(stderr, "[float-controls] f32 denormal flush: %s (%u of %u probe results differ from the emulated flush, %.0f ms)\n", state->float32FlushToZero ? "hardware" : "emulated", probe.mismatches, probe.compared, std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - probeStart).count());
}
if (state->float32DenormPreserve) {
const auto probeStart = std::chrono::steady_clock::now();
state->probingFloatControls = true;
const auto probe = ProbeFloat32DenormPreserve(*this, Target());
state->probingFloatControls = false;
state->float32DenormPreserve = probe.mismatches == 0u;
std::fprintf(stderr, "[float-controls] f32 denormal preserve: %s (%u of %u probe results on normal values differ from the default mode by more than the Vulkan precision bounds, %.0f ms)\n", state->float32DenormPreserve ? "requested" : "not requested", probe.mismatches, probe.compared, std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - probeStart).count());
}
if (std::getenv("APS5_NO_NATIVE_F16_NANS") == nullptr) {
const auto probeStart = std::chrono::steady_clock::now();
state->probingFloatControls = true;
const auto probe = ProbeFloat16Conversions(*this, Target());
state->probingFloatControls = false;
state->float16WidenNans = probe.widen.probed && probe.widen.mismatches == 0u;
state->float16NarrowNans = probe.narrow.probed && probe.narrow.mismatches == 0u;
const auto describe = [](const Float16ConversionProbeDirection& direction, bool native) {
if (!direction.probed) return std::string("emulated (no native conversion)");
std::string text = std::string(native ? "native" : "emulated") + " (" + std::to_string(direction.mismatches) + " of " + std::to_string(direction.compared) + " probe results differ";
if (direction.first) {
char first[96];
std::snprintf(first, sizeof(first), ", first 0x%08x: 0x%08x emulated, 0x%08x native", direction.first->input, direction.first->emulated, direction.first->native);
text += first;
}
return text + ")";
};
std::fprintf(stderr, "[float-controls] f16 to f32 NaN results: %s; f32 to f16 NaN results: %s (%.0f ms)\n", describe(probe.widen, state->float16WidenNans).c_str(), describe(probe.narrow, state->float16NarrowNans).c_str(), std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - probeStart).count());
}
// A device without a window is usually replaced by the window's device before the title draws
// (Driver::AttachWindow): its replay starts at its first draw or dispatch instead, so the
// journal is replayed once, on the device the title draws with.
@@ -3492,6 +3731,7 @@ bool VulkanDevice::Presentable() const {
}
bool VulkanDevice::PresentClear(std::uint32_t width, std::uint32_t height, bool opaque, const DisplayBuffer* plane) {
state->presentingGuestFrame = false;
APS5_LOG_OUT_DEBUG("PresentClear width=%u height=%u opaque=%u", width, height, static_cast<unsigned>(opaque));
return present(width, height, opaque, {}, nullptr, nullptr, VK_FILTER_LINEAR, false, false, nullptr, 0, false, plane);
}
@@ -3512,6 +3752,7 @@ void VulkanDevice::PresentPixels(std::uint32_t width, std::uint32_t height, std:
frameDumpOutput.Write_nid_no_patch(name, width, height, pixels);
}
// Tests and tools present pixels synchronously; the game path splits the steps (see Driver::Present).
state->presentingGuestFrame = false;
if (!present(width, height, true, pixels)) return;
FinishPresent();
QueuePresent();
@@ -3705,6 +3946,11 @@ FrameDumps& Dumps() {
}
bool VulkanDevice::PresentDisplayBuffer(const DisplayBuffer& buffer, const DisplayBuffer* plane) {
state->presentingGuestFrame = true;
struct ClearGuestFrame {
bool& flag;
~ClearGuestFrame() { flag = false; }
} clearGuestFrame{state->presentingGuestFrame};
state->presentedAddress = buffer.address;
if (buffer.dccAddress != 0 && buffer.tilingMode == 0) {
static const bool profile = std::getenv("APS5_PROFILE_DRAW") != nullptr;
@@ -4130,6 +4376,7 @@ bool VulkanDevice::present(std::uint32_t width, std::uint32_t height, bool opaqu
state->lastPresentSerial = batchesAtBlit;
state->presentCursor = (state->presentCursor + 1) % state->presentSlots.size();
state->queuePending = true;
state->queueGuestFrame = state->presentingGuestFrame;
state->queueIndex = index;
++presentCounters.presents;
if (plane != nullptr) ++presentCounters.planes;
@@ -4241,6 +4488,8 @@ void VulkanDevice::QueuePresent() {
const auto presented = state->DeviceFunction<PFN_vkQueuePresentKHR>("vkQueuePresentKHR")(state->presentQueue != VK_NULL_HANDLE ? state->presentQueue : state->queue, &present);
if (presented == VK_ERROR_OUT_OF_DATE_KHR) state->extent = {0, 0};
else if (presented != VK_SUBOPTIMAL_KHR) check(presented, "vkQueuePresentKHR");
if (state->queueGuestFrame && (presented == VK_SUCCESS || presented == VK_SUBOPTIMAL_KHR)) LibcRunReportFramePresented_nid_no_patch();
state->queueGuestFrame = false;
timing.Mark("queue_present");
APS5_LOG_OUT_DEBUG("vkQueuePresentKHR queued imageIndex=%u", index);
}
@@ -4316,6 +4565,8 @@ ShaderRecompiler::SpirvTarget VulkanDevice::Target() const {
target.fusedExactArithmetic = state->fusedExactArithmetic;
target.hostInterpolationFirst = state->hostInterpolationFirst;
target.float32DenormPreserve = state->float32DenormPreserve;
target.float16WidenNans = state->float16WidenNans;
target.float16NarrowNans = state->float16NarrowNans;
return target;
}
@@ -4380,6 +4631,10 @@ bool VulkanDevice::SamplerFilterMinmax() const {
return state->samplerFilterMinmax;
}
bool VulkanDevice::SamplerMirrorClampToEdge() const {
return state->samplerMirrorClampToEdge;
}
bool VulkanDevice::ConservativeRasterization() const {
return state->conservativeRasterization;
}
@@ -4445,6 +4700,8 @@ Graphics::Context VulkanDevice::buildContext() const {
context.sparseBinding = state->sparseBinding;
context.sparseResidencyBuffer = state->sparseResidencyBuffer;
context.sparseResidencyAliased = state->sparseResidencyAliased;
context.sparseResidencyImage2D = state->sparseResidencyImage2D;
context.sparseImageFormatProperties = state->sparseResidencyImage2D ? state->InstanceFunction<PFN_vkGetPhysicalDeviceSparseImageFormatProperties>("vkGetPhysicalDeviceSparseImageFormatProperties") : nullptr;
context.queueFamily = state->queueFamily;
context.sparseFamily = state->sparseFamily;
context.sparseQueue = state->sparseQueue;
@@ -4465,6 +4722,7 @@ Graphics::Context VulkanDevice::buildContext() const {
context.depthBounds = state->depthBounds;
context.depthBiasClamp = state->depthBiasClamp;
context.samplerFilterMinmax = state->samplerFilterMinmax;
context.samplerMirrorClampToEdge = state->samplerMirrorClampToEdge;
context.nonSeamlessCubeMap = state->nonSeamlessCubeMap;
context.mergedCoverageSampleCounts = state->mergedCoverageSampleCounts;
context.truncatedCoverageSampleCounts = state->truncatedCoverageSampleCounts;
@@ -4499,6 +4757,7 @@ Graphics::Context VulkanDevice::buildContext() const {
context.largePoints = state->largePoints;
context.sampleRateShading = state->sampleRateShading;
context.fillModeNonSolid = state->fillModeNonSolid;
context.wideLines = state->wideLines;
context.maintenance5 = state->maintenance5;
context.storageImageMultisample = state->storageImageMultisample;
context.storageImageWriteWithoutFormat = state->storageImageWriteWithoutFormat;
@@ -4512,6 +4771,7 @@ Graphics::Context VulkanDevice::buildContext() const {
context.imageFormatList = state->imageFormatList;
context.demoteToHelperInvocation = state->demoteToHelperInvocation;
context.earlyFragmentSampleMaskTestBeforeSampleCounting = state->earlyFragmentSampleMaskTestBeforeSampleCounting;
context.fmaFloat16 = state->fmaFloat16;
context.primitiveListRestart = state->primitiveListRestart;
context.imageViewMinLod = state->imageViewMinLod;
context.shaderResourceMinLod = state->shaderResourceMinLod;
@@ -5600,10 +5860,25 @@ void VulkanDevice::recordDispatch(RecordedDispatch& record) {
if (record.pushStages != 0) {
context.Resolved(&Graphics::DeviceFunctions::cmdPushConstants, "vkCmdPushConstants")(commands, record.objects->layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, Graphics::ComputePushConstantBytes, record.pushBytes->data());
}
static const bool reportingDispatch = LibcRunReportEnabled_nid_no_patch();
if (reportingDispatch) recorder.NoteGuestWork(commands);
const auto gpuTiming = recorder.BeginGpuTiming(record.programAddress != 0 ? record.programAddress : record.shader->program->variantId);
if (state->checkpointMarker != nullptr) state->checkpointMarker(commands, reinterpret_cast<const void*>(static_cast<std::uintptr_t>(record.programAddress)));
const auto marker = state->bufferMarker != nullptr ? state->markerLog.Next(record.programAddress) : 0u;
if (marker != 0) state->bufferMarker(commands, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, state->markerBuffer, 0, marker);
AgcDriver::FaultToken faultToken = 0;
if (state->checkpointMarker != nullptr || state->bufferMarker != nullptr) {
faultToken = AgcDriver::FaultTokenRing::Instance().Claim();
if (faultToken != 0) {
if (auto* entry = AgcDriver::FaultTokenRing::Instance().Mutable(faultToken)) {
entry->submitSerial = recorder.OpenSerial();
entry->programAddress = record.programAddress;
entry->variantId = record.shader != nullptr && record.shader->program != nullptr ? record.shader->program->variantId : 0;
std::snprintf(entry->desc, sizeof(entry->desc), "dispatch %ux%ux%u", record.x, record.y, record.z);
recorder.NoteFaultToken(faultToken);
std::atomic_ref<AgcDriver::FaultToken>(entry->token).store(faultToken, std::memory_order_release);
}
}
}
if (state->checkpointMarker != nullptr) state->checkpointMarker(commands, reinterpret_cast<const void*>(static_cast<std::uintptr_t>(faultToken)));
if (faultToken != 0 && state->bufferMarker != nullptr) state->bufferMarker(commands, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, state->markerBuffer, 0, faultToken);
if (argumentImport != nullptr) {
context.Resolved(&Graphics::DeviceFunctions::cmdDispatchIndirect, "vkCmdDispatchIndirect")(commands, indirectBuffer, indirectOffset);
} else {
@@ -5636,7 +5911,7 @@ void VulkanDevice::recordDispatch(RecordedDispatch& record) {
}
}
recorder.EndGpuTiming(gpuTiming);
if (marker != 0) state->bufferMarker(commands, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, state->markerBuffer, sizeof(std::uint32_t), marker);
if (faultToken != 0 && state->bufferMarker != nullptr) state->bufferMarker(commands, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, state->markerBuffer, sizeof(std::uint32_t), faultToken);
if (overlapCapable) {
recorder.DeferDispatchBarrier(overlapQueue, runOwners, runAccesses);
resources.CopyBacksAfterRun(record.resources);
+50
View File
@@ -127,6 +127,56 @@ int APS5_VABI sceAgcDriverTmpInitIdhs(void) {
return 0;
}
int APS5_VABI sceAgcSdmaClose(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceAgcSdmaConstFill(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceAgcSdmaCopyLinear(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceAgcSdmaCopyTiledBC(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceAgcSdmaCopyTiledGen2(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceAgcSdmaCopyWindowBC(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceAgcSdmaCopyWindowGen2(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceAgcSdmaFlush(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceAgcSdmaOpen(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceAgcSdmaSetTileModesBC(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
}
extern "C" {
@@ -25,8 +25,11 @@ public:
BdaResources(const BdaResources&) = delete;
BdaResources& operator=(const BdaResources&) = delete;
VkDescriptorBufferInfo Table() const;
std::span<const std::byte> TableBytes() const;
bool TableGuardCurrent(VkDevice device, std::span<const ShaderRecompiler::BdaAbi::Range> ranges);
VkDescriptorBufferInfo Fault() const;
void CheckFault() const;
void CheckUse(const BdaResources* record) const;
void NoteUse(std::uint64_t serial);
bool TakeFaultSlot(const Context& context);
bool HoldsFaultSlot() const { return faultChunk != nullptr; }
@@ -75,8 +78,9 @@ private:
// The page table is read-only to the shader, so consecutive builds mapping the same ranges to the
// same device addresses share one buffer while one of them is alive (see the table cache in
// BdaResources.cpp, which refers to it weakly).
void markWrittenPages() const;
void checkSrtGuard() const;
void checkFault(const BdaResources& record) const;
void markWrittenPages(const BdaResources& record) const;
void checkSrtGuard(const BdaResources& faults) const;
std::span<std::byte> faultBytes() const;
std::shared_ptr<Buffer> table;
VkDevice faultDevice = VK_NULL_HANDLE;
@@ -85,6 +89,7 @@ private:
bool reportOnly = false;
std::uint64_t lastUse = 0;
std::size_t tableBytes = 0;
std::uint64_t tableGuardSerial = 0;
std::vector<ImageTableFaults> imageTables;
std::vector<std::pair<std::uint64_t, std::uint64_t>> imageTableRanges;
std::vector<SrtGuardFaults> srtGuards;
@@ -2,6 +2,8 @@
#define CORE_LIBS_PRX_LIBSCEAGCDRIVER_GRAPHICS_INCLUDE_BUFFERPOOL_HPP
#include "prx/libSceAgcDriver/Graphics/include/Context.hpp"
#include "prx/libSceAgcDriver/Graphics/include/ImageMemory.hpp"
#include <array>
#include <chrono>
#include "prx/libSceAgcDriver/Execution/include/Mutex.hpp"
#include <cstdint>
@@ -68,6 +70,8 @@ public:
static std::size_t Capacity(std::size_t bytes);
static VkBufferUsageFlags Usage(VkBufferUsageFlags usage, VkMemoryPropertyFlags properties);
VkDeviceMemory AllocateMemory(const VkMemoryAllocateInfo& allocation, const char* operation, std::optional<std::uint32_t> hostType = std::nullopt, std::uint32_t* allocatedType = nullptr, bool newImage = false);
ImageAllocation AllocateImage(const Context& context, VkImage image, const VkImageCreateInfo& imageInfo, const char* operation, bool newImage, bool budgeted);
std::size_t ImageSlabBlocks();
static VkDeviceSize ImageBudget(VkDeviceSize deviceBudget);
VkDeviceMemory TakeImageMemory(const VkMemoryAllocateInfo& allocation, const char* operation, std::optional<std::uint32_t> hostType = std::nullopt, std::uint32_t* allocatedType = nullptr, bool newImage = false);
void PutImageMemory(VkDeviceMemory memory, VkDeviceSize bytes, std::uint32_t memoryType) noexcept;
@@ -82,6 +86,29 @@ public:
std::size_t SlabBlocks();
private:
friend class ImageAllocation;
VkDeviceMemory allocateMemoryWithReuse(const VkMemoryAllocateInfo& allocation, const char* operation, std::optional<std::uint32_t> hostType, std::uint32_t* allocatedType, bool newImage, const std::function<bool(std::uint32_t)>& reuse);
static constexpr VkDeviceSize imageUnitBytes = 256;
static constexpr VkDeviceSize imageBlockBytes = VkDeviceSize{4} << 20u;
static constexpr std::uint32_t imageBlockUnits = static_cast<std::uint32_t>(imageBlockBytes / imageUnitBytes);
struct ImageBlock {
VkDeviceMemory memory = VK_NULL_HANDLE;
std::uint32_t memoryType = 0;
std::array<std::uint64_t, imageBlockUnits / 64> occupied{};
std::uint32_t freeUnits = imageBlockUnits;
std::uint32_t allocations = 0;
std::uint32_t hint = 0;
ImageBlock* previous = nullptr;
ImageBlock* next = nullptr;
bool retained = false;
};
ImageAllocation takeImageRange(const std::shared_ptr<BufferPool>& owner, std::uint32_t memoryType, VkDeviceSize bytes, VkDeviceSize alignment);
static std::optional<std::uint32_t> imageRange(const ImageBlock& block, std::uint32_t units, std::uint32_t alignment);
static void markImageRange(ImageBlock& block, std::uint32_t first, std::uint32_t units, bool occupied) noexcept;
void linkImageBlock(ImageBlock& block) noexcept;
void unlinkImageBlock(ImageBlock& block) noexcept;
void releaseImageAllocation(const ImageAllocation& allocation) noexcept;
VkDeviceSize trimImageBlocks();
struct SlabBlock {
VkDeviceMemory memory = VK_NULL_HANDLE;
std::byte* mapping = nullptr;
@@ -178,6 +205,10 @@ private:
AgcDriver::Mutex slabMutex;
std::unordered_map<std::uint64_t, Slab> slabs;
std::unordered_map<VkDeviceMemory, std::unique_ptr<SlabBlock>> slabBlocks;
AgcDriver::Mutex imageMutex;
std::unordered_map<VkDeviceMemory, std::unique_ptr<ImageBlock>> imageBlocks;
std::array<ImageBlock*, VK_MAX_MEMORY_TYPES> imageAvailable{};
std::atomic<VkDeviceSize> retainedImageSlabBytes{0};
static constexpr VkDeviceSize budget = 512ull * 1024 * 1024;
// The small tier's own budget (slots of at most half a MiB each): pinned host memory the large
// tier's budget does not count.
@@ -184,6 +184,8 @@ struct Context {
bool sparseBinding = false;
bool sparseResidencyBuffer = false;
bool sparseResidencyAliased = false;
bool sparseResidencyImage2D = false;
PFN_vkGetPhysicalDeviceSparseImageFormatProperties sparseImageFormatProperties = nullptr;
std::uint32_t queueFamily = 0;
std::uint32_t sparseFamily = VK_QUEUE_FAMILY_IGNORED;
VkQueue sparseQueue = VK_NULL_HANDLE;
@@ -214,6 +216,7 @@ struct Context {
bool dualSrcBlend = false;
bool logicOp = false;
bool samplerFilterMinmax = false;
bool samplerMirrorClampToEdge = false;
bool nonSeamlessCubeMap = false;
VkSampleCountFlags mergedCoverageSampleCounts = 0;
VkSampleCountFlags truncatedCoverageSampleCounts = 0;
@@ -248,6 +251,7 @@ struct Context {
bool largePoints = false;
bool sampleRateShading = false;
bool fillModeNonSolid = false;
bool wideLines = false;
bool maintenance5 = false;
bool storageImageMultisample = false;
bool storageImageWriteWithoutFormat = false;
@@ -260,6 +264,7 @@ struct Context {
bool viewportIndexLayer = false;
bool demoteToHelperInvocation = false;
bool earlyFragmentSampleMaskTestBeforeSampleCounting = false;
bool fmaFloat16 = false;
bool primitiveListRestart = false;
bool imageViewMinLod = false;
bool shaderResourceMinLod = false;
@@ -86,11 +86,13 @@ std::optional<MemoryValueFill> MatchMemoryValueFill(std::span<const std::uint32_
void NoteMemoryValueFill(const MemoryValueFill& fill);
bool DepthSurfaceHolds(const Context& context, const GuestTextureResource& resource, const Texture* texture);
void NoteDepthMetadataFill(std::uint64_t address, std::size_t bytes, std::uint32_t pattern);
std::size_t DiscardFilledDepthPlanes(std::uint64_t address, std::size_t bytes, std::uint32_t pattern);
void NoteDepthRenderControl(const DepthRenderControl& draw);
VkImageAspectFlags HtileFillClears(std::uint32_t pattern, bool stencilInHtile);
std::uint64_t HtileMetadataBytes(VkExtent2D extent);
bool HtileFillCovers(std::uint64_t htile, VkExtent2D extent, std::uint64_t address, std::size_t bytes);
std::shared_ptr<Texture> DepthSurfaceTexture(const Context& context, std::span<const std::uint32_t> words, const GuestTextureResource& resource, VkComponentMapping components, VkImageViewType multisampleViewType = VK_IMAGE_VIEW_TYPE_2D);
std::optional<VkExtent2D> ActiveDepthExtent(VkDevice device, std::uint64_t address);
std::shared_ptr<Texture> DepthSurfaceFirstSample(const Context& context, std::span<const std::uint32_t> words, const GuestTextureResource& resource, VkComponentMapping components);
std::size_t DepthPlaneCopyCount();
VkDeviceSize DepthPlaneCopyBytes();
@@ -7,6 +7,8 @@
#include "prx/libSceAgcDriver/Execution/include/Pm4.hpp"
#include "prx/libSceAgcDriver/Execution/include/Recipe.hpp"
#include "prx/libSceAgcDriver/Graphics/include/Recorder.hpp"
#include <array>
#include <cstdint>
#include <memory>
#include <vector>
@@ -165,6 +167,14 @@ void RunColorMetadataPass(const Context& context, const ColorMetadataPass& pass)
std::vector<std::pair<std::uint64_t, std::uint64_t>> PipelinedColorMetadataPassWrites(const ColorMetadataPass& pass);
bool DrawPipelineEnabled();
bool CommitTrims();
enum class AddressDrawReuse : std::uint8_t { Reused, Built, NotReadOnly, NotSpaceOnly, SnapshotOutside, PartialOverlap, SnapshotChanged, MovedBuffer, PatchedData, SpaceChanged, InUse, Revalidation, Count };
using AddressDrawReuseCounts = std::array<std::uint64_t, static_cast<std::size_t>(AddressDrawReuse::Count)>;
AddressDrawReuseCounts AddressDrawReuseCounters();
const char* AddressDrawReuseName(AddressDrawReuse outcome);
std::uint64_t AddressDrawReuseVerifications();
enum class DrawStopForTest { None = 0, ReturnAfterResolve = 1, ThrowAfterResolve = 2 };
void SetSpaceKeepFailuresForTest(std::uint32_t count);
void SetDrawStopAfterResolveForTest(DrawStopForTest stop);
}
@@ -57,6 +57,10 @@ inline VkDeviceSize HostImportOffset(const HostImport& import, std::uint64_t add
return address - import.base + import.lead;
}
inline bool HostImportDeviceLocal(const Context& context, const HostImport& import) {
return import.memoryType < context.memory.memoryTypeCount && (context.memory.memoryHeaps[context.memory.memoryTypes[import.memoryType].heapIndex].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) != 0;
}
struct HostImportStart {
std::uint64_t guest;
VkDeviceAddress device;
@@ -67,6 +71,7 @@ inline HostImportStart HostImportBufferStart(const HostImport& import) {
}
enum class ImportWatch : std::uint8_t { Watch, Unwatch };
enum class SnapshotService : std::uint8_t { Served, Outside, Partial, Changed };
struct ImportProbe {
const char* failure = nullptr;
@@ -155,6 +160,7 @@ bool ImportMappedRanges(const Context& context, const GuestAllocations::Mapped&
// re-checks with HostImportFor when it binds the import.
bool HostImportCovers(const Context& context, std::uint64_t address, std::size_t bytes);
bool ComparedHostImportCovers(const Context& context, std::uint64_t address, std::size_t bytes);
std::uint64_t HostImportSetGeneration();
struct RegisteredPiece {
std::uint64_t address;
std::uint64_t bytes;
@@ -287,6 +293,16 @@ std::vector<std::uint64_t> AddressTableKey(std::span<const std::pair<std::uint64
void ClearImageMirrors(VkDevice device);
void ClearHostImports(VkDevice device);
struct RetainedAddressSpace {
std::shared_ptr<const void> space;
VkDevice device = VK_NULL_HANDLE;
std::uint64_t recorder = 0;
std::uint64_t serial = 0;
RetainedAddressSpace* next = nullptr;
};
void ClearRetainedSpaces(VkDevice device);
std::size_t RetainedSpaceCount();
struct AddressCopy {
std::uint64_t begin;
std::uint64_t end;
@@ -336,8 +352,8 @@ public:
void AddReadable(std::uint64_t address, std::size_t bytes);
// Device-local staging of written and atomic elements inside host imports (see
// GuestBufferMemory.cpp): allowed only for a build whose every use records its work and then
// calls RecordCopyBacks (a dispatch), since a staged region's results reach guest memory by
// that copy alone. Call before Upload.
// calls RecordCopyBacks (a dispatch or a recorded draw), since a staged region's results reach
// guest memory by that copy alone. Call before Upload.
void AllowDeviceStaging() { stagingAllowed = true; }
void DisallowAddressStaging() { addressStaging = false; }
void AllowAdjustedRegions() { adjustedRegions = true; }
@@ -374,6 +390,7 @@ public:
const std::vector<ShaderRecompiler::BdaAbi::Range>* ranges;
};
std::optional<CachedTable> CachedAddressTable() const;
static std::optional<std::pair<std::uint64_t, std::shared_ptr<const std::vector<ShaderRecompiler::BdaAbi::Range>>>> TrySnapshotAddressSpace() noexcept;
// The registered memory an address-based build maps, shared by consecutive builds (see
// GuestBufferMemory.cpp): its lease and the sorted, immutable regions of the ranges served in
// place by imports and mirrors. Opaque outside GuestBufferMemory.cpp.
@@ -405,10 +422,22 @@ public:
for (const auto& region : regions) if (region.gpuCopy && !region.deviceLocal) return true;
return false;
}
bool HasStagedCopies() const {
for (const auto& region : regions) if (region.gpuCopy && region.deviceLocal) return true;
return false;
}
void MarkStagedWrites() const;
// Whether registered allocations are pinned until write-back (address-based shaders): by this
// build's own lease, or by the cached address space it holds.
bool HoldsLease() const { return !lease.empty() || space != nullptr; }
bool SpaceOnly() const;
std::shared_ptr<const void> ReleaseSpace();
bool RetakeSpace();
bool SpaceHeld() const;
void HoldSpaceThrough(std::uint64_t recorder, std::uint64_t serial);
bool ReleaseCompletedSpace(std::uint64_t recorder, std::uint64_t completedThrough);
static void ReleaseRetainedSpaces(std::uint64_t recorder, std::uint64_t completedThrough);
SnapshotService SnapshotsServedInPlace(std::span<const GuestMemorySnapshot> snapshots) const;
std::size_t CopiedBytes() const {
std::size_t bytes = 0;
for (const auto& region : regions) if (region.buffer != nullptr) bytes += static_cast<std::size_t>((region.bufferEnd != 0 ? region.bufferEnd : region.end) - region.begin);
@@ -435,6 +464,7 @@ public:
std::vector<std::pair<std::uint64_t, std::uint64_t>> own;
};
std::optional<SplitReads> SplitInPlaceReads() const;
bool InPlaceReadsOverlap(std::uint64_t address, std::size_t bytes) const;
std::vector<std::pair<std::uint64_t, std::uint64_t>> DeviceReads() const;
void DeviceReads(std::vector<std::pair<std::uint64_t, std::uint64_t>>& out) const;
@@ -558,6 +588,11 @@ private:
// The cached address space this build maps through (its lease pins the ranges); `regions` then
// holds only the regions outside it (V#s, snapshots, ranges copied per build).
std::shared_ptr<const AddressSpace> space;
std::weak_ptr<const AddressSpace> releasedSpace;
std::uint64_t spaceHeldThrough = 0;
std::uint64_t spaceHeldBy = 0;
std::unique_ptr<RetainedAddressSpace> retention;
void ensureRetention();
mutable std::uint64_t tableSerial = 0;
mutable std::shared_ptr<const std::vector<ShaderRecompiler::BdaAbi::Range>> tableRanges;
// Import registry epoch when `direct` pointers were taken at acquire time; they are reused while
@@ -41,6 +41,7 @@ enum class TextureTileMode {
kGcnDisplay2DPrt,
kGcnThinPrt,
kGcnThin2DPrt,
kGcnThick1D,
// Upstream's name for SW_64KB_R_X (tile mode 0x1b).
RenderTarget64KB = kR64KBX
};
@@ -114,7 +115,7 @@ struct GuestTextureResource {
};
constexpr bool IsGcnMicroTiled(TextureTileMode mode) {
return mode == TextureTileMode::kGcnThin1D || mode == TextureTileMode::kGcnDisplay1D;
return mode == TextureTileMode::kGcnThin1D || mode == TextureTileMode::kGcnDisplay1D || mode == TextureTileMode::kGcnThick1D;
}
constexpr bool IsGcnDepthTiled(TextureTileMode mode) {
@@ -134,6 +135,10 @@ constexpr bool IsGcnTiled(TextureTileMode mode) {
return IsGcnMicroTiled(mode) || IsGcnMacroTiled(mode);
}
constexpr bool IsGcnThick(TextureTileMode mode) {
return mode == TextureTileMode::kGcnThick1D;
}
constexpr TextureTileMode GcnMicroTileMode(TextureTileMode mode) {
if (mode == TextureTileMode::kGcnDisplay2D || mode == TextureTileMode::kGcnDisplayPrt || mode == TextureTileMode::kGcnDisplay2DPrt) return TextureTileMode::kGcnDisplay1D;
return IsGcnMacroTiled(mode) ? TextureTileMode::kGcnThin1D : mode;
@@ -0,0 +1,46 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGCDRIVER_GRAPHICS_INCLUDE_GUESTWORKMARK_HPP
#define CORE_LIBS_PRX_LIBSCEAGCDRIVER_GRAPHICS_INCLUDE_GUESTWORKMARK_HPP
#include <array>
#include <cstddef>
namespace AgcDriver::Graphics::GuestWorkMark {
struct Marks {
std::array<const void*, 8> buffers{};
std::size_t count = 0;
};
inline Marks& Local() {
thread_local Marks marks;
return marks;
}
inline void Note(const void* commands) {
auto& marks = Local();
for (std::size_t index = 0; index < marks.count; ++index) if (marks.buffers[index] == commands) return;
if (marks.count == marks.buffers.size()) marks.buffers[0] = marks.buffers[--marks.count];
marks.buffers[marks.count++] = commands;
}
inline bool Take(const void* commands) {
auto& marks = Local();
for (std::size_t index = 0; index < marks.count; ++index) {
if (marks.buffers[index] != commands) continue;
marks.buffers[index] = marks.buffers[--marks.count];
return true;
}
return false;
}
inline std::size_t Count() {
return Local().count;
}
inline void Forget(const void* commands) {
static_cast<void>(Take(commands));
}
}
#endif
@@ -0,0 +1,41 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGCDRIVER_GRAPHICS_INCLUDE_IMAGEMEMORY_HPP
#define CORE_LIBS_PRX_LIBSCEAGCDRIVER_GRAPHICS_INCLUDE_IMAGEMEMORY_HPP
#include "prx/libSceAgcDriver/Graphics/include/Context.hpp"
#include <cstdint>
#include <memory>
namespace AgcDriver::Graphics {
class ImageAllocation {
public:
ImageAllocation() = default;
~ImageAllocation();
ImageAllocation(const ImageAllocation&) = delete;
ImageAllocation& operator=(const ImageAllocation&) = delete;
ImageAllocation(ImageAllocation&& other) noexcept;
ImageAllocation& operator=(ImageAllocation&& other) noexcept;
void Reset() noexcept;
explicit operator bool() const noexcept { return memory != VK_NULL_HANDLE; }
VkDeviceMemory Memory() const noexcept { return memory; }
VkDeviceSize Offset() const noexcept { return offset; }
VkDeviceSize Size() const noexcept { return bytes; }
std::uint32_t MemoryType() const noexcept { return memoryType; }
private:
friend class BufferPool;
std::shared_ptr<BufferPool> owner;
VkDeviceMemory memory = VK_NULL_HANDLE;
VkDeviceSize offset = 0;
VkDeviceSize bytes = 0;
std::uint32_t memoryType = 0;
bool slab = false;
bool dedicated = false;
};
ImageAllocation AllocateImageMemory(const Context& context, VkImage image, const VkImageCreateInfo& imageInfo, const char* operation, bool newImage = false, bool budgeted = false);
std::uint64_t ImageMemoryReleasedBytes() noexcept;
}
#endif
@@ -7,6 +7,7 @@
#include "BdaAbi.hpp"
#include "prx/libSceAgcDriver/Graphics/include/State.hpp"
#include <array>
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <functional>
@@ -51,12 +52,16 @@ public:
void Discard();
std::optional<std::uint32_t> Pending() const { return filled; }
const std::string& Refusal() const { return refusal; }
std::uint64_t Noted() const { return noted; }
std::uint64_t SameRun() const { return sameRun; }
private:
std::uint64_t address = 0;
std::uint64_t bytes = 0;
std::optional<std::uint32_t> filled;
std::string refusal;
std::uint64_t noted = 0;
std::uint64_t sameRun = 0;
};
enum class MultisampleColorContent { Unknown, Fill, FastClear, Clear, Drawn };
@@ -69,9 +74,15 @@ struct MultisampleColorAlias {
MultisampleColorContent newest = MultisampleColorContent::Unknown;
std::optional<VkClearColorValue> value;
std::optional<std::uint8_t> byte;
std::shared_ptr<std::atomic<bool>> active;
std::uint64_t contents = 0;
std::uint64_t filledBytes = 0;
std::uint64_t fills = 0;
std::uint64_t sameRun = 0;
};
std::optional<MultisampleColorAlias> MultisampleColorTargetOver(std::uint64_t address, std::size_t bytes);
std::vector<MultisampleColorAlias> MultisampleColorTargetsOver(std::uint64_t address, std::size_t bytes);
void WithMultisampleTargetsLockForTest(const std::function<void()>& inside);
std::uint64_t MultisampledColorBytes(const ColorTarget& target);
@@ -148,6 +148,7 @@ bool HasStencil(VkFormat format);
void ValidateViewport(const Context& context, const VkViewport& viewport);
void ValidateDepthBounds(const Context& context, const State& state);
void ValidateMeshLimits(const Context& context, const ShaderRecompiler::MeshConfiguration& mesh, std::uint32_t invocations);
void ValidateLineWidth(const Context& context, float width);
void ValidateProvokingVertex(const Context& context, const State& state, std::span<const CompiledShader> shaders = {});
bool BarycentricPatches(const State& state, std::span<const CompiledShader> shaders);
bool ValidateSampleLocations(const Context& context, const State& state);
@@ -157,7 +158,7 @@ bool ShadersWriteMemory(std::span<const CompiledShader> shaders);
bool DeclaresEarlyFragmentTests(const ShaderRecompiler::RecompileResult& program);
void ValidateSampleMask(const Context& context, const State& state, std::span<const CompiledShader> shaders);
// Returns the color attachment locations the pixel shader writes.
std::set<std::uint32_t> ValidateShaders(std::span<const CompiledShader> shaders, const State& state, const VkPhysicalDeviceSubgroupProperties& subgroup, bool fragmentShaderBarycentric, bool descriptorIndexing = false, bool imageInt64Atomics = false, bool geometryShader = false, bool sampleRateShading = false, bool bufferInt64Atomics = false, bool shaderClipDistance = false, bool shaderCullDistance = false, bool viewportIndexLayer = false, bool runtimeDescriptorArray = false, bool demoteToHelperInvocation = false, bool shaderTerminateInvocation = false, bool meshShader = true, bool shaderResourceMinLod = false);
std::set<std::uint32_t> ValidateShaders(std::span<const CompiledShader> shaders, const State& state, const VkPhysicalDeviceSubgroupProperties& subgroup, bool fragmentShaderBarycentric, bool descriptorIndexing = false, bool imageInt64Atomics = false, bool geometryShader = false, bool sampleRateShading = false, bool bufferInt64Atomics = false, bool shaderClipDistance = false, bool shaderCullDistance = false, bool viewportIndexLayer = false, bool runtimeDescriptorArray = false, bool demoteToHelperInvocation = false, bool shaderTerminateInvocation = false, bool meshShader = true, bool shaderResourceMinLod = false, bool fmaFloat16 = false);
}
@@ -5,6 +5,7 @@
#include "prx/libSceAgcDriver/Graphics/include/Context.hpp"
#include "prx/libSceAgcDriver/Graphics/include/PassHazards.hpp"
#include "prx/libSceAgcDriver/Execution/include/Mutex.hpp"
#include "prx/libSceAgcDriver/Execution/include/SubmissionSnapshots.hpp"
#include <unordered_map>
#include <atomic>
#include <chrono>
@@ -122,7 +123,7 @@ public:
static constexpr std::size_t KeptBytesBudget = std::size_t{512} << 20u;
void BoundKeptBytes();
std::size_t InFlightKeptBytes() const { return inFlightKeptBytes; }
enum class SnapshotUse : std::uint8_t { Storage, Vertex, Index16, Index32, Index16Restart, Index32Restart };
enum class SnapshotUse : std::uint8_t { Storage, Vertex, Index16, Index32, Index16Restart, Index32Restart, PaddedVertex };
static constexpr std::size_t DrawSnapshotBudget = std::size_t{1024} << 20u;
static constexpr std::size_t DrawSnapshotEntries = 1024;
static constexpr std::size_t UnwrittenSnapshotEntries = 4096;
@@ -249,6 +250,7 @@ public:
bool DumpSamples(VkDeviceAddress target, std::uint64_t address = 0);
void NoteSampledDraw(VkCommandBuffer commands);
void NoteDrawTraceToken(std::uint64_t token) noexcept;
void NoteFaultToken(AgcDriver::FaultToken token) noexcept;
bool QueuesSampleDumps() const;
void PrepareSampleSlot();
void EndPassSamples();
@@ -450,12 +452,14 @@ public:
// so a batch is submitted after a bounded amount of work (APS5_BATCH_CAP).
static std::uint64_t RecordedWorkSinceSubmit();
static void CountRecordedWork();
bool NoteGuestWork(VkCommandBuffer commands);
// The recorder of the current device, for code that only has guest addresses (the flush hook)
// and for helpers that must not recycle resources the recorded work still uses.
static Recorder* Active();
VkDevice Device() const { return context.device; }
std::uint64_t Id() const { return id; }
static bool Alive(std::uint64_t id);
// Whether the calling thread runs inside a batch's completion action (finish()): a store made
// there must not have a publish recorded for it (UnitShadow), see SyncThrough.
static bool InCompletion();
@@ -627,8 +631,12 @@ private:
std::vector<ReadListNote> readLists;
// Submission number (1-based): identifies a batch after its allocation may have been reused.
std::uint64_t serial = 0;
std::uint64_t predictedSerial = 0;
AgcDriver::FaultToken firstToken = 0;
AgcDriver::FaultToken lastToken = 0;
std::uint64_t traceId = 0;
bool submitted = false;
bool guestWork = false;
std::atomic<bool> submitStarted{false};
// The GpuMutex queue tag of the thread that opened the batch, and when it was submitted
// (the [syncwait] line reports what a wait's target and the batches ahead of it were).
@@ -962,6 +970,14 @@ private:
mutable bool publishedWriteRangesValid = false;
};
inline void EmitNvCheckpointToken(VkCommandBuffer commands, AgcDriver::FaultToken token, PFN_vkCmdSetCheckpointNV setCheckpoint) noexcept {
try {
if (commands == VK_NULL_HANDLE || setCheckpoint == nullptr || token == 0) return;
setCheckpoint(commands, reinterpret_cast<const void*>(static_cast<std::uintptr_t>(token)));
} catch (...) {
}
}
}
#endif
@@ -97,6 +97,8 @@ private:
std::uint32_t memoryType = 0;
};
void NoteGuestWorkOnCommandBuffer(VkCommandBuffer commands);
class CommandBatch {
public:
explicit CommandBatch(const Context& context);
@@ -26,6 +26,7 @@ public:
bool ReadsOpaqueBlackBorder() const;
bool RequiresNonSeamlessCube() const;
static void Validate(const Context& context, const GuestSamplerResource& descriptor);
static bool ShaderAppliesLodBias(const GuestSamplerResource& descriptor);
static bool ReadsOpaqueBlackBorder(const GuestSamplerResource& descriptor);
private:
@@ -10,6 +10,7 @@
#include "IntermediateRepresentation/IrMetadata/ResourcePlan.hpp"
#include "prx/libSceAgcDriver/Graphics/include/Shaders.hpp"
#include <array>
#include <atomic>
#include <chrono>
#include <limits>
#include <list>
@@ -155,6 +156,9 @@ struct ImageTableReuseCounts {
std::uint64_t replayed = 0;
std::uint64_t writesKept = 0;
std::uint64_t writesMade = 0;
std::uint64_t variantSurfaces = 0;
std::uint64_t variantSubstituted = 0;
std::uint64_t variantRejected = 0;
};
ImageTableReuseCounts ImageTableReuses();
std::uint64_t SampledTexturesCleared();
@@ -170,7 +174,7 @@ struct PresyncSurface {
class ShaderResources {
public:
ShaderResources(const Context& context, const ShaderRecompiler::RecompileResult& vertex, const ShaderRecompiler::RecompileResult& fragment, const ColorTarget& target, std::uint64_t indexAddress, std::size_t indexBytes);
ShaderResources(const Context& context, std::span<const CompiledShader> shaders, const ColorTarget& target, std::uint32_t colorAttachments, std::uint64_t indexAddress, std::size_t indexBytes, std::span<const GuestMemorySnapshot> snapshots = {});
ShaderResources(const Context& context, std::span<const CompiledShader> shaders, const ColorTarget& target, std::uint32_t colorAttachments, std::uint64_t indexAddress, std::size_t indexBytes, std::span<const GuestMemorySnapshot> snapshots = {}, bool deviceStaging = false);
ShaderResources(const Context& context, const CompiledShader& compute, std::span<const GuestMemorySnapshot> snapshots = {});
// Two-stage build for dispatches (see build): with `deferred` the constructor runs stage A only,
// which needs no device lock, and Complete() runs stage B under GuestMemory::GpuMutex; until
@@ -217,8 +221,20 @@ public:
std::size_t size;
std::span<const std::uint32_t> words;
};
std::shared_ptr<DrawBindings> PrepareDrawBindings(Recorder& recorder, std::span<const MovedBuffer> moved = {}, bool movedOnly = false) const;
std::optional<std::vector<MovedBuffer>> MovedReadOnlyBuffers(std::span<const CompiledShader> shaders, Recorder& recorder, const ColorTarget* target) const;
struct DrawUse {
DrawUse() = default;
DrawUse(const DrawUse&) = delete;
DrawUse& operator=(const DrawUse&) = delete;
~DrawUse();
std::shared_ptr<BdaResources> record;
std::shared_ptr<DrawBindings> bindings;
std::shared_ptr<std::atomic<bool>> ownRecord;
};
std::shared_ptr<DrawUse> BeginDrawUse(Recorder& recorder) const;
void CompleteDrawUse(const DrawUse& use) const;
void BindDrawUse(VkCommandBuffer commands, VkPipelineLayout layout, const DrawUse* use) const;
std::shared_ptr<DrawBindings> PrepareDrawBindings(Recorder& recorder, std::span<const MovedBuffer> moved = {}, bool movedOnly = false, const BdaResources* faultRecord = nullptr) const;
std::optional<std::vector<MovedBuffer>> MovedReadOnlyBuffers(std::span<const CompiledShader> shaders, Recorder& recorder, const ColorTarget* target, bool* patchedData = nullptr) const;
static std::uint64_t BytesUpToTarget(std::uint64_t address, std::uint64_t bytes, std::uint64_t stride, const ColorTarget* target);
enum class MoveRefusal : std::size_t { None, Shape, NotGuest, Written, Limit, Inaccessible, Overlap, Bindings, Count };
struct MoveProof {
@@ -242,12 +258,23 @@ public:
bool HasCopiedWrites() const { return guestMemory.HasCopiedWrites(); }
bool HasGpuCopies() const { return guestMemory.HasGpuCopies(); }
bool HasHostGpuCopies() const { return guestMemory.HasHostGpuCopies(); }
bool HasStagedCopies() const { return guestMemory.HasStagedCopies(); }
const void* MemoryOwner() const { return &guestMemory; }
void CopyBacksAfterRun(std::shared_ptr<ShaderResources> self) { afterRunSelf = std::move(self); }
void RunAccesses(std::vector<std::array<std::uint64_t, 3>>& out) const;
bool HoldsLease() const { return guestMemory.HoldsLease(); }
bool SpaceReuse() const { return spaceReuse; }
static bool SpaceReuseDisabled();
bool BdaReadOnly() const { return usesBda && bdaReadOnly; }
bool RetakeSpace() { return guestMemory.RetakeSpace(); }
bool SpaceHeld() const { return guestMemory.SpaceHeld(); }
SnapshotService SnapshotsServedInPlace(std::span<const GuestMemorySnapshot> snapshots) const { return guestMemory.SnapshotsServedInPlace(snapshots); }
std::shared_ptr<const void> ReleaseSpace() { return guestMemory.ReleaseSpace(); }
void HoldSpaceThrough(std::uint64_t recorder, std::uint64_t serial) { guestMemory.HoldSpaceThrough(recorder, serial); }
bool ReleaseCompletedSpace(std::uint64_t recorder, std::uint64_t completedThrough) { return guestMemory.ReleaseCompletedSpace(recorder, completedThrough); }
bool UsesAddressTable() const { return usesBda; }
std::span<const std::byte> AddressTableBytes() const;
bool AddressTableGuardCurrent();
std::size_t CopiedBytes() const { return guestMemory.CopiedBytes(); }
bool WritesOverlap(std::uint64_t address, std::size_t bytes) const { return guestMemory.WritesOverlap(address, bytes); }
bool CopiedWritesOverlap(std::uint64_t address, std::size_t bytes) const { return guestMemory.CopiedWritesOverlap(address, bytes); }
@@ -311,6 +338,7 @@ public:
struct ProofReport {
ProofPath path = ProofPath::Fast;
ProofFailure failure = ProofFailure::None;
bool audited = false;
};
bool Revalidate(std::span<const CompiledShader> shaders, ProofReport* report = nullptr);
static bool EpochProofs();
@@ -517,7 +545,7 @@ private:
std::size_t nextImageRecord = 0;
// Stage B: the record's texture when the fastRevalidate predicate proves it current under the
// lock and the cache still holds it; null sends the element to cachedTexture.
std::shared_ptr<Texture> fastTexture(const ImageRecord& record);
std::shared_ptr<Texture> fastTexture(ImageRecord& record);
void resolveImageBinding(const ShaderRecompiler::DescriptorBinding& binding, Binding& item, std::span<const std::shared_ptr<Sampler>> shaderSamplers);
void applySamplerVariants();
void forgetDeferredInputs();
@@ -547,6 +575,7 @@ private:
bool depth = false;
bool valid = false;
};
bool keepsTemplateRecords() const;
void captureValidation();
// A surface of this object the fast proof found a foreign image pending over: the element
// (index into textures, or into storageTextures when `storage`) whose own object stands in for
@@ -592,6 +621,7 @@ private:
std::vector<BdaResources::SrtGuardFaults> srtGuardFaults;
bool usesBda = false;
bool bdaReadOnly = true;
bool spaceReuse = false;
bool faultReportOnly = true;
std::vector<std::uint64_t> multisampleSources;
bool usesFaultBuffer = false;
@@ -635,11 +665,14 @@ private:
};
std::vector<FaultDescriptor> faultDescriptors;
void prepareFaultSlot() const;
void writeDrawSets(DrawBindings& result, std::span<const std::size_t> selected, const BdaResources* faultRecord) const;
std::shared_ptr<std::atomic<bool>> ownRecordBusy = std::make_shared<std::atomic<bool>>(false);
mutable std::vector<VkDescriptorPoolSize> drawPoolSizes;
// Guest buffer elements bound read-only: each use of this object skips that many pending-write
// notes (counted in MarkGpuWrites for the [buffers] line).
std::size_t readOnlyBuffers = 0;
std::chrono::steady_clock::time_point lastFullWalk = std::chrono::steady_clock::now();
std::uint64_t walkImportGeneration = HostImportSetGeneration();
std::vector<std::pair<std::uint64_t, std::uint64_t>> writeOnlyRanges;
bool drawBuild = false;
std::uint64_t dispatchThreads = 0;
@@ -179,6 +179,7 @@ struct State {
VkRect2D scissor;
VkCullModeFlags cullMode;
VkPolygonMode polygonMode = VK_POLYGON_MODE_FILL;
float lineWidth = 1.0f;
VkFrontFace frontFace;
VkProvokingVertexModeEXT provokingVertexMode = VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT;
VkPipelineColorBlendAttachmentState blend;
@@ -4,6 +4,7 @@
#include "prx/libSceAgcDriver/Graphics/include/Context.hpp"
#include "prx/libSceAgcDriver/Graphics/include/DccMetadata.hpp"
#include "prx/libSceAgcDriver/Graphics/include/GuestTextureResource.hpp"
#include "prx/libSceAgcDriver/Graphics/include/ImageMemory.hpp"
#include "prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp"
#include "prx/libSceAgcDriver/Graphics/include/TextureTiling.hpp"
#include "prx/libSceAgcDriver/Graphics/include/UnitShadow.hpp"
@@ -40,6 +41,14 @@ bool StorageFormatAvailable(const Context& context, std::uint32_t guestFormat);
VkFormat HostStorageFormat(const Context& context, VkFormat format);
bool StorageClearAvailable(const Context& context, std::uint32_t guestFormat, DccKeys keys);
std::uint64_t SampledTextureMemory();
struct SparseLevelBinds {
std::vector<VkSparseImageMemoryBind> levels;
std::vector<VkSparseMemoryBind> tails;
VkDeviceSize bytes = 0;
};
std::optional<SparseLevelBinds> PlanSparseLevels(VkExtent3D extent, std::uint32_t mipLevels, std::uint32_t arrayLayers, VkDeviceSize alignment, std::span<const VkSparseImageMemoryRequirements> requirements, std::uint32_t firstLevel);
bool ClearKeepsDenormals(const Context& context, VkFormat format);
bool ClearColorForTexel(VkFormat format, std::uint32_t elementBytes, std::span<const std::uint32_t, 4> pattern, VkClearColorValue& clear);
@@ -50,12 +59,13 @@ struct OwnedImage {
OwnedImage(const OwnedImage&) = delete;
OwnedImage& operator=(const OwnedImage&) = delete;
~OwnedImage();
void Allocate(const Context& device, const VkMemoryAllocateInfo& allocation, std::uint32_t mask, const char* operation, bool newImage = false);
void Allocate(const Context& device, const VkImageCreateInfo& imageInfo, const char* operation, bool newImage = false, bool budgeted = false);
Context context;
VkImage image;
VkDeviceMemory memory;
VkDeviceSize memoryBytes = 0;
std::uint32_t memoryType = 0;
ImageAllocation allocation;
};
class Texture {
@@ -298,7 +308,7 @@ public:
std::uint32_t TrackedUnits() const { return trackedLayers; }
void MarkSliceDirty(std::uint32_t slice, std::uint32_t count = 1);
bool MarkDrawn(std::uint32_t slice, std::uint32_t count, VkRect2D scissor);
void Flush();
void Flush(const char* reason = "cache eviction");
void Detach();
bool Dirty() const;
// Stores every pending image overlapping the range, except `except`; returns whether any was.
@@ -401,7 +411,18 @@ public:
// contains a descriptor of its first mips), if any; the caller decides whether the geometry fits
// (Texture::CanCopyFrom, ResidentPresentable).
static std::shared_ptr<StorageTexture> FindPending(std::uint64_t address, std::uint64_t bytes);
VkDevice Device() const;
static std::uint64_t EightBitWrites();
static std::shared_ptr<StorageTexture> FindPendingSlice(std::uint64_t address, std::uint64_t bytes);
struct WriteRecord {
std::uint32_t width;
std::uint32_t height;
TextureTileMode tileMode;
TextureDimension dimension;
std::uint32_t format;
std::uint64_t serial;
};
static std::optional<WriteRecord> LastWrite(std::uint64_t address);
// How a buffer fill of [address, address + bytes) (Driver.cpp's fill HLE) meets the storage
// images alive: none of them; a whole surface (Exact) or one array layer of a surface (Layer),
// `image` and `layer` naming it, whatever other images lie over the range (`others`, of which
@@ -482,12 +503,14 @@ public:
static std::uint64_t SinglePassMoves();
static std::uint64_t SlabRetiles();
static std::uint64_t PaddingSeedCopies();
static std::uint64_t LinearImportRetiles();
static std::uint64_t RefreshesProved();
static std::uint64_t ClearHandOvers();
static std::uint64_t CreationHandOvers();
static std::uint64_t HandedOverSuperseded();
static void SetClearHandOver(bool enabled);
static std::uint64_t UntrackedCompares();
static std::uint64_t GuestSnapshots();
static std::uint64_t OccasionalLabelStores();
std::uint64_t GuestBytes() const;
std::uint64_t BudgetBytes() const;
@@ -525,6 +548,7 @@ private:
void hashBeforeUnwatch(std::uint64_t address, std::size_t bytes, bool proven);
void forgetUnwatchHash(std::uint32_t first, std::uint32_t count);
bool originalHolds(std::uint64_t address, std::size_t bytes) const;
bool guestBytesStillHeld() const;
bool compareUntracked(std::uint64_t address, std::size_t bytes, std::span<std::uint8_t> changed, bool memoize = false) const;
// Stores the pending tracked layers overlapping [address, address + bytes) to guest memory; in
// each, 64 KiB blocks the CPU wrote since the layer's generation keep the CPU's bytes. Block
@@ -790,9 +814,8 @@ private:
// write here bumps the pending serial although the image was pending already.
bool lent = false;
VkImage image = VK_NULL_HANDLE;
VkDeviceMemory memory = VK_NULL_HANDLE;
ImageAllocation imageAllocation;
VkDeviceSize memoryBytes = 0;
std::uint32_t memoryType = 0;
VkImageView view = VK_NULL_HANDLE;
std::uint32_t defaultMip = 0;
std::map<std::uint32_t, VkImageView> extraViews;
@@ -805,7 +828,7 @@ private:
bool attachable = false;
std::map<std::tuple<VkFormat, std::uint32_t, std::uint32_t, std::uint32_t, std::uint32_t>, VkImageView> attachmentViews;
VkImage proxyImage = VK_NULL_HANDLE;
VkDeviceMemory proxyMemory = VK_NULL_HANDLE;
ImageAllocation proxyAllocation;
VkImageView proxyView = VK_NULL_HANDLE;
VkFormat storageFormat = VK_FORMAT_UNDEFINED;
VkFormat imageFormat = VK_FORMAT_UNDEFINED;
Loaded 100 of 1662 files, more files were not shown because too many files have changed in this diff. Show more