mirror of
https://repo.dec05eba.com/gpu-screen-recorder
synced 2026-05-05 22:40:42 +09:00
Fix cursor capture in nvidia wayland, hdr, clear background immediately in window capture
This commit is contained in:
@@ -276,6 +276,7 @@ bool gsr_capture_base_setup_cuda_textures(gsr_capture_base *self, AVFrame *frame
|
||||
color_conversion_params.destination_textures[0] = self->target_textures[0];
|
||||
color_conversion_params.destination_textures[1] = self->target_textures[1];
|
||||
color_conversion_params.num_destination_textures = 2;
|
||||
color_conversion_params.load_external_image_shader = true;
|
||||
|
||||
if(gsr_color_conversion_init(&self->color_conversion, &color_conversion_params) != 0) {
|
||||
fprintf(stderr, "gsr error: gsr_capture_kms_setup_cuda_textures: failed to create color conversion\n");
|
||||
@@ -357,7 +358,7 @@ bool drm_create_codec_context(const char *card_path, AVCodecContext *video_codec
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cuda_create_codec_context(CUcontext cu_ctx, AVCodecContext *video_codec_context, int width, int height, CUstream *cuda_stream) {
|
||||
bool cuda_create_codec_context(CUcontext cu_ctx, AVCodecContext *video_codec_context, int width, int height, bool hdr, CUstream *cuda_stream) {
|
||||
AVBufferRef *device_ctx = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_CUDA);
|
||||
if(!device_ctx) {
|
||||
fprintf(stderr, "gsr error: cuda_create_codec_context failed: failed to create hardware device context\n");
|
||||
@@ -383,7 +384,7 @@ bool cuda_create_codec_context(CUcontext cu_ctx, AVCodecContext *video_codec_con
|
||||
AVHWFramesContext *hw_frame_context = (AVHWFramesContext*)frame_context->data;
|
||||
hw_frame_context->width = width;
|
||||
hw_frame_context->height = height;
|
||||
hw_frame_context->sw_format = AV_PIX_FMT_NV12;
|
||||
hw_frame_context->sw_format = hdr ? AV_PIX_FMT_P010LE : AV_PIX_FMT_NV12;
|
||||
hw_frame_context->format = video_codec_context->pix_fmt;
|
||||
hw_frame_context->device_ref = device_ctx;
|
||||
hw_frame_context->device_ctx = (AVHWDeviceContext*)device_ctx->data;
|
||||
|
||||
@@ -349,7 +349,7 @@ bool gsr_capture_kms_capture(gsr_capture_kms *self, AVFrame *frame, bool hdr, bo
|
||||
gsr_color_conversion_draw(&self->base.color_conversion, self->base.cursor_texture,
|
||||
cursor_pos, cursor_size,
|
||||
(vec2i){0, 0}, cursor_size,
|
||||
texture_rotation, false);
|
||||
texture_rotation, cursor_texture_is_external);
|
||||
}
|
||||
|
||||
self->base.egl->eglSwapBuffers(self->base.egl->egl_display, self->base.egl->egl_surface);
|
||||
|
||||
@@ -38,7 +38,7 @@ static int gsr_capture_kms_cuda_start(gsr_capture *cap, AVCodecContext *video_co
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!cuda_create_codec_context(cap_kms->cuda.cu_ctx, video_codec_context, video_codec_context->width, video_codec_context->height, &cap_kms->cuda_stream)) {
|
||||
if(!cuda_create_codec_context(cap_kms->cuda.cu_ctx, video_codec_context, video_codec_context->width, video_codec_context->height, cap_kms->params.hdr, &cap_kms->cuda_stream)) {
|
||||
gsr_capture_kms_cuda_stop(cap, video_codec_context);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ static int gsr_capture_nvfbc_start(gsr_capture *cap, AVCodecContext *video_codec
|
||||
frame->width = video_codec_context->width;
|
||||
frame->height = video_codec_context->height;
|
||||
|
||||
if(!cuda_create_codec_context(cap_nvfbc->cuda.cu_ctx, video_codec_context, video_codec_context->width, video_codec_context->height, &cap_nvfbc->cuda_stream))
|
||||
if(!cuda_create_codec_context(cap_nvfbc->cuda.cu_ctx, video_codec_context, video_codec_context->width, video_codec_context->height, false, &cap_nvfbc->cuda_stream))
|
||||
goto error_cleanup;
|
||||
|
||||
gsr_cuda_context cuda_context = {
|
||||
|
||||
@@ -117,6 +117,7 @@ int gsr_capture_xcomposite_start(gsr_capture_xcomposite *self, AVCodecContext *v
|
||||
frame->height = video_codec_context->height;
|
||||
|
||||
self->window_resize_timer = clock_get_monotonic_seconds();
|
||||
self->clear_next_frame = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ static int gsr_capture_xcomposite_cuda_start(gsr_capture *cap, AVCodecContext *v
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!cuda_create_codec_context(cap_xcomp->cuda.cu_ctx, video_codec_context, video_codec_context->width, video_codec_context->height, &cap_xcomp->cuda_stream)) {
|
||||
if(!cuda_create_codec_context(cap_xcomp->cuda.cu_ctx, video_codec_context, video_codec_context->width, video_codec_context->height, false, &cap_xcomp->cuda_stream)) {
|
||||
gsr_capture_xcomposite_cuda_stop(cap, video_codec_context);
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user