backed color target convenience method

main
cosmonaut 2021-01-16 16:12:20 -08:00
parent cde30b290a
commit 7a98e98fc3
2 changed files with 34 additions and 1 deletions

View File

@ -13,6 +13,34 @@ namespace Campari
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyColorTarget;
public static ColorTarget CreateBackedColorTarget2D(
GraphicsDevice device,
uint width,
uint height,
Refresh.ColorFormat format,
bool canBeSampled,
Refresh.SampleCount sampleCount = Refresh.SampleCount.One,
uint levelCount = 1
)
{
var flags = Refresh.TextureUsageFlags.ColorTargetBit;
if (canBeSampled) { flags |= Refresh.TextureUsageFlags.SamplerBit; }
var texture = Texture.CreateTexture2D(
device,
width,
height,
format,
flags,
sampleCount,
levelCount
);
var textureSlice = new TextureSlice(texture);
return new ColorTarget(device, sampleCount, ref textureSlice);
}
public ColorTarget(GraphicsDevice device, Refresh.SampleCount sampleCount, ref TextureSlice textureSlice) : base(device)
{
var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();

View File

@ -11,7 +11,12 @@ namespace Campari
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyDepthStencilTarget;
public DepthStencilTarget(GraphicsDevice device, uint width, uint height, Refresh.DepthFormat depthFormat) : base(device)
public DepthStencilTarget(
GraphicsDevice device,
uint width,
uint height,
Refresh.DepthFormat depthFormat
) : base(device)
{
Handle = Refresh.Refresh_CreateDepthStencilTarget(device.Handle, width, height, depthFormat);
Width = width;