[gnome-remote-desktop] rdp/rdpgfx: Allow GFX surfaces to have their own aligned size
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-remote-desktop] rdp/rdpgfx: Allow GFX surfaces to have their own aligned size
- Date: Fri, 4 Mar 2022 18:25:36 +0000 (UTC)
commit d69cdb10b03758fb0d6a79f28ab9f0400378e6e2
Author: Pascal Nowack <Pascal Nowack gmx de>
Date: Fri Feb 11 12:42:19 2022 +0100
rdp/rdpgfx: Allow GFX surfaces to have their own aligned size
This is necessary in order to use a separate surface to render frame
content to later.
These separate render surfaces are necessary to be able to satisfy both
the AVC requirements of the RDPGFX protocol, but also the restrictions
on the encoder side.
src/grd-rdp-gfx-surface.c | 42 +++++++++++++++++++++++++++++++++--------
src/grd-rdp-gfx-surface.h | 30 +++++++++++++++++++++++++----
src/grd-rdp-graphics-pipeline.c | 35 ++++++++++++++++++++--------------
3 files changed, 81 insertions(+), 26 deletions(-)
---
diff --git a/src/grd-rdp-gfx-surface.c b/src/grd-rdp-gfx-surface.c
index de3cd0c7..73b8200c 100644
--- a/src/grd-rdp-gfx-surface.c
+++ b/src/grd-rdp-gfx-surface.c
@@ -29,6 +29,7 @@ struct _GrdRdpGfxSurface
GObject parent;
GrdRdpGraphicsPipeline *graphics_pipeline;
+ GrdRdpGfxSurfaceFlag flags;
GrdRdpSurface *rdp_surface;
gboolean created;
@@ -36,6 +37,9 @@ struct _GrdRdpGfxSurface
uint32_t codec_context_id;
uint32_t serial;
+ uint16_t width;
+ uint16_t height;
+
GrdRdpGfxFrameController *frame_controller;
};
@@ -65,6 +69,18 @@ grd_rdp_gfx_surface_get_rdp_surface (GrdRdpGfxSurface *gfx_surface)
return gfx_surface->rdp_surface;
}
+uint16_t
+grd_rdp_gfx_surface_get_width (GrdRdpGfxSurface *gfx_surface)
+{
+ return gfx_surface->width;
+}
+
+uint16_t
+grd_rdp_gfx_surface_get_height (GrdRdpGfxSurface *gfx_surface)
+{
+ return gfx_surface->height;
+}
+
GrdRdpGfxFrameController *
grd_rdp_gfx_surface_get_frame_controller (GrdRdpGfxSurface *gfx_surface)
{
@@ -81,23 +97,33 @@ grd_rdp_gfx_surface_attach_frame_controller (GrdRdpGfxSurface *gfx_surfa
}
GrdRdpGfxSurface *
-grd_rdp_gfx_surface_new (GrdRdpGraphicsPipeline *graphics_pipeline,
- GrdRdpSurface *rdp_surface,
- uint16_t surface_id,
- uint32_t serial)
+grd_rdp_gfx_surface_new (GrdRdpGraphicsPipeline *graphics_pipeline,
+ const GrdRdpGfxSurfaceDescriptor *surface_descriptor)
{
GrdRdpGfxSurface *gfx_surface;
gfx_surface = g_object_new (GRD_TYPE_RDP_GFX_SURFACE, NULL);
gfx_surface->graphics_pipeline = graphics_pipeline;
- gfx_surface->rdp_surface = rdp_surface;
- gfx_surface->surface_id = surface_id;
- gfx_surface->serial = serial;
+ gfx_surface->flags = surface_descriptor->flags;
+ gfx_surface->rdp_surface = surface_descriptor->rdp_surface;
+ gfx_surface->surface_id = surface_descriptor->surface_id;
+ gfx_surface->serial = surface_descriptor->serial;
/*
* Use the same id for the codec context as for the surface
* (only relevant for RDPGFX_WIRE_TO_SURFACE_PDU_2 PDUs)
*/
- gfx_surface->codec_context_id = surface_id;
+ gfx_surface->codec_context_id = surface_descriptor->surface_id;
+
+ if (surface_descriptor->flags & GRD_RDP_GFX_SURFACE_FLAG_ALIGNED_SIZE)
+ {
+ gfx_surface->width = surface_descriptor->aligned_width;
+ gfx_surface->height = surface_descriptor->aligned_height;
+ }
+ else
+ {
+ gfx_surface->width = gfx_surface->rdp_surface->width;
+ gfx_surface->height = gfx_surface->rdp_surface->height;
+ }
grd_rdp_graphics_pipeline_create_surface (graphics_pipeline, gfx_surface);
gfx_surface->created = TRUE;
diff --git a/src/grd-rdp-gfx-surface.h b/src/grd-rdp-gfx-surface.h
index 85f43d67..abfdb07a 100644
--- a/src/grd-rdp-gfx-surface.h
+++ b/src/grd-rdp-gfx-surface.h
@@ -29,10 +29,28 @@
G_DECLARE_FINAL_TYPE (GrdRdpGfxSurface, grd_rdp_gfx_surface,
GRD, RDP_GFX_SURFACE, GObject)
-GrdRdpGfxSurface *grd_rdp_gfx_surface_new (GrdRdpGraphicsPipeline *graphics_pipeline,
- GrdRdpSurface *rdp_surface,
- uint16_t surface_id,
- uint32_t serial);
+typedef enum _GrdRdpGfxSurfaceFlag
+{
+ GRD_RDP_GFX_SURFACE_FLAG_NONE = 0,
+ GRD_RDP_GFX_SURFACE_FLAG_ALIGNED_SIZE = 1 << 0,
+} GrdRdpGfxSurfaceFlag;
+
+typedef struct _GrdRdpGfxSurfaceDescriptor
+{
+ /* Mandatory */
+ GrdRdpGfxSurfaceFlag flags;
+ uint16_t surface_id;
+ uint32_t serial;
+
+ GrdRdpSurface *rdp_surface;
+
+ /* GRD_RDP_GFX_SURFACE_FLAG_ALIGNED_SIZE */
+ uint16_t aligned_width;
+ uint16_t aligned_height;
+} GrdRdpGfxSurfaceDescriptor;
+
+GrdRdpGfxSurface *grd_rdp_gfx_surface_new (GrdRdpGraphicsPipeline *graphics_pipeline,
+ const GrdRdpGfxSurfaceDescriptor *surface_descriptor);
uint16_t grd_rdp_gfx_surface_get_surface_id (GrdRdpGfxSurface *gfx_surface);
@@ -42,6 +60,10 @@ uint32_t grd_rdp_gfx_surface_get_serial (GrdRdpGfxSurface *gfx_surface);
GrdRdpSurface *grd_rdp_gfx_surface_get_rdp_surface (GrdRdpGfxSurface *gfx_surface);
+uint16_t grd_rdp_gfx_surface_get_width (GrdRdpGfxSurface *gfx_surface);
+
+uint16_t grd_rdp_gfx_surface_get_height (GrdRdpGfxSurface *gfx_surface);
+
GrdRdpGfxFrameController *grd_rdp_gfx_surface_get_frame_controller (GrdRdpGfxSurface *gfx_surface);
void grd_rdp_gfx_surface_attach_frame_controller (GrdRdpGfxSurface *gfx_surface,
diff --git a/src/grd-rdp-graphics-pipeline.c b/src/grd-rdp-graphics-pipeline.c
index 36163dc5..1190cde2 100644
--- a/src/grd-rdp-graphics-pipeline.c
+++ b/src/grd-rdp-graphics-pipeline.c
@@ -126,6 +126,8 @@ grd_rdp_graphics_pipeline_create_surface (GrdRdpGraphicsPipeline *graphics_pipel
GrdRdpSurface *rdp_surface = grd_rdp_gfx_surface_get_rdp_surface (gfx_surface);
uint16_t surface_id = grd_rdp_gfx_surface_get_surface_id (gfx_surface);
uint32_t surface_serial = grd_rdp_gfx_surface_get_serial (gfx_surface);
+ uint16_t surface_width = grd_rdp_gfx_surface_get_width (gfx_surface);
+ uint16_t surface_height = grd_rdp_gfx_surface_get_height (gfx_surface);
GfxSurfaceContext *surface_context;
HWAccelContext *hwaccel_context;
uint32_t encode_session_id;
@@ -146,8 +148,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,
- rdp_surface->width,
- rdp_surface->height,
+ surface_width,
+ surface_height,
rdp_surface->refresh_rate))
{
g_debug ("[RDP.RDPGFX] Creating NVENC session for surface %u", surface_id);
@@ -164,8 +166,8 @@ grd_rdp_graphics_pipeline_create_surface (GrdRdpGraphicsPipeline *graphics_pipel
g_mutex_unlock (&graphics_pipeline->gfx_mutex);
create_surface.surfaceId = surface_id;
- create_surface.width = rdp_surface->width;
- create_surface.height = rdp_surface->height;
+ create_surface.width = surface_width;
+ create_surface.height = surface_height;
create_surface.pixelFormat = GFX_PIXEL_FORMAT_XRGB_8888;
rdpgfx_context->CreateSurface (rdpgfx_context, &create_surface);
@@ -419,8 +421,8 @@ refresh_gfx_surface_avc420 (GrdRdpGraphicsPipeline *graphics_pipeline,
SYSTEMTIME system_time;
cairo_rectangle_int_t cairo_rect, region_extents;
int n_rects;
- uint16_t surface_width = rdp_surface->width;
- uint16_t surface_height = rdp_surface->height;
+ uint16_t surface_width = grd_rdp_gfx_surface_get_width (gfx_surface);
+ uint16_t surface_height = grd_rdp_gfx_surface_get_height (gfx_surface);
uint16_t aligned_width;
uint16_t aligned_height;
cairo_region_t *region;
@@ -681,8 +683,10 @@ refresh_gfx_surface_rfx_progressive (GrdRdpGraphicsPipeline *graphics_pipeline,
GrdRdpGfxSurface *gfx_surface = rdp_surface->gfx_surface;
GrdRdpGfxFrameController *frame_controller =
grd_rdp_gfx_surface_get_frame_controller (gfx_surface);
+ uint16_t surface_width = grd_rdp_gfx_surface_get_width (gfx_surface);
+ uint16_t surface_height = grd_rdp_gfx_surface_get_height (gfx_surface);
uint32_t src_stride = grd_session_rdp_get_stride_for_width (session_rdp,
- rdp_surface->width);
+ surface_width);
RDPGFX_SURFACE_COMMAND cmd = {0};
RDPGFX_START_FRAME_PDU cmd_start = {0};
RDPGFX_END_FRAME_PDU cmd_end = {0};
@@ -710,7 +714,7 @@ refresh_gfx_surface_rfx_progressive (GrdRdpGraphicsPipeline *graphics_pipeline,
if (!rdp_surface->valid)
{
rfx_context_reset (graphics_pipeline->rfx_context,
- rdp_surface->width, rdp_surface->height);
+ surface_width, surface_height);
rdp_surface->valid = TRUE;
}
@@ -738,8 +742,8 @@ refresh_gfx_surface_rfx_progressive (GrdRdpGraphicsPipeline *graphics_pipeline,
rfx_rects,
n_rects,
buffer->local_data,
- rdp_surface->width,
- rdp_surface->height,
+ surface_width,
+ surface_height,
src_stride);
g_free (rfx_rects);
@@ -947,11 +951,14 @@ grd_rdp_graphics_pipeline_refresh_gfx (GrdRdpGraphicsPipeline *graphics_pipeline
if (!rdp_surface->gfx_surface)
{
g_autoptr (GrdRdpGfxFrameController) frame_controller = NULL;
+ GrdRdpGfxSurfaceDescriptor surface_descriptor = {};
- rdp_surface->gfx_surface =
- grd_rdp_gfx_surface_new (graphics_pipeline, rdp_surface,
- get_next_free_surface_id (graphics_pipeline),
- get_next_free_serial (graphics_pipeline));
+ surface_descriptor.surface_id = get_next_free_surface_id (graphics_pipeline);
+ surface_descriptor.serial = get_next_free_serial (graphics_pipeline);
+ surface_descriptor.rdp_surface = rdp_surface;
+
+ rdp_surface->gfx_surface = grd_rdp_gfx_surface_new (graphics_pipeline,
+ &surface_descriptor);
frame_controller =
grd_rdp_gfx_frame_controller_new (session_rdp,
graphics_pipeline->pipeline_context,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]