KhronosGroup / KhronosGroup/SPIRV-Cross

invalid MSL when using BDA

Open
#2,368 4 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
GLSL
Stars
2.5k
Forks
713
Avg merge
2d 18h
Merged PRs (30d)
16

Description

MoltenVK SDK version is 1.3.290

Full Shader here:
```glsl
#version 460
#extension GL_EXT_buffer_reference : require

layout(std430, buffer_reference, buffer_reference_align = 4) readonly buffer ChunkLocalFaceBuffer
{
uint face_data[];
};

layout(push_constant) readonly uniform PushConstants {
ChunkLocalFaceBuffer ptr_quads_data;
} in_push_constants;

void main() {
const uint face_data = in_push_constants.ptr_quads_data.face_data[46645];
}
```

produces the following error:
```
[Aug 08/23/2024 13:25:47:578:212] [crates/gfx/src/vulkan/inst.rs:148] [ERROR] VK_ERROR_INITIALIZATION_FAILED: Shader library compile failed (Error code 3):
program_source:132:97: error: reinterpret_cast from 'uint' (aka 'unsigned int') to 'ulong' (aka 'unsigned long') is not allowed
bool _43 = inst_buffer_device_address(52u, uint4(0u, gl_VertexIndex, gl_InstanceIndex, 0u), reinterpret_cast(in_push_constants.ptr_quads_data->face_data[46645]), 4u, 61u, _53, _56, _63, _66, _72, _72BufferSize, _83);
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the supplied GLSL shader and reproduce the generated MSL failure through SPIRV-Cross and MoltenVK, using the error reported at crates/gfx/src/vulkan/inst.rs:148 as the reproduction point. Trace the generated buffer-device-address expression involving ptr_quads_data->face_data[46645]. Done means the shader produces valid MSL without the uint-to-ulong reinterpret_cast error.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.