[Mesa-dev] [PATCH 2/2] clover: allow driver to override transfer pitch

Zoltan Gilian zoltan.gilian at gmail.com
Thu Jul 30 15:04:12 PDT 2015


The driver may set the pitch of a 2d or 3d mapping.
---
 src/gallium/state_trackers/clover/api/transfer.cpp  | 13 ++++++++-----
 src/gallium/state_trackers/clover/core/resource.hpp |  8 ++++++++
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/transfer.cpp b/src/gallium/state_trackers/clover/api/transfer.cpp
index f21819f..8bd4aa0 100644
--- a/src/gallium/state_trackers/clover/api/transfer.cpp
+++ b/src/gallium/state_trackers/clover/api/transfer.cpp
@@ -218,8 +218,11 @@ namespace {
       static mapping
       get(command_queue &q, image *obj, cl_map_flags flags,
           const vector_t& origin, const vector_t& region,
-          const vector_t& pitch) {
-         return { q, obj->resource(q), flags, true, origin, region };
+          vector_t& pitch) {
+         mapping res{ q, obj->resource(q), flags, true, origin, region };
+         pitch[1] = res.get_row_pitch();
+         pitch[2] = res.get_slice_pitch();
+         return res;
       }
    };
 
@@ -250,10 +253,10 @@ namespace {
    template<typename T, typename S>
    std::function<void (event &)>
    soft_copy_op(command_queue &q,
-                T dst_obj, const vector_t &dst_orig, const vector_t &dst_pitch,
-                S src_obj, const vector_t &src_orig, const vector_t &src_pitch,
+                T dst_obj, const vector_t &dst_orig, vector_t dst_pitch,
+                S src_obj, const vector_t &src_orig, vector_t src_pitch,
                 const vector_t &region) {
-      return [=, &q](event &) {
+      return [=, &q](event &) mutable {
          auto dst = _map<T>::get(q, dst_obj, CL_MAP_WRITE,
                                  dst_orig, region, dst_pitch);
          auto src = _map<S>::get(q, src_obj, CL_MAP_READ,
diff --git a/src/gallium/state_trackers/clover/core/resource.hpp b/src/gallium/state_trackers/clover/core/resource.hpp
index 9993dcb..90f74fd 100644
--- a/src/gallium/state_trackers/clover/core/resource.hpp
+++ b/src/gallium/state_trackers/clover/core/resource.hpp
@@ -122,6 +122,14 @@ namespace clover {
          return (T *)p;
       }
 
+      unsigned get_row_pitch() const {
+         return pxfer->stride;
+      }
+
+      unsigned get_slice_pitch() const {
+         return pxfer->layer_stride;
+      }
+
    private:
       pipe_context *pctx;
       pipe_transfer *pxfer;
-- 
2.4.6



More information about the mesa-dev mailing list