Browse Source

merge refcount into buffer memory cookie

tags/20190320
nihui 7 years ago
parent
commit
0acdbebf3b
2 changed files with 8 additions and 8 deletions
  1. +2
    -0
      src/allocator.h
  2. +6
    -8
      src/mat.h

+ 2
- 0
src/allocator.h View File

@@ -199,6 +199,8 @@ public:
size_t capacity;
VkDeviceMemory memory;
void* mapped_ptr;
// initialize and modified by mat
int refcount;
};

class VkAllocator


+ 6
- 8
src/mat.h View File

@@ -1217,7 +1217,7 @@ inline void VkMat::create(int _w, size_t _elemsize, VkAllocator* _allocator, VkA

state = 1;

refcount = new int;
refcount = (int*)((unsigned char*)data + offsetof(VkBufferMemory, refcount));
*refcount = 1;
}
}
@@ -1250,7 +1250,7 @@ inline void VkMat::create(int _w, int _h, size_t _elemsize, VkAllocator* _alloca

state = 1;

refcount = new int;
refcount = (int*)((unsigned char*)data + offsetof(VkBufferMemory, refcount));
*refcount = 1;
}
}
@@ -1283,7 +1283,7 @@ inline void VkMat::create(int _w, int _h, int _c, size_t _elemsize, VkAllocator*

state = 1;

refcount = new int;
refcount = (int*)((unsigned char*)data + offsetof(VkBufferMemory, refcount));
*refcount = 1;
}
}
@@ -1316,7 +1316,7 @@ inline void VkMat::create(int _w, size_t _elemsize, int _packing, VkAllocator* _

state = 1;

refcount = new int;
refcount = (int*)((unsigned char*)data + offsetof(VkBufferMemory, refcount));
*refcount = 1;
}
}
@@ -1349,7 +1349,7 @@ inline void VkMat::create(int _w, int _h, size_t _elemsize, int _packing, VkAllo

state = 1;

refcount = new int;
refcount = (int*)((unsigned char*)data + offsetof(VkBufferMemory, refcount));
*refcount = 1;
}
}
@@ -1382,7 +1382,7 @@ inline void VkMat::create(int _w, int _h, int _c, size_t _elemsize, int _packing

state = 1;

refcount = new int;
refcount = (int*)((unsigned char*)data + offsetof(VkBufferMemory, refcount));
*refcount = 1;
}
}
@@ -1478,8 +1478,6 @@ inline void VkMat::release()
{
staging_allocator->fastFree(staging_data);
}

delete refcount;
}

data = 0;


Loading…
Cancel
Save