d3d11memory: Add private method for texture wrapped memory allocation
Unlike public method gst_d3d11_allocator_alloc_wrapped(), newly added method by this commit will not calculate CPU accessible memory size, since staging texture must be allocated to calculate the size. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2697>
This commit is contained in:
parent
3919491eb2
commit
46a3394581
@ -41,6 +41,16 @@ void gst_d3d11_device_dxgi_debug (GstD3D11Device * device,
|
|||||||
const gchar * function,
|
const gchar * function,
|
||||||
gint line);
|
gint line);
|
||||||
|
|
||||||
|
/* Memory allocated by this method does not hold correct size.
|
||||||
|
* So this is private method and only plugins in -bad are expected to call
|
||||||
|
* this method */
|
||||||
|
GST_D3D11_API
|
||||||
|
GstMemory * gst_d3d11_allocator_alloc_wrapped_native_size (GstD3D11Allocator * allocator,
|
||||||
|
GstD3D11Device * device,
|
||||||
|
ID3D11Texture2D * texture,
|
||||||
|
gpointer user_data,
|
||||||
|
GDestroyNotify notify);
|
||||||
|
|
||||||
#define GST_D3D11_CLEAR_COM(obj) G_STMT_START { \
|
#define GST_D3D11_CLEAR_COM(obj) G_STMT_START { \
|
||||||
if (obj) { \
|
if (obj) { \
|
||||||
(obj)->Release (); \
|
(obj)->Release (); \
|
||||||
|
@ -1692,6 +1692,46 @@ gst_d3d11_allocator_alloc_wrapped (GstD3D11Allocator * allocator,
|
|||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GstMemory *
|
||||||
|
gst_d3d11_allocator_alloc_wrapped_native_size (GstD3D11Allocator * allocator,
|
||||||
|
GstD3D11Device * device, ID3D11Texture2D * texture, gpointer user_data,
|
||||||
|
GDestroyNotify notify)
|
||||||
|
{
|
||||||
|
GstMemory *mem;
|
||||||
|
GstD3D11Memory *dmem;
|
||||||
|
D3D11_TEXTURE2D_DESC desc = { 0, };
|
||||||
|
ID3D11Texture2D *tex = nullptr;
|
||||||
|
HRESULT hr;
|
||||||
|
gsize size;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_D3D11_ALLOCATOR (allocator), nullptr);
|
||||||
|
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), nullptr);
|
||||||
|
g_return_val_if_fail (texture != nullptr, nullptr);
|
||||||
|
|
||||||
|
hr = texture->QueryInterface (IID_PPV_ARGS (&tex));
|
||||||
|
if (FAILED (hr)) {
|
||||||
|
GST_WARNING_OBJECT (allocator, "Not a valid texture handle");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
tex->GetDesc (&desc);
|
||||||
|
mem = gst_d3d11_allocator_alloc_internal (allocator, device, &desc, tex);
|
||||||
|
|
||||||
|
if (!mem)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
/* XXX: This is not correct memory size */
|
||||||
|
size = desc.Width * desc.Height;
|
||||||
|
mem->maxsize = mem->size = size;
|
||||||
|
|
||||||
|
dmem = GST_D3D11_MEMORY_CAST (mem);
|
||||||
|
|
||||||
|
dmem->priv->user_data = user_data;
|
||||||
|
dmem->priv->notify = notify;
|
||||||
|
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_d3d11_allocator_set_active:
|
* gst_d3d11_allocator_set_active:
|
||||||
* @allocator: a #GstD3D11Allocator
|
* @allocator: a #GstD3D11Allocator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user