RefreshCS/src/Refresh.cs

1043 lines
30 KiB
C#
Raw Normal View History

2021-01-06 00:30:14 +00:00
/* RefreshCS - C# bindings for the Refresh graphics Library
2021-01-05 23:33:38 +00:00
*
* Copyright (c) 2020 Evan Hemsley
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from
* the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in a
* product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
* Evan "cosmonaut" Hemsley <evan@moonside.games>
*
*/
using System;
using System.IO;
using System.Runtime.InteropServices;
2021-01-06 02:57:05 +00:00
namespace RefreshCS
2021-01-05 23:33:38 +00:00
{
public static class Refresh
{
private const string nativeLibName = "Refresh";
/* Enums */
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
}
2021-01-16 03:05:28 +00:00
[Flags]
public enum ClearOptionsFlags : uint
2021-01-05 23:33:38 +00:00
{
Color = 1,
Depth = 2,
2021-01-16 03:05:28 +00:00
Stencil = 4,
DepthStencil = Depth | Stencil,
All = Color | Depth | Stencil
2021-01-05 23:33:38 +00:00
}
public enum IndexElementSize
{
Sixteen,
ThirtyTwo
}
public enum TextureFormat
2021-01-05 23:33:38 +00:00
{
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,
D16,
D32,
D16S8,
D32S8
2021-01-05 23:33:38 +00:00
}
2021-01-16 02:08:00 +00:00
[Flags]
public enum TextureUsageFlags : uint
2021-01-05 23:33:38 +00:00
{
Sampler = 1,
ColorTarget = 2,
DepthStencilTarget = 4
2021-01-05 23:33:38 +00:00
}
public enum SampleCount
{
One,
Two,
Four,
Eight,
Sixteen,
ThirtyTwo,
SixtyFour
}
2021-02-10 06:51:02 +00:00
public enum CubeMapFace : uint
2021-01-05 23:33:38 +00:00
{
PositiveX,
NegativeX,
PositiveY,
NegativeY,
PositiveZ,
NegativeZ
}
2021-01-16 02:08:00 +00:00
[Flags]
public enum BufferUsageFlags : uint
2021-01-06 05:35:36 +00:00
{
Vertex = 1,
Index = 2,
Compute = 4
}
2021-01-05 23:33:38 +00:00
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
}
2021-01-16 02:08:00 +00:00
[Flags]
public enum ColorComponentFlags : uint
2021-01-05 23:33:38 +00:00
{
R = 1,
G = 2,
B = 4,
2021-01-16 02:08:00 +00:00
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
2021-01-05 23:33:38 +00:00
}
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
}
/* Native Structures */
[StructLayout(LayoutKind.Sequential)]
public struct DepthStencilValue
{
public float depth;
public uint stencil;
}
[StructLayout(LayoutKind.Sequential)]
public struct Rect
{
public int x;
public int y;
public int w;
public int 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 TextureSlice
{
public IntPtr texture;
public Rect rectangle;
public uint depth;
public uint layer;
public uint level;
}
[StructLayout(LayoutKind.Sequential)]
public struct PresentationParameters
{
public IntPtr deviceWindowHandle;
public PresentMode presentMode;
}
[StructLayout(LayoutKind.Sequential)]
public struct SamplerStateCreateInfo
{
public Filter minFilter;
public Filter magFilter;
public SamplerMipmapMode mipmapMode;
public SamplerAddressMode addressModeU;
public SamplerAddressMode addressModeV;
public SamplerAddressMode addressModeW;
public float mipLodBias;
public byte anisotropyEnable;
public float maxAnisotropy;
public byte compareEnable;
public CompareOp compareOp;
public float minLod;
public float maxLod;
public BorderColor borderColor;
}
[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)]
2021-01-06 05:35:36 +00:00
public struct VertexInputState
2021-01-05 23:33:38 +00:00
{
2021-01-06 05:35:36 +00:00
public IntPtr vertexBindings;
2021-01-05 23:33:38 +00:00
public uint vertexBindingCount;
2021-01-06 05:35:36 +00:00
public IntPtr vertexAttributes;
2021-01-05 23:33:38 +00:00
public uint vertexAttributeCount;
}
[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-06 00:01:27 +00:00
[StructLayout(LayoutKind.Sequential)]
public struct ColorTargetBlendState
{
public byte blendEnable;
public BlendFactor sourceColorBlendFactor;
public BlendFactor destinationColorBlendFactor;
public BlendOp colorBlendOp;
public BlendFactor sourceAlphaBlendFactor;
public BlendFactor destinationAlphaBlendFactor;
public BlendOp alphaBlendOp;
2021-01-16 02:08:00 +00:00
public ColorComponentFlags colorWriteMask;
2021-01-06 00:01:27 +00:00
}
[StructLayout(LayoutKind.Sequential)]
public struct ComputePipelineLayoutCreateInfo
{
public uint bufferBindingCount;
public uint imageBindingCount;
}
[StructLayout(LayoutKind.Sequential)]
public struct GraphicsPipelineLayoutCreateInfo
{
public uint vertexSamplerBindingCount;
public uint fragmentSamplerBindingCount;
}
[StructLayout(LayoutKind.Sequential)]
public struct ColorTargetDescription
{
public TextureFormat format;
2021-01-06 00:01:27 +00:00
public SampleCount multisampleCount;
public LoadOp loadOp;
public StoreOp storeOp;
}
[StructLayout(LayoutKind.Sequential)]
public struct DepthStencilTargetDescription
{
public TextureFormat format;
2021-01-06 00:01:27 +00:00
public LoadOp loadOp;
public StoreOp storeOp;
public LoadOp stencilLoadOp;
public StoreOp stencilStoreOp;
}
[StructLayout(LayoutKind.Sequential)]
2021-01-06 05:35:36 +00:00
public struct RenderPassCreateInfo
2021-01-06 00:01:27 +00:00
{
2021-01-06 05:35:36 +00:00
public IntPtr colorTargetDescriptions; /* Refresh_ColorTargetDescription */
2021-01-06 00:01:27 +00:00
public uint colorTargetCount;
2021-01-06 05:35:36 +00:00
public IntPtr depthStencilTargetDescription;
2021-01-06 00:01:27 +00:00
}
[StructLayout(LayoutKind.Sequential)]
2021-01-06 05:35:36 +00:00
public struct ShaderModuleCreateInfo
2021-01-06 00:01:27 +00:00
{
public UIntPtr codeSize; /* size_t */
2021-01-06 05:35:36 +00:00
public IntPtr byteCode;
2021-01-06 00:01:27 +00:00
}
2021-01-14 09:57:26 +00:00
[StructLayout(LayoutKind.Sequential)]
public struct TextureCreateInfo
{
2021-01-14 10:07:17 +00:00
public uint width;
public uint height;
public uint depth;
public byte isCube;
public SampleCount sampleCount;
public uint levelCount;
public TextureFormat format;
2021-01-16 02:08:00 +00:00
public TextureUsageFlags usageFlags; /* Refresh_TextureUsageFlags */
2021-01-14 09:57:26 +00:00
}
2021-01-06 00:01:27 +00:00
[StructLayout(LayoutKind.Sequential)]
2021-01-06 05:35:36 +00:00
public struct ShaderStageState
2021-01-06 00:01:27 +00:00
{
public IntPtr shaderModule;
[MarshalAs(UnmanagedType.LPStr)]
public string entryPointName;
2021-01-16 02:08:00 +00:00
public ulong uniformBufferSize;
2021-01-06 00:01:27 +00:00
}
[StructLayout(LayoutKind.Sequential)]
2021-01-06 05:35:36 +00:00
public struct ViewportState
2021-01-06 00:01:27 +00:00
{
2021-01-06 05:35:36 +00:00
public IntPtr viewports;
2021-01-06 00:01:27 +00:00
public uint viewportCount;
2021-01-06 05:35:36 +00:00
public IntPtr scissors;
2021-01-06 00:01:27 +00:00
public uint scissorCount;
}
[StructLayout(LayoutKind.Sequential)]
public struct RasterizerState
{
public byte depthClampEnable;
public FillMode fillMode;
public CullMode cullMode;
public FrontFace frontFace;
public byte depthBiasEnable;
public float depthBiasConstantFactor;
public float depthBiasClamp;
public float depthBiasSlopeFactor;
public float lineWidth;
}
[StructLayout(LayoutKind.Sequential)]
public struct MultisampleState
{
public SampleCount multisampleCount;
public uint sampleMask;
}
[StructLayout(LayoutKind.Sequential)]
public struct DepthStencilState
{
public byte depthTestEnable;
public byte depthWriteEnable;
public CompareOp compareOp;
public byte depthBoundsTestEnable;
public byte stencilTestEnable;
public StencilOpState frontStencilState;
public StencilOpState backStencilState;
public float minDepthBounds;
public float maxDepthBounds;
}
[StructLayout(LayoutKind.Sequential)]
2021-01-06 07:41:56 +00:00
public unsafe struct ColorBlendState
2021-01-06 00:01:27 +00:00
{
public byte logicOpEnable;
public LogicOp logicOp;
2021-01-06 05:35:36 +00:00
public IntPtr blendStates;
2021-01-06 00:01:27 +00:00
public uint blendStateCount;
2021-01-06 07:41:56 +00:00
public fixed float blendConstants[4];
2021-01-06 00:01:27 +00:00
}
[StructLayout(LayoutKind.Sequential)]
public struct ComputePipelineCreateInfo
{
2021-01-16 03:05:28 +00:00
public ShaderStageState computeShaderState;
public ComputePipelineLayoutCreateInfo pipelineLayoutCreateInfo;
2021-01-06 00:01:27 +00:00
}
[StructLayout(LayoutKind.Sequential)]
public struct GraphicsPipelineCreateInfo
{
2021-01-06 05:35:36 +00:00
public ShaderStageState vertexShaderState;
2021-01-07 01:33:57 +00:00
public ShaderStageState fragmentShaderState;
2021-01-06 00:01:27 +00:00
public VertexInputState vertexInputState;
2021-01-14 05:11:13 +00:00
public PrimitiveType primitiveType;
2021-01-06 00:01:27 +00:00
public ViewportState viewportState;
2021-01-06 05:35:36 +00:00
public RasterizerState rasterizerState;
2021-01-06 00:01:27 +00:00
public MultisampleState multisampleState;
public DepthStencilState depthStencilState;
public ColorBlendState colorBlendState;
public GraphicsPipelineLayoutCreateInfo pipelineLayoutCreateInfo;
public IntPtr renderPass;
}
[StructLayout(LayoutKind.Sequential)]
public struct FramebufferCreateInfo
{
public IntPtr renderPass;
2021-01-06 05:35:36 +00:00
public IntPtr pColorTargets;
2021-01-06 00:01:27 +00:00
public uint colorTargetCount;
public IntPtr depthStencilTarget;
public uint width;
public uint height;
}
2021-01-06 00:25:30 +00:00
/* Logging */
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void Refresh_LogFunc(IntPtr msg);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_HookLogFunctions(
Refresh_LogFunc info,
Refresh_LogFunc warn,
Refresh_LogFunc error
);
/* Init/Quit */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_CreateDevice(
2021-01-22 01:25:39 +00:00
in PresentationParameters presentationParameters,
2021-01-06 00:25:30 +00:00
byte debugMode
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_DestroyDevice(IntPtr device);
/* Drawing */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_Clear(
IntPtr device,
IntPtr commandBuffer,
2021-01-22 01:25:39 +00:00
in Rect clearRect,
2021-01-16 03:05:28 +00:00
Refresh.ClearOptionsFlags clearOptions,
2021-01-22 22:16:18 +00:00
IntPtr colors,
2021-01-06 00:25:30 +00:00
uint colorCount,
2021-01-22 22:16:18 +00:00
DepthStencilValue depthStencilValue
2021-01-06 00:25:30 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_DrawInstancedPrimitives(
2021-01-06 02:57:05 +00:00
IntPtr device,
2021-01-06 00:25:30 +00:00
IntPtr commandBuffer,
uint baseVertex,
uint startIndex,
uint primitiveCount,
uint instanceCount,
uint vertexParamOffset,
uint fragmentParamOffset
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_DrawIndexedPrimitives(
IntPtr device,
IntPtr commandBuffer,
2021-01-14 05:11:13 +00:00
uint baseVertex,
2021-01-06 00:25:30 +00:00
uint startIndex,
uint primitiveCount,
uint vertexParamOffset,
uint fragmentParamOffset
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_DrawPrimitives(
IntPtr device,
IntPtr commandBuffer,
uint vertexStart,
uint primitiveCount,
uint vertexParamOffset,
uint fragmentParamOffset
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_DispatchCompute(
IntPtr device,
IntPtr commandBuffer,
uint groupCountX,
uint groupCountY,
uint groupCountZ,
uint computeParamOffset
);
2021-01-06 00:41:33 +00:00
/* Creates */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_CreateRenderPass(
IntPtr device,
2021-01-22 01:25:39 +00:00
in RenderPassCreateInfo renderPassCreateInfo
2021-01-06 00:41:33 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_CreateComputePipeline(
IntPtr device,
2021-01-22 01:25:39 +00:00
in ComputePipelineCreateInfo computePipelineCreateInfo
2021-01-06 00:41:33 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_CreateGraphicsPipeline(
IntPtr device,
2021-01-22 01:25:39 +00:00
in GraphicsPipelineCreateInfo graphicsPipelineCreateInfo
2021-01-06 00:41:33 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_CreateSampler(
IntPtr device,
2021-01-22 01:25:39 +00:00
in SamplerStateCreateInfo samplerStateCreateInfo
2021-01-06 00:41:33 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_CreateFramebuffer(
IntPtr device,
2021-01-22 01:25:39 +00:00
in FramebufferCreateInfo framebufferCreateInfo
2021-01-06 00:41:33 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_CreateShaderModule(
IntPtr device,
2021-01-22 01:25:39 +00:00
in ShaderModuleCreateInfo shaderModuleCreateInfo
2021-01-06 00:41:33 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2021-01-14 09:57:26 +00:00
public static extern IntPtr Refresh_CreateTexture(
2021-01-06 00:41:33 +00:00
IntPtr device,
2021-01-22 01:25:39 +00:00
in TextureCreateInfo textureCreateInfo
2021-01-06 00:41:33 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_CreateRenderTarget(
2021-01-06 00:41:33 +00:00
IntPtr device,
in TextureSlice textureSlice,
SampleCount multisampleCount
2021-01-06 00:41:33 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_CreateBuffer(
IntPtr device,
2021-01-16 02:08:00 +00:00
BufferUsageFlags usageFlags,
2021-01-06 00:41:33 +00:00
uint sizeInBytes
);
2021-01-06 01:04:44 +00:00
/* Setters */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_SetTextureData(
IntPtr device,
2021-11-15 04:41:23 +00:00
IntPtr commandBuffer,
2021-11-15 05:06:50 +00:00
in TextureSlice textureSlice,
2021-01-06 01:04:44 +00:00
IntPtr data,
uint dataLengthInBytes
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_SetTextureDataYUV(
IntPtr device,
2021-11-15 04:41:23 +00:00
IntPtr commandBuffer,
2021-01-06 01:04:44 +00:00
IntPtr y,
IntPtr u,
IntPtr v,
uint yWidth,
uint yHeight,
uint uvWidth,
uint uvHeight,
IntPtr data,
uint dataLength
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_CopyTextureToTexture(
IntPtr device,
IntPtr commandBuffer,
2021-01-22 01:25:39 +00:00
in TextureSlice sourceTextureSlice,
in TextureSlice destinationTextureSlice,
2021-01-06 01:04:44 +00:00
Filter filter
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_CopyTextureToBuffer(
IntPtr device,
IntPtr commandBuffer,
2021-01-22 01:25:39 +00:00
in TextureSlice textureSlice,
2021-01-06 01:04:44 +00:00
IntPtr buffer
);
2021-01-16 03:05:28 +00:00
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_GetBufferData(
IntPtr device,
IntPtr buffer,
IntPtr data,
uint dataLengthInBytes
);
2021-01-06 01:04:44 +00:00
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_SetBufferData(
IntPtr device,
2022-01-13 21:59:47 +00:00
IntPtr commandBuffer,
2021-01-06 01:04:44 +00:00
IntPtr buffer,
uint offsetInBytes,
IntPtr data,
uint dataLengthInBytes
2021-01-06 01:04:44 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2021-02-01 03:39:01 +00:00
public static extern uint Refresh_PushVertexShaderUniforms(
2021-01-06 01:04:44 +00:00
IntPtr device,
2022-01-12 20:57:00 +00:00
IntPtr commandBuffer,
2021-01-06 01:04:44 +00:00
IntPtr data,
2021-02-03 00:33:39 +00:00
uint dataLengthInBytes
2021-01-06 01:04:44 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2021-02-01 03:39:01 +00:00
public static extern uint Refresh_PushFragmentShaderUniforms(
2021-01-06 01:04:44 +00:00
IntPtr device,
2022-01-12 20:57:00 +00:00
IntPtr commandBuffer,
2021-01-06 01:04:44 +00:00
IntPtr data,
2021-02-03 00:33:39 +00:00
uint dataLengthInBytes
2021-01-06 01:04:44 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2021-02-01 05:18:24 +00:00
public static extern uint Refresh_PushComputeShaderUniforms(
2021-01-06 01:04:44 +00:00
IntPtr device,
2022-01-12 20:57:00 +00:00
IntPtr commandBuffer,
2021-01-06 01:04:44 +00:00
IntPtr data,
2021-02-03 00:33:39 +00:00
uint dataLengthInBytes
2021-01-06 01:04:44 +00:00
);
/* Disposal */
2021-01-06 02:00:26 +00:00
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_QueueDestroyTexture(
IntPtr device,
IntPtr texture
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_QueueDestroySampler(
IntPtr device,
IntPtr sampler
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_QueueDestroyBuffer(
IntPtr device,
IntPtr buffer
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_QueueDestroyRenderTarget(
2021-01-06 02:00:26 +00:00
IntPtr device,
IntPtr renderTarget
2021-01-06 02:00:26 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_QueueDestroyFramebuffer(
IntPtr device,
IntPtr framebuffer
);
2021-01-14 09:26:25 +00:00
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_QueueDestroyShaderModule(
IntPtr device,
IntPtr shaderModule
);
2021-01-06 02:00:26 +00:00
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_QueueDestroyRenderPass(
IntPtr device,
IntPtr renderPass
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_QueueDestroyComputePipeline(
IntPtr device,
IntPtr computePipeline
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_QueueDestroyGraphicsPipeline(
IntPtr device,
IntPtr graphicsPipeline
);
2021-01-06 01:04:44 +00:00
/* Graphics State */
2021-01-06 02:00:26 +00:00
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BeginRenderPass(
IntPtr device,
IntPtr commandBuffer,
IntPtr renderPass,
IntPtr framebuffer,
2021-01-22 01:25:39 +00:00
in Rect renderArea,
2021-01-06 05:35:36 +00:00
IntPtr pColorClearValues,
2021-01-06 02:00:26 +00:00
uint colorClearCount,
2021-01-22 01:25:39 +00:00
in DepthStencilValue depthStencilClearValue
2021-01-06 02:00:26 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BeginRenderPass(
IntPtr device,
IntPtr commandBuffer,
IntPtr renderPass,
IntPtr framebuffer,
2021-01-22 01:25:39 +00:00
in Rect renderArea,
IntPtr pColorClearValues,
uint colorClearCount,
IntPtr depthStencilClearValue /* NULL */
);
2021-01-06 02:00:26 +00:00
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_EndRenderPass(
IntPtr device,
IntPtr commandBuffer
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BindGraphicsPipeline(
IntPtr device,
IntPtr commandBuffer,
IntPtr graphicsPipeline
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2021-01-06 05:35:36 +00:00
public static extern void Refresh_BindVertexBuffers(
2021-01-06 02:00:26 +00:00
IntPtr device,
IntPtr commandBuffer,
uint firstBinding,
uint bindingCount,
2021-01-06 07:41:56 +00:00
IntPtr pBuffers,
IntPtr pOffsets
2021-01-06 02:00:26 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BindIndexBuffer(
IntPtr device,
IntPtr commandBuffer,
IntPtr buffer,
uint offset,
IndexElementSize indexElementSize
);
2021-01-06 01:04:44 +00:00
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BindVertexSamplers(
IntPtr device,
IntPtr commandBuffer,
2021-01-06 07:41:56 +00:00
IntPtr pTextures,
IntPtr pSamplers
2021-01-06 01:04:44 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BindFragmentSamplers(
IntPtr device,
IntPtr commandBuffer,
2021-01-06 07:41:56 +00:00
IntPtr pTextures,
IntPtr pSamplers
2021-01-06 02:00:26 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BindComputePipeline(
IntPtr device,
IntPtr commandBuffer,
IntPtr computePipeline
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BindComputeBuffers(
IntPtr device,
IntPtr commandBuffer,
2021-01-06 07:41:56 +00:00
IntPtr pBuffers
2021-01-06 02:00:26 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BindComputeTextures(
IntPtr device,
IntPtr commandBuffer,
2021-01-06 07:41:56 +00:00
IntPtr pTextures
2021-01-06 02:00:26 +00:00
);
/* Submission/Presentation */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_AcquireCommandBuffer(
IntPtr device,
byte isFixed
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_QueuePresent(
IntPtr device,
IntPtr commandBuffer,
2021-01-22 01:25:39 +00:00
in TextureSlice textureSlice,
in Rect destinationRectangle,
2021-01-06 02:00:26 +00:00
Filter filter
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_QueuePresent(
IntPtr device,
IntPtr commandBuffer,
2021-01-22 01:25:39 +00:00
in TextureSlice textureSlice,
2021-01-06 02:00:26 +00:00
IntPtr destinationRectangle, /* null Rect */
Filter filter
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_Submit(
IntPtr device,
uint commandBufferCount,
2021-01-06 07:41:56 +00:00
IntPtr pCommandBuffers
2021-01-06 02:00:26 +00:00
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_Wait(
IntPtr device
2021-01-06 01:04:44 +00:00
);
2021-01-06 05:35:36 +00:00
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_Image_Load(
[MarshalAs(UnmanagedType.LPStr)] string filename,
out int width,
out int height,
out int numChannels
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_Image_Free(
IntPtr mem
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_Image_SavePNG(
[MarshalAs(UnmanagedType.LPStr)] string filename,
int w,
int h,
IntPtr data
);
2021-01-05 23:33:38 +00:00
}
}