64 if (this->hash ==
hash)
return *
this;
65 if (
refCnt > 0)
log_bad(
"Iache reference exists. you lost the hash. \n");
67 new (
this)
Iache(hash);
74 log_once(
" Call Swap Iache %d %x <=> %x , %x <=> %x \n",
refCnt, this->hach.
id, iach.hach.id, this->hash, iach.hash);
76 if (this->hash == iach.hash)
return *
this;
77 if (
refCnt > 0)
log_bad(
"Iache reference exists. you lost the hash. \n");
79 new (
this)
Iache(iach.hash);
80 this->hach.
id = iach.hach.id;
81 this->format = iach.format;
82 this->multisample = iach.multisample;
83 this->refCnt = iach.refCnt;
85 log_once(
" Call Swap view %x id %x hash %x version %x\n", this->vkI, this->hach.
id, this->hach.hash, this->hach.version);
89 static size_t rehash(std::string imgName,
size_t seed)
noexcept
91 static std::hash<std::string> h_img{};
92 static std::hash<size_t> h_seed{};
95 hash += h_img(imgName);
108 long cnt = InterlockedDecrement(&
refCnt);
109 log_once(
" Decrement Iache %d \n", cnt);
146 AcquireSRWLockExclusive(&
excl);
148 desc.info.buffer = VK_NULL_HANDLE;
150 ReleaseSRWLockExclusive(&
excl);
157 AcquireSRWLockExclusive(&
excl);
161 ReleaseSRWLockExclusive(&
excl);
197 if (
vkView != VK_NULL_HANDLE) {
198 vkDestroyBufferView($device,
vkView, NULL);
219 std::vector<VkBufferView>
view;
233 for (
auto& v :
view) {
234 if (v != VK_NULL_HANDLE) {
235 vkDestroyBufferView($device, v, NULL);
261 std::vector<VkDescriptorBufferInfo>
infos;
270 static inline VkDeviceSize alignedSize(VkDeviceSize sz, VkDeviceSize align)
272 return ((sz + align - 1) / (align)) * align;
275 VkDeviceSize
alignmentSB(T& bach,VkDeviceSize size,VkDeviceSize _alignment = 0) {
277 const VkDeviceSize maxChunk = 512 * 1024 * 1024;
278 if (_alignment == 0) {
279 VkPhysicalDeviceLimits& limits = $properties.limits;
280 _alignment = limits.minStorageBufferOffsetAlignment;
283 auto alignment = _alignment - (size % _alignment);
284 if (alignment < _alignment)
return size + alignment;
299 VkDescriptorBufferInfo
info = {
303 bach.infos.push_back(
info);
304 if (expect > 0) assert(bach.infos.size() == expect);
311 assert(bach.vkBuffer != VK_NULL_HANDLE);
312 for (
auto&
info : bach.infos)
info.buffer = bach.vkBuffer;
318#define $Policy_AllocateMemory Callback_vkAllocateMemory
319#define $Temperance Tempera
323template<
class Mem,
size_t Size>
327#define MemType(vk,sz) CacheVk<vk, sz>
328#define MemStatic(vk,sz) CacheVk<vk, sz> vk##Cache##sz
329#define Mem(vk,sz) vk##Cache##sz
330#define MemExtern(vk,sz) extern CacheVk<vk, sz> vk##Cache##sz
331#define MemClear(vk,sz) vk##Cache##sz.clear();
336#define OBJ_GEOM(obj) ((obj)->geometry->attributes->buffer)
struct StoBacheArray StoBacheArray
#define log_once(...)
DELETE ALL ^((?!\w).)*log_once(.*; ^((?!\w).)*log_once((.* )+?.*;.
std::string INPUT_String(arth::INPUT type)
std::queue< uint32_t > vacancy
Bache & operator=(const Bache &other)
static size_t rehash(std::string imgName, size_t seed) noexcept
Iache & operator=(T &iach)
Iache & operator=(size_t hash)
std::vector< VkDeviceSize > sizeSet
VkDescriptorBufferInfo info
std::vector< VkDescriptorBufferInfo > infos
std::vector< VkBufferView > view
bool operator<(const StoBache &rhs) const
VkDescriptorBufferInfo info
VkDescriptorBufferInfo info
std::string_view LayoutType