@@ -32,15 +32,6 @@ If you have questions concerning this license or the applicable additional terms
3232#include " ../BufferObject.h"
3333#include " Staging_VK.h"
3434
35- #if defined( ID_USE_AMD_ALLOCATOR )
36- #define VMA_IMPLEMENTATION
37-
38- #define VMA_MAX ( v1, v2 ) Max( (v1), (v2) )
39- #define VMA_MIN ( v1, v2 ) Min( (v1), (v2) )
40-
41- #include " vma.h"
42- #endif
43-
4435extern idCVar r_showBuffers;
4536
4637/*
@@ -108,7 +99,7 @@ bool idVertexBuffer::AllocBufferObject( const void * data, int allocSize, buffer
10899 vmaReq.flags = VMA_MEMORY_REQUIREMENT_PERSISTENT_MAP_BIT;
109100 }
110101
111- ID_VK_CHECK ( vmaCreateBuffer ( vmaAllocator, &bufferCreateInfo, &vmaReq, &m_apiObject, &m_allocation, NULL ) );
102+ ID_VK_CHECK ( vmaCreateBuffer ( vmaAllocator, &bufferCreateInfo, &vmaReq, &m_apiObject, &m_vmaAllocation, &m_allocation ) );
112103
113104#else
114105 VkResult ret = vkCreateBuffer ( vkcontext.device , &bufferCreateInfo, NULL , &m_apiObject );
@@ -167,9 +158,10 @@ void idVertexBuffer::FreeBufferObject() {
167158
168159 if ( m_apiObject != VK_NULL_HANDLE ) {
169160#if defined( ID_USE_AMD_ALLOCATOR )
170- vmaDestroyBuffer ( vmaAllocator, m_apiObject, m_allocation );
161+ vmaDestroyBuffer ( vmaAllocator, m_apiObject, m_vmaAllocation );
171162 m_apiObject = VK_NULL_HANDLE;
172- m_allocation = VmaAllocation ();
163+ m_allocation = VmaAllocationInfo ();
164+ m_vmaAllocation = NULL ;
173165#else
174166 vulkanAllocator.Free ( m_allocation );
175167 vkDestroyBuffer ( vkcontext.device , m_apiObject, NULL );
@@ -198,7 +190,7 @@ void idVertexBuffer::Update( const void * data, int size, int offset ) const {
198190 if ( m_usage == BU_DYNAMIC ) {
199191 CopyBuffer (
200192#if defined( ID_USE_AMD_ALLOCATOR )
201- (byte *)m_allocation-> GetMappedData () + GetOffset () + offset,
193+ (byte *)m_allocation. pMappedData + GetOffset () + offset,
202194#else
203195 m_allocation.data + GetOffset () + offset,
204196#endif
@@ -233,7 +225,7 @@ void * idVertexBuffer::MapBuffer( bufferMapType_t mapType ) {
233225 }
234226
235227#if defined( ID_USE_AMD_ALLOCATOR )
236- void * buffer = (byte *)m_allocation-> GetMappedData () + GetOffset ();
228+ void * buffer = (byte *)m_allocation. pMappedData + GetOffset ();
237229#else
238230 void * buffer = m_allocation.data + GetOffset ();
239231#endif
@@ -271,7 +263,8 @@ void idVertexBuffer::ClearWithoutFreeing() {
271263 m_offsetInOtherBuffer = OWNS_BUFFER_FLAG;
272264 m_apiObject = VK_NULL_HANDLE;
273265#if defined( ID_USE_AMD_ALLOCATOR )
274- m_allocation = VmaAllocation ();
266+ m_allocation = VmaAllocationInfo ();
267+ m_vmaAllocation = NULL ;
275268#else
276269 m_allocation.deviceMemory = VK_NULL_HANDLE;
277270#endif
@@ -332,7 +325,7 @@ bool idIndexBuffer::AllocBufferObject( const void * data, int allocSize, bufferU
332325 vmaReq.flags = VMA_MEMORY_REQUIREMENT_PERSISTENT_MAP_BIT;
333326 }
334327
335- ID_VK_CHECK ( vmaCreateBuffer ( vmaAllocator, &bufferCreateInfo, &vmaReq, &m_apiObject, &m_allocation, NULL ) );
328+ ID_VK_CHECK ( vmaCreateBuffer ( vmaAllocator, &bufferCreateInfo, &vmaReq, &m_apiObject, &m_vmaAllocation, &m_allocation ) );
336329
337330#else
338331 VkResult ret = vkCreateBuffer ( vkcontext.device , &bufferCreateInfo, NULL , &m_apiObject );
@@ -391,9 +384,10 @@ void idIndexBuffer::FreeBufferObject() {
391384
392385 if ( m_apiObject != VK_NULL_HANDLE ) {
393386#if defined( ID_USE_AMD_ALLOCATOR )
394- vmaDestroyBuffer ( vmaAllocator, m_apiObject, m_allocation );
387+ vmaDestroyBuffer ( vmaAllocator, m_apiObject, m_vmaAllocation );
395388 m_apiObject = VK_NULL_HANDLE;
396- m_allocation = VmaAllocation ();
389+ m_allocation = VmaAllocationInfo ();
390+ m_vmaAllocation = NULL ;
397391#else
398392 vulkanAllocator.Free ( m_allocation );
399393 vkDestroyBuffer ( vkcontext.device , m_apiObject, NULL );
@@ -422,7 +416,7 @@ void idIndexBuffer::Update( const void * data, int size, int offset ) const {
422416 if ( m_usage == BU_DYNAMIC ) {
423417 CopyBuffer (
424418#if defined( ID_USE_AMD_ALLOCATOR )
425- (byte *)m_allocation-> GetMappedData () + GetOffset () + offset,
419+ (byte *)m_allocation. pMappedData + GetOffset () + offset,
426420#else
427421 m_allocation.data + GetOffset () + offset,
428422#endif
@@ -457,7 +451,7 @@ void * idIndexBuffer::MapBuffer( bufferMapType_t mapType ) {
457451 }
458452
459453#if defined( ID_USE_AMD_ALLOCATOR )
460- void * buffer = (byte *)m_allocation-> GetMappedData () + GetOffset ();
454+ void * buffer = (byte *)m_allocation. pMappedData + GetOffset ();
461455#else
462456 void * buffer = m_allocation.data + GetOffset ();
463457#endif
@@ -495,7 +489,8 @@ void idIndexBuffer::ClearWithoutFreeing() {
495489 m_offsetInOtherBuffer = OWNS_BUFFER_FLAG;
496490 m_apiObject = VK_NULL_HANDLE;
497491#if defined( ID_USE_AMD_ALLOCATOR )
498- m_allocation = VmaAllocation ();
492+ m_allocation = VmaAllocationInfo ();
493+ m_vmaAllocation = NULL ;
499494#else
500495 m_allocation.deviceMemory = VK_NULL_HANDLE;
501496#endif
@@ -557,13 +552,13 @@ bool idUniformBuffer::AllocBufferObject( const void * data, int allocSize, buffe
557552 vmaReq.flags = VMA_MEMORY_REQUIREMENT_PERSISTENT_MAP_BIT;
558553 }
559554
560- ID_VK_CHECK ( vmaCreateBuffer ( vmaAllocator, &bufferCreateInfo, &vmaReq, &m_apiObject, &m_allocation, NULL ) );
555+ ID_VK_CHECK ( vmaCreateBuffer ( vmaAllocator, &bufferCreateInfo, &vmaReq, &m_apiObject, &m_vmaAllocation, &m_allocation ) );
561556
562557#else
563558 VkResult ret = vkCreateBuffer ( vkcontext.device , &bufferCreateInfo, NULL , &m_apiObject );
564559 assert ( ret == VK_SUCCESS );
565560
566- VkMemoryRequirements memoryRequirements;
561+ VkMemoryRequirements memoryRequirements = {} ;
567562 vkGetBufferMemoryRequirements ( vkcontext.device , m_apiObject, &memoryRequirements );
568563
569564 vulkanMemoryUsage_t memUsage = ( m_usage == BU_STATIC ) ? VULKAN_MEMORY_USAGE_GPU_ONLY : VULKAN_MEMORY_USAGE_CPU_TO_GPU;
@@ -616,9 +611,10 @@ void idUniformBuffer::FreeBufferObject() {
616611
617612 if ( m_apiObject != VK_NULL_HANDLE ) {
618613#if defined( ID_USE_AMD_ALLOCATOR )
619- vmaDestroyBuffer ( vmaAllocator, m_apiObject, m_allocation );
614+ vmaDestroyBuffer ( vmaAllocator, m_apiObject, m_vmaAllocation );
620615 m_apiObject = VK_NULL_HANDLE;
621- m_allocation = VmaAllocation ();
616+ m_allocation = VmaAllocationInfo ();
617+ m_vmaAllocation = NULL ;
622618#else
623619 vulkanAllocator.Free ( m_allocation );
624620 vkDestroyBuffer ( vkcontext.device , m_apiObject, NULL );
@@ -647,7 +643,7 @@ void idUniformBuffer::Update( const void * data, int size, int offset ) const {
647643 if ( m_usage == BU_DYNAMIC ) {
648644 CopyBuffer (
649645#if defined( ID_USE_AMD_ALLOCATOR )
650- (byte *)m_allocation-> GetMappedData () + GetOffset () + offset,
646+ (byte *)m_allocation. pMappedData + GetOffset () + offset,
651647#else
652648 m_allocation.data + GetOffset () + offset,
653649#endif
@@ -683,7 +679,7 @@ void * idUniformBuffer::MapBuffer( bufferMapType_t mapType ) {
683679 }
684680
685681#if defined( ID_USE_AMD_ALLOCATOR )
686- void * buffer = (byte *)m_allocation-> GetMappedData () + GetOffset ();
682+ void * buffer = (byte *)m_allocation. pMappedData + GetOffset ();
687683#else
688684 void * buffer = m_allocation.data + GetOffset ();
689685#endif
@@ -721,7 +717,8 @@ void idUniformBuffer::ClearWithoutFreeing() {
721717 m_offsetInOtherBuffer = OWNS_BUFFER_FLAG;
722718 m_apiObject = VK_NULL_HANDLE;
723719#if defined( ID_USE_AMD_ALLOCATOR )
724- m_allocation = VmaAllocation ();
720+ m_allocation = VmaAllocationInfo ();
721+ m_vmaAllocation = NULL ;
725722#else
726723 m_allocation.deviceMemory = VK_NULL_HANDLE;
727724#endif
0 commit comments