Skip to content

Commit 8b9cd51

Browse files
committed
Merge branch 'master' of github.com:loki-47-6F-64/sunshine
2 parents 9f14b22 + e7cbfb3 commit 8b9cd51

22 files changed

+4893
-139
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

+56-21
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,12 +350,20 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
323350
${OPENSSL_LIBRARIES}
324351
${PLATFORM_LIBRARIES})
325352

353+
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:${SUNSHINE_COMPILE_OPTIONS}>")
354+
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-std=c++17>")
355+
add_compile_options("$<$<COMPILE_LANGUAGE:C>:${SUNSHINE_COMPILE_OPTIONS}>")
356+
357+
foreach(flag IN LISTS SUNSHINE_COMPILE_OPTIONS)
358+
add_compile_options($<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=${flag}>)
359+
endforeach()
360+
add_compile_options($<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-std=c++14>)
361+
add_compile_options($<$<COMPILE_LANGUAGE:CUDA>:-std=c++14>)
362+
326363
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_ASSETS_DIR="${SUNSHINE_ASSETS_DIR}")
327364
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_CONFIG_DIR="${SUNSHINE_CONFIG_DIR}")
328365
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_DEFAULT_DIR="${SUNSHINE_DEFAULT_DIR}")
329366
add_executable(sunshine ${SUNSHINE_TARGET_FILES})
330367
target_link_libraries(sunshine ${SUNSHINE_EXTERNAL_LIBRARIES})
331368
target_compile_definitions(sunshine PUBLIC ${SUNSHINE_DEFINITIONS})
332-
set_target_properties(sunshine PROPERTIES CXX_STANDARD 17)
333-
334-
target_compile_options(sunshine PRIVATE ${SUNSHINE_COMPILE_OPTIONS})
369+
# set_target_properties(sunshine PROPERTIES CXX_STANDARD 17)

README.md

+22-14
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,38 @@ Sunshine is a Gamestream host for Moonlight
1717

1818
Ubuntu 20.04:
1919
Install the following:
20-
#### X11 Only
20+
21+
#### Common
22+
```
23+
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
2124
```
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
25+
#### X11
26+
```
27+
sudo apt install libxtst-dev libx11-dev libxrandr-dev libxfixes-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev
2328
```
2429

25-
#### X11 + KMS (Requires additional setup)
26-
KMS allows Sunshine to grab the monitor with lower latency then through X11
30+
#### KMS
31+
This requires additional [setup](README.md#Setup).
32+
```
33+
sudo apt install libdrm-dev libcap-dev
34+
```
2735

36+
#### Wayland
37+
This is for wlroots based compositores, such as Sway
2838
```
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
39+
sudo apt install libwayland-dev
40+
```
41+
42+
#### Cuda + NvFBC
43+
This requires proprietary software
44+
```
45+
sudo apt install nvidia-cuda-dev nvidia-cuda-toolkit
3046
```
3147

3248
#### Warning:
3349
You might require ffmpeg version >= 4.3. Check the troubleshooting section for more information.
3450

3551
### Compilation:
36-
37-
#### X11 Only
38-
- `git clone https://github.com/loki-47-6F-64/sunshine.git --recurse-submodules`
39-
- `cd sunshine && mkdir build && cd build`
40-
- `cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DSUNSHINE_ENABLE_DRM=OFF ..`
41-
- `make -j ${nproc}`
42-
43-
#### X11 + KMS
4452
- `git clone https://github.com/loki-47-6F-64/sunshine.git --recurse-submodules`
4553
- `cd sunshine && mkdir build && cd build`
4654
- `cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 ..`
@@ -91,7 +99,7 @@ It's necessary to allow Sunshine to use KMS
9199
- If you get "Error: Failed to create client: Daemon not running", ensure that your avahi-daemon is running:
92100
- `systemctl status avahi-daemon`
93101

94-
- If you 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.
102+
- 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.
95103
- 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.**
96104

97105
## Windows 10

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ environment:
99

1010
install:
1111
- 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
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 nvidia-cuda-dev nvidia-cuda-toolkit
1313
- 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"
1414

1515
before_build:

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

sunshine/platform/common.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ class deinit_t {
141141

142142
struct img_t {
143143
public:
144+
img_t() = default;
145+
146+
img_t(img_t &&) = delete;
147+
img_t(const img_t &) = delete;
148+
img_t &operator=(img_t &&) = delete;
149+
img_t &operator=(const img_t &) = delete;
150+
144151
std::uint8_t *data {};
145152
std::int32_t width {};
146153
std::int32_t height {};
@@ -279,8 +286,8 @@ std::unique_ptr<audio_control_t> audio_control();
279286
*/
280287
std::shared_ptr<display_t> display(mem_type_e hwdevice_type, const std::string &display_name, int framerate);
281288

282-
// A list of names of displays accepted as display_name
283-
std::vector<std::string> display_names();
289+
// A list of names of displays accepted as display_name with the mem_type_e
290+
std::vector<std::string> display_names(mem_type_e hwdevice_type);
284291

285292
input_t input();
286293
void move_mouse(input_t &input, int deltaX, int deltaY);

0 commit comments

Comments
 (0)