public VulkanMemoryBlock(VulkanMemoryAllocator allocator, VulkanMemoryPool?pool, int memoryTypeIndex, DeviceMemory memory, uint id, IBlockMetadata metaObject) { Allocator = allocator; ParentPool = pool; MemoryTypeIndex = memoryTypeIndex; DeviceMemory = memory; ID = id; MetaData = metaObject; }
protected AllocatorAndBuffersExample() : base() { scheduler = new WaitScheduler(Device); this.Allocator = CreateAllocator(); CreateBuffers(); CreateUniformBuffer(); CreateDepthBuffer(); }
public void CheckCorruption(VulkanMemoryAllocator allocator) { var data = this.Map(1); try { this.MetaData.CheckCorruption((nuint)(nint)data); } finally { this.Unmap(1); } }
public BlockList(VulkanMemoryAllocator allocator, VulkanMemoryPool?pool, int memoryTypeIndex, long preferredBlockSize, int minBlockCount, int maxBlockCount, long bufferImageGranularity, int frameInUseCount, bool explicitBlockSize, Func <long, IBlockMetadata> algorithm) { this.Allocator = allocator; this.ParentPool = pool; this.MemoryTypeIndex = memoryTypeIndex; this.PreferredBlockSize = preferredBlockSize; this.minBlockCount = minBlockCount; this.maxBlockCount = maxBlockCount; this.BufferImageGranularity = bufferImageGranularity; this.FrameInUseCount = frameInUseCount; this.explicitBlockSize = explicitBlockSize; metaObjectCreate = algorithm; }
internal VulkanMemoryPool(VulkanMemoryAllocator allocator, in AllocationPoolCreateInfo poolInfo, long preferredBlockSize)
internal DefragmentationContext(VulkanMemoryAllocator allocator, uint currentFrame, uint flags, DefragmentationStats stats) { throw new NotImplementedException(); }
internal BlockAllocation(VulkanMemoryAllocator allocator, int currentFrameIndex) : base(allocator, currentFrameIndex) { }
public DedicatedAllocation(VulkanMemoryAllocator allocator, int memTypeIndex, DeviceMemory memory, SuballocationType suballocType, IntPtr mappedData, long size) : base(allocator, 0) { this.memory = memory; this.mappedData = mappedData; this.memoryTypeIndex = memTypeIndex; }
public unsafe void Initialize( int maxFrames, QueueManager queueManager, Vk vk, Instance instance, Device device, PhysicalDevice physicalDevice #if DEBUG , ExtDebugUtils debugUtils #endif ) { #if DEBUG _debugUtils = debugUtils; #endif _vma = new VulkanMemoryAllocator(new VulkanMemoryAllocatorCreateInfo(new Version32(1, 1, 0), vk, instance, physicalDevice, device, AllocatorCreateFlags.BufferDeviceAddress)); _frames = new FrameData[maxFrames]; _queueManager = queueManager; _vk = vk; _instance = instance; _device = device; // if (!_vk.TryGetDeviceExtension(_instance, _device, out _khrSynchronization2)) // throw new Exception($"{KhrSynchronization2.ExtensionName} not found!"); Console.WriteLine("Initializing Render Graph"); (QueueFamilyIndex, Queue) = _queueManager.GetQueue(true, true, false, true); Console.WriteLine("Creating Command Pools"); for (int i = 0; i < _frames.Length; i++) { _vk.CreateCommandPool(_device, new CommandPoolCreateInfo(queueFamilyIndex: QueueFamilyIndex), null, out var commandPool).ThrowCode(); _frames[i] = new FrameData(commandPool); } Console.WriteLine("Creating Descriptor Layout"); var bindings = stackalloc DescriptorSetLayoutBinding[] { new DescriptorSetLayoutBinding(0, DescriptorType.StorageImage, 1, ShaderStageFlags.ShaderStageComputeBit, null), new DescriptorSetLayoutBinding(1, DescriptorType.StorageBuffer, 1, ShaderStageFlags.ShaderStageComputeBit, null), }; _vk.CreateDescriptorSetLayout(_device, new DescriptorSetLayoutCreateInfo(bindingCount: 2, pBindings: bindings), null, out var setLayout).ThrowCode(); _setLayout = setLayout; Name(ObjectType.DescriptorSetLayout, _setLayout.Handle, "Primary Set Layout"); var pushConstantRange = new PushConstantRange(ShaderStageFlags.ShaderStageComputeBit, 0, sizeof(uint) * 2); _vk.CreatePipelineLayout(_device, new PipelineLayoutCreateInfo(setLayoutCount: 1, pSetLayouts: &setLayout, pushConstantRangeCount: 1, pPushConstantRanges: &pushConstantRange), null, out _pipelineLayout).ThrowCode(); Name(ObjectType.PipelineLayout, _pipelineLayout.Handle, "Primary Pipeline Layout"); Console.WriteLine("Loading Primary Compute"); _computeShader = new ComputeShader(vk, instance, device, physicalDevice, _pipelineLayout, (ReadOnlySpan <byte>)File.ReadAllBytes("./shaders/compute.spv"), "main", null); _vk.GetPhysicalDeviceMemoryProperties(physicalDevice, out var memoryProperties); _memoryTypes = new MemoryType[32]; new Span <MemoryType>(&memoryProperties.MemoryTypes.Element0, 32).CopyTo(_memoryTypes); EngineContext = new EngineContext(); Console.WriteLine("Done Initializing Render Graph"); }
public FastDefragAlgorithm(VulkanMemoryAllocator allocator, BlockList list, uint currentFrame, bool overlappingMoveSupported) : base(allocator, list, currentFrame) { this.overlappingMoveSupported = overlappingMoveSupported; }
public BlockListDefragmentationContext(VulkanMemoryAllocator allocator, VulkanMemoryPool?customPool, BlockList list, uint currentFrame) { }
protected DefragmentationAlgorithm(VulkanMemoryAllocator allocator, BlockList list, uint currentFrame) { this.Allocator = allocator; this.BlockList = list; this.CurrentFrame = currentFrame; }