Skip to content

Add CUDA WebShader browser encoder and integrated viewer - #1

Draft
SamG-Coder wants to merge 2 commits into
mainfrom
feat/cuda-webshader-encoder
Draft

SamG-Coder wants to merge 2 commits into
mainfrom
feat/cuda-webshader-encoder

Conversation

@SamG-Coder

Copy link
Copy Markdown
Owner

Add a browser encoder at webgpu/encode.html that runs CUDA device kernels through CUDA WebShader and hands exported assets directly to the existing WebGPU viewer. Users can select one to six material maps, fit one-to-four-channel latent planes, compare reconstructions, and download the standard NNTC JSON plus DDS files as a ZIP.

The GPU path covers filtered observation generation, streamed decoder normal equations, four-color latent coordinate descent and reconstruction. Host code handles source mip/PCA initialization, small dense solves, quantization/BC packing and file I/O. The CUDA WebShader submodule pins 896432c, which adds the reusable fitting operation in SamG-Coder/cuda-webshader#2.

Scope: this is a format-compatible browser implementation, not native encoder parity. It uses f32 GPU accumulation and a different optimizer, and does not port all native material options, global sparse solves or decoder-objective BC refinement. The native implementation remains available. docs/BROWSER_ENCODER.md explains supported features and numerical differences.

Validation:

  • Six Node tests pass, including all 32 channel/storage layouts through the existing viewer parser.
  • Seven hardware WebGPU cases pass, covering six distinct output maps, odd sizes, split BC, mip chains, constants, repeated output, early/mid-run cancellation and GPU buffer cleanup. Independent exported-file reconstruction agrees within 2.71e-7.
  • Real UI tests encode the bundled 512x512 single-map and four-map materials, download ZIPs, load the interactive viewer and check desktop/mobile layouts with no browser errors.
  • The upstream Python DDS decoder reads both ZIP exports successfully; its single-map result is 35.16 dB.
  • Local Edge/WebGPU default measurements: approximately 2.8 s / 35.2 dB for m1 and 3.5-3.6 s for m1-m4. Not a native CUDA benchmark.
  • Optional SwiftShader could not obtain an adapter in installed Edge and is not counted as a pass.

Run: git submodule update --init --recursive; npm ci; npm start. Open http://127.0.0.1:5174.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant