Example #1
0
        internal static ShaderModule    LoadShader(string filePath, Device dv)
        {
            if (!File.Exists(filePath))
            {
                Console.WriteLine("Bad file path: " + filePath + " in LoadShader()");
                return(null);
            }
            FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);

            if (fs == null)
            {
                Console.WriteLine("Couldn't open shader: " + filePath + " in LoadShader()");
                return(null);
            }
            BinaryReader br = new BinaryReader(fs);

            if (br == null)
            {
                Console.WriteLine("Couldn't open shader: " + filePath + " in LoadShader()");
                return(null);
            }

            byte    [] bytes = br.ReadBytes((int)fs.Length);

            br.Close();
            fs.Close();

            ShaderModuleCreateInfo smci = new ShaderModuleCreateInfo(bytes);

            ShaderModule sm = dv.CreateShaderModule(smci);

            return(sm);
        }
Example #2
0
        public void CreateComputePipeline()
        {
            var descriptorSetLayoutCreateInfo = new DescriptorSetLayoutCreateInfo(
                new DescriptorSetLayoutBinding(0, DescriptorType.StorageBuffer, 1, ShaderStages.Compute),
                new DescriptorSetLayoutBinding(1, DescriptorType.StorageBuffer, 1, ShaderStages.Compute));

            using (DescriptorSetLayout descriptorSetLayout = Device.CreateDescriptorSetLayout(descriptorSetLayoutCreateInfo))
                using (PipelineLayout pipelineLayout = Device.CreatePipelineLayout(new PipelineLayoutCreateInfo(new[] { descriptorSetLayout })))
                    using (ShaderModule shader = Device.CreateShaderModule(new ShaderModuleCreateInfo(ReadAllBytes("Shader.comp.spv"))))
                        using (PipelineCache cache = Device.CreatePipelineCache())
                        {
                            var pipelineCreateInfo = new ComputePipelineCreateInfo(
                                new PipelineShaderStageCreateInfo(ShaderStages.Compute, shader, "main"),
                                pipelineLayout);

                            using (Device.CreateComputePipelines(new[] { pipelineCreateInfo })[0]) { }
                            using (Device.CreateComputePipelines(new[] { pipelineCreateInfo }, cache)[0]) { }
                            using (Device.CreateComputePipelines(new[] { pipelineCreateInfo }, allocator: CustomAllocator)[0]) { }
                            using (Device.CreateComputePipelines(new[] { pipelineCreateInfo }, cache, CustomAllocator)[0]) { }
                            using (Device.CreateComputePipeline(pipelineCreateInfo)) { }
                            using (Device.CreateComputePipeline(pipelineCreateInfo, allocator: CustomAllocator)) { }
                            using (Device.CreateComputePipeline(pipelineCreateInfo, cache)) { }
                            using (Device.CreateComputePipeline(pipelineCreateInfo, cache, CustomAllocator)) { }
                        }
        }
Example #3
0
        public override void Initialise(Device device, VulkanBufferManager bufferManager)
        {
            this.vertexShader = device.CreateVertexModule(shanq => from input in shanq.GetInput <Vertex>()
                                                          select new VertexOutput
            {
                Colour   = input.Colour,
                Position = new vec4(input.Position, 0, 1)
            });

            this.fragmentShader = device.CreateFragmentModule(shanq => from input in shanq.GetInput <FragmentInput>()
                                                              select new FragmentOutput
            {
                Colour = new vec4(input.Colour, 1)
            });

            indexCount = indices.Count();

            this.vertexBuffer = bufferManager.CreateBuffer((uint)Marshal.SizeOf <Vertex>() * (uint)vertices.Length, BufferUsageFlags.TransferDestination | BufferUsageFlags.VertexBuffer, MemoryPropertyFlags.DeviceLocal);

            this.vertexBuffer.Update(vertices);

            this.indexBuffer = bufferManager.CreateBuffer((uint)Marshal.SizeOf <uint>() * (uint)indices.Length, BufferUsageFlags.TransferDestination | BufferUsageFlags.IndexBuffer, MemoryPropertyFlags.DeviceLocal);

            this.indexBuffer.Update(indices);

            this.pipelineLayout = device.CreatePipelineLayout(null, null);
        }
Example #4
0
        public void GetData()
        {
            var descriptorSetLayoutCreateInfo = new DescriptorSetLayoutCreateInfo(
                new DescriptorSetLayoutBinding(0, DescriptorType.StorageBuffer, 1, ShaderStages.Compute),
                new DescriptorSetLayoutBinding(1, DescriptorType.StorageBuffer, 1, ShaderStages.Compute));

            using (DescriptorSetLayout descriptorSetLayout = Device.CreateDescriptorSetLayout(descriptorSetLayoutCreateInfo))
                using (PipelineLayout pipelineLayout = Device.CreatePipelineLayout(new PipelineLayoutCreateInfo(new[] { descriptorSetLayout })))
                    using (ShaderModule shader = Device.CreateShaderModule(new ShaderModuleCreateInfo(ReadAllBytes("Shader.comp.spv"))))
                    {
                        var pipelineCreateInfo = new ComputePipelineCreateInfo(
                            new PipelineShaderStageCreateInfo(ShaderStages.Compute, shader, "main"),
                            pipelineLayout);

                        byte[] cacheBytes;

                        // Populate cache.
                        using (PipelineCache cache = Device.CreatePipelineCache())
                        {
                            using (Device.CreateComputePipeline(pipelineCreateInfo, cache)) { }
                            cacheBytes = cache.GetData();
                        }

                        Assert.False(cacheBytes.All(x => x == 0));

                        // Recreate pipeline from cache.
                        using (PipelineCache cache = Device.CreatePipelineCache(new PipelineCacheCreateInfo(cacheBytes)))
                        {
                            using (Device.CreateComputePipeline(pipelineCreateInfo, cache)) { }
                        }
                    }
        }
