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