Skip to content

Commit 9e93bb2

Browse files
committed
Merge branch 'master' into crct
2 parents 8f47190 + 0e6c41f commit 9e93bb2

32 files changed

+5386
-161
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@
1010
[submodule "third-party/miniupnp"]
1111
path = third-party/miniupnp
1212
url = https://github.com/miniupnp/miniupnp
13+
[submodule "third-party/nv-codec-headers"]
14+
path = third-party/nv-codec-headers
15+
url = https://github.com/FFmpeg/nv-codec-headers

CMakeLists.txt

+59-19
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@ project(Sunshine)
44

55
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
66

7-
add_subdirectory(third-party/Simple-Web-Server)
8-
9-
set(UPNPC_BUILD_SHARED OFF CACHE BOOL "no shared libraries")
10-
set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Don't build tests for miniupnpc")
11-
set(UPNPC_BUILD_SAMPLE OFF CACHE BOOL "Don't build samples for miniupnpc")
12-
set(UPNPC_NO_INSTALL ON CACHE BOOL "Don't install any libraries build for miniupnpc")
13-
add_subdirectory(third-party/miniupnp/miniupnpc)
14-
include_directories(third-party/miniupnp)
15-
167
if(WIN32)
178
# Ugly hack to compile with #include <qos2.h>
189
add_compile_definitions(
@@ -21,11 +12,21 @@ if(WIN32)
2112
QOS_NON_ADAPTIVE_FLOW=2)
2213
endif()
2314
add_subdirectory(third-party/moonlight-common-c/enet)
15+
add_subdirectory(third-party/Simple-Web-Server)
16+
17+
set(UPNPC_BUILD_SHARED OFF CACHE BOOL "no shared libraries")
18+
set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Don't build tests for miniupnpc")
19+
set(UPNPC_BUILD_SAMPLE OFF CACHE BOOL "Don't build samples for miniupnpc")
20+
set(UPNPC_NO_INSTALL ON CACHE BOOL "Don't install any libraries build for miniupnpc")
21+
add_subdirectory(third-party/miniupnp/miniupnpc)
22+
include_directories(third-party/miniupnp)
2423

2524
find_package(Threads REQUIRED)
2625
find_package(OpenSSL REQUIRED)
26+
set(Boost_USE_STATIC_LIBS ON)
27+
find_package(Boost COMPONENTS log filesystem REQUIRED)
2728

28-
list(APPEND SUNSHINE_COMPILE_OPTIONS -fPIC -Wall -Wno-missing-braces -Wno-maybe-uninitialized -Wno-sign-compare)
29+
list(APPEND SUNSHINE_COMPILE_OPTIONS -Wall -Wno-missing-braces -Wno-maybe-uninitialized -Wno-sign-compare)
2930