Example #5
0
        public void CmdDraw()
        {
            var renderPassCreateInfo = new RenderPassCreateInfo(new[] { new SubpassDescription(
                                                                            new[] { new AttachmentReference(0, ImageLayout.ColorAttachmentOptimal) }) },
                                                                new[] { new AttachmentDescription {
                                                                            Format = Format.B8G8R8A8UNorm, Samples = SampleCounts.Count1
                                                                        } });
            var imageCreateInfo = new ImageCreateInfo
            {
                Usage       = ImageUsages.ColorAttachment,
                Format      = Format.B8G8R8A8UNorm,
                Extent      = new Extent3D(2, 2, 1),
                ImageType   = ImageType.Image2D,
                MipLevels   = 1,
                ArrayLayers = 1,
                Samples     = SampleCounts.Count1
            };
            var imageViewCreateInfo = new ImageViewCreateInfo(
                Format.B8G8R8A8UNorm,
                new ImageSubresourceRange(ImageAspects.Color, 0, 1, 0, 1));

            using (ShaderModule vertexShader = Device.CreateShaderModule(new ShaderModuleCreateInfo(ReadAllBytes("Shader.vert.spv"))))
                using (ShaderModule fragmentShader = Device.CreateShaderModule(new ShaderModuleCreateInfo(ReadAllBytes("Shader.frag.spv"))))
                    using (PipelineLayout pipelineLayout = Device.CreatePipelineLayout())
                        using (RenderPass renderPass = Device.CreateRenderPass(renderPassCreateInfo))
                            using (Image image = Device.CreateImage(imageCreateInfo))
                            {
                                MemoryRequirements imageMemReq = image.GetMemoryRequirements();
                                int memTypeIndex = PhysicalDeviceMemoryProperties.MemoryTypes.IndexOf(imageMemReq.MemoryTypeBits, MemoryProperties.DeviceLocal);
                                using (DeviceMemory imageMemory = Device.AllocateMemory(new MemoryAllocateInfo(imageMemReq.Size, memTypeIndex)))
                                {
                                    image.BindMemory(imageMemory);
                                    using (ImageView imageView = image.CreateView(imageViewCreateInfo))
                                        using (Framebuffer framebuffer = renderPass.CreateFramebuffer(new FramebufferCreateInfo(new[] { imageView }, 2, 2)))
                                            using (Pipeline pipeline = Device.CreateGraphicsPipeline(new GraphicsPipelineCreateInfo(
                                                                                                         pipelineLayout,
                                                                                                         renderPass,
                                                                                                         0,
                                                                                                         new[]
                                            {
                                                new PipelineShaderStageCreateInfo(ShaderStages.Vertex, vertexShader, "main"),
                                                new PipelineShaderStageCreateInfo(ShaderStages.Fragment, fragmentShader, "main")
                                            },
                                                                                                         new PipelineInputAssemblyStateCreateInfo(),
                                                                                                         new PipelineVertexInputStateCreateInfo(),
                                                                                                         new PipelineRasterizationStateCreateInfo {
                                                RasterizerDiscardEnable = true, LineWidth = 1.0f
                                            })))
                                            {
                                                CommandBuffer.Begin();
                                                CommandBuffer.CmdBeginRenderPass(new RenderPassBeginInfo(framebuffer, new Rect2D(0, 0, 2, 2)));
                                                CommandBuffer.CmdBindPipeline(PipelineBindPoint.Graphics, pipeline);
                                                CommandBuffer.CmdDraw(3);
                                                CommandBuffer.CmdEndRenderPass();
                                                CommandBuffer.End();
                                            }
                                }
                            }
        }
Example #6
0
        public Shader(string name, bool edgeAA, VulkanRenderer renderer)
        {
            _renderer = renderer;
            _name     = name;

            _vertexShaderModule   = CreateShader(ShaderCode.VERTEX_SHADER_SOURCE_SPV);
            _fragmentShaderModule = CreateShader(edgeAA ? ShaderCode.FRAGMENT_SHADER_EDGE_AA_SOURCE_SPV : ShaderCode.FRAGMENT_SHADER_SOURCE_SPV);
        }
Example #7
0
        private void TearDown()
        {
            device.WaitIdle();

            renderFinishedSemaphore.Dispose();
            renderFinishedSemaphore = null;

            imageAvailableSemaphore.Dispose();
            imageAvailableSemaphore = null;

            vertexBufferMemory.Free();
            vertexBufferMemory = null;

            vertexBuffer.Dispose();
            vertexBuffer = null;

            commandPool.Dispose();
            commandPool = null;

            foreach (var frameBuffer in frameBuffers)
            {
                frameBuffer.Dispose();
            }
            frameBuffers = null;

            fragShader.Dispose();
            fragShader = null;

            vertShader.Dispose();
            vertShader = null;

            pipeline.Dispose();
            pipeline = null;

            pipelineLayout.Dispose();
            pipelineLayout = null;

            foreach (var imageView in swapChainImageViews)
            {
                imageView.Dispose();
            }
            swapChainImageViews = null;

            renderPass.Dispose();
            renderPass = null;

            swapChain.Dispose();
            swapChain = null;

            device.Dispose();
            device = null;

            surface.Dispose();
            surface = null;

            instance.Dispose();
            instance = null;
        }
Example #8
0
        private void TearDown()
        {
            device.WaitIdle();

            this.renderFinishedSemaphore.Dispose();
            this.renderFinishedSemaphore = null;

            this.imageAvailableSemaphore.Dispose();
            this.imageAvailableSemaphore = null;

            this.device.FreeMemory(this.vertexBufferMemory);
            this.vertexBufferMemory = null;

            this.vertexBuffer.Dispose();
            this.vertexBuffer = null;

            this.commandPool.Dispose();
            this.commandPool = null;

            foreach (var frameBuffer in this.frameBuffers)
            {
                frameBuffer.Dispose();
            }
            this.frameBuffers = null;

            this.fragShader.Dispose();
            this.fragShader = null;

            this.vertShader.Dispose();
            this.vertShader = null;

            this.pipeline.Dispose();
            this.pipeline = null;

            this.pipelineLayout.Dispose();
            this.pipelineLayout = null;

            foreach (var imageView in this.swapChainImageViews)
            {
                imageView.Dispose();
            }
            this.swapChainImageViews = null;

            this.renderPass.Dispose();
            this.renderPass = null;

            this.swapChain.Dispose();
            this.swapChain = null;

            this.device.Dispose();
            this.device = null;

            this.surface.Dispose();
            this.surface = null;

            this.instance.Dispose();
            this.instance = null;
        }
Example #9
0
 protected void Awake()
 {
     this.shader        = ShaderModule.GetScopeOverlay();
     this.maskTexture   = ShaderModule.GetMaskTexture();
     this.kernelId      = this.shader.FindKernel("RefractionBlur");
     this.renderTexture = new RenderTexture(Screen.width, Screen.height, 1, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear);
     this.renderTexture.enableRandomWrite = true;
     _ = this.renderTexture.Create();
 }
