microsoft / microsoft/DirectXShaderCompiler

[SPIR-V] Cannot cast initializer type 'int' into variable type 'RaytracingAccelerationStructure'

Open
#8,111 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug spirv
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.