mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-10 17:35:59 +00:00
d3d11bufferpool: Hide buffer_size field from header
User can get the required buffer size by using buffer pool config. Since d3d11 implementation is a candidate for public library in the future, we need to hide everything from header as much as possible. Note that the total size of allocated d3d11 texture memory by GPU is not controllable factor. It depends on hardware specific alignment/padding requirement. So, GstD3D11 implementation updates actual buffer size by allocating D3D11 texture, since there's no way to get CPU accessible memory size without allocating real D3D11 texture. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2482>
This commit is contained in:
parent
1874206abd
commit
fe4ec03a4b
11 changed files with 84 additions and 31 deletions
|
@ -307,10 +307,8 @@ gst_d3d11_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
||||||
priv->offset[1] = priv->stride[0] * desc[0].Height;
|
priv->offset[1] = priv->stride[0] * desc[0].Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->buffer_size = offset;
|
|
||||||
|
|
||||||
gst_buffer_pool_config_set_params (config,
|
gst_buffer_pool_config_set_params (config,
|
||||||
caps, self->buffer_size, min_buffers, max_buffers);
|
caps, offset, min_buffers, max_buffers);
|
||||||
|
|
||||||
return GST_BUFFER_POOL_CLASS (parent_class)->set_config (pool, config) && ret;
|
return GST_BUFFER_POOL_CLASS (parent_class)->set_config (pool, config) && ret;
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,6 @@ struct _GstD3D11BufferPool
|
||||||
|
|
||||||
GstD3D11Device *device;
|
GstD3D11Device *device;
|
||||||
|
|
||||||
/* re-calculated buffer size based on d3d11 pitch and stride */
|
|
||||||
guint buffer_size;
|
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
GstD3D11BufferPoolPrivate *priv;
|
GstD3D11BufferPoolPrivate *priv;
|
||||||
|
|
||||||
|
|
|
@ -1955,6 +1955,7 @@ gst_d3d11_compositor_propose_allocation (GstAggregator * aggregator,
|
||||||
|
|
||||||
if (gst_query_get_n_allocation_pools (query) == 0) {
|
if (gst_query_get_n_allocation_pools (query) == 0) {
|
||||||
GstD3D11AllocationParams *d3d11_params;
|
GstD3D11AllocationParams *d3d11_params;
|
||||||
|
GstStructure *config;
|
||||||
|
|
||||||
d3d11_params = gst_d3d11_allocation_params_new (self->device, &info,
|
d3d11_params = gst_d3d11_allocation_params_new (self->device, &info,
|
||||||
(GstD3D11AllocationFlags) 0, D3D11_BIND_SHADER_RESOURCE);
|
(GstD3D11AllocationFlags) 0, D3D11_BIND_SHADER_RESOURCE);
|
||||||
|
@ -1968,8 +1969,12 @@ gst_d3d11_compositor_propose_allocation (GstAggregator * aggregator,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* d3d11 buffer pool might update buffer size by self */
|
/* d3d11 buffer pool will update buffer size based on allocated texture,
|
||||||
size = GST_D3D11_BUFFER_POOL (pool)->buffer_size;
|
* get size from config again */
|
||||||
|
config = gst_buffer_pool_get_config (pool);
|
||||||
|
gst_buffer_pool_config_get_params (config,
|
||||||
|
nullptr, &size, nullptr, nullptr);
|
||||||
|
gst_structure_free (config);
|
||||||
|
|
||||||
gst_query_add_allocation_pool (query, pool, size, 0, 0);
|
gst_query_add_allocation_pool (query, pool, size, 0, 0);
|
||||||
gst_object_unref (pool);
|
gst_object_unref (pool);
|
||||||
|
@ -2042,8 +2047,12 @@ gst_d3d11_compositor_decide_allocation (GstAggregator * aggregator,
|
||||||
gst_d3d11_allocation_params_free (d3d11_params);
|
gst_d3d11_allocation_params_free (d3d11_params);
|
||||||
|
|
||||||
gst_buffer_pool_set_config (pool, config);
|
gst_buffer_pool_set_config (pool, config);
|
||||||
/* d3d11 buffer pool might update buffer size by self */
|
|
||||||
size = GST_D3D11_BUFFER_POOL (pool)->buffer_size;
|
/* d3d11 buffer pool will update buffer size based on allocated texture,
|
||||||
|
* get size from config again */
|
||||||
|
config = gst_buffer_pool_get_config (pool);
|
||||||
|
gst_buffer_pool_config_get_params (config, nullptr, &size, nullptr, nullptr);
|
||||||
|
gst_structure_free (config);
|
||||||
|
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
|
gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
|
||||||
|
|
|
@ -1252,7 +1252,12 @@ gst_d3d11_base_convert_propose_allocation (GstBaseTransform * trans,
|
||||||
gst_query_add_allocation_meta (query,
|
gst_query_add_allocation_meta (query,
|
||||||
GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE, NULL);
|
GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE, NULL);
|
||||||
|
|
||||||
size = GST_D3D11_BUFFER_POOL (pool)->buffer_size;
|
/* d3d11 buffer pool will update buffer size based on allocated texture,
|
||||||
|
* get size from config again */
|
||||||
|
config = gst_buffer_pool_get_config (pool);
|
||||||
|
gst_buffer_pool_config_get_params (config, nullptr, &size, nullptr, nullptr);
|
||||||
|
gst_structure_free (config);
|
||||||
|
|
||||||
gst_query_add_allocation_pool (query, pool, size, 0, 0);
|
gst_query_add_allocation_pool (query, pool, size, 0, 0);
|
||||||
|
|
||||||
gst_object_unref (pool);
|
gst_object_unref (pool);
|
||||||
|
@ -1359,7 +1364,11 @@ gst_d3d11_base_convert_decide_allocation (GstBaseTransform * trans,
|
||||||
gst_buffer_pool_config_set_params (config, outcaps, size, min, max);
|
gst_buffer_pool_config_set_params (config, outcaps, size, min, max);
|
||||||
gst_buffer_pool_set_config (pool, config);
|
gst_buffer_pool_set_config (pool, config);
|
||||||
|
|
||||||
size = GST_D3D11_BUFFER_POOL (pool)->buffer_size;
|
/* d3d11 buffer pool will update buffer size based on allocated texture,
|
||||||
|
* get size from config again */
|
||||||
|
config = gst_buffer_pool_get_config (pool);
|
||||||
|
gst_buffer_pool_config_get_params (config, nullptr, &size, nullptr, nullptr);
|
||||||
|
gst_structure_free (config);
|
||||||
|
|
||||||
if (update_pool)
|
if (update_pool)
|
||||||
gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
|
gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
|
||||||
|
|
|
@ -1702,8 +1702,14 @@ gst_d3d11_decoder_decide_allocation (GstD3D11Decoder * decoder,
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_pool_set_config (pool, config);
|
gst_buffer_pool_set_config (pool, config);
|
||||||
if (use_d3d11_pool)
|
if (use_d3d11_pool) {
|
||||||
size = GST_D3D11_BUFFER_POOL (pool)->buffer_size;
|
/* d3d11 buffer pool will update buffer size based on allocated texture,
|
||||||
|
* get size from config again */
|
||||||
|
config = gst_buffer_pool_get_config (pool);
|
||||||
|
gst_buffer_pool_config_get_params (config,
|
||||||
|
nullptr, &size, nullptr, nullptr);
|
||||||
|
gst_structure_free (config);
|
||||||
|
}
|
||||||
|
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
|
gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
|
||||||
|
|
|
@ -948,7 +948,12 @@ gst_d3d11_deinterlace_propose_allocation (GstBaseTransform * trans,
|
||||||
gst_query_add_allocation_meta (query,
|
gst_query_add_allocation_meta (query,
|
||||||
GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE, NULL);
|
GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE, NULL);
|
||||||
|
|
||||||
size = GST_D3D11_BUFFER_POOL (pool)->buffer_size;
|
/* d3d11 buffer pool will update buffer size based on allocated texture,
|
||||||
|
* get size from config again */
|
||||||
|
config = gst_buffer_pool_get_config (pool);
|
||||||
|
gst_buffer_pool_config_get_params (config, nullptr, &size, nullptr, nullptr);
|
||||||
|
gst_structure_free (config);
|
||||||
|
|
||||||
gst_query_add_allocation_pool (query, pool, size, min_buffers, 0);
|
gst_query_add_allocation_pool (query, pool, size, min_buffers, 0);
|
||||||
|
|
||||||
gst_object_unref (pool);
|
gst_object_unref (pool);
|
||||||
|
@ -1022,7 +1027,11 @@ gst_d3d11_deinterlace_decide_allocation (GstBaseTransform * trans,
|
||||||
gst_buffer_pool_config_set_params (config, outcaps, size, min, max);
|
gst_buffer_pool_config_set_params (config, outcaps, size, min, max);
|
||||||
gst_buffer_pool_set_config (pool, config);
|
gst_buffer_pool_set_config (pool, config);
|
||||||
|
|
||||||
size = GST_D3D11_BUFFER_POOL (pool)->buffer_size;
|
/* d3d11 buffer pool will update buffer size based on allocated texture,
|
||||||
|
* get size from config again */
|
||||||
|
config = gst_buffer_pool_get_config (pool);
|
||||||
|
gst_buffer_pool_config_get_params (config, nullptr, &size, nullptr, nullptr);
|
||||||
|
gst_structure_free (config);
|
||||||
|
|
||||||
if (update_pool)
|
if (update_pool)
|
||||||
gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
|
gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
|
||||||
|
|
|
@ -378,9 +378,11 @@ gst_d3d11_desktop_dup_src_decide_allocation (GstBaseSrc * bsrc,
|
||||||
|
|
||||||
gst_buffer_pool_set_config (pool, config);
|
gst_buffer_pool_set_config (pool, config);
|
||||||
|
|
||||||
/* buffer size might be recalculated by pool depending on
|
/* d3d11 buffer pool will update buffer size based on allocated texture,
|
||||||
* device's stride/padding constraints */
|
* get size from config again */
|
||||||
size = GST_D3D11_BUFFER_POOL (pool)->buffer_size;
|
config = gst_buffer_pool_get_config (pool);
|
||||||
|
gst_buffer_pool_config_get_params (config, nullptr, &size, nullptr, nullptr);
|
||||||
|
gst_structure_free (config);
|
||||||
|
|
||||||
if (update_pool)
|
if (update_pool)
|
||||||
gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
|
gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
|
||||||
|
|
|
@ -295,9 +295,13 @@ gst_d3d11_download_propose_allocation (GstBaseTransform * trans,
|
||||||
|
|
||||||
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
|
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
|
||||||
|
|
||||||
/* d3d11 buffer pool might update buffer size by self */
|
|
||||||
if (is_d3d11) {
|
if (is_d3d11) {
|
||||||
size = GST_D3D11_BUFFER_POOL (pool)->buffer_size;
|
/* d3d11 buffer pool will update buffer size based on allocated texture,
|
||||||
|
* get size from config again */
|
||||||
|
config = gst_buffer_pool_get_config (pool);
|
||||||
|
gst_buffer_pool_config_get_params (config, nullptr, &size, nullptr,
|
||||||
|
nullptr);
|
||||||
|
gst_structure_free (config);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_query_add_allocation_pool (query, pool, size, 0, 0);
|
gst_query_add_allocation_pool (query, pool, size, 0, 0);
|
||||||
|
|
|
@ -326,9 +326,14 @@ gst_d3d11_upload_propose_allocation (GstBaseTransform * trans,
|
||||||
if (!gst_buffer_pool_set_config (pool, config))
|
if (!gst_buffer_pool_set_config (pool, config))
|
||||||
goto config_failed;
|
goto config_failed;
|
||||||
|
|
||||||
/* d3d11 buffer pool might update buffer size by self */
|
/* d3d11 buffer pool will update buffer size based on allocated texture,
|
||||||
if (is_d3d11)
|
* get size from config again */
|
||||||
size = GST_D3D11_BUFFER_POOL (pool)->buffer_size;
|
if (is_d3d11) {
|
||||||
|
config = gst_buffer_pool_get_config (pool);
|
||||||
|
gst_buffer_pool_config_get_params (config,
|
||||||
|
nullptr, &size, nullptr, nullptr);
|
||||||
|
gst_structure_free (config);
|
||||||
|
}
|
||||||
|
|
||||||
gst_query_add_allocation_pool (query, pool, size, 0, 0);
|
gst_query_add_allocation_pool (query, pool, size, 0, 0);
|
||||||
gst_object_unref (pool);
|
gst_object_unref (pool);
|
||||||
|
@ -446,8 +451,11 @@ gst_d3d11_upload_decide_allocation (GstBaseTransform * trans, GstQuery * query)
|
||||||
|
|
||||||
gst_buffer_pool_set_config (pool, config);
|
gst_buffer_pool_set_config (pool, config);
|
||||||
|
|
||||||
/* update size with calculated one */
|
/* d3d11 buffer pool will update buffer size based on allocated texture,
|
||||||
size = GST_D3D11_BUFFER_POOL (pool)->buffer_size;
|
* get size from config again */
|
||||||
|
config = gst_buffer_pool_get_config (pool);
|
||||||
|
gst_buffer_pool_config_get_params (config, nullptr, &size, nullptr, nullptr);
|
||||||
|
gst_structure_free (config);
|
||||||
|
|
||||||
if (update_pool)
|
if (update_pool)
|
||||||
gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
|
gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
|
||||||
|
|
|
@ -885,8 +885,14 @@ gst_d3d11_video_sink_propose_allocation (GstBaseSink * sink, GstQuery * query)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_d3d11)
|
if (is_d3d11) {
|
||||||
size = GST_D3D11_BUFFER_POOL (pool)->buffer_size;
|
/* d3d11 buffer pool will update buffer size based on allocated texture,
|
||||||
|
* get size from config again */
|
||||||
|
config = gst_buffer_pool_get_config (pool);
|
||||||
|
gst_buffer_pool_config_get_params (config, nullptr, &size, nullptr,
|
||||||
|
nullptr);
|
||||||
|
gst_structure_free (config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We need at least 2 buffers because we hold on to the last one for redrawing
|
/* We need at least 2 buffers because we hold on to the last one for redrawing
|
||||||
|
|
|
@ -1360,9 +1360,14 @@ gst_mf_video_enc_propose_allocation (GstVideoEncoder * enc, GstQuery * query)
|
||||||
if (!gst_buffer_pool_set_config (pool, config))
|
if (!gst_buffer_pool_set_config (pool, config))
|
||||||
goto config_failed;
|
goto config_failed;
|
||||||
|
|
||||||
/* d3d11 buffer pool might update buffer size by self */
|
/* d3d11 buffer pool will update buffer size based on allocated texture,
|
||||||
if (is_d3d11)
|
* get size from config again */
|
||||||
size = GST_D3D11_BUFFER_POOL (pool)->buffer_size;
|
if (is_d3d11) {
|
||||||
|
config = gst_buffer_pool_get_config (pool);
|
||||||
|
gst_buffer_pool_config_get_params (config,
|
||||||
|
nullptr, &size, nullptr, nullptr);
|
||||||
|
gst_structure_free (config);
|
||||||
|
}
|
||||||
|
|
||||||
gst_query_add_allocation_pool (query, pool, size, 0, 0);
|
gst_query_add_allocation_pool (query, pool, size, 0, 0);
|
||||||
gst_object_unref (pool);
|
gst_object_unref (pool);
|
||||||
|
|
Loading…
Reference in a new issue