Skip to content

Commit

Permalink
#1046 tweak to allow us to build against SDK v6 - tested on Linux only
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@11471 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Dec 22, 2015
1 parent bf18c35 commit 21c930d
Show file tree
Hide file tree
Showing 5 changed files with 2,438 additions and 12 deletions.
25 changes: 18 additions & 7 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,19 @@ def is_msvc():
WIN32_BUILD_LIB_PREFIX = os.environ.get("XPRA_WIN32_BUILD_LIB_PREFIX", "C:\\")
nvenc4_sdk = WIN32_BUILD_LIB_PREFIX + "nvenc_4.0.0_sdk"
nvenc5_sdk = WIN32_BUILD_LIB_PREFIX + "nvenc_5.0.1_sdk"
nvenc6_sdk = WIN32_BUILD_LIB_PREFIX + "nvidia_video_sdk_6.0.1"
nvapi_path = WIN32_BUILD_LIB_PREFIX + "NVAPI"
try:
import pycuda
except:
pycuda = None
nvenc4_ENABLED = pycuda and os.path.exists(nvenc4_sdk) and is_msvc()
nvenc5_ENABLED = pycuda and os.path.exists(nvenc5_sdk) and is_msvc()
nvenc6_ENABLED = pycuda and os.path.exists(nvenc6_sdk) and is_msvc()
else:
nvenc4_ENABLED = pkg_config_ok("--exists", "nvenc4")
nvenc5_ENABLED = pkg_config_ok("--exists", "nvenc5")
nvenc6_ENABLED = pkg_config_ok("--exists", "nvenc6")

csc_opencl_ENABLED = pkg_config_ok("--exists", "OpenCL") and check_pyopencl_AMD()
memoryview_ENABLED = sys.version>='2.7'
Expand All @@ -180,7 +183,7 @@ def is_msvc():

