d3d11colorconverter: Add support conversion with blending

This is pre-work for d3d11compositor support

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1323>
This commit is contained in:
Seungha Yang 2020-06-03 01:20:41 +09:00 committed by GStreamer Merge Bot
parent 94ac3cc94d
commit ca87289e56
8 changed files with 35 additions and 18 deletions

View file

@ -1566,7 +1566,7 @@ gst_d3d11_color_convert_transform (GstBaseTransform * trans,
if (!gst_d3d11_color_converter_convert (self->converter,
copy_input ? self->shader_resource_view : resource_view,
copy_output ? self->render_target_view : render_view)) {
copy_output ? self->render_target_view : render_view, NULL, NULL)) {
GST_ERROR_OBJECT (self, "Failed to convert");
return GST_FLOW_ERROR;

View file

@ -1506,7 +1506,8 @@ gst_d3d11_color_converter_update_vertex_buffer (GstD3D11ColorConverter * self)
gboolean
gst_d3d11_color_converter_convert (GstD3D11ColorConverter * converter,
ID3D11ShaderResourceView * srv[GST_VIDEO_MAX_PLANES],
ID3D11RenderTargetView * rtv[GST_VIDEO_MAX_PLANES])
ID3D11RenderTargetView * rtv[GST_VIDEO_MAX_PLANES],
ID3D11BlendState * blend, gfloat blend_factor[4])
{
gboolean ret;
@ -1515,7 +1516,8 @@ gst_d3d11_color_converter_convert (GstD3D11ColorConverter * converter,
g_return_val_if_fail (rtv != NULL, FALSE);
gst_d3d11_device_lock (converter->device);
ret = gst_d3d11_color_converter_convert_unlocked (converter, srv, rtv);
ret = gst_d3d11_color_converter_convert_unlocked (converter,
srv, rtv, blend, blend_factor);
gst_d3d11_device_unlock (converter->device);
return ret;
@ -1524,7 +1526,8 @@ gst_d3d11_color_converter_convert (GstD3D11ColorConverter * converter,
gboolean
gst_d3d11_color_converter_convert_unlocked (GstD3D11ColorConverter * converter,
ID3D11ShaderResourceView * srv[GST_VIDEO_MAX_PLANES],
ID3D11RenderTargetView * rtv[GST_VIDEO_MAX_PLANES])
ID3D11RenderTargetView * rtv[GST_VIDEO_MAX_PLANES],
ID3D11BlendState * blend, gfloat blend_factor[4])
{
gboolean ret;
ID3D11Resource *resource;
@ -1555,7 +1558,7 @@ gst_d3d11_color_converter_convert_unlocked (GstD3D11ColorConverter * converter,
}
ret = gst_d3d11_draw_quad_unlocked (converter->quad[0], converter->viewport,
1, srv, converter->num_input_view, rtv, 1, NULL);
1, srv, converter->num_input_view, rtv, 1, NULL, blend, blend_factor);
if (!ret)
return FALSE;
@ -1564,7 +1567,7 @@ gst_d3d11_color_converter_convert_unlocked (GstD3D11ColorConverter * converter,
ret = gst_d3d11_draw_quad_unlocked (converter->quad[1],
&converter->viewport[1], converter->num_output_view - 1,
srv, converter->num_input_view, &rtv[1], converter->num_output_view - 1,
NULL);
NULL, blend, blend_factor);
if (!ret)
return FALSE;

View file

@ -36,11 +36,15 @@ void gst_d3d11_color_converter_free (GstD3D11ColorConverter
gboolean gst_d3d11_color_converter_convert (GstD3D11ColorConverter * converter,
ID3D11ShaderResourceView *srv[GST_VIDEO_MAX_PLANES],
ID3D11RenderTargetView *rtv[GST_VIDEO_MAX_PLANES]);
ID3D11RenderTargetView *rtv[GST_VIDEO_MAX_PLANES],
ID3D11BlendState *blend,
gfloat blend_factor[4]);
gboolean gst_d3d11_color_converter_convert_unlocked (GstD3D11ColorConverter * converter,
ID3D11ShaderResourceView *srv[GST_VIDEO_MAX_PLANES],
ID3D11RenderTargetView *rtv[GST_VIDEO_MAX_PLANES]);
ID3D11RenderTargetView *rtv[GST_VIDEO_MAX_PLANES],
ID3D11BlendState *blend,
gfloat blend_factor[4]);
gboolean gst_d3d11_color_converter_update_viewport (GstD3D11ColorConverter * converter,
D3D11_VIEWPORT * viewport);

View file

@ -1250,7 +1250,7 @@ copy_to_system (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
gst_d3d11_color_converter_update_src_rect (priv->converter, &rect);
if (!gst_d3d11_color_converter_convert_unlocked (priv->converter,
srv, priv->fallback_render_target_view)) {
srv, priv->fallback_render_target_view, NULL, NULL)) {
GST_ERROR_OBJECT (self, "Failed to convert");
goto error;
}
@ -1386,7 +1386,8 @@ copy_to_d3d11 (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
gst_d3d11_color_converter_update_src_rect (priv->converter, &rect);
if (!gst_d3d11_color_converter_convert_unlocked (priv->converter, srv, rtv)) {
if (!gst_d3d11_color_converter_convert_unlocked (priv->converter,
srv, rtv, NULL, NULL)) {
GST_ERROR_OBJECT (self, "Failed to convert");
goto error;
}

View file

@ -667,7 +667,7 @@ gst_d3d11_overlay_compositor_draw_unlocked (GstD3D11OverlayCompositor *
(GstD3D11CompositionOverlay *) iter->data;
ret = gst_d3d11_draw_quad_unlocked (overlay->quad,
&compositor->viewport, 1, &overlay->srv, 1, rtv, 1, NULL);
&compositor->viewport, 1, &overlay->srv, 1, rtv, 1, NULL, NULL, NULL);
if (!ret)
break;

View file

@ -349,7 +349,8 @@ gst_d3d11_draw_quad (GstD3D11Quad * quad,
D3D11_VIEWPORT viewport[GST_VIDEO_MAX_PLANES], guint num_viewport,
ID3D11ShaderResourceView * srv[GST_VIDEO_MAX_PLANES], guint num_srv,
ID3D11RenderTargetView * rtv[GST_VIDEO_MAX_PLANES], guint num_rtv,
ID3D11DepthStencilView * dsv)
ID3D11DepthStencilView * dsv, ID3D11BlendState * blend,
gfloat blend_factor[4])
{
gboolean ret;
@ -357,7 +358,7 @@ gst_d3d11_draw_quad (GstD3D11Quad * quad,
gst_d3d11_device_lock (quad->device);
ret = gst_d3d11_draw_quad_unlocked (quad, viewport, num_viewport,
srv, num_srv, rtv, num_viewport, dsv);
srv, num_srv, rtv, num_viewport, dsv, blend, blend_factor);
gst_d3d11_device_unlock (quad->device);
return ret;
@ -368,11 +369,13 @@ gst_d3d11_draw_quad_unlocked (GstD3D11Quad * quad,
D3D11_VIEWPORT viewport[GST_VIDEO_MAX_PLANES], guint num_viewport,
ID3D11ShaderResourceView * srv[GST_VIDEO_MAX_PLANES], guint num_srv,
ID3D11RenderTargetView * rtv[GST_VIDEO_MAX_PLANES], guint num_rtv,
ID3D11DepthStencilView * dsv)
ID3D11DepthStencilView * dsv, ID3D11BlendState * blend,
gfloat blend_factor[4])
{
ID3D11DeviceContext *context_handle;
UINT offsets = 0;
ID3D11ShaderResourceView *clear_view[GST_VIDEO_MAX_PLANES] = { NULL, };
ID3D11BlendState *blend_state = blend;
g_return_val_if_fail (quad != NULL, FALSE);
g_return_val_if_fail (viewport != NULL, FALSE);
@ -403,8 +406,10 @@ gst_d3d11_draw_quad_unlocked (GstD3D11Quad * quad,
ID3D11DeviceContext_PSSetShaderResources (context_handle, 0, num_srv, srv);
ID3D11DeviceContext_OMSetRenderTargets (context_handle, num_rtv, rtv, dsv);
if (!blend_state)
blend_state = quad->blend;
ID3D11DeviceContext_OMSetBlendState (context_handle,
quad->blend, NULL, 0xffffffff);
blend_state, blend_factor, 0xffffffff);
ID3D11DeviceContext_OMSetDepthStencilState (context_handle,
quad->depth_stencil, 1);

View file

@ -66,7 +66,9 @@ gboolean gst_d3d11_draw_quad (GstD3D11Quad * quad,
guint num_srv,
ID3D11RenderTargetView *rtv[GST_VIDEO_MAX_PLANES],
guint num_rtv,
ID3D11DepthStencilView *dsv);
ID3D11DepthStencilView *dsv,
ID3D11BlendState *blend,
gfloat blend_factor[4]);
gboolean gst_d3d11_draw_quad_unlocked (GstD3D11Quad * quad,
D3D11_VIEWPORT viewport[GST_VIDEO_MAX_PLANES],
@ -75,7 +77,9 @@ gboolean gst_d3d11_draw_quad_unlocked (GstD3D11Quad * quad,
guint num_srv,
ID3D11RenderTargetView *rtv[GST_VIDEO_MAX_PLANES],
guint num_rtv,
ID3D11DepthStencilView *dsv);
ID3D11DepthStencilView *dsv,
ID3D11BlendState *blend,
gfloat blend_factor[4]);
G_END_DECLS

View file

@ -937,7 +937,7 @@ gst_d3d111_window_present (GstD3D11Window * self, GstBuffer * buffer)
}
} else {
if (!gst_d3d11_color_converter_convert_unlocked (self->converter,
srv, &self->rtv)) {
srv, &self->rtv, NULL, NULL)) {
GST_ERROR_OBJECT (self, "Couldn't render to backbuffer using converter");
return GST_FLOW_ERROR;
} else {