Commit graph CultLib/packages/cultmath/tools
Author SHA1 Message Date
Meta Vens
ab86876362 build-glsl.sh: delete the [128] shape arm; the shape check runs on a library array of length 128 through the real script
Selection is by name, so a non-site 128 array is legitimate output. The shape check is a function and the array-128 variant passes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 00:37:44 +02:00
Meta Vens
263fc4b435 spvedit.py: drop the sentinel value check (the wrapper owns the sentinel); test the element-type check with a float3 array of the sentinel length
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 23:42:01 +02:00
Meta Vens
f736994942 build-glsl.sh: test that a consumer's own SPIRV_CROSS_CONSTANT_ID_0 and the built core.glsl coexist
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 23:30:35 +02:00
Meta Vens
72af377a05 build-glsl.sh: the length-in-expression refusal test spells the sentinel in hex, which dxc keeps as the capacity constant
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 23:20:48 +02:00
Meta Vens
7416e8a775 glsl build: the capacity constant carries CultMath's own SpecId, so a consumer's SPIRV_CROSS_CONSTANT_ID_0 cannot clash
SPIRV-Cross names the macro from the SpecId and offers no option to rename it, so the SpecId is CultMath's own
('CMS1'); partition.py reads it from spvedit.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 23:00:04 +02:00
Meta Vens
ae838b60fd glsl build: the capacity edit names the site arrays by a sentinel length, with tests for the tool refusals
wrappers.py compiles the library with CULTMATH_MAX_SITES defined as a sentinel no shader file spells, so the three
site arrays get an array length id of their own and spvedit.py converts exactly that constant to the overridable
specialization constant (default from the HLSL guard). A library array of literal length 128 keeps its own id and
stays a plain constant. build-glsl.sh gains the pipeline function and scratch variants: a macro outside a declarator,
a folded expression reaching the capacity id, and a non-site float4 x[128] parameter that a consumer's override must
not resize. The [128] shape arm goes: a non-site 128 array is legitimate output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 22:59:55 +02:00
Meta Vens
38668b6ec0 nocontract.py and run-lavapipe.sh: the strict-form gate under GLSL_DIR (-Gis, NoContraction on both modules)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 21:41:56 +02:00
Meta Vens
7b121f6ab2 build-glsl.sh: capacity checks (a) to (e), and a [128], _cos, _sin shape refusal
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 21:36:35 +02:00
Meta Vens
c2658fa0b2 partition.py: the capacity header at the head of core.glsl, the one spec-constant block accepted
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 21:36:34 +02:00
Meta Vens
40ab7a20c5 spvedit.py: the capacity edit, one array length id becomes a spec constant (SpecId 0)
Does not build alone: partition.py refuses the spec-constant block until the next commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 21:36:34 +02:00
Meta Vens
51f284ac6c wrappers.py: array arguments by declarator name, a capacity column, a refusal for CULTMATH_MAX_SITES outside its guard
Does not build alone: spvedit.py still reads four columns until the next commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 21:36:31 +02:00
Meta Vens
7c47cbaffd Merge origin/main (phasor-field-rename a085c0b3) into hands/cultmath-glsl-build-dxc
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 21:32:08 +02:00
Meta Vens
150ea0a060 CultMath shaders: cultmath_power_border, cultmath_lattice_cell_distance and cultmath_weighted_lattice_cells over a fixed-capacity site array
CULTMATH_MAX_SITES defaults to 128 under #ifndef. The consumer-written ring-loop and border-loop comment recipes are deleted. The C# mirror takes the array as T[]; the span twins live in SiteArrays; the GLSL lowering keeps the capacity macro; gen.py learns the array leaf; the smooth-step family gains its cap-point draw; CULTMATH_WRITE_GLSL refuses non-Linux.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 16:09:18 +02:00
Meta Vens
b7f18ff5b1 build-glsl.sh: fail on inout, param_var_, wrapper names, export and mix(mix( in the output
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 13:24:11 +02:00
Meta Vens
9f0c20929c cultmath device run: GLSL_DIR runs the built route and compares lavapipe-glsl to lavapipe-hlsl bit for bit
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 13:04:16 +02:00
Meta Vens
330290dbd3 partition.py: fix duplicate-signature key
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 12:59:52 +02:00
Meta Vens
cd94a2185d partition.py: duplicate chunks are duplicate signatures, not names (overloads)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 12:58:55 +02:00
Meta Vens
bcb263f2cc cultmath glsl build: build-glsl.sh, pinned tools, pipeline, ES 3.00 and consumer checks
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 12:54:26 +02:00
Meta Vens
951bd15635 cultmath glsl build: partition.py, origin partition and constants with refusals
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 12:53:48 +02:00
Meta Vens
b10f4530d0 cultmath glsl build: spvedit.py, the one SPIR-V edit with by-value parameters
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 12:49:50 +02:00
Meta Vens
da082e7e7c cultmath glsl build: wrappers.py, build-only export wrappers (188) with a count refusal
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 12:49:12 +02:00
Meta Vens
4bf6e6750c Merge hands/cultmath-shader-conforming-run (verdicts s1, s2) 2026-10-16 23:33:53 +02:00
Meta Vens
9a3ad78c11 cultmath: lavapipe bounds carry exact result bits, a reduced-precision tripwire, and the judge reads the stated device tolerance
Per verdict s1: the judge keeps the fixture tolerance as correctness and adds a recorded sha256 of each family's
result per route (a change in the computation fails until re-recorded); a test refuses mediump/lowp/precision
other than highp and min16float/min10float/min16int/half in the committed shaders; phacelle's tolerance text states
a device clause (2^-18) that the judge parses and enforces. The committed bounds file lacks the new column until
the next WRITE_BOUNDS=1 job, so this commit's device run fails and it does not pass DeviceResultsHoldFixture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 21:22:14 +02:00
Meta Vens
d02da58d7e cultmath: run-lavapipe.sh prints one hash of all device outputs, so a repeat run shows determinism
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 20:08:52 +02:00
Meta Vens
cc00ee09b9 cultmath: generator maps integer vector and matrix return types to HLSL (applied)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 20:02:37 +02:00
Meta Vens
89bf977dcf cultmath: generator maps integer vector and matrix return types to HLSL
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 20:01:10 +02:00
Meta Vens
37bc6de8b1 cultmath: lavapipe shader generator, Vulkan host and job script
tools/device/gen.py spells one HLSL and one GLSL ES 3.10 compute shader per work
item, vkrun.c dispatches it on the first Vulkan device, run-lavapipe.sh runs the
whole conforming job. None of them compares. Also fixes the metric test's family
choice. Not yet run: these may not build or run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 19:59:42 +02:00
Meta Vens
7d75b45240 compile-glsl.ps1: a function with no parameters is called with no arguments
The wrapper built one empty argument for an empty parameter list, so cultmath_site_cells_empty() failed glslang.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 18:34:34 +02:00
Meta Vens
4250dd28d5 cultmath: compile-hlsl.ps1 fails on warnings and on a missing shader without its path; compile-glsl.ps1 passes struct arguments
dxc runs with -WX; a ShaderPath that is not a file throws naming the parameter and entry index,
never the path; the GLSL wrapper builds a struct parameter from its declaration's field zeros.
design.md and README state the struct-argument twin rule, the span twins and the missing shader identity.
No C# change; the compiles run on Starfire after the last commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 03:02:13 +02:00
Meta Vens
5b9c77480b cultmath: compile-hlsl.ps1 comment no longer names a dxc architecture directory
The spec's negative check greps the script for arm64; the comment matched. Comment
only; script rerun on Starfire (compiles both copies, exit 0; arm64 dxc control throws). Builds.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 01:30:23 +02:00
Meta Vens
b2852304b1 cultmath: flat integral_clamp_linear returns +0 for a zero-length span; HLSL guard, lo-normalise and pin tests behavioural; owned dxc compile script
The b == 0 branch now guards t1 != t0 like the sloped branch (C# and both HLSL
copies), so an infinite bound times a zero length no longer forms NaN.
Edge-grid mirror test and a counting-clamp shadow test replace the text-order
check; the four pin tests assert equality with their measured expression;
tools/compile-hlsl.ps1 is the one dxc compile verdict for the HLSL copies.

Builds. CultMath.glsl and glsl-parity.json are not yet regenerated, so
CommittedGlslEqualsLowering and GoldenFixtureMatchesCSharp are red at this
commit; the next commit regenerates them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 01:01:54 +02:00
Meta Vens
77a60d2910 CultMath Cycles: an infinite exponent is even in cycles_power; the oracle's infinite family and the pins for infinite operands
cycles_power read b - 2 floor(0.5 b) != 0 as odd, which is NaN for b = +-inf, so a negative base got a negative result where Cycles' powf(a, +-inf) is never negative. Odd now means the remainder is exactly 1 (C#, HLSL, Unity copy). oracle.py gains the infinite family (operands made in-kernel as +-exp(100), results read through comparisons with 0) for power, modulo and Map Range Smooth Step; the infinite.json fixture and the regenerated GLSL follow in the next commit. This commit builds; InfiniteOperandsFollowBlender and CommittedGlslEqualsLowering fail until it lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 04:42:39 +02:00
Meta Vens
c65725da8f CultMath Cycles: arcsine, arccosine and arctan2 with Cycles' guards; per-function oracle seeds; the ruled unfused reference, empty Tolerances and the class table
Fixtures and the regenerated GLSL follow in the next commit, so the tests that read the new rows
(InverseTrigonometry..., OperandStreams...) are red at this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 02:45:51 +02:00
Meta Vens
3ea9c32382 CultMath oracle: the exact-zero Burn rows put a colour above 1 in every channel
The z channel's boundary mutant survived because 0/0 reads as 0 after the clamp. mix.json follows. Builds.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 10:00:57 +02:00
Meta Vens
3a83ee361a CultMath: Burn cases with a divisor of exactly 0, and tests for what the film hides (guards returning 0) and for rgb_to_hsv's primaries
Stryker's survivors in math.Cycles.cs that were not equivalent: Burn's divisor <= 0 boundary, Logarithm's
a <= 0 guard, and rgb_to_hsv's h < 0 wrap. mix.json is regenerated in a later commit, so
FamilyMatchesBlender is unchanged here and the new Burn rows are absent. Builds.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 09:50:14 +02:00
Meta Vens
602c88444d CultMath oracle: power cases with a base of -1 and exponents past the int range, and compare cases inside FLT_EPSILON
The film zeroes an infinite result, which had hidden both the power quirk and Compare's epsilon floor
from the fixtures (two hand mutants of the HLSL survived). The fixtures are regenerated in a later commit.

Builds.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 09:04:28 +02:00
Meta Vens
ddca0252e6 CultMath: a Blender ramp table has 257 entries (size + 1 at i / 256); the oracle samples it so, and the oracle test leaves unread operands unread
Builds. Fixtures and CultMath.Cycles.glsl are still to come.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 06:14:44 +02:00
Meta Vens
892cfbaa6a CultMath: rgb_to_hsv divides by 6 the way Cycles' kernel does (a multiply by 1/6); the ramp is checked by a constant ramp (index) and a linear one (weight); Map Range sockets by their identifiers; the mirror pins 115 functions
Builds. Fixtures and CultMath.Cycles.glsl are still to come.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 05:51:30 +02:00
Meta Vens
51c5da11c4 CultMath: cycles_modulo is exact (power-of-two subtraction, no quotient form); RGB to BW coefficients are Blender's; oracle.py pins the SSE4.2 CPU kernel
The oracle's first fixtures showed Cycles' AVX2 kernel fuses multiply-adds and its film zeroes
non-finite results; the tool now exits 4 off the SSE4.2 kernel (CYCLES_CPU_NO_AVX2=1) and the
test skips cases Cycles cannot report. The Unity copy of CultMath.hlsl carries the new include.

Builds. Fixtures and CultMath.Cycles.glsl are still to come.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 05:28:03 +02:00
Meta Vens
e3c94f8edc CultMath: oracle.py reads Mix and Map Range sockets by identifier; GlslMirrorTests compiles; compile-glsl.ps1 takes -Cycles
Builds.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 04:41:18 +02:00
Meta Vens
99884cc34c CultMath: the Cycles oracle tool (oracle.py) and CyclesOracleTests
oracle.py bakes each Cycles node under Blender 5.2.2 LTS (build d13f752e3b9c, refusing any other)
into float images; CyclesOracleTests holds math.cycles_* to the fixtures it writes. No fixtures
exist at this commit, so the tests fail here; builds.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 04:04:39 +02:00
Meta Vens
8b970cbebf CultMath tools: compile-glsl.ps1 -Phacelle concatenates CultMath.Phacelle.glsl after the library
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 13:40:16 +02:00
Meta Vens
34a9329db5 CultMath tools: get-glslang.ps1 (pinned 16.6.0) and compile-glsl.ps1
compile-glsl.ps1 writes the wrapper a WebGL2 consumer writes (#version 300 es, highp precision,
the library by concatenation, one call of every public function) and compiles it with glslang;
-Body replaces the calls, for the negative control.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 20:09:45 +02:00
Meta Vens
7821e06d55 Add HLSL vector conversions, int clamp, and double frac to CultMath
Aetheria Cut 8a needs int2(float2), clamp(int, int, int), and
frac(double). Fill them in CultMath as dxc compiles them:

- generate-swizzles.ps1 emits same-size conversion constructors and
  math functions between float, int, and bool vectors. dxc lowers
  float to int as fptosi (toward zero; NaN and out-of-range undefined),
  numeric to bool as != 0 (fcmp une, NaN is true), bool to numeric as
  0 or 1. floatN(int) splat keeps floatN(0) from going ambiguous
  against floatN(intN).
- Int and int-vector clamp are min(max(x, a), b), matching dxc's
  IMin(IMax(x, a), b); inverted bounds return b.
- frac(double) keeps double precision. dxc demotes double frac to
  float, as it does exp and lerp; CultMath's existing double overloads
  already diverge that way, and design.md now says so.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 16:16:32 +02:00
Meta Vens
77ee6fe488 Pin dxc to dxc_2026_07_29 and verify its SHA256
get-dxc.ps1 fetched releases/latest with no pin or hash, so the compiler that
defines parity could change under the tests. It now downloads v1.9.2607's
dxc_2026_07_29.zip (dxcompiler 1.9.0.5402) and refuses a zip whose SHA256 is
not A1DFB116...CD241. The hash was taken from the zip downloaded from
Microsoft's GitHub release and matches the digest GitHub publishes for the
asset. Script ran end to end and installed 1.9.0.5402.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 14:17:11 +02:00
Meta Vens
5d8ef0c3de Generate every HLSL swizzle and mixed constructor; fix intrinsic types
tools/generate-swizzles.ps1 writes the checked-in src/CultMath/Swizzles.g.cs
as partial structs plus a partial math: for float2/3/4, int2/3/4 and bool2/3/4
every swizzle of length 2-4 including repeats, in xyzw and rgba naming, with
setters only on non-repeating masks, plus single-component r/g/b/a. double2/3
get lengths 2-3 (there is no double4). Every HLSL mixed constructor
(float4(float2, float2), float4(float, float2, float), copy forms, ...) exists
as a struct constructor and, for float/int/bool, a math function. The
hand-written swizzles and mixed constructors it supersedes are deleted.

Matrices store private rows and return ref float2/float3 from the row
indexer ([UnscopedRef], polyfilled for netstandard2.1), so m[1][2] = s
compiles as in HLSL; _mRC are get/set properties over the rows. Equality and
hashing stay value-based.

Intrinsics follow HLSL: sign returns int/intN and yields 0 for NaN; step is
x >= y ? 1 : 0 so NaN yields 0; any/all accept float and int vectors;
min/max/abs on int vectors return int vectors, and abs(int) returns int.

Strips the UTF-8 BOMs this branch added to math.cs, CultMath.csproj and
HlslSemanticsTests.cs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 13:57:02 +02:00
Meta Vens
ea88cfcd05 Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00