public EnvironmentCube(string cubemapPath, DescriptorSet dsSkybox, PipelineLayout plLayout, Queue staggingQ, RenderPass renderPass, PipelineCache cache = null) : base(renderPass, cache, "EnvCube pipeline") { using (CommandPool cmdPool = new CommandPool(staggingQ.Dev, staggingQ.index)) { vboSkybox = new GPUBuffer <float> (staggingQ, cmdPool, VkBufferUsageFlags.VertexBuffer, box_vertices); cubemap = KTX.KTX.Load(staggingQ, cmdPool, cubemapPath, VkImageUsageFlags.Sampled, VkMemoryPropertyFlags.DeviceLocal, true); cubemap.CreateView(VkImageViewType.Cube, VkImageAspectFlags.Color); cubemap.CreateSampler(VkSamplerAddressMode.ClampToEdge); cubemap.SetName("skybox Texture"); cubemap.Descriptor.imageLayout = VkImageLayout.ShaderReadOnlyOptimal; GraphicPipelineConfig cfg = GraphicPipelineConfig.CreateDefault(VkPrimitiveTopology.TriangleList, renderPass.Samples, false); cfg.RenderPass = renderPass; cfg.Layout = plLayout; cfg.AddVertexBinding(0, 3 * sizeof(float)); cfg.AddVertexAttributes(0, VkFormat.R32g32b32Sfloat); cfg.AddShader(VkShaderStageFlags.Vertex, "#deferred.skybox.vert.spv"); cfg.AddShader(VkShaderStageFlags.Fragment, "#deferred.skybox.frag.spv"); cfg.multisampleState.rasterizationSamples = Samples; layout = cfg.Layout; init(cfg); generateBRDFLUT(staggingQ, cmdPool); generateCubemaps(staggingQ, cmdPool); } }
/// <summary> /// Create a new Pipeline with supplied PipelineLayout /// </summary> public ComputePipeline(PipelineLayout layout, string spirvPath, PipelineCache cache = null, string name = "pipeline") : base(layout.Dev, cache, name) { SpirVPath = spirvPath; this.layout = layout; Activate(); }
public FSQPipeline(RenderPass renderPass, PipelineLayout pipelineLayout, int attachment = 0, PipelineCache pipelineCache = null) : base(renderPass, pipelineCache, "FSQ pipeline") { using (GraphicPipelineConfig cfg = GraphicPipelineConfig.CreateDefault(VkPrimitiveTopology.TriangleList, this.RenderPass.Samples, false)) { cfg.RenderPass = RenderPass; cfg.Layout = pipelineLayout; cfg.AddShader(Dev, VkShaderStageFlags.Vertex, "#vke.FullScreenQuad.vert.spv"); cfg.AddShader(Dev, VkShaderStageFlags.Fragment, FragPath); cfg.multisampleState.rasterizationSamples = Samples; cfg.blendAttachments[attachment] = new VkPipelineColorBlendAttachmentState(true); layout = cfg.Layout; init(cfg); } }
/// <summary> /// execute the descriptors writes targeting descriptorSets setted on AddWriteInfo call /// </summary> public void Push(PrimaryCommandBuffer cmd, PipelineLayout plLayout, params object[] descriptors) { using (PinnedObjects pinCtx = new PinnedObjects()) { int i = 0; int wdsPtr = 0; while (i < descriptors.Length) { int firstDescriptor = i; VkWriteDescriptorSet wds = WriteDescriptorSets[wdsPtr]; wds.dstSet = 0; IntPtr pDescriptors = IntPtr.Zero; if (wds.descriptorCount > 1) { List <IntPtr> descPtrArray = new List <IntPtr> (); for (int d = 0; d < wds.descriptorCount; d++) { descPtrArray.Add(descriptors[i].Pin(pinCtx)); i++; } pDescriptors = descPtrArray.Pin(pinCtx); } else { pDescriptors = descriptors[i].Pin(pinCtx); i++; } if (descriptors[firstDescriptor] is VkDescriptorBufferInfo) { wds.pBufferInfo = pDescriptors; } else if (descriptors[firstDescriptor] is VkDescriptorImageInfo) { wds.pImageInfo = pDescriptors; } WriteDescriptorSets[wdsPtr] = wds; wdsPtr++; } vkCmdPushDescriptorSetKHR(cmd.Handle, VkPipelineBindPoint.Graphics, plLayout.handle, 0, (uint)WriteDescriptorSets.Count, WriteDescriptorSets.Pin(pinCtx)); } }
public void PushConstant(PipelineLayout pipelineLayout, VkShaderStageFlags stageFlags, uint size, Object data, uint offset = 0) { vkCmdPushConstants(handle, pipelineLayout.handle, stageFlags, offset, size, data.Pin()); data.Unpin(); }
public void BindDescriptorSets(VkPipelineBindPoint bindPoint, PipelineLayout pipelineLayout, uint firstSet, params DescriptorSet[] descriptorSets) { vkCmdBindDescriptorSets(handle, bindPoint, pipelineLayout.handle, firstSet, (uint)descriptorSets.Length, descriptorSets.Pin(), 0, IntPtr.Zero); descriptorSets.Unpin(); }
public void BindDescriptorSet(VkPipelineBindPoint bindPoint, PipelineLayout pipelineLayout, DescriptorSet descriptorSet, uint firstSet = 0) { vkCmdBindDescriptorSets(handle, bindPoint, pipelineLayout.handle, firstSet, 1, ref descriptorSet.handle, 0, IntPtr.Zero); }