VulkanRaytracingCycles 0.0.0
Cycles Render Engine With VulkanRaytracingShaderModules. ( Experiment , in progress)
vkmm::VkMAInfo Struct Reference

#include <AllocatorVk.h>

Classes

struct  Header
 

Public Member Functions

template<class T >
VkStructureType setsType (T *i)
 
size_t getSize (Header *h)
 
template<typename T >
T * getStruct ()
 
template<>
float * getStruct ()
 
 VkMAInfo ()
 
template<typename T >
void append (T *&info)
 
void clear ()
 
 ~VkMAInfo ()
 

Public Attributes

struct vkmm::VkMAInfo::HeaderpCurr
 
std::size_t size
 

Detailed Description

Definition at line 414 of file AllocatorVk.h.

Inheritance diagram for vkmm::VkMAInfo:

Constructor & Destructor Documentation

◆ VkMAInfo()

vkmm::VkMAInfo::VkMAInfo ( )
inline

Definition at line 473 of file AllocatorVk.h.

473 :size(0) {
474
475 (*(VkMemoryAllocateInfo*)(this)) = VkMemoryAllocateInfo{ .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO };
476 pCurr = (Header*)(this);
477
478
479 };
std::size_t size
Definition: AllocatorVk.h:436
struct vkmm::VkMAInfo::Header * pCurr

◆ ~VkMAInfo()

vkmm::VkMAInfo::~VkMAInfo ( )
inline

Definition at line 514 of file AllocatorVk.h.

515 {
516 clear();
517 }

Member Function Documentation

◆ append()

template<typename T >
void vkmm::VkMAInfo::append ( T *&  info)
inline

BYTE* ptr = traits::allocate(alloc, size + n);

Definition at line 481 of file AllocatorVk.h.

481 {
482
483 size_t n = sizeof(T);
485 BYTE* ptr = new BYTE[n];
486 info = reinterpret_cast<T*>(ptr);
487 size += n;
488
489 pCurr->pNext = (void*)info;
490 pCurr = (Header*)info;
492 pCurr->pNext = nullptr;
493
494 }
VkStructureType sType
Definition: AllocatorVk.h:433
VkStructureType setsType(T *i)
Definition: AllocatorVk.h:438

◆ clear()

void vkmm::VkMAInfo::clear ( )
inline

Definition at line 495 of file AllocatorVk.h.

495 {
496
497 if (size > 0) {
498 auto h = (VkMAInfo::Header*)(this->pNext);
499 BYTE* data = nullptr;
500 size_t dsize = 0;
501 while (h) {
502 data = (BYTE*)h;
503 dsize = getSize(h);
504 h = (VkMAInfo::Header*)h->pNext;
505 memset(data, 0, dsize);
506 ::operator delete(data, dsize);
507 }
508 size = 0;
509 }
510 (*(VkMemoryAllocateInfo*)(this)) = VkMemoryAllocateInfo{ .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO };
511 pCurr = (Header*)(this);
512
513 }
size_t getSize(Header *h)
Definition: AllocatorVk.h:447

◆ getSize()

size_t vkmm::VkMAInfo::getSize ( Header h)
inline

Definition at line 447 of file AllocatorVk.h.

447 {
448 switch (h->sType)
449 {
450#define STYPE2SIZE(t,stype) case stype: return sizeof(t);
451 STYPE2SIZE(VkMemoryAllocateFlagsInfo, VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO)
452 STYPE2SIZE(VkMemoryDedicatedAllocateInfo, VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO)
453 default:
454 break;
455 }
456 assert(0);
457 return 0;
458 };
#define STYPE2SIZE(t, stype)

◆ getStruct() [1/2]

template<typename T >
T * vkmm::VkMAInfo::getStruct ( )
inline

Definition at line 460 of file AllocatorVk.h.

460 {
461 auto h = (VkMAInfo::Header*)(VkMemoryAllocateInfo::pNext);
462 VkStructureType stype = setsType((T*)h);
463 while (h) {
464 if (stype == h->sType) return (T*)h;
465 else h = (VkMAInfo::Header*)h->pNext;
466 }
467 return (T*)nullptr;
468 };

◆ getStruct() [2/2]

template<>
float * vkmm::VkMAInfo::getStruct ( )
inline

Definition at line 470 of file AllocatorVk.h.

470 {
471 return (float*)nullptr;
472 }

◆ setsType()

template<class T >
VkStructureType vkmm::VkMAInfo::setsType ( T *  i)
inline

Definition at line 438 of file AllocatorVk.h.

438 {
439 if (0) {}
440#define ST2STYPE(t,stype) else if (std::is_same<T, t>::value) return stype;
441 ST2STYPE(VkMemoryAllocateFlagsInfo, VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO)
442 ST2STYPE(VkMemoryDedicatedAllocateInfo, VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO)
443 ;
444 assert(0);
445 return (VkStructureType)0;
446 };
#define ST2STYPE(t, stype)

Member Data Documentation

◆ pCurr

struct vkmm::VkMAInfo::Header* vkmm::VkMAInfo::pCurr

◆ size

std::size_t vkmm::VkMAInfo::size

Definition at line 436 of file AllocatorVk.h.


The documentation for this struct was generated from the following file: