private static void Engine_OnRebuildGraph() { var graph = Engine.RenderGraph; for (int i = 0; i < GraphicsDevice.MaxFramesInFlight; i++) { var out_img = GraphicsDevice.DefaultFramebuffer[i].ColorAttachments[0]; graph.RegisterResource(out_img); graph.RegisterResource(depthImageViews[i]); } graph.RegisterShader(vertS); graph.RegisterShader(fragS); planetBuffers.RebuildGraph(); var gpass = new GraphicsPass("main_pass") { Shaders = new string[] { vertS.Name, fragS.Name }, ViewportWidth = GraphicsDevice.Width, ViewportHeight = GraphicsDevice.Height, ViewportDynamic = false, DepthWriteEnable = true, DepthTest = DepthTest.Always, CullMode = CullMode.None, Fill = FillMode.Fill, ViewportMinDepth = 0, ViewportMaxDepth = 1, RenderLayout = new RenderLayout() { Color = new RenderLayoutEntry[] { new RenderLayoutEntry() { DesiredLayout = ImageLayout.ColorAttachmentOptimal, FirstLoadStage = PipelineStage.ColorAttachOut, Format = GraphicsDevice.DefaultFramebuffer[GraphicsDevice.CurrentFrameID].ColorAttachments[0].Format, LastStoreStage = PipelineStage.ColorAttachOut, LoadOp = AttachmentLoadOp.DontCare, StoreOp = AttachmentStoreOp.Store, }, }, Depth = new RenderLayoutEntry() { DesiredLayout = ImageLayout.DepthAttachmentOptimal, FirstLoadStage = PipelineStage.EarlyFragTests, Format = ImageFormat.Depth32f, LastStoreStage = PipelineStage.LateFragTests, LoadOp = AttachmentLoadOp.DontCare, StoreOp = AttachmentStoreOp.Store, }, }, DescriptorSetup = new DescriptorSetup() { Descriptors = new DescriptorConfig[] { new DescriptorConfig() { Count = 1, Index = 0, DescriptorType = DescriptorType.UniformBuffer, } }, PushConstants = null, }, Resources = new ResourceUsageEntry[] { new BufferUsageEntry() { StartStage = PipelineStage.VertShader, StartAccesses = AccessFlags.ShaderRead, FinalStage = PipelineStage.VertShader, FinalAccesses = AccessFlags.None } } }; graph.RegisterGraphicsPass(gpass); planet.RebuildGraph(); graph.GatherDescriptors(); }
public void RebuildGraph() { if (cur_cntr == 0) { indexBuffer.RebuildGraph(); paramBuffer.RebuildGraph(); Engine.RenderGraph.RegisterShader(vertexShader); Engine.RenderGraph.RegisterShader(fragmentShader); Engine.RenderGraph.RegisterGraphicsPass(new GraphicsPass("TerrainFace_pass") { Shaders = new string[] { vertexShader.Name, fragmentShader.Name }, ViewportWidth = Engine.Width, ViewportHeight = Engine.Height, ViewportDynamic = false, DepthWriteEnable = true, DepthTest = DepthTest.Greater, CullMode = CullMode.None, Fill = FillMode.Fill, ViewportMinDepth = 0, ViewportMaxDepth = 1, RenderLayout = new RenderLayout() { Color = new RenderLayoutEntry[] { new RenderLayoutEntry() { DesiredLayout = ImageLayout.ColorAttachmentOptimal, FirstLoadStage = PipelineStage.ColorAttachOut, Format = GraphicsDevice.DefaultFramebuffer[GraphicsDevice.CurrentFrameID].ColorAttachments[0].Format, LastStoreStage = PipelineStage.ColorAttachOut, LoadOp = AttachmentLoadOp.Load, StoreOp = AttachmentStoreOp.Store, }, }, Depth = new RenderLayoutEntry() { DesiredLayout = ImageLayout.DepthAttachmentOptimal, FirstLoadStage = PipelineStage.EarlyFragTests, Format = ImageFormat.Depth32f, LastStoreStage = PipelineStage.LateFragTests, LoadOp = AttachmentLoadOp.Load, StoreOp = AttachmentStoreOp.Store, }, }, DescriptorSetup = new DescriptorSetup() { Descriptors = new DescriptorConfig[] { new DescriptorConfig() { Count = 1, Index = 0, DescriptorType = DescriptorType.UniformBuffer, }, new DescriptorConfig() { Count = 1, Index = 1, DescriptorType = DescriptorType.UniformBuffer }, new DescriptorConfig() { Count = 1, Index = 2, DescriptorType = DescriptorType.StorageBuffer } }, PushConstants = new PushConstantConfig[] { new PushConstantConfig() { Offset = 0, Size = pushConstantsLen, Stages = ShaderType.All }, }, }, Resources = new ResourceUsageEntry[] { new BufferUsageEntry() { StartStage = PipelineStage.VertShader, StartAccesses = AccessFlags.ShaderRead, FinalStage = PipelineStage.VertShader, FinalAccesses = AccessFlags.None }, new BufferUsageEntry() { StartStage = PipelineStage.VertShader, StartAccesses = AccessFlags.ShaderRead, FinalStage = PipelineStage.FragShader, FinalAccesses = AccessFlags.None, }, new BufferUsageEntry() { StartStage = PipelineStage.VertShader, StartAccesses = AccessFlags.ShaderRead, FinalStage = PipelineStage.VertShader, FinalAccesses = AccessFlags.None, } } }); } }