luv

Workshop wiki

light-reference.lisp

luvcraft/light-reference.lisp

system luvcraft/light-reference · 17 definitions · on GitHub

The deliberately simple voxel-light oracle and its differential harness. This file is loaded only by the explicit LUVCRAFT/LIGHT-REFERENCE system; no reference implementation participates in production solver dispatch.

defpackage#:luvcraft.light-reference
:use#:cl#:luv
:export#:compare-voxel-light-solvers#:voxel-light-solver-comparison#:voxel-light-solver-comparison-candidate-bytes-consed#:voxel-light-solver-comparison-candidate-executions#:voxel-light-solver-comparison-candidate-garbage-collections#:voxel-light-solver-comparison-candidate-gc-seconds#:voxel-light-solver-comparison-candidate-seconds#:voxel-light-solver-comparison-candidate-solver#:voxel-light-solver-comparison-candidate-visits#:voxel-light-solver-comparison-equal-p#:voxel-light-solver-comparison-legacy-bytes-consed#:voxel-light-solver-comparison-legacy-garbage-collections#:voxel-light-solver-comparison-legacy-gc-seconds#:voxel-light-solver-comparison-legacy-seconds#:voxel-light-solver-comparison-legacy-visits#:voxel-light-solver-comparison-mismatched-keys
in-package#:luvcraft
records:define-columnar-bufferlight-worklist-bucket

ENTRY supplies the semantic chunk boundary, while OFFSET and LEVEL are unboxed site data. The generated buffer owns their shared extent.

entrynil:type
ornulllight-region-entry
:clear-on-removet
offset0:type
unsigned-byte32
level0:type
unsigned-byte8
defstruct
light-worklist
:constructor%make-light-worklist
scheduling:lifo:type
member:lifo:level
:read-onlyt
field-definitionnil:type:read-onlyt
buckets
:typesimple-vector:read-onlyt
maximum-level-1:typefixnum
count0:typefixnum
defunmake-light-worklist
&key
scheduling:lifo
field-definition

Make the reference solver's packed LIFO or level-scheduled worklist.

This machinery belongs to the test-only voxel-light oracle. Both modes retain ENTRY plus dense OFFSET and LEVEL lanes, never a cons or coordinate object per item. #QS1ERH #LDP5UR

