Ejemplo n.º 1
0
        internal static void _ctor(ref D3D12MA_Pool pThis, ref D3D12MA_Allocator allocator, [NativeTypeName("const D3D12MA_POOL_DESC&")] D3D12MA_POOL_DESC *desc)
        {
            D3D12MA_IUnknownImpl._ctor(ref pThis.m_IUnknownImpl, Vtbl);

            pThis.m_Allocator   = (D3D12MA_Allocator *)Unsafe.AsPointer(ref allocator);
            pThis.m_Desc        = *desc;
            pThis.m_BlockVector = null;
            pThis.m_Name        = null;
            pThis.m_PrevPool    = null;
            pThis.m_NextPool    = null;

            bool  explicitBlockSize  = desc->BlockSize != 0;
            ulong preferredBlockSize = explicitBlockSize ? desc->BlockSize : D3D12MA_DEFAULT_BLOCK_SIZE;

            D3D12_HEAP_FLAGS heapFlags     = desc->HeapFlags;
            uint             maxBlockCount = desc->MaxBlockCount != 0 ? desc->MaxBlockCount : uint.MaxValue;

            pThis.m_BlockVector = D3D12MA_NEW <D3D12MA_BlockVector>(allocator.GetAllocs());
            D3D12MA_BlockVector._ctor(
                ref *pThis.m_BlockVector,
                (D3D12MA_Allocator *)Unsafe.AsPointer(ref allocator),
                &desc->HeapProperties,
                heapFlags,
                preferredBlockSize,
                desc->MinBlockCount, maxBlockCount,
                explicitBlockSize,
                D3D12MA_MAX(desc->MinAllocationAlignment, D3D12MA_DEBUG_ALIGNMENT)
                );
        }
        internal static void _ctor(ref D3D12MA_VirtualBlock pThis, D3D12MA_ALLOCATION_CALLBACKS *allocationCallbacks, [NativeTypeName("UINT64")] ulong size)
        {
            D3D12MA_IUnknownImpl._ctor(ref pThis.m_IUnknownImpl, Vtbl);

            pThis.m_AllocationCallbacks = *allocationCallbacks;
            pThis.m_Size = size;

            D3D12MA_BlockMetadata_Generic._ctor(ref pThis.m_Metadata, (D3D12MA_ALLOCATION_CALLBACKS *)Unsafe.AsPointer(ref pThis.m_AllocationCallbacks), true); // isVirtual

            pThis.m_Metadata.Init(pThis.m_Size);
        }