diff --git a/src/Graphics/RefreshEnums.cs b/src/Graphics/RefreshEnums.cs index 85c28653..d2f79f48 100644 --- a/src/Graphics/RefreshEnums.cs +++ b/src/Graphics/RefreshEnums.cs @@ -253,7 +253,8 @@ namespace MoonWorks.Graphics RGA = R | G | A, GBA = G | B | A, - RGBA = R | G | B | A + RGBA = R | G | B | A, + None = 0 } public enum ShaderStageType diff --git a/src/Graphics/Resources/RenderTarget.cs b/src/Graphics/Resources/RenderTarget.cs index 4e04470f..597fa7a0 100644 --- a/src/Graphics/Resources/RenderTarget.cs +++ b/src/Graphics/Resources/RenderTarget.cs @@ -10,7 +10,7 @@ namespace MoonWorks.Graphics protected override Action QueueDestroyFunction => Refresh.Refresh_QueueDestroyRenderTarget; - public static RenderTarget CreateBackedColorTarget2D( + public static RenderTarget CreateBackedRenderTarget( GraphicsDevice device, uint width, uint height, @@ -18,10 +18,26 @@ namespace MoonWorks.Graphics bool canBeSampled, SampleCount sampleCount = SampleCount.One, uint levelCount = 1 - ) - { - var flags = TextureUsageFlags.ColorTarget; - if (canBeSampled) { flags |= TextureUsageFlags.Sampler; } + ) { + TextureUsageFlags flags = 0; + + if ( + format == TextureFormat.D16 || + format == TextureFormat.D32 || + format == TextureFormat.D16S8 || + format == TextureFormat.D32S8 + ) { + flags |= TextureUsageFlags.DepthStencilTarget; + } + else + { + flags |= TextureUsageFlags.ColorTarget; + } + + if (canBeSampled) + { + flags |= TextureUsageFlags.Sampler; + } var texture = Texture.CreateTexture2D( device, @@ -36,42 +52,6 @@ namespace MoonWorks.Graphics return new RenderTarget(device, new TextureSlice(texture), sampleCount); } - public static RenderTarget CreateDepthBuffer( - GraphicsDevice device, - uint width, - uint height - ) { - var flags = TextureUsageFlags.DepthStencilTarget; - - var texture = Texture.CreateTexture2D( - device, - width, - height, - TextureFormat.D32, - flags - ); - - return new RenderTarget(device, new TextureSlice(texture)); - } - - public static RenderTarget CreateDepthStencilBuffer( - GraphicsDevice device, - uint width, - uint height - ) { - var flags = TextureUsageFlags.DepthStencilTarget; - - var texture = Texture.CreateTexture2D( - device, - width, - height, - TextureFormat.D32S8, - flags - ); - - return new RenderTarget(device, new TextureSlice(texture)); - } - public RenderTarget(GraphicsDevice device, in TextureSlice textureSlice, SampleCount sampleCount = SampleCount.One) : base(device) { Handle = Refresh.Refresh_CreateRenderTarget( diff --git a/src/Graphics/State/ColorTargetBlendState.cs b/src/Graphics/State/ColorTargetBlendState.cs index f5c082ea..b29545c4 100644 --- a/src/Graphics/State/ColorTargetBlendState.cs +++ b/src/Graphics/State/ColorTargetBlendState.cs @@ -67,6 +67,12 @@ namespace MoonWorks.Graphics ColorWriteMask = ColorComponentFlags.RGBA }; + public static readonly ColorTargetBlendState Disable = new ColorTargetBlendState + { + BlendEnable = false, + ColorWriteMask = ColorComponentFlags.None + }; + public Refresh.ColorTargetBlendState ToRefreshColorTargetBlendState() { return new Refresh.ColorTargetBlendState