Skip to content

Bring support for wasm and mac - #17

Closed
cwfitzgerald wants to merge 18 commits into
trunkfrom
support-for-wasm-mac
Closed

cwfitzgerald wants to merge 18 commits into
trunkfrom
support-for-wasm-mac

Conversation

@cwfitzgerald

Copy link
Copy Markdown
Owner

Checklist

  • cargo clippy reports no issues
  • cargo doc reports no issues
  • cargo deny issues have been fixed or added to deny.toml
  • Human-readable change descriptions added to CHANGELOG.md under the "Unreleased" heading.
    • If the change does not affect the user (or is a process change), preface the change with "Internal:"
    • Add credit to yourself for each change: Added new functionality. @githubname

Description

Related Issues

Add FormatProfile {Core, Tier2, Native} with from_device detection and an
override on FsrContextInfo. Expose FsrFormats via FsrContext::formats(); validate
caller-provided textures against the active profile. Only Native is wired up;
Core/Tier2 assert pending their shader variants.
Seven storage images are only ever imageStore'd; declare them writeonly in
GLSL and bind them WriteOnly. Required for the widened core-profile formats
(which only validate as write-only) and a correctness improvement on native.
Regenerated SPIR-V and shader table.
Frame info is a single read-modify-write vec4 of per-frame metadata. Storing it
in a 1x1 Rgba32Float texture needs read-write storage-texture access, which is
heavily restricted in baseline WebGPU. Back it with a storage buffer instead —
unrestricted read-write at every format profile, and simpler. Profile-independent.
@cwfitzgerald
cwfitzgerald force-pushed the support-for-wasm-mac branch from 0b74975 to f794931 Compare June 9, 2026 18:48
Add the FFX_WGPU_FORMAT_PROFILE shader permutation and FSR3_FMT_* macros that
remap storage-image formats per profile: on Core, single-channel sampled
textures widen to RGBA and point-sampled/read-write ones pack into 32-bit
formats. Thread FormatProfile through choose_shaders, resource format
selection, texture creation, and bind-group layouts (unfilterable sample types
for the packed core formats). The xtask names the profile enum Core/Tier2/Native.

SPD mips still use the native format; Core/Tier2 remain asserted-off until the
SPD restructure lands. Native is unchanged.
Pull the passthrough-vs-SpirV shader-module creation out of FsrPass::new into a
shared create_shader_module, so the upcoming Core SPD pyramid passes can reuse
it. No behavior change.
…eader

Move the per-pixel shading-change difference metric (the sample sets, sorting
network, ComputeDiff, and SpdLoadSourceImage) out of
ffx_fsr3upscaler_shading_change_pyramid.h into a new
ffx_fsr3upscaler_shading_change_diff.h, included by the pyramid header. This
lets the upcoming Core write-only mip0 pass share the exact same metric.
Preprocessed output is unchanged, so the compiled SPIR-V is identical.
Tier2 keeps FFX's single-pass SPD but widens the mips to rgba16float.
Core has no multi-channel read-write storage, so the luma and
shading-change pyramids become a chain of write-only single-level
dispatches (mip0 reduction, downsample chain, auto-exposure), behind an
SpdPyramid wrapper that keeps the dispatch call sites profile-agnostic.
Lifts the Native-only assert and adds Core/Tier2 smoke tests plus a
Core-vs-Native scene-average comparison.

The packed 32-bit Core formats (R32Float / Rg32Float) are not filterable on a
baseline device without float32-filterable, so the exposure, dilated depth,
dilated motion-vector, and new-locks SRVs are bound unfilterable on Core, and
the debug view point-loads the dilated depth and motion vectors instead of
linearly sampling them. They are only ever point-loaded in production passes.
Verify wgpu-ffx builds for wasm32-unknown-unknown with the WebGPU backend (clippy + doc), so the WebGPU-compatible Core profile keeps compiling for the web even though we do not run it there.
@cwfitzgerald
cwfitzgerald force-pushed the support-for-wasm-mac branch from f794931 to d96d4b8 Compare June 9, 2026 19:40
@cwfitzgerald
cwfitzgerald force-pushed the support-for-wasm-mac branch from d34afb3 to a29d26c Compare June 9, 2026 21:17
cwfitzgerald and others added 4 commits June 29, 2026 15:50
…passthrough path

PASSTHROUGH_SHADERS being present does not mean the active backend consumes
SPIR-V passthrough; only Vulkan does. Pick the shader delivery from the adapter
backend so Metal/DX12 take the naga ShaderSource::SpirV path instead of failing
create_shader_module_passthrough.

The single-pass SPD decorates a read-write storage image `coherent`, which naga
rejects (memory decorations are only valid in the storage address space), so it
is only usable on the passthrough path. Naga backends now use the write-only
Core SPD mip chain at every profile, sidestepping the coherent image.
…t every profile

InputExposure (Rg32Float) and OutputDilatedDepth (R32Float) are 32-bit float at
every profile and only ever point-loaded (texelFetch, no sampler), but their
SRV layout entries were only marked unfilterable on Core. On Tier2/Native a
filterable binding rejects the 32-bit view format at create_bind_group on any
device lacking float32-filterable (e.g. Metal under AUTO_EXPOSURE). Mark both
unfilterable at every profile.

Add fsr_dispatch_smoke_auto_exposure, which drops FLOAT32_FILTERABLE and runs a
dispatch with HIGH_DYNAMIC_RANGE | AUTO_EXPOSURE (exposure: None) to bind the
internal default-exposure texture and exercise the fallback.
@cwfitzgerald

Copy link
Copy Markdown
Owner Author

So the thing is that this runs but has visual artifacts, so I'm going to close it.

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