Example #1
0
 public static extern int vmaAllocateMemoryForImage(
     IntPtr allocator,
     IntPtr image,
     ref VmaAllocationCreateInfo pCreateInfo,
     out IntPtr pAllocation,
     out VmaAllocationInfo pAllocationInfo
     );
Example #2
0
 public static extern int vmaAllocateMemoryForBuffer(
     IntPtr allocator,
     IntPtr buffer,
     ref VmaAllocationCreateInfo pCreateInfo,
     out IntPtr pAllocation,
     out VmaAllocationInfo pAllocationInfo
     );
Example #3
0
 public static extern int vmaAllocateMemory(
     IntPtr allocator,
     IntPtr pVkMemoryRequirements,
     ref VmaAllocationCreateInfo pCreateInfo,
     out IntPtr pAllocation,
     out VmaAllocationInfo pAllocationInfo
     );
Example #4
0
 public static extern int vmaCreateImage(
     IntPtr allocator,
     IntPtr pImageCreateInfo,
     ref VmaAllocationCreateInfo pAllocationCreateInfo,
     out ulong pImage,
     out IntPtr pAllocation,
     IntPtr pAllocationInfo
     );
Example #5
0
 public static extern int vmaCreateBuffer(
     IntPtr allocator,
     IntPtr pBufferCreateInfo,
     ref VmaAllocationCreateInfo pAllocationCreateInfo,
     out ulong pBuffer,
     out IntPtr pAllocation,
     IntPtr pAllocationInfo
     );
Example #6
0
 public static extern int vmaAllocateMemoryPages(
     IntPtr allocator,
     IntPtr pVkMemoryRequirements,
     ref VmaAllocationCreateInfo pCreateInfo,
     uint allocationCount,
     out IntPtr[] pAllocations,
     out VmaAllocationInfo pAllocationInfo
     );
Example #7
0
        public void Build(int deviceIndex)
        {
            if (!locked)
            {
                var devInfo = GraphicsDevice.GetDeviceInfo(deviceIndex);

                unsafe
                {
                    fixed(uint *queueFamInds = devInfo.QueueFamilyIndices)
                    {
                        var creatInfo = new VkImageCreateInfo()
                        {
                            sType       = VkStructureType.StructureTypeImageCreateInfo,
                            flags       = 0,
                            format      = (VkFormat)Format,
                            usage       = (VkImageUsageFlags)Usage,
                            mipLevels   = Levels,
                            arrayLayers = Layers,
                            extent      = new VkExtent3D()
                            {
                                width  = Width,
                                height = Height,
                                depth  = Depth
                            },
                            samples               = VkSampleCountFlags.SampleCount1Bit,
                            tiling                = VkImageTiling.ImageTilingOptimal,
                            sharingMode           = VkSharingMode.SharingModeExclusive,
                            initialLayout         = (VkImageLayout)InitialLayout,
                            pQueueFamilyIndices   = queueFamInds,
                            queueFamilyIndexCount = (uint)devInfo.QueueFamilyIndices.Length,
                        };

                        creatInfo.imageType = Dimensions switch
                        {
                            1 => VkImageType.ImageType1d,
                            2 => VkImageType.ImageType2d,
                            3 => VkImageType.ImageType3d,
                            _ => throw new Exception("Unknown Image Shape.")
                        };
                        var vmaCreatInfo = new VmaAllocationCreateInfo()
                        {
                            usage = (VmaMemoryUsage)MemoryUsage
                        };

                        var allocInfo_p = new ManagedPtr <VmaAllocationInfo>();
                        var res         = GraphicsDevice.CreateImage(deviceIndex, creatInfo.Pointer(), vmaCreatInfo.Pointer(), out var img_l, out var imgAlloc_l, allocInfo_p);

                        hndl      = img_l;
                        imgAlloc  = imgAlloc_l;
                        allocInfo = allocInfo_p.Value;
                        devID     = deviceIndex;

                        CurrentLayout     = InitialLayout;
                        CurrentAccesses   = AccessFlags.None;
                        CurrentUsageStage = PipelineStage.Top;

                        if (GraphicsDevice.EnableValidation)
                        {
                            var objName = new VkDebugUtilsObjectNameInfoEXT()
                            {
                                sType        = VkStructureType.StructureTypeDebugUtilsObjectNameInfoExt,
                                pObjectName  = Name,
                                objectType   = VkObjectType.ObjectTypeImage,
                                objectHandle = (ulong)hndl
                            };
                            GraphicsDevice.SetDebugUtilsObjectNameEXT(GraphicsDevice.GetDeviceInfo(deviceIndex).Device, objName.Pointer());
                        }
                    }
                }
                locked = true;
            }
            else
            {
                throw new Exception("Image is locked.");
            }
        }
Example #8
0
 public static extern int vmaFindMemoryTypeIndexForImageInfo(
     IntPtr allocator,
     IntPtr pImageCreateInfo,
     ref VmaAllocationCreateInfo pAllocationCreateInfo,
     out uint pMemoryTypeIndex
     );
Example #9
0
 public static extern int vmaFindMemoryTypeIndex(
     IntPtr allocator,
     uint memoryTypeBits,
     ref VmaAllocationCreateInfo pAllocationCreateInfo,
     out uint pMemoryTypeIndex
     );