Esempio n. 1
0
        public void CreateView(VkImageViewType type = VkImageViewType.ImageView2D, VkImageAspectFlags aspectFlags = VkImageAspectFlags.Color,
                               uint layerCount      = 1,
                               uint baseMipLevel    = 0, uint levelCount = 1, uint baseArrayLayer = 0,
                               VkComponentSwizzle r = VkComponentSwizzle.R,
                               VkComponentSwizzle g = VkComponentSwizzle.G,
                               VkComponentSwizzle b = VkComponentSwizzle.B,
                               VkComponentSwizzle a = VkComponentSwizzle.A)
        {
            VkImageView           view     = default(VkImageView);
            VkImageViewCreateInfo viewInfo = VkImageViewCreateInfo.New();

            viewInfo.image        = handle;
            viewInfo.viewType     = type;
            viewInfo.format       = Format;
            viewInfo.components.r = r;
            viewInfo.components.g = g;
            viewInfo.components.b = b;
            viewInfo.components.a = a;
            viewInfo.subresourceRange.aspectMask     = aspectFlags;
            viewInfo.subresourceRange.baseMipLevel   = baseMipLevel;
            viewInfo.subresourceRange.levelCount     = levelCount;
            viewInfo.subresourceRange.baseArrayLayer = baseArrayLayer;
            viewInfo.subresourceRange.layerCount     = layerCount;

            Utils.CheckResult(vkCreateImageView(Dev.VkDev, ref viewInfo, IntPtr.Zero, out view));

            if (Descriptor.imageView.Handle != 0)
            {
                Dev.DestroyImageView(Descriptor.imageView);
            }
            Descriptor.imageView = view;
        }
Esempio n. 2
0
        public ImageView(Image image, VkImageSubresourceRange range, VkImageViewType type, VkFormat?format = null,
                         VkComponentMapping?swizzle = null)
        {
            Device = image.Device;
            Image  = image;

            unsafe
            {
                var info = new VkImageViewCreateInfo()
                {
                    SType      = VkStructureType.ImageViewCreateInfo,
                    Flags      = 0,
                    PNext      = IntPtr.Zero,
                    Format     = format ?? image.Format,
                    Components = swizzle ?? new VkComponentMapping()
                    {
                        R = VkComponentSwizzle.Identity,
                        G = VkComponentSwizzle.Identity,
                        B = VkComponentSwizzle.Identity,
                        A = VkComponentSwizzle.Identity
                    },
                    Image            = image.Handle,
                    ViewType         = type,
                    SubresourceRange = range
                };
                Handle = Device.Handle.CreateImageView(&info, Instance.AllocationCallbacks);
            }
        }
Esempio n. 3
0
        public VkImageView CreateImageView(VkImage image, VkFormat format, VkImageViewType viewType = VkImageViewType.ImageView2D, VkImageAspectFlags aspectFlags = VkImageAspectFlags.Color)
        {
            VkImageView           view;
            VkImageViewCreateInfo infos = VkImageViewCreateInfo.New();

            infos.image      = image;
            infos.viewType   = viewType;
            infos.format     = format;
            infos.components = new VkComponentMapping {
                r = VkComponentSwizzle.R, g = VkComponentSwizzle.G, b = VkComponentSwizzle.B, a = VkComponentSwizzle.A
            };
            infos.subresourceRange = new VkImageSubresourceRange(aspectFlags);

            Utils.CheckResult(vkCreateImageView(dev, ref infos, IntPtr.Zero, out view));
            return(view);
        }
Esempio n. 4
0
 public unsafe VkImageViewCreateInfo(
     VkImage image,
     VkImageViewType viewType,
     VkFormat format,
     VkComponentMapping components,
     VkImageSubresourceRange subresourceRange,
     VkImageViewCreateFlags flags = VkImageViewCreateFlags.None,
     void *pNext = default)
 {
     sType                 = VkStructureType.ImageViewCreateInfo;
     this.pNext            = pNext;
     this.flags            = flags;
     this.image            = image;
     this.viewType         = viewType;
     this.format           = format;
     this.components       = components;
     this.subresourceRange = subresourceRange;
 }
Esempio n. 5
0
        public static Texture Create(uint width, uint height, VkImageViewType imageViewType, uint layers, VkFormat format, uint levels = 0, VkImageUsageFlags additionalUsage = VkImageUsageFlags.None)
        {
            Texture texture = new Texture
            {
                extent    = new VkExtent3D(width, height, 1),
                layers    = layers,
                mipLevels = (levels > 0) ? levels : (uint)NumMipmapLevels(width, height),
            };

            VkImageUsageFlags usage = VkImageUsageFlags.Sampled | VkImageUsageFlags.TransferDst | additionalUsage;

            if (texture.mipLevels > 1)
            {
                usage |= VkImageUsageFlags.TransferSrc; // For mipmap generation
            }

            texture.image     = Image.Create(width, height, (imageViewType == VkImageViewType.ImageCube || imageViewType == VkImageViewType.ImageCubeArray) ? VkImageCreateFlags.CubeCompatible : VkImageCreateFlags.None, layers, texture.mipLevels, format, VkSampleCountFlags.Count1, usage);
            texture.imageView = ImageView.Create(texture.image, imageViewType, format, VkImageAspectFlags.Color, 0, Vulkan.RemainingMipLevels, 0, layers);
            texture.sampler   = new Sampler(VkFilter.Linear, VkSamplerMipmapMode.Linear, VkSamplerAddressMode.ClampToBorder, texture.mipLevels, Device.Features.samplerAnisotropy == true);
            texture.UpdateDescriptor();
            return(texture);
        }
Esempio n. 6
0
        public static ImageView Create(Image image, VkImageViewType viewType, VkFormat format, VkImageAspectFlags aspectMask, uint baseMipLevel, uint numMipLevels, uint baseArrayLayer = 0, uint arrayLayers = 1)
        {
            var viewCreateInfo = new VkImageViewCreateInfo
            {
                sType      = VkStructureType.ImageViewCreateInfo,
                image      = image,
                viewType   = viewType,
                format     = format,
                components = new VkComponentMapping(VkComponentSwizzle.R, VkComponentSwizzle.G, VkComponentSwizzle.B, VkComponentSwizzle.A),

                subresourceRange = new VkImageSubresourceRange
                {
                    aspectMask     = aspectMask,
                    baseMipLevel   = baseMipLevel,
                    levelCount     = numMipLevels,
                    baseArrayLayer = baseArrayLayer,
                    layerCount     = arrayLayers,
                }
            };

            return(new ImageView(image, ref viewCreateInfo));
        }
Esempio n. 7
0
 public VkImageView CreateImageView(VkImageViewType viewType, VkImageSubresourceRange subressourceRange)
 {
     return(_Parent.CreateImageView(this, viewType, _Format, new VkComponentMapping(VkComponentSwizzle.VK_COMPONENT_SWIZZLE_IDENTITY, VkComponentSwizzle.VK_COMPONENT_SWIZZLE_IDENTITY, VkComponentSwizzle.VK_COMPONENT_SWIZZLE_IDENTITY, VkComponentSwizzle.VK_COMPONENT_SWIZZLE_IDENTITY), subressourceRange));
 }
Esempio n. 8
0
 public VkImageView CreateImageView(VkImageViewType viewType, VkComponentMapping componentMapping, VkImageSubresourceRange subressourceRange)
 {
     return(_Parent.CreateImageView(this, viewType, _Format, componentMapping, subressourceRange));
 }