From ef10be4e9db616e345c995ed04de6b92ba5d1d06 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Tue, 1 Mar 2022 23:32:44 -0800 Subject: [PATCH] add some shortcut defaults to structs --- src/Graphics/RefreshStructs.cs | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/Graphics/RefreshStructs.cs b/src/Graphics/RefreshStructs.cs index 4f0ef762..9fb19eb2 100644 --- a/src/Graphics/RefreshStructs.cs +++ b/src/Graphics/RefreshStructs.cs @@ -12,6 +12,12 @@ namespace MoonWorks.Graphics public float Depth; public uint Stencil; + public DepthStencilValue(float depth, uint stencil) + { + Depth = depth; + Stencil = stencil; + } + // FIXME: can we do an unsafe cast somehow? public Refresh.DepthStencilValue ToRefresh() { @@ -157,6 +163,30 @@ namespace MoonWorks.Graphics public LoadOp LoadOp; public StoreOp StoreOp; + public ColorAttachmentInfo(Texture texture, Color clearColor, StoreOp storeOp = StoreOp.Store) + { + Texture = texture; + Depth = 0; + Layer = 0; + Level = 0; + SampleCount = SampleCount.One; + ClearColor = clearColor; + LoadOp = LoadOp.Clear; + StoreOp = storeOp; + } + + public ColorAttachmentInfo(Texture texture, StoreOp storeOp = StoreOp.Store) + { + Texture = texture; + Depth = 0; + Layer = 0; + Level = 0; + SampleCount = SampleCount.One; + ClearColor = Color.White; + LoadOp = LoadOp.DontCare; + StoreOp = StoreOp.Store; + } + public Refresh.ColorAttachmentInfo ToRefresh() { return new Refresh.ColorAttachmentInfo @@ -192,6 +222,19 @@ namespace MoonWorks.Graphics public LoadOp StencilLoadOp; public StoreOp StencilStoreOp; + public DepthStencilAttachmentInfo(Texture texture, DepthStencilValue clearValue) + { + Texture = texture; + Depth = 0; + Layer = 0; + Level = 0; + DepthStencilClearValue = clearValue; + LoadOp = LoadOp.Clear; + StoreOp = StoreOp.DontCare; + StencilLoadOp = LoadOp.DontCare; + StencilStoreOp = StoreOp.DontCare; + } + public Refresh.DepthStencilAttachmentInfo ToRefresh() { return new Refresh.DepthStencilAttachmentInfo