update render target and texture format API
parent
6ce1ce21b8
commit
7f6236cb49
|
@ -1 +1 @@
|
||||||
Subproject commit 369ced4f80f0e7de22fa806b547831154a23efad
|
Subproject commit f5beb976bbe9c5775bef66cf20d264e918edffcd
|
|
@ -51,7 +51,7 @@ namespace MoonWorks.Graphics
|
||||||
ThirtyTwo
|
ThirtyTwo
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ColorFormat
|
public enum TextureFormat
|
||||||
{
|
{
|
||||||
R8G8B8A8,
|
R8G8B8A8,
|
||||||
R5G6B5,
|
R5G6B5,
|
||||||
|
@ -71,22 +71,19 @@ namespace MoonWorks.Graphics
|
||||||
R32G32B32A32_SFLOAT,
|
R32G32B32A32_SFLOAT,
|
||||||
R16_SFLOAT,
|
R16_SFLOAT,
|
||||||
R16G16_SFLOAT,
|
R16G16_SFLOAT,
|
||||||
R16G16B16A16_SFLOAT
|
R16G16B16A16_SFLOAT,
|
||||||
}
|
D16,
|
||||||
|
D32,
|
||||||
public enum DepthFormat
|
D16S8,
|
||||||
{
|
D32S8
|
||||||
Depth16,
|
|
||||||
Depth32,
|
|
||||||
Depth16Stencil8,
|
|
||||||
Depth32Stencil8
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum TextureUsageFlags : uint
|
public enum TextureUsageFlags : uint
|
||||||
{
|
{
|
||||||
Sampler = 1,
|
Sampler = 1,
|
||||||
ColorTarget = 2
|
ColorTarget = 2,
|
||||||
|
DepthStencilTarget = 4
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SampleCount
|
public enum SampleCount
|
||||||
|
|
|
@ -84,7 +84,7 @@ namespace MoonWorks.Graphics
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct ColorTargetDescription
|
public struct ColorTargetDescription
|
||||||
{
|
{
|
||||||
public ColorFormat format;
|
public TextureFormat format;
|
||||||
public SampleCount multisampleCount;
|
public SampleCount multisampleCount;
|
||||||
public LoadOp loadOp;
|
public LoadOp loadOp;
|
||||||
public StoreOp storeOp;
|
public StoreOp storeOp;
|
||||||
|
@ -93,7 +93,7 @@ namespace MoonWorks.Graphics
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct DepthStencilTargetDescription
|
public struct DepthStencilTargetDescription
|
||||||
{
|
{
|
||||||
public DepthFormat depthFormat;
|
public TextureFormat depthFormat;
|
||||||
public LoadOp loadOp;
|
public LoadOp loadOp;
|
||||||
public StoreOp storeOp;
|
public StoreOp storeOp;
|
||||||
public LoadOp stencilLoadOp;
|
public LoadOp stencilLoadOp;
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
using System;
|
|
||||||
using RefreshCS;
|
|
||||||
|
|
||||||
namespace MoonWorks.Graphics
|
|
||||||
{
|
|
||||||
public class DepthStencilTarget : GraphicsResource
|
|
||||||
{
|
|
||||||
public uint Width { get; }
|
|
||||||
public uint Height { get; }
|
|
||||||
public DepthFormat Format { get; }
|
|
||||||
|
|
||||||
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyDepthStencilTarget;
|
|
||||||
|
|
||||||
public DepthStencilTarget(
|
|
||||||
GraphicsDevice device,
|
|
||||||
uint width,
|
|
||||||
uint height,
|
|
||||||
DepthFormat depthFormat
|
|
||||||
) : base(device)
|
|
||||||
{
|
|
||||||
Handle = Refresh.Refresh_CreateDepthStencilTarget(
|
|
||||||
device.Handle,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
(Refresh.DepthFormat) depthFormat
|
|
||||||
);
|
|
||||||
Width = width;
|
|
||||||
Height = height;
|
|
||||||
Format = depthFormat;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,8 +12,8 @@ namespace MoonWorks.Graphics
|
||||||
uint width,
|
uint width,
|
||||||
uint height,
|
uint height,
|
||||||
RenderPass renderPass,
|
RenderPass renderPass,
|
||||||
DepthStencilTarget depthStencilTarget, /* can be NULL */
|
RenderTarget depthStencilTarget, /* can be NULL */
|
||||||
params ColorTarget[] colorTargets
|
params RenderTarget[] colorTargets
|
||||||
) : base(device)
|
) : base(device)
|
||||||
{
|
{
|
||||||
IntPtr[] colorTargetHandles = new IntPtr[colorTargets.Length];
|
IntPtr[] colorTargetHandles = new IntPtr[colorTargets.Length];
|
||||||
|
|
|
@ -3,18 +3,18 @@ using RefreshCS;
|
||||||
|
|
||||||
namespace MoonWorks.Graphics
|
namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
public class ColorTarget : GraphicsResource
|
public class RenderTarget : GraphicsResource
|
||||||
{
|
{
|
||||||
public TextureSlice TextureSlice { get; }
|
public TextureSlice TextureSlice { get; }
|
||||||
public ColorFormat Format => TextureSlice.Texture.Format;
|
public TextureFormat Format => TextureSlice.Texture.Format;
|
||||||
|
|
||||||
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyColorTarget;
|
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyRenderTarget;
|
||||||
|
|
||||||
public static ColorTarget CreateBackedColorTarget2D(
|
public static RenderTarget CreateBackedColorTarget2D(
|
||||||
GraphicsDevice device,
|
GraphicsDevice device,
|
||||||
uint width,
|
uint width,
|
||||||
uint height,
|
uint height,
|
||||||
ColorFormat format,
|
TextureFormat format,
|
||||||
bool canBeSampled,
|
bool canBeSampled,
|
||||||
SampleCount sampleCount = SampleCount.One,
|
SampleCount sampleCount = SampleCount.One,
|
||||||
uint levelCount = 1
|
uint levelCount = 1
|
||||||
|
@ -33,17 +33,15 @@ namespace MoonWorks.Graphics
|
||||||
levelCount
|
levelCount
|
||||||
);
|
);
|
||||||
|
|
||||||
var textureSlice = new TextureSlice(texture);
|
return new RenderTarget(device, new TextureSlice(texture), sampleCount);
|
||||||
|
|
||||||
return new ColorTarget(device, sampleCount, ref textureSlice);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ColorTarget(GraphicsDevice device, SampleCount sampleCount, ref TextureSlice textureSlice) : base(device)
|
public RenderTarget(GraphicsDevice device, in TextureSlice textureSlice, SampleCount sampleCount = SampleCount.One) : base(device)
|
||||||
{
|
{
|
||||||
Handle = Refresh.Refresh_CreateColorTarget(
|
Handle = Refresh.Refresh_CreateRenderTarget(
|
||||||
device.Handle,
|
device.Handle,
|
||||||
(Refresh.SampleCount) sampleCount,
|
textureSlice.ToRefreshTextureSlice(),
|
||||||
textureSlice.ToRefreshTextureSlice()
|
(Refresh.SampleCount) sampleCount
|
||||||
);
|
);
|
||||||
TextureSlice = textureSlice;
|
TextureSlice = textureSlice;
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@ namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
public uint Width { get; }
|
public uint Width { get; }
|
||||||
public uint Height { get; }
|
public uint Height { get; }
|
||||||
public ColorFormat Format { get; }
|
public TextureFormat Format { get; }
|
||||||
|
|
||||||
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyTexture;
|
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyTexture;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ namespace MoonWorks.Graphics
|
||||||
textureCreateInfo.Width = (uint)width;
|
textureCreateInfo.Width = (uint)width;
|
||||||
textureCreateInfo.Height = (uint)height;
|
textureCreateInfo.Height = (uint)height;
|
||||||
textureCreateInfo.Depth = 1;
|
textureCreateInfo.Depth = 1;
|
||||||
textureCreateInfo.Format = ColorFormat.R8G8B8A8;
|
textureCreateInfo.Format = TextureFormat.R8G8B8A8;
|
||||||
textureCreateInfo.IsCube = false;
|
textureCreateInfo.IsCube = false;
|
||||||
textureCreateInfo.LevelCount = 1;
|
textureCreateInfo.LevelCount = 1;
|
||||||
textureCreateInfo.SampleCount = SampleCount.One;
|
textureCreateInfo.SampleCount = SampleCount.One;
|
||||||
|
@ -52,7 +52,7 @@ namespace MoonWorks.Graphics
|
||||||
GraphicsDevice device,
|
GraphicsDevice device,
|
||||||
uint width,
|
uint width,
|
||||||
uint height,
|
uint height,
|
||||||
ColorFormat format,
|
TextureFormat format,
|
||||||
TextureUsageFlags usageFlags,
|
TextureUsageFlags usageFlags,
|
||||||
SampleCount sampleCount = SampleCount.One,
|
SampleCount sampleCount = SampleCount.One,
|
||||||
uint levelCount = 1
|
uint levelCount = 1
|
||||||
|
@ -78,7 +78,7 @@ namespace MoonWorks.Graphics
|
||||||
uint width,
|
uint width,
|
||||||
uint height,
|
uint height,
|
||||||
uint depth,
|
uint depth,
|
||||||
ColorFormat format,
|
TextureFormat format,
|
||||||
TextureUsageFlags usageFlags,
|
TextureUsageFlags usageFlags,
|
||||||
SampleCount sampleCount = SampleCount.One,
|
SampleCount sampleCount = SampleCount.One,
|
||||||
uint levelCount = 1
|
uint levelCount = 1
|
||||||
|
@ -102,7 +102,7 @@ namespace MoonWorks.Graphics
|
||||||
public static Texture CreateTextureCube(
|
public static Texture CreateTextureCube(
|
||||||
GraphicsDevice device,
|
GraphicsDevice device,
|
||||||
uint size,
|
uint size,
|
||||||
ColorFormat format,
|
TextureFormat format,
|
||||||
TextureUsageFlags usageFlags,
|
TextureUsageFlags usageFlags,
|
||||||
SampleCount sampleCount = SampleCount.One,
|
SampleCount sampleCount = SampleCount.One,
|
||||||
uint levelCount = 1
|
uint levelCount = 1
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace MoonWorks.Graphics
|
||||||
public bool IsCube;
|
public bool IsCube;
|
||||||
public SampleCount SampleCount;
|
public SampleCount SampleCount;
|
||||||
public uint LevelCount;
|
public uint LevelCount;
|
||||||
public ColorFormat Format;
|
public TextureFormat Format;
|
||||||
public TextureUsageFlags UsageFlags;
|
public TextureUsageFlags UsageFlags;
|
||||||
|
|
||||||
public Refresh.TextureCreateInfo ToRefreshTextureCreateInfo()
|
public Refresh.TextureCreateInfo ToRefreshTextureCreateInfo()
|
||||||
|
@ -23,7 +23,7 @@ namespace MoonWorks.Graphics
|
||||||
isCube = Conversions.BoolToByte(IsCube),
|
isCube = Conversions.BoolToByte(IsCube),
|
||||||
sampleCount = (Refresh.SampleCount) SampleCount,
|
sampleCount = (Refresh.SampleCount) SampleCount,
|
||||||
levelCount = LevelCount,
|
levelCount = LevelCount,
|
||||||
format = (Refresh.ColorFormat) Format,
|
format = (Refresh.TextureFormat) Format,
|
||||||
usageFlags = (Refresh.TextureUsageFlags) UsageFlags
|
usageFlags = (Refresh.TextureUsageFlags) UsageFlags
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace MoonWorks.Graphics
|
||||||
public struct TextureSlice
|
public struct TextureSlice
|
||||||
{
|
{
|
||||||
public Texture Texture { get; }
|
public Texture Texture { get; }
|
||||||
public Refresh.Rect Rectangle { get; }
|
public Rect Rectangle { get; }
|
||||||
public uint Depth { get; }
|
public uint Depth { get; }
|
||||||
public uint Layer { get; }
|
public uint Layer { get; }
|
||||||
public uint Level { get; }
|
public uint Level { get; }
|
||||||
|
@ -13,7 +13,7 @@ namespace MoonWorks.Graphics
|
||||||
public TextureSlice(Texture texture)
|
public TextureSlice(Texture texture)
|
||||||
{
|
{
|
||||||
Texture = texture;
|
Texture = texture;
|
||||||
Rectangle = new Refresh.Rect
|
Rectangle = new Rect
|
||||||
{
|
{
|
||||||
x = 0,
|
x = 0,
|
||||||
y = 0,
|
y = 0,
|
||||||
|
@ -25,7 +25,7 @@ namespace MoonWorks.Graphics
|
||||||
Level = 0;
|
Level = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextureSlice(Texture texture, Refresh.Rect rectangle, uint depth = 0, uint layer = 0, uint level = 0)
|
public TextureSlice(Texture texture, Rect rectangle, uint depth = 0, uint layer = 0, uint level = 0)
|
||||||
{
|
{
|
||||||
Texture = texture;
|
Texture = texture;
|
||||||
Rectangle = rectangle;
|
Rectangle = rectangle;
|
||||||
|
@ -39,7 +39,7 @@ namespace MoonWorks.Graphics
|
||||||
Refresh.TextureSlice textureSlice = new Refresh.TextureSlice
|
Refresh.TextureSlice textureSlice = new Refresh.TextureSlice
|
||||||
{
|
{
|
||||||
texture = Texture.Handle,
|
texture = Texture.Handle,
|
||||||
rectangle = Rectangle,
|
rectangle = Rectangle.ToRefresh(),
|
||||||
depth = Depth,
|
depth = Depth,
|
||||||
layer = Layer,
|
layer = Layer,
|
||||||
level = Level
|
level = Level
|
||||||
|
|
Loading…
Reference in New Issue