From 5524e501f37c9a82e8e838d073551d08f046fcc8 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Wed, 27 Jan 2021 14:02:46 -0800 Subject: [PATCH] add explicit resource dependencies to graphics resource objects --- src/Graphics/Resources/ComputePipeline.cs | 4 ++++ src/Graphics/Resources/Framebuffer.cs | 18 ++++++++++++++++++ src/Graphics/Resources/GraphicsPipeline.cs | 8 ++++++++ 3 files changed, 30 insertions(+) diff --git a/src/Graphics/Resources/ComputePipeline.cs b/src/Graphics/Resources/ComputePipeline.cs index 75be750b..67ed7597 100644 --- a/src/Graphics/Resources/ComputePipeline.cs +++ b/src/Graphics/Resources/ComputePipeline.cs @@ -7,6 +7,8 @@ namespace MoonWorks.Graphics { protected override Action QueueDestroyFunction => Refresh.Refresh_QueueDestroyComputePipeline; + public ShaderStageState ComputeShaderState { get; } + public unsafe ComputePipeline( GraphicsDevice device, ShaderStageState computeShaderState, @@ -34,6 +36,8 @@ namespace MoonWorks.Graphics device.Handle, computePipelineCreateInfo ); + + ComputeShaderState = computeShaderState; } } } diff --git a/src/Graphics/Resources/Framebuffer.cs b/src/Graphics/Resources/Framebuffer.cs index 3498080d..4be408b7 100644 --- a/src/Graphics/Resources/Framebuffer.cs +++ b/src/Graphics/Resources/Framebuffer.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using RefreshCS; namespace MoonWorks.Graphics @@ -7,6 +8,13 @@ namespace MoonWorks.Graphics { protected override Action QueueDestroyFunction => Refresh.Refresh_QueueDestroyFramebuffer; + public RenderTarget DepthStencilTarget { get; } + + private RenderTarget[] colorTargets { get; } + public IEnumerable ColorTargets => colorTargets; + + public RenderPass RenderPass { get; } + public unsafe Framebuffer( GraphicsDevice device, uint width, @@ -46,6 +54,16 @@ namespace MoonWorks.Graphics Handle = Refresh.Refresh_CreateFramebuffer(device.Handle, framebufferCreateInfo); } + + DepthStencilTarget = depthStencilTarget; + + this.colorTargets = new RenderTarget[colorTargets.Length]; + for (var i = 0; i < colorTargets.Length; i++) + { + this.colorTargets[i] = colorTargets[i]; + } + + RenderPass = renderPass; } } } diff --git a/src/Graphics/Resources/GraphicsPipeline.cs b/src/Graphics/Resources/GraphicsPipeline.cs index 0f3d34a4..44d867fc 100644 --- a/src/Graphics/Resources/GraphicsPipeline.cs +++ b/src/Graphics/Resources/GraphicsPipeline.cs @@ -8,6 +8,10 @@ namespace MoonWorks.Graphics { protected override Action QueueDestroyFunction => Refresh.Refresh_QueueDestroyGraphicsPipeline; + public ShaderStageState VertexShaderState { get; } + public ShaderStageState FragmentShaderState { get; } + public RenderPass RenderPass { get; } + public unsafe GraphicsPipeline( GraphicsDevice device, ColorBlendState colorBlendState, @@ -99,6 +103,10 @@ namespace MoonWorks.Graphics vertexBindingsHandle.Free(); viewportHandle.Free(); scissorHandle.Free(); + + VertexShaderState = vertexShaderState; + FragmentShaderState = fragmentShaderState; + RenderPass = renderPass; } } }