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

Author: Timur Kristóf <[email protected]>
Date:   Mon Nov 27 22:04:54 2023 +0100

radv: Move SDMA function and struct declarations to a new header.

Very few parts of RADV actually need the SDMA functions, so
moving them to a separate header makes the driver cleaner and
also improves compilation time when SDMA functions change.

Signed-off-by: Timur Kristóf <[email protected]>
Reviewed-by: Tatsuyuki Ishi <[email protected]>
Reviewed-by: Samuel Pitoiset <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26353>

---

 src/amd/vulkan/meson.build             |  3 +-
 src/amd/vulkan/meta/radv_meta_buffer.c |  1 +
 src/amd/vulkan/meta/radv_meta_copy.c   |  1 +
 src/amd/vulkan/radv_private.h          | 13 -------
 src/amd/vulkan/radv_sdma.c             | 22 +----------
 src/amd/vulkan/radv_sdma.h             | 71 ++++++++++++++++++++++++++++++++++
 src/amd/vulkan/radv_shader.c           |  1 +
 7 files changed, 77 insertions(+), 35 deletions(-)

diff --git a/src/amd/vulkan/meson.build b/src/amd/vulkan/meson.build
index 9b2dc9463c2..f1f982e31e1 100644
--- a/src/amd/vulkan/meson.build
+++ b/src/amd/vulkan/meson.build
@@ -129,6 +129,7 @@ libradv_files = files(
   'radv_rt_shader.c',
   'radv_sampler.c',
   'radv_sdma.c',
+  'radv_sdma.h',
   'radv_shader.c',
   'radv_shader.h',
   'radv_shader_args.c',
@@ -292,7 +293,7 @@ if with_tests
       cpp_args : [cpp_msvc_compat_args],
       gnu_symbol_visibility : 'hidden',
       include_directories : [
-        inc_include, 
+        inc_include,
         inc_src,
         inc_mapi,
         inc_mesa,
diff --git a/src/amd/vulkan/meta/radv_meta_buffer.c 
b/src/amd/vulkan/meta/radv_meta_buffer.c
index 5432e65916a..fccf7ace12e 100644
--- a/src/amd/vulkan/meta/radv_meta_buffer.c
+++ b/src/amd/vulkan/meta/radv_meta_buffer.c
@@ -1,5 +1,6 @@
 #include "nir/nir_builder.h"
 #include "radv_meta.h"
+#include "radv_sdma.h"
 
 #include "radv_cs.h"
 #include "sid.h"
diff --git a/src/amd/vulkan/meta/radv_meta_copy.c 
b/src/amd/vulkan/meta/radv_meta_copy.c
index 6714b5f6fad..57fd8e1162c 100644
--- a/src/amd/vulkan/meta/radv_meta_copy.c
+++ b/src/amd/vulkan/meta/radv_meta_copy.c
@@ -23,6 +23,7 @@
 
 #include "radv_meta.h"
 #include "radv_private.h"
+#include "radv_sdma.h"
 #include "vk_format.h"
 
 static VkFormat
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 3f0da53d273..2af4a0e2cfb 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -2883,19 +2883,6 @@ void radv_rra_trace_init(struct radv_device *device);
 VkResult radv_rra_dump_trace(VkQueue vk_queue, char *filename);
 void radv_rra_trace_finish(VkDevice vk_device, struct radv_rra_trace_data 
*data);
 
-void radv_sdma_copy_buffer_image(const struct radv_device *device, struct 
radeon_cmdbuf *cs, struct radv_image *image,
-                                 struct radv_buffer *buffer, const 
VkBufferImageCopy2 *region, bool to_image);
-bool radv_sdma_use_unaligned_buffer_image_copy(const struct radv_device 
*device, const struct radv_image *image,
-                                               const struct radv_buffer 
*buffer, const VkBufferImageCopy2 *region);
-void radv_sdma_copy_buffer_image_unaligned(const struct radv_device *device, 
struct radeon_cmdbuf *cs,
-                                           struct radv_image *image, struct 
radv_buffer *buffer,
-                                           const VkBufferImageCopy2 *region, 
struct radeon_winsys_bo *temp_bo,
-                                           bool to_image);
-void radv_sdma_copy_buffer(const struct radv_device *device, struct 
radeon_cmdbuf *cs, uint64_t src_va, uint64_t dst_va,
-                           uint64_t size);
-void radv_sdma_fill_buffer(const struct radv_device *device, struct 
radeon_cmdbuf *cs, const uint64_t va,
-                           const uint64_t size, const uint32_t value);
-
 void radv_memory_trace_init(struct radv_device *device);
 void radv_rmv_log_bo_allocate(struct radv_device *device, struct 
radeon_winsys_bo *bo, uint32_t size, bool is_internal);
 void radv_rmv_log_bo_destroy(struct radv_device *device, struct 
radeon_winsys_bo *bo);
diff --git a/src/amd/vulkan/radv_sdma.c b/src/amd/vulkan/radv_sdma.c
index 2bc56d0e0f8..38278693de9 100644
--- a/src/amd/vulkan/radv_sdma.c
+++ b/src/amd/vulkan/radv_sdma.c
@@ -24,32 +24,12 @@
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include "radv_sdma.h"
 #include "util/macros.h"
 #include "util/u_memory.h"
 #include "radv_cs.h"
 #include "radv_private.h"
 
-struct radv_sdma_linear_info {
-   uint64_t va;
-   unsigned pitch;
-   unsigned slice_pitch;
-   unsigned bpp;
-   unsigned blk_w;
-   unsigned blk_h;
-};
-
-struct radv_sdma_tiled_info {
-   VkExtent3D extent;
-   uint64_t va;
-   uint64_t meta_va;
-   uint32_t meta_config;
-   uint32_t info_dword;
-   uint32_t header_dword;
-   unsigned bpp;
-   unsigned blk_w;
-   unsigned blk_h;
-};
-
 struct radv_sdma_chunked_copy_info {
    unsigned bpp;
    unsigned blk_w;
diff --git a/src/amd/vulkan/radv_sdma.h b/src/amd/vulkan/radv_sdma.h
new file mode 100644
index 00000000000..797bd3b98fd
--- /dev/null
+++ b/src/amd/vulkan/radv_sdma.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright © 2023 Valve 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 RADV_SDMA_H
+#define RADV_SDMA_H
+
+#include "radv_private.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct radv_sdma_linear_info {
+   uint64_t va;
+   unsigned pitch;
+   unsigned slice_pitch;
+   unsigned bpp;
+   unsigned blk_w;
+   unsigned blk_h;
+};
+
+struct radv_sdma_tiled_info {
+   VkExtent3D extent;
+   uint64_t va;
+   uint64_t meta_va;
+   uint32_t meta_config;
+   uint32_t info_dword;
+   uint32_t header_dword;
+   unsigned bpp;
+   unsigned blk_w;
+   unsigned blk_h;
+};
+
+void radv_sdma_copy_buffer_image(const struct radv_device *device, struct 
radeon_cmdbuf *cs, struct radv_image *image,
+                                 struct radv_buffer *buffer, const 
VkBufferImageCopy2 *region, bool to_image);
+bool radv_sdma_use_unaligned_buffer_image_copy(const struct radv_device 
*device, const struct radv_image *image,
+                                               const struct radv_buffer 
*buffer, const VkBufferImageCopy2 *region);
+void radv_sdma_copy_buffer_image_unaligned(const struct radv_device *device, 
struct radeon_cmdbuf *cs,
+                                           struct radv_image *image, struct 
radv_buffer *buffer,
+                                           const VkBufferImageCopy2 *region, 
struct radeon_winsys_bo *temp_bo,
+                                           bool to_image);
+void radv_sdma_copy_buffer(const struct radv_device *device, struct 
radeon_cmdbuf *cs, uint64_t src_va, uint64_t dst_va,
+                           uint64_t size);
+void radv_sdma_fill_buffer(const struct radv_device *device, struct 
radeon_cmdbuf *cs, const uint64_t va,
+                           const uint64_t size, const uint32_t value);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RADV_SDMA_H */
diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index 7b911a44906..ab6d0ff7a03 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -39,6 +39,7 @@
 #include "radv_cs.h"
 #include "radv_debug.h"
 #include "radv_private.h"
+#include "radv_sdma.h"
 #include "radv_shader_args.h"
 
 #include "util/u_debug.h"

Reply via email to