3031
if(WIN32)
3132
file(
@@ -105,12 +106,28 @@ else()
105106
option(SUNSHINE_ENABLE_DRM "Enable KMS grab if available" ON)
106107
option(SUNSHINE_ENABLE_X11 "Enable X11 grab if available" ON)
107108
option(SUNSHINE_ENABLE_WAYLAND "Enable building wayland specific code" ON)
109+
option(SUNSHINE_ENABLE_CUDA "Enable cuda specific code" ON)
108110

109111
if(${SUNSHINE_ENABLE_X11})
110112
find_package(X11)
111113
else()
112114
set(X11_FOUND OFF)
113115
endif()
116+
117+
set(CUDA_FOUND OFF)
118+
if(${SUNSHINE_ENABLE_CUDA})
119+
include(CheckLanguage)
120+
check_language(CUDA)
121+
122+
if(CMAKE_CUDA_COMPILER)
123+
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
124+
set(CMAKE_CUDA_ARCHITECTURES 35)
125+
endif()
126+
127+
set(CUDA_FOUND ON)
128+
enable_language(CUDA)
129+
endif()
130+
endif()
114131
if(${SUNSHINE_ENABLE_DRM})
115132
find_package(LIBDRM)
116133
find_package(LIBCAP)
@@ -131,6 +148,17 @@ else()
131148
include_directories(${X11_INCLUDE_DIR})
132149
list(APPEND PLATFORM_TARGET_FILES sunshine/platform/linux/x11grab.cpp)
133150
endif()
151+
152+
if(CUDA_FOUND)
153+
include_directories(third-party/nvfbc)
154+
list(APPEND PLATFORM_TARGET_FILES
155+
sunshine/platform/linux/cuda.cu
156+
sunshine/platform/linux/cuda.cpp
157+
third-party/nvfbc/NvFBC.h)
158+
159+
add_compile_definitions(SUNSHINE_BUILD_CUDA)
160+
endif()
161+
134162
if(LIBDRM_FOUND AND LIBCAP_FOUND)
135163
add_compile_definitions(SUNSHINE_BUILD_DRM)
136164
include_directories(${LIBDRM_INCLUDE_DIRS} ${LIBCAP_INCLUDE_DIRS})
@@ -180,14 +208,15 @@ else()
180208
sunshine/platform/linux/wlgrab.cpp
181209
sunshine/platform/linux/wayland.cpp)
182210
endif()
183-
if(NOT ${X11_FOUND} AND NOT (${LIBDRM_FOUND} AND ${LIBCAP_FOUND}) AND NOT ${WAYLAND_FOUND})
184-
message(FATAL_ERROR "Couldn't find either x11, wayland or (libdrm and libcap)")
211+
if(NOT ${X11_FOUND} AND NOT (${LIBDRM_FOUND} AND ${LIBCAP_FOUND}) AND NOT ${WAYLAND_FOUND} AND NOT ${})
212+
message(FATAL_ERROR "Couldn't find either x11, wayland, cuda or (libdrm and libcap)")
185213
endif()
186214

187215
list(APPEND PLATFORM_TARGET_FILES
188216
sunshine/platform/linux/publish.cpp
189217
sunshine/platform/linux/vaapi.h
190218
sunshine/platform/linux/vaapi.cpp
219+
sunshine/platform/linux/cuda.h
191220
sunshine/platform/linux/graphics.h
192221
sunshine/platform/linux/graphics.cpp
193222
sunshine/platform/linux/misc.h
@@ -212,6 +241,7 @@ else()
212241

213242
include_directories(
214243
/usr/include/libevdev-1.0
244+
third-party/nv-codec-headers/include
215245
third-party/glad/include)
216246

217247
if(NOT DEFINED SUNSHINE_EXECUTABLE_PATH)
@@ -221,11 +251,6 @@ else()
221251
configure_file(sunshine.service.in sunshine.service @ONLY)
222252
endif()
223253

224-
add_subdirectory(third-party/cbs)
225-
226-
set(Boost_USE_STATIC_LIBS ON)
227-
find_package(Boost COMPONENTS log filesystem REQUIRED)
228-
229254
set(SUNSHINE_TARGET_FILES
230255
third-party/moonlight-common-c/reedsolomon/rs.c
231256
third-party/moonlight-common-c/reedsolomon/rs.h
@@ -285,9 +310,11 @@ include_directories(
285310
${PLATFORM_INCLUDE_DIRS}
286311
)
287312

313+
add_subdirectory(third-party/cbs)
314+
288315
string(TOUPPER "x${CMAKE_BUILD_TYPE}" BUILD_TYPE)
289316
if("${BUILD_TYPE}" STREQUAL "XDEBUG")
290-
list(APPEND SUNSHINE_COMPILE_OPTIONS -O0 -pedantic -ggdb3)
317+
list(APPEND SUNSHINE_COMPILE_OPTIONS -O0 -ggdb3)
291318
if(WIN32)
292319
set_source_files_properties(sunshine/nvhttp.cpp PROPERTIES COMPILE_FLAGS -O2)
293320
endif()
@@ -323,6 +350,10 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
323350
${OPENSSL_LIBRARIES}
324351
${PLATFORM_LIBRARIES})
325352

353+
if (NOT WIN32)
354+
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES Boost::log)
355+
endif()
356+
326357
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_ASSETS_DIR="${SUNSHINE_ASSETS_DIR}")
327358
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_CONFIG_DIR="${SUNSHINE_CONFIG_DIR}")
328359
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_DEFAULT_DIR="${SUNSHINE_DEFAULT_DIR}")
@@ -331,4 +362,13 @@ target_link_libraries(sunshine ${SUNSHINE_EXTERNAL_LIBRARIES})
331362
target_compile_definitions(sunshine PUBLIC ${SUNSHINE_DEFINITIONS})
332363
set_target_properties(sunshine PROPERTIES CXX_STANDARD 17)
333364

