예제 #1
0
        protected override void CreateRenderPath()
        {
            Add(new ShadowPass());

            clustering = CreateClusteringPass();

            Add(clustering);

            lightCull = new ComputePass(ComputeLight);

            Add(lightCull);

            mainPass = new FrameGraphPass
            {
                new AttachmentInfo(Graphics.ColorFormat),
                new AttachmentInfo(Graphics.DepthFormat)
                {
                    //loadOp = VkAttachmentLoadOp.Load,
                    storeOp = VkAttachmentStoreOp.Store
                },

                new SceneSubpass("cluster_forward")
                {
                    Set1 = resourceSet1,
                    Set2 = resourceSet2,
                    DisableDepthStencil = false
                }
            };

            Add(mainPass);
        }
예제 #2
0
        public void AddRenderPass(FrameGraphPass renderPass)
        {
            RenderPassList.Add(renderPass);
            renderPass.Renderer = this;

            if (initialized)
            {
                renderPass.Init();
            }
        }
예제 #3
0
        public FrameGraphPass AddGraphicsPass(Action <GraphicsSubpass, RenderContext, CommandBuffer> onDraw)
        {
            var renderPass = new FrameGraphPass
            {
                new AttachmentInfo(Graphics.Swapchain.ColorFormat),

                new GraphicsSubpass
                {
                    OnDraw = onDraw
                }
            };

            AddRenderPass(renderPass);
            return(renderPass);
        }
예제 #4
0
        protected FrameGraphPass CreateClusteringPass()
        {
            var clustering = new FrameGraphPass(SubmitQueue.EarlyGraphics)
            {
                new AttachmentInfo(depthTexture.format),

                new SceneSubpass("clustering")
                {
                    Set1 = clusterSet1,
                    OutputAttachments   = null,
                    DisableDepthStencil = false
                }
            };

            clustering.renderPassCreator = OnCreateClusterRenderPass;
            return(clustering);
        }
예제 #5
0
        protected override void OnEndPass(FrameGraphPass renderPass, CommandBuffer cmd)
        {
            int imageIndex = Graphics.WorkContext;

            if (renderPass == clustering)
            {
                var queryPool = query_pool[imageIndex];
                //cb.WriteTimestamp(PipelineStageFlags.FragmentShader, queryPool, QUERY_CLUSTERING * 2 + 1);
            }
            else if (renderPass == mainPass)
            {
                var queryPool = query_pool[imageIndex];

                //cb.WriteTimestamp(PipelineStageFlags.ColorAttachmentOutput, queryPool, QUERY_ONSCREEN * 2 + 1);
                ClearBuffers(cmd, imageIndex);
            }
        }
예제 #6
0
        protected override void OnBeginPass(FrameGraphPass renderPass, CommandBuffer cmd)
        {
            int imageIndex = Graphics.WorkContext;

            if (renderPass == clustering)
            {
                var queryPool = query_pool[imageIndex];
                //cb.ResetQueryPool(queryPool, 0, 4);
                //cb.WriteTimestamp(PipelineStageFlags.TopOfPipe, queryPool, QUERY_CLUSTERING * 2);
            }
            else if (renderPass == mainPass)
            {
                var queryPool = query_pool[imageIndex];
                //cb.ResetQueryPool(queryPool, 10, 4);
                //cb.WriteTimestamp(PipelineStageFlags.TopOfPipe, queryPool, QUERY_ONSCREEN * 2);
            }
        }
예제 #7
0
        public ForwardRenderer()
        {
            Add(new ShadowPass());

            var onScreenPass = new FrameGraphPass
            {
                new AttachmentInfo(Graphics.ColorFormat),
                new AttachmentInfo(Graphics.DepthFormat),

                new SceneSubpass
                {
                    DisableDepthStencil = false
                }
            };

            Add(onScreenPass);
        }
예제 #8
0
 protected virtual void OnEndPass(FrameGraphPass renderPass, CommandBuffer cmd)
 {
 }
