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

Author: Jan Vesely <jan.ves...@rutgers.edu>
Date:   Wed Mar  1 19:45:03 2017 -0500

clover: use pipe_resource references

v2: buffers are created with one reference.
v3: add pipe_resource reference to mapping object
v4: rename to pres and drop inline initializers

CC: "17.0 13.0" <mesa-sta...@lists.freedesktop.org>

Signed-off-by: Jan Vesely <jan.ves...@rutgers.edu>
Reviewed-by: Francisco Jerez <curroje...@riseup.net>

---

 src/gallium/state_trackers/clover/core/resource.cpp | 11 ++++++++---
 src/gallium/state_trackers/clover/core/resource.hpp |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/clover/core/resource.cpp 
b/src/gallium/state_trackers/clover/core/resource.cpp
index 06fd3f608f..28fba1ac1a 100644
--- a/src/gallium/state_trackers/clover/core/resource.cpp
+++ b/src/gallium/state_trackers/clover/core/resource.cpp
@@ -25,6 +25,7 @@
 #include "pipe/p_screen.h"
 #include "util/u_sampler.h"
 #include "util/u_format.h"
+#include "util/u_inlines.h"
 
 using namespace clover;
 
@@ -176,7 +177,7 @@ root_resource::root_resource(clover::device &dev, 
memory_obj &obj,
 }
 
 root_resource::~root_resource() {
-   device().pipe->resource_destroy(device().pipe, pipe);
+   pipe_resource_reference(&this->pipe, NULL);
 }
 
 sub_resource::sub_resource(resource &r, const vector &offset) :
@@ -189,7 +190,7 @@ mapping::mapping(command_queue &q, resource &r,
                  cl_map_flags flags, bool blocking,
                  const resource::vector &origin,
                  const resource::vector &region) :
-   pctx(q.pipe) {
+   pctx(q.pipe), pres(NULL) {
    unsigned usage = ((flags & CL_MAP_WRITE ? PIPE_TRANSFER_WRITE : 0 ) |
                      (flags & CL_MAP_READ ? PIPE_TRANSFER_READ : 0 ) |
                      (flags & CL_MAP_WRITE_INVALIDATE_REGION ?
@@ -202,12 +203,14 @@ mapping::mapping(command_queue &q, resource &r,
       pxfer = NULL;
       throw error(CL_OUT_OF_RESOURCES);
    }
+   pipe_resource_reference(&pres, r.pipe);
 }
 
 mapping::mapping(mapping &&m) :
-   pctx(m.pctx), pxfer(m.pxfer), p(m.p) {
+   pctx(m.pctx), pxfer(m.pxfer), pres(m.pres), p(m.p) {
    m.pctx = NULL;
    m.pxfer = NULL;
+   m.pres = NULL;
    m.p = NULL;
 }
 
@@ -215,12 +218,14 @@ mapping::~mapping() {
    if (pxfer) {
       pctx->transfer_unmap(pctx, pxfer);
    }
+   pipe_resource_reference(&pres, NULL);
 }
 
 mapping &
 mapping::operator=(mapping m) {
    std::swap(pctx, m.pctx);
    std::swap(pxfer, m.pxfer);
+   std::swap(pres, m.pres);
    std::swap(p, m.p);
    return *this;
 }
diff --git a/src/gallium/state_trackers/clover/core/resource.hpp 
b/src/gallium/state_trackers/clover/core/resource.hpp
index 9993dcb585..3b994b4008 100644
--- a/src/gallium/state_trackers/clover/core/resource.hpp
+++ b/src/gallium/state_trackers/clover/core/resource.hpp
@@ -125,6 +125,7 @@ namespace clover {
    private:
       pipe_context *pctx;
       pipe_transfer *pxfer;
+      pipe_resource *pres;
       void *p;
    };
 }

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to