Example #10
0
        public bool LoadShader(string filePath)
        {
            ShaderModule sm = Shaders.LoadShader(filePath,
                                                 mDevices.GetLogicalDevice());

            if (sm != null)
            {
                mShaders.Add(filePath, sm);
                return(true);
            }
            return(false);
        }
Example #11
0
        /// <summary>
        /// Implement IDisposable.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            VKVertexShader?.Dispose();
            VKFragmentShader?.Dispose();
            VKComputeShader?.Dispose();

            VKVertexShader   = null;
            VKFragmentShader = null;
            VKComputeShader  = null;
        }
Example #12
0
        private static unsafe PipelineShaderStageCreateInfo ShaderStageCreateInfo(ShaderModule module, ShaderStageFlags stage)
        {
            return(new PipelineShaderStageCreateInfo()
            {
                SType = StructureType.PipelineShaderStageCreateInfo,

                Module = module,
                PName = (byte *)SilkMarshal.StringToPtr("main"),
                PSpecializationInfo = null,
                Stage = stage
            });
        }
        void CreateComputePipeline()
        {
            /*
             * We create a compute pipeline here.
             */

            /*
             * Create a shader module. A shader module basically just encapsulates some shader code.
             */
            // the code in comp.spv was created by running the command:
            // glslangValidator.exe -V shader.comp
            byte[] code = ReadFile("shaders/shader.comp.spv");
            ShaderModuleCreateInfo createInfo = new ShaderModuleCreateInfo()
            {
                Code = code
            };

            computeShaderModule = device.CreateShaderModule(createInfo);

            /*
             * Now let us actually create the compute pipeline.
             * A compute pipeline is very simple compared to a graphics pipeline.
             * It only consists of a single stage with a compute shader.
             * So first we specify the compute shader stage, and it's entry point(main).
             */
            PipelineShaderStageCreateInfo shaderStageCreateInfo = new PipelineShaderStageCreateInfo()
            {
                Stage  = ShaderStages.Compute,// VK_SHADER_STAGE_COMPUTE_BIT;
                Module = computeShaderModule,
                Name   = "main"
            };

            /*
             * The pipeline layout allows the pipeline to access descriptor sets.
             * So we just specify the descriptor set layout we created earlier.
             */
            PipelineLayoutCreateInfo pipelineLayoutCreateInfo = new PipelineLayoutCreateInfo(new[] { descriptorSetLayout });

            pipelineLayout = device.CreatePipelineLayout(pipelineLayoutCreateInfo);

            ComputePipelineCreateInfo pipelineCreateInfo = new ComputePipelineCreateInfo()
            {
                Stage  = shaderStageCreateInfo,
                Layout = pipelineLayout
            };

            /*
             * Now, we finally create the compute pipeline.
             */
            ComputePipelineCreateInfo[] ci = { pipelineCreateInfo };
            pipelines = device.CreateComputePipelines(ci);
        }
        private Pipeline CreateGraphicsPipeline()
        {
            ShaderModule vertexShader           = Content.Load <ShaderModule>("Shader.vert.spv");
            ShaderModule fragmentShader         = Content.Load <ShaderModule>("Shader.frag.spv");
            var          shaderStageCreateInfos = new[]
            {
                new PipelineShaderStageCreateInfo(ShaderStages.Vertex, vertexShader, "main"),
                new PipelineShaderStageCreateInfo(ShaderStages.Fragment, fragmentShader, "main")
            };

            var vertexInputStateCreateInfo   = new PipelineVertexInputStateCreateInfo();
            var inputAssemblyStateCreateInfo = new PipelineInputAssemblyStateCreateInfo(PrimitiveTopology.TriangleList);
            var viewportStateCreateInfo      = new PipelineViewportStateCreateInfo(
                new Viewport(0, 0, Host.Width, Host.Height),
                new Rect2D(0, 0, Host.Width, Host.Height));
            var rasterizationStateCreateInfo = new PipelineRasterizationStateCreateInfo
            {
                PolygonMode = PolygonMode.Fill,
                CullMode    = CullModes.Back,
                FrontFace   = FrontFace.CounterClockwise,
                LineWidth   = 1.0f
            };
            var multisampleStateCreateInfo = new PipelineMultisampleStateCreateInfo
            {
                RasterizationSamples = SampleCounts.Count1,
                MinSampleShading     = 1.0f
            };
            var colorBlendAttachmentState = new PipelineColorBlendAttachmentState
            {
                SrcColorBlendFactor = BlendFactor.One,
                DstColorBlendFactor = BlendFactor.Zero,
                ColorBlendOp        = BlendOp.Add,
                SrcAlphaBlendFactor = BlendFactor.One,
                DstAlphaBlendFactor = BlendFactor.Zero,
                AlphaBlendOp        = BlendOp.Add,
                ColorWriteMask      = ColorComponents.All
            };
            var colorBlendStateCreateInfo = new PipelineColorBlendStateCreateInfo(
                new[] { colorBlendAttachmentState });

            var pipelineCreateInfo = new GraphicsPipelineCreateInfo(
                _pipelineLayout, _renderPass, 0,
                shaderStageCreateInfos,
                inputAssemblyStateCreateInfo,
                vertexInputStateCreateInfo,
                rasterizationStateCreateInfo,
                viewportState: viewportStateCreateInfo,
                multisampleState: multisampleStateCreateInfo,
                colorBlendState: colorBlendStateCreateInfo);

            return(Context.Device.CreateGraphicsPipeline(pipelineCreateInfo));
        }
Example #15
0
        static void Main(string[] args)
        {
            byte[] shaderBytes = File.ReadAllBytes(@"E:\Data\Projects\Vessel\VesselSharp\spirv-reflect-sharp\pbr_khr.frag.spv");
            using (ShaderModule module = SpirvReflect.ReflectCreateShaderModule(shaderBytes))
            {
                var in_vars        = module.EnumerateInputVariables();
                var intf_vars      = module.EnumerateInterfaceVariables();
                var out_vars       = module.EnumerateOutputVariables();
                var push_constants = module.EnumeratePushConstants();

                var getVar = module.GetInputVariable(2);
            }
        }
Example #16
0
        private void CreateShaderModules()
        {
            ShaderModule CreateShader(string path)
            {
                var shaderData = LoadShaderData(path, out int codeSize);

                return(device.CreateShaderModule(codeSize, shaderData));
            }

            this.vertShader = CreateShader(@".\Shaders\vert.spv");

            this.fragShader = CreateShader(@".\Shaders\frag.spv");
        }