예제 #9
0
 public RenderPipeline Add(FrameGraphPass renderPass)
 {
     AddRenderPass(renderPass);
     return(this);
 }
예제 #10
0
        protected override void CreateRenderPath()
        {
            this.Add(new ShadowPass());

            geometryPass = new FrameGraphPass(SubmitQueue.EarlyGraphics)
            {
                new AttachmentInfo("albedo", SizeHint.Full, VkFormat.R8G8B8A8UNorm, VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.Sampled),
                new AttachmentInfo("normal", SizeHint.Full, VkFormat.R8G8B8A8UNorm, VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.Sampled),
                new AttachmentInfo(depthTexture.format),

                new SceneSubpass("gbuffer")
                {
                    Set1 = clusterSet1
                }
            };

            geometryPass.renderPassCreator = OnCreateRenderPass;

            this.Add(geometryPass);

            translucentClustering = this.CreateClusteringPass();

            this.Add(translucentClustering);

            if (enableSSAO)
            {
                ssaoPass = new FrameGraphPass
                {
                    new AttachmentInfo("ssao", SizeHint.Full, VkFormat.R8UNorm, VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.Sampled),

                    new SSAOSubpass()
                };

                this.Add(ssaoPass);

                ssaoBlur = new FrameGraphPass
                {
                    new AttachmentInfo("ssao_blur", SizeHint.Full, VkFormat.R8UNorm, VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.Sampled),

                    new SSAOBlurSubpass()
                };

                this.Add(ssaoBlur);
            }

            lightCull = new ComputePass(ComputeLight);
            this.Add(lightCull);

            var specializationInfo = new SpecializationInfo(new VkSpecializationMapEntry(0, 0, sizeof(uint)));

            specializationInfo.Write(0, enableSSAO ? 1 : 0);

            compositePass = new FrameGraphPass
            {
                new AttachmentInfo("color", SizeHint.Full, VkFormat.R8G8B8A8UNorm, VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.Sampled),
                new AttachmentInfo(depthTexture.format)
                {
                    storeOp = VkAttachmentStoreOp.Store
                },

                new FullScreenSubpass("shaders/glsl/cluster_deferred.frag", specializationInfo)
                {
예제 #11
0
        public ForwardHdrRenderer()
        {
            Add(new ShadowPass());

            var fgPass = new FrameGraphPass
            {
                new AttachmentInfo("color", SizeHint.Full, VkFormat.R16G16B16A16SFloat, VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.Sampled | VkImageUsageFlags.InputAttachment)
                {
                    finalLayout = VkImageLayout.ShaderReadOnlyOptimal
                },

                new AttachmentInfo(Graphics.DepthFormat),

                new SceneSubpass
                {
                    DisableDepthStencil = false
                }
            };


            Add(fgPass);


            var specializationInfo = new SpecializationInfo(new VkSpecializationMapEntry(0, 0, sizeof(uint)));

            specializationInfo.Write(0, 1);

            var onScreenPass = new FrameGraphPass
            {
                new AttachmentInfo(Graphics.Swapchain.ColorFormat),

                new FullScreenSubpass("shaders/post/fullscreen.frag")
                {
                    onBindResource = (rs) =>
                    {
                        rs.SetResourceSet(0, fgPass.RenderTarget[0]);
                    }
                },

                new FullScreenSubpass("shaders/post/bloom.frag")
                {
                    AddtiveMode = true,

                    onBindResource = (rs) =>
                    {
                        rs.SetResourceSet(0, fgPass.RenderTarget[0]);
                    }
                },


                new FullScreenSubpass("shaders/post/bloom.frag", specializationInfo)
                {
                    AddtiveMode = true,

                    onBindResource = (rs) =>
                    {
                        rs.SetResourceSet(0, fgPass.RenderTarget[0]);
                    }
                }
            };


            Add(onScreenPass);
        }