Skip to content

Instantly share code, notes, and snippets.

Avatar

Arseny Kapoulkine zeux

View GitHub Profile
@zeux
zeux / builtin.lua
Created May 20, 2020
Roblox Luau type surface as of May 20, 2020
View builtin.lua
export type any=any
export type nil=nil
export type string=string
export type number=number
export type boolean=boolean
@zeux
zeux / codecbench-clang.txt
Created Apr 25, 2020
codecbench: native gcc vs native clang vs v8 Wasm vs WAVM Wasm
View codecbench-clang.txt
source: vertex data 32064032 bytes, index data 24000000 bytes
pass 0: vertex data 18518385 bytes, index data 2332680 bytes
decode: vertex 9.31 ms (3.21 GB/sec), index 5.65 ms (3.95 GB/sec)
decode: vertex 9.43 ms (3.17 GB/sec), index 5.64 ms (3.96 GB/sec)
decode: vertex 9.44 ms (3.16 GB/sec), index 5.69 ms (3.93 GB/sec)
decode: vertex 9.47 ms (3.15 GB/sec), index 5.72 ms (3.91 GB/sec)
decode: vertex 9.50 ms (3.14 GB/sec), index 5.72 ms (3.91 GB/sec)
decode: vertex 9.36 ms (3.19 GB/sec), index 5.82 ms (3.84 GB/sec)
decode: vertex 9.57 ms (3.12 GB/sec), index 5.75 ms (3.89 GB/sec)
decode: vertex 9.47 ms (3.15 GB/sec), index 5.72 ms (3.91 GB/sec)
@zeux
zeux / fixupsimd.js
Last active Apr 3, 2020
A SIMD opcode remapper for the impending Wasm SIMD instruction renumbering, written on stream https://www.youtube.com/watch?v=zo20ryVj6e8
View fixupsimd.js
function fixupSimd(input) {
var data = new Uint8Array(input);
var read = 0;
var result = new Uint8Array(data.length * 2); // worst case: opcode renumbering changes 1-byte to 2-byte
var write = 0;
var readByte = function() {
read++;
if (read >= data.length) {
@zeux
zeux / codec-versioning.md
Last active Jan 27, 2020
Writing down various options to extend meshoptimizer encoding API with format versioning
View codec-versioning.md

Problem

meshoptimizer currently ships with index and vertex codecs with the API along these lines:

size_t encode(destination, destination_capacity, source, source_size)
void decode(destination, destination_size, source, source_size)

The next version of meshoptimizer needs to make backwards incompatible changes to the encoding format to allow for better compression.

View roblox-graphics-apis-2020.md

State of Roblox graphics API across all platforms, with percentage deltas since EOY 2019. Updated November 6 2020.

Windows

API Share
Direct3D 11+ 88% (+3%)
Direct3D 10.1 7% (-2%)
Direct3D 10.0 4% (-1%)
Direct3D 9 1%
@zeux
zeux / types.lua
Created Jan 18, 2020
Luau dumptypes output as of 1/17/2020
View types.lua
This file has been truncated, but you can view the full file.
type AdvancedDragger={
AncestryChanged:Event,
Archivable:boolean,
AttributeChanged:Event,
AttributesReplicate:string,
AttributesSerialize:any,
Changed:Event,
ChildAdded:Event,
@zeux
zeux / nbody.s
Last active Jan 2, 2020
luaujit: nbody.lua when compiled using experimental Luau JIT engine. All assembly snippets only show inner loop body. Variants: scalar - using type info, records and basic block compiler to generate much more efficient inner loop; vector - scalar but with scalars replaced with first-class 3-component vector
View nbody.s
# table type guard (memory safety)
cmp dword ptr [rdi + 12], 6
jne 1072 <.text+0x5ea>
# load array index and convert to integer (+ exactness check)
movsd xmm0, qword ptr [rdi + 256]
cvttsd2si eax, xmm0
cvtsi2sd xmm1, eax
ucomisd xmm1, xmm0
jne 1046 <.text+0x5ea>
# indices are 1-based; could remove this one with runtime changes
@zeux
zeux / islandize-reuv.cpp
Last active Jun 25, 2019
Isolate UV islands and move each island to 0..1 range if possible; this reduces the total UV range of the mesh.
View islandize-reuv.cpp
unsigned int follow(std::vector<unsigned int>& ids, unsigned int v)
{
unsigned int nv = v;
while (ids[nv] != nv)
nv = ids[nv];
return ids[v] = nv;
}
size_t islandize(const std::vector<unsigned int>& indices, std::vector<unsigned int>& islands)
@zeux
zeux / half-spirv.md
Last active Jun 12, 2020
Notes on supporting half-precision computation in SPIRV based shader pipelines
View half-spirv.md

The following assumes that HLSL source is used as an input for shader compilation, glslang is used to compile it to SPIRV, and then SPIRV-Cross is optionally used to compile the result to MSL/GLSL.

First, make sure you use min16floatN type instead of halfN type. This is necessary because glslang treats halfN type (with default compilation options) as floatN because unfortunately that's what DX10 does as well.

#define half min16float
#define half2 min16float2
#define half3 min16float3
View decomposetrs.cpp
void decomposeMatrix(const float* matrix, float translation[3], float rotation[4], float scale[3])
{
translation[0] = matrix[12];
translation[1] = matrix[13];
translation[2] = matrix[14];
// 0 1 2
// 4 5 6
// 8 9 10
float det =
You can’t perform that action at this time.