Example #17
0
        private void CreateComputePipeline()
        {
            var pipelineLayoutCreateInfo = new PipelineLayoutCreateInfo(new[] { _descriptorSetLayout });

            _pipelineLayout = Device.Logical.CreatePipelineLayout(pipelineLayoutCreateInfo);

            using (ShaderModule shader = Device.Logical.CreateShaderModule(new ShaderModuleCreateInfo(SpirV)))
            {
                var computePipelineCreateInfo = new ComputePipelineCreateInfo(
                    new PipelineShaderStageCreateInfo(ShaderStages.Compute, shader, "main"),
                    _pipelineLayout);
                _pipeline = Device.Logical.CreateComputePipeline(computePipelineCreateInfo);
            }
        }
Example #18
0
        private void CreateShaderModules()
        {
            this.vertShader = ShanqShader.CreateVertexModule(this.device,
                                                             shanq => from input in shanq.GetInput <Vertex>()
                                                             select new VertexOutput {
                Colour   = input.Colour,
                Position = new vec4(input.Position, 0, 1)
            });

            this.fragShader = ShanqShader.CreateFragmentModule(this.device,
                                                               shanq => from input in shanq.GetInput <FragmentInput>()
                                                               select new FragmentOutput {
                Colour = new vec4(input.Colour, 1)
            });
        }
Example #19
0
        private void CreateShaderModules()
        {
            // Shanq

            //vertShader = ShanqShader.CreateVertexModule(
            //	device,
            //	VectorTypeLibrary.Instance,
            //	shanq => from input in shanq.GetInput<Vertex>()
            //			 select new VertexOutput
            //			 {
            //				 Colour = input.Colour,
            //				 Position = new Vector4(input.Position, 0, 1)
            //			 }
            //);

            //fragShader = ShanqShader.CreateFragmentModule(
            //	device,
            //	VectorTypeLibrary.Instance,
            //	shanq => from input in shanq.GetInput<FragmentInput>()
            //			 select new FragmentOutput
            //			 {
            //				 Colour = new Vector4(input.Colour, 1)
            //			 }
            //);

            ShaderModule CreateShader(string path)
            {
                var shaderData = LoadShaderData(path, out int codeSize);

                return(device.CreateShaderModule(codeSize, shaderData));
            }

            uint[] LoadShaderData(string filePath, out int codeSize)
            {
                var fileBytes  = File.ReadAllBytes(filePath);
                var shaderData = new uint[(int)System.Math.Ceiling(fileBytes.Length / 4f)];

                System.Buffer.BlockCopy(fileBytes, 0, shaderData, 0, fileBytes.Length);

                codeSize = fileBytes.Length;

                return(shaderData);
            }

            vertShader = CreateShader(@".\Shaders\shader.vert.spv");

            fragShader = CreateShader(@".\Shaders\shader.frag.spv");
        }
Example #20
0
        private void CreateShaderModules()
        {
            int codeSize;
            var vertShaderData = LoadShaderData(@".\Shaders\vert.spv", out codeSize);

            this.vertShader = device.CreateShaderModule(new ShaderModuleCreateInfo {
                Code     = vertShaderData,
                CodeSize = codeSize
            });

            var fragShaderData = LoadShaderData(@".\Shaders\frag.spv", out codeSize);

            this.fragShader = device.CreateShaderModule(new ShaderModuleCreateInfo {
                Code     = fragShaderData,
                CodeSize = codeSize
            });
        }
Example #21
0
        private void CreateShaderModules()
        {
            this.vertShader = this.device.CreateVertexModule(shanq => from input in shanq.GetInput <Vertex>()
                                                             select new VertexOutput
            {
                Uv       = input.Uv,
                Position = new vec4(input.Position, (float)input.Test, 1)
            });

            this.fragShader = this.device.CreateFragmentModule(shanq => from input in shanq.GetInput <FragmentInput>()
                                                               from texture in shanq.GetSampler2d <vec4>(1, 0)
                                                               select new FragmentOutput
            {
                Colour    = texture.Sample(input.Uv),
                FragDepth = input.FragCoord.z
            });
        }
Example #22
0
        private void CreateShaderModules()
        {
            this.vertShader = this.device.CreateVertexModule(shanq => from input in shanq.GetInput <Vertex>()
                                                             from ubo in shanq.GetBinding <UniformBufferObject>()
                                                             let transform = ubo.Proj * ubo.View * ubo.Model
                                                                             select new VertexOutput
            {
                Position = transform * new vec4(input.Position, 0, 1),
                Colour   = input.Colour
            });

            this.fragShader = this.device.CreateFragmentModule(shanq => from input in shanq.GetInput <FragmentInput>()
                                                               let colour = new vec4(input.Colour, 1)
                                                                            select new FragmentOutput
            {
                Colour = colour
            });
        }
