Skip to content

Commit

Permalink
VCEEncの更新を反映。
Browse files Browse the repository at this point in the history
  • Loading branch information
rigaya committed Oct 29, 2024
1 parent 5eb1ac8 commit bb95921
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 7 deletions.
49 changes: 49 additions & 0 deletions NVEncCore/rgy_device_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,19 @@ RGY_ERR DeviceVulkan::Init(int adapterID, const std::vector<const char*> &extIns
RGY_ERR res = RGY_ERR_NONE;
m_log = log;
m_logTryMode = logTryMode;
AddMessage(RGY_LOG_DEBUG, _T("Init Vulkan device...\n"));

if (m_vk.init() != 0) {
AddMessage(RGY_LOG_ERROR, _T("LoadFunctionsTable() failed - check if the proper Vulkan SDK is installed\n"));
return RGY_ERR_NULL_PTR;
}
AddMessage(RGY_LOG_DEBUG, _T("LoadFunctionsTable() success.\n"));

if ((res = CreateInstance(extInstance)) != RGY_ERR_NONE) {
AddMessage(RGY_LOG_ERROR, _T("CreateInstance() failed\n"));
return res;
}
AddMessage(RGY_LOG_DEBUG, _T("CreateInstance() success.\n"));

#if defined(_DEBUG) && defined(ENABLE_VALIDATION)
const bool bDebug = true;
Expand All @@ -99,17 +102,20 @@ RGY_ERR DeviceVulkan::Init(int adapterID, const std::vector<const char*> &extIns
AddMessage(RGY_LOG_ERROR, _T("LoadInstanceFunctionsTableExt() failed - check if the proper Vulkan SDK is installed\n"));
return RGY_ERR_NULL_PTR;
}
AddMessage(RGY_LOG_DEBUG, _T("LoadInstanceFunctionsTableExt() success.\n"));

// load instance based functions
if (CreateDeviceAndFindQueues(adapterID, extDevice) != 0) {
AddMessage(RGY_LOG_ERROR, _T("CreateDeviceAndFindQueues() failed\n"));
return RGY_ERR_NULL_PTR;
}
AddMessage(RGY_LOG_DEBUG, _T("CreateDeviceAndFindQueues() success.\n"));

if (m_vk.load(m_vkDevice) != 0) {
AddMessage(RGY_LOG_ERROR, _T("LoadDeviceFunctionsTableExt() failed - check if the proper Vulkan SDK is installed\n"));
return RGY_ERR_NULL_PTR;
}
AddMessage(RGY_LOG_DEBUG, _T("LoadDeviceFunctionsTableExt() success.\n"));

return RGY_ERR_NONE;
}
Expand Down Expand Up @@ -387,4 +393,47 @@ void DeviceVulkan::AddMessage(RGYLogLevel log_level, const TCHAR *format, ...) {
va_end(args);
AddMessage(log_level, buffer);
}

#if defined(_WIN32) || defined(_WIN64)
HANDLE DeviceVulkan::getMemHandle(VkDeviceMemory memory) {
HANDLE handle = NULL;
VkMemoryGetWin32HandleInfoKHR win32_handle_info{};
win32_handle_info.sType = VK_STRUCTURE_TYPE_MEMORY_GET_WIN32_HANDLE_INFO_KHR;
win32_handle_info.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR;
win32_handle_info.memory = memory;
GetVulkan()->vkGetMemoryWin32HandleKHR(m_device, &win32_handle_info, &handle);
return handle;
}

HANDLE DeviceVulkan::getSemaphoreHandle(VkSemaphore &sempahore) {
HANDLE handle = NULL;
VkSemaphoreGetWin32HandleInfoKHR win32_handle_info{};
win32_handle_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_GET_WIN32_HANDLE_INFO_KHR;
win32_handle_info.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT;
win32_handle_info.semaphore = sempahore;
GetVulkan()->vkGetSemaphoreWin32HandleKHR(m_device, &win32_handle_info, &handle);
return handle;
}
#else
int DeviceVulkan::getMemHandle(VkDeviceMemory memory) {
int fd = 0;
VkMemoryGetFdInfoKHR fd_info{};
fd_info.sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR;
fd_info.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;
fd_info.memory = memory;
GetVulkan()->vkGetMemoryFdKHR(m_vkDevice, &fd_info, &fd);
return fd;
}

