mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 05:01:23 +00:00
d3d11videosink: Add redraw-on-update property
If users update geometry related properties very frequently for a stream to be animated, redrawing on every update can make rendering choppy or can be a performance bottleneck. To address the issue, adding a property to control the behavior of redrawing scene when geometry related properties are updated. Also, do not resize swapchain on such property update, since re-allocating backbuffer and multi-sampled render target is unnecessary in that case. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5575>
This commit is contained in:
parent
443f205c38
commit
107edc0c07
4 changed files with 53 additions and 14 deletions
|
@ -10406,6 +10406,18 @@
|
|||
"type": "GstVideoPrimariesMode",
|
||||
"writable": true
|
||||
},
|
||||
"redraw-on-update": {
|
||||
"blurb": "Immediately apply updated geometry related properties and redraw. If disabled, properties will be applied on the next frame or window resize",
|
||||
"conditionally-available": false,
|
||||
"construct": false,
|
||||
"construct-only": false,
|
||||
"controllable": false,
|
||||
"default": "true",
|
||||
"mutable": "null",
|
||||
"readable": true,
|
||||
"type": "gboolean",
|
||||
"writable": true
|
||||
},
|
||||
"render-rectangle": {
|
||||
"blurb": "The render rectangle ('<x, y, width, height>')",
|
||||
"conditionally-available": false,
|
||||
|
|
|
@ -74,6 +74,7 @@ enum
|
|||
PROP_SCALE_Y,
|
||||
PROP_MSAA,
|
||||
PROP_SAMPLING_METHOD,
|
||||
PROP_REDRAW_ON_UPDATE,
|
||||
PROP_RENDER_RECTANGE,
|
||||
};
|
||||
|
||||
|
@ -93,6 +94,7 @@ enum
|
|||
#define DEFAULT_ORTHO FALSE
|
||||
#define DEFAULT_MSAA GST_D3D11_MSAA_DISABLED
|
||||
#define DEFAULT_SAMPLING_METHOD GST_D3D11_SAMPLING_METHOD_BILINEAR
|
||||
#define DEFAULT_REDROW_ON_UPDATE TRUE
|
||||
|
||||
/**
|
||||
* GstD3D11VideoSinkDisplayFormat:
|
||||
|
@ -212,6 +214,7 @@ struct _GstD3D11VideoSink
|
|||
gfloat scale_y;
|
||||
GstD3D11MSAAMode msaa;
|
||||
GstD3D11SamplingMethod sampling_method;
|
||||
gboolean redraw_on_update;
|
||||
|
||||
/* saved render rectangle until we have a window */
|
||||
GstVideoRectangle render_rect;
|
||||
|
@ -539,6 +542,21 @@ gst_d3d11_video_sink_class_init (GstD3D11VideoSinkClass * klass)
|
|||
DEFAULT_SAMPLING_METHOD, (GParamFlags) (GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
/**
|
||||
* GstD3D11VideoSink:redraw-on-update:
|
||||
*
|
||||
* Immediately apply updated geometry related properties and redraw
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
g_object_class_install_property (gobject_class, PROP_REDRAW_ON_UPDATE,
|
||||
g_param_spec_boolean ("redraw-on-update",
|
||||
"redraw-on-update",
|
||||
"Immediately apply updated geometry related properties and redraw. "
|
||||
"If disabled, properties will be applied on the next frame or "
|
||||
"window resize", DEFAULT_REDROW_ON_UPDATE,
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
/**
|
||||
* GstD3D11VideoSink:render-rectangle:
|
||||
*
|
||||
|
@ -668,6 +686,7 @@ gst_d3d11_video_sink_init (GstD3D11VideoSink * self)
|
|||
self->scale_y = DEFAULT_SCALE;
|
||||
self->msaa = DEFAULT_MSAA;
|
||||
self->sampling_method = DEFAULT_SAMPLING_METHOD;
|
||||
self->redraw_on_update = DEFAULT_REDROW_ON_UPDATE;
|
||||
|
||||
InitializeCriticalSection (&self->lock);
|
||||
}
|
||||
|
@ -765,6 +784,9 @@ gst_d3d11_videosink_set_property (GObject * object, guint prop_id,
|
|||
case PROP_SAMPLING_METHOD:
|
||||
self->sampling_method = (GstD3D11SamplingMethod) g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_REDRAW_ON_UPDATE:
|
||||
self->redraw_on_update = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_RENDER_RECTANGE:
|
||||
gst_video_overlay_set_property (object, PROP_RENDER_RECTANGE,
|
||||
PROP_RENDER_RECTANGE, value);
|
||||
|
@ -847,6 +869,9 @@ gst_d3d11_videosink_get_property (GObject * object, guint prop_id,
|
|||
case PROP_SAMPLING_METHOD:
|
||||
g_value_set_enum (value, self->sampling_method);
|
||||
break;
|
||||
case PROP_REDRAW_ON_UPDATE:
|
||||
g_value_set_boolean (value, self->redraw_on_update);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -1272,7 +1297,8 @@ done:
|
|||
"enable-navigation-events", self->enable_navigation_events,
|
||||
"emit-present", self->emit_present, nullptr);
|
||||
|
||||
gst_d3d11_window_set_orientation (self->window, self->selected_method,
|
||||
gst_d3d11_window_set_orientation (self->window, self->redraw_on_update,
|
||||
self->selected_method,
|
||||
self->fov, self->ortho, self->rotation_x, self->rotation_y,
|
||||
self->rotation_z, self->scale_x, self->scale_y);
|
||||
gst_d3d11_window_set_msaa_mode (self->window, self->msaa);
|
||||
|
@ -1540,7 +1566,8 @@ gst_d3d11_video_sink_set_orientation (GstD3D11VideoSink * self,
|
|||
}
|
||||
|
||||
if (self->window) {
|
||||
gst_d3d11_window_set_orientation (self->window, self->selected_method,
|
||||
gst_d3d11_window_set_orientation (self->window, self->redraw_on_update,
|
||||
self->selected_method,
|
||||
self->fov, self->ortho, self->rotation_x, self->rotation_y,
|
||||
self->rotation_z, self->scale_x, self->scale_y);
|
||||
}
|
||||
|
|
|
@ -953,7 +953,7 @@ gst_d3d11_window_present (GstD3D11Window * self, GstBuffer * buffer,
|
|||
/* We use flip mode swapchain and will not redraw borders.
|
||||
* So backbuffer should be cleared manually in order to remove artifact of
|
||||
* previous client's rendering on present signal */
|
||||
if (self->emit_present) {
|
||||
if (self->emit_present || self->first_present) {
|
||||
const FLOAT clear_color[] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
context->ClearRenderTargetView (rtv, clear_color);
|
||||
}
|
||||
|
@ -987,12 +987,10 @@ gst_d3d11_window_present (GstD3D11Window * self, GstBuffer * buffer,
|
|||
viewport.MinDepth = 0.0f;
|
||||
viewport.MaxDepth = 1.0f;
|
||||
|
||||
g_object_set (self->converter, "dest-x", (gint) self->render_rect.left,
|
||||
"dest-y", (gint) self->render_rect.top,
|
||||
"dest-width",
|
||||
(gint) (self->render_rect.right - self->render_rect.left),
|
||||
"dest-height",
|
||||
(gint) (self->render_rect.bottom - self->render_rect.top), nullptr);
|
||||
g_object_set (self->converter, "dest-x", (gint) viewport.TopLeftX,
|
||||
"dest-y", (gint) viewport.TopLeftY,
|
||||
"dest-width", (gint) viewport.Width,
|
||||
"dest-height", (gint) viewport.Height, nullptr);
|
||||
|
||||
if (!gst_d3d11_need_transform (self->rotation_x, self->rotation_y,
|
||||
self->rotation_z, self->scale_x, self->scale_y)) {
|
||||
|
@ -1196,7 +1194,7 @@ gst_d3d11_window_get_native_type_to_string (GstD3D11WindowNativeType type)
|
|||
}
|
||||
|
||||
void
|
||||
gst_d3d11_window_set_orientation (GstD3D11Window * window,
|
||||
gst_d3d11_window_set_orientation (GstD3D11Window * window, gboolean immediate,
|
||||
GstVideoOrientationMethod method, gfloat fov, gboolean ortho,
|
||||
gfloat rotation_x, gfloat rotation_y, gfloat rotation_z,
|
||||
gfloat scale_x, gfloat scale_y)
|
||||
|
@ -1213,10 +1211,11 @@ gst_d3d11_window_set_orientation (GstD3D11Window * window,
|
|||
window->rotation_y = rotation_y;
|
||||
window->rotation_z = rotation_z;
|
||||
window->scale_x = scale_y;
|
||||
if (window->swap_chain) {
|
||||
GstD3D11WindowClass *klass = GST_D3D11_WINDOW_GET_CLASS (window);
|
||||
|
||||
klass->on_resize (window, window->surface_width, window->surface_height);
|
||||
window->first_present = TRUE;
|
||||
if (immediate && window->swap_chain && window->backbuffer
|
||||
&& window->cached_buffer) {
|
||||
gst_d3d11_window_present (window, window->cached_buffer,
|
||||
window->backbuffer, window->msaa_buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,6 +187,7 @@ void gst_d3d11_window_set_title (GstD3D11Window * window,
|
|||
const gchar *title);
|
||||
|
||||
void gst_d3d11_window_set_orientation (GstD3D11Window * window,
|
||||
gboolean immediate,
|
||||
GstVideoOrientationMethod method,
|
||||
gfloat fov,
|
||||
gboolean ortho,
|
||||
|
|
Loading…
Reference in a new issue