예제 #1
0
 public void Dispose()
 {
     imageAvailableSemaphore.Dispose();
     renderFinishedSemaphore.Dispose();
     indexBufferMemory.Dispose();
     indexBuffer.Dispose();
     vertexBufferMemory.Dispose();
     vertexBuffer.Dispose();
     commandPool.Dispose();
     foreach (var fb in swapchainFramebuffers)
     {
         fb.Dispose();
     }
     pipeline.Dispose();
     pipelineLayout.Dispose();
     renderPass.Dispose();
     foreach (var iv in swapchainImageViews)
     {
         iv.Dispose();
     }
     swapchain.Dispose();
     device.Dispose();
     surface.Dispose();
     debugCallbacks.Dispose();
     instance.Dispose();
     GLFW.DestroyWindow(window);
     GLFW.Terminate();
 }
예제 #2
0
 public void Dispose()
 {
     generator.Dispose();
     imageAvailableSemaphore.Dispose();
     renderFinishedSemaphore.Dispose();
     descriptorPool.Dispose();
     uniformBuffer.Dispose();
     uniformBufferMemory.Dispose();
     indexBuffer.Dispose();
     indexBufferMemory.Dispose();
     vertexBuffer.Dispose();
     vertexBufferMemory.Dispose();
     textureSampler.Dispose();
     textureImageView.Dispose();
     textureImage.Dispose();
     textureImageMemory.Dispose();
     stagingBuffer.Dispose();
     stagingBufferMemory.Dispose();
     commandPool.Dispose();
     foreach (var fb in swapchainFramebuffers)
     {
         fb.Dispose();
     }
     pipeline.Dispose();
     pipelineLayout.Dispose();
     descriptorSetLayout.Dispose();
     renderPass.Dispose();
     foreach (var iv in swapchainImageViews)
     {
         iv.Dispose();
     }
     swapchain.Dispose();
     device.Dispose();
     surface.Dispose();
     instance.Dispose();
     window.Dispose();
     GLFW.Terminate();
 }
예제 #3
0
        void CreateGraphicsPipeline()
        {
            var vert = CreateShaderModule(File.ReadAllBytes("vert.spv"));
            var frag = CreateShaderModule(File.ReadAllBytes("frag.spv"));

            var vertInfo = new VkPipelineShaderStageCreateInfo();

            vertInfo.stage  = VkShaderStageFlags.VertexBit;
            vertInfo.module = vert;
            vertInfo.name   = "main";

            var fragInfo = new VkPipelineShaderStageCreateInfo();

            fragInfo.stage  = VkShaderStageFlags.FragmentBit;
            fragInfo.module = frag;
            fragInfo.name   = "main";

            var shaderStages = new List <VkPipelineShaderStageCreateInfo> {
                vertInfo, fragInfo
            };

            var vertexInputInfo = new VkPipelineVertexInputStateCreateInfo();

            var inputAssembly = new VkPipelineInputAssemblyStateCreateInfo();

            inputAssembly.topology = VkPrimitiveTopology.TriangleList;

            var viewport = new VkViewport();

            viewport.width    = swapchainExtent.width;
            viewport.height   = swapchainExtent.height;
            viewport.minDepth = 0f;
            viewport.maxDepth = 1f;

            var scissor = new VkRect2D();

            scissor.extent = swapchainExtent;

            var viewportState = new VkPipelineViewportStateCreateInfo();

            viewportState.viewports = new List <VkViewport> {
                viewport
            };
            viewportState.scissors = new List <VkRect2D> {
                scissor
            };

            var rasterizer = new VkPipelineRasterizationStateCreateInfo();

            rasterizer.polygonMode = VkPolygonMode.Fill;
            rasterizer.lineWidth   = 1f;
            rasterizer.cullMode    = VkCullModeFlags.BackBit;
            rasterizer.frontFace   = VkFrontFace.Clockwise;

            var multisampling = new VkPipelineMultisampleStateCreateInfo();

            multisampling.rasterizationSamples = VkSampleCountFlags._1_Bit;
            multisampling.minSampleShading     = 1f;

            var colorBlendAttachment = new VkPipelineColorBlendAttachmentState();

            colorBlendAttachment.colorWriteMask = VkColorComponentFlags.RBit
                                                  | VkColorComponentFlags.GBit
                                                  | VkColorComponentFlags.BBit
                                                  | VkColorComponentFlags.ABit;
            colorBlendAttachment.srcColorBlendFactor = VkBlendFactor.One;
            colorBlendAttachment.dstColorBlendFactor = VkBlendFactor.Zero;
            colorBlendAttachment.colorBlendOp        = VkBlendOp.Add;
            colorBlendAttachment.srcAlphaBlendFactor = VkBlendFactor.One;
            colorBlendAttachment.dstAlphaBlendFactor = VkBlendFactor.Zero;
            colorBlendAttachment.alphaBlendOp        = VkBlendOp.Add;

            var colorBlending = new VkPipelineColorBlendStateCreateInfo();

            colorBlending.logicOp     = VkLogicOp.Copy;
            colorBlending.attachments = new List <VkPipelineColorBlendAttachmentState> {
                colorBlendAttachment
            };

            var pipelineLayoutInfo = new VkPipelineLayoutCreateInfo();

            pipelineLayout?.Dispose();

            pipelineLayout = new VkPipelineLayout(device, pipelineLayoutInfo);

            var info = new VkGraphicsPipelineCreateInfo();

            info.stages             = shaderStages;
            info.vertexInputState   = vertexInputInfo;
            info.inputAssemblyState = inputAssembly;
            info.viewportState      = viewportState;
            info.rasterizationState = rasterizer;
            info.multisampleState   = multisampling;
            info.colorBlendState    = colorBlending;
            info.layout             = pipelineLayout;
            info.renderPass         = renderPass;
            info.subpass            = 0;
            info.basePipelineHandle = null;
            info.basePipelineIndex  = -1;

            pipeline?.Dispose();

            pipeline = new VkGraphicsPipeline(device, info, null);

            vert.Dispose();
            frag.Dispose();
        }