forked from MoonsideGames/MoonWorks
some state tweaks
parent
29a86c2040
commit
4eb2cb6b09
|
@ -253,7 +253,8 @@ namespace MoonWorks.Graphics
|
||||||
RGA = R | G | A,
|
RGA = R | G | A,
|
||||||
GBA = G | B | A,
|
GBA = G | B | A,
|
||||||
|
|
||||||
RGBA = R | G | B | A
|
RGBA = R | G | B | A,
|
||||||
|
None = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ShaderStageType
|
public enum ShaderStageType
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace MoonWorks.Graphics
|
||||||
|
|
||||||
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyRenderTarget;
|
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyRenderTarget;
|
||||||
|
|
||||||
public static RenderTarget CreateBackedColorTarget2D(
|
public static RenderTarget CreateBackedRenderTarget(
|
||||||
GraphicsDevice device,
|
GraphicsDevice device,
|
||||||
uint width,
|
uint width,
|
||||||
uint height,
|
uint height,
|
||||||
|
@ -18,10 +18,26 @@ namespace MoonWorks.Graphics
|
||||||
bool canBeSampled,
|
bool canBeSampled,
|
||||||
SampleCount sampleCount = SampleCount.One,
|
SampleCount sampleCount = SampleCount.One,
|
||||||
uint levelCount = 1
|
uint levelCount = 1
|
||||||
)
|
) {
|
||||||
{
|
TextureUsageFlags flags = 0;
|
||||||
var flags = TextureUsageFlags.ColorTarget;
|
|
||||||
if (canBeSampled) { flags |= TextureUsageFlags.Sampler; }
|
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(
|
var texture = Texture.CreateTexture2D(
|
||||||
device,
|
device,
|
||||||
|
@ -36,42 +52,6 @@ namespace MoonWorks.Graphics
|
||||||
return new RenderTarget(device, new TextureSlice(texture), sampleCount);
|
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)
|
public RenderTarget(GraphicsDevice device, in TextureSlice textureSlice, SampleCount sampleCount = SampleCount.One) : base(device)
|
||||||
{
|
{
|
||||||
Handle = Refresh.Refresh_CreateRenderTarget(
|
Handle = Refresh.Refresh_CreateRenderTarget(
|
||||||
|
|
|
@ -67,6 +67,12 @@ namespace MoonWorks.Graphics
|
||||||
ColorWriteMask = ColorComponentFlags.RGBA
|
ColorWriteMask = ColorComponentFlags.RGBA
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static readonly ColorTargetBlendState Disable = new ColorTargetBlendState
|
||||||
|
{
|
||||||
|
BlendEnable = false,
|
||||||
|
ColorWriteMask = ColorComponentFlags.None
|
||||||
|
};
|
||||||
|
|
||||||
public Refresh.ColorTargetBlendState ToRefreshColorTargetBlendState()
|
public Refresh.ColorTargetBlendState ToRefreshColorTargetBlendState()
|
||||||
{
|
{
|
||||||
return new Refresh.ColorTargetBlendState
|
return new Refresh.ColorTargetBlendState
|
||||||
|
|
Loading…
Reference in New Issue