check-typescheduling
member:lifo:level
let*
row-declaration
records:make-columnar-row-declarationlayout-definition
andfield-definition`
level.,field-definition
buckets
dotimes
level
lengthbuckets
setf
arefbucketslevel
make-light-worklist-bucket:capacity256:row-declarationrow-declaration
%make-light-worklist:schedulingscheduling:field-definitionfield-definition:bucketsbuckets
defmethodluvcraft.world.fields:materialized-field-definition
worklistlight-worklist
field-name
let
definition
light-worklist-field-definitionworklist
anddefinition
eqfield-name
luvcraft.world.fields:voxel-field-definition-namedefinition
definition
defunlight-worklist-empty-p
worklist
zerop
light-worklist-countworklist
defunlight-worklist-push
worklistentryoffsetlevel

Push entry, domain offset, and propagation level onto worklist.

check-typeentrylight-region-entry
check-typeoffset
unsigned-byte32
check-typelevel
unsigned-byte8
let*
bucket-level
ecase
light-worklist-schedulingworklist
:lifo0
:levellevel
bucket
aref
light-worklist-bucketsworklist
bucket-level
light-worklist-bucket-pushbucketentryoffsetlevel
incf
light-worklist-countworklist
setf
light-worklist-maximum-levelworklist
maxbucket-level
light-worklist-maximum-levelworklist
worklist
defunlight-worklist-pop
worklist

Pop (VALUES ENTRY OFFSET LEVEL PRESENT-P), clearing retained ENTRY.

when
return-fromlight-worklist-pop
valuesnilnilnilnil
let*
bucket-level
light-worklist-maximum-levelworklist
bucket
aref
light-worklist-bucketsworklist
bucket-level
multiple-value-bind
entryoffsetlevelpresent-p
light-worklist-bucket-popbucket
unlesspresent-p
error"Lighting worklist count disagrees with bucket ~D."bucket-level
decf
light-worklist-countworklist
when
zerop
light-worklist-bucket-lengthbucket
loopforcandidatedownfrom
1-bucket-level
to0when
plusp
light-worklist-bucket-length
aref
light-worklist-bucketsworklist
candidate
do
setf
light-worklist-maximum-levelworklist
candidate
finally
setf
light-worklist-maximum-levelworklist
-1
valuesentryoffsetlevelt
defunpropagate-light-region
regionfield-readerqueueskylight-p

Run the reference FIELD's max-fixpoint propagation from packed queue sites.

let
visited0
with-cpu-trace-zone
:lighting/legacy/drain-sites:tracy-valuevisited
loopuntildo
multiple-value-bind
entryoffsetqueued-levelpresent-p
declare
ignorequeued-levelpresent-p
let*
declare
dynamic-extentlocal
incfvisited
let
level
aref
funcallfield-readerentry
offset
when
plusplevel
do-chunk-window-neighbors
neighbor-offsetdestinationcrossingdirectionmaterializationavailabilityregiondomainlocal*voxel-face-directions*
valuesdestination
let
neighbor
ecaseavailability
:localentry
:availablematerialization
:unavailablenil
whenneighbor
let*
opacity
light-region-opacityneighborneighbor-offset
loss
if
andskylight-p
opacity
candidate
-levelloss
levels
funcallfield-readerneighbor
when
>candidate
areflevelsneighbor-offset
setf
areflevelsneighbor-offset
candidate
light-worklist-pushqueueneighborneighbor-offsetcandidate
visited
defunseed-reference-open-sky-at-offset
entryoffsetdownward-p
let*
when
>level
arefoffset
setf
arefoffset
level
t
defunseed-reference-open-boundaries
regionkeyentryenqueue
dolist
when
map-entry-face-sitesentrydirection
lambda
offsetlocal
valueslocal
when
funcallenqueueentryoffset
arefoffset
defunseed-reference-sky-boundaries
region&key
scheduling:level
let
queue
make-light-worklist:schedulingscheduling:field-definition
maphash
lambda
keyentry
seed-reference-open-boundariesregionkeyentry
lambda
seed-entryoffsetlevel
light-worklist-pushqueueseed-entryoffsetlevel
light-region-entriesregion
queue
defunseed-reference-emitters
region&key
scheduling:level
let
queue
make-light-worklist:schedulingscheduling:field-definition
maphash
lambda
keyentry
declare
ignorekey
let
indices
light-region-entry-indicesentry
do-chunk-domain-sites
offsetlocaldomain
valueslocal
let
level
arefemission
arefindicesoffset
when
plusplevel
setf
areflevelsoffset
level
light-worklist-pushqueueentryoffsetlevel
light-region-entriesregion
queue
defunsolve-light-region
region&key
scheduling:level

Solve region with the explicit test/reference voxel-light oracle.

with-cpu-trace-zone
:lighting/legacy
let*
sky-worklist
with-cpu-trace-zone
:lighting/legacy/seed-sky
seed-reference-sky-boundariesregion:schedulingscheduling
sky-visits
with-cpu-trace-zone
:lighting/legacy/propagate-sky
block-worklist
with-cpu-trace-zone
:lighting/legacy/seed-block
seed-reference-emittersregion:schedulingscheduling
block-visits
with-cpu-trace-zone
:lighting/legacy/propagate-block
valuesregion
+sky-visitsblock-visits
in-package#:luvcraft.light-reference
defstructvoxel-light-solver-comparison
equal-pnil:typeboolean
mismatched-keysnil:typelist
legacy-visits0:type
integer0#.most-positive-fixnum
candidate-visits0:type
integer0#.most-positive-fixnum
legacy-seconds0d0:typedouble-float
candidate-seconds0d0:typedouble-float
legacy-bytes-consed0:typeinteger
candidate-bytes-consed0:typeinteger
legacy-gc-seconds0d0:typedouble-float
candidate-gc-seconds0d0:typedouble-float
legacy-garbage-collections0:typefixnum
candidate-garbage-collections0:typefixnum
candidate-executionsnil:typelist
candidate-solver:compiled:typekeyword
defunlight-regions-mismatched-keys
leftright
let
mismatchesnil
maphash
lambda
keyleft-entry
let
right-entry
gethashkey
luvcraft::light-region-entriesright
luvcraft::light-region-entriesleft
maphash
lambda
keyright-entry
declare
ignoreright-entry
unless
gethashkey
luvcraft::light-region-entriesleft
pushnewkeymismatches:test#'equalp
luvcraft::light-region-entriesright
nreversemismatches
defuncompare-voxel-light-solvers
world&key
candidate:compiled

Compare the test-only legacy oracle with production candidate over world.

Equivalent captures are solved without publication. The result reports exact per-chunk array equality, work and runtime observations, and the candidate's retained frontier executions. Unsupported candidate names signal through the production solver protocol.

with-cpu-trace-zone
:lighting/compare
let
candidate-region
legacy-visits0
candidate-visits0
legacy-seconds0d0
candidate-seconds0d0
legacy-observation
make-runtime-observation
candidate-observation
make-runtime-observation
executionsnil
with-runtime-observation
legacy-observation
multiple-value-setq
legacy-regionlegacy-visits
setflegacy-seconds
runtime-observation-elapsed-secondslegacy-observation
tracy-plot"lighting legacy allocated bytes"
runtime-observation-bytes-consedlegacy-observation
tracy-plot"lighting legacy GC ms"
*1000d0
runtime-observation-gc-secondslegacy-observation
tracy-plot"lighting legacy collections"
runtime-observation-garbage-collectionslegacy-observation
with-runtime-observation
candidate-observation
multiple-value-setq
candidate-regioncandidate-visitsexecutions
luvcraft:solve-light-region-usingcandidatecandidate-region
setfcandidate-seconds
runtime-observation-elapsed-secondscandidate-observation
tracy-plot"lighting candidate allocated bytes"
runtime-observation-bytes-consedcandidate-observation
tracy-plot"lighting candidate GC ms"
*1000d0
runtime-observation-gc-secondscandidate-observation
tracy-plot"lighting candidate collections"
runtime-observation-garbage-collectionscandidate-observation
let
mismatches
light-regions-mismatched-keyslegacy-regioncandidate-region
make-voxel-light-solver-comparison:equal-p
nullmismatches
:mismatched-keysmismatches:legacy-visitslegacy-visits:candidate-visitscandidate-visits:legacy-secondslegacy-seconds:candidate-secondscandidate-seconds:legacy-bytes-consed
runtime-observation-bytes-consedlegacy-observation
:candidate-bytes-consed
runtime-observation-bytes-consedcandidate-observation
:legacy-gc-seconds
runtime-observation-gc-secondslegacy-observation
:candidate-gc-seconds
runtime-observation-gc-secondscandidate-observation
:legacy-garbage-collections
runtime-observation-garbage-collectionslegacy-observation
:candidate-garbage-collections
runtime-observation-garbage-collectionscandidate-observation
:candidate-executionsexecutions:candidate-solvercandidate