forked from MoonsideGames/MoonWorks
removing explicit RefreshCS references in API
parent
52b60b66f4
commit
d22a70c116
|
@ -5,7 +5,8 @@ using System.Runtime.InteropServices;
|
||||||
namespace MoonWorks.Audio
|
namespace MoonWorks.Audio
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// For streaming long playback. Reads an OGG file.
|
/// For streaming long playback.
|
||||||
|
/// Can be extended to support custom decoders.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class StreamingSound : SoundInstance
|
public abstract class StreamingSound : SoundInstance
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,21 +19,24 @@ namespace MoonWorks.Graphics
|
||||||
public unsafe void BeginRenderPass(
|
public unsafe void BeginRenderPass(
|
||||||
RenderPass renderPass,
|
RenderPass renderPass,
|
||||||
Framebuffer framebuffer,
|
Framebuffer framebuffer,
|
||||||
ref Refresh.Rect renderArea,
|
ref Rect renderArea,
|
||||||
ref Refresh.DepthStencilValue depthStencilClearValue,
|
ref DepthStencilValue depthStencilClearValue,
|
||||||
params Refresh.Color[] clearColors
|
params Color[] clearColors
|
||||||
) {
|
) {
|
||||||
fixed (Refresh.Color* clearColorPtr = &clearColors[0])
|
var refreshRenderArea = renderArea.ToRefresh();
|
||||||
|
var refreshDepthStencilClearValue = depthStencilClearValue.ToRefresh();
|
||||||
|
|
||||||
|
fixed (Color* clearColorPtr = &clearColors[0])
|
||||||
{
|
{
|
||||||
Refresh.Refresh_BeginRenderPass(
|
Refresh.Refresh_BeginRenderPass(
|
||||||
Device.Handle,
|
Device.Handle,
|
||||||
Handle,
|
Handle,
|
||||||
renderPass.Handle,
|
renderPass.Handle,
|
||||||
framebuffer.Handle,
|
framebuffer.Handle,
|
||||||
ref renderArea,
|
ref refreshRenderArea,
|
||||||
(IntPtr) clearColorPtr,
|
(IntPtr) clearColorPtr,
|
||||||
(uint)clearColors.Length,
|
(uint)clearColors.Length,
|
||||||
ref depthStencilClearValue
|
ref refreshDepthStencilClearValue
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,17 +44,19 @@ namespace MoonWorks.Graphics
|
||||||
public unsafe void BeginRenderPass(
|
public unsafe void BeginRenderPass(
|
||||||
RenderPass renderPass,
|
RenderPass renderPass,
|
||||||
Framebuffer framebuffer,
|
Framebuffer framebuffer,
|
||||||
ref Refresh.Rect renderArea,
|
ref Rect renderArea,
|
||||||
params Refresh.Color[] clearColors
|
params Color[] clearColors
|
||||||
) {
|
) {
|
||||||
fixed (Refresh.Color* clearColorPtr = &clearColors[0])
|
var refreshRenderArea = renderArea.ToRefresh();
|
||||||
|
|
||||||
|
fixed (Color* clearColorPtr = &clearColors[0])
|
||||||
{
|
{
|
||||||
Refresh.Refresh_BeginRenderPass(
|
Refresh.Refresh_BeginRenderPass(
|
||||||
Device.Handle,
|
Device.Handle,
|
||||||
Handle,
|
Handle,
|
||||||
renderPass.Handle,
|
renderPass.Handle,
|
||||||
framebuffer.Handle,
|
framebuffer.Handle,
|
||||||
ref renderArea,
|
ref refreshRenderArea,
|
||||||
(IntPtr) clearColorPtr,
|
(IntPtr) clearColorPtr,
|
||||||
(uint) clearColors.Length,
|
(uint) clearColors.Length,
|
||||||
IntPtr.Zero
|
IntPtr.Zero
|
||||||
|
@ -323,23 +328,24 @@ namespace MoonWorks.Graphics
|
||||||
|
|
||||||
public void QueuePresent(
|
public void QueuePresent(
|
||||||
ref TextureSlice textureSlice,
|
ref TextureSlice textureSlice,
|
||||||
ref Refresh.Rect destinationRectangle,
|
ref Rect destinationRectangle,
|
||||||
Refresh.Filter filter
|
Filter filter
|
||||||
) {
|
) {
|
||||||
var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();
|
var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();
|
||||||
|
var refreshRect = destinationRectangle.ToRefresh();
|
||||||
|
|
||||||
Refresh.Refresh_QueuePresent(
|
Refresh.Refresh_QueuePresent(
|
||||||
Device.Handle,
|
Device.Handle,
|
||||||
Handle,
|
Handle,
|
||||||
ref refreshTextureSlice,
|
ref refreshTextureSlice,
|
||||||
ref destinationRectangle,
|
ref refreshRect,
|
||||||
filter
|
(Refresh.Filter) filter
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void QueuePresent(
|
public void QueuePresent(
|
||||||
ref TextureSlice textureSlice,
|
ref TextureSlice textureSlice,
|
||||||
Refresh.Filter filter
|
Filter filter
|
||||||
) {
|
) {
|
||||||
var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();
|
var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();
|
||||||
|
|
||||||
|
@ -348,13 +354,13 @@ namespace MoonWorks.Graphics
|
||||||
Handle,
|
Handle,
|
||||||
ref refreshTextureSlice,
|
ref refreshTextureSlice,
|
||||||
IntPtr.Zero,
|
IntPtr.Zero,
|
||||||
filter
|
(Refresh.Filter) filter
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void QueuePresent(
|
public void QueuePresent(
|
||||||
Texture texture,
|
Texture texture,
|
||||||
Refresh.Filter filter
|
Filter filter
|
||||||
) {
|
) {
|
||||||
var refreshTextureSlice = new Refresh.TextureSlice
|
var refreshTextureSlice = new Refresh.TextureSlice
|
||||||
{
|
{
|
||||||
|
@ -376,14 +382,14 @@ namespace MoonWorks.Graphics
|
||||||
Handle,
|
Handle,
|
||||||
ref refreshTextureSlice,
|
ref refreshTextureSlice,
|
||||||
IntPtr.Zero,
|
IntPtr.Zero,
|
||||||
filter
|
(Refresh.Filter) filter
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CopyTextureToTexture(
|
public void CopyTextureToTexture(
|
||||||
ref TextureSlice sourceTextureSlice,
|
ref TextureSlice sourceTextureSlice,
|
||||||
ref TextureSlice destinationTextureSlice,
|
ref TextureSlice destinationTextureSlice,
|
||||||
Refresh.Filter filter
|
Filter filter
|
||||||
) {
|
) {
|
||||||
var sourceRefreshTextureSlice = sourceTextureSlice.ToRefreshTextureSlice();
|
var sourceRefreshTextureSlice = sourceTextureSlice.ToRefreshTextureSlice();
|
||||||
var destRefreshTextureSlice = destinationTextureSlice.ToRefreshTextureSlice();
|
var destRefreshTextureSlice = destinationTextureSlice.ToRefreshTextureSlice();
|
||||||
|
@ -393,7 +399,7 @@ namespace MoonWorks.Graphics
|
||||||
Handle,
|
Handle,
|
||||||
ref sourceRefreshTextureSlice,
|
ref sourceRefreshTextureSlice,
|
||||||
ref destRefreshTextureSlice,
|
ref destRefreshTextureSlice,
|
||||||
filter
|
(Refresh.Filter) filter
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,298 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
/* Recreate all the enums in here so we don't need to explicitly
|
||||||
|
* reference the RefreshCS namespace when using MoonWorks.Graphics
|
||||||
|
*/
|
||||||
|
namespace MoonWorks.Graphics
|
||||||
|
{
|
||||||
|
public enum PresentMode
|
||||||
|
{
|
||||||
|
Immediate,
|
||||||
|
Mailbox,
|
||||||
|
FIFO,
|
||||||
|
FIFORelaxed
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum PrimitiveType
|
||||||
|
{
|
||||||
|
PointList,
|
||||||
|
LineList,
|
||||||
|
LineStrip,
|
||||||
|
TriangleList,
|
||||||
|
TriangleStrip
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum LoadOp
|
||||||
|
{
|
||||||
|
Load,
|
||||||
|
Clear,
|
||||||
|
DontCare
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum StoreOp
|
||||||
|
{
|
||||||
|
Store,
|
||||||
|
DontCare
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum ClearOptionsFlags : uint
|
||||||
|
{
|
||||||
|
Color = 1,
|
||||||
|
Depth = 2,
|
||||||
|
Stencil = 4,
|
||||||
|
DepthStencil = Depth | Stencil,
|
||||||
|
All = Color | Depth | Stencil
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum IndexElementSize
|
||||||
|
{
|
||||||
|
Sixteen,
|
||||||
|
ThirtyTwo
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ColorFormat
|
||||||
|
{
|
||||||
|
R8G8B8A8,
|
||||||
|
R5G6B5,
|
||||||
|
A1R5G5B5,
|
||||||
|
B4G4R4A4,
|
||||||
|
BC1,
|
||||||
|
BC2,
|
||||||
|
BC3,
|
||||||
|
R8G8_SNORM,
|
||||||
|
R8G8B8A8_SNORM,
|
||||||
|
A2R10G10B10,
|
||||||
|
R16G16,
|
||||||
|
R16G16B16A16,
|
||||||
|
R8,
|
||||||
|
R32_SFLOAT,
|
||||||
|
R32G32_SFLOAT,
|
||||||
|
R32G32B32A32_SFLOAT,
|
||||||
|
R16_SFLOAT,
|
||||||
|
R16G16_SFLOAT,
|
||||||
|
R16G16B16A16_SFLOAT
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DepthFormat
|
||||||
|
{
|
||||||
|
Depth16,
|
||||||
|
Depth32,
|
||||||
|
Depth16Stencil8,
|
||||||
|
Depth32Stencil8
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum TextureUsageFlags : uint
|
||||||
|
{
|
||||||
|
SamplerBit = 1,
|
||||||
|
ColorTargetBit = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SampleCount
|
||||||
|
{
|
||||||
|
One,
|
||||||
|
Two,
|
||||||
|
Four,
|
||||||
|
Eight,
|
||||||
|
Sixteen,
|
||||||
|
ThirtyTwo,
|
||||||
|
SixtyFour
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CubeMapFace
|
||||||
|
{
|
||||||
|
PositiveX,
|
||||||
|
NegativeX,
|
||||||
|
PositiveY,
|
||||||
|
NegativeY,
|
||||||
|
PositiveZ,
|
||||||
|
NegativeZ
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum BufferUsageFlags : uint
|
||||||
|
{
|
||||||
|
Vertex = 1,
|
||||||
|
Index = 2,
|
||||||
|
Compute = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum VertexElementFormat
|
||||||
|
{
|
||||||
|
Single,
|
||||||
|
Vector2,
|
||||||
|
Vector3,
|
||||||
|
Vector4,
|
||||||
|
Color,
|
||||||
|
Byte4,
|
||||||
|
Short2,
|
||||||
|
Short4,
|
||||||
|
NormalizedShort2,
|
||||||
|
NormalizedShort4,
|
||||||
|
HalfVector2,
|
||||||
|
HalfVector4
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum VertexInputRate
|
||||||
|
{
|
||||||
|
Vertex,
|
||||||
|
Instance
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum FillMode
|
||||||
|
{
|
||||||
|
Fill,
|
||||||
|
Line,
|
||||||
|
Point
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CullMode
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Front,
|
||||||
|
Back,
|
||||||
|
FrontAndBack
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum FrontFace
|
||||||
|
{
|
||||||
|
CounterClockwise,
|
||||||
|
Clockwise
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CompareOp
|
||||||
|
{
|
||||||
|
Never,
|
||||||
|
Less,
|
||||||
|
Equal,
|
||||||
|
LessOrEqual,
|
||||||
|
Greater,
|
||||||
|
NotEqual,
|
||||||
|
GreaterOrEqual,
|
||||||
|
Always
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum StencilOp
|
||||||
|
{
|
||||||
|
Keep,
|
||||||
|
Zero,
|
||||||
|
Replace,
|
||||||
|
IncrementAndClamp,
|
||||||
|
DecrementAndClamp,
|
||||||
|
Invert,
|
||||||
|
IncrementAndWrap,
|
||||||
|
DecrementAndWrap
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum BlendOp
|
||||||
|
{
|
||||||
|
Add,
|
||||||
|
Subtract,
|
||||||
|
ReverseSubtract,
|
||||||
|
Min,
|
||||||
|
Max
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum LogicOp
|
||||||
|
{
|
||||||
|
Clear,
|
||||||
|
And,
|
||||||
|
AndReverse,
|
||||||
|
Copy,
|
||||||
|
AndInverted,
|
||||||
|
NoOp,
|
||||||
|
Xor,
|
||||||
|
Or,
|
||||||
|
Nor,
|
||||||
|
Equivalent,
|
||||||
|
Invert,
|
||||||
|
OrReverse,
|
||||||
|
CopyInverted,
|
||||||
|
OrInverted,
|
||||||
|
Nand,
|
||||||
|
Set
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum BlendFactor
|
||||||
|
{
|
||||||
|
Zero,
|
||||||
|
One,
|
||||||
|
SourceColor,
|
||||||
|
OneMinusSourceColor,
|
||||||
|
DestinationColor,
|
||||||
|
OneMinusDestinationColor,
|
||||||
|
SourceAlpha,
|
||||||
|
OneMinusSourceAlpha,
|
||||||
|
DestinationAlpha,
|
||||||
|
OneMinusDestinationAlpha,
|
||||||
|
ConstantColor,
|
||||||
|
OneMinusConstantColor,
|
||||||
|
ConstantAlpha,
|
||||||
|
OneMinusConstantAlpha,
|
||||||
|
SourceAlphaSaturate,
|
||||||
|
SourceOneColor,
|
||||||
|
OneMinusSourceOneColor,
|
||||||
|
SourceOneAlpha,
|
||||||
|
OneMinusSourceOneAlpha
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum ColorComponentFlags : uint
|
||||||
|
{
|
||||||
|
R = 1,
|
||||||
|
G = 2,
|
||||||
|
B = 4,
|
||||||
|
A = 8,
|
||||||
|
|
||||||
|
RG = R | G,
|
||||||
|
RB = R | B,
|
||||||
|
RA = R | A,
|
||||||
|
GB = G | B,
|
||||||
|
GA = G | A,
|
||||||
|
BA = B | A,
|
||||||
|
|
||||||
|
RGB = R | G | B,
|
||||||
|
RGA = R | G | A,
|
||||||
|
GBA = G | B | A,
|
||||||
|
|
||||||
|
RGBA = R | G | B | A
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ShaderStageType
|
||||||
|
{
|
||||||
|
Vertex,
|
||||||
|
Fragment
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Filter
|
||||||
|
{
|
||||||
|
Nearest,
|
||||||
|
Linear,
|
||||||
|
Cubic
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SamplerMipmapMode
|
||||||
|
{
|
||||||
|
Nearest,
|
||||||
|
Linear
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SamplerAddressMode
|
||||||
|
{
|
||||||
|
Repeat,
|
||||||
|
MirroredRepeat,
|
||||||
|
ClampToEdge,
|
||||||
|
ClampToBorder
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum BorderColor
|
||||||
|
{
|
||||||
|
FloatTransparentBlack,
|
||||||
|
IntTransparentBlack,
|
||||||
|
FloatOpaqueBlack,
|
||||||
|
IntOpaqueBlack,
|
||||||
|
FloatOpaqueWhite,
|
||||||
|
IntOpaqueWhite
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
using RefreshCS;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
/* Recreate some structs in here so we don't need to explicitly
|
||||||
|
* reference the RefreshCS namespace when using MoonWorks.Graphics
|
||||||
|
*/
|
||||||
|
namespace MoonWorks.Graphics
|
||||||
|
{
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct Color
|
||||||
|
{
|
||||||
|
public byte r;
|
||||||
|
public byte g;
|
||||||
|
public byte b;
|
||||||
|
public byte a;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct DepthStencilValue
|
||||||
|
{
|
||||||
|
public float depth;
|
||||||
|
public uint stencil;
|
||||||
|
|
||||||
|
// FIXME: can we do an unsafe cast somehow?
|
||||||
|
public Refresh.DepthStencilValue ToRefresh()
|
||||||
|
{
|
||||||
|
return new Refresh.DepthStencilValue
|
||||||
|
{
|
||||||
|
depth = depth,
|
||||||
|
stencil = stencil
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct Rect
|
||||||
|
{
|
||||||
|
public int x;
|
||||||
|
public int y;
|
||||||
|
public int w;
|
||||||
|
public int h;
|
||||||
|
|
||||||
|
// FIXME: can we do an unsafe cast somehow?
|
||||||
|
public Refresh.Rect ToRefresh()
|
||||||
|
{
|
||||||
|
return new Refresh.Rect
|
||||||
|
{
|
||||||
|
x = x,
|
||||||
|
y = y,
|
||||||
|
w = w,
|
||||||
|
h = h
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct Vec4
|
||||||
|
{
|
||||||
|
public float x;
|
||||||
|
public float y;
|
||||||
|
public float z;
|
||||||
|
public float w;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct Viewport
|
||||||
|
{
|
||||||
|
public float x;
|
||||||
|
public float y;
|
||||||
|
public float w;
|
||||||
|
public float h;
|
||||||
|
public float minDepth;
|
||||||
|
public float maxDepth;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct VertexBinding
|
||||||
|
{
|
||||||
|
public uint binding;
|
||||||
|
public uint stride;
|
||||||
|
public VertexInputRate inputRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct VertexAttribute
|
||||||
|
{
|
||||||
|
public uint location;
|
||||||
|
public uint binding;
|
||||||
|
public VertexElementFormat format;
|
||||||
|
public uint offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct ColorTargetDescription
|
||||||
|
{
|
||||||
|
public ColorFormat format;
|
||||||
|
public SampleCount multisampleCount;
|
||||||
|
public LoadOp loadOp;
|
||||||
|
public StoreOp storeOp;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct DepthStencilTargetDescription
|
||||||
|
{
|
||||||
|
public DepthFormat depthFormat;
|
||||||
|
public LoadOp loadOp;
|
||||||
|
public StoreOp storeOp;
|
||||||
|
public LoadOp stencilLoadOp;
|
||||||
|
public StoreOp stencilStoreOp;
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,13 +9,13 @@ namespace MoonWorks.Graphics
|
||||||
|
|
||||||
public Buffer(
|
public Buffer(
|
||||||
GraphicsDevice device,
|
GraphicsDevice device,
|
||||||
Refresh.BufferUsageFlags usageFlags,
|
BufferUsageFlags usageFlags,
|
||||||
uint sizeInBytes
|
uint sizeInBytes
|
||||||
) : base(device)
|
) : base(device)
|
||||||
{
|
{
|
||||||
Handle = Refresh.Refresh_CreateBuffer(
|
Handle = Refresh.Refresh_CreateBuffer(
|
||||||
device.Handle,
|
device.Handle,
|
||||||
usageFlags,
|
(Refresh.BufferUsageFlags) usageFlags,
|
||||||
sizeInBytes
|
sizeInBytes
|
||||||
);
|
);
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@ namespace MoonWorks.Graphics
|
||||||
public uint Height { get; }
|
public uint Height { get; }
|
||||||
|
|
||||||
public Texture Texture { get; }
|
public Texture Texture { get; }
|
||||||
public Refresh.ColorFormat Format => Texture.Format;
|
public ColorFormat Format => Texture.Format;
|
||||||
|
|
||||||
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyColorTarget;
|
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyColorTarget;
|
||||||
|
|
||||||
|
@ -17,14 +17,14 @@ namespace MoonWorks.Graphics
|
||||||
GraphicsDevice device,
|
GraphicsDevice device,
|
||||||
uint width,
|
uint width,
|
||||||
uint height,
|
uint height,
|
||||||
Refresh.ColorFormat format,
|
ColorFormat format,
|
||||||
bool canBeSampled,
|
bool canBeSampled,
|
||||||
Refresh.SampleCount sampleCount = Refresh.SampleCount.One,
|
SampleCount sampleCount = SampleCount.One,
|
||||||
uint levelCount = 1
|
uint levelCount = 1
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var flags = Refresh.TextureUsageFlags.ColorTargetBit;
|
var flags = TextureUsageFlags.ColorTargetBit;
|
||||||
if (canBeSampled) { flags |= Refresh.TextureUsageFlags.SamplerBit; }
|
if (canBeSampled) { flags |= TextureUsageFlags.SamplerBit; }
|
||||||
|
|
||||||
var texture = Texture.CreateTexture2D(
|
var texture = Texture.CreateTexture2D(
|
||||||
device,
|
device,
|
||||||
|
@ -41,10 +41,14 @@ namespace MoonWorks.Graphics
|
||||||
return new ColorTarget(device, sampleCount, ref textureSlice);
|
return new ColorTarget(device, sampleCount, ref textureSlice);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ColorTarget(GraphicsDevice device, Refresh.SampleCount sampleCount, ref TextureSlice textureSlice) : base(device)
|
public ColorTarget(GraphicsDevice device, SampleCount sampleCount, ref TextureSlice textureSlice) : base(device)
|
||||||
{
|
{
|
||||||
var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();
|
var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();
|
||||||
Handle = Refresh.Refresh_CreateColorTarget(device.Handle, sampleCount, ref refreshTextureSlice);
|
Handle = Refresh.Refresh_CreateColorTarget(
|
||||||
|
device.Handle,
|
||||||
|
(Refresh.SampleCount) sampleCount,
|
||||||
|
ref refreshTextureSlice
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,7 +7,7 @@ namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
public uint Width { get; }
|
public uint Width { get; }
|
||||||
public uint Height { get; }
|
public uint Height { get; }
|
||||||
public Refresh.DepthFormat Format { get; }
|
public DepthFormat Format { get; }
|
||||||
|
|
||||||
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyDepthStencilTarget;
|
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyDepthStencilTarget;
|
||||||
|
|
||||||
|
@ -15,12 +15,18 @@ namespace MoonWorks.Graphics
|
||||||
GraphicsDevice device,
|
GraphicsDevice device,
|
||||||
uint width,
|
uint width,
|
||||||
uint height,
|
uint height,
|
||||||
Refresh.DepthFormat depthFormat
|
DepthFormat depthFormat
|
||||||
) : base(device)
|
) : base(device)
|
||||||
{
|
{
|
||||||
Handle = Refresh.Refresh_CreateDepthStencilTarget(device.Handle, width, height, depthFormat);
|
Handle = Refresh.Refresh_CreateDepthStencilTarget(
|
||||||
|
device.Handle,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
(Refresh.DepthFormat) depthFormat
|
||||||
|
);
|
||||||
Width = width;
|
Width = width;
|
||||||
Height = height;
|
Height = height;
|
||||||
|
Format = depthFormat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,7 +17,7 @@ namespace MoonWorks.Graphics
|
||||||
MultisampleState multisampleState,
|
MultisampleState multisampleState,
|
||||||
GraphicsPipelineLayoutCreateInfo pipelineLayoutCreateInfo,
|
GraphicsPipelineLayoutCreateInfo pipelineLayoutCreateInfo,
|
||||||
RasterizerState rasterizerState,
|
RasterizerState rasterizerState,
|
||||||
Refresh.PrimitiveType primitiveType,
|
PrimitiveType primitiveType,
|
||||||
VertexInputState vertexInputState,
|
VertexInputState vertexInputState,
|
||||||
ViewportState viewportState,
|
ViewportState viewportState,
|
||||||
RenderPass renderPass
|
RenderPass renderPass
|
||||||
|
@ -38,7 +38,7 @@ namespace MoonWorks.Graphics
|
||||||
Refresh.GraphicsPipelineCreateInfo graphicsPipelineCreateInfo;
|
Refresh.GraphicsPipelineCreateInfo graphicsPipelineCreateInfo;
|
||||||
|
|
||||||
graphicsPipelineCreateInfo.colorBlendState.logicOpEnable = Conversions.BoolToByte(colorBlendState.LogicOpEnable);
|
graphicsPipelineCreateInfo.colorBlendState.logicOpEnable = Conversions.BoolToByte(colorBlendState.LogicOpEnable);
|
||||||
graphicsPipelineCreateInfo.colorBlendState.logicOp = colorBlendState.LogicOp;
|
graphicsPipelineCreateInfo.colorBlendState.logicOp = (Refresh.LogicOp) colorBlendState.LogicOp;
|
||||||
graphicsPipelineCreateInfo.colorBlendState.blendStates = (IntPtr) colorTargetBlendStates;
|
graphicsPipelineCreateInfo.colorBlendState.blendStates = (IntPtr) colorTargetBlendStates;
|
||||||
graphicsPipelineCreateInfo.colorBlendState.blendStateCount = (uint) colorBlendState.ColorTargetBlendStates.Length;
|
graphicsPipelineCreateInfo.colorBlendState.blendStateCount = (uint) colorBlendState.ColorTargetBlendStates.Length;
|
||||||
graphicsPipelineCreateInfo.colorBlendState.blendConstants[0] = colorBlendState.BlendConstants.R;
|
graphicsPipelineCreateInfo.colorBlendState.blendConstants[0] = colorBlendState.BlendConstants.R;
|
||||||
|
@ -90,7 +90,7 @@ namespace MoonWorks.Graphics
|
||||||
graphicsPipelineCreateInfo.viewportState.scissors = scissorHandle.AddrOfPinnedObject();
|
graphicsPipelineCreateInfo.viewportState.scissors = scissorHandle.AddrOfPinnedObject();
|
||||||
graphicsPipelineCreateInfo.viewportState.scissorCount = (uint) viewportState.Scissors.Length;
|
graphicsPipelineCreateInfo.viewportState.scissorCount = (uint) viewportState.Scissors.Length;
|
||||||
|
|
||||||
graphicsPipelineCreateInfo.primitiveType = primitiveType;
|
graphicsPipelineCreateInfo.primitiveType = (Refresh.PrimitiveType) primitiveType;
|
||||||
graphicsPipelineCreateInfo.renderPass = renderPass.Handle;
|
graphicsPipelineCreateInfo.renderPass = renderPass.Handle;
|
||||||
|
|
||||||
Handle = Refresh.Refresh_CreateGraphicsPipeline(device.Handle, ref graphicsPipelineCreateInfo);
|
Handle = Refresh.Refresh_CreateGraphicsPipeline(device.Handle, ref graphicsPipelineCreateInfo);
|
|
@ -9,10 +9,10 @@ namespace MoonWorks.Graphics
|
||||||
|
|
||||||
public unsafe RenderPass(
|
public unsafe RenderPass(
|
||||||
GraphicsDevice device,
|
GraphicsDevice device,
|
||||||
params Refresh.ColorTargetDescription[] colorTargetDescriptions
|
params ColorTargetDescription[] colorTargetDescriptions
|
||||||
) : base(device)
|
) : base(device)
|
||||||
{
|
{
|
||||||
fixed (Refresh.ColorTargetDescription* ptr = colorTargetDescriptions)
|
fixed (ColorTargetDescription* ptr = colorTargetDescriptions)
|
||||||
{
|
{
|
||||||
Refresh.RenderPassCreateInfo renderPassCreateInfo;
|
Refresh.RenderPassCreateInfo renderPassCreateInfo;
|
||||||
renderPassCreateInfo.colorTargetCount = (uint) colorTargetDescriptions.Length;
|
renderPassCreateInfo.colorTargetCount = (uint) colorTargetDescriptions.Length;
|
||||||
|
@ -25,13 +25,13 @@ namespace MoonWorks.Graphics
|
||||||
|
|
||||||
public unsafe RenderPass(
|
public unsafe RenderPass(
|
||||||
GraphicsDevice device,
|
GraphicsDevice device,
|
||||||
Refresh.DepthStencilTargetDescription depthStencilTargetDescription,
|
DepthStencilTargetDescription depthStencilTargetDescription,
|
||||||
params Refresh.ColorTargetDescription[] colorTargetDescriptions
|
params ColorTargetDescription[] colorTargetDescriptions
|
||||||
) : base(device)
|
) : base(device)
|
||||||
{
|
{
|
||||||
Refresh.DepthStencilTargetDescription* depthStencilPtr = &depthStencilTargetDescription;
|
DepthStencilTargetDescription* depthStencilPtr = &depthStencilTargetDescription;
|
||||||
|
|
||||||
fixed (Refresh.ColorTargetDescription* colorPtr = colorTargetDescriptions)
|
fixed (ColorTargetDescription* colorPtr = colorTargetDescriptions)
|
||||||
{
|
{
|
||||||
Refresh.RenderPassCreateInfo renderPassCreateInfo;
|
Refresh.RenderPassCreateInfo renderPassCreateInfo;
|
||||||
renderPassCreateInfo.colorTargetCount = (uint)colorTargetDescriptions.Length;
|
renderPassCreateInfo.colorTargetCount = (uint)colorTargetDescriptions.Length;
|
|
@ -10,7 +10,7 @@ namespace MoonWorks.Graphics
|
||||||
|
|
||||||
public unsafe ShaderModule(GraphicsDevice device, FileInfo fileInfo) : base(device)
|
public unsafe ShaderModule(GraphicsDevice device, FileInfo fileInfo) : base(device)
|
||||||
{
|
{
|
||||||
fixed (uint* ptr = Bytecode.ReadBytecode(fileInfo))
|
fixed (uint* ptr = Bytecode.ReadBytecodeAsUInt32(fileInfo))
|
||||||
{
|
{
|
||||||
Refresh.ShaderModuleCreateInfo shaderModuleCreateInfo;
|
Refresh.ShaderModuleCreateInfo shaderModuleCreateInfo;
|
||||||
shaderModuleCreateInfo.codeSize = (UIntPtr) fileInfo.Length;
|
shaderModuleCreateInfo.codeSize = (UIntPtr) fileInfo.Length;
|
|
@ -8,7 +8,7 @@ namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
public uint Width { get; }
|
public uint Width { get; }
|
||||||
public uint Height { get; }
|
public uint Height { get; }
|
||||||
public Refresh.ColorFormat Format { get; }
|
public ColorFormat Format { get; }
|
||||||
|
|
||||||
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyTexture;
|
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyTexture;
|
||||||
|
|
||||||
|
@ -21,15 +21,15 @@ namespace MoonWorks.Graphics
|
||||||
out var channels
|
out var channels
|
||||||
);
|
);
|
||||||
|
|
||||||
MoonWorks.Graphics.TextureCreateInfo textureCreateInfo;
|
TextureCreateInfo textureCreateInfo;
|
||||||
textureCreateInfo.Width = (uint)width;
|
textureCreateInfo.Width = (uint)width;
|
||||||
textureCreateInfo.Height = (uint)height;
|
textureCreateInfo.Height = (uint)height;
|
||||||
textureCreateInfo.Depth = 1;
|
textureCreateInfo.Depth = 1;
|
||||||
textureCreateInfo.Format = Refresh.ColorFormat.R8G8B8A8;
|
textureCreateInfo.Format = ColorFormat.R8G8B8A8;
|
||||||
textureCreateInfo.IsCube = false;
|
textureCreateInfo.IsCube = false;
|
||||||
textureCreateInfo.LevelCount = 1;
|
textureCreateInfo.LevelCount = 1;
|
||||||
textureCreateInfo.SampleCount = Refresh.SampleCount.One;
|
textureCreateInfo.SampleCount = SampleCount.One;
|
||||||
textureCreateInfo.UsageFlags = Refresh.TextureUsageFlags.SamplerBit;
|
textureCreateInfo.UsageFlags = TextureUsageFlags.SamplerBit;
|
||||||
|
|
||||||
var texture = new Texture(device, ref textureCreateInfo);
|
var texture = new Texture(device, ref textureCreateInfo);
|
||||||
|
|
||||||
|
@ -51,13 +51,13 @@ namespace MoonWorks.Graphics
|
||||||
GraphicsDevice device,
|
GraphicsDevice device,
|
||||||
uint width,
|
uint width,
|
||||||
uint height,
|
uint height,
|
||||||
Refresh.ColorFormat format,
|
ColorFormat format,
|
||||||
Refresh.TextureUsageFlags usageFlags,
|
TextureUsageFlags usageFlags,
|
||||||
Refresh.SampleCount sampleCount = Refresh.SampleCount.One,
|
SampleCount sampleCount = SampleCount.One,
|
||||||
uint levelCount = 1
|
uint levelCount = 1
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var textureCreateInfo = new MoonWorks.Graphics.TextureCreateInfo
|
var textureCreateInfo = new TextureCreateInfo
|
||||||
{
|
{
|
||||||
Width = width,
|
Width = width,
|
||||||
Height = height,
|
Height = height,
|
||||||
|
@ -77,13 +77,13 @@ namespace MoonWorks.Graphics
|
||||||
uint width,
|
uint width,
|
||||||
uint height,
|
uint height,
|
||||||
uint depth,
|
uint depth,
|
||||||
Refresh.ColorFormat format,
|
ColorFormat format,
|
||||||
Refresh.TextureUsageFlags usageFlags,
|
TextureUsageFlags usageFlags,
|
||||||
Refresh.SampleCount sampleCount = Refresh.SampleCount.One,
|
SampleCount sampleCount = SampleCount.One,
|
||||||
uint levelCount = 1
|
uint levelCount = 1
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var textureCreateInfo = new MoonWorks.Graphics.TextureCreateInfo
|
var textureCreateInfo = new TextureCreateInfo
|
||||||
{
|
{
|
||||||
Width = width,
|
Width = width,
|
||||||
Height = height,
|
Height = height,
|
||||||
|
@ -101,13 +101,13 @@ namespace MoonWorks.Graphics
|
||||||
public static Texture CreateTextureCube(
|
public static Texture CreateTextureCube(
|
||||||
GraphicsDevice device,
|
GraphicsDevice device,
|
||||||
uint size,
|
uint size,
|
||||||
Refresh.ColorFormat format,
|
ColorFormat format,
|
||||||
Refresh.TextureUsageFlags usageFlags,
|
TextureUsageFlags usageFlags,
|
||||||
Refresh.SampleCount sampleCount = Refresh.SampleCount.One,
|
SampleCount sampleCount = SampleCount.One,
|
||||||
uint levelCount = 1
|
uint levelCount = 1
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var textureCreateInfo = new MoonWorks.Graphics.TextureCreateInfo
|
var textureCreateInfo = new TextureCreateInfo
|
||||||
{
|
{
|
||||||
Width = size,
|
Width = size,
|
||||||
Height = size,
|
Height = size,
|
||||||
|
@ -122,7 +122,7 @@ namespace MoonWorks.Graphics
|
||||||
return new Texture(device, ref textureCreateInfo);
|
return new Texture(device, ref textureCreateInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture(GraphicsDevice device, ref MoonWorks.Graphics.TextureCreateInfo textureCreateInfo) : base(device)
|
public Texture(GraphicsDevice device, ref TextureCreateInfo textureCreateInfo) : base(device)
|
||||||
{
|
{
|
||||||
var refreshTextureCreateInfo = textureCreateInfo.ToRefreshTextureCreateInfo();
|
var refreshTextureCreateInfo = textureCreateInfo.ToRefreshTextureCreateInfo();
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace MoonWorks.Graphics
|
||||||
public unsafe struct ColorBlendState
|
public unsafe struct ColorBlendState
|
||||||
{
|
{
|
||||||
public bool LogicOpEnable;
|
public bool LogicOpEnable;
|
||||||
public Refresh.LogicOp LogicOp;
|
public LogicOp LogicOp;
|
||||||
public BlendConstants BlendConstants;
|
public BlendConstants BlendConstants;
|
||||||
public ColorTargetBlendState[] ColorTargetBlendStates;
|
public ColorTargetBlendState[] ColorTargetBlendStates;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@ namespace MoonWorks.Graphics
|
||||||
public uint Height;
|
public uint Height;
|
||||||
public uint Depth;
|
public uint Depth;
|
||||||
public bool IsCube;
|
public bool IsCube;
|
||||||
public Refresh.SampleCount SampleCount;
|
public SampleCount SampleCount;
|
||||||
public uint LevelCount;
|
public uint LevelCount;
|
||||||
public Refresh.ColorFormat Format;
|
public ColorFormat Format;
|
||||||
public Refresh.TextureUsageFlags UsageFlags;
|
public TextureUsageFlags UsageFlags;
|
||||||
|
|
||||||
public Refresh.TextureCreateInfo ToRefreshTextureCreateInfo()
|
public Refresh.TextureCreateInfo ToRefreshTextureCreateInfo()
|
||||||
{
|
{
|
||||||
|
@ -21,10 +21,10 @@ namespace MoonWorks.Graphics
|
||||||
height = Height,
|
height = Height,
|
||||||
depth = Depth,
|
depth = Depth,
|
||||||
isCube = Conversions.BoolToByte(IsCube),
|
isCube = Conversions.BoolToByte(IsCube),
|
||||||
sampleCount = SampleCount,
|
sampleCount = (Refresh.SampleCount) SampleCount,
|
||||||
levelCount = LevelCount,
|
levelCount = LevelCount,
|
||||||
format = Format,
|
format = (Refresh.ColorFormat) Format,
|
||||||
usageFlags = UsageFlags
|
usageFlags = (Refresh.TextureUsageFlags) UsageFlags
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
public struct VertexInputState
|
public struct VertexInputState
|
||||||
{
|
{
|
||||||
public Refresh.VertexBinding[] VertexBindings;
|
public VertexBinding[] VertexBindings;
|
||||||
public Refresh.VertexAttribute[] VertexAttributes;
|
public VertexAttribute[] VertexAttributes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
public struct ViewportState
|
public struct ViewportState
|
||||||
{
|
{
|
||||||
public Refresh.Viewport[] Viewports;
|
public Viewport[] Viewports;
|
||||||
public Refresh.Rect[] Scissors;
|
public Rect[] Scissors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,9 @@ namespace MoonWorks.Graphics
|
||||||
Level = level;
|
Level = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RefreshCS.Refresh.TextureSlice ToRefreshTextureSlice()
|
public Refresh.TextureSlice ToRefreshTextureSlice()
|
||||||
{
|
{
|
||||||
RefreshCS.Refresh.TextureSlice textureSlice = new RefreshCS.Refresh.TextureSlice
|
Refresh.TextureSlice textureSlice = new Refresh.TextureSlice
|
||||||
{
|
{
|
||||||
texture = Texture.Handle,
|
texture = Texture.Handle,
|
||||||
rectangle = Rectangle,
|
rectangle = Rectangle,
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace MoonWorks.Graphics
|
||||||
{
|
{
|
||||||
public static class Bytecode
|
public static class Bytecode
|
||||||
{
|
{
|
||||||
public static uint[] ReadBytecode(FileInfo fileInfo)
|
public static uint[] ReadBytecodeAsUInt32(FileInfo fileInfo)
|
||||||
{
|
{
|
||||||
byte[] data;
|
byte[] data;
|
||||||
int size;
|
int size;
|
|
@ -1,10 +0,0 @@
|
||||||
namespace MoonWorks
|
|
||||||
{
|
|
||||||
public enum PresentMode
|
|
||||||
{
|
|
||||||
Immediate,
|
|
||||||
Mailbox,
|
|
||||||
FIFO,
|
|
||||||
FIFORelaxed
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue