diff --git a/bindings/cs/bgfx.cs b/bindings/cs/bgfx.cs
index f8a19b6f88..91dc676886 100644
--- a/bindings/cs/bgfx.cs
+++ b/bindings/cs/bgfx.cs
@@ -530,47 +530,47 @@ public enum ClearFlags : ushort
}
[Flags]
- public enum DiscardFlags : uint
+ public enum DiscardFlags : byte
{
///
/// Preserve everything.
///
- None = 0x00000000,
+ None = 0x00,
///
/// Discard texture sampler and buffer bindings.
///
- Bindings = 0x00000001,
+ Bindings = 0x01,
///
/// Discard index buffer.
///
- IndexBuffer = 0x00000002,
+ IndexBuffer = 0x02,
///
/// Discard instance data.
///
- InstanceData = 0x00000004,
+ InstanceData = 0x04,
///
/// Discard state and uniform bindings.
///
- State = 0x00000008,
+ State = 0x08,
///
/// Discard transform.
///
- Transform = 0x00000010,
+ Transform = 0x10,
///
/// Discard vertex streams.
///
- VertexStreams = 0x00000020,
+ VertexStreams = 0x20,
///
/// Discard all states.
///
- All = 0x000000ff,
+ All = 0xff,
}
[Flags]
@@ -1257,17 +1257,17 @@ public enum CapsFormatFlags : uint
}
[Flags]
- public enum ResolveFlags : uint
+ public enum ResolveFlags : byte
{
///
/// No resolve flags.
///
- None = 0x00000000,
+ None = 0x00,
///
/// Auto-generate mip maps on resolve.
///
- AutoGenMips = 0x00000001,
+ AutoGenMips = 0x01,
}
[Flags]
@@ -1315,37 +1315,37 @@ public enum PciIdFlags : ushort
}
[Flags]
- public enum CubeMapFlags : uint
+ public enum CubeMapFlags : byte
{
///
/// Cubemap +x.
///
- PositiveX = 0x00000000,
+ PositiveX = 0x00,
///
/// Cubemap -x.
///
- NegativeX = 0x00000001,
+ NegativeX = 0x01,
///
/// Cubemap +y.
///
- PositiveY = 0x00000002,
+ PositiveY = 0x02,
///
/// Cubemap -y.
///
- NegativeY = 0x00000003,
+ NegativeY = 0x03,
///
/// Cubemap +z.
///
- PositiveZ = 0x00000004,
+ PositiveZ = 0x04,
///
/// Cubemap -z.
///
- NegativeZ = 0x00000005,
+ NegativeZ = 0x05,
}
public enum Fatal
@@ -2032,306 +2032,576 @@ public enum RenderFrame
Count
}
+ ///
+ /// GPU info.
+ ///
+ ///
public unsafe struct Caps
{
public unsafe struct GPU
{
+ /// Vendor PCI id. See `BGFX_PCI_ID_*`.
public ushort vendorId;
+ /// Device id.
public ushort deviceId;
}
+ ///
+ /// Renderer runtime limits.
+ ///
+ ///
public unsafe struct Limits
{
+ /// Maximum number of draw calls.
public uint maxDrawCalls;
+ /// Maximum number of blit calls.
public uint maxBlits;
+ /// Maximum texture size.
public uint maxTextureSize;
+ /// Maximum texture layers.
public uint maxTextureLayers;
+ /// Maximum number of views.
public uint maxViews;
+ /// Maximum number of frame buffer handles.
public uint maxFrameBuffers;
+ /// Maximum number of frame buffer attachments.
public uint maxFBAttachments;
+ /// Maximum number of program handles.
public uint maxPrograms;
+ /// Maximum number of shader handles.
public uint maxShaders;
+ /// Maximum number of texture handles.
public uint maxTextures;
+ /// Maximum number of texture samplers.
public uint maxTextureSamplers;
+ /// Maximum number of compute bindings.
public uint maxComputeBindings;
+ /// Maximum number of vertex format layouts.
public uint maxVertexLayouts;
+ /// Maximum number of vertex streams.
public uint maxVertexStreams;
+ /// Maximum number of index buffer handles.
public uint maxIndexBuffers;
+ /// Maximum number of vertex buffer handles.
public uint maxVertexBuffers;
+ /// Maximum number of dynamic index buffer handles.
public uint maxDynamicIndexBuffers;
+ /// Maximum number of dynamic vertex buffer handles.
public uint maxDynamicVertexBuffers;
+ /// Maximum number of uniform handles.
public uint maxUniforms;
+ /// Maximum number of occlusion query handles.
public uint maxOcclusionQueries;
+ /// Maximum number of encoder threads.
public uint maxEncoders;
+ /// Minimum resource command buffer size.
public uint minResourceCbSize;
+ /// Maximum transient vertex buffer size.
public uint transientVbSize;
+ /// Maximum transient index buffer size.
public uint transientIbSize;
}
+ ///
+ /// Renderer capabilities.
+ ///
+ ///
+ /// Renderer backend type. See: `bgfx::RendererType`
public RendererType rendererType;
+ /// Supported functionality. @attention See `BGFX_CAPS_*` flags at https://bkaradzic.github.io/bgfx/bgfx.html#available-caps
public ulong supported;
+ /// Selected GPU vendor PCI id.
public ushort vendorId;
+ /// Selected GPU device id.
public ushort deviceId;
+ /// True when NDC depth is in [-1, 1] range, otherwise its [0, 1].
public byte homogeneousDepth;
+ /// True when NDC origin is at bottom left.
public byte originBottomLeft;
+ /// Number of enumerated GPUs.
public byte numGPUs;
+ /// Enumerated GPUs.
public fixed uint gpu[4];
+ /// Renderer runtime limits.
public Limits limits;
+ /// Supported texture format capabilities flags: - `BGFX_CAPS_FORMAT_TEXTURE_NONE` - Texture format is not supported. - `BGFX_CAPS_FORMAT_TEXTURE_2D` - Texture format is supported. - `BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB` - Texture as sRGB format is supported. - `BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED` - Texture format is emulated. - `BGFX_CAPS_FORMAT_TEXTURE_3D` - Texture format is supported. - `BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB` - Texture as sRGB format is supported. - `BGFX_CAPS_FORMAT_TEXTURE_3D_EMULATED` - Texture format is emulated. - `BGFX_CAPS_FORMAT_TEXTURE_CUBE` - Texture format is supported. - `BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB` - Texture as sRGB format is supported. - `BGFX_CAPS_FORMAT_TEXTURE_CUBE_EMULATED` - Texture format is emulated. - `BGFX_CAPS_FORMAT_TEXTURE_VERTEX` - Texture format can be used from vertex shader. - `BGFX_CAPS_FORMAT_TEXTURE_IMAGE_READ` - Texture format can be used as image and read from. - `BGFX_CAPS_FORMAT_TEXTURE_IMAGE_WRITE` - Texture format can be used as image and written to. - `BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER` - Texture format can be used as frame buffer. - `BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER_MSAA` - Texture format can be used as MSAA frame buffer. - `BGFX_CAPS_FORMAT_TEXTURE_MSAA` - Texture can be sampled as MSAA. - `BGFX_CAPS_FORMAT_TEXTURE_MIP_AUTOGEN` - Texture format supports auto-generated mips.
public fixed ushort formats[96];
}
+ ///
+ /// Internal data.
+ ///
+ ///
public unsafe struct InternalData
{
+ /// Renderer capabilities.
public Caps* caps;
+ /// GL context, or D3D device.
public void* context;
}
+ ///
+ /// Platform data.
+ ///
+ ///
public unsafe struct PlatformData
{
+ /// Native display type (*nix specific).
public void* ndt;
+ /// Native window handle. If `NULL`, bgfx will create a headless context/device, provided the rendering API supports it.
public void* nwh;
+ /// GL context, D3D device, or Vulkan device. If `NULL`, bgfx will create context/device.
public void* context;
+ /// GL back-buffer, or D3D render target view. If `NULL` bgfx will create back-buffer color surface.
public void* backBuffer;
+ /// Backbuffer depth/stencil. If `NULL`, bgfx will create a back-buffer depth/stencil surface.
public void* backBufferDS;
+ /// Handle type. Needed for platforms having more than one option.
public NativeWindowHandleType type;
}
+ ///
+ /// Backbuffer resolution and reset parameters.
+ ///
+ ///
public unsafe struct Resolution
{
+ /// Backbuffer format.
public TextureFormat format;
+ /// Backbuffer width.
public uint width;
+ /// Backbuffer height.
public uint height;
+ /// Reset parameters.
public uint reset;
+ /// Number of back buffers.
public byte numBackBuffers;
+ /// Maximum frame latency.
public byte maxFrameLatency;
+ /// Scale factor for debug text.
public byte debugTextScale;
}
+ ///
+ /// Configurable runtime limits parameters.
+ ///
+ ///
public unsafe struct Init
{
public unsafe struct Limits
{
+ /// Maximum number of encoder threads.
public ushort maxEncoders;
+ /// Minimum resource command buffer size.
public uint minResourceCbSize;
+ /// Maximum transient vertex buffer size.
public uint transientVbSize;
+ /// Maximum transient index buffer size.
public uint transientIbSize;
}
+ ///
+ /// Initialization parameters used by `bgfx::init`.
+ ///
+ ///
+ /// Select rendering backend. When set to RendererType::Count a default rendering backend will be selected appropriate to the platform. See: `bgfx::RendererType`
public RendererType type;
+ /// Vendor PCI ID. If set to `BGFX_PCI_ID_NONE`, discrete and integrated GPUs will be prioritised. - `BGFX_PCI_ID_NONE` - Autoselect adapter. - `BGFX_PCI_ID_SOFTWARE_RASTERIZER` - Software rasterizer. - `BGFX_PCI_ID_AMD` - AMD adapter. - `BGFX_PCI_ID_APPLE` - Apple adapter. - `BGFX_PCI_ID_INTEL` - Intel adapter. - `BGFX_PCI_ID_NVIDIA` - NVIDIA adapter. - `BGFX_PCI_ID_MICROSOFT` - Microsoft adapter.
public ushort vendorId;
+ /// Device ID. If set to 0 it will select first device, or device with matching ID.
public ushort deviceId;
+ /// Capabilities initialization mask (default: UINT64_MAX).
public ulong capabilities;
+ /// Enable device for debugging.
public byte debug;
+ /// Enable device for profiling.
public byte profile;
+ /// Platform data.
public PlatformData platformData;
+ /// Backbuffer resolution and reset parameters. See: `bgfx::Resolution`.
public Resolution resolution;
+ /// Configurable runtime limits parameters.
public Limits limits;
+ /// Provide application specific callback interface. See: `bgfx::CallbackI`
public IntPtr callback;
+ /// Custom allocator. When a custom allocator is not specified, bgfx uses the CRT allocator. Bgfx assumes custom allocator is thread safe.
public IntPtr allocator;
}
+ ///
+ /// Memory must be obtained by calling `bgfx::alloc`, `bgfx::copy`, or `bgfx::makeRef`.
+ /// @attention It is illegal to create this structure on stack and pass it to any bgfx API.
+ ///
+ ///
public unsafe struct Memory
{
+ /// Pointer to data.
public byte* data;
+ /// Data size.
public uint size;
}
+ ///
+ /// Transient index buffer.
+ ///
+ ///
public unsafe struct TransientIndexBuffer
{
+ /// Pointer to data.
public byte* data;
+ /// Data size.
public uint size;
+ /// First index.
public uint startIndex;
+ /// Index buffer handle.
public IndexBufferHandle handle;
+ /// Index buffer format is 16-bits if true, otherwise it is 32-bit.
public byte isIndex16;
}
+ ///
+ /// Transient vertex buffer.
+ ///
+ ///
public unsafe struct TransientVertexBuffer
{
+ /// Pointer to data.
public byte* data;
+ /// Data size.
public uint size;
+ /// First vertex.
public uint startVertex;
+ /// Vertex stride.
public ushort stride;
+ /// Vertex buffer handle.
public VertexBufferHandle handle;
+ /// Vertex layout handle.
public VertexLayoutHandle layoutHandle;
}
+ ///
+ /// Instance data buffer info.
+ ///
+ ///
public unsafe struct InstanceDataBuffer
{
+ /// Pointer to data.
public byte* data;
+ /// Data size.
public uint size;
+ /// Offset in vertex buffer.
public uint offset;
+ /// Number of instances.
public uint num;
+ /// Vertex buffer stride.
public ushort stride;
+ /// Vertex buffer object handle.
public VertexBufferHandle handle;
}
+ ///
+ /// Texture info.
+ ///
+ ///
public unsafe struct TextureInfo
{
+ /// Texture format.
public TextureFormat format;
+ /// Total amount of bytes required to store texture.
public uint storageSize;
+ /// Texture width.
public ushort width;
+ /// Texture height.
public ushort height;
+ /// Texture depth.
public ushort depth;
+ /// Number of layers in texture array.
public ushort numLayers;
+ /// Number of MIP maps.
public byte numMips;
+ /// Format bits per pixel.
public byte bitsPerPixel;
+ /// Texture is cubemap.
public byte cubeMap;
}
+ ///
+ /// Uniform info.
+ ///
+ ///
public unsafe struct UniformInfo
{
+ /// Uniform name.
public fixed byte name[256];
+ /// Uniform type.
public UniformType type;
+ /// Number of elements in array.
public ushort num;
}
+ ///
+ /// Frame buffer texture attachment info.
+ ///
+ ///
public unsafe struct Attachment
{
+ /// Attachment access. See `Access::Enum`.
public Access access;
+ /// Render target texture handle.
public TextureHandle handle;
+ /// Mip level.
public ushort mip;
+ /// Cubemap side or depth layer/slice to use.
public ushort layer;
+ /// Number of texture layer/slice(s) in array to use.
public ushort numLayers;
+ /// Resolve flags. See: `BGFX_RESOLVE_*`
public byte resolve;
}
+ ///
+ /// Transform data.
+ ///
+ ///
public unsafe struct Transform
{
+ /// Pointer to first 4x4 matrix.
public float* data;
+ /// Number of matrices.
public ushort num;
}
+ ///
+ /// View stats.
+ ///
+ ///
public unsafe struct ViewStats
{
+ /// View name.
public fixed byte name[256];
+ /// View id.
public ushort view;
+ /// CPU (submit) begin time.
public long cpuTimeBegin;
+ /// CPU (submit) end time.
public long cpuTimeEnd;
+ /// GPU begin time.
public long gpuTimeBegin;
+ /// GPU end time.
public long gpuTimeEnd;
+ /// Frame which generated gpuTimeBegin, gpuTimeEnd.
public uint gpuFrameNum;
}
+ ///
+ /// Encoder stats.
+ ///
+ ///
public unsafe struct EncoderStats
{
+ /// Encoder thread CPU submit begin time.
public long cpuTimeBegin;
+ /// Encoder thread CPU submit end time.
public long cpuTimeEnd;
}
+ ///
+ /// Renderer statistics data.
+ /// @remarks All time values are high-resolution timestamps, while
+ /// time frequencies define timestamps-per-second for that hardware.
+ ///
+ ///
public unsafe struct Stats
{
+ /// CPU time between two `bgfx::frame` calls.
public long cpuTimeFrame;
+ /// Render thread CPU submit begin time.
public long cpuTimeBegin;
+ /// Render thread CPU submit end time.
public long cpuTimeEnd;
+ /// CPU timer frequency. Timestamps-per-second
public long cpuTimerFreq;
+ /// GPU frame begin time.
public long gpuTimeBegin;
+ /// GPU frame end time.
public long gpuTimeEnd;
+ /// GPU timer frequency.
public long gpuTimerFreq;
+ /// Time spent waiting for render backend thread to finish issuing draw commands to underlying graphics API.
public long waitRender;
+ /// Time spent waiting for submit thread to advance to next frame.
public long waitSubmit;
+ /// Number of draw calls submitted.
public uint numDraw;
+ /// Number of compute calls submitted.
public uint numCompute;
+ /// Number of blit calls submitted.
public uint numBlit;
+ /// GPU driver latency.
public uint maxGpuLatency;
+ /// Frame which generated gpuTimeBegin, gpuTimeEnd.
public uint gpuFrameNum;
+ /// Number of used dynamic index buffers.
public ushort numDynamicIndexBuffers;
+ /// Number of used dynamic vertex buffers.
public ushort numDynamicVertexBuffers;
+ /// Number of used frame buffers.
public ushort numFrameBuffers;
+ /// Number of used index buffers.
public ushort numIndexBuffers;
+ /// Number of used occlusion queries.
public ushort numOcclusionQueries;
+ /// Number of used programs.
public ushort numPrograms;
+ /// Number of used shaders.
public ushort numShaders;
+ /// Number of used textures.
public ushort numTextures;
+ /// Number of used uniforms.
public ushort numUniforms;
+ /// Number of used vertex buffers.
public ushort numVertexBuffers;
+ /// Number of used vertex layouts.
public ushort numVertexLayouts;
+ /// Estimate of texture memory used.
public long textureMemoryUsed;
+ /// Estimate of render target memory used.
public long rtMemoryUsed;
+ /// Amount of transient vertex buffer used.
public int transientVbUsed;
+ /// Amount of transient index buffer used.
public int transientIbUsed;
+ /// Number of primitives rendered.
public fixed uint numPrims[5];
+ /// Maximum available GPU memory for application.
public long gpuMemoryMax;
+ /// Amount of GPU memory used by the application.
public long gpuMemoryUsed;
+ /// Backbuffer width in pixels.
public ushort width;
+ /// Backbuffer height in pixels.
public ushort height;
+ /// Debug text width in characters.
public ushort textWidth;
+ /// Debug text height in characters.
public ushort textHeight;
+ /// Number of view stats.
public ushort numViews;
+ /// Array of View stats.
public ViewStats* viewStats;
+ /// Number of encoders used during frame.
public byte numEncoders;
+ /// Array of encoder stats.
public EncoderStats* encoderStats;
}
+ ///
+ /// Vertex layout.
+ ///
+ ///
public unsafe struct VertexLayout
{
+ /// Hash.
public uint hash;
+ /// Stride.
public ushort stride;
+ /// Attribute offsets.
public fixed ushort offset[18];
+ /// Used attributes.
public fixed ushort attributes[18];
}
+ ///
+ /// Encoders are used for submitting draw calls from multiple threads. Only one encoder
+ /// per thread should be used. Use `bgfx::begin()` to obtain an encoder for a thread.
+ ///
+ ///
public unsafe struct Encoder
{
}
public struct DynamicIndexBufferHandle {
- public ushort idx;
- public bool Valid => idx != UInt16.MaxValue;
+ public ushort idx;
+ public static readonly DynamicIndexBufferHandle Invalid = new DynamicIndexBufferHandle(ushort.MaxValue);
+ public DynamicIndexBufferHandle(ushort index) => idx = index;
+ public bool Valid => this.idx != Invalid.idx;
}
public struct DynamicVertexBufferHandle {
- public ushort idx;
- public bool Valid => idx != UInt16.MaxValue;
+ public ushort idx;
+ public static readonly DynamicVertexBufferHandle Invalid = new DynamicVertexBufferHandle(ushort.MaxValue);
+ public DynamicVertexBufferHandle(ushort index) => idx = index;
+ public bool Valid => this.idx != Invalid.idx;
}
public struct FrameBufferHandle {
- public ushort idx;
- public bool Valid => idx != UInt16.MaxValue;
+ public ushort idx;
+ public static readonly FrameBufferHandle Invalid = new FrameBufferHandle(ushort.MaxValue);
+ public FrameBufferHandle(ushort index) => idx = index;
+ public bool Valid => this.idx != Invalid.idx;
}
public struct IndexBufferHandle {
- public ushort idx;
- public bool Valid => idx != UInt16.MaxValue;
+ public ushort idx;
+ public static readonly IndexBufferHandle Invalid = new IndexBufferHandle(ushort.MaxValue);
+ public IndexBufferHandle(ushort index) => idx = index;
+ public bool Valid => this.idx != Invalid.idx;
}
public struct IndirectBufferHandle {
- public ushort idx;
- public bool Valid => idx != UInt16.MaxValue;
+ public ushort idx;
+ public static readonly IndirectBufferHandle Invalid = new IndirectBufferHandle(ushort.MaxValue);
+ public IndirectBufferHandle(ushort index) => idx = index;
+ public bool Valid => this.idx != Invalid.idx;
}
public struct OcclusionQueryHandle {
- public ushort idx;
- public bool Valid => idx != UInt16.MaxValue;
+ public ushort idx;
+ public static readonly OcclusionQueryHandle Invalid = new OcclusionQueryHandle(ushort.MaxValue);
+ public OcclusionQueryHandle(ushort index) => idx = index;
+ public bool Valid => this.idx != Invalid.idx;
}
public struct ProgramHandle {
- public ushort idx;
- public bool Valid => idx != UInt16.MaxValue;
+ public ushort idx;
+ public static readonly ProgramHandle Invalid = new ProgramHandle(ushort.MaxValue);
+ public ProgramHandle(ushort index) => idx = index;
+ public bool Valid => this.idx != Invalid.idx;
}
public struct ShaderHandle {
- public ushort idx;
- public bool Valid => idx != UInt16.MaxValue;
+ public ushort idx;
+ public static readonly ShaderHandle Invalid = new ShaderHandle(ushort.MaxValue);
+ public ShaderHandle(ushort index) => idx = index;
+ public bool Valid => this.idx != Invalid.idx;
}
public struct TextureHandle {
- public ushort idx;
- public bool Valid => idx != UInt16.MaxValue;
+ public ushort idx;
+ public static readonly TextureHandle Invalid = new TextureHandle(ushort.MaxValue);
+ public TextureHandle(ushort index) => idx = index;
+ public bool Valid => this.idx != Invalid.idx;
}
public struct UniformHandle {
- public ushort idx;
- public bool Valid => idx != UInt16.MaxValue;
+ public ushort idx;
+ public static readonly UniformHandle Invalid = new UniformHandle(ushort.MaxValue);
+ public UniformHandle(ushort index) => idx = index;
+ public bool Valid => this.idx != Invalid.idx;
}
public struct VertexBufferHandle {
- public ushort idx;
- public bool Valid => idx != UInt16.MaxValue;
+ public ushort idx;
+ public static readonly VertexBufferHandle Invalid = new VertexBufferHandle(ushort.MaxValue);
+ public VertexBufferHandle(ushort index) => idx = index;
+ public bool Valid => this.idx != Invalid.idx;
}
public struct VertexLayoutHandle {
- public ushort idx;
- public bool Valid => idx != UInt16.MaxValue;
+ public ushort idx;
+ public static readonly VertexLayoutHandle Invalid = new VertexLayoutHandle(ushort.MaxValue);
+ public VertexLayoutHandle(ushort index) => idx = index;
+ public bool Valid => this.idx != Invalid.idx;
}
@@ -2347,7 +2617,7 @@ public struct VertexLayoutHandle {
/// Resolve flags. See: `BGFX_RESOLVE_*`
///
[DllImport(DllName, EntryPoint="bgfx_attachment_init", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void attachment_init(Attachment* _this, TextureHandle _handle, Access _access, ushort _layer, ushort _numLayers, ushort _mip, byte _resolve);
+ public static extern unsafe void attachment_init(Attachment* _this, TextureHandle _handle, Access _access = Access.Write, ushort _layer = 0, ushort _numLayers = 1, ushort _mip = 0, byte _resolve = (byte)ResolveFlags.AutoGenMips);
///
/// Start VertexLayout.
@@ -2356,7 +2626,7 @@ public struct VertexLayoutHandle {
/// Renderer backend type. See: `bgfx::RendererType`
///
[DllImport(DllName, EntryPoint="bgfx_vertex_layout_begin", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe VertexLayout* vertex_layout_begin(VertexLayout* _this, RendererType _rendererType);
+ public static extern unsafe VertexLayout* vertex_layout_begin(VertexLayout* _this, RendererType _rendererType = RendererType.Noop);
///
/// Add attribute to VertexLayout.
@@ -2370,7 +2640,7 @@ public struct VertexLayoutHandle {
/// Packaging rule for vertexPack, vertexUnpack, and vertexConvert for AttribType::Uint8 and AttribType::Int16. Unpacking code must be implemented inside vertex shader.
///
[DllImport(DllName, EntryPoint="bgfx_vertex_layout_add", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe VertexLayout* vertex_layout_add(VertexLayout* _this, Attrib _attrib, byte _num, AttribType _type, bool _normalized, bool _asInt);
+ public static extern unsafe VertexLayout* vertex_layout_add(VertexLayout* _this, Attrib _attrib, byte _num, AttribType _type, bool _normalized = false, bool _asInt = false);
///
/// Decode attribute.
@@ -2423,7 +2693,7 @@ public struct VertexLayoutHandle {
/// Vertex index that will be modified.
///
[DllImport(DllName, EntryPoint="bgfx_vertex_pack", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void vertex_pack(float _input, bool _inputNormalized, Attrib _attr, VertexLayout* _layout, void* _data, uint _index);
+ public static extern unsafe void vertex_pack(float _input, bool _inputNormalized, Attrib _attr, VertexLayout* _layout, void* _data, uint _index = 0);
///
/// Unpack vertex attribute from vertex stream format.
@@ -2436,7 +2706,7 @@ public struct VertexLayoutHandle {
/// Vertex index that will be unpacked.
///
[DllImport(DllName, EntryPoint="bgfx_vertex_unpack", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void vertex_unpack(float _output, Attrib _attr, VertexLayout* _layout, void* _data, uint _index);
+ public static extern unsafe void vertex_unpack(float _output, Attrib _attr, VertexLayout* _layout, void* _data, uint _index = 0);
///
/// Converts vertex stream data from one vertex stream format to another.
@@ -2449,7 +2719,7 @@ public struct VertexLayoutHandle {
/// Number of vertices to convert from source to destination.
///
[DllImport(DllName, EntryPoint="bgfx_vertex_convert", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void vertex_convert(VertexLayout* _dstLayout, void* _dstData, VertexLayout* _srcLayout, void* _srcData, uint _num);
+ public static extern unsafe void vertex_convert(VertexLayout* _dstLayout, void* _dstData, VertexLayout* _srcLayout, void* _srcData, uint _num = 1);
///
/// Weld vertices.
@@ -2463,7 +2733,7 @@ public struct VertexLayoutHandle {
/// Error tolerance for vertex position comparison.
///
[DllImport(DllName, EntryPoint="bgfx_weld_vertices", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe uint weld_vertices(void* _output, VertexLayout* _layout, void* _data, uint _num, bool _index32, float _epsilon);
+ public static extern unsafe uint weld_vertices(void* _output, VertexLayout* _layout, void* _data, uint _num, bool _index32, float _epsilon = 0.001f);
///
/// Convert index buffer for use with different primitive topologies.
@@ -2505,7 +2775,7 @@ public struct VertexLayoutHandle {
/// Array where supported renderers will be written.
///
[DllImport(DllName, EntryPoint="bgfx_get_supported_renderers", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe byte get_supported_renderers(byte _max, RendererType* _enum);
+ public static extern unsafe byte get_supported_renderers(byte _max = 0, RendererType* _enum = default);
///
/// Returns name of renderer.
@@ -2554,7 +2824,7 @@ public struct VertexLayoutHandle {
/// Texture format. See: `TextureFormat::Enum`.
///
[DllImport(DllName, EntryPoint="bgfx_reset", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void reset(uint _width, uint _height, uint _flags, TextureFormat _format);
+ public static extern unsafe void reset(uint _width, uint _height, uint _flags = (uint)ResetFlags.None, TextureFormat _format = TextureFormat.Count);
///
/// Advance to next frame. When using multithreaded renderer, this call
@@ -2565,7 +2835,7 @@ public struct VertexLayoutHandle {
/// Capture frame with graphics debugger.
///
[DllImport(DllName, EntryPoint="bgfx_frame", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe uint frame(bool _capture);
+ public static extern unsafe uint frame(bool _capture = false);
///
/// Returns current renderer backend API type.
@@ -2644,7 +2914,7 @@ public struct VertexLayoutHandle {
/// User data to be passed to callback function.
///
[DllImport(DllName, EntryPoint="bgfx_make_ref_release", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe Memory* make_ref_release(void* _data, uint _size, IntPtr _releaseFn, void* _userData);
+ public static extern unsafe Memory* make_ref_release(void* _data, uint _size, IntPtr _releaseFn = default, void* _userData = default);
///
/// Set debug flags.
@@ -2663,7 +2933,7 @@ public struct VertexLayoutHandle {
/// Default 8x16 or 8x8 font.
///
[DllImport(DllName, EntryPoint="bgfx_dbg_text_clear", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void dbg_text_clear(byte _attr, bool _small);
+ public static extern unsafe void dbg_text_clear(byte _attr = 0, bool _small = false);
///
/// Print formatted data to internal debug text character-buffer (VGA-compatible text mode).
@@ -2712,7 +2982,7 @@ public struct VertexLayoutHandle {
/// Buffer creation flags. - `BGFX_BUFFER_NONE` - No flags. - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers.
///
[DllImport(DllName, EntryPoint="bgfx_create_index_buffer", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe IndexBufferHandle create_index_buffer(Memory* _mem, ushort _flags);
+ public static extern unsafe IndexBufferHandle create_index_buffer(Memory* _mem, ushort _flags = (ushort)BufferFlags.None);
///
/// Set static index buffer debug name.
@@ -2723,7 +2993,7 @@ public struct VertexLayoutHandle {
/// Static index buffer name length (if length is INT32_MAX, it's expected that _name is zero terminated string.
///
[DllImport(DllName, EntryPoint="bgfx_set_index_buffer_name", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_index_buffer_name(IndexBufferHandle _handle, [MarshalAs(UnmanagedType.LPStr)] string _name, int _len);
+ public static extern unsafe void set_index_buffer_name(IndexBufferHandle _handle, [MarshalAs(UnmanagedType.LPStr)] string _name, int _len = int.MaxValue);
///
/// Destroy static index buffer.
@@ -2761,7 +3031,7 @@ public struct VertexLayoutHandle {
/// Buffer creation flags. - `BGFX_BUFFER_NONE` - No flags. - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers.
///
[DllImport(DllName, EntryPoint="bgfx_create_vertex_buffer", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe VertexBufferHandle create_vertex_buffer(Memory* _mem, VertexLayout* _layout, ushort _flags);
+ public static extern unsafe VertexBufferHandle create_vertex_buffer(Memory* _mem, VertexLayout* _layout, ushort _flags = (ushort)BufferFlags.None);
///
/// Set static vertex buffer debug name.
@@ -2772,7 +3042,7 @@ public struct VertexLayoutHandle {
/// Static vertex buffer name length (if length is INT32_MAX, it's expected that _name is zero terminated string.
///
[DllImport(DllName, EntryPoint="bgfx_set_vertex_buffer_name", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_vertex_buffer_name(VertexBufferHandle _handle, [MarshalAs(UnmanagedType.LPStr)] string _name, int _len);
+ public static extern unsafe void set_vertex_buffer_name(VertexBufferHandle _handle, [MarshalAs(UnmanagedType.LPStr)] string _name, int _len = int.MaxValue);
///
/// Destroy static vertex buffer.
@@ -2791,7 +3061,7 @@ public struct VertexLayoutHandle {
/// Buffer creation flags. - `BGFX_BUFFER_NONE` - No flags. - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers.
///
[DllImport(DllName, EntryPoint="bgfx_create_dynamic_index_buffer", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe DynamicIndexBufferHandle create_dynamic_index_buffer(uint _num, ushort _flags);
+ public static extern unsafe DynamicIndexBufferHandle create_dynamic_index_buffer(uint _num, ushort _flags = (ushort)BufferFlags.None);
///
/// Create a dynamic index buffer and initialize it.
@@ -2801,7 +3071,7 @@ public struct VertexLayoutHandle {
/// Buffer creation flags. - `BGFX_BUFFER_NONE` - No flags. - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers.
///
[DllImport(DllName, EntryPoint="bgfx_create_dynamic_index_buffer_mem", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe DynamicIndexBufferHandle create_dynamic_index_buffer_mem(Memory* _mem, ushort _flags);
+ public static extern unsafe DynamicIndexBufferHandle create_dynamic_index_buffer_mem(Memory* _mem, ushort _flags = (ushort)BufferFlags.None);
///
/// Update dynamic index buffer.
@@ -2832,7 +3102,7 @@ public struct VertexLayoutHandle {
/// Buffer creation flags. - `BGFX_BUFFER_NONE` - No flags. - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers.
///
[DllImport(DllName, EntryPoint="bgfx_create_dynamic_vertex_buffer", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe DynamicVertexBufferHandle create_dynamic_vertex_buffer(uint _num, VertexLayout* _layout, ushort _flags);
+ public static extern unsafe DynamicVertexBufferHandle create_dynamic_vertex_buffer(uint _num, VertexLayout* _layout, ushort _flags = (ushort)BufferFlags.None);
///
/// Create dynamic vertex buffer and initialize it.
@@ -2843,7 +3113,7 @@ public struct VertexLayoutHandle {
/// Buffer creation flags. - `BGFX_BUFFER_NONE` - No flags. - `BGFX_BUFFER_COMPUTE_READ` - Buffer will be read from by compute shader. - `BGFX_BUFFER_COMPUTE_WRITE` - Buffer will be written into by compute shader. When buffer is created with `BGFX_BUFFER_COMPUTE_WRITE` flag it cannot be updated from CPU. - `BGFX_BUFFER_COMPUTE_READ_WRITE` - Buffer will be used for read/write by compute shader. - `BGFX_BUFFER_ALLOW_RESIZE` - Buffer will resize on buffer update if a different amount of data is passed. If this flag is not specified, and more data is passed on update, the buffer will be trimmed to fit the existing buffer size. This flag has effect only on dynamic buffers. - `BGFX_BUFFER_INDEX32` - Buffer is using 32-bit indices. This flag has effect only on index buffers.
///
[DllImport(DllName, EntryPoint="bgfx_create_dynamic_vertex_buffer_mem", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe DynamicVertexBufferHandle create_dynamic_vertex_buffer_mem(Memory* _mem, VertexLayout* _layout, ushort _flags);
+ public static extern unsafe DynamicVertexBufferHandle create_dynamic_vertex_buffer_mem(Memory* _mem, VertexLayout* _layout, ushort _flags = (ushort)BufferFlags.None);
///
/// Update dynamic vertex buffer.
@@ -2873,7 +3143,7 @@ public struct VertexLayoutHandle {
/// Set to `true` if input indices will be 32-bit.
///
[DllImport(DllName, EntryPoint="bgfx_get_avail_transient_index_buffer", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe uint get_avail_transient_index_buffer(uint _num, bool _index32);
+ public static extern unsafe uint get_avail_transient_index_buffer(uint _num, bool _index32 = false);
///
/// Returns number of requested or maximum available vertices.
@@ -2904,7 +3174,7 @@ public struct VertexLayoutHandle {
/// Set to `true` if input indices will be 32-bit.
///
[DllImport(DllName, EntryPoint="bgfx_alloc_transient_index_buffer", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void alloc_transient_index_buffer(TransientIndexBuffer* _tib, uint _num, bool _index32);
+ public static extern unsafe void alloc_transient_index_buffer(TransientIndexBuffer* _tib, uint _num, bool _index32 = false);
///
/// Allocate transient vertex buffer.
@@ -2932,7 +3202,7 @@ public struct VertexLayoutHandle {
///
[DllImport(DllName, EntryPoint="bgfx_alloc_transient_buffers", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
- public static extern unsafe bool alloc_transient_buffers(TransientVertexBuffer* _tvb, VertexLayout* _layout, uint _numVertices, TransientIndexBuffer* _tib, uint _numIndices, bool _index32);
+ public static extern unsafe bool alloc_transient_buffers(TransientVertexBuffer* _tvb, VertexLayout* _layout, uint _numVertices, TransientIndexBuffer* _tib, uint _numIndices, bool _index32 = false);
///
/// Allocate instance data buffer.
@@ -2985,7 +3255,7 @@ public struct VertexLayoutHandle {
/// Maximum capacity of array.
///
[DllImport(DllName, EntryPoint="bgfx_get_shader_uniforms", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe ushort get_shader_uniforms(ShaderHandle _handle, UniformHandle* _uniforms, ushort _max);
+ public static extern unsafe ushort get_shader_uniforms(ShaderHandle _handle, UniformHandle* _uniforms = default, ushort _max = 0);
///
/// Set shader debug name.
@@ -2996,7 +3266,7 @@ public struct VertexLayoutHandle {
/// Shader name length (if length is INT32_MAX, it's expected that _name is zero terminated string).
///
[DllImport(DllName, EntryPoint="bgfx_set_shader_name", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_shader_name(ShaderHandle _handle, [MarshalAs(UnmanagedType.LPStr)] string _name, int _len);
+ public static extern unsafe void set_shader_name(ShaderHandle _handle, [MarshalAs(UnmanagedType.LPStr)] string _name, int _len = int.MaxValue);
///
/// Destroy shader.
@@ -3018,7 +3288,7 @@ public struct VertexLayoutHandle {
/// If true, shaders will be destroyed when program is destroyed.
///
[DllImport(DllName, EntryPoint="bgfx_create_program", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe ProgramHandle create_program(ShaderHandle _vsh, ShaderHandle _fsh, bool _destroyShaders);
+ public static extern unsafe ProgramHandle create_program(ShaderHandle _vsh, ShaderHandle _fsh, bool _destroyShaders = false);
///
/// Create program with compute shader.
@@ -3028,7 +3298,7 @@ public struct VertexLayoutHandle {
/// If true, shaders will be destroyed when program is destroyed.
///
[DllImport(DllName, EntryPoint="bgfx_create_compute_program", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe ProgramHandle create_compute_program(ShaderHandle _csh, bool _destroyShaders);
+ public static extern unsafe ProgramHandle create_compute_program(ShaderHandle _csh, bool _destroyShaders = false);
///
/// Destroy program.
@@ -3090,7 +3360,7 @@ public struct VertexLayoutHandle {
/// When non-`NULL` is specified it returns parsed texture information.
///
[DllImport(DllName, EntryPoint="bgfx_create_texture", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe TextureHandle create_texture(Memory* _mem, ulong _flags, byte _skip, TextureInfo* _info);
+ public static extern unsafe TextureHandle create_texture(Memory* _mem, ulong _flags, byte _skip = 0, TextureInfo* _info = default);
///
/// Create 2D texture.
@@ -3105,7 +3375,7 @@ public struct VertexLayoutHandle {
/// Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.
///
[DllImport(DllName, EntryPoint="bgfx_create_texture_2d", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe TextureHandle create_texture_2d(ushort _width, ushort _height, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags, Memory* _mem);
+ public static extern unsafe TextureHandle create_texture_2d(ushort _width, ushort _height, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags, Memory* _mem = default);
///
/// Create texture with size based on back-buffer ratio. Texture will maintain ratio
@@ -3119,7 +3389,7 @@ public struct VertexLayoutHandle {
/// Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.
///
[DllImport(DllName, EntryPoint="bgfx_create_texture_2d_scaled", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe TextureHandle create_texture_2d_scaled(BackbufferRatio _ratio, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags);
+ public static extern unsafe TextureHandle create_texture_2d_scaled(BackbufferRatio _ratio, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags = (ulong)TextureFlags.None|(ulong)SamplerFlags.None);
///
/// Create 3D texture.
@@ -3134,7 +3404,7 @@ public struct VertexLayoutHandle {
/// Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.
///
[DllImport(DllName, EntryPoint="bgfx_create_texture_3d", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe TextureHandle create_texture_3d(ushort _width, ushort _height, ushort _depth, bool _hasMips, TextureFormat _format, ulong _flags, Memory* _mem);
+ public static extern unsafe TextureHandle create_texture_3d(ushort _width, ushort _height, ushort _depth, bool _hasMips, TextureFormat _format, ulong _flags = (ulong)TextureFlags.None|(ulong)SamplerFlags.None, Memory* _mem = default);
///
/// Create Cube texture.
@@ -3148,7 +3418,7 @@ public struct VertexLayoutHandle {
/// Texture data. If `_mem` is non-NULL, created texture will be immutable. If `_mem` is NULL content of the texture is uninitialized. When `_numLayers` is more than 1, expected memory layout is texture and all mips together for each array element.
///
[DllImport(DllName, EntryPoint="bgfx_create_texture_cube", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe TextureHandle create_texture_cube(ushort _size, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags, Memory* _mem);
+ public static extern unsafe TextureHandle create_texture_cube(ushort _size, bool _hasMips, ushort _numLayers, TextureFormat _format, ulong _flags = (ulong)TextureFlags.None|(ulong)SamplerFlags.None, Memory* _mem = default);
///
/// Update 2D texture.
@@ -3166,7 +3436,7 @@ public struct VertexLayoutHandle {
/// Pitch of input image (bytes). When _pitch is set to UINT16_MAX, it will be calculated internally based on _width.
///
[DllImport(DllName, EntryPoint="bgfx_update_texture_2d", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void update_texture_2d(TextureHandle _handle, ushort _layer, byte _mip, ushort _x, ushort _y, ushort _width, ushort _height, Memory* _mem, ushort _pitch);
+ public static extern unsafe void update_texture_2d(TextureHandle _handle, ushort _layer, byte _mip, ushort _x, ushort _y, ushort _width, ushort _height, Memory* _mem, ushort _pitch = ushort.MaxValue);
///
/// Update 3D texture.
@@ -3203,7 +3473,7 @@ public struct VertexLayoutHandle {
/// Pitch of input image (bytes). When _pitch is set to UINT16_MAX, it will be calculated internally based on _width.
///
[DllImport(DllName, EntryPoint="bgfx_update_texture_cube", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void update_texture_cube(TextureHandle _handle, ushort _layer, byte _side, byte _mip, ushort _x, ushort _y, ushort _width, ushort _height, Memory* _mem, ushort _pitch);
+ public static extern unsafe void update_texture_cube(TextureHandle _handle, ushort _layer, byte _side, byte _mip, ushort _x, ushort _y, ushort _width, ushort _height, Memory* _mem, ushort _pitch = ushort.MaxValue);
///
/// Read back texture content.
@@ -3216,7 +3486,7 @@ public struct VertexLayoutHandle {
/// Mip level.
///
[DllImport(DllName, EntryPoint="bgfx_read_texture", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe uint read_texture(TextureHandle _handle, void* _data, byte _mip);
+ public static extern unsafe uint read_texture(TextureHandle _handle, void* _data, byte _mip = 0);
///
/// Set texture debug name.
@@ -3227,7 +3497,7 @@ public struct VertexLayoutHandle {
/// Texture name length (if length is INT32_MAX, it's expected that _name is zero terminated string.
///
[DllImport(DllName, EntryPoint="bgfx_set_texture_name", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_texture_name(TextureHandle _handle, [MarshalAs(UnmanagedType.LPStr)] string _name, int _len);
+ public static extern unsafe void set_texture_name(TextureHandle _handle, [MarshalAs(UnmanagedType.LPStr)] string _name, int _len = int.MaxValue);
///
/// Returns texture direct access pointer.
@@ -3259,7 +3529,7 @@ public struct VertexLayoutHandle {
/// Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.
///
[DllImport(DllName, EntryPoint="bgfx_create_frame_buffer", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe FrameBufferHandle create_frame_buffer(ushort _width, ushort _height, TextureFormat _format, ulong _textureFlags);
+ public static extern unsafe FrameBufferHandle create_frame_buffer(ushort _width, ushort _height, TextureFormat _format, ulong _textureFlags = (ulong)SamplerFlags.UClamp|(ulong)SamplerFlags.VClamp);
///
/// Create frame buffer with size based on back-buffer ratio. Frame buffer will maintain ratio
@@ -3271,7 +3541,7 @@ public struct VertexLayoutHandle {
/// Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.
///
[DllImport(DllName, EntryPoint="bgfx_create_frame_buffer_scaled", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe FrameBufferHandle create_frame_buffer_scaled(BackbufferRatio _ratio, TextureFormat _format, ulong _textureFlags);
+ public static extern unsafe FrameBufferHandle create_frame_buffer_scaled(BackbufferRatio _ratio, TextureFormat _format, ulong _textureFlags = (ulong)SamplerFlags.UClamp|(ulong)SamplerFlags.VClamp);
///
/// Create MRT frame buffer from texture handles (simple).
@@ -3282,7 +3552,7 @@ public struct VertexLayoutHandle {
/// If true, textures will be destroyed when frame buffer is destroyed.
///
[DllImport(DllName, EntryPoint="bgfx_create_frame_buffer_from_handles", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe FrameBufferHandle create_frame_buffer_from_handles(byte _num, TextureHandle* _handles, bool _destroyTexture);
+ public static extern unsafe FrameBufferHandle create_frame_buffer_from_handles(byte _num, TextureHandle* _handles, bool _destroyTexture = false);
///
/// Create MRT frame buffer from texture handles with specific layer and
@@ -3294,7 +3564,7 @@ public struct VertexLayoutHandle {
/// If true, textures will be destroyed when frame buffer is destroyed.
///
[DllImport(DllName, EntryPoint="bgfx_create_frame_buffer_from_attachment", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe FrameBufferHandle create_frame_buffer_from_attachment(byte _num, Attachment* _attachment, bool _destroyTexture);
+ public static extern unsafe FrameBufferHandle create_frame_buffer_from_attachment(byte _num, Attachment* _attachment, bool _destroyTexture = false);
///
/// Create frame buffer for multiple window rendering.
@@ -3310,7 +3580,7 @@ public struct VertexLayoutHandle {
/// Window back buffer depth format.
///
[DllImport(DllName, EntryPoint="bgfx_create_frame_buffer_from_nwh", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe FrameBufferHandle create_frame_buffer_from_nwh(void* _nwh, ushort _width, ushort _height, TextureFormat _format, TextureFormat _depthFormat);
+ public static extern unsafe FrameBufferHandle create_frame_buffer_from_nwh(void* _nwh, ushort _width, ushort _height, TextureFormat _format = TextureFormat.Count, TextureFormat _depthFormat = TextureFormat.Count);
///
/// Set frame buffer debug name.
@@ -3321,7 +3591,7 @@ public struct VertexLayoutHandle {
/// Frame buffer name length (if length is INT32_MAX, it's expected that _name is zero terminated string.
///
[DllImport(DllName, EntryPoint="bgfx_set_frame_buffer_name", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_frame_buffer_name(FrameBufferHandle _handle, [MarshalAs(UnmanagedType.LPStr)] string _name, int _len);
+ public static extern unsafe void set_frame_buffer_name(FrameBufferHandle _handle, [MarshalAs(UnmanagedType.LPStr)] string _name, int _len = int.MaxValue);
///
/// Obtain texture handle of frame buffer attachment.
@@ -3330,7 +3600,7 @@ public struct VertexLayoutHandle {
/// Frame buffer handle.
///
[DllImport(DllName, EntryPoint="bgfx_get_texture", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe TextureHandle get_texture(FrameBufferHandle _handle, byte _attachment);
+ public static extern unsafe TextureHandle get_texture(FrameBufferHandle _handle, byte _attachment = 0);
///
/// Destroy frame buffer.
@@ -3372,7 +3642,7 @@ public struct VertexLayoutHandle {
/// Number of elements in array.
///
[DllImport(DllName, EntryPoint="bgfx_create_uniform", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe UniformHandle create_uniform([MarshalAs(UnmanagedType.LPStr)] string _name, UniformType _type, ushort _num);
+ public static extern unsafe UniformHandle create_uniform([MarshalAs(UnmanagedType.LPStr)] string _name, UniformType _type, ushort _num = 1);
///
/// Retrieve uniform info.
@@ -3408,7 +3678,7 @@ public struct VertexLayoutHandle {
/// Number of pixels that passed test. This argument can be `NULL` if result of occlusion query is not needed.
///
[DllImport(DllName, EntryPoint="bgfx_get_result", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe OcclusionQueryResult get_result(OcclusionQueryHandle _handle, int* _result);
+ public static extern unsafe OcclusionQueryResult get_result(OcclusionQueryHandle _handle, int* _result = default);
///
/// Destroy occlusion query.
@@ -3493,7 +3763,7 @@ public struct VertexLayoutHandle {
/// Height of view scissor region.
///
[DllImport(DllName, EntryPoint="bgfx_set_view_scissor", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_view_scissor(ushort _id, ushort _x, ushort _y, ushort _width, ushort _height);
+ public static extern unsafe void set_view_scissor(ushort _id, ushort _x = 0, ushort _y = 0, ushort _width = 0, ushort _height = 0);
///
/// Set view clear flags.
@@ -3506,7 +3776,7 @@ public struct VertexLayoutHandle {
/// Stencil clear value.
///
[DllImport(DllName, EntryPoint="bgfx_set_view_clear", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_view_clear(ushort _id, ushort _flags, uint _rgba, float _depth, byte _stencil);
+ public static extern unsafe void set_view_clear(ushort _id, ushort _flags, uint _rgba = 0x000000ff, float _depth = 1.0f, byte _stencil = 0);
///
/// Set view clear flags with different clear color for each
@@ -3528,7 +3798,7 @@ public struct VertexLayoutHandle {
/// Palette index for frame buffer attachment 7.
///
[DllImport(DllName, EntryPoint="bgfx_set_view_clear_mrt", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_view_clear_mrt(ushort _id, ushort _flags, float _depth, byte _stencil, byte _c0, byte _c1, byte _c2, byte _c3, byte _c4, byte _c5, byte _c6, byte _c7);
+ public static extern unsafe void set_view_clear_mrt(ushort _id, ushort _flags, float _depth, byte _stencil, byte _c0 = byte.MaxValue, byte _c1 = byte.MaxValue, byte _c2 = byte.MaxValue, byte _c3 = byte.MaxValue, byte _c4 = byte.MaxValue, byte _c5 = byte.MaxValue, byte _c6 = byte.MaxValue, byte _c7 = byte.MaxValue);
///
/// Set view sorting mode.
@@ -3540,7 +3810,7 @@ public struct VertexLayoutHandle {
/// View sort mode. See `ViewMode::Enum`.
///
[DllImport(DllName, EntryPoint="bgfx_set_view_mode", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_view_mode(ushort _id, ViewMode _mode);
+ public static extern unsafe void set_view_mode(ushort _id, ViewMode _mode = ViewMode.Default);
///
/// Set view frame buffer.
@@ -3575,7 +3845,7 @@ public struct VertexLayoutHandle {
/// View remap id table. Passing `NULL` will reset view ids to default state.
///
[DllImport(DllName, EntryPoint="bgfx_set_view_order", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_view_order(ushort _id, ushort _num, ushort* _order);
+ public static extern unsafe void set_view_order(ushort _id = 0, ushort _num = ushort.MaxValue, ushort* _order = default);
///
/// Reset all view settings to default.
@@ -3591,7 +3861,7 @@ public struct VertexLayoutHandle {
/// Explicitly request an encoder for a worker thread.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_begin", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe Encoder* encoder_begin(bool _forThread);
+ public static extern unsafe Encoder* encoder_begin(bool _forThread = false);
///
/// End submitting draw calls from thread.
@@ -3630,7 +3900,7 @@ public struct VertexLayoutHandle {
/// Sets blend factor used by `BGFX_STATE_BLEND_FACTOR` and `BGFX_STATE_BLEND_INV_FACTOR` blend modes.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_set_state", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void encoder_set_state(Encoder* _this, ulong _state, uint _rgba);
+ public static extern unsafe void encoder_set_state(Encoder* _this, ulong _state, uint _rgba = 0);
///
/// Set condition for rendering.
@@ -3650,7 +3920,7 @@ public struct VertexLayoutHandle {
/// Back stencil state. If back is set to `BGFX_STENCIL_NONE` _fstencil is applied to both front and back facing primitives.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_set_stencil", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void encoder_set_stencil(Encoder* _this, uint _fstencil, uint _bstencil);
+ public static extern unsafe void encoder_set_stencil(Encoder* _this, uint _fstencil, uint _bstencil = (uint)StencilFlags.None);
///
/// Set scissor for draw primitive.
@@ -3675,7 +3945,7 @@ public struct VertexLayoutHandle {
/// Index in scissor cache.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_set_scissor_cached", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void encoder_set_scissor_cached(Encoder* _this, ushort _cache);
+ public static extern unsafe void encoder_set_scissor_cached(Encoder* _this, ushort _cache = ushort.MaxValue);
///
/// Set model matrix for draw primitive. If it is not called,
@@ -3686,7 +3956,7 @@ public struct VertexLayoutHandle {
/// Number of matrices in array.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_set_transform", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe uint encoder_set_transform(Encoder* _this, void* _mtx, ushort _num);
+ public static extern unsafe uint encoder_set_transform(Encoder* _this, void* _mtx, ushort _num = 1);
///
/// Set model matrix from matrix cache for draw primitive.
@@ -3696,7 +3966,7 @@ public struct VertexLayoutHandle {
/// Number of matrices from cache.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_set_transform_cached", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void encoder_set_transform_cached(Encoder* _this, uint _cache, ushort _num);
+ public static extern unsafe void encoder_set_transform_cached(Encoder* _this, uint _cache, ushort _num = 1);
///
/// Reserve matrices in internal matrix cache.
@@ -3718,7 +3988,7 @@ public struct VertexLayoutHandle {
/// Number of elements. Passing `UINT16_MAX` will use the _num passed on uniform creation.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_set_uniform", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void encoder_set_uniform(Encoder* _this, UniformHandle _handle, void* _value, ushort _num);
+ public static extern unsafe void encoder_set_uniform(Encoder* _this, UniformHandle _handle, void* _value, ushort _num = 1);
///
/// Set index buffer for draw primitive.
@@ -3777,6 +4047,24 @@ public struct VertexLayoutHandle {
///
[DllImport(DllName, EntryPoint="bgfx_encoder_set_vertex_buffer_with_layout", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void encoder_set_vertex_buffer_with_layout(Encoder* _this, byte _stream, VertexBufferHandle _handle, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle);
+ ///
+ /// Set vertex buffer for draw primitive.
+ ///
+ ///
+ /// Vertex stream.
+ /// Vertex buffer.
+ /// First vertex to render.
+ /// Number of vertices to render.
+ /// Vertex layout for aliasing vertex buffer. If invalid handle is used, vertex layout used for creation of vertex buffer will be used.
+ ///
+ public static unsafe void encoder_set_vertex_buffer_with_layout(Encoder* _this, byte _stream, VertexBufferHandle _handle, uint _startVertex, uint _numVertices) =>
+ encoder_set_vertex_buffer_with_layout(
+ _this,
+ _stream,
+ _handle,
+ _startVertex,
+ _numVertices,
+ VertexLayoutHandle.Invalid);
///
/// Set vertex buffer for draw primitive.
@@ -3792,6 +4080,14 @@ public struct VertexLayoutHandle {
[DllImport(DllName, EntryPoint="bgfx_encoder_set_dynamic_vertex_buffer_with_layout", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void encoder_set_dynamic_vertex_buffer_with_layout(Encoder* _this, byte _stream, DynamicVertexBufferHandle _handle, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle);
+ public static unsafe void encoder_set_dynamic_vertex_buffer_with_layout(Encoder* _this, byte _stream, DynamicVertexBufferHandle _handle, uint _startVertex, uint _numVertices) =>
+ encoder_set_dynamic_vertex_buffer_with_layout(
+ _this,
+ _stream,
+ _handle,
+ _startVertex,
+ _numVertices,
+ VertexLayoutHandle.Invalid);
///
/// Set vertex buffer for draw primitive.
@@ -3817,6 +4113,24 @@ public struct VertexLayoutHandle {
///
[DllImport(DllName, EntryPoint="bgfx_encoder_set_transient_vertex_buffer_with_layout", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void encoder_set_transient_vertex_buffer_with_layout(Encoder* _this, byte _stream, TransientVertexBuffer* _tvb, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle);
+ ///
+ /// Set vertex buffer for draw primitive.
+ ///
+ ///
+ /// Vertex stream.
+ /// Transient vertex buffer.
+ /// First vertex to render.
+ /// Number of vertices to render.
+ /// Vertex layout for aliasing vertex buffer. If invalid handle is used, vertex layout used for creation of vertex buffer will be used.
+ ///
+ public static unsafe void encoder_set_transient_vertex_buffer_with_layout(Encoder* _this, byte _stream, TransientVertexBuffer* _tvb, uint _startVertex, uint _numVertices) =>
+ encoder_set_transient_vertex_buffer_with_layout(
+ _this,
+ _stream,
+ _tvb,
+ _startVertex,
+ _numVertices,
+ VertexLayoutHandle.Invalid);
///
/// Set number of vertices for auto generated vertices use in conjunction
@@ -3881,7 +4195,7 @@ public struct VertexLayoutHandle {
/// Texture sampling mode. Default value UINT32_MAX uses texture sampling settings from the texture. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_set_texture", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void encoder_set_texture(Encoder* _this, byte _stage, UniformHandle _sampler, TextureHandle _handle, uint _flags);
+ public static extern unsafe void encoder_set_texture(Encoder* _this, byte _stage, UniformHandle _sampler, TextureHandle _handle, uint _flags = uint.MaxValue);
///
/// Submit an empty primitive for rendering. Uniforms and draw state
@@ -3907,7 +4221,7 @@ public struct VertexLayoutHandle {
/// Discard or preserve states. See `BGFX_DISCARD_*`.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_submit", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void encoder_submit(Encoder* _this, ushort _id, ProgramHandle _program, uint _depth, byte _flags);
+ public static extern unsafe void encoder_submit(Encoder* _this, ushort _id, ProgramHandle _program, uint _depth = 0, byte _flags = (byte)DiscardFlags.All);
///
/// Submit primitive with occlusion query for rendering.
@@ -3920,7 +4234,7 @@ public struct VertexLayoutHandle {
/// Discard or preserve states. See `BGFX_DISCARD_*`.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_submit_occlusion_query", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void encoder_submit_occlusion_query(Encoder* _this, ushort _id, ProgramHandle _program, OcclusionQueryHandle _occlusionQuery, uint _depth, byte _flags);
+ public static extern unsafe void encoder_submit_occlusion_query(Encoder* _this, ushort _id, ProgramHandle _program, OcclusionQueryHandle _occlusionQuery, uint _depth = 0, byte _flags = (byte)DiscardFlags.All);
///
/// Submit primitive for rendering with index and instance data info from
@@ -3937,7 +4251,7 @@ public struct VertexLayoutHandle {
/// Discard or preserve states. See `BGFX_DISCARD_*`.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_submit_indirect", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void encoder_submit_indirect(Encoder* _this, ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint _start, uint _num, uint _depth, byte _flags);
+ public static extern unsafe void encoder_submit_indirect(Encoder* _this, ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint _start = 0, uint _num = 1, uint _depth = 0, byte _flags = (byte)DiscardFlags.All);
///
/// Submit primitive for rendering with index and instance data info and
@@ -3956,7 +4270,7 @@ public struct VertexLayoutHandle {
/// Discard or preserve states. See `BGFX_DISCARD_*`.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_submit_indirect_count", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void encoder_submit_indirect_count(Encoder* _this, ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint _start, IndexBufferHandle _numHandle, uint _numIndex, uint _numMax, uint _depth, byte _flags);
+ public static extern unsafe void encoder_submit_indirect_count(Encoder* _this, ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint _start, IndexBufferHandle _numHandle, uint _numIndex = 0, uint _numMax = uint.MaxValue, uint _depth = 0, byte _flags = (byte)DiscardFlags.All);
///
/// Set compute index buffer.
@@ -4024,7 +4338,7 @@ public struct VertexLayoutHandle {
/// Texture format. See: `TextureFormat::Enum`.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_set_image", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void encoder_set_image(Encoder* _this, byte _stage, TextureHandle _handle, byte _mip, Access _access, TextureFormat _format);
+ public static extern unsafe void encoder_set_image(Encoder* _this, byte _stage, TextureHandle _handle, byte _mip, Access _access, TextureFormat _format = TextureFormat.Count);
///
/// Dispatch compute.
@@ -4038,7 +4352,7 @@ public struct VertexLayoutHandle {
/// Discard or preserve states. See `BGFX_DISCARD_*`.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_dispatch", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void encoder_dispatch(Encoder* _this, ushort _id, ProgramHandle _program, uint _numX, uint _numY, uint _numZ, byte _flags);
+ public static extern unsafe void encoder_dispatch(Encoder* _this, ushort _id, ProgramHandle _program, uint _numX = 1, uint _numY = 1, uint _numZ = 1, byte _flags = (byte)DiscardFlags.All);
///
/// Dispatch compute indirect.
@@ -4052,7 +4366,7 @@ public struct VertexLayoutHandle {
/// Discard or preserve states. See `BGFX_DISCARD_*`.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_dispatch_indirect", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void encoder_dispatch_indirect(Encoder* _this, ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint _start, uint _num, byte _flags);
+ public static extern unsafe void encoder_dispatch_indirect(Encoder* _this, ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint _start = 0, uint _num = 1, byte _flags = (byte)DiscardFlags.All);
///
/// Discard previously set state for draw or compute call.
@@ -4061,7 +4375,7 @@ public struct VertexLayoutHandle {
/// Discard or preserve states. See `BGFX_DISCARD_*`.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_discard", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void encoder_discard(Encoder* _this, byte _flags);
+ public static extern unsafe void encoder_discard(Encoder* _this, byte _flags = (byte)DiscardFlags.All);
///
/// Blit 2D texture region between two 2D textures.
@@ -4085,7 +4399,7 @@ public struct VertexLayoutHandle {
/// If texture is 3D this argument represents depth of region, otherwise it's unused.
///
[DllImport(DllName, EntryPoint="bgfx_encoder_blit", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void encoder_blit(Encoder* _this, ushort _id, TextureHandle _dst, byte _dstMip, ushort _dstX, ushort _dstY, ushort _dstZ, TextureHandle _src, byte _srcMip, ushort _srcX, ushort _srcY, ushort _srcZ, ushort _width, ushort _height, ushort _depth);
+ public static extern unsafe void encoder_blit(Encoder* _this, ushort _id, TextureHandle _dst, byte _dstMip, ushort _dstX, ushort _dstY, ushort _dstZ, TextureHandle _src, byte _srcMip = 0, ushort _srcX = 0, ushort _srcY = 0, ushort _srcZ = 0, ushort _width = ushort.MaxValue, ushort _height = ushort.MaxValue, ushort _depth = ushort.MaxValue);
///
/// Request screen shot of window back buffer.
@@ -4114,7 +4428,7 @@ public struct VertexLayoutHandle {
/// Timeout in milliseconds.
///
[DllImport(DllName, EntryPoint="bgfx_render_frame", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe RenderFrame render_frame(int _msecs);
+ public static extern unsafe RenderFrame render_frame(int _msecs = -1);
///
/// Set platform data.
@@ -4168,7 +4482,7 @@ public struct VertexLayoutHandle {
/// Texture creation (see `BGFX_TEXTURE_*`.), and sampler (see `BGFX_SAMPLER_*`) flags. Default texture sampling mode is linear, and wrap mode is repeat. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.
///
[DllImport(DllName, EntryPoint="bgfx_override_internal_texture", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe UIntPtr override_internal_texture(TextureHandle _handle, ushort _width, ushort _height, byte _numMips, TextureFormat _format, ulong _flags);
+ public static extern unsafe UIntPtr override_internal_texture(TextureHandle _handle, ushort _width, ushort _height, byte _numMips, TextureFormat _format, ulong _flags = (ulong)TextureFlags.None | (ulong)SamplerFlags.None);
///
/// Sets a debug marker. This allows you to group graphics calls together for easy browsing in
@@ -4198,7 +4512,7 @@ public struct VertexLayoutHandle {
/// Sets blend factor used by `BGFX_STATE_BLEND_FACTOR` and `BGFX_STATE_BLEND_INV_FACTOR` blend modes.
///
[DllImport(DllName, EntryPoint="bgfx_set_state", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_state(ulong _state, uint _rgba);
+ public static extern unsafe void set_state(ulong _state, uint _rgba = 0);
///
/// Set condition for rendering.
@@ -4218,7 +4532,7 @@ public struct VertexLayoutHandle {
/// Back stencil state. If back is set to `BGFX_STENCIL_NONE` _fstencil is applied to both front and back facing primitives.
///
[DllImport(DllName, EntryPoint="bgfx_set_stencil", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_stencil(uint _fstencil, uint _bstencil);
+ public static extern unsafe void set_stencil(uint _fstencil, uint _bstencil = (uint)StencilFlags.None);
///
/// Set scissor for draw primitive.
@@ -4243,7 +4557,7 @@ public struct VertexLayoutHandle {
/// Index in scissor cache.
///
[DllImport(DllName, EntryPoint="bgfx_set_scissor_cached", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_scissor_cached(ushort _cache);
+ public static extern unsafe void set_scissor_cached(ushort _cache = ushort.MaxValue);
///
/// Set model matrix for draw primitive. If it is not called,
@@ -4254,7 +4568,7 @@ public struct VertexLayoutHandle {
/// Number of matrices in array.
///
[DllImport(DllName, EntryPoint="bgfx_set_transform", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe uint set_transform(void* _mtx, ushort _num);
+ public static extern unsafe uint set_transform(void* _mtx, ushort _num = 1);
///
/// Set model matrix from matrix cache for draw primitive.
@@ -4264,7 +4578,7 @@ public struct VertexLayoutHandle {
/// Number of matrices from cache.
///
[DllImport(DllName, EntryPoint="bgfx_set_transform_cached", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_transform_cached(uint _cache, ushort _num);
+ public static extern unsafe void set_transform_cached(uint _cache, ushort _num = 1);
///
/// Reserve matrices in internal matrix cache.
@@ -4286,7 +4600,7 @@ public struct VertexLayoutHandle {
/// Number of elements. Passing `UINT16_MAX` will use the _num passed on uniform creation.
///
[DllImport(DllName, EntryPoint="bgfx_set_uniform", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_uniform(UniformHandle _handle, void* _value, ushort _num);
+ public static extern unsafe void set_uniform(UniformHandle _handle, void* _value, ushort _num = 1);
///
/// Set index buffer for draw primitive.
@@ -4345,6 +4659,23 @@ public struct VertexLayoutHandle {
///
[DllImport(DllName, EntryPoint="bgfx_set_vertex_buffer_with_layout", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void set_vertex_buffer_with_layout(byte _stream, VertexBufferHandle _handle, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle);
+ ///
+ /// Set vertex buffer for draw primitive.
+ ///
+ ///
+ /// Vertex stream.
+ /// Vertex buffer.
+ /// First vertex to render.
+ /// Number of vertices to render.
+ /// Vertex layout for aliasing vertex buffer. If invalid handle is used, vertex layout used for creation of vertex buffer will be used.
+ ///
+ public static unsafe void set_vertex_buffer_with_layout(byte _stream, VertexBufferHandle _handle, uint _startVertex, uint _numVertices) =>
+ set_vertex_buffer_with_layout(
+ _stream,
+ _handle,
+ _startVertex,
+ _numVertices,
+ VertexLayoutHandle.Invalid);
///
/// Set vertex buffer for draw primitive.
@@ -4370,6 +4701,23 @@ public struct VertexLayoutHandle {
///
[DllImport(DllName, EntryPoint="bgfx_set_dynamic_vertex_buffer_with_layout", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void set_dynamic_vertex_buffer_with_layout(byte _stream, DynamicVertexBufferHandle _handle, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle);
+ ///
+ /// Set vertex buffer for draw primitive.
+ ///
+ ///
+ /// Vertex stream.
+ /// Dynamic vertex buffer.
+ /// First vertex to render.
+ /// Number of vertices to render.
+ /// Vertex layout for aliasing vertex buffer. If invalid handle is used, vertex layout used for creation of vertex buffer will be used.
+ ///
+ public static unsafe void set_dynamic_vertex_buffer_with_layout(byte _stream, DynamicVertexBufferHandle _handle, uint _startVertex, uint _numVertices) =>
+ set_dynamic_vertex_buffer_with_layout(
+ _stream,
+ _handle,
+ _startVertex,
+ _numVertices,
+ VertexLayoutHandle.Invalid);
///
/// Set vertex buffer for draw primitive.
@@ -4395,6 +4743,23 @@ public struct VertexLayoutHandle {
///
[DllImport(DllName, EntryPoint="bgfx_set_transient_vertex_buffer_with_layout", CallingConvention = CallingConvention.Cdecl)]
public static extern unsafe void set_transient_vertex_buffer_with_layout(byte _stream, TransientVertexBuffer* _tvb, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle);
+ ///
+ /// Set vertex buffer for draw primitive.
+ ///
+ ///
+ /// Vertex stream.
+ /// Transient vertex buffer.
+ /// First vertex to render.
+ /// Number of vertices to render.
+ /// Vertex layout for aliasing vertex buffer. If invalid handle is used, vertex layout used for creation of vertex buffer will be used.
+ ///
+ public static unsafe void set_transient_vertex_buffer_with_layout(byte _stream, TransientVertexBuffer* _tvb, uint _startVertex, uint _numVertices) =>
+ set_transient_vertex_buffer_with_layout(
+ _stream,
+ _tvb,
+ _startVertex,
+ _numVertices,
+ VertexLayoutHandle.Invalid);
///
/// Set number of vertices for auto generated vertices use in conjunction
@@ -4459,7 +4824,7 @@ public struct VertexLayoutHandle {
/// Texture sampling mode. Default value UINT32_MAX uses texture sampling settings from the texture. - `BGFX_SAMPLER_[U/V/W]_[MIRROR/CLAMP]` - Mirror or clamp to edge wrap mode. - `BGFX_SAMPLER_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic sampling.
///
[DllImport(DllName, EntryPoint="bgfx_set_texture", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_texture(byte _stage, UniformHandle _sampler, TextureHandle _handle, uint _flags);
+ public static extern unsafe void set_texture(byte _stage, UniformHandle _sampler, TextureHandle _handle, uint _flags = uint.MaxValue);
///
/// Submit an empty primitive for rendering. Uniforms and draw state
@@ -4483,7 +4848,7 @@ public struct VertexLayoutHandle {
/// Which states to discard for next draw. See `BGFX_DISCARD_*`.
///
[DllImport(DllName, EntryPoint="bgfx_submit", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void submit(ushort _id, ProgramHandle _program, uint _depth, byte _flags);
+ public static extern unsafe void submit(ushort _id, ProgramHandle _program, uint _depth = 0, byte _flags = (byte)DiscardFlags.All);
///
/// Submit primitive with occlusion query for rendering.
@@ -4496,7 +4861,7 @@ public struct VertexLayoutHandle {
/// Which states to discard for next draw. See `BGFX_DISCARD_*`.
///
[DllImport(DllName, EntryPoint="bgfx_submit_occlusion_query", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void submit_occlusion_query(ushort _id, ProgramHandle _program, OcclusionQueryHandle _occlusionQuery, uint _depth, byte _flags);
+ public static extern unsafe void submit_occlusion_query(ushort _id, ProgramHandle _program, OcclusionQueryHandle _occlusionQuery, uint _depth = 0, byte _flags = (byte)DiscardFlags.All);
///
/// Submit primitive for rendering with index and instance data info from
@@ -4513,7 +4878,7 @@ public struct VertexLayoutHandle {
/// Which states to discard for next draw. See `BGFX_DISCARD_*`.
///
[DllImport(DllName, EntryPoint="bgfx_submit_indirect", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void submit_indirect(ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint _start, uint _num, uint _depth, byte _flags);
+ public static extern unsafe void submit_indirect(ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint _start = 0, uint _num = 1, uint _depth = 0, byte _flags = (byte)DiscardFlags.All);
///
/// Submit primitive for rendering with index and instance data info and
@@ -4532,7 +4897,7 @@ public struct VertexLayoutHandle {
/// Which states to discard for next draw. See `BGFX_DISCARD_*`.
///
[DllImport(DllName, EntryPoint="bgfx_submit_indirect_count", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void submit_indirect_count(ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint _start, IndexBufferHandle _numHandle, uint _numIndex, uint _numMax, uint _depth, byte _flags);
+ public static extern unsafe void submit_indirect_count(ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, uint _start, IndexBufferHandle _numHandle, uint _numIndex = 0, uint _numMax = uint.MaxValue, uint _depth = 0, byte _flags = (byte)DiscardFlags.All);
///
/// Set compute index buffer.
@@ -4600,7 +4965,7 @@ public struct VertexLayoutHandle {
/// Texture format. See: `TextureFormat::Enum`.
///
[DllImport(DllName, EntryPoint="bgfx_set_image", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void set_image(byte _stage, TextureHandle _handle, byte _mip, Access _access, TextureFormat _format);
+ public static extern unsafe void set_image(byte _stage, TextureHandle _handle, byte _mip, Access _access, TextureFormat _format = TextureFormat.Count);
///
/// Dispatch compute.
@@ -4614,7 +4979,7 @@ public struct VertexLayoutHandle {
/// Discard or preserve states. See `BGFX_DISCARD_*`.
///
[DllImport(DllName, EntryPoint="bgfx_dispatch", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void dispatch(ushort _id, ProgramHandle _program, uint _numX, uint _numY, uint _numZ, byte _flags);
+ public static extern unsafe void dispatch(ushort _id, ProgramHandle _program, uint _numX = 1, uint _numY = 1, uint _numZ = 1, byte _flags = (byte)DiscardFlags.All);
///
/// Dispatch compute indirect.
@@ -4628,7 +4993,7 @@ public struct VertexLayoutHandle {
/// Discard or preserve states. See `BGFX_DISCARD_*`.
///
[DllImport(DllName, EntryPoint="bgfx_dispatch_indirect", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void dispatch_indirect(ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, ushort _start, ushort _num, byte _flags);
+ public static extern unsafe void dispatch_indirect(ushort _id, ProgramHandle _program, IndirectBufferHandle _indirectHandle, ushort _start = 0, ushort _num = 1, byte _flags = (byte)DiscardFlags.All);
///
/// Discard previously set state for draw or compute call.
@@ -4637,7 +5002,7 @@ public struct VertexLayoutHandle {
/// Draw/compute states to discard.
///
[DllImport(DllName, EntryPoint="bgfx_discard", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void discard(byte _flags);
+ public static extern unsafe void discard(byte _flags = (byte)DiscardFlags.All);
///
/// Blit 2D texture region between two 2D textures.
@@ -4661,7 +5026,7 @@ public struct VertexLayoutHandle {
/// If texture is 3D this argument represents depth of region, otherwise it's unused.
///
[DllImport(DllName, EntryPoint="bgfx_blit", CallingConvention = CallingConvention.Cdecl)]
- public static extern unsafe void blit(ushort _id, TextureHandle _dst, byte _dstMip, ushort _dstX, ushort _dstY, ushort _dstZ, TextureHandle _src, byte _srcMip, ushort _srcX, ushort _srcY, ushort _srcZ, ushort _width, ushort _height, ushort _depth);
+ public static extern unsafe void blit(ushort _id, TextureHandle _dst, byte _dstMip, ushort _dstX, ushort _dstY, ushort _dstZ, TextureHandle _src, byte _srcMip = 0, ushort _srcX = 0, ushort _srcY = 0, ushort _srcZ = 0, ushort _width = ushort.MaxValue, ushort _height = ushort.MaxValue, ushort _depth = ushort.MaxValue);
}
}
diff --git a/scripts/bindings-cs.lua b/scripts/bindings-cs.lua
index 355922f6e3..a538c22a1d 100644
--- a/scripts/bindings-cs.lua
+++ b/scripts/bindings-cs.lua
@@ -129,6 +129,35 @@ local function convert_ret_type(arg)
return ctype
end
+local function convert_default_arg(arg)
+
+ local cvalue = tostring(arg.default)
+
+ if cvalue == "UINT8_MAX" then
+ cvalue = "byte.MaxValue"
+ elseif cvalue == "UINT16_MAX" then
+ cvalue = "ushort.MaxValue"
+ elseif cvalue == "UINT32_MAX" then
+ cvalue = "uint.MaxValue"
+ elseif cvalue == "INT32_MAX" then
+ cvalue = "int.MaxValue"
+ elseif cvalue == "NULL" then
+ cvalue = "default"
+ elseif hasPrefix(cvalue, "BGFX_") then
+ --cvalue = "("..convert_type(arg)..")(" .. format_default_enum_value(cvalue) .. ")"
+
+ local type = convert_type(arg)
+ cvalue = cvalue:lower()
+ :gsub("_%l", string.upper)
+ :gsub("bgfx_([%a-Z]+)_", "("..type..")%1Flags.")
+ :gsub('_','')
+ else
+ cvalue = cvalue:gsub("::", ".") --Convert C++ Enum::Value to C# Enum.Value
+ end
+
+ return cvalue
+end
+
local converter = {}
local yield = coroutine.yield
local indent = ""
@@ -180,6 +209,9 @@ local function FlagBlock(typ)
elseif typ.bits == 16 then
format = "0x%04x"
enumType = " : ushort"
+ elseif typ.bits == 8 then
+ format = "0x%02x"
+ enumType = " : byte"
end
yield("[Flags]")
@@ -267,10 +299,12 @@ function converter.types(typ)
if typ.handle then
lastCombinedFlagBlock()
- yield("public struct " .. typ.name .. " {")
- yield(" public ushort idx;")
- yield(" public bool Valid => idx != UInt16.MaxValue;")
- yield("}")
+ yield("public struct " .. typ.name .. " {")
+ yield(" public ushort idx;")
+ yield(" public static readonly " .. typ.name .. " Invalid = new " .. typ.name .. "(ushort.MaxValue);")
+ yield(" public " .. typ.name .. "(ushort index) => idx = index;")
+ yield(" public bool Valid => this.idx != Invalid.idx;")
+ yield("}")
elseif hasSuffix(typ.name, "::Enum") then
lastCombinedFlagBlock()
@@ -355,6 +389,15 @@ function converter.types(typ)
local skip = false
+ if typ.comments ~= nil then
+ yield("/// ")
+ for _, line in ipairs(typ.comments) do
+ yield("/// " .. line)
+ end
+ yield("/// ")
+ yield("///")
+ end
+
if typ.namespace ~= nil then
if namespace ~= typ.namespace then
yield("public unsafe struct " .. typ.namespace)
@@ -374,9 +417,22 @@ function converter.types(typ)
end
for _, member in ipairs(typ.struct) do
+
+ if member.comment ~= nil then
+ local comment = table.concat(member.comment, " ")
+
+ yield(indent .. "\t/// "
+ .. comment
+ .. ""
+ )
+
+ hasParams = true
+ end
+
yield(
indent .. "\tpublic " .. convert_struct_member(member) .. ";"
)
+
end
yield(indent .. "}")
@@ -428,16 +484,80 @@ function converter.funcs(func)
end
local args = {}
+ local hasDefaultInvalidHandle = false
+
if func.this ~= nil then
args[1] = func.this_type.type .. "* _this"
end
for _, arg in ipairs(func.args) do
- table.insert(args, convert_type(arg) .. " " .. arg.name)
+
+ local argStr = convert_type(arg) .. " " .. arg.name;
+
+
+ if arg.default ~= nil then
+
+ if arg.default == "BGFX_INVALID_HANDLE" then
+ hasDefaultInvalidHandle = true
+ else
+ argStr = argStr .. " = " .. convert_default_arg(arg)
+ end
+ end
+
+ table.insert(args, argStr)
end
yield("public static extern unsafe " .. convert_ret_type(func.ret) .. " " .. func.cname
.. "(" .. table.concat(args, ", ") .. ");")
+
+ if hasDefaultInvalidHandle then
+
+ if func.comments ~= nil then
+ yield("/// ")
+ for _, line in ipairs(func.comments) do
+ yield("/// " .. line)
+ end
+ yield("/// ")
+ yield("///")
+
+ local hasParams = false
+
+ for _, arg in ipairs(func.args) do
+ if arg.comment ~= nil then
+ local comment = table.concat(arg.comment, " ")
+
+ yield("/// "
+ .. comment
+ .. ""
+ )
+
+ hasParams = true
+ end
+ end
+
+ if hasParams then
+ yield("///")
+ end
+ end
+ table.remove(args, #args)
+ yield("public static unsafe " .. convert_ret_type(func.ret) .. " " .. func.cname
+ .. "(" .. table.concat(args, ", ") .. ") =>")
+ yield(func.cname .. "(")
+ if func.this ~= nil then
+ yield("_this,")
+ end
+ for _, arg in pairs(func.args) do
+ if next(func.args,_) == nil then
+ yield(convert_type(arg) .. ".Invalid);")
+ else
+ yield(arg.name ..',')
+ end
+ end
+
+ end
end
+
-- printtable("idl types", idl.types)
-- printtable("idl funcs", idl.funcs)