Brandon Schneider
|
9c5fe97dc1
|
feat(infra): SPIR-V packet generator and WGSL scar filter shader
Add spirv_packet_generator.py: reads SPIR-V assembly, applies copy-if
optimization (OpPhi→OpSelect transform), and emits JSON packet descriptors
with the 5 OpPhi-derived fields (type_id, cond_id, true_val_id,
false_val_id, result_id) that fully specify the packet layout.
Add burgers_scar_filter.wgsl: 291-line WGSL compute shader for spectral
scar filtering in 2D Burgers RG solver. Uses three copy-if patterns:
1. scar_pressure > threshold → apply hyperviscosity damping
2. |kx| > k_cut || |ky| > k_cut → zero (dealiasing)
3. factor < 0.999 → multiply velocity components
Also fix spirv_copy_if_optimizer.py: OpSelect now uses phi_instr.args[0]
(type operand) as its type, instead of compute_instr.result_id. This
produces structurally correct SPIR-V where the result type matches the
OpSelect opcode layout.
Build: 3313 jobs, 0 errors (lake build)
Tools: glslang, spirv-as, spirv-dis (native); tint from nixpkgs for WGSL
|
2026-05-30 16:40:58 -05:00 |
|
Brandon Schneider
|
2e15c7c0a5
|
feat: SPIR-V copy-if optimizer — skip zero deltas in GPU shaders
Transforms branch-based patterns to OpSelect:
Before: 3 blocks, OpBranchConditional, OpPhi
After: 1 block, OpSelect (single-cycle on most GPUs)
Pattern detection:
- OpSelectionMerge + OpBranchConditional
- True block: single compute + OpBranch
- False block: empty (just OpBranch)
- Merge block: OpPhi merging true/false values
Transformation:
- Remove SelectionMerge + BranchConditional
- Inline compute instruction
- Replace OpPhi with OpSelect
- Collapse 3 blocks to 1
Same pattern as:
- VCN delta+RLE (3.3x): skip zero bytes
- QR spatial hash (2.18x): skip non-neighbors
- Lean compilation (2.7x): skip trivial theorems
- Spatial hash (86.5% cache hit): skip empty cells
Driver-agnostic: works at SPIR-V level before Mesa.
No Mesa fork required. No NIR pass needed.
|
2026-05-30 15:57:08 -05:00 |
|