Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
path = third-party/plasma-wayland-protocols
url = https://github.com/KDE/plasma-wayland-protocols.git
branch = master
[submodule "third-party/pyrowave"]
path = third-party/pyrowave
url = https://github.com/Themaister/pyrowave.git

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
url = https://github.com/Themaister/pyrowave.git
url = https://github.com/Themaister/pyrowave.git
branch = master

branch = master
[submodule "third-party/Simple-Web-Server"]
path = third-party/Simple-Web-Server
url = https://github.com/LizardByte-infrastructure/Simple-Web-Server.git
Expand Down
1 change: 1 addition & 0 deletions cmake/compile_definitions/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ if(WIN32)
# add_nvenc_sdk_implementation: args = `target_name`, `sdk_version`, `sdk_include_dir`
function(add_nvenc_sdk_implementation target_name sdk_version sdk_include_dir)
add_library(${target_name} OBJECT ${NVENC_IMPLEMENTATION_SOURCES})
target_link_libraries(${target_name} PRIVATE sunshine_pyrowave)
target_include_directories(${target_name} BEFORE PRIVATE "${sdk_include_dir}")
target_compile_definitions(${target_name} PRIVATE
NVENC_FACTORY_SUFFIX=${sdk_version}
Expand Down
1 change: 1 addition & 0 deletions cmake/dependencies/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ include_directories(SYSTEM ${MINIUPNP_INCLUDE_DIRS})

# ffmpeg pre-compiled binaries
include("${CMAKE_MODULE_PATH}/dependencies/ffmpeg.cmake")
include("${CMAKE_MODULE_PATH}/dependencies/pyrowave.cmake")

# Opus
if(TARGET PkgConfig::SUNSHINE_BUNDLED_OPUS)
Expand Down
60 changes: 60 additions & 0 deletions cmake/dependencies/pyrowave.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Build the pinned PyroWave C API into Sunshine.
include_guard(GLOBAL)

# Build the codec and C API without exposing upstream options to Sunshine.
function(sunshine_add_pyrowave)
set(pyrowave_source_dir "${CMAKE_SOURCE_DIR}/third-party/pyrowave")
# Defer configuring Granite until the options below are set, including local source overrides.
CPMAddPackage(NAME pyrowave_granite DOWNLOAD_ONLY YES)

# Scope upstream options to the dependency build and use its precompiled shaders.
# cmake-lint: disable=C0103
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(GRANITE_SHARED OFF)
set(GRANITE_TOOLS OFF)
set(GRANITE_RENDERER OFF)
set(GRANITE_PLATFORM "null")
set(GRANITE_INSTALL_TARGETS OFF)
set(GRANITE_HIDDEN ON)
set(GRANITE_POSITION_INDEPENDENT ON)
set(GRANITE_SHIPPING ON)
set(GRANITE_FFMPEG OFF)
set(GRANITE_FFMPEG_VULKAN OFF)
set(GRANITE_SHADER_COMPILER_OPTIMIZE OFF)
set(GRANITE_VULKAN_SHADER_MANAGER_RUNTIME_COMPILER OFF)
set(GRANITE_VULKAN_SPIRV_CROSS OFF)
set(GRANITE_VULKAN_FOSSILIZE OFF)
set(GRANITE_VULKAN_SYSTEM_HANDLES OFF)
set(GRANITE_VULKAN_DXGI_INTEROP OFF)
set(GRANITE_RENDERDOC_CAPTURE OFF)
add_subdirectory("${pyrowave_granite_SOURCE_DIR}" "${pyrowave_granite_BINARY_DIR}" EXCLUDE_FROM_ALL)

# Keep Volk's function pointers distinct from the Vulkan loader used by FFmpeg.
target_compile_definitions(granite-volk-headers INTERFACE VOLK_NAMESPACE)
set_source_files_properties("${pyrowave_granite_SOURCE_DIR}/third_party/volk/volk.c"
TARGET_DIRECTORY granite-volk PROPERTIES LANGUAGE CXX)

set(PYROWAVE_DEVEL OFF)
set(PYROWAVE_UTILS OFF)
add_subdirectory("${pyrowave_source_dir}" "${CMAKE_BINARY_DIR}/third-party/pyrowave" EXCLUDE_FROM_ALL)

# Upstream exposes the C API only for standalone builds; add its wrapper here.
add_library(sunshine_pyrowave STATIC
"${pyrowave_source_dir}/pyrowave_c.cpp"
"${pyrowave_granite_SOURCE_DIR}/video/scaler.cpp")
target_include_directories(sunshine_pyrowave PRIVATE
"${pyrowave_source_dir}/shaders" "${pyrowave_granite_SOURCE_DIR}/video")
target_include_directories(sunshine_pyrowave SYSTEM INTERFACE
"${pyrowave_source_dir}"
"${pyrowave_granite_SOURCE_DIR}/third_party/khronos/vulkan-headers/include")
target_link_libraries(sunshine_pyrowave PRIVATE pyrowave granite-vulkan granite-math Threads::Threads)

# Clients use the vendored revision to diagnose bitstream compatibility.
execute_process(COMMAND git -C "${pyrowave_source_dir}" rev-parse --short=8 HEAD
OUTPUT_VARIABLE pyrowave_bitstream_id OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
target_compile_definitions(sunshine_pyrowave INTERFACE
SUNSHINE_PYROWAVE_BITSTREAM_ID="${pyrowave_bitstream_id}")
endfunction()

sunshine_add_pyrowave()
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES sunshine_pyrowave)
28 changes: 28 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2096,6 +2096,7 @@ consent prompt for directory ACLs, so the Web UI shows setup steps for correctin
<td colspan="2">
Percentage of error correcting packets per data packet in each video frame.
Set to <code>0</code> to disable forward error correction.
PyroWave protects only critical data when the client supports record framing.
@warning{Higher values can correct for more network packet loss,
but at the cost of increasing bandwidth usage.}
</td>
Expand Down Expand Up @@ -2252,6 +2253,33 @@ consent prompt for directory ACLs, so the Web UI shows setup steps for correctin
</tr>
</table>

### pyrowave

<table>
<tr>
<td>Description</td>
<td colspan="2">
Allows compatible clients to request PyroWave 8-bit or 10-bit 4:2:0 or 4:4:4 video streams.
Support is advertised based on encoder capabilities. HDR requires a supported capture backend
and HDR enabled on the host display and client.
Transport framing is negotiated with the client.
@warning{PyroWave consumes a significant amount of bandwidth. Not recommended unless on LAN and utilizing a hardwired connection.}
</td>
</tr>
<tr>
<td>Default</td>
<td colspan="2">@code{}
enabled
@endcode</td>
</tr>
<tr>
<td>Example</td>
<td colspan="2">@code{}
pyrowave = disabled
@endcode</td>
</tr>
</table>

### capture

<table>
Expand Down
11 changes: 11 additions & 0 deletions package-lock.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,14 @@ CPMDeclarePackage(Boost
URL_HASH SHA256=${BOOST_SHA256}
DOWNLOAD_ONLY YES
)

# Granite/PyroWave (no official releases/versioning, so the commit hash is tracked)
set(PYROWAVE_GRANITE_TAG fb178c8080d163419e8d20f10715c61c53c1ec9b)
CPMDeclarePackage(pyrowave_granite
NAME pyrowave_granite
GITHUB_REPOSITORY Themaister/Granite
GIT_TAG ${PYROWAVE_GRANITE_TAG}
GIT_SUBMODULES third_party/volk third_party/khronos/vulkan-headers
GIT_SUBMODULES_RECURSE OFF
DOWNLOAD_ONLY YES
)
16 changes: 16 additions & 0 deletions packaging/linux/flatpak/dev.lizardbyte.app.Sunshine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ modules:
- -DBUILD_WERROR=ON
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_CUDA_COMPILER=/app/cuda/bin/nvcc
- -DCPM_pyrowave_granite_SOURCE=/run/build/sunshine/third-party/pyrowave-granite
- -DFFMPEG_PREPARED_BINARIES=/app/ffmpeg
- -DGLAD_SKIP_PIP_INSTALL=ON
- -DSUNSHINE_ASSETS_DIR=share/sunshine
Expand Down Expand Up @@ -107,5 +108,20 @@ modules:
- type: git
url: "@GITHUB_CLONE_URL@"
commit: "@GITHUB_COMMIT@"
- type: git
url: https://github.com/Themaister/Granite.git
commit: "@PYROWAVE_GRANITE_TAG@"
disable-submodules: true
dest: third-party/pyrowave-granite
- type: git
url: https://github.com/zeux/volk.git
commit: 47cddf7ed97b94118a08aacb548a411188e016cc
disable-submodules: true
dest: third-party/pyrowave-granite/third_party/volk
- type: git
url: https://github.com/KhronosGroup/Vulkan-Headers.git
commit: 6802bb4733b63ed5efd3adb308a6c885ef180ea1
disable-submodules: true
dest: third-party/pyrowave-granite/third_party/khronos/vulkan-headers
- type: file
path: package-lock.json
2 changes: 2 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ namespace config {

0, // hevc_mode
0, // av1_mode
true, // pyrowave

2, // min_threads
{
Expand Down Expand Up @@ -1600,6 +1601,7 @@ namespace config {
int_f(vars, "qp", video.qp);
int_between_f(vars, "hevc_mode", video.hevc_mode, {0, 3});
int_between_f(vars, "av1_mode", video.av1_mode, {0, 3});
bool_f(vars, "pyrowave", video.pyrowave);
int_f(vars, "min_threads", video.min_threads);
string_f(vars, "sw_preset", video.sw.sw_preset);
if (!video.sw.sw_preset.empty()) {
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ namespace config {

int hevc_mode; ///< HEVC support mode advertised to clients.
int av1_mode; ///< AV1 support mode advertised to clients.
bool pyrowave; ///< Advertise successfully probed PyroWave profiles unless explicitly disabled.

int min_threads; ///< Minimum number of threads or slices for CPU encoding.

Expand Down
1 change: 1 addition & 0 deletions src/nvhttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,7 @@ namespace nvhttp {
if ((video::active_av1_mode == 4 || video::active_av1_mode == 5) && video::last_encoder_probe_supported_dynamic_range_yuv444_for_codec[2]) {
codec_mode_flags |= SCM_AV1_HIGH10_444;
}
codec_mode_flags |= video::active_pyrowave_profiles & video::pyrowave::scm_mask;
return codec_mode_flags;
}

Expand Down
Loading