Bindless Textures ignored when using GL_EXT_buffer_reference2.
DoeringChristian opened this issue · comments
DoeringChristian commented
I have tried to reflect this glsl code:
#version 460
#extension GL_EXT_ray_tracing : require
#extension GL_EXT_nonuniform_qualifier : enable
#extension GL_EXT_buffer_reference2 : require
#extension GL_EXT_scalar_block_layout : enable
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
layout(set = 0, binding = 0) buffer Instances{
uint64_t refs[];
};
layout(set = 0, binding = 1) uniform sampler2D textures[];
layout(buffer_reference, scalar) buffer Indices{
uint i[];
};
void main(){
uint64_t ref = refs[gl_InstanceCustomIndexEXT];
Indices indices = Indices(refs[0]);
}
Using the GL_EXT_buffer_reference2 extension. The code is compiled to the spirv1.5 spec which gives this spriv code for the "textures " bindless samplers:
OpName %textures "textures"
OpDecorate %_runtimearr_ulong ArrayStride 8
OpMemberDecorate %Instances 0 Offset 0
OpDecorate %Instances Block
OpDecorate %_ DescriptorSet 0
OpDecorate %_ Binding 0
OpDecorate %gl_InstanceCustomIndexEXT BuiltIn InstanceCustomIndexNV
OpDecorate %_runtimearr_uint ArrayStride 4
OpMemberDecorate %Indices 0 Offset 0
OpDecorate %Indices Block
OpDecorate %indices AliasedPointer
OpDecorate %textures DescriptorSet 0
OpDecorate %textures Binding 1
With the only difference beeing this:
OpDecorate %Indices Block
OpDecorate %indices AliasedPointer
But spirq does not recognize the "textures" descriptor on reflection if this line exists:
Indices indices = Indices(refs[0]);
Debug from spriq entry points:
With the line:
main {
exec_model: ClosestHitNV,
name: "main",
vars: [
Descriptor {
name: None,
desc_bind: (set=0, bind=0),
desc_ty: StorageBuffer(
ReadWrite,
),
ty: Instances { refs: [u64] },
nbind: 1,
},
],
exec_modes: [],
},
Without the line:
main {
exec_model: ClosestHitNV,
name: "main",
vars: [
Descriptor {
name: None,
desc_bind: (set=0, bind=0),
desc_ty: StorageBuffer(
ReadWrite,
),
ty: Instances { refs: [u64] },
nbind: 1,
},
Descriptor {
name: Some(
"textures",
),
desc_bind: (set=0, bind=1),
desc_ty: CombinedImageSampler,
ty: sampler2D<f32>,
nbind: 1,
},
],
exec_modes: [],
},
Thanks for any help in advance.
PENGUINLIONG commented
Thanks for your detailed report. It seems that SPIR-Q was not able to parsing OpForwardPointer
correctly, leading to the behavior you observed. It should have been resolved by #82 . It works with your provided shader. :)