Example #23
0
        public void CmdBindPipeline()
        {
            var descriptorSetLayoutCreateInfo = new DescriptorSetLayoutCreateInfo(
                new DescriptorSetLayoutBinding(0, DescriptorType.StorageBuffer, 1, ShaderStages.Compute),
                new DescriptorSetLayoutBinding(1, DescriptorType.StorageBuffer, 1, ShaderStages.Compute));

            using (DescriptorSetLayout descriptorSetLayout = Device.CreateDescriptorSetLayout(descriptorSetLayoutCreateInfo))
                using (PipelineLayout pipelineLayout = Device.CreatePipelineLayout(new PipelineLayoutCreateInfo(new[] { descriptorSetLayout })))
                    using (ShaderModule shader = Device.CreateShaderModule(new ShaderModuleCreateInfo(ReadAllBytes("Shader.comp.spv"))))
                    {
                        var pipelineCreateInfo = new ComputePipelineCreateInfo(
                            new PipelineShaderStageCreateInfo(ShaderStages.Compute, shader, "main"),
                            pipelineLayout);

                        using (Pipeline pipeline = Device.CreateComputePipeline(pipelineCreateInfo))
                        {
                            CommandBuffer.Begin();
                            CommandBuffer.CmdBindPipeline(PipelineBindPoint.Compute, pipeline);
                            CommandBuffer.End();
                        }
                    }
        }
            public Item(
                int order,
                bool depthClamp,
                bool depthBias,
                IInternalRenderObject renderObject,
                SpecializationContainer specializationContainer,
                PushDataContainer pushDataContainer,
                ShaderProgram vertProg,
                ShaderProgram fragProg,
                Device logicalDevice,
                string debugName = null)
            {
                this.order                   = order;
                this.renderObject            = renderObject;
                this.specializationContainer = specializationContainer;
                this.pushDataContainer       = pushDataContainer;
                this.depthClamp              = depthClamp;
                this.depthBias               = depthBias;
                this.debugName               = debugName;

                vertModule = vertProg.CreateModule(logicalDevice);
                fragModule = fragProg.CreateModule(logicalDevice);
            }
        internal static Pipeline CreatePipeline(
            Device logicalDevice,
            RenderPass renderpass,
            PipelineLayout layout,
            ShaderModule vertModule,
            ShaderModule fragModule,
            SpecializationContainer specializationContainer,
            bool depthClamp,
            bool depthBias,
            ReadOnlySpan <DeviceTexture> targets,
            IInternalRenderObject renderObject)
        {
            if (logicalDevice == null)
            {
                throw new ArgumentNullException(nameof(logicalDevice));
            }
            if (renderpass == null)
            {
                throw new ArgumentNullException(nameof(renderpass));
            }

            var shaderStages = new []
            {
                new PipelineShaderStageCreateInfo(
                    stage: ShaderStages.Vertex, module: vertModule, name: "main",
                    specializationInfo: specializationContainer?.GetInfo()),
                new PipelineShaderStageCreateInfo(
                    stage: ShaderStages.Fragment,
                    module: fragModule, name: "main",
                    specializationInfo: specializationContainer?.GetInfo())
            };
            var depthTest = new PipelineDepthStencilStateCreateInfo {
                DepthTestEnable       = true,
                DepthWriteEnable      = true,
                DepthCompareOp        = CompareOp.LessOrEqual,
                DepthBoundsTestEnable = false,
                StencilTestEnable     = false
            };
            var rasterizer = new PipelineRasterizationStateCreateInfo(
                depthClampEnable: depthClamp,
                rasterizerDiscardEnable: false,
                polygonMode: PolygonMode.Fill,
                cullMode: CullModes.Back,
                frontFace: renderObject.GetFrontFace(),
                depthBiasEnable: depthBias,
                depthBiasConstantFactor: .1f,
                depthBiasSlopeFactor: 1.75f,
                lineWidth: 1f
                );

            //Gather all the color targets and setup a blend-state for them
            ResizeArray <PipelineColorBlendAttachmentState> blendAttachments =
                new ResizeArray <PipelineColorBlendAttachmentState>();

            for (int i = 0; i < targets.Length; i++)
            {
                if (!targets[i].DepthTexture)
                {
                    blendAttachments.Add(new PipelineColorBlendAttachmentState(
                                             colorWriteMask: ColorComponents.All, blendEnable: false));
                }
            }

            var blending = new PipelineColorBlendStateCreateInfo(
                attachments: blendAttachments.ToArray(),
                logicOpEnable: false
                );
            var multisampleState = new PipelineMultisampleStateCreateInfo(
                rasterizationSamples: SampleCounts.Count1,
                sampleShadingEnable: false
                );
            //Pass the viewport and scissor-rect as dynamic so we are not tied to swapchain size
            //the advantage is this is that we don't need to recreate the pipeline on swapchain
            //resize
            var dynamicState = new PipelineDynamicStateCreateInfo(
                DynamicState.Viewport,
                DynamicState.Scissor
                );

            return(logicalDevice.CreateGraphicsPipeline(new GraphicsPipelineCreateInfo(
                                                            layout: layout,
                                                            renderPass: renderpass,
                                                            subpass: 0,
                                                            stages: shaderStages,
                                                            inputAssemblyState: renderObject.GetInputAssemblyStateInfo(),
                                                            vertexInputState: renderObject.GetVertexInputState(),
                                                            rasterizationState: rasterizer,
                                                            tessellationState: null,
                                                            //Pass empty viewport and scissor-rect as we set them dynamically
                                                            viewportState: new PipelineViewportStateCreateInfo(new Viewport(), new Rect2D()),
                                                            multisampleState: multisampleState,
                                                            depthStencilState: depthTest,
                                                            colorBlendState: blending,
                                                            dynamicState: dynamicState,
                                                            flags: PipelineCreateFlags.None
                                                            )));
        }
Example #26
0
 internal static unsafe extern void vkDestroyShaderModule(Device device, ShaderModule shaderModule, AllocationCallbacks *Allocator);
Example #27
0
 public unsafe void DestroyShaderModule(ShaderModule shaderModule, AllocationCallbacks* allocator = null)
 {
     vkDestroyShaderModule(this, shaderModule, allocator);
 }
Example #28
0
 /// <param name="Stage">Shader stage</param>
 /// <param name="Module">Module containing entry point</param>
 /// <param name="Name">Null-terminated entry point name</param>
 public PipelineShaderStageCreateInfo(ShaderStageFlags Stage, ShaderModule Module, String Name) : this()
 {
     this.Stage  = Stage;
     this.Module = Module;
     this.Name   = Name;
 }
Example #29
0
 internal static unsafe extern Result vkCreateShaderModule(Device device, ShaderModuleCreateInfo* createInfo, AllocationCallbacks* allocator, ShaderModule* shaderModule);
