Module: Mesa
Branch: main
Commit: ef9c371f6026bad85d7053f636a4cb53b8a6c2d6
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ef9c371f6026bad85d7053f636a4cb53b8a6c2d6

Author: Yevhenii Kolesnikov <[email protected]>
Date:   Fri Apr  2 17:52:34 2021 +0300

vulkan: Add a common vk_command_buffer structure

This can be used e.g. for storing debug labels for the common
implementation of VK_EXT_debug_utils.

Signed-off-by: Yevhenii Kolesnikov <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13000>

---

 src/vulkan/util/meson.build         |  2 ++
 src/vulkan/util/vk_command_buffer.c | 46 +++++++++++++++++++++++++++++++
 src/vulkan/util/vk_command_buffer.h | 55 +++++++++++++++++++++++++++++++++++++
 3 files changed, 103 insertions(+)

diff --git a/src/vulkan/util/meson.build b/src/vulkan/util/meson.build
index cd87a69cbf3..6390fc9050f 100644
--- a/src/vulkan/util/meson.build
+++ b/src/vulkan/util/meson.build
@@ -52,6 +52,8 @@ files_vulkan_util = files(
   'vk_alloc.c',
   'vk_alloc.h',
   'vk_cmd_copy.c',
+  'vk_command_buffer.c',
+  'vk_command_buffer.h',
   'vk_debug_report.c',
   'vk_debug_report.h',
   'vk_deferred_operation.c',
diff --git a/src/vulkan/util/vk_command_buffer.c 
b/src/vulkan/util/vk_command_buffer.c
new file mode 100644
index 00000000000..23d2b669e2a
--- /dev/null
+++ b/src/vulkan/util/vk_command_buffer.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2021 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "vk_command_buffer.h"
+
+VkResult
+vk_command_buffer_init(struct vk_command_buffer *command_buffer,
+                       struct vk_device *device)
+{
+   memset(command_buffer, 0, sizeof(*command_buffer));
+   vk_object_base_init(device, &command_buffer->base,
+                       VK_OBJECT_TYPE_COMMAND_BUFFER);
+
+   return VK_SUCCESS;
+}
+
+void
+vk_command_buffer_reset(struct vk_command_buffer *command_buffer)
+{
+}
+
+void
+vk_command_buffer_finish(struct vk_command_buffer *command_buffer)
+{
+   vk_object_base_finish(&command_buffer->base);
+}
diff --git a/src/vulkan/util/vk_command_buffer.h 
b/src/vulkan/util/vk_command_buffer.h
new file mode 100644
index 00000000000..96caefe4ca9
--- /dev/null
+++ b/src/vulkan/util/vk_command_buffer.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2021 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef VK_COMMAND_BUFFER_H
+#define VK_COMMAND_BUFFER_H
+
+#include "vk_object.h"
+#include "util/u_dynarray.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct vk_command_buffer {
+   struct vk_object_base base;
+};
+
+VK_DEFINE_HANDLE_CASTS(vk_command_buffer, base, VkCommandBuffer,
+                       VK_OBJECT_TYPE_COMMAND_BUFFER)
+
+VkResult MUST_CHECK
+vk_command_buffer_init(struct vk_command_buffer *command_buffer,
+                       struct vk_device *device);
+
+void
+vk_command_buffer_reset(struct vk_command_buffer *command_buffer);
+
+void
+vk_command_buffer_finish(struct vk_command_buffer *command_buffer);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* VK_COMMAND_BUFFER_H */

Reply via email to