Skip to content

feat(heap): multisampled depth, storage textures and acceleration structures in the heap - #16

Merged
turbo-devv merged 4 commits into
mainfrom
feat/heap-ms-storage-accel
Nov 24, 2026
Merged

turbo-devv merged 4 commits into
mainfrom
feat/heap-ms-storage-accel

Conversation

@turbo-devv

@turbo-devv turbo-devv commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Shaders can now read three more kinds of resource from the heap (group 7), indexed by immediates, so openOMSI's renderer can drop its last root bind groups.

Heap bindings

Binding Contents Declared by
0..=5 mx_tex2d .. mx_tex2d_u32 (unchanged) prelude
6 mx_texdepth_ms: binding_array<texture_depth_multisampled_2d> (new) prelude
7, 8 mx_samplers, mx_samplers_cmp (were 6, 7) prelude
9, 10 mx_buffers, mx_rw_buffers (were 8, 9) prelude
11 binding_array<acceleration_structure> shader
12..=15 binding_array<texture_storage_2d<F, write>>, any format shader
16..=63 typed buffer views (unchanged) shader

Everything refers to mx_shader::heap::*. Acceleration structures are not in the prelude, which would ask every shader for ray queries.

  • Storage textures: a view of a STORAGE_BINDING texture showing one mip of a 2D texture gets a heap index (the same one as its sampled view when the texture also has TEXTURE_BINDING). All arrays at 12..=15 alias one array of storage textures.
  • Acceleration structures: Tlas::index(), taken from the texture index space.

Per backend

  • Metal 3: storage views and TLASes go in the texture table (MTLResourceIDs). Storage textures are declared for writing, and TLASes plus the BLASes of their last build for reading, on every encoder. Direct heap binding (write_direct) binds TLASes with set*AccelerationStructure. Metal 2 (bound tier) refuses heap acceleration structures.
  • Vulkan: MS depth views are written into binding 6. A STORAGE_IMAGE array sits at binding 12 (needs descriptorBindingStorageImageUpdateAfterBind) and an ACCELERATION_STRUCTURE_KHR array at binding 11. Ray queries now require descriptorBindingAccelerationStructureUpdateAfterBind, which every driver with ray queries has.
  • Direct3D 12: after the buffer UAVs come T UAVs, one per texture slot, for storage views. TLAS SRVs sit in texture slots. Root-signature ranges cover them (spaces 27 and 28..=31), and the sampler heap moves to space 80. Draws and dispatches that write storage textures through the heap put them in UNORDERED_ACCESS. The texture-slot limit is halved because each slot now takes two descriptors.
  • OpenGL: heap storage textures bind to image units (GL 4.2 / ES 3.1 and later).
  • Direct3D 11: heap storage textures bind as UAVs, MS depth as SRVs.
  • naga (vendor/naga/MX_PATCHES.md): the validator and the MSL writer now accept binding arrays of acceleration structures. The HLSL storage-texture unreachable! happened because mX's binding map gave those arrays no size; that is fixed in mx_shader::hlsl and needed no naga patch.

Tests

New conformance tests: MS depth read through mx_texdepth_ms; a compute pass writing rgba16float and rgba8unorm storage textures through the heap, then sampling one of them through mx_tex2d; ray queries against two TLASes taken from the heap.

Ran on an M4:

  • cargo test -p mx-types -p mx-shader --all-features: pass. Includes new unit tests per writer, SPIR-V through spirv-val and GLSL through glslangValidator.
  • Conformance, 33 tests:
    • Metal: pass with and without MX_METAL_DIRECT=0 and MX_NO_RESIDENCY_SET=1, and under Metal API and shader validation.
    • MX_METAL_BOUND=1: pass.
    • MoltenVK under the Khronos layer with sync validation: pass, only the two known reports. MoltenVK has no ray queries, so that test is skipped.
    • ANGLE ES 3.0: pass, with the new MS-depth and storage tests skipped (no MS textures or images on ES 3.0).
  • openomsi_shaders: pass on Metal, Metal 2, MoltenVK and ANGLE.
  • cargo clippy (workspace, and x86_64-pc-windows-gnu for mx-dx12/mx-dx11/mx) and cargo fmt: clean.

Not run: Direct3D 12 and 11 (compiled only; CI's WARP runs the D3D12 tests), Vulkan ray queries through the heap, GL storage textures and MS depth (CI's llvmpipe runs them).

