mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-02 11:00:41 +00:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5f0f6e6306 | |||
| d43238b9af | |||
| 2addf1556e | |||
| 883cdead8b | |||
| 104bfa3a8f | |||
| 023c4758e9 | |||
| b9239c4944 | |||
| f229172d3b | |||
| eb18c5b8bd | |||
| 0c7d068112 | |||
| f29a23738a | |||
| 7e5e326842 | |||
| f93e4031ba | |||
| 7e55b4b563 | |||
| ee5049f0d3 | |||
| 15de6e0e08 | |||
| 75519010d2 | |||
| 3e61e6da87 | |||
| 8242e54e42 | |||
| 47b310266e | |||
| 3cfac4abcd | |||
| 92c52342b8 | |||
| db2bdde9b3 | |||
| ce0b15dcf7 | |||
| db922e50e3 | |||
| ca52cf679a | |||
| aa4e494c08 |
@@ -63,3 +63,6 @@ artifacts
|
|||||||
/install*
|
/install*
|
||||||
vulkansdk*.exe
|
vulkansdk*.exe
|
||||||
*.tar.zst
|
*.tar.zst
|
||||||
|
|
||||||
|
# Build-time generated external sources
|
||||||
|
externals/generated
|
||||||
|
|||||||
+2
-2
@@ -214,8 +214,6 @@ if(MSVC)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# TODO(crueter): Cleanup, each dep that has a bundled option should allow to choose between bundled, external, system
|
# TODO(crueter): Cleanup, each dep that has a bundled option should allow to choose between bundled, external, system
|
||||||
cmake_dependent_option(YUZU_USE_BUNDLED_SDL3 "Download bundled SDL3 build" "${MSVC}" "NOT ANDROID" OFF)
|
|
||||||
|
|
||||||
option(ENABLE_CUBEB "Enables the cubeb audio backend" ON)
|
option(ENABLE_CUBEB "Enables the cubeb audio backend" ON)
|
||||||
|
|
||||||
set(EXT_DEFAULT OFF)
|
set(EXT_DEFAULT OFF)
|
||||||
@@ -223,6 +221,8 @@ if (MSVC OR ANDROID)
|
|||||||
set(EXT_DEFAULT ON)
|
set(EXT_DEFAULT ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
option(YUZU_USE_BUNDLED_SDL3 "Download bundled SDL3 build" ${EXT_DEFAULT})
|
||||||
|
|
||||||
# ffmpeg
|
# ffmpeg
|
||||||
option(YUZU_USE_BUNDLED_FFMPEG "Download bundled FFmpeg" ${EXT_DEFAULT})
|
option(YUZU_USE_BUNDLED_FFMPEG "Download bundled FFmpeg" ${EXT_DEFAULT})
|
||||||
cmake_dependent_option(YUZU_USE_EXTERNAL_FFMPEG "Build FFmpeg from external source" "${SOLARIS}" "NOT WIN32 AND NOT ANDROID" OFF)
|
cmake_dependent_option(YUZU_USE_EXTERNAL_FFMPEG "Build FFmpeg from external source" "${SOLARIS}" "NOT WIN32 AND NOT ANDROID" OFF)
|
||||||
|
|||||||
@@ -186,12 +186,6 @@
|
|||||||
"repo": "eden-emulator/oaknut",
|
"repo": "eden-emulator/oaknut",
|
||||||
"version": "v2.0.3"
|
"version": "v2.0.3"
|
||||||
},
|
},
|
||||||
"oboe": {
|
|
||||||
"bundled": true,
|
|
||||||
"hash": "ce4011afe7345370d4ead3b891cd69a5ef224b129535783586c0ca75051d303ed446e6c7f10bde8da31fff58d6e307f1732a3ffd03b249f9ef1fd48fd4132715",
|
|
||||||
"repo": "google/oboe",
|
|
||||||
"version": "1.10.0"
|
|
||||||
},
|
|
||||||
"openssl": {
|
"openssl": {
|
||||||
"hash": "29002ce50cb95a4f4f1d0e9d3f684401fbd4eac34203dc2eef3b6334af5d44aa46bf788b63a6f5c139c383eafb7269ae87a58a9a3ad5912903b9773e545ccc0a",
|
"hash": "29002ce50cb95a4f4f1d0e9d3f684401fbd4eac34203dc2eef3b6334af5d44aa46bf788b63a6f5c139c383eafb7269ae87a58a9a3ad5912903b9773e545ccc0a",
|
||||||
"min_version": "3.0.0",
|
"min_version": "3.0.0",
|
||||||
|
|||||||
Vendored
+37
-43
@@ -136,48 +136,49 @@ if(ENABLE_CUBEB)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT ANDROID)
|
if (NOT YUZU_USE_BUNDLED_SDL3)
|
||||||
if (NOT YUZU_USE_BUNDLED_SDL3)
|
if (NOT WIN32)
|
||||||
if (NOT WIN32)
|
# Yuzu itself needs: Atomic Audio Events Joystick Haptic Sensor Threads Timers
|
||||||
# Yuzu itself needs: Atomic Audio Events Joystick Haptic Sensor Threads Timers
|
# Since 2.0.18 Atomic+Threads required for HIDAPI/libusb (see https://github.com/libsdl-org/SDL/issues/5095)
|
||||||
# Since 2.0.18 Atomic+Threads required for HIDAPI/libusb (see https://github.com/libsdl-org/SDL/issues/5095)
|
# Yuzu-cmd also needs: Video (depends on Loadso/Dlopen)
|
||||||
# Yuzu-cmd also needs: Video (depends on Loadso/Dlopen)
|
# CPUinfo also required for SDL Audio, at least until 2.28.0 (see https://github.com/libsdl-org/SDL/issues/7809)
|
||||||
# CPUinfo also required for SDL Audio, at least until 2.28.0 (see https://github.com/libsdl-org/SDL/issues/7809)
|
set(SDL_UNUSED_SUBSYSTEMS
|
||||||
set(SDL_UNUSED_SUBSYSTEMS
|
File Filesystem
|
||||||
File Filesystem
|
Locale Power Render)
|
||||||
Locale Power Render)
|
foreach(_SUB ${SDL_UNUSED_SUBSYSTEMS})
|
||||||
foreach(_SUB ${SDL_UNUSED_SUBSYSTEMS})
|
string(TOUPPER ${_SUB} _OPT)
|
||||||
string(TOUPPER ${_SUB} _OPT)
|
set(SDL_${_OPT} OFF)
|
||||||
set(SDL_${_OPT} OFF)
|
endforeach()
|
||||||
endforeach()
|
|
||||||
|
|
||||||
set(HIDAPI ON)
|
set(HIDAPI ON)
|
||||||
endif()
|
|
||||||
|
|
||||||
if (APPLE)
|
|
||||||
set(SDL_FILE ON)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
AddJsonPackage(sdl3)
|
|
||||||
else()
|
|
||||||
message(STATUS "Using bundled SDL3")
|
|
||||||
AddJsonPackage(sdl3-ci)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Normalize SDL3 link target across package variants.
|
if (APPLE)
|
||||||
# Some SDL3 packages export only SDL3::SDL3-shared or SDL3::SDL3-static.
|
set(SDL_FILE ON)
|
||||||
if (NOT TARGET SDL3::SDL3)
|
endif()
|
||||||
if (TARGET SDL3::SDL3-shared)
|
|
||||||
add_library(SDL3::SDL3 ALIAS SDL3::SDL3-shared)
|
AddJsonPackage(sdl3)
|
||||||
elseif (TARGET SDL3::SDL3-static)
|
else()
|
||||||
add_library(SDL3::SDL3 ALIAS SDL3::SDL3-static)
|
message(STATUS "Using bundled SDL3")
|
||||||
else()
|
AddJsonPackage(sdl3-ci)
|
||||||
message(FATAL_ERROR "SDL3 package found, but no usable SDL3 target was exported")
|
|
||||||
endif()
|
# copy sdl java sources for consumption by Gradle
|
||||||
|
if (ANDROID)
|
||||||
|
file(COPY ${SDL3_SOURCE_DIR}/java DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/generated/sdl)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(BUILD_SHARED_LIBS OFF)
|
# Normalize SDL3 link target across package variants.
|
||||||
|
# Some SDL3 packages export only SDL3::SDL3-shared or SDL3::SDL3-static.
|
||||||
|
if (NOT TARGET SDL3::SDL3)
|
||||||
|
if (TARGET SDL3::SDL3-shared)
|
||||||
|
add_library(SDL3::SDL3 ALIAS SDL3::SDL3-shared)
|
||||||
|
elseif (TARGET SDL3::SDL3-static)
|
||||||
|
add_library(SDL3::SDL3 ALIAS SDL3::SDL3-static)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "SDL3 package found, but no usable SDL3 target was exported")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# SPIRV Headers
|
# SPIRV Headers
|
||||||
AddJsonPackage(spirv-headers)
|
AddJsonPackage(spirv-headers)
|
||||||
@@ -385,13 +386,6 @@ if (YUZU_CRASH_DUMPS AND NOT TARGET libbreakpad_client)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# oboe
|
|
||||||
if (ANDROID)
|
|
||||||
AddJsonPackage(oboe)
|
|
||||||
|
|
||||||
add_library(oboe::oboe ALIAS oboe)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
# moltenvk
|
# moltenvk
|
||||||
if (NOT YUZU_USE_BUNDLED_MOLTENVK)
|
if (NOT YUZU_USE_BUNDLED_MOLTENVK)
|
||||||
|
|||||||
Vendored
+51
-95
@@ -35,10 +35,7 @@ if (NOT YUZU_USE_BUNDLED_FFMPEG)
|
|||||||
elseif (NOT (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES CMAKE_SYSTEM_PROCESSOR
|
elseif (NOT (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES CMAKE_SYSTEM_PROCESSOR
|
||||||
AND CMAKE_HOST_SYSTEM_NAME MATCHES CMAKE_SYSTEM_NAME))
|
AND CMAKE_HOST_SYSTEM_NAME MATCHES CMAKE_SYSTEM_NAME))
|
||||||
string(TOLOWER "${CMAKE_SYSTEM_NAME}" FFmpeg_SYSTEM_NAME)
|
string(TOLOWER "${CMAKE_SYSTEM_NAME}" FFmpeg_SYSTEM_NAME)
|
||||||
# systems FFmpeg natively supports
|
if (FFmpeg_SYSTEM_NAME STREQUAL "openorbis" OR FFmpeg_SYSTEM_NAME STREQUAL "managarm")
|
||||||
if (NOT (NETBSD OR SOLARIS OR FREEBSD
|
|
||||||
OR OPENBSD OR DRAGONFLYBSD OR HAIKU
|
|
||||||
OR LINUX OR MSYS OR WIN32 OR ANDROID OR APPLE))
|
|
||||||
set(FFmpeg_SYSTEM_NAME "none")
|
set(FFmpeg_SYSTEM_NAME "none")
|
||||||
endif()
|
endif()
|
||||||
# TODO: Can we really do better? Auto-detection? Something clever?
|
# TODO: Can we really do better? Auto-detection? Something clever?
|
||||||
@@ -57,24 +54,23 @@ if (NOT YUZU_USE_BUNDLED_FFMPEG)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (OPENORBIS OR MANAGARM OR EMSCRIPTEN)
|
if (OPENORBIS OR MANAGARM)
|
||||||
# Doesn't support VA-API, don't go thru the embarrassment of trying to enable it
|
# Doesn't support VA-API, don't go thru the embarrassment of trying to enable it
|
||||||
|
list(APPEND FFmpeg_HWACCEL_FLAGS --disable-vaapi)
|
||||||
|
elseif (ANDROID)
|
||||||
list(APPEND FFmpeg_HWACCEL_FLAGS
|
list(APPEND FFmpeg_HWACCEL_FLAGS
|
||||||
--disable-vaapi
|
--enable-mediacodec
|
||||||
--disnable-cuvid
|
--enable-jni
|
||||||
--disnable-ffnvcodec
|
)
|
||||||
--disnable-nvdec
|
elseif (UNIX AND NOT DEFINED FFmpeg_IS_CROSS_COMPILING AND NOT ANDROID)
|
||||||
--disable-vulkan
|
|
||||||
--disable-libdrm)
|
|
||||||
elseif (UNIX)
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(LIBVA libva)
|
||||||
|
pkg_check_modules(CUDA cuda)
|
||||||
|
pkg_check_modules(FFNVCODEC ffnvcodec)
|
||||||
|
pkg_check_modules(VDPAU vdpau)
|
||||||
|
|
||||||
find_package(X11)
|
find_package(X11)
|
||||||
if(X11_FOUND)
|
if(X11_FOUND)
|
||||||
# Include X11 if possible, some APIs such as VDPAU heavily depend
|
|
||||||
# upon it's existence!
|
|
||||||
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${X11_LIBRARIES})
|
|
||||||
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${X11_INCLUDE_DIRS})
|
|
||||||
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${X11_LDFLAGS})
|
|
||||||
if (NOT APPLE)
|
if (NOT APPLE)
|
||||||
# In Solaris needs explicit linking for ffmpeg which links to /lib/amd64/libX11.so
|
# In Solaris needs explicit linking for ffmpeg which links to /lib/amd64/libX11.so
|
||||||
if(SOLARIS)
|
if(SOLARIS)
|
||||||
@@ -83,37 +79,32 @@ elseif (UNIX)
|
|||||||
"${CMAKE_SYSROOT}/usr/lib/xorg/amd64/libdrm.so")
|
"${CMAKE_SYSROOT}/usr/lib/xorg/amd64/libdrm.so")
|
||||||
else()
|
else()
|
||||||
pkg_check_modules(LIBDRM libdrm REQUIRED)
|
pkg_check_modules(LIBDRM libdrm REQUIRED)
|
||||||
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${LIBDRM_LIBRARIES})
|
list(APPEND FFmpeg_HWACCEL_LIBRARIES
|
||||||
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${LIBDRM_INCLUDE_DIRS})
|
${LIBDRM_LIBRARIES})
|
||||||
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${LIBDRM_LDFLAGS})
|
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS
|
||||||
|
${LIBDRM_INCLUDE_DIRS})
|
||||||
endif()
|
endif()
|
||||||
list(APPEND FFmpeg_HWACCEL_FLAGS --enable-libdrm)
|
list(APPEND FFmpeg_HWACCEL_FLAGS
|
||||||
|
--enable-libdrm)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
pkg_check_modules(LIBVA libva)
|
|
||||||
if(LIBVA_FOUND)
|
if(LIBVA_FOUND)
|
||||||
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${LIBVA_LIBRARIES})
|
|
||||||
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${LIBVA_INCLUDE_DIRS})
|
|
||||||
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${LIBVA_LDFLAGS})
|
|
||||||
|
|
||||||
# Logically, they can only exist if libva itself exists
|
|
||||||
pkg_check_modules(LIBVA-DRM libva-drm REQUIRED)
|
pkg_check_modules(LIBVA-DRM libva-drm REQUIRED)
|
||||||
pkg_check_modules(LIBVA-X11 libva-x11 REQUIRED)
|
pkg_check_modules(LIBVA-X11 libva-x11 REQUIRED)
|
||||||
if (LIBVA-DRM_FOUND)
|
list(APPEND FFmpeg_HWACCEL_LIBRARIES
|
||||||
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${LIBVA-DRM_LIBRARIES})
|
${X11_LIBRARIES}
|
||||||
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${LIBVA-DRM_INCLUDE_DIRS})
|
${LIBVA-DRM_LIBRARIES}
|
||||||
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${LIBVA-DRM_LDFLAGS})
|
${LIBVA-X11_LIBRARIES}
|
||||||
endif()
|
${LIBVA_LIBRARIES})
|
||||||
if (LIBVA-X11_FOUND)
|
|
||||||
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${LIBVA-X11_LIBRARIES})
|
|
||||||
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${LIBVA-X11_INCLUDE_DIRS})
|
|
||||||
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${LIBVA-X11_LDFLAGS})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
list(APPEND FFmpeg_HWACCEL_FLAGS
|
list(APPEND FFmpeg_HWACCEL_FLAGS
|
||||||
--enable-hwaccel=h264_vaapi
|
--enable-hwaccel=h264_vaapi
|
||||||
--enable-hwaccel=vp8_vaapi
|
--enable-hwaccel=vp8_vaapi
|
||||||
--enable-hwaccel=vp9_vaapi)
|
--enable-hwaccel=vp9_vaapi)
|
||||||
|
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS
|
||||||
|
${X11_INCLUDE_DIRS}
|
||||||
|
${LIBVA-DRM_INCLUDE_DIRS}
|
||||||
|
${LIBVA-X11_INCLUDE_DIRS}
|
||||||
|
${LIBVA_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
message(STATUS "ffmpeg: va-api libraries version ${LIBVA_VERSION} found")
|
message(STATUS "ffmpeg: va-api libraries version ${LIBVA_VERSION} found")
|
||||||
else()
|
else()
|
||||||
list(APPEND FFmpeg_HWACCEL_FLAGS --disable-vaapi)
|
list(APPEND FFmpeg_HWACCEL_FLAGS --disable-vaapi)
|
||||||
@@ -124,12 +115,6 @@ elseif (UNIX)
|
|||||||
message(WARNING "ffmpeg: X11 libraries not found, disabling VA-API...")
|
message(WARNING "ffmpeg: X11 libraries not found, disabling VA-API...")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
pkg_check_modules(CUDA cuda)
|
|
||||||
pkg_check_modules(FFNVCODEC ffnvcodec)
|
|
||||||
pkg_check_modules(VDPAU vdpau)
|
|
||||||
pkg_check_modules(VULKAN vulkan)
|
|
||||||
find_package(spirv-headers)
|
|
||||||
|
|
||||||
if (FFNVCODEC_FOUND)
|
if (FFNVCODEC_FOUND)
|
||||||
list(APPEND FFmpeg_HWACCEL_FLAGS
|
list(APPEND FFmpeg_HWACCEL_FLAGS
|
||||||
--enable-cuvid
|
--enable-cuvid
|
||||||
@@ -137,7 +122,8 @@ elseif (UNIX)
|
|||||||
--enable-nvdec
|
--enable-nvdec
|
||||||
--enable-hwaccel=h264_nvdec
|
--enable-hwaccel=h264_nvdec
|
||||||
--enable-hwaccel=vp8_nvdec
|
--enable-hwaccel=vp8_nvdec
|
||||||
--enable-hwaccel=vp9_nvdec)
|
--enable-hwaccel=vp9_nvdec
|
||||||
|
)
|
||||||
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${FFNVCODEC_LIBRARIES})
|
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${FFNVCODEC_LIBRARIES})
|
||||||
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${FFNVCODEC_INCLUDE_DIRS})
|
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${FFNVCODEC_INCLUDE_DIRS})
|
||||||
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${FFNVCODEC_LDFLAGS})
|
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${FFNVCODEC_LDFLAGS})
|
||||||
@@ -158,7 +144,8 @@ elseif (UNIX)
|
|||||||
list(APPEND FFmpeg_HWACCEL_FLAGS
|
list(APPEND FFmpeg_HWACCEL_FLAGS
|
||||||
--enable-vdpau
|
--enable-vdpau
|
||||||
--enable-hwaccel=h264_vdpau
|
--enable-hwaccel=h264_vdpau
|
||||||
--enable-hwaccel=vp9_vdpau)
|
--enable-hwaccel=vp9_vdpau
|
||||||
|
)
|
||||||
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${VDPAU_LIBRARIES})
|
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${VDPAU_LIBRARIES})
|
||||||
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${VDPAU_INCLUDE_DIRS})
|
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${VDPAU_INCLUDE_DIRS})
|
||||||
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${VDPAU_LDFLAGS})
|
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${VDPAU_LDFLAGS})
|
||||||
@@ -167,24 +154,6 @@ elseif (UNIX)
|
|||||||
list(APPEND FFmpeg_HWACCEL_FLAGS --disable-vdpau)
|
list(APPEND FFmpeg_HWACCEL_FLAGS --disable-vdpau)
|
||||||
message(WARNING "ffmpeg: libvdpau-dev not found, disabling Video Decode and Presentation API for Unix (VDPAU)...")
|
message(WARNING "ffmpeg: libvdpau-dev not found, disabling Video Decode and Presentation API for Unix (VDPAU)...")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (VULKAN_FOUND AND NOT APPLE)
|
|
||||||
list(APPEND FFmpeg_HWACCEL_FLAGS
|
|
||||||
--enable-vulkan
|
|
||||||
--enable-hwaccel=h264_vulkan
|
|
||||||
--enable-hwaccel=vp9_vulkan)
|
|
||||||
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${VULKAN_LIBRARIES})
|
|
||||||
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${VULKAN_INCLUDE_DIRS})
|
|
||||||
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${VULKAN_LDFLAGS})
|
|
||||||
message(STATUS "ffmpeg: vulkan libraries version ${VULKAN_VERSION} found")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (SPIRV_HEADERS_FOUND)
|
|
||||||
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${SPIRV_HEADERS_LIBRARIES})
|
|
||||||
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${SPIRV_HEADERS_INCLUDE_DIRS})
|
|
||||||
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${SPIRV_HEADERS_LDFLAGS})
|
|
||||||
message(STATUS "ffmpeg: spirv-headers libraries version ${SPIRV_HEADERS_VERSION} found")
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (OPENORBIS)
|
if (OPENORBIS)
|
||||||
@@ -193,28 +162,20 @@ if (OPENORBIS)
|
|||||||
-lSceUserService
|
-lSceUserService
|
||||||
-lSceSysmodule
|
-lSceSysmodule
|
||||||
-lSceNet
|
-lSceNet
|
||||||
-lSceLibcInternal)
|
-lSceLibcInternal
|
||||||
|
)
|
||||||
list(APPEND FFmpeg_CROSS_COMPILE_FLAGS
|
list(APPEND FFmpeg_CROSS_COMPILE_FLAGS
|
||||||
--disable-pthreads
|
--disable-pthreads
|
||||||
--extra-cflags=${CMAKE_SYSROOT}/usr/include
|
--extra-cflags=${CMAKE_SYSROOT}/usr/include
|
||||||
--extra-cxxflags=${CMAKE_SYSROOT}/usr/include
|
--extra-cxxflags=${CMAKE_SYSROOT}/usr/include
|
||||||
--extra-libs="${FFmpeg_CROSS_COMPILE_LIBS}")
|
--extra-libs="${FFmpeg_CROSS_COMPILE_LIBS}"
|
||||||
|
)
|
||||||
elseif (MANAGARM)
|
elseif (MANAGARM)
|
||||||
# Required for proper stuff
|
# Required for proper stuff
|
||||||
list(APPEND FFmpeg_CROSS_COMPILE_FLAGS
|
list(APPEND FFmpeg_CROSS_COMPILE_FLAGS
|
||||||
--disable-pthreads
|
--disable-pthreads
|
||||||
--extra-libs="${FFmpeg_CROSS_COMPILE_LIBS}")
|
--extra-libs="${FFmpeg_CROSS_COMPILE_LIBS}"
|
||||||
endif()
|
)
|
||||||
|
|
||||||
# Usually used by Emscripten
|
|
||||||
if (DEFINED CMAKE_AR)
|
|
||||||
list(APPEND FFmpeg_CROSS_COMPILE_FLAGS --ar=${CMAKE_AR})
|
|
||||||
endif()
|
|
||||||
if (DEFINED CMAKE_NM)
|
|
||||||
list(APPEND FFmpeg_CROSS_COMPILE_FLAGS --nm=${CMAKE_NM})
|
|
||||||
endif()
|
|
||||||
if (DEFINED CMAKE_RANLIB)
|
|
||||||
list(APPEND FFmpeg_CROSS_COMPILE_FLAGS --ranlib=${CMAKE_RANLIB})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (YUZU_USE_BUNDLED_FFMPEG)
|
if (YUZU_USE_BUNDLED_FFMPEG)
|
||||||
@@ -289,14 +250,8 @@ else()
|
|||||||
|
|
||||||
# `configure` parameters builds only exactly what yuzu needs from FFmpeg
|
# `configure` parameters builds only exactly what yuzu needs from FFmpeg
|
||||||
# `--disable-vdpau` is needed to avoid linking issues
|
# `--disable-vdpau` is needed to avoid linking issues
|
||||||
set(FFmpeg_CC ${CMAKE_C_COMPILER_LAUNCHER} ${CMAKE_C_COMPILER})
|
set(FFmpeg_CC ${CMAKE_C_COMPILER_LAUNCHER} ${CMAKE_C_COMPILER})
|
||||||
set(FFmpeg_CXX ${CMAKE_CXX_COMPILER_LAUNCHER} ${CMAKE_CXX_COMPILER})
|
set(FFmpeg_CXX ${CMAKE_CXX_COMPILER_LAUNCHER} ${CMAKE_CXX_COMPILER})
|
||||||
if (FFmpeg_IS_CROSS_COMPILING)
|
|
||||||
list(APPEND FFmpeg_CROSS_COMPILE_FLAGS --ld=${CMAKE_LINKER})
|
|
||||||
endif ()
|
|
||||||
# TODO: This is a bit fragile, it depends on FFmpeg_HWACCEL_LDFLAGS being a list
|
|
||||||
# whereas CMAKE_C_FLAGS (and likewise) is meant to NOT be a list, but rather
|
|
||||||
# an elongated piece of string
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT
|
OUTPUT
|
||||||
${FFmpeg_MAKEFILE}
|
${FFmpeg_MAKEFILE}
|
||||||
@@ -310,7 +265,6 @@ else()
|
|||||||
--disable-ffprobe
|
--disable-ffprobe
|
||||||
--disable-network
|
--disable-network
|
||||||
--disable-swresample
|
--disable-swresample
|
||||||
--disable-iconv
|
|
||||||
--enable-decoder=h264
|
--enable-decoder=h264
|
||||||
--enable-decoder=vp8
|
--enable-decoder=vp8
|
||||||
--enable-decoder=vp9
|
--enable-decoder=vp9
|
||||||
@@ -318,9 +272,10 @@ else()
|
|||||||
--enable-pic
|
--enable-pic
|
||||||
--cc=${FFmpeg_CC}
|
--cc=${FFmpeg_CC}
|
||||||
--cxx=${FFmpeg_CXX}
|
--cxx=${FFmpeg_CXX}
|
||||||
|
--ld=${CMAKE_LINKER}
|
||||||
--extra-cflags=${CMAKE_C_FLAGS}
|
--extra-cflags=${CMAKE_C_FLAGS}
|
||||||
--extra-cxxflags=${CMAKE_CXX_FLAGS}
|
--extra-cxxflags=${CMAKE_CXX_FLAGS}
|
||||||
--extra-ldflags="${FFmpeg_HWACCEL_LDFLAGS}"
|
--extra-ldflags=${CMAKE_C_LINK_FLAGS}
|
||||||
${FFmpeg_HWACCEL_FLAGS}
|
${FFmpeg_HWACCEL_FLAGS}
|
||||||
${FFmpeg_CROSS_COMPILE_FLAGS}
|
${FFmpeg_CROSS_COMPILE_FLAGS}
|
||||||
WORKING_DIRECTORY
|
WORKING_DIRECTORY
|
||||||
@@ -328,30 +283,31 @@ else()
|
|||||||
)
|
)
|
||||||
unset(FFmpeg_CC)
|
unset(FFmpeg_CC)
|
||||||
unset(FFmpeg_CXX)
|
unset(FFmpeg_CXX)
|
||||||
unset(FFmpeg_LD)
|
|
||||||
unset(FFmpeg_HWACCEL_FLAGS)
|
unset(FFmpeg_HWACCEL_FLAGS)
|
||||||
unset(FFmpeg_CROSS_COMPILE_FLAGS)
|
unset(FFmpeg_CROSS_COMPILE_FLAGS)
|
||||||
|
|
||||||
# Workaround for Ubuntu 18.04's older version of make not being able to call make as a child
|
# Workaround for Ubuntu 18.04's older version of make not being able to call make as a child
|
||||||
# with context of the jobserver. Also helps ninja users.
|
# with context of the jobserver. Also helps ninja users.
|
||||||
cmake_host_system_information(RESULT SYSTEM_THREADS QUERY NUMBER_OF_LOGICAL_CORES)
|
execute_process(
|
||||||
|
COMMAND
|
||||||
|
nproc
|
||||||
|
OUTPUT_VARIABLE
|
||||||
|
SYSTEM_THREADS)
|
||||||
|
|
||||||
set(FFmpeg_BUILD_LIBRARIES ${FFmpeg_LIBRARIES})
|
set(FFmpeg_BUILD_LIBRARIES ${FFmpeg_LIBRARIES})
|
||||||
|
|
||||||
# BSD make or Solaris make don't support ffmpeg make-j8
|
# BSD make or Solaris make don't support ffmpeg make-j8
|
||||||
if (DEFINED SYSTEM_THREADS AND (LINUX OR ANDROID OR APPLE OR WIN32))
|
if (LINUX OR ANDROID OR APPLE OR WIN32 OR FREEBSD)
|
||||||
set(FFmpeg_MAKE_ARGS -j${SYSTEM_THREADS})
|
set(FFmpeg_MAKE_ARGS -j${SYSTEM_THREADS})
|
||||||
else()
|
else()
|
||||||
set(FFmpeg_MAKE_ARGS "")
|
set(FFmpeg_MAKE_ARGS "")
|
||||||
endif()
|
endif()
|
||||||
# Most distros use 'gmake', Arch uses 'make'
|
|
||||||
find_program(MAKE gmake NAMES gmake make REQUIRED)
|
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT
|
OUTPUT
|
||||||
${FFmpeg_BUILD_LIBRARIES}
|
${FFmpeg_BUILD_LIBRARIES}
|
||||||
COMMAND
|
COMMAND
|
||||||
${MAKE} ${FFmpeg_MAKE_ARGS}
|
gmake ${FFmpeg_MAKE_ARGS}
|
||||||
WORKING_DIRECTORY
|
WORKING_DIRECTORY
|
||||||
${FFmpeg_BUILD_DIR}
|
${FFmpeg_BUILD_DIR}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -272,6 +272,13 @@ android {
|
|||||||
resValue("string", "app_name_suffixed", "$currentName$suffix")
|
resValue("string", "app_name_suffixed", "$currentName$suffix")
|
||||||
resValue("string", "app_name", "Eden$suffix")
|
resValue("string", "app_name", "Eden$suffix")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
named("main") {
|
||||||
|
java.srcDir("${edenDir}/externals/generated/sdl/java")
|
||||||
|
kotlin.srcDir("${edenDir}/externals/generated/sdl/java")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
idea {
|
idea {
|
||||||
|
|||||||
Vendored
+3
@@ -9,6 +9,9 @@
|
|||||||
-keep class org.ini4j.spi.IniBuilder
|
-keep class org.ini4j.spi.IniBuilder
|
||||||
-keep class org.ini4j.spi.IniFormatter
|
-keep class org.ini4j.spi.IniFormatter
|
||||||
|
|
||||||
|
-keep class org.libsdl.app.** { *; }
|
||||||
|
-keepclassmembers class org.libsdl.app.** { *; }
|
||||||
|
|
||||||
# Suppress warnings for R8
|
# Suppress warnings for R8
|
||||||
-dontwarn org.bouncycastle.jsse.BCSSLParameters
|
-dontwarn org.bouncycastle.jsse.BCSSLParameters
|
||||||
-dontwarn org.bouncycastle.jsse.BCSSLSocket
|
-dontwarn org.bouncycastle.jsse.BCSSLSocket
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import android.widget.TextView
|
|||||||
import androidx.annotation.Keep
|
import androidx.annotation.Keep
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import org.libsdl.app.SDL
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
import org.yuzu.yuzu_emu.activities.EmulationActivity
|
import org.yuzu.yuzu_emu.activities.EmulationActivity
|
||||||
import org.yuzu.yuzu_emu.fragments.CoreErrorDialogFragment
|
import org.yuzu.yuzu_emu.fragments.CoreErrorDialogFragment
|
||||||
@@ -52,6 +53,8 @@ object NativeLibrary {
|
|||||||
init {
|
init {
|
||||||
try {
|
try {
|
||||||
System.loadLibrary("yuzu-android")
|
System.loadLibrary("yuzu-android")
|
||||||
|
SDL.setupJNI()
|
||||||
|
initJvm()
|
||||||
} catch (ex: UnsatisfiedLinkError) {
|
} catch (ex: UnsatisfiedLinkError) {
|
||||||
error("[NativeLibrary] $ex")
|
error("[NativeLibrary] $ex")
|
||||||
}
|
}
|
||||||
@@ -367,6 +370,7 @@ object NativeLibrary {
|
|||||||
NetPlayManager.clearChat()
|
NetPlayManager.clearChat()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
external fun initJvm()
|
||||||
external fun initMultiplayer()
|
external fun initMultiplayer()
|
||||||
|
|
||||||
@Keep
|
@Keep
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ add_library(yuzu-android SHARED
|
|||||||
set_property(TARGET yuzu-android PROPERTY IMPORTED_LOCATION ${FFmpeg_LIBRARY_DIR})
|
set_property(TARGET yuzu-android PROPERTY IMPORTED_LOCATION ${FFmpeg_LIBRARY_DIR})
|
||||||
|
|
||||||
target_link_libraries(yuzu-android PRIVATE audio_core common core input_common frontend_common video_core)
|
target_link_libraries(yuzu-android PRIVATE audio_core common core input_common frontend_common video_core)
|
||||||
target_link_libraries(yuzu-android PRIVATE android camera2ndk EGL glad jnigraphics log)
|
target_link_libraries(yuzu-android PRIVATE android camera2ndk EGL glad jnigraphics log GLESv2)
|
||||||
if (ARCHITECTURE_arm64)
|
if (ARCHITECTURE_arm64)
|
||||||
target_link_libraries(yuzu-android PRIVATE adrenotools)
|
target_link_libraries(yuzu-android PRIVATE adrenotools)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1730,6 +1730,15 @@ jint Java_org_yuzu_yuzu_1emu_NativeLibrary_loadAmiibo(JNIEnv* env, jobject jobj,
|
|||||||
return static_cast<jint>(info);
|
return static_cast<jint>(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT void JNICALL
|
||||||
|
Java_org_yuzu_yuzu_1emu_NativeLibrary_initJvm(JNIEnv *env, jclass clazz) {
|
||||||
|
JavaVM *vm;
|
||||||
|
if (env->GetJavaVM(&vm) != JNI_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Common::Android::Initialize(vm, env);
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_org_yuzu_yuzu_1emu_NativeLibrary_initMultiplayer(
|
Java_org_yuzu_yuzu_1emu_NativeLibrary_initMultiplayer(
|
||||||
JNIEnv* env, [[maybe_unused]] jobject obj) {
|
JNIEnv* env, [[maybe_unused]] jobject obj) {
|
||||||
|
|||||||
@@ -800,7 +800,6 @@
|
|||||||
<string name="theme_mode_dark">تاریک</string>
|
<string name="theme_mode_dark">تاریک</string>
|
||||||
|
|
||||||
<!-- Audio output engines -->
|
<!-- Audio output engines -->
|
||||||
<string name="oboe">oboe</string>
|
|
||||||
<string name="cubeb">cubeb</string>
|
<string name="cubeb">cubeb</string>
|
||||||
|
|
||||||
<!-- Anisotropic filtering options -->
|
<!-- Anisotropic filtering options -->
|
||||||
|
|||||||
@@ -465,13 +465,13 @@
|
|||||||
|
|
||||||
<string-array name="outputEngineEntries">
|
<string-array name="outputEngineEntries">
|
||||||
<item>@string/auto</item>
|
<item>@string/auto</item>
|
||||||
<item>@string/oboe</item>
|
<item>@string/sdl3</item>
|
||||||
<item>@string/cubeb</item>
|
<item>@string/cubeb</item>
|
||||||
<item>@string/string_null</item>
|
<item>@string/string_null</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<integer-array name="outputEngineValues">
|
<integer-array name="outputEngineValues">
|
||||||
<item>0</item>
|
<item>0</item>
|
||||||
<item>4</item>
|
<item>2</item>
|
||||||
<item>1</item>
|
<item>1</item>
|
||||||
<item>3</item>
|
<item>3</item>
|
||||||
</integer-array>
|
</integer-array>
|
||||||
|
|||||||
@@ -1240,7 +1240,7 @@
|
|||||||
<string name="theme_mode_dark">Dark</string>
|
<string name="theme_mode_dark">Dark</string>
|
||||||
|
|
||||||
<!-- Audio output engines -->
|
<!-- Audio output engines -->
|
||||||
<string name="oboe" translatable="false">oboe</string>
|
<string name="sdl3" translatable="false">SDL3</string>
|
||||||
<string name="cubeb" translatable="false">cubeb</string>
|
<string name="cubeb" translatable="false">cubeb</string>
|
||||||
|
|
||||||
<!-- Anisotropic filtering options -->
|
<!-- Anisotropic filtering options -->
|
||||||
|
|||||||
@@ -238,20 +238,11 @@ if (ENABLE_CUBEB)
|
|||||||
target_compile_definitions(audio_core PRIVATE HAVE_CUBEB=1)
|
target_compile_definitions(audio_core PRIVATE HAVE_CUBEB=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ANDROID)
|
target_sources(audio_core PRIVATE
|
||||||
target_sources(audio_core PRIVATE
|
sink/sdl3_sink.cpp
|
||||||
sink/oboe_sink.cpp
|
sink/sdl3_sink.h)
|
||||||
sink/oboe_sink.h)
|
|
||||||
|
|
||||||
target_link_libraries(audio_core PRIVATE oboe)
|
target_link_libraries(audio_core PRIVATE SDL3::SDL3)
|
||||||
target_compile_definitions(audio_core PUBLIC HAVE_OBOE)
|
target_compile_definitions(audio_core PRIVATE HAVE_SDL3)
|
||||||
else()
|
|
||||||
target_sources(audio_core PRIVATE
|
|
||||||
sink/sdl3_sink.cpp
|
|
||||||
sink/sdl3_sink.h)
|
|
||||||
|
|
||||||
target_link_libraries(audio_core PRIVATE SDL3::SDL3)
|
|
||||||
target_compile_definitions(audio_core PRIVATE HAVE_SDL3)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
create_target_directory_groups(audio_core)
|
create_target_directory_groups(audio_core)
|
||||||
|
|||||||
@@ -1,230 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#include <span>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <oboe/Oboe.h>
|
|
||||||
|
|
||||||
#include "audio_core/common/common.h"
|
|
||||||
#include "audio_core/sink/oboe_sink.h"
|
|
||||||
#include "audio_core/sink/sink_stream.h"
|
|
||||||
#include "common/logging.h"
|
|
||||||
#include "common/scope_exit.h"
|
|
||||||
#include "core/core.h"
|
|
||||||
|
|
||||||
namespace AudioCore::Sink {
|
|
||||||
|
|
||||||
class OboeSinkStream final : public SinkStream,
|
|
||||||
public oboe::AudioStreamDataCallback,
|
|
||||||
public oboe::AudioStreamErrorCallback {
|
|
||||||
public:
|
|
||||||
explicit OboeSinkStream(Core::System& system_, StreamType type_, const std::string& name_,
|
|
||||||
u32 system_channels_)
|
|
||||||
: SinkStream(system_, type_) {
|
|
||||||
name = name_;
|
|
||||||
system_channels = system_channels_;
|
|
||||||
|
|
||||||
this->OpenStream();
|
|
||||||
}
|
|
||||||
|
|
||||||
~OboeSinkStream() override {
|
|
||||||
LOG_INFO(Audio_Sink, "Destroyed Oboe stream");
|
|
||||||
}
|
|
||||||
|
|
||||||
void Finalize() override {
|
|
||||||
this->Stop();
|
|
||||||
m_stream.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Start(bool resume = false) override {
|
|
||||||
if (!m_stream || !paused) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
paused = false;
|
|
||||||
|
|
||||||
if (m_stream->start() != oboe::Result::OK) {
|
|
||||||
LOG_CRITICAL(Audio_Sink, "Error starting Oboe stream");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Stop() override {
|
|
||||||
if (!m_stream || paused) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->SignalPause();
|
|
||||||
|
|
||||||
if (m_stream->stop() != oboe::Result::OK) {
|
|
||||||
LOG_CRITICAL(Audio_Sink, "Error stopping Oboe stream");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
static s32 QueryChannelCount(oboe::Direction direction) {
|
|
||||||
std::shared_ptr<oboe::AudioStream> temp_stream;
|
|
||||||
oboe::AudioStreamBuilder builder;
|
|
||||||
|
|
||||||
const auto result = ConfigureBuilder(builder, direction)->openStream(temp_stream);
|
|
||||||
if (result == oboe::Result::OK) {
|
|
||||||
return temp_stream->getChannelCount() >= 6 ? 6 : 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_ERROR(Audio_Sink, "Failed to open {} stream. Using default channel count 2",
|
|
||||||
direction == oboe::Direction::Output ? "output" : "input");
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
oboe::DataCallbackResult onAudioReady(oboe::AudioStream*, void* audio_data,
|
|
||||||
s32 num_buffer_frames) override {
|
|
||||||
const size_t num_channels = this->GetDeviceChannels();
|
|
||||||
const size_t frame_size = num_channels;
|
|
||||||
const size_t num_frames = static_cast<size_t>(num_buffer_frames);
|
|
||||||
|
|
||||||
if (type == StreamType::In) {
|
|
||||||
std::span<const s16> input_buffer{reinterpret_cast<const s16*>(audio_data),
|
|
||||||
num_frames * frame_size};
|
|
||||||
this->ProcessAudioIn(input_buffer, num_frames);
|
|
||||||
} else {
|
|
||||||
std::span<s16> output_buffer{reinterpret_cast<s16*>(audio_data),
|
|
||||||
num_frames * frame_size};
|
|
||||||
this->ProcessAudioOutAndRender(output_buffer, num_frames);
|
|
||||||
}
|
|
||||||
|
|
||||||
return oboe::DataCallbackResult::Continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
void onErrorAfterClose(oboe::AudioStream*, oboe::Result) override {
|
|
||||||
LOG_INFO(Audio_Sink, "Audio stream closed, reinitializing");
|
|
||||||
|
|
||||||
if (this->OpenStream()) {
|
|
||||||
m_stream->start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
static oboe::AudioStreamBuilder* ConfigureBuilder(oboe::AudioStreamBuilder& builder,
|
|
||||||
oboe::Direction direction) {
|
|
||||||
// TODO: investigate callback delay issues when using AAudio
|
|
||||||
return builder.setPerformanceMode(oboe::PerformanceMode::LowLatency)
|
|
||||||
->setAudioApi(oboe::AudioApi::OpenSLES)
|
|
||||||
->setDirection(direction)
|
|
||||||
->setSampleRate(TargetSampleRate)
|
|
||||||
->setSampleRateConversionQuality(oboe::SampleRateConversionQuality::High)
|
|
||||||
->setFormat(oboe::AudioFormat::I16)
|
|
||||||
->setFormatConversionAllowed(true)
|
|
||||||
->setUsage(oboe::Usage::Game)
|
|
||||||
->setBufferCapacityInFrames(TargetSampleCount * 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenStream() {
|
|
||||||
const auto direction = [&]() {
|
|
||||||
switch (type) {
|
|
||||||
case StreamType::In:
|
|
||||||
return oboe::Direction::Input;
|
|
||||||
case StreamType::Out:
|
|
||||||
case StreamType::Render:
|
|
||||||
return oboe::Direction::Output;
|
|
||||||
default:
|
|
||||||
ASSERT(false);
|
|
||||||
return oboe::Direction::Output;
|
|
||||||
}
|
|
||||||
}();
|
|
||||||
|
|
||||||
const auto expected_channels = QueryChannelCount(direction);
|
|
||||||
const auto expected_mask = [&]() {
|
|
||||||
switch (expected_channels) {
|
|
||||||
case 1:
|
|
||||||
return oboe::ChannelMask::Mono;
|
|
||||||
case 2:
|
|
||||||
return oboe::ChannelMask::Stereo;
|
|
||||||
case 6:
|
|
||||||
return oboe::ChannelMask::CM5Point1;
|
|
||||||
default:
|
|
||||||
ASSERT(false);
|
|
||||||
return oboe::ChannelMask::Unspecified;
|
|
||||||
}
|
|
||||||
}();
|
|
||||||
|
|
||||||
oboe::AudioStreamBuilder builder;
|
|
||||||
const auto result = ConfigureBuilder(builder, direction)
|
|
||||||
->setChannelCount(expected_channels)
|
|
||||||
->setChannelMask(expected_mask)
|
|
||||||
->setChannelConversionAllowed(true)
|
|
||||||
->setDataCallback(this)
|
|
||||||
->setErrorCallback(this)
|
|
||||||
->openStream(m_stream);
|
|
||||||
ASSERT(result == oboe::Result::OK);
|
|
||||||
return result == oboe::Result::OK && this->SetStreamProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SetStreamProperties() {
|
|
||||||
ASSERT(m_stream);
|
|
||||||
|
|
||||||
m_stream->setBufferSizeInFrames(TargetSampleCount * 2);
|
|
||||||
device_channels = m_stream->getChannelCount();
|
|
||||||
|
|
||||||
const auto sample_rate = m_stream->getSampleRate();
|
|
||||||
const auto buffer_capacity = m_stream->getBufferCapacityInFrames();
|
|
||||||
const auto stream_backend =
|
|
||||||
m_stream->getAudioApi() == oboe::AudioApi::AAudio ? "AAudio" : "OpenSLES";
|
|
||||||
|
|
||||||
LOG_INFO(Audio_Sink, "Opened Oboe {} stream with {} channels sample rate {} capacity {}",
|
|
||||||
stream_backend, device_channels, sample_rate, buffer_capacity);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<oboe::AudioStream> m_stream{};
|
|
||||||
};
|
|
||||||
|
|
||||||
OboeSink::OboeSink() {
|
|
||||||
// TODO: This is not generally knowable
|
|
||||||
// The channel count is distinct based on direction and can change
|
|
||||||
device_channels = OboeSinkStream::QueryChannelCount(oboe::Direction::Output);
|
|
||||||
}
|
|
||||||
|
|
||||||
OboeSink::~OboeSink() = default;
|
|
||||||
|
|
||||||
SinkStream* OboeSink::AcquireSinkStream(Core::System& system, u32 system_channels,
|
|
||||||
const std::string& name, StreamType type) {
|
|
||||||
SinkStreamPtr& stream = sink_streams.emplace_back(
|
|
||||||
std::make_unique<OboeSinkStream>(system, type, name, system_channels));
|
|
||||||
|
|
||||||
return stream.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OboeSink::CloseStream(SinkStream* to_remove) {
|
|
||||||
sink_streams.remove_if([&](auto& stream) { return stream.get() == to_remove; });
|
|
||||||
}
|
|
||||||
|
|
||||||
void OboeSink::CloseStreams() {
|
|
||||||
sink_streams.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
f32 OboeSink::GetDeviceVolume() const {
|
|
||||||
if (sink_streams.empty()) {
|
|
||||||
return 1.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sink_streams.front()->GetDeviceVolume();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OboeSink::SetDeviceVolume(f32 volume) {
|
|
||||||
for (auto& stream : sink_streams) {
|
|
||||||
stream->SetDeviceVolume(volume);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OboeSink::SetSystemVolume(f32 volume) {
|
|
||||||
for (auto& stream : sink_streams) {
|
|
||||||
stream->SetSystemVolume(volume);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace AudioCore::Sink
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "audio_core/sink/sink.h"
|
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
class System;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace AudioCore::Sink {
|
|
||||||
class SinkStream;
|
|
||||||
|
|
||||||
class OboeSink final : public Sink {
|
|
||||||
public:
|
|
||||||
explicit OboeSink();
|
|
||||||
~OboeSink() override;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new sink stream.
|
|
||||||
*
|
|
||||||
* @param system - Core system.
|
|
||||||
* @param system_channels - Number of channels the audio system expects.
|
|
||||||
* May differ from the device's channel count.
|
|
||||||
* @param name - Name of this stream.
|
|
||||||
* @param type - Type of this stream, render/in/out.
|
|
||||||
*
|
|
||||||
* @return A pointer to the created SinkStream
|
|
||||||
*/
|
|
||||||
SinkStream* AcquireSinkStream(Core::System& system, u32 system_channels,
|
|
||||||
const std::string& name, StreamType type) override;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Close a given stream.
|
|
||||||
*
|
|
||||||
* @param stream - The stream to close.
|
|
||||||
*/
|
|
||||||
void CloseStream(SinkStream* stream) override;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Close all streams.
|
|
||||||
*/
|
|
||||||
void CloseStreams() override;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the device volume. Set from calls to the IAudioDevice service.
|
|
||||||
*
|
|
||||||
* @return Volume of the device.
|
|
||||||
*/
|
|
||||||
f32 GetDeviceVolume() const override;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the device volume. Set from calls to the IAudioDevice service.
|
|
||||||
*
|
|
||||||
* @param volume - New volume of the device.
|
|
||||||
*/
|
|
||||||
void SetDeviceVolume(f32 volume) override;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the system volume. Comes from the audio system using this stream.
|
|
||||||
*
|
|
||||||
* @param volume - New volume of the system.
|
|
||||||
*/
|
|
||||||
void SetSystemVolume(f32 volume) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// List of streams managed by this sink
|
|
||||||
std::list<SinkStreamPtr> sink_streams{};
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace AudioCore::Sink
|
|
||||||
@@ -10,9 +10,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "audio_core/sink/sink_details.h"
|
#include "audio_core/sink/sink_details.h"
|
||||||
#ifdef HAVE_OBOE
|
|
||||||
#include "audio_core/sink/oboe_sink.h"
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_CUBEB
|
#ifdef HAVE_CUBEB
|
||||||
#include "audio_core/sink/cubeb_sink.h"
|
#include "audio_core/sink/cubeb_sink.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -43,24 +40,8 @@ struct SinkDetails {
|
|||||||
/// SuitableFn is_suitable; // REVERTED FOR LatencyFn latency ABOVE - DIABLO 3 FIX
|
/// SuitableFn is_suitable; // REVERTED FOR LatencyFn latency ABOVE - DIABLO 3 FIX
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOTE TO PROBABLY FIX LATER FOR ANDROID - the return value "0u" for the first HAVE_OBOE
|
|
||||||
// section below was just copied from the null section so there's a somewhat valid value
|
|
||||||
// being returned, since the previous "true" value probably isn't compatible with the
|
|
||||||
// previous EA-3833 code. (HAVE_OBOE was introduced in a later release.) Eventually need
|
|
||||||
// to change "0u" for something else directly from the oboe_sink.cpp functions.
|
|
||||||
|
|
||||||
// sink_details is ordered in terms of desirability, with the best choice at the top.
|
// sink_details is ordered in terms of desirability, with the best choice at the top.
|
||||||
constexpr SinkDetails sink_details[] = {
|
constexpr SinkDetails sink_details[] = {
|
||||||
#ifdef HAVE_OBOE
|
|
||||||
SinkDetails{
|
|
||||||
Settings::AudioEngine::Oboe,
|
|
||||||
[](std::string_view device_id) -> std::unique_ptr<Sink> {
|
|
||||||
return std::make_unique<OboeSink>();
|
|
||||||
},
|
|
||||||
[](bool capture) { return std::vector<std::string>{"Default"}; },
|
|
||||||
[]() { return 0u; },
|
|
||||||
},
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_CUBEB
|
#ifdef HAVE_CUBEB
|
||||||
SinkDetails{
|
SinkDetails{
|
||||||
Settings::AudioEngine::Cubeb,
|
Settings::AudioEngine::Cubeb,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
#include "android_common.h"
|
#include "android_common.h"
|
||||||
@@ -51,7 +51,7 @@ jstring ToJString(JNIEnv* env, std::u16string_view str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double GetJDouble(JNIEnv* env, jobject jdouble) {
|
double GetJDouble(JNIEnv* env, jobject jdouble) {
|
||||||
return env->GetDoubleField(jdouble, GetDoubleValueField());
|
return env->CallDoubleMethod(jdouble, GetDoubleValueMethod());
|
||||||
}
|
}
|
||||||
|
|
||||||
jobject ToJDouble(JNIEnv* env, double value) {
|
jobject ToJDouble(JNIEnv* env, double value) {
|
||||||
@@ -59,7 +59,7 @@ jobject ToJDouble(JNIEnv* env, double value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s32 GetJInteger(JNIEnv* env, jobject jinteger) {
|
s32 GetJInteger(JNIEnv* env, jobject jinteger) {
|
||||||
return env->GetIntField(jinteger, GetIntegerValueField());
|
return env->CallIntMethod(jinteger, GetIntegerValueMethod());
|
||||||
}
|
}
|
||||||
|
|
||||||
jobject ToJInteger(JNIEnv* env, s32 value) {
|
jobject ToJInteger(JNIEnv* env, s32 value) {
|
||||||
@@ -67,7 +67,7 @@ jobject ToJInteger(JNIEnv* env, s32 value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GetJBoolean(JNIEnv* env, jobject jboolean) {
|
bool GetJBoolean(JNIEnv* env, jobject jboolean) {
|
||||||
return env->GetBooleanField(jboolean, GetBooleanValueField());
|
return env->CallBooleanMethod(jboolean, GetBooleanValueMethod());
|
||||||
}
|
}
|
||||||
|
|
||||||
jobject ToJBoolean(JNIEnv* env, bool value) {
|
jobject ToJBoolean(JNIEnv* env, bool value) {
|
||||||
|
|||||||
+188
-192
@@ -63,15 +63,15 @@ static jfieldID s_patch_title_id_field;
|
|||||||
|
|
||||||
static jclass s_double_class;
|
static jclass s_double_class;
|
||||||
static jmethodID s_double_constructor;
|
static jmethodID s_double_constructor;
|
||||||
static jfieldID s_double_value_field;
|
static jmethodID s_double_value_method;
|
||||||
|
|
||||||
static jclass s_integer_class;
|
static jclass s_integer_class;
|
||||||
static jmethodID s_integer_constructor;
|
static jmethodID s_integer_constructor;
|
||||||
static jfieldID s_integer_value_field;
|
static jmethodID s_integer_value_method;
|
||||||
|
|
||||||
static jclass s_boolean_class;
|
static jclass s_boolean_class;
|
||||||
static jmethodID s_boolean_constructor;
|
static jmethodID s_boolean_constructor;
|
||||||
static jfieldID s_boolean_value_field;
|
static jmethodID s_boolean_value_method;
|
||||||
|
|
||||||
static jclass s_player_input_class;
|
static jclass s_player_input_class;
|
||||||
static jmethodID s_player_input_constructor;
|
static jmethodID s_player_input_constructor;
|
||||||
@@ -103,7 +103,6 @@ static jmethodID s_clear_chat;
|
|||||||
static constexpr jint JNI_VERSION = JNI_VERSION_1_6;
|
static constexpr jint JNI_VERSION = JNI_VERSION_1_6;
|
||||||
|
|
||||||
namespace Common::Android {
|
namespace Common::Android {
|
||||||
|
|
||||||
JNIEnv *GetEnvForThread() {
|
JNIEnv *GetEnvForThread() {
|
||||||
thread_local static struct OwnedEnv {
|
thread_local static struct OwnedEnv {
|
||||||
OwnedEnv() {
|
OwnedEnv() {
|
||||||
@@ -299,8 +298,8 @@ namespace Common::Android {
|
|||||||
return s_double_constructor;
|
return s_double_constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetDoubleValueField() {
|
jmethodID GetDoubleValueMethod() {
|
||||||
return s_double_value_field;
|
return s_double_value_method;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetIntegerClass() {
|
jclass GetIntegerClass() {
|
||||||
@@ -311,8 +310,8 @@ namespace Common::Android {
|
|||||||
return s_integer_constructor;
|
return s_integer_constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetIntegerValueField() {
|
jmethodID GetIntegerValueMethod() {
|
||||||
return s_integer_value_field;
|
return s_integer_value_method;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetBooleanClass() {
|
jclass GetBooleanClass() {
|
||||||
@@ -323,8 +322,8 @@ namespace Common::Android {
|
|||||||
return s_boolean_constructor;
|
return s_boolean_constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID GetBooleanValueField() {
|
jmethodID GetBooleanValueMethod() {
|
||||||
return s_boolean_value_field;
|
return s_boolean_value_method;
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetPlayerInputClass() {
|
jclass GetPlayerInputClass() {
|
||||||
@@ -429,188 +428,6 @@ namespace Common::Android {
|
|||||||
|
|
||||||
jint InitFFmpegOnLoad(JavaVM *vm);
|
jint InitFFmpegOnLoad(JavaVM *vm);
|
||||||
|
|
||||||
jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
|
||||||
s_java_vm = vm;
|
|
||||||
InitFFmpegOnLoad(vm);
|
|
||||||
|
|
||||||
JNIEnv *env;
|
|
||||||
if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION) != JNI_OK)
|
|
||||||
return JNI_ERR;
|
|
||||||
|
|
||||||
// Initialize Java classes
|
|
||||||
const jclass native_library_class = env->FindClass("org/yuzu/yuzu_emu/NativeLibrary");
|
|
||||||
s_native_library_class = reinterpret_cast<jclass>(env->NewGlobalRef(native_library_class));
|
|
||||||
s_disk_cache_progress_class = reinterpret_cast<jclass>(env->NewGlobalRef(
|
|
||||||
env->FindClass("org/yuzu/yuzu_emu/disk_shader_cache/DiskShaderCacheProgress")));
|
|
||||||
s_load_callback_stage_class = reinterpret_cast<jclass>(env->NewGlobalRef(env->FindClass(
|
|
||||||
"org/yuzu/yuzu_emu/disk_shader_cache/DiskShaderCacheProgress$LoadCallbackStage")));
|
|
||||||
|
|
||||||
const jclass game_dir_class = env->FindClass("org/yuzu/yuzu_emu/model/GameDir");
|
|
||||||
s_game_dir_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_dir_class));
|
|
||||||
s_game_dir_constructor = env->GetMethodID(game_dir_class, "<init>",
|
|
||||||
"(Ljava/lang/String;Z)V");
|
|
||||||
env->DeleteLocalRef(game_dir_class);
|
|
||||||
|
|
||||||
// Initialize methods
|
|
||||||
s_exit_emulation_activity =
|
|
||||||
env->GetStaticMethodID(s_native_library_class, "exitEmulationActivity", "(I)V");
|
|
||||||
s_disk_cache_load_progress =
|
|
||||||
env->GetStaticMethodID(s_disk_cache_progress_class, "loadProgress", "(III)V");
|
|
||||||
s_copy_to_storage = env->GetStaticMethodID(s_native_library_class, "copyFileToStorage",
|
|
||||||
"(Ljava/lang/String;Ljava/lang/String;)Z");
|
|
||||||
s_file_exists = env->GetStaticMethodID(s_native_library_class, "exists",
|
|
||||||
"(Ljava/lang/String;)Z");
|
|
||||||
s_file_extension = env->GetStaticMethodID(s_native_library_class, "getFileExtension",
|
|
||||||
"(Ljava/lang/String;)Ljava/lang/String;");
|
|
||||||
s_on_emulation_started =
|
|
||||||
env->GetStaticMethodID(s_native_library_class, "onEmulationStarted", "()V");
|
|
||||||
s_on_emulation_stopped =
|
|
||||||
env->GetStaticMethodID(s_native_library_class, "onEmulationStopped", "(I)V");
|
|
||||||
s_on_program_changed =
|
|
||||||
env->GetStaticMethodID(s_native_library_class, "onProgramChanged", "(I)V");
|
|
||||||
|
|
||||||
const jclass game_class = env->FindClass("org/yuzu/yuzu_emu/model/Game");
|
|
||||||
s_game_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_class));
|
|
||||||
s_game_constructor = env->GetMethodID(game_class, "<init>",
|
|
||||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/"
|
|
||||||
"String;Ljava/lang/String;Ljava/lang/String;Z)V");
|
|
||||||
s_game_title_field = env->GetFieldID(game_class, "title", "Ljava/lang/String;");
|
|
||||||
s_game_path_field = env->GetFieldID(game_class, "path", "Ljava/lang/String;");
|
|
||||||
s_game_program_id_field = env->GetFieldID(game_class, "programId", "Ljava/lang/String;");
|
|
||||||
s_game_developer_field = env->GetFieldID(game_class, "developer", "Ljava/lang/String;");
|
|
||||||
s_game_version_field = env->GetFieldID(game_class, "version", "Ljava/lang/String;");
|
|
||||||
s_game_is_homebrew_field = env->GetFieldID(game_class, "isHomebrew", "Z");
|
|
||||||
env->DeleteLocalRef(game_class);
|
|
||||||
|
|
||||||
const jclass string_class = env->FindClass("java/lang/String");
|
|
||||||
s_string_class = reinterpret_cast<jclass>(env->NewGlobalRef(string_class));
|
|
||||||
env->DeleteLocalRef(string_class);
|
|
||||||
|
|
||||||
const jclass pair_class = env->FindClass("kotlin/Pair");
|
|
||||||
s_pair_class = reinterpret_cast<jclass>(env->NewGlobalRef(pair_class));
|
|
||||||
s_pair_constructor =
|
|
||||||
env->GetMethodID(pair_class, "<init>", "(Ljava/lang/Object;Ljava/lang/Object;)V");
|
|
||||||
s_pair_first_field = env->GetFieldID(pair_class, "first", "Ljava/lang/Object;");
|
|
||||||
s_pair_second_field = env->GetFieldID(pair_class, "second", "Ljava/lang/Object;");
|
|
||||||
env->DeleteLocalRef(pair_class);
|
|
||||||
|
|
||||||
const jclass overlay_control_data_class =
|
|
||||||
env->FindClass("org/yuzu/yuzu_emu/overlay/model/OverlayControlData");
|
|
||||||
s_overlay_control_data_class =
|
|
||||||
reinterpret_cast<jclass>(env->NewGlobalRef(overlay_control_data_class));
|
|
||||||
s_overlay_control_data_constructor =
|
|
||||||
env->GetMethodID(overlay_control_data_class, "<init>",
|
|
||||||
"(Ljava/lang/String;ZLkotlin/Pair;Lkotlin/Pair;Lkotlin/Pair;F)V");
|
|
||||||
s_overlay_control_data_id_field =
|
|
||||||
env->GetFieldID(overlay_control_data_class, "id", "Ljava/lang/String;");
|
|
||||||
s_overlay_control_data_enabled_field =
|
|
||||||
env->GetFieldID(overlay_control_data_class, "enabled", "Z");
|
|
||||||
s_overlay_control_data_landscape_position_field =
|
|
||||||
env->GetFieldID(overlay_control_data_class, "landscapePosition", "Lkotlin/Pair;");
|
|
||||||
s_overlay_control_data_portrait_position_field =
|
|
||||||
env->GetFieldID(overlay_control_data_class, "portraitPosition", "Lkotlin/Pair;");
|
|
||||||
s_overlay_control_data_foldable_position_field =
|
|
||||||
env->GetFieldID(overlay_control_data_class, "foldablePosition", "Lkotlin/Pair;");
|
|
||||||
s_overlay_control_data_individual_scale_field =
|
|
||||||
env->GetFieldID(overlay_control_data_class, "individualScale", "F");
|
|
||||||
env->DeleteLocalRef(overlay_control_data_class);
|
|
||||||
|
|
||||||
const jclass patch_class = env->FindClass("org/yuzu/yuzu_emu/model/Patch");
|
|
||||||
s_patch_class = reinterpret_cast<jclass>(env->NewGlobalRef(patch_class));
|
|
||||||
s_patch_constructor = env->GetMethodID(
|
|
||||||
patch_class, "<init>",
|
|
||||||
"(ZLjava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;JI)V");
|
|
||||||
s_patch_enabled_field = env->GetFieldID(patch_class, "enabled", "Z");
|
|
||||||
s_patch_name_field = env->GetFieldID(patch_class, "name", "Ljava/lang/String;");
|
|
||||||
s_patch_version_field = env->GetFieldID(patch_class, "version", "Ljava/lang/String;");
|
|
||||||
s_patch_type_field = env->GetFieldID(patch_class, "type", "I");
|
|
||||||
s_patch_program_id_field = env->GetFieldID(patch_class, "programId", "Ljava/lang/String;");
|
|
||||||
s_patch_title_id_field = env->GetFieldID(patch_class, "titleId", "Ljava/lang/String;");
|
|
||||||
env->DeleteLocalRef(patch_class);
|
|
||||||
|
|
||||||
const jclass double_class = env->FindClass("java/lang/Double");
|
|
||||||
s_double_class = reinterpret_cast<jclass>(env->NewGlobalRef(double_class));
|
|
||||||
s_double_constructor = env->GetMethodID(double_class, "<init>", "(D)V");
|
|
||||||
s_double_value_field = env->GetFieldID(double_class, "value", "D");
|
|
||||||
env->DeleteLocalRef(double_class);
|
|
||||||
|
|
||||||
const jclass int_class = env->FindClass("java/lang/Integer");
|
|
||||||
s_integer_class = reinterpret_cast<jclass>(env->NewGlobalRef(int_class));
|
|
||||||
s_integer_constructor = env->GetMethodID(int_class, "<init>", "(I)V");
|
|
||||||
s_integer_value_field = env->GetFieldID(int_class, "value", "I");
|
|
||||||
env->DeleteLocalRef(int_class);
|
|
||||||
|
|
||||||
const jclass boolean_class = env->FindClass("java/lang/Boolean");
|
|
||||||
s_boolean_class = reinterpret_cast<jclass>(env->NewGlobalRef(boolean_class));
|
|
||||||
s_boolean_constructor = env->GetMethodID(boolean_class, "<init>", "(Z)V");
|
|
||||||
s_boolean_value_field = env->GetFieldID(boolean_class, "value", "Z");
|
|
||||||
env->DeleteLocalRef(boolean_class);
|
|
||||||
|
|
||||||
const jclass player_input_class =
|
|
||||||
env->FindClass("org/yuzu/yuzu_emu/features/input/model/PlayerInput");
|
|
||||||
s_player_input_class = reinterpret_cast<jclass>(env->NewGlobalRef(player_input_class));
|
|
||||||
s_player_input_constructor = env->GetMethodID(
|
|
||||||
player_input_class, "<init>",
|
|
||||||
"(Z[Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;ZIJJJJLjava/lang/String;Z)V");
|
|
||||||
s_player_input_connected_field = env->GetFieldID(player_input_class, "connected", "Z");
|
|
||||||
s_player_input_buttons_field =
|
|
||||||
env->GetFieldID(player_input_class, "buttons", "[Ljava/lang/String;");
|
|
||||||
s_player_input_analogs_field =
|
|
||||||
env->GetFieldID(player_input_class, "analogs", "[Ljava/lang/String;");
|
|
||||||
s_player_input_motions_field =
|
|
||||||
env->GetFieldID(player_input_class, "motions", "[Ljava/lang/String;");
|
|
||||||
s_player_input_vibration_enabled_field =
|
|
||||||
env->GetFieldID(player_input_class, "vibrationEnabled", "Z");
|
|
||||||
s_player_input_vibration_strength_field =
|
|
||||||
env->GetFieldID(player_input_class, "vibrationStrength", "I");
|
|
||||||
s_player_input_body_color_left_field =
|
|
||||||
env->GetFieldID(player_input_class, "bodyColorLeft", "J");
|
|
||||||
s_player_input_body_color_right_field =
|
|
||||||
env->GetFieldID(player_input_class, "bodyColorRight", "J");
|
|
||||||
s_player_input_button_color_left_field =
|
|
||||||
env->GetFieldID(player_input_class, "buttonColorLeft", "J");
|
|
||||||
s_player_input_button_color_right_field =
|
|
||||||
env->GetFieldID(player_input_class, "buttonColorRight", "J");
|
|
||||||
s_player_input_profile_name_field =
|
|
||||||
env->GetFieldID(player_input_class, "profileName", "Ljava/lang/String;");
|
|
||||||
s_player_input_use_system_vibrator_field =
|
|
||||||
env->GetFieldID(player_input_class, "useSystemVibrator", "Z");
|
|
||||||
env->DeleteLocalRef(player_input_class);
|
|
||||||
|
|
||||||
const jclass yuzu_input_device_interface =
|
|
||||||
env->FindClass("org/yuzu/yuzu_emu/features/input/YuzuInputDevice");
|
|
||||||
s_yuzu_input_device_interface =
|
|
||||||
reinterpret_cast<jclass>(env->NewGlobalRef(yuzu_input_device_interface));
|
|
||||||
s_yuzu_input_device_get_name =
|
|
||||||
env->GetMethodID(yuzu_input_device_interface, "getName", "()Ljava/lang/String;");
|
|
||||||
s_yuzu_input_device_get_guid =
|
|
||||||
env->GetMethodID(yuzu_input_device_interface, "getGUID", "()Ljava/lang/String;");
|
|
||||||
s_yuzu_input_device_get_port = env->GetMethodID(yuzu_input_device_interface, "getPort",
|
|
||||||
"()I");
|
|
||||||
s_yuzu_input_device_get_supports_vibration =
|
|
||||||
env->GetMethodID(yuzu_input_device_interface, "getSupportsVibration", "()Z");
|
|
||||||
s_yuzu_input_device_vibrate = env->GetMethodID(yuzu_input_device_interface, "vibrate",
|
|
||||||
"(F)V");
|
|
||||||
s_yuzu_input_device_get_axes =
|
|
||||||
env->GetMethodID(yuzu_input_device_interface, "getAxes", "()[Ljava/lang/Integer;");
|
|
||||||
s_yuzu_input_device_has_keys =
|
|
||||||
env->GetMethodID(yuzu_input_device_interface, "hasKeys", "([I)[Z");
|
|
||||||
env->DeleteLocalRef(yuzu_input_device_interface);
|
|
||||||
s_add_netplay_message = env->GetStaticMethodID(s_native_library_class, "addNetPlayMessage",
|
|
||||||
"(ILjava/lang/String;)V");
|
|
||||||
s_clear_chat = env->GetStaticMethodID(s_native_library_class, "clearChat", "()V");
|
|
||||||
|
|
||||||
|
|
||||||
// Initialize Android Storage
|
|
||||||
Common::FS::Android::RegisterCallbacks(env, s_native_library_class);
|
|
||||||
|
|
||||||
// Initialize applets
|
|
||||||
Common::Android::SoftwareKeyboard::InitJNI(env);
|
|
||||||
Common::Android::WebBrowser::InitJNI(env);
|
|
||||||
|
|
||||||
return JNI_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
void JNI_OnUnload(JavaVM *vm, void *reserved) {
|
void JNI_OnUnload(JavaVM *vm, void *reserved) {
|
||||||
JNIEnv *env;
|
JNIEnv *env;
|
||||||
if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION) != JNI_OK) {
|
if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION) != JNI_OK) {
|
||||||
@@ -645,4 +462,183 @@ namespace Common::Android {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void Initialize(JavaVM* vm, JNIEnv *env) {
|
||||||
|
s_java_vm = vm;
|
||||||
|
InitFFmpegOnLoad(vm);
|
||||||
|
|
||||||
|
if (env->ExceptionCheck()) {
|
||||||
|
env->ExceptionClear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize Java classes
|
||||||
|
const jclass native_library_class = env->FindClass("org/yuzu/yuzu_emu/NativeLibrary");
|
||||||
|
s_native_library_class = reinterpret_cast<jclass>(env->NewGlobalRef(native_library_class));
|
||||||
|
s_disk_cache_progress_class = reinterpret_cast<jclass>(env->NewGlobalRef(
|
||||||
|
env->FindClass("org/yuzu/yuzu_emu/disk_shader_cache/DiskShaderCacheProgress")));
|
||||||
|
s_load_callback_stage_class = reinterpret_cast<jclass>(env->NewGlobalRef(env->FindClass(
|
||||||
|
"org/yuzu/yuzu_emu/disk_shader_cache/DiskShaderCacheProgress$LoadCallbackStage")));
|
||||||
|
|
||||||
|
const jclass game_dir_class = env->FindClass("org/yuzu/yuzu_emu/model/GameDir");
|
||||||
|
s_game_dir_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_dir_class));
|
||||||
|
s_game_dir_constructor = env->GetMethodID(game_dir_class, "<init>",
|
||||||
|
"(Ljava/lang/String;Z)V");
|
||||||
|
env->DeleteLocalRef(game_dir_class);
|
||||||
|
|
||||||
|
// Initialize methods
|
||||||
|
s_exit_emulation_activity =
|
||||||
|
env->GetStaticMethodID(s_native_library_class, "exitEmulationActivity", "(I)V");
|
||||||
|
s_disk_cache_load_progress =
|
||||||
|
env->GetStaticMethodID(s_disk_cache_progress_class, "loadProgress", "(III)V");
|
||||||
|
s_copy_to_storage = env->GetStaticMethodID(s_native_library_class, "copyFileToStorage",
|
||||||
|
"(Ljava/lang/String;Ljava/lang/String;)Z");
|
||||||
|
s_file_exists = env->GetStaticMethodID(s_native_library_class, "exists",
|
||||||
|
"(Ljava/lang/String;)Z");
|
||||||
|
s_file_extension = env->GetStaticMethodID(s_native_library_class, "getFileExtension",
|
||||||
|
"(Ljava/lang/String;)Ljava/lang/String;");
|
||||||
|
s_on_emulation_started =
|
||||||
|
env->GetStaticMethodID(s_native_library_class, "onEmulationStarted", "()V");
|
||||||
|
s_on_emulation_stopped =
|
||||||
|
env->GetStaticMethodID(s_native_library_class, "onEmulationStopped", "(I)V");
|
||||||
|
s_on_program_changed =
|
||||||
|
env->GetStaticMethodID(s_native_library_class, "onProgramChanged", "(I)V");
|
||||||
|
|
||||||
|
const jclass game_class = env->FindClass("org/yuzu/yuzu_emu/model/Game");
|
||||||
|
s_game_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_class));
|
||||||
|
s_game_constructor = env->GetMethodID(game_class, "<init>",
|
||||||
|
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/"
|
||||||
|
"String;Ljava/lang/String;Ljava/lang/String;Z)V");
|
||||||
|
s_game_title_field = env->GetFieldID(game_class, "title", "Ljava/lang/String;");
|
||||||
|
s_game_path_field = env->GetFieldID(game_class, "path", "Ljava/lang/String;");
|
||||||
|
s_game_program_id_field = env->GetFieldID(game_class, "programId", "Ljava/lang/String;");
|
||||||
|
s_game_developer_field = env->GetFieldID(game_class, "developer", "Ljava/lang/String;");
|
||||||
|
s_game_version_field = env->GetFieldID(game_class, "version", "Ljava/lang/String;");
|
||||||
|
s_game_is_homebrew_field = env->GetFieldID(game_class, "isHomebrew", "Z");
|
||||||
|
env->DeleteLocalRef(game_class);
|
||||||
|
|
||||||
|
const jclass string_class = env->FindClass("java/lang/String");
|
||||||
|
s_string_class = reinterpret_cast<jclass>(env->NewGlobalRef(string_class));
|
||||||
|
env->DeleteLocalRef(string_class);
|
||||||
|
|
||||||
|
const jclass pair_class = env->FindClass("kotlin/Pair");
|
||||||
|
s_pair_class = reinterpret_cast<jclass>(env->NewGlobalRef(pair_class));
|
||||||
|
s_pair_constructor =
|
||||||
|
env->GetMethodID(pair_class, "<init>", "(Ljava/lang/Object;Ljava/lang/Object;)V");
|
||||||
|
s_pair_first_field = env->GetFieldID(pair_class, "first", "Ljava/lang/Object;");
|
||||||
|
s_pair_second_field = env->GetFieldID(pair_class, "second", "Ljava/lang/Object;");
|
||||||
|
env->DeleteLocalRef(pair_class);
|
||||||
|
|
||||||
|
const jclass overlay_control_data_class =
|
||||||
|
env->FindClass("org/yuzu/yuzu_emu/overlay/model/OverlayControlData");
|
||||||
|
s_overlay_control_data_class =
|
||||||
|
reinterpret_cast<jclass>(env->NewGlobalRef(overlay_control_data_class));
|
||||||
|
s_overlay_control_data_constructor =
|
||||||
|
env->GetMethodID(overlay_control_data_class, "<init>",
|
||||||
|
"(Ljava/lang/String;ZLkotlin/Pair;Lkotlin/Pair;Lkotlin/Pair;F)V");
|
||||||
|
s_overlay_control_data_id_field =
|
||||||
|
env->GetFieldID(overlay_control_data_class, "id", "Ljava/lang/String;");
|
||||||
|
s_overlay_control_data_enabled_field =
|
||||||
|
env->GetFieldID(overlay_control_data_class, "enabled", "Z");
|
||||||
|
s_overlay_control_data_landscape_position_field =
|
||||||
|
env->GetFieldID(overlay_control_data_class, "landscapePosition", "Lkotlin/Pair;");
|
||||||
|
s_overlay_control_data_portrait_position_field =
|
||||||
|
env->GetFieldID(overlay_control_data_class, "portraitPosition", "Lkotlin/Pair;");
|
||||||
|
s_overlay_control_data_foldable_position_field =
|
||||||
|
env->GetFieldID(overlay_control_data_class, "foldablePosition", "Lkotlin/Pair;");
|
||||||
|
s_overlay_control_data_individual_scale_field =
|
||||||
|
env->GetFieldID(overlay_control_data_class, "individualScale", "F");
|
||||||
|
env->DeleteLocalRef(overlay_control_data_class);
|
||||||
|
|
||||||
|
const jclass patch_class = env->FindClass("org/yuzu/yuzu_emu/model/Patch");
|
||||||
|
s_patch_class = reinterpret_cast<jclass>(env->NewGlobalRef(patch_class));
|
||||||
|
s_patch_constructor = env->GetMethodID(
|
||||||
|
patch_class, "<init>",
|
||||||
|
"(ZLjava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;JI)V");
|
||||||
|
s_patch_enabled_field = env->GetFieldID(patch_class, "enabled", "Z");
|
||||||
|
s_patch_name_field = env->GetFieldID(patch_class, "name", "Ljava/lang/String;");
|
||||||
|
s_patch_version_field = env->GetFieldID(patch_class, "version", "Ljava/lang/String;");
|
||||||
|
s_patch_type_field = env->GetFieldID(patch_class, "type", "I");
|
||||||
|
s_patch_program_id_field = env->GetFieldID(patch_class, "programId", "Ljava/lang/String;");
|
||||||
|
s_patch_title_id_field = env->GetFieldID(patch_class, "titleId", "Ljava/lang/String;");
|
||||||
|
env->DeleteLocalRef(patch_class);
|
||||||
|
|
||||||
|
const jclass double_class = env->FindClass("java/lang/Double");
|
||||||
|
s_double_class = reinterpret_cast<jclass>(env->NewGlobalRef(double_class));
|
||||||
|
s_double_constructor = env->GetMethodID(double_class, "<init>", "(D)V");
|
||||||
|
s_double_value_method = env->GetMethodID(double_class, "doubleValue", "()D");
|
||||||
|
env->DeleteLocalRef(double_class);
|
||||||
|
|
||||||
|
const jclass int_class = env->FindClass("java/lang/Integer");
|
||||||
|
s_integer_class = reinterpret_cast<jclass>(env->NewGlobalRef(int_class));
|
||||||
|
s_integer_constructor = env->GetMethodID(int_class, "<init>", "(I)V");
|
||||||
|
s_integer_value_method = env->GetMethodID(int_class, "intValue", "()I");
|
||||||
|
env->DeleteLocalRef(int_class);
|
||||||
|
|
||||||
|
const jclass boolean_class = env->FindClass("java/lang/Boolean");
|
||||||
|
s_boolean_class = reinterpret_cast<jclass>(env->NewGlobalRef(boolean_class));
|
||||||
|
s_boolean_constructor = env->GetMethodID(boolean_class, "<init>", "(Z)V");
|
||||||
|
s_boolean_value_method = env->GetMethodID(boolean_class, "booleanValue", "()Z");
|
||||||
|
env->DeleteLocalRef(boolean_class);
|
||||||
|
|
||||||
|
const jclass player_input_class =
|
||||||
|
env->FindClass("org/yuzu/yuzu_emu/features/input/model/PlayerInput");
|
||||||
|
s_player_input_class = reinterpret_cast<jclass>(env->NewGlobalRef(player_input_class));
|
||||||
|
s_player_input_constructor = env->GetMethodID(
|
||||||
|
player_input_class, "<init>",
|
||||||
|
"(Z[Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;ZIJJJJLjava/lang/String;Z)V");
|
||||||
|
s_player_input_connected_field = env->GetFieldID(player_input_class, "connected", "Z");
|
||||||
|
s_player_input_buttons_field =
|
||||||
|
env->GetFieldID(player_input_class, "buttons", "[Ljava/lang/String;");
|
||||||
|
s_player_input_analogs_field =
|
||||||
|
env->GetFieldID(player_input_class, "analogs", "[Ljava/lang/String;");
|
||||||
|
s_player_input_motions_field =
|
||||||
|
env->GetFieldID(player_input_class, "motions", "[Ljava/lang/String;");
|
||||||
|
s_player_input_vibration_enabled_field =
|
||||||
|
env->GetFieldID(player_input_class, "vibrationEnabled", "Z");
|
||||||
|
s_player_input_vibration_strength_field =
|
||||||
|
env->GetFieldID(player_input_class, "vibrationStrength", "I");
|
||||||
|
s_player_input_body_color_left_field =
|
||||||
|
env->GetFieldID(player_input_class, "bodyColorLeft", "J");
|
||||||
|
s_player_input_body_color_right_field =
|
||||||
|
env->GetFieldID(player_input_class, "bodyColorRight", "J");
|
||||||
|
s_player_input_button_color_left_field =
|
||||||
|
env->GetFieldID(player_input_class, "buttonColorLeft", "J");
|
||||||
|
s_player_input_button_color_right_field =
|
||||||
|
env->GetFieldID(player_input_class, "buttonColorRight", "J");
|
||||||
|
s_player_input_profile_name_field =
|
||||||
|
env->GetFieldID(player_input_class, "profileName", "Ljava/lang/String;");
|
||||||
|
s_player_input_use_system_vibrator_field =
|
||||||
|
env->GetFieldID(player_input_class, "useSystemVibrator", "Z");
|
||||||
|
env->DeleteLocalRef(player_input_class);
|
||||||
|
|
||||||
|
const jclass yuzu_input_device_interface =
|
||||||
|
env->FindClass("org/yuzu/yuzu_emu/features/input/YuzuInputDevice");
|
||||||
|
s_yuzu_input_device_interface =
|
||||||
|
reinterpret_cast<jclass>(env->NewGlobalRef(yuzu_input_device_interface));
|
||||||
|
s_yuzu_input_device_get_name =
|
||||||
|
env->GetMethodID(yuzu_input_device_interface, "getName", "()Ljava/lang/String;");
|
||||||
|
s_yuzu_input_device_get_guid =
|
||||||
|
env->GetMethodID(yuzu_input_device_interface, "getGUID", "()Ljava/lang/String;");
|
||||||
|
s_yuzu_input_device_get_port = env->GetMethodID(yuzu_input_device_interface, "getPort",
|
||||||
|
"()I");
|
||||||
|
s_yuzu_input_device_get_supports_vibration =
|
||||||
|
env->GetMethodID(yuzu_input_device_interface, "getSupportsVibration", "()Z");
|
||||||
|
s_yuzu_input_device_vibrate = env->GetMethodID(yuzu_input_device_interface, "vibrate",
|
||||||
|
"(F)V");
|
||||||
|
s_yuzu_input_device_get_axes =
|
||||||
|
env->GetMethodID(yuzu_input_device_interface, "getAxes", "()[Ljava/lang/Integer;");
|
||||||
|
s_yuzu_input_device_has_keys =
|
||||||
|
env->GetMethodID(yuzu_input_device_interface, "hasKeys", "([I)[Z");
|
||||||
|
env->DeleteLocalRef(yuzu_input_device_interface);
|
||||||
|
s_add_netplay_message = env->GetStaticMethodID(s_native_library_class, "addNetPlayMessage",
|
||||||
|
"(ILjava/lang/String;)V");
|
||||||
|
s_clear_chat = env->GetStaticMethodID(s_native_library_class, "clearChat", "()V");
|
||||||
|
|
||||||
|
// Initialize Android Storage
|
||||||
|
Common::FS::Android::RegisterCallbacks(env, s_native_library_class);
|
||||||
|
|
||||||
|
// Initialize applets
|
||||||
|
Common::Android::SoftwareKeyboard::InitJNI(env);
|
||||||
|
Common::Android::WebBrowser::InitJNI(env);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Common::Android
|
} // namespace Common::Android
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Common::Android {
|
namespace Common::Android {
|
||||||
|
|
||||||
|
void Initialize(JavaVM* vm, JNIEnv *env);
|
||||||
JNIEnv* GetEnvForThread();
|
JNIEnv* GetEnvForThread();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,15 +81,15 @@ jfieldID GetPatchTitleIdField();
|
|||||||
|
|
||||||
jclass GetDoubleClass();
|
jclass GetDoubleClass();
|
||||||
jmethodID GetDoubleConstructor();
|
jmethodID GetDoubleConstructor();
|
||||||
jfieldID GetDoubleValueField();
|
jmethodID GetDoubleValueMethod();
|
||||||
|
|
||||||
jclass GetIntegerClass();
|
jclass GetIntegerClass();
|
||||||
jmethodID GetIntegerConstructor();
|
jmethodID GetIntegerConstructor();
|
||||||
jfieldID GetIntegerValueField();
|
jmethodID GetIntegerValueMethod();
|
||||||
|
|
||||||
jclass GetBooleanClass();
|
jclass GetBooleanClass();
|
||||||
jmethodID GetBooleanConstructor();
|
jmethodID GetBooleanConstructor();
|
||||||
jfieldID GetBooleanValueField();
|
jmethodID GetBooleanValueMethod();
|
||||||
|
|
||||||
jclass GetPlayerInputClass();
|
jclass GetPlayerInputClass();
|
||||||
jmethodID GetPlayerInputConstructor();
|
jmethodID GetPlayerInputConstructor();
|
||||||
|
|||||||
@@ -92,14 +92,14 @@ struct EnumMetadata {
|
|||||||
// AudioEngine must be specified discretely due to having existing but slightly different
|
// AudioEngine must be specified discretely due to having existing but slightly different
|
||||||
// canonicalizations
|
// canonicalizations
|
||||||
// TODO (lat9nq): Remove explicit definition of AudioEngine/sink_id
|
// TODO (lat9nq): Remove explicit definition of AudioEngine/sink_id
|
||||||
enum class AudioEngine : u32 { Auto, Cubeb, Sdl3, Null, Oboe, };
|
enum class AudioEngine : u32 { Auto, Cubeb, Sdl3, Null, };
|
||||||
template<>
|
template<>
|
||||||
inline std::vector<std::pair<std::string_view, AudioEngine>> EnumMetadata<AudioEngine>::Canonicalizations() {
|
inline std::vector<std::pair<std::string_view, AudioEngine>> EnumMetadata<AudioEngine>::Canonicalizations() {
|
||||||
return {
|
return {
|
||||||
{"auto", AudioEngine::Auto},
|
{"auto", AudioEngine::Auto},
|
||||||
{"cubeb", AudioEngine::Cubeb},
|
{"cubeb", AudioEngine::Cubeb},
|
||||||
{"sdl3", AudioEngine::Sdl3},
|
{"sdl3", AudioEngine::Sdl3},
|
||||||
{"null", AudioEngine::Null}, {"oboe", AudioEngine::Oboe},
|
{"null", AudioEngine::Null},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// @brief This is just a sufficiently large number that is more than the number of other enums declared here
|
/// @brief This is just a sufficiently large number that is more than the number of other enums declared here
|
||||||
@@ -113,7 +113,7 @@ inline AudioEngine EnumMetadata<AudioEngine>::GetFirst() {
|
|||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
inline AudioEngine EnumMetadata<AudioEngine>::GetLast() {
|
inline AudioEngine EnumMetadata<AudioEngine>::GetLast() {
|
||||||
return AudioEngine::Oboe;
|
return AudioEngine::Null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ENUM(AudioMode, Mono, Stereo, Surround);
|
ENUM(AudioMode, Mono, Stereo, Surround);
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ std::set<s32> Android::GetDeviceAxes(JNIEnv* env, jobject& j_device) const {
|
|||||||
std::set<s32> axes;
|
std::set<s32> axes;
|
||||||
for (int i = 0; i < env->GetArrayLength(j_axes); ++i) {
|
for (int i = 0; i < env->GetArrayLength(j_axes); ++i) {
|
||||||
jobject axis = env->GetObjectArrayElement(j_axes, i);
|
jobject axis = env->GetObjectArrayElement(j_axes, i);
|
||||||
axes.insert(env->GetIntField(axis, Common::Android::GetIntegerValueField()));
|
axes.insert(env->CallIntMethod(axis, Common::Android::GetIntegerValueMethod()));
|
||||||
}
|
}
|
||||||
return axes;
|
return axes;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ namespace VideoCommon {
|
|||||||
|
|
||||||
enum class BufferFlagBits {
|
enum class BufferFlagBits {
|
||||||
Picked = 1 << 0,
|
Picked = 1 << 0,
|
||||||
CachedWrites = 1 << 1,
|
|
||||||
PreemtiveDownload = 1 << 2,
|
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_FLAG_OPERATORS(BufferFlagBits)
|
DECLARE_ENUM_FLAG_OPERATORS(BufferFlagBits)
|
||||||
|
|
||||||
@@ -58,15 +56,6 @@ public:
|
|||||||
flags |= BufferFlagBits::Picked;
|
flags |= BufferFlagBits::Picked;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarkPreemtiveDownload() noexcept {
|
|
||||||
flags |= BufferFlagBits::PreemtiveDownload;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Unmark buffer as picked
|
|
||||||
void Unpick() noexcept {
|
|
||||||
flags &= ~BufferFlagBits::Picked;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Increases the likeliness of this being a stream buffer
|
/// Increases the likeliness of this being a stream buffer
|
||||||
void IncreaseStreamScore(int score) noexcept {
|
void IncreaseStreamScore(int score) noexcept {
|
||||||
stream_score += score;
|
stream_score += score;
|
||||||
@@ -87,15 +76,6 @@ public:
|
|||||||
return True(flags & BufferFlagBits::Picked);
|
return True(flags & BufferFlagBits::Picked);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true when the buffer has pending cached writes
|
|
||||||
[[nodiscard]] bool HasCachedWrites() const noexcept {
|
|
||||||
return True(flags & BufferFlagBits::CachedWrites);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsPreemtiveDownload() const noexcept {
|
|
||||||
return True(flags & BufferFlagBits::PreemtiveDownload);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the base CPU address of the buffer
|
/// Returns the base CPU address of the buffer
|
||||||
[[nodiscard]] VAddr CpuAddr() const noexcept {
|
[[nodiscard]] VAddr CpuAddr() const noexcept {
|
||||||
return cpu_addr;
|
return cpu_addr;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
||||||
@@ -121,25 +122,6 @@ void BufferCache<P>::WriteMemory(DAddr device_addr, u64 size) {
|
|||||||
memory_tracker.MarkRegionAsCpuModified(device_addr, size);
|
memory_tracker.MarkRegionAsCpuModified(device_addr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
|
||||||
void BufferCache<P>::CachedWriteMemory(DAddr device_addr, u64 size) {
|
|
||||||
const bool is_dirty = IsRegionRegistered(device_addr, size);
|
|
||||||
if (!is_dirty) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DAddr aligned_start = Common::AlignDown(device_addr, DEVICE_PAGESIZE);
|
|
||||||
DAddr aligned_end = Common::AlignUp(device_addr + size, DEVICE_PAGESIZE);
|
|
||||||
if (!IsRegionGpuModified(aligned_start, aligned_end - aligned_start)) {
|
|
||||||
WriteMemory(device_addr, size);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp_buffer.resize_destructive(size);
|
|
||||||
device_memory.ReadBlockUnsafe(device_addr, tmp_buffer.data(), size);
|
|
||||||
|
|
||||||
InlineMemoryImplementation(device_addr, size, tmp_buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
bool BufferCache<P>::OnCPUWrite(DAddr device_addr, u64 size) {
|
bool BufferCache<P>::OnCPUWrite(DAddr device_addr, u64 size) {
|
||||||
const bool is_dirty = IsRegionRegistered(device_addr, size);
|
const bool is_dirty = IsRegionRegistered(device_addr, size);
|
||||||
@@ -422,7 +404,7 @@ void BufferCache<P>::UnbindGraphicsStorageBuffers(size_t stage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
bool BufferCache<P>::BindGraphicsStorageBuffer(size_t stage, size_t ssbo_index, u32 cbuf_index,
|
void BufferCache<P>::BindGraphicsStorageBuffer(size_t stage, size_t ssbo_index, u32 cbuf_index,
|
||||||
u32 cbuf_offset, bool is_written) {
|
u32 cbuf_offset, bool is_written) {
|
||||||
const bool already_enabled =
|
const bool already_enabled =
|
||||||
((channel_state->enabled_storage_buffers[stage] >> ssbo_index) & 1U) != 0;
|
((channel_state->enabled_storage_buffers[stage] >> ssbo_index) & 1U) != 0;
|
||||||
@@ -433,7 +415,7 @@ bool BufferCache<P>::BindGraphicsStorageBuffer(size_t stage, size_t ssbo_index,
|
|||||||
LOG_WARNING(HW_GPU,
|
LOG_WARNING(HW_GPU,
|
||||||
"Skipping graphics storage buffer {} due to driver limit {}",
|
"Skipping graphics storage buffer {} due to driver limit {}",
|
||||||
ssbo_index, max_bindings);
|
ssbo_index, max_bindings);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -449,7 +431,6 @@ bool BufferCache<P>::BindGraphicsStorageBuffer(size_t stage, size_t ssbo_index,
|
|||||||
const GPUVAddr ssbo_addr = cbufs.const_buffers[cbuf_index].address + cbuf_offset;
|
const GPUVAddr ssbo_addr = cbufs.const_buffers[cbuf_index].address + cbuf_offset;
|
||||||
channel_state->storage_buffers[stage][ssbo_index] =
|
channel_state->storage_buffers[stage][ssbo_index] =
|
||||||
StorageBufferBinding(ssbo_addr, cbuf_index, is_written);
|
StorageBufferBinding(ssbo_addr, cbuf_index, is_written);
|
||||||
return (channel_state->storage_buffers[stage][ssbo_index].buffer_id != NULL_BUFFER_ID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
@@ -762,16 +743,6 @@ void BufferCache<P>::BindHostIndexBuffer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
|
||||||
void BufferCache<P>::BindHostVertexBuffer(u32 index, Buffer& buffer, u32 offset, u32 size,
|
|
||||||
u32 stride) {
|
|
||||||
if constexpr (IS_OPENGL) {
|
|
||||||
runtime.BindVertexBuffer(index, buffer, offset, size, stride);
|
|
||||||
} else {
|
|
||||||
runtime.BindVertexBuffer(index, buffer.Handle(), offset, size, stride);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
Binding& BufferCache<P>::VertexBufferSlot(u32 index) {
|
Binding& BufferCache<P>::VertexBufferSlot(u32 index) {
|
||||||
ASSERT(index < NUM_VERTEX_BUFFERS);
|
ASSERT(index < NUM_VERTEX_BUFFERS);
|
||||||
@@ -1197,7 +1168,7 @@ void BufferCache<P>::DoUpdateGraphicsBuffers(bool is_indexed) {
|
|||||||
if (is_indexed) {
|
if (is_indexed) {
|
||||||
UpdateIndexBuffer();
|
UpdateIndexBuffer();
|
||||||
}
|
}
|
||||||
UpdateVertexBuffers();
|
UpdateVertexBuffers(is_indexed);
|
||||||
UpdateTransformFeedbackBuffers();
|
UpdateTransformFeedbackBuffers();
|
||||||
for (size_t stage = 0; stage < NUM_STAGES; ++stage) {
|
for (size_t stage = 0; stage < NUM_STAGES; ++stage) {
|
||||||
UpdateUniformBuffers(stage);
|
UpdateUniformBuffers(stage);
|
||||||
@@ -1251,9 +1222,14 @@ void BufferCache<P>::UpdateIndexBuffer() {
|
|||||||
const GPUVAddr gpu_addr_begin = index_buffer_ref.StartAddress();
|
const GPUVAddr gpu_addr_begin = index_buffer_ref.StartAddress();
|
||||||
const GPUVAddr gpu_addr_end = index_buffer_ref.EndAddress();
|
const GPUVAddr gpu_addr_end = index_buffer_ref.EndAddress();
|
||||||
const std::optional<DAddr> device_addr = gpu_memory->GpuToCpuAddress(gpu_addr_begin);
|
const std::optional<DAddr> device_addr = gpu_memory->GpuToCpuAddress(gpu_addr_begin);
|
||||||
const u32 address_size = static_cast<u32>(gpu_addr_end - gpu_addr_begin);
|
u64 address_size = 0;
|
||||||
const u32 draw_size = (index_buffer_ref.count + index_buffer_ref.first) * u32(index_buffer_ref.FormatSizeInBytes());
|
if (gpu_addr_end > gpu_addr_begin) {
|
||||||
const u32 size = (std::min)(address_size, draw_size);
|
address_size = (std::min)(gpu_addr_end - gpu_addr_begin,
|
||||||
|
u64{(std::numeric_limits<u32>::max)()});
|
||||||
|
}
|
||||||
|
const u64 draw_size = (u64{index_buffer_ref.count} + u64{index_buffer_ref.first}) *
|
||||||
|
u64{index_buffer_ref.FormatSizeInBytes()};
|
||||||
|
const u32 size = static_cast<u32>((std::min)(address_size, draw_size));
|
||||||
if (size == 0 || !device_addr) {
|
if (size == 0 || !device_addr) {
|
||||||
channel_state->index_buffer = NULL_BINDING;
|
channel_state->index_buffer = NULL_BINDING;
|
||||||
return;
|
return;
|
||||||
@@ -1266,20 +1242,142 @@ void BufferCache<P>::UpdateIndexBuffer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
void BufferCache<P>::UpdateVertexBuffers() {
|
u64 BufferCache<P>::DrawMaxIndex() {
|
||||||
|
if (max_index_scanned) {
|
||||||
|
return cached_max_index;
|
||||||
|
}
|
||||||
|
max_index_scanned = true;
|
||||||
|
cached_max_index = 0;
|
||||||
|
const auto& index_buffer_ref = maxwell3d->draw_manager.draw_state.index_buffer;
|
||||||
|
const u32 count = index_buffer_ref.count;
|
||||||
|
if (count == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
index_scan_buffer.resize_destructive(count);
|
||||||
|
gpu_memory->ReadBlockUnsafe(index_buffer_ref.IndexStart(), index_scan_buffer.data(),
|
||||||
|
size_t{count} * sizeof(u32));
|
||||||
|
u32 restart_index = (std::numeric_limits<u32>::max)();
|
||||||
|
if (maxwell3d->regs.primitive_restart.enabled != 0) {
|
||||||
|
restart_index = maxwell3d->regs.primitive_restart.index;
|
||||||
|
}
|
||||||
|
u32 max_index = 0;
|
||||||
|
for (u32 i = 0; i < count; ++i) {
|
||||||
|
const u32 value = index_scan_buffer[i];
|
||||||
|
if (value == restart_index) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
max_index = (std::max)(max_index, value);
|
||||||
|
}
|
||||||
|
cached_max_index = max_index;
|
||||||
|
return cached_max_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class P>
|
||||||
|
u64 BufferCache<P>::StreamAttributeExtent(u32 index) {
|
||||||
|
using VertexAttribute = typename Maxwell::VertexAttribute;
|
||||||
|
if (stream_extents_valid) {
|
||||||
|
return stream_extents[index];
|
||||||
|
}
|
||||||
|
stream_extents_valid = true;
|
||||||
|
stream_extents.fill(0);
|
||||||
|
for (size_t i = 0; i < Maxwell::NumVertexAttributes; ++i) {
|
||||||
|
const auto& attribute = maxwell3d->regs.vertex_attrib_format[i];
|
||||||
|
if (attribute.constant != 0 || attribute.size == VertexAttribute::Size::Invalid) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const u32 buffer = attribute.buffer.Value();
|
||||||
|
if (buffer >= NUM_VERTEX_BUFFERS) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const u64 end = static_cast<u64>(attribute.offset.Value()) +
|
||||||
|
static_cast<u64>(attribute.SizeInBytes());
|
||||||
|
stream_extents[buffer] = (std::max)(stream_extents[buffer], end);
|
||||||
|
}
|
||||||
|
return stream_extents[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class P>
|
||||||
|
u64 BufferCache<P>::DrawVertexBound(u32 index, bool is_indexed) {
|
||||||
|
const auto& array = maxwell3d->regs.vertex_streams[index];
|
||||||
|
if (array.enable == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
const u64 extent = StreamAttributeExtent(index);
|
||||||
|
if (extent == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
const u64 stride = static_cast<u64>(array.stride);
|
||||||
|
if (stride == 0) {
|
||||||
|
return extent;
|
||||||
|
}
|
||||||
|
const auto& draw_state = maxwell3d->draw_manager.draw_state;
|
||||||
|
u64 elements = 0;
|
||||||
|
if (maxwell3d->regs.vertex_stream_instances.IsInstancingEnabled(index)) {
|
||||||
|
if (draw_instance_count == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
const u64 base_instance = static_cast<u64>(draw_state.base_instance);
|
||||||
|
elements = base_instance + 1;
|
||||||
|
if (array.frequency != 0) {
|
||||||
|
elements = (base_instance + static_cast<u64>(draw_instance_count) - 1) /
|
||||||
|
static_cast<u64>(array.frequency) +
|
||||||
|
1;
|
||||||
|
}
|
||||||
|
} else if (!is_indexed) {
|
||||||
|
elements = static_cast<u64>(draw_state.vertex_buffer.first) +
|
||||||
|
static_cast<u64>(draw_state.vertex_buffer.count);
|
||||||
|
} else {
|
||||||
|
const auto format = draw_state.index_buffer.format;
|
||||||
|
u64 max_index = 0xFF;
|
||||||
|
if (format == Maxwell::IndexFormat::UnsignedShort) {
|
||||||
|
max_index = 0xFFFF;
|
||||||
|
} else if (format != Maxwell::IndexFormat::UnsignedByte) {
|
||||||
|
const auto& limit = maxwell3d->regs.vertex_stream_limits[index];
|
||||||
|
const GPUVAddr gpu_addr_begin = array.Address();
|
||||||
|
const GPUVAddr gpu_addr_end = limit.Address() + 1;
|
||||||
|
if (gpu_addr_end <= gpu_addr_begin) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
const bool walks = gpu_addr_end - gpu_addr_begin >= IMPLAUSIBLE_VERTEX_SIZE ||
|
||||||
|
!gpu_memory->IsWithinGPUAddressRange(gpu_addr_end);
|
||||||
|
if (!walks) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
max_index = DrawMaxIndex();
|
||||||
|
}
|
||||||
|
elements = static_cast<u64>(draw_state.base_index) + max_index + 1;
|
||||||
|
}
|
||||||
|
if (elements == 0) {
|
||||||
|
return extent;
|
||||||
|
}
|
||||||
|
return (elements - 1) * stride + extent;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class P>
|
||||||
|
void BufferCache<P>::UpdateVertexBuffers(bool is_indexed) {
|
||||||
auto& flags = maxwell3d->dirty.flags;
|
auto& flags = maxwell3d->dirty.flags;
|
||||||
|
max_index_scanned = false;
|
||||||
|
stream_extents_valid = false;
|
||||||
|
for (u32 index = 0; index < NUM_VERTEX_BUFFERS; ++index) {
|
||||||
|
const u64 bound = DrawVertexBound(index, is_indexed);
|
||||||
|
if (bound <= last_draw_bounds[index]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
flags[Dirty::VertexBuffer0 + index] = true;
|
||||||
|
flags[Dirty::VertexBuffers] = true;
|
||||||
|
}
|
||||||
if (!maxwell3d->dirty.flags[Dirty::VertexBuffers]) {
|
if (!maxwell3d->dirty.flags[Dirty::VertexBuffers]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
flags[Dirty::VertexBuffers] = false;
|
flags[Dirty::VertexBuffers] = false;
|
||||||
|
|
||||||
for (u32 index = 0; index < NUM_VERTEX_BUFFERS; ++index) {
|
for (u32 index = 0; index < NUM_VERTEX_BUFFERS; ++index) {
|
||||||
UpdateVertexBuffer(index);
|
UpdateVertexBuffer(index, is_indexed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
void BufferCache<P>::UpdateVertexBuffer(u32 index) {
|
void BufferCache<P>::UpdateVertexBuffer(u32 index, bool is_indexed) {
|
||||||
if (!maxwell3d->dirty.flags[Dirty::VertexBuffer0 + index]) {
|
if (!maxwell3d->dirty.flags[Dirty::VertexBuffer0 + index]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1288,15 +1386,31 @@ void BufferCache<P>::UpdateVertexBuffer(u32 index) {
|
|||||||
const GPUVAddr gpu_addr_begin = array.Address();
|
const GPUVAddr gpu_addr_begin = array.Address();
|
||||||
const GPUVAddr gpu_addr_end = limit.Address() + 1;
|
const GPUVAddr gpu_addr_end = limit.Address() + 1;
|
||||||
const std::optional<DAddr> device_addr = gpu_memory->GpuToCpuAddress(gpu_addr_begin);
|
const std::optional<DAddr> device_addr = gpu_memory->GpuToCpuAddress(gpu_addr_begin);
|
||||||
const u32 address_size = static_cast<u32>(gpu_addr_end - gpu_addr_begin);
|
if (array.enable == 0 || !device_addr || gpu_addr_end <= gpu_addr_begin) {
|
||||||
u32 size = address_size; // TODO: Analyze stride and number of vertices
|
|
||||||
if (array.enable == 0 || size == 0 || !device_addr) {
|
|
||||||
channel_state->vertex_buffers[index] = NULL_BINDING;
|
channel_state->vertex_buffers[index] = NULL_BINDING;
|
||||||
UpdateVertexBufferSlot(index, NULL_BINDING);
|
UpdateVertexBufferSlot(index, NULL_BINDING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!gpu_memory->IsWithinGPUAddressRange(gpu_addr_end) || size >= 64_MiB) {
|
// TODO: Analyze stride and number of vertices
|
||||||
size = static_cast<u32>(gpu_memory->MaxContinuousRange(gpu_addr_begin, size));
|
constexpr u64 implausible_size = IMPLAUSIBLE_VERTEX_SIZE;
|
||||||
|
u64 address_size = gpu_addr_end - gpu_addr_begin;
|
||||||
|
if (address_size > u64{(std::numeric_limits<u32>::max)()}) {
|
||||||
|
address_size = implausible_size;
|
||||||
|
}
|
||||||
|
const u64 draw_bound = DrawVertexBound(index, is_indexed);
|
||||||
|
last_draw_bounds[index] = (std::numeric_limits<u64>::max)();
|
||||||
|
if (draw_bound != 0) {
|
||||||
|
last_draw_bounds[index] = draw_bound;
|
||||||
|
address_size = (std::min)(address_size, draw_bound);
|
||||||
|
}
|
||||||
|
if (!gpu_memory->IsWithinGPUAddressRange(gpu_addr_end) || address_size >= implausible_size) {
|
||||||
|
address_size = gpu_memory->MaxContinuousRange(gpu_addr_begin, address_size);
|
||||||
|
}
|
||||||
|
const u32 size = static_cast<u32>(address_size);
|
||||||
|
if (size == 0) {
|
||||||
|
channel_state->vertex_buffers[index] = NULL_BINDING;
|
||||||
|
UpdateVertexBufferSlot(index, NULL_BINDING);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const BufferId buffer_id = FindBuffer(*device_addr, size);
|
const BufferId buffer_id = FindBuffer(*device_addr, size);
|
||||||
const Binding binding{
|
const Binding binding{
|
||||||
@@ -1578,9 +1692,10 @@ template <class P>
|
|||||||
BufferId BufferCache<P>::CreateBuffer(DAddr device_addr, u32 wanted_size) {
|
BufferId BufferCache<P>::CreateBuffer(DAddr device_addr, u32 wanted_size) {
|
||||||
DAddr device_addr_end = Common::AlignUp(device_addr + wanted_size, CACHING_PAGESIZE);
|
DAddr device_addr_end = Common::AlignUp(device_addr + wanted_size, CACHING_PAGESIZE);
|
||||||
device_addr = Common::AlignDown(device_addr, CACHING_PAGESIZE);
|
device_addr = Common::AlignDown(device_addr, CACHING_PAGESIZE);
|
||||||
wanted_size = static_cast<u32>(device_addr_end - device_addr);
|
constexpr u64 max_buffer_size = u64{(std::numeric_limits<u32>::max)()};
|
||||||
|
wanted_size = static_cast<u32>((std::min)(device_addr_end - device_addr, max_buffer_size));
|
||||||
const OverlapResult overlap = ResolveOverlaps(device_addr, wanted_size);
|
const OverlapResult overlap = ResolveOverlaps(device_addr, wanted_size);
|
||||||
const u32 size = static_cast<u32>(overlap.end - overlap.begin);
|
const u32 size = static_cast<u32>((std::min)(overlap.end - overlap.begin, max_buffer_size));
|
||||||
const BufferId new_buffer_id = slot_buffers.insert(runtime, overlap.begin, size);
|
const BufferId new_buffer_id = slot_buffers.insert(runtime, overlap.begin, size);
|
||||||
auto& new_buffer = slot_buffers[new_buffer_id];
|
auto& new_buffer = slot_buffers[new_buffer_id];
|
||||||
const size_t size_bytes = new_buffer.SizeBytes();
|
const size_t size_bytes = new_buffer.SizeBytes();
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ constexpr u32 NUM_VERTEX_BUFFERS = 16;
|
|||||||
#else
|
#else
|
||||||
constexpr u32 NUM_VERTEX_BUFFERS = 32;
|
constexpr u32 NUM_VERTEX_BUFFERS = 32;
|
||||||
#endif
|
#endif
|
||||||
|
constexpr u64 IMPLAUSIBLE_VERTEX_SIZE = 64_MiB;
|
||||||
constexpr u32 NUM_TRANSFORM_FEEDBACK_BUFFERS = 4;
|
constexpr u32 NUM_TRANSFORM_FEEDBACK_BUFFERS = 4;
|
||||||
constexpr u32 NUM_GRAPHICS_UNIFORM_BUFFERS = 18;
|
constexpr u32 NUM_GRAPHICS_UNIFORM_BUFFERS = 18;
|
||||||
constexpr u32 NUM_COMPUTE_UNIFORM_BUFFERS = 8;
|
constexpr u32 NUM_COMPUTE_UNIFORM_BUFFERS = 8;
|
||||||
@@ -217,8 +218,6 @@ public:
|
|||||||
|
|
||||||
void WriteMemory(DAddr device_addr, u64 size);
|
void WriteMemory(DAddr device_addr, u64 size);
|
||||||
|
|
||||||
void CachedWriteMemory(DAddr device_addr, u64 size);
|
|
||||||
|
|
||||||
bool OnCPUWrite(DAddr device_addr, u64 size);
|
bool OnCPUWrite(DAddr device_addr, u64 size);
|
||||||
|
|
||||||
void DownloadMemory(DAddr device_addr, u64 size);
|
void DownloadMemory(DAddr device_addr, u64 size);
|
||||||
@@ -248,7 +247,7 @@ public:
|
|||||||
|
|
||||||
void UnbindGraphicsStorageBuffers(size_t stage);
|
void UnbindGraphicsStorageBuffers(size_t stage);
|
||||||
|
|
||||||
bool BindGraphicsStorageBuffer(size_t stage, size_t ssbo_index, u32 cbuf_index, u32 cbuf_offset,
|
void BindGraphicsStorageBuffer(size_t stage, size_t ssbo_index, u32 cbuf_index, u32 cbuf_offset,
|
||||||
bool is_written);
|
bool is_written);
|
||||||
|
|
||||||
void UnbindGraphicsTextureBuffers(size_t stage);
|
void UnbindGraphicsTextureBuffers(size_t stage);
|
||||||
@@ -309,6 +308,10 @@ public:
|
|||||||
current_draw_indirect = current_draw_indirect_;
|
current_draw_indirect = current_draw_indirect_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetDrawInstanceCount(u32 draw_instance_count_) {
|
||||||
|
draw_instance_count = draw_instance_count_;
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] std::pair<Buffer*, u32> GetDrawIndirectCount();
|
[[nodiscard]] std::pair<Buffer*, u32> GetDrawIndirectCount();
|
||||||
|
|
||||||
[[nodiscard]] std::pair<Buffer*, u32> GetDrawIndirectBuffer();
|
[[nodiscard]] std::pair<Buffer*, u32> GetDrawIndirectBuffer();
|
||||||
@@ -376,8 +379,6 @@ private:
|
|||||||
|
|
||||||
void BindHostTransformFeedbackBuffers();
|
void BindHostTransformFeedbackBuffers();
|
||||||
|
|
||||||
void BindHostVertexBuffer(u32 index, Buffer& buffer, u32 offset, u32 size, u32 stride);
|
|
||||||
|
|
||||||
void BindHostComputeUniformBuffers();
|
void BindHostComputeUniformBuffers();
|
||||||
|
|
||||||
void BindHostComputeStorageBuffers();
|
void BindHostComputeStorageBuffers();
|
||||||
@@ -390,9 +391,15 @@ private:
|
|||||||
|
|
||||||
void UpdateIndexBuffer();
|
void UpdateIndexBuffer();
|
||||||
|
|
||||||
void UpdateVertexBuffers();
|
void UpdateVertexBuffers(bool is_indexed);
|
||||||
|
|
||||||
void UpdateVertexBuffer(u32 index);
|
void UpdateVertexBuffer(u32 index, bool is_indexed);
|
||||||
|
|
||||||
|
[[nodiscard]] u64 DrawVertexBound(u32 index, bool is_indexed);
|
||||||
|
|
||||||
|
[[nodiscard]] u64 DrawMaxIndex();
|
||||||
|
|
||||||
|
[[nodiscard]] u64 StreamAttributeExtent(u32 index);
|
||||||
|
|
||||||
void UpdateDrawIndirect();
|
void UpdateDrawIndirect();
|
||||||
|
|
||||||
@@ -484,6 +491,14 @@ private:
|
|||||||
|
|
||||||
const Tegra::Engines::Maxwell3D::DrawManager::IndirectParams* current_draw_indirect{};
|
const Tegra::Engines::Maxwell3D::DrawManager::IndirectParams* current_draw_indirect{};
|
||||||
|
|
||||||
|
u32 draw_instance_count = 0;
|
||||||
|
std::array<u64, NUM_VERTEX_BUFFERS> last_draw_bounds{};
|
||||||
|
Common::ScratchBuffer<u32> index_scan_buffer;
|
||||||
|
u64 cached_max_index = 0;
|
||||||
|
bool max_index_scanned = false;
|
||||||
|
std::array<u64, NUM_VERTEX_BUFFERS> stream_extents{};
|
||||||
|
bool stream_extents_valid = false;
|
||||||
|
|
||||||
u32 last_index_count = 0;
|
u32 last_index_count = 0;
|
||||||
|
|
||||||
u32 enabled_vertex_buffers_mask = 0;
|
u32 enabled_vertex_buffers_mask = 0;
|
||||||
|
|||||||
@@ -206,6 +206,40 @@ foreach(VARIANT IN ITEMS ${SHADER_TYPE_VARIANTS})
|
|||||||
set(SHADER_HEADERS ${SHADER_HEADERS} ${VARIANT_HEADER_FILE})
|
set(SHADER_HEADERS ${SHADER_HEADERS} ${VARIANT_HEADER_FILE})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
set(SHADER_DEFINE_VARIANTS
|
||||||
|
"block_linear_unswizzle_2d.comp|nonarrow|HAS_EXTENDED_TYPES=0"
|
||||||
|
"pitch_unswizzle.comp|nonarrow|HAS_EXTENDED_TYPES=0"
|
||||||
|
"block_linear_unswizzle_3d.comp|nonarrow|HAS_EXTENDED_TYPES=0"
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach(VARIANT IN ITEMS ${SHADER_DEFINE_VARIANTS})
|
||||||
|
string(REPLACE "|" ";" VARIANT_PARTS ${VARIANT})
|
||||||
|
list(GET VARIANT_PARTS 0 VARIANT_FILENAME)
|
||||||
|
list(GET VARIANT_PARTS 1 VARIANT_SUFFIX)
|
||||||
|
list(GET VARIANT_PARTS 2 VARIANT_DEFINE)
|
||||||
|
|
||||||
|
set(VARIANT_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/${VARIANT_FILENAME})
|
||||||
|
get_filename_component(VARIANT_STEM ${VARIANT_FILENAME} NAME_WE)
|
||||||
|
get_filename_component(VARIANT_EXT ${VARIANT_FILENAME} EXT)
|
||||||
|
string(REPLACE "." "" VARIANT_EXT ${VARIANT_EXT})
|
||||||
|
set(VARIANT_NAME ${VARIANT_STEM}_${VARIANT_SUFFIX}_${VARIANT_EXT})
|
||||||
|
|
||||||
|
string(TOUPPER ${VARIANT_NAME}_SPV VARIANT_VARIABLE_NAME)
|
||||||
|
set(VARIANT_HEADER_FILE ${SHADER_DIR}/${VARIANT_NAME}_spv.h)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT
|
||||||
|
${VARIANT_HEADER_FILE}
|
||||||
|
COMMAND
|
||||||
|
${GLSLANGVALIDATOR} -V ${QUIET_FLAG} -I"${FIDELITYFX_INCLUDE_DIR}" ${GLSL_FLAGS}
|
||||||
|
-D${VARIANT_DEFINE}
|
||||||
|
--variable-name ${VARIANT_VARIABLE_NAME} -o ${VARIANT_HEADER_FILE} ${VARIANT_SOURCE}
|
||||||
|
--target-env ${SPIR_V_VERSION}
|
||||||
|
MAIN_DEPENDENCY
|
||||||
|
${VARIANT_SOURCE}
|
||||||
|
)
|
||||||
|
set(SHADER_HEADERS ${SHADER_HEADERS} ${VARIANT_HEADER_FILE})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
foreach(FILEPATH IN ITEMS ${FIDELITYFX_FILES})
|
foreach(FILEPATH IN ITEMS ${FIDELITYFX_FILES})
|
||||||
get_filename_component(FILENAME ${FILEPATH} NAME)
|
get_filename_component(FILENAME ${FILEPATH} NAME)
|
||||||
string(REPLACE "." "_" HEADER_NAME ${FILENAME})
|
string(REPLACE "." "_" HEADER_NAME ${FILENAME})
|
||||||
|
|||||||
@@ -5,9 +5,13 @@
|
|||||||
|
|
||||||
#ifdef VULKAN
|
#ifdef VULKAN
|
||||||
|
|
||||||
|
#ifndef HAS_EXTENDED_TYPES
|
||||||
|
#define HAS_EXTENDED_TYPES 1
|
||||||
|
#endif
|
||||||
|
#if HAS_EXTENDED_TYPES
|
||||||
#extension GL_EXT_shader_16bit_storage : require
|
#extension GL_EXT_shader_16bit_storage : require
|
||||||
#extension GL_EXT_shader_8bit_storage : require
|
#extension GL_EXT_shader_8bit_storage : require
|
||||||
#define HAS_EXTENDED_TYPES 1
|
#endif
|
||||||
#define BEGIN_PUSH_CONSTANTS layout(push_constant) uniform PushConstants {
|
#define BEGIN_PUSH_CONSTANTS layout(push_constant) uniform PushConstants {
|
||||||
#define END_PUSH_CONSTANTS };
|
#define END_PUSH_CONSTANTS };
|
||||||
#define UNIFORM(n)
|
#define UNIFORM(n)
|
||||||
|
|||||||
@@ -5,9 +5,13 @@
|
|||||||
|
|
||||||
#ifdef VULKAN
|
#ifdef VULKAN
|
||||||
|
|
||||||
|
#ifndef HAS_EXTENDED_TYPES
|
||||||
|
#define HAS_EXTENDED_TYPES 1
|
||||||
|
#endif
|
||||||
|
#if HAS_EXTENDED_TYPES
|
||||||
#extension GL_EXT_shader_16bit_storage : require
|
#extension GL_EXT_shader_16bit_storage : require
|
||||||
#extension GL_EXT_shader_8bit_storage : require
|
#extension GL_EXT_shader_8bit_storage : require
|
||||||
#define HAS_EXTENDED_TYPES 1
|
#endif
|
||||||
#define BEGIN_PUSH_CONSTANTS layout(push_constant) uniform PushConstants {
|
#define BEGIN_PUSH_CONSTANTS layout(push_constant) uniform PushConstants {
|
||||||
#define END_PUSH_CONSTANTS };
|
#define END_PUSH_CONSTANTS };
|
||||||
#define UNIFORM(n)
|
#define UNIFORM(n)
|
||||||
|
|||||||
@@ -5,9 +5,13 @@
|
|||||||
|
|
||||||
#ifdef VULKAN
|
#ifdef VULKAN
|
||||||
|
|
||||||
|
#ifndef HAS_EXTENDED_TYPES
|
||||||
|
#define HAS_EXTENDED_TYPES 1
|
||||||
|
#endif
|
||||||
|
#if HAS_EXTENDED_TYPES
|
||||||
#extension GL_EXT_shader_16bit_storage : require
|
#extension GL_EXT_shader_16bit_storage : require
|
||||||
#extension GL_EXT_shader_8bit_storage : require
|
#extension GL_EXT_shader_8bit_storage : require
|
||||||
#define HAS_EXTENDED_TYPES 1
|
#endif
|
||||||
#define BEGIN_PUSH_CONSTANTS layout(push_constant) uniform PushConstants {
|
#define BEGIN_PUSH_CONSTANTS layout(push_constant) uniform PushConstants {
|
||||||
#define END_PUSH_CONSTANTS };
|
#define END_PUSH_CONSTANTS };
|
||||||
#define UNIFORM(n)
|
#define UNIFORM(n)
|
||||||
|
|||||||
@@ -226,22 +226,6 @@ void BufferCacheRuntime::BindIndexBuffer(Buffer& buffer, u32 offset, u32 size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCacheRuntime::BindVertexBuffer(u32 index, Buffer& buffer, u32 offset, u32 size,
|
|
||||||
u32 stride) {
|
|
||||||
if (index >= max_attributes) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (has_unified_vertex_buffers) {
|
|
||||||
buffer.MakeResident(GL_READ_ONLY);
|
|
||||||
glBindVertexBuffer(index, 0, 0, static_cast<GLsizei>(stride));
|
|
||||||
glBufferAddressRangeNV(GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV, index,
|
|
||||||
buffer.HostGpuAddr() + offset, static_cast<GLsizeiptr>(size));
|
|
||||||
} else {
|
|
||||||
glBindVertexBuffer(index, buffer.Handle(), static_cast<GLintptr>(offset),
|
|
||||||
static_cast<GLsizei>(stride));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings) {
|
void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings) {
|
||||||
// TODO: Should HostBindings provide the correct runtime types to avoid these transforms?
|
// TODO: Should HostBindings provide the correct runtime types to avoid these transforms?
|
||||||
std::array<GLuint, 32> buffer_handles;
|
std::array<GLuint, 32> buffer_handles;
|
||||||
|
|||||||
@@ -99,8 +99,6 @@ public:
|
|||||||
|
|
||||||
void BindIndexBuffer(Buffer& buffer, u32 offset, u32 size);
|
void BindIndexBuffer(Buffer& buffer, u32 offset, u32 size);
|
||||||
|
|
||||||
void BindVertexBuffer(u32 index, Buffer& buffer, u32 offset, u32 size, u32 stride);
|
|
||||||
|
|
||||||
void BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings);
|
void BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings);
|
||||||
|
|
||||||
void BindUniformBuffer(size_t stage, u32 binding_index, Buffer& buffer, u32 offset, u32 size);
|
void BindUniformBuffer(size_t stage, u32 binding_index, Buffer& buffer, u32 offset, u32 size);
|
||||||
|
|||||||
@@ -259,6 +259,7 @@ void RasterizerOpenGL::PrepareDraw(bool is_indexed, Func&& draw_func) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerOpenGL::Draw(bool is_indexed, u32 instance_count) {
|
void RasterizerOpenGL::Draw(bool is_indexed, u32 instance_count) {
|
||||||
|
buffer_cache.SetDrawInstanceCount(instance_count);
|
||||||
PrepareDraw(is_indexed, [this, is_indexed, instance_count](GLenum primitive_mode) {
|
PrepareDraw(is_indexed, [this, is_indexed, instance_count](GLenum primitive_mode) {
|
||||||
const auto& draw_state = maxwell3d->draw_manager.draw_state;
|
const auto& draw_state = maxwell3d->draw_manager.draw_state;
|
||||||
const GLuint base_instance = GLuint(draw_state.base_instance);
|
const GLuint base_instance = GLuint(draw_state.base_instance);
|
||||||
@@ -304,6 +305,7 @@ void RasterizerOpenGL::Draw(bool is_indexed, u32 instance_count) {
|
|||||||
void RasterizerOpenGL::DrawIndirect() {
|
void RasterizerOpenGL::DrawIndirect() {
|
||||||
const auto& params = maxwell3d->draw_manager.indirect_state;
|
const auto& params = maxwell3d->draw_manager.indirect_state;
|
||||||
buffer_cache.SetDrawIndirect(¶ms);
|
buffer_cache.SetDrawIndirect(¶ms);
|
||||||
|
buffer_cache.SetDrawInstanceCount(0);
|
||||||
PrepareDraw(params.is_indexed, [this, ¶ms](GLenum primitive_mode) {
|
PrepareDraw(params.is_indexed, [this, ¶ms](GLenum primitive_mode) {
|
||||||
if (params.is_byte_count) {
|
if (params.is_byte_count) {
|
||||||
const GPUVAddr tfb_object_base_addr = params.indirect_start_address - 4U;
|
const GPUVAddr tfb_object_base_addr = params.indirect_start_address - 4U;
|
||||||
|
|||||||
@@ -585,29 +585,6 @@ void BufferCacheRuntime::BindQuadIndexBuffer(PrimitiveTopology topology, u32 fir
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCacheRuntime::BindVertexBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size, u32 stride) {
|
|
||||||
if (index >= device.GetMaxVertexInputBindings()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (device.IsExtExtendedDynamicStateSupported()) {
|
|
||||||
scheduler.Record([index, buffer, offset, size, stride](vk::CommandBuffer cmdbuf) {
|
|
||||||
const VkDeviceSize vk_offset = buffer != VK_NULL_HANDLE ? offset : 0;
|
|
||||||
const VkDeviceSize vk_size = buffer != VK_NULL_HANDLE ? size : VK_WHOLE_SIZE;
|
|
||||||
const VkDeviceSize vk_stride = stride;
|
|
||||||
cmdbuf.BindVertexBuffers2EXT(index, 1, &buffer, &vk_offset, &vk_size, &vk_stride);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (!device.HasNullDescriptor() && buffer == VK_NULL_HANDLE) {
|
|
||||||
ReserveNullBuffer();
|
|
||||||
buffer = *null_buffer;
|
|
||||||
offset = 0;
|
|
||||||
}
|
|
||||||
scheduler.Record([index, buffer, offset](vk::CommandBuffer cmdbuf) {
|
|
||||||
cmdbuf.BindVertexBuffer(index, buffer, offset);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings) {
|
void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings) {
|
||||||
boost::container::static_vector<VkBuffer, VideoCommon::NUM_VERTEX_BUFFERS> buffer_handles(bindings.buffers.size());
|
boost::container::static_vector<VkBuffer, VideoCommon::NUM_VERTEX_BUFFERS> buffer_handles(bindings.buffers.size());
|
||||||
for (u32 i = 0; i < bindings.buffers.size(); ++i) {
|
for (u32 i = 0; i < bindings.buffers.size(); ++i) {
|
||||||
|
|||||||
@@ -138,8 +138,6 @@ public:
|
|||||||
|
|
||||||
void BindQuadIndexBuffer(PrimitiveTopology topology, u32 first, u32 count);
|
void BindQuadIndexBuffer(PrimitiveTopology topology, u32 first, u32 count);
|
||||||
|
|
||||||
void BindVertexBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size, u32 stride);
|
|
||||||
|
|
||||||
void BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings);
|
void BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings);
|
||||||
|
|
||||||
void BindTransformFeedbackBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size);
|
void BindTransformFeedbackBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size);
|
||||||
|
|||||||
@@ -22,7 +22,13 @@
|
|||||||
#include "video_core/host_shaders/resolve_conditional_render_comp_spv.h"
|
#include "video_core/host_shaders/resolve_conditional_render_comp_spv.h"
|
||||||
#include "video_core/host_shaders/vulkan_quad_indexed_comp_spv.h"
|
#include "video_core/host_shaders/vulkan_quad_indexed_comp_spv.h"
|
||||||
#include "video_core/host_shaders/vulkan_uint8_comp_spv.h"
|
#include "video_core/host_shaders/vulkan_uint8_comp_spv.h"
|
||||||
|
#include "video_core/host_shaders/block_linear_unswizzle_2d_comp_spv.h"
|
||||||
|
#include "video_core/host_shaders/block_linear_unswizzle_2d_nonarrow_comp_spv.h"
|
||||||
#include "video_core/host_shaders/block_linear_unswizzle_3d_bcn_comp_spv.h"
|
#include "video_core/host_shaders/block_linear_unswizzle_3d_bcn_comp_spv.h"
|
||||||
|
#include "video_core/host_shaders/block_linear_unswizzle_3d_comp_spv.h"
|
||||||
|
#include "video_core/host_shaders/block_linear_unswizzle_3d_nonarrow_comp_spv.h"
|
||||||
|
#include "video_core/host_shaders/pitch_unswizzle_comp_spv.h"
|
||||||
|
#include "video_core/host_shaders/pitch_unswizzle_nonarrow_comp_spv.h"
|
||||||
#include "video_core/renderer_vulkan/vk_compute_pass.h"
|
#include "video_core/renderer_vulkan/vk_compute_pass.h"
|
||||||
#include "video_core/surface.h"
|
#include "video_core/surface.h"
|
||||||
#include "video_core/renderer_vulkan/vk_descriptor_pool.h"
|
#include "video_core/renderer_vulkan/vk_descriptor_pool.h"
|
||||||
@@ -872,4 +878,291 @@ void BlockLinearUnswizzle3DPass::UnswizzleChunk(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
constexpr u32 UNSWIZZLE_BINDING_INPUT_BUFFER = 0;
|
||||||
|
constexpr u32 UNSWIZZLE_BINDING_OUTPUT_IMAGE = 1;
|
||||||
|
constexpr size_t UNSWIZZLE_NUM_BINDINGS = 2;
|
||||||
|
|
||||||
|
constexpr std::array<VkDescriptorSetLayoutBinding, UNSWIZZLE_NUM_BINDINGS>
|
||||||
|
UNSWIZZLE_DESCRIPTOR_SET_BINDINGS{{
|
||||||
|
{
|
||||||
|
.binding = UNSWIZZLE_BINDING_INPUT_BUFFER,
|
||||||
|
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||||
|
.descriptorCount = 1,
|
||||||
|
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||||
|
.pImmutableSamplers = nullptr,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.binding = UNSWIZZLE_BINDING_OUTPUT_IMAGE,
|
||||||
|
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||||
|
.descriptorCount = 1,
|
||||||
|
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||||
|
.pImmutableSamplers = nullptr,
|
||||||
|
},
|
||||||
|
}};
|
||||||
|
|
||||||
|
constexpr std::array<VkDescriptorUpdateTemplateEntry, UNSWIZZLE_NUM_BINDINGS>
|
||||||
|
UNSWIZZLE_DESCRIPTOR_UPDATE_TEMPLATE{{
|
||||||
|
{
|
||||||
|
.dstBinding = UNSWIZZLE_BINDING_INPUT_BUFFER,
|
||||||
|
.dstArrayElement = 0,
|
||||||
|
.descriptorCount = 1,
|
||||||
|
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||||
|
.offset = UNSWIZZLE_BINDING_INPUT_BUFFER * sizeof(DescriptorUpdateEntry),
|
||||||
|
.stride = sizeof(DescriptorUpdateEntry),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.dstBinding = UNSWIZZLE_BINDING_OUTPUT_IMAGE,
|
||||||
|
.dstArrayElement = 0,
|
||||||
|
.descriptorCount = 1,
|
||||||
|
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||||
|
.offset = UNSWIZZLE_BINDING_OUTPUT_IMAGE * sizeof(DescriptorUpdateEntry),
|
||||||
|
.stride = sizeof(DescriptorUpdateEntry),
|
||||||
|
},
|
||||||
|
}};
|
||||||
|
|
||||||
|
constexpr DescriptorBankInfo UNSWIZZLE_BANK_INFO{
|
||||||
|
.uniform_buffers = 0,
|
||||||
|
.storage_buffers = 1,
|
||||||
|
.texture_buffers = 0,
|
||||||
|
.image_buffers = 0,
|
||||||
|
.textures = 0,
|
||||||
|
.images = 1,
|
||||||
|
.score = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
[[nodiscard]] std::span<const u32> UnswizzleSpv(const Device& device,
|
||||||
|
std::span<const u32> extended,
|
||||||
|
std::span<const u32> narrow) {
|
||||||
|
if (device.IsStorageBuffer8BitAccessSupported() &&
|
||||||
|
device.IsStorageBuffer16BitAccessSupported()) {
|
||||||
|
return extended;
|
||||||
|
}
|
||||||
|
return narrow;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct PitchUnswizzlePushConstants {
|
||||||
|
alignas(8) std::array<u32, 2> origin;
|
||||||
|
alignas(8) std::array<s32, 2> destination;
|
||||||
|
u32 bytes_per_block;
|
||||||
|
u32 pitch;
|
||||||
|
};
|
||||||
|
|
||||||
|
void RecordUnswizzleEntryBarrier(Scheduler& scheduler, VkPipeline vk_pipeline, VkImage vk_image,
|
||||||
|
VkImageAspectFlags aspect_mask, bool is_initialized) {
|
||||||
|
scheduler.Record([vk_pipeline, vk_image, aspect_mask,
|
||||||
|
is_initialized](vk::CommandBuffer cmdbuf) {
|
||||||
|
VkAccessFlags src_access = VK_ACCESS_NONE;
|
||||||
|
VkImageLayout old_layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
|
if (is_initialized) {
|
||||||
|
src_access = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT |
|
||||||
|
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||||
|
old_layout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
|
}
|
||||||
|
const VkImageMemoryBarrier image_barrier{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.srcAccessMask = src_access,
|
||||||
|
.dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
|
||||||
|
.oldLayout = old_layout,
|
||||||
|
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||||
|
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
|
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
|
.image = vk_image,
|
||||||
|
.subresourceRange{
|
||||||
|
.aspectMask = aspect_mask,
|
||||||
|
.baseMipLevel = 0,
|
||||||
|
.levelCount = VK_REMAINING_MIP_LEVELS,
|
||||||
|
.baseArrayLayer = 0,
|
||||||
|
.layerCount = VK_REMAINING_ARRAY_LAYERS,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
VkPipelineStageFlags src_stage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
||||||
|
if (is_initialized) {
|
||||||
|
src_stage = vk::PIPELINE_STAGE_GRAPHICS_COMPUTE_TRANSFER;
|
||||||
|
}
|
||||||
|
cmdbuf.PipelineBarrier(src_stage, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, image_barrier);
|
||||||
|
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_COMPUTE, vk_pipeline);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecordUnswizzleExitBarrier(Scheduler& scheduler, VkImage vk_image,
|
||||||
|
VkImageAspectFlags aspect_mask) {
|
||||||
|
scheduler.Record([vk_image, aspect_mask](vk::CommandBuffer cmdbuf) {
|
||||||
|
const VkImageMemoryBarrier image_barrier{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
|
||||||
|
.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT |
|
||||||
|
VK_ACCESS_COLOR_ATTACHMENT_READ_BIT,
|
||||||
|
.oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||||
|
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||||
|
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
|
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
|
.image = vk_image,
|
||||||
|
.subresourceRange{
|
||||||
|
.aspectMask = aspect_mask,
|
||||||
|
.baseMipLevel = 0,
|
||||||
|
.levelCount = VK_REMAINING_MIP_LEVELS,
|
||||||
|
.baseArrayLayer = 0,
|
||||||
|
.layerCount = VK_REMAINING_ARRAY_LAYERS,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||||
|
vk::PIPELINE_STAGE_GRAPHICS_COMPUTE_TRANSFER, 0, image_barrier);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Anonymous namespace
|
||||||
|
|
||||||
|
BlockLinearUnswizzle2DPass::BlockLinearUnswizzle2DPass(
|
||||||
|
const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool_,
|
||||||
|
ComputePassDescriptorQueue& compute_pass_descriptor_queue_)
|
||||||
|
: ComputePass(device_, scheduler_, descriptor_pool_, UNSWIZZLE_DESCRIPTOR_SET_BINDINGS,
|
||||||
|
UNSWIZZLE_DESCRIPTOR_UPDATE_TEMPLATE, UNSWIZZLE_BANK_INFO,
|
||||||
|
COMPUTE_PUSH_CONSTANT_RANGE<sizeof(
|
||||||
|
VideoCommon::Accelerated::BlockLinearSwizzle2DParams)>,
|
||||||
|
UnswizzleSpv(device_, BLOCK_LINEAR_UNSWIZZLE_2D_COMP_SPV,
|
||||||
|
BLOCK_LINEAR_UNSWIZZLE_2D_NONARROW_COMP_SPV)),
|
||||||
|
scheduler{scheduler_}, compute_pass_descriptor_queue{compute_pass_descriptor_queue_} {}
|
||||||
|
|
||||||
|
BlockLinearUnswizzle2DPass::~BlockLinearUnswizzle2DPass() = default;
|
||||||
|
|
||||||
|
void BlockLinearUnswizzle2DPass::Unswizzle(
|
||||||
|
Image& image, const StagingBufferRef& map,
|
||||||
|
std::span<const VideoCommon::SwizzleParameters> swizzles) {
|
||||||
|
using namespace VideoCommon::Accelerated;
|
||||||
|
scheduler.RequestOutsideRenderPassOperationContext();
|
||||||
|
const VkPipeline vk_pipeline = *pipeline;
|
||||||
|
const VkImageAspectFlags aspect_mask = image.AspectMask();
|
||||||
|
const VkImage vk_image = image.Handle();
|
||||||
|
const bool is_initialized = image.ExchangeInitialization();
|
||||||
|
RecordUnswizzleEntryBarrier(scheduler, vk_pipeline, vk_image, aspect_mask, is_initialized);
|
||||||
|
|
||||||
|
const u32 num_layers = static_cast<u32>(image.info.resources.layers);
|
||||||
|
for (const VideoCommon::SwizzleParameters& swizzle : swizzles) {
|
||||||
|
const size_t input_offset = swizzle.buffer_offset + map.offset;
|
||||||
|
const u32 num_dispatches_x = Common::DivCeil(swizzle.num_tiles.width, 32U);
|
||||||
|
const u32 num_dispatches_y = Common::DivCeil(swizzle.num_tiles.height, 32U);
|
||||||
|
|
||||||
|
compute_pass_descriptor_queue.Acquire(scheduler, 2);
|
||||||
|
compute_pass_descriptor_queue.AddBuffer(map.buffer, input_offset,
|
||||||
|
image.guest_size_bytes - swizzle.buffer_offset);
|
||||||
|
compute_pass_descriptor_queue.AddImage(image.StorageImageView(swizzle.level));
|
||||||
|
const void* const descriptor_data{compute_pass_descriptor_queue.UpdateData()};
|
||||||
|
|
||||||
|
const auto params = MakeBlockLinearSwizzle2DParams(swizzle, image.info);
|
||||||
|
scheduler.Record([this, num_dispatches_x, num_dispatches_y, num_layers, params,
|
||||||
|
descriptor_data](vk::CommandBuffer cmdbuf) {
|
||||||
|
const VkDescriptorSet set = descriptor_allocator.Commit();
|
||||||
|
device.GetLogical().UpdateDescriptorSet(set, *descriptor_template, descriptor_data);
|
||||||
|
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_COMPUTE, *layout, 0, set, {});
|
||||||
|
cmdbuf.PushConstants(*layout, VK_SHADER_STAGE_COMPUTE_BIT, params);
|
||||||
|
cmdbuf.Dispatch(num_dispatches_x, num_dispatches_y, num_layers);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
RecordUnswizzleExitBarrier(scheduler, vk_image, aspect_mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockLinearUnswizzleImage3DPass::BlockLinearUnswizzleImage3DPass(
|
||||||
|
const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool_,
|
||||||
|
ComputePassDescriptorQueue& compute_pass_descriptor_queue_)
|
||||||
|
: ComputePass(device_, scheduler_, descriptor_pool_, UNSWIZZLE_DESCRIPTOR_SET_BINDINGS,
|
||||||
|
UNSWIZZLE_DESCRIPTOR_UPDATE_TEMPLATE, UNSWIZZLE_BANK_INFO,
|
||||||
|
COMPUTE_PUSH_CONSTANT_RANGE<sizeof(BlockLinearSwizzle3DParams)>,
|
||||||
|
UnswizzleSpv(device_, BLOCK_LINEAR_UNSWIZZLE_3D_COMP_SPV,
|
||||||
|
BLOCK_LINEAR_UNSWIZZLE_3D_NONARROW_COMP_SPV)),
|
||||||
|
scheduler{scheduler_}, compute_pass_descriptor_queue{compute_pass_descriptor_queue_} {}
|
||||||
|
|
||||||
|
BlockLinearUnswizzleImage3DPass::~BlockLinearUnswizzleImage3DPass() = default;
|
||||||
|
|
||||||
|
void BlockLinearUnswizzleImage3DPass::Unswizzle(
|
||||||
|
Image& image, const StagingBufferRef& map,
|
||||||
|
std::span<const VideoCommon::SwizzleParameters> swizzles) {
|
||||||
|
using namespace VideoCommon::Accelerated;
|
||||||
|
scheduler.RequestOutsideRenderPassOperationContext();
|
||||||
|
const VkPipeline vk_pipeline = *pipeline;
|
||||||
|
const VkImageAspectFlags aspect_mask = image.AspectMask();
|
||||||
|
const VkImage vk_image = image.Handle();
|
||||||
|
const bool is_initialized = image.ExchangeInitialization();
|
||||||
|
RecordUnswizzleEntryBarrier(scheduler, vk_pipeline, vk_image, aspect_mask, is_initialized);
|
||||||
|
|
||||||
|
for (const VideoCommon::SwizzleParameters& swizzle : swizzles) {
|
||||||
|
const size_t input_offset = swizzle.buffer_offset + map.offset;
|
||||||
|
const u32 num_dispatches_x = Common::DivCeil(swizzle.num_tiles.width, 16U);
|
||||||
|
const u32 num_dispatches_y = Common::DivCeil(swizzle.num_tiles.height, 8U);
|
||||||
|
const u32 num_dispatches_z = Common::DivCeil(swizzle.num_tiles.depth, 8U);
|
||||||
|
|
||||||
|
compute_pass_descriptor_queue.Acquire(scheduler, 2);
|
||||||
|
compute_pass_descriptor_queue.AddBuffer(map.buffer, input_offset,
|
||||||
|
image.guest_size_bytes - swizzle.buffer_offset);
|
||||||
|
compute_pass_descriptor_queue.AddImage(image.StorageImageView(swizzle.level));
|
||||||
|
const void* const descriptor_data{compute_pass_descriptor_queue.UpdateData()};
|
||||||
|
|
||||||
|
const auto params = MakeBlockLinearSwizzle3DParams(swizzle, image.info);
|
||||||
|
scheduler.Record([this, num_dispatches_x, num_dispatches_y, num_dispatches_z, params,
|
||||||
|
descriptor_data](vk::CommandBuffer cmdbuf) {
|
||||||
|
const VkDescriptorSet set = descriptor_allocator.Commit();
|
||||||
|
device.GetLogical().UpdateDescriptorSet(set, *descriptor_template, descriptor_data);
|
||||||
|
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_COMPUTE, *layout, 0, set, {});
|
||||||
|
cmdbuf.PushConstants(*layout, VK_SHADER_STAGE_COMPUTE_BIT, params);
|
||||||
|
cmdbuf.Dispatch(num_dispatches_x, num_dispatches_y, num_dispatches_z);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
RecordUnswizzleExitBarrier(scheduler, vk_image, aspect_mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
PitchUnswizzlePass::PitchUnswizzlePass(
|
||||||
|
const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool_,
|
||||||
|
ComputePassDescriptorQueue& compute_pass_descriptor_queue_)
|
||||||
|
: ComputePass(device_, scheduler_, descriptor_pool_, UNSWIZZLE_DESCRIPTOR_SET_BINDINGS,
|
||||||
|
UNSWIZZLE_DESCRIPTOR_UPDATE_TEMPLATE, UNSWIZZLE_BANK_INFO,
|
||||||
|
COMPUTE_PUSH_CONSTANT_RANGE<sizeof(PitchUnswizzlePushConstants)>,
|
||||||
|
UnswizzleSpv(device_, PITCH_UNSWIZZLE_COMP_SPV,
|
||||||
|
PITCH_UNSWIZZLE_NONARROW_COMP_SPV)),
|
||||||
|
scheduler{scheduler_}, compute_pass_descriptor_queue{compute_pass_descriptor_queue_} {}
|
||||||
|
|
||||||
|
PitchUnswizzlePass::~PitchUnswizzlePass() = default;
|
||||||
|
|
||||||
|
void PitchUnswizzlePass::Unswizzle(Image& image, const StagingBufferRef& map,
|
||||||
|
std::span<const VideoCommon::SwizzleParameters> swizzles) {
|
||||||
|
scheduler.RequestOutsideRenderPassOperationContext();
|
||||||
|
const VkPipeline vk_pipeline = *pipeline;
|
||||||
|
const VkImageAspectFlags aspect_mask = image.AspectMask();
|
||||||
|
const VkImage vk_image = image.Handle();
|
||||||
|
const bool is_initialized = image.ExchangeInitialization();
|
||||||
|
RecordUnswizzleEntryBarrier(scheduler, vk_pipeline, vk_image, aspect_mask, is_initialized);
|
||||||
|
|
||||||
|
const u32 bytes_per_block = VideoCore::Surface::BytesPerBlock(image.info.format);
|
||||||
|
const u32 pitch = image.info.pitch;
|
||||||
|
for (const VideoCommon::SwizzleParameters& swizzle : swizzles) {
|
||||||
|
const size_t input_offset = swizzle.buffer_offset + map.offset;
|
||||||
|
const u32 num_dispatches_x = Common::DivCeil(swizzle.num_tiles.width, 32U);
|
||||||
|
const u32 num_dispatches_y = Common::DivCeil(swizzle.num_tiles.height, 32U);
|
||||||
|
|
||||||
|
compute_pass_descriptor_queue.Acquire(scheduler, 2);
|
||||||
|
compute_pass_descriptor_queue.AddBuffer(map.buffer, input_offset,
|
||||||
|
image.guest_size_bytes - swizzle.buffer_offset);
|
||||||
|
compute_pass_descriptor_queue.AddImage(image.StorageImageView(swizzle.level));
|
||||||
|
const void* const descriptor_data{compute_pass_descriptor_queue.UpdateData()};
|
||||||
|
|
||||||
|
const PitchUnswizzlePushConstants params{
|
||||||
|
.origin{0, 0},
|
||||||
|
.destination{0, 0},
|
||||||
|
.bytes_per_block = bytes_per_block,
|
||||||
|
.pitch = pitch,
|
||||||
|
};
|
||||||
|
scheduler.Record([this, num_dispatches_x, num_dispatches_y, params,
|
||||||
|
descriptor_data](vk::CommandBuffer cmdbuf) {
|
||||||
|
const VkDescriptorSet set = descriptor_allocator.Commit();
|
||||||
|
device.GetLogical().UpdateDescriptorSet(set, *descriptor_template, descriptor_data);
|
||||||
|
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_COMPUTE, *layout, 0, set, {});
|
||||||
|
cmdbuf.PushConstants(*layout, VK_SHADER_STAGE_COMPUTE_BIT, params);
|
||||||
|
cmdbuf.Dispatch(num_dispatches_x, num_dispatches_y, 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
RecordUnswizzleExitBarrier(scheduler, vk_image, aspect_mask);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|||||||
@@ -164,4 +164,49 @@ private:
|
|||||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue;
|
ComputePassDescriptorQueue& compute_pass_descriptor_queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class BlockLinearUnswizzle2DPass final : public ComputePass {
|
||||||
|
public:
|
||||||
|
explicit BlockLinearUnswizzle2DPass(
|
||||||
|
const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool_,
|
||||||
|
ComputePassDescriptorQueue& compute_pass_descriptor_queue_);
|
||||||
|
~BlockLinearUnswizzle2DPass();
|
||||||
|
|
||||||
|
void Unswizzle(Image& image, const StagingBufferRef& map,
|
||||||
|
std::span<const VideoCommon::SwizzleParameters> swizzles);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Scheduler& scheduler;
|
||||||
|
ComputePassDescriptorQueue& compute_pass_descriptor_queue;
|
||||||
|
};
|
||||||
|
|
||||||
|
class BlockLinearUnswizzleImage3DPass final : public ComputePass {
|
||||||
|
public:
|
||||||
|
explicit BlockLinearUnswizzleImage3DPass(
|
||||||
|
const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool_,
|
||||||
|
ComputePassDescriptorQueue& compute_pass_descriptor_queue_);
|
||||||
|
~BlockLinearUnswizzleImage3DPass();
|
||||||
|
|
||||||
|
void Unswizzle(Image& image, const StagingBufferRef& map,
|
||||||
|
std::span<const VideoCommon::SwizzleParameters> swizzles);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Scheduler& scheduler;
|
||||||
|
ComputePassDescriptorQueue& compute_pass_descriptor_queue;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PitchUnswizzlePass final : public ComputePass {
|
||||||
|
public:
|
||||||
|
explicit PitchUnswizzlePass(const Device& device_, Scheduler& scheduler_,
|
||||||
|
DescriptorPool& descriptor_pool_,
|
||||||
|
ComputePassDescriptorQueue& compute_pass_descriptor_queue_);
|
||||||
|
~PitchUnswizzlePass();
|
||||||
|
|
||||||
|
void Unswizzle(Image& image, const StagingBufferRef& map,
|
||||||
|
std::span<const VideoCommon::SwizzleParameters> swizzles);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Scheduler& scheduler;
|
||||||
|
ComputePassDescriptorQueue& compute_pass_descriptor_queue;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|||||||
@@ -694,9 +694,11 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
|
|||||||
const size_t num_vertex_arrays = (std::min)(
|
const size_t num_vertex_arrays = (std::min)(
|
||||||
Maxwell::NumVertexArrays, static_cast<size_t>(device.GetMaxVertexInputBindings()));
|
Maxwell::NumVertexArrays, static_cast<size_t>(device.GetMaxVertexInputBindings()));
|
||||||
for (size_t index = 0; index < num_vertex_arrays; ++index) {
|
for (size_t index = 0; index < num_vertex_arrays; ++index) {
|
||||||
const bool instanced = key.state.binding_divisors[index] != 0;
|
const bool instanced = ((key.state.enabled_divisors >> index) & 1) != 0;
|
||||||
const auto rate =
|
auto rate = VK_VERTEX_INPUT_RATE_VERTEX;
|
||||||
instanced ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX;
|
if (instanced) {
|
||||||
|
rate = VK_VERTEX_INPUT_RATE_INSTANCE;
|
||||||
|
}
|
||||||
vertex_bindings.push_back({
|
vertex_bindings.push_back({
|
||||||
.binding = static_cast<u32>(index),
|
.binding = static_cast<u32>(index),
|
||||||
.stride = key.state.vertex_strides[index],
|
.stride = key.state.vertex_strides[index],
|
||||||
@@ -705,7 +707,7 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
|
|||||||
if (instanced) {
|
if (instanced) {
|
||||||
vertex_binding_divisors.push_back({
|
vertex_binding_divisors.push_back({
|
||||||
.binding = static_cast<u32>(index),
|
.binding = static_cast<u32>(index),
|
||||||
.divisor = key.state.binding_divisors[index],
|
.divisor = device.GetVertexAttribDivisor(key.state.binding_divisors[index]),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,10 +137,12 @@ VkRect2D GetScissorState(const Maxwell& regs, size_t index, u32 up_scale = 1, u3
|
|||||||
max_y = (std::max)(max_y, 0);
|
max_y = (std::max)(max_y, 0);
|
||||||
|
|
||||||
if (src.enable) {
|
if (src.enable) {
|
||||||
scissor.offset.x = scale_up(src.min_x);
|
const s32 min_x = static_cast<s32>(src.min_x.Value());
|
||||||
|
const s32 max_x = static_cast<s32>(src.max_x.Value());
|
||||||
|
scissor.offset.x = scale_up(min_x);
|
||||||
scissor.offset.y = scale_up(min_y);
|
scissor.offset.y = scale_up(min_y);
|
||||||
scissor.extent.width = scale_up(src.max_x - src.min_x);
|
scissor.extent.width = scale_up((std::max)(max_x - min_x, 0));
|
||||||
scissor.extent.height = scale_up(max_y - min_y);
|
scissor.extent.height = scale_up((std::max)(max_y - min_y, 0));
|
||||||
} else {
|
} else {
|
||||||
scissor.offset.x = 0;
|
scissor.offset.x = 0;
|
||||||
scissor.offset.y = 0;
|
scissor.offset.y = 0;
|
||||||
@@ -260,6 +262,7 @@ void RasterizerVulkan::PrepareDraw(bool is_indexed, Func&& draw_func) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerVulkan::Draw(bool is_indexed, u32 instance_count) {
|
void RasterizerVulkan::Draw(bool is_indexed, u32 instance_count) {
|
||||||
|
buffer_cache.SetDrawInstanceCount(instance_count);
|
||||||
PrepareDraw(is_indexed, [this, is_indexed, instance_count] {
|
PrepareDraw(is_indexed, [this, is_indexed, instance_count] {
|
||||||
const auto& draw_state = maxwell3d->draw_manager.draw_state;
|
const auto& draw_state = maxwell3d->draw_manager.draw_state;
|
||||||
const u32 num_instances{instance_count};
|
const u32 num_instances{instance_count};
|
||||||
@@ -295,6 +298,7 @@ void RasterizerVulkan::Draw(bool is_indexed, u32 instance_count) {
|
|||||||
void RasterizerVulkan::DrawIndirect() {
|
void RasterizerVulkan::DrawIndirect() {
|
||||||
const auto& params = maxwell3d->draw_manager.indirect_state;
|
const auto& params = maxwell3d->draw_manager.indirect_state;
|
||||||
buffer_cache.SetDrawIndirect(¶ms);
|
buffer_cache.SetDrawIndirect(¶ms);
|
||||||
|
buffer_cache.SetDrawInstanceCount(0);
|
||||||
PrepareDraw(params.is_indexed, [this, ¶ms] {
|
PrepareDraw(params.is_indexed, [this, ¶ms] {
|
||||||
const auto indirect_buffer = buffer_cache.GetDrawIndirectBuffer();
|
const auto indirect_buffer = buffer_cache.GetDrawIndirectBuffer();
|
||||||
const auto& buffer = indirect_buffer.first;
|
const auto& buffer = indirect_buffer.first;
|
||||||
@@ -1917,13 +1921,19 @@ void RasterizerVulkan::UpdateVertexInput(Tegra::Engines::Maxwell3D::Regs& regs)
|
|||||||
for (u32 binding = 0; binding < max_bindings; ++binding) {
|
for (u32 binding = 0; binding < max_bindings; ++binding) {
|
||||||
const auto& input_binding{regs.vertex_streams[binding]};
|
const auto& input_binding{regs.vertex_streams[binding]};
|
||||||
const bool is_instanced{regs.vertex_stream_instances.IsInstancingEnabled(binding)};
|
const bool is_instanced{regs.vertex_stream_instances.IsInstancingEnabled(binding)};
|
||||||
|
auto input_rate = VK_VERTEX_INPUT_RATE_VERTEX;
|
||||||
|
u32 divisor = 1;
|
||||||
|
if (is_instanced) {
|
||||||
|
input_rate = VK_VERTEX_INPUT_RATE_INSTANCE;
|
||||||
|
divisor = device.GetVertexAttribDivisor(input_binding.frequency);
|
||||||
|
}
|
||||||
bindings.push_back({
|
bindings.push_back({
|
||||||
.sType = VK_STRUCTURE_TYPE_VERTEX_INPUT_BINDING_DESCRIPTION_2_EXT,
|
.sType = VK_STRUCTURE_TYPE_VERTEX_INPUT_BINDING_DESCRIPTION_2_EXT,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.binding = binding,
|
.binding = binding,
|
||||||
.stride = input_binding.stride,
|
.stride = input_binding.stride,
|
||||||
.inputRate = is_instanced ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX,
|
.inputRate = input_rate,
|
||||||
.divisor = is_instanced ? input_binding.frequency : 1,
|
.divisor = divisor,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -449,7 +449,9 @@ void Scheduler::EndRenderPass()
|
|||||||
| VK_ACCESS_COLOR_ATTACHMENT_READ_BIT
|
| VK_ACCESS_COLOR_ATTACHMENT_READ_BIT
|
||||||
| VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT
|
| VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT
|
||||||
| VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT
|
| VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT
|
||||||
| VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
| VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
|
||||||
|
| VK_ACCESS_TRANSFER_READ_BIT
|
||||||
|
| VK_ACCESS_TRANSFER_WRITE_BIT,
|
||||||
.oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
.oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
@@ -460,7 +462,7 @@ void Scheduler::EndRenderPass()
|
|||||||
}
|
}
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT |
|
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT |
|
||||||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, vk::PIPELINE_STAGE_GRAPHICS_COMPUTE,
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, vk::PIPELINE_STAGE_GRAPHICS_COMPUTE_TRANSFER,
|
||||||
0, nullptr, nullptr, vk::Span(barriers.data(), num_images));
|
0, nullptr, nullptr, vk::Span(barriers.data(), num_images));
|
||||||
if (has_transform_feedback) {
|
if (has_transform_feedback) {
|
||||||
static constexpr VkMemoryBarrier XFB_OUTPUT_BARRIER{
|
static constexpr VkMemoryBarrier XFB_OUTPUT_BARRIER{
|
||||||
|
|||||||
@@ -160,6 +160,55 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
|
|||||||
info.size.depth == 1;
|
info.size.depth == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] PixelFormat UnswizzleViewFormat(u32 bytes_per_block) {
|
||||||
|
switch (bytes_per_block) {
|
||||||
|
case 1:
|
||||||
|
return PixelFormat::R8_UINT;
|
||||||
|
case 2:
|
||||||
|
return PixelFormat::R16_UINT;
|
||||||
|
case 4:
|
||||||
|
return PixelFormat::R32_UINT;
|
||||||
|
case 8:
|
||||||
|
return PixelFormat::R32G32_UINT;
|
||||||
|
case 16:
|
||||||
|
return PixelFormat::R32G32B32A32_UINT;
|
||||||
|
default:
|
||||||
|
return PixelFormat::Invalid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr u32 UNSWIZZLE_WORKGROUP_INVOCATIONS = 32 * 32;
|
||||||
|
|
||||||
|
[[nodiscard]] bool SupportsAcceleratedUnswizzleDevice(const Device& device) {
|
||||||
|
return device.IsKhrImageFormatListSupported() &&
|
||||||
|
device.GetMaxComputeWorkGroupInvocations() >= UNSWIZZLE_WORKGROUP_INVOCATIONS;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool SupportsAcceleratedUnswizzle(const Device& device, const ImageInfo& info) {
|
||||||
|
if (!SupportsAcceleratedUnswizzleDevice(device)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (info.num_samples > 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (info.type != ImageType::e2D && info.type != ImageType::e3D &&
|
||||||
|
info.type != ImageType::Linear) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const PixelFormat view_format =
|
||||||
|
UnswizzleViewFormat(VideoCore::Surface::BytesPerBlock(info.format));
|
||||||
|
if (view_format == PixelFormat::Invalid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!VideoCore::Surface::IsViewCompatible(info.format, view_format, false, true)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const auto host_format =
|
||||||
|
MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, false, view_format);
|
||||||
|
return device.IsFormatSupported(host_format.format, VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT,
|
||||||
|
FormatType::Optimal);
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] VkImageCreateInfo MakeImageCreateInfo(const Device& device, const ImageInfo& info,
|
[[nodiscard]] VkImageCreateInfo MakeImageCreateInfo(const Device& device, const ImageInfo& info,
|
||||||
std::optional<VkFormat> format_override = {}) {
|
std::optional<VkFormat> format_override = {}) {
|
||||||
auto format_info =
|
auto format_info =
|
||||||
@@ -248,8 +297,18 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
|
|||||||
return allocator.CreateImage(image_ci);
|
return allocator.CreateImage(image_ci);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] VkImageViewType StorageViewType(ImageType type) {
|
||||||
|
if (type == ImageType::e3D) {
|
||||||
|
return VK_IMAGE_VIEW_TYPE_3D;
|
||||||
|
}
|
||||||
|
if (type == ImageType::Linear) {
|
||||||
|
return VK_IMAGE_VIEW_TYPE_2D;
|
||||||
|
}
|
||||||
|
return VK_IMAGE_VIEW_TYPE_2D_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] vk::ImageView MakeStorageView(const vk::Device& device, u32 level, VkImage image,
|
[[nodiscard]] vk::ImageView MakeStorageView(const vk::Device& device, u32 level, VkImage image,
|
||||||
VkFormat format) {
|
VkFormat format, VkImageViewType view_type) {
|
||||||
static constexpr VkImageViewUsageCreateInfo storage_image_view_usage_create_info{
|
static constexpr VkImageViewUsageCreateInfo storage_image_view_usage_create_info{
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
@@ -260,7 +319,7 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
|
|||||||
.pNext = &storage_image_view_usage_create_info,
|
.pNext = &storage_image_view_usage_create_info,
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.image = image,
|
.image = image,
|
||||||
.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY,
|
.viewType = view_type,
|
||||||
.format = format,
|
.format = format,
|
||||||
.components{
|
.components{
|
||||||
.r = VK_COMPONENT_SWIZZLE_IDENTITY,
|
.r = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||||
@@ -658,18 +717,11 @@ void CopyBufferToImage(vk::CommandBuffer cmdbuf, VkBuffer src_buffer, VkImage im
|
|||||||
.subresourceRange = subresource_range,
|
.subresourceRange = subresource_range,
|
||||||
};
|
};
|
||||||
|
|
||||||
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT |
|
cmdbuf.PipelineBarrier(vk::PIPELINE_STAGE_GRAPHICS_COMPUTE, VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
|
||||||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT |
|
|
||||||
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
|
|
||||||
read_barrier);
|
read_barrier);
|
||||||
cmdbuf.CopyBufferToImage(src_buffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, copies);
|
cmdbuf.CopyBufferToImage(src_buffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, copies);
|
||||||
// TODO: Move this to another API
|
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, vk::PIPELINE_STAGE_GRAPHICS_COMPUTE, 0,
|
||||||
cmdbuf.PipelineBarrier(
|
nullptr, nullptr, write_barrier);
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
|
||||||
VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT |
|
|
||||||
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT |
|
|
||||||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
|
||||||
0, nullptr, nullptr, write_barrier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] VkImageBlit MakeImageBlit(const Region2D& dst_region, const Region2D& src_region,
|
[[nodiscard]] VkImageBlit MakeImageBlit(const Region2D& dst_region, const Region2D& src_region,
|
||||||
@@ -968,6 +1020,14 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, Scheduler& sched
|
|||||||
bl3d_unswizzle_pass.emplace(device, scheduler, descriptor_pool,
|
bl3d_unswizzle_pass.emplace(device, scheduler, descriptor_pool,
|
||||||
staging_buffer_pool, compute_pass_descriptor_queue);
|
staging_buffer_pool, compute_pass_descriptor_queue);
|
||||||
}
|
}
|
||||||
|
if (SupportsAcceleratedUnswizzleDevice(device)) {
|
||||||
|
bl_unswizzle_2d_pass.emplace(device, scheduler, descriptor_pool,
|
||||||
|
compute_pass_descriptor_queue);
|
||||||
|
bl_unswizzle_image_3d_pass.emplace(device, scheduler, descriptor_pool,
|
||||||
|
compute_pass_descriptor_queue);
|
||||||
|
pitch_unswizzle_pass.emplace(device, scheduler, descriptor_pool,
|
||||||
|
compute_pass_descriptor_queue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCacheRuntime::Finish() {
|
void TextureCacheRuntime::Finish() {
|
||||||
@@ -1902,16 +1962,12 @@ Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu
|
|||||||
if (runtime->device.HasDebuggingToolAttached()) {
|
if (runtime->device.HasDebuggingToolAttached()) {
|
||||||
original_image.SetObjectNameEXT(VideoCommon::Name(*this).c_str());
|
original_image.SetObjectNameEXT(VideoCommon::Name(*this).c_str());
|
||||||
}
|
}
|
||||||
|
if (False(flags & VideoCommon::ImageFlagBits::Converted) &&
|
||||||
|
SupportsAcceleratedUnswizzle(runtime->device, info)) {
|
||||||
|
flags |= VideoCommon::ImageFlagBits::AcceleratedUpload;
|
||||||
|
}
|
||||||
current_image = &Image::original_image;
|
current_image = &Image::original_image;
|
||||||
storage_image_views.resize(info.resources.levels);
|
storage_image_views.resize(info.resources.levels);
|
||||||
if (WillUseAcceleratedAstcDecode(runtime->device, info)) {
|
|
||||||
const auto& device = runtime->device.GetLogical();
|
|
||||||
const VkFormat storage_format = VK_FORMAT_A8B8G8R8_UNORM_PACK32;
|
|
||||||
for (s32 level = 0; level < info.resources.levels; ++level) {
|
|
||||||
storage_image_views[level] =
|
|
||||||
MakeStorageView(device, level, *original_image, storage_format);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Image::Image(const VideoCommon::NullImageParams& params) : VideoCommon::ImageBase{params} {}
|
Image::Image(const VideoCommon::NullImageParams& params) : VideoCommon::ImageBase{params} {}
|
||||||
@@ -2035,7 +2091,7 @@ void Image::UploadMemory(VkBuffer buffer, VkDeviceSize offset,
|
|||||||
temp_vk_image, info.format, info.num_samples,
|
temp_vk_image, info.format, info.num_samples,
|
||||||
{image_copies.data(), image_copies.size()}, false);
|
{image_copies.data(), image_copies.size()}, false);
|
||||||
}
|
}
|
||||||
initialized = true;
|
InitializationFor(current_image) = true;
|
||||||
runtime->ReleaseMsaaScratchImage(temp_vk_image);
|
runtime->ReleaseMsaaScratchImage(temp_vk_image);
|
||||||
|
|
||||||
if (is_rescaled) {
|
if (is_rescaled) {
|
||||||
@@ -2056,7 +2112,7 @@ void Image::UploadMemory(VkBuffer buffer, VkDeviceSize offset,
|
|||||||
const VkBuffer src_buffer = buffer;
|
const VkBuffer src_buffer = buffer;
|
||||||
const VkImage vk_image = *original_image;
|
const VkImage vk_image = *original_image;
|
||||||
const VkImageAspectFlags vk_aspect_mask = aspect_mask;
|
const VkImageAspectFlags vk_aspect_mask = aspect_mask;
|
||||||
const bool was_initialized = std::exchange(initialized, true);
|
const bool was_initialized = std::exchange(InitializationFor(&Image::original_image), true);
|
||||||
|
|
||||||
scheduler->Record([src_buffer, vk_image, vk_aspect_mask, was_initialized,
|
scheduler->Record([src_buffer, vk_image, vk_aspect_mask, was_initialized,
|
||||||
vk_copies](vk::CommandBuffer cmdbuf) {
|
vk_copies](vk::CommandBuffer cmdbuf) {
|
||||||
@@ -2321,16 +2377,46 @@ void Image::DownloadMemory(const StagingBufferRef& map, std::span<const BufferIm
|
|||||||
DownloadMemory(buffers, offsets, copies);
|
DownloadMemory(buffers, offsets, copies);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<vk::ImageView>& Image::StorageViewsFor(vk::Image Image::*image) {
|
||||||
|
if (image == &Image::scaled_image) {
|
||||||
|
if (scaled_storage_image_views.empty()) {
|
||||||
|
scaled_storage_image_views.resize(info.resources.levels);
|
||||||
|
}
|
||||||
|
return scaled_storage_image_views;
|
||||||
|
}
|
||||||
|
return storage_image_views;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool& Image::InitializationFor(vk::Image Image::*image) noexcept {
|
||||||
|
if (image == &Image::scaled_image) {
|
||||||
|
return scaled_initialized;
|
||||||
|
}
|
||||||
|
return original_initialized;
|
||||||
|
}
|
||||||
|
|
||||||
VkImageView Image::StorageImageView(s32 level) noexcept {
|
VkImageView Image::StorageImageView(s32 level) noexcept {
|
||||||
auto& view = storage_image_views[level];
|
const bool astc_decode = WillUseAcceleratedAstcDecode(runtime->device, info);
|
||||||
|
const bool unswizzle_upload =
|
||||||
|
!astc_decode && True(flags & ImageFlagBits::AcceleratedUpload);
|
||||||
|
vk::Image Image::*target = current_image;
|
||||||
|
if (astc_decode || unswizzle_upload) {
|
||||||
|
target = &Image::original_image;
|
||||||
|
}
|
||||||
|
auto& view = StorageViewsFor(target)[level];
|
||||||
if (!view) {
|
if (!view) {
|
||||||
auto format_info =
|
auto format_info =
|
||||||
MaxwellToVK::SurfaceFormat(runtime->device, FormatType::Optimal, true, info.format);
|
MaxwellToVK::SurfaceFormat(runtime->device, FormatType::Optimal, true, info.format);
|
||||||
if (WillUseAcceleratedAstcDecode(runtime->device, info)) {
|
if (astc_decode) {
|
||||||
format_info.format = VK_FORMAT_A8B8G8R8_UNORM_PACK32;
|
format_info.format = VK_FORMAT_A8B8G8R8_UNORM_PACK32;
|
||||||
}
|
}
|
||||||
view = MakeStorageView(runtime->device.GetLogical(), level, *(this->*current_image),
|
if (unswizzle_upload) {
|
||||||
format_info.format);
|
const PixelFormat view_format =
|
||||||
|
UnswizzleViewFormat(VideoCore::Surface::BytesPerBlock(info.format));
|
||||||
|
format_info = MaxwellToVK::SurfaceFormat(runtime->device, FormatType::Optimal, false,
|
||||||
|
view_format);
|
||||||
|
}
|
||||||
|
view = MakeStorageView(runtime->device.GetLogical(), level, *(this->*target),
|
||||||
|
format_info.format, StorageViewType(info.type));
|
||||||
}
|
}
|
||||||
return *view;
|
return *view;
|
||||||
}
|
}
|
||||||
@@ -2370,6 +2456,7 @@ bool Image::ScaleUp(bool ignore) {
|
|||||||
}
|
}
|
||||||
if (NeedsScaleHelper()) {
|
if (NeedsScaleHelper()) {
|
||||||
if (!BlitScaleHelper(true)) {
|
if (!BlitScaleHelper(true)) {
|
||||||
|
flags &= ~ImageFlagBits::Rescaled;
|
||||||
current_image = &Image::original_image;
|
current_image = &Image::original_image;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2559,6 +2646,10 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
|
|||||||
if (device->IsExtAstcDecodeModeSupported() && IsLdrAstcFormat(format_info.format)) {
|
if (device->IsExtAstcDecodeModeSupported() && IsLdrAstcFormat(format_info.format)) {
|
||||||
view_next = &astc_decode_mode;
|
view_next = &astc_decode_mode;
|
||||||
}
|
}
|
||||||
|
auto subresource_range = MakeSubresourceRange(aspect_mask, info.range);
|
||||||
|
if (True(flags & VideoCommon::ImageViewFlagBits::Slice)) {
|
||||||
|
subresource_range.levelCount = 1;
|
||||||
|
}
|
||||||
const VkImageViewCreateInfo create_info{
|
const VkImageViewCreateInfo create_info{
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
||||||
.pNext = view_next,
|
.pNext = view_next,
|
||||||
@@ -2567,7 +2658,7 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
|
|||||||
.viewType = VkImageViewType{},
|
.viewType = VkImageViewType{},
|
||||||
.format = format_info.format,
|
.format = format_info.format,
|
||||||
.components = swizzle_mapping,
|
.components = swizzle_mapping,
|
||||||
.subresourceRange = MakeSubresourceRange(aspect_mask, info.range),
|
.subresourceRange = subresource_range,
|
||||||
};
|
};
|
||||||
const auto create = [&](TextureType tex_type, std::optional<u32> num_layers) {
|
const auto create = [&](TextureType tex_type, std::optional<u32> num_layers) {
|
||||||
VkImageViewCreateInfo ci{create_info};
|
VkImageViewCreateInfo ci{create_info};
|
||||||
@@ -3141,6 +3232,19 @@ void TextureCacheRuntime::AccelerateImageUpload(
|
|||||||
return astc_decoder_pass->Assemble(image, map, swizzles);
|
return astc_decoder_pass->Assemble(image, map, swizzles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bl_unswizzle_2d_pass && image.info.type == ImageType::e2D) {
|
||||||
|
return bl_unswizzle_2d_pass->Unswizzle(image, map, swizzles);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bl_unswizzle_image_3d_pass && image.info.type == ImageType::e3D &&
|
||||||
|
!IsPixelFormatBCn(image.info.format)) {
|
||||||
|
return bl_unswizzle_image_3d_pass->Unswizzle(image, map, swizzles);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pitch_unswizzle_pass && image.info.type == ImageType::Linear) {
|
||||||
|
return pitch_unswizzle_pass->Unswizzle(image, map, swizzles);
|
||||||
|
}
|
||||||
|
|
||||||
if (!Settings::values.gpu_unswizzle_enabled.GetValue() || !bl3d_unswizzle_pass) {
|
if (!Settings::values.gpu_unswizzle_enabled.GetValue() || !bl3d_unswizzle_pass) {
|
||||||
if (IsPixelFormatBCn(image.info.format) && image.info.type == ImageType::e3D) {
|
if (IsPixelFormatBCn(image.info.format) && image.info.type == ImageType::e3D) {
|
||||||
ASSERT(false && "GPU unswizzle is disabled for BCn 3D texture");
|
ASSERT(false && "GPU unswizzle is disabled for BCn 3D texture");
|
||||||
|
|||||||
@@ -159,6 +159,9 @@ public:
|
|||||||
std::optional<ASTCDecoderPass> astc_decoder_pass;
|
std::optional<ASTCDecoderPass> astc_decoder_pass;
|
||||||
|
|
||||||
std::optional<BlockLinearUnswizzle3DPass> bl3d_unswizzle_pass;
|
std::optional<BlockLinearUnswizzle3DPass> bl3d_unswizzle_pass;
|
||||||
|
std::optional<BlockLinearUnswizzle2DPass> bl_unswizzle_2d_pass;
|
||||||
|
std::optional<BlockLinearUnswizzleImage3DPass> bl_unswizzle_image_3d_pass;
|
||||||
|
std::optional<PitchUnswizzlePass> pitch_unswizzle_pass;
|
||||||
const Settings::ResolutionScalingInfo& resolution;
|
const Settings::ResolutionScalingInfo& resolution;
|
||||||
std::array<std::vector<VkFormat>, VideoCore::Surface::MaxPixelFormat> view_formats;
|
std::array<std::vector<VkFormat>, VideoCore::Surface::MaxPixelFormat> view_formats;
|
||||||
|
|
||||||
@@ -350,7 +353,7 @@ public:
|
|||||||
|
|
||||||
/// Returns true when the image is already initialized and mark it as initialized
|
/// Returns true when the image is already initialized and mark it as initialized
|
||||||
[[nodiscard]] bool ExchangeInitialization() noexcept {
|
[[nodiscard]] bool ExchangeInitialization() noexcept {
|
||||||
return std::exchange(initialized, true);
|
return std::exchange(InitializationFor(current_image), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkImageView StorageImageView(s32 level) noexcept;
|
VkImageView StorageImageView(s32 level) noexcept;
|
||||||
@@ -370,6 +373,10 @@ private:
|
|||||||
|
|
||||||
bool NeedsScaleHelper() const;
|
bool NeedsScaleHelper() const;
|
||||||
|
|
||||||
|
std::vector<vk::ImageView>& StorageViewsFor(vk::Image Image::*image);
|
||||||
|
|
||||||
|
bool& InitializationFor(vk::Image Image::*image) noexcept;
|
||||||
|
|
||||||
Scheduler* scheduler{};
|
Scheduler* scheduler{};
|
||||||
TextureCacheRuntime* runtime{};
|
TextureCacheRuntime* runtime{};
|
||||||
|
|
||||||
@@ -387,8 +394,10 @@ private:
|
|||||||
vk::Image Image::*current_image{};
|
vk::Image Image::*current_image{};
|
||||||
|
|
||||||
std::vector<vk::ImageView> storage_image_views;
|
std::vector<vk::ImageView> storage_image_views;
|
||||||
|
std::vector<vk::ImageView> scaled_storage_image_views;
|
||||||
VkImageAspectFlags aspect_mask = 0;
|
VkImageAspectFlags aspect_mask = 0;
|
||||||
bool initialized = false;
|
bool original_initialized = false;
|
||||||
|
bool scaled_initialized = false;
|
||||||
|
|
||||||
std::optional<Framebuffer> scale_framebuffer;
|
std::optional<Framebuffer> scale_framebuffer;
|
||||||
std::optional<Framebuffer> normal_framebuffer;
|
std::optional<Framebuffer> normal_framebuffer;
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -23,8 +26,8 @@ struct BlockLinearSwizzle2DParams {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct BlockLinearSwizzle3DParams {
|
struct BlockLinearSwizzle3DParams {
|
||||||
std::array<u32, 3> origin;
|
alignas(16) std::array<u32, 3> origin;
|
||||||
std::array<s32, 3> destination;
|
alignas(16) std::array<s32, 3> destination;
|
||||||
u32 bytes_per_block_log2;
|
u32 bytes_per_block_log2;
|
||||||
u32 slice_size;
|
u32 slice_size;
|
||||||
u32 block_size;
|
u32 block_size;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "video_core/engines/kepler_compute.h"
|
#include "video_core/engines/kepler_compute.h"
|
||||||
#include "video_core/guest_memory.h"
|
#include "video_core/guest_memory.h"
|
||||||
#include "video_core/host1x/gpu_device_memory_manager.h"
|
#include "video_core/host1x/gpu_device_memory_manager.h"
|
||||||
|
#include "video_core/texture_cache/accelerated_swizzle.h"
|
||||||
#include "video_core/texture_cache/image_view_base.h"
|
#include "video_core/texture_cache/image_view_base.h"
|
||||||
#include "video_core/texture_cache/samples_helper.h"
|
#include "video_core/texture_cache/samples_helper.h"
|
||||||
#include "video_core/texture_cache/texture_cache_base.h"
|
#include "video_core/texture_cache/texture_cache_base.h"
|
||||||
@@ -279,11 +280,11 @@ void TextureCache<P>::CheckFeedbackLoop(std::span<const ImageViewInOut> views) {
|
|||||||
|
|
||||||
const ImageId view_image_id = slot_image_views[view.id].image_id;
|
const ImageId view_image_id = slot_image_views[view.id].image_id;
|
||||||
{
|
{
|
||||||
bool is_continue = false;
|
bool is_feedback = false;
|
||||||
for (size_t i = 0; i < 8; ++i)
|
for (size_t i = 0; i < 8; ++i)
|
||||||
is_continue |= (rt_active_mask & (1u << i)) && view_image_id == rt_image_id[i];
|
is_feedback |= (rt_active_mask & (1u << i)) && view_image_id == rt_image_id[i];
|
||||||
if (is_continue)
|
if (is_feedback)
|
||||||
continue;
|
return true;
|
||||||
}
|
}
|
||||||
if (depth_active && view_image_id == rt_depth_image_id) {
|
if (depth_active && view_image_id == rt_depth_image_id) {
|
||||||
return true;
|
return true;
|
||||||
@@ -626,14 +627,25 @@ void TextureCache<P>::DownloadMemory(DAddr cpu_addr, size_t size) {
|
|||||||
std::ranges::sort(images, [this](ImageId lhs, ImageId rhs) {
|
std::ranges::sort(images, [this](ImageId lhs, ImageId rhs) {
|
||||||
return slot_images[lhs].modification_tick < slot_images[rhs].modification_tick;
|
return slot_images[lhs].modification_tick < slot_images[rhs].modification_tick;
|
||||||
});
|
});
|
||||||
|
size_t total_size_bytes = 0;
|
||||||
|
for (const ImageId image_id : images) {
|
||||||
|
total_size_bytes += slot_images[image_id].unswizzled_size_bytes;
|
||||||
|
}
|
||||||
|
auto download_map = runtime.DownloadStagingBuffer(total_size_bytes);
|
||||||
for (const ImageId image_id : images) {
|
for (const ImageId image_id : images) {
|
||||||
Image& image = slot_images[image_id];
|
Image& image = slot_images[image_id];
|
||||||
auto map = runtime.DownloadStagingBuffer(image.unswizzled_size_bytes);
|
|
||||||
const auto copies = FixSmallVectorADL(FullDownloadCopies(image.info));
|
const auto copies = FixSmallVectorADL(FullDownloadCopies(image.info));
|
||||||
image.DownloadMemory(map, copies);
|
image.DownloadMemory(download_map, copies);
|
||||||
runtime.Finish();
|
download_map.offset += image.unswizzled_size_bytes;
|
||||||
SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, map.mapped_span,
|
}
|
||||||
|
runtime.Finish();
|
||||||
|
std::span<u8> download_span = download_map.mapped_span;
|
||||||
|
for (const ImageId image_id : images) {
|
||||||
|
const ImageBase& image = slot_images[image_id];
|
||||||
|
const auto copies = FixSmallVectorADL(FullDownloadCopies(image.info));
|
||||||
|
SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, download_span,
|
||||||
swizzle_data_buffer);
|
swizzle_data_buffer);
|
||||||
|
download_span = download_span.subspan(image.unswizzled_size_bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1122,6 +1134,12 @@ void TextureCache<P>::RefreshContents(Image& image, ImageId image_id) {
|
|||||||
|
|
||||||
TrackImage(image, image_id);
|
TrackImage(image, image_id);
|
||||||
|
|
||||||
|
if (image.info.rescaleable &&
|
||||||
|
IsRegionGpuModified(image.cpu_addr, image.guest_size_bytes)) {
|
||||||
|
runtime.TransitionImageLayout(image);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (image.info.num_samples > 1 && !runtime.CanUploadMSAA()) {
|
if (image.info.num_samples > 1 && !runtime.CanUploadMSAA()) {
|
||||||
LOG_WARNING(HW_GPU, "MSAA image uploads are not implemented");
|
LOG_WARNING(HW_GPU, "MSAA image uploads are not implemented");
|
||||||
runtime.TransitionImageLayout(image);
|
runtime.TransitionImageLayout(image);
|
||||||
@@ -1157,8 +1175,7 @@ void TextureCache<P>::UploadImageContents(Image& image, StagingBuffer& staging)
|
|||||||
const GPUVAddr gpu_addr = image.gpu_addr;
|
const GPUVAddr gpu_addr = image.gpu_addr;
|
||||||
|
|
||||||
if (True(image.flags & ImageFlagBits::AcceleratedUpload)) {
|
if (True(image.flags & ImageFlagBits::AcceleratedUpload)) {
|
||||||
gpu_memory->ReadBlock(gpu_addr, mapped_span.data(), mapped_span.size_bytes(),
|
gpu_memory->ReadBlockUnsafe(gpu_addr, mapped_span.data(), image.guest_size_bytes);
|
||||||
VideoCommon::CacheType::NoTextureCache);
|
|
||||||
const auto uploads = FullUploadSwizzles(image.info);
|
const auto uploads = FullUploadSwizzles(image.info);
|
||||||
runtime.AccelerateImageUpload(image, staging, FixSmallVectorADL(uploads), 0, 0);
|
runtime.AccelerateImageUpload(image, staging, FixSmallVectorADL(uploads), 0, 0);
|
||||||
return;
|
return;
|
||||||
@@ -1265,6 +1282,9 @@ ImageId TextureCache<P>::FindImage(const ImageInfo& info, GPUVAddr gpu_addr,
|
|||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
bool TextureCache<P>::ImageCanRescale(ImageBase& image) {
|
bool TextureCache<P>::ImageCanRescale(ImageBase& image) {
|
||||||
|
if (!Settings::values.resolution_info.active) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!image.info.rescaleable) {
|
if (!image.info.rescaleable) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1352,12 +1372,12 @@ void TextureCache<P>::QueueAsyncDecode(Image& image, ImageId image_id) {
|
|||||||
decode->image_id = image_id;
|
decode->image_id = image_id;
|
||||||
async_decodes.push_back(std::move(decode));
|
async_decodes.push_back(std::move(decode));
|
||||||
|
|
||||||
std::vector<u8> local_unswizzle_data_buffer(image.unswizzled_size_bytes, 0);
|
Common::ScratchBuffer<u8> local_unswizzle_data_buffer(image.unswizzled_size_bytes);
|
||||||
Tegra::Memory::GpuGuestMemory<u8, Tegra::Memory::GuestMemoryFlags::UnsafeRead> swizzle_data(*gpu_memory, image.gpu_addr, image.guest_size_bytes, &swizzle_data_buffer);
|
Tegra::Memory::GpuGuestMemory<u8, Tegra::Memory::GuestMemoryFlags::UnsafeRead> swizzle_data(*gpu_memory, image.gpu_addr, image.guest_size_bytes, &swizzle_data_buffer);
|
||||||
auto copies = UnswizzleImage(*gpu_memory, image.gpu_addr, image.info, swizzle_data, local_unswizzle_data_buffer);
|
auto copies = UnswizzleImage(*gpu_memory, image.gpu_addr, image.info, swizzle_data, local_unswizzle_data_buffer);
|
||||||
const size_t out_size = MapSizeBytes(image);
|
const size_t out_size = MapSizeBytes(image);
|
||||||
|
|
||||||
auto func = [out_size, copies, info = image.info,
|
auto func = [out_size, copies = std::move(copies), info = image.info,
|
||||||
input = std::move(local_unswizzle_data_buffer),
|
input = std::move(local_unswizzle_data_buffer),
|
||||||
async_decode = decode_ptr]() mutable {
|
async_decode = decode_ptr]() mutable {
|
||||||
async_decode->decoded_data.resize_destructive(out_size);
|
async_decode->decoded_data.resize_destructive(out_size);
|
||||||
@@ -1426,18 +1446,16 @@ void TextureCache<P>::TickAsyncUnswizzle() {
|
|||||||
Image& image = slot_images[task.image_id];
|
Image& image = slot_images[task.image_id];
|
||||||
|
|
||||||
if (!task.initialized) {
|
if (!task.initialized) {
|
||||||
task.total_size = MapSizeBytes(image);
|
task.total_size = image.guest_size_bytes;
|
||||||
task.staging_buffer = runtime.UploadStagingBuffer(task.total_size, true);
|
task.staging_buffer = runtime.UploadStagingBuffer(task.total_size, true);
|
||||||
|
|
||||||
const auto& info = image.info;
|
const auto layout = FullUploadSwizzles(task.info);
|
||||||
const u32 bytes_per_block = BytesPerBlock(info.format);
|
const auto params =
|
||||||
const u32 width_blocks = Common::DivCeil(info.size.width, 4u);
|
VideoCommon::Accelerated::MakeBlockLinearSwizzle3DParams(layout.front(), task.info);
|
||||||
const u32 height_blocks = Common::DivCeil(info.size.height, 4u);
|
task.bytes_per_slice = params.slice_size;
|
||||||
|
task.chunked = task.info.block.depth == 0;
|
||||||
const u32 stride = width_blocks * bytes_per_block;
|
|
||||||
const u32 aligned_height = height_blocks;
|
|
||||||
task.bytes_per_slice = static_cast<size_t>(stride) * aligned_height;
|
|
||||||
task.last_submitted_offset = 0;
|
task.last_submitted_offset = 0;
|
||||||
|
task.slices_submitted = 0;
|
||||||
task.initialized = true;
|
task.initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1452,31 +1470,39 @@ void TextureCache<P>::TickAsyncUnswizzle() {
|
|||||||
if (copy_amount == 0) copy_amount = task.bytes_per_slice;
|
if (copy_amount == 0) copy_amount = task.bytes_per_slice;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu_memory->ReadBlock(image.gpu_addr + task.current_offset,
|
gpu_memory->ReadBlockUnsafe(image.gpu_addr + task.current_offset,
|
||||||
task.staging_buffer.mapped_span.data() + task.current_offset,
|
task.staging_buffer.mapped_span.data() + task.current_offset,
|
||||||
copy_amount);
|
copy_amount);
|
||||||
task.current_offset += copy_amount;
|
task.current_offset += copy_amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool is_final_batch = task.current_offset >= task.total_size;
|
const bool is_final_batch = task.current_offset >= task.total_size;
|
||||||
const size_t bytes_ready = task.current_offset - task.last_submitted_offset;
|
|
||||||
const u32 complete_slices = static_cast<u32>(bytes_ready / task.bytes_per_slice);
|
|
||||||
|
|
||||||
if (complete_slices >= swizzle_slices_per_batch || (is_final_batch && complete_slices > 0)) {
|
if (task.chunked) {
|
||||||
const u32 z_start = static_cast<u32>(task.last_submitted_offset / task.bytes_per_slice);
|
const size_t bytes_ready = task.current_offset - task.last_submitted_offset;
|
||||||
const u32 slices_to_process = (std::min)(complete_slices, swizzle_slices_per_batch);
|
const u32 complete_slices = static_cast<u32>(bytes_ready / task.bytes_per_slice);
|
||||||
const u32 z_count = (std::min)(slices_to_process, image.info.size.depth - z_start);
|
|
||||||
|
|
||||||
if (z_count > 0) {
|
if (complete_slices >= swizzle_slices_per_batch || (is_final_batch && complete_slices > 0)) {
|
||||||
const auto uploads = FullUploadSwizzles(task.info);
|
const u32 z_start = task.slices_submitted;
|
||||||
runtime.AccelerateImageUpload(image, task.staging_buffer, FixSmallVectorADL(uploads), z_start, z_count);
|
const u32 slices_to_process = (std::min)(complete_slices, swizzle_slices_per_batch);
|
||||||
task.last_submitted_offset += (static_cast<size_t>(z_count) * task.bytes_per_slice);
|
const u32 z_count = (std::min)(slices_to_process, image.info.size.depth - z_start);
|
||||||
|
|
||||||
|
if (z_count > 0) {
|
||||||
|
const auto uploads = FullUploadSwizzles(task.info);
|
||||||
|
runtime.AccelerateImageUpload(image, task.staging_buffer,
|
||||||
|
FixSmallVectorADL(uploads), z_start, z_count);
|
||||||
|
task.last_submitted_offset += static_cast<size_t>(z_count) * task.bytes_per_slice;
|
||||||
|
task.slices_submitted += z_count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else if (is_final_batch && task.slices_submitted == 0) {
|
||||||
|
const auto uploads = FullUploadSwizzles(task.info);
|
||||||
|
runtime.AccelerateImageUpload(image, task.staging_buffer, FixSmallVectorADL(uploads), 0,
|
||||||
|
image.info.size.depth);
|
||||||
|
task.slices_submitted = image.info.size.depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if complete
|
const bool all_slices_submitted = task.slices_submitted >= image.info.size.depth;
|
||||||
const u32 slices_submitted = static_cast<u32>(task.last_submitted_offset / task.bytes_per_slice);
|
|
||||||
const bool all_slices_submitted = slices_submitted >= image.info.size.depth;
|
|
||||||
|
|
||||||
if (is_final_batch && all_slices_submitted) {
|
if (is_final_batch && all_slices_submitted) {
|
||||||
runtime.FreeDeferredStagingBuffer(task.staging_buffer);
|
runtime.FreeDeferredStagingBuffer(task.staging_buffer);
|
||||||
|
|||||||
@@ -139,6 +139,8 @@ class TextureCache : public VideoCommon::ChannelSetupCaches<TextureCacheChannelI
|
|||||||
AsyncBuffer staging_buffer;
|
AsyncBuffer staging_buffer;
|
||||||
size_t last_submitted_offset = 0;
|
size_t last_submitted_offset = 0;
|
||||||
size_t bytes_per_slice;
|
size_t bytes_per_slice;
|
||||||
|
u32 slices_submitted = 0;
|
||||||
|
bool chunked = false;
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1219,6 +1219,11 @@ bool Device::GetSuitability(bool requires_swapchain) {
|
|||||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT;
|
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT;
|
||||||
SetNext(next, properties.transform_feedback);
|
SetNext(next, properties.transform_feedback);
|
||||||
}
|
}
|
||||||
|
if (extensions.vertex_attribute_divisor) {
|
||||||
|
properties.vertex_attribute_divisor.sType =
|
||||||
|
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT;
|
||||||
|
SetNext(next, properties.vertex_attribute_divisor);
|
||||||
|
}
|
||||||
if (extensions.maintenance5) {
|
if (extensions.maintenance5) {
|
||||||
properties.maintenance5.sType =
|
properties.maintenance5.sType =
|
||||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_PROPERTIES_KHR;
|
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_PROPERTIES_KHR;
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ VK_DEFINE_HANDLE(VmaAllocator)
|
|||||||
FEATURE(EXT, ProvokingVertex, PROVOKING_VERTEX, provoking_vertex) \
|
FEATURE(EXT, ProvokingVertex, PROVOKING_VERTEX, provoking_vertex) \
|
||||||
FEATURE(EXT, Robustness2, ROBUSTNESS_2, robustness2) \
|
FEATURE(EXT, Robustness2, ROBUSTNESS_2, robustness2) \
|
||||||
FEATURE(EXT, TransformFeedback, TRANSFORM_FEEDBACK, transform_feedback) \
|
FEATURE(EXT, TransformFeedback, TRANSFORM_FEEDBACK, transform_feedback) \
|
||||||
|
FEATURE(EXT, VertexAttributeDivisor, VERTEX_ATTRIBUTE_DIVISOR, vertex_attribute_divisor) \
|
||||||
FEATURE(EXT, VertexInputDynamicState, VERTEX_INPUT_DYNAMIC_STATE, vertex_input_dynamic_state) \
|
FEATURE(EXT, VertexInputDynamicState, VERTEX_INPUT_DYNAMIC_STATE, vertex_input_dynamic_state) \
|
||||||
FEATURE(KHR, Maintenance5, MAINTENANCE_5, maintenance5) \
|
FEATURE(KHR, Maintenance5, MAINTENANCE_5, maintenance5) \
|
||||||
FEATURE(KHR, Maintenance6, MAINTENANCE_6, maintenance6) \
|
FEATURE(KHR, Maintenance6, MAINTENANCE_6, maintenance6) \
|
||||||
@@ -92,7 +93,6 @@ VK_DEFINE_HANDLE(VmaAllocator)
|
|||||||
EXTENSION(EXT, SHADER_STENCIL_EXPORT, shader_stencil_export) \
|
EXTENSION(EXT, SHADER_STENCIL_EXPORT, shader_stencil_export) \
|
||||||
EXTENSION(EXT, SHADER_VIEWPORT_INDEX_LAYER, shader_viewport_index_layer) \
|
EXTENSION(EXT, SHADER_VIEWPORT_INDEX_LAYER, shader_viewport_index_layer) \
|
||||||
EXTENSION(EXT, TOOLING_INFO, tooling_info) \
|
EXTENSION(EXT, TOOLING_INFO, tooling_info) \
|
||||||
EXTENSION(EXT, VERTEX_ATTRIBUTE_DIVISOR, vertex_attribute_divisor) \
|
|
||||||
EXTENSION(KHR, CREATE_RENDERPASS_2, create_renderpass2) \
|
EXTENSION(KHR, CREATE_RENDERPASS_2, create_renderpass2) \
|
||||||
EXTENSION(KHR, DEPTH_STENCIL_RESOLVE, depth_stencil_resolve) \
|
EXTENSION(KHR, DEPTH_STENCIL_RESOLVE, depth_stencil_resolve) \
|
||||||
EXTENSION(KHR, DRAW_INDIRECT_COUNT, draw_indirect_count) \
|
EXTENSION(KHR, DRAW_INDIRECT_COUNT, draw_indirect_count) \
|
||||||
@@ -359,6 +359,7 @@ public:
|
|||||||
|
|
||||||
#define FN_MAX_LIMIT_LIST \
|
#define FN_MAX_LIMIT_LIST \
|
||||||
FN_MAX_LIMIT_ELEM(ComputeSharedMemorySize) \
|
FN_MAX_LIMIT_ELEM(ComputeSharedMemorySize) \
|
||||||
|
FN_MAX_LIMIT_ELEM(ComputeWorkGroupInvocations) \
|
||||||
FN_MAX_LIMIT_ELEM(PerStageDescriptorSampledImages) \
|
FN_MAX_LIMIT_ELEM(PerStageDescriptorSampledImages) \
|
||||||
FN_MAX_LIMIT_ELEM(PerStageResources) \
|
FN_MAX_LIMIT_ELEM(PerStageResources) \
|
||||||
FN_MAX_LIMIT_ELEM(DescriptorSetSamplers) \
|
FN_MAX_LIMIT_ELEM(DescriptorSetSamplers) \
|
||||||
@@ -689,6 +690,32 @@ FN_MAX_LIMIT_LIST
|
|||||||
return features.host_query_reset.hostQueryReset != VK_FALSE;
|
return features.host_query_reset.hostQueryReset != VK_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 GetMaxVertexAttribDivisor() const {
|
||||||
|
const u32 reported = properties.vertex_attribute_divisor.maxVertexAttribDivisor;
|
||||||
|
if (reported == 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return reported;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsVertexAttributeInstanceRateZeroDivisorSupported() const {
|
||||||
|
return features.vertex_attribute_divisor.vertexAttributeInstanceRateZeroDivisor == VK_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 GetVertexAttribDivisor(u32 frequency) const {
|
||||||
|
const u32 max_divisor = GetMaxVertexAttribDivisor();
|
||||||
|
if (frequency == 0) {
|
||||||
|
if (IsVertexAttributeInstanceRateZeroDivisorSupported()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return max_divisor;
|
||||||
|
}
|
||||||
|
if (frequency > max_divisor) {
|
||||||
|
return max_divisor;
|
||||||
|
}
|
||||||
|
return frequency;
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns true if the device supports VK_EXT_transform_feedback.
|
/// Returns true if the device supports VK_EXT_transform_feedback.
|
||||||
bool IsExtTransformFeedbackSupported() const {
|
bool IsExtTransformFeedbackSupported() const {
|
||||||
return extensions.transform_feedback;
|
return extensions.transform_feedback;
|
||||||
@@ -1189,6 +1216,7 @@ private:
|
|||||||
VkPhysicalDeviceDescriptorBufferPropertiesEXT descriptor_buffer{};
|
VkPhysicalDeviceDescriptorBufferPropertiesEXT descriptor_buffer{};
|
||||||
VkPhysicalDeviceSubgroupSizeControlProperties subgroup_size_control{};
|
VkPhysicalDeviceSubgroupSizeControlProperties subgroup_size_control{};
|
||||||
VkPhysicalDeviceTransformFeedbackPropertiesEXT transform_feedback{};
|
VkPhysicalDeviceTransformFeedbackPropertiesEXT transform_feedback{};
|
||||||
|
VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT vertex_attribute_divisor{};
|
||||||
VkPhysicalDeviceMaintenance5PropertiesKHR maintenance5{};
|
VkPhysicalDeviceMaintenance5PropertiesKHR maintenance5{};
|
||||||
VkPhysicalDeviceDepthStencilResolveProperties depth_stencil_resolve{};
|
VkPhysicalDeviceDepthStencilResolveProperties depth_stencil_resolve{};
|
||||||
VkPhysicalDeviceCustomBorderColorPropertiesEXT custom_border_color{};
|
VkPhysicalDeviceCustomBorderColorPropertiesEXT custom_border_color{};
|
||||||
|
|||||||
Reference in New Issue
Block a user