Exemplo n.º 1
0
        public static Vk.ImageView CreateImageView(VkContext state, Vk.Image image, Vk.Format format,
                                                   Vk.ImageAspectFlags aspectFlags)
        {
            var subresourceRange = new Vk.ImageSubresourceRange();

            subresourceRange.AspectMask     = aspectFlags;
            subresourceRange.BaseMipLevel   = 0;
            subresourceRange.LevelCount     = 1;
            subresourceRange.BaseArrayLayer = 0;
            subresourceRange.LayerCount     = 1;

            var viewInfo = new Vk.ImageViewCreateInfo();

            viewInfo.Image            = image;
            viewInfo.ViewType         = Vk.ImageViewType.View2D;
            viewInfo.Format           = format;
            viewInfo.SubresourceRange = subresourceRange;

            return(state.Device.CreateImageView(viewInfo));
        }
Exemplo n.º 2
0
        private void createImageViews(VkContext context)
        {
            var imageViews = new Vk.ImageView[this.wrapper.ImageCapacity];

            for (int i = 0; i < this.wrapper.ImageCapacity; i++)
            {
                Vk.ImageViewCreateInfo createInfo = new Vk.ImageViewCreateInfo();
                createInfo.Image    = this.wrapper.Images[i];
                createInfo.ViewType = Vk.ImageViewType.View2D;
                createInfo.Format   = this.wrapper.Format;

                Vk.ComponentMapping componentMapping = new Vk.ComponentMapping();
                componentMapping.R = Vk.ComponentSwizzle.Identity;
                componentMapping.G = Vk.ComponentSwizzle.Identity;
                componentMapping.B = Vk.ComponentSwizzle.Identity;
                componentMapping.A = Vk.ComponentSwizzle.Identity;

                createInfo.Components = componentMapping;

                Vk.ImageSubresourceRange subresourceRange = new Vk.ImageSubresourceRange();
                subresourceRange.AspectMask     = Vk.ImageAspectFlags.Color;
                subresourceRange.BaseMipLevel   = 0;
                subresourceRange.LevelCount     = 1;
                subresourceRange.BaseArrayLayer = 0;
                subresourceRange.LayerCount     = 1;

                createInfo.SubresourceRange = subresourceRange;

                try {
                    imageViews[i] = context.Device.CreateImageView(createInfo);
                } catch (Vk.ResultException result) {
                    throw new VkException($"An error occurred while creating image view {i}.", result);
                }
            }

            this.wrapper.ImageViews = imageViews;
        }