2021-01-20 21:32:48 +00:00
|
|
|
|
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
|
|
|
|
|
{
|
2022-02-23 05:14:32 +00:00
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
public struct DepthStencilValue
|
|
|
|
|
{
|
|
|
|
|
public float Depth;
|
|
|
|
|
public uint Stencil;
|
2021-01-20 21:32:48 +00:00
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
// FIXME: can we do an unsafe cast somehow?
|
|
|
|
|
public Refresh.DepthStencilValue ToRefresh()
|
|
|
|
|
{
|
|
|
|
|
return new Refresh.DepthStencilValue
|
|
|
|
|
{
|
|
|
|
|
depth = Depth,
|
|
|
|
|
stencil = Stencil
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-20 21:32:48 +00:00
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
public struct Rect
|
|
|
|
|
{
|
|
|
|
|
public int X;
|
|
|
|
|
public int Y;
|
|
|
|
|
public int W;
|
|
|
|
|
public int H;
|
2021-01-20 21:32:48 +00:00
|
|
|
|
|
2022-02-26 02:01:22 +00:00
|
|
|
|
public Rect(int x, int y, int w, int h)
|
|
|
|
|
{
|
|
|
|
|
X = x;
|
|
|
|
|
Y = y;
|
|
|
|
|
W = w;
|
|
|
|
|
H = h;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Rect(int w, int h)
|
|
|
|
|
{
|
|
|
|
|
X = 0;
|
|
|
|
|
Y = 0;
|
|
|
|
|
W = w;
|
|
|
|
|
H = h;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
// FIXME: can we do an unsafe cast somehow?
|
|
|
|
|
public Refresh.Rect ToRefresh()
|
|
|
|
|
{
|
|
|
|
|
return new Refresh.Rect
|
|
|
|
|
{
|
|
|
|
|
x = X,
|
|
|
|
|
y = Y,
|
|
|
|
|
w = W,
|
|
|
|
|
h = H
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-20 21:32:48 +00:00
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
public struct Viewport
|
|
|
|
|
{
|
|
|
|
|
public float X;
|
|
|
|
|
public float Y;
|
|
|
|
|
public float W;
|
|
|
|
|
public float H;
|
|
|
|
|
public float MinDepth;
|
|
|
|
|
public float MaxDepth;
|
2022-02-26 02:01:22 +00:00
|
|
|
|
|
|
|
|
|
public Viewport(float w, float h)
|
|
|
|
|
{
|
|
|
|
|
X = 0;
|
|
|
|
|
Y = 0;
|
|
|
|
|
W = w;
|
|
|
|
|
H = h;
|
|
|
|
|
MinDepth = 0;
|
|
|
|
|
MaxDepth = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Viewport(float x, float y, float w, float h)
|
|
|
|
|
{
|
|
|
|
|
X = x;
|
|
|
|
|
Y = y;
|
|
|
|
|
W = w;
|
|
|
|
|
H = h;
|
|
|
|
|
MinDepth = 0;
|
|
|
|
|
MaxDepth = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Viewport(float x, float y, float w, float h, float minDepth, float maxDepth)
|
|
|
|
|
{
|
|
|
|
|
X = x;
|
|
|
|
|
Y = y;
|
|
|
|
|
W = w;
|
|
|
|
|
H = h;
|
|
|
|
|
MinDepth = minDepth;
|
|
|
|
|
MaxDepth = maxDepth;
|
|
|
|
|
}
|
2022-02-23 05:14:32 +00:00
|
|
|
|
}
|
2021-01-20 21:32:48 +00:00
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
public struct VertexBinding
|
|
|
|
|
{
|
|
|
|
|
public uint Binding;
|
|
|
|
|
public uint Stride;
|
|
|
|
|
public VertexInputRate InputRate;
|
|
|
|
|
}
|
2021-01-20 21:32:48 +00:00
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
public struct VertexAttribute
|
|
|
|
|
{
|
|
|
|
|
public uint Location;
|
|
|
|
|
public uint Binding;
|
|
|
|
|
public VertexElementFormat Format;
|
|
|
|
|
public uint Offset;
|
|
|
|
|
}
|
2021-01-20 21:32:48 +00:00
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
public struct StencilOpState
|
|
|
|
|
{
|
|
|
|
|
public StencilOp FailOp;
|
|
|
|
|
public StencilOp PassOp;
|
|
|
|
|
public StencilOp DepthFailOp;
|
|
|
|
|
public CompareOp CompareOp;
|
|
|
|
|
public uint CompareMask;
|
|
|
|
|
public uint WriteMask;
|
|
|
|
|
public uint Reference;
|
2021-01-22 01:27:25 +00:00
|
|
|
|
|
2022-02-23 05:14:32 +00:00
|
|
|
|
// FIXME: can we do an explicit cast here?
|
|
|
|
|
public Refresh.StencilOpState ToRefresh()
|
|
|
|
|
{
|
|
|
|
|
return new Refresh.StencilOpState
|
|
|
|
|
{
|
|
|
|
|
failOp = (Refresh.StencilOp) FailOp,
|
|
|
|
|
passOp = (Refresh.StencilOp) PassOp,
|
|
|
|
|
depthFailOp = (Refresh.StencilOp) DepthFailOp,
|
|
|
|
|
compareOp = (Refresh.CompareOp) CompareOp,
|
|
|
|
|
compareMask = CompareMask,
|
|
|
|
|
writeMask = WriteMask,
|
|
|
|
|
reference = Reference
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-25 05:34:36 +00:00
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
public struct ColorAttachmentInfo
|
|
|
|
|
{
|
2022-03-02 06:57:10 +00:00
|
|
|
|
public Texture Texture;
|
|
|
|
|
public uint Depth;
|
|
|
|
|
public uint Layer;
|
|
|
|
|
public uint Level;
|
|
|
|
|
public SampleCount SampleCount;
|
2022-02-25 16:15:48 +00:00
|
|
|
|
public Color ClearColor;
|
|
|
|
|
public LoadOp LoadOp;
|
|
|
|
|
public StoreOp StoreOp;
|
2022-02-25 05:34:36 +00:00
|
|
|
|
|
|
|
|
|
public Refresh.ColorAttachmentInfo ToRefresh()
|
|
|
|
|
{
|
|
|
|
|
return new Refresh.ColorAttachmentInfo
|
|
|
|
|
{
|
2022-03-02 06:57:10 +00:00
|
|
|
|
texture = Texture.Handle,
|
|
|
|
|
depth = Depth,
|
|
|
|
|
layer = Layer,
|
|
|
|
|
level = Level,
|
|
|
|
|
sampleCount = (Refresh.SampleCount) SampleCount,
|
2022-02-25 05:34:36 +00:00
|
|
|
|
clearColor = new Refresh.Vec4
|
|
|
|
|
{
|
2022-02-25 16:15:48 +00:00
|
|
|
|
x = ClearColor.R / 255f,
|
|
|
|
|
y = ClearColor.G / 255f,
|
|
|
|
|
z = ClearColor.B / 255f,
|
|
|
|
|
w = ClearColor.A / 255f
|
2022-02-25 05:34:36 +00:00
|
|
|
|
},
|
2022-02-25 16:15:48 +00:00
|
|
|
|
loadOp = (Refresh.LoadOp) LoadOp,
|
|
|
|
|
storeOp = (Refresh.StoreOp) StoreOp
|
2022-02-25 05:34:36 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
public struct DepthStencilAttachmentInfo
|
|
|
|
|
{
|
2022-03-02 06:57:10 +00:00
|
|
|
|
public Texture Texture;
|
|
|
|
|
public uint Depth;
|
|
|
|
|
public uint Layer;
|
|
|
|
|
public uint Level;
|
|
|
|
|
public DepthStencilValue DepthStencilClearValue;
|
2022-02-25 16:15:48 +00:00
|
|
|
|
public LoadOp LoadOp;
|
|
|
|
|
public StoreOp StoreOp;
|
|
|
|
|
public LoadOp StencilLoadOp;
|
|
|
|
|
public StoreOp StencilStoreOp;
|
2022-02-25 05:34:36 +00:00
|
|
|
|
|
|
|
|
|
public Refresh.DepthStencilAttachmentInfo ToRefresh()
|
|
|
|
|
{
|
|
|
|
|
return new Refresh.DepthStencilAttachmentInfo
|
|
|
|
|
{
|
2022-03-02 06:57:10 +00:00
|
|
|
|
texture = Texture.Handle,
|
|
|
|
|
depth = Depth,
|
|
|
|
|
layer = Layer,
|
|
|
|
|
level = Level,
|
|
|
|
|
depthStencilClearValue = DepthStencilClearValue.ToRefresh(),
|
2022-02-25 16:15:48 +00:00
|
|
|
|
loadOp = (Refresh.LoadOp) LoadOp,
|
|
|
|
|
storeOp = (Refresh.StoreOp) StoreOp,
|
|
|
|
|
stencilLoadOp = (Refresh.LoadOp) StencilLoadOp,
|
|
|
|
|
stencilStoreOp = (Refresh.StoreOp) StencilStoreOp
|
2022-02-25 05:34:36 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
public struct ColorAttachmentDescription
|
|
|
|
|
{
|
2022-02-25 16:15:48 +00:00
|
|
|
|
public TextureFormat Format;
|
|
|
|
|
public SampleCount SampleCount;
|
2022-02-26 01:50:08 +00:00
|
|
|
|
public ColorAttachmentBlendState BlendState;
|
2022-02-25 05:34:36 +00:00
|
|
|
|
}
|
2021-01-20 21:32:48 +00:00
|
|
|
|
}
|