int DeviceVulkan::getSemaphoreHandle(VkSemaphore &sempahore) {
int fd = 0;
VkSemaphoreGetFdInfoKHR fd_info{};
fd_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR;
fd_info.handleType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;
fd_info.semaphore = sempahore;
GetVulkan()->vkGetSemaphoreFdKHR(m_vkDevice, &fd_info, &fd);
return fd;
}
#endif

#endif
11 changes: 11 additions & 0 deletions NVEncCore/rgy_device_vulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include "rgy_log.h"
#include "rgy_err.h"

class DeviceVulkan;

#if ENABLE_VULKAN
#include "rgy_vulkan.h"

Expand Down Expand Up @@ -74,6 +76,14 @@ class DeviceVulkan {
VkPhysicalDevice GetPhysicalDevice() { return m_vkPhysicalDevice; }
VkInstance GetInstance() { return m_vkInstance; }

#if defined(_WIN32) || defined(_WIN64)
HANDLE getMemHandle(VkDeviceMemory memory);
HANDLE getSemaphoreHandle(VkSemaphore &sempahore);
#else
int getMemHandle(VkDeviceMemory memory);
int getSemaphoreHandle(VkSemaphore &sempahore);
#endif

protected:
void AddMessage(RGYLogLevel log_level, const tstring &str);
void AddMessage(RGYLogLevel log_level, const TCHAR *format, ...);
Expand Down Expand Up @@ -105,6 +115,7 @@ class DeviceVulkan {
std::shared_ptr<RGYLog> m_log;
bool m_logTryMode;
};

#endif //#if ENABLE_VULKAN

#endif //#if __RGY_DEVICE_VULKAN_H__
2 changes: 1 addition & 1 deletion NVEncCore/rgy_prm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ RGY_VPP_RESIZE_TYPE getVppResizeType(RGY_VPP_RESIZE_ALGO resize) {
} else if (resize < RGY_VPP_RESIZE_NGX_MAX) {
return RGY_VPP_RESIZE_TYPE_NGX;
#endif
#if ((ENCODER_NVENC || ENCODER_QSV) && (ENABLE_VPP_FILTER_LIBPLACEBO || FOR_AUO)) || CUFILTERS || CLFILTERS_AUF
#if ((ENCODER_NVENC || ENCODER_QSV || ENCODER_VCEENC) && (ENABLE_VPP_FILTER_LIBPLACEBO || FOR_AUO)) || CUFILTERS || CLFILTERS_AUF
} else if (resize < RGY_VPP_RESIZE_LIBPLACEBO_MAX) {
return RGY_VPP_RESIZE_TYPE_LIBPLACEBO;
#endif
Expand Down
12 changes: 6 additions & 6 deletions NVEncCore/rgy_prm.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static const int RGY_AUDIO_QUALITY_DEFAULT = 0;
#define ENABLE_VPP_FILTER_TWEAK (ENCODER_QSV || ENCODER_NVENC || ENCODER_VCEENC || ENCODER_MPP || CLFILTERS_AUF)
#define ENABLE_VPP_FILTER_OVERLAY (ENCODER_QSV || ENCODER_NVENC || ENCODER_VCEENC || ENCODER_MPP)
#define ENABLE_VPP_FILTER_DEBAND (ENCODER_QSV || ENCODER_NVENC || ENCODER_VCEENC || ENCODER_MPP || CLFILTERS_AUF)
#define ENABLE_VPP_FILTER_LIBPLACEBO (ENABLE_LIBPLACEBO && (ENCODER_QSV || ENCODER_NVENC))
#define ENABLE_VPP_FILTER_LIBPLACEBO (ENABLE_LIBPLACEBO && (ENCODER_QSV || ENCODER_NVENC || ENCODER_VCEENC))
#define ENABLE_VPP_FILTER_FRUC ( ENCODER_NVENC)
#define ENABLE_VPP_FILTER_DELOGO_MULTIADD ( ENCODER_NVENC)
#define ENABLE_VPP_ORDER (CLFILTERS_AUF)
Expand Down Expand Up @@ -544,7 +544,7 @@ enum RGY_VPP_RESIZE_ALGO {
RGY_VPP_RESIZE_NGX_VSR,
RGY_VPP_RESIZE_NGX_MAX,
#endif
#if ((ENCODER_NVENC || ENCODER_QSV) && (ENABLE_VPP_FILTER_LIBPLACEBO || FOR_AUO)) || CUFILTERS || CLFILTERS_AUF
#if ((ENCODER_NVENC || ENCODER_QSV || ENCODER_VCEENC) && (ENABLE_VPP_FILTER_LIBPLACEBO || FOR_AUO)) || CUFILTERS || CLFILTERS_AUF
RGY_VPP_RESIZE_LIBPLACEBO_SPLINE16,
RGY_VPP_RESIZE_LIBPLACEBO_SPLINE36,
RGY_VPP_RESIZE_LIBPLACEBO_SPLINE64,
Expand Down Expand Up @@ -604,7 +604,7 @@ enum RGY_VPP_RESIZE_TYPE {
RGY_VPP_RESIZE_TYPE_NVVFX,
RGY_VPP_RESIZE_TYPE_NGX,
#endif
#if ((ENCODER_NVENC || ENCODER_QSV) && (ENABLE_VPP_FILTER_LIBPLACEBO || FOR_AUO)) || CUFILTERS || CLFILTERS_AUF
#if ((ENCODER_NVENC || ENCODER_QSV || ENCODER_VCEENC) && (ENABLE_VPP_FILTER_LIBPLACEBO || FOR_AUO)) || CUFILTERS || CLFILTERS_AUF
RGY_VPP_RESIZE_TYPE_LIBPLACEBO,
#endif
#if ENCODER_VCEENC
Expand Down Expand Up @@ -647,7 +647,7 @@ static bool isNgxResizeFiter(const RGY_VPP_RESIZE_ALGO interp) {
}

static bool isLibplaceboResizeFiter(const RGY_VPP_RESIZE_ALGO interp) {
#if ((ENCODER_NVENC || ENCODER_QSV) && (ENABLE_VPP_FILTER_LIBPLACEBO || FOR_AUO)) || CUFILTERS || CLFILTERS_AUF
#if ((ENCODER_NVENC || ENCODER_QSV || ENCODER_VCEENC) && (ENABLE_VPP_FILTER_LIBPLACEBO || FOR_AUO)) || CUFILTERS || CLFILTERS_AUF
return getVppResizeType(interp) == RGY_VPP_RESIZE_TYPE_LIBPLACEBO;
#else
UNREFERENCED_PARAMETER(interp);
Expand Down Expand Up @@ -706,7 +706,7 @@ const CX_DESC list_vpp_resize[] = {
#if ENCODER_NVENC && (!defined(_M_IX86) || FOR_AUO) || CUFILTERS || CLFILTERS_AUF
{ _T("ngx-vsr"), RGY_VPP_RESIZE_NGX_VSR },
#endif
#if ((ENCODER_NVENC || ENCODER_QSV) && (ENABLE_VPP_FILTER_LIBPLACEBO || FOR_AUO)) || CUFILTERS || CLFILTERS_AUF
#if ((ENCODER_NVENC || ENCODER_QSV || ENCODER_VCEENC) && (ENABLE_VPP_FILTER_LIBPLACEBO || FOR_AUO)) || CUFILTERS || CLFILTERS_AUF
{ _T("libplacebo-spline16"), RGY_VPP_RESIZE_LIBPLACEBO_SPLINE16 },
{ _T("libplacebo-spline36"), RGY_VPP_RESIZE_LIBPLACEBO_SPLINE36 },
{ _T("libplacebo-spline64"), RGY_VPP_RESIZE_LIBPLACEBO_SPLINE64 },
Expand Down Expand Up @@ -787,7 +787,7 @@ const CX_DESC list_vpp_resize_help[] = {
#if ENCODER_NVENC && (!defined(_M_IX86) || FOR_AUO) || CUFILTERS || CLFILTERS_AUF
{ _T("ngx-vsr"), RGY_VPP_RESIZE_NGX_VSR },
#endif
#if ((ENCODER_NVENC || ENCODER_QSV) && (ENABLE_VPP_FILTER_LIBPLACEBO || FOR_AUO)) || CUFILTERS || CLFILTERS_AUF
#if ((ENCODER_NVENC || ENCODER_QSV || ENCODER_VCEENC) && (ENABLE_VPP_FILTER_LIBPLACEBO || FOR_AUO)) || CUFILTERS || CLFILTERS_AUF
{ _T("libplacebo-spline16"), RGY_VPP_RESIZE_LIBPLACEBO_SPLINE16 },
{ _T("libplacebo-spline36"), RGY_VPP_RESIZE_LIBPLACEBO_SPLINE36 },
{ _T("libplacebo-spline64"), RGY_VPP_RESIZE_LIBPLACEBO_SPLINE64 },
Expand Down

0 comments on commit bb95921

Please sign in to comment.