[gnome-remote-desktop] hwaccel-nvidia: Also return aligned size when creating NVENC session
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-remote-desktop] hwaccel-nvidia: Also return aligned size when creating NVENC session
- Date: Fri, 4 Mar 2022 18:25:36 +0000 (UTC)
commit 565776b157e2ba1571b5eadd482ec574936d5144
Author: Pascal Nowack <Pascal Nowack gmx de>
Date: Fri Feb 11 13:48:13 2022 +0100
hwaccel-nvidia: Also return aligned size when creating NVENC session
This allows the graphics pipeline to determine, whether a separate
render surface is needed or not.
src/grd-hwaccel-nvidia.c | 16 ++++++++--------
src/grd-hwaccel-nvidia.h | 2 ++
src/grd-rdp-graphics-pipeline.c | 6 ++++--
3 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/src/grd-hwaccel-nvidia.c b/src/grd-hwaccel-nvidia.c
index bbc53cae..4ea8f5e5 100644
--- a/src/grd-hwaccel-nvidia.c
+++ b/src/grd-hwaccel-nvidia.c
@@ -266,6 +266,8 @@ grd_hwaccel_nvidia_create_nvenc_session (GrdHwAccelNvidia *hwaccel_nvidia,
uint32_t *encode_session_id,
uint16_t surface_width,
uint16_t surface_height,
+ uint16_t *aligned_width,
+ uint16_t *aligned_height,
uint16_t refresh_rate)
{
NvEncEncodeSession *encode_session;
@@ -273,16 +275,14 @@ grd_hwaccel_nvidia_create_nvenc_session (GrdHwAccelNvidia *hwaccel_nvidia,
NV_ENC_INITIALIZE_PARAMS init_params = {0};
NV_ENC_CONFIG encode_config = {0};
NV_ENC_CREATE_BITSTREAM_BUFFER create_bitstream_buffer = {0};
- uint16_t aligned_width;
- uint16_t aligned_height;
- aligned_width = surface_width + (surface_width % 16 ? 16 - surface_width % 16 : 0);
- aligned_height = surface_height + (surface_height % 64 ? 64 - surface_height % 64 : 0);
+ *aligned_width = grd_get_aligned_size (surface_width, 16);
+ *aligned_height = grd_get_aligned_size (surface_height, 64);
*encode_session_id = get_next_free_encode_session_id (hwaccel_nvidia);
encode_session = g_malloc0 (sizeof (NvEncEncodeSession));
- encode_session->enc_width = aligned_width;
- encode_session->enc_height = aligned_height;
+ encode_session->enc_width = *aligned_width;
+ encode_session->enc_height = *aligned_height;
open_params.version = NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER;
open_params.deviceType = NV_ENC_DEVICE_TYPE_CUDA;
@@ -313,8 +313,8 @@ grd_hwaccel_nvidia_create_nvenc_session (GrdHwAccelNvidia *hwaccel_nvidia,
init_params.version = NV_ENC_INITIALIZE_PARAMS_VER;
init_params.encodeGUID = NV_ENC_CODEC_H264_GUID;
- init_params.encodeWidth = aligned_width;
- init_params.encodeHeight = aligned_height;
+ init_params.encodeWidth = *aligned_width;
+ init_params.encodeHeight = *aligned_height;
init_params.darWidth = surface_width;
init_params.darHeight = surface_height;
init_params.frameRateNum = refresh_rate;
diff --git a/src/grd-hwaccel-nvidia.h b/src/grd-hwaccel-nvidia.h
index f8a54c59..a5b4da71 100644
--- a/src/grd-hwaccel-nvidia.h
+++ b/src/grd-hwaccel-nvidia.h
@@ -80,6 +80,8 @@ gboolean grd_hwaccel_nvidia_create_nvenc_session (GrdHwAccelNvidia *hwaccel_nvid
uint32_t *encode_session_id,
uint16_t surface_width,
uint16_t surface_height,
+ uint16_t *aligned_width,
+ uint16_t *aligned_height,
uint16_t refresh_rate);
void grd_hwaccel_nvidia_free_nvenc_session (GrdHwAccelNvidia *hwaccel_nvidia,
diff --git a/src/grd-rdp-graphics-pipeline.c b/src/grd-rdp-graphics-pipeline.c
index 4cae800f..ba36fa33 100644
--- a/src/grd-rdp-graphics-pipeline.c
+++ b/src/grd-rdp-graphics-pipeline.c
@@ -131,6 +131,8 @@ grd_rdp_graphics_pipeline_create_surface (GrdRdpGraphicsPipeline *graphics_pipel
GfxSurfaceContext *surface_context;
HWAccelContext *hwaccel_context;
uint32_t encode_session_id;
+ uint16_t aligned_width;
+ uint16_t aligned_height;
surface_context = g_malloc0 (sizeof (GfxSurfaceContext));
@@ -149,8 +151,8 @@ grd_rdp_graphics_pipeline_create_surface (GrdRdpGraphicsPipeline *graphics_pipel
graphics_pipeline->hwaccel_nvidia &&
grd_hwaccel_nvidia_create_nvenc_session (graphics_pipeline->hwaccel_nvidia,
&encode_session_id,
- surface_width,
- surface_height,
+ surface_width, surface_height,
+ &aligned_width, &aligned_height,
rdp_surface->refresh_rate))
{
g_debug ("[RDP.RDPGFX] Creating NVENC session for surface %u", surface_id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]