clover: Tidy up resource::mapping.
authorFrancisco Jerez <currojerez@riseup.net>
Mon, 16 Sep 2013 06:07:10 +0000 (23:07 -0700)
committerFrancisco Jerez <currojerez@riseup.net>
Mon, 21 Oct 2013 17:47:03 +0000 (10:47 -0700)
Tested-by: Tom Stellard <thomas.stellard@amd.com>
src/gallium/state_trackers/clover/core/resource.cpp
src/gallium/state_trackers/clover/core/resource.hpp

index c503c86d7716786e76929970038d8cfaf2b80288..7e6b51f7c62236e25a73766970b821129eeabab5 100644 (file)
@@ -71,7 +71,7 @@ resource::add_map(command_queue &q, cl_map_flags flags, bool blocking,
 
 void
 resource::del_map(void *p) {
-   erase_if([&](mapping &m) {
+   erase_if([&](const mapping &m) {
          return static_cast<void *>(m) == p;
       }, maps);
 }
@@ -185,8 +185,9 @@ mapping::mapping(command_queue &q, resource &r,
 
 mapping::mapping(mapping &&m) :
    pctx(m.pctx), pxfer(m.pxfer), p(m.p) {
-   m.p = NULL;
+   m.pctx = NULL;
    m.pxfer = NULL;
+   m.p = NULL;
 }
 
 mapping::~mapping() {
index f447088055a234a865738a5aaa35c93ca77e4ae2..7a6a3f19a239721a19d6b81e70164662613ec9ae 100644 (file)
@@ -62,7 +62,7 @@ namespace clover {
       friend class kernel;
 
    protected:
-      resource(device &dev, clover::memory_obj &obj);
+      resource(device &dev, memory_obj &obj);
 
       pipe_sampler_view *bind_sampler_view(command_queue &q);
       void unbind_sampler_view(command_queue &q,
@@ -86,8 +86,7 @@ namespace clover {
    public:
       root_resource(device &dev, memory_obj &obj,
                     command_queue &q, const std::string &data);
-      root_resource(device &dev, memory_obj &obj,
-                    root_resource &r);
+      root_resource(device &dev, memory_obj &obj, root_resource &r);
       virtual ~root_resource();
    };
 
@@ -109,19 +108,17 @@ namespace clover {
       mapping(command_queue &q, resource &r, cl_map_flags flags,
               bool blocking, const resource::vector &origin,
               const resource::vector &region);
-      mapping(const mapping &m) = delete;
       mapping(mapping &&m);
       ~mapping();
 
       mapping &
       operator=(mapping m);
 
-      operator void *() {
-         return p;
-      }
+      mapping(const mapping &m) = delete;
 
-      operator char *() {
-         return (char *)p;
+      template<typename T>
+      operator T *() const {
+         return (T *)p;
       }
 
    private: