public DeviceMemory(Device device, MemoryRequirements requirements) { Device = device; MemoryType = requirements.FindMemoryType(PhysicalDevice); Logging.Allocations?.Trace( $"Allocating {Extensions.FormatFileSize(requirements.TypeRequirements.Size)} of {MemoryType.Flags} memory"); if (MemoryType == null) { throw new NotSupportedException($"Unable to find memory type for {requirements}"); } if (requirements.DedicatedMemory.RequirementLevel != MemoryRequirementLevel.None) { if (TryAllocateDedicated(requirements, MemoryType)) { return; } if (requirements.DedicatedMemory.RequirementLevel == MemoryRequirementLevel.Required) { throw new NotSupportedException($"Unable to allocate dedicated memory for {requirements}"); } } if (!TryAllocateNormal(requirements.TypeRequirements.Size, MemoryType)) { throw new NotSupportedException($"Failed to allocate memory for {requirements}"); } }
private static MemoryType FindDeviceMemory(PhysicalDevice dev, ulong capacity) { var req = new MemoryRequirements() { DeviceLocal = MemoryRequirementLevel.Required, TypeRequirements = new VkMemoryRequirements() { Size = capacity } }; return(req.FindMemoryType(dev)); }
public DeferredTransfer(Device dev, Queue transferQueue) { Device = dev; var reqs = new MemoryRequirements { HostVisible = MemoryRequirementLevel.Required, HostCoherent = MemoryRequirementLevel.Preferred }; _transferType = reqs.FindMemoryType(dev.PhysicalDevice); _transferQueue = transferQueue; _cmdBufferPool = new CommandPoolCached(dev, transferQueue.FamilyIndex, 32, VkCommandPoolCreateFlag.Transient | VkCommandPoolCreateFlag.ResetCommandBuffer); }
private static MemoryType FindHostMemory(PhysicalDevice dev, bool requiresCoherent, ulong capacity) { var req = new MemoryRequirements() { HostVisible = MemoryRequirementLevel.Required, HostCoherent = requiresCoherent ? MemoryRequirementLevel.Required : MemoryRequirementLevel.Preferred, TypeRequirements = new VkMemoryRequirements() { Size = capacity } }; return(req.FindMemoryType(dev)); }