SOURCE DUMP v1

This commit is contained in:
Rian Drake 2026-10-15 14:09:11 +13:00
commit fb20299e9d
5 changed files with 768360 additions and 0 deletions

View file

@ -0,0 +1,379 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using Brutal.Numerics;
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
namespace Brutal.GliApi;
/// <summary>
/// A library providing interop for basic functionality of the Gli texture library
/// </summary>
public static partial class Gli
{
/// <summary>
/// Representation of a native gli::texture*
/// </summary>
[NativeMarshalling(typeof(NativeTextureMarshaller))]
public sealed unsafe class Texture : INullable, IDisposable
{
internal Texture(nint impl)
{
Impl = impl;
// A null handle means the native load/create failed. Accessing Levels here would
// dereference the null native pointer, so leave the row-pitch cache empty and let
// callers detect the failure via IsNull().
_rowPitch = impl != 0 ? new long[Levels] : [];
}
~Texture()
{
Release();
}
/// <summary>
/// Create an empty texture
/// </summary>
/// <returns>The created native texture</returns>
public Texture()
: this(PInvoke.createEmpty()) { }
/// <summary>
/// Load a texture from a file. Returns an empty handle in case of failure.
/// </summary>
public Texture(string filePath)
: this(PInvoke.load(filePath)) { }
/// <summary>
/// Load a texture from memory. Returns an empty handle in case of failure.
/// </summary>
public Texture(ReadOnlySpan<byte> data)
: this(PInvoke.loadFromMemory(data, data.Length)) { }
/// <summary>
/// Create a texture object and allocate a texture storage for it
/// </summary>
/// <param name="target">Type/Shape of the texture storage_linear</param>
/// <param name="format">Texel format</param>
/// <param name="extent">Size of the texture: width, height and depth.</param>
/// <param name="layers">Number of one-dimensional or two-dimensional images of identical size and format</param>
/// <param name="faces">6 for cube map textures otherwise 1.</param>
/// <param name="levels">Number of images in the texture mipmap chain.</param>
/// <param name="swizzles">A mechanism to swizzle the components of a texture before they are applied according to the texture environment.</param>
/// <returns>The created native texture</returns>
public Texture(
Target target,
Format format,
int3 extent,
long layers,
long faces,
long levels,
Swizzles swizzles
)
: this(PInvoke.create(target, format, extent, layers, faces, levels, swizzles)) { }
/// <summary>
/// Create a texture object by sharing an existing texture storage_type from another texture instance.
/// </summary>
/// <remarks>
/// This texture object is effectively a texture view where the layer, the face and the level allows identifying
/// a specific subset of the texture storage_linear source, and where the target and format can be reinterpreted
/// with a different compatible texture target and texture format.
/// </remarks>
/// <param name="texture">The texture to share the storage_type from</param>
/// <param name="target">Type/Shape of the texture storage_linear</param>
/// <param name="format">Texel format</param>
/// <param name="baseLayer">The base layer of the texture instance</param>
/// <param name="maxLayer">The max layer of the texture instance</param>
/// <param name="baseFace">The base face of the texture instance</param>
/// <param name="maxFace">The max face of the texture instance</param>
/// <param name="baseLevel">The base level of the texture instance</param>
/// <param name="maxLevel">The max level of the texture instance</param>
/// <param name="swizzles">A mechanism to swizzle the components of a texture before they are applied according to the texture environment.</param>
/// <returns>The created native texture</returns>
public Texture(
Texture texture,
Target target,
Format format,
long baseLayer,
long maxLayer,
long baseFace,
long maxFace,
long baseLevel,
long maxLevel,
Swizzles swizzles
)
: this(
PInvoke.createFromExistingSubset(
texture,
target,
format,
baseLayer,
maxLayer,
baseFace,
maxFace,
baseLevel,
maxLevel,
swizzles
)
) { }
/// <summary>
/// Create a texture object by sharing an existing texture storage_type from another texture instance.
/// </summary>
/// <remarks>
/// This texture object is effectively a texture view where the target and format can be reinterpreted
/// with a different compatible texture target and texture format.
/// </remarks>
/// <param name="texture">The texture to share the storage from</param>
/// <param name="target">Type/Shape of the texture storage</param>
/// <param name="format">Texel format</param>
/// <param name="swizzles">A mechanism to swizzle the components of a texture before they are applied according to the texture environment.</param>
/// <returns>The created native texture</returns>
public Texture(Texture texture, Target target, Format format, Swizzles swizzles)
: this(PInvoke.createFromExisting(texture, target, format, swizzles)) { }
public bool IsNull() => Impl == 0;
public void Dispose()
{
Release();
GC.SuppressFinalize(this);
}
private void Release()
{
// Atomically claim the handle so that only one caller (a racing Dispose or the
// finalizer) can ever hand it to native release, preventing a double-free.
var impl = Interlocked.Exchange(ref Impl, 0);
if (impl != 0)
PInvoke.release(impl);
}
internal nint Impl;
private byte* _data;
private long _size;
private int3 _extent;
private Format _format;
private long _layers;
private long _levels;
private long _faces;
private Target _target;
private int3 _blockExtent;
private bool? _isCompressed;
private long _blockSize;
private readonly long[] _rowPitch;
/// <summary>
/// Returns a pointer to the beginning of the texture instance data.
/// </summary>
public byte* Data => _data = _data != null ? _data : PInvoke.data(this);
/// <summary>
/// Returns the memory size of the instance data in bytes.
/// </summary>
public long Size => _size = _size != 0 ? _size : PInvoke.size(this);
/// <summary>
/// Returns pointer to the image data for a single level, layer and face.
/// </summary>
/// <param name="level">Level to retrieve data for</param>
/// <param name="layer">Layer to retrieve data for</param>
/// <param name="face">Face to retrieve data for</param>
/// <returns></returns>
public byte* ImageData(int level, int layer = 0, int face = 0) => PInvoke.imagedata(this, level, layer, face);
/// <summary>
/// Returns the size in bytes of a specified mip level of the texture
/// </summary>
/// <param name="level">The level whose size you require</param>
/// <returns>The size in bytes of the level</returns>
public long ImageSize(int level) => PInvoke.levelsize(this, level);
/// <summary>
/// Return the size of a texture instance: width, height and depth.
/// </summary>
public int3 Extent => _extent = _extent != default ? _extent : PInvoke.extent(this);
/// <summary>
/// Return the extent of a specified mip level. The value is in texels.
/// </summary>
/// <param name="level">mip level of extent to return</param>
/// <returns>The extent</returns>
public int3 ImageExtent(int level) => PInvoke.extent(this, level);
/// <summary>
/// Gets the row pitch for a mip level
/// </summary>
/// <param name="level">Level to get</param>
/// <returns>Row pitch in bytes</returns>
public long ImageRowPitch(int level) =>
_rowPitch[level] = _rowPitch[level] != 0 ? _rowPitch[level] : PInvoke.rowpitch(this, level);
/// <summary>
/// Returns the size of a "block" in bytes. Block can be a compressed block or texel.
/// </summary>
public long BlockSize => _blockSize = _blockSize != 0 ? _blockSize : PInvoke.blocksize(this);
/// <summary>
/// Returns whether this texture is in a compressed format.
/// </summary>
public bool IsCompressed => _isCompressed ??= PInvoke.iscompressed(this);
/// <summary>
/// Returns the size of a block in texels.
/// </summary>
public int3 BlockExtent => _blockExtent = _blockExtent != default ? _blockExtent : PInvoke.blockextent(this);
/// <summary>
/// Returns the texture instance format.
/// </summary>
public Format Format => _format = _format != 0 ? _format : PInvoke.format(this);
/// <summary>
/// Returns the number of layers in a texture instance
/// </summary>
public long Layers => _layers = _layers != 0 ? _layers : PInvoke.layers(this);
/// <summary>
/// Returns the number of levels in a texture instance
/// </summary>
public long Levels => _levels = _levels != 0 ? _levels : PInvoke.levels(this);
/// <summary>
/// Returns the number of faces in a texture instance
/// </summary>
public long Faces => _faces = _faces != 0 ? _faces : PInvoke.faces(this);
/// <summary>
/// Returns the target of a texture instance.
/// </summary>
public Target Target => _target = _target != 0 ? _target : PInvoke.target(this);
/// <summary>
/// Save a texture storage_linear to a file.
/// </summary>
/// <param name="filePath"> Path for where to save the file. It must include the filename and filename extension.</param>
/// <remarks>
/// The function uses the filename extension included in the path to figure out the file container to use.
/// </remarks>
/// <returns>False if the function fails to save the file.</returns>
public bool Save(string filePath)
{
return PInvoke.save(this, filePath);
}
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
internal static partial class PInvoke
{
[LibraryImport("gli")]
public static unsafe partial nint createEmpty();
[LibraryImport("gli")]
public static unsafe partial nint create(
Target target,
Format format,
int3 extent,
long layers,
long faces,
long levels,
Swizzles swizzles
);
[LibraryImport("gli")]
public static unsafe partial nint createFromExistingSubset(
Texture texture,
Target target,
Format format,
long baseLayer,
long maxLayer,
long baseFace,
long maxFace,
long baseLevel,
long maxLevel,
Swizzles swizzles
);
[LibraryImport("gli")]
public static unsafe partial nint createFromExisting(
Texture texture,
Target target,
Format format,
Swizzles swizzles
);
[LibraryImport("gli", StringMarshalling = StringMarshalling.Utf8)]
public static unsafe partial Bool8 save(Texture texture, string filePath);
[LibraryImport("gli")]
public static unsafe partial void release(nint texture);
[LibraryImport("gli", StringMarshalling = StringMarshalling.Utf8)]
public static unsafe partial nint load(string fileName);
[LibraryImport("gli")]
public static unsafe partial nint loadFromMemory(ReadOnlySpan<byte> data, long size);
[LibraryImport("gli")]
public static unsafe partial byte* data(Texture texture);
[LibraryImport("gli")]
public static unsafe partial byte* imagedata(Texture texture, long level, long layer = 0, long face = 0);
[LibraryImport("gli")]
public static partial long size(Texture texture);
[LibraryImport("gli")]
public static partial long levelsize(Texture texture, long level = 0);
[LibraryImport("gli")]
public static partial int3 extent(Texture texture, long level = 0);
[LibraryImport("gli")]
public static partial Format format(Texture texture);
[LibraryImport("gli")]
public static partial long layers(Texture texture);
[LibraryImport("gli")]
public static partial long levels(Texture texture);
[LibraryImport("gli")]
public static partial long faces(Texture texture);
[LibraryImport("gli")]
public static partial Target target(Texture texture);
[LibraryImport("gli")]
public static partial long rowpitch(Texture texture, long level = 0);
[LibraryImport("gli")]
public static partial long blocksize(Texture texture);
[LibraryImport("gli")]
public static partial int3 blockextent(Texture texture);
[LibraryImport("gli")]
public static partial Bool8 iscompressed(Texture texture);
}
[CustomMarshaller(
managedType: typeof(Texture),
marshalMode: MarshalMode.Default,
marshallerType: typeof(NativeTextureMarshaller)
)]
internal static class NativeTextureMarshaller
{
internal static nint ConvertToUnmanaged(Texture? managed)
{
return managed?.Impl ?? 0;
}
internal static Texture ConvertToManaged(nint unmanaged)
{
return new Texture(unmanaged);
}
}
}

View file

@ -0,0 +1,131 @@
THIRD-PARTY LICENSE NOTICES
RocketWerkz.Brutal.Gli
Brutal.Gli redistributes the third-party components named below, as native libraries.
Each is reproduced with the license that governs it.
==============================================================================
GLI
==============================================================================
Name GLI, an image library for texture loading and format conversion
Version 0.8.3
built from upstream 0.8.2.0-108-g779b99ac
Upstream https://github.com/g-truc/gli
SPDX MIT -- upstream offers two licenses and both are reproduced below
Shipped as gli.dll (win-x64), libgli.so (linux-x64), libgli.dylib (osx-arm64)
Upstream offers this component under either of the two licenses below. Both are
reproduced as upstream states them.
Copyright (c) 2010 - 2020 G-Truc Creation
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
Restrictions: By making use of the Software for military purposes, you
choose to make a Bunny unhappy.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2010 - 2020 G-Truc Creation
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==============================================================================
OpenGL Mathematics (GLM)
==============================================================================
Name OpenGL Mathematics, a header-only mathematics library
Version 0.9.9.9
Upstream https://github.com/g-truc/glm
Shipped as compiled into gli.dll, libgli.so and libgli.dylib
GLI is built against this component and its templates are instantiated into the
libraries shipped here, so it is redistributed with them rather than beside them.
================================================================================
OpenGL Mathematics (GLM)
--------------------------------------------------------------------------------
GLM is licensed under The Happy Bunny License or MIT License
================================================================================
The Happy Bunny License (Modified MIT License)
--------------------------------------------------------------------------------
Copyright (c) 2005 - G-Truc Creation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
Restrictions:
By making use of the Software for military purposes, you choose to make a
Bunny unhappy.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================================================
The MIT License
--------------------------------------------------------------------------------
Copyright (c) 2005 - G-Truc Creation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -0,0 +1,255 @@
namespace Brutal.GliApi;
public static partial class Gli
{
/// <summary>
/// GLI's internal format definition
/// </summary>
public enum Format
{
Undefined = 0,
RG4_UNorm_Pack8,
First = RG4_UNorm_Pack8,
RGBA4_UNorm_Pack16,
BGRA4_UNorm_Pack16,
R5G6B5_UNorm_Pack16,
B5G6R5_UNorm_Pack16,
RGB5A1_UNorm_Pack16,
BGR5A1_UNorm_Pack16,
A1RGB5_UNorm_Pack16,
R8_UNorm_Pack8,
R8_SNorm_Pack8,
R8_UScaled_Pack8,
R8_SScaled_Pack8,
R8_UInt_Pack8,
R8_SInt_Pack8,
R8_SRGB_Pack8,
RG8_UNorm_Pack8,
RG8_SNorm_Pack8,
RG8_UScaled_Pack8,
RG8_SScaled_Pack8,
RG8_UInt_Pack8,
RG8_SInt_Pack8,
RG8_SRGB_Pack8,
RGB8_UNorm_Pack8,
RGB8_SNorm_Pack8,
RGB8_UScaled_Pack8,
RGB8_SScaled_Pack8,
RGB8_UInt_Pack8,
RGB8_SInt_Pack8,
RGB8_SRGB_Pack8,
BGR8_UNorm_Pack8,
BGR8_SNorm_Pack8,
BGR8_UScaled_Pack8,
BGR8_SScaled_Pack8,
BGR8_UInt_Pack8,
BGR8_SInt_Pack8,
BGR8_SRGB_Pack8,
RGBA8_UNorm_Pack8,
RGBA8_SNorm_Pack8,
RGBA8_UScaled_Pack8,
RGBA8_SScaled_Pack8,
RGBA8_UInt_Pack8,
RGBA8_SInt_Pack8,
RGBA8_SRGB_Pack8,
BGRA8_UNorm_Pack8,
BGRA8_SNorm_Pack8,
BGRA8_UScaled_Pack8,
BGRA8_SScaled_Pack8,
BGRA8_UInt_Pack8,
BGRA8_SInt_Pack8,
BGRA8_SRGB_Pack8,
RGBA8_UNorm_Pack32,
RGBA8_SNorm_Pack32,
RGBA8_UScaled_Pack32,
RGBA8_SScaled_Pack32,
RGBA8_UInt_Pack32,
RGBA8_SInt_Pack32,
RGBA8_SRGB_Pack32,
RGB10A2_UNorm_Pack32,
RGB10A2_SNorm_Pack32,
RGB10A2_UScaled_Pack32,
RGB10A2_SScaled_Pack32,
RGB10A2_UInt_Pack32,
RGB10A2_SInt_Pack32,
BGR10A2_UNorm_Pack32,
BGR10A2_SNorm_Pack32,
BGR10A2_UScaled_Pack32,
BGR10A2_SScaled_Pack32,
BGR10A2_UInt_Pack32,
BGR10A2_SInt_Pack32,
R16_UNorm_Pack16,
R16_SNorm_Pack16,
R16_UScaled_Pack16,
R16_SScaled_Pack16,
R16_UInt_Pack16,
R16_SInt_Pack16,
R16_SFloat_Pack16,
RG16_UNorm_Pack16,
RG16_SNorm_Pack16,
RG16_UScaled_Pack16,
RG16_SScaled_Pack16,
RG16_UInt_Pack16,
RG16_SInt_Pack16,
RG16_SFloat_Pack16,
RGB16_UNorm_Pack16,
RGB16_SNorm_Pack16,
RGB16_UScaled_Pack16,
RGB16_SScaled_Pack16,
RGB16_UInt_Pack16,
RGB16_SInt_Pack16,
RGB16_SFloat_Pack16,
RGBA16_UNorm_Pack16,
RGBA16_SNorm_Pack16,
RGBA16_UScaled_Pack16,
RGBA16_SScaled_Pack16,
RGBA16_UInt_Pack16,
RGBA16_SInt_Pack16,
RGBA16_SFloat_Pack16,
R32_UInt_Pack32,
R32_SInt_Pack32,
R32_SFloat_Pack32,
RG32_UInt_Pack32,
RG32_SInt_Pack32,
RG32_SFloat_Pack32,
RGB32_UInt_Pack32,
RGB32_SInt_Pack32,
RGB32_SFloat_Pack32,
RGBA32_UInt_Pack32,
RGBA32_SInt_Pack32,
RGBA32_SFloat_Pack32,
R64_UInt_Pack64,
R64_SInt_Pack64,
R64_SFloat_Pack64,
RG64_UInt_Pack64,
RG64_SInt_Pack64,
RG64_SFloat_Pack64,
RGB64_UInt_Pack64,
RGB64_SInt_Pack64,
RGB64_SFloat_Pack64,
RGBA64_UInt_Pack64,
RGBA64_SInt_Pack64,
RGBA64_SFloat_Pack64,
RG11B10_UFloat_Pack32,
RGB9E5_UFloat_Pack32,
D16_UNorm_Pack16,
D24_UNorm_Pack32,
D32_SFloat_Pack32,
S8_UInt_Pack8,
D16_UNorm_S8_UInt_Pack32,
D24_UNorm_S8_UInt_Pack32,
D32_SFloat_S8_UInt_Pack64,
RGB_DXT1_UNorm_Block8,
RGB_DXT1_SRGB_Block8,
RGBA_DXT1_UNorm_Block8,
RGBA_DXT1_SRGB_Block8,
RGBA_DXT3_UNorm_Block16,
RGBA_DXT3_SRGB_Block16,
RGBA_DXT5_UNorm_Block16,
RGBA_DXT5_SRGB_Block16,
R_ATI1N_UNorm_Block8,
R_ATI1N_SNorm_Block8,
RG_ATI2N_UNorm_Block16,
RG_ATI2N_SNorm_Block16,
RGB_BP_UFloat_Block16,
RGB_BP_SFloat_Block16,
RGBA_BP_UNorm_Block16,
RGBA_BP_SRGB_Block16,
RGB_ETC2_UNorm_Block8,
RGB_ETC2_SRGB_Block8,
RGBA_ETC2_UNorm_Block8,
RGBA_ETC2_SRGB_Block8,
RGBA_ETC2_UNorm_Block16,
RGBA_ETC2_SRGB_Block16,
R_EAC_UNorm_Block8,
R_EAC_SNorm_Block8,
RG_EAC_UNorm_Block16,
RG_EAC_SNorm_Block16,
RGBA_ASTC_4X4_UNorm_Block16,
RGBA_ASTC_4X4_SRGB_Block16,
RGBA_ASTC_5X4_UNorm_Block16,
RGBA_ASTC_5X4_SRGB_Block16,
RGBA_ASTC_5X5_UNorm_Block16,
RGBA_ASTC_5X5_SRGB_Block16,
RGBA_ASTC_6X5_UNorm_Block16,
RGBA_ASTC_6X5_SRGB_Block16,
RGBA_ASTC_6X6_UNorm_Block16,
RGBA_ASTC_6X6_SRGB_Block16,
RGBA_ASTC_8X5_UNorm_Block16,
RGBA_ASTC_8X5_SRGB_Block16,
RGBA_ASTC_8X6_UNorm_Block16,
RGBA_ASTC_8X6_SRGB_Block16,
RGBA_ASTC_8X8_UNorm_Block16,
RGBA_ASTC_8X8_SRGB_Block16,
RGBA_ASTC_10X5_UNorm_Block16,
RGBA_ASTC_10X5_SRGB_Block16,
RGBA_ASTC_10X6_UNorm_Block16,
RGBA_ASTC_10X6_SRGB_Block16,
RGBA_ASTC_10X8_UNorm_Block16,
RGBA_ASTC_10X8_SRGB_Block16,
RGBA_ASTC_10X10_UNorm_Block16,
RGBA_ASTC_10X10_SRGB_Block16,
RGBA_ASTC_12X10_UNorm_Block16,
RGBA_ASTC_12X10_SRGB_Block16,
RGBA_ASTC_12X12_UNorm_Block16,
RGBA_ASTC_12X12_SRGB_Block16,
RGB_PVRTC1_8X8_UNorm_Block32,
RGB_PVRTC1_8X8_SRGB_Block32,
RGB_PVRTC1_16X8_UNorm_Block32,
RGB_PVRTC1_16X8_SRGB_Block32,
RGBA_PVRTC1_8X8_UNorm_Block32,
RGBA_PVRTC1_8X8_SRGB_Block32,
RGBA_PVRTC1_16X8_UNorm_Block32,
RGBA_PVRTC1_16X8_SRGB_Block32,
RGBA_PVRTC2_4X4_UNorm_Block8,
RGBA_PVRTC2_4X4_SRGB_Block8,
RGBA_PVRTC2_8X4_UNorm_Block8,
RGBA_PVRTC2_8X4_SRGB_Block8,
RGB_ETC_UNorm_Block8,
RGB_ATC_UNorm_Block8,
RGBA_ATCA_UNorm_Block16,
RGBA_ATCI_UNorm_Block16,
L8_UNorm_Pack8,
A8_UNorm_Pack8,
LA8_UNorm_Pack8,
L16_UNorm_Pack16,
A16_UNorm_Pack16,
LA16_UNorm_Pack16,
BGR8_UNorm_Pack32,
BGR8_SRGB_Pack32,
RG3B2_UNorm_Pack8,
Last = RG3B2_UNorm_Pack8,
}
}

View file

@ -0,0 +1,55 @@
using System.Runtime.InteropServices;
namespace Brutal.GliApi;
public static partial class Gli
{
/// <summary>
/// Represent the source of a channel
/// </summary>
public enum Swizzle
{
Red,
Green,
Blue,
Alpha,
Zero,
One,
First = Red,
ChannelFirst = Red,
ChannelLast = Alpha,
Last = One,
}
/// <summary>
/// Implementation of the Gli swizzles
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct Swizzles()
{
/// <summary>
/// The R channel swizzle
/// </summary>
public Swizzle R = Swizzle.Red;
/// <summary>
/// The G channel swizzle
/// </summary>
public Swizzle G = Swizzle.Green;
/// <summary>
/// The B channel swizzle
/// </summary>
public Swizzle B = Swizzle.Blue;
/// <summary>
/// The A channel swizzle
/// </summary>
public Swizzle A = Swizzle.Alpha;
/// <summary>
///
/// </summary>
public static Swizzles Identity => new Swizzles();
}
}

View file

@ -0,0 +1,56 @@
namespace Brutal.GliApi;
public static partial class Gli
{
/// <summary>
/// Texture target: type/shape of the texture data
/// </summary>
public enum Target
{
_1D,
_1DArray,
_2D,
_2DArray,
_3D,
Rect,
RectArray,
Cube,
CubeArray,
}
}
public static class GliTargetExtensions
{
public static int DimensionCount(this Gli.Target target) =>
target.Is1d() ? 1 : (target.Is2d() ? 2 : (target.Is3d() ? 3 : 2));
public static bool Is1d(this Gli.Target target)
{
return target is Gli.Target._1D or Gli.Target._1DArray;
}
public static bool Is2d(this Gli.Target target)
{
return target is Gli.Target._2D or Gli.Target._2DArray or Gli.Target.Rect or Gli.Target.RectArray;
}
public static bool Is3d(this Gli.Target target)
{
return target is Gli.Target._3D;
}
public static bool IsArray(this Gli.Target target)
{
return target is Gli.Target._1DArray or Gli.Target._2DArray or Gli.Target.CubeArray;
}
public static bool IsCube(this Gli.Target target)
{
return target is Gli.Target.Cube or Gli.Target.CubeArray;
}
public static bool IsRect(this Gli.Target target)
{
return target is Gli.Target.Rect or Gli.Target.RectArray;
}
}