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

This commit is contained in:
Yunus Shaikh committed 2026-11-07 03:58:53 -08:00
commit 86527d2f76
499 files changed
+20097 -3449

No files matched your search

+4 -1
View File
@@ -61,7 +61,7 @@ jobs:
full: ${{ steps.gate.outputs.full }}
relinker-hosts: ${{ steps.gate.outputs.relinker-hosts }}
steps:
- uses: actions/github-script@v8
- uses: actions/github-script@v9
id: gate
env:
PR_NUMBER: ${{ inputs.pr }}
@@ -469,6 +469,9 @@ jobs:
MESA_SHADER_CACHE_DIR: /var/cache/anyps5/mesa
MESA_SHADER_CACHE_MAX_SIZE: 4G
steps:
- name: Remove git locks left by an interrupted checkout
shell: bash
run: if [ -d .git ]; then find .git -name '*.lock' -type f -print -delete; fi
- uses: actions/checkout@v7
with:
ref: ${{ needs.eligibility.outputs.sha }}
+1 -1
View File
@@ -27,7 +27,7 @@ jobs:
cmake -S core/libs/tests/emscripten -B build-native -DCMAKE_BUILD_TYPE=Release
cmake --build build-native --parallel 2
ctest --test-dir build-native --output-on-failure --no-tests=error
- uses: actions/setup-node@v6
- uses: actions/setup-node@v7
with:
node-version: '26'
- name: Compile memory64 libraries and test conversions and module errors
+1 -1
View File
@@ -18,7 +18,7 @@ jobs:
issues: write
pull-requests: write
steps:
- uses: actions/github-script@v8
- uses: actions/github-script@v9
with:
script: |
const { owner, repo } = context.repo;
+7 -1
View File
@@ -150,12 +150,12 @@ jobs:
permissions:
contents: write
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/download-artifact@v8
with:
pattern: release-*
@@ -174,11 +174,15 @@ jobs:
chmod +x "dist/relinker-$RELEASE_TAG"
- name: Prepare release notes
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api --method POST "repos/$GH_REPO/releases/generate-notes" -f tag_name="$RELEASE_TAG" > "$RUNNER_TEMP/release-notes.json"
python tools/prepare_release_notes.py --input "$RUNNER_TEMP/release-notes.json" --body "$RUNNER_TEMP/release-body.md" --full dist/release-notes.md
- name: Create or refresh draft and upload files
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
release_marker="<!-- anyps5-release-workflow:$GITHUB_SHA -->"
printf '\n%s\n' "$release_marker" >> "$RUNNER_TEMP/release-body.md"
@@ -215,4 +219,6 @@ jobs:
exit 1
fi
- name: Publish complete release
env:
GH_TOKEN: ${{ github.token }}
run: gh release edit "$RELEASE_TAG" --draft=false
+1
View File
@@ -57,6 +57,7 @@ build-wasm/
.idea/
.vscode/
.system_generated/
.venv/
venv/
+3
View File
@@ -82,3 +82,6 @@
[submodule "3rdparty/sqlite"]
path = 3rdparty/sqlite
url = https://github.com/sqlite/sqlite.git
[submodule "3rdparty/fontconfig"]
path = 3rdparty/fontconfig
url = https://github.com/fontconfig/fontconfig.git
Vendored Submodule
+1
Submodule 3rdparty/fontconfig added at 72b9a48f57.
+28
View File
@@ -191,6 +191,7 @@ if(BUILD_TESTING)
add_test(NAME pad_command_file COMMAND pad_command_file_tests)
set_tests_properties(pad_command_file PROPERTIES TIMEOUT 20)
if(Python3_Interpreter_FOUND)
get_property(windows_tooling_before DIRECTORY PROPERTY TESTS)
add_test(NAME mingw_host_only_test_targets COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_mingw_host_only_test_targets.py)
add_test(NAME patch_lib_atrac9 COMMAND ${Python3_EXECUTABLE}
@@ -301,6 +302,8 @@ if(BUILD_TESTING)
${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)
add_test(NAME release_workflow COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/tests/test_release_workflow.py)
set_tests_properties(release_workflow PROPERTIES TIMEOUT 20)
foreach(shard RANGE 0 11)
if(shard EQUAL 0)
set(conventions_test_name conventions_function_bodies)
@@ -355,6 +358,8 @@ if(BUILD_TESTING)
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_check_conventions_unknown_nids.py)
add_test(NAME conventions_debt_length COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_check_conventions_debt_length.py)
add_test(NAME conventions_debt_labels COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_check_conventions_debt_labels.py)
add_test(NAME test_registration COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_test_registration.py)
add_test(NAME unbuilt_exports COMMAND ${Python3_EXECUTABLE}
@@ -450,6 +455,8 @@ if(BUILD_TESTING)
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_stubgen.py)
add_test(NAME debt_split COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_debt_split.py)
add_test(NAME debt_report COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_debt_report.py)
add_test(NAME agc_test_split COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_agc_test_split.py)
add_test(NAME stubgen_stdout_newlines COMMAND ${Python3_EXECUTABLE}
@@ -643,6 +650,27 @@ if(BUILD_TESTING)
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)
add_test(NAME relinker_fuzz_seeds COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_relinker_fuzz_seeds.py)
if(WIN32)
get_property(windows_tooling_after DIRECTORY PROPERTY TESTS)
list(REMOVE_ITEM windows_tooling_after ${windows_tooling_before})
function(raise_windows_tooling_test_timeouts)
foreach(windows_tooling_test IN LISTS ARGN)
get_test_property(${windows_tooling_test} TIMEOUT windows_tooling_timeout)
if(windows_tooling_timeout MATCHES "^[0-9.]+$" AND windows_tooling_timeout LESS 120)
set_tests_properties(${windows_tooling_test} PROPERTIES TIMEOUT 120)
endif()
endforeach()
endfunction()
raise_windows_tooling_test_timeouts(${windows_tooling_after})
function(raise_windows_deferred_tooling_test_timeouts)
get_property(windows_deferred_tests DIRECTORY PROPERTY TESTS)
list(FILTER windows_deferred_tests INCLUDE REGEX "^check_compile_")
raise_windows_tooling_test_timeouts(${windows_deferred_tests})
endfunction()
cmake_language(DEFER CALL raise_windows_deferred_tooling_test_timeouts)
endif()
endif()
endif()
+1 -1
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) | [Bahasa Indonesia](docs/user/README.id.md)
**English** | [Português (Brasil)](docs/user/README.pt-BR.md) | [Español](docs/user/README.es.md) | [Català](docs/user/README.ca.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
+13 -2
View File
@@ -708,7 +708,7 @@ if(BUILD_TESTING)
target_include_directories(guest_kernel_sys_pthread_np_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_sys_pthread_np_tests PRIVATE libkernel_sys libkernel libc)
configure_windows_unwind(guest_kernel_sys_pthread_np_tests)
foreach(pthreadNpMode IN ITEMS rwlockattr kind)
foreach(pthreadNpMode IN ITEMS rwlockattr kind attr)
add_test(NAME guest_kernel_sys_pthread_np_${pthreadNpMode} COMMAND guest_kernel_sys_pthread_np_tests ${pthreadNpMode})
set_tests_properties(guest_kernel_sys_pthread_np_${pthreadNpMode} PROPERTIES TIMEOUT 20)
if(WIN32)
@@ -802,7 +802,7 @@ if(BUILD_TESTING)
add_test(NAME windows_crash_thread_name COMMAND windows_crash_thread_name_tests $<TARGET_FILE:libc>)
set_tests_properties(windows_crash_thread_name PROPERTIES TIMEOUT 20
PASS_REGULAR_EXPRESSION "on thread [0-9]+ 'a+Z'[^~]*thread [0-9]+ 'c+Y':"
FAIL_REGULAR_EXPRESSION "Zb|Yd|did not fault")
FAIL_REGULAR_EXPRESSION "thread [0-9]+ 'a+Z[^']|thread [0-9]+ 'c+Y[^']|did not fault")
add_test_executable(windows_crash_text_tests tests/WindowsCrashText.cpp)
add_dependencies(windows_crash_text_tests libc)
if(MINGW)
@@ -956,6 +956,17 @@ if(BUILD_TESTING)
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceXml>")
endif()
add_test_executable(guest_fontconfig_current_tests tests/GuestFontconfigCurrent.cpp)
target_include_directories(guest_fontconfig_current_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_fontconfig_current_tests PRIVATE libfontconfig libkernel libc)
configure_windows_unwind(guest_fontconfig_current_tests)
add_test(NAME guest_fontconfig_current COMMAND guest_fontconfig_current_tests)
set_tests_properties(guest_fontconfig_current PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_fontconfig_current PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libfontconfig>")
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)
+37 -74
View File
@@ -9,90 +9,73 @@
extern "C" {
int APS5_VABI sceAbstractYoutubeUnknown_Hyxyxn00C18_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage10YoutubeAPI11SendContentEPKvl() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Hyxyxn00C18", sceAbstractYoutubeUnknown_Hyxyxn00C18_nid_no_patch);
int APS5_VABI sceAbstractYoutubeUnknown_YWi5nsiD7Gc_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage10YoutubeAPI14SetAccessTokenERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("YWi5nsiD7Gc", sceAbstractYoutubeUnknown_YWi5nsiD7Gc_nid_no_patch);
int APS5_VABI sceAbstractYoutubeUnknown_Iy3kQxW3G10_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage10YoutubeAPI17GetUploadLocationERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEmS7_RS5_() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Iy3kQxW3G10", sceAbstractYoutubeUnknown_Iy3kQxW3G10_nid_no_patch);
int APS5_VABI sceAbstractYoutubeUnknown_LHSZA0ujcbM_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage10YoutubeAPI5StartERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("LHSZA0ujcbM", sceAbstractYoutubeUnknown_LHSZA0ujcbM_nid_no_patch);
int APS5_VABI sceAbstractYoutubeUnknown_Vzp_LwIEg3o_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage10YoutubeAPI6ResumeERSbIcSt11char_traitsIcENS_8StlAllocIcEEERlm() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Vzp+LwIEg3o", sceAbstractYoutubeUnknown_Vzp_LwIEg3o_nid_no_patch);
int APS5_VABI sceAbstractYoutubeUnknown_a3T5ylvPLd8_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage10YoutubeAPI7SuspendEv() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("a3T5ylvPLd8", sceAbstractYoutubeUnknown_a3T5ylvPLd8_nid_no_patch);
int APS5_VABI sceAbstractYoutubeUnknown_XB_EN3hFrS4_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage10YoutubeAPI8initHttpEv() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("XB-EN3hFrS4", sceAbstractYoutubeUnknown_XB_EN3hFrS4_nid_no_patch);
int APS5_VABI sceAbstractYoutubeUnknown_NomnFPQmVmY_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage10YoutubeAPI8termHttpEv() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("NomnFPQmVmY", sceAbstractYoutubeUnknown_NomnFPQmVmY_nid_no_patch);
int APS5_VABI sceAbstractYoutubeUnknown_Koq9Z_B4jcQ_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage10YoutubeAPIC1Ev() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Koq9Z-B4jcQ", sceAbstractYoutubeUnknown_Koq9Z_B4jcQ_nid_no_patch);
int APS5_VABI sceAbstractYoutubeUnknown_PAkQucLJN0c_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage10YoutubeAPIC2Ev() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("PAkQucLJN0c", sceAbstractYoutubeUnknown_PAkQucLJN0c_nid_no_patch);
int APS5_VABI sceAbstractYoutubeUnknown_iqJYGVNed1E_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage10YoutubeAPID1Ev() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("iqJYGVNed1E", sceAbstractYoutubeUnknown_iqJYGVNed1E_nid_no_patch);
int APS5_VABI sceAbstractYoutubeUnknown_Pf_StbYH98s_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage10YoutubeAPID2Ev() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Pf-StbYH98s", sceAbstractYoutubeUnknown_Pf_StbYH98s_nid_no_patch);
int APS5_VABI sceAbstractYoutubeUnknown__mALZnOB7ro_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage13YoutubeFolder10NewContentERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEPSt10shared_ptrINS_7ContentEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("-mALZnOB7ro", sceAbstractYoutubeUnknown__mALZnOB7ro_nid_no_patch);
int APS5_VABI sceAbstractYoutubeUnknown_A8fX5m6Lnrg_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage13YoutubeFolder12RemoveFolderERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEb() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("A8fX5m6Lnrg", sceAbstractYoutubeUnknown_A8fX5m6Lnrg_nid_no_patch);
int APS5_VABI sceAbstractYoutubeUnknown_LGgxtVdxaLY_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage13YoutubeFolder13RemoveContentERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("LGgxtVdxaLY", sceAbstractYoutubeUnknown_LGgxtVdxaLY_nid_no_patch);
int APS5_VABI sceAbstractYoutubeUnknown_JiGH4RQ_WxU_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage13YoutubeFolder4OpenENS_8ItemTypeE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("JiGH4RQ+WxU", sceAbstractYoutubeUnknown_JiGH4RQ_WxU_nid_no_patch);
int APS5_VABI sceAbstractYoutubeUnknown_vJGnqFj6ygE_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage13YoutubeFolder5CloseEv() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("vJGnqFj6ygE", sceAbstractYoutubeUnknown_vJGnqFj6ygE_nid_no_patch);
}
@@ -258,104 +241,84 @@ int APS5_VABI _ZNK15AbstractStorage14YoutubeStorage7GetStatEPNS_4StatE() {
extern "C" {
int APS5_VABI abstractYoutubeLegacyUnknown__plus_XiOtdILEHI_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeContent12readExternalESt10shared_ptrINS_7ContentEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("+XiOtdILEHI", abstractYoutubeLegacyUnknown__plus_XiOtdILEHI_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_4orcGYZG2cE_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage9SerializeESt10shared_ptrINS_7ContentEES1_INS_4ItemEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("4orcGYZG2cE", abstractYoutubeLegacyUnknown_4orcGYZG2cE_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_6svBaAI4Ggw_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage15RemoveRecursiveERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("6svBaAI4Ggw", abstractYoutubeLegacyUnknown_6svBaAI4Ggw_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_CCv9CYanMNI_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage15CreateRecursiveERKSbIcSt11char_traitsIcENS_8StlAllocIcEEENS_8ItemTypeEPSt10shared_ptrINS_4ItemEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("CCv9CYanMNI", abstractYoutubeLegacyUnknown_CCv9CYanMNI_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_EEx55k0zSLo_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage13YoutubeFolder9NewFolderERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEPSt10shared_ptrINS_6FolderEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("EEx55k0zSLo", abstractYoutubeLegacyUnknown_EEx55k0zSLo_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_HYDApQYDgcI_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage7IsExistERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("HYDApQYDgcI", abstractYoutubeLegacyUnknown_HYDApQYDgcI_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_IGnFlGNW_plus_Vo_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeStorageC2ERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("IGnFlGNW+Vo", abstractYoutubeLegacyUnknown_IGnFlGNW_plus_Vo_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_JzBDUIC5xok_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage13YoutubeFolderC1ERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEb() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("JzBDUIC5xok", abstractYoutubeLegacyUnknown_JzBDUIC5xok_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_NPYN89qO2Ks_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage7GetItemERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEPSt10shared_ptrINS_4ItemEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("NPYN89qO2Ks", abstractYoutubeLegacyUnknown_NPYN89qO2Ks_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_P_plus_ZjKSLi5lg_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage13YoutubeFolderC2ERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEb() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("P+ZjKSLi5lg", abstractYoutubeLegacyUnknown_P_plus_ZjKSLi5lg_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_RkaqMMDQJp4_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeService23create_storage_instanceERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("RkaqMMDQJp4", abstractYoutubeLegacyUnknown_RkaqMMDQJp4_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_ZpVRh3D86UY_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeStorageC1ERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("ZpVRh3D86UY", abstractYoutubeLegacyUnknown_ZpVRh3D86UY_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_ZwkYXHwQ7Mc_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeContent13writeExternalESt10shared_ptrINS_7ContentEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("ZwkYXHwQ7Mc", abstractYoutubeLegacyUnknown_ZwkYXHwQ7Mc_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_cktbTmca48I_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage10GetContentERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEPSt10shared_ptrINS_7ContentEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("cktbTmca48I", abstractYoutubeLegacyUnknown_cktbTmca48I_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_fUXj4GBxyHs_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage13GetRootFolderEPSt10shared_ptrINS_6FolderEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("fUXj4GBxyHs", abstractYoutubeLegacyUnknown_fUXj4GBxyHs_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_g58APdyJ_minus_5Y_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage9GetForderERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEPSt10shared_ptrINS_6FolderEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("g58APdyJ-5Y", abstractYoutubeLegacyUnknown_g58APdyJ_minus_5Y_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_hXCJIJZZ5MY_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeContent6RenameERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("hXCJIJZZ5MY", abstractYoutubeLegacyUnknown_hXCJIJZZ5MY_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_kgeuOe7oln8_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage11DeserializeESt10shared_ptrINS_7ContentEEPS1_INS_4ItemEE() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("kgeuOe7oln8", abstractYoutubeLegacyUnknown_kgeuOe7oln8_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_pR9ULw2VrSs_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeContentC2ERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEb() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("pR9ULw2VrSs", abstractYoutubeLegacyUnknown_pR9ULw2VrSs_nid_no_patch);
int APS5_VABI abstractYoutubeLegacyUnknown_tjbj7QysZwk_nid_no_patch() {
int APS5_VABI _ZN15AbstractStorage14YoutubeContentC1ERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEb() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("tjbj7QysZwk", abstractYoutubeLegacyUnknown_tjbj7QysZwk_nid_no_patch);
}
@@ -43,5 +43,22 @@ int APS5_VABI _ZNK15AbstractStorage14YoutubeService14GetServiceTypeEv();
int APS5_VABI _ZNK15AbstractStorage14YoutubeStorage10GetServiceEv();
int APS5_VABI _ZNK15AbstractStorage14YoutubeStorage13GetCapabilityEv();
int APS5_VABI _ZNK15AbstractStorage14YoutubeStorage7GetStatEPNS_4StatE();
int APS5_VABI _ZN15AbstractStorage10YoutubeAPI11SendContentEPKvl();
int APS5_VABI _ZN15AbstractStorage10YoutubeAPI14SetAccessTokenERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE();
int APS5_VABI _ZN15AbstractStorage10YoutubeAPI17GetUploadLocationERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEmS7_RS5_();
int APS5_VABI _ZN15AbstractStorage10YoutubeAPI5StartERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE();
int APS5_VABI _ZN15AbstractStorage10YoutubeAPI6ResumeERSbIcSt11char_traitsIcENS_8StlAllocIcEEERlm();
int APS5_VABI _ZN15AbstractStorage10YoutubeAPI7SuspendEv();
int APS5_VABI _ZN15AbstractStorage10YoutubeAPI8initHttpEv();
int APS5_VABI _ZN15AbstractStorage10YoutubeAPI8termHttpEv();
int APS5_VABI _ZN15AbstractStorage10YoutubeAPIC1Ev();
int APS5_VABI _ZN15AbstractStorage10YoutubeAPIC2Ev();
int APS5_VABI _ZN15AbstractStorage10YoutubeAPID1Ev();
int APS5_VABI _ZN15AbstractStorage10YoutubeAPID2Ev();
int APS5_VABI _ZN15AbstractStorage13YoutubeFolder10NewContentERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEPSt10shared_ptrINS_7ContentEE();
int APS5_VABI _ZN15AbstractStorage13YoutubeFolder12RemoveFolderERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEb();
int APS5_VABI _ZN15AbstractStorage13YoutubeFolder13RemoveContentERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE();
int APS5_VABI _ZN15AbstractStorage13YoutubeFolder4OpenENS_8ItemTypeE();
int APS5_VABI _ZN15AbstractStorage13YoutubeFolder5CloseEv();
}
@@ -4,25 +4,25 @@
extern "C" {
int APS5_VABI abstractYoutubeLegacyUnknown__plus_XiOtdILEHI_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_4orcGYZG2cE_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_6svBaAI4Ggw_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_CCv9CYanMNI_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_EEx55k0zSLo_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_HYDApQYDgcI_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_IGnFlGNW_plus_Vo_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_JzBDUIC5xok_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_NPYN89qO2Ks_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_P_plus_ZjKSLi5lg_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_RkaqMMDQJp4_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_ZpVRh3D86UY_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_ZwkYXHwQ7Mc_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_cktbTmca48I_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_fUXj4GBxyHs_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_g58APdyJ_minus_5Y_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_hXCJIJZZ5MY_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_kgeuOe7oln8_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_pR9ULw2VrSs_nid_no_patch();
int APS5_VABI abstractYoutubeLegacyUnknown_tjbj7QysZwk_nid_no_patch();
int APS5_VABI _ZN15AbstractStorage14YoutubeContent12readExternalESt10shared_ptrINS_7ContentEE();
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage9SerializeESt10shared_ptrINS_7ContentEES1_INS_4ItemEE();
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage15RemoveRecursiveERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE();
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage15CreateRecursiveERKSbIcSt11char_traitsIcENS_8StlAllocIcEEENS_8ItemTypeEPSt10shared_ptrINS_4ItemEE();
int APS5_VABI _ZN15AbstractStorage13YoutubeFolder9NewFolderERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEPSt10shared_ptrINS_6FolderEE();
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage7IsExistERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE();
int APS5_VABI _ZN15AbstractStorage14YoutubeStorageC2ERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE();
int APS5_VABI _ZN15AbstractStorage13YoutubeFolderC1ERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEb();
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage7GetItemERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEPSt10shared_ptrINS_4ItemEE();
int APS5_VABI _ZN15AbstractStorage13YoutubeFolderC2ERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEb();
int APS5_VABI _ZN15AbstractStorage14YoutubeService23create_storage_instanceERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE();
int APS5_VABI _ZN15AbstractStorage14YoutubeStorageC1ERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE();
int APS5_VABI _ZN15AbstractStorage14YoutubeContent13writeExternalESt10shared_ptrINS_7ContentEE();
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage10GetContentERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEPSt10shared_ptrINS_7ContentEE();
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage13GetRootFolderEPSt10shared_ptrINS_6FolderEE();
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage9GetForderERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEPSt10shared_ptrINS_6FolderEE();
int APS5_VABI _ZN15AbstractStorage14YoutubeContent6RenameERKSbIcSt11char_traitsIcENS_8StlAllocIcEEE();
int APS5_VABI _ZN15AbstractStorage14YoutubeStorage11DeserializeESt10shared_ptrINS_7ContentEEPS1_INS_4ItemEE();
int APS5_VABI _ZN15AbstractStorage14YoutubeContentC2ERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEb();
int APS5_VABI _ZN15AbstractStorage14YoutubeContentC1ERKSbIcSt11char_traitsIcENS_8StlAllocIcEEEb();
}
+31 -5
View File
@@ -1,6 +1,7 @@
#include "prx/libc/include/general/ExportMacros.hpp"
#include "prx/libSceAcm/include/InventoryExports.hpp"
#include "prx/libSceAcm/include/Api.hpp"
#include <cerrno>
#include <cstdint>
#include <cstddef>
#include <cstring>
@@ -225,8 +226,17 @@ int APS5_VABI sceAcmBatchStartBuffer(AcmContextId context, const void* batch_com
if (!g_contexts.contains(context)) return SCE_ACM_ERROR_BAD_CONTEXT;
AcmBatchId id = g_nextId.fetch_add(1, std::memory_order_relaxed);
while (id == 0) id = g_nextId.fetch_add(1, std::memory_order_relaxed);
if (batch_error) std::memset(batch_error, 0, sizeof(*batch_error));
*batch = id;
if (batch_error) {
AcmBatchError err{};
const int savedErrno = errno;
const bool copied = GuestCopyOut_nid_no_patch(batch_error, &err, sizeof(err));
errno = savedErrno;
if (!copied) return SCE_ACM_ERROR_BAD_POINTER;
}
const int savedErrno = errno;
const bool copied = GuestCopyOut_nid_no_patch(batch, &id, sizeof(id));
errno = savedErrno;
if (!copied) return SCE_ACM_ERROR_BAD_POINTER;
return 0;
}
@@ -239,8 +249,17 @@ int APS5_VABI sceAcmBatchStartBuffers(AcmContextId context, uint32_t batch_info_
if (!g_contexts.contains(context)) return SCE_ACM_ERROR_BAD_CONTEXT;
AcmBatchId id = g_nextId.fetch_add(1, std::memory_order_relaxed);
while (id == 0) id = g_nextId.fetch_add(1, std::memory_order_relaxed);
if (batch_error) std::memset(batch_error, 0, sizeof(*batch_error));
*batch = id;
if (batch_error) {
AcmBatchError err{};
const int savedErrno = errno;
const bool copied = GuestCopyOut_nid_no_patch(batch_error, &err, sizeof(err));
errno = savedErrno;
if (!copied) return SCE_ACM_ERROR_BAD_POINTER;
}
const int savedErrno = errno;
const bool copied = GuestCopyOut_nid_no_patch(batch, &id, sizeof(id));
errno = savedErrno;
if (!copied) return SCE_ACM_ERROR_BAD_POINTER;
return 0;
}
@@ -261,7 +280,14 @@ int APS5_VABI sceAcmContextCreate(AcmContextId* context) {
std::lock_guard<std::mutex> lock(g_mutex);
g_contexts.insert(id);
}
*context = id;
const int savedErrno = errno;
const bool copied = GuestCopyOut_nid_no_patch(context, &id, sizeof(id));
errno = savedErrno;
if (!copied) {
std::lock_guard<std::mutex> lock(g_mutex);
g_contexts.erase(id);
return SCE_ACM_ERROR_BAD_POINTER;
}
return 0;
}
@@ -7,6 +7,7 @@
extern "C" {
std::uint32_t* APS5_VABI sceAgcAcbAtomicGds_0900(CommandBuffer* buf, std::uint32_t control, std::uint32_t mode, std::uint32_t gdsOp, std::uint32_t src, std::uint16_t offset, std::uint16_t index, std::uint32_t mask, std::uint32_t data, std::uint64_t compareData, std::uint64_t extraData);
std::uint32_t* APS5_VABI sceAgcAcbAtomicGds(CommandBuffer* buf, std::uint32_t control, std::uint32_t mode, std::uint32_t gdsOp, std::uint32_t src, std::uint16_t offset, std::uint16_t index, std::uint32_t mask, std::uint32_t data, std::uint64_t compareData, std::uint64_t extraData);
std::uint32_t* APS5_VABI sceAgcAcbJump(CommandBuffer* buf, std::uint8_t cachePolicy, const std::uint32_t* target, std::uint32_t sizeInDwords);
uint32_t APS5_VABI sceAgcAcbJumpGetSize(void);
uint32_t* APS5_VABI sceAgcAcbResetQueue(CommandBuffer* buf, uint32_t op, uint32_t value);
@@ -154,4 +154,8 @@ uint32_t* APS5_VABI sceAgcAcbSetMarker(CommandBuffer* buf, const char* str, uint
return packet;
}
std::uint32_t* APS5_VABI sceAgcAcbAtomicGds(CommandBuffer* buf, std::uint32_t control, std::uint32_t mode, std::uint32_t gdsOp, std::uint32_t src, std::uint16_t offset, std::uint16_t index, std::uint32_t mask, std::uint32_t data, std::uint64_t compareData, std::uint64_t extraData) {
return sceAgcAcbAtomicGds_0900(buf, control & ~0x80u, mode, gdsOp, src, offset, index, mask, data, compareData, extraData);
}
}
@@ -5,8 +5,8 @@
#include <cstdint>
extern "C" {
std::uint32_t* APS5_VABI sceAgcDcbAtomicGds(CommandBuffer* buf, std::uint32_t control, std::uint32_t mode, std::uint32_t gdsOp, std::uint32_t src, std::uint16_t offset, std::uint16_t index, std::uint32_t mask, std::uint32_t data, std::uint64_t compareData, std::uint64_t extraData);
std::uint32_t* APS5_VABI sceAgcDcbAtomicGds_0900(CommandBuffer* buf, std::uint32_t control, std::uint32_t mode, std::uint32_t gdsOp, std::uint32_t src, std::uint16_t offset, std::uint16_t index, std::uint32_t mask, std::uint32_t data, std::uint64_t compareData, std::uint64_t extraData);
std::uint32_t* APS5_VABI sceAgcDcbAtomicGds(CommandBuffer* buf, std::uint32_t engine, std::uint32_t control, std::uint32_t mode, std::uint32_t gdsOp, std::uint32_t src, std::uint16_t offset, std::uint16_t index, std::uint32_t mask, std::uint32_t data, std::uint64_t compareData, std::uint64_t extraData);
std::uint32_t* APS5_VABI sceAgcDcbAtomicGds_0900(CommandBuffer* buf, std::uint32_t engine, std::uint32_t control, std::uint32_t mode, std::uint32_t gdsOp, std::uint32_t src, std::uint16_t offset, std::uint16_t index, std::uint32_t mask, std::uint32_t data, std::uint64_t compareData, std::uint64_t extraData);
}
#include "SceShaders.hpp"
@@ -12,10 +12,10 @@
extern "C" {
std::uint32_t* APS5_VABI sceAgcDcbAtomicGds_0900(CommandBuffer* buf, std::uint32_t control, std::uint32_t mode, std::uint32_t gdsOp, std::uint32_t src, std::uint16_t offset, std::uint16_t index, std::uint32_t mask, std::uint32_t data, std::uint64_t compareData, std::uint64_t extraData) {
std::uint32_t* APS5_VABI sceAgcDcbAtomicGds_0900(CommandBuffer* buf, std::uint32_t engine, std::uint32_t control, std::uint32_t mode, std::uint32_t gdsOp, std::uint32_t src, std::uint16_t offset, std::uint16_t index, std::uint32_t mask, std::uint32_t data, std::uint64_t compareData, std::uint64_t extraData) {
const auto operation = (control & 0xffu) | ((control & 0x200u) << 7u) |
((control & 0x20u) << 13u) | ((control & 0x40u) << 14u) |
((control & 0x20u) == 0 && mode == 1 ? 0x20000u : 0u);
((control & 0x20u) == 0 && mode == 1 ? 0x20000u : 0u) | ((engine & 3u) << 30u);
return Agc::Command::Emit(buf, 0x1du, {
operation, ((gdsOp & 1u) << 8u) | (src & 0x3fu), offset, index,
mask & 0x00ff00ffu, data, static_cast<std::uint32_t>(compareData),
@@ -23,8 +23,8 @@ std::uint32_t* APS5_VABI sceAgcDcbAtomicGds_0900(CommandBuffer* buf, std::uint32
static_cast<std::uint32_t>(extraData >> 32u)}, __func__);
}
std::uint32_t* APS5_VABI sceAgcDcbAtomicGds(CommandBuffer* buf, std::uint32_t control, std::uint32_t mode, std::uint32_t gdsOp, std::uint32_t src, std::uint16_t offset, std::uint16_t index, std::uint32_t mask, std::uint32_t data, std::uint64_t compareData, std::uint64_t extraData) {
return sceAgcDcbAtomicGds_0900(buf, control, mode, gdsOp, src, offset, index, mask, data, compareData, extraData);
std::uint32_t* APS5_VABI sceAgcDcbAtomicGds(CommandBuffer* buf, std::uint32_t engine, std::uint32_t control, std::uint32_t mode, std::uint32_t gdsOp, std::uint32_t src, std::uint16_t offset, std::uint16_t index, std::uint32_t mask, std::uint32_t data, std::uint64_t compareData, std::uint64_t extraData) {
return sceAgcDcbAtomicGds_0900(buf, engine, control & ~0x80u, mode, gdsOp, src, offset, index, mask, data, compareData, extraData);
}
@@ -12,6 +12,7 @@ struct SizeAlign {
extern "C" int APS5_VABI sceAgcFuseShaderHalves_0200(Shader* fusedResult, const Shader* front, const Shader* back, void* scratchMem);
extern "C" int APS5_VABI sceAgcGetFusedShaderSize_0080(SizeAlign* dst, const Shader* front, const Shader* back);
extern "C" int APS5_VABI sceAgcGetFusedShaderSize(SizeAlign* dst, const Shader* front, const Shader* back);
#include "SceShaders.hpp"
@@ -412,4 +412,14 @@ int APS5_VABI sceAgcGetFusedShaderSize_0080(SizeAlign* dst, const Shader* front,
return 0;
}
int APS5_VABI sceAgcGetFusedShaderSize(SizeAlign* dst, const Shader* front, const Shader* back) {
if (front == nullptr || back == nullptr) APS5_INVALID_ARG_EX;
if (!ValidHalves(front, back)) return GRAPHICS5_ERROR_INVALID_SHADER_HALVES;
if (dst == nullptr) APS5_INVALID_ARG_EX;
dst->m_size = std::uint64_t{back->num_sh_registers} * sizeof(ShaderRegister);
const std::uint32_t align = 4;
std::memcpy(&dst->m_align, &align, sizeof(align));
return 0;
}
}
@@ -19,4 +19,18 @@ int main() {
std::fprintf(stderr, "ACB atomic GDS builder wrote a different size than its size accessor\n");
return 1;
}
std::array<std::uint32_t, 16> unversionedWords{};
CommandBuffer unversionedBuffer{unversionedWords.data(), unversionedWords.data() + unversionedWords.size(), unversionedWords.data(), unversionedWords.data() + unversionedWords.size(), nullptr, nullptr, 0};
const auto* versioned = sceAgcAcbAtomicGds_0900(&buffer, 0x2e1u, 1, 1, 7, 0x100, 0x200, 0x00ff00ffu, 0x12345678u, 0x1122334455667788ull, 0x99aabbccddeeff00ull);
const auto* unversioned = sceAgcAcbAtomicGds(&unversionedBuffer, 0x2e1u, 1, 1, 7, 0x100, 0x200, 0x00ff00ffu, 0x12345678u, 0x1122334455667788ull, 0x99aabbccddeeff00ull);
if (unversioned != unversionedWords.data() || unversionedBuffer.cursor_up != unversionedWords.data() + 11 || versioned[1] != 0x001500e1u || unversioned[1] != 0x00150061u) {
std::fprintf(stderr, "unversioned ACB atomic GDS must clear operation bit 7\n");
return 1;
}
for (int i = 2; i < 11; ++i) {
if (versioned[i] != unversioned[i]) {
std::fprintf(stderr, "versioned and unversioned ACB atomic GDS emitted different payloads\n");
return 1;
}
}
}
@@ -35,17 +35,19 @@ void testAtomicGds() {
std::array<std::uint32_t, 32> words{};
CommandBuffer buffer{words.data(), words.data() + words.size(), words.data(), words.data() + words.size(), nullptr, nullptr, 0};
const auto* packet = sceAgcDcbAtomicGds_0900(&buffer, 0x261u, 1, 3, 7, 0x100, 0x200, 0x00ff00ffu, 0x12345678u, 0x1122334455667788ull, 0x99aabbccddeeff00ull);
const auto* packet = sceAgcDcbAtomicGds_0900(&buffer, 2, 0x2e1u, 1, 3, 7, 0x100, 0x200, 0x00ff00ffu, 0x12345678u, 0x1122334455667788ull, 0x99aabbccddeeff00ull);
check(packet != nullptr && packet == words.data(), "DCB atomic GDS returned unexpected packet pointer");
check(buffer.cursor_up == words.data() + 11, "DCB atomic GDS cursor advance does not match 11 dwords");
check(packet[0] == 0xc0091d00u, "DCB atomic GDS header opcode mismatch");
std::array<std::uint32_t, 32> unversionedWords{};
CommandBuffer unversionedBuffer{unversionedWords.data(), unversionedWords.data() + unversionedWords.size(), unversionedWords.data(), unversionedWords.data() + unversionedWords.size(), nullptr, nullptr, 0};
const auto* unversionedPacket = sceAgcDcbAtomicGds(&unversionedBuffer, 0x261u, 1, 3, 7, 0x100, 0x200, 0x00ff00ffu, 0x12345678u, 0x1122334455667788ull, 0x99aabbccddeeff00ull);
const auto* unversionedPacket = sceAgcDcbAtomicGds(&unversionedBuffer, 2, 0x2e1u, 1, 3, 7, 0x100, 0x200, 0x00ff00ffu, 0x12345678u, 0x1122334455667788ull, 0x99aabbccddeeff00ull);
check(unversionedPacket != nullptr && unversionedPacket == unversionedWords.data(), "unversioned DCB atomic GDS returned unexpected packet pointer");
check(unversionedBuffer.cursor_up == unversionedWords.data() + 11, "unversioned DCB atomic GDS cursor advance does not match 11 dwords");
check(std::equal(words.begin(), words.begin() + 11, unversionedWords.begin()), "versioned and unversioned DCB atomic GDS emitted different packets");
check(packet[1] == 0x801500e1u, "DCB atomic GDS operation dword mismatch");
check(unversionedPacket[1] == 0x80150061u, "unversioned DCB atomic GDS kept operation bit 7");
check(std::equal(words.begin() + 2, words.begin() + 11, unversionedWords.begin() + 2), "versioned and unversioned DCB atomic GDS emitted different payloads");
}
}
@@ -134,6 +134,9 @@ void testFusion(std::size_t misalignment, std::uint32_t terminator = SSetpcS6) {
SizeAlign size{};
check(sceAgcGetFusedShaderSize_0080(&size, &halves.front, &halves.back) == 0, "fused size query failed");
check(size.m_size == 6 * sizeof(ShaderRegister) && size.m_align == 4, "fused size is not the back half's register list");
SizeAlign unversioned{~0ull, ~std::size_t{0}};
check(sceAgcGetFusedShaderSize(&unversioned, &halves.front, &halves.back) == 0, "unversioned fused size query failed");
check(unversioned.m_size == size.m_size && unversioned.m_align == (~std::size_t{0} << 32u | 4u), "unversioned fused size must store a 32-bit alignment");
std::vector<std::uint8_t> storage(size.m_size + 512, 0xcd);
auto* scratch = aligned(storage, 256) + misalignment;
Shader fused{};
@@ -263,10 +266,12 @@ void testRejections() {
SizeAlign size{};
Shader fused{};
expectFailure([&] { sceAgcGetFusedShaderSize_0080(nullptr, &halves.front, &halves.back); });
expectFailure([&] { sceAgcGetFusedShaderSize(nullptr, &halves.front, &halves.back); });
expectFailure([&] { sceAgcFuseShaderHalves_0200(&fused, &halves.front, &halves.back, nullptr); });
{
Halves swapped;
check(sceAgcGetFusedShaderSize_0080(&size, &swapped.back, &swapped.front) == InvalidShaderHalves, "swapped halves were accepted by the size query");
check(sceAgcGetFusedShaderSize(nullptr, &swapped.back, &swapped.front) == InvalidShaderHalves, "the unversioned size query checked its output before the halves");
check(sceAgcFuseShaderHalves_0200(&fused, &swapped.back, &swapped.front, nullptr) == InvalidShaderHalves, "swapped halves were fused");
}
{
@@ -381,6 +386,21 @@ void testHullHalves() {
check(backSh[4].value == 0u, "hull fusion wrote the back half's registers");
}
void testUnversionedSize() {
Halves halves;
SizeAlign size{};
check(sceAgcGetFusedShaderSize(&size, &halves.front, &halves.back) == 0, "unversioned fused size query failed");
check(size.m_size == halves.back.num_sh_registers * sizeof(ShaderRegister) && size.m_align == 4, "unversioned fused size did not cover the back half's register list");
SizeAlign merged{};
check(sceAgcGetFusedShaderSize_0080(&merged, &halves.front, &halves.back) == 0 && merged.m_size == size.m_size, "unversioned size differed from the _0080 merged geometry size");
check(sceAgcGetFusedShaderSize(&size, &halves.back, &halves.front) == InvalidShaderHalves, "unversioned query accepted swapped halves");
expectFailure([&] { sceAgcGetFusedShaderSize(nullptr, &halves.front, &halves.back); });
halves.front.type = static_cast<std::uint8_t>(ShaderRegs::ShaderBinaryType::HsFront);
check(sceAgcGetFusedShaderSize(&size, &halves.front, &halves.back) == InvalidShaderHalves, "unversioned query accepted mismatched stage halves");
halves.back.type = static_cast<std::uint8_t>(ShaderRegs::ShaderBinaryType::HsBack);
check(sceAgcGetFusedShaderSize(&size, &halves.front, &halves.back) == 0 && size.m_size == halves.back.num_sh_registers * sizeof(ShaderRegister), "unversioned query rejected hull halves");
}
}
int main() {
@@ -397,6 +417,7 @@ int main() {
testRejections();
testFrontConstantBuffer();
testHullHalves();
testUnversionedSize();
LibcRunShutdown_nid_postfix();
std::puts("AGC shader fusion tests passed");
return 0;
@@ -563,6 +563,12 @@ configure_windows_unwind(libSceAgcDriver)
if(WIN32)
target_link_options(libSceAgcDriver PRIVATE LINKER:--exclude-symbols=_Znwy:_Znay:_ZnwyRKSt9nothrow_t:_ZnayRKSt9nothrow_t:_ZdlPv:_ZdaPv:_ZdlPvy:_ZdaPvy:_ZdlPvRKSt9nothrow_t:_ZdaPvRKSt9nothrow_t)
endif()
if(MINGW AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(agcStdExportScript "${CMAKE_CURRENT_BINARY_DIR}/libSceAgcDriverStdExports.ver")
file(CONFIGURE OUTPUT "${agcStdExportScript}" CONTENT "{\n local:\n _ZSt*;\n _ZNSt*;\n _ZNKSt*;\n _ZNRSt*;\n _ZNKRSt*;\n _ZNOSt*;\n _ZNKOSt*;\n _ZNSa*;\n _ZNKSa*;\n};\n")
target_link_options(libSceAgcDriver PRIVATE "LINKER:--version-script=${agcStdExportScript}")
set_property(TARGET libSceAgcDriver APPEND PROPERTY LINK_DEPENDS "${agcStdExportScript}")
endif()
if(WIN32)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/Execution/src/GuestMemory.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Execution/src/Driver/Lifecycle.cpp PROPERTIES COMPILE_DEFINITIONS _WIN32_WINNT=0x0602)
@@ -33,6 +33,7 @@ void Driver::lookupDraw(const Submission& submission, const std::shared_ptr<Vulk
mix(tess.mergedHull);
}
mix(graphics.rectList);
mix(graphics.rasterizerDiscard);
mix(programs.size());
for (std::size_t i = 0; i < programs.size(); ++i) {
const auto& program = programs[i];
@@ -87,6 +88,11 @@ void Driver::lookupDraw(const Submission& submission, const std::shared_ptr<Vulk
mix(merge.target);
mix(merge.mask);
mix(merge.samples);
mix(static_cast<std::uint64_t>(merge.packing));
mix(merge.blendControl);
mix(merge.layered);
mix(merge.firstSlice);
mix(merge.lastSlice);
for (const auto word : merge.descriptor) mix(word);
mix(merge.depthStencilWrites);
mix(merge.depthStencilTests);
@@ -229,7 +229,7 @@ bool Driver::sameDecode(const DrawDecode& a, const DrawDecode& b) {
const auto& s = a.state;
const auto& t = b.state;
const auto sameColor = [](const Graphics::ColorTarget& x, const Graphics::ColorTarget& y) {
return x.address == y.address && x.extent.width == y.extent.width && x.extent.height == y.extent.height && x.format == y.format && x.bytes == y.bytes && x.componentMapping == y.componentMapping && x.tileMode == y.tileMode && x.elementBytes == y.elementBytes && x.dccAddress == y.dccAddress && x.dccAlphaOnMsb == y.dccAlphaOnMsb && x.slot == y.slot && x.exportIndex == y.exportIndex && x.partialWriteMask == y.partialWriteMask && x.staged == y.staged && x.stagedMask == y.stagedMask && x.stagedFormat == y.stagedFormat;
return x.address == y.address && x.extent.width == y.extent.width && x.extent.height == y.extent.height && x.format == y.format && x.bytes == y.bytes && x.componentMapping == y.componentMapping && x.tileMode == y.tileMode && x.elementBytes == y.elementBytes && x.dccAddress == y.dccAddress && x.dccAlphaOnMsb == y.dccAlphaOnMsb && x.slot == y.slot && x.exportIndex == y.exportIndex && x.partialWriteMask == y.partialWriteMask && x.staged == y.staged && x.stagedMask == y.stagedMask && x.stagedFormat == y.stagedFormat && x.mergeBlend == y.mergeBlend;
};
const auto sameBlend = [](const VkPipelineColorBlendAttachmentState& x, const VkPipelineColorBlendAttachmentState& y) {
return x.blendEnable == y.blendEnable && x.srcColorBlendFactor == y.srcColorBlendFactor && x.dstColorBlendFactor == y.dstColorBlendFactor && x.colorBlendOp == y.colorBlendOp && x.srcAlphaBlendFactor == y.srcAlphaBlendFactor && x.dstAlphaBlendFactor == y.dstAlphaBlendFactor && x.alphaBlendOp == y.alphaBlendOp && x.colorWriteMask == y.colorWriteMask;
@@ -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.lineWidth != t.lineWidth || 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.rasterizerDiscard != t.rasterizerDiscard || 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;
@@ -1018,10 +1018,17 @@ std::vector<ShaderRecompiler::TableCallee> ReadTableCallees(const ShaderRecompil
constexpr std::uint64_t limitBytes = 64u << 20u;
constexpr std::size_t limitCallees = 64u;
const auto slot = call.userDataRegister - request.context.userDataBaseRegister;
const auto pointer = call.constantPointer ? *call.constantPointer : static_cast<std::uint64_t>(request.context.userData[slot]) | static_cast<std::uint64_t>(request.context.userData[slot + 1u]) << 32u;
const auto words = ReadGuestBytes(pointer + call.descriptorOffset, 16u, "call table descriptor");
ShaderRecompiler::ShaderBufferResource descriptor{};
std::memcpy(descriptor.fields.data(), words.data(), words.size());
if (call.descriptorInUserData) {
if (slot + 4u > request.context.userData.size()) throw std::runtime_error("its call table descriptor is outside the user data");
std::uint32_t words[4]{};
for (std::size_t index = 0u; index < 4u; ++index) words[index] = request.context.userData[slot + index];
std::memcpy(descriptor.fields.data(), words, sizeof(words));
} else {
const auto pointer = call.constantPointer ? *call.constantPointer : static_cast<std::uint64_t>(request.context.userData[slot]) | static_cast<std::uint64_t>(request.context.userData[slot + 1u]) << 32u;
const auto words = ReadGuestBytes(pointer + call.descriptorOffset, 16u, "call table descriptor");
std::memcpy(descriptor.fields.data(), words.data(), words.size());
}
const auto bytes = descriptor.GetSize();
if (bytes > limitBytes) throw std::runtime_error("its call table of " + std::to_string(bytes) + " bytes is larger than the " + std::to_string(limitBytes) + " bytes that are searched for callees");
const auto table = bytes == 0u ? std::vector<std::uint8_t>{} : ReadGuestBytes(descriptor.Base48(), bytes, "call table");
@@ -46,6 +46,7 @@ void AppendHostWrittenDepthRanges(std::uint64_t address, std::size_t bytes, std:
enum class DepthPublicationStage { ReadCaptured, GuestCopied, BeforeCommit, PlaneCommitted };
void SetDepthPublicationHookForTest(void (*hook)(DepthPublicationStage));
bool HasResidentDepthGuards_nid_no_patch();
bool ResidentDepthGuardOverlaps_nid_no_patch(std::uint64_t address, std::size_t bytes);
void RetireUnmappedDepth_nid_no_patch(std::uintptr_t address, std::size_t bytes);
void RequireNoNativeDepthFeedback_nid_no_patch(const Context& context, const DepthTarget& target, std::span<const std::shared_ptr<Texture>> sampled);
void ClearDepthSurfaces(VkDevice device);
@@ -102,6 +102,7 @@ std::shared_ptr<Texture> MultisampleTargetTexture(const Context& context, const
std::shared_ptr<Texture> MultisampleTargetFirstSample(const Context& context, const GuestTextureResource& resource, VkComponentMapping components);
VkImageView MultisampleTargetView(const Context& context, const ColorTarget& target, VkImage* image = nullptr);
VkImageView MultisampleTargetView(const Context& context, const ColorTarget& target, std::shared_ptr<void>& owner, VkImage* image = nullptr);
void PrepareMultisampleTargetForDraw_nid_no_patch(const Context& context, const ColorTarget& target);
void KeepMultisampleTarget_nid_no_patch(const std::shared_ptr<void>& owner);
void MaterializeMultisampleTargetClear(const Context& context, const ColorTarget& target);
VkImageView MultisampleTargetStorageView(const Context& context, const GuestTextureResource& resource, bool uintStorage = false);
@@ -87,7 +87,8 @@ struct ColorTarget {
std::uint32_t dccControl = 0;
std::uint64_t fmaskAddress = 0;
std::uint32_t fmaskPipeBankXor = 0;
std::uint16_t partialWriteMask = 0;
std::uint32_t partialWriteMask = 0;
std::uint32_t mergeBlend = 0;
bool staged = false;
std::uint16_t stagedMask = 0;
VkFormat stagedFormat = VK_FORMAT_UNDEFINED;
@@ -228,7 +229,9 @@ bool SampleMaskFollowsOrder(const State& state, const SampleOrder& order);
std::array<std::uint16_t, 4> QuadSampleMasks(const State& state, const SampleOrder& order);
std::array<std::uint8_t, 8> ExportMappings(const State& state);
std::array<ShaderRecompiler::ColorExportPacking, 8> ExportPackings(const State& state);
std::uint16_t PackedWriteMask(std::uint8_t componentMapping, std::uint32_t exportedMask);
std::uint32_t PackedWriteMask(std::uint8_t componentMapping, std::uint32_t exportedMask);
std::uint32_t PackedWriteMask(ShaderRecompiler::ColorExportPacking packing, std::uint8_t componentMapping, std::uint32_t exportedMask);
std::uint32_t PackedBlendControl(std::uint32_t blendControl);
GuestTextureResource TargetMergeSurface(const ColorTarget& color);
ColorTarget StagedMergeTarget(const ColorTarget& staged);
bool DepthStencilWrites(const State& state);
@@ -249,6 +252,7 @@ ReversedBlend TranslateReversedBlend(std::uint32_t blendControl, std::uint8_t co
std::size_t CmaskBytes(std::uint32_t width, std::uint32_t height);
std::uint32_t ColorWriteMask(const Registers& context);
GuestTextureResource SurfaceForTarget(const ColorTarget& color);
GuestTextureResource ArraySurfaceForTarget(const ColorTarget& color);
struct ColorMetadataPass {
enum class Mode { EliminateFastClear, DccDecompress, Resolve, FmaskDecompress };
@@ -1494,6 +1494,7 @@ public:
std::optional<std::uint32_t> clearPattern;
std::uint64_t clearFillNote = 0u;
std::uint64_t clearFillFloor = 0u;
std::uint64_t clearStoreStamp = 0u;
bool clearStored = false;
std::uint64_t stencilClearGeneration = 0u;
std::optional<std::uint8_t> stencilClearValue;
@@ -3018,6 +3019,15 @@ bool HasResidentDepthGuards_nid_no_patch() {
return anyDepthGuard().load(std::memory_order_acquire);
}
bool ResidentDepthGuardOverlaps_nid_no_patch(std::uint64_t address, std::size_t bytes) {
if (bytes == 0u || !anyDepthGuard().load(std::memory_order_acquire)) return false;
Require(address <= std::numeric_limits<std::uint64_t>::max() - bytes, "native depth overlap range overflows");
std::shared_lock lock(depthGuardMutex());
return std::ranges::any_of(depthGuards(), [&](const DepthGuard& range) {
return range.active->load(std::memory_order_acquire) && address < range.address + range.bytes && range.address < address + bytes;
});
}
void RetireUnmappedDepth_nid_no_patch(std::uintptr_t address, std::size_t bytes) {
if (bytes == 0u) return;
Require(address <= std::numeric_limits<std::uint64_t>::max() - bytes, "native depth release range overflows");
@@ -3809,13 +3819,20 @@ void NoteDepthMetadataFill(std::uint64_t address, std::size_t bytes, std::uint32
else {
const auto* recorder = RecorderFor(surface->context);
const auto refill = surface->clearGeneration != 0u && surface->clearPattern == pattern && surface->clearFillNote == 0u && recorder != nullptr ? fillNoteAfter(*recorder, metadata, surface->clearFillFloor, pattern) : 0u;
const auto sameStored = [&] {
if (surface->clearGeneration == 0u || surface->clearPattern != pattern) return false;
std::vector<std::uint32_t> words(metadata.bytes / sizeof(std::uint32_t));
std::memcpy(words.data(), reinterpret_cast<const void*>(metadata.address), metadata.bytes);
return std::all_of(words.begin(), words.end(), [&](std::uint32_t word) { return word == pattern; }) && GuestMemory::NewestStamp(metadata.address, metadata.bytes) > surface->clearStoreStamp;
};
if (surface->clearPending || (surface->clearGeneration != 0u && !surface->clearPattern.has_value())) surface->sampling.Refuse("native multisample depth metadata fill over a pending HTILE clear dispatch is not implemented");
else if (surface->clearGeneration != 0u && refill == 0u) surface->sampling.Refuse("overlapping native multisample depth clear transitions are not implemented");
else if (surface->clearGeneration != 0u && refill == 0u && !sameStored()) surface->sampling.Refuse("overlapping native multisample depth clear transitions are not implemented");
else if (refill != 0u) surface->clearFillNote = refill;
else {
surface->clearGeneration = GuestMemory::CollectWritesUncached(metadata.address, metadata.bytes);
surface->clearAspects = VK_IMAGE_ASPECT_DEPTH_BIT | (target.htileStencil ? VK_IMAGE_ASPECT_STENCIL_BIT : 0u);
surface->clearPattern = pattern;
surface->clearStoreStamp = GuestMemory::NewestStamp(metadata.address, metadata.bytes);
surface->clearFillNote = recorder != nullptr ? recorder->LastWriteNote(address, bytes) : 0u;
surface->clearFillFloor = recorder != nullptr ? recorder->NewestWriteNote(metadata.address, metadata.bytes) : 0u;
surface->clearStored = GuestMemory::StoredAllSince_nid_no_patch(metadata.address, metadata.bytes, metadata.generation);
@@ -409,21 +409,6 @@ std::uint64_t DrawRenderPassKey(const Context& context, const State& state, std:
namespace {
GuestTextureResource ArraySurfaceForTarget(const ColorTarget& color) {
Require(color.arrayLastSlice != 0, "the color target is not a view of a 2D array");
auto surface = SurfaceForTarget(color);
surface.baseAddress = color.arrayAddress;
surface.width = color.surfaceExtent.width;
surface.height = color.surfaceExtent.height;
surface.depthOrLastArray = color.arrayLastSlice;
surface.dimension = TextureDimension::k2DArray;
return surface;
}
}
namespace {
bool writesStencilTarget(const State& state) {
const auto keeps = [](const VkStencilOpState& face) {
return face.writeMask == 0u || (face.failOp == VK_STENCIL_OP_KEEP && face.passOp == VK_STENCIL_OP_KEEP && face.depthFailOp == VK_STENCIL_OP_KEEP);
@@ -3225,6 +3210,7 @@ bool prepareDraw(const Context& context, const State& state, const Pm4::DrawPara
if (color.staged) {
const auto packed = StagedMergeTarget(color);
binding.stagedTemporary = AcquireStagedTemporary(context, color.extent, color.samples);
PrepareMultisampleTargetForDraw_nid_no_patch(context, packed);
static_cast<void>(MultisampleTargetView(context, packed, binding.multisampleOwner, &binding.multisampleImage));
binding.stagedTarget = MultisampleTargetStorageView(context, TargetMergeSurface(packed));
Require(MultisampleTargetStorable(context, packed), "a partial write of a multisampled packed color target needs a multisample image of this form to allow storage");
@@ -3232,6 +3218,7 @@ bool prepareDraw(const Context& context, const State& state, const Pm4::DrawPara
timer.phase(PhaseReadTarget);
continue;
}
PrepareMultisampleTargetForDraw_nid_no_patch(context, color);
targetViews.push_back(MultisampleTargetView(context, color, binding.multisampleOwner, &binding.multisampleImage));
timer.phase(PhaseReadTarget);
continue;
@@ -2913,6 +2913,7 @@ struct RefreshBlock {
std::size_t length;
std::uint64_t generation = 0;
std::uint8_t fill = 0;
mutable bool unchanged = false;
};
constexpr std::uint8_t SparseCopy = 1;
@@ -2928,8 +2929,14 @@ bool compareBlock(const RefreshBlock& block) {
if (target != nullptr) std::memset(target, 0, block.length);
return true;
}
const auto index = static_cast<std::size_t>(block.address / 65536 - block.mirror->base / 65536);
if (target != nullptr && block.fill == 0 && block.generation != 0 && std::memcmp(target, guest, block.length) == 0) {
block.mirror->generations[index] = block.generation;
block.unchanged = true;
return false;
}
if (target != nullptr) std::memcpy(target, guest, block.length);
if (block.fill == 0) block.mirror->generations[static_cast<std::size_t>(block.address / 65536 - block.mirror->base / 65536)] = block.generation;
if (block.fill == 0) block.mirror->generations[index] = block.generation;
return target != nullptr;
}
if (block.fill != 0) {
@@ -2939,9 +2946,12 @@ bool compareBlock(const RefreshBlock& block) {
return true;
}
if (block.mirror->heap) {
std::memcpy(block.mirror->buffer->Bytes().data() + offset, guest, block.length);
block.mirror->generations[static_cast<std::size_t>(block.address / 65536 - block.mirror->base / 65536)] = block.generation;
return true;
const auto index = static_cast<std::size_t>(block.address / 65536 - block.mirror->base / 65536);
auto* target = block.mirror->buffer->Bytes().data() + offset;
const bool same = block.generation != 0 && std::memcmp(target, guest, block.length) == 0;
if (!same) std::memcpy(target, guest, block.length);
block.mirror->generations[index] = block.generation;
return !same;
}
if (std::memcmp(block.mirror->shadow.data() + offset, guest, block.length) == 0) return false;
std::memcpy(block.mirror->buffer->Bytes().data() + offset, guest, block.length);
@@ -3108,7 +3118,7 @@ void compareBlocks(std::span<const RefreshBlock> blocks) {
bindHeapBlocks(blocks);
const auto copied = RefreshPool::Get().Run(blocks);
for (const auto& block : blocks) {
if (block.mirror->resident != nullptr && block.mirror->resident->Block(block.address) != nullptr) block.mirror->resident->MarkChanged(block.address, block.address + block.length);
if (!block.unchanged && block.mirror->resident != nullptr && block.mirror->resident->Block(block.address) != nullptr) block.mirror->resident->MarkChanged(block.address, block.address + block.length);
}
auto& state = Mirrors();
state.blocksCompared += blocks.size();
@@ -375,8 +375,10 @@ GuestTextureResource DecodeTextureResource(std::span<const std::uint32_t> descri
std::array<std::uint32_t, 8> EncodeTextureResource(const GuestTextureResource& resource) {
const bool multisampled = resource.dimension == TextureDimension::k2DMsaa;
Require((resource.dimension == TextureDimension::k2D && resource.samples == 1u) || (multisampled && resource.samples >= 2u && resource.samples <= 16u && std::has_single_bit(resource.samples)), "only 2D and multisampled 2D surfaces have a texture descriptor encoding");
Require(resource.mipCount == 1u && resource.allocatedMipCount <= 1u && resource.baseLevel == 0u && resource.lastLevel == 0u && resource.depthOrLastArray == 0u && resource.baseArray == 0u && resource.dccAddress == 0u && resource.minLod == 0u && !resource.iterate256 && resource.bcSwizzle == 0u && resource.linearPitch == 0u, "only single-level, single-layer surfaces without metadata have a texture descriptor encoding");
const bool array = resource.dimension == TextureDimension::k2DArray;
Require(((resource.dimension == TextureDimension::k2D || array) && resource.samples == 1u) || (multisampled && resource.samples >= 2u && resource.samples <= 16u && std::has_single_bit(resource.samples)), "only 2D, 2D array and multisampled 2D surfaces have a texture descriptor encoding");
Require(resource.mipCount >= 1u && resource.mipCount <= 16u && (resource.allocatedMipCount == 0u || resource.allocatedMipCount == resource.mipCount) && resource.baseLevel <= resource.lastLevel && resource.lastLevel < resource.mipCount && (array ? resource.baseArray <= resource.depthOrLastArray && resource.depthOrLastArray <= 0x1fffu : resource.depthOrLastArray == 0u && resource.baseArray == 0u), "the surface's mip levels or array slices have no texture descriptor encoding");
Require((!multisampled || resource.mipCount == 1u) && resource.dccAddress == 0u && resource.minLod == 0u && !resource.iterate256 && resource.bcSwizzle == 0u && resource.linearPitch == 0u, "only single-level multisampled surfaces and surfaces without metadata have a texture descriptor encoding");
Require(resource.width >= 1u && resource.width <= 0x4000u && resource.height >= 1u && resource.height <= 0x4000u && resource.format < 0x200u, "the surface's extent or format has no texture descriptor encoding");
const auto xorMask = resource.tileMode == TextureTileMode::kS4KBX || resource.tileMode == TextureTileMode::kD4KBX ? 0xfffull : 0xffffull;
Require(XorSwizzleMode(resource.tileMode) != 0 ? (resource.baseAddress & xorMask) == 0 && (resource.pipeBankXor & ~xorMask) == 0 : resource.pipeBankXor == 0, "the surface's pipe and bank XOR has no texture descriptor encoding");
@@ -405,8 +407,10 @@ std::array<std::uint32_t, 8> EncodeTextureResource(const GuestTextureResource& r
words[0] = static_cast<std::uint32_t>(base);
words[1] = static_cast<std::uint32_t>(base >> 32u) | (resource.format << 20u) | (((resource.width - 1u) & 3u) << 30u);
words[2] = ((resource.width - 1u) >> 2u) | ((resource.height - 1u) << 14u);
words[3] = resource.dstSelX | (resource.dstSelY << 3u) | (resource.dstSelZ << 6u) | (resource.dstSelW << 9u) | (sampleLevel << 16u) | (tileMode << 20u) | ((multisampled ? 14u : 9u) << 28u);
words[5] = sampleLevel << 4u;
const auto lastLevel = multisampled ? sampleLevel : resource.lastLevel;
words[3] = resource.dstSelX | (resource.dstSelY << 3u) | (resource.dstSelZ << 6u) | (resource.dstSelW << 9u) | (resource.baseLevel << 12u) | (lastLevel << 16u) | (tileMode << 20u) | ((multisampled ? 14u : array ? 13u : 9u) << 28u);
words[4] = resource.depthOrLastArray | (resource.baseArray << 16u);
words[5] = (multisampled ? sampleLevel : resource.mipCount - 1u) << 4u;
return words;
}
@@ -193,12 +193,19 @@ struct TargetUse {
std::atomic<bool> claimed{false};
};
std::shared_ptr<Buffer> stageGuestSamples(const Context& context, const MultisampleTextureLayout& layout, std::span<const std::byte> snapshot) {
Require(snapshot.size() == layout.Bytes(), "the multisampled guest color snapshot and footprint differ");
auto staging = std::make_shared<Buffer>(context, static_cast<std::size_t>((layout.LinearBytes() + 3u) & ~std::uint64_t{3}), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
layout.Detile(snapshot, staging->Bytes().first(static_cast<std::size_t>(layout.LinearBytes())));
return staging;
}
class MultisampleTarget : public std::enable_shared_from_this<MultisampleTarget> {
public:
MultisampleTarget(const Context& context, const ColorTarget& target, bool guestSamples = false) : context(context), target(target), cmask(target.cmaskAddress, target.cmaskBytes), colorFill(target) {
MultisampleTarget(const Context& context, const ColorTarget& target, bool guestSamples = false, std::optional<VkClearColorValue> initialClear = std::nullopt, std::shared_ptr<Buffer> preparedUpload = {}) : context(context), target(target), cmask(target.cmaskAddress, target.cmaskBytes), colorFill(target) {
this->context.bufferPool.reset();
if (target.dccAddress != 0) metadataValid = std::make_shared<std::atomic<bool>>(true);
const auto initial = initialDccClear(target);
const auto initial = initialClear ? *initialClear : initialDccClear(target);
if (target.dccAddress != 0) cleared = initial;
const auto samples = static_cast<VkSampleCountFlagBits>(target.samples);
Require((context.limits.framebufferColorSampleCounts & samples) != 0, "the device cannot render color with the target's sample count");
@@ -229,17 +236,18 @@ public:
};
if (storageFormat != VK_FORMAT_UNDEFINED && (!context.storageImageMultisample || !storageSupports(storageFormat, VK_IMAGE_USAGE_STORAGE_BIT, 0u) || !storageSupports(target.format, usage | VK_IMAGE_USAGE_STORAGE_BIT, storageFlags) || !uintStorageSupported())) storageFormat = VK_FORMAT_UNDEFINED;
VkImageCreateFlags flags = orderFlags;
std::shared_ptr<Buffer> upload;
const auto elementFormat = guestSamples ? TextureDetiler::ImageElementFormat(target.elementBytes) : VK_FORMAT_UNDEFINED;
auto upload = std::move(preparedUpload);
const bool importSamples = guestSamples || upload != nullptr;
const auto elementFormat = importSamples ? TextureDetiler::ImageElementFormat(target.elementBytes) : VK_FORMAT_UNDEFINED;
const auto alignment = std::max<VkDeviceSize>({4u, target.elementBytes, context.limits.minStorageBufferOffsetAlignment});
const auto stride = context.limits.maxStorageBufferRange / alignment * alignment;
if (guestSamples) {
if (importSamples) {
Require(context.detiler != nullptr && context.storageImageMultisample && context.storageImageWriteWithoutFormat, "uploading multisampled guest color requires formatless multisampled storage image writes");
Require(stride != 0, "uploading multisampled guest color needs a storage range of at least one aligned element");
flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT;
Require(storageSupports(elementFormat, VK_IMAGE_USAGE_STORAGE_BIT, 0u) && storageSupports(target.format, usage | VK_IMAGE_USAGE_STORAGE_BIT, flags), "the device cannot upload multisampled guest color through an unsigned storage view");
usage |= VK_IMAGE_USAGE_STORAGE_BIT;
upload = guestSampleUpload(target);
if (upload == nullptr) upload = guestSampleUpload(target);
}
twinFormat = colorTwinFormat(context, target.format);
if (twinFormat != VK_FORMAT_UNDEFINED) {
@@ -778,9 +786,7 @@ private:
Require(layout.LinearBytes() / use.elementBytes <= std::numeric_limits<std::uint32_t>::max(), "the multisampled guest color element count is unsupported");
std::vector<std::byte> guest(static_cast<std::size_t>(layout.Bytes()));
GuestMemory::Read(use.address, guest);
auto staging = std::make_shared<Buffer>(context, static_cast<std::size_t>((layout.LinearBytes() + 3u) & ~std::uint64_t{3}), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
layout.Detile(guest, staging->Bytes().first(static_cast<std::size_t>(layout.LinearBytes())));
return staging;
return stageGuestSamples(context, layout, guest);
}
VkClearColorValue initialDccClear(const ColorTarget& use) {
@@ -1059,7 +1065,7 @@ bool holdHostOnly(const MultisampleTarget& target) {
return true;
}
MultisampleTarget& acquire(const Context& context, const ColorTarget& requested) {
MultisampleTarget& acquire(const Context& context, const ColorTarget& requested, std::optional<VkClearColorValue> initialClear = std::nullopt, std::shared_ptr<Buffer> initialUpload = {}) {
discardRetiredTargets();
for (const auto& target : targets()) {
if (!target->active->load(std::memory_order_acquire)) continue;
@@ -1104,7 +1110,7 @@ MultisampleTarget& acquire(const Context& context, const ColorTarget& requested)
return *target;
}
const auto& use = requested;
auto target = std::make_shared<MultisampleTarget>(context, use);
auto target = std::make_shared<MultisampleTarget>(context, use, false, initialClear, std::move(initialUpload));
target->Keep();
targets().push_back(std::move(target));
auto& created = *targets().back();
@@ -1422,6 +1428,52 @@ bool TakeMultisampledClear(MultisampledCmask& cmask, MultisampledColorFill& colo
return true;
}
void PrepareMultisampleTargetForDraw_nid_no_patch(const Context& context, const ColorTarget& target) {
{
TargetsLock lock;
discardRetiredTargets();
if (std::ranges::any_of(targets(), [&](const auto& candidate) { return candidate->context.device == context.device && candidate->Serves(target); })) return;
}
if (target.dccAddress != 0u || target.cmaskFastClear) return;
Require(target.cmaskAddress == 0u, "initial multisample color contents with CMASK require a modeled metadata import");
Require(target.layers == 1u && target.arraySlice == 0u && target.arrayLastSlice == 0u && target.depth == 1u && target.depthSlice == 0u && target.mipCount == 1u && target.mip == 0u && !target.mipTail, "initial multisample array, volume or mip contents are not implemented");
Require(FindGuestColorTargetFormat(target.format, target.elementBytes).has_value(), "initial multisample color format or element size is unsupported");
Require(target.elementBytes != 0u && target.elementBytes <= 16u && 16u % target.elementBytes == 0u, "initial multisample color texel size is not implemented");
const auto bytes = MultisampledColorBytes(target);
Require(bytes != 0u && bytes <= std::numeric_limits<std::size_t>::max() && target.address <= std::numeric_limits<std::uint64_t>::max() - bytes, "initial multisample color footprint is not implemented");
const auto requireUnowned = [&] {
Require(!ResidentDepthGuardOverlaps_nid_no_patch(target.address, static_cast<std::size_t>(bytes)), "initial multisample color contents overlap resident native depth");
std::shared_lock guardLock(guardedMutex());
Require(std::ranges::none_of(guarded(), [&](const GuardedRange& range) { return range.active->load(std::memory_order_acquire) && target.address < range.address + range.bytes && range.address < target.address + bytes; }), "initial multisample color contents overlap another native owner");
};
requireUnowned();
Require(GuestMemory::Accessible(reinterpret_cast<const void*>(target.address), static_cast<std::size_t>(bytes)), "initial multisample color contents are not fully mapped");
std::vector<std::byte> snapshot(static_cast<std::size_t>(bytes));
GuestMemory::Read(target.address, snapshot);
requireUnowned();
Require(GuestMemory::CompareMapped(target.address, snapshot) == GuestMemory::Compare::Equal, "initial multisample color contents changed during capture");
std::optional<VkClearColorValue> clear;
if (std::equal(snapshot.begin() + target.elementBytes, snapshot.end(), snapshot.begin())) {
std::array<std::uint32_t, 4> pattern{};
auto texels = std::as_writable_bytes(std::span(pattern));
for (std::size_t offset = 0u; offset < texels.size(); offset += target.elementBytes) std::memcpy(texels.data() + offset, snapshot.data(), target.elementBytes);
VkClearColorValue value{};
if (ClearColorForTexel(target.format, target.elementBytes, pattern, value)) clear = value;
}
std::shared_ptr<Buffer> upload;
if (!clear) {
Require(target.tileMode == ColorTileMode::RenderTarget, "nonuniform initial multisample color tiling is not implemented");
Require(context.detiler != nullptr && context.storageImageMultisample && context.storageImageWriteWithoutFormat, "initial multisample color samples require enabled formatless multisampled storage image writes");
const MultisampleTextureLayout layout(TextureTileMode::kR64KBX, target.elementBytes, target.samples, target.extent.width, target.extent.height, 1u, target.pipeBankXor);
Require(layout.Bytes() == bytes && layout.LinearBytes() / target.elementBytes <= std::numeric_limits<std::uint32_t>::max(), "initial multisample color layout and footprint differ");
upload = stageGuestSamples(context, layout, snapshot);
}
TargetsLock lock;
requireUnowned();
Require(GuestMemory::CompareMapped(target.address, snapshot) == GuestMemory::Compare::Equal, "initial multisample color contents changed during upload preparation");
acquire(context, target, clear, std::move(upload));
}
SampleOrderTarget MultisampleTargetOrderTarget(const Context& context, const ColorTarget& target) {
TargetsLock lock;
auto& found = acquire(context, target);
@@ -42,7 +42,7 @@ static_assert(sizeof(VkStencilOpState) == 28, "VkStencilOpState changed: update
static_assert(sizeof(VkVertexInputBindingDescription) == 12, "VkVertexInputBindingDescription changed: update the recipe codec");
static_assert(sizeof(VkVertexInputAttributeDescription) == 16, "VkVertexInputAttributeDescription changed: update the recipe codec");
#if defined(__linux__) && defined(__x86_64__) && defined(__GLIBCXX__)
static_assert(sizeof(State) == 944, "State changed: update CanonicalPipelineState and the recipe codec");
static_assert(sizeof(State) == 952, "State changed: update CanonicalPipelineState and the recipe codec");
static_assert(sizeof(ShaderStages) == 164, "ShaderStages changed: update the recipe codec");
static_assert(sizeof(ShaderRecompiler::MeshConfiguration) == 40, "MeshConfiguration changed: update the recipe codec");
static_assert(sizeof(ShaderRecompiler::TessellationConfiguration) == 40, "TessellationConfiguration changed: update the recipe codec");
@@ -51,7 +51,7 @@ static_assert(sizeof(ShaderRecompiler::TessellationConfiguration) == 40, "Tessel
constexpr std::uint32_t FileMagic = 0x4c4a5041u;
// Bumped when the recipe codec, CanonicalPipelineState or the store key change in a way the
// layout guards above do not catch (a field renumbered or reinterpreted at the same size).
constexpr std::uint32_t FileFormat = 16u;
constexpr std::uint32_t FileFormat = 17u;
constexpr std::uint32_t ModuleRecord = 1u;
constexpr std::uint32_t GraphicsRecord = 2u;
constexpr std::uint32_t ComputeRecord = 3u;
@@ -209,6 +209,7 @@ void encodeState(Writer& writer, const State& state) {
writer.U32(color.exportIndex);
writer.Raw(color.componentMapping);
writer.Raw(color.partialWriteMask);
writer.Raw(color.mergeBlend);
}
writer.Raws(std::span<const VkPipelineColorBlendAttachmentState>(state.blends));
for (const auto value : state.blendConstants) writer.Raw(value);
@@ -281,7 +282,8 @@ void decodeState(Reader& reader, State& state) {
color.format = static_cast<VkFormat>(reader.U32());
color.exportIndex = reader.U32();
color.componentMapping = reader.Raw<std::uint8_t>();
color.partialWriteMask = reader.Raw<std::uint16_t>();
color.partialWriteMask = reader.Raw<std::uint32_t>();
color.mergeBlend = reader.Raw<std::uint32_t>();
state.colors.push_back(color);
}
reader.Raws(state.blends, 8u);
@@ -1572,6 +1574,7 @@ State CanonicalPipelineState(const State& state) {
canonicalColor.exportIndex = color.exportIndex;
canonicalColor.componentMapping = color.componentMapping;
canonicalColor.partialWriteMask = color.partialWriteMask;
canonicalColor.mergeBlend = color.mergeBlend;
canonical.colors.push_back(canonicalColor);
}
canonical.blends = state.blends;
@@ -5646,7 +5646,15 @@ void ShaderResources::resolveImageTables() {
const auto state = CurrentTableState();
std::vector<std::shared_ptr<Texture>> cached;
const bool storageTable = std::find(binding.imageWritten.begin(), binding.imageWritten.end(), true) != binding.imageWritten.end();
if (auto* reused = storageTable || item == nullptr ? nullptr : FindReusedTable(context.device, binding, state); reused != nullptr && TableCurrent(*reused) && CachedTableTextures(*reused, cached)) {
auto* reused = storageTable || item == nullptr ? nullptr : FindReusedTable(context.device, binding, state);
if (reused != nullptr && AnyPendingCpuWrites(context)) {
bool landed = false;
for (const auto& entry : reused->elements) {
if (!entry.rejected && CompletePendingCpuWrites(context, entry.resource.baseAddress, static_cast<std::size_t>(entry.guestBytes))) landed = true;
}
if (landed && CurrentTableState() != state) reused = nullptr;
}
if (reused != nullptr && TableCurrent(*reused) && CachedTableTextures(*reused, cached)) {
const bool replay = TableReplay() && reused->replayable && reused->imageSamplers == binding.imageSamplers && reused->samplers == samplerKey;
if (!replay) reused->bound.assign(binding.count, {});
auto next = cached.begin();
@@ -5659,7 +5667,6 @@ void ShaderResources::resolveImageTables() {
} else if (entry.rejected) {
table.map[faults + element] = rejectTableElement(table, words, entry.message);
} else {
CompletePendingCpuWrites(context, entry.resource.baseAddress, static_cast<std::size_t>(entry.guestBytes));
if (!replay) {
reused->bound[element] = bind(element, words, std::move(*next++), entry.resource, entry.guestBytes, entry.firstLayer);
} else if (!reused->bound[element].empty()) {
@@ -650,7 +650,7 @@ Module Inspect(const CompiledShader& compiled, const State& state, const VkPhysi
if (mesh) Require(module.primitiveIndices == state.stages.mesh->outputPrimitiveSize, "mesh shader does not export primitive indices");
if (fragment) Require(module.primitiveInputs == 0 || !primitiveLocations.empty(), "per-primitive pixel inputs need the barycentric emulation layout");
if (fragment) Require(!module.meshCapability || module.primitiveInputs != 0, "a pixel shader declares mesh shading without a per-primitive input");
if (stage == Stage::Vertex || mesh || ((evaluation || geometry) && !state.rasterizerDiscard)) Require(module.position, "vertex shader does not export position");
if (mesh || ((stage == Stage::Vertex || evaluation || geometry) && !state.rasterizerDiscard)) Require(module.position, "vertex shader does not export position");
return module;
}
@@ -1362,10 +1362,12 @@ bool DepthResummarizeDrawsNothing(const QueueState& queue) {
std::string DepthMaintenanceRejection(const QueueState& queue) {
if (DepthResummarizeDrawsNothing(queue)) return {};
const auto control = find(queue.context, 0x000);
if (control == queue.context.end() || (control->second & ~0x2fe3u) == 0) return {};
if (control == queue.context.end()) return {};
constexpr std::uint32_t maintenance = 0x0000101cu;
if ((control->second & maintenance) == 0) return {};
const auto depthControl = find(queue.context, 0x200);
const bool colorMasks = find(queue.context, 0x8e) != queue.context.end() && find(queue.context, 0x8f) != queue.context.end();
if ((control->second & ~0x2fe3u) == 0x10u && depthControl != queue.context.end() && (depthControl->second & 3u) == 0 && colorMasks && ColorWriteMask(queue.context) == 0) return {};
if ((control->second & (maintenance & ~0x10u)) == 0 && depthControl != queue.context.end() && (depthControl->second & 3u) == 0 && colorMasks && ColorWriteMask(queue.context) == 0) return {};
return zeroMessage(0x000, control->second, "DB_RENDER_CONTROL depth copy, resummarize or decompress");
}
@@ -1681,7 +1683,12 @@ State DecodeState(const QueueState& queue, bool vertexWorkgroup) {
APS5_LOG_OUT_DEBUG("Export format=%u", exportFormat);
// SPI_SHADER_POS_FORMAT: POS0 must be a 4-component position; later vectors carry the misc/clip
// exports that PA_CL_VS_OUT_CNTL validation above already limits to ignored layer/viewport data.
Require((read(cx, 0x1c3) & 0xfu) == 4, "additional position exports are unsupported");
const auto positionFormat = read(cx, 0x1c3) & 0xfu;
if (positionFormat == 0u) {
result.rasterizerDiscard = true;
} else {
Require(positionFormat == 4u, "position export format " + std::to_string(positionFormat) + " is unsupported");
}
for (std::uint32_t index = 0; index < exportCount; ++index) {
const auto slot = exportSlots[index];
if (((targetMask >> (4u * slot)) & 0xfu) == 0) continue;
@@ -1861,18 +1868,30 @@ State DecodeState(const QueueState& queue, bool vertexWorkgroup) {
const auto slotExport = (exportFormat >> (4u * color.exportIndex)) & 0xfu;
if (slotExport == 5 || slotExport == 6) throw std::runtime_error("AGC graphics: color export format " + std::to_string(slotExport) + " into " + packed + " target is unsupported");
if (state.srcColorBlendFactor == VK_BLEND_FACTOR_ONE && state.dstColorBlendFactor == VK_BLEND_FACTOR_ZERO && state.colorBlendOp == VK_BLEND_OP_ADD) state.blendEnable = VK_FALSE;
const bool floating = color.packing == ShaderRecompiler::ColorExportPacking::Float11_11_10;
if (floating && state.blendEnable) {
color.mergeBlend = PackedBlendControl(blend);
state.blendEnable = VK_FALSE;
}
Require(!state.blendEnable, "blending into " + packed + " color target is unsupported");
const bool nibbles = color.packing == ShaderRecompiler::ColorExportPacking::Unorm4_4_4_4;
const std::uint32_t packedMask = nibbles ? 0xfu : 7u;
Require(nibbles || (exportedMask & packedMask) == packedMask, "partial writes of " + packed + " color target are unsupported");
if ((exportedMask & packedMask) != packedMask) {
Require(color.mipCount == 1u && color.depth == 1u && color.layers == 1u && color.arrayLastSlice == 0u, "partial writes of a mipmapped, volume or array " + std::string(PackedColorTargetName(color.packing)) + " color target are not implemented");
Require(std::ranges::none_of(result.colors, [](const ColorTarget& other) { return other.partialWriteMask != 0 || other.staged; }), "partial writes of a packed color target merge into their target alone and cannot join another merged color target of the draw");
const auto written = PackedWriteMask(mapping, exportedMask);
Require(nibbles || floating || (exportedMask & packedMask) == packedMask, "partial writes of " + packed + " color target are unsupported");
if ((exportedMask & packedMask) != packedMask || color.mergeBlend != 0u) {
const std::string merged = color.mergeBlend != 0u ? "blending into " : "partial writes of ";
if (color.depth != 1u || (color.samples > 1u && (color.mipCount != 1u || color.layers != 1u || color.arrayLastSlice != 0u))) {
char detail[160];
std::snprintf(detail, sizeof(detail), " (%ux%u, %u samples, mip %u of %u%s, depth %u slice %u, layers %u, last slice %u)", color.extent.width, color.extent.height, color.samples, color.mip, color.mipCount, color.mipTail ? " in the tail" : "", color.depth, color.depthSlice, color.layers, color.arrayLastSlice);
Require(false, merged + "a volume " + std::string(PackedColorTargetName(color.packing)) + " color target, or a mipmapped or array multisampled one, are not implemented" + detail);
}
Require(std::ranges::none_of(result.colors, [](const ColorTarget& other) { return other.partialWriteMask != 0 || other.staged; }), std::string(color.mergeBlend != 0u ? "blending into a packed color target merges into its target alone" : "partial writes of a packed color target merge into their target alone") + " and cannot join another merged color target of the draw");
const auto written = PackedWriteMask(color.packing, mapping, exportedMask & packedMask);
Require(written != 0u, merged + packed + " color target that writes none of its channels is not implemented");
Require(!floating || color.samples == 1u, merged + "a multisampled 11_11_10 float color target are not implemented");
if (color.samples > 1u) {
Require(LogicOpFromRop(result.colorRop) == VK_LOGIC_OP_COPY, "a partial write of a multisampled 4_4_4_4 unorm color target under a color logic operation is not implemented");
color.staged = true;
color.stagedMask = written;
color.stagedMask = static_cast<std::uint16_t>(written);
color.stagedFormat = color.format;
color.format = VK_FORMAT_R32_UINT;
state.colorWriteMask = VK_COLOR_COMPONENT_R_BIT;
@@ -1942,14 +1961,39 @@ std::array<ShaderRecompiler::ColorExportPacking, 8> ExportPackings(const State&
return packings;
}
std::uint16_t PackedWriteMask(std::uint8_t componentMapping, std::uint32_t exportedMask) {
std::uint16_t mask = 0;
std::uint32_t PackedWriteMask(std::uint8_t componentMapping, std::uint32_t exportedMask) {
return PackedWriteMask(ShaderRecompiler::ColorExportPacking::Unorm4_4_4_4, componentMapping, exportedMask);
}
std::uint32_t PackedWriteMask(ShaderRecompiler::ColorExportPacking packing, std::uint8_t componentMapping, std::uint32_t exportedMask) {
constexpr std::array<std::uint32_t, 4> nibbles{0x000fu, 0x00f0u, 0x0f00u, 0xf000u};
constexpr std::array<std::uint32_t, 4> floats{0x000003ffu, 0x001ffc00u, 0xffe00000u, 0u};
Require(packing == ShaderRecompiler::ColorExportPacking::Unorm4_4_4_4 || packing == ShaderRecompiler::ColorExportPacking::Float11_11_10, "a write mask of a packed color target that is neither 4_4_4_4 unorm nor 11_11_10 float");
const auto& fields = packing == ShaderRecompiler::ColorExportPacking::Unorm4_4_4_4 ? nibbles : floats;
std::uint32_t mask = 0;
for (std::uint32_t component = 0; component < 4; ++component) {
if (((exportedMask >> ((componentMapping >> (2u * component)) & 3u)) & 1u) != 0) mask = static_cast<std::uint16_t>(mask | (0xfu << (4u * component)));
if (((exportedMask >> ((componentMapping >> (2u * component)) & 3u)) & 1u) != 0) mask |= fields[component];
}
return mask;
}
std::uint32_t PackedBlendControl(std::uint32_t blendControl) {
const auto source = blendControl & 0x1fu;
const auto combine = (blendControl >> 5u) & 7u;
const auto destination = (blendControl >> 8u) & 0x1fu;
char detail[96];
std::snprintf(detail, sizeof(detail), " (CB_BLEND_CONTROL 0x%08x)", blendControl);
Require(combine <= 4u, std::string("blending into an 11_11_10 float color target with an unknown combine function is not implemented") + detail);
const auto factor = [&](std::uint32_t value) {
if (value >= 15u && value <= 18u) Require(false, std::string("dual-source blending into an 11_11_10 float color target is not implemented") + detail);
if (value == 13u || value == 14u || value == 19u || value == 20u) Require(false, std::string("blending into an 11_11_10 float color target with a constant color factor is not implemented") + detail);
Require(value <= 10u, std::string("blending into an 11_11_10 float color target with an unknown blend factor is not implemented") + detail);
};
factor(source);
factor(destination);
return 0x40000000u | (destination << 8u) | (combine << 5u) | source;
}
ColorTarget StagedMergeTarget(const ColorTarget& staged) {
Require(staged.staged, "only a staged color target has a merge target");
auto target = staged;
@@ -1962,12 +2006,14 @@ ColorTarget StagedMergeTarget(const ColorTarget& staged) {
}
GuestTextureResource TargetMergeSurface(const ColorTarget& color) {
auto surface = SurfaceForTarget(color);
auto surface = color.arrayLastSlice != 0u ? ArraySurfaceForTarget(color) : SurfaceForTarget(color);
if (color.samples > 1u) {
Require(surface.baseAddress == color.surfaceAddress, "a merged multisampled color target does not start at its surface");
Require(surface.baseAddress == color.surfaceAddress && surface.dimension == TextureDimension::k2D && surface.mipCount == 1u, "a merged multisampled color target does not start at its single-level surface");
surface.dimension = TextureDimension::k2DMsaa;
surface.samples = color.samples;
}
surface.baseLevel = color.mip;
surface.lastLevel = color.mip;
return surface;
}
@@ -1993,6 +2039,11 @@ std::vector<ShaderRecompiler::TargetMerge> ExportTargetMerges(const State& state
merge.target = static_cast<std::uint8_t>(color.exportIndex);
merge.mask = color.partialWriteMask;
merge.samples = static_cast<std::uint8_t>(color.samples);
merge.packing = color.packing;
merge.blendControl = color.mergeBlend;
merge.layered = color.arrayLastSlice != 0u;
merge.firstSlice = merge.layered ? color.arraySlice : 0u;
merge.lastSlice = merge.layered ? color.arraySlice + color.layers - 1u : 0u;
merge.descriptor = EncodeTextureResource(TargetMergeSurface(color));
merge.depthStencilWrites = DepthStencilWrites(state);
merge.depthStencilTests = DepthStencilTests(state);
@@ -2185,6 +2236,17 @@ ColorTarget DecodeGcnColorBuffer(const Registers& cx, std::uint32_t slot) {
return color;
}
GuestTextureResource ArraySurfaceForTarget(const ColorTarget& color) {
Require(color.arrayLastSlice != 0, "the color target is not a view of a 2D array");
auto surface = SurfaceForTarget(color);
surface.baseAddress = color.arrayAddress;
surface.width = color.surfaceExtent.width;
surface.height = color.surfaceExtent.height;
surface.depthOrLastArray = color.arrayLastSlice;
surface.dimension = TextureDimension::k2DArray;
return surface;
}
ColorTarget DecodeColorBuffer(const Registers& cx, std::uint32_t slot, bool allowMultisampleDcc) {
if (ShaderRecompiler::GcnGuestShaders()) return DecodeGcnColorBuffer(cx, slot);
const auto stride = slot * 0xfu;
@@ -3070,6 +3070,10 @@ void heapMirrorTests(const Context& context, const BdaTestAccess& access) {
guest[65536 + 7] = 0x44;
Require(build(0, {}) == first && MirrorCounters().blocksCopied == one.blocksCopied + 2, "two written heap blocks were not read again");
Require(access.addressBytes(first)[5] == std::byte{0x33} && access.addressBytes(first)[65536 + 7] == std::byte{0x44}, "the heap mirror missed the CPU writes");
const auto stamped = MirrorCounters();
AgcDriver::GuestMemory::MarkWritten(address + 65536 + 16, 16);
Require(build(0, {}) == first && MirrorCounters().heapRefills == stamped.heapRefills + 1 && MirrorCounters().blocksCopied == stamped.blocksCopied, "a block stamped without a byte change was copied into its mirror again");
Require(build(0, {}) == first && MirrorCounters().heapRefills == stamped.heapRefills + 1 && MirrorCounters().blocksCopied == stamped.blocksCopied, "a stamped block whose bytes matched its mirror was found changed again");
const auto quiet = MirrorCounters();
Require(build(0, {}) == first && MirrorCounters().heapChecks == quiet.heapChecks && MirrorCounters().sweeps == quiet.sweeps && MirrorCounters().blocksCopied == quiet.blocksCopied, "an unchanged heap range was compared block by block or the mirrors were swept again");
guest[65536 + 9] = 0x66;
@@ -0,0 +1,154 @@
#define SPV_ENABLE_UTILITY_CODE
#include <spirv/unified1/spirv.hpp>
#undef SPV_ENABLE_UTILITY_CODE
#include "Recompiler.hpp"
#include <array>
#include <cstdint>
#include <cstdio>
#include <exception>
#include <map>
#include <span>
#include <stdexcept>
#include <string>
#include <string_view>
#include <vector>
using namespace ShaderRecompiler;
namespace {
struct Instruction {
std::uint32_t opcode = 0;
std::vector<std::uint32_t> operands;
};
struct Module {
std::map<std::uint32_t, Instruction> definitions;
std::multimap<std::uint32_t, std::uint32_t> users;
std::map<std::uint32_t, std::uint32_t> constants;
std::vector<std::uint32_t> results[2];
};
constexpr std::uint32_t ResultOpcodes[2] = {spv::OpFAdd, spv::OpFSub};
Module Parse(std::span<const std::uint32_t> words) {
if (words.size() < 5 || words[0] != spv::MagicNumber) throw std::runtime_error("the recompiler returned no SPIR-V module");
Module module;
for (std::size_t offset = 5; offset < words.size();) {
const auto count = words[offset] >> spv::WordCountShift;
if (count == 0 || count > words.size() - offset) throw std::runtime_error("the recompiler returned a malformed SPIR-V instruction");
const auto opcode = words[offset] & spv::OpCodeMask;
bool hasResult = false;
bool hasType = false;
spv::HasResultAndType(static_cast<spv::Op>(opcode), &hasResult, &hasType);
if (hasResult && hasType && count >= 3) {
const auto id = words[offset + 2];
Instruction instruction{opcode, {words.begin() + static_cast<std::ptrdiff_t>(offset + 3), words.begin() + static_cast<std::ptrdiff_t>(offset + count)}};
for (const auto operand : instruction.operands) module.users.emplace(operand, id);
if (opcode == spv::OpConstant && instruction.operands.size() == 1) module.constants[id] = instruction.operands[0];
for (std::size_t kind = 0; kind < 2; ++kind)
if (opcode == ResultOpcodes[kind]) module.results[kind].push_back(id);
module.definitions.emplace(id, std::move(instruction));
}
offset += count;
}
return module;
}
bool Constant(const Module& module, std::uint32_t id, std::uint32_t value) {
const auto found = module.constants.find(id);
return found != module.constants.end() && found->second == value;
}
bool NanTest(const Module& module, std::uint32_t id) {
const auto compare = module.definitions.find(id);
if (compare == module.definitions.end() || compare->second.opcode != spv::OpUGreaterThan || compare->second.operands.size() != 2) return false;
if (!Constant(module, compare->second.operands[1], 0x7f800000u)) return false;
const auto magnitude = module.definitions.find(compare->second.operands[0]);
return magnitude != module.definitions.end() && magnitude->second.opcode == spv::OpBitwiseAnd && magnitude->second.operands.size() == 2 && Constant(module, magnitude->second.operands[1], 0x7fffffffu);
}
std::uint32_t NanSelectsOnResult(const Module& module, std::uint32_t result) {
std::uint32_t value = result;
std::uint32_t selects = 0;
for (bool advanced = true; advanced;) {
advanced = false;
const auto [first, last] = module.users.equal_range(value);
for (auto user = first; user != last; ++user) {
const auto& instruction = module.definitions.at(user->second);
if (instruction.opcode == spv::OpBitcast) {
value = user->second;
advanced = true;
break;
}
if (instruction.opcode == spv::OpSelect && instruction.operands.size() == 3 && instruction.operands[2] == value && NanTest(module, instruction.operands[0])) {
value = user->second;
++selects;
advanced = true;
break;
}
}
}
return selects;
}
std::vector<std::uint32_t> Recompiled(std::span<const std::uint32_t> code) {
const std::array<std::uint32_t, 4> userData{0x10000000u, 0x00100000u, 0x40u, 0x00027facu};
const std::array<std::uint32_t, 2> capabilities{1u, 61u};
const std::array<std::string_view, 1> extensions{"SPV_KHR_storage_buffer_storage_class"};
RecompileRequest request{};
request.shader = {ShaderStage::Compute, 0x20000u, code, 0, {}};
request.context.waveSize = 64;
request.context.userDataBaseRegister = 0;
request.context.userData = userData;
request.context.compute = ShaderComputeStageInfo{{64u, 1u, 1u}, 0u, {false, false, false}, false, 1u};
request.target.vulkanVersion = 0x00403000u;
request.target.spirvVersion = 0x00010600u;
request.target.subgroupSize = 32u;
request.target.bdaAbiVersion = 1;
request.target.supportedCapabilities = capabilities;
request.target.supportedExtensions = extensions;
request.target.maxWorkgroupSize = {1024u, 1024u, 64u};
request.target.maxWorkgroupInvocations = 1024;
request.target.maxWorkgroupSharedMemoryBytes = 49152;
request.layout = {0, 0, 0, 128};
request.useCache = false;
const auto result = Recompile(request);
const auto& words = result.spirv.Words();
return {words.begin(), words.end()};
}
alignas(256) constexpr std::array<std::uint32_t, 11> Chain{
0x34020084u, 0xe0381000u, 0x80000401u, 0xbf8c3f70u,
0x06100b04u, 0x08100d08u, 0x0a100f08u, 0x06100908u,
0xe0701000u, 0x80000801u, 0xbf810000u,
};
}
int main() {
try {
const auto module = Parse(Recompiled(Chain));
bool passed = true;
for (std::size_t kind = 0; kind < 2; ++kind) {
const char* name = kind == 0 ? "v_add_f32" : "v_sub_f32/v_subrev_f32";
if (module.results[kind].empty()) {
std::printf("FAIL: no %s result in the module\n", name);
passed = false;
continue;
}
for (const auto result : module.results[kind]) {
const auto selects = NanSelectsOnResult(module, result);
if (selects != 1u) {
std::printf("FAIL: the %s result %u passes %u NaN selects before the register holds it, expected 1\n", name, result, selects);
passed = false;
}
}
}
std::printf(passed ? "PASS: every f32 add and sub result passes one NaN select\n" : "f32 NaN result selects: FAILED\n");
return passed ? 0 : 1;
} catch (const std::exception& error) {
std::printf("FAIL: %s\n", error.what());
return 1;
}
}
@@ -36,6 +36,7 @@
#include "prx/libc/include/GuestHeap.hpp"
#include "ImageTableAbi.hpp"
#include "SpirvBackend/SpirvSpecialization.hpp"
#include <spirv/unified1/GLSL.std.450.h>
#include <limits>
#include "RdnaDecoder/RdnaInstructionDecoder.hpp"
#include <spirv/unified1/spirv.hpp>
@@ -433,6 +434,24 @@ void stateTests() {
Require(state.color.address == reinterpret_cast<std::uintptr_t>(colorMemory.data()) && state.color.bytes == colorMemory.size(), "render-target address or size changed");
Require(state.viewport.y == 4 && state.viewport.height == -4, "negative viewport height was lost");
Require(state.color.format == VK_FORMAT_R8G8B8A8_UNORM, "RGBA format changed");
Require(!state.rasterizerDiscard, "a four-component position export discarded rasterization");
queue.context[0x1b3] = 2;
queue.context[0x1b4] = 2;
queue.context[0x1c3] = 0;
state = AgcDriver::Graphics::DecodeState(queue);
Require(state.rasterizerDiscard, "a disabled position export did not discard rasterization");
Require(AgcDriver::Graphics::DrawRejection(queue, false).empty(), "a draw without a position export was rejected");
queue.context[0x1c3] = 0x44;
Require(!AgcDriver::Graphics::DecodeState(queue).rasterizerDiscard, "an auxiliary position export discarded rasterization");
queue.context[0x1c3] = 1;
expectFailure([&] { AgcDriver::Graphics::DecodeState(queue); }, "position export format 1");
queue.context[0x1c3] = 2;
expectFailure([&] { AgcDriver::Graphics::DecodeState(queue); }, "position export format 2");
queue.context[0x1c3] = 3;
expectFailure([&] { AgcDriver::Graphics::DecodeState(queue); }, "position export format 3");
queue = makeState();
queue.context[0x1c3] = 0;
Require(AgcDriver::Graphics::CanonicalPipelineState(AgcDriver::Graphics::DecodeState(queue)).rasterizerDiscard, "the canonical state dropped the rasterizer discard");
queue.userConfig[0x24b] = 1;
queue.context[0x1b3] = 2;
queue.context[0x1b4] = 2;
@@ -2988,7 +3007,7 @@ void memoryValueFillTests() {
}
void depthMaintenanceTests() {
for (const auto mode : {0x4u, 0x8u, 0x84u, 0x108u, 0xf88u, 0x1000u, 0x4000u}) {
for (const auto mode : {0x4u, 0x8u, 0x84u, 0x108u, 0xf88u, 0x1000u}) {
for (const auto clear : {0u, 1u, 2u, 3u}) {
auto queue = makeState();
queue.context[0x000] = mode | clear;
@@ -3007,6 +3026,14 @@ void depthMaintenanceTests() {
queue.context[0x000] = control;
Require(AgcDriver::Graphics::DepthMaintenanceRejection(queue).empty(), "ordinary depth controls were mistaken for maintenance");
}
for (const auto reserved : {0x00004000u, 0x80000000u, 0xffffc000u}) {
auto queue = makeState();
queue.context[0x000] = reserved;
Require(AgcDriver::Graphics::DepthMaintenanceRejection(queue).empty(), "reserved DB_RENDER_CONTROL bits were mistaken for maintenance");
static_cast<void>(AgcDriver::Graphics::DecodeState(queue));
queue.context[0x000] = reserved | 4u;
Require(AgcDriver::Graphics::DepthMaintenanceRejection(queue).find("DB_RENDER_CONTROL") != std::string::npos, "a maintenance bit next to reserved bits was not reported");
}
for (const auto clear : {0u, 1u, 2u, 3u}) {
auto queue = makeState();
queue.context[0x000] = 0x10u | clear;
@@ -8215,6 +8242,7 @@ struct ModuleShape {
bool layerOutput = false;
bool terminateInvocation = false;
bool omitTerminateExtension = false;
bool noPosition = false;
};
void emit(std::vector<std::uint32_t>& out, spv::Op op, std::initializer_list<std::uint32_t> operands) {
@@ -8364,7 +8392,7 @@ std::vector<std::uint32_t> makeModule(const ModuleShape& shape) {
emit(declarations, spv::OpVariable, {inputPointer, input, spv::StorageClassInput});
emit(annotations, spv::OpDecorate, {input, spv::DecorationLocation, 0});
}
if (shape.fragment) emit(annotations, spv::OpDecorate, {output, spv::DecorationLocation, 0});
if (shape.fragment || shape.noPosition) emit(annotations, spv::OpDecorate, {output, spv::DecorationLocation, 0});
else emit(annotations, spv::OpDecorate, {output, spv::DecorationBuiltIn, spv::BuiltInPosition});
if (shape.push) {
const auto length = id();
@@ -9339,6 +9367,15 @@ void barycentricEmulationTests() {
expectFailure([&] { ValidateShaders(shaders, state, subgroup, false, false, false, true); }, "triangle primitives");
state.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
ValidateShaders(shaders, state, subgroup, false, false, false, true);
RecompileResult withoutPosition;
withoutPosition.spirv = makeModule({.noPosition = true});
RecompileResult plainPixel;
plainPixel.spirv = makeModule({.fragment = true});
const std::array<CompiledShader, 2> withoutPositionShaders{{{ShaderStage::Vertex, &withoutPosition, 0}, {ShaderStage::Fragment, &plainPixel, 0}}};
expectFailure([&] { ValidateShaders(withoutPositionShaders, state, subgroup, false, false, false, true); }, "vertex shader does not export position");
auto discarded = state;
discarded.rasterizerDiscard = true;
ValidateShaders(withoutPositionShaders, discarded, subgroup, false, false, false, true);
const auto plain = compile(interpolates, false);
const std::array<CompiledShader, 3> plainShaders{{{ShaderStage::Vertex, &vertex, 0}, {ShaderStage::Geometry, &geometry, 0}, {ShaderStage::Fragment, &plain, 0}}};
expectFailure([&] { ValidateShaders(plainShaders, state, subgroup, false, false, false, true); }, "only for emulated barycentrics");
@@ -11617,18 +11654,78 @@ void float11_11_10TargetTests() {
}
changed = queue;
for (std::uint32_t i = 0; i < 4; ++i) changed.context[0x105 + i] = 0;
changed.context[0x1e0] = 0x60010101u;
const auto additive = AgcDriver::Graphics::DecodeState(changed);
Require(additive.color.mergeBlend == 0x40000101u && additive.color.partialWriteMask == 0xffffffffu && !additive.blends[0].blendEnable && additive.blends[0].colorWriteMask == 0u, "an additive blend into an 11_11_10 float target did not decode as a blending merge of the whole word");
const auto onlyMerge = [](const AgcDriver::Graphics::State& state) {
const auto merges = AgcDriver::Graphics::ExportTargetMerges(state);
Require(merges.size() == 1u, "an 11_11_10 float blend did not merge into exactly one color target");
return merges.front();
};
const auto additiveMerge = onlyMerge(additive);
Require(additiveMerge.mask == 0xffffffffu && additiveMerge.packing == ColorExportPacking::Float11_11_10 && additiveMerge.blendControl == 0x40000101u, "the additive 11_11_10 float blend did not reach the pixel shader's target merge");
auto cube = additive;
auto& face = cube.colors.at(0);
face.arrayAddress = face.surfaceAddress;
face.surfaceExtent = {128u, 128u};
face.mipCount = 8u;
face.mip = 3u;
face.arrayLastSlice = 5u;
face.arraySlice = 2u;
face.layers = 4u;
cube.color = face;
const auto cubeMerge = onlyMerge(cube);
const auto cubeSurface = AgcDriver::Graphics::DecodeTextureResource(cubeMerge.descriptor);
Require(cubeMerge.layered && cubeMerge.firstSlice == 2u && cubeMerge.lastSlice == 5u && cubeSurface.dimension == AgcDriver::Graphics::TextureDimension::k2DArray && cubeSurface.baseAddress == face.arrayAddress && cubeSurface.width == 128u && cubeSurface.height == 128u && cubeSurface.mipCount == 8u && cubeSurface.baseLevel == 3u && cubeSurface.lastLevel == 3u && cubeSurface.baseArray == 0u && cubeSurface.depthOrLastArray == 5u && cubeSurface.format == AgcDriver::Graphics::SurfaceForTarget(face).format, "the merge of mip 3 of slices 2..5 of a mipmapped 11_11_10 float array does not address its whole array at that mip");
Require(!additiveMerge.layered && additiveMerge.firstSlice == 0u && additiveMerge.lastSlice == 0u, "the merge of a one-layer 11_11_10 float target was marked layered");
{
constexpr std::array<std::uint32_t, 3> mergeCode{0xf800180fu, 0x07060504u, 0xbf810000u};
auto merging = packedExportRequest(changed, cube, mergeCode);
merging.context.pixel->targetMerges = {cubeMerge};
const std::array<std::uint32_t, 4> capabilities{spv::CapabilityShader, spv::CapabilityFragmentShaderPixelInterlockEXT, spv::CapabilityStorageImageReadWithoutFormat, spv::CapabilityGeometry};
merging.target.supportedCapabilities = capabilities;
const ShaderRecompiler::RequestSerializer serializer;
Require(serializer.Deserialize(serializer.Serialize(merging)).request.context.pixel->targetMerges == std::vector{cubeMerge}, "the layered 11_11_10 float target merge was lost in serialization");
auto flat = merging;
flat.context.pixel->targetMerges = {additiveMerge};
auto shifted = merging;
shifted.context.pixel->targetMerges.front().firstSlice = 0u;
std::vector<std::uint64_t> layeredKey, flatKey, shiftedKey;
ShaderRecompiler::RecompileCacheKey::BuildInterface(merging, layeredKey);
ShaderRecompiler::RecompileCacheKey::BuildInterface(flat, flatKey);
ShaderRecompiler::RecompileCacheKey::BuildInterface(shifted, shiftedKey);
Require(layeredKey != flatKey && layeredKey != shiftedKey, "the static shader key does not separate a layered merge from a one-layer merge or from another first slice");
const auto words = ShaderRecompiler::Recompile(merging).spirv.Copy();
bool arrayed = false, layer = false, geometry = false, clamped = false;
for (std::size_t at = 5; at < words.size() && (words[at] >> 16u) != 0; at += words[at] >> 16u) {
const auto op = static_cast<spv::Op>(words[at] & 0xffffu);
if (op == spv::OpTypeImage && words[at + 3] == spv::Dim2D && words[at + 5] == 1u && words[at + 7] == 2u) arrayed = true;
if (op == spv::OpDecorate && words[at + 2] == spv::DecorationBuiltIn && words[at + 3] == spv::BuiltInLayer) layer = true;
if (op == spv::OpCapability && words[at + 1] == spv::CapabilityGeometry) geometry = true;
if (op == spv::OpExtInst && words[at + 4] == GLSLstd450UMin) clamped = true;
}
Require(arrayed && layer && geometry && clamped && interlockShape(words) == "capability extension ordered begin end ", "a layered 11_11_10 float merge module does not address an arrayed storage image by gl_Layer, clamped to the view's last slice, inside a pixel interlock");
auto multisampled = merging;
multisampled.context.pixel->targetMerges.front().samples = 2u;
expectFailure([&] { static_cast<void>(ShaderRecompiler::Recompile(multisampled)); }, "a color target merge into a multisampled array");
}
changed.context[0x1e0] = 0x65040504u;
Require(AgcDriver::Graphics::DecodeState(changed).color.mergeBlend == 0x40000504u, "a source-over blend into an 11_11_10 float target did not keep its color equation");
for (const auto replace : {0x40010001u, 0x60010001u, 0x60050001u}) {
changed.context[0x1e0] = replace;
const auto replaced = AgcDriver::Graphics::DecodeState(changed);
Require(replaced.blends.size() == 1 && !replaced.blends[0].blendEnable && replaced.color.packing == ColorExportPacking::Float11_11_10 && replaced.color.componentMapping == 0xc6u, "a blend that writes the source color into an 11_11_10 float target was refused or kept blending");
}
for (const auto blend : {0x60010101u, 0x40010005u}) {
changed.context[0x1e0] = blend;
expectFailure([&] { AgcDriver::Graphics::DecodeState(changed); }, "blending into an 11_11_10 float color target");
Require(replaced.blends.size() == 1 && !replaced.blends[0].blendEnable && replaced.color.packing == ColorExportPacking::Float11_11_10 && replaced.color.componentMapping == 0xc6u && replaced.color.mergeBlend == 0u && replaced.color.partialWriteMask == 0u, "a blend that writes the source color into an 11_11_10 float target was refused or kept blending");
}
changed.context[0x1e0] = 0x40000d01u;
expectFailure([&] { AgcDriver::Graphics::DecodeState(changed); }, "blending into an 11_11_10 float color target with a constant color factor");
changed.context[0x1e0] = 0x40000f01u;
expectFailure([&] { AgcDriver::Graphics::DecodeState(changed); }, "dual-source blending into an 11_11_10 float color target");
changed.context[0x1e0] = 0x400001a1u;
expectFailure([&] { AgcDriver::Graphics::DecodeState(changed); }, "unsupported blend operation 5");
changed = queue;
changed.context[0x8e] = 6;
expectFailure([&] { AgcDriver::Graphics::DecodeState(changed); }, "partial writes of an 11_11_10 float color target");
const auto partial = AgcDriver::Graphics::DecodeState(changed);
Require(partial.color.partialWriteMask == 0x001fffffu && partial.color.mergeBlend == 0u, "a green and blue write of an 11_11_10 float target did not merge into the word's low 21 bits");
changed.context[0x8e] = 7;
Require(AgcDriver::Graphics::DecodeState(changed).color.packing == ColorExportPacking::Float11_11_10, "an RGB write of an 11_11_10 float target was refused");
for (const auto format : {5u, 6u}) {
@@ -7495,13 +7495,19 @@ void verifySingleLaneVertexWave() {
};
static constexpr std::array<std::uint32_t, 11> waterfall{0xbe80047eu, 0xbe821400u, 0xd7600003u, 0x00000500u, 0xbe801c02u, 0xbf138000u, 0xbf85fffau, 0x7e020203u, 0xf80008cfu, 0x01010101u, 0xbf810000u};
static constexpr std::array<std::uint32_t, 6> lane31{0xd7600006u, 0x00013f00u, 0x7e020206u, 0xf80008cfu, 0x01010101u, 0xbf810000u};
static constexpr std::array<std::uint32_t, 12> comparedWaterfall{0x7d880a84u, 0x87806a7eu, 0xbe821400u, 0xd7600003u, 0x00000505u, 0xbe801c02u, 0xbf138000u, 0xbf85fffau, 0x7e020203u, 0xf80008cfu, 0x01010101u, 0xbf810000u};
static constexpr std::array<std::uint32_t, 11> everyLaneWaterfall{0xbe8004c1u, 0xbe821400u, 0xd7600003u, 0x00000505u, 0xbe801c02u, 0xbf138000u, 0xbf85fffau, 0x7e020203u, 0xf80008cfu, 0x01010101u, 0xbf810000u};
static constexpr std::array<std::uint32_t, 7> selectedLane{0x7e040505u, 0xd7600003u, 0x00000505u, 0x7e020203u, 0xf80008cfu, 0x01010101u, 0xbf810000u};
static constexpr std::array<std::uint32_t, 13> guardedWaterfall{0x7d880a84u, 0x87806a7eu, 0xbf840006u, 0xbe821400u, 0xd7600003u, 0x00000505u, 0xbe801c02u, 0xbf138000u, 0xbf85fffau, 0x7e020203u, 0xf80008cfu, 0x01010101u, 0xbf810000u};
static constexpr std::array<std::uint32_t, 7> execLane{0xbe82137eu, 0xd7600003u, 0x00000505u, 0x7e020203u, 0xf80008cfu, 0x01010101u, 0xbf810000u};
static constexpr std::array<std::uint32_t, 10> conditionalLane{0xbe82137eu, 0x7e080505u, 0xbf068004u, 0x8502c102u, 0xd7600003u, 0x00000505u, 0x7e020203u, 0xf80008cfu, 0x01010101u, 0xbf810000u};
const auto single = compiled(waveInfo, 32u, false);
const auto wide = compiled(waveInfo, 64u, true);
require(hasConstant(single, 0x0101u) && !hasConstant(single, 0x4040u) && !hasConstant(single, 0x2020u), "single-lane vertex wave: s3 of a vertex program without vertex subgroups was not one vertex and one primitive");
require(hasConstant(wide, 0x4040u) && !hasConstant(wide, 0x0101u), "single-lane vertex wave: s3 of a vertex program with vertex subgroups on 64 lanes changed");
require(single == compiled(waveInfo, 4u, false), "single-lane vertex wave: the program without vertex subgroups depended on the device subgroup size");
for (const auto code : {std::span<const std::uint32_t>(laneOps), std::span<const std::uint32_t>(waterfall)}) {
for (const auto code : {std::span<const std::uint32_t>(laneOps), std::span<const std::uint32_t>(waterfall), std::span<const std::uint32_t>(guardedWaterfall), std::span<const std::uint32_t>(execLane)}) {
const auto withSubgroups = compiled(code, 32u, true);
const auto withoutSubgroups = compiled(code, 32u, false);
require(usesSubgroups(withSubgroups), "single-lane vertex wave: the program did not use subgroup operations with vertex subgroups");
@@ -7509,6 +7515,44 @@ void verifySingleLaneVertexWave() {
}
expectFailure([&] { static_cast<void>(compiled(lane31, 32u, false)); }, "v_readlane_b32 of lane 31 is outside the 1-lane host subgroup", "single-lane vertex wave: a vertex program without vertex subgroups read lane 31");
require(!compiled(lane31, 32u, true).empty(), "single-lane vertex wave: lane 31 of a 32-lane vertex subgroup did not build");
const char* registerLane = "v_readlane_b32 of a register-selected lane is outside the 1-lane host subgroup";
expectFailure([&] { static_cast<void>(compiled(selectedLane, 32u, false)); }, registerLane, "single-lane vertex wave: a vertex program without vertex subgroups read the lane v_readfirstlane_b32 took from the vertex index");
expectFailure([&] { static_cast<void>(compiled(everyLaneWaterfall, 32u, false)); }, registerLane, "single-lane vertex wave: a vertex program without vertex subgroups ran an s_ff1 waterfall over every lane instead of the exec mask");
expectFailure([&] { static_cast<void>(compiled(comparedWaterfall, 32u, false)); }, registerLane, "single-lane vertex wave: a vertex program without vertex subgroups entered an s_ff1 waterfall over a compare result that can be empty, which reads lane 63");
expectFailure([&] { static_cast<void>(compiled(conditionalLane, 32u, false)); }, registerLane, "single-lane vertex wave: a vertex program without vertex subgroups read the lane s_cselect_b32 took from s_ff1_i32_b32 of EXEC or -1 on a test of the vertex index");
require(!compiled(selectedLane, 32u, true).empty(), "single-lane vertex wave: the lane v_readfirstlane_b32 took from the vertex index did not build on a 32-lane vertex subgroup");
const auto firstLaneRead = [](std::initializer_list<std::uint32_t> mask, bool guarded) {
std::vector<std::uint32_t> code(mask);
if (guarded) code.insert(code.end(), {0xbf078000u, 0xbf840003u});
code.insert(code.end(), {0xbe821300u, 0xd7600003u, 0x00000505u, 0x7e020203u, 0xf80008cfu, 0x01010101u, 0xbf810000u});
return code;
};
const std::array<std::pair<const char*, std::vector<std::uint32_t>>, 3> ownMasks{{
{"a compare result tested for zero before s_ff1_i32_b32", firstLaneRead({0x7d880a84u, 0xbe80036au}, true)},
{"a copy of EXEC", firstLaneRead({0xbe80037eu}, false)},
{"a copy of EXEC ORed with a compare result", firstLaneRead({0x7d880a84u, 0xbe87036au, 0xbe86037eu, 0x88000706u}, false)},
}};
for (const auto& [name, code] : ownMasks) {
const auto spirv = compiled(code, 32u, false);
require(!spirv.empty() && !usesSubgroups(spirv), (std::string("single-lane vertex wave: the lane s_ff1 took from ") + name + " did not build without subgroup operations").c_str());
}
const std::array<std::pair<const char*, std::vector<std::uint32_t>>, 12> otherMasks{{
{"an AND of two words v_readfirstlane_b32 took from the vertex index, tested for zero", firstLaneRead({0x7e080505u, 0x80058104u, 0x87000504u}, true)},
{"a copy of EXEC ORed with a word v_readfirstlane_b32 took from the vertex index, tested for zero", firstLaneRead({0x7e080505u, 0xbe86037eu, 0x88000406u}, true)},
{"a copy of EXEC XORed with a word v_readfirstlane_b32 took from the vertex index, tested for zero", firstLaneRead({0x7e080505u, 0xbe86037eu, 0x89000406u}, true)},
{"an s_cselect_b32 of a copy of EXEC or a word v_readfirstlane_b32 took from the vertex index, tested for zero", firstLaneRead({0x7e080505u, 0xbe86037eu, 0xbf068004u, 0x85000406u}, true)},
{"a copy of EXEC ANDed with a word v_readfirstlane_b32 took from the vertex index", firstLaneRead({0x7e080505u, 0xbe86037eu, 0x87000406u}, false)},
{"an s_cselect_b32 of a copy of EXEC or 0", firstLaneRead({0x7e080505u, 0xbe86037eu, 0xbf068004u, 0x85008006u}, false)},
{"an OR of two compare results", firstLaneRead({0x7d880a84u, 0xbe87036au, 0x7d880a88u, 0xbe88036au, 0x88000807u}, false)},
{"a compare result in the low word and EXEC in the high word, tested for zero by s_cmp_lg_u64", {0x7d880a84u, 0xbe80036au, 0xbe81037eu, 0xbf138000u, 0xbf840003u, 0xbe821400u, 0xd7600003u, 0x00000505u, 0x7e020203u, 0xf80008cfu, 0x01010101u, 0xbf810000u}},
{"a compare result in the low word and EXEC in the high word, tested for zero by the SCC of s_and_b64", {0x7d880a84u, 0xbe82036au, 0xbe83037eu, 0x87800202u, 0xbf840003u, 0xbe821400u, 0xd7600003u, 0x00000505u, 0x7e020203u, 0xf80008cfu, 0x01010101u, 0xbf810000u}},
{"a compare result read only when s_cmp_lg_u32 found it zero", {0x7d880a84u, 0xbe80036au, 0xbf078000u, 0xbf850003u, 0xbe821300u, 0xd7600003u, 0x00000505u, 0x7e020203u, 0xf80008cfu, 0x01010101u, 0xbf810000u}},
{"a copy of EXEC behind an s_cselect_b32 on s_cmp_lg_u32 of a word v_readfirstlane_b32 took from the vertex index", {0x7e080505u, 0xbe80037eu, 0xbe821300u, 0xbf078004u, 0x8502c102u, 0xd7600003u, 0x00000505u, 0x7e020203u, 0xf80008cfu, 0x01010101u, 0xbf810000u}},
{"a copy of EXEC behind an s_cselect_b32 on s_cmp_eq_u32 of that copy and 0", {0xbe80037eu, 0xbe821300u, 0xbf068000u, 0x8502c102u, 0xd7600003u, 0x00000505u, 0x7e020203u, 0xf80008cfu, 0x01010101u, 0xbf810000u}},
}};
for (const auto& [name, code] : otherMasks) {
expectFailure([&] { static_cast<void>(compiled(code, 32u, false)); }, registerLane, (std::string("single-lane vertex wave: the lane s_ff1 took from ") + name + " was accepted").c_str());
}
ShaderPixelStageInfo info{};
info.inputAddr = PixelInputBit(PixelInput::PerspectiveCenter);
@@ -7655,6 +7699,7 @@ void verifySingleLaneDomainWave() {
};
static constexpr std::array<std::uint32_t, 11> waterfall{0xbe80047eu, 0xbe821400u, 0xd7600003u, 0x00000505u, 0xbe801c02u, 0xbf138000u, 0xbf85fffau, 0x7e020203u, 0xf80008cfu, 0x01010101u, 0xbf810000u};
static constexpr std::array<std::uint32_t, 6> lane31{0xd7600006u, 0x00013f05u, 0x7e020206u, 0xf80008cfu, 0x01010101u, 0xbf810000u};
static constexpr std::array<std::uint32_t, 7> selectedLane{0x7e040505u, 0xd7600003u, 0x00000505u, 0x7e020203u, 0xf80008cfu, 0x01010101u, 0xbf810000u};
for (const auto code : {std::span<const std::uint32_t>(laneOps), std::span<const std::uint32_t>(waterfall)}) {
const auto withSubgroups = compiled(code, 32u, true);
@@ -7672,6 +7717,8 @@ void verifySingleLaneDomainWave() {
}
expectFailure([&] { static_cast<void>(compiled(lane31, 32u, false)); }, "v_readlane_b32 of lane 31 is outside the 1-lane host subgroup", "single-lane domain wave: a domain program without tessellation evaluation subgroups read lane 31");
require(!compiled(lane31, 32u, true).empty(), "single-lane domain wave: lane 31 of a 32-lane tessellation evaluation subgroup did not build");
expectFailure([&] { static_cast<void>(compiled(selectedLane, 32u, false)); }, "v_readlane_b32 of a register-selected lane is outside the 1-lane host subgroup", "single-lane domain wave: a domain program without tessellation evaluation subgroups read the lane v_readfirstlane_b32 took from v5");
require(!compiled(selectedLane, 32u, true).empty(), "single-lane domain wave: the lane v_readfirstlane_b32 took from v5 did not build on a 32-lane tessellation evaluation subgroup");
auto request = domain(laneOps, 32u, false);
const auto replay = RequestSerializer{}.Deserialize(RequestSerializer{}.Serialize(request));
@@ -8089,7 +8136,7 @@ void verifyPixelRequestSerialization() {
pixel.stencilRefExportEnable = true;
pixel.ditheredAlphaToCoverage = true;
pixel.reversedBlend = 0x570001u;
pixel.targetMerges = {{1u, 0x0ff0u, 1u, {0x100u, 0x2u, 0x3u, 0x4u, 0x5u, 0x6u, 0x7u, 0x8u}}};
pixel.targetMerges = {{.target = 1u, .mask = 0x0ff0u, .samples = 1u, .descriptor = {0x100u, 0x2u, 0x3u, 0x4u, 0x5u, 0x6u, 0x7u, 0x8u}}};
const std::array<std::array<std::uint8_t, 8>, 3> mappings{{
{0x00u, 0xe4u, 0xc6u, 0x1bu, 0xffu, 0x80u, 0x55u, 0xaau},
{0xe4u, 0xe4u, 0xe4u, 0xe4u, 0xe4u, 0xe4u, 0xe4u, 0xe4u},
@@ -8155,7 +8202,7 @@ void verifyPixelRequestSerialization() {
require(blendKey != replayKey, "a field of the unclamped color target blend did not change the static shader identity");
}
auto second = blending;
second.context.pixel->targetMerges.push_back({3u, 0xffffu, 1u, {0x300u}, false, false, {true, false, 4u, 5u, 0u, 4u, 5u, 0u, 0xfu, {}}});
second.context.pixel->targetMerges.push_back({.target = 3u, .mask = 0xffffu, .samples = 1u, .descriptor = {0x300u}, .depthStencilWrites = false, .depthStencilTests = false, .blend = {true, false, 4u, 5u, 0u, 4u, 5u, 0u, 0xfu, {}}});
RecompileCacheKey::Build(second, replayKey);
const auto secondKey = replayKey;
require(secondKey != blendKey && RecompileCacheKey::ContextHash(second) != RecompileCacheKey::ContextHash(blending), "a second merged target did not change the static shader identity");
@@ -8209,7 +8256,7 @@ void verifyPixelRequestSerialization() {
minimal.context.pixel->layerExported = true;
minimal.context.pixel->ditheredAlphaToCoverage = true;
const auto encoded = serializer.Serialize(minimal);
require(requestPrefix(encoded, 8u) == "NVNQQTYAAAA=", "new requests did not use serialization version 54");
require(requestPrefix(encoded, 8u) == "NVNQQTcAAAA=", "new requests did not use serialization version 55");
auto withBarycentric = minimal;
withBarycentric.target.fragmentBarycentricBuiltins = true;
require(serializer.Deserialize(serializer.Serialize(withBarycentric)).request.target.fragmentBarycentricBuiltins && !serializer.Deserialize(encoded).request.target.fragmentBarycentricBuiltins, "barycentric built-ins were lost in serialization");
@@ -8330,7 +8377,7 @@ void verifyPixelRequestSerialization() {
for (std::size_t bytes = 0; bytes < 45u; ++bytes) {
expectFailure([&] { static_cast<void>(serializer.Deserialize(requestPrefix(encoded, mappingOffset + bytes))); }, "truncated data", "a truncated pixel mapping, packing, dual-source, alpha-to-coverage, stencil reference export flag, primitive class, layer export, dither or front-face flag, quad pixel mask or quad sample mask was accepted");
}
for (const auto unsupported : {"NVNQQQAAAAA=", "NVNQQTIAAAA=", "NVNQQTcAAAA="}) {
for (const auto unsupported : {"NVNQQQAAAAA=", "NVNQQTIAAAA=", "NVNQQTgAAAA="}) {
expectFailure([&] { static_cast<void>(serializer.Deserialize(unsupported)); }, "serialization version", "an unsupported request version was accepted");
}
static constexpr std::string_view version18Request{
@@ -8449,10 +8496,26 @@ void verifyDepthExportClamp() {
const auto both = RequestSerializer{}.Deserialize(RequestSerializer{}.Serialize(tail));
require(both.request.target.largePixelFunctionLdsBuffer && both.request.target.pixelFunctionStorageDwords == 2048u &&
both.request.context.pixel->depthExportMin == 0.25f && both.request.context.pixel->depthExportMax == 0.75f,
"depth export: a version 54 request lost the bounds or the version 45 target tail");
"depth export: a version 55 request lost the bounds or the version 45 target tail");
auto bytes = decodeBase64(RequestSerializer{}.Serialize(tail));
require(bytes.size() > 8u && bytes[4] == 54u, "depth export: a depth exporting request did not use serialization version 54");
require(bytes.size() > 8u && bytes[4] == 55u, "depth export: a depth exporting request did not use serialization version 55");
const auto eraseVersion55MergeFields = [](std::vector<std::uint8_t>& serialized, RecompileRequest marked) {
static constexpr std::array<std::uint8_t, 4> marker{0xefu, 0xcdu, 0xabu, 0x89u};
marked.context.pixel->targetMerges.assign(1u, {});
marked.context.pixel->targetMerges.front().descriptor[7] = 0x89abcdefu;
const auto markedBytes = decodeBase64(RequestSerializer{}.Serialize(marked));
const auto descriptorEnd = std::search(markedBytes.begin(), markedBytes.end(), marker.begin(), marker.end()) - markedBytes.begin() + 4;
const auto fields = serialized.begin() + descriptorEnd + 2;
require(markedBytes.size() == serialized.size() && serialized.end() - fields > 15 && std::all_of(fields, fields + 15, [](std::uint8_t value) { return value == 0u; }), "the version 55 color target merge fields do not follow the merge's depth and stencil flags");
serialized.erase(fields, fields + 15);
};
eraseVersion55MergeFields(bytes, tail);
static constexpr std::array<std::uint8_t, 8> boundBytes{0x00u, 0x00u, 0x80u, 0x3eu, 0x00u, 0x00u, 0x40u, 0x3fu};
auto version49 = bytes;
version49.resize(version49.size() - 5u);
version49[4] = 49u;
const auto replay49 = RequestSerializer{}.Deserialize(encodeBase64(version49));
require(replay49.request.context.pixel->depthExportMin == 0.25f && replay49.request.context.pixel->depthExportMax == 0.75f && replay49.request.target.pixelFunctionStorageDwords == 2048u, "depth export: a version 49 request lost the bounds or the version 45 target tail");
const auto found = std::search(bytes.begin(), bytes.end(), boundBytes.begin(), boundBytes.end());
require(found != bytes.end() && std::search(found + 1, bytes.end(), boundBytes.begin(), boundBytes.end()) == bytes.end(),
"depth export: the clamp bounds were not written exactly once");
@@ -8481,7 +8544,8 @@ void verifyDepthExportClamp() {
ditheredPixel.ditheredAlphaSamples = 2u;
dithered.context.pixel = ditheredPixel;
auto ditheredBytes = decodeBase64(RequestSerializer{}.Serialize(dithered));
require(ditheredBytes.size() > 8u && ditheredBytes[4] == 54u, "a two-sample dithered request did not use serialization version 54");
require(ditheredBytes.size() > 8u && ditheredBytes[4] == 55u, "a two-sample dithered request did not use serialization version 55");
eraseVersion55MergeFields(ditheredBytes, dithered);
if (depthExport) {
const auto bounds = std::search(ditheredBytes.begin(), ditheredBytes.end(), boundBytes.begin(), boundBytes.end());
require(bounds != ditheredBytes.end(), "a two-sample dithered depth exporting request lacks the clamp bounds");
@@ -8622,26 +8686,68 @@ void verifyVertexInfoVersion19() {
require(blendOffset == allBitsOffset + 18u, "the reversed-order blend code is not serialized after the front-face all-bits flag, quad pixel mask and quad sample masks");
constexpr std::size_t iterationBytes = 35u;
constexpr std::size_t sampleOrderBytes = 16u;
constexpr std::size_t mergeBytes = 40u;
constexpr std::size_t mergeBytes = 55u;
constexpr std::size_t sampleMaskBytes = 16u;
const auto orderOffset = blendOffset + 4u + iterationBytes;
const auto mergeOffset = static_cast<std::ptrdiff_t>(orderOffset + sampleOrderBytes);
auto merging = pixel;
merging.context.pixel->targetMerges = {{3u, 0xf00fu, 2u, {1u, 2u, 3u, 4u, 5u, 6u, 7u, 0x89abcdefu}, true, true}};
merging.context.pixel->targetMerges = {{.target = 3u, .mask = 0xf00fu, .samples = 2u, .packing = ColorExportPacking::Float11_11_10, .blendControl = 0x20010001u, .layered = true, .firstSlice = 2u, .lastSlice = 0x105u, .descriptor = {1u, 2u, 3u, 4u, 5u, 6u, 7u, 0x89abcdefu}, .depthStencilWrites = true, .depthStencilTests = true}};
const auto mergingBytes = decodeBase64(serializer.Serialize(merging));
require(mergingBytes.size() == plainPixel.size() && std::equal(plainPixel.begin(), plainPixel.begin() + mergeOffset, mergingBytes.begin()) && mergingBytes[mergeOffset] == 3u && mergingBytes[mergeOffset + 1] == 0x0fu && mergingBytes[mergeOffset + 2] == 0xf0u && mergingBytes[mergeOffset + 5] == 2u && mergingBytes[mergeOffset + 6] == 1u && mergingBytes[mergeOffset + 34] == 0xefu && mergingBytes[mergeOffset + 37] == 0x89u && mergingBytes[mergeOffset + 38] == 1u && mergingBytes[mergeOffset + 39] == 1u && std::equal(plainPixel.begin() + mergeOffset + static_cast<std::ptrdiff_t>(mergeBytes), plainPixel.end(), mergingBytes.begin() + mergeOffset + static_cast<std::ptrdiff_t>(mergeBytes)), "the color target merge is not the 40 bytes the version 46 pixel info adds after the sample order");
require(mergingBytes.size() == plainPixel.size() && std::equal(plainPixel.begin(), plainPixel.begin() + mergeOffset, mergingBytes.begin()) && mergingBytes[mergeOffset] == 3u && mergingBytes[mergeOffset + 1] == 0x0fu && mergingBytes[mergeOffset + 2] == 0xf0u && mergingBytes[mergeOffset + 5] == 2u && mergingBytes[mergeOffset + 6] == 1u && mergingBytes[mergeOffset + 34] == 0xefu && mergingBytes[mergeOffset + 37] == 0x89u && mergingBytes[mergeOffset + 38] == 1u && mergingBytes[mergeOffset + 39] == 1u && mergingBytes[mergeOffset + 40] == 0u && mergingBytes[mergeOffset + 41] == static_cast<std::uint8_t>(ColorExportPacking::Float11_11_10) && mergingBytes[mergeOffset + 42] == 0x01u && mergingBytes[mergeOffset + 45] == 0x20u && mergingBytes[mergeOffset + 46] == 1u && mergingBytes[mergeOffset + 47] == 2u && mergingBytes[mergeOffset + 51] == 0x05u && mergingBytes[mergeOffset + 52] == 0x01u && std::equal(plainPixel.begin() + mergeOffset + static_cast<std::ptrdiff_t>(mergeBytes), plainPixel.end(), mergingBytes.begin() + mergeOffset + static_cast<std::ptrdiff_t>(mergeBytes)), "the color target merge is not the 55 bytes the version 54 pixel info adds after the sample order");
require(serializer.Deserialize(serializer.Serialize(merging)).request.context.pixel->targetMerges == merging.context.pixel->targetMerges, "a serialized request lost its color target merge");
auto version54 = mergingBytes;
version54.erase(version54.begin() + mergeOffset + 40, version54.begin() + mergeOffset + static_cast<std::ptrdiff_t>(mergeBytes));
version54[4] = 54u;
auto version53 = version54;
version53.resize(version53.size() - 2u);
version53[4] = 53u;
auto version49 = version53;
version49.resize(version49.size() - 3u);
version49[4] = 49u;
auto mergeAt49 = merging.context.pixel->targetMerges.front();
mergeAt49.packing = ColorExportPacking::Unorm4_4_4_4;
mergeAt49.blendControl = 0u;
mergeAt49.layered = false;
mergeAt49.firstSlice = 0u;
mergeAt49.lastSlice = 0u;
require(serializer.Deserialize(encodeBase64(version49)).request.context.pixel->targetMerges == std::vector{mergeAt49}, "a version 49 color target merge was not read as a single-slice 4_4_4_4 merge without blending");
require(serializer.Deserialize(encodeBase64(version54)).request.context.pixel->targetMerges == std::vector{mergeAt49}, "a version 54 color target merge, as main writes it, was not read as a single-slice 4_4_4_4 merge without blending");
require(serializer.Deserialize(encodeBase64(version53)).request.context.pixel->targetMerges == std::vector{mergeAt49}, "a version 53 color target merge, as main writes it, was not read as a single-slice 4_4_4_4 merge without blending");
version49[static_cast<std::size_t>(mergeOffset) + 4u] = 1u;
expectFailure([&] { static_cast<void>(serializer.Deserialize(encodeBase64(version49))); }, "target merge mask", "a version 49 color target merge word with a bit above the blend flag and the further merge count was accepted");
auto wideMerging = merging;
wideMerging.context.pixel->targetMerges.front().mask = 0xffe003ffu;
require(serializer.Deserialize(serializer.Serialize(wideMerging)).request.context.pixel->targetMerges == wideMerging.context.pixel->targetMerges, "a version 55 color target merge lost the upper half of its 32-bit mask");
auto blendMerging = pixel;
blendMerging.context.pixel->targetMerges = {{1u, 0xffffu, 1u, {1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u}, true, false, {true, true, 6u, 7u, 1u, 1u, 0u, 4u, 0xbu, {0x3fc00000u, 0xbe800000u, 0x3f000000u, 0x40000000u}}}};
blendMerging.context.pixel->targetMerges = {{.target = 1u, .mask = 0xffffu, .samples = 1u, .descriptor = {1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u}, .depthStencilWrites = true, .depthStencilTests = false, .blend = {true, true, 6u, 7u, 1u, 1u, 0u, 4u, 0xbu, {0x3fc00000u, 0xbe800000u, 0x3f000000u, 0x40000000u}}}};
const auto blendMergingBytes = decodeBase64(serializer.Serialize(blendMerging));
constexpr std::size_t blendPayloadBytes = 24u;
require(blendMergingBytes.size() == plainPixel.size() + blendPayloadBytes && std::equal(plainPixel.begin(), plainPixel.begin() + mergeOffset, blendMergingBytes.begin()) && blendMergingBytes[mergeOffset] == 1u && blendMergingBytes[mergeOffset + 1] == 0xffu && blendMergingBytes[mergeOffset + 2] == 0xffu && blendMergingBytes[mergeOffset + 3] == 0x01u && blendMergingBytes[mergeOffset + 4] == 0x00u, "a color target blend is not flagged in the merge mask word, or changed the bytes before the merge");
require(blendMergingBytes.size() == plainPixel.size() + blendPayloadBytes && std::equal(plainPixel.begin(), plainPixel.begin() + mergeOffset, blendMergingBytes.begin()) && blendMergingBytes[mergeOffset] == 1u && blendMergingBytes[mergeOffset + 1] == 0xffu && blendMergingBytes[mergeOffset + 2] == 0xffu && blendMergingBytes[mergeOffset + 3] == 0u && blendMergingBytes[mergeOffset + 4] == 0u && blendMergingBytes[mergeOffset + 40] == 1u && blendMergingBytes[mergeOffset + 41] == 1u, "a color target blend is not flagged after the merge's depth and stencil flags, or changed the bytes before the merge");
require(serializer.Deserialize(serializer.Serialize(blendMerging)).request.context.pixel->targetMerges == blendMerging.context.pixel->targetMerges, "a serialized request lost its color target blend");
const auto blendRecordToVersion49 = [&](std::vector<std::uint8_t>& bytes, std::ptrdiff_t record) {
const auto at = bytes.begin() + record;
const auto flags = at[40];
bytes.erase(at + 41 + static_cast<std::ptrdiff_t>(blendPayloadBytes), at + static_cast<std::ptrdiff_t>(mergeBytes + blendPayloadBytes));
bytes.erase(at + 40);
at[3] = flags;
};
auto blendVersion49 = blendMergingBytes;
blendRecordToVersion49(blendVersion49, mergeOffset);
blendVersion49.resize(blendVersion49.size() - 5u);
blendVersion49[4] = 49u;
require(serializer.Deserialize(encodeBase64(blendVersion49)).request.context.pixel->targetMerges == blendMerging.context.pixel->targetMerges, "a version 49 color target blend flagged in the merge mask word was not read as an unpacked blend");
auto twoMerging = blendMerging;
twoMerging.context.pixel->targetMerges.push_back({3u, 0xffffu, 1u, {9u, 10u, 11u, 12u, 13u, 14u, 15u, 16u}, true, false, {true, false, 4u, 5u, 0u, 4u, 5u, 0u, 0x3u, {}}});
twoMerging.context.pixel->targetMerges.push_back({.target = 3u, .mask = 0xffffu, .samples = 1u, .descriptor = {9u, 10u, 11u, 12u, 13u, 14u, 15u, 16u}, .depthStencilWrites = true, .depthStencilTests = false, .blend = {true, false, 4u, 5u, 0u, 4u, 5u, 0u, 0x3u, {}}});
const auto twoMergingBytes = decodeBase64(serializer.Serialize(twoMerging));
require(twoMergingBytes.size() == blendMergingBytes.size() + mergeBytes + blendPayloadBytes && twoMergingBytes[mergeOffset + 3] == 0x03u && std::equal(blendMergingBytes.begin() + mergeOffset + 4, blendMergingBytes.begin() + mergeOffset + static_cast<std::ptrdiff_t>(mergeBytes + blendPayloadBytes), twoMergingBytes.begin() + mergeOffset + 4), "a second color target merge did not follow the first, counted in the first merge word");
const auto twoMergingFlags = mergeOffset + 40;
require(twoMergingBytes.size() == blendMergingBytes.size() + mergeBytes + blendPayloadBytes && twoMergingBytes[static_cast<std::size_t>(twoMergingFlags)] == 0x03u && std::equal(blendMergingBytes.begin() + mergeOffset, blendMergingBytes.begin() + twoMergingFlags, twoMergingBytes.begin() + mergeOffset) && std::equal(blendMergingBytes.begin() + twoMergingFlags + 1, blendMergingBytes.begin() + mergeOffset + static_cast<std::ptrdiff_t>(mergeBytes + blendPayloadBytes), twoMergingBytes.begin() + twoMergingFlags + 1), "a second color target merge did not follow the first, counted in the first merge's flags");
require(serializer.Deserialize(serializer.Serialize(twoMerging)).request.context.pixel->targetMerges == twoMerging.context.pixel->targetMerges, "a serialized request lost its second color target merge");
auto twoVersion49 = twoMergingBytes;
blendRecordToVersion49(twoVersion49, mergeOffset + static_cast<std::ptrdiff_t>(mergeBytes + blendPayloadBytes));
blendRecordToVersion49(twoVersion49, mergeOffset);
twoVersion49.resize(twoVersion49.size() - 5u);
twoVersion49[4] = 49u;
require(serializer.Deserialize(encodeBase64(twoVersion49)).request.context.pixel->targetMerges == twoMerging.context.pixel->targetMerges, "a version 49 request with a second color target merge counted in the first merge word was not read as two unpacked blends");
auto unmasked = twoMergingBytes;
const auto secondMask = mergeOffset + static_cast<std::ptrdiff_t>(mergeBytes + blendPayloadBytes) + 1;
unmasked[secondMask] = unmasked[secondMask + 1] = 0u;
@@ -8895,7 +9001,7 @@ void verifyMergedHullConfiguration() {
require(!serializer.Deserialize(separate).request.graphics->tessellation->mergedHull, "a separate hull configuration was read as merged");
constexpr std::size_t pointTailBytes = 13u;
auto legacy = decodeBase64(merged);
require(legacy.size() > 60u + pointTailBytes && legacy[4] == 54u, "a merged hull request did not use serialization version 54");
require(legacy.size() > 60u + pointTailBytes && legacy[4] == 55u, "a merged hull request did not use serialization version 55");
legacy.resize(legacy.size() - sizeof(std::uint32_t) - 7u - pointTailBytes);
legacy.pop_back();
legacy.pop_back();
@@ -3,6 +3,7 @@
#include "Recompiler.hpp"
#include "Translation/InstructionTranslator.hpp"
#include "BdaAbi.hpp"
#include <algorithm>
#include <array>
#include <cstdint>
#include <cstdio>
@@ -60,12 +61,13 @@ void expectRejected(std::span<const std::uint32_t> code, std::optional<ShaderFlo
}
void verifyReads() {
constexpr std::array<std::uint32_t, 11> code{
constexpr std::array<std::uint32_t, 16> code{
0xb9140001, 0xb9150801, 0xb9161001, 0xb9171801, 0xb9180041,
0xb9190841, 0xb91a1041, 0xb91b0081, 0xb91c0881, 0xb91d00c1, 0xbf810000
0xb9190841, 0xb91a1041, 0xb91b0081, 0xb91c0881, 0xb91d00c1,
0xb91e0901, 0xb91f0981, 0xb9201901, 0xb9213801, 0xb9221881, 0xbf810000
};
constexpr std::array<std::uint32_t, 10> offsets{0, 0, 0, 0, 1, 1, 1, 2, 2, 3};
constexpr std::array<std::uint32_t, 10> masks{1, 3, 7, 15, 1, 3, 7, 1, 3, 1};
constexpr std::array<std::uint32_t, 15> offsets{0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 6, 4, 0, 2};
constexpr std::array<std::uint32_t, 15> masks{1, 3, 7, 15, 1, 3, 7, 1, 3, 1, 3, 3, 15, 255, 15};
for (const auto waveSize : {32u, 64u}) {
for (std::uint32_t mode = 0; mode < 256; ++mode) {
const auto program = translate(code, ShaderFloatMode{mode, true, true, true}, waveSize);
@@ -73,8 +75,11 @@ void verifyReads() {
expectRegister(program, 20 + index, (mode >> offsets[index]) & masks[index]);
}
}
const auto legacy = translate(code, std::nullopt, waveSize);
for (std::uint32_t index = 0; index < offsets.size(); ++index) expectRegister(legacy, 20 + index, 0);
std::array<std::uint32_t, 11> roundingCode{};
std::copy_n(code.begin(), 10, roundingCode.begin());
roundingCode[10] = code.back();
const auto legacy = translate(roundingCode, std::nullopt, waveSize);
for (std::uint32_t index = 0; index < 10; ++index) expectRegister(legacy, 20 + index, 0);
}
}
@@ -186,12 +191,35 @@ void verifyRoundInstruction() {
}
void verifyUnsupportedReads() {
for (const auto instruction : {0xb9140002u, 0xb9140101u, 0xb91408c1u, 0xb914f801u}) {
for (const auto instruction : {0xb9140002u, 0xb9140201u, 0xb91409c1u, 0xb914f801u}) {
const std::array<std::uint32_t, 2> code{instruction, endProgram};
expectRejected(code, ShaderFloatMode{0xc0}, "s_getreg_b32");
}
}
void verifyDenormalReadsAfterRoundingWrites() {
constexpr std::array<std::uint32_t, 5> offsets{4, 6, 4, 0, 2};
constexpr std::array<std::uint32_t, 5> masks{3, 3, 15, 255, 15};
for (std::uint32_t mode = 0; mode < 256; ++mode) {
const std::array<std::uint32_t, 5> dynamic{0xb9801801, 0xb9140901, 0xb9150981, 0xb9161901, endProgram};
const auto unknownRounding = translate(dynamic, ShaderFloatMode{mode});
for (std::uint32_t index = 0; index < 3; ++index) {
expectRegister(unknownRounding, 20 + index, (mode >> offsets[index]) & masks[index]);
}
for (std::uint32_t rounding = 0; rounding < 16; ++rounding) {
const std::array<std::uint32_t, 8> immediate{0xba801801, rounding, 0xb9140901, 0xb9150981, 0xb9161901, 0xb9173801, 0xb9181881, endProgram};
const auto program = translate(immediate, ShaderFloatMode{mode});
const std::array<std::uint32_t, 7> instruction{roundMode(rounding), 0xb9140901, 0xb9150981, 0xb9161901, 0xb9173801, 0xb9181881, endProgram};
const auto rounded = translate(instruction, ShaderFloatMode{mode});
const std::uint32_t expected = (mode & 0xf0u) | rounding;
for (std::uint32_t index = 0; index < offsets.size(); ++index) {
expectRegister(program, 20 + index, (expected >> offsets[index]) & masks[index]);
expectRegister(rounded, 20 + index, (expected >> offsets[index]) & masks[index]);
}
}
}
}
void verifyBranch() {
for (std::uint32_t rounding = 0; rounding < 16; ++rounding) {
const ShaderFloatMode mode{0xc0u | rounding};
@@ -309,13 +337,14 @@ int main() {
const char* name;
void (*run)();
};
constexpr std::array<Check, 16> checks{{
constexpr std::array<Check, 17> checks{{
{"encodings", verifyEncodings}, {"reads", verifyReads}, {"dynamicWrites", verifyDynamicWrites},
{"partialOverwrite", verifyDynamicWriteSurvivesPartialOverwrite}, {"immediateWrites", verifyImmediateWrites},
{"roundInstruction", verifyRoundInstruction}, {"unsupportedReads", verifyUnsupportedReads}, {"branch", verifyBranch},
{"diamond", verifyDiamond}, {"directed32", verifyRoundingBeforeDirected32Use}, {"restored", verifyRoundingRestoredBeforeUse},
{"untouchedFields", verifyUntouchedFieldsStayAccepted}, {"unmodelled", verifyUnmodelledDirectedRounding},
{"directedF16", verifyDirectedF16Conversion}, {"loop", verifyRoundingInLoop}, {"propagation", verifyRecompilePropagation},
{"denormalAfterRounding", verifyDenormalReadsAfterRoundingWrites},
}};
int failures = 0;
for (const auto& check : checks) {
@@ -55,7 +55,7 @@ if(BUILD_TESTING)
add_test(NAME agc_graphics_profile_draw COMMAND agc_driver_graphics_tests)
set_tests_properties(agc_graphics_profile_draw PROPERTIES
ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1;APS5_PROFILE_DRAW=1"
SKIP_RETURN_CODE 77 TIMEOUT 60 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
SKIP_RETURN_CODE 77 TIMEOUT 300 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
if(WIN32)
set_tests_properties(agc_command_batch_fence_failure agc_graphics_profile_draw PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
@@ -16,10 +16,11 @@ if(BUILD_TESTING)
add_test(NAME agc_driver_native_depth_stencil_view COMMAND agc_driver_native_multisample_depth_tests --stencil-view)
add_test(NAME agc_driver_native_depth_buffer_clear COMMAND agc_driver_native_multisample_depth_tests --buffer-clear)
add_test(NAME agc_driver_native_depth_uniform_planes COMMAND agc_driver_native_multisample_depth_tests --uniform-planes)
set_tests_properties(agc_driver_native_depth_clears agc_driver_native_depth_clear_refusals agc_driver_native_depth_stencil agc_driver_native_depth_separate_stencil agc_driver_native_depth_aliased_stencil agc_driver_native_depth_expand_gate agc_driver_native_depth_stencil_view agc_driver_native_depth_buffer_clear agc_driver_native_depth_uniform_planes agc_driver_native_depth_aliased_depth_depth_only agc_driver_native_depth_aliased_depth_stencil agc_driver_native_depth_aliased_depth_no_stencil PROPERTIES TIMEOUT 30 ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1" SKIP_RETURN_CODE 77 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
add_test(NAME agc_driver_native_depth_stored_repeat_fill COMMAND agc_driver_native_multisample_depth_tests --stored-repeat-fill)
set_tests_properties(agc_driver_native_depth_clears agc_driver_native_depth_clear_refusals agc_driver_native_depth_stencil agc_driver_native_depth_separate_stencil agc_driver_native_depth_aliased_stencil agc_driver_native_depth_expand_gate agc_driver_native_depth_stencil_view agc_driver_native_depth_buffer_clear agc_driver_native_depth_uniform_planes agc_driver_native_depth_aliased_depth_depth_only agc_driver_native_depth_aliased_depth_stencil agc_driver_native_depth_aliased_depth_no_stencil agc_driver_native_depth_stored_repeat_fill PROPERTIES TIMEOUT 30 ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1" SKIP_RETURN_CODE 77 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
if(WIN32)
set_tests_properties(agc_driver_native_depth_retirement PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
set_tests_properties(agc_driver_native_depth_clears agc_driver_native_depth_clear_refusals agc_driver_native_depth_stencil agc_driver_native_depth_separate_stencil agc_driver_native_depth_aliased_stencil agc_driver_native_depth_expand_gate agc_driver_native_depth_stencil_view agc_driver_native_depth_buffer_clear agc_driver_native_depth_uniform_planes agc_driver_native_depth_aliased_depth_depth_only agc_driver_native_depth_aliased_depth_stencil agc_driver_native_depth_aliased_depth_no_stencil PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
set_tests_properties(agc_driver_native_depth_clears agc_driver_native_depth_clear_refusals agc_driver_native_depth_stencil agc_driver_native_depth_separate_stencil agc_driver_native_depth_aliased_stencil agc_driver_native_depth_expand_gate agc_driver_native_depth_stencil_view agc_driver_native_depth_buffer_clear agc_driver_native_depth_uniform_planes agc_driver_native_depth_aliased_depth_depth_only agc_driver_native_depth_aliased_depth_stencil agc_driver_native_depth_aliased_depth_no_stencil agc_driver_native_depth_stored_repeat_fill PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_test(NAME agc_driver_native_depth_publication COMMAND agc_driver_native_multisample_depth_tests --publication)
set_tests_properties(agc_driver_native_depth_publication PROPERTIES TIMEOUT 30 ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1" SKIP_RETURN_CODE 77 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
@@ -0,0 +1 @@
target_include_directories(agc_driver_packed_float_blend_tests PRIVATE $<TARGET_PROPERTY:shader_recompiler_agc_driver,INTERFACE_INCLUDE_DIRECTORIES>)
@@ -1,6 +1,13 @@
target_include_directories(agc_driver_sample_multisample_target_tests PRIVATE $<TARGET_PROPERTY:shader_recompiler_agc_driver,INTERFACE_INCLUDE_DIRECTORIES>)
if(BUILD_TESTING)
foreach(initialMode IN ITEMS uniform uniform_refusals uniform_hook)
add_test(NAME agc_driver_native_color_initial_${initialMode} COMMAND agc_driver_sample_multisample_target_tests --initial-${initialMode})
set_tests_properties(agc_driver_native_color_initial_${initialMode} PROPERTIES TIMEOUT 30 ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1" SKIP_RETURN_CODE 77 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
if(WIN32)
set_tests_properties(agc_driver_native_color_initial_${initialMode} PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
endforeach()
add_test(NAME agc_driver_native_fmask COMMAND agc_driver_sample_multisample_target_tests --native-fmask)
set_tests_properties(agc_driver_native_fmask PROPERTIES TIMEOUT 30 ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1" SKIP_RETURN_CODE 77 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
if(WIN32)
@@ -14,3 +21,13 @@ if(BUILD_TESTING)
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
endif()
if(BUILD_TESTING)
foreach(initialMode IN ITEMS nonuniform nonuniform_lifetime nonuniform_capabilities nonuniform_hook)
add_test(NAME agc_driver_native_color_initial_${initialMode} COMMAND agc_driver_sample_multisample_target_tests --initial-${initialMode})
set_tests_properties(agc_driver_native_color_initial_${initialMode} PROPERTIES TIMEOUT 30 ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1" SKIP_RETURN_CODE 77 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
if(WIN32)
set_tests_properties(agc_driver_native_color_initial_${initialMode} PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
endforeach()
endif()
@@ -0,0 +1,13 @@
add_test_executable(agc_f32_nan_result_selects_tests EXCLUDE_FROM_ALL tests/F32NanResultSelects.cpp)
target_link_libraries(agc_f32_nan_result_selects_tests PRIVATE shader_recompiler_agc_driver libc)
set_target_properties(agc_f32_nan_result_selects_tests PROPERTIES CXX_EXTENSIONS OFF)
configure_windows_unwind(agc_f32_nan_result_selects_tests)
if(BUILD_TESTING)
set_target_properties(agc_f32_nan_result_selects_tests PROPERTIES EXCLUDE_FROM_ALL OFF)
add_test(NAME agc_f32_nan_result_selects COMMAND agc_f32_nan_result_selects_tests)
if(WIN32)
set_tests_properties(agc_f32_nan_result_selects PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
endif()
@@ -331,7 +331,8 @@ void MultisampledCase(AgcDriver::VulkanDevice& device, const Shaders& compiled,
}};
AgcDriver::Graphics::State state{};
state.stages = {AgcDriver::Graphics::ShaderPath::Vertex, 0u, 32u, 32u, std::nullopt, std::nullopt};
state.color = {reinterpret_cast<std::uintptr_t>(block + MultisampledColorOffset), {Width, Height}, VK_FORMAT_R8G8B8A8_UNORM, Width * Height * 16u, 0xe4u};
state.color = {reinterpret_cast<std::uintptr_t>(block + MultisampledColorOffset), {Width, Height}, VK_FORMAT_R8G8B8A8_UNORM, 1u << 16u, 0xe4u};
state.color.tileMode = AgcDriver::Graphics::ColorTileMode::RenderTarget;
state.color.samples = 4;
state.colors = {state.color};
state.hasColorTarget = true;
@@ -41,6 +41,9 @@ constexpr std::uint32_t Type2D = 9;
constexpr std::size_t Block = 0x10000;
constexpr std::size_t SurfaceBytes = 4 * Block;
constexpr std::size_t SettledImportBytes = 64 * Block;
constexpr std::size_t Runs = SettledImportBytes / SurfaceBytes - 1;
constexpr std::size_t Slots = 2 * (Runs + 1);
constexpr std::size_t ReservedBytes = Slots * SurfaceBytes;
constexpr std::uint32_t Untouched = 0xdeadbeefu;
constexpr std::uint32_t Stored = 0x12345678u;
constexpr std::uint32_t Filled = 0x9abcdef0u;
@@ -116,24 +119,49 @@ void Fill(std::vector<std::uint32_t>& words, const std::uint32_t* texels, const
Dispatch(words, FillCode, 64, (static_cast<std::uint32_t>(userData.size()) << 1u) | 0x80u, userData, static_cast<std::uint32_t>(SurfaceBytes / 1024u));
}
class Surface {
class Reservation {
public:
Surface() {
Reservation() {
#ifdef _WIN32
region = static_cast<std::uint8_t*>(GuestArena::GuestArenaAllocate_nid_postfix(SurfaceBytes, Block));
if (region != nullptr) GuestArena::GuestArenaCommit_nid_postfix(region, SurfaceBytes, PAGE_READWRITE, SurfaceBytes);
base = static_cast<std::uint8_t*>(GuestArena::GuestArenaAllocate_nid_postfix(ReservedBytes, ReservedBytes));
#else
void* mapped = mmap(nullptr, SurfaceBytes + Block, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
void* mapped = mmap(nullptr, 2 * ReservedBytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (mapped != MAP_FAILED) {
const auto begin = reinterpret_cast<std::uintptr_t>(mapped);
const auto aligned = (begin + Block - 1) & ~std::uintptr_t{Block - 1};
const auto aligned = (begin + ReservedBytes - 1) & ~std::uintptr_t{ReservedBytes - 1};
if (aligned != begin) munmap(mapped, aligned - begin);
if (aligned != begin + Block) munmap(reinterpret_cast<void*>(aligned + SurfaceBytes), begin + Block - aligned);
region = reinterpret_cast<std::uint8_t*>(aligned);
GuestWriteWatch::GuestWriteWatchRegister_nid_postfix(region, SurfaceBytes);
munmap(reinterpret_cast<void*>(aligned + ReservedBytes), begin + ReservedBytes - aligned);
base = reinterpret_cast<std::uint8_t*>(aligned);
GuestWriteWatch::GuestWriteWatchRegister_nid_postfix(base, ReservedBytes);
}
#endif
Require(region != nullptr, "direct write completion: cannot allocate the guest surface");
Require(base != nullptr, "direct write completion: cannot reserve the guest surfaces");
}
~Reservation() {
#ifdef _WIN32
GuestArena::GuestArenaRelease_nid_postfix(base, ReservedBytes);
#else
munmap(base, ReservedBytes);
GuestWriteWatch::GuestWriteWatchUnregister_nid_postfix(base, ReservedBytes);
#endif
}
Reservation(const Reservation&) = delete;
Reservation& operator=(const Reservation&) = delete;
std::uint8_t* Slot(std::size_t index) const { return base + index * SurfaceBytes; }
private:
std::uint8_t* base = nullptr;
};
class Surface {
public:
explicit Surface(std::uint8_t* slot) : region(slot) {
#ifdef _WIN32
GuestArena::GuestArenaCommit_nid_postfix(region, SurfaceBytes, PAGE_READWRITE, SurfaceBytes);
#endif
texels = reinterpret_cast<std::uint32_t*>(region);
std::fill(texels, texels + SurfaceBytes / 4u, Untouched);
GuestAllocations::Mutation().Add(region, SurfaceBytes, true, true, true);
@@ -143,10 +171,6 @@ public:
GuestAllocations::Mutation().Remove(region);
#ifdef _WIN32
GuestArena::GuestArenaReset_nid_postfix(region, SurfaceBytes);
GuestArena::GuestArenaRelease_nid_postfix(region, SurfaceBytes);
#else
munmap(region, SurfaceBytes);
GuestWriteWatch::GuestWriteWatchUnregister_nid_postfix(region, SurfaceBytes);
#endif
}
@@ -224,14 +248,14 @@ int main() {
struct ShutdownGuard {
~ShutdownGuard() { try { AgcDriverShutdown_nid_postfix(); } catch (...) {} }
} shutdown;
const Reservation reservation;
{
Surface probe;
Surface probe(reservation.Slot(0));
Require(AgcDriver::Graphics::DescribeSurface(AgcDriver::Graphics::DecodeTextureResource(TextureDescriptor(probe.Texels()))).guestBytes == SurfaceBytes, "direct write completion: unexpected surface size");
}
{
constexpr std::size_t Runs = SettledImportBytes / SurfaceBytes - 1;
std::vector<std::unique_ptr<Surface>> surfaces;
for (std::size_t index = 0; index <= 2 * Runs + 1; ++index) surfaces.push_back(std::make_unique<Surface>());
for (std::size_t index = 0; index < Slots; ++index) surfaces.push_back(std::make_unique<Surface>(reservation.Slot(index)));
static_cast<void>(StoreAfterFill(*surfaces[0], false));
std::size_t kept = 0;
std::size_t dropped = 0;
@@ -83,8 +83,9 @@ const std::array<Check, 4> PackedChecks{{
}};
struct Mode {
const char* name;
std::string name;
std::optional<ShaderRecompiler::ShaderFloatMode> floatMode;
bool scalar = true;
};
const std::array<Mode, 7> Modes{{
@@ -254,11 +255,24 @@ int main() {
request.context.floatMode = mode.floatMode;
return ShaderRecompiler::Recompile(request);
};
std::vector<Mode> modes(Modes.begin(), Modes.end());
for (std::uint32_t rounding = 0; rounding < 4; ++rounding) {
for (std::uint32_t denorm = 0; denorm < 4; ++denorm) {
for (const bool ieee : {false, true}) {
for (const bool dx10 : {false, true}) {
modes.push_back({"packed rounding=" + std::to_string(rounding) + " denorm=" + std::to_string(denorm) + " ieee=" + std::to_string(ieee) + " dx10=" + std::to_string(dx10),
ShaderRecompiler::ShaderFloatMode{0x30u | (rounding << 2u) | (denorm << 6u), dx10, ieee, false}, false});
}
}
}
}
constexpr std::array<std::uint32_t, 16> special{0x0000u, 0x8000u, 0x7c00u, 0xfc00u, 0x7e01u, 0xfe42u, 0x7c01u, 0xfc42u,
0x0001u, 0x8001u, 0x03ffu, 0x83ffu, 0x0400u, 0x8400u, 0x3c00u, 0xbc00u};
std::uint64_t compared = 0u;
for (const auto& mode : Modes) {
for (const auto& mode : modes) {
const bool flushInputs = mode.floatMode.has_value() && (mode.floatMode->floatMode & 0x40u) == 0u;
const Model model{mode.floatMode.has_value() && mode.floatMode->ieeeMode, !mode.floatMode.has_value() || mode.floatMode->dx10Clamp, flushInputs};
const auto scalar = compile(ScalarCode, mode);
const auto scalar = mode.scalar ? std::optional{compile(ScalarCode, mode)} : std::nullopt;
const auto packed = compile(PackedCode, mode);
for (std::uint32_t batch = 0; batch < Batches; ++batch) {
for (std::uint32_t tid = 0; tid < Threads; ++tid) {
@@ -268,6 +282,11 @@ int main() {
if (tid % 8u == 1u) row[1] = row[0] ^ 0x80008000u;
if (tid % 8u == 2u) row[2] = row[1];
if (tid % 8u == 3u) row[2] = row[0] ^ 0x80008000u;
if (tid < special.size()) {
for (std::uint32_t index = 0; index < Inputs; ++index) {
row[index] = special[(tid + batch + index) % special.size()] | (special[(tid + batch + index + 7u) % special.size()] << 16u);
}
}
}
const auto run = [&](const ShaderRecompiler::RecompileResult& result, std::span<const std::uint32_t> code, std::span<const Check> checks, bool isPacked) {
Output.fill(0xdeadbeefu);
@@ -283,7 +302,7 @@ int main() {
}
}
};
run(scalar, ScalarCode, ScalarChecks, false);
if (scalar.has_value()) run(*scalar, ScalarCode, ScalarChecks, false);
run(packed, PackedCode, PackedChecks, true);
}
}
@@ -1,5 +1,6 @@
#include "prx/libSceAgcDriver/Execution/include/GuestMemory.hpp"
#include "prx/libSceAgcDriver/Execution/include/VulkanDevice.hpp"
#include "prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp"
#include "prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp"
#include "prx/libSceAgcDriver/Graphics/include/Texture.hpp"
#include "prx/libc/include/GuestAllocations.hpp"
@@ -250,6 +251,43 @@ void RunImageStore(AgcDriver::VulkanDevice& device, const GuestBlock& block) {
Require(Row(block.Texels(23)) == Row(stored.data()), "image table reuse: the image store wrote the wrong values");
}
void RunPendingWriteBack(AgcDriver::VulkanDevice& device, const GuestBlock& block) {
if (!AgcDriver::GuestMemory::WriteWatched()) return;
for (std::uint32_t texture = 0; texture < Records; ++texture) {
Fill(block, texture, 0.875f);
SetRecord(block, texture, texture);
}
const auto srt = Buffer(block.Table(), Records * Stride);
const auto keys = Buffer(Keys.data(), static_cast<std::uint32_t>(sizeof(Keys)));
std::copy(srt.begin(), srt.end(), Srt.begin());
std::copy(keys.begin(), keys.end(), Srt.begin() + 4);
SetOutput(Output.data());
const auto result = Compile(device, block);
SetOutput(block.Texels(13));
const auto writer = Compile(device, block);
SetOutput(Output.data());
AgcDriver::GuestMemory::BumpCollectEpoch();
const auto before = AgcDriver::Graphics::ImageTableReuses();
const auto old = Row(block.Texels(13));
Require(Dispatch(device, result, 25) == Row(block.Texels(25)), "image table reuse: the table before a write-back was left pending sampled the wrong entry");
Require(Dispatch(device, result, 13) == old, "image table reuse: the table reused before a write-back was left pending sampled the wrong entry");
Expect(before, 2 - CpuWriteResolutions, CpuWriteResolutions, "two dispatches of a table before a write-back is left pending");
Keys[0] = 13;
device.Dispatch(writer, 1, 1, 1, {}, AddressOf(TableCode.data()));
const auto& context = device.graphicsContext();
if (AgcDriver::Graphics::HostImportCovers(context, AddressOf(block.Texels(13)), TextureBytes) || !AgcDriver::Graphics::AnyPendingCpuWrites(context) || Row(block.Texels(13)) != old) {
device.WaitIdle();
std::puts("a dispatch's write-back over a table entry was not left pending: a table used over a pending write-back is not tested");
return;
}
const auto sampled = Dispatch(device, result, 13);
const auto written = Row(block.Texels(13));
Require(written != old && written[4] == old[1], "image table reuse: the dispatch writing into an entry's texels with its write-back left pending stored the wrong values");
const auto step = Since(before);
Require(sampled == written, std::string("image table reuse: a table used while a dispatch's write-back was pending over an entry sampled ") + (sampled == old ? "the entry's old texels" : "neither the entry's old texels nor the written ones") + " (" + std::to_string(step.reused) + " reused and " + std::to_string(step.resolved) + " resolved tables in the step)");
Expect(before, 3 - CpuWriteResolutions, CpuWriteResolutions + 1, "a write-back pending over an entry when its table is used again");
}
void RunTests(AgcDriver::VulkanDevice& device, const GuestBlock& block, const GuestBlock& stores) {
for (std::uint32_t texture = 0; texture < Records; ++texture) {
Fill(block, texture, 0.25f);
@@ -362,9 +400,11 @@ int main() {
try {
GuestBlock block;
GuestBlock stores(UnimportableBytes);
GuestBlock pending(UnimportableBytes);
const auto device = OpenVulkanTestDevice();
if (!device) return VulkanTestSkipped;
RunTests(*device, block, stores);
RunPendingWriteBack(*device, pending);
std::puts("image table reuse tests passed");
return 0;
} catch (const std::exception& error) {
@@ -33,7 +33,7 @@ using ShaderRecompiler::ShaderStage;
constexpr std::uint32_t Samples = 4;
alignas(4096) std::array<std::byte, Width * Height * 4 * Samples> Multisampled{};
alignas(4096) std::array<std::byte, 65536> Multisampled{};
alignas(4096) std::array<float, Width * Height> DepthA{};
alignas(4096) std::array<float, Width * Height> DepthB{};
@@ -87,6 +87,7 @@ void Draw(const Context& context, AgcDriver::VulkanDevice& device, const Shaders
State state{};
state.stages = {ShaderPath::Vertex, 0u, 32u, 32u, std::nullopt, std::nullopt};
state.color = {reinterpret_cast<std::uintptr_t>(Multisampled.data()), {Width, Height}, VK_FORMAT_R8G8B8A8_UNORM, Multisampled.size(), 0xe4u};
state.color.tileMode = ColorTileMode::RenderTarget;
state.color.samples = Samples;
state.colors = {state.color};
state.hasColorTarget = true;
@@ -2703,6 +2703,10 @@ void CheckAliasedDepth(Context context, std::uint32_t fragments, const AliasedDe
if (which == DepthAliasCase::NewTargetAfterImport) {
auto other = color;
other.format = VK_FORMAT_R16G16_SFLOAT;
TargetRefuses([&] { PrepareMultisampleTargetForDraw_nid_no_patch(context, other); }, "initial multisample color contents overlap resident native depth");
Require(DepthSurfaceAt(target.address) && CachedSampledTexture(context, words) == texture, "refused color initialization released the resident depth owner");
recorder.Sync();
read();
MultisampleTargetView(context, other);
}
if (which == DepthAliasCase::DrawnAfterImport || which == DepthAliasCase::NewTargetAfterImport) TargetRefuses([&] { CachedSampledTexture(context, words); }, depthAliasRefusal);
@@ -3348,6 +3352,100 @@ void CheckUniformPlanesWithoutHtile(Context context, std::uint32_t samples) {
std::printf("Native D32S8 without HTILE, samples=%u: uniform planes imported and sampled, other planes refused\n", samples);
}
void CheckStoredRepeatFill(Context context, std::uint32_t samples) {
constexpr VkExtent2D extent{5u, 3u};
const auto depthBytes = static_cast<std::size_t>(MultisampledDepthBytes_nid_no_patch(extent, 4u, samples));
const auto stencilBytes = static_cast<std::size_t>(MultisampledDepthBytes_nid_no_patch(extent, 1u, samples));
const auto metadataBytes = static_cast<std::size_t>(HtileMetadataBytes(extent));
TargetMemory memory(depthBytes), stencil(stencilBytes), metadata(65536u);
std::memset(memory.Data(), 0, depthBytes);
std::memset(stencil.Data(), 0, stencilBytes);
std::memset(metadata.Data(), 0, metadataBytes);
DepthTarget target{memory.Address(), stencil.Address(), extent, VK_FORMAT_D32_SFLOAT_S8_UINT, 0.0f, 0u, metadata.Address(), false, samples};
target.depthSwizzle = 24u;
target.iterate256 = target.htilePipeAligned = true;
target.htileDepthOnly = true;
Recorder recorder(context);
recorder.Activate();
const auto clear = [&] {
recorder.Sync();
ClearCachedTextures(context.device);
ClearDepthSurfaces(context.device);
};
struct Cleanup {
decltype(clear)& action;
~Cleanup() { action(); }
} cleanup{clear};
const auto words = DepthSampleWords(target);
const auto store = [&](std::uint32_t word, std::size_t bytes) {
AgcDriver::GuestMemory::StoreOwnBytes(target.htileAddress, bytes, [&] {
for (std::size_t offset = 0u; offset + 4u <= bytes; offset += 4u) std::memcpy(metadata.Data() + offset, &word, 4u);
});
};
const auto sample = [&](float expected) {
Require(DepthSurfaceView(context, target) != VK_NULL_HANDLE, "a native HTILE depth target with a repeated fill has no attachment view");
auto texture = CachedSampledTexture(context, words);
Require(texture != nullptr, "a native HTILE depth target with a repeated fill was not imported");
recorder.Sync();
const auto count = extent.width * extent.height * samples;
Buffer output(context, (count + 2u) * 16u, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
const Fetch fetch(context, *texture, output, FetchShader(extent.width, extent.height, samples, false, true));
CommandBatch batch(context);
fetch.Run(batch.Handle(), count);
RecordMemoryBarrier(context, batch.Handle(), VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_HOST_BIT, VK_ACCESS_SHADER_WRITE_BIT, VK_ACCESS_HOST_READ_BIT);
batch.SubmitAndWait();
output.Invalidate();
for (std::uint32_t index = 0u; index < count; ++index) {
std::array<float, 4> sampled{};
std::memcpy(sampled.data(), output.Bytes().data() + (index + 1u) * 16u, 16u);
Require(sampled == std::array<float, 4>{expected, 0.0f, 0.0f, 1.0f}, "a repeated native HTILE fill lost the depth clear");
}
texture.reset();
};
const auto reset = [&](float expected) {
clear();
std::memset(metadata.Data(), 0, metadataBytes);
target.clearDepth = expected;
sample(expected);
};
sample(0.0f);
const std::uint32_t one = 0xfffffff0u;
target.clearDepth = 1.0f;
NoteDepthMetadataFill(target.htileAddress, metadataBytes, one);
store(one, metadataBytes);
NoteDepthMetadataFill(target.htileAddress, metadataBytes, one);
sample(1.0f);
reset(0.0f);
NoteDepthMetadataFill(target.htileAddress, metadataBytes, 0u);
NoteDepthMetadataFill(target.htileAddress, metadataBytes, 0u);
TargetRefuses([&] { CachedSampledTexture(context, words); }, "overlapping native multisample depth clear transitions are not implemented");
reset(0.0f);
target.clearDepth = 1.0f;
NoteDepthMetadataFill(target.htileAddress, metadataBytes, one);
store(one, 4u);
NoteDepthMetadataFill(target.htileAddress, metadataBytes, one);
TargetRefuses([&] { CachedSampledTexture(context, words); }, "overlapping native multisample depth clear transitions are not implemented");
reset(0.0f);
target.clearDepth = 1.0f;
{
const auto view = DepthSurfaceView(context, target);
Require(view != VK_NULL_HANDLE, "the repeated fill fixture after a draw has no attachment view");
DepthRaster raster(context, target, view);
CommandBatch batch(context);
raster.Run(batch.Handle(), 0.0f);
batch.SubmitAndWait();
recorder.Sync();
}
NoteDepthMetadataFill(target.htileAddress, metadataBytes, one);
store(one, metadataBytes);
NoteDepthMetadataFill(target.htileAddress, metadataBytes, one);
sample(1.0f);
std::printf("Native D32S8 with HTILE, samples=%u: a stored whole-HTILE fill was accepted, an unstored or partially stored one was refused and a stored refill after a draw was accepted\n", samples);
}
int main(int argc, char** argv) {
try {
#ifdef __linux__
@@ -3426,6 +3524,18 @@ int main(int argc, char** argv) {
}
return 0;
}
if (argc == 2 && std::string_view(argv[1]) == "--stored-repeat-fill") {
const auto supported = [&](std::uint32_t samples) { return DepthSupported(context, HostDepthFormat(context, VK_FORMAT_D32_SFLOAT_S8_UINT), samples) && (context.limits.framebufferStencilSampleCounts & samples) != 0u; };
Require(supported(4u), "the stored repeated HTILE fill regression requires sampled D32S8 with four samples");
std::uint32_t checked = 0u, unavailable = 0u;
for (const auto samples : {2u, 4u, 8u}) {
if (!supported(samples)) { ++unavailable; continue; }
CheckStoredRepeatFill(context, samples);
++checked;
}
std::printf("Native depth stored repeated HTILE fill cases checked=%u unavailable=%u\n", checked, unavailable);
return checked != 0u ? 0 : VulkanTestSkipped;
}
if (argc == 2 && std::string_view(argv[1]) == "--uniform-planes") {
std::uint32_t checked = 0u, unavailable = 0u;
for (const auto samples : {2u, 4u, 8u}) {
@@ -0,0 +1,684 @@
#include "prx/libSceAgcDriver/Execution/include/GuestMemory.hpp"
#include "prx/libSceAgcDriver/Execution/include/VulkanDevice.hpp"
#include "prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hpp"
#include "prx/libSceAgcDriver/Graphics/include/ColorTargetLayout.hpp"
#include "prx/libSceAgcDriver/Graphics/include/Draw.hpp"
#include "prx/libSceAgcDriver/Graphics/include/Recorder.hpp"
#include "prx/libSceAgcDriver/Graphics/include/ShaderInputState.hpp"
#include "prx/libSceAgcDriver/Graphics/include/State.hpp"
#include "prx/libSceAgcDriver/Graphics/include/Texture.hpp"
#include "prx/libSceAgcDriver/Graphics/include/TextureTiling.hpp"
#include "prx/libc/include/GuestAllocations.hpp"
#include "prx/libc/include/GuestArena.hpp"
#include "prx/libc/include/GuestWriteWatch.hpp"
#include "Recompiler.hpp"
#include "Optimization/ResourceProgram.hpp"
#include "VulkanTestDevice.hpp"
#ifdef _WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
#else
#include <sys/mman.h>
#endif
#include <array>
#include <algorithm>
#include <bit>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
#include <map>
#include <span>
#include <optional>
#include <string>
#include <string_view>
#include <vector>
namespace {
using AgcDriver::Graphics::ColorTargetLayout;
using AgcDriver::Graphics::ColorTileMode;
using AgcDriver::Graphics::Require;
using ShaderRecompiler::ShaderStage;
constexpr std::uint32_t Width = 256;
constexpr std::uint32_t Height = 128;
constexpr std::uint32_t ScissorWidth = 128;
constexpr std::size_t BlockBytes = 65536;
constexpr std::uint32_t Float11_11_10Info = 0x4171cu;
constexpr std::uint32_t TiledAttrib3 = 0x4dc6c000u;
constexpr std::uint32_t Float32Export = 9;
constexpr std::uint32_t DepthInput = 0x400u;
constexpr std::uint32_t LayerExport = (1u << 18u) | (1u << 21u);
alignas(256) constexpr std::array<std::uint32_t, 6> VertexCode{
0xe0382000, 0x80000005, 0xbf8c3f70, 0xf80008cf, 0x03020100, 0xbf810000,
};
alignas(256) constexpr std::array<std::uint32_t, 10> LayeredVertexCode{
0xe0382000, 0x80000005, 0xe030201c, 0x80000405, 0xbf8c3f70, 0xf80000cf, 0x03020100, 0xf80008d4, 0x00040000, 0xbf810000,
};
struct LayeredVertex {
std::array<float, 4> position;
std::array<float, 3> unused;
std::uint32_t layer;
};
constexpr std::array<std::array<float, 4>, 3> Triangle{{
{-1.0f, -1.0f, 0.5f, 1.0f}, {3.0f, -1.0f, 0.5f, 1.0f}, {-1.0f, 3.0f, 0.5f, 1.0f}
}};
alignas(256) std::array<std::array<std::uint32_t, 64>, 64> Programs{};
std::size_t programCount = 0;
std::uint32_t SmallFloat(float value, std::uint32_t mantissaBits) {
const std::uint32_t infinity = 0x1fu << mantissaBits;
if (std::isnan(value)) {
const auto top = (std::bit_cast<std::uint32_t>(value) & 0x7fffffu) >> (23u - mantissaBits);
return infinity | (top == 0u ? 1u : top);
}
if (!(value > 0.0f)) return 0;
if (std::isinf(value)) return infinity;
const double magnitude = value;
const double scale = std::ldexp(1.0, static_cast<int>(mantissaBits));
if (magnitude < std::ldexp(1.0, -14)) return static_cast<std::uint32_t>(std::floor(magnitude * std::ldexp(1.0, 14) * scale));
int exponent = 0;
const double fraction = std::frexp(magnitude, &exponent);
if (exponent - 1 > 15) return infinity - 1u;
return (static_cast<std::uint32_t>(exponent - 1 + 15) << mantissaBits) | static_cast<std::uint32_t>(std::floor((fraction * 2.0 - 1.0) * scale));
}
float Unpacked(std::uint32_t raw, std::uint32_t mantissaBits) {
const auto exponent = raw >> mantissaBits;
const auto mantissa = raw & ((1u << mantissaBits) - 1u);
Require(exponent != 0x1fu, "the test's stored words hold finite values");
if (exponent == 0u) return static_cast<float>(std::ldexp(static_cast<double>(mantissa), -14 - static_cast<int>(mantissaBits)));
return static_cast<float>(std::ldexp(1.0 + std::ldexp(static_cast<double>(mantissa), -static_cast<int>(mantissaBits)), static_cast<int>(exponent) - 15));
}
constexpr std::array<std::uint32_t, 3> FieldOffset{0u, 10u, 21u};
constexpr std::array<std::uint32_t, 3> FieldMantissa{5u, 6u, 6u};
float Factor(std::uint32_t code, float source, float destination, float sourceAlpha) {
switch (code) {
case 0: return 0.0f;
case 1: return 1.0f;
case 2: return source;
case 3: return 1.0f - source;
case 4: return sourceAlpha;
case 5: return 1.0f - sourceAlpha;
case 6: return 1.0f;
case 7: return 0.0f;
case 8: return destination;
case 9: return 1.0f - destination;
case 10: return std::fmin(sourceAlpha, 0.0f);
default: throw std::runtime_error("the test uses a blend factor the reference does not model");
}
}
float Term(std::uint32_t code, float value, float source, float destination, float sourceAlpha) {
if (code == 0u) return 0.0f;
if (code == 1u) return value;
return value * Factor(code, source, destination, sourceAlpha);
}
float BlendChannel(std::uint32_t control, float source, float destination, float sourceAlpha) {
const auto sourceFactor = control & 0x1fu;
const auto combine = (control >> 5u) & 7u;
const auto destinationFactor = (control >> 8u) & 0x1fu;
const auto s = Term(sourceFactor, source, source, destination, sourceAlpha);
const auto d = Term(destinationFactor, destination, source, destination, sourceAlpha);
switch (combine) {
case 0: return s + d;
case 1: return s - d;
case 2: return std::fmin(source, destination);
case 3: return std::fmax(source, destination);
case 4: return d - s;
default: throw std::runtime_error("the test uses a combine function the reference does not model");
}
}
std::uint32_t Blended(std::uint32_t control, std::uint32_t wordMask, std::array<float, 4> rgba, std::uint32_t stored) {
const std::array<float, 3> source{rgba[2], rgba[1], rgba[0]};
std::uint32_t word = 0;
for (std::uint32_t field = 0; field < 3; ++field) {
const auto destination = Unpacked((stored >> FieldOffset[field]) & ((1u << (FieldMantissa[field] + 5u)) - 1u), FieldMantissa[field]);
const auto value = control == 0u ? source[field] : BlendChannel(control, source[field], destination, rgba[3]);
word |= SmallFloat(value, FieldMantissa[field]) << FieldOffset[field];
}
return (stored & ~wordMask) | (word & wordMask);
}
std::span<const std::uint32_t> Program(const std::array<std::uint32_t, 4>& vgprs) {
Require(programCount < Programs.size(), "too many test programs");
auto& code = Programs[programCount++];
std::size_t at = 0;
for (std::uint32_t vgpr = 0; vgpr < 4u; ++vgpr) {
code[at++] = 0x7e0002ffu | ((4u + vgpr) << 17u);
code[at++] = vgprs[vgpr];
}
code[at++] = 0xf800180fu;
code[at++] = 0x07060504u;
code[at++] = 0xbf810000u;
return std::span<const std::uint32_t>(code.data(), at);
}
std::span<const std::uint32_t> Float32Program(std::array<float, 4> rgba) {
return Program({std::bit_cast<std::uint32_t>(rgba[0]), std::bit_cast<std::uint32_t>(rgba[1]), std::bit_cast<std::uint32_t>(rgba[2]), std::bit_cast<std::uint32_t>(rgba[3])});
}
std::span<const std::uint32_t> DepthAsRedProgram(std::array<float, 4> rgba) {
Require(programCount < Programs.size(), "too many test programs");
auto& code = Programs[programCount++];
std::size_t at = 0;
code[at++] = 0x7e080300u;
for (std::uint32_t vgpr = 1; vgpr < 4u; ++vgpr) {
code[at++] = 0x7e0002ffu | ((4u + vgpr) << 17u);
code[at++] = std::bit_cast<std::uint32_t>(rgba[vgpr]);
}
code[at++] = 0xf800180fu;
code[at++] = 0x07060504u;
code[at++] = 0xbf810000u;
return std::span<const std::uint32_t>(code.data(), at);
}
const std::array<std::array<float, 4>, 3>& TriangleAt(float z) {
static std::map<float, std::array<std::array<float, 4>, 3>> triangles;
return triangles.try_emplace(z, std::array<std::array<float, 4>, 3>{{{-1.0f, -1.0f, z, 1.0f}, {3.0f, -1.0f, z, 1.0f}, {-1.0f, 3.0f, z, 1.0f}}}).first->second;
}
struct Block {
explicit Block(std::size_t bytes) : bytes(bytes), watched(AgcDriver::GuestMemory::WriteWatched()) {
#ifdef _WIN32
if (watched) {
data = static_cast<std::uint8_t*>(GuestArena::GuestArenaAllocate_nid_postfix(bytes, BlockBytes));
GuestArena::GuestArenaCommit_nid_postfix(data, bytes, PAGE_READWRITE, bytes);
} else {
data = static_cast<std::uint8_t*>(VirtualAlloc(nullptr, bytes, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE));
}
#else
if (watched) {
void* raw = mmap(nullptr, bytes + BlockBytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
Require(raw != MAP_FAILED, "cannot map the color target");
const auto begin = reinterpret_cast<std::uintptr_t>(raw);
const auto aligned = (begin + BlockBytes - 1) & ~(static_cast<std::uintptr_t>(BlockBytes) - 1);
if (aligned != begin) munmap(raw, aligned - begin);
if (aligned + bytes != begin + bytes + BlockBytes) munmap(reinterpret_cast<void*>(aligned + bytes), begin + BlockBytes - aligned);
data = reinterpret_cast<std::uint8_t*>(aligned);
GuestWriteWatch::GuestWriteWatchRegister_nid_postfix(data, bytes);
} else {
data = static_cast<std::uint8_t*>(std::aligned_alloc(BlockBytes, bytes));
}
#endif
Require(data != nullptr, "cannot allocate the color target");
Require(!watched || AgcDriver::GuestMemory::Watched(Address(), bytes), "the color target is not write-watched");
GuestAllocations::Mutation mutation;
mutation.Add(data, bytes, true, true, true);
}
~Block() {
AgcDriver::Graphics::StorageTexture::FlushPending(Address(), bytes, nullptr, "test release");
{
GuestAllocations::Mutation mutation;
mutation.Remove(data);
}
#ifdef _WIN32
if (watched) {
GuestArena::GuestArenaReset_nid_postfix(data, bytes);
GuestArena::GuestArenaRelease_nid_postfix(data, bytes);
} else {
VirtualFree(data, 0, MEM_RELEASE);
}
#else
if (watched) {
munmap(data, bytes);
GuestWriteWatch::GuestWriteWatchUnregister_nid_postfix(data, bytes);
} else {
std::free(data);
}
#endif
}
Block(const Block&) = delete;
Block& operator=(const Block&) = delete;
std::uint64_t Address() const { return reinterpret_cast<std::uintptr_t>(data); }
std::size_t bytes;
bool watched;
std::uint8_t* data = nullptr;
};
AgcDriver::Graphics::ColorTarget DecodeTarget(const Block& block) {
AgcDriver::Registers cx;
cx[0x318] = static_cast<std::uint32_t>(block.Address() >> 8u);
cx[0x31b] = 0;
cx[0x31c] = Float11_11_10Info;
cx[0x31d] = 0;
cx[0x3b0] = ((Width - 1u) << 14u) | (Height - 1u);
cx[0x3b8] = TiledAttrib3;
cx[0x390] = static_cast<std::uint32_t>(block.Address() >> 40u);
auto color = AgcDriver::Graphics::DecodeColorBuffer(cx, 0);
Require(color.format == VK_FORMAT_R32_UINT && color.componentMapping == 0xc6u && color.packing == ShaderRecompiler::ColorExportPacking::Float11_11_10 && color.tileMode == ColorTileMode::RenderTarget && color.bytes == block.bytes, "the tiled 11_11_10 float target did not decode as a packed R32_UINT target");
return color;
}
struct DrawSetup {
std::uint32_t inputs = 0;
std::span<const std::array<float, 4>> vertices = Triangle;
std::span<const LayeredVertex> layered{};
VkExtent2D extent{Width, Height};
std::uint32_t scissorWidth = ScissorWidth;
std::optional<VkPipelineColorBlendAttachmentState> hostBlend{};
};
std::uint32_t Draw(AgcDriver::VulkanDevice& device, AgcDriver::Graphics::ColorTarget color, std::uint32_t blendControl, std::uint32_t exportedMask, std::span<const std::uint32_t> pixelCode, const DrawSetup& setup = {}) {
const auto target = device.Target();
constexpr std::uint32_t waveSize = 64;
std::vector<std::uint32_t> vertexUserData(4, 0u);
const bool layered = !setup.layered.empty();
const auto address = layered ? reinterpret_cast<std::uintptr_t>(setup.layered.data()) : reinterpret_cast<std::uintptr_t>(setup.vertices.data());
const auto vertexCount = static_cast<std::uint32_t>(layered ? setup.layered.size() : setup.vertices.size());
const std::uint32_t stride = layered ? sizeof(LayeredVertex) : 16u;
const auto vertexCode = layered ? std::span<const std::uint32_t>(LayeredVertexCode) : std::span<const std::uint32_t>(VertexCode);
const std::array<std::uint32_t, 4> vertexBuffer{static_cast<std::uint32_t>(address), static_cast<std::uint32_t>((address >> 32u) & 0xffffu) | (stride << 16u), vertexCount, 0x01016facu};
std::copy(vertexBuffer.begin(), vertexBuffer.end(), vertexUserData.begin());
ShaderRecompiler::ShaderVertexStageInfo vertexInfo{};
vertexInfo.paClVsOutCntl = layered ? LayerExport : 0u;
const std::array<ShaderRecompiler::MemoryRegion, 1> vertexMemory{{{reinterpret_cast<std::uintptr_t>(vertexCode.data()), std::as_bytes(vertexCode)}}};
ShaderRecompiler::RecompileRequest vertex{
{ShaderStage::Vertex, reinterpret_cast<std::uintptr_t>(vertexCode.data()), vertexCode, 0, {}},
{waveSize, 0, vertexUserData, std::nullopt, std::nullopt, vertexInfo, vertexMemory},
target,
{0, 0, 0, 64}
};
vertex.useCache = false;
const auto vertexResult = ShaderRecompiler::Recompile(vertex);
const auto vertexPush = static_cast<std::uint32_t>(vertexResult.pushConstants.size());
const bool merged = !setup.hostBlend && (blendControl != 0u || (exportedMask & 7u) != 7u);
color.mergeBlend = blendControl == 0u || !merged ? 0u : AgcDriver::Graphics::PackedBlendControl(blendControl);
color.partialWriteMask = merged ? AgcDriver::Graphics::PackedWriteMask(color.packing, color.componentMapping, exportedMask & 7u) : 0u;
AgcDriver::Graphics::State state{};
state.stages = {AgcDriver::Graphics::ShaderPath::Vertex, 0u, waveSize, waveSize, std::nullopt, std::nullopt};
state.colors = {color};
state.color = color;
state.hasColorTarget = true;
state.renderExtent = setup.extent;
state.renderLayers = color.layers;
state.layerExports = layered ? LayerExport : 0u;
state.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
state.viewport = {0, static_cast<float>(setup.extent.height), static_cast<float>(setup.extent.width), -static_cast<float>(setup.extent.height), 0, 1};
state.negativeOneToOne = false;
state.scissor = {{0, 0}, {setup.scissorWidth, setup.extent.height}};
state.cullMode = VK_CULL_MODE_NONE;
state.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
VkPipelineColorBlendAttachmentState blend = setup.hostBlend.value_or(VkPipelineColorBlendAttachmentState{});
blend.colorWriteMask = merged ? 0u : VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT;
state.blends = {blend};
state.blend = blend;
state.blendConstants = {};
const auto codeAddress = reinterpret_cast<std::uintptr_t>(pixelCode.data());
const AgcDriver::Registers context{{0x1b6, 0x8000}, {0x1b3, setup.inputs}, {0x1b4, setup.inputs}, {0x203, 0}, {0x1c5, Float32Export}};
const std::array<ShaderRecompiler::MemoryRegion, 1> pixelMemory{{{codeAddress, std::as_bytes(pixelCode)}}};
ShaderRecompiler::RecompileRequest fragment{
{ShaderStage::Fragment, codeAddress, pixelCode, 0, {}},
{waveSize, 0, {}, std::nullopt, AgcDriver::Graphics::DecodePixelStageInfo(context, {}), std::nullopt, pixelMemory},
target,
PixelPushLayout(vertexPush, target)
};
const auto handle = ShaderRecompiler::PrepareShader(fragment);
AgcDriver::DriverDetail::ShaderSnapshot snapshot{codeAddress, 0, 1, {pixelCode.begin(), pixelCode.end()}, {}};
snapshot.prepared->entries.push_back({0, handle});
fragment.shader.code = snapshot.code;
fragment.context.pixel = AgcDriver::Graphics::DecodePixelStageInfo(context, AgcDriver::Graphics::ExportMappings(state));
fragment.context.pixel->targetExportPacking = AgcDriver::Graphics::ExportPackings(state);
fragment.context.pixel->targetMerges = AgcDriver::Graphics::ExportTargetMerges(state);
fragment.context.pixel->layerExported = layered;
const auto& merges = fragment.context.pixel->targetMerges;
const auto merge = merges.empty() ? ShaderRecompiler::TargetMerge{} : merges.front();
Require(merges.size() == (merged ? 1u : 0u) && merge.mask == color.partialWriteMask && merge.blendControl == color.mergeBlend && (!merged || merge.packing == ShaderRecompiler::ColorExportPacking::Float11_11_10), "the draw's target merge disagrees with its blend and write mask");
Require(!merged || (merge.layered == (color.arrayLastSlice != 0u) && merge.firstSlice == (merge.layered ? color.arraySlice : 0u) && merge.lastSlice == (merge.layered ? color.arraySlice + color.layers - 1u : 0u)), "the draw's target merge does not address the target's array from its first slice");
const ShaderRecompiler::SrtRuntime runtime{};
const auto invocation = AgcDriver::DriverDetail::InvocationFor(snapshot, 0, fragment);
const auto pixelResult = invocation.Materialize(*invocation.Capture(runtime));
const bool registered = pixelResult->variantId == ShaderRecompiler::GetPreparedArtifact(*handle).variantId;
Require(registered != merged, merged ? "the blending draw reused the registered pixel shader" : "the plain write did not use the registered pixel shader");
const std::array<AgcDriver::Graphics::CompiledShader, 2> shaders{{
{ShaderStage::Vertex, &vertexResult, 0},
{ShaderStage::Fragment, pixelResult.get(), PixelPushOffset(vertexPush, target)}
}};
const AgcDriver::Pm4::DrawParameters draw{0, vertexCount, 0, 1, 0, false};
device.Draw(state, draw, shaders);
return color.partialWriteMask;
}
std::vector<std::uint32_t> ReadBack(AgcDriver::VulkanDevice& device, const Block& block) {
AgcDriver::Graphics::StorageTexture::FlushPending(block.Address(), block.bytes, nullptr, "test read-back");
device.WaitIdle();
std::vector<std::uint32_t> stored(block.bytes / 4u);
AgcDriver::GuestMemory::Read(block.Address(), std::as_writable_bytes(std::span(stored)), 1);
return stored;
}
std::vector<std::uint32_t> Fill(Block& block, std::uint32_t seed) {
std::vector<std::uint32_t> words(block.bytes / 4u);
for (std::size_t index = 0; index < words.size(); ++index) {
const auto hash = static_cast<std::uint32_t>((index + seed) * 0x9e3779b9u);
const auto field = [&](std::uint32_t shift, std::uint32_t mantissaBits) { return ((11u + ((hash >> shift) % 8u)) << mantissaBits) | ((hash >> (shift + 3u)) & ((1u << mantissaBits) - 1u)); };
words[index] = field(0u, 5u) | (field(8u, 6u) << 10u) | (field(17u, 6u) << 21u);
}
std::memcpy(block.data, words.data(), block.bytes);
return words;
}
void ExpectWords(AgcDriver::VulkanDevice& device, const Block& block, const ColorTargetLayout& layout, const std::vector<std::uint32_t>& expected, const std::vector<std::uint32_t>& before, const std::string& what) {
const auto stored = ReadBack(device, block);
for (std::uint32_t y = 0; y < Height; ++y) {
for (std::uint32_t x = 0; x < Width; ++x) {
const auto index = layout.Offset(x, y) / 4u;
if (stored[index] == expected[index]) continue;
char detail[192];
std::snprintf(detail, sizeof(detail), ": pixel (%u, %u) holds 0x%08x, expected 0x%08x (it held 0x%08x)", x, y, stored[index], expected[index], before[index]);
throw std::runtime_error(what + detail);
}
}
}
void ApplyInside(const ColorTargetLayout& layout, std::vector<std::uint32_t>& words, std::uint32_t control, std::uint32_t wordMask, std::array<float, 4> rgba) {
for (std::uint32_t y = 0; y < Height; ++y) {
for (std::uint32_t x = 0; x < ScissorWidth; ++x) {
auto& word = words[layout.Offset(x, y) / 4u];
word = Blended(control, wordMask, rgba, word);
}
}
}
struct Case {
std::uint32_t control;
std::uint32_t mask;
std::array<float, 4> rgba;
const char* name;
};
std::string Describe(const Case& draw) {
char text[192];
std::snprintf(text, sizeof(text), "%s (CB_BLEND_CONTROL 0x%08x, CB_TARGET_MASK 0x%x) of (%.9g, %.9g, %.9g, %.9g)", draw.name, draw.control, draw.mask, draw.rgba[0], draw.rgba[1], draw.rgba[2], draw.rgba[3]);
return text;
}
void Sequence(AgcDriver::VulkanDevice& device, Block& block, const ColorTargetLayout& layout, const AgcDriver::Graphics::ColorTarget& color, std::span<const Case> draws, std::uint32_t seed, const std::string& what) {
const auto before = Fill(block, seed);
auto expected = before;
for (const auto& draw : draws) {
const auto wordMask = Draw(device, color, draw.control, draw.mask, Float32Program(draw.rgba));
ApplyInside(layout, expected, draw.control, wordMask == 0u ? 0xffffffffu : wordMask, draw.rgba);
}
ExpectWords(device, block, layout, expected, before, what);
}
void SameDrawOverdraw(AgcDriver::VulkanDevice& device, Block& block, const ColorTargetLayout& layout, const AgcDriver::Graphics::ColorTarget& color, float first, float last, std::uint32_t seed) {
constexpr std::uint32_t Layers = 16;
constexpr std::uint32_t SourceOver = 0x65040504u;
const std::array<float, 4> constant{0.0f, 0.75f, 1.5f, 0.5f};
static std::map<float, std::vector<std::array<float, 4>>> stacks;
auto& vertices = stacks[last];
std::vector<float> order;
for (std::uint32_t layer = 0; layer < Layers; ++layer) {
const auto z = layer % 2u == 0u ? first : last;
const auto& triangle = TriangleAt(z);
vertices.insert(vertices.end(), triangle.begin(), triangle.end());
order.push_back(z);
}
const auto before = Fill(block, seed);
auto expected = before;
for (const auto z : order) ApplyInside(layout, expected, SourceOver, 0xffffffffu, {z, constant[1], constant[2], constant[3]});
Draw(device, color, SourceOver, 0xfu, DepthAsRedProgram(constant), {DepthInput, vertices});
char what[192];
std::snprintf(what, sizeof(what), "one source-over draw of %u full-screen triangles alternating z %.2f and %.2f, z blended into red in primitive order", Layers, first, last);
ExpectWords(device, block, layout, expected, before, what);
}
constexpr std::uint32_t Float10_11_11Info = 0x40718u;
AgcDriver::Graphics::ColorTarget DecodeBenchTarget(const Block& block, std::uint32_t info, std::uint32_t side) {
AgcDriver::Registers cx;
cx[0x318] = static_cast<std::uint32_t>(block.Address() >> 8u);
cx[0x31b] = 0;
cx[0x31c] = info;
cx[0x31d] = 0;
cx[0x3b0] = ((side - 1u) << 14u) | (side - 1u);
cx[0x3b8] = TiledAttrib3;
cx[0x390] = static_cast<std::uint32_t>(block.Address() >> 40u);
return AgcDriver::Graphics::DecodeColorBuffer(cx, 0);
}
struct Timed {
double gpuMs;
double wallMs;
};
template <typename Work> Timed TimeOnGpu(AgcDriver::VulkanDevice& device, Work&& work) {
auto* recorder = AgcDriver::Graphics::Recorder::Active();
Require(recorder != nullptr && AgcDriver::Graphics::Recorder::BatchStampsEnabled(), "the overdraw benchmark needs the device's recorder with batch timestamps (APS5_PROFILE_GPU)");
device.WaitIdle();
const auto before = recorder->NewestSubmitted();
const auto start = std::chrono::steady_clock::now();
work();
device.WaitIdle();
const auto wall = std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - start).count();
std::size_t missing = 0;
const auto batches = recorder->CompletedBatches(before, recorder->NewestSubmitted(), missing);
Require(missing == 0 && !batches.empty(), "the overdraw benchmark lost a batch's timestamps");
double gpu = 0;
for (const auto& batch : batches) {
Require(batch.gpuEndNs >= batch.gpuStartNs && batch.gpuEndNs > 0, "a benchmark batch has no GPU timestamps");
gpu += (batch.gpuEndNs - batch.gpuStartNs) / 1.0e6;
}
return {gpu, wall};
}
double Median(std::vector<double> values) {
std::sort(values.begin(), values.end());
return values[values.size() / 2u];
}
int OverdrawBenchmark() {
#ifdef _WIN32
_putenv("APS5_PROFILE_GPU=1");
#else
setenv("APS5_PROFILE_GPU", "1", 1);
#endif
const auto device = OpenVulkanTestDevice();
if (!device) return VulkanTestSkipped;
if (!TargetHasCapability(device->Target(), spv::CapabilityFragmentShaderPixelInterlockEXT)) {
std::puts("skipped, the device lacks fragmentShaderPixelInterlock");
return VulkanTestSkipped;
}
constexpr std::uint32_t Side = 2048;
constexpr std::uint32_t Layers = 64;
constexpr std::uint32_t Rounds = 9;
constexpr std::uint32_t PremultipliedOver = 0x40000501u;
const ColorTargetLayout layout(Side, Side, ColorTileMode::RenderTarget, 4);
Block mergedBlock(layout.Bytes());
Block hostBlock(layout.Bytes());
const auto merged = DecodeBenchTarget(mergedBlock, Float11_11_10Info, Side);
const auto host = DecodeBenchTarget(hostBlock, Float10_11_11Info, Side);
Require(merged.packing == ShaderRecompiler::ColorExportPacking::Float11_11_10 && merged.format == VK_FORMAT_R32_UINT, "the 11_11_10 float benchmark target did not decode as a packed R32_UINT target");
Require(host.packing == ShaderRecompiler::ColorExportPacking::None && host.format == VK_FORMAT_B10G11R11_UFLOAT_PACK32, "the 10_11_11 float benchmark target did not decode as a B10G11R11 target");
VkPipelineColorBlendAttachmentState over{};
over.blendEnable = VK_TRUE;
over.srcColorBlendFactor = VK_BLEND_FACTOR_ONE;
over.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
over.colorBlendOp = VK_BLEND_OP_ADD;
over.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
over.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
over.alphaBlendOp = VK_BLEND_OP_ADD;
const auto program = Float32Program({0.25f, 0.5f, 0.125f, 0.5f});
std::vector<std::array<float, 4>> one(Triangle.begin(), Triangle.end());
std::vector<std::array<float, 4>> stack;
for (std::uint32_t layer = 0; layer < Layers; ++layer) stack.insert(stack.end(), Triangle.begin(), Triangle.end());
struct Path {
const char* name;
AgcDriver::Graphics::ColorTarget color;
std::optional<VkPipelineColorBlendAttachmentState> hostBlend;
std::vector<double> oneGpu, stackGpu, stackWall;
};
std::array<Path, 2> paths{{
{"11_11_10 float through the interlocked merge", merged, std::nullopt, {}, {}, {}},
{"10_11_11 float blended by the host", host, over, {}, {}, {}},
}};
for (std::uint32_t round = 0; round <= Rounds; ++round) {
for (auto& path : paths) {
const DrawSetup single{0, one, {}, {Side, Side}, Side, path.hostBlend};
const DrawSetup layered{0, stack, {}, {Side, Side}, Side, path.hostBlend};
const auto first = TimeOnGpu(*device, [&] { Draw(*device, path.color, PremultipliedOver, 0xfu, program, single); });
const auto all = TimeOnGpu(*device, [&] { Draw(*device, path.color, PremultipliedOver, 0xfu, program, layered); });
if (round == 0) continue;
path.oneGpu.push_back(first.gpuMs);
path.stackGpu.push_back(all.gpuMs);
path.stackWall.push_back(all.wallMs);
}
}
std::printf("overdraw benchmark: one draw of N full-target triangles, premultiplied source-over (CB_BLEND_CONTROL 0x%08x), %ux%u tiled target, median GPU time of %u rounds from the recorder's batch timestamps\n", PremultipliedOver, Side, Side, Rounds);
double perLayer[2]{};
for (std::size_t index = 0; index < paths.size(); ++index) {
const auto& path = paths[index];
const auto oneMs = Median(path.oneGpu);
const auto stackMs = Median(path.stackGpu);
perLayer[index] = (stackMs - oneMs) / (Layers - 1u);
std::printf(" %s: N=1 %.3f ms, N=%u %.3f ms (wall %.3f ms), %.4f ms per full-target layer (%.2f Gpixel/s)\n", path.name, oneMs, Layers, stackMs, Median(path.stackWall), perLayer[index], static_cast<double>(Side) * Side / (perLayer[index] * 1.0e6));
}
std::printf(" the merge takes %.2fx the host blend's time per layer\n", perLayer[0] / perLayer[1]);
return 0;
}
struct ArrayShape {
std::uint32_t side;
std::uint32_t mips;
std::uint32_t slices;
};
std::size_t ArrayBytes(const ArrayShape& shape) {
return static_cast<std::size_t>(AgcDriver::Graphics::ComputeSurfaceSize(AgcDriver::Graphics::ComputeElementMipLayout(AgcDriver::Graphics::TextureTileMode::kR64KBX, 4u, shape.side, shape.side, shape.mips), shape.slices));
}
AgcDriver::Graphics::ColorTarget DecodeArrayTarget(const Block& block, const ArrayShape& shape, std::uint32_t mip, std::uint32_t first, std::uint32_t layers) {
AgcDriver::Registers cx;
cx[0x318] = static_cast<std::uint32_t>(block.Address() >> 8u);
cx[0x31b] = first | ((first + layers - 1u) << 13u) | (mip << 26u);
cx[0x31c] = Float11_11_10Info;
cx[0x31d] = 0;
cx[0x3b0] = ((shape.mips - 1u) << 28u) | ((shape.side - 1u) << 14u) | (shape.side - 1u);
cx[0x3b8] = (TiledAttrib3 & ~0x1fffu) | (shape.slices - 1u);
cx[0x390] = static_cast<std::uint32_t>(block.Address() >> 40u);
cx[0x207] = LayerExport;
auto color = AgcDriver::Graphics::DecodeColorBuffer(cx, 0);
Require(color.packing == ShaderRecompiler::ColorExportPacking::Float11_11_10 && color.tileMode == ColorTileMode::RenderTarget && color.mip == mip && color.mipCount == shape.mips && color.arraySlice == first && color.layers == layers && color.arrayLastSlice == shape.slices - 1u && color.arrayAddress == block.Address(), "the 11_11_10 float array view did not decode as mip " + std::to_string(mip) + " of slices " + std::to_string(first) + " to " + std::to_string(first + layers - 1u));
return color;
}
void ArrayBlend(AgcDriver::VulkanDevice& device, Block& block, const ArrayShape& shape, std::uint32_t mip, std::uint32_t first, std::uint32_t layers, bool exportsLayer, const Case& draw, std::uint32_t seed, const std::string& what) {
const auto color = DecodeArrayTarget(block, shape, mip, first, layers);
const auto surface = AgcDriver::Graphics::ArraySurfaceForTarget(color);
const auto geometry = AgcDriver::Graphics::DescribeSurface(surface);
const auto& level = geometry.mips.at(mip);
const auto covered = AgcDriver::Graphics::CoveredMipBytes(surface.tileMode, 4u, level);
std::uint64_t coveredBytes = 0;
for (const auto& [begin, end] : covered) coveredBytes += end - begin;
Require(!level.tail && coveredBytes == 4ull * level.width * level.height && geometry.layers == shape.slices, what + ": the drawn mip is not whole tile blocks of its texels");
static std::map<std::uint32_t, std::vector<LayeredVertex>> stacks;
auto& vertices = stacks[seed];
if (exportsLayer) {
for (std::uint32_t layer = 0; layer < layers; ++layer) {
for (const auto& corner : Triangle) vertices.push_back({corner, {}, layer});
}
}
const auto before = Fill(block, seed);
auto expected = before;
const auto wordMask = Draw(device, color, draw.control, draw.mask, Float32Program(draw.rgba), {0u, Triangle, vertices, {level.width, level.height}, level.width});
for (std::uint32_t slice = first; slice < first + layers; ++slice) {
for (const auto& [begin, end] : covered) {
for (auto offset = begin; offset < end; offset += 4u) {
auto& word = expected[(geometry.GuestLayerOffset(slice) + level.tiledOffset + offset) / 4u];
word = Blended(draw.control, wordMask == 0u ? 0xffffffffu : wordMask, draw.rgba, word);
}
}
}
const auto stored = ReadBack(device, block);
for (std::size_t index = 0; index < stored.size(); ++index) {
if (stored[index] == expected[index]) continue;
const auto slice = static_cast<std::uint32_t>(index * 4u / geometry.layerBytes);
char detail[192];
std::snprintf(detail, sizeof(detail), ": word %zu (slice %u, byte 0x%llx of the slice) holds 0x%08x, expected 0x%08x (it held 0x%08x)", index, slice, static_cast<unsigned long long>(index * 4u - geometry.GuestLayerOffset(slice)), stored[index], expected[index], before[index]);
throw std::runtime_error(what + detail);
}
}
}
int main(int argc, char** argv) {
try {
if (argc == 2 && std::string_view(argv[1]) == "--benchmark-overdraw") return OverdrawBenchmark();
const auto device = OpenVulkanTestDevice();
if (!device) return VulkanTestSkipped;
if (!TargetHasCapability(device->Target(), spv::CapabilityFragmentShaderPixelInterlockEXT)) {
std::puts("skipped, the device lacks fragmentShaderPixelInterlock");
return VulkanTestSkipped;
}
const ColorTargetLayout layout(Width, Height, ColorTileMode::RenderTarget, 4);
Block block(layout.Bytes());
const auto color = DecodeTarget(block);
Require(AgcDriver::Graphics::PackedWriteMask(color.packing, color.componentMapping, 1u) == 0xffe00000u && AgcDriver::Graphics::PackedWriteMask(color.packing, color.componentMapping, 4u) == 0x000003ffu && AgcDriver::Graphics::PackedWriteMask(color.packing, color.componentMapping, 7u) == 0xffffffffu, "the export components did not map to the guest fields (red in 31..21, blue in 9..0)");
const std::array<Case, 11> cases{{
{0x65040504u, 0xfu, {1.0f, 0.5f, 0.25f, 0.25f}, "a source-over blend"},
{0x60010101u, 0xfu, {0.5f, 0.75f, 2.0f, 1.0f}, "an additive blend"},
{0x40000121u, 0xfu, {4.0f, 0.125f, 0.0f, 1.0f}, "a subtracting blend"},
{0x40000181u, 0xfu, {0.25f, 0.5f, 8.0f, 1.0f}, "a reverse-subtracting blend"},
{0x40000141u, 0xfu, {0.5f, 1.0f, 2.0f, 1.0f}, "a MIN blend"},
{0x40000161u, 0xfu, {0.5f, 1.0f, 2.0f, 1.0f}, "a MAX blend"},
{0x40000008u, 0xfu, {0.5f, 2.0f, 0.75f, 1.0f}, "a multiplying blend (DST_COLOR, ZERO)"},
{0x40000109u, 0xfu, {0.5f, 0.25f, 0.75f, 1.0f}, "a screen blend (ONE_MINUS_DST_COLOR, ONE)"},
{0x40000302u, 0xfu, {0.5f, 0.75f, 0.25f, 1.0f}, "a SRC_COLOR, ONE_MINUS_SRC_COLOR blend"},
{0x40000706u, 0xfu, {0.5f, 0.75f, 0.25f, 1.0f}, "a DST_ALPHA, ONE_MINUS_DST_ALPHA blend into the alpha-less target"},
{0x4000010au, 0xfu, {0.5f, 0.75f, 0.25f, 0.5f}, "a SRC_ALPHA_SATURATE, ONE blend into the alpha-less target"},
}};
for (std::size_t index = 0; index < cases.size(); ++index) {
const std::array<Case, 1> one{cases[index]};
Sequence(*device, block, layout, color, one, static_cast<std::uint32_t>(index), Describe(cases[index]) + " into a tiled 11_11_10 float target");
}
const std::array<Case, 2> partials{{
{0x65040504u, 0x1u, {2.0f, 0.5f, 0.25f, 0.5f}, "a source-over blend of red alone"},
{0x00000000u, 0x6u, {0.0f, 0.625f, 3.0f, 1.0f}, "a plain write of green and blue alone"},
}};
for (std::size_t index = 0; index < partials.size(); ++index) {
const std::array<Case, 1> one{partials[index]};
Sequence(*device, block, layout, color, one, 40u + static_cast<std::uint32_t>(index), Describe(partials[index]) + " into a tiled 11_11_10 float target");
}
const std::array<Case, 4> chain{{cases[0], {0x00000000u, 0xfu, {0.5f, 0.5f, 0.5f, 1.0f}, "a plain write"}, cases[1], cases[2]}};
Sequence(*device, block, layout, color, chain, 60u, "a source-over blend, a plain write, an additive and a subtracting blend drawn back to back");
SameDrawOverdraw(*device, block, layout, color, 0.25f, 0.75f, 70u);
SameDrawOverdraw(*device, block, layout, color, 0.75f, 0.25f, 71u);
if (!TargetHasCapability(device->Target(), spv::CapabilityGeometry) && !TargetHasCapability(device->Target(), spv::CapabilityShaderViewportIndexLayerEXT)) {
std::puts("layered 11_11_10 float blend tests skipped, the device cannot read gl_Layer in a pixel shader");
return 0;
}
constexpr ArrayShape cube{128u, 8u, 6u};
constexpr ArrayShape array{256u, 2u, 4u};
Block cubeBlock(ArrayBytes(cube));
Block arrayBlock(ArrayBytes(array));
ArrayBlend(*device, cubeBlock, cube, 0u, 0u, 6u, true, cases[0], 80u, Describe(cases[0]) + " into mip 0 of all 6 slices of a 128x128 11_11_10 float array of 8 mips, one layer per slice");
ArrayBlend(*device, arrayBlock, array, 1u, 1u, 3u, true, cases[1], 81u, Describe(cases[1]) + " into mip 1 of slices 1 to 3 of a 256x256 11_11_10 float array of 2 mips and 4 slices, one layer per slice");
ArrayBlend(*device, cubeBlock, cube, 0u, 2u, 1u, false, partials[1], 82u, Describe(partials[1]) + " into mip 0 of slice 2 alone of a 128x128 11_11_10 float array of 8 mips, no layer exported");
std::printf("11_11_10 float blend tests passed: %zu single blends, %zu partial writes, a back-to-back chain and 2 same-draw overdraws of 16 layers into a %ux%u tiled target, the unscissored pixels kept, and 3 merges into mips and slices of 2D arrays\n", cases.size(), partials.size(), Width, Height);
return 0;
} catch (const std::exception& error) {
std::cerr << error.what() << '\n';
return 1;
}
}
@@ -1,5 +1,7 @@
#include "prx/libSceAgcDriver/Execution/include/GuestMemory.hpp"
#include "prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp"
#include "prx/libSceAgcDriver/Graphics/include/Draw.hpp"
#include "prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hpp"
#include "prx/libSceAgcDriver/Graphics/include/Recorder.hpp"
#include "DepthFastClearHarness.hpp"
#include "VulkanTestDevice.hpp"
@@ -9,6 +11,7 @@
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <mutex>
#include <span>
#include <stdexcept>
@@ -34,11 +37,29 @@ using ShaderRecompiler::ShaderStage;
constexpr std::uint32_t Samples = 4;
alignas(4096) std::array<std::byte, Width * Height * 4 * Samples> ColorA{};
alignas(4096) std::array<std::byte, Width * Height * 4 * Samples> ColorB{};
alignas(4096) std::array<float, Width * Height> DepthA{};
alignas(4096) std::array<float, Width * Height> DepthB{};
alignas(4096) std::array<float, Width * Height> DepthC{};
constexpr std::size_t SurfaceBytes = 65536;
class Surface {
public:
std::span<std::byte> Bytes() {
void* pointer = storage.data();
std::size_t space = storage.size();
auto* aligned = static_cast<std::byte*>(std::align(SurfaceBytes, SurfaceBytes, pointer, space));
Require(aligned != nullptr, "pass break reasons: cannot align the surface backing");
return {aligned, SurfaceBytes};
}
std::uint64_t Address() { return reinterpret_cast<std::uintptr_t>(Bytes().data()); }
private:
std::array<std::byte, SurfaceBytes * 2> storage{};
};
Surface ColorA{};
Surface ColorB{};
Surface DepthA{};
Surface DepthB{};
Surface DepthC{};
struct Counts {
DrawPassCounts passes;
@@ -69,16 +90,19 @@ void ExpectBreak(const Counts& before, const Counts& after, PassBreak reason, co
}
}
void Draw(const Context& context, AgcDriver::VulkanDevice& device, const Shaders& compiled, std::span<std::byte> color, std::uint64_t depth) {
void Draw(const Context& context, AgcDriver::VulkanDevice& device, const Shaders& compiled, Surface& color, std::uint64_t depth) {
const std::array<CompiledShader, 2> shaders{{
{ShaderStage::Vertex, &compiled.vertex, 0},
{ShaderStage::Fragment, &compiled.pixel, PixelPushOffset(compiled.vertexPush, device.Target())}
}};
State state{};
state.stages = {ShaderPath::Vertex, 0u, 32u, 32u, std::nullopt, std::nullopt};
state.color = {reinterpret_cast<std::uintptr_t>(color.data()), {Width, Height}, VK_FORMAT_R8G8B8A8_UNORM, color.size(), 0xe4u};
state.color = {color.Address(), {Width, Height}, VK_FORMAT_R8G8B8A8_UNORM, color.Bytes().size(), 0xe4u};
state.color.surfaceAddress = state.color.address;
state.color.surfaceExtent = state.color.extent;
state.color.tileMode = ColorTileMode::RenderTarget;
state.color.samples = Samples;
Expect(MultisampledColorBytes(state.color) == color.Bytes().size(), "the color backing differs from its multisample footprint");
state.colors = {state.color};
state.hasColorTarget = true;
state.depth = DepthTarget{depth, 0, {Width, Height}, VK_FORMAT_D32_SFLOAT, 1.0f, 0, 0, false, Samples};
@@ -121,9 +145,10 @@ int main() {
std::lock_guard gpu(AgcDriver::GuestMemory::GpuMutex());
Recorder recorder(context);
recorder.Activate();
const auto depthA = reinterpret_cast<std::uintptr_t>(DepthA.data());
const auto depthB = reinterpret_cast<std::uintptr_t>(DepthB.data());
const auto depthC = reinterpret_cast<std::uintptr_t>(DepthC.data());
Expect(MultisampledDepthBytes_nid_no_patch({Width, Height}, sizeof(float), Samples) == DepthA.Bytes().size(), "the depth backing differs from its multisample footprint");
const auto depthA = DepthA.Address();
const auto depthB = DepthB.Address();
const auto depthC = DepthC.Address();
auto before = Snapshot();
Draw(context, *device, shaders, ColorA, depthA);
auto after = Snapshot();
@@ -209,6 +209,7 @@ void Draw(AgcDriver::VulkanDevice& device, GuestBuffer& pixels, GuestBuffer& ver
{ShaderStage::Fragment, &pixelResult, PixelPushOffset(vertexPush, target)}
}};
std::lock_guard gpu(AgcDriver::GuestMemory::GpuMutex());
AgcDriver::Graphics::State state{};
state.stages = {AgcDriver::Graphics::ShaderPath::Vertex, 0u, 64u, 64u, std::nullopt, std::nullopt};
state.color = {AddressOf(pixels.Data()), {Width, Height}, VK_FORMAT_R8G8B8A8_UNORM, TargetLayout.Bytes(), 0xe4u, ColorTileMode::RenderTarget};
@@ -286,6 +286,12 @@ void ResidentTests(AgcDriver::VulkanDevice& device) {
Require(again.rebuilds == steady.rebuilds && again.heapBytes == steady.heapBytes, "resident heap mirror: an unchanged dispatch rebuilt or grew the heap mirrors");
CheckReads(output, "unchanged dispatch", true);
CheckStores(written, "unchanged dispatch");
const auto settled = AgcDriver::Graphics::MirrorCounters();
AgcDriver::GuestMemory::MarkWritten(read.Address() + 8, 16);
Dispatch(device, read, written, output);
Require(AgcDriver::Graphics::MirrorCounters().blocksCopied == settled.blocksCopied, "resident heap mirror: a block stamped without a byte change was copied into its mirror again");
CheckReads(output, "a stamped block that did not change", true);
CheckStores(written, "a stamped block that did not change");
}
void StagingChunkTests(AgcDriver::VulkanDevice& device) {
@@ -3,6 +3,8 @@
#include "prx/libSceAgcDriver/Execution/include/VulkanDevice.hpp"
#include "prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hpp"
#include "prx/libSceAgcDriver/Graphics/include/ColorTargetLayout.hpp"
#include "prx/libSceAgcDriver/Graphics/include/BufferPool.hpp"
#include "prx/libSceAgcDriver/Graphics/include/Recorder.hpp"
#include "prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp"
#include "prx/libSceAgcDriver/Graphics/include/Draw.hpp"
#include "prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp"
@@ -29,6 +31,7 @@
#endif
#include <algorithm>
#include <array>
#include <atomic>
#include <bit>
#include <cmath>
#include <cstdint>
@@ -754,8 +757,10 @@ void CheckOverwrittenTarget(AgcDriver::VulkanDevice& device) {
std::memset(reused.data + colorBytes / 2u, 0x5a, 256u);
AgcDriver::Graphics::RequireNoMultisampleTarget(written, 256u, "a read of target memory the title wrote over");
AgcDriver::Graphics::RequireNoMultisampleTarget(reused.Address(), 64u, "a read of the rest of a target the title wrote over");
const std::vector<std::uint8_t> guest(reused.data, reused.data + reused.bytes);
Draw(device, state);
device.WaitIdle();
Require(std::equal(guest.begin(), guest.end(), reused.data), "a fresh draw after a partial guest overwrite changed guest color memory");
refusal.clear();
try {
AgcDriver::Graphics::RequireNoMultisampleTarget(written, 256u, "a read of a target drawn again over memory the title wrote");
@@ -811,6 +816,7 @@ void CheckClaimedTargets(AgcDriver::VulkanDevice& device) {
Draw(device, TargetState(DecodeTarget(reused.Address(), 0u)));
device.WaitIdle();
Require(!Refused(reused.Address(), 0x1000u, "a read of a 2x target that a single-sample color target was drawn over"), "a 2x target that a single-sample color target was drawn over is still guarded");
AgcDriver::GuestMemory::FlushGpuWrites(reused.Address(), reused.bytes);
}
{
Block reused(2u * BlockBytes);
@@ -819,10 +825,12 @@ void CheckClaimedTargets(AgcDriver::VulkanDevice& device) {
Require(AgcDriver::Graphics::MultisampledColorBytes(wide.color) == 2u * BlockBytes && AgcDriver::Graphics::MultisampledColorBytes(narrow.color) == BlockBytes, "the 2x target does not span the 4x target and one more block");
Draw(device, wide);
device.WaitIdle();
Draw(device, narrow);
device.WaitIdle();
Require(!Refused(reused.Address() + BlockBytes, 0x1000u, "a read of the part of a 2x target that a 4x target drawn over it does not cover"), "a 2x target that a 4x target was drawn over is still guarded");
Require(Refused(reused.Address(), 0x1000u, "a read of a 4x target drawn over a 2x target"), "a 4x target drawn over a 2x target is not guarded");
std::string refusal;
try { Draw(device, narrow); }
catch (const std::runtime_error& error) { refusal = error.what(); }
Require(refusal.find("overlap another native owner") != std::string::npos, "an incompatible target shape did not refuse unpublished native samples");
Require(Refused(reused.Address() + BlockBytes, 0x1000u, "a read after a refused narrower target"), "a refused narrower target retired the original owner's tail");
Require(Refused(reused.Address(), 0x1000u, "a read of the original target after a refused replacement"), "a refused narrower target retired the original owner");
}
if (context.storageImageMultisample) {
Block color(BlockBytes);
@@ -953,6 +961,356 @@ void RequireRefused(AgcDriver::VulkanDevice& device, const std::array<std::uint3
Require(refusal.find(expected) != std::string::npos, what + " was not refused: " + refusal);
}
std::vector<std::array<float, 4>> StoreInitial(const Block& block, std::uint32_t fragments, std::uint32_t pipeBankXor, bool uniform) {
using namespace AgcDriver::Graphics;
const MultisampleTextureLayout layout(TextureTileMode::kR64KBX, 8u, fragments, Side, Side, 1u, pipeBankXor);
Require(layout.Bytes() <= block.bytes, "the initial color footprint exceeds its allocation");
StoreWords(block, block.bytes, 0x38003800u);
std::vector<std::byte> linear(static_cast<std::size_t>(layout.LinearBytes()));
std::vector<std::array<float, 4>> expected(Side * Side * fragments);
for (std::uint32_t index = 0; index < expected.size(); ++index) {
const auto sample = index % fragments;
const auto pixel = index / fragments;
const bool ones = uniform || ((pixel % Side) * 3u + (pixel / Side) * 5u + sample * 7u) % 2u == 0u;
const std::array<std::uint16_t, 4> bits = ones ? std::array<std::uint16_t, 4>{0x3c00u, 0x3c00u, 0x3c00u, 0x3c00u} : std::array<std::uint16_t, 4>{0x3a00u, 0x3400u, 0x3800u, 0x3c00u};
std::memcpy(linear.data() + index * sizeof(bits), bits.data(), sizeof(bits));
expected[index] = ones ? Ones : Written;
}
layout.Tile(linear, std::as_writable_bytes(std::span(block.data, static_cast<std::size_t>(layout.Bytes()))));
return expected;
}
void NonuniformInitialContents(AgcDriver::VulkanDevice& device) {
using namespace AgcDriver::Graphics;
const auto context = AgcDriver::VulkanDeviceTestAccess::ContextOf(device);
std::uint32_t exercised = 0u;
for (const auto shift : {1u, 2u, 3u}) {
const auto fragments = 1u << shift;
if ((context.limits.framebufferColorSampleCounts & fragments) == 0u || (context.limits.sampledImageColorSampleCounts & fragments) == 0u) continue;
for (const auto pipeBankXor : {0u, 0x8100u}) {
Block block(4u * BlockBytes);
const auto expected = StoreInitial(block, fragments, pipeBankXor, false);
const std::vector<std::uint8_t> before(block.data, block.data + block.bytes);
auto color = DecodeTarget(block.Address(), shift);
color.pipeBankXor = pipeBankXor;
const auto state = TargetState(color);
Draw(device, state);
auto descriptor = TargetDescriptor(block, shift);
descriptor[0] ^= pipeBankXor >> 8u;
const auto loaded = LoadSamples(device, descriptor, fragments);
const auto locations = SampleLocations(state);
std::uint32_t drawn = 0u, untouched = 0u;
for (std::uint32_t y = 0u; y < Side; ++y) {
for (std::uint32_t x = 0u; x < Side; ++x) {
for (std::uint32_t sample = 0u; sample < fragments; ++sample) {
const auto index = (y * Side + x) * fragments + sample;
const auto& texel = loaded[index];
Require(texel == Drawn || texel == expected[index], "a first partial draw lost a nonuniform initial sample");
const auto px = x + static_cast<double>(locations[sample].x);
const auto py = y + static_cast<double>(locations[sample].y);
const auto distance = std::min({EdgeDistance(px, py, 0u), EdgeDistance(px, py, 1u), EdgeDistance(px, py, 2u)});
if (std::fabs(distance) < EdgeMargin) continue;
Require(texel == (distance > 0.0 ? Drawn : expected[index]), "nonuniform initial contents and raster coverage disagree");
drawn += distance > 0.0;
untouched += distance < 0.0;
}
}
}
Require(drawn != 0u && untouched != 0u, "nonuniform samples were not checked on both sides of the draw");
Require(std::equal(before.begin(), before.end(), block.data), "nonuniform initialization changed guest bytes or padding");
device.SubmitRecorded(true);
device.WaitIdle();
ClearCachedTextures(context.device);
ClearMultisampleTargets(context.device);
std::printf("nonuniform initial contents: %u fragments xor=0x%x preserve untouched samples and guest padding\n", fragments, pipeBankXor);
++exercised;
}
}
Require(exercised != 0u, "no nonuniform initial multisample case was exercised");
}
int NonuniformInitialLifetime(AgcDriver::VulkanDevice& device) {
using namespace AgcDriver::Graphics;
const auto context = AgcDriver::VulkanDeviceTestAccess::ContextOf(device);
Require((context.limits.framebufferColorSampleCounts & Samples) != 0u, "initial lifetime sample count is unavailable");
device.WaitIdle();
auto* previous = Recorder::Active();
Require(previous != nullptr && previous->Device() == context.device, "initial lifetime fixture has no device recorder to restore");
struct Restore { Recorder* previous; ~Restore() { previous->Activate(); } } restore{previous};
for (const bool uniform : {false, true}) {
Block block(BlockBytes);
if (uniform) StoreWords(block, block.bytes, FillOnes);
const auto expected = uniform ? std::vector<std::array<float, 4>>(Side * Side * Samples, Ones) : StoreInitial(block, Samples, 0u, false);
const auto color = DecodeTarget(block);
const auto state = TargetState(color);
{
auto recorded = context;
recorded.bufferPool = std::make_shared<BufferPool>(context);
Recorder recorder(recorded);
std::shared_ptr<void> owner;
VkImageView view = VK_NULL_HANDLE;
std::size_t initialBytes = 0;
constexpr std::size_t uploadBytes = Side * Side * Samples * 8u;
constexpr auto properties = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
const auto usage = BufferPool::Usage(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, properties);
{
std::lock_guard gpu(AgcDriver::GuestMemory::GpuMutex());
recorder.Activate();
PrepareMultisampleTargetForDraw_nid_no_patch(recorded, color);
view = MultisampleTargetView(recorded, color, owner);
initialBytes = recorder.OpenKeptBytes();
const auto premature = recorded.bufferPool->Take(uploadBytes, usage);
if (premature) recorded.bufferPool->Put(*premature);
Require(!premature.has_value(), "initial upload was recycled before submission completed");
recorder.Submit();
}
recorder.Sync();
Require(recorder.InFlightKeptBytes() == 0, "completed initial contents still count as in-flight kept bytes");
auto released = recorded.bufferPool->Take(uploadBytes, usage);
Require(released.has_value() != uniform, "initial upload was not returned to the caller's pool after completion, or uniform clear allocated an upload");
if (released) recorded.bufferPool->Put(*released);
for (int round = 0; round < 3; ++round) {
{
std::lock_guard gpu(AgcDriver::GuestMemory::GpuMutex());
std::shared_ptr<void> reusedOwner;
Require(MultisampleTargetView(recorded, color, reusedOwner) == view && reusedOwner == owner, "initial-content accounting did not reuse its resident target");
const auto targetBytes = recorder.OpenKeptBytes();
Require(targetBytes != 0 && initialBytes == targetBytes + (uniform ? 0u : uploadBytes), "reused target still counts initial color snapshot or upload bytes");
KeepMultisampleTarget_nid_no_patch(owner);
Require(recorder.OpenKeptBytes() == targetBytes, "one target is counted twice within a submission");
recorder.Submit();
}
recorder.Sync();
}
}
previous->Activate();
Draw(device, state);
const auto loaded = LoadSamples(device, block);
Require(loaded.size() == expected.size(), "initial lifetime sample count differs");
for (std::size_t index = 0; index < loaded.size(); ++index) Require(loaded[index] == Drawn || loaded[index] == expected[index], "initial contents were lost after completion and reuse");
std::printf("native color initial lifetime: %s contents survive completion and three resident reuses without retaining initialization bytes\n", uniform ? "uniform" : "varying");
}
return 0;
}
VKAPI_ATTR VkResult VKAPI_CALL RefuseInitialImage(VkPhysicalDevice, VkFormat, VkImageType, VkImageTiling, VkImageUsageFlags, VkImageCreateFlags, VkImageFormatProperties*) {
return VK_ERROR_FORMAT_NOT_SUPPORTED;
}
void NonuniformInitialCapabilities(AgcDriver::VulkanDevice& device) {
using namespace AgcDriver::Graphics;
const auto context = AgcDriver::VulkanDeviceTestAccess::ContextOf(device);
Block block(4u * BlockBytes);
const auto expected = StoreInitial(block, Samples, 0x8100u, false);
const std::vector<std::uint8_t> before(block.data, block.data + block.bytes);
auto color = DecodeTarget(block);
color.pipeBankXor = 0x8100u;
const auto refused = [&](const Context& unavailable, const char* expected) {
std::string error;
try {
std::lock_guard gpu(AgcDriver::GuestMemory::GpuMutex());
PrepareMultisampleTargetForDraw_nid_no_patch(unavailable, color);
} catch (const std::runtime_error& failure) { error = failure.what(); }
Require(error.find(expected) != std::string::npos, "initial upload capability refusal differs: " + error);
Require(!MultisampleColorTargetOver(color.address, static_cast<std::size_t>(MultisampledColorBytes(color))), "refused initial upload left a resident owner");
Require(std::equal(before.begin(), before.end(), block.data), "refused initial upload changed guest contents");
};
for (const auto missing : {0u, 1u, 2u}) {
auto unavailable = context;
if (missing == 0u) unavailable.storageImageMultisample = false;
if (missing == 1u) unavailable.storageImageWriteWithoutFormat = false;
if (missing == 2u) unavailable.detiler = nullptr;
refused(unavailable, "require enabled formatless");
}
auto unavailable = context;
unavailable.limits.maxStorageBufferRange = 0u;
refused(unavailable, "at least one aligned element");
unavailable = context;
unavailable.imageFormatProperties = RefuseInitialImage;
refused(unavailable, "vkGetPhysicalDeviceImageFormatProperties multisampled target");
color.tileMode = ColorTileMode::Z64KBX;
refused(context, "nonuniform initial multisample color tiling");
color.tileMode = ColorTileMode::RenderTarget;
auto chunked = context;
chunked.limits.maxStorageBufferRange = 256u;
{
std::lock_guard gpu(AgcDriver::GuestMemory::GpuMutex());
PrepareMultisampleTargetForDraw_nid_no_patch(chunked, color);
}
Draw(device, TargetState(color));
auto descriptor = TargetDescriptor(block, SampleShift);
descriptor[0] ^= 0x81u;
const auto loaded = LoadSamples(device, descriptor);
for (std::size_t index = 0; index < loaded.size(); ++index) Require(loaded[index] == Drawn || loaded[index] == expected[index], "chunked initial upload lost sample values");
Require(std::equal(before.begin(), before.end(), block.data), "chunked initial upload changed guest contents");
device.SubmitRecorded(true);
device.WaitIdle();
ClearCachedTextures(context.device);
ClearMultisampleTargets(context.device);
std::puts("nonuniform initial upload: missing capabilities refuse without ownership or byte changes; 256-byte chunks preserve samples");
}
void NonuniformInitialHook(AgcDriver::VulkanDevice& device) {
using namespace AgcDriver::Graphics;
const auto context = AgcDriver::VulkanDeviceTestAccess::ContextOf(device);
Block block(4u * BlockBytes);
const auto expected = StoreInitial(block, Samples, 0u, false);
static std::atomic<std::uint32_t> captures{0u};
struct Reset { ~Reset() { AgcDriver::GuestMemory::SetFlushHook(nullptr); } } reset;
AgcDriver::GuestMemory::SetFlushHook([](std::uint64_t, std::size_t) {
Require(!HoldsMultisampleTargetsLock(), "nonuniform initial capture held the targets lock across a flush callback");
WithMultisampleTargetsLockForTest([] {});
captures.fetch_add(1u, std::memory_order_relaxed);
});
{
std::lock_guard gpu(AgcDriver::GuestMemory::GpuMutex());
PrepareMultisampleTargetForDraw_nid_no_patch(context, DecodeTarget(block));
}
AgcDriver::GuestMemory::SetFlushHook(nullptr);
Require(captures.load(std::memory_order_relaxed) == 1u, "nonuniform initial capture read guest contents more than once");
const auto loaded = LoadSamples(device, block);
Require(loaded == expected, "nonuniform capture changed initial sample values before a draw");
device.SubmitRecorded(true);
device.WaitIdle();
ClearCachedTextures(context.device);
ClearMultisampleTargets(context.device);
std::puts("nonuniform initial upload captures once outside the targets lock");
}
void UniformInitialContents(AgcDriver::VulkanDevice& device) {
using namespace AgcDriver::Graphics;
const auto context = AgcDriver::VulkanDeviceTestAccess::ContextOf(device);
std::uint32_t exercised = 0u;
for (const auto shift : {1u, 2u, 3u}) {
const auto fragments = 1u << shift;
if ((context.limits.framebufferColorSampleCounts & fragments) == 0u || (context.limits.sampledImageColorSampleCounts & fragments) == 0u) continue;
Block block(4u * BlockBytes);
StoreWords(block, block.bytes, FillOnes);
const std::vector<std::uint8_t> before(block.data, block.data + block.bytes);
const auto color = DecodeTarget(block.Address(), shift);
const auto state = TargetState(color);
Draw(device, state);
const auto loaded = LoadSamples(device, TargetDescriptor(block, shift), fragments);
std::uint32_t drawn = 0u;
std::uint32_t untouched = 0u;
const auto locations = SampleLocations(state);
for (std::uint32_t y = 0u; y < Side; ++y) {
for (std::uint32_t x = 0u; x < Side; ++x) {
for (std::uint32_t sample = 0u; sample < fragments; ++sample) {
const auto& texel = loaded[(y * Side + x) * fragments + sample];
Require(texel == Drawn || texel == Ones, "a first partial draw lost the uniform initial sample");
const auto px = x + static_cast<double>(locations[sample].x);
const auto py = y + static_cast<double>(locations[sample].y);
const auto distance = std::min({EdgeDistance(px, py, 0u), EdgeDistance(px, py, 1u), EdgeDistance(px, py, 2u)});
if (std::fabs(distance) < EdgeMargin) continue;
Require((texel == Drawn) == (distance > 0.0), "initial multisample contents and raster coverage disagree");
drawn += texel == Drawn;
untouched += texel == Ones;
}
}
}
Require(drawn != 0u && untouched != 0u, "uniform initial contents were not checked on both sides of a partial draw");
Require(std::equal(before.begin(), before.end(), block.data), "uniform initialization changed guest bytes or padding");
device.SubmitRecorded(true);
device.WaitIdle();
ClearCachedTextures(context.device);
ClearMultisampleTargets(context.device);
std::printf("uniform initial contents: %u fragments preserve untouched samples and guest padding\n", fragments);
++exercised;
}
Require(exercised != 0u, "no uniform multisample initialization case was exercised");
}
void UniformInitialRefusals(AgcDriver::VulkanDevice& device) {
using namespace AgcDriver::Graphics;
const auto context = AgcDriver::VulkanDeviceTestAccess::ContextOf(device);
const auto refuses = [&](const ColorTarget& color, const char* expected, const Context* selected = nullptr) {
std::string refusal;
try {
std::lock_guard gpu(AgcDriver::GuestMemory::GpuMutex());
PrepareMultisampleTargetForDraw_nid_no_patch(selected != nullptr ? *selected : context, color);
} catch (const std::runtime_error& error) { refusal = error.what(); }
Require(refusal.find(expected) != std::string::npos, std::string("initial color refusal did not match ") + expected + ": " + refusal);
};
Block block(4u * BlockBytes);
StoreWords(block, block.bytes, FillOnes);
const auto color = DecodeTarget(block);
auto invalid = color;
invalid.address = invalid.surfaceAddress = 0u;
refuses(invalid, "not fully mapped");
block.data[BlockBytes - 1u] ^= 1u;
const std::vector<std::uint8_t> varying(block.data, block.data + block.bytes);
auto unavailable = context;
unavailable.storageImageMultisample = false;
refuses(color, "require enabled formatless", &unavailable);
Require(std::equal(varying.begin(), varying.end(), block.data), "a refused initial import changed guest contents");
Require(!MultisampleColorTargetOver(color.address, static_cast<std::size_t>(MultisampledColorBytes(color))), "a refused initial import left a resident owner");
StoreWords(block, block.bytes, FillOnes);
auto noStorage = context;
noStorage.storageImageMultisample = false;
noStorage.storageImageWriteWithoutFormat = false;
{
std::lock_guard gpu(AgcDriver::GuestMemory::GpuMutex());
PrepareMultisampleTargetForDraw_nid_no_patch(noStorage, color);
}
CheckUniform(LoadSamples(device, block), Ones, "uniform initialization without storage writes");
const auto original = MultisampleColorTargetOver(color.address, static_cast<std::size_t>(MultisampledColorBytes(color)));
Require(original && original->active->load(std::memory_order_acquire), "uniform initialization did not retain its owner");
auto alias = color;
alias.format = VK_FORMAT_R32G32_SFLOAT;
refuses(alias, "overlap another native owner");
const auto current = MultisampleColorTargetOver(color.address, static_cast<std::size_t>(MultisampledColorBytes(color)));
Require(current && current->active == original->active && original->active->load(std::memory_order_acquire), "refused replacement retired the original owner");
CheckUniform(LoadSamples(device, block), Ones, "after refused owner replacement");
Block depthMemory(4u * BlockBytes, true), htile(BlockBytes, true);
DepthTarget depth{depthMemory.Address(), 0u, {Side, Side}, VK_FORMAT_D32_SFLOAT, 0.0f, 0u, htile.Address(), false, Samples};
depth.depthSwizzle = 24u;
depth.iterate256 = depth.htilePipeAligned = depth.htileDepthOnly = true;
{
std::lock_guard gpu(AgcDriver::GuestMemory::GpuMutex());
const auto view = DepthSurfaceView(context, depth);
Require(ResidentDepthGuardOverlaps_nid_no_patch(depth.address, static_cast<std::size_t>(MultisampledDepthBytes_nid_no_patch(depth.extent, 4u, Samples))), "initial color refusal fixture has no resident depth guard");
std::string refusal;
try { PrepareMultisampleTargetForDraw_nid_no_patch(context, DecodeTarget(depthMemory)); }
catch (const std::runtime_error& error) { refusal = error.what(); }
Require(DepthSurfaceAt(depth.address), "refused initial color capture retired an unwritten native depth owner");
Require(refusal.find("overlap resident native depth") != std::string::npos, "initial color capture did not refuse a resident depth owner");
Require(DepthSurfaceView(context, depth) == view, "refused color capture replaced the native depth image");
}
device.SubmitRecorded(true);
device.WaitIdle();
ClearCachedTextures(context.device);
ClearDepthSurfaces(context.device);
ClearMultisampleTargets(context.device);
std::puts("uniform initial refusal checks passed: unreadable memory, differing padding, no storage features, retained owner");
}
void UniformInitialFlushHook(AgcDriver::VulkanDevice& device) {
using namespace AgcDriver::Graphics;
const auto context = AgcDriver::VulkanDeviceTestAccess::ContextOf(device);
static std::atomic<std::uint32_t> captures{0u};
Block block(4u * BlockBytes);
StoreWords(block, block.bytes, FillOnes);
struct Reset { ~Reset() { AgcDriver::GuestMemory::SetFlushHook(nullptr); } } reset;
AgcDriver::GuestMemory::SetFlushHook([](std::uint64_t, std::size_t) {
Require(!HoldsMultisampleTargetsLock(), "initial color capture held the targets lock across a flush callback");
WithMultisampleTargetsLockForTest([] {});
captures.fetch_add(1u, std::memory_order_relaxed);
});
{
std::lock_guard gpu(AgcDriver::GuestMemory::GpuMutex());
PrepareMultisampleTargetForDraw_nid_no_patch(context, DecodeTarget(block));
}
AgcDriver::GuestMemory::SetFlushHook(nullptr);
Require(captures.load(std::memory_order_relaxed) == 1u, "initial color capture did not run its flush callback exactly once");
CheckUniform(LoadSamples(device, block), Ones, "after a reentrant initial-capture flush hook");
device.SubmitRecorded(true);
device.WaitIdle();
ClearCachedTextures(context.device);
ClearMultisampleTargets(context.device);
std::puts("uniform initial capture flush callback entered the target registry without holding its lock");
}
alignas(256) std::array<std::uint32_t, 12> VertexValues{};
void DrawVertexInput(AgcDriver::VulkanDevice& device, const AgcDriver::Graphics::State& state, std::uint64_t address, std::uint32_t stride) {
@@ -1070,6 +1428,10 @@ int NativeVertexInput(std::unique_ptr<AgcDriver::VulkanDevice>& device) {
std::memcpy(source.data + colorBytes + vertex * sizeof(element), element.data(), sizeof(element));
}
std::memcpy(source.data + colorBytes - 8u, element.data(), 8u);
{
std::lock_guard gpu(AgcDriver::GuestMemory::GpuMutex());
AgcDriver::Graphics::MaterializeMultisampleTargetClear(context, color);
}
Draw(*device, TargetState(color));
AgcDriver::Graphics::NoteColorMetadataFill(source.Address(), static_cast<std::size_t>(colorBytes), FillOnes);
CheckUniform(LoadSamples(*device, source), Ones, "before the fixed-function vertex probe");
@@ -1312,6 +1674,13 @@ int main(int argc, char** argv) {
return 0;
}
if (argc == 2 && std::string_view(argv[1]) == "--native-vertex-input") return NativeVertexInput(device);
if (argc == 2 && std::string_view(argv[1]) == "--initial-nonuniform_lifetime") return NonuniformInitialLifetime(*device);
if (argc == 2 && std::string_view(argv[1]) == "--initial-nonuniform_capabilities") { NonuniformInitialCapabilities(*device); return 0; }
if (argc == 2 && std::string_view(argv[1]) == "--initial-nonuniform_hook") { NonuniformInitialHook(*device); return 0; }
if (argc == 2 && std::string_view(argv[1]) == "--initial-nonuniform") { NonuniformInitialContents(*device); return 0; }
if (argc == 2 && std::string_view(argv[1]) == "--initial-uniform") { UniformInitialContents(*device); return 0; }
if (argc == 2 && std::string_view(argv[1]) == "--initial-uniform_refusals") { UniformInitialRefusals(*device); return 0; }
if (argc == 2 && std::string_view(argv[1]) == "--initial-uniform_hook") { UniformInitialFlushHook(*device); return 0; }
Block block(4u * BlockBytes);
Block other(BlockBytes);
Block output(2u * 1024u * 1024u);
@@ -1341,10 +1710,12 @@ int main(int argc, char** argv) {
CheckFirstSampleReads(*device, TargetDescriptor(zeroed, SampleShift), std::vector<std::array<float, 4>>(Side * Side * Samples), false, "from zeroed color memory no draw rendered to");
Block aliased(4u * BlockBytes);
Draw(*device, TargetState(DecodeSwappedTarget(aliased)), 0, 2u, Unorm8PixelCode);
Draw(*device, TargetState(DecodeTarget(aliased)));
const auto aliasedSamples = LoadSamples(*device, aliased);
CheckSamples(state, aliasedSamples, {});
CheckFirstSampleReads(*device, TargetDescriptor(aliased, SampleShift), aliasedSamples, true, "from a 4x RGBA16F target drawn after a BGRA8 target at the same address");
const auto originalAliasSamples = LoadSamples(*device, aliased, Format8888Unorm);
std::string aliasRefusal;
try { Draw(*device, TargetState(DecodeTarget(aliased))); }
catch (const std::runtime_error& error) { aliasRefusal = error.what(); }
Require(aliasRefusal.find("overlap another native owner") != std::string::npos, "an unrelated-format draw did not refuse unpublished native samples");
Require(LoadSamples(*device, aliased, Format8888Unorm) == originalAliasSamples, "a refused unrelated-format draw changed the original native samples");
std::puts("DIM 2D image_load, image_sample_lz and image_sample_l reads of a 4x color target return each pixel's sample 0");
Block swapped(4u * BlockBytes);
Draw(*device, TargetState(DecodeSwappedTarget(swapped)), 0, 2u, Unorm8PixelCode);
@@ -1383,6 +1754,10 @@ int main(int argc, char** argv) {
const auto bdaState = TargetState(DecodeTarget(bda));
CheckBdaSpan(*device, bda, 0, false);
CheckBdaSpan(*device, bda, BlockBytes, false);
{
std::lock_guard gpu(AgcDriver::GuestMemory::GpuMutex());
AgcDriver::Graphics::MaterializeMultisampleTargetClear(AgcDriver::VulkanDeviceTestAccess::ContextOf(*device), bdaState.color);
}
Draw(*device, bdaState);
CheckBdaSpan(*device, bda, 0, true);
CheckBdaSpan(*device, bda, BlockBytes, false);
@@ -1533,6 +1908,10 @@ int main(int argc, char** argv) {
device->WaitIdle();
AgcDriver::Graphics::ClearMultisampleTargets(device->Device());
CheckBdaSpan(*device, block, 0, false);
{
std::lock_guard gpu(AgcDriver::GuestMemory::GpuMutex());
AgcDriver::Graphics::MaterializeMultisampleTargetClear(AgcDriver::VulkanDeviceTestAccess::ContextOf(*device), DecodeTarget(block));
}
Draw(*device, TargetState(DecodeTarget(block)));
std::puts("every sample of a 4x color target loaded through its multisampled texture descriptor matches the triangle drawn into it, then the fill of its color memory; a surface no draw rendered to loads the value its color memory repeats and keeps it under a later draw");
struct ReleaseIndexDevice {
@@ -7,6 +7,7 @@
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <optional>
#include <span>
#include <string>
#include <vector>
@@ -25,6 +26,11 @@ alignas(256) constexpr std::array<std::uint32_t, 14> Code{
0x7e160215, 0xe0701000, 0x80010a03, 0xe0701004, 0x80010b03, 0xbf810000,
};
alignas(256) constexpr std::array<std::uint32_t, 14> DenormalCode{
0x34060086, 0xbe9403ff, 0x55555555, 0xbe9503ff, 0x55555555, 0xb9141901, 0xb9153801, 0x7e140214,
0x7e160215, 0xe0701000, 0x80010a03, 0xe0701004, 0x80010b03, 0xbf810000,
};
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};
@@ -36,11 +42,11 @@ std::string Hex(std::uint32_t value) {
return text;
}
ShaderRecompiler::RecompileRequest Request(AgcDriver::VulkanDevice& device, std::span<const std::uint32_t> code, std::span<const std::uint32_t> userData, std::span<const ShaderRecompiler::MemoryRegion> memory) {
ShaderRecompiler::RecompileRequest Request(AgcDriver::VulkanDevice& device, std::span<const std::uint32_t> code, std::span<const std::uint32_t> userData, std::span<const ShaderRecompiler::MemoryRegion> memory, std::optional<ShaderRecompiler::ShaderFloatMode> floatMode = std::nullopt) {
const ShaderRecompiler::ShaderComputeStageInfo compute{{Threads, 1, 1}, 0u, {false, false, false}, false, 1};
ShaderRecompiler::RecompileRequest request{
{ShaderStage::Compute, reinterpret_cast<std::uintptr_t>(code.data()), code, 0, {}},
{32, 0, userData, compute, std::nullopt, std::nullopt, memory},
{32, 0, userData, compute, std::nullopt, std::nullopt, memory, floatMode},
device.Target(),
{0, 0, 0, 128}
};
@@ -58,27 +64,25 @@ void ExpectRefused(AgcDriver::VulkanDevice& device, std::uint32_t word, const ch
} catch (const std::exception& error) {
refusal = error.what();
}
Require(refusal.find("only the MODE round mode fields are modeled") != std::string::npos, std::string("s_getreg_b32 reading ") + what + " was not refused");
Require(refusal.find("only the MODE round and denormal mode fields are modeled") != std::string::npos, std::string("s_getreg_b32 reading ") + what + " was not refused");
}
void Run(AgcDriver::VulkanDevice& device) {
void Run(AgcDriver::VulkanDevice& device, std::span<const std::uint32_t> code, std::optional<ShaderRecompiler::ShaderFloatMode> floatMode) {
Output.fill(0xdeadbeefu);
std::vector<std::uint32_t> userData(8, 0u);
const auto output = BufferDescriptor(Output.data(), static_cast<std::uint32_t>(Output.size() * 4u));
std::copy(output.begin(), output.end(), userData.begin() + 4);
const std::span<const std::uint32_t> code(Code);
const std::array<ShaderRecompiler::MemoryRegion, 1> memory{{{reinterpret_cast<std::uintptr_t>(code.data()), std::as_bytes(code)}}};
const auto result = ShaderRecompiler::Recompile(Request(device, code, userData, memory));
const auto result = ShaderRecompiler::Recompile(Request(device, code, userData, memory, floatMode));
device.Dispatch(result, 1, 1, 1, {}, reinterpret_cast<std::uintptr_t>(code.data()));
device.WaitIdle();
}
void Check() {
constexpr std::array<const char*, 2> names{"hwreg(MODE, 0, 4)", "hwreg(MODE, 2, 2)"};
void Check(const std::array<const char*, 2>& names, const std::array<std::uint32_t, 2>& expected) {
for (std::uint32_t tid = 0; tid < Threads; ++tid) {
for (std::uint32_t index = 0; index < names.size(); ++index) {
const std::uint32_t actual = Output[tid * Results + index];
Require(actual == 0u, std::string("s_getreg_b32: lane ") + std::to_string(tid) + " " + names[index] + " is " + Hex(actual) + ", expected 0x00000000");
Require(actual == expected[index], std::string("s_getreg_b32: lane ") + std::to_string(tid) + " " + names[index] + " is " + Hex(actual) + ", expected " + Hex(expected[index]));
}
}
}
@@ -89,9 +93,10 @@ int main() {
try {
const auto device = OpenVulkanTestDevice();
if (!device) return VulkanTestSkipped;
Run(*device);
Check();
ExpectRefused(*device, 0xb9141901u, "the MODE denormal fields");
Run(*device, Code, std::nullopt);
Check({"hwreg(MODE, 0, 4)", "hwreg(MODE, 2, 2)"}, {0u, 0u});
Run(*device, DenormalCode, ShaderRecompiler::ShaderFloatMode{0xc0u});
Check({"hwreg(MODE, 4, 4)", "hwreg(MODE, 0, 8)"}, {0xcu, 0xc0u});
ExpectRefused(*device, 0xb914f804u, "hardware register 4");
std::puts("s_getreg_b32 tests passed");
return 0;
+60
View File
@@ -0,0 +1,60 @@
add_library(libSceAgcVsh SHARED EXCLUDE_FROM_ALL
${CMAKE_CURRENT_SOURCE_DIR}/Export.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Acb/src/Control.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Acb/src/Dispatch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Acb/src/Memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Acb/src/Sync.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Cb/src/Branch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Cb/src/Dispatch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Cb/src/Registers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Cb/src/Sync.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Command/src/Control.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Command/src/Draw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Command/src/Memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Command/src/Packet.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Command/src/RegisterDefaults.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/DcbDraw/src/DrawIndexed.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/DcbDraw/src/DrawNonIndexed.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/DcbDraw/src/IndexBuffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/DcbDraw/src/Instancing.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/DcbDraw/src/Stats.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/DcbFlow/src/Control.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/DcbFlow/src/Dispatch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/DcbFlow/src/Memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/DcbFlow/src/Sync.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/DcbState/src/ContextState.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/DcbState/src/Display.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/DcbState/src/Init.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/DcbState/src/Marker.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/DcbState/src/Predication.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/DcbState/src/Registers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/DcbState/src/Workload.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Misc/src/PacketInfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Misc/src/RegisterDefaults.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Misc/src/ShaderFusion.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Misc/src/Suspend.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Patch/src/Branch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Patch/src/CondExec.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Patch/src/Dma.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Patch/src/IndirectRegisters.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Patch/src/Jump.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Patch/src/Nop.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Patch/src/QueueEndOfPipeAction.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Patch/src/Rewind.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Patch/src/WaitRegMem.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Predication/src/Predication.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Shader/src/CreateShader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Shader/src/InterpolantMapping.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Shader/src/LinkShaders.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Shader/src/PrimState.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../libSceAgc/Shader/src/ShaderUtils.cpp
)
target_include_directories(libSceAgcVsh PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(libSceAgcVsh PRIVATE libSceAgcDriver libc)
option(APS5_AGC_CREATE_LOG "Logging sceAgcCreateShader Ok status" ON)
target_compile_definitions(libSceAgcVsh PRIVATE
APS5_AGC_CREATE_LOG=$<BOOL:${APS5_AGC_CREATE_LOG}>
)
File diff suppressed because it is too large. Load diff
+1 -149
View File
@@ -1,158 +1,10 @@
#pragma once
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
int APS5_VABI sceAgcDcbCopyData_nid_no_patch(void);
int APS5_VABI sceAgcBranchPatchSetElseTarget_nid_no_patch(void);
int APS5_VABI sceAgcCbSetShRegistersDirect_nid_no_patch(void);
int APS5_VABI sceAgcCreateShader_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetNumInstancesGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetUcRegisterDirectGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbDrawIndexIndirectMultiGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbAtomicGdsGetSize_nid_no_patch(void);
int APS5_VABI sceAgcAcbCopyDataGetSize_nid_no_patch(void);
int APS5_VABI sceAgcAcbWaitUntilSafeForRendering_nid_no_patch(void);
int APS5_VABI sceAgcAsyncCondExecPatchSetEnd_nid_no_patch(void);
int APS5_VABI sceAgcDcbDmaDataGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetUcRegistersIndirect_nid_no_patch(void);
int APS5_VABI sceAgcGetRegisterDefaults2_nid_no_patch(void);
int APS5_VABI sceAgcCbReleaseMem_nid_no_patch(void);
int APS5_VABI sceAgcCondExecPatchSetEnd_nid_no_patch(void);
int APS5_VABI sceAgcDcbAtomicGds_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetCxRegistersIndirectGetSize_nid_no_patch(void);
int APS5_VABI sceAgcCbSetUcRegisterRangeDirect_nid_no_patch(void);
int APS5_VABI sceAgcDcbEventWrite_nid_no_patch(void);
int APS5_VABI sceAgcDcbWriteData_nid_no_patch(void);
int APS5_VABI sceAgcSetUcRegIndirectPatchSetAddress_nid_no_patch(void);
int APS5_VABI sceAgcCbCondWriteGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbQueueEndOfShaderActionGetSize_nid_no_patch(void);
int APS5_VABI sceAgcGetPacketSize_nid_no_patch(void);
int APS5_VABI sceAgcAcbAcquireMem_nid_no_patch(void);
int APS5_VABI sceAgcAcbEventWriteGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetIndexIndirectArgs_nid_no_patch(void);
int APS5_VABI sceAgcAcbDmaData_nid_no_patch(void);
int APS5_VABI sceAgcDcbDrawIndexIndirect_nid_no_patch(void);
int APS5_VABI sceAgcDcbPrimeUtcl2GetSize_nid_no_patch(void);
int APS5_VABI sceAgcAsyncCondExecPatchSetCommandAddress_nid_no_patch(void);
int APS5_VABI sceAgcAcbAcquireMemGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetIndexIndirectArgsGetSize_nid_no_patch(void);
int APS5_VABI sceAgcCreateInterpolantMapping_nid_no_patch(void);
int APS5_VABI sceAgcDcbDrawIndexIndirectMulti_nid_no_patch(void);
int APS5_VABI sceAgcDcbEventWriteGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetUcRegisterDirect_nid_no_patch(void);
int APS5_VABI sceAgcQueueEndOfPipeActionPatchAddress_nid_no_patch(void);
int APS5_VABI sceAgcDcbDrawIndirectMultiGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetBaseDrawIndirectArgsGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetNumInstances_nid_no_patch(void);
int APS5_VABI sceAgcDcbWaitOnAddressGetSize_nid_no_patch(void);
int APS5_VABI sceAgcAcbAtomicGds_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetBoolPredicationEnableGetSize_nid_no_patch(void);
int APS5_VABI sceAgcAcbAtomicMemGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetCfRegisterRangeDirect_nid_no_patch(void);
int APS5_VABI sceAgcDcbCondExecGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbDrawIndexMultiInstanced_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetCxRegistersIndirect_nid_no_patch(void);
int APS5_VABI sceAgcCbSetShRegistersDirectGetSize_nid_no_patch(void);
int APS5_VABI sceAgcCondExecPatchSetCommandAddress_nid_no_patch(void);
int APS5_VABI sceAgcRewindPatchSetRewindState_nid_no_patch(void);
int APS5_VABI sceAgcQueueEndOfPipeActionPatchGcrCntl_nid_no_patch(void);
int APS5_VABI sceAgcWaitRegMemPatchReference_nid_no_patch(void);
int APS5_VABI sceAgcAcbRewind_nid_no_patch(void);
int APS5_VABI sceAgcAcbCondExecGetSize_nid_no_patch(void);
int APS5_VABI sceAgcSuspendPointAndCheckStatus_nid_no_patch(void);
int APS5_VABI sceAgcAcbWaitRegMem_nid_no_patch(void);
int APS5_VABI sceAgcDcbAcquireMem_nid_no_patch(void);
int APS5_VABI sceAgcSetCxRegIndirectPatchSetNumRegisters_nid_no_patch(void);
int APS5_VABI sceAgcDcbContextStateOp_nid_no_patch(void);
int APS5_VABI sceAgcAcbWriteData_nid_no_patch(void);
int APS5_VABI sceAgcAcbDmaDataGetSize_nid_no_patch(void);
int APS5_VABI sceAgcCbSetShRegisterRangeDirectGetSize_nid_no_patch(void);
int APS5_VABI sceAgcCbNop_nid_no_patch(void);
int APS5_VABI sceAgcDcbResetQueue_nid_no_patch(void);
int APS5_VABI sceAgcDcbDmaData_nid_no_patch(void);
int APS5_VABI sceAgcDcbDrawIndexGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDmaDataPatchSetDstAddressOrOffset_nid_no_patch(void);
int APS5_VABI sceAgcCbQueueEndOfPipeActionGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetFlip_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetMarker_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetPredication_nid_no_patch(void);
int APS5_VABI sceAgcDcbAtomicMem_nid_no_patch(void);
int APS5_VABI sceAgcGetRegisterDefaults2Internal_nid_no_patch(void);
int APS5_VABI sceAgcSetShRegIndirectPatchAddRegisters_nid_no_patch(void);
int APS5_VABI sceAgcDcbPrimeUtcl2_nid_no_patch(void);
int APS5_VABI sceAgcAcbRewindGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetZPassPredicationEnableGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbWaitUntilSafeForRendering_nid_no_patch(void);
int APS5_VABI sceAgcBranchPatchSetThenTarget_nid_no_patch(void);
int APS5_VABI sceAgcSetCxRegIndirectPatchSetAddress_nid_no_patch(void);
int APS5_VABI sceAgcDcbAtomicMemGetSize_nid_no_patch(void);
int APS5_VABI sceAgcUpdatePrimState_nid_no_patch(void);
int APS5_VABI sceAgcCbNopGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbGetLodStats_nid_no_patch(void);
int APS5_VABI sceAgcWaitRegMemPatchAddress_nid_no_patch(void);
int APS5_VABI sceAgcQueueEndOfPipeActionPatchData_nid_no_patch(void);
int APS5_VABI sceAgcGetRegisterDefaultsInternal_nid_no_patch(void);
int APS5_VABI sceAgcInit_nid_no_patch(void);
int APS5_VABI sceAgcDcbDispatchIndirectGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbCondExec_nid_no_patch(void);
int APS5_VABI sceAgcAcbSetMarker_nid_no_patch(void);
int APS5_VABI sceAgcDcbDrawIndexOffsetGetSize_nid_no_patch(void);
int APS5_VABI sceAgcAcbJump_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetIndexCount_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetShRegistersIndirectGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbStallCommandBufferParserGetSize_nid_no_patch(void);
int APS5_VABI sceAgcSuspendPoint_nid_no_patch(void);
int APS5_VABI sceAgcWaitRegMemPatchMask_nid_no_patch(void);
int APS5_VABI sceAgcAcbDispatchIndirectGetSize_nid_no_patch(void);
int APS5_VABI sceAgcAcbAtomicGdsGetSize_nid_no_patch(void);
int APS5_VABI sceAgcCbCondWrite_nid_no_patch(void);
int APS5_VABI sceAgcDcbEndOcclusionQueryGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetPredicationDisableGetSize_nid_no_patch(void);
int APS5_VABI sceAgcLinkShaders_nid_no_patch(void);
int APS5_VABI sceAgcDcbWaitRegMem_nid_no_patch(void);
int APS5_VABI sceAgcGetRegisterDefaults_nid_no_patch(void);
int APS5_VABI sceAgcCbSetShRegisterRangeDirect_nid_no_patch(void);
int APS5_VABI sceAgcSetCxRegIndirectPatchAddRegisters_nid_no_patch(void);
int APS5_VABI sceAgcDcbDispatchIndirect_nid_no_patch(void);
int APS5_VABI sceAgcCbMemSemaphore_nid_no_patch(void);
int APS5_VABI sceAgcCbSetUcRegisterRangeDirectGetSize_nid_no_patch(void);
int APS5_VABI sceAgcCbDispatch_nid_no_patch(void);
int APS5_VABI sceAgcDcbCopyDataGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbDrawIndexMultiInstancedGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDmaDataPatchSetSrcAddressOrOffsetOrImmediate_nid_no_patch(void);
int APS5_VABI sceAgcSetShRegIndirectPatchSetAddress_nid_no_patch(void);
int APS5_VABI sceAgcDcbJump_nid_no_patch(void);
int APS5_VABI sceAgcDcbJumpGetSize_nid_no_patch(void);
int APS5_VABI sceAgcAcbPrimeUtcl2_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetCxRegisterDirectGetSize_nid_no_patch(void);
int APS5_VABI sceAgcQueueEndOfPipeActionPatchType_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetCxRegisterDirect_nid_no_patch(void);
int APS5_VABI sceAgcDcbDrawIndex_nid_no_patch(void);
int APS5_VABI sceAgcCbDispatchGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbGetLodStatsGetSize_nid_no_patch(void);
int APS5_VABI sceAgcGetDataPacketPayloadAddress_nid_no_patch(void);
int APS5_VABI sceAgcDcbDrawIndirect_nid_no_patch(void);
int APS5_VABI sceAgcAcbSetFlip_nid_no_patch(void);
int APS5_VABI sceAgcGetFusedShaderSize_nid_no_patch(void);
int APS5_VABI sceAgcSetRangePredication_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetShRegisterDirectGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbSetIndexSize_nid_no_patch(void);
int APS5_VABI sceAgcSetPacketPredication_nid_no_patch(void);
int APS5_VABI sceAgcDcbDrawIndexOffset_nid_no_patch(void);
int APS5_VABI sceAgcAsyncRewindPatchSetRewindState_nid_no_patch(void);
int APS5_VABI sceAgcJumpPatchSetTarget_nid_no_patch(void);
int APS5_VABI sceAgcBranchPatchSetCompareAddress_nid_no_patch(void);
int APS5_VABI sceAgcAcbJumpGetSize_nid_no_patch(void);
int APS5_VABI sceAgcCbBranch_nid_no_patch(void);
int APS5_VABI sceAgcDcbDrawIndexIndirectGetSize_nid_no_patch(void);
int APS5_VABI sceAgcAcbCopyData_nid_no_patch(void);
int APS5_VABI sceAgcDcbWriteDataGetSize_nid_no_patch(void);
int APS5_VABI sceAgcAcbAtomicMem_nid_no_patch(void);
int APS5_VABI sceAgcAcbPrimeUtcl2GetSize_nid_no_patch(void);
int APS5_VABI sceAgcAcbResetQueue_nid_no_patch(void);
int APS5_VABI sceAgcAcbQueueEndOfShaderActionGetSize_nid_no_patch(void);
int APS5_VABI sceAgcDcbBeginOcclusionQueryGetSize_nid_no_patch(void);
}
+2 -1
View File
@@ -1,3 +1,4 @@
#pragma once
#include "prx/libSceAgcVsh/include/Api.hpp"
#include "prx/libSceAgc/libSceAgc.hpp"
#include "prx/libSceAgcVsh/include/Api.hpp"
+18 -36
View File
@@ -70,99 +70,81 @@ int APS5_VABI libSceAjmiUnknown_4MsUK9kAnKg_nid_no_patch() {
}
APS5_EXPORT("4MsUK9kAnKg", libSceAjmiUnknown_4MsUK9kAnKg_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_6fY_minus_ci3au2U_nid_no_patch() {
int APS5_VABI sceAjmiModuleUnregister() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("6fY-ci3au2U", libSceAjmiUnknown_6fY_minus_ci3au2U_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_9zA4YMlkR9M_nid_no_patch() {
int APS5_VABI sceAjmiBatchStartBuffer() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("9zA4YMlkR9M", libSceAjmiUnknown_9zA4YMlkR9M_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_BD002VBfhuE_nid_no_patch() {
int APS5_VABI sceAjmiFinalize() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("BD002VBfhuE", libSceAjmiUnknown_BD002VBfhuE_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_EYIibEpcHuw_nid_no_patch() {
int APS5_VABI sceAjmiStrError() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("EYIibEpcHuw", libSceAjmiUnknown_EYIibEpcHuw_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_J3UwQ5e6sNU_nid_no_patch() {
int APS5_VABI sceAjmiBatchJobControlBufferRa() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("J3UwQ5e6sNU", libSceAjmiUnknown_J3UwQ5e6sNU_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_LESEGgm133w_nid_no_patch() {
int APS5_VABI sceAjmiInstanceSwitch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("LESEGgm133w", libSceAjmiUnknown_LESEGgm133w_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_MTdd8ApwO50_nid_no_patch() {
int APS5_VABI sceAjmiDecAt9ParseConfigData() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("MTdd8ApwO50", libSceAjmiUnknown_MTdd8ApwO50_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_QhA7rTjJbro_nid_no_patch() {
int APS5_VABI sceAjmiInitialize() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("QhA7rTjJbro", libSceAjmiUnknown_QhA7rTjJbro_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_RbLGSlJB6dc_nid_no_patch() {
int APS5_VABI sceAjmiBatchErrorDump() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("RbLGSlJB6dc", libSceAjmiUnknown_RbLGSlJB6dc_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_Uqtj4RSP_minus_JQ_nid_no_patch() {
int APS5_VABI sceAjmiInstanceCodecType() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Uqtj4RSP-JQ", libSceAjmiUnknown_Uqtj4RSP_minus_JQ_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_X8sT_minus_xi_minus_dVE_nid_no_patch() {
int APS5_VABI sceAjmiMemoryUnregister() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("X8sT-xi-dVE", libSceAjmiUnknown_X8sT_minus_xi_minus_dVE_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_YtubBgSeNH0_nid_no_patch() {
int APS5_VABI sceAjmiInstanceDestroy() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("YtubBgSeNH0", libSceAjmiUnknown_YtubBgSeNH0_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_cWZnCK7na5Y_nid_no_patch() {
int APS5_VABI sceAjmiDecMp3ParseFrame() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("cWZnCK7na5Y", libSceAjmiUnknown_cWZnCK7na5Y_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_dTsNpEt1AqQ_nid_no_patch() {
int APS5_VABI sceAjmiMemoryRegister() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("dTsNpEt1AqQ", libSceAjmiUnknown_dTsNpEt1AqQ_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_dmwcwCeItmE_nid_no_patch() {
int APS5_VABI sceAjmiModuleRegister() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("dmwcwCeItmE", libSceAjmiUnknown_dmwcwCeItmE_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_m0xisYC6U2w_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("m0xisYC6U2w", libSceAjmiUnknown_m0xisYC6U2w_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_ofRX8Vq0ss0_nid_no_patch() {
int APS5_VABI sceAjmiInstanceCreate() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("ofRX8Vq0ss0", libSceAjmiUnknown_ofRX8Vq0ss0_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_pfPwiigOE3A_nid_no_patch() {
int APS5_VABI sceAjmiInstanceExtend() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("pfPwiigOE3A", libSceAjmiUnknown_pfPwiigOE3A_nid_no_patch);
int APS5_VABI libSceAjmiUnknown_r7NMFYcJi08_nid_no_patch() {
int APS5_VABI sceAjmiBatchJobRunSplitBufferRa() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("r7NMFYcJi08", libSceAjmiUnknown_r7NMFYcJi08_nid_no_patch);
}
@@ -7,24 +7,24 @@ extern "C" {
int APS5_VABI sceAjmiBatchCancel();
int APS5_VABI sceAjmiBatchWait();
int APS5_VABI libSceAjmiUnknown_4MsUK9kAnKg_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_6fY_minus_ci3au2U_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_9zA4YMlkR9M_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_BD002VBfhuE_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_EYIibEpcHuw_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_J3UwQ5e6sNU_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_LESEGgm133w_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_MTdd8ApwO50_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_QhA7rTjJbro_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_RbLGSlJB6dc_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_Uqtj4RSP_minus_JQ_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_X8sT_minus_xi_minus_dVE_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_YtubBgSeNH0_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_cWZnCK7na5Y_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_dTsNpEt1AqQ_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_dmwcwCeItmE_nid_no_patch();
int APS5_VABI sceAjmiModuleUnregister();
int APS5_VABI sceAjmiBatchStartBuffer();
int APS5_VABI sceAjmiFinalize();
int APS5_VABI sceAjmiStrError();
int APS5_VABI sceAjmiBatchJobControlBufferRa();
int APS5_VABI sceAjmiInstanceSwitch();
int APS5_VABI sceAjmiDecAt9ParseConfigData();
int APS5_VABI sceAjmiInitialize();
int APS5_VABI sceAjmiBatchErrorDump();
int APS5_VABI sceAjmiInstanceCodecType();
int APS5_VABI sceAjmiMemoryUnregister();
int APS5_VABI sceAjmiInstanceDestroy();
int APS5_VABI sceAjmiDecMp3ParseFrame();
int APS5_VABI sceAjmiMemoryRegister();
int APS5_VABI sceAjmiModuleRegister();
int APS5_VABI libSceAjmiUnknown_m0xisYC6U2w_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_ofRX8Vq0ss0_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_pfPwiigOE3A_nid_no_patch();
int APS5_VABI libSceAjmiUnknown_r7NMFYcJi08_nid_no_patch();
int APS5_VABI sceAjmiInstanceCreate();
int APS5_VABI sceAjmiInstanceExtend();
int APS5_VABI sceAjmiBatchJobRunSplitBufferRa();
}
+7 -13
View File
@@ -5,31 +5,25 @@
#include <cstddef>
#include <cstring>
#include <mutex>
#include <stdexcept>
#include <string>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
#include "prx/libkernel/AppMetadata/include/AppMetadata.hpp"
static std::mutex g_serviceMutex;
static bool g_serviceStarted = false;
static void RequireStarted(const char* function) {
if (!g_serviceStarted) throw std::runtime_error(std::string(function) + ": called before sceAppInstUtilInitialize");
}
static int g_serviceReferences = 0;
static constexpr int ErrorNullArgument = static_cast<int>(0x80A30003);
static constexpr int ErrorNotInitialized = static_cast<int>(0x80A31000);
extern "C" {
int APS5_VABI sceAppInstUtilInitialize(void) {
std::lock_guard lock(g_serviceMutex);
if (g_serviceStarted) throw std::runtime_error("sceAppInstUtilInitialize: the service is already initialized");
g_serviceStarted = true;
++g_serviceReferences;
return 0;
}
int APS5_VABI sceAppInstUtilTerminate(void) {
std::lock_guard lock(g_serviceMutex);
RequireStarted(__func__);
g_serviceStarted = false;
--g_serviceReferences;
return 0;
}
int APS5_VABI sceAppInstUtilAppInstallAll(void* reserved) {
@@ -49,9 +43,9 @@ int APS5_VABI sceAppInstUtilAppIsInUpdating(const char* titleId, bool* updating)
return 0;
}
int APS5_VABI sceAppInstUtilAppExists(const char* titleId, int32_t* exists) {
if (titleId == nullptr || exists == nullptr) return ErrorNullArgument;
std::lock_guard lock(g_serviceMutex);
RequireStarted(__func__);
if (titleId == nullptr || exists == nullptr) APS5_INVALID_ARG_EX;
if (g_serviceReferences <= 0) return ErrorNotInitialized;
*exists = std::strcmp(titleId, GetAppTitleId_nid_postfix().value) == 0 ? 1 : 0;
return 0;
}
@@ -0,0 +1,38 @@
#pragma once
#include "SceTypes.hpp"
extern "C" {
int APS5_VABI sceAudioOut2CustomHrtfIsExist();
int APS5_VABI sceAudioOut2Enable3DAudioForUserForCronos();
int APS5_VABI sceAudioOut2EnableCinematicVrRotation();
int APS5_VABI sceAudioOut2EnableMonoHpOutput();
int APS5_VABI sceAudioOut2EnableTVCorrection();
int APS5_VABI sceAudioOut2SetHearingAssist();
int APS5_VABI sceAudioOut2SetSparkEQ();
int APS5_VABI sceAudioOut2SetSpeakerInfoForCronos();
}
extern "C" {
int APS5_VABI libSceAudioOutUnknown_0E_minus_UkHm_plus_hZI_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_0rE3t9ZgyXE_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_7uryG3ZsXQU_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_9rWEssK8GMk_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_BDnwsIqujuQ_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_EeEaULhU2_minus_g_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_ElgxuhkuY_minus_k_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_GKzVK6pYgTk_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_NuGwMXbT8RU_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_QEcXEGqvnb4_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_aFxSMCVm5mQ_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_cRISiyyeyps_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_cYDvFPDrl6g_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_dDyfkQG1MPc_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_fcv6kkqIs1Y_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_g_minus_JTbmmuf7M_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_mWypJWwaLcc_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_tylNHKM16GA_nid_no_patch();
int APS5_VABI libSceAudioOutUnknown_yd_minus_81WQGSTw_nid_no_patch();
}
@@ -3,3 +3,4 @@
#include "prx/libSceAudioOut/include/AudioOut.hpp"
#include "prx/libSceAudioOut/include/AudioOut2.hpp"
#include "prx/libSceAudioOut/include/InventoryExports.hpp"
#include "prx/libSceAudioOut/include/LaterExports.hpp"
@@ -1,5 +1,6 @@
#include "prx/libc/include/general/ExportMacros.hpp"
#include "prx/libSceAudioOut/include/InventoryExports.hpp"
#include "prx/libSceAudioOut/include/LaterExports.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
@@ -218,3 +219,138 @@ int APS5_VABI libSceAudioOutUnknown_yt9g5kdJy1o_nid_no_patch() {
APS5_EXPORT("yt9g5kdJy1o", libSceAudioOutUnknown_yt9g5kdJy1o_nid_no_patch);
}
extern "C" {
int APS5_VABI sceAudioOut2CustomHrtfIsExist() {
NotImplemented_nid_no_patch(__func__);
}
int APS5_VABI sceAudioOut2Enable3DAudioForUserForCronos() {
NotImplemented_nid_no_patch(__func__);
}
int APS5_VABI sceAudioOut2EnableCinematicVrRotation() {
NotImplemented_nid_no_patch(__func__);
}
int APS5_VABI sceAudioOut2EnableMonoHpOutput() {
NotImplemented_nid_no_patch(__func__);
}
int APS5_VABI sceAudioOut2EnableTVCorrection() {
NotImplemented_nid_no_patch(__func__);
}
int APS5_VABI sceAudioOut2SetHearingAssist() {
NotImplemented_nid_no_patch(__func__);
}
int APS5_VABI sceAudioOut2SetSparkEQ() {
NotImplemented_nid_no_patch(__func__);
}
int APS5_VABI sceAudioOut2SetSpeakerInfoForCronos() {
NotImplemented_nid_no_patch(__func__);
}
}
extern "C" {
int APS5_VABI libSceAudioOutUnknown_0E_minus_UkHm_plus_hZI_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("0E-UkHm+hZI", libSceAudioOutUnknown_0E_minus_UkHm_plus_hZI_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_0rE3t9ZgyXE_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("0rE3t9ZgyXE", libSceAudioOutUnknown_0rE3t9ZgyXE_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_7uryG3ZsXQU_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("7uryG3ZsXQU", libSceAudioOutUnknown_7uryG3ZsXQU_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_9rWEssK8GMk_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("9rWEssK8GMk", libSceAudioOutUnknown_9rWEssK8GMk_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_BDnwsIqujuQ_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("BDnwsIqujuQ", libSceAudioOutUnknown_BDnwsIqujuQ_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_EeEaULhU2_minus_g_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("EeEaULhU2-g", libSceAudioOutUnknown_EeEaULhU2_minus_g_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_ElgxuhkuY_minus_k_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("ElgxuhkuY-k", libSceAudioOutUnknown_ElgxuhkuY_minus_k_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_GKzVK6pYgTk_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("GKzVK6pYgTk", libSceAudioOutUnknown_GKzVK6pYgTk_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_NuGwMXbT8RU_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("NuGwMXbT8RU", libSceAudioOutUnknown_NuGwMXbT8RU_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_QEcXEGqvnb4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("QEcXEGqvnb4", libSceAudioOutUnknown_QEcXEGqvnb4_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_aFxSMCVm5mQ_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("aFxSMCVm5mQ", libSceAudioOutUnknown_aFxSMCVm5mQ_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_cRISiyyeyps_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("cRISiyyeyps", libSceAudioOutUnknown_cRISiyyeyps_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_cYDvFPDrl6g_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("cYDvFPDrl6g", libSceAudioOutUnknown_cYDvFPDrl6g_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_dDyfkQG1MPc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("dDyfkQG1MPc", libSceAudioOutUnknown_dDyfkQG1MPc_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_fcv6kkqIs1Y_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("fcv6kkqIs1Y", libSceAudioOutUnknown_fcv6kkqIs1Y_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_g_minus_JTbmmuf7M_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("g-JTbmmuf7M", libSceAudioOutUnknown_g_minus_JTbmmuf7M_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_mWypJWwaLcc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("mWypJWwaLcc", libSceAudioOutUnknown_mWypJWwaLcc_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_tylNHKM16GA_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("tylNHKM16GA", libSceAudioOutUnknown_tylNHKM16GA_nid_no_patch);
int APS5_VABI libSceAudioOutUnknown_yd_minus_81WQGSTw_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("yd-81WQGSTw", libSceAudioOutUnknown_yd_minus_81WQGSTw_nid_no_patch);
}
+24 -7
View File
@@ -102,18 +102,35 @@ std::int32_t validateCtrl(const AudiodecCtrl* ctrl, std::uint32_t codecType) {
return validateWordSize(wordSizeOf(ctrl->pParam), codecType);
}
std::int32_t validateBuffers(const AudiodecCtrl* ctrl) {
bool invalidStreamSize(std::uint32_t size) {
return size == 0 || size == UINT32_MAX;
}
std::int32_t validateDecodeCtrl(const AudiodecCtrl* ctrl) {
if (!ctrl) return ERROR_INVALID_CTRL_POINTER;
if (!ctrl->pParam) return ERROR_INVALID_PARAM_POINTER;
if (!ctrl->pBsiInfo) return ERROR_INVALID_BSI_INFO_POINTER;
if (!ctrl->pAuInfo) return ERROR_INVALID_AU_INFO_POINTER;
if (!ctrl->pAuInfo->p_au_addr) return ERROR_INVALID_AU_POINTER;
if (!ctrl->pPcmItem) return ERROR_INVALID_PCM_ITEM_POINTER;
if (!ctrl->pPcmItem->p_pcm_addr) return ERROR_INVALID_PCM_POINTER;
if (invalidStreamSize(ctrl->pAuInfo->ui_au_size)) return ERROR_INVALID_AU_SIZE;
if (invalidStreamSize(ctrl->pPcmItem->ui_pcm_size)) return ERROR_INVALID_PCM_SIZE;
if (ctrl->pAuInfo->ui_size != sizeof(AudiodecAuInfo)) return ERROR_INVALID_AU_INFO_SIZE;
if (ctrl->pPcmItem->ui_size != sizeof(AudiodecPcmItem)) return ERROR_INVALID_PCM_ITEM_SIZE;
if (!ctrl->pAuInfo->p_au_addr) return ERROR_INVALID_AU_POINTER;
if (!ctrl->pPcmItem->p_pcm_addr) return ERROR_INVALID_PCM_POINTER;
if (ctrl->pAuInfo->ui_au_size == 0) return ERROR_INVALID_AU_SIZE;
if (ctrl->pPcmItem->ui_pcm_size == 0) return ERROR_INVALID_PCM_SIZE;
return 0;
}
std::int32_t validateDecodeInfo(const AudiodecCtrl* ctrl, std::uint32_t codecType) {
const std::uint32_t infoSize = *static_cast<const std::uint32_t*>(ctrl->pBsiInfo);
if (codecType == TYPE_AT9) {
if (*static_cast<const std::uint32_t*>(ctrl->pParam) != sizeof(AudiodecParamAt9)) return ERROR_INVALID_PARAM_SIZE;
return infoSize == sizeof(AudiodecAt9Info) ? 0 : ERROR_INVALID_BSI_INFO_SIZE;
}
const std::size_t expected = codecType == TYPE_MP3 ? sizeof(AudiodecMp3Info) : sizeof(AudiodecM4aacInfo);
return infoSize == expected ? 0 : ERROR_INVALID_BSI_INFO_SIZE;
}
void fillAt9Info(AudiodecAt9Info* info, const Audiodec::At9Format& format) {
const std::uint32_t superframeSamples = format.frameSamples * format.framesInSuperframe;
info->ui_channel = format.channels;
@@ -231,11 +248,11 @@ int32_t APS5_VABI sceAudiodecClearContext(int32_t handle) {
}
int32_t APS5_VABI sceAudiodecDecode(int32_t handle, AudiodecCtrl* ctrl) {
if (const std::int32_t result = validateDecodeCtrl(ctrl); result != 0) return result;
std::lock_guard lock(g_mutex);
Instance* instance = find(handle);
if (!instance) return ERROR_INVALID_HANDLE;
if (const std::int32_t result = validateCtrl(ctrl, instance->codecType); result != 0) return result;
if (const std::int32_t result = validateBuffers(ctrl); result != 0) return result;
if (const std::int32_t result = validateDecodeInfo(ctrl, instance->codecType); result != 0) return result;
const Audiodec::DecodeResult decoded = instance->decoder->Decode(static_cast<const std::uint8_t*>(ctrl->pAuInfo->p_au_addr), ctrl->pAuInfo->ui_au_size,
static_cast<std::uint8_t*>(ctrl->pPcmItem->p_pcm_addr), ctrl->pPcmItem->ui_pcm_size);
@@ -12,4 +12,13 @@ if(BUILD_TESTING)
set_tests_properties(guest_avplayer_native PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceAvPlayer.native>")
endif()
add_test_executable(guest_avplayer_native_printf_tests ${LIBS_INCLUDE_DIR}/tests/GuestAvPlayerNativePrintf.cpp)
target_include_directories(guest_avplayer_native_printf_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_avplayer_native_printf_tests PRIVATE libSceAvPlayer.native libc)
configure_windows_unwind(guest_avplayer_native_printf_tests)
add_test(NAME guest_avplayer_native_printf COMMAND guest_avplayer_native_printf_tests)
if(WIN32)
set_tests_properties(guest_avplayer_native_printf PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceAvPlayer.native>")
endif()
endif()
+20 -6
View File
@@ -1,19 +1,33 @@
#include "prx/libSceAvPlayer.native/include/Api.hpp"
#include <cstdarg>
#include <cstdint>
#include <cstddef>
#include <cstdio>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
#include "prx/libSceAvPlayer/include/LogCallback.hpp"
extern "C" {
int APS5_VABI sceAvPlayerPrintf(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
int APS5_VABI sceAvPlayerPrintf(const char* format, ...) {
if (!format) return -1;
#ifdef _WIN32
__builtin_sysv_va_list arguments;
__builtin_sysv_va_start(arguments, format);
const int result = SceAvPlayerWriteLog(format, reinterpret_cast<VaList*>(arguments));
__builtin_sysv_va_end(arguments);
#else
std::va_list arguments;
va_start(arguments, format);
const int result = SceAvPlayerWriteLog(format, reinterpret_cast<VaList*>(arguments));
va_end(arguments);
#endif
return result;
}
int APS5_VABI sceAvPlayerVprintf(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
int APS5_VABI sceAvPlayerVprintf(const char* format, VaList* arguments) {
if (!format) return -1;
return SceAvPlayerWriteLog(format, arguments);
}
}
@@ -1,10 +1,11 @@
#pragma once
#include "SceTypes.hpp"
#include <cstdarg>
extern "C" {
int APS5_VABI sceAvPlayerPrintf(void);
int APS5_VABI sceAvPlayerVprintf(void);
int APS5_VABI sceAvPlayerPrintf(const char* format, ...);
int APS5_VABI sceAvPlayerVprintf(const char* format, VaList* arguments);
}
+31 -2
View File
@@ -5,15 +5,21 @@
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <string_view>
#include "SceTypes.hpp"
#include "prx/libSceAvPlayer/include/AvPlayer.hpp"
#include "prx/libSceAvPlayer/include/LogCallback.hpp"
#include "prx/libc/include/WindowsFormatting.hpp"
using namespace AvPlayer;
namespace {
void* LogCallback = nullptr;
void* LogUserData = nullptr;
Player* ToPlayer(AvPlayerInternal* h) {
return static_cast<Player*>(h);
}
@@ -28,6 +34,30 @@ constexpr std::size_t Ps5VideoFrameBuffersOffset = 0x228;
}
extern "C" {
void SceAvPlayerSetLogCallbackState(void* callback, void* user_data) {
LogCallback = callback;
LogUserData = user_data;
}
int SceAvPlayerWriteLog(const char* format, VaList* arguments) {
if (LogCallback) {
return reinterpret_cast<SceAvPlayerLogCallback>(LogCallback)(LogUserData, format, arguments);
}
#ifdef _WIN32
return LibcDetail::PrintWindows(format, arguments);
#else
std::va_list copy;
va_copy(copy, *reinterpret_cast<std::va_list*>(arguments));
const int result = std::vprintf(format, copy);
va_end(copy);
return result;
#endif
}
}
#pragma GCC visibility push(default)
extern "C" {
@@ -156,8 +186,7 @@ int APS5_VABI sceAvPlayerSetAvailableBandwidth(AvPlayerInternal* h, uint32_t sta
}
int APS5_VABI sceAvPlayerSetLogCallback(void* callback, void* user_data) {
(void)callback;
(void)user_data;
SceAvPlayerSetLogCallbackState(callback, user_data);
return SCE_OK;
}
@@ -0,0 +1,12 @@
#pragma once
#include "SceTypes.hpp"
#include <cstdarg>
extern "C" {
typedef int (APS5_VABI* SceAvPlayerLogCallback)(void* user_data, const char* format, VaList* arguments);
void SceAvPlayerSetLogCallbackState(void* callback, void* user_data);
int SceAvPlayerWriteLog(const char* format, VaList* arguments);
}
@@ -42,13 +42,16 @@ int APS5_VABI scePlayerReviewDialogTerminate(void) {
int APS5_VABI scePlayerReviewDialogOpen(const PlayerReviewDialogParam* param) {
if (param == nullptr) return COMMON_DIALOG_ERROR_ARG_NULL;
const int status = g_status.load();
int status = g_status.load();
if (status == COMMON_DIALOG_STATUS_NONE) return COMMON_DIALOG_ERROR_NOT_INITIALIZED;
if (status == COMMON_DIALOG_STATUS_RUNNING) return COMMON_DIALOG_ERROR_BUSY;
if (!ValidateCommonDialogBaseParam(param->base) || param->size != sizeof(*param) || param->userId == -1 || !std::all_of(std::begin(param->reserved), std::end(param->reserved), [](std::uint8_t value) { return value == 0; }) || param->mode > 1) return COMMON_DIALOG_ERROR_INVALID_ARGUMENT;
UserServiceLoginUserIdList users{};
if (sceUserServiceGetLoginUserIdList(&users) != 0 || std::none_of(std::begin(users.user_id), std::end(users.user_id), [param](std::int32_t userId) { return userId != -1 && userId == param->userId; })) return COMMON_DIALOG_ERROR_INVALID_ARGUMENT;
g_status = COMMON_DIALOG_STATUS_FINISHED;
while (!g_status.compare_exchange_weak(status, COMMON_DIALOG_STATUS_FINISHED)) {
if (status == COMMON_DIALOG_STATUS_NONE) return COMMON_DIALOG_ERROR_NOT_INITIALIZED;
if (status == COMMON_DIALOG_STATUS_RUNNING) return COMMON_DIALOG_ERROR_BUSY;
}
return 0;
}
+12
View File
@@ -2078,6 +2078,18 @@ const uint8_t* APS5_VABI sceCesRefersUcsProfileCp1258(void) {
return singleByteProfile(SingleByte::Cp1258);
}
const uint8_t* APS5_VABI sceCesRefersUcsProfileCp1253(void) {
return singleByteProfile(SingleByte::Cp1253);
}
const uint8_t* APS5_VABI sceCesRefersUcsProfileCp1255(void) {
return singleByteProfile(SingleByte::Cp1255);
}
const uint8_t* APS5_VABI sceCesRefersUcsProfileCp1257(void) {
return singleByteProfile(SingleByte::Cp1257);
}
const uint8_t* APS5_VABI sceCesRefersUcsProfileAscii(void) {
return singleByteProfile(SingleByte::Ascii);
}
@@ -12,19 +12,4 @@ int APS5_VABI sceCesIso2022JpUcsProfileSetSbcs(void) {
return 0;
}
int APS5_VABI sceCesRefersUcsProfileCp1253(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceCesRefersUcsProfileCp1255(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceCesRefersUcsProfileCp1257(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
}
+41 -1
View File
@@ -54,6 +54,9 @@ enum Table : std::size_t {
JisX0201Tilde0x7e,
KsX1003,
KsX1003Tilde0x7e,
Cp1253,
Cp1255,
Cp1257,
Cp864,
Count,
};
@@ -541,6 +544,36 @@ inline constexpr uint16_t HIGH[Count][128] = {
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
},
{
0x20AC, Unassigned, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, Unassigned, 0x2030, Unassigned, 0x2039, Unassigned, Unassigned, Unassigned, Unassigned,
Unassigned, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, Unassigned, 0x2122, Unassigned, 0x203A, Unassigned, Unassigned, Unassigned, Unassigned,
0x00A0, 0x0385, 0x0386, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, Unassigned, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x2015,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x00B5, 0x00B6, 0x00B7, 0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F,
0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
0x03A0, 0x03A1, Unassigned, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF,
0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, Unassigned,
},
{
0x20AC, Unassigned, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6, 0x2030, Unassigned, 0x2039, Unassigned, Unassigned, Unassigned, Unassigned,
Unassigned, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x02DC, 0x2122, Unassigned, 0x203A, Unassigned, Unassigned, Unassigned, Unassigned,
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x20AA, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
0x05B0, 0x05B1, 0x05B2, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7, 0x05B8, 0x05B9, Unassigned, 0x05BB, 0x05BC, 0x05BD, 0x05BE, 0x05BF,
0x05C0, 0x05C1, 0x05C2, 0x05C3, 0x05F0, 0x05F1, 0x05F2, 0x05F3, 0x05F4, Unassigned, Unassigned, Unassigned, Unassigned, Unassigned, Unassigned, Unassigned,
0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, Unassigned, Unassigned, 0x200E, 0x200F, Unassigned,
},
{
0x20AC, Unassigned, 0x201A, Unassigned, 0x201E, 0x2026, 0x2020, 0x2021, Unassigned, 0x2030, Unassigned, 0x2039, Unassigned, 0x00A8, 0x02C7, 0x00B8,
Unassigned, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, Unassigned, 0x2122, Unassigned, 0x203A, Unassigned, 0x00AF, 0x02DB, Unassigned,
0x00A0, Unassigned, 0x00A2, 0x00A3, 0x00A4, Unassigned, 0x00A6, 0x00A7, 0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00C6,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6,
0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112, 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B,
0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, 0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF,
0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C,
0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7, 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x02D9,
},
{
0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518,
0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0xFFFF, 0xFFFF, 0xFEFB, 0xFEFC, 0xFFFF,
@@ -607,6 +640,9 @@ inline constexpr LowCode LOW[Count][2] = {
{{0x5C, 0x00A5}},
{{0x5C, 0x20A9}, {0x7E, 0x203E}},
{{0x5C, 0x20A9}},
{},
{},
{},
{{0x25, 0x066A}},
};
@@ -614,7 +650,8 @@ inline constexpr bool SEVEN_BIT[Count] = {
false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false, false, false, true, false, true, true,
true, false, true, true, true, false, true, true, false,
true, false, true, true, true, false, true, true,
false, false, false, false,
};
inline constexpr bool LOW_GRAPHICS_UNASSIGNED[Count] = {
@@ -667,6 +704,9 @@ inline constexpr bool LOW_GRAPHICS_UNASSIGNED[Count] = {
false,
false,
false,
false,
false,
false,
};
}
+3 -3
View File
@@ -234,9 +234,9 @@ int APS5_VABI sceCesMbcsUcsSetMbcsReplacementCharUCode(void* context, uint32_t u
const uint8_t* APS5_VABI sceCesRefersUcsProfileAscii(void);
const uint8_t* APS5_VABI sceCesRefersUcsProfileAsciiWithKatakana(void);
const uint8_t* APS5_VABI sceCesRefersUcsProfileBs4730(void);
int APS5_VABI sceCesRefersUcsProfileCp1253(void);
int APS5_VABI sceCesRefersUcsProfileCp1255(void);
int APS5_VABI sceCesRefersUcsProfileCp1257(void);
const uint8_t* APS5_VABI sceCesRefersUcsProfileCp1253(void);
const uint8_t* APS5_VABI sceCesRefersUcsProfileCp1255(void);
const uint8_t* APS5_VABI sceCesRefersUcsProfileCp1257(void);
const uint8_t* APS5_VABI sceCesRefersUcsProfileCp857(void);
const uint8_t* APS5_VABI sceCesRefersUcsProfileCp869(void);
const uint8_t* APS5_VABI sceCesRefersUcsProfileCp874(void);
@@ -126,32 +126,26 @@ int APS5_VABI sceCompanionHttpdSetBody(const char* body, std::uint64_t size, voi
}
int APS5_VABI sceCompanionHttpdGet2ndScreenStatus(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceCompanionHttpdGetUserId(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceCompanionHttpdInitialize2(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceCompanionHttpdRegisterRequestBodyReceptionCallback(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceCompanionHttpdRegisterRequestCallback2(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceCompanionHttpdUnregisterRequestBodyReceptionCallback(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
+12 -6
View File
@@ -85,18 +85,24 @@ int APS5_VABI sceContentExportFrom(void) {
}
int APS5_VABI sceContentExportFromFileForSf(std::int32_t expId, const ContentExportParam* param, const ContentExportSfParam* sfParam, const char* sourcePath, const char* thumbnailPath, char* path, std::size_t pathBufferLength) {
NotImplemented_nid_no_patch(__func__);
return 0;
std::lock_guard lock(g_sessionMutex);
RequireSession(__func__, expId);
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceContentExportFromFileWithContentIdList(std::int32_t expId, const ContentExportParam* param, const char* sourcePath, const char* thumbnailPath, const std::int64_t* contentIds, std::uint32_t contentCount, char* path, std::size_t pathBufferLength) {
NotImplemented_nid_no_patch(__func__);
return 0;
std::lock_guard lock(g_sessionMutex);
RequireSession(__func__, expId);
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceContentExportFromFileWithTitleIdList(std::int32_t expId, const ContentExportParam* param, const char* sourcePath, const char* thumbnailPath, const char* titleIdList, char* path, std::size_t pathBufferLength) {
NotImplemented_nid_no_patch(__func__);
return 0;
std::lock_guard lock(g_sessionMutex);
RequireSession(__func__, expId);
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceContentExportInit(const ContentExportInitParam* param) {
@@ -34,10 +34,9 @@ int APS5_VABI customMusicPlayReady4LegacyUnknown_22PDPuDQG_minus_M_nid_no_patch(
}
APS5_EXPORT("22PDPuDQG-M", customMusicPlayReady4LegacyUnknown_22PDPuDQG_minus_M_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_2G9_minus_Dn_minus_tsSA_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyBufferMalloc() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("2G9-Dn-tsSA", customMusicPlayReady4LegacyUnknown_2G9_minus_Dn_minus_tsSA_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_3NXC30GzkpE_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
@@ -54,10 +53,9 @@ int APS5_VABI customMusicPlayReady4LegacyUnknown_3f1p8hnCT_minus_E_nid_no_patch(
}
APS5_EXPORT("3f1p8hnCT-E", customMusicPlayReady4LegacyUnknown_3f1p8hnCT_minus_E_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_4ti9Z3f6i5k_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyStoreCleanup() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("4ti9Z3f6i5k", customMusicPlayReady4LegacyUnknown_4ti9Z3f6i5k_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_6rmPEBymtCw_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
@@ -69,10 +67,9 @@ int APS5_VABI customMusicPlayReady4LegacyUnknown_8Bm7S9Vdc1c_nid_no_patch() {
}
APS5_EXPORT("8Bm7S9Vdc1c", customMusicPlayReady4LegacyUnknown_8Bm7S9Vdc1c_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_8PkaYafg_plus_JY_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyReaderBind() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("8PkaYafg+JY", customMusicPlayReady4LegacyUnknown_8PkaYafg_plus_JY_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_8bpWr65Gw3M_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
@@ -94,10 +91,9 @@ int APS5_VABI customMusicPlayReady4LegacyUnknown_9T5tJy16kV8_nid_no_patch() {
}
APS5_EXPORT("9T5tJy16kV8", customMusicPlayReady4LegacyUnknown_9T5tJy16kV8_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_B67MDDZLP3w_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyFinalize() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("B67MDDZLP3w", customMusicPlayReady4LegacyUnknown_B67MDDZLP3w_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_EGrgP9DR2FI_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
@@ -114,10 +110,9 @@ int APS5_VABI customMusicPlayReady4LegacyUnknown_H1Cm6TaA_minus_c4_nid_no_patch(
}
APS5_EXPORT("H1Cm6TaA-c4", customMusicPlayReady4LegacyUnknown_H1Cm6TaA_minus_c4_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_HCgz5p5pO1M_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyMemFree() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("HCgz5p5pO1M", customMusicPlayReady4LegacyUnknown_HCgz5p5pO1M_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_He1EUNsSDT0_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
@@ -129,45 +124,40 @@ int APS5_VABI customMusicPlayReady4LegacyUnknown_IoKOXedG_plus_Ok_nid_no_patch()
}
APS5_EXPORT("IoKOXedG+Ok", customMusicPlayReady4LegacyUnknown_IoKOXedG_plus_Ok_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_LRQY2jsxnJI_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyBufferFree() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("LRQY2jsxnJI", customMusicPlayReady4LegacyUnknown_LRQY2jsxnJI_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_MBROhxkvkjs_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("MBROhxkvkjs", customMusicPlayReady4LegacyUnknown_MBROhxkvkjs_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_Ot1T0TKkYZg_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyMemRealloc() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Ot1T0TKkYZg", customMusicPlayReady4LegacyUnknown_Ot1T0TKkYZg_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_OtOGIehVSt4_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyBufferRealloc() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("OtOGIehVSt4", customMusicPlayReady4LegacyUnknown_OtOGIehVSt4_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_P7k_plus_0QIqke0_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("P7k+0QIqke0", customMusicPlayReady4LegacyUnknown_P7k_plus_0QIqke0_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_Puass3BLcIk_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyCdmiLoad() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Puass3BLcIk", customMusicPlayReady4LegacyUnknown_Puass3BLcIk_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_QD_plus_E9EybrSc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("QD+E9EybrSc", customMusicPlayReady4LegacyUnknown_QD_plus_E9EybrSc_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_QsbHVhJ3xEA_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyCdmiUpdate() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("QsbHVhJ3xEA", customMusicPlayReady4LegacyUnknown_QsbHVhJ3xEA_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_R_plus_lU8Vokisk_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
@@ -179,30 +169,26 @@ int APS5_VABI customMusicPlayReady4LegacyUnknown_R3woi4ILIsQ_nid_no_patch() {
}
APS5_EXPORT("R3woi4ILIsQ", customMusicPlayReady4LegacyUnknown_R3woi4ILIsQ_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_RfHY_minus_Ba2ap4_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyCdmiRemove() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("RfHY-Ba2ap4", customMusicPlayReady4LegacyUnknown_RfHY_minus_Ba2ap4_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_Te5nrRJAxOw_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyLicenseDelete() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Te5nrRJAxOw", customMusicPlayReady4LegacyUnknown_Te5nrRJAxOw_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_Ubo6V3NmKYc_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyUnlink() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Ubo6V3NmKYc", customMusicPlayReady4LegacyUnknown_Ubo6V3NmKYc_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_UquDHokokVk_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("UquDHokokVk", customMusicPlayReady4LegacyUnknown_UquDHokokVk_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_VY_minus_v3HGTTMA_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyInitialize() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("VY-v3HGTTMA", customMusicPlayReady4LegacyUnknown_VY_minus_v3HGTTMA_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_VxM1jP5AsbA_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
@@ -239,20 +225,18 @@ int APS5_VABI customMusicPlayReady4LegacyUnknown_ZF9yYeEaQgo_nid_no_patch() {
}
APS5_EXPORT("ZF9yYeEaQgo", customMusicPlayReady4LegacyUnknown_ZF9yYeEaQgo_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_ZcWzMk9_plus_xCE_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyApiStart() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("ZcWzMk9+xCE", customMusicPlayReady4LegacyUnknown_ZcWzMk9_plus_xCE_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_a_minus_t8J_minus__minus_PwCU_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("a-t8J--PwCU", customMusicPlayReady4LegacyUnknown_a_minus_t8J_minus__minus_PwCU_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_ai5JotXAbQI_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyCdmiClose() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("ai5JotXAbQI", customMusicPlayReady4LegacyUnknown_ai5JotXAbQI_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_b8EPlts2i3Q_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
@@ -269,10 +253,9 @@ int APS5_VABI customMusicPlayReady4LegacyUnknown_dIGY_minus_SEf1J0_nid_no_patch(
}
APS5_EXPORT("dIGY-SEf1J0", customMusicPlayReady4LegacyUnknown_dIGY_minus_SEf1J0_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_dOj2LWDnVGI_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyBufferInit() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("dOj2LWDnVGI", customMusicPlayReady4LegacyUnknown_dOj2LWDnVGI_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_dSrDh1gljnU_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
@@ -309,10 +292,9 @@ int APS5_VABI customMusicPlayReady4LegacyUnknown_g3r22JvImAM_nid_no_patch() {
}
APS5_EXPORT("g3r22JvImAM", customMusicPlayReady4LegacyUnknown_g3r22JvImAM_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_g9EIY6p97OQ_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyMemAlloc() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("g9EIY6p97OQ", customMusicPlayReady4LegacyUnknown_g9EIY6p97OQ_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_jVTkCgb0nDk_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
@@ -324,20 +306,18 @@ int APS5_VABI customMusicPlayReady4LegacyUnknown_o3cColUYySI_nid_no_patch() {
}
APS5_EXPORT("o3cColUYySI", customMusicPlayReady4LegacyUnknown_o3cColUYySI_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_odzl7DZarOI_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyReaderDecrypt() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("odzl7DZarOI", customMusicPlayReady4LegacyUnknown_odzl7DZarOI_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_oidw_plus_viysuk_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("oidw+viysuk", customMusicPlayReady4LegacyUnknown_oidw_plus_viysuk_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_pirbKf6n6mo_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyApiStop() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("pirbKf6n6mo", customMusicPlayReady4LegacyUnknown_pirbKf6n6mo_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_pwX56Tpmq8Q_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
@@ -354,20 +334,18 @@ int APS5_VABI customMusicPlayReady4LegacyUnknown_qXdAcP7SjLw_nid_no_patch() {
}
APS5_EXPORT("qXdAcP7SjLw", customMusicPlayReady4LegacyUnknown_qXdAcP7SjLw_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_rRIQK67BCB8_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyReaderCommit() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("rRIQK67BCB8", customMusicPlayReady4LegacyUnknown_rRIQK67BCB8_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_rzZ9pwS94rs_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("rzZ9pwS94rs", customMusicPlayReady4LegacyUnknown_rzZ9pwS94rs_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_sH7aon3o7j8_nid_no_patch() {
int APS5_VABI sceCustomMusicPlayReadyReaderClose() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("sH7aon3o7j8", customMusicPlayReady4LegacyUnknown_sH7aon3o7j8_nid_no_patch);
int APS5_VABI customMusicPlayReady4LegacyUnknown_tFvu6lioQ0I_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
@@ -10,40 +10,40 @@ int APS5_VABI customMusicPlayReady4LegacyUnknown__minus_L_plus_RF25Tp_plus_Q_nid
int APS5_VABI customMusicPlayReady4LegacyUnknown_0p2nr6DTns4_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_19gH7n14WFE_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_22PDPuDQG_minus_M_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_2G9_minus_Dn_minus_tsSA_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyBufferMalloc();
int APS5_VABI customMusicPlayReady4LegacyUnknown_3NXC30GzkpE_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_3ZSo0WzWH0Q_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_3f1p8hnCT_minus_E_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_4ti9Z3f6i5k_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyStoreCleanup();
int APS5_VABI customMusicPlayReady4LegacyUnknown_6rmPEBymtCw_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_8Bm7S9Vdc1c_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_8PkaYafg_plus_JY_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyReaderBind();
int APS5_VABI customMusicPlayReady4LegacyUnknown_8bpWr65Gw3M_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_8wb_plus_q_plus_GlgbM_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_9Dg_plus_YcRTVy4_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_9T5tJy16kV8_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_B67MDDZLP3w_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyFinalize();
int APS5_VABI customMusicPlayReady4LegacyUnknown_EGrgP9DR2FI_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_GBi7nfZxcxw_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_H1Cm6TaA_minus_c4_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_HCgz5p5pO1M_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyMemFree();
int APS5_VABI customMusicPlayReady4LegacyUnknown_He1EUNsSDT0_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_IoKOXedG_plus_Ok_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_LRQY2jsxnJI_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyBufferFree();
int APS5_VABI customMusicPlayReady4LegacyUnknown_MBROhxkvkjs_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_Ot1T0TKkYZg_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_OtOGIehVSt4_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyMemRealloc();
int APS5_VABI sceCustomMusicPlayReadyBufferRealloc();
int APS5_VABI customMusicPlayReady4LegacyUnknown_P7k_plus_0QIqke0_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_Puass3BLcIk_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyCdmiLoad();
int APS5_VABI customMusicPlayReady4LegacyUnknown_QD_plus_E9EybrSc_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_QsbHVhJ3xEA_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyCdmiUpdate();
int APS5_VABI customMusicPlayReady4LegacyUnknown_R_plus_lU8Vokisk_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_R3woi4ILIsQ_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_RfHY_minus_Ba2ap4_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_Te5nrRJAxOw_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_Ubo6V3NmKYc_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyCdmiRemove();
int APS5_VABI sceCustomMusicPlayReadyLicenseDelete();
int APS5_VABI sceCustomMusicPlayReadyUnlink();
int APS5_VABI customMusicPlayReady4LegacyUnknown_UquDHokokVk_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_VY_minus_v3HGTTMA_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyInitialize();
int APS5_VABI customMusicPlayReady4LegacyUnknown_VxM1jP5AsbA_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_W4CCMYydloQ_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_WnjQGtO2Zb8_nid_no_patch();
@@ -51,13 +51,13 @@ int APS5_VABI customMusicPlayReady4LegacyUnknown_WuGl5uZDeRs_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_XeOVOR20YoQ_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_ZCJ9MHGdy6Y_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_ZF9yYeEaQgo_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_ZcWzMk9_plus_xCE_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyApiStart();
int APS5_VABI customMusicPlayReady4LegacyUnknown_a_minus_t8J_minus__minus_PwCU_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_ai5JotXAbQI_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyCdmiClose();
int APS5_VABI customMusicPlayReady4LegacyUnknown_b8EPlts2i3Q_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_c7PBSVey838_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_dIGY_minus_SEf1J0_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_dOj2LWDnVGI_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyBufferInit();
int APS5_VABI customMusicPlayReady4LegacyUnknown_dSrDh1gljnU_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_eZI6nOaH3T8_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_eb6nz6Q91VY_nid_no_patch();
@@ -65,18 +65,18 @@ int APS5_VABI customMusicPlayReady4LegacyUnknown_fIb77Jl_minus_8BM_nid_no_patch(
int APS5_VABI customMusicPlayReady4LegacyUnknown_fWaJ_plus_0_minus_ptrg_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_ff7P9skOZr8_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_g3r22JvImAM_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_g9EIY6p97OQ_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyMemAlloc();
int APS5_VABI customMusicPlayReady4LegacyUnknown_jVTkCgb0nDk_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_o3cColUYySI_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_odzl7DZarOI_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyReaderDecrypt();
int APS5_VABI customMusicPlayReady4LegacyUnknown_oidw_plus_viysuk_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_pirbKf6n6mo_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyApiStop();
int APS5_VABI customMusicPlayReady4LegacyUnknown_pwX56Tpmq8Q_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_q6SSNVt6LAo_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_qXdAcP7SjLw_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_rRIQK67BCB8_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyReaderCommit();
int APS5_VABI customMusicPlayReady4LegacyUnknown_rzZ9pwS94rs_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_sH7aon3o7j8_nid_no_patch();
int APS5_VABI sceCustomMusicPlayReadyReaderClose();
int APS5_VABI customMusicPlayReady4LegacyUnknown_tFvu6lioQ0I_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_udAxCLwq69I_nid_no_patch();
int APS5_VABI customMusicPlayReady4LegacyUnknown_v1vu4XXyGpw_nid_no_patch();
+5 -21
View File
@@ -10,10 +10,6 @@
#include "HitLog.hpp"
#include "prx/libc/include/General.hpp"
#ifdef _WIN32
#include <windows.h>
#endif
namespace {
constexpr int kStatusNone = 0;
constexpr int kStatusInitialized = 1;
@@ -33,19 +29,6 @@ std::mutex g_lock;
int g_status = kStatusNone;
bool g_presented = false;
bool Readable(const void* p, std::size_t n) {
#ifdef _WIN32
if (p == nullptr) return false;
MEMORY_BASIC_INFORMATION mbi;
if (VirtualQuery(p, &mbi, sizeof(mbi)) == 0 || mbi.State != MEM_COMMIT) return false;
if ((mbi.Protect & (PAGE_NOACCESS | PAGE_GUARD)) != 0) return false;
const auto end = reinterpret_cast<std::uintptr_t>(mbi.BaseAddress) + mbi.RegionSize;
return reinterpret_cast<std::uintptr_t>(p) + n <= end;
#else
return p != nullptr;
#endif
}
void Refresh() {
if (g_status != kStatusRunning || !g_presented) return;
std::size_t chosen = 0;
@@ -65,14 +48,15 @@ int APS5_VABI sceErrorDialogInitialize(void) {
int APS5_VABI sceErrorDialogOpen(const void* param) {
std::lock_guard g(g_lock);
if (g_status != kStatusInitialized && g_status != kStatusFinished) return kErrInvalidState;
if (!Readable(param, kParamSize)) return kErrParam;
std::uint8_t buffer[kParamSize];
if (param == nullptr || !GuestCopyIn_nid_no_patch(buffer, param, kParamSize)) return kErrParam;
std::int32_t size = 0;
std::memcpy(&size, param, sizeof(size));
std::memcpy(&size, buffer, sizeof(size));
if (static_cast<std::size_t>(size) != kParamSize) return kErrParam;
std::int32_t errorCode = 0;
std::int32_t userId = 0;
std::memcpy(&errorCode, static_cast<const std::uint8_t*>(param) + 4, sizeof(errorCode));
std::memcpy(&userId, static_cast<const std::uint8_t*>(param) + 8, sizeof(userId));
std::memcpy(&errorCode, buffer + 4, sizeof(errorCode));
std::memcpy(&userId, buffer + 8, sizeof(userId));
ModalDialogRequest request = ErrorDialog::BuildRequest(errorCode);
request.owner = ModalDialogOwnerErrorDialog;
g_presented = ModalDialogOpen_nid_postfix(request);
+1 -1
View File
@@ -365,7 +365,7 @@ int APS5_VABI sceFontGraphicsDrawupFillRadialGradient(FontGraphicsFrame* graphic
int APS5_VABI sceFontGraphicsAdjustGradientSpread();
int APS5_VABI sceFontGraphicsCanvasSetSurfaceFillWithLayout();
int APS5_VABI sceFontGraphicsCanvasGetPreprocess();
int APS5_VABI sceFontGraphicsReportError();
int APS5_VABI sceFontGraphicsReportError(int error);
int APS5_VABI sceFontGraphicsDrawRectangleShape();
int APS5_VABI sceFontGraphicsProcessSetSyncPolicy();
int APS5_VABI sceFontGraphicsCanvasSetSurfaceFillWithMapping();
@@ -8,6 +8,7 @@
namespace Font {
void SetGraphicsErrorCallback(GraphicsErrorCallback callback);
int ReportGraphicsError(int error);
int GraphicsRegionInit(FontGraphicsRegion* region, float x, float y, float width, float height);
int GraphicsRegionInitCircular(FontGraphicsRegion* region, float centerX, float centerY, float outerRadius, float innerRadius);
int GraphicsRegionInitRoundish(FontGraphicsRegion* region, float x, float y, float width, float height, float outerRadius, float innerRadius, std::uint32_t flags);
@@ -310,6 +310,13 @@ void SetGraphicsErrorCallback(GraphicsErrorCallback callback) {
g_errorCallback.store(callback);
}
int ReportGraphicsError(int error) {
const auto callback = g_errorCallback.load();
if (callback == nullptr) return static_cast<int>(0x80460020);
callback(error);
return 0;
}
int GraphicsRegionInit(FontGraphicsRegion* region, float x, float y, float width, float height) {
if (!region || 0.0f > width || 0.0f > height) return Fail(SCE_FONT_ERROR_INVALID_PARAMETER);
*region = {x, y, width, height, RectangleRegionFlags, RegionTag, 0.0f, 0.0f};
@@ -494,8 +494,8 @@ int APS5_VABI sceFontGraphicsCanvasGetPreprocess() {
NotImplemented_nid_no_patch(__func__);
}
int APS5_VABI sceFontGraphicsReportError() {
NotImplemented_nid_no_patch(__func__);
int APS5_VABI sceFontGraphicsReportError(int error) {
return Font::ReportGraphicsError(error);
}
int APS5_VABI sceFontGraphicsDrawRectangleShape() {
+1 -2
View File
@@ -66,8 +66,7 @@ int APS5_VABI sceFontFtSupportPfr(FontLibrary library) {
}
int APS5_VABI sceFontFtSupportSystemFonts(FontLibrary library) {
NotImplemented_nid_no_patch(__func__);
return 0;
return FontFt::SupportFormats(library, {"cff", "truetype"});
}
int APS5_VABI sceFontFtSupportTrueType(FontLibrary library) {
+18
View File
@@ -0,0 +1,18 @@
add_library(libSceFontGs SHARED EXCLUDE_FROM_ALL
${CMAKE_CURRENT_SOURCE_DIR}/Export.cpp
)
target_include_directories(libSceFontGs PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(libSceFontGs PRIVATE libSceFont libkernel_sys)
configure_windows_unwind(libSceFontGs)
if(BUILD_TESTING)
add_test_executable(guest_font_gs_gnm_tests ${LIBS_INCLUDE_DIR}/tests/GuestFontGsGnm.cpp)
target_include_directories(guest_font_gs_gnm_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_font_gs_gnm_tests PRIVATE libSceFontGs libSceFont libkernel libc)
configure_windows_unwind(guest_font_gs_gnm_tests)
add_test(NAME guest_font_gs_gnm COMMAND guest_font_gs_gnm_tests)
if(WIN32)
set_tests_properties(guest_font_gs_gnm PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceFontGs>;PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceFont>;PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel_sys>")
endif()
endif()
+818 -18
View File
@@ -1,39 +1,839 @@
#include "prx/libSceFontGs/include/InventoryExports.hpp"
#include "prx/libSceFont/include/Api.hpp"
#include "prx/libkernel_sys/include/Api.hpp"
#include <array>
#include <bit>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
namespace {
constexpr int FontGsFatal = static_cast<int>(0x80460001);
constexpr int FontGsInvalidParameter = static_cast<int>(0x80460002);
constexpr int FontGsInvalidSequence = static_cast<int>(0x8046009a);
constexpr int FontGsSequenceLocked = static_cast<int>(0x804600b8);
constexpr std::uint8_t FontGnmSurfaceTag = 0x48;
constexpr std::uint16_t FontGnmSequenceTag = 0xf80;
constexpr float FontGnmDrawupLimit = 16834.0f;
constexpr std::size_t FontGnmRecordStateOffset = 0x10;
struct FontGnmSurface {
void* head;
std::uint8_t reserved8[5];
std::uint8_t tag;
std::uint8_t reserved0e;
std::uint8_t mode;
std::uint8_t reserved10[0xc];
std::uint32_t busy;
std::uint8_t reserved20[8];
const void* fillObject;
std::uint8_t reserved30[8];
std::uint32_t initialized;
};
static_assert(offsetof(FontGnmSurface, tag) == 0x0d);
static_assert(offsetof(FontGnmSurface, mode) == 0x0f);
static_assert(offsetof(FontGnmSurface, busy) == 0x1c);
static_assert(offsetof(FontGnmSurface, fillObject) == 0x28);
static_assert(offsetof(FontGnmSurface, initialized) == 0x38);
struct FontGnmCommands {
std::uint8_t reserved[0x28];
const void* first;
std::uint32_t firstSize;
std::uint32_t secondCount;
const void* second;
};
static_assert(offsetof(FontGnmCommands, first) == 0x28);
static_assert(offsetof(FontGnmCommands, firstSize) == 0x30);
static_assert(offsetof(FontGnmCommands, secondCount) == 0x34);
static_assert(offsetof(FontGnmCommands, second) == 0x38);
struct FontGnmSequence {
std::uint16_t tag;
std::uint8_t reserved2[0x19];
std::uint8_t lock;
std::uint8_t reserved1c[0xc];
FontGnmCommands* commands;
};
static_assert(offsetof(FontGnmSequence, lock) == 0x1b);
static_assert(offsetof(FontGnmSequence, commands) == 0x28);
constexpr int FontGsSurfaceConfigInvalid = static_cast<int>(0x8046005c);
constexpr std::uint8_t FontGnmSurfaceConfigTag = 0x44;
enum GnmArrayModeValue : std::uint32_t {
GnmArrayModeLinearGeneral = 0,
GnmArrayModeLinearAligned = 1,
GnmArrayMode1dTiledThin1 = 2,
GnmArrayMode1dTiledThick = 3,
GnmArrayMode2dTiledThin1 = 4,
GnmArrayModePrtTiledThin1 = 5,
GnmArrayModePrt2dTiledThin1 = 6,
GnmArrayMode2dTiledThick = 7,
GnmArrayMode2dTiledXThick = 8,
GnmArrayModePrtTiledThick = 9,
GnmArrayModePrt2dTiledThick = 10,
GnmArrayModePrt3dTiledThin1 = 11,
GnmArrayMode3dTiledThin1 = 12,
GnmArrayMode3dTiledThick = 13,
GnmArrayMode3dTiledXThick = 14,
GnmArrayModePrt3dTiledThick = 15,
};
enum GnmMicroTileModeValue : std::uint32_t {
GnmMicroTileModeDisplay = 0,
GnmMicroTileModeThin = 1,
GnmMicroTileModeDepth = 2,
GnmMicroTileModeRotated = 3,
GnmMicroTileModeThick = 4,
};
enum GnmPipeConfigValue : std::uint32_t {
GnmPipeConfigP2 = 0,
GnmPipeConfigP8_32x32_8x16 = 0xa,
GnmPipeConfigP8_32x32_16x16 = 0xc,
GnmPipeConfigNeoP16 = 0x12,
};
enum GnmTileSplitValue : std::uint32_t {
GnmTileSplit64B = 0,
GnmTileSplit128B = 1,
GnmTileSplit256B = 2,
GnmTileSplit512B = 3,
GnmTileSplit1KB = 4,
};
enum GnmSampleSplitValue : std::uint32_t {
GnmSampleSplit1 = 0,
GnmSampleSplit2 = 1,
};
constexpr std::uint32_t GnmTileModeWord(std::uint32_t arrayMode, std::uint32_t pipeConfig, std::uint32_t tileSplit, std::uint32_t microMode,
std::uint32_t sampleSplit, std::uint32_t altPipeConfig) {
return arrayMode << 2 | pipeConfig << 6 | tileSplit << 11 | microMode << 22 | sampleSplit << 25 | altPipeConfig << 27;
}
constexpr std::uint32_t GnmTile(std::uint32_t arrayMode, std::uint32_t pipeConfig, std::uint32_t tileSplit, std::uint32_t microMode,
std::uint32_t sampleSplit) {
return GnmTileModeWord(arrayMode, pipeConfig, tileSplit, microMode, sampleSplit, GnmPipeConfigNeoP16);
}
constexpr std::uint32_t GnmTileModes[32] = {
GnmTile(GnmArrayMode2dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeDepth, GnmSampleSplit1),
GnmTile(GnmArrayMode2dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit128B, GnmMicroTileModeDepth, GnmSampleSplit1),
GnmTile(GnmArrayMode2dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit256B, GnmMicroTileModeDepth, GnmSampleSplit1),
GnmTile(GnmArrayMode2dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit512B, GnmMicroTileModeDepth, GnmSampleSplit1),
GnmTile(GnmArrayMode2dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit1KB, GnmMicroTileModeDepth, GnmSampleSplit1),
GnmTile(GnmArrayMode1dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeDepth, GnmSampleSplit1),
GnmTile(GnmArrayModePrt2dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit256B, GnmMicroTileModeDepth, GnmSampleSplit1),
GnmTile(GnmArrayModePrt2dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit1KB, GnmMicroTileModeDepth, GnmSampleSplit1),
GnmTile(GnmArrayModeLinearAligned, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeDisplay, GnmSampleSplit1),
GnmTile(GnmArrayMode1dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeDisplay, GnmSampleSplit1),
GnmTile(GnmArrayMode2dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeDisplay, GnmSampleSplit2),
GnmTile(GnmArrayModePrtTiledThin1, GnmPipeConfigP8_32x32_8x16, GnmTileSplit64B, GnmMicroTileModeDisplay, GnmSampleSplit2),
GnmTile(GnmArrayModePrt2dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeDisplay, GnmSampleSplit2),
GnmTile(GnmArrayMode1dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeThin, GnmSampleSplit1),
GnmTile(GnmArrayMode2dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeThin, GnmSampleSplit2),
GnmTile(GnmArrayMode3dTiledThin1, GnmPipeConfigP8_32x32_8x16, GnmTileSplit64B, GnmMicroTileModeThin, GnmSampleSplit2),
GnmTile(GnmArrayModePrtTiledThin1, GnmPipeConfigP8_32x32_8x16, GnmTileSplit64B, GnmMicroTileModeThin, GnmSampleSplit2),
GnmTile(GnmArrayModePrt2dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeThin, GnmSampleSplit2),
GnmTile(GnmArrayModePrt3dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeThin, GnmSampleSplit2),
GnmTile(GnmArrayMode1dTiledThick, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeThick, GnmSampleSplit1),
GnmTile(GnmArrayMode2dTiledThick, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeThick, GnmSampleSplit1),
GnmTile(GnmArrayMode3dTiledThick, GnmPipeConfigP8_32x32_8x16, GnmTileSplit64B, GnmMicroTileModeThick, GnmSampleSplit1),
GnmTile(GnmArrayModePrtTiledThick, GnmPipeConfigP8_32x32_8x16, GnmTileSplit64B, GnmMicroTileModeThick, GnmSampleSplit1),
GnmTile(GnmArrayModePrt2dTiledThick, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeThick, GnmSampleSplit1),
GnmTile(GnmArrayModePrt3dTiledThick, GnmPipeConfigP8_32x32_8x16, GnmTileSplit64B, GnmMicroTileModeThick, GnmSampleSplit1),
GnmTile(GnmArrayMode2dTiledXThick, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeThick, GnmSampleSplit1),
GnmTile(GnmArrayMode3dTiledXThick, GnmPipeConfigP8_32x32_8x16, GnmTileSplit64B, GnmMicroTileModeThick, GnmSampleSplit1),
GnmTile(GnmArrayMode1dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeRotated, GnmSampleSplit1),
GnmTile(GnmArrayMode2dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeRotated, GnmSampleSplit2),
GnmTile(GnmArrayModePrtTiledThin1, GnmPipeConfigP8_32x32_8x16, GnmTileSplit64B, GnmMicroTileModeRotated, GnmSampleSplit2),
GnmTile(GnmArrayModePrt2dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit64B, GnmMicroTileModeRotated, GnmSampleSplit2),
GnmTileModeWord(GnmArrayModeLinearGeneral, GnmPipeConfigP2, GnmTileSplit64B, GnmMicroTileModeDisplay, GnmSampleSplit1, GnmPipeConfigP2)};
enum GnmMacroTileFieldValue : std::uint32_t {
GnmBankWidth1 = 0,
GnmBankHeight1 = 0,
GnmBankHeight2 = 1,
GnmBankHeight4 = 2,
GnmBankHeight8 = 3,
GnmMacroAspect1 = 0,
GnmMacroAspect2 = 1,
GnmMacroAspect4 = 2,
GnmBanks2 = 0,
GnmBanks4 = 1,
GnmBanks8 = 2,
GnmBanks16 = 3,
};
constexpr std::uint32_t GnmMacroTile(std::uint32_t bankWidth, std::uint32_t bankHeight, std::uint32_t aspect, std::uint32_t banks,
std::uint32_t altBankHeight, std::uint32_t altAspect, std::uint32_t altBanks) {
return bankWidth | bankHeight << 2 | aspect << 4 | banks << 6 | altBankHeight << 8 | altAspect << 10 | altBanks << 12;
}
constexpr std::uint32_t GnmMacroTileModes[16] = {
GnmMacroTile(GnmBankWidth1, GnmBankHeight4, GnmMacroAspect4, GnmBanks16, GnmBankHeight4, GnmMacroAspect2, GnmBanks8),
GnmMacroTile(GnmBankWidth1, GnmBankHeight2, GnmMacroAspect2, GnmBanks16, GnmBankHeight4, GnmMacroAspect2, GnmBanks8),
GnmMacroTile(GnmBankWidth1, GnmBankHeight1, GnmMacroAspect2, GnmBanks16, GnmBankHeight2, GnmMacroAspect1, GnmBanks8),
GnmMacroTile(GnmBankWidth1, GnmBankHeight1, GnmMacroAspect2, GnmBanks16, GnmBankHeight2, GnmMacroAspect1, GnmBanks8),
GnmMacroTile(GnmBankWidth1, GnmBankHeight1, GnmMacroAspect1, GnmBanks8, GnmBankHeight1, GnmMacroAspect1, GnmBanks8),
GnmMacroTile(GnmBankWidth1, GnmBankHeight1, GnmMacroAspect1, GnmBanks4, GnmBankHeight1, GnmMacroAspect1, GnmBanks8),
GnmMacroTile(GnmBankWidth1, GnmBankHeight1, GnmMacroAspect1, GnmBanks2, GnmBankHeight1, GnmMacroAspect1, GnmBanks4),
GnmMacroTile(GnmBankWidth1, GnmBankHeight1, GnmMacroAspect1, GnmBanks2, GnmBankHeight1, GnmMacroAspect1, GnmBanks2),
GnmMacroTile(GnmBankWidth1, GnmBankHeight8, GnmMacroAspect4, GnmBanks16, GnmBankHeight4, GnmMacroAspect2, GnmBanks16),
GnmMacroTile(GnmBankWidth1, GnmBankHeight4, GnmMacroAspect4, GnmBanks16, GnmBankHeight4, GnmMacroAspect2, GnmBanks8),
GnmMacroTile(GnmBankWidth1, GnmBankHeight2, GnmMacroAspect2, GnmBanks16, GnmBankHeight2, GnmMacroAspect1, GnmBanks8),
GnmMacroTile(GnmBankWidth1, GnmBankHeight1, GnmMacroAspect2, GnmBanks16, GnmBankHeight1, GnmMacroAspect1, GnmBanks8),
GnmMacroTile(GnmBankWidth1, GnmBankHeight1, GnmMacroAspect1, GnmBanks8, GnmBankHeight1, GnmMacroAspect1, GnmBanks4),
GnmMacroTile(GnmBankWidth1, GnmBankHeight1, GnmMacroAspect1, GnmBanks4, GnmBankHeight1, GnmMacroAspect1, GnmBanks4),
GnmMacroTile(GnmBankWidth1, GnmBankHeight1, GnmMacroAspect1, GnmBanks2, GnmBankHeight1, GnmMacroAspect1, GnmBanks2),
GnmMacroTile(GnmBankWidth1, GnmBankHeight1, GnmMacroAspect1, GnmBanks2, GnmBankHeight1, GnmMacroAspect1, GnmBanks2)};
enum GnmChannelTypeValue : std::uint32_t {
GnmChannelTypeUNorm = 0,
GnmChannelTypeSNorm = 1,
GnmChannelTypeUInt = 4,
GnmChannelTypeSInt = 5,
GnmChannelTypeFloat = 7,
GnmChannelTypeSrgb = 9,
};
constexpr std::uint32_t GnmRenderTargetTypeSrgb = 6;
constexpr std::uint32_t GnmMicroTileTexels = 64;
enum GnmSurfaceFormatValue : std::uint32_t {
GnmFormatInvalid = 0x00,
GnmFormat8 = 0x01,
GnmFormat16 = 0x02,
GnmFormat8_8 = 0x03,
GnmFormat32 = 0x04,
GnmFormat16_16 = 0x05,
GnmFormat10_11_11 = 0x06,
GnmFormat11_11_10 = 0x07,
GnmFormat10_10_10_2 = 0x08,
GnmFormat2_10_10_10 = 0x09,
GnmFormat8_8_8_8 = 0x0a,
GnmFormat32_32 = 0x0b,
GnmFormat16_16_16_16 = 0x0c,
GnmFormat32_32_32 = 0x0d,
GnmFormat32_32_32_32 = 0x0e,
GnmFormat5_6_5 = 0x10,
GnmFormat1_5_5_5 = 0x11,
GnmFormat5_5_5_1 = 0x12,
GnmFormat4_4_4_4 = 0x13,
GnmFormat8_24 = 0x14,
GnmFormat24_8 = 0x15,
GnmFormatX24_8_32 = 0x16,
GnmFormatGB_GR = 0x20,
GnmFormatBG_RG = 0x21,
GnmFormat5_9_9_9 = 0x22,
GnmFormatBc1 = 0x23,
GnmFormatBc2 = 0x24,
GnmFormatBc3 = 0x25,
GnmFormatBc4 = 0x26,
GnmFormatBc5 = 0x27,
GnmFormatBc6 = 0x28,
GnmFormatBc7 = 0x29,
GnmFormatFmask8_S2_F1 = 0x2c,
GnmFormatFmask8_S4_F1 = 0x2d,
GnmFormatFmask8_S8_F1 = 0x2e,
GnmFormatFmask8_S2_F2 = 0x2f,
GnmFormatFmask8_S4_F2 = 0x30,
GnmFormatFmask8_S4_F4 = 0x31,
GnmFormatFmask16_S16_F1 = 0x32,
GnmFormatFmask16_S8_F2 = 0x33,
GnmFormatFmask32_S16_F2 = 0x34,
GnmFormatFmask32_S8_F4 = 0x35,
GnmFormatFmask32_S8_F8 = 0x36,
GnmFormatFmask64_S16_F4 = 0x37,
GnmFormatFmask64_S16_F8 = 0x38,
GnmFormat4_4 = 0x39,
GnmFormat6_5_5 = 0x3a,
GnmFormat1 = 0x3b,
GnmFormat1Reversed = 0x3c,
};
constexpr std::uint32_t GnmFormatCount = GnmFormat1Reversed + 1;
constexpr std::uint32_t GnmFormatUndefined = 0xffffffff;
constexpr std::uint32_t GnmBlockTexels = 16;
constexpr std::uint32_t GnmFmaskComponents = 2;
struct GnmFormatShape {
std::uint32_t bits;
std::uint32_t components;
};
constexpr GnmFormatShape GnmChannels(std::uint32_t x = 0, std::uint32_t y = 0, std::uint32_t z = 0, std::uint32_t w = 0) {
return {x + y + z + w, static_cast<std::uint32_t>((x != 0) + (y != 0) + (z != 0) + (w != 0))};
}
constexpr GnmFormatShape GnmPadded(std::uint32_t padding, GnmFormatShape shape) { return {shape.bits + padding, shape.components}; }
constexpr GnmFormatShape GnmBlock(std::uint32_t blockBits, std::uint32_t components) { return {blockBits / GnmBlockTexels, components}; }
constexpr GnmFormatShape GnmShape(std::uint32_t format) {
switch (format) {
case GnmFormatInvalid: return GnmChannels();
case GnmFormat8: return GnmChannels(8);
case GnmFormat16: return GnmChannels(16);
case GnmFormat8_8: return GnmChannels(8, 8);
case GnmFormat32: return GnmChannels(32);
case GnmFormat16_16: return GnmChannels(16, 16);
case GnmFormat10_11_11: return GnmChannels(10, 11, 11);
case GnmFormat11_11_10: return GnmChannels(11, 11, 10);
case GnmFormat10_10_10_2: return GnmChannels(10, 10, 10, 2);
case GnmFormat2_10_10_10: return GnmChannels(2, 10, 10, 10);
case GnmFormat8_8_8_8: return GnmChannels(8, 8, 8, 8);
case GnmFormat32_32: return GnmChannels(32, 32);
case GnmFormat16_16_16_16: return GnmChannels(16, 16, 16, 16);
case GnmFormat32_32_32: return GnmChannels(32, 32, 32);
case GnmFormat32_32_32_32: return GnmChannels(32, 32, 32, 32);
case GnmFormat5_6_5: return GnmChannels(5, 6, 5);
case GnmFormat1_5_5_5: return GnmChannels(1, 5, 5, 5);
case GnmFormat5_5_5_1: return GnmChannels(5, 5, 5, 1);
case GnmFormat4_4_4_4: return GnmChannels(4, 4, 4, 4);
case GnmFormat8_24: return GnmChannels(8, 24);
case GnmFormat24_8: return GnmChannels(24, 8);
case GnmFormatX24_8_32: return GnmPadded(24, GnmChannels(8, 32));
case GnmFormatGB_GR:
case GnmFormatBG_RG: return {GnmChannels(8, 8, 8, 8).bits / 2, 3};
case GnmFormat5_9_9_9: return GnmPadded(5, GnmChannels(9, 9, 9));
case GnmFormatBc1: return GnmBlock(64, 4);
case GnmFormatBc2:
case GnmFormatBc3:
case GnmFormatBc7: return GnmBlock(128, 4);
case GnmFormatBc4: return GnmBlock(64, 1);
case GnmFormatBc5: return GnmBlock(128, 2);
case GnmFormatBc6: return GnmBlock(128, 3);
case GnmFormatFmask8_S2_F1:
case GnmFormatFmask8_S4_F1:
case GnmFormatFmask8_S8_F1:
case GnmFormatFmask8_S2_F2:
case GnmFormatFmask8_S4_F2:
case GnmFormatFmask8_S4_F4: return {8, GnmFmaskComponents};
case GnmFormatFmask16_S16_F1:
case GnmFormatFmask16_S8_F2: return {16, GnmFmaskComponents};
case GnmFormatFmask32_S16_F2:
case GnmFormatFmask32_S8_F4:
case GnmFormatFmask32_S8_F8: return {32, GnmFmaskComponents};
case GnmFormatFmask64_S16_F4:
case GnmFormatFmask64_S16_F8: return {64, GnmFmaskComponents};
case GnmFormat4_4: return GnmChannels(4, 4);
case GnmFormat6_5_5: return GnmChannels(6, 5, 5);
case GnmFormat1:
case GnmFormat1Reversed: return GnmChannels(1);
default: return {GnmFormatUndefined, GnmFormatUndefined};
}
}
template <std::uint32_t GnmFormatShape::*Field>
constexpr std::array<std::uint32_t, GnmFormatCount> GnmFormatTable() {
std::array<std::uint32_t, GnmFormatCount> table{};
for (std::uint32_t format = 0; format < GnmFormatCount; ++format) table[format] = GnmShape(format).*Field;
return table;
}
constexpr std::array<std::uint32_t, GnmFormatCount> GnmComponentCounts = GnmFormatTable<&GnmFormatShape::components>();
constexpr std::array<std::uint32_t, GnmFormatCount> GnmElementBits = GnmFormatTable<&GnmFormatShape::bits>();
static_assert(GnmElementBits[GnmFormat8_8_8_8] == 32 && GnmComponentCounts[GnmFormat8_8_8_8] == 4);
static_assert(GnmElementBits[GnmFormat32_32_32] == 96 && GnmComponentCounts[GnmFormat32_32_32] == 3);
static_assert(GnmElementBits[GnmFormat5_6_5] == 16 && GnmComponentCounts[GnmFormat5_6_5] == 3);
static_assert(GnmElementBits[GnmFormatBc1] == 4 && GnmElementBits[GnmFormatBc7] == 8);
static_assert(GnmTileModeWord(GnmArrayMode2dTiledThin1, GnmPipeConfigP8_32x32_16x16, GnmTileSplit1KB, GnmMicroTileModeDepth, GnmSampleSplit2,
GnmPipeConfigNeoP16) == (4u << 2 | 0xcu << 6 | 4u << 11 | 2u << 22 | 1u << 25 | 0x12u << 27));
struct GnmSurfaceLayout {
std::uint32_t pitch;
std::uint32_t height;
std::uint32_t tileMode;
};
std::uint32_t Read32(const std::uint8_t* bytes, std::size_t offset) {
std::uint32_t value;
std::memcpy(&value, bytes + offset, sizeof(value));
return value;
}
std::uint64_t Read64(const std::uint8_t* bytes, std::size_t offset) {
std::uint64_t value;
std::memcpy(&value, bytes + offset, sizeof(value));
return value;
}
template <typename T>
void Write(std::uint8_t* bytes, std::size_t offset, T value) {
std::memcpy(bytes + offset, &value, sizeof(value));
}
std::uint32_t AlignUp(std::uint32_t value, std::uint32_t alignment) {
return (value + alignment - 1) & (0u - alignment);
}
constexpr std::uint32_t GnmArrayMode(std::uint32_t entry) { return (entry >> 2) & 0xf; }
constexpr std::uint32_t GnmMicroMode(std::uint32_t entry) { return (entry >> 22) & 7; }
constexpr std::uint32_t GnmThicknessOf(std::uint32_t arrayMode) {
switch (arrayMode) {
case GnmArrayMode1dTiledThick:
case GnmArrayMode2dTiledThick:
case GnmArrayModePrtTiledThick:
case GnmArrayModePrt2dTiledThick:
case GnmArrayMode3dTiledThick:
case GnmArrayModePrt3dTiledThick: return 4;
case GnmArrayMode2dTiledXThick:
case GnmArrayMode3dTiledXThick: return 8;
default: return 1;
}
}
constexpr std::uint32_t GnmThinOrThickTileMode(std::uint32_t arrayMode) {
std::uint32_t tileMode = 0;
while (tileMode < 0x1f) {
const std::uint32_t micro = GnmMicroMode(GnmTileModes[tileMode]);
if ((micro == GnmMicroTileModeThin || micro == GnmMicroTileModeThick) && GnmArrayMode(GnmTileModes[tileMode]) == arrayMode) break;
++tileMode;
}
return tileMode;
}
static_assert([] {
for (std::uint32_t arrayMode = 2; arrayMode < 0xe; ++arrayMode) {
if (((0xe3fu >> (arrayMode - 2)) & 1) != 0 && GnmThinOrThickTileMode(arrayMode) == 0x1f) return false;
}
return true;
}());
constexpr std::uint32_t GnmRenderTargetType(std::uint32_t channelType) {
switch (channelType) {
case GnmChannelTypeSNorm:
case GnmChannelTypeUInt:
case GnmChannelTypeSInt:
case GnmChannelTypeFloat: return channelType;
case GnmChannelTypeSrgb: return GnmRenderTargetTypeSrgb;
default: return GnmChannelTypeUNorm;
}
}
std::uint32_t GnmDataFormat(std::uint32_t surface, std::uint32_t type, std::uint32_t x, std::uint32_t y, std::uint32_t z, std::uint32_t w) {
return (surface & 0xff) | (type & 0xf) << 8 | (x & 7) << 12 | (y & 7) << 15 | (z & 7) << 18 | (w & 7) << 21;
}
std::uint32_t GnmChannel(std::uint32_t format, std::uint32_t index) { return (format >> (12 + 3 * index)) & 7; }
bool GnmSwizzle(std::uint32_t format, std::uint32_t* index) {
const std::uint32_t surface = format & 0xff;
if (surface > 0x3c) return false;
const std::uint32_t x = GnmChannel(format, 0);
const std::uint32_t y = GnmChannel(format, 1);
const std::uint32_t z = GnmChannel(format, 2);
const std::uint32_t w = GnmChannel(format, 3);
int result = -1;
switch (GnmComponentCounts[surface]) {
case 1:
result = x == 4 ? 0 : y == 4 ? 1 : z == 4 ? 2 : w == 4 ? 3 : -1;
break;
case 2:
result = x == 4 && y == 5 ? 0 : x == 4 && w == 5 ? 1 : y == 4 && x == 5 ? 2 : w == 4 && x == 5 ? 3 : -1;
break;
case 3:
result = x == 4 && y == 5 && z == 6 ? 0
: x == 4 && y == 5 && w == 6 ? 1
: z == 4 && y == 5 && x == 6 ? 2
: w == 4 && y == 5 && x == 6 ? 3
: -1;
break;
case 4:
result = x == 4 && y == 5 && z == 6 && w == 7 ? 0
: z == 4 && y == 5 && x == 6 && w == 7 ? 1
: w == 4 && z == 5 && y == 6 && x == 7 ? 2
: w == 4 && x == 5 && y == 6 && z == 7 ? 3
: -1;
break;
default:
return false;
}
if (result < 0) return false;
if (index != nullptr) *index = static_cast<std::uint32_t>(result);
return true;
}
bool GnmTextureFormatSupported(std::uint32_t format) {
const std::uint32_t surface = format & 0xff;
if (surface - 1 > 0x15) return false;
if (surface == 8 || surface == 9) {
if ((format & 0xf00) == 0x900) return false;
} else if (surface == 0xd || surface == 0xf) {
return false;
}
const std::uint32_t type = (format >> 8) & 0xf;
if (type > 9 || ((0x2b3u >> type) & 1) == 0) return false;
return GnmSwizzle(format, nullptr);
}
std::uint32_t GnmDegradeArrayMode(std::uint32_t arrayMode, std::uint32_t bits) {
const std::uint32_t index = arrayMode - 3;
if (GnmThicknessOf(arrayMode) == 1) return arrayMode;
const std::uint32_t size = bits * GnmMicroTileTexels * GnmThicknessOf(arrayMode);
if (size < 0x2001) return arrayMode;
switch (index) {
case 0: return 3;
case 4: return 4;
case 5: return size < 0x4010 ? 7 : 4;
case 6: return 5;
case 7: return 6;
case 10: return 0xc;
case 11: return size < 0x4010 ? 0xd : 0xc;
case 12: return 0xb;
default: return arrayMode;
}
}
bool GnmTileModeForArrayMode(std::uint32_t tileMode, std::uint32_t arrayMode, std::uint32_t& result) {
if (tileMode > 0x1f) return false;
const std::uint32_t entry = GnmTileModes[tileMode];
if (GnmArrayMode(entry) == arrayMode) {
result = tileMode;
return true;
}
switch (GnmMicroMode(entry)) {
case 0:
if (arrayMode != 2) return false;
result = 9;
return true;
case 1:
case 4:
if (arrayMode - 2 >= 0xc || ((0xe3fu >> (arrayMode - 2)) & 1) == 0) return false;
result = GnmThinOrThickTileMode(arrayMode);
return true;
case 2:
result = 5;
return true;
default:
return false;
}
}
bool GnmMacroTileIndex(std::uint32_t tileMode, std::uint32_t bits, std::uint32_t& index) {
if (tileMode > 0x1f) return false;
const std::uint32_t entry = GnmTileModes[tileMode];
const std::uint32_t arrayMode = GnmArrayMode(entry);
if (((0xfff0u >> arrayMode) & 1) == 0 || bits - 1 > 0x7f) return false;
const std::uint32_t tileBytes = ((bits * GnmThicknessOf(arrayMode)) << 6) >> 3;
const std::uint32_t scaled = tileBytes << ((entry >> 25) & 3);
const std::uint32_t split = tileMode >= 8 ? (scaled >= 0x101 ? scaled : 0x100) : 0x40u << ((entry >> 11) & 7);
const std::uint32_t limit = split < 0x400 ? split : 0x400;
const std::uint32_t bytes = tileBytes >= limit ? limit : tileBytes;
if (!std::has_single_bit(bytes) || bytes < 0x40) return false;
index = static_cast<std::uint32_t>(std::bit_width((bytes >> 6) | 1)) - 1 + (((0x8e60u >> arrayMode) & 1) != 0 ? 8 : 0);
return true;
}
bool GnmComputeMacroLayout(std::uint32_t tileMode, std::uint32_t arrayMode, std::uint32_t pipes, bool neo, std::uint32_t width,
std::uint32_t height, std::uint32_t bits, GnmSurfaceLayout& layout) {
std::uint32_t macroIndex = 0;
if (!GnmMacroTileIndex(tileMode, bits, macroIndex)) return false;
const std::uint32_t macro = GnmMacroTileModes[macroIndex];
const std::uint32_t bankWidth = 1u << (macro & 3);
const std::uint32_t bankHeight = 1u << (neo ? (macro >> 8) & 3 : (macro >> 2) & 3);
const std::uint32_t aspect = 1u << (neo ? (macro >> 10) & 3 : (macro >> 4) & 3);
const std::uint32_t banks = 2u << (neo ? (macro >> 12) & 3 : (macro >> 6) & 3);
const std::uint32_t entry = GnmTileModes[tileMode];
const std::uint32_t tileBytes = (GnmThicknessOf(arrayMode) * bits * 8) & 0x1ffffff8;
std::uint32_t split = 0;
if (GnmMicroMode(entry) == 2) {
split = 0x40u << ((entry >> 11) & 7);
} else {
split = tileBytes << ((entry >> 25) & 3);
if (split < 0x101) split = 0x100;
}
if (split >= 0x400) split = 0x400;
if (banks < aspect || banks * pipes == 0) return false;
const std::uint32_t splitBytes = tileBytes >= split ? split : tileBytes;
std::uint32_t bankTiles = 0x100 / (splitBytes * bankWidth);
if (bankTiles == 0) bankTiles = 1;
if (!std::has_single_bit(bankTiles)) return false;
std::uint32_t pipeTiles = 0x100 / (splitBytes * pipes * bankWidth);
if (pipeTiles == 0) pipeTiles = 1;
if (!std::has_single_bit(pipeTiles)) return false;
const std::uint32_t macroAspect = AlignUp(aspect, pipeTiles);
const std::uint32_t macroBankHeight = AlignUp(bankHeight, bankTiles);
if (splitBytes * bankWidth * macroBankHeight >= 0x401) NotImplemented_nid_no_patch("sceFontGraphicsGnmSurfaceInit");
std::uint32_t pitchAlign = macroAspect * pipes * bankWidth * 8;
const std::uint32_t heightAlign = banks * macroBankHeight * 8 / macroAspect;
if (((0x8e60u >> arrayMode) & 1) != 0) {
const std::uint32_t sliceBits = heightAlign * bits * pitchAlign;
if (sliceBits <= 0x7ffff) {
if (0x10000 % (sliceBits >> 3) != 0) return false;
pitchAlign *= 0x10000 / (sliceBits >> 3);
}
}
if (macroBankHeight * bankWidth * splitBytes < 0x100 || macroAspect * pipes * bankWidth * splitBytes <= 0xff) return false;
if (!std::has_single_bit(pitchAlign) || !std::has_single_bit(heightAlign)) return false;
layout.pitch = AlignUp(width, pitchAlign);
layout.height = AlignUp(height, heightAlign);
return true;
}
bool GnmComputeSurface(std::uint32_t tileMode, bool neo, std::uint32_t width, std::uint32_t height, std::uint32_t bits,
GnmSurfaceLayout& layout) {
if (bits - 1 > 0x7f || !std::has_single_bit(bits) || tileMode > 0x1f) return false;
const std::uint32_t entry = GnmTileModes[tileMode];
const std::uint32_t pipeConfig = neo ? entry >> 27 : (entry >> 6) & 0x1f;
const std::uint32_t pipes = pipeConfig == 0xa || pipeConfig == 0xc ? 8 : pipeConfig == 0x12 ? 16 : 0;
const std::uint32_t original = GnmArrayMode(entry);
if (GnmThicknessOf(original) == 8 && bits >= 0x41) return false;
const std::uint32_t arrayMode = GnmDegradeArrayMode(original, bits);
std::uint32_t macroMode = tileMode;
GnmTileModeForArrayMode(tileMode, arrayMode, macroMode);
layout.pitch = width;
layout.height = height;
if (arrayMode == 1) {
const std::uint32_t bytes = (bits + 7) >> 3;
const std::uint32_t elements = (0x40 / bytes) & 0xff;
const std::uint32_t pitchAlign = elements >= 9 ? elements : 8;
const std::uint32_t slice = (0x100 / bytes) & 0xffff;
const std::uint32_t sliceAlign = slice >= 0x41 ? slice : 0x40;
layout.pitch = AlignUp(width, pitchAlign);
while (static_cast<std::uint64_t>(layout.pitch) * height % sliceAlign != 0) layout.pitch += pitchAlign;
} else if (arrayMode == 2 || arrayMode == 3) {
const std::uint32_t thickness = GnmThicknessOf(arrayMode);
layout.pitch = AlignUp(width, 8);
layout.height = AlignUp(height, 8);
while ((((layout.pitch * layout.height * bits + 7) >> 3) * thickness & 0xff) != 0) layout.pitch += 8;
} else if (arrayMode >= 4) {
if (macroMode > 0x1f || !GnmComputeMacroLayout(macroMode, arrayMode, pipes, neo, width, height, bits, layout)) return false;
}
return GnmTileModeForArrayMode(tileMode, arrayMode, layout.tileMode);
}
std::uint32_t GnmTextureFormatWord(std::uint32_t format) {
const std::uint32_t numeric = GnmRenderTargetType((format >> 8) & 0xf);
const std::uint32_t paired = numeric & ~1u;
std::uint32_t swizzle = 0;
GnmSwizzle(format, &swizzle);
std::uint32_t word = numeric == 0 || numeric == 6 ? 0 : static_cast<std::uint32_t>(numeric != 1) << 18;
word |= static_cast<std::uint32_t>(paired == 4) << 16;
word |= static_cast<std::uint32_t>(numeric < 7 && ((0x43u >> numeric) & 1) != 0 && paired != 4) << 15;
return word | (swizzle & 3) << 11 | (numeric & 7) << 8 | (format << 2 & 0x7c);
}
bool GnmInitTexture(std::uint8_t* output, std::uint32_t width, std::uint32_t height, std::uint32_t format, std::uint32_t tileMode,
bool neo) {
if (!GnmTextureFormatSupported(format) || width - 1 > 0x3fff || height - 1 > 0x3fff) return false;
std::uint32_t texture[16] = {};
if (neo) texture[6] = 8;
GnmSurfaceLayout layout{};
const bool computed = GnmComputeSurface(tileMode, neo, width, height, GnmElementBits[format & 0xff], layout);
if (computed) {
const std::uint32_t pitchTiles = (layout.pitch >> 3) - 1;
const std::uint32_t mode = layout.tileMode & 0x1f;
texture[1] = (pitchTiles & 0x7ff) | (pitchTiles << 20 & 0x7ff00000);
texture[2] = ((layout.pitch * layout.height >> 6) - 1) & 0x3fffff;
texture[4] = GnmTextureFormatWord(format) | static_cast<std::uint32_t>(neo) << 31;
texture[5] = mode << 5 | mode;
texture[15] = height << 16 | (width & 0xffff);
}
std::memcpy(output, texture, sizeof(texture));
return computed;
}
void GnmSetTextureBase(std::uint8_t* output, std::uint64_t base) {
std::uint32_t address = static_cast<std::uint32_t>(base >> 8);
const std::uint32_t formatWord = Read32(output, 0x10);
const std::uint32_t surface = (formatWord >> 2) & 0x1f;
const std::uint32_t tileMode = Read32(output, 0x14) & 0x1f;
std::uint32_t index = 0;
if (surface != 0 && ((0x7f7dcdfu >> tileMode) & 1) != 0 && GnmMacroTileIndex(tileMode, GnmElementBits[surface], index)) {
const bool neo = (formatWord & 0x80000000) != 0;
const std::uint32_t banks = neo ? (GnmMacroTileModes[index] >> 12) & 3 : (GnmMacroTileModes[index] >> 6) & 3;
const std::uint32_t mask = ((2u << banks) - 1) << (neo ? 4 : 3);
address = (address & ~mask) | (Read32(output, 0) & mask);
}
Write(output, 0, address);
}
int GnmSurfaceInit(void* surface, const void* config) {
if (surface == nullptr) return FontGsInvalidParameter;
auto* const out = static_cast<std::uint8_t*>(surface);
const auto* const in = static_cast<const std::uint8_t*>(config);
if (in[0x0d] == FontGnmSurfaceConfigTag) std::memset(out, 0, 0x100);
else Write<std::uint16_t>(out, 0x0e, 0);
if ((in[0x0d] | 4) != FontGnmSurfaceConfigTag) return FontGsInvalidParameter;
if (Read32(in, 0x24) != 1 || Read32(in, 0x18) != 0 || Read32(in, 0x1c) != 0) return FontGsSurfaceConfigInvalid;
const std::uint64_t base = Read64(in, 0);
std::uint32_t format = GnmDataFormat(Read32(in, 0x40), Read32(in, 0x44), Read32(in, 0x48), Read32(in, 0x4c), Read32(in, 0x50),
Read32(in, 0x54));
const std::uint32_t stride = Read32(in, 0x08);
const std::uint32_t width = Read32(in, 0x10);
const std::uint32_t height = Read32(in, 0x14);
const std::uint8_t flags = in[0x0c];
const std::uint32_t tileMode = Read32(in, 0x20);
if (static_cast<std::int32_t>(stride) < 0 || static_cast<std::int32_t>(width) < 0 || static_cast<std::int32_t>(height) < 0)
return FontGsSurfaceConfigInvalid;
const std::uint32_t type = (format >> 8) & 0xf;
std::uint8_t tag = 0;
switch (format & 0xff) {
case 1:
if ((format & 0xf00) != 0 || GnmChannel(format, 0) != 0 || GnmChannel(format, 1) != 0 || GnmChannel(format, 2) != 0 ||
GnmChannel(format, 3) != 4)
return FontGsSurfaceConfigInvalid;
tag = 0x10;
break;
case 3:
if ((type != 9 && type != 0) || GnmChannel(format, 0) != 4 || GnmChannel(format, 3) != 5) return FontGsSurfaceConfigInvalid;
format = GnmDataFormat(3, 0, 5, 0, 0, 4);
tag = 0x20;
break;
case 9:
tag = 0x4a;
break;
case 10:
if ((type != 9 && type != 0) || GnmChannel(format, 0) < 2 || GnmChannel(format, 1) < 2 || GnmChannel(format, 2) < 2 ||
GnmChannel(format, 3) != 7)
return FontGsSurfaceConfigInvalid;
tag = 0x40;
break;
case 12:
tag = 0x4e;
break;
case 14:
tag = 0x4f;
break;
default:
return FontGsSurfaceConfigInvalid;
}
const bool neo = sceKernelIsNeoMode() != 0;
if (!GnmInitTexture(out + 0x40, width, height, format, tileMode, neo)) return FontGsSurfaceConfigInvalid;
GnmSetTextureBase(out + 0x40, base);
Write(out, 0x5c, static_cast<std::uint32_t>(Read64(in, 0x58) >> 8));
Write(out, 0x64, static_cast<std::uint32_t>(Read64(in, 0x78) >> 8));
Write(out, 0x6c, Read64(in, 0x68));
Write(out, 0x00, base);
Write(out, 0x08, stride);
out[0x0c] = flags;
out[0x0d] = tag;
Write<std::uint16_t>(out, 0x0e, 0x47e0);
Write(out, 0x10, width);
Write(out, 0x14, height);
Write<std::uint64_t>(out, 0x18, 0);
Write(out, 0x20, width);
Write(out, 0x24, height);
Write(out, 0x28, Read32(in, 0x34));
std::uint16_t extent;
std::memcpy(&extent, in + 0x30, sizeof(extent));
Write(out, 0x2c, extent);
Write<std::uint16_t>(out, 0x2e, 1);
Write<std::uint32_t>(out, 0x30, 0);
Write<std::uint16_t>(out, 0x34, 0x100);
Write<std::uint32_t>(out, 0x36, 0x44);
Write<std::uint16_t>(out, 0x3a, 0);
Write(out, 0x3c, static_cast<std::uint16_t>(width));
Write(out, 0x3e, static_cast<std::uint16_t>(height));
return 0;
}
const FontGnmSurface* ReadGnmSurface(const void* surface) {
const auto* const gnm = static_cast<const FontGnmSurface*>(surface);
if (gnm->tag != FontGnmSurfaceTag || gnm->head == nullptr || gnm->initialized != 1 || gnm->busy != 0) return nullptr;
return gnm;
}
void MarkGnmRecord(void* output) {
*reinterpret_cast<std::uint32_t*>(static_cast<std::uint8_t*>(output) + FontGnmRecordStateOffset) = 1;
}
const FontGnmCommands* CheckSequence(const FontGraphicsCanvasSequence* sequence, bool outputs, int& error) {
const auto* const seq = reinterpret_cast<const FontGnmSequence*>(sequence);
if (seq == nullptr || seq->tag != FontGnmSequenceTag) error = FontGsInvalidSequence;
else if (!outputs) error = FontGsInvalidParameter;
else if ((seq->lock & 1) != 0) error = FontGsSequenceLocked;
else if (seq->commands == nullptr) error = FontGsFatal;
else return seq->commands;
sceFontGraphicsReportError(error);
return nullptr;
}
}
extern "C" {
APS5_DUMMY_FUN
int APS5_VABI sceFontGraphicsGnmSurfaceInit(void) {
NotImplemented_nid_no_patch(__func__);
void* APS5_VABI sceFontSelectGraphicsGnm(std::uint32_t index) {
if (index == 0) NotImplemented_nid_no_patch(__func__);
return nullptr;
}
int APS5_VABI sceFontSelectGraphicsGnm(void) {
NotImplemented_nid_no_patch(__func__);
int APS5_VABI sceFontGraphicsGnmSurfaceInit(void* surface, const void* config) {
return GnmSurfaceInit(surface, config);
}
int APS5_VABI sceFontGsUnknown_DI4LrTUrD04_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
int APS5_VABI sceFontGraphicsGnmDrawupFillTextureImage(FontGraphicsFrame* graphicsObject, const void* surface, void** output,
float x, float y, float width, float height) {
if (output == nullptr) return FontGsInvalidParameter;
*output = nullptr;
if (graphicsObject == nullptr || surface == nullptr) return FontGsInvalidParameter;
const auto* const gnm = ReadGnmSurface(surface);
if (gnm == nullptr || !(x >= 0.0f)) return FontGsInvalidParameter;
const float right = x + width;
if (!(right >= x) || !(right <= FontGnmDrawupLimit) || !(y >= 0.0f)) return FontGsInvalidParameter;
const float bottom = y + height;
if (!(bottom >= y) || !(bottom <= FontGnmDrawupLimit)) return FontGsInvalidParameter;
const int error = sceFontGraphicsDrawupFillTextureImageObject(graphicsObject, gnm->fillObject, gnm->mode, output, x, y, width, height);
if (error != 0) return error;
MarkGnmRecord(*output);
return 0;
}
APS5_EXPORT("DI4LrTUrD04", sceFontGsUnknown_DI4LrTUrD04_nid_no_patch);
int APS5_VABI sceFontGsUnknown_NtbMKwRg6qg_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
int APS5_VABI sceFontGraphicsGnmDrawupFillTexturePattern(FontGraphicsFrame* graphicsObject, const void* surface, std::uint32_t format,
std::uint32_t select, std::uint32_t dimension1, std::uint32_t option1,
std::uint32_t option2, std::uint32_t dimension2, void** output) {
if (output == nullptr) return FontGsInvalidParameter;
*output = nullptr;
if (graphicsObject == nullptr || surface == nullptr) return FontGsInvalidParameter;
const auto* const gnm = ReadGnmSurface(surface);
if (gnm == nullptr) return FontGsInvalidParameter;
const int error = sceFontGraphicsDrawupFillTexturePatternObject(graphicsObject, gnm->fillObject, gnm->mode, format, select,
dimension1, option1, option2, dimension2, output);
if (error != 0) return error;
MarkGnmRecord(*output);
return 0;
}
APS5_EXPORT("NtbMKwRg6qg", sceFontGsUnknown_NtbMKwRg6qg_nid_no_patch);
int APS5_VABI sceFontGsUnknown_UsBLoyXsQZs_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
int APS5_VABI sceFontGraphicsSequenceGetGnmCommandsForChain(FontGraphicsCanvasSequence* sequence, void** commands,
std::uint32_t* numCommands, void** commands2, std::uint32_t* numCommands2) {
if (commands != nullptr) *commands = nullptr;
if (numCommands != nullptr) *numCommands = 0;
if (commands2 != nullptr) *commands2 = nullptr;
if (numCommands2 != nullptr) *numCommands2 = 0;
int error = 0;
const bool outputs = commands != nullptr && numCommands != nullptr && commands2 != nullptr && numCommands2 != nullptr;
const auto* const gnm = CheckSequence(sequence, outputs, error);
if (gnm == nullptr) return error;
*commands = const_cast<void*>(gnm->first);
*numCommands = gnm->firstSize >> 2;
*commands2 = const_cast<void*>(gnm->second);
*numCommands2 = gnm->secondCount;
return 0;
}
APS5_EXPORT("UsBLoyXsQZs", sceFontGsUnknown_UsBLoyXsQZs_nid_no_patch);
int APS5_VABI sceFontGsUnknown_uksHKVEsxu4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
int APS5_VABI sceFontGraphicsSequenceGetGnmCommandsForSubmit(FontGraphicsCanvasSequence* sequence, void** commands,
std::uint32_t* numCommands) {
if (commands != nullptr) *commands = nullptr;
if (numCommands != nullptr) *numCommands = 0;
int error = 0;
const auto* const gnm = CheckSequence(sequence, commands != nullptr && numCommands != nullptr, error);
if (gnm == nullptr) return error;
*commands = const_cast<void*>(gnm->first);
*numCommands = gnm->firstSize;
return 0;
}
APS5_EXPORT("uksHKVEsxu4", sceFontGsUnknown_uksHKVEsxu4_nid_no_patch);
}
@@ -1,10 +1,27 @@
#pragma once
#include "SceTypes.hpp"
#include <cstdint>
struct FontGraphicsFrame;
struct FontGraphicsCanvasSequence;
extern "C" {
int APS5_VABI sceFontGraphicsGnmSurfaceInit(void);
int APS5_VABI sceFontSelectGraphicsGnm(void);
int APS5_VABI sceFontGraphicsGnmSurfaceInit(void* surface, const void* config);
void* APS5_VABI sceFontSelectGraphicsGnm(std::uint32_t index);
int APS5_VABI sceFontGraphicsGnmDrawupFillTextureImage(FontGraphicsFrame* graphicsObject, const void* surface, void** output,
float x, float y, float width, float height);
int APS5_VABI sceFontGraphicsGnmDrawupFillTexturePattern(FontGraphicsFrame* graphicsObject, const void* surface, std::uint32_t format,
std::uint32_t select, std::uint32_t dimension1, std::uint32_t option1,
std::uint32_t option2, std::uint32_t dimension2, void** output);
int APS5_VABI sceFontGraphicsSequenceGetGnmCommandsForChain(FontGraphicsCanvasSequence* sequence, void** commands,
std::uint32_t* numCommands, void** commands2, std::uint32_t* numCommands2);
int APS5_VABI sceFontGraphicsSequenceGetGnmCommandsForSubmit(FontGraphicsCanvasSequence* sequence, void** commands,
std::uint32_t* numCommands);
}
@@ -326,6 +326,19 @@ if(BUILD_TESTING)
endif()
endif()
if(BUILD_TESTING)
add_test_executable(guest_freetype_output_guards_tests ${LIBS_INCLUDE_DIR}/tests/GuestFreeTypeOutputGuards.cpp)
target_include_directories(guest_freetype_output_guards_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_freetype_output_guards_tests PRIVATE libSceFreeType freetype libkernel libc)
configure_windows_unwind(guest_freetype_output_guards_tests)
add_test(NAME guest_freetype_output_guards COMMAND guest_freetype_output_guards_tests)
set_tests_properties(guest_freetype_output_guards PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_freetype_output_guards PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceFreeType>;PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
endif()
include("${CMAKE_CURRENT_LIST_DIR}/MemoryRecord.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/ModuleProperties.cmake")
@@ -57,4 +57,6 @@ void SyncSlot(GuestFace& face);
}
extern "C" void FreeTypeSyncFace_nid_no_patch(FreeType::GuestFaceRec* face);
#endif
@@ -129,3 +129,7 @@ void SyncSlot(GuestFace& face) {
}
}
extern "C" void FreeTypeSyncFace_nid_no_patch(FreeType::GuestFaceRec* face) {
if (auto* owner = FreeType::FaceOf(face)) FreeType::SyncFace(*owner);
}
@@ -16,6 +16,7 @@ int APS5_VABI FT_Get_Glyph_Name_nid_postfix(GuestFaceRec* face, std::uint32_t gl
const FT_Face host = owner ? owner->host : nullptr;
if (!host || !buffer || bufferSize == 0) return FT_Get_Glyph_Name(host, glyphIndex, buffer, bufferSize);
GuestArena::HostWrite write(buffer, bufferSize);
if (!write.Open()) return FT_Err_Invalid_Argument;
if (static_cast<std::int64_t>(glyphIndex) >= host->num_glyphs) {
static_cast<char*>(buffer)[0] = '\0';
return FT_Err_Invalid_Glyph_Index;
@@ -43,6 +44,8 @@ int APS5_VABI FT_Get_Sfnt_Name_nid_postfix(GuestFaceRec* face, std::uint32_t ind
FT_SfntName native{};
const FT_Error error = FT_Get_Sfnt_Name(owner ? owner->host : nullptr, index, name ? &native : nullptr);
if (!error) {
GuestArena::HostWrite write(name, sizeof(*name));
if (!write.Open()) return FT_Err_Invalid_Argument;
name->platform_id = native.platform_id;
name->encoding_id = native.encoding_id;
name->language_id = native.language_id;
@@ -1,6 +1,7 @@
#include "prx/libSceFreeType/include/Api.hpp"
#include "prx/libSceFreeType/include/GuestObjects.hpp"
#include "prx/libSceFreeType/include/PostScriptInfo.hpp"
#include "prx/libc/include/GuestArena.hpp"
#include FT_TYPE1_TABLES_H
@@ -13,6 +14,8 @@ int APS5_VABI FT_Get_PS_Font_Info_nid_postfix(GuestFaceRec* face, GuestPSFontInf
PS_FontInfoRec native{};
const int error = FT_Get_PS_Font_Info(owner ? owner->host : nullptr, info ? &native : nullptr);
if (error != 0) return error;
GuestArena::HostWrite write(info, sizeof(*info));
if (!write.Open()) return FT_Err_Invalid_Argument;
info->version = native.version;
info->notice = native.notice;
info->fullName = native.full_name;
Loaded 100 of 499 files, more files were not shown because too many files have changed in this diff. Show more