OpenGL fixes (found with openOMSI on ANGLE):

  • fix(gl) 8118158: a dropped view's heap slot stays readable until its submission is done. GL replays command buffers at submit; the entry was cleared at once, so a draw recorded before the drop bound an empty slot (openOMSI's GPU mip chain came out black). Test: a_removed_slot_reads_until_reclaimed.
  • fix(gl) a78aa1a, eaa7aa1: blend state and colour masks. glow calls the ES 3.2 glEnablei / glBlendFuncSeparatei / glColorMaski, which ANGLE's ES 3.0 refuses, so blending was off. Targets that agree now use the plain calls; others use OES_draw_buffers_indexed's entry points, loaded through EGL (IndexedOes), on ES 3.0/3.1. Checked with openOMSI's renderer and interface on ANGLE.

…tructures in the heap

Heap bindings renumbered: 0..=6 sampled textures (mx_texdepth_ms at 6), 7/8 samplers,
9/10 mx_buffers/mx_rw_buffers, 11 acceleration structures, 12..=15 shader-declared
storage-texture views, 16..=63 typed buffer views. Writers place the new kinds (MSL:
texture table; SPIR-V: one storage-image binding, one AS binding; HLSL: spaces 14, 27,
28..=31, sampler heap moved to space 80). naga patched for binding arrays of acceleration
structures (validator, MSL writer).
…l, Vulkan and GL

- Texture views with STORAGE_BINDING (one mip of a 2D view) get a heap index; TLASes
  get one too (Tlas::index), in the texture index space.
- Metal: storage views and TLASes in the texture table; storage textures declared for
  writing, TLASes and their BLASes declared to every encoder; direct binding of TLASes;
  Metal 2 refuses heap acceleration structures.
- Vulkan: MS depth views in mx_texdepth_ms, a STORAGE_IMAGE array and an
  ACCELERATION_STRUCTURE_KHR array in the heap set (update after bind); ray queries now
  need descriptorBindingAccelerationStructureUpdateAfterBind.
- GL: heap storage textures bound to image units.
- Conformance tests for each kind.
…ct3D 12 and 11

- Direct3D 12: a UAV per texture slot after the buffer UAVs for storage-texture views,
  TLAS SRVs in texture slots (Tlas::index), root signature ranges for both (spaces 27 and
  28..=31); draws and dispatches that write storage textures through the heap put them in
  UNORDERED_ACCESS. The texture limit halves (two descriptors a slot).
- Direct3D 11 (bound tier): heap storage textures bound as UAVs, MS depth as SRVs.
@turbo-devv
turbo-devv merged commit 57f28f0 into main Nov 24, 2026
4 checks passed
turbo-devv added a commit to turbo-devv/openOMSI-fork that referenced this pull request Nov 24, 2026
turbo-devv added a commit to openOMSI-org/openOMSI that referenced this pull request Nov 24, 2026
* perf(render-mx): the temporal motion group read from the heap

The motion vectors' uniform and the last frame's model places are read at the scene
shader's lights and grid places, which the motion pipelines do not otherwise read
(MotionHeap); no group 3 for them.

* build(mx): pin mX aca1cb9 (MS depth, storage textures and acceleration structures in the heap; openOMSI-org/mX#16)

* perf(render-mx): the last bind groups go: ray tracing and the multisampled pane depth through the heap

- groups_to_heap reads storage textures (one heap array a format, mX's bindings 12-15),
  acceleration structures (mx_tlas, binding 11), multisampled depth (mx_texdepth_ms) and
  writable buffers (read-write typed views; HeapGroup makes writable views for them), and
  keeps a module's enable directives first.
- The ray tracing's modules (lighting, texture means, coordinates, reflections, denoiser)
  read everything from the heap (RT_LIGHTING, RT_AVG, RT_UV, RT_REFLECT, RT_DENOISE).
- The masked prefill reads the panes' multisampled depth at the frame's ground place.
- every_module_in_the_heap_validates covers the ray tracing and the scene shader.

* build(mx): pin mX 8118158 (GL heap slots stay readable until their submission is done)

* build(mx): pin mX a78aa1a (OpenGL ES 3.0 blends: no per-buffer calls where the targets agree)

* perf(ui-mx, xr-mx): the interface and the headset's mirror read their pictures from the heap

A layer's numbers and the picture's and sampler's places are a draw's 128 bytes of
immediates; the per-layer uniform buffer and the bind groups go. No bind groups are left in
openOMSI's mX crates.

* docs(mx): no bind groups left; the GL fixes

* build(mx): pin mX eaa7aa1 (per-buffer blending through OES_draw_buffers_indexed on ES 3.0)

* build(mx): pin mX c447f0b (openOMSI-org/mX#17: the GL fixes on top of main)
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