d3d11: Pass GstD3D11Memory object to ensure_{shader_resource,render_target}_view methods

The method name indicates it should be d3d11memory, so passing
GstD3D11Memory seems to make more sense than GstMemory.
This commit is contained in:
Seungha Yang 2019-12-15 15:50:19 +09:00
parent 7c041f1934
commit 61cb6b2bbe
4 changed files with 22 additions and 31 deletions

View file

@ -819,7 +819,7 @@ do_convert (GstD3D11Device * device, DoConvertData * data)
gst_memory_unmap (mem, &info);
}
if (gst_d3d11_memory_ensure_shader_resource_view (mem)) {
if (gst_d3d11_memory_ensure_shader_resource_view (d3d11_mem)) {
GST_TRACE_OBJECT (self, "Use input texture resource without copy");
for (j = 0; j < d3d11_mem->num_shader_resource_views; j++) {
@ -866,7 +866,7 @@ do_convert (GstD3D11Device * device, DoConvertData * data)
d3d11_mem = (GstD3D11Memory *) mem;
if (gst_d3d11_memory_ensure_render_target_view (mem)) {
if (gst_d3d11_memory_ensure_render_target_view (d3d11_mem)) {
GST_TRACE_OBJECT (self, "Render to output texture directly");
for (j = 0; j < d3d11_mem->num_render_target_views; j++) {

View file

@ -774,51 +774,43 @@ gst_is_d3d11_memory (GstMemory * mem)
}
gboolean
gst_d3d11_memory_ensure_shader_resource_view (GstMemory * mem)
gst_d3d11_memory_ensure_shader_resource_view (GstD3D11Memory * mem)
{
GstD3D11Memory *dmem;
g_return_val_if_fail (gst_is_d3d11_memory (GST_MEMORY_CAST (mem)), FALSE);
g_return_val_if_fail (gst_is_d3d11_memory (mem), FALSE);
dmem = (GstD3D11Memory *) mem;
if (dmem->num_shader_resource_views)
if (mem->num_shader_resource_views)
return TRUE;
if (!(dmem->desc.BindFlags & D3D11_BIND_SHADER_RESOURCE)) {
GST_WARNING_OBJECT (mem->allocator,
"Need BindFlags, current flag 0x%x", dmem->desc.BindFlags);
if (!(mem->desc.BindFlags & D3D11_BIND_SHADER_RESOURCE)) {
GST_WARNING_OBJECT (GST_MEMORY_CAST (mem)->allocator,
"Need BindFlags, current flag 0x%x", mem->desc.BindFlags);
return FALSE;
}
gst_d3d11_device_thread_add (dmem->device,
gst_d3d11_device_thread_add (mem->device,
(GstD3D11DeviceThreadFunc) create_shader_resource_views, mem);
return ! !dmem->num_shader_resource_views;
return ! !mem->num_shader_resource_views;
}
gboolean
gst_d3d11_memory_ensure_render_target_view (GstMemory * mem)
gst_d3d11_memory_ensure_render_target_view (GstD3D11Memory * mem)
{
GstD3D11Memory *dmem;
g_return_val_if_fail (gst_is_d3d11_memory (GST_MEMORY_CAST (mem)), FALSE);
g_return_val_if_fail (gst_is_d3d11_memory (mem), FALSE);
dmem = (GstD3D11Memory *) mem;
if (dmem->num_render_target_views)
if (mem->num_render_target_views)
return TRUE;
if (!(dmem->desc.BindFlags & D3D11_BIND_RENDER_TARGET)) {
GST_WARNING_OBJECT (mem->allocator,
"Need BindFlags, current flag 0x%x", dmem->desc.BindFlags);
if (!(mem->desc.BindFlags & D3D11_BIND_RENDER_TARGET)) {
GST_WARNING_OBJECT (GST_MEMORY_CAST (mem)->allocator,
"Need BindFlags, current flag 0x%x", mem->desc.BindFlags);
return FALSE;
}
gst_d3d11_device_thread_add (dmem->device,
gst_d3d11_device_thread_add (mem->device,
(GstD3D11DeviceThreadFunc) create_render_target_views, mem);
return ! !dmem->num_render_target_views;
return ! !mem->num_render_target_views;
}

View file

@ -163,9 +163,9 @@ GstMemory * gst_d3d11_allocator_alloc (GstD3D11Allocator * allocator
gboolean gst_is_d3d11_memory (GstMemory * mem);
gboolean gst_d3d11_memory_ensure_shader_resource_view (GstMemory * mem);
gboolean gst_d3d11_memory_ensure_shader_resource_view (GstD3D11Memory * mem);
gboolean gst_d3d11_memory_ensure_render_target_view (GstMemory * mem);
gboolean gst_d3d11_memory_ensure_render_target_view (GstD3D11Memory * mem);
G_END_DECLS

View file

@ -672,7 +672,7 @@ gst_d3d11_video_sink_show_frame (GstVideoSink * sink, GstBuffer * buf)
break;
}
if (self->need_srv && !gst_d3d11_memory_ensure_shader_resource_view (mem)) {
if (self->need_srv && !gst_d3d11_memory_ensure_shader_resource_view (dmem)) {
GST_LOG_OBJECT (sink,
"shader resource view is unavailable, need fallback");
render_buf = NULL;
@ -743,8 +743,7 @@ gst_d3d11_video_sink_show_frame (GstVideoSink * sink, GstBuffer * buf)
gst_memory_unmap (GST_MEMORY_CAST (dmem), &info);
if (self->need_srv &&
!gst_d3d11_memory_ensure_shader_resource_view (GST_MEMORY_CAST
(dmem))) {
!gst_d3d11_memory_ensure_shader_resource_view (dmem)) {
GST_ERROR_OBJECT (self, "shader resource view is not available");
gst_buffer_unref (render_buf);