examples/Sponza does not build natively: glslang rejects the descriptor_heap combined image sampler in closesthit.glsl #164

Open
opened 2026-10-06 15:31:29 +00:00 by jorijnvdgraaf · 0 comments

Summary

At 2b6f90b, examples/Sponza does not build for the native target. The shader compile fails:

$ cd examples/Sponza && crafter-build
[15/17] Compiling shader closesthit.glsl
closesthit.glsl: GLSL parse failed
ERROR: closesthit.glsl:18: 'albedo' : layout(descriptor_heap) cannot be used with combined image samplers.
ERROR: 1 compilation errors.  No code generated.

Every other native example builds. The system glslang CLI (16.4.0) rejects the file with the same message.

Cause

examples/Sponza/closesthit.glsl:18 declares a combined image sampler in the heap and samples it at line 25:

layout(descriptor_heap) uniform sampler2D albedo[];
...
hitValue = texture(albedo[albedoSlot], bary).rgb;

glslang has refused that since upstream commit c8253623 ("Reject descriptor_heap combined image samplers", 2026-06-30). crafter-build links an unpinned glslang, so any crafter-build built after that date fails here. On the reporting machine the last successful closesthit.spv dates from 2026-06-16.

This is the only such declaration in the repository. The file was last touched in 42a4795 (the SPDX update), so the breakage is unrelated to the descriptor-set fallback that landed in 48aa9be. Nothing caught it because no check builds the examples, and SponzaBench deliberately avoids the texture sample.

Suggested fix

Declare the texture and the sampler separately, as shaders/ui-shared.glsl does:

layout(descriptor_heap) uniform texture2D albedoTexture[];
layout(descriptor_heap) uniform sampler   albedoSampler[];
...
hitValue = texture(sampler2D(albedoTexture[albedoSlot], albedoSampler[0]), bary).rgb;

A copy of the shader with exactly this change compiles with glslang 16.4.0 and passes spirv-val. It has not been run.

The C++ side in examples/Sponza/main.cpp has to follow:

  • the heap is created with no sampler slots (Initialize(2, 1, 0) at line 80) and needs one;
  • the albedo descriptor written at line 206 becomes VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, and the sampler goes into the sampler heap with vkWriteSamplerDescriptorsEXT, the way UIRenderer::RegisterSampler does it.

Both indices should stay constant (a spec constant or a literal): the README notes that a runtime descriptor_heap index inside a hit shader device-losts on the current NVIDIA driver.

README.md (the "Native RT limitation" note) and examples/Sponza/README.md quote the old albedo[albedoSlot] form and need the same update.

## Summary At `2b6f90b`, `examples/Sponza` does not build for the native target. The shader compile fails: ``` $ cd examples/Sponza && crafter-build [15/17] Compiling shader closesthit.glsl closesthit.glsl: GLSL parse failed ERROR: closesthit.glsl:18: 'albedo' : layout(descriptor_heap) cannot be used with combined image samplers. ERROR: 1 compilation errors. No code generated. ``` Every other native example builds. The system `glslang` CLI (16.4.0) rejects the file with the same message. ## Cause `examples/Sponza/closesthit.glsl:18` declares a combined image sampler in the heap and samples it at line 25: ```glsl layout(descriptor_heap) uniform sampler2D albedo[]; ... hitValue = texture(albedo[albedoSlot], bary).rgb; ``` glslang has refused that since upstream commit `c8253623` ("Reject descriptor_heap combined image samplers", 2026-06-30). crafter-build links an unpinned glslang, so any crafter-build built after that date fails here. On the reporting machine the last successful `closesthit.spv` dates from 2026-06-16. This is the only such declaration in the repository. The file was last touched in `42a4795` (the SPDX update), so the breakage is unrelated to the descriptor-set fallback that landed in `48aa9be`. Nothing caught it because no check builds the examples, and SponzaBench deliberately avoids the texture sample. ## Suggested fix Declare the texture and the sampler separately, as `shaders/ui-shared.glsl` does: ```glsl layout(descriptor_heap) uniform texture2D albedoTexture[]; layout(descriptor_heap) uniform sampler albedoSampler[]; ... hitValue = texture(sampler2D(albedoTexture[albedoSlot], albedoSampler[0]), bary).rgb; ``` A copy of the shader with exactly this change compiles with glslang 16.4.0 and passes `spirv-val`. It has not been run. The C++ side in `examples/Sponza/main.cpp` has to follow: - the heap is created with no sampler slots (`Initialize(2, 1, 0)` at line 80) and needs one; - the albedo descriptor written at line 206 becomes `VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE`, and the sampler goes into the sampler heap with `vkWriteSamplerDescriptorsEXT`, the way `UIRenderer::RegisterSampler` does it. Both indices should stay constant (a spec constant or a literal): the README notes that a runtime `descriptor_heap` index inside a hit shader device-losts on the current NVIDIA driver. `README.md` (the "Native RT limitation" note) and `examples/Sponza/README.md` quote the old `albedo[albedoSlot]` form and need the same update.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Catcrafts/Crafter.Graphics#164
No description provided.