Example #1
0
 void initUISurface()
 {
     uiImage?.Dispose();
     vkvgSurf?.Dispose();
     vkvgSurf = new vkvg.Surface(vkvgDev, (int)swapChain.Width, (int)swapChain.Height);
     uiImage  = new Image(dev, new VkImage((ulong)vkvgSurf.VkImage.ToInt64()), VkFormat.B8g8r8a8Unorm,
                          VkImageUsageFlags.ColorAttachment, (uint)vkvgSurf.Width, (uint)vkvgSurf.Height);
     uiImage.CreateView(VkImageViewType.ImageView2D, VkImageAspectFlags.Color);
     uiImage.CreateSampler(VkFilter.Nearest, VkFilter.Nearest, VkSamplerMipmapMode.Nearest, VkSamplerAddressMode.ClampToBorder);
     uiImage.Descriptor.imageLayout = VkImageLayout.ShaderReadOnlyOptimal;
 }
Example #2
0
 void recreateSurface()
 {
     vkvgImage?.Dispose();
     vkvgSurf?.Dispose();
     vkvgSurf = new vkvg.Surface(vkvgDev, (int)swapChain.Width, (int)swapChain.Height);
     vkvgSurf.Clear();
     vkvgImage = new Image(dev, new VkImage((ulong)vkvgSurf.VkImage.ToInt64()), VkFormat.B8g8r8a8Unorm,
                           VkImageUsageFlags.ColorAttachment, (uint)vkvgSurf.Width, (uint)vkvgSurf.Height);
     vkvgImage.CreateView(VkImageViewType.ImageView2D, VkImageAspectFlags.Color);
     vkvgImage.CreateSampler(VkFilter.Nearest, VkFilter.Nearest, VkSamplerMipmapMode.Nearest, VkSamplerAddressMode.ClampToBorder);
     recreateSurfaceStatus = false;
 }
Example #3
0
        protected override void OnResize()
        {
            base.OnResize();

            dev.WaitIdle();

            vkvgSurf?.Dispose();
            vkvgSurf = new vkvg.Surface(vkvgDev, (int)Width, (int)Height);
            vkvgSurf.Clear();

            VkImage srcImg = new VkImage((ulong)vkvgSurf.VkImage.ToInt64());

            for (int i = 0; i < swapChain.ImageCount; ++i)
            {
                cmds[i] = cmdPool.AllocateCommandBuffer();
                cmds[i].Start();

                Utils.setImageLayout(cmds[i].Handle, swapChain.images[i].Handle, VkImageAspectFlags.Color,
                                     VkImageLayout.Undefined, VkImageLayout.TransferDstOptimal,
                                     VkPipelineStageFlags.BottomOfPipe, VkPipelineStageFlags.Transfer);
                Utils.setImageLayout(cmds[i].Handle, srcImg, VkImageAspectFlags.Color,
                                     VkImageLayout.ColorAttachmentOptimal, VkImageLayout.TransferSrcOptimal,
                                     VkPipelineStageFlags.ColorAttachmentOutput, VkPipelineStageFlags.Transfer);

                VkImageSubresourceLayers imgSubResLayer = new VkImageSubresourceLayers
                {
                    aspectMask     = VkImageAspectFlags.Color,
                    mipLevel       = 0,
                    baseArrayLayer = 0,
                    layerCount     = 1
                };
                VkImageCopy cregion = new VkImageCopy
                {
                    srcSubresource = imgSubResLayer,
                    srcOffset      = default,
Example #4
0
        protected override void OnResize()
        {
            vkvgImage?.Dispose();
            vkvgSurf?.Dispose();
            vkvgSurf  = new vkvg.Surface(vkvgDev, (int)swapChain.Width, (int)swapChain.Height);
            vkvgImage = new Image(dev, new VkImage((ulong)vkvgSurf.VkImage.ToInt64()), VkFormat.B8g8r8a8Unorm,
                                  VkImageUsageFlags.ColorAttachment, (uint)vkvgSurf.Width, (uint)vkvgSurf.Height);
            vkvgImage.CreateView(VkImageViewType.ImageView2D, VkImageAspectFlags.Color);
            vkvgImage.CreateSampler(VkFilter.Nearest, VkFilter.Nearest, VkSamplerMipmapMode.Nearest, VkSamplerAddressMode.ClampToBorder);

            vkvgImage.Descriptor.imageLayout = VkImageLayout.ShaderReadOnlyOptimal;
            DescriptorSetWrites uboUpdate = new DescriptorSetWrites(dsMats, descLayoutMatrix.Bindings[1]);

            uboUpdate.Write(dev, vkvgImage.Descriptor);

            updateMatrices();

            if (frameBuffers != null)
            {
                for (int i = 0; i < swapChain.ImageCount; ++i)
                {
                    frameBuffers[i]?.Dispose();
                }
            }

            frameBuffers = new Framebuffer[swapChain.ImageCount];

            for (int i = 0; i < swapChain.ImageCount; ++i)
            {
                frameBuffers[i] = new Framebuffer(pipeline.RenderPass, swapChain.Width, swapChain.Height,
                                                  (pipeline.Samples == VkSampleCountFlags.SampleCount1) ? new Image[] {
                    swapChain.images[i],
                    null
                } : new Image[] {
                    null,
                    null,
                    swapChain.images[i]
                });
                frameBuffers[i].SetName("main FB " + i);
            }

            buildCommandBuffers();
        }