SOURCE DUMP v1

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

View file

@ -0,0 +1,43 @@
namespace Brutal.MeshOptimizer
{
/// <summary>
/// Vertex buffer filter encoders
/// These functions can be used to encode data in a format that meshopt_decodeFilter can decode
/// </summary>
/// <remarks>
/// <para>
/// meshopt_encodeFilterOct encodes unit vectors with K-bit (2 &lt;= K &lt;= 16) signed X/Y as an output.
/// Each component is stored as an 8-bit or 16-bit normalized integer; stride must be equal to 4 or 8. Z will store 1.0f, W is preserved as is.
/// Input data must contain 4 floats for every vector (count*4 total).
/// </para>
/// <para>
/// meshopt_encodeFilterQuat encodes unit quaternions with K-bit (4 &lt;= K &lt;= 16) component encoding.
/// Each component is stored as an 16-bit integer; stride must be equal to 8.
/// Input data must contain 4 floats for every quaternion (count*4 total).
/// </para>
/// <para>
/// meshopt_encodeFilterExp encodes arbitrary (finite) floating-point data with 8-bit exponent and K-bit integer mantissa (1 &lt;= K &lt;= 24).
/// Exponent can be shared between all components of a given vector as defined by stride or all values of a given component; stride must be divisible by 4.
/// Input data must contain stride/4 floats for every vector (count*stride/4 total).
/// </para>
/// <para>
/// meshopt_encodeFilterColor encodes RGBA color data by converting RGB to YCoCg color space with K-bit (2 &lt;= K &lt;= 16) component encoding; A is stored using K-1 bits.
/// Each component is stored as an 8-bit or 16-bit integer; stride must be equal to 4 or 8.
/// Input data must contain 4 floats for every color (count*4 total).
/// </para>
/// </remarks>
public enum MeshOptEncodeExpMode
{
/// When encoding exponents, use separate values for each component (maximum quality)
EncodeExpSeparate,
/// When encoding exponents, use shared value for all components of each vector (better compression)
EncodeExpSharedVector,
/// When encoding exponents, use shared value for each component of all vectors (best compression)
EncodeExpSharedComponent,
/// When encoding exponents, use separate values for each component, but clamp to 0 (good quality if very small values are not important)
EncodeExpClamped,
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,35 @@
using Brutal.Interop;
using Brutal.Numerics;
using Brutal.Pointers;
namespace Brutal.MeshOptimizer
{
[StructLayout(LayoutKind.Explicit, Size = 48)]
public unsafe partial struct MeshOptBounds
{
/// bounding sphere, useful for frustum and occlusion culling
[FieldOffset(0)]
public float3 Center;
[FieldOffset(12)]
public float Radius;
/// normal cone, useful for backface culling
[FieldOffset(16)]
public float3 ConeApex;
[FieldOffset(28)]
public float3 ConeAxis;
/// = cos(angle/2)
[FieldOffset(40)]
public float ConeCutoff;
/// normal cone axis and cutoff, stored in 8-bit SNORM format; decode using x/127.0
[FieldOffset(44)]
public byte3 ConeAxisS8;
[FieldOffset(47)]
public byte ConeCutoffS8;
}
}

View file

@ -0,0 +1,17 @@
using Brutal.Interop;
using Brutal.Numerics;
using Brutal.Pointers;
namespace Brutal.MeshOptimizer
{
[StructLayout(LayoutKind.Explicit, Size = 16)]
public unsafe partial struct MeshOptCoverageStatistics
{
[FieldOffset(0)]
public float3 Coverage;
/// viewport size in mesh coordinates
[FieldOffset(12)]
public float Extent;
}
}

View file

@ -0,0 +1,24 @@
using Brutal.Interop;
using Brutal.Numerics;
using Brutal.Pointers;
namespace Brutal.MeshOptimizer
{
[StructLayout(LayoutKind.Explicit, Size = 16)]
public unsafe partial struct MeshOptMeshlet
{
/// offsets within meshlet_vertices and meshlet_triangles arrays with meshlet data
[FieldOffset(0)]
public int VertexOffset;
[FieldOffset(4)]
public int TriangleOffset;
/// number of vertices and triangles used in the meshlet; data is stored in consecutive range [offset..offset+count) for vertices and [offset..offset+count*3) for triangles
[FieldOffset(8)]
public int VertexCount;
[FieldOffset(12)]
public int TriangleCount;
}
}

View file

@ -0,0 +1,20 @@
using Brutal.Interop;
using Brutal.Numerics;
using Brutal.Pointers;
namespace Brutal.MeshOptimizer
{
[StructLayout(LayoutKind.Explicit, Size = 12)]
public unsafe partial struct MeshOptOverdrawStatistics
{
[FieldOffset(0)]
public int PixelsCovered;
[FieldOffset(4)]
public int PixelsShaded;
/// shaded pixels / covered pixels; best case 1.0
[FieldOffset(8)]
public float Overdraw;
}
}

View file

@ -0,0 +1,19 @@
using Brutal.Interop;
using Brutal.Numerics;
using Brutal.Pointers;
namespace Brutal.MeshOptimizer
{
[StructLayout(LayoutKind.Explicit, Size = 24)]
public unsafe partial struct MeshOptStream
{
[FieldOffset(0)]
public Ptr Data;
[FieldOffset(8)]
public ByteSize64 Size;
[FieldOffset(16)]
public ByteSize64 Stride;
}
}

View file

@ -0,0 +1,24 @@
using Brutal.Interop;
using Brutal.Numerics;
using Brutal.Pointers;
namespace Brutal.MeshOptimizer
{
[StructLayout(LayoutKind.Explicit, Size = 16)]
public unsafe partial struct MeshOptVertexCacheStatistics
{
[FieldOffset(0)]
public int VerticesTransformed;
[FieldOffset(4)]
public int WarpsExecuted;
/// transformed vertices / triangle count; best case 0.5, worst case 3.0, optimum depends on topology
[FieldOffset(8)]
public float Acmr;
/// transformed vertices / vertex count; best case 1.0, worst case 6.0, optimum is 1.0 (each vertex is transformed once)
[FieldOffset(12)]
public float Atvr;
}
}

View file

@ -0,0 +1,17 @@
using Brutal.Interop;
using Brutal.Numerics;
using Brutal.Pointers;
namespace Brutal.MeshOptimizer
{
[StructLayout(LayoutKind.Explicit, Size = 8)]
public unsafe partial struct MeshOptVertexFetchStatistics
{
[FieldOffset(0)]
public int BytesFetched;
/// fetched bytes / vertex buffer size; best case 1.0 (each byte is fetched once)
[FieldOffset(4)]
public float Overfetch;
}
}

View file

@ -0,0 +1 @@
global using System.Runtime.InteropServices;

View file

@ -0,0 +1,44 @@
THIRD-PARTY LICENSE NOTICES
RocketWerkz.Brutal.MeshOptimizer
Brutal.MeshOptimizer redistributes one third-party component, meshoptimizer, as native
libraries on every runtime identifier it supports. It is reproduced below with the
license that governs it.
==============================================================================
meshoptimizer
==============================================================================
Name meshoptimizer, a mesh optimisation library
Version 1.1
built from upstream v1.1.1-36-gc8359675
Upstream https://github.com/zeux/meshoptimizer
SPDX MIT
Shipped as meshoptimizer.dll (win-x64), libmeshoptimizer.so (linux-x64),
libmeshoptimizer.dylib (osx-arm64)
Built from meshoptimizer's own sources only. The upstream project also carries cgltf,
fast_obj and sdefl; all three belong to gltfpack, a separate executable this build
does not produce, so none of them reaches the library shipped here.
MIT License
Copyright (c) 2016-2026 Arseny Kapoulkine
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.