#allow some of these flags to be modified on the command line:
SWITCHES = ["enc_x264", "enc_x265",
"nvenc4", "nvenc5",
"nvenc4", "nvenc5", "nvenc6",
"vpx", "webp", "pillow",
"dec_avcodec2", "csc_swscale",
"csc_opencl", "csc_cython",
Expand Down Expand Up @@ -895,6 +898,7 @@ def pkgconfig(*pkgs_options, **ekw):
"xpra/codecs/vpx/constants.pxi",
"xpra/codecs/nvenc4/encoder.c",
"xpra/codecs/nvenc5/encoder.c",
"xpra/codecs/nvenc6/encoder.c",
"xpra/codecs/cuda_common/BGRA_to_NV12.fatbin",
"xpra/codecs/cuda_common/BGRA_to_U.fatbin",
"xpra/codecs/cuda_common/BGRA_to_V.fatbin",
Expand Down Expand Up @@ -1521,18 +1525,23 @@ def add_keywords(path_dirs=[], inc_dirs=[], lib_dirs=[], libs=[], noref=True, no
add_keywords([webp_bin_dir], [webp_include_dir],
[webp_lib_dir],
webp_lib_names, nocmt=True)
elif ("nvenc4" in pkgs_options[0]) or ("nvenc5" in pkgs_options[0]):
elif ("nvenc4" in pkgs_options[0]) or ("nvenc5" in pkgs_options[0]) or ("nvenc6" in pkgs_options[0]):
for x in ("pycuda", "pytools"):
if x not in external_includes:
external_includes.append(x)
if "nvenc4" in pkgs_options[0]:
nvenc_path = nvenc4_sdk
nvenc_include_dir = nvenc_path + "\\Samples\\nvEncodeApp\\inc"
nvenc_core_include_dir = nvenc_path + "\\Samples\\core\\include"
else:
elif "nvenc5" in pkgs_options[0]:
nvenc_path = nvenc5_sdk
nvenc_include_dir = nvenc_path + "\\Samples\\common\\inc"
nvenc_core_include_dir = nvenc_path + "\\Samples\\common\\inc" #FIXME!
else:
assert "nvenc6" in pkgs_options[0]
nvenc_path = nvenc6_sdk
nvenc_include_dir = nvenc_path + "\\Samples\\common\\inc"
nvenc_core_include_dir = nvenc_path + "\\Samples\\common\\inc" #FIXME!
#let's not use crazy paths, just copy the dll somewhere that makes sense:
nvenc_bin_dir = nvenc_path + "\\bin\\win32\\release"
nvenc_lib_names = [] #not linked against it, we use dlopen!
Expand Down Expand Up @@ -1934,14 +1943,15 @@ def cython_add(*args, **kwargs):

toggle_packages(nvenc4_ENABLED, "xpra.codecs.nvenc4")
toggle_packages(nvenc5_ENABLED, "xpra.codecs.nvenc5")
toggle_packages(nvenc4_ENABLED or nvenc5_ENABLED, "xpra.codecs.cuda_common", "xpra.codecs.nv_util")
if (nvenc4_ENABLED or nvenc5_ENABLED) and WIN32:
toggle_packages(nvenc6_ENABLED, "xpra.codecs.nvenc6")
toggle_packages(nvenc4_ENABLED or nvenc5_ENABLED or nvenc6_ENABLED, "xpra.codecs.cuda_common", "xpra.codecs.nv_util")
if (nvenc4_ENABLED or nvenc5_ENABLED or nvenc6_ENABLED) and WIN32:
cython_add(Extension("xpra.codecs.nvapi_version",
["xpra/codecs/nvapi_version.pyx"],
**pkgconfig("nvapi")
))

if nvenc4_ENABLED or nvenc5_ENABLED:
if nvenc4_ENABLED or nvenc5_ENABLED or nvenc6_ENABLED:
#find nvcc:
path_options = os.environ.get("PATH", "").split(os.path.pathsep)
if WIN32:
Expand Down Expand Up @@ -2047,7 +2057,8 @@ def cython_add(*args, **kwargs):
CUDA_BIN = "CUDA"
add_data_files(CUDA_BIN, ["xpra/codecs/cuda_common/%s.fatbin" % x for x in kernels])
for nvenc_version, _nvenc_version_enabled in {4 : nvenc4_ENABLED,
5 : nvenc5_ENABLED}.items():
5 : nvenc5_ENABLED,
6 : nvenc6_ENABLED}.items():
if not _nvenc_version_enabled:
continue
nvencmodule = "nvenc%s" % nvenc_version
Expand Down
6 changes: 3 additions & 3 deletions src/xpra/codecs/loader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# This file is part of Xpra.
# Copyright (C) 2010-2014 Antoine Martin <[email protected]>
# Copyright (C) 2010-2015 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

Expand All @@ -20,7 +20,7 @@

#these codecs may well not load because we
#do not require the libraries to be installed
NOWARN = ["nvenc4", "nvenc5", "opencl"]
NOWARN = ["nvenc4", "nvenc5", "nvenc6", "opencl"]

SELFTEST = os.environ.get("XPRA_CODEC_SELFTEST", "1")=="1"
FULL_SELFTEST = os.environ.get("XPRA_CODEC_FULL_SELFTEST", "0")=="1"
Expand Down Expand Up @@ -142,7 +142,7 @@ def load_codecs(encoders=True, decoders=True, csc=True):
codec_import_check("enc_x265", "x265 encoder", "xpra.codecs.enc_x265", "xpra.codecs.enc_x265.encoder", "Encoder")
add_codec_version("x265", "xpra.codecs.enc_x265.encoder")

for v in (4, 5):
for v in (4, 5, 6):
codec_import_check("nvenc%s" % v, "nvenc encoder", "xpra.codecs.nvenc%s" % v, "xpra.codecs.nvenc%s.encoder" % v, "Encoder")
add_codec_version("nvenc%s" % v, "xpra.codecs.nvenc%s.encoder" % v)

Expand Down
4 changes: 4 additions & 0 deletions src/xpra/codecs/nvenc6/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is part of Xpra.
# Copyright (C) 2015 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.
Loading

0 comments on commit 21c930d

Please sign in to comment.