Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(win/nvenc): add split frame encoding option #3061

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
14 changes: 11 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,18 @@
path = third-party/nanors
url = https://github.com/sleepybishop/nanors.git
branch = master
[submodule "third-party/nv-codec-headers"]
path = third-party/nv-codec-headers
url = https://github.com/FFmpeg/nv-codec-headers
[submodule "third-party/nvenc-headers/1100"]
path = third-party/nvenc-headers/1100
url = https://github.com/FFmpeg/nv-codec-headers.git
branch = sdk/11.0
[submodule "third-party/nvenc-headers/1200"]
path = third-party/nvenc-headers/1200
url = https://github.com/FFmpeg/nv-codec-headers.git
branch = sdk/12.0
[submodule "third-party/nvenc-headers/1202"]
path = third-party/nvenc-headers/1202
url = https://github.com/FFmpeg/nv-codec-headers.git
branch = master
[submodule "third-party/nvapi-open-source-sdk"]
path = third-party/nvapi-open-source-sdk
url = https://github.com/LizardByte/nvapi-open-source-sdk
Expand Down
4 changes: 0 additions & 4 deletions cmake/compile_definitions/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ elseif(UNIX)
endif()
endif()

include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/third-party/nv-codec-headers/include")
file(GLOB NVENC_SOURCES CONFIGURE_DEPENDS "src/nvenc/*.cpp" "src/nvenc/*.h")
list(APPEND PLATFORM_TARGET_FILES ${NVENC_SOURCES})

configure_file("${CMAKE_SOURCE_DIR}/src/version.h.in" version.h @ONLY)
include_directories("${CMAKE_CURRENT_BINARY_DIR}") # required for importing version.h

Expand Down
8 changes: 7 additions & 1 deletion cmake/compile_definitions/windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ file(GLOB NVPREFS_FILES CONFIGURE_DEPENDS
"${CMAKE_SOURCE_DIR}/src/platform/windows/nvprefs/*.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/windows/nvprefs/*.h")

include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/third-party/nvenc-headers")
file(GLOB_RECURSE NVENC_SOURCES CONFIGURE_DEPENDS
"${CMAKE_SOURCE_DIR}/src/nvenc/*.h"
"${CMAKE_SOURCE_DIR}/src/nvenc/*.cpp")

# vigem
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include")

Expand Down Expand Up @@ -57,7 +62,8 @@ set(PLATFORM_TARGET_FILES
"${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include/ViGEm/Common.h"
"${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include/ViGEm/Util.h"
"${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/include/ViGEm/km/BusShared.h"
${NVPREFS_FILES})
${NVPREFS_FILES}
${NVENC_SOURCES})

set(OPENSSL_LIBRARIES
libssl.a
Expand Down
40 changes: 40 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,46 @@ editing the `conf` file in a text editor. Use the examples as reference.
</tr>
</table>

### [nvenc_split_encode](https://localhost:47990/config/#nvenc_split_encode)

<table>
<tr>
<td>Description</td>
<td colspan="2">
Split the encoding of each video frame over multiple NVENC hardware units.
Significantly reduces encoding latency with a marginal compression efficiency penalty.
This option is ignored if your GPU has a singular NVENC unit.
@note{This option only applies when using NVENC [encoder](#encoderhttpslocalhost47990configencoder).}
@note{Applies to Windows only.}
</td>
</tr>
<tr>
<td>Default</td>
<td colspan="2">@code{}
driver_decides
@endcode</td>
</tr>
<tr>
<td>Example</td>
<td colspan="2">@code{}
nvenc_split_encode = driver_decides
@endcode</td>
</tr>
<tr>
<td rowspan="3">Choices</td>
<td>disabled</td>
<td>Disabled</td>
</tr>
<tr>
<td>driver_decides</td>
<td>NVIDIA driver makes the decision whether to enable it</td>
</tr>
<tr>
<td>enabled</td>
<td>Enabled</td>
</tr>
</table>

### [nvenc_latency_over_power](https://localhost:47990/config/#nvenc_latency_over_power)

<table>
Expand Down
11 changes: 11 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ namespace config {
return nvenc::nvenc_two_pass::quarter_resolution;
}

nvenc::nvenc_split_frame_encoding
split_encode_from_view(const std::string_view &preset) {
using enum nvenc::nvenc_split_frame_encoding;
if (preset == "disabled") return disabled;
if (preset == "driver_decides") return driver_decides;
if (preset == "enabled") return force_enabled;
BOOST_LOG(warning) << "config: unknown nvenc_split_encode value: " << preset;
return driver_decides;
}

} // namespace nv

namespace amd {
Expand Down Expand Up @@ -960,6 +970,7 @@ namespace config {
bool_f(vars, "nvenc_spatial_aq", video.nv.adaptive_quantization);
generic_f(vars, "nvenc_twopass", video.nv.two_pass, nv::twopass_from_view);
bool_f(vars, "nvenc_h264_cavlc", video.nv.h264_cavlc);
generic_f(vars, "nvenc_split_encode", video.nv.split_frame_encoding, nv::split_encode_from_view);
bool_f(vars, "nvenc_realtime_hags", video.nv_realtime_hags);
bool_f(vars, "nvenc_opengl_vulkan_on_dxgi", video.nv_opengl_vulkan_on_dxgi);
bool_f(vars, "nvenc_latency_over_power", video.nv_sunshine_high_power_mode);
Expand Down
Loading
Loading