Module: Mesa
Branch: master
Commit: 95527fe22926af9e2d7cbcffe23216ab2837cd85
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=95527fe22926af9e2d7cbcffe23216ab2837cd85

Author: Dave Airlie <[email protected]>
Date:   Thu Oct 29 07:15:02 2020 +1000

clover/module: add a printf support to module (v5)

This adds storage for printf formats encoded as number of
argument sizes + the printf format string, and storage
for sideband printf strings if the backend wants them.

It adds a flag that decides if the backend wants AMD (LLVM)
behaviour or NIR wrt the format of the global buffer and
how to decode strings.

Based on work by EdB in his printf support, but made useful
to be generic.

I'm not a huge fan of the buffer format flag, but this was
the easiest way to denote the llvm abi buffer format.

v3: rename buffer fmt

v4: use a single strings storage and one struct

v5: move printf_info into module, cleanup serialisation struct

Reviewed-by: Francisco Jerez <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8254>

---

 src/gallium/frontends/clover/core/module.cpp | 13 +++++++++++++
 src/gallium/frontends/clover/core/module.hpp |  8 ++++++++
 2 files changed, 21 insertions(+)

diff --git a/src/gallium/frontends/clover/core/module.cpp 
b/src/gallium/frontends/clover/core/module.cpp
index b9510168558..0071ebef8e3 100644
--- a/src/gallium/frontends/clover/core/module.cpp
+++ b/src/gallium/frontends/clover/core/module.cpp
@@ -155,6 +155,17 @@ namespace {
       }
    };
 
+   /// (De)serialize a printf format
+   template<>
+   struct _serializer<module::printf_info> {
+      template<typename S, typename QT>
+      static void
+      proc(S & s, QT &x) {
+         _proc(s, x.arg_sizes);
+         _proc(s, x.strings);
+      }
+   };
+
    /// (De)serialize a module::section.
    template<>
    struct _serializer<module::section> {
@@ -206,6 +217,8 @@ namespace {
       proc(S &s, QT &x) {
          _proc(s, x.syms);
          _proc(s, x.secs);
+         _proc(s, x.printf_infos);
+         _proc(s, x.printf_strings_in_buffer);
       }
    };
 };
diff --git a/src/gallium/frontends/clover/core/module.hpp 
b/src/gallium/frontends/clover/core/module.hpp
index 92c090f70d7..01694b83222 100644
--- a/src/gallium/frontends/clover/core/module.hpp
+++ b/src/gallium/frontends/clover/core/module.hpp
@@ -55,6 +55,11 @@ namespace clover {
          std::vector<char> data;
       };
 
+      struct printf_info {
+         std::vector<uint32_t> arg_sizes;
+         std::vector<uint8_t> strings;
+      };
+
       struct arg_info {
          arg_info(const std::string &arg_name, const std::string &type_name,
                   const cl_kernel_arg_type_qualifier type_qualifier,
@@ -153,6 +158,9 @@ namespace clover {
 
       std::vector<symbol> syms;
       std::vector<section> secs;
+      std::vector<printf_info> printf_infos;
+      // printfs strings stored in output buffer
+      uint32_t printf_strings_in_buffer;
    };
 }
 

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to