334-
target_compile_options(sunshine PRIVATE ${SUNSHINE_COMPILE_OPTIONS})
365+
if(NOT DEFINED CMAKE_CUDA_STANDARD)
366+
set(CMAKE_CUDA_STANDARD 17)
367+
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
368+
endif()
369+
370+
foreach(flag IN LISTS SUNSHINE_COMPILE_OPTIONS)
371+
list(APPEND SUNSHINE_COMPILE_OPTIONS_CUDA "$<$<COMPILE_LANGUAGE:CUDA>:--compiler-options=${flag}>")
372+
endforeach()
373+
374+
target_compile_options(sunshine PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${SUNSHINE_COMPILE_OPTIONS}>;$<$<COMPILE_LANGUAGE:CUDA>:${SUNSHINE_COMPILE_OPTIONS_CUDA};-std=c++17>)

README.md

+31-12
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,47 @@ Sunshine is a Gamestream host for Moonlight
1313

1414
## Linux
1515

16+
If you do not wish to clutter your PC with development files, yet you want the very latest version...
17+
You can use these [build scripts](scripts/README.md)
18+
They make use of docker to handle building Sunshine automatically
19+
1620
### Requirements:
1721

1822
Ubuntu 20.04:
1923
Install the following:
20-
#### X11 Only
24+
25+
#### Common
26+
```
27+
sudo apt install cmake gcc-10 g++-10 libssl-dev libavdevice-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libpulse-dev libopus-dev libevdev-dev
28+
```
29+
#### X11
2130
```
22-
sudo apt install cmake gcc-10 g++-10 libssl-dev libavdevice-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libpulse-dev libopus-dev libxtst-dev libx11-dev libxrandr-dev libxfixes-dev libevdev-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev
31+
sudo apt install libxtst-dev libx11-dev libxrandr-dev libxfixes-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev
2332
```
2433

