From 782931530579b702e3f70ec3ffd844fccfacad28 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sun, 31 Mar 2024 20:28:27 +0900 Subject: [PATCH] d3d12memory: Define new D3D12 map flags Define GST_MAP_READ_D3D12 and GST_MAP_READ_D3D12 flags Part-of: --- .../gst-plugins-bad/sys/d3d12/gstd3d12encoder.cpp | 6 ++---- .../sys/d3d12/gstd3d12graphicscapture.cpp | 3 +-- .../gst-plugins-bad/sys/d3d12/gstd3d12ipcsink.cpp | 3 +-- .../gst-plugins-bad/sys/d3d12/gstd3d12memory.h | 14 ++++++++++++++ .../sys/d3d12/gstd3d12pluginutils.cpp | 6 ++---- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12encoder.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12encoder.cpp index 02bd755a9a..b047b53474 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12encoder.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12encoder.cpp @@ -704,8 +704,7 @@ gst_d3d12_encoder_upload_frame (GstD3D12Encoder * self, GstBuffer * buffer) auto dmem = GST_D3D12_MEMORY_CAST (mem); if (gst_d3d12_device_is_equal (dmem->device, self->device)) { GstMapInfo map_info; - if (!gst_memory_map (mem, &map_info, - (GstMapFlags) (GST_MAP_READ | GST_MAP_D3D12))) { + if (!gst_memory_map (mem, &map_info, GST_MAP_READ_D3D12)) { GST_ERROR_OBJECT (self, "Couldn't map memory"); return nullptr; } @@ -813,8 +812,7 @@ gst_d3d12_encoder_upload_frame (GstD3D12Encoder * self, GstBuffer * buffer) GstMapInfo map_info; mem = gst_buffer_peek_memory (upload, 0); - if (!gst_memory_map (mem, &map_info, - (GstMapFlags) (GST_MAP_READ | GST_MAP_D3D12))) { + if (!gst_memory_map (mem, &map_info, GST_MAP_READ_D3D12)) { GST_ERROR_OBJECT (self, "Couldn't map memory"); gst_buffer_unref (upload); return nullptr; diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12graphicscapture.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12graphicscapture.cpp index f0f45535ab..0b4f9f168a 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12graphicscapture.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12graphicscapture.cpp @@ -582,8 +582,7 @@ public: shared_data, (GDestroyNotify) shared_texture_data_free); } - if (!gst_memory_map (mem, - &map_info, (GstMapFlags) (GST_MAP_WRITE | GST_MAP_D3D12))) { + if (!gst_memory_map (mem, &map_info, GST_MAP_WRITE_D3D12)) { GST_ERROR_OBJECT (obj_, "Couldn't map memory"); gst_buffer_unref (outbuf); return GST_FLOW_ERROR; diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12ipcsink.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12ipcsink.cpp index 9477338cc7..03d3f53b4a 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12ipcsink.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12ipcsink.cpp @@ -620,8 +620,7 @@ gst_d3d12_ipc_sink_prepare (GstBaseSink * sink, GstBuffer * buf) dmem = (GstD3D12Memory *) gst_buffer_peek_memory (uploaded, 0); /* Upload staging to device memory */ - if (!gst_video_frame_map (&frame, &priv->info, uploaded, - (GstMapFlags) (GST_MAP_READ | GST_MAP_D3D12))) { + if (!gst_video_frame_map (&frame, &priv->info, uploaded, GST_MAP_READ_D3D12)) { GST_ERROR_OBJECT (self, "Couldn't upload memory"); gst_buffer_unref (uploaded); return GST_FLOW_ERROR; diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12memory.h b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12memory.h index 8afdbb3518..74b49fb501 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12memory.h +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12memory.h @@ -68,6 +68,20 @@ G_BEGIN_DECLS */ #define GST_MAP_D3D12 (GST_MAP_FLAG_LAST << 1) +/** + * GST_MAP_READ_D3D12: + * + * GstMapFlags value alias for GST_MAP_READ | GST_MAP_D3D12 + */ +#define GST_MAP_READ_D3D12 ((GstMapFlags) (GST_MAP_READ | GST_MAP_D3D12)) + +/** + * GST_MAP_WRITE_D3D12: + * + * GstMapFlags value alias for GST_MAP_WRITE | GST_MAP_D3D12 + */ +#define GST_MAP_WRITE_D3D12 ((GstMapFlags) (GST_MAP_WRITE | GST_MAP_D3D12)) + /** * GstD3D12MemoryTransfer: * diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp index ccd795aae3..f6cfdfd8eb 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12pluginutils.cpp @@ -228,15 +228,13 @@ gst_d3d12_buffer_copy_into (GstBuffer * dst, GstBuffer * src, /* Map memory to execute pending upload and wait for external fence */ GstMapInfo map_info; - if (!gst_memory_map (src_mem, &map_info, - (GstMapFlags) (GST_MAP_READ | GST_MAP_D3D12))) { + if (!gst_memory_map (src_mem, &map_info, GST_MAP_READ_D3D12)) { GST_ERROR ("Cannot map src d3d12 memory"); return FALSE; } gst_memory_unmap (src_mem, &map_info); - if (!gst_memory_map (dst_mem, &map_info, - (GstMapFlags) (GST_MAP_WRITE | GST_MAP_D3D12))) { + if (!gst_memory_map (dst_mem, &map_info, GST_MAP_WRITE_D3D12)) { GST_ERROR ("Cannot map dst d3d12 memory"); return FALSE; }