microsoft / microsoft/DirectXShaderCompiler
[SPIR-V] Cannot cast initializer type 'int' into variable type 'RaytracingAccelerationStructure'
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
My usage of loading RaytracingAccelerationStructure from ResourceDescriptorHeap doesn't compile in Spirv mode, but it does in regular dx12 mode when using templated casting in a very specific syntax.
Steps to Reproduce
This fails to compile with the error message: error: Cannot cast initializer type 'int' into variable type 'RaytracingAccelerationStructure' T operator[](uint index) { return T(ResourceDescriptorHeap[index]); }
template<typename T>
struct BindlessResource
{
T operator[](uint index) { return T(ResourceDescriptorHeap[index]); }
};
static const BindlessResource<RaytracingAccelerationStructure> bindless_accelerationstructures;
The workaround is to have different casting syntax:
template<typename T>
struct BindlessResource
{
T operator[](uint index) { return (T)ResourceDescriptorHeap[index]; }
};
static const BindlessResource<RaytracingAccelerationStructure> bindless_accelerationstructures;
Environment
- DXC version version: 1.9 (2025 last release)
- Host Operating System: Windows 11
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the templated BindlessResource case in DXC's SPIR-V mode, using ResourceDescriptorHeap and RaytracingAccelerationStructure as shown in the issue. Trace the handling of constructor-style casts versus C-style casts, then confirm that the constructor form compiles without breaking the regular DX12 behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100