Example #30
0
        public void CreateGraphicsPipeline()
        {
            var attachment = new AttachmentDescription
            {
                Samples        = SampleCounts.Count1,
                Format         = Format.B8G8R8A8UNorm,
                InitialLayout  = ImageLayout.Undefined,
                FinalLayout    = ImageLayout.PresentSrcKhr,
                LoadOp         = AttachmentLoadOp.Clear,
                StoreOp        = AttachmentStoreOp.Store,
                StencilLoadOp  = AttachmentLoadOp.DontCare,
                StencilStoreOp = AttachmentStoreOp.DontCare
            };
            var subpass    = new SubpassDescription(new[] { new AttachmentReference(0, ImageLayout.ColorAttachmentOptimal) });
            var createInfo = new RenderPassCreateInfo(new[] { subpass }, new[] { attachment });

            using (PipelineCache cache = Device.CreatePipelineCache())
                using (RenderPass renderPass = Device.CreateRenderPass(createInfo))
                    using (PipelineLayout layout = Device.CreatePipelineLayout())
                        using (ShaderModule vertexShader = Device.CreateShaderModule(new ShaderModuleCreateInfo(ReadAllBytes("Shader.vert.spv"))))
                            using (ShaderModule fragmentShader = Device.CreateShaderModule(new ShaderModuleCreateInfo(ReadAllBytes("Shader.frag.spv"))))
                            {
                                var shaderStageCreateInfos = new[]
                                {
                                    new PipelineShaderStageCreateInfo(ShaderStages.Vertex, vertexShader, "main"),
                                    new PipelineShaderStageCreateInfo(ShaderStages.Fragment, fragmentShader, "main")
                                };
                                var vertexInputStateCreateInfo   = new PipelineVertexInputStateCreateInfo();
                                var inputAssemblyStateCreateInfo = new PipelineInputAssemblyStateCreateInfo(PrimitiveTopology.TriangleList);
                                var viewportStateCreateInfo      = new PipelineViewportStateCreateInfo(
                                    new Viewport(0, 0, 32, 32),
                                    new Rect2D(0, 0, 32, 32));
                                var rasterizationStateCreateInfo = new PipelineRasterizationStateCreateInfo
                                {
                                    PolygonMode = PolygonMode.Fill,
                                    CullMode    = CullModes.Back,
                                    FrontFace   = FrontFace.CounterClockwise,
                                    LineWidth   = 1.0f
                                };
                                var tessellationStateCreateInfo = new PipelineTessellationStateCreateInfo(4);
                                var multisampleStateCreateInfo  = new PipelineMultisampleStateCreateInfo
                                {
                                    RasterizationSamples = SampleCounts.Count1,
                                    MinSampleShading     = 1.0f
                                };
                                var colorBlendAttachmentState = new PipelineColorBlendAttachmentState
                                {
                                    SrcColorBlendFactor = BlendFactor.One,
                                    DstColorBlendFactor = BlendFactor.Zero,
                                    ColorBlendOp        = BlendOp.Add,
                                    SrcAlphaBlendFactor = BlendFactor.One,
                                    DstAlphaBlendFactor = BlendFactor.Zero,
                                    AlphaBlendOp        = BlendOp.Add,
                                    ColorWriteMask      = ColorComponents.All
                                };
                                var depthStencilStateCreateInfo = new PipelineDepthStencilStateCreateInfo();
                                var colorBlendStateCreateInfo   = new PipelineColorBlendStateCreateInfo(
                                    new[] { colorBlendAttachmentState });
                                var dynamicStateCreateInfo = new PipelineDynamicStateCreateInfo(DynamicState.LineWidth);

                                var pipelineCreateInfo = new GraphicsPipelineCreateInfo(
                                    layout, renderPass, 0,
                                    shaderStageCreateInfos,
                                    inputAssemblyStateCreateInfo,
                                    vertexInputStateCreateInfo,
                                    rasterizationStateCreateInfo,
                                    tessellationStateCreateInfo,
                                    viewportStateCreateInfo,
                                    multisampleStateCreateInfo,
                                    depthStencilStateCreateInfo,
                                    colorBlendStateCreateInfo,
                                    dynamicStateCreateInfo);
                                using (Device.CreateGraphicsPipelines(new[] { pipelineCreateInfo })[0]) { }
                                using (Device.CreateGraphicsPipelines(new[] { pipelineCreateInfo }, cache)[0]) { }
                                using (Device.CreateGraphicsPipelines(new[] { pipelineCreateInfo }, allocator: CustomAllocator)[0]) { }
                                using (Device.CreateGraphicsPipelines(new[] { pipelineCreateInfo }, cache, CustomAllocator)[0]) { }
                                using (Device.CreateGraphicsPipeline(pipelineCreateInfo)) { }
                                using (Device.CreateGraphicsPipeline(pipelineCreateInfo, allocator: CustomAllocator)) { }
                                using (Device.CreateGraphicsPipeline(pipelineCreateInfo, cache)) { }
                                using (Device.CreateGraphicsPipeline(pipelineCreateInfo, cache, CustomAllocator)) { }
                            }
        }
Example #31
0
 internal static unsafe extern void vkDestroyShaderModule(Device device, ShaderModule shaderModule, AllocationCallbacks* allocator);
Example #32
0
        private Pipeline CreateGraphicsPipeline()
        {
            // Create shader modules. Shader modules are one of the objects required to create the
            // graphics pipeline. But after the pipeline is created, we don't need these shader
            // modules anymore, so we dispose them.
            ShaderModule vertexShader           = Content.Load <ShaderModule>("Shader.vert.spv");
            ShaderModule fragmentShader         = Content.Load <ShaderModule>("Shader.frag.spv");
            var          shaderStageCreateInfos = new[]
            {
                new PipelineShaderStageCreateInfo(ShaderStages.Vertex, vertexShader, "main"),
                new PipelineShaderStageCreateInfo(ShaderStages.Fragment, fragmentShader, "main")
            };

            var vertexInputStateCreateInfo = new PipelineVertexInputStateCreateInfo(
                new[] { new VertexInputBindingDescription(0, Interop.SizeOf <Vertex>(), VertexInputRate.Vertex) },
                new[]
            {
                new VertexInputAttributeDescription(0, 0, Format.R32G32B32SFloat, 0),      // Position.
                new VertexInputAttributeDescription(1, 0, Format.R32G32B32SFloat, 12),     // Normal.
                new VertexInputAttributeDescription(2, 0, Format.R32G32SFloat, 24)         // TexCoord.
            }
                );
            var inputAssemblyStateCreateInfo = new PipelineInputAssemblyStateCreateInfo(PrimitiveTopology.TriangleList);
            var viewportStateCreateInfo      = new PipelineViewportStateCreateInfo(
                new Viewport(0, 0, Host.Width, Host.Height),
                new Rect2D(0, 0, Host.Width, Host.Height));
            var rasterizationStateCreateInfo = new PipelineRasterizationStateCreateInfo
            {
                PolygonMode = PolygonMode.Fill,
                CullMode    = CullModes.Back,
                FrontFace   = FrontFace.CounterClockwise,
                LineWidth   = 1.0f
            };
            var multisampleStateCreateInfo = new PipelineMultisampleStateCreateInfo
            {
                RasterizationSamples = SampleCounts.Count1,
                MinSampleShading     = 1.0f
            };
            var depthStencilCreateInfo = new PipelineDepthStencilStateCreateInfo
            {
                DepthTestEnable  = true,
                DepthWriteEnable = true,
                DepthCompareOp   = CompareOp.LessOrEqual,
                Back             = new StencilOpState
                {
                    FailOp    = StencilOp.Keep,
                    PassOp    = StencilOp.Keep,
                    CompareOp = CompareOp.Always
                },
                Front = new StencilOpState
                {
                    FailOp    = StencilOp.Keep,
                    PassOp    = StencilOp.Keep,
                    CompareOp = CompareOp.Always
                }
            };
            var colorBlendAttachmentState = new PipelineColorBlendAttachmentState
            {
                SrcColorBlendFactor = BlendFactor.One,
                DstColorBlendFactor = BlendFactor.Zero,
                ColorBlendOp        = BlendOp.Add,
                SrcAlphaBlendFactor = BlendFactor.One,
                DstAlphaBlendFactor = BlendFactor.Zero,
                AlphaBlendOp        = BlendOp.Add,
                ColorWriteMask      = ColorComponents.All
            };
            var colorBlendStateCreateInfo = new PipelineColorBlendStateCreateInfo(
                new[] { colorBlendAttachmentState });

            var pipelineCreateInfo = new GraphicsPipelineCreateInfo(
                _pipelineLayout, _renderPass, 0,
                shaderStageCreateInfos,
                inputAssemblyStateCreateInfo,
                vertexInputStateCreateInfo,
                rasterizationStateCreateInfo,
                viewportState: viewportStateCreateInfo,
                multisampleState: multisampleStateCreateInfo,
                depthStencilState: depthStencilCreateInfo,
                colorBlendState: colorBlendStateCreateInfo);

            return(Context.Device.CreateGraphicsPipeline(pipelineCreateInfo));
        }