25-
#### X11 + KMS (Requires additional setup)
26-
KMS allows Sunshine to grab the monitor with lower latency then through X11
34+
#### KMS
35+
This requires additional [setup](README.md#Setup).
36+
```
37+
sudo apt install libdrm-dev libcap-dev
38+
```
2739

40+
#### Wayland
41+
This is for wlroots based compositores, such as Sway
2842
```
29-
sudo apt install cmake gcc-10 g++-10 libssl-dev libavdevice-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libpulse-dev libopus-dev libxtst-dev libx11-dev libxrandr-dev libxfixes-dev libevdev-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev libdrm-dev libcap-dev
43+
sudo apt install libwayland-dev
3044
```
3145

32-
### Compilation:
46+
#### Cuda + NvFBC
47+
This requires proprietary software
48+
On Ubuntu 20.04, the cuda compiler will fail since it's version is too old, it's recommended you compile the sources with the [build scripts](scripts/README.md)
49+
```
50+
sudo apt install nvidia-cuda-dev nvidia-cuda-toolkit
51+
```
3352

34-
#### X11 Only
35-
- `git clone https://github.com/loki-47-6F-64/sunshine.git --recurse-submodules`
36-
- `cd sunshine && mkdir build && cd build`
37-
- `cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DSUNSHINE_ENABLE_DRM=OFF ..`
38-
- `make -j ${nproc}`
53+
#### Warning:
54+
You might require ffmpeg version >= 4.3. Check the troubleshooting section for more information.
3955

40-
#### X11 + KMS
56+
### Compilation:
4157
- `git clone https://github.com/loki-47-6F-64/sunshine.git --recurse-submodules`
4258
- `cd sunshine && mkdir build && cd build`
4359
- `cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 ..`
@@ -88,6 +104,9 @@ It's necessary to allow Sunshine to use KMS
88104
- If you get "Error: Failed to create client: Daemon not running", ensure that your avahi-daemon is running:
89105
- `systemctl status avahi-daemon`
90106

107+
- If you use hardware acceleration on Linux using an Intel or an AMD GPU (with VAAPI), you will get tons of [graphical issues](https://github.com/loki-47-6F-64/sunshine/issues/228) if your ffmpeg version is < 4.3. If it is not available in your distribution's repositories, consider using a newer version of your distribution.
108+
- Ubuntu started to ship ffmpeg 4.3 starting with groovy (20.10). If you're using an older version, you could use [this PPA](https://launchpad.net/%7Esavoury1/+archive/ubuntu/ffmpeg4) instead of upgrading. **Using PPAs is dangerous and may break your system. Use it at your own risk.**
109+
91110
## Windows 10
92111

93112
### Requirements:

appveyor.yml

+18-15
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
1-
image:
2-
- Ubuntu2004
3-
- Visual Studio 2019
1+
services:
2+
- docker
43

54
environment:
65
matrix:
7-
- BUILD_TYPE: Debug
8-
- BUILD_TYPE: Release
6+
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004
7+
DOCKERFILE: Dockerfile-2004
8+
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004
9+
DOCKERFILE: Dockerfile-2104
10+
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004
11+
DOCKERFILE: Dockerfile-debian
12+
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
13+
BUILD_TYPE: Release
914

1015
install:
11-
- sh: sudo apt update --ignore-missing
12-
- sh: sudo apt install -y build-essential fakeroot gcc-10 g++-10 cmake libssl-dev libavdevice-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libpulse-dev libopus-dev libxtst-dev libx11-dev libxrandr-dev libxfixes-dev libevdev-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev libdrm-dev libcap-dev
1316
- cmd: C:\msys64\usr\bin\bash -lc "pacman --needed --noconfirm -S mingw-w64-x86_64-openssl mingw-w64-x86_64-cmake mingw-w64-x86_64-toolchain mingw-w64-x86_64-opus mingw-w64-x86_64-x265 mingw-w64-x86_64-boost git yasm nasm diffutils make"
1417

1518
before_build:
16-
- git submodule update --init --recursive
17-
- mkdir build
18-
- cd build
19+
- cmd: git submodule update --init --recursive
20+
- cmd: mkdir build
21+
- cmd: cd build
22+
- sh: cd scripts
23+
- sh: ./build-container.sh -f $DOCKERFILE
1924

2025
build_script:
2126
- cmd: set OLDPATH=%PATH%
2227
- cmd: set PATH=C:\msys64\mingw64\bin
23-
- sh: cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSUNSHINE_EXECUTABLE_PATH=sunshine -DSUNSHINE_ASSETS_DIR=/etc/sunshine ..
2428
- cmd: cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSUNSHINE_ASSETS_DIR=assets -G "MinGW Makefiles" ..
25-
- sh: make -j$(nproc)
2629
- cmd: mingw32-make -j2
2730
- cmd: set PATH=%OLDPATH%
31+
- sh: ./build-sunshine.sh -pu
2832

2933
after_build:
30-
- sh: ./gen-deb
3134
- cmd: Del ..\assets\apps_linux.json
3235
- cmd: 7z a Sunshine-Windows.zip ..\assets
3336
- cmd: 7z a Sunshine-Windows.zip sunshine.exe
@@ -37,5 +40,5 @@ after_build:
3740
- cmd: 7z a Sunshine-Windows.zip ..\tools\install-service.bat
3841
- cmd: 7z a Sunshine-Windows.zip ..\tools\uninstall-service.bat
3942
- cmd: appveyor PushArtifact Sunshine-Windows.zip
40-
- sh: appveyor PushArtifact package-deb/sunshine.deb
41-
- sh: appveyor PushArtifact sunshine.service
43+
- sh: appveyor PushArtifact sunshine-build/sunshine.deb
44+

assets/sunshine.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
# You can find the name of the audio sink using the following command:
141141
# !! Linux only !!
142142
# pacmd list-sinks | grep "name:" if running vanilla pulseaudio
143-
# pactl info | grep Source` if running pipewire
143+
# pPipewire: Use `pactl info | grep Source`. In some causes you'd need to use the `sink` device. Try `pactl info | grep Sink`, if _Source_ doesn't work
144144
# audio_sink = alsa_output.pci-0000_09_00.3.analog-stereo
145145
#
146146
# !! Windows only !!

gen-deb.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ Package: sunshine
3737
Architecture: amd64
3838
Maintainer: @loki
3939
Priority: optional
40-
Version: 0.10.2
41-
Depends: libssl1.1, libavdevice58, libboost-thread1.67.0 | libboost-thread1.71.0, libboost-filesystem1.67.0 | libboost-filesystem1.71.0, libboost-log1.67.0 | libboost-log1.71.0, libpulse0, libopus0, libxcb-shm0, libxcb-xfixes0, libxtst6, libevdev2, libdrm2, libcap2
40+
Version: 0.11.0
41+
Depends: libssl1.1, libavdevice58, libboost-thread1.67.0 | libboost-thread1.71.0 | libboost-thread1.74.0, libboost-filesystem1.67.0 | libboost-filesystem1.71.0 | libboost-filesystem1.74.0, libboost-log1.67.0 | libboost-log1.71.0 | libboost-log1.74.0, libpulse0, libopus0, libxcb-shm0, libxcb-xfixes0, libxtst6, libevdev2, libdrm2, libcap2
4242
Description: Gamestream host for Moonlight
4343
EOF
4444

scripts/Dockerfile-2004

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM ubuntu:20.04 AS sunshine-2004
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
ARG TZ="Europe/London"
5+
6+
RUN apt-get update -y && \
7+
apt-get install -y \
8+
git wget gcc-10 g++-10 build-essential cmake libssl-dev libavdevice-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libpulse-dev libopus-dev libxtst-dev libx11-dev libxrandr-dev libxfixes-dev libevdev-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev libdrm-dev libcap-dev libwayland-dev
9+
10+
RUN cp /usr/bin/gcc-10 /usr/bin/gcc && cp /usr/bin/g++-10 /usr/bin/gcc-10
11+
12+
RUN wget https://developer.download.nvidia.com/compute/cuda/11.4.2/local_installers/cuda_11.4.2_470.57.02_linux.run --progress=bar:force:noscroll -q --show-progress -O /root/cuda.run && chmod a+x /root/cuda.run
13+
RUN /root/cuda.run --silent --toolkit --toolkitpath=/usr --no-opengl-libs --no-man-page --no-drm && rm /root/cuda.run
14+
15+
COPY build-private.sh /root/build.sh
16+
17+
18+
ENTRYPOINT ["/root/build.sh"]

scripts/Dockerfile-2104

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM ubuntu:21.04 AS sunshine-2104
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
ARG TZ="Europe/London"
5+
6+
RUN apt-get update -y && \
7+
apt-get install -y \
8+
git build-essential cmake libssl-dev libavdevice-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libpulse-dev libopus-dev libxtst-dev libx11-dev libxrandr-dev libxfixes-dev libevdev-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev libdrm-dev libcap-dev libwayland-dev nvidia-cuda-dev nvidia-cuda-toolkit
9+
10+
COPY build-private.sh /root/build.sh
11+
12+
13+
ENTRYPOINT ["/root/build.sh"]

scripts/Dockerfile-debian

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM debian:bullseye AS sunshine-debian
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
ARG TZ="Europe/London"
5+
6+
RUN echo deb http://deb.debian.org/debian/ bullseye main contrib non-free | tee /etc/apt/sources.list.d/non-free.list
7+
RUN apt-get update -y && \
8+
apt-get install -y \
9+
git build-essential cmake libssl-dev libavdevice-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libpulse-dev libopus-dev libxtst-dev libx11-dev libxrandr-dev libxfixes-dev libevdev-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev libdrm-dev libcap-dev libwayland-dev nvidia-cuda-dev nvidia-cuda-toolkit
10+
11+
COPY build-private.sh /root/build.sh
12+
13+
14+
ENTRYPOINT ["/root/build.sh"]

0 commit comments

Comments
 (0)