microsoft / microsoft/DirectXShaderCompiler
[SPIR-V] `vk::SpirvOpaqueType` as a descriptor , always gets placed in `$Globals`
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
Suppose
Steps to Reproduce
My custom Godbolt
#include "nbl/builtin/hlsl/spirv_intrinsics/core.hlsl"
namespace nbl
{
namespace hlsl
{
namespace spirv
{
//[[vk::ext_capability(spv::CapabilityRayQueryKHR)]]
using RayQueryKHR = vk::SpirvOpaqueType<spv::OpTypeRayQueryKHR>;
//[[vk::ext_capability(spv::CapabilityRayQueryKHR)]]
using AccelerationStructureKHR = vk::SpirvOpaqueType<spv::OpTypeAccelerationStructureKHR>;
//using RayQueryEXT = pointer_t<>;
[[vk::ext_capability(spv::CapabilityRayQueryKHR)]]
[[vk::ext_instruction(spv::OpRayQueryInitializeKHR)]]
void rayQueryInitializeKHR([[vk::ext_reference]] RayQueryKHR query, [[vk::ext_reference]] AccelerationStructureKHR AS, uint32_t flags, uint32_t cull_mask, float32_t3 origin, float32_t tmin, float32_t3 direction, float32_t tmax);
}
}
}
using namespace nbl::hlsl;
[[vk::binding(0,0)]] spirv::AccelerationStructureKHR topLevelAS;
[numthreads(64,1,1)]
void main()
{
spirv::RayQueryKHR rq;
spirv::rayQueryInitializeKHR(rq,topLevelAS,0x0,0x0,float32_t3(1.f,2.f,3.f),0.125f,float32_t3(0.f,0.f,1.f),2048.f);
}
The funny thing is that if I replace with
[[vk::binding(0,0)]] static spirv::AccelerationStructureKHR topLevelAS;
if compiles and codegens completely wrong SPIR-V, (the variable is not in Uniform class, doesn't have the binding decorations, etc.
Actual Behavior
<source>:28:3: error: variable 'topLevelAS' will be placed in $Globals so cannot have vk::binding attribute
[[vk::binding(0,0)]] spirv::AccelerationStructureKHR topLevelAS;
^
Compiler returned: 3221225477
Environment
- DXC version: trunk from Novemeber
- Host Operating System: Windows
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 running the linked Godbolt reproduction and compare the ordinary and static declarations of topLevelAS. Done means the non-static vk::binding declaration no longer reports placement in $Globals, while the generated SPIR-V preserves the Uniform class, binding decorations, and related descriptor behavior.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100