Example #33
0
        void CreatePipeline()
        {
            ShaderModule vertex_shader_module   = CreateShaderModule("assets/shader03.vert.spv");
            ShaderModule fragment_shader_module = CreateShaderModule("assets/shader03.frag.spv");

            var shader_stage_create_infos = stackalloc PipelineShaderStageCreateInfo[2];

            // Vertex shader
            shader_stage_create_infos[0] = new PipelineShaderStageCreateInfo
            {
                sType  = StructureType.PipelineShaderStageCreateInfo,                  // VkStructureType                                sType
                pNext  = IntPtr.Zero,                                                  // const void                                    *pNext
                flags  = 0,                                                            // VkPipelineShaderStageCreateFlagBits               flags
                stage  = ShaderStageFlagBits.VertexBit,                                // VkShaderStageFlagBits                          stage
                module = vertex_shader_module,                                         // VkShaderModule                                 module
                pName  = (byte *)Marshal.StringToHGlobalAnsi("main"),                  // const char                                    *pName
                pSpecializationInfo = (SpecializationInfo *)0                          // const VkSpecializationInfo                    *pSpecializationInfo
            };
            // Fragment shader
            shader_stage_create_infos[1] = new PipelineShaderStageCreateInfo
            {
                sType  = StructureType.PipelineShaderStageCreateInfo,                  // VkStructureType                                sType
                pNext  = IntPtr.Zero,                                                  // const void                                    *pNext
                flags  = 0,                                                            // VkPipelineShaderStageCreateFlagBits               flags
                stage  = ShaderStageFlagBits.FragmentBit,                              // VkShaderStageFlagBits                          stage
                module = fragment_shader_module,                                       // VkShaderModule                                 module
                pName  = (byte *)Marshal.StringToHGlobalAnsi("main"),                  // const char                                    *pName
                pSpecializationInfo = (SpecializationInfo *)0                          // const VkSpecializationInfo                    *pSpecializationInfo
            };

            var vertex_input_state_create_info = new PipelineVertexInputStateCreateInfo
            {
                sType = StructureType.PipelineVertexInputStateCreateInfo,                           // VkStructureType                                sType
                pNext = IntPtr.Zero,                                                                // const void                                    *pNext
                flags = 0,                                                                          // VkPipelineVertexInputStateCreateFlagBits          flags;
                vertexBindingDescriptionCount   = 0,                                                // uint32_t                                       vertexBindingDescriptionCount
                pVertexBindingDescriptions      = (VertexInputBindingDescription *)0,               // const VkVertexInputBindingDescription         *pVertexBindingDescriptions
                vertexAttributeDescriptionCount = 0,                                                // uint32_t                                       vertexAttributeDescriptionCount
                pVertexAttributeDescriptions    = (VertexInputAttributeDescription *)0              // const VkVertexInputAttributeDescription       *pVertexAttributeDescriptions
            };

            var input_assembly_state_create_info = new PipelineInputAssemblyStateCreateInfo
            {
                sType    = StructureType.PipelineInputAssemblyStateCreateInfo,              // VkStructureType                                sType
                pNext    = IntPtr.Zero,                                                     // const void                                    *pNext
                flags    = 0,                                                               // VkPipelineInputAssemblyStateCreateFlagBits        flags
                topology = PrimitiveTopology.TriangleList,                                  // VkPrimitiveTopology                            topology
                primitiveRestartEnable = false                                              // VkBool32                                       primitiveRestartEnable
            };

            Viewport viewport = new Viewport
            {
                x        = 0.0f,                        // float       x
                y        = 0.0f,                        // float       y
                width    = 300.0f,                      // float       width
                height   = 300.0f,                      // float       height
                minDepth = 0.0f,                        // float       minDepth
                maxDepth = 1.0f                         // float       maxDepth
            };

            Rect2D scissor = new Rect2D
            {
                offset = new Offset2D
                {                                       // VkOffset2D  offset
                    x = 0,                              // int32_t     x
                    y = 0                               // int32_t     y
                },
                extent = new Extent2D
                {                                       // VkExtent2D  extent
                    width  = 300,                       // int32_t     width
                    height = 300                        // int32_t     height
                }
            };

            var viewport_state_create_info = new PipelineViewportStateCreateInfo
            {
                sType         = StructureType.PipelineViewportStateCreateInfo,         // VkStructureType                                sType
                pNext         = IntPtr.Zero,                                           // const void                                    *pNext
                flags         = 0,                                                     // VkPipelineViewportStateCreateFlagBits             flags
                viewportCount = 1,                                                     // uint32_t                                       viewportCount
                pViewports    = &viewport,                                             // const VkViewport                              *pViewports
                scissorCount  = 1,                                                     // uint32_t                                       scissorCount
                pScissors     = &scissor                                               // const VkRect2D                                *pScissors
            };

            var rasterization_state_create_info = new PipelineRasterizationStateCreateInfo
            {
                sType                   = StructureType.PipelineRasterizationStateCreateInfo, // VkStructureType                                sType
                pNext                   = IntPtr.Zero,                                        // const void                                    *pNext
                flags                   = 0,                                                  // VkPipelineRasterizationStateCreateFlagBits        flags
                depthClampEnable        = false,                                              // VkBool32                                       depthClampEnable
                rasterizerDiscardEnable = false,                                              // VkBool32                                       rasterizerDiscardEnable
                polygonMode             = PolygonMode.Fill,                                   // VkPolygonMode                                  polygonMode
                cullMode                = CullModeFlagBits.BackBit,                           // VkCullModeFlagBits                                cullMode
                frontFace               = FrontFace.CounterClockwise,                         // VkFrontFace                                    frontFace
                depthBiasEnable         = false,                                              // VkBool32                                       depthBiasEnable
                depthBiasConstantFactor = 0.0f,                                               // float                                          depthBiasConstantFactor
                depthBiasClamp          = 0.0f,                                               // float                                          depthBiasClamp
                depthBiasSlopeFactor    = 0.0f,                                               // float                                          depthBiasSlopeFactor
                lineWidth               = 1.0f                                                // float                                          lineWidth
            };

            var multisample_state_create_info = new PipelineMultisampleStateCreateInfo
            {
                sType = StructureType.PipelineMultisampleStateCreateInfo,                 // VkStructureType                                sType
                pNext = IntPtr.Zero,                                                      // const void                                    *pNext
                flags = 0,                                                                // VkPipelineMultisampleStateCreateFlagBits          flags
                rasterizationSamples  = SampleCountFlagBits._1Bit,                        // VkSampleCountFlagBits                          rasterizationSamples
                sampleShadingEnable   = false,                                            // VkBool32                                       sampleShadingEnable
                minSampleShading      = 1.0f,                                             // float                                          minSampleShading
                pSampleMask           = (uint *)0,                                        // const VkSampleMask                            *pSampleMask
                alphaToCoverageEnable = false,                                            // VkBool32                                       alphaToCoverageEnable
                alphaToOneEnable      = false                                             // VkBool32                                       alphaToOneEnable
            };

            var color_blend_attachment_state = new PipelineColorBlendAttachmentState
            {
                blendEnable                 = false,                                                    // VkBool32                                       blendEnable
                sourceColorBlendFactor      = BlendFactor.One,                                          // VkBlendFactor                                  srcColorBlendFactor
                destinationColorBlendFactor = BlendFactor.Zero,                                         // VkBlendFactor                                  dstColorBlendFactor
                colorBlendOperation         = BlendOperation.Add,                                       // VkBlendOp                                      colorBlendOp
                sourceAlphaBlendFactor      = BlendFactor.One,                                          // VkBlendFactor                                  srcAlphaBlendFactor
                destinationAlphaBlendFactor = BlendFactor.Zero,                                         // VkBlendFactor                                  dstAlphaBlendFactor
                alphaBlendOperation         = BlendOperation.Add,                                       // VkBlendOp                                      alphaBlendOp
                colorWriteMask              = ColorComponentFlagBits.RBit | ColorComponentFlagBits.GBit // VkColorComponentFlagBits                          colorWriteMask
                                              | ColorComponentFlagBits.BBit | ColorComponentFlagBits.ABit
            };

            var color_blend_state_create_info = new PipelineColorBlendStateCreateInfo
            {
                sType = StructureType.PipelineColorBlendStateCreateInfo,                 // VkStructureType                                sType
                pNext = IntPtr.Zero,                                                     // const void                                    *pNext
                flags = 0,                                                               // VkPipelineColorBlendStateCreateFlagBits           flags
                logicOperationEnable = false,                                            // VkBool32                                       logicOpEnable
                logicOperation       = LogicOperation.Copy,                              // VkLogicOp                                      logicOp
                attachmentCount      = 1,                                                // uint32_t                                       attachmentCount
                pAttachments         = &color_blend_attachment_state,                    // const VkPipelineColorBlendAttachmentState     *pAttachments
            };

            //blendConstants = { 0.0f, 0.0f, 0.0f, 0.0f }              // float                                          blendConstants[4]
            color_blend_state_create_info.blendConstants[0] = 0;
            color_blend_state_create_info.blendConstants[1] = 0;
            color_blend_state_create_info.blendConstants[2] = 0;
            color_blend_state_create_info.blendConstants[3] = 0;

            var pipeline_layout = CreatePipelineLayout();

            var pipeline_create_info = new GraphicsPipelineCreateInfo
            {
                sType               = StructureType.GraphicsPipelineCreateInfo,               // VkStructureType                                sType
                pNext               = IntPtr.Zero,                                            // const void                                    *pNext
                flags               = 0,                                                      // VkPipelineCreateFlagBits                          flags
                stageCount          = 2,                                                      // uint32_t                                       stageCount
                pStages             = shader_stage_create_infos,                              // const VkPipelineShaderStageCreateInfo         *pStages
                pVertexInputState   = &vertex_input_state_create_info,                        // const VkPipelineVertexInputStateCreateInfo    *pVertexInputState;
                pInputAssemblyState = &input_assembly_state_create_info,                      // const VkPipelineInputAssemblyStateCreateInfo  *pInputAssemblyState
                pTessellationState  = (PipelineTessellationStateCreateInfo *)0,               // const VkPipelineTessellationStateCreateInfo   *pTessellationState
                pViewportState      = &viewport_state_create_info,                            // const VkPipelineViewportStateCreateInfo       *pViewportState
                pRasterizationState = &rasterization_state_create_info,                       // const VkPipelineRasterizationStateCreateInfo  *pRasterizationState
                pMultisampleState   = &multisample_state_create_info,                         // const VkPipelineMultisampleStateCreateInfo    *pMultisampleState
                pDepthStencilState  = (PipelineDepthStencilStateCreateInfo *)0,               // const VkPipelineDepthStencilStateCreateInfo   *pDepthStencilState
                pColorBlendState    = &color_blend_state_create_info,                         // const VkPipelineColorBlendStateCreateInfo     *pColorBlendState
                pDynamicState       = (PipelineDynamicStateCreateInfo *)0,                    // const VkPipelineDynamicStateCreateInfo        *pDynamicState
                layout              = pipeline_layout,                                        // VkPipelineLayout                               layout
                renderPass          = Vulkan.RenderPass,                                      // VkRenderPass                                   renderPass
                subpass             = 0,                                                      // uint32_t                                       subpass
                basePipelineHandle  = default(Pipeline),                                      // VkPipeline                                     basePipelineHandle
                basePipelineIndex   = -1                                                      // int32_t                                        basePipelineIndex
            };

            vk.CreateGraphicsPipelines(GetDevice, default(PipelineCache), 1, &pipeline_create_info, (AllocationCallbacks *)0, out Vulkan.GraphicsPipeline).CheckError();

            Marshal.FreeHGlobal((IntPtr)shader_stage_create_infos[0].pName);
            Marshal.FreeHGlobal((IntPtr)shader_stage_create_infos[1].pName);
        }