* and #GstD3D11Allocator in order to allocate new ID3D11Texture2D
* object with given configuration
*
- * Returns: a #GstD3D11AllocationParams or %NULL if @info is not supported
+ * Returns: (transfer full) (nullable): a #GstD3D11AllocationParams or %NULL if @info is not supported
*
* Since: 1.22
*/
* gst_d3d11_memory_get_resource_handle:
* @mem: a #GstD3D11Memory
*
- * Returns: (transfer none): a ID3D11Resource handle. Caller must not release
+ * Returns: (transfer none) (nullable): a ID3D11Resource handle. Caller must not release
* returned handle.
*
* Since: 1.22
GstD3D11Memory *dmem = GST_D3D11_MEMORY_CAST (mem);
GstD3D11Memory *copy_dmem;
GstD3D11Device *device = dmem->device;
- ID3D11Device *device_handle = gst_d3d11_device_get_device_handle (device);
ID3D11DeviceContext *device_context =
gst_d3d11_device_get_device_context_handle (device);
D3D11_TEXTURE2D_DESC dst_desc = { 0, };
D3D11_TEXTURE2D_DESC src_desc = { 0, };
GstMemory *copy = NULL;
GstMapInfo info;
- HRESULT hr;
- UINT bind_flags = 0;
- UINT supported_flags = 0;
if (dmem->priv->native_type != GST_D3D11_MEMORY_NATIVE_TYPE_TEXTURE_2D)
return priv->fallback_copy (mem, offset, size);
dst_desc.SampleDesc.Count = 1;
dst_desc.ArraySize = 1;
dst_desc.Usage = D3D11_USAGE_DEFAULT;
-
- /* If supported, use bind flags for SRV/RTV */
- hr = device_handle->CheckFormatSupport (src_desc.Format, &supported_flags);
- if (gst_d3d11_result (hr, device)) {
- if ((supported_flags & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE) ==
- D3D11_FORMAT_SUPPORT_SHADER_SAMPLE) {
- bind_flags |= D3D11_BIND_SHADER_RESOURCE;
- }
-
- if ((supported_flags & D3D11_FORMAT_SUPPORT_RENDER_TARGET) ==
- D3D11_FORMAT_SUPPORT_RENDER_TARGET) {
- bind_flags |= D3D11_BIND_RENDER_TARGET;
- }
- }
+ dst_desc.BindFlags = src_desc.BindFlags;
copy = gst_d3d11_allocator_alloc_internal (alloc, device, &dst_desc, nullptr);
if (!copy) {
GstD3D11Memory *dmem;
ID3D11RenderTargetView *rtv = nullptr;
GstD3D11ClearRTVFunc clear_func = nullptr;
+ gboolean is_new_texture = TRUE;
device_handle = gst_d3d11_device_get_device_handle (device);
GST_ERROR_OBJECT (self, "Couldn't create texture");
return nullptr;
}
+ } else {
+ is_new_texture = FALSE;
}
mem =
if (!mem)
return nullptr;
+ /* Don't clear external texture */
+ if (!is_new_texture)
+ return mem;
+
/* Clear with YUV black if needed and possible
* TODO: do this using UAV if RTV is not allowed (e.g., packed YUV formats) */
if ((desc->BindFlags & D3D11_BIND_RENDER_TARGET) == 0)
* @device: (transfer none): a #GstD3D11Device
* @desc: a D3D11_TEXTURE2D_DESC struct
*
- * Returns: a newly allocated #GstD3D11Memory with given parameters.
+ * Returns: (transfer full) (nullable): a newly allocated #GstD3D11Memory with given parameters.
*
* Since: 1.22
*/
* @device: (transfer none): a #GstD3D11Device
* @desc: a D3D11_BUFFER_DESC struct
*
- * Returns: a newly allocated #GstD3D11Memory with given parameters.
+ * Returns: (transfer full) (nullable): a newly allocated #GstD3D11Memory with given parameters.
*
* Since: 1.22
*/
* Caller must not be confused that @size is CPU accessible size, not raw
* texture size.
*
- * Returns: a newly allocated #GstD3D11Memory with given @texture
+ * Returns: (transfer full) (nullable): a newly allocated #GstD3D11Memory with given @texture
* if successful, or %NULL if @texture is not a valid handle or configuration
* is not supported.
*
g_return_val_if_fail (GST_IS_D3D11_ALLOCATOR (allocator), FALSE);
klass = GST_D3D11_ALLOCATOR_GET_CLASS (allocator);
- if (klass->set_actvie)
- return klass->set_actvie (allocator, active);
+ if (klass->set_active)
+ return klass->set_active (allocator, active);
return TRUE;
}
gsize mem_size;
};
-static void gst_d3d11_pool_allocator_dispose (GObject * object);
static void gst_d3d11_pool_allocator_finalize (GObject * object);
static gboolean
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstD3D11AllocatorClass *d3d11alloc_class = GST_D3D11_ALLOCATOR_CLASS (klass);
- gobject_class->dispose = gst_d3d11_pool_allocator_dispose;
gobject_class->finalize = gst_d3d11_pool_allocator_finalize;
- d3d11alloc_class->set_actvie = gst_d3d11_pool_allocator_set_active;
+ d3d11alloc_class->set_active = gst_d3d11_pool_allocator_set_active;
}
static void
}
static void
-gst_d3d11_pool_allocator_dispose (GObject * object)
-{
- GstD3D11PoolAllocator *self = GST_D3D11_POOL_ALLOCATOR (object);
-
- gst_clear_object (&self->device);
-
- G_OBJECT_CLASS (pool_alloc_parent_class)->dispose (object);
-}
-
-static void
gst_d3d11_pool_allocator_finalize (GObject * object)
{
GstD3D11PoolAllocator *self = GST_D3D11_POOL_ALLOCATOR (object);
GST_D3D11_CLEAR_COM (priv->texture);
+ gst_clear_object (&self->device);
+
G_OBJECT_CLASS (pool_alloc_parent_class)->finalize (object);
}
GST_MINI_OBJECT_CAST (mem)->dispose = NULL;
mem->allocator = (GstAllocator *) gst_object_ref (_d3d11_memory_allocator);
- gst_object_unref (self);
/* keep it around in our queue */
gst_atomic_queue_push (self->priv->queue, mem);
gst_poll_write_control (self->priv->poll);
dec_outstanding (self);
+
+ gst_object_unref (self);
}
static gboolean