mirror of
https://repo.dec05eba.com/gpu-screen-recorder
synced 2026-05-07 15:19:55 +09:00
Attempt to fix nvenc query on old nvidia cards (driver version 470)
This commit is contained in:
@@ -281,6 +281,7 @@ static bool get_supported_video_codecs(const NV_ENCODE_API_FUNCTION_LIST *functi
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define NVENCAPI_VERSION_470 (11 | (1 << 24))
|
#define NVENCAPI_VERSION_470 (11 | (1 << 24))
|
||||||
|
#define NVENCAPI_STRUCT_VERSION_470(ver) ((uint32_t)NVENCAPI_VERSION_470 | ((ver)<<16) | (0x7 << 28))
|
||||||
|
|
||||||
static gsr_supported_video_codecs gsr_video_encoder_cuda_get_supported_codecs(gsr_video_encoder *encoder, bool cleanup) {
|
static gsr_supported_video_codecs gsr_video_encoder_cuda_get_supported_codecs(gsr_video_encoder *encoder, bool cleanup) {
|
||||||
(void)encoder;
|
(void)encoder;
|
||||||
@@ -309,14 +310,17 @@ static gsr_supported_video_codecs gsr_video_encoder_cuda_get_supported_codecs(gs
|
|||||||
NV_ENCODE_API_FUNCTION_LIST function_list;
|
NV_ENCODE_API_FUNCTION_LIST function_list;
|
||||||
memset(&function_list, 0, sizeof(function_list));
|
memset(&function_list, 0, sizeof(function_list));
|
||||||
function_list.version = NV_ENCODE_API_FUNCTION_LIST_VER;
|
function_list.version = NV_ENCODE_API_FUNCTION_LIST_VER;
|
||||||
|
if(nvEncodeAPICreateInstance(&function_list) != NV_ENC_SUCCESS) {
|
||||||
|
function_list.version = NVENCAPI_STRUCT_VERSION_470(2);
|
||||||
if(nvEncodeAPICreateInstance(&function_list) != NV_ENC_SUCCESS) {
|
if(nvEncodeAPICreateInstance(&function_list) != NV_ENC_SUCCESS) {
|
||||||
fprintf(stderr, "gsr error: gsr_video_encoder_cuda_get_supported_codecs: nvEncodeAPICreateInstance failed\n");
|
fprintf(stderr, "gsr error: gsr_video_encoder_cuda_get_supported_codecs: nvEncodeAPICreateInstance failed\n");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS params;
|
NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS params;
|
||||||
memset(¶ms, 0, sizeof(params));
|
memset(¶ms, 0, sizeof(params));
|
||||||
params.version = NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER;
|
params.version = NVENCAPI_STRUCT_VERSION(1);
|
||||||
params.deviceType = NV_ENC_DEVICE_TYPE_CUDA;
|
params.deviceType = NV_ENC_DEVICE_TYPE_CUDA;
|
||||||
params.device = cuda.cu_ctx;
|
params.device = cuda.cu_ctx;
|
||||||
params.apiVersion = NVENCAPI_VERSION;
|
params.apiVersion = NVENCAPI_VERSION;
|
||||||
@@ -325,6 +329,7 @@ static gsr_supported_video_codecs gsr_video_encoder_cuda_get_supported_codecs(gs
|
|||||||
if(function_list.nvEncOpenEncodeSessionEx(¶ms, &nvenc_encoder) != NV_ENC_SUCCESS) {
|
if(function_list.nvEncOpenEncodeSessionEx(¶ms, &nvenc_encoder) != NV_ENC_SUCCESS) {
|
||||||
// Old nvidia gpus dont support the new nvenc api (which is required for av1).
|
// Old nvidia gpus dont support the new nvenc api (which is required for av1).
|
||||||
// In such cases fallback to old api version if possible and try again.
|
// In such cases fallback to old api version if possible and try again.
|
||||||
|
params.version = NVENCAPI_STRUCT_VERSION_470(1);
|
||||||
params.apiVersion = NVENCAPI_VERSION_470;
|
params.apiVersion = NVENCAPI_VERSION_470;
|
||||||
if(function_list.nvEncOpenEncodeSessionEx(¶ms, &nvenc_encoder) != NV_ENC_SUCCESS) {
|
if(function_list.nvEncOpenEncodeSessionEx(¶ms, &nvenc_encoder) != NV_ENC_SUCCESS) {
|
||||||
fprintf(stderr, "gsr error: gsr_video_encoder_cuda_get_supported_codecs: nvEncOpenEncodeSessionEx failed\n");
|
fprintf(stderr, "gsr error: gsr_video_encoder_cuda_get_supported_codecs: nvEncOpenEncodeSessionEx failed\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user