Compare commits

...

15 Commits

Author SHA1 Message Date
cosmonaut b92ecb60e3 remove DrawIndexedPrimitives 2024-03-13 09:44:38 -07:00
cosmonaut 995a54fa2d Debug Name API 2024-03-11 16:10:57 -07:00
cosmonaut 1bf28f4397 add WriteOptions.Unsafe 2024-03-11 10:17:37 -07:00
cosmonaut 8f42783fd1 TransferUsage 2024-03-08 15:29:35 -08:00
cosmonaut 029f19196a rename Discard to Cycle 2024-03-07 14:24:03 -08:00
cosmonaut 22b6a83aea rename SafeDiscard to Discard 2024-03-07 14:14:15 -08:00
cosmonaut 55acf6ee18 change backend selection behavior 2024-03-07 10:34:14 -08:00
cosmonaut 859675dbab modify readback API 2024-03-05 17:38:06 -08:00
cosmonaut 7465d4d4de D3D11 support 2024-03-05 16:12:14 -08:00
cosmonaut 86cc5fa142 fix Stencil API 2024-03-02 23:10:29 -08:00
cosmonaut 4268db4616 restructure bindings API 2024-03-01 12:42:04 -08:00
cosmonaut 020e76782a TextureSlice and TextureRegion API 2024-02-29 23:47:49 -08:00
cosmonaut 031ad4c047 API updates 2024-02-28 19:15:22 -08:00
cosmonaut 2e346d8401 rename CpuBuffer to TransferBuffer 2024-02-23 09:55:45 -08:00
cosmonaut ad0b168c47 proposed Refresh 2 changes 2024-02-23 00:05:44 -08:00
2 changed files with 312 additions and 181 deletions

View File

@ -4,7 +4,6 @@
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>RefreshCS</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Platforms>x64</Platforms>
</PropertyGroup>
<ItemGroup>

View File

