Compare commits

..

No commits in common. "refresh2" and "main" have entirely different histories.

2 changed files with 181 additions and 312 deletions

View File

@ -4,6 +4,7 @@
<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 = 2;
public const uint REFRESH_MINOR_VERSION = 0;
public const uint REFRESH_MAJOR_VERSION = 1;
public const uint REFRESH_MINOR_VERSION = 15;
public const uint REFRESH_PATCH_VERSION = 0;
public const uint REFRESH_COMPILED_VERSION = (
@ -308,29 +308,10 @@ 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
}
@ -377,36 +358,10 @@ namespace RefreshCS
public struct TextureSlice
{
public IntPtr texture;
public uint mipLevel;
public Rect rectangle;
public uint depth;
public uint layer;
}
[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;
public uint level;
}
[StructLayout(LayoutKind.Sequential)]
@ -470,6 +425,9 @@ namespace RefreshCS
public StencilOp passOp;
public StencilOp depthFailOp;
public CompareOp compareOp;
public uint compareMask;
public uint writeMask;
public uint reference;
}
[StructLayout(LayoutKind.Sequential)]
@ -499,7 +457,6 @@ namespace RefreshCS
public uint height;
public uint depth;
public byte isCube;
public uint layerCount;
public uint levelCount;
public SampleCount sampleCount;
public TextureFormat format;
@ -512,7 +469,7 @@ namespace RefreshCS
public IntPtr shaderModule;
[MarshalAs(UnmanagedType.LPStr)]
public string entryPointName;
public uint uniformBufferSize;
public ulong uniformBufferSize;
public uint samplerBindingCount;
}
@ -522,7 +479,7 @@ namespace RefreshCS
public IntPtr shaderModule;
[MarshalAs(UnmanagedType.LPStr)]
public string entryPointName;
public uint uniformBufferSize;
public ulong uniformBufferSize;
public uint bufferBindingCount;
public uint imageBindingCount;
}
@ -554,11 +511,8 @@ namespace RefreshCS
public CompareOp compareOp;
public byte depthBoundsTestEnable;
public byte stencilTestEnable;
public StencilOpState backStencilState;
public StencilOpState frontStencilState;
public uint compareMask;
public uint writeMask;
public uint reference;
public StencilOpState backStencilState;
public float minDepthBounds;
public float maxDepthBounds;
}
@ -593,54 +547,28 @@ namespace RefreshCS
public fixed float blendConstants[4];
}
[StructLayout(LayoutKind.Sequential)]
public struct ColorAttachmentInfo
{
public TextureSlice textureSlice;
public IntPtr texture;
public uint depth;
public uint layer;
public uint level;
public Vec4 clearColor;
public LoadOp loadOp;
public StoreOp storeOp;
public WriteOptions writeOption;
}
[StructLayout(LayoutKind.Sequential)]
public struct DepthStencilAttachmentInfo
{
public TextureSlice textureSlice;
public IntPtr texture;
public uint depth;
public uint layer;
public uint level;
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 */
@ -658,9 +586,8 @@ namespace RefreshCS
/* Init/Quit */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static unsafe extern Backend Refresh_SelectBackend(
Backend* preferredBackends,
uint preferredBackendCount,
public static extern Backend Refresh_SelectBackend(
Backend preferredBackend,
out uint flags
);
@ -672,7 +599,64 @@ namespace RefreshCS
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_DestroyDevice(IntPtr device);
/* State Creation */
/* 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 */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_CreateComputePipeline(
@ -705,33 +689,100 @@ namespace RefreshCS
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_CreateGpuBuffer(
public static extern IntPtr Refresh_CreateBuffer(
IntPtr device,
BufferUsageFlags usageFlags,
uint sizeInBytes
);
/* Setters */
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Refresh_CreateTransferBuffer(
public static extern void Refresh_SetTextureData(
IntPtr device,
TransferUsage usage,
uint sizeInBytes
IntPtr commandBuffer,
in TextureSlice textureSlice,
IntPtr data,
uint dataLengthInBytes
);
/* Debug Naming */
[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
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_SetGpuBufferName(
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(
IntPtr device,
IntPtr buffer,
[MarshalAs(UnmanagedType.LPUTF8Str)] string text
IntPtr data,
uint dataLengthInBytes
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_SetTextureName(
public static extern void Refresh_SetBufferData(
IntPtr device,
IntPtr texture,
[MarshalAs(UnmanagedType.LPUTF8Str)] string text
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
);
/* Disposal */
@ -749,15 +800,9 @@ namespace RefreshCS
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_QueueDestroyGpuBuffer(
public static extern void Refresh_QueueDestroyBuffer(
IntPtr device,
IntPtr gpuBuffer
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_QueueDestroyTransferBuffer(
IntPtr device,
IntPtr transferBuffer
IntPtr buffer
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -798,6 +843,12 @@ 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,
@ -820,92 +871,38 @@ namespace RefreshCS
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void Refresh_BindVertexBuffers(
public static extern void Refresh_BindVertexBuffers(
IntPtr device,
IntPtr commandBuffer,
uint firstBinding,
uint bindingCount,
BufferBinding* pBindings
IntPtr pBuffers,
IntPtr pOffsets
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void Refresh_BindIndexBuffer(
IntPtr device,
IntPtr commandBuffer,
in BufferBinding pBinding,
IntPtr buffer,
uint offset,
IndexElementSize indexElementSize
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void Refresh_BindVertexSamplers(
public static extern void Refresh_BindVertexSamplers(
IntPtr device,
IntPtr commandBuffer,
TextureSamplerBinding* pBindings
IntPtr pTextures,
IntPtr pSamplers
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void Refresh_BindFragmentSamplers(
public static extern void Refresh_BindFragmentSamplers(
IntPtr device,
IntPtr commandBuffer,
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
IntPtr pTextures,
IntPtr pSamplers
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@ -916,119 +913,17 @@ namespace RefreshCS
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void Refresh_BindComputeBuffers(
public static extern void Refresh_BindComputeBuffers(
IntPtr device,
IntPtr commandBuffer,
ComputeBufferBinding* pBindings
IntPtr pBuffers
);
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void Refresh_BindComputeTextures(
public static extern void Refresh_BindComputeTextures(
IntPtr device,
IntPtr commandBuffer,
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
IntPtr pTextures
);
/* Submission/Presentation */
@ -1110,24 +1005,6 @@ 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,
@ -1137,15 +1014,6 @@ 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);