d3d11: Aggregate d3d11 memory usage query for dynamic-usage type decision
Even if one of downstream d3d11 elements can support dynamic-usage memory, another one might not support it. Also, to support dynamic-usage, both upstream and downstream d3d11device must be the same object.
This commit is contained in:
parent
d731bcb18a
commit
81dde0f5b8
@ -96,8 +96,6 @@ static GstFlowReturn gst_d3d11_color_convert_transform (GstBaseTransform *
|
|||||||
static gboolean gst_d3d11_color_convert_set_info (GstD3D11BaseFilter * filter,
|
static gboolean gst_d3d11_color_convert_set_info (GstD3D11BaseFilter * filter,
|
||||||
GstCaps * incaps, GstVideoInfo * in_info, GstCaps * outcaps,
|
GstCaps * incaps, GstVideoInfo * in_info, GstCaps * outcaps,
|
||||||
GstVideoInfo * out_info);
|
GstVideoInfo * out_info);
|
||||||
static gboolean gst_d3d11_color_convert_query (GstBaseTransform * trans,
|
|
||||||
GstPadDirection direction, GstQuery * query);
|
|
||||||
|
|
||||||
/* copies the given caps */
|
/* copies the given caps */
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
@ -170,7 +168,6 @@ gst_d3d11_color_convert_class_init (GstD3D11ColorConvertClass * klass)
|
|||||||
GST_DEBUG_FUNCPTR (gst_d3d11_color_convert_decide_allocation);
|
GST_DEBUG_FUNCPTR (gst_d3d11_color_convert_decide_allocation);
|
||||||
trans_class->transform =
|
trans_class->transform =
|
||||||
GST_DEBUG_FUNCPTR (gst_d3d11_color_convert_transform);
|
GST_DEBUG_FUNCPTR (gst_d3d11_color_convert_transform);
|
||||||
trans_class->query = GST_DEBUG_FUNCPTR (gst_d3d11_color_convert_query);
|
|
||||||
|
|
||||||
bfilter_class->set_info =
|
bfilter_class->set_info =
|
||||||
GST_DEBUG_FUNCPTR (gst_d3d11_color_convert_set_info);
|
GST_DEBUG_FUNCPTR (gst_d3d11_color_convert_set_info);
|
||||||
@ -454,26 +451,6 @@ gst_d3d11_color_convert_decide_allocation (GstBaseTransform * trans,
|
|||||||
query);
|
query);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_d3d11_color_convert_query (GstBaseTransform * trans,
|
|
||||||
GstPadDirection direction, GstQuery * query)
|
|
||||||
{
|
|
||||||
if (gst_query_is_d3d11_usage (query) && direction == GST_PAD_SINK) {
|
|
||||||
D3D11_USAGE usage = D3D11_USAGE_DEFAULT;
|
|
||||||
|
|
||||||
gst_query_parse_d3d11_usage (query, &usage);
|
|
||||||
if (usage == D3D11_USAGE_DEFAULT || usage == D3D11_USAGE_DYNAMIC)
|
|
||||||
gst_query_set_d3d11_usage_result (query, TRUE);
|
|
||||||
else
|
|
||||||
gst_query_set_d3d11_usage_result (query, FALSE);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GST_BASE_TRANSFORM_CLASS (parent_class)->query (trans, direction,
|
|
||||||
query);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
create_shader_input_resource (GstD3D11ColorConvert * self,
|
create_shader_input_resource (GstD3D11ColorConvert * self,
|
||||||
GstD3D11Device * device, const GstD3D11Format * format, GstVideoInfo * info)
|
GstD3D11Device * device, const GstD3D11Format * format, GstVideoInfo * info)
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "gstd3d11memory.h"
|
#include "gstd3d11memory.h"
|
||||||
#include "gstd3d11device.h"
|
#include "gstd3d11device.h"
|
||||||
#include "gstd3d11bufferpool.h"
|
#include "gstd3d11bufferpool.h"
|
||||||
|
#include "gstd3d11utils.h"
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (gst_d3d11_download_debug);
|
GST_DEBUG_CATEGORY_STATIC (gst_d3d11_download_debug);
|
||||||
#define GST_CAT_DEFAULT gst_d3d11_download_debug
|
#define GST_CAT_DEFAULT gst_d3d11_download_debug
|
||||||
@ -67,6 +68,8 @@ static gboolean gst_d3d11_download_decide_allocation (GstBaseTransform * trans,
|
|||||||
GstQuery * query);
|
GstQuery * query);
|
||||||
static GstFlowReturn gst_d3d11_download_transform (GstBaseTransform * trans,
|
static GstFlowReturn gst_d3d11_download_transform (GstBaseTransform * trans,
|
||||||
GstBuffer * inbuf, GstBuffer * outbuf);
|
GstBuffer * inbuf, GstBuffer * outbuf);
|
||||||
|
static gboolean gst_d3d11_download_query (GstBaseTransform * trans,
|
||||||
|
GstPadDirection direction, GstQuery * query);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_d3d11_download_class_init (GstD3D11DownloadClass * klass)
|
gst_d3d11_download_class_init (GstD3D11DownloadClass * klass)
|
||||||
@ -91,6 +94,7 @@ gst_d3d11_download_class_init (GstD3D11DownloadClass * klass)
|
|||||||
trans_class->decide_allocation =
|
trans_class->decide_allocation =
|
||||||
GST_DEBUG_FUNCPTR (gst_d3d11_download_decide_allocation);
|
GST_DEBUG_FUNCPTR (gst_d3d11_download_decide_allocation);
|
||||||
trans_class->transform = GST_DEBUG_FUNCPTR (gst_d3d11_download_transform);
|
trans_class->transform = GST_DEBUG_FUNCPTR (gst_d3d11_download_transform);
|
||||||
|
trans_class->query = GST_DEBUG_FUNCPTR (gst_d3d11_download_query);
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_d3d11_download_debug,
|
GST_DEBUG_CATEGORY_INIT (gst_d3d11_download_debug,
|
||||||
"d3d11download", 0, "d3d11download Element");
|
"d3d11download", 0, "d3d11download Element");
|
||||||
@ -315,3 +319,28 @@ invalid_buffer:
|
|||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_d3d11_download_query (GstBaseTransform * trans, GstPadDirection direction,
|
||||||
|
GstQuery * query)
|
||||||
|
{
|
||||||
|
if (gst_query_is_d3d11_usage (query) && direction == GST_PAD_SINK) {
|
||||||
|
GstD3D11BaseFilter *filter = GST_D3D11_BASE_FILTER (trans);
|
||||||
|
D3D11_USAGE usage = D3D11_USAGE_DEFAULT;
|
||||||
|
GstD3D11Device *device;
|
||||||
|
|
||||||
|
gst_query_parse_d3d11_usage (query, &device, &usage);
|
||||||
|
if (filter->device == device && usage == D3D11_USAGE_DEFAULT) {
|
||||||
|
gst_query_set_d3d11_usage_result (query, TRUE);
|
||||||
|
gst_object_unref (device);
|
||||||
|
} else {
|
||||||
|
gst_query_set_d3d11_usage_result (query, FALSE);
|
||||||
|
gst_object_unref (device);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return GST_BASE_TRANSFORM_CLASS (parent_class)->query (trans, direction,
|
||||||
|
query);
|
||||||
|
}
|
||||||
|
@ -315,7 +315,8 @@ gst_d3d11_upload_decide_allocation (GstBaseTransform * trans, GstQuery * query)
|
|||||||
GstQuery *usage_query;
|
GstQuery *usage_query;
|
||||||
gboolean can_dynamic = FALSE;
|
gboolean can_dynamic = FALSE;
|
||||||
|
|
||||||
usage_query = gst_query_new_d3d11_usage (D3D11_USAGE_DYNAMIC);
|
usage_query =
|
||||||
|
gst_query_new_d3d11_usage (filter->device, D3D11_USAGE_DYNAMIC);
|
||||||
gst_pad_peer_query (GST_BASE_TRANSFORM_SRC_PAD (trans), usage_query);
|
gst_pad_peer_query (GST_BASE_TRANSFORM_SRC_PAD (trans), usage_query);
|
||||||
gst_query_parse_d3d11_usage_result (usage_query, &can_dynamic);
|
gst_query_parse_d3d11_usage_result (usage_query, &can_dynamic);
|
||||||
gst_query_unref (usage_query);
|
gst_query_unref (usage_query);
|
||||||
|
@ -341,12 +341,15 @@ gst_d3d11_is_windows_8_or_greater (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GstQuery *
|
GstQuery *
|
||||||
gst_query_new_d3d11_usage (D3D11_USAGE usage)
|
gst_query_new_d3d11_usage (GstD3D11Device * device, D3D11_USAGE usage)
|
||||||
{
|
{
|
||||||
GstQuery *query;
|
GstQuery *query;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
|
||||||
|
|
||||||
structure = gst_structure_new ("GstQueryD3D11Usage",
|
structure = gst_structure_new ("GstQueryD3D11Usage",
|
||||||
|
"device", GST_TYPE_D3D11_DEVICE, device,
|
||||||
"usage", G_TYPE_INT, usage, "result", G_TYPE_BOOLEAN, FALSE, NULL);
|
"usage", G_TYPE_INT, usage, "result", G_TYPE_BOOLEAN, FALSE, NULL);
|
||||||
query = gst_query_new_custom (GST_QUERY_CUSTOM, structure);
|
query = gst_query_new_custom (GST_QUERY_CUSTOM, structure);
|
||||||
|
|
||||||
@ -354,7 +357,8 @@ gst_query_new_d3d11_usage (D3D11_USAGE usage)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_query_parse_d3d11_usage (GstQuery * query, D3D11_USAGE * usage)
|
gst_query_parse_d3d11_usage (GstQuery * query, GstD3D11Device ** device,
|
||||||
|
D3D11_USAGE * usage)
|
||||||
{
|
{
|
||||||
const GstStructure *structure;
|
const GstStructure *structure;
|
||||||
|
|
||||||
@ -365,7 +369,8 @@ gst_query_parse_d3d11_usage (GstQuery * query, D3D11_USAGE * usage)
|
|||||||
|
|
||||||
structure = gst_query_get_structure (query);
|
structure = gst_query_get_structure (query);
|
||||||
|
|
||||||
gst_structure_get (structure, "usage", G_TYPE_INT, usage, NULL);
|
gst_structure_get (structure, "device", GST_TYPE_D3D11_DEVICE, device,
|
||||||
|
"usage", G_TYPE_INT, usage, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -42,9 +42,11 @@ gboolean gst_d3d11_ensure_element_data (GstElement * element,
|
|||||||
|
|
||||||
gboolean gst_d3d11_is_windows_8_or_greater (void);
|
gboolean gst_d3d11_is_windows_8_or_greater (void);
|
||||||
|
|
||||||
GstQuery * gst_query_new_d3d11_usage (D3D11_USAGE usage);
|
GstQuery * gst_query_new_d3d11_usage (GstD3D11Device * device,
|
||||||
|
D3D11_USAGE usage);
|
||||||
|
|
||||||
void gst_query_parse_d3d11_usage (GstQuery * query,
|
void gst_query_parse_d3d11_usage (GstQuery * query,
|
||||||
|
GstD3D11Device ** device,
|
||||||
D3D11_USAGE *usage);
|
D3D11_USAGE *usage);
|
||||||
|
|
||||||
void gst_query_set_d3d11_usage_result (GstQuery * query,
|
void gst_query_set_d3d11_usage_result (GstQuery * query,
|
||||||
|
@ -660,14 +660,19 @@ gst_d3d11_video_sink_query (GstBaseSink * sink, GstQuery * query)
|
|||||||
case GST_QUERY_CUSTOM:
|
case GST_QUERY_CUSTOM:
|
||||||
if (gst_query_is_d3d11_usage (query)) {
|
if (gst_query_is_d3d11_usage (query)) {
|
||||||
D3D11_USAGE usage = D3D11_USAGE_DEFAULT;
|
D3D11_USAGE usage = D3D11_USAGE_DEFAULT;
|
||||||
|
GstD3D11Device *device;
|
||||||
|
|
||||||
gst_query_parse_d3d11_usage (query, &usage);
|
gst_query_parse_d3d11_usage (query, &device, &usage);
|
||||||
if (usage == D3D11_USAGE_DEFAULT || usage == D3D11_USAGE_DYNAMIC)
|
if (device == self->device &&
|
||||||
|
(usage == D3D11_USAGE_DEFAULT || usage == D3D11_USAGE_DYNAMIC)) {
|
||||||
gst_query_set_d3d11_usage_result (query, TRUE);
|
gst_query_set_d3d11_usage_result (query, TRUE);
|
||||||
else
|
gst_object_unref (device);
|
||||||
|
} else {
|
||||||
gst_query_set_d3d11_usage_result (query, FALSE);
|
gst_query_set_d3d11_usage_result (query, FALSE);
|
||||||
|
gst_object_unref (device);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user