@ -35,8 +35,8 @@ namespace RefreshCS
/* Version */
public const uint REFRESH_MAJOR_VERSION = 1;
public const uint REFRESH_MINOR_VERSION = 15;
public const uint REFRESH_MAJOR_VERSION = 2;
public const uint REFRESH_MINOR_VERSION = 0;
public const uint REFRESH_PATCH_VERSION = 0;
public const uint REFRESH_COMPILED_VERSION = (
@ -308,10 +308,29 @@ namespace RefreshCS
IntOpaqueWhite
}
public enum TransferUsage
{
Buffer,
Texture
}
public enum TransferOptions
{
Cycle,
Unsafe
}
public enum WriteOptions
{
Cycle,
Unsafe,
Safe
}
public enum Backend
{
DontCare,
Vulkan,
D3D11,
PS5,
Invalid
}
@ -358,10 +377,36 @@ namespace RefreshCS
public struct TextureSlice
{
public IntPtr texture;
public Rect rectangle;
public uint depth;
public uint mipLevel;
public uint layer;
public uint level;
}
[StructLayout(LayoutKind.Sequential)]
public struct TextureRegion
{
public TextureSlice textureSlice;
public uint x;
public uint y;
public uint z;
public uint w;
public uint h;
public uint d;
}
[StructLayout(LayoutKind.Sequential)]
public struct BufferImageCopy
{
public uint bufferOffset;
public uint bufferStride;
public uint bufferImageHeight;
}
[StructLayout(LayoutKind.Sequential)]
public struct BufferCopy
{
public uint srcOffset;
public uint dstOffset;
public uint size;
}
[StructLayout(LayoutKind.Sequential)]
@ -425,9 +470,6 @@ namespace RefreshCS
public StencilOp passOp;
public StencilOp depthFailOp;
public CompareOp compareOp;
public uint compareMask;
public uint writeMask;
public uint reference;
}
[StructLayout(LayoutKind.Sequential)]
@ -457,6 +499,7 @@ namespace RefreshCS
public uint height;
public uint depth;
public byte isCube;
public uint layerCount;
public uint levelCount;
public SampleCount sampleCount;
public TextureFormat format;
@ -469,7 +512,7 @@ namespace RefreshCS
public IntPtr shaderModule;
[MarshalAs(UnmanagedType.LPStr)]
public string entryPointName;
public ulong uniformBufferSize;
public uint uniformBufferSize;
public uint samplerBindingCount;
}
@ -479,7 +522,7 @@ namespace RefreshCS
public IntPtr shaderModule;
[MarshalAs(UnmanagedType.LPStr)]
public string entryPointName;
public ulong uniformBufferSize;
public uint uniformBufferSize;
public uint bufferBindingCount;
public uint imageBindingCount;
}
@ -511,8 +554,11 @@ namespace RefreshCS
public CompareOp compareOp;
public byte depthBoundsTestEnable;
public byte stencilTestEnable;
public StencilOpState frontStencilState;
public StencilOpState backStencilState;
public StencilOpState frontStencilState;
public uint compareMask;
public uint writeMask;
public uint reference;
public float minDepthBounds;
public float maxDepthBounds;
}
@ -547,28 +593,54 @@ namespace RefreshCS
public fixed float blendConstants[4];
}
[StructLayout(LayoutKind.Sequential)]
public struct ColorAttachmentInfo
{
public IntPtr texture;
public uint depth;
public uint layer;
public uint level;
public TextureSlice textureSlice;
public Vec4 clearColor;
public LoadOp loadOp;
public StoreOp storeOp;
public WriteOptions writeOption;
}
[StructLayout(LayoutKind.Sequential)]
public struct DepthStencilAttachmentInfo
{
public IntPtr texture;
public uint depth;
public uint layer;
public uint level;
public TextureSlice textureSlice;
public DepthStencilValue depthStencilClearValue;
public LoadOp loadOp;
public StoreOp storeOp;
public LoadOp stencilLoadOp;
public StoreOp stencilStoreOp;
public WriteOptions writeOption;
}
[StructLayout(LayoutKind.Sequential)]
public struct BufferBinding
{
public IntPtr gpuBuffer;
public uint offset;
}
[StructLayout(LayoutKind.Sequential)]
public struct TextureSamplerBinding
{
public IntPtr texture;
public IntPtr sampler;
}
[StructLayout(LayoutKind.Sequential)]
public struct ComputeBufferBinding
{
public IntPtr gpuBuffer;
public WriteOptions writeOption;
}
[StructLayout(LayoutKind.Sequential)]
public struct ComputeTextureBinding
{
public TextureSlice textureSlice;
public WriteOptions writeOption;
}
/* Logging */
@ -586,8 +658,9 @@ namespace RefreshCS
/* Init/Quit */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Backend Refresh_SelectBackend(
Backend preferredBackend,
public static unsafe extern Backend Refresh_SelectBackend(
Backend* preferredBackends,
uint preferredBackendCount,
out uint flags
);
@ -599,64 +672,7 @@ namespace RefreshCS
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_DestroyDevice(IntPtr device);
/* Drawing */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_DrawInstancedPrimitives(
IntPtr device,
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,
uint baseVertex,
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_DrawPrimitivesIndirect(
IntPtr device,
IntPtr commandBuffer,
IntPtr buffer,
uint offsetInBytes,
uint drawCount,
uint stride,
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
);
/* Creates */
/* State Creation */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_CreateComputePipeline(
@ -689,100 +705,33 @@ namespace RefreshCS
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_CreateBuffer(
public static extern IntPtr Refresh_CreateGpuBuffer(
IntPtr device,
BufferUsageFlags usageFlags,
uint sizeInBytes
);
/* Setters */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_SetTextureData(
public static extern IntPtr Refresh_CreateTransferBuffer(
IntPtr device,
IntPtr commandBuffer,
in TextureSlice textureSlice,
IntPtr data,
uint dataLengthInBytes
TransferUsage usage,
uint sizeInBytes
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_SetTextureDataYUV(
IntPtr device,
IntPtr commandBuffer,
IntPtr y,
IntPtr u,
IntPtr v,
uint yWidth,
uint yHeight,
uint uvWidth,
uint uvHeight,
IntPtr yDataPtr,
IntPtr uDataPtr,
IntPtr vDataPtr,
uint yDataLength,
uint uvDataLength,
uint yStride,
uint uvStride
);
/* Debug Naming */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_CopyTextureToTexture(
IntPtr device,
IntPtr commandBuffer,
in TextureSlice sourceTextureSlice,
in TextureSlice destinationTextureSlice,
Filter filter
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_CopyTextureToBuffer(
IntPtr device,
IntPtr commandBuffer,
in TextureSlice textureSlice,
IntPtr buffer
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_GetBufferData(
public static extern void Refresh_SetGpuBufferName(
IntPtr device,
IntPtr buffer,
IntPtr data,
uint dataLengthInBytes
[MarshalAs(UnmanagedType.LPUTF8Str)] string text
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_SetBufferData(
public static extern void Refresh_SetTextureName(
IntPtr device,
IntPtr commandBuffer,
IntPtr buffer,
uint offsetInBytes,
IntPtr data,
uint dataLengthInBytes
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint Refresh_PushVertexShaderUniforms(
IntPtr device,
IntPtr commandBuffer,
IntPtr data,
uint dataLengthInBytes
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint Refresh_PushFragmentShaderUniforms(
IntPtr device,
IntPtr commandBuffer,
IntPtr data,
uint dataLengthInBytes
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern uint Refresh_PushComputeShaderUniforms(
IntPtr device,
IntPtr commandBuffer,
IntPtr data,
uint dataLengthInBytes
IntPtr texture,
[MarshalAs(UnmanagedType.LPUTF8Str)] string text
);
/* Disposal */
@ -800,9 +749,15 @@ namespace RefreshCS
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_QueueDestroyBuffer(
public static extern void Refresh_QueueDestroyGpuBuffer(
IntPtr device,
IntPtr buffer
IntPtr gpuBuffer
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_QueueDestroyTransferBuffer(
IntPtr device,
IntPtr transferBuffer
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -843,12 +798,6 @@ namespace RefreshCS
DepthStencilAttachmentInfo* depthStencilAttachmentInfo /* can be NULL */
);
[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,
@ -871,38 +820,92 @@ namespace RefreshCS
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BindVertexBuffers(
public static extern unsafe void Refresh_BindVertexBuffers(
IntPtr device,
IntPtr commandBuffer,
uint firstBinding,
uint bindingCount,
IntPtr pBuffers,
IntPtr pOffsets
BufferBinding* pBindings
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BindIndexBuffer(
IntPtr device,
IntPtr commandBuffer,
IntPtr buffer,
uint offset,
in BufferBinding pBinding,
IndexElementSize indexElementSize
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BindVertexSamplers(
public static extern unsafe void Refresh_BindVertexSamplers(
IntPtr device,
IntPtr commandBuffer,
IntPtr pTextures,
IntPtr pSamplers
TextureSamplerBinding* pBindings
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BindFragmentSamplers(
public static extern unsafe void Refresh_BindFragmentSamplers(
IntPtr device,
IntPtr commandBuffer,
IntPtr pTextures,
IntPtr pSamplers
TextureSamplerBinding* pBindings
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_PushVertexShaderUniforms(
IntPtr device,
IntPtr commandBuffer,
IntPtr data,
uint dataLengthInBytes
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_PushFragmentShaderUniforms(
IntPtr device,
IntPtr commandBuffer,
IntPtr data,
uint dataLengthInBytes
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_DrawInstancedPrimitives(
IntPtr device,
IntPtr commandBuffer,
uint baseVertex,
uint startIndex,
uint primitiveCount,
uint instanceCount
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_DrawPrimitives(
IntPtr device,
IntPtr commandBuffer,
uint vertexStart,
uint primitiveCount
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_DrawPrimitivesIndirect(
IntPtr device,
IntPtr commandBuffer,
IntPtr gpuBuffer,
uint offsetInBytes,
uint drawCount,
uint stride
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_EndRenderPass(
IntPtr device,
IntPtr commandBuffer
);
/* Compute Pass */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BeginComputePass(
IntPtr device,
IntPtr commandBuffer
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -913,17 +916,119 @@ namespace RefreshCS
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BindComputeBuffers(
public static extern unsafe void Refresh_BindComputeBuffers(
IntPtr device,
IntPtr commandBuffer,
IntPtr pBuffers
ComputeBufferBinding* pBindings
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BindComputeTextures(
public static extern unsafe void Refresh_BindComputeTextures(
IntPtr device,
IntPtr commandBuffer,
IntPtr pTextures
ComputeTextureBinding* pBindings
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_PushComputeShaderUniforms(
IntPtr device,
IntPtr commandBuffer,
IntPtr data,
uint dataLengthInBytes
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_DispatchCompute(
IntPtr device,
IntPtr commandBuffer,
uint groupCountX,
uint groupCountY,
uint groupCountZ
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_EndComputePass(
IntPtr device,
IntPtr commandBuffer
);
/* TransferBuffer Set/Get */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_SetTransferData(
IntPtr device,
IntPtr data,
IntPtr transferBuffer,
in BufferCopy copyParams,
TransferOptions option
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_GetTransferData(
IntPtr device,
IntPtr transferBuffer,
IntPtr data,
in BufferCopy copyParams
);
/* Copy Pass */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BeginCopyPass(
IntPtr device,
IntPtr commandBuffer
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_UploadToTexture(
IntPtr device,
IntPtr commandBuffer,
IntPtr transferBuffer,
in TextureRegion textureRegion,
in BufferImageCopy copyParams,
WriteOptions writeOption
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_UploadToBuffer(
IntPtr device,
IntPtr commandBuffer,
IntPtr transferBuffer,
IntPtr gpuBuffer,
in BufferCopy copyParams,
WriteOptions writeOption
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_CopyTextureToTexture(
IntPtr device,
IntPtr commandBuffer,
in TextureRegion source,
in TextureRegion destination,
WriteOptions writeOption
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_CopyBufferToBuffer(
IntPtr device,
IntPtr commandBuffer,
IntPtr source,
IntPtr destination,
in BufferCopy copyParams,
WriteOptions writeOption
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_GenerateMipmaps(
IntPtr device,
IntPtr commandBuffer,
IntPtr texture
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_EndCopyPass(
IntPtr device,
IntPtr commandBuffer
);
/* Submission/Presentation */
@ -1005,6 +1110,24 @@ namespace RefreshCS
IntPtr fence
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_DownloadFromTexture(
IntPtr device,
in TextureRegion textureRegion,
IntPtr transferBuffer,
in BufferImageCopy copyParams,
TransferOptions transferOption
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_DownloadFromBuffer(
IntPtr device,
IntPtr gpuBuffer,
IntPtr transferBuffer,
in BufferCopy copyParams,
TransferOptions transferOption
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_Image_Load(
IntPtr bufferPtr,
@ -1014,6 +1137,15 @@ namespace RefreshCS
out int len
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern byte Refresh_Image_Info(
IntPtr bufferPtr,
int bufferLength,
out int w,
out int h,
out int len
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_Image_Free(IntPtr mem);