Skip to content

qt-patches: HLSL gl_NumWorkGroups, Metal per-call buffer sizes, Vulkan render-pass sync - #52

Merged
jcelerier merged 3 commits into
masterfrom
qt-patches/hlsl-num-workgroups
Oct 28, 2026
Merged

jcelerier merged 3 commits into
masterfrom
qt-patches/hlsl-num-workgroups

Conversation

@jcelerier

@jcelerier jcelerier commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Three Qt patches found while testing score's shader pipeline on D3D, Metal and Vulkan.

qtshadertools 0003: HLSL gl_NumWorkGroups through a constant buffer

qtshadertools never calls SPIRV-Cross's remap_num_workgroups_builtin(), so a compute shader that reads gl_NumWorkGroups cannot be baked for HLSL (D3D11/D3D12).

  • QShaderBaker::setHlslNumWorkGroupsBinding(int) makes the remap opt-in; nothing changes for shaders that don't set it.
  • The added cbuffer is reported in the native resource binding map, so QRhi can bind it.
  • QT_SHADERTOOLS_HAS_HLSL_NUM_WORKGROUPS_BINDING lets score detect the patched build.

Applies after 0001/0002 on the pinned qtshadertools (4e195e12c7); checked with git apply --check and against the pinned SPIRV-Cross sources. The score side (filling the cbuffer, including for indirect dispatch) comes in a separate score PR and needs a Windows test run.

qtbase 0015: Metal length() reads the sizes of its own draw or dispatch

QRhiMetal rewrote one per-pipeline buffer-size buffer in place on every setShaderResources, so all draws and dispatches recorded with a pipeline in a frame read the storage buffer sizes of the last one. Each call now gets its own region, per frame slot.

score's test_gfx_csf_every_mesh: 24/216 assertions failed on Metal with the continuous SDK, all pass with the patch; 83 other storage, CSF, indirect, raw raster and scene tests unchanged.

qtbase 0016: Vulkan offscreen render passes wait for previous attachment writes

A texture render target's render pass had no external subpass dependency, so the UNDEFINED → attachment layout transition did not chain after the resource-tracking barrier and raced the previous pass's writes to the same image (SYNC-HAZARD-WRITE-AFTER-WRITE at vkCmdBeginRenderPass whenever a frame renders twice into one target).

score on Vulkan with synchronization validation, Linux debug Qt with the patch: 7 tests lose all their validation errors (raw_raster_input_buffer_count 690 → 0, raw_raster_aux_count 575 → 0, selffb_depth_grab, per_layer_depth, raw_raster_depth_array_input, raster_layer_queue, gltf_light_shadows); 84 other render-target tests unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JeL19ofVgPe9u9q7J1V9ex

jcelerier and others added 3 commits October 26, 2026 10:42
qtshadertools never called SPIRV-Cross's remap_num_workgroups_builtin(),
so a compute shader reading gl_NumWorkGroups could not be baked for HLSL.
The patch makes it opt-in through QShaderBaker::setHlslNumWorkGroupsBinding
and reports the added cbuffer in the native resource binding map. Applies
after 0001/0002 on the pinned qtshadertools (4e195e12c7); verified with
git apply --check and against the pinned SPIRV-Cross sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JeL19ofVgPe9u9q7J1V9ex
QRhiMetal rewrote one per-pipeline buffer size buffer in place on every
setShaderResources, so all draws and dispatches recorded with a pipeline
in a frame read the storage buffer sizes of the last one. Each call now
gets its own region, per frame slot.

score's test_gfx_csf_every_mesh: 24/216 assertions failed on Metal with
the continuous SDK, all pass with this patch; 83 other storage, CSF,
indirect, raw raster and scene tests unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JeL19ofVgPe9u9q7J1V9ex
…nt writes

A texture render target's render pass had no external subpass
dependency, so the UNDEFINED -> attachment layout transition of a pass
did not chain after the resource-tracking barrier and raced the previous
pass's writes to the same image: SYNC-HAZARD-WRITE-AFTER-WRITE at
vkCmdBeginRenderPass whenever a frame renders twice into one target.

score, Vulkan, synchronization validation on, Linux debug Qt with the
patch: 7 tests lose all their validation errors (raw_raster_input_buffer_count
690 -> 0, raw_raster_aux_count 575 -> 0, selffb_depth_grab, per_layer_depth,
raw_raster_depth_array_input, raster_layer_queue, gltf_light_shadows);
84 other render-target tests unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JeL19ofVgPe9u9q7J1V9ex
@jcelerier jcelerier changed the title qt-patches: HLSL gl_NumWorkGroups through a constant buffer qt-patches: HLSL gl_NumWorkGroups, Metal per-call buffer sizes, Vulkan render-pass sync Oct 26, 2026
@jcelerier
jcelerier merged commit c7e6e99 into master Oct 28, 2026
12 of 14 checks passed
@jcelerier
jcelerier deleted the qt-patches/hlsl-num-workgroups branch October 28, 2026 00:21
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