Esempio n. 1
0
        public Image(Device device, ImageCreateInfo info)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }
            Device = device;

            CreateImage(info);

            Device.Commands.getImageMemoryRequirements(Device.Native, image, out requirements);
        }
Esempio n. 2
0
        void CreateImage(ImageCreateInfo mInfo)
        {
            var info = new VkImageCreateInfo();

            info.sType       = VkStructureType.ImageCreateInfo;
            info.flags       = mInfo.flags;
            info.imageType   = mInfo.imageType;
            info.format      = mInfo.format;
            info.extent      = mInfo.extent;
            info.mipLevels   = mInfo.mipLevels;
            info.arrayLayers = mInfo.arrayLayers;
            info.samples     = mInfo.samples;
            info.tiling      = mInfo.tiling;
            info.usage       = mInfo.usage;
            info.sharingMode = mInfo.sharingMode;

            var indicesMarshalled = new NativeArray <uint>(mInfo.queueFamilyIndices);

            info.queueFamilyIndexCount = (uint)indicesMarshalled.Count;
            info.pQueueFamilyIndices   = indicesMarshalled.Address;
            info.initialLayout         = mInfo.initialLayout;

            using (indicesMarshalled) {
                var result = Device.Commands.createImage(Device.Native, ref info, Device.Instance.AllocationCallbacks, out image);
                if (result != VkResult.Success)
                {
                    throw new ImageException(string.Format("Error creating image: {0}", result));
                }
            }

            Flags       = mInfo.flags;
            ImageType   = mInfo.imageType;
            Format      = mInfo.format;
            Extent      = mInfo.extent;
            MipLevels   = mInfo.mipLevels;
            ArrayLayers = mInfo.arrayLayers;
            Samples     = mInfo.samples;
            Tiling      = mInfo.tiling;
            Usage       = mInfo.usage;
        }