Revert "d3d11: Add support for D3D11_USAGE_DYNAMIC"
authorSeungha Yang <seungha.yang@navercorp.com>
Fri, 10 Jan 2020 11:44:19 +0000 (20:44 +0900)
committerSeungha Yang <seungha.yang@navercorp.com>
Mon, 13 Jan 2020 01:58:08 +0000 (01:58 +0000)
This reverts commit ddd13fc7c061a9873b181d0de32aaf9546e7d0af

Dynamic usage can reduce the number of copy per frame but make
things complicated and the benefit seems to not significant.
Also since we don't provide _map() method for the dynamic usage,
application cannot read buffers which make "last-sample" property
unusable in case of d3d11videosink.

13 files changed:
sys/d3d11/gstd3d11bufferpool.c
sys/d3d11/gstd3d11colorconvert.c
sys/d3d11/gstd3d11decoder.c
sys/d3d11/gstd3d11download.c
sys/d3d11/gstd3d11h264dec.c
sys/d3d11/gstd3d11h265dec.c
sys/d3d11/gstd3d11memory.c
sys/d3d11/gstd3d11memory.h
sys/d3d11/gstd3d11upload.c
sys/d3d11/gstd3d11utils.c
sys/d3d11/gstd3d11utils.h
sys/d3d11/gstd3d11videosink.c
sys/d3d11/gstd3d11vp9dec.c

index 63bd683..16f0e60 100644 (file)
@@ -153,7 +153,7 @@ gst_d3d11_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
   if (!priv->d3d11_params) {
     /* allocate memory with resource format by default */
     priv->d3d11_params = gst_d3d11_allocation_params_new (&info,
-        GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT, D3D11_USAGE_DEFAULT, 0);
+        GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT, 0);
   }
 #ifndef GST_DISABLE_GST_DEBUG
   {
index 38b788d..790cce7 100644 (file)
@@ -341,7 +341,7 @@ gst_d3d11_color_convert_propose_allocation (GstBaseTransform * trans,
   d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
   if (!d3d11_params) {
     d3d11_params = gst_d3d11_allocation_params_new (&info,
-        GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT, D3D11_USAGE_DEFAULT,
+        GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT,
         D3D11_BIND_SHADER_RESOURCE);
   } else {
     /* Set bind flag */
@@ -422,7 +422,7 @@ gst_d3d11_color_convert_decide_allocation (GstBaseTransform * trans,
   d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
   if (!d3d11_params) {
     d3d11_params = gst_d3d11_allocation_params_new (&info,
-        GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT, D3D11_USAGE_DEFAULT,
+        GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT,
         D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET);
   } else {
     /* Set bind flag */
index 2d4e4a7..9a1b42c 100644 (file)
@@ -394,8 +394,7 @@ gst_d3d11_decoder_prepare_output_view_pool (GstD3D11Decoder * self,
   gst_clear_object (&priv->internal_pool);
 
   alloc_params = gst_d3d11_allocation_params_new (info,
-      GST_D3D11_ALLOCATION_FLAG_TEXTURE_ARRAY, D3D11_USAGE_DEFAULT,
-      D3D11_BIND_DECODER);
+      GST_D3D11_ALLOCATION_FLAG_TEXTURE_ARRAY, D3D11_BIND_DECODER);
 
   if (!alloc_params) {
     GST_ERROR_OBJECT (self, "Failed to create allocation param");
index dc66ea4..1e46d20 100644 (file)
@@ -68,8 +68,6 @@ static gboolean gst_d3d11_download_decide_allocation (GstBaseTransform * trans,
     GstQuery * query);
 static GstFlowReturn gst_d3d11_download_transform (GstBaseTransform * trans,
     GstBuffer * inbuf, GstBuffer * outbuf);
-static gboolean gst_d3d11_download_query (GstBaseTransform * trans,
-    GstPadDirection direction, GstQuery * query);
 
 static void
 gst_d3d11_download_class_init (GstD3D11DownloadClass * klass)
@@ -94,7 +92,6 @@ gst_d3d11_download_class_init (GstD3D11DownloadClass * klass)
   trans_class->decide_allocation =
       GST_DEBUG_FUNCPTR (gst_d3d11_download_decide_allocation);
   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,
       "d3d11download", 0, "d3d11download Element");
@@ -319,28 +316,3 @@ invalid_buffer:
     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);
-}
index 966206d..971e533 100644 (file)
@@ -446,8 +446,7 @@ gst_d3d11_h264_dec_decide_allocation (GstVideoDecoder * decoder,
   if (self->use_d3d11_output) {
     d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
     if (!d3d11_params)
-      d3d11_params = gst_d3d11_allocation_params_new (&vinfo, 0,
-          D3D11_USAGE_DEFAULT, 0);
+      d3d11_params = gst_d3d11_allocation_params_new (&vinfo, 0, 0);
 
     /* dxva2 decoder uses non-resource format
      * (e.g., use NV12 instead of R8 + R8G8 */
index fec9d48..d7b54d3 100644 (file)
@@ -410,8 +410,7 @@ gst_d3d11_h265_dec_decide_allocation (GstVideoDecoder * decoder,
   if (self->use_d3d11_output) {
     d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
     if (!d3d11_params)
-      d3d11_params = gst_d3d11_allocation_params_new (&vinfo, 0,
-          D3D11_USAGE_DEFAULT, 0);
+      d3d11_params = gst_d3d11_allocation_params_new (&vinfo, 0, 0);
 
     /* dxva2 decoder uses non-resource format
      * (e.g., use NV12 instead of R8 + R8G8 */
index b2eacf4..02c96a9 100644 (file)
@@ -31,12 +31,11 @@ GST_DEBUG_CATEGORY_STATIC (gst_d3d11_allocator_debug);
 
 GstD3D11AllocationParams *
 gst_d3d11_allocation_params_new (GstVideoInfo * info,
-    GstD3D11AllocationFlags flags, D3D11_USAGE usage, gint bind_flags)
+    GstD3D11AllocationFlags flags, gint bind_flags)
 {
   GstD3D11AllocationParams *ret;
   const GstD3D11Format *d3d11_format;
   gint i;
-  gint cpu_access_flags;
 
   g_return_val_if_fail (info != NULL, NULL);
 
@@ -46,15 +45,6 @@ gst_d3d11_allocation_params_new (GstVideoInfo * info,
     return NULL;
   }
 
-  if (usage == D3D11_USAGE_DEFAULT) {
-    cpu_access_flags = 0;
-  } else if (usage == D3D11_USAGE_DYNAMIC) {
-    cpu_access_flags = D3D11_CPU_ACCESS_WRITE;
-  } else {
-    GST_FIXME ("Neither default nor dynamic usage");
-    return NULL;
-  }
-
   ret = g_new0 (GstD3D11AllocationParams, 1);
 
   ret->info = *info;
@@ -89,9 +79,8 @@ gst_d3d11_allocation_params_new (GstVideoInfo * info,
       ret->desc[i].Format = d3d11_format->resource_format[i];
       ret->desc[i].SampleDesc.Count = 1;
       ret->desc[i].SampleDesc.Quality = 0;
-      ret->desc[i].Usage = usage;
+      ret->desc[i].Usage = D3D11_USAGE_DEFAULT;
       ret->desc[i].BindFlags = bind_flags;
-      ret->desc[i].CPUAccessFlags = cpu_access_flags;
     }
   } else {
     g_assert (d3d11_format->dxgi_format != DXGI_FORMAT_UNKNOWN);
@@ -103,9 +92,8 @@ gst_d3d11_allocation_params_new (GstVideoInfo * info,
     ret->desc[0].Format = d3d11_format->dxgi_format;
     ret->desc[0].SampleDesc.Count = 1;
     ret->desc[0].SampleDesc.Quality = 0;
-    ret->desc[0].Usage = usage;
+    ret->desc[0].Usage = D3D11_USAGE_DEFAULT;
     ret->desc[0].BindFlags = bind_flags;
-    ret->desc[0].CPUAccessFlags = cpu_access_flags;
   }
 
   ret->flags = flags;
@@ -234,12 +222,6 @@ gst_d3d11_memory_map (GstMemory * mem, gsize maxsize, GstMapFlags flags)
 {
   GstD3D11Memory *dmem = (GstD3D11Memory *) mem;
 
-  if (dmem->desc.Usage == D3D11_USAGE_DYNAMIC) {
-    GST_FIXME_OBJECT (mem->allocator,
-        "D3D11_USAGE_DYNAMIC shouldn't be used with gst_memory_map");
-    return NULL;
-  }
-
   g_mutex_lock (&dmem->lock);
   if ((flags & GST_MAP_D3D11) == GST_MAP_D3D11) {
     if (dmem->staging &&
@@ -320,12 +302,6 @@ gst_d3d11_memory_unmap_full (GstMemory * mem, GstMapInfo * info)
 {
   GstD3D11Memory *dmem = (GstD3D11Memory *) mem;
 
-  if (dmem->desc.Usage == D3D11_USAGE_DYNAMIC) {
-    GST_FIXME_OBJECT (mem->allocator,
-        "D3D11_USAGE_DYNAMIC shouldn't be used with gst_memory_unmap");
-    return;
-  }
-
   g_mutex_lock (&dmem->lock);
   if ((info->flags & GST_MAP_D3D11) == GST_MAP_D3D11) {
     if ((info->flags & GST_MAP_WRITE) == GST_MAP_WRITE)
@@ -640,7 +616,6 @@ gst_d3d11_allocator_alloc (GstD3D11Allocator * allocator,
   D3D11_TEXTURE2D_DESC *desc;
   gsize *size;
   gboolean is_first = FALSE;
-  GstMemoryFlags memory_flags;
   guint index_to_use = 0;
   GstD3D11MemoryType type = GST_D3D11_MEMORY_TYPE_TEXTURE;
 
@@ -651,16 +626,6 @@ gst_d3d11_allocator_alloc (GstD3D11Allocator * allocator,
   desc = &params->desc[params->plane];
   size = &params->size[params->plane];
 
-  if (desc->Usage == D3D11_USAGE_DEFAULT) {
-    memory_flags = 0;
-  } else if (desc->Usage == D3D11_USAGE_DYNAMIC) {
-    /* FIXME: how we can make D3D11_USAGE_DYNAMIC work with GST_MAP_READWRITE ? */
-    memory_flags = GST_MEMORY_FLAG_NOT_MAPPABLE;
-  } else {
-    GST_FIXME_OBJECT (allocator, "Cannot support usage %d", desc->Usage);
-    return NULL;
-  }
-
   if (*size == 0)
     is_first = TRUE;
 
@@ -701,30 +666,19 @@ gst_d3d11_allocator_alloc (GstD3D11Allocator * allocator,
   /* per plane, allocated staging texture to calculate actual size,
    * stride, and offset */
   if (is_first) {
-    ID3D11Texture2D *target;
-    D3D11_MAP map_type;
     gint num_plane;
     gint stride[GST_VIDEO_MAX_PLANES];
     gsize mem_size;
     gint i;
 
-    if (desc->Usage == D3D11_USAGE_DEFAULT) {
-      staging = create_staging_texture (device, desc);
-      if (!staging) {
-        GST_ERROR_OBJECT (allocator, "Couldn't create staging texture");
-        goto error;
-      }
-
-      target = staging;
-      map_type = D3D11_MAP_READ;
-    } else if (desc->Usage == D3D11_USAGE_DYNAMIC) {
-      target = texture;
-      map_type = D3D11_MAP_WRITE_DISCARD;
-    } else {
-      g_assert_not_reached ();
+    staging = create_staging_texture (device, desc);
+    if (!staging) {
+      GST_ERROR_OBJECT (allocator, "Couldn't create staging texture");
+      goto error;
     }
 
-    if (!calculate_mem_size (device, target, desc, map_type, stride, &mem_size))
+    if (!calculate_mem_size (device,
+            staging, desc, D3D11_MAP_READ, stride, &mem_size))
       goto error;
 
     num_plane = gst_d3d11_dxgi_format_n_planes (desc->Format);
@@ -739,7 +693,7 @@ gst_d3d11_allocator_alloc (GstD3D11Allocator * allocator,
   mem = g_new0 (GstD3D11Memory, 1);
 
   gst_memory_init (GST_MEMORY_CAST (mem),
-      memory_flags, GST_ALLOCATOR_CAST (allocator), NULL, *size, 0, 0, *size);
+      0, GST_ALLOCATOR_CAST (allocator), NULL, *size, 0, 0, *size);
 
   g_mutex_init (&mem->lock);
   mem->info = params->info;
index 74a3d36..430f789 100644 (file)
@@ -163,7 +163,6 @@ GType               gst_d3d11_allocation_params_get_type (void);
 
 GstD3D11AllocationParams * gst_d3d11_allocation_params_new (GstVideoInfo * info,
                                                             GstD3D11AllocationFlags flags,
-                                                            D3D11_USAGE usage,
                                                             gint bind_flags);
 
 GstD3D11AllocationParams * gst_d3d11_allocation_params_copy (GstD3D11AllocationParams * src);
index 0437637..0485e62 100644 (file)
@@ -279,7 +279,6 @@ gst_d3d11_upload_decide_allocation (GstBaseTransform * trans, GstQuery * query)
   GstStructure *config;
   gboolean update_pool = FALSE;
   GstVideoInfo vinfo;
-  gint i;
 
   gst_query_parse_allocation (query, &outcaps, NULL);
 
@@ -311,45 +310,6 @@ gst_d3d11_upload_decide_allocation (GstBaseTransform * trans, GstQuery * query)
   gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META);
   gst_buffer_pool_config_set_params (config, outcaps, size, min, max);
 
-  {
-    GstQuery *usage_query;
-    gboolean can_dynamic = FALSE;
-
-    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_query_parse_d3d11_usage_result (usage_query, &can_dynamic);
-    gst_query_unref (usage_query);
-
-    if (can_dynamic) {
-      GstD3D11AllocationParams *d3d11_params;
-
-      GST_DEBUG_OBJECT (trans, "downstream support dynamic usage");
-
-      d3d11_params =
-          gst_buffer_pool_config_get_d3d11_allocation_params (config);
-      if (!d3d11_params) {
-        /* dynamic usage should have at least one bind flag.
-         * but followings are not allowed in this case
-         * D3D11_BIND_STREAM_OUTPUT
-         * D3D11_BIND_RENDER_TARGET
-         * D3D11_BIND_DEPTH_STENCIL
-         * D3D11_BIND_UNORDERED_ACCESS */
-        d3d11_params = gst_d3d11_allocation_params_new (&vinfo,
-            GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT,
-            D3D11_USAGE_DYNAMIC, D3D11_BIND_SHADER_RESOURCE);
-      } else {
-        for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
-          d3d11_params->desc[i].Usage = D3D11_USAGE_DYNAMIC;
-          d3d11_params->desc[i].CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
-        }
-      }
-
-      gst_buffer_pool_config_set_d3d11_allocation_params (config, d3d11_params);
-      gst_d3d11_allocation_params_free (d3d11_params);
-    }
-  }
-
   gst_buffer_pool_set_config (pool, config);
 
   /* update size with calculated one */
@@ -367,85 +327,11 @@ gst_d3d11_upload_decide_allocation (GstBaseTransform * trans, GstQuery * query)
 }
 
 static GstFlowReturn
-upload_transform_dynamic (GstD3D11BaseFilter * filter,
-    GstD3D11Device * device, GstBuffer * inbuf, GstBuffer * outbuf)
-{
-  GstVideoFrame in_frame;
-  gint i, j, k;
-  GstFlowReturn ret = GST_FLOW_OK;
-  ID3D11DeviceContext *device_context =
-      gst_d3d11_device_get_device_context_handle (device);
-
-  if (!gst_video_frame_map (&in_frame, &filter->in_info, inbuf,
-          GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF))
-    goto invalid_buffer;
-
-  gst_d3d11_device_lock (device);
-  for (i = 0, j = 0; i < gst_buffer_n_memory (outbuf); i++) {
-    GstD3D11Memory *dmem =
-        (GstD3D11Memory *) gst_buffer_peek_memory (outbuf, i);
-    D3D11_MAPPED_SUBRESOURCE map;
-    HRESULT hr;
-    D3D11_TEXTURE2D_DESC *desc = &dmem->desc;
-    gsize offset[GST_VIDEO_MAX_PLANES];
-    gint stride[GST_VIDEO_MAX_PLANES];
-    gsize dummy;
-
-    hr = ID3D11DeviceContext_Map (device_context,
-        (ID3D11Resource *) dmem->texture, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
-
-    if (!gst_d3d11_result (hr, device)) {
-      GST_ERROR_OBJECT (filter,
-          "Failed to map staging texture (0x%x)", (guint) hr);
-      gst_d3d11_device_unlock (device);
-      ret = GST_FLOW_ERROR;
-      goto done;
-    }
-
-    gst_d3d11_dxgi_format_get_size (desc->Format, desc->Width, desc->Height,
-        map.RowPitch, offset, stride, &dummy);
-
-    for (k = 0; k < gst_d3d11_dxgi_format_n_planes (dmem->desc.Format); k++) {
-      gint h, width;
-      guint8 *dst, *src;
-
-      dst = (guint8 *) map.pData + offset[k];
-      src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, j);
-      width = GST_VIDEO_FRAME_COMP_WIDTH (&in_frame, j) *
-          GST_VIDEO_FRAME_COMP_PSTRIDE (&in_frame, j);
-
-      for (h = 0; h < GST_VIDEO_FRAME_COMP_HEIGHT (&in_frame, j); h++) {
-        memcpy (dst, src, width);
-        dst += stride[k];
-        src += GST_VIDEO_FRAME_PLANE_STRIDE (&in_frame, j);
-      }
-
-      j++;
-    }
-
-    ID3D11DeviceContext_Unmap (device_context,
-        (ID3D11Resource *) dmem->texture, 0);
-  }
-  gst_d3d11_device_unlock (device);
-
-done:
-  gst_video_frame_unmap (&in_frame);
-
-  return ret;
-
-  /* ERRORS */
-invalid_buffer:
-  {
-    GST_ELEMENT_WARNING (filter, CORE, NOT_IMPLEMENTED, (NULL),
-        ("invalid video buffer received"));
-    return GST_FLOW_ERROR;
-  }
-}
-
-static GstFlowReturn
-upload_transform (GstD3D11BaseFilter * filter, GstBuffer * inbuf,
+gst_d3d11_upload_transform (GstBaseTransform * trans, GstBuffer * inbuf,
     GstBuffer * outbuf)
 {
+  GstD3D11BaseFilter *filter = GST_D3D11_BASE_FILTER (trans);
+
   GstVideoFrame in_frame, out_frame;
   gint i;
   GstFlowReturn ret = GST_FLOW_OK;
@@ -481,24 +367,3 @@ invalid_buffer:
     return GST_FLOW_ERROR;
   }
 }
-
-static GstFlowReturn
-gst_d3d11_upload_transform (GstBaseTransform * trans, GstBuffer * inbuf,
-    GstBuffer * outbuf)
-{
-  GstD3D11BaseFilter *filter = GST_D3D11_BASE_FILTER (trans);
-  GstMemory *mem;
-  GstD3D11Device *device;
-
-  mem = gst_buffer_peek_memory (outbuf, 0);
-  if (gst_is_d3d11_memory (mem)) {
-    GstD3D11Memory *dmem = (GstD3D11Memory *) mem;
-    device = dmem->device;
-
-    if (dmem->desc.Usage == D3D11_USAGE_DYNAMIC) {
-      return upload_transform_dynamic (filter, device, inbuf, outbuf);
-    }
-  }
-
-  return upload_transform (filter, inbuf, outbuf);
-}
index e396f3c..404dbde 100644 (file)
@@ -342,92 +342,6 @@ gst_d3d11_is_windows_8_or_greater (void)
   return ret;
 }
 
-GstQuery *
-gst_query_new_d3d11_usage (GstD3D11Device * device, D3D11_USAGE usage)
-{
-  GstQuery *query;
-  GstStructure *structure;
-
-  g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
-
-  structure = gst_structure_new ("GstQueryD3D11Usage",
-      "device", GST_TYPE_D3D11_DEVICE, device,
-      "usage", G_TYPE_INT, usage, "result", G_TYPE_BOOLEAN, FALSE, NULL);
-  query = gst_query_new_custom (GST_QUERY_CUSTOM, structure);
-
-  return query;
-}
-
-void
-gst_query_parse_d3d11_usage (GstQuery * query, GstD3D11Device ** device,
-    D3D11_USAGE * usage)
-{
-  const GstStructure *structure;
-
-  g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CUSTOM);
-
-  if (!gst_query_is_d3d11_usage (query))
-    return;
-
-  structure = gst_query_get_structure (query);
-
-  gst_structure_get (structure, "device", GST_TYPE_D3D11_DEVICE, device,
-      "usage", G_TYPE_INT, usage, NULL);
-}
-
-void
-gst_query_set_d3d11_usage_result (GstQuery * query, gboolean result)
-{
-  GstStructure *structure;
-  const gchar *name;
-
-  g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CUSTOM);
-  g_return_if_fail (gst_query_is_writable (query));
-
-  structure = gst_query_writable_structure (query);
-  name = gst_structure_get_name (structure);
-
-  g_return_if_fail (g_strcmp0 (name, "GstQueryD3D11Usage") == 0);
-  gst_structure_set (structure, "result", G_TYPE_BOOLEAN, result, NULL);
-}
-
-void
-gst_query_parse_d3d11_usage_result (GstQuery * query, gboolean * result)
-{
-  const GstStructure *structure;
-  const gchar *name;
-
-  g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CUSTOM);
-  g_return_if_fail (gst_query_is_writable (query));
-  g_return_if_fail (result != NULL);
-
-  structure = gst_query_get_structure (query);
-  name = gst_structure_get_name (structure);
-
-  g_return_if_fail (g_strcmp0 (name, "GstQueryD3D11Usage") == 0);
-
-  gst_structure_get (structure, "result", G_TYPE_BOOLEAN, result, NULL);
-}
-
-gboolean
-gst_query_is_d3d11_usage (GstQuery * query)
-{
-  const GstStructure *structure;
-
-  g_return_val_if_fail (GST_IS_QUERY (query), FALSE);
-
-  if (GST_QUERY_TYPE (query) != GST_QUERY_CUSTOM)
-    return FALSE;
-
-  structure = gst_query_get_structure (query);
-
-  if (!structure ||
-      g_strcmp0 (gst_structure_get_name (structure), "GstQueryD3D11Usage"))
-    return FALSE;
-
-  return TRUE;
-}
-
 /*
  * This is an incomplete matrix of in formats and a score for the prefered output
  * format.
index fc7b397..7616285 100644 (file)
@@ -42,21 +42,6 @@ gboolean        gst_d3d11_ensure_element_data       (GstElement * element,
 
 gboolean        gst_d3d11_is_windows_8_or_greater   (void);
 
-GstQuery *      gst_query_new_d3d11_usage           (GstD3D11Device * device,
-                                                     D3D11_USAGE usage);
-
-void            gst_query_parse_d3d11_usage         (GstQuery * query,
-                                                     GstD3D11Device ** device,
-                                                     D3D11_USAGE *usage);
-
-void            gst_query_set_d3d11_usage_result    (GstQuery * query,
-                                                     gboolean result);
-
-void            gst_query_parse_d3d11_usage_result  (GstQuery * query,
-                                                     gboolean * result);
-
-gboolean        gst_query_is_d3d11_usage            (GstQuery * query);
-
 GstCaps *       gst_d3d11_caps_fixate_format        (GstCaps * caps,
                                                      GstCaps * othercaps);
 
index 237a280..95f9174 100644 (file)
@@ -416,13 +416,11 @@ gst_d3d11_video_sink_set_caps (GstBaseSink * sink, GstCaps * caps)
     d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
     if (!d3d11_params) {
       d3d11_params = gst_d3d11_allocation_params_new (&self->info,
-          GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT, D3D11_USAGE_DYNAMIC,
+          GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT,
           D3D11_BIND_SHADER_RESOURCE);
     } else {
       /* Set bind flag */
       for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&self->info); i++) {
-        d3d11_params->desc[i].Usage = D3D11_USAGE_DYNAMIC;
-        d3d11_params->desc[i].CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
         d3d11_params->desc[i].BindFlags |= D3D11_BIND_SHADER_RESOURCE;
       }
     }
@@ -625,7 +623,7 @@ gst_d3d11_video_sink_propose_allocation (GstBaseSink * sink, GstQuery * query)
     d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
     if (!d3d11_params) {
       d3d11_params = gst_d3d11_allocation_params_new (&info,
-          GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT, D3D11_USAGE_DEFAULT,
+          GST_D3D11_ALLOCATION_FLAG_USE_RESOURCE_FORMAT,
           D3D11_BIND_SHADER_RESOURCE);
     } else {
       /* Set bind flag */
@@ -688,24 +686,6 @@ gst_d3d11_video_sink_query (GstBaseSink * sink, GstQuery * query)
         return TRUE;
       }
       break;
-    case GST_QUERY_CUSTOM:
-      if (gst_query_is_d3d11_usage (query)) {
-        D3D11_USAGE usage = D3D11_USAGE_DEFAULT;
-        GstD3D11Device *device;
-
-        gst_query_parse_d3d11_usage (query, &device, &usage);
-        if (device == self->device &&
-            (usage == D3D11_USAGE_DEFAULT || usage == D3D11_USAGE_DYNAMIC)) {
-          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;
-        }
-      }
-      break;
     default:
       break;
   }
index ea83c2e..d3f15d2 100644 (file)
@@ -415,8 +415,7 @@ gst_d3d11_vp9_dec_decide_allocation (GstVideoDecoder * decoder,
   if (self->use_d3d11_output) {
     d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
     if (!d3d11_params)
-      d3d11_params = gst_d3d11_allocation_params_new (&vinfo, 0,
-          D3D11_USAGE_DEFAULT, 0);
+      d3d11_params = gst_d3d11_allocation_params_new (&vinfo, 0, 0);
 
     /* dxva2 decoder uses non-resource format
      * (e.g., use NV12 instead of R8 + R8G8 */