using System; using RefreshCS; namespace MoonWorks.Graphics { /// /// A render pass describes the kind of render targets that will be used in rendering. /// public class RenderPass : GraphicsResource { protected override Action QueueDestroyFunction => Refresh.Refresh_QueueDestroyRenderPass; /// /// Creates a render pass using color target descriptions. /// /// An initialized GraphicsDevice. /// Up to 4 color target descriptions may be provided. public unsafe RenderPass( GraphicsDevice device, params ColorTargetDescription[] colorTargetDescriptions ) : base(device) { fixed (ColorTargetDescription* ptr = colorTargetDescriptions) { Refresh.RenderPassCreateInfo renderPassCreateInfo; renderPassCreateInfo.colorTargetCount = (uint) colorTargetDescriptions.Length; renderPassCreateInfo.colorTargetDescriptions = (IntPtr) ptr; renderPassCreateInfo.depthStencilTargetDescription = IntPtr.Zero; Handle = Refresh.Refresh_CreateRenderPass(device.Handle, renderPassCreateInfo); } } /// /// Creates a render pass using a depth/stencil target description and optional color target descriptions. /// /// An initialized GraphicsDevice. /// A depth/stencil target description. /// Up to 4 color target descriptions may be provided. public unsafe RenderPass( GraphicsDevice device, in DepthStencilTargetDescription depthStencilTargetDescription, params ColorTargetDescription[] colorTargetDescriptions ) : base(device) { fixed (DepthStencilTargetDescription* depthStencilPtr = &depthStencilTargetDescription) fixed (ColorTargetDescription* colorPtr = colorTargetDescriptions) { Refresh.RenderPassCreateInfo renderPassCreateInfo; renderPassCreateInfo.colorTargetCount = (uint) colorTargetDescriptions.Length; renderPassCreateInfo.colorTargetDescriptions = (IntPtr) colorPtr; renderPassCreateInfo.depthStencilTargetDescription = (IntPtr) depthStencilPtr; Handle = Refresh.Refresh_CreateRenderPass(device.Handle, renderPassCreateInfo); } } } }