glslang icon indicating copy to clipboard operation
glslang copied to clipboard

DeviceMemory pointer to image casts (SPV_NV_bindless_texture)

Open fknfilewalker opened this issue 6 months ago • 7 comments

How can I access these operations using glslang?

OpConvertUToImageNV = 5391,
OpConvertUToSamplerNV = 5392,
OpConvertImageToUNV = 5393,
OpConvertSamplerToUNV = 5394,
OpConvertUToSampledImageNV = 5395,
OpConvertSampledImageToUNV = 5396,
OpSamplerImageAddressingModeNV = 5397

from https://github.com/KhronosGroup/SPIRV-Headers/blob/1c6bb2743599e6eb6f37b2969acc0aef812e32e3/include/spirv/unified1/spirv.hpp#L1843

fknfilewalker avatar Dec 21 '23 14:12 fknfilewalker

You can try to use the GL_EXT_spirv_intrinsics extension to access them directly, as NVIDIA has not written a glslang patch for this extension yet. @pmistryNV may be able to provide more information.

arcady-lunarg avatar Dec 21 '23 17:12 arcady-lunarg

Totally missed that GL_EXT_spirv_intrinsics is already out. Super nice!

Not really sure were to put OpSamplerImageAddressingModeNV but otherwise the spirv output looks good. Also not sure how to handle uint64_t vs uvec2.

#define NV_bindless_texture 1

spirv_instruction (extensions = ["SPV_NV_bindless_texture"], capabilities = [5390], id = 5391) 
image2D opConvertUToImageNV(uint64_t ptr);

spirv_instruction (extensions = ["SPV_NV_bindless_texture"], capabilities = [5390], id = 5392) 
sampler opConvertUToSamplerNV(uint64_t ptr);

spirv_instruction (extensions = ["SPV_NV_bindless_texture"], capabilities = [5390], id = 5395) 
sampler2D opConvertUToSampledImageNV(uint64_t ptr);

spirv_instruction (extensions = ["SPV_NV_bindless_texture"], capabilities = [5390], id = 5397)
void opSamplerImageAddressingModeNV(uint bit_width);

#define BindlessSamplerNV spirv_type (extensions = ["SPV_NV_bindless_texture"], capabilities = [5390], id = 5398)
#define BindlessImageNV spirv_type (extensions = ["SPV_NV_bindless_texture"], capabilities = [5390], id = 5399)
#define BoundSamplerNV spirv_type (extensions = ["SPV_NV_bindless_texture"], capabilities = [5390], id = 5400)
#define BoundImageNV spirv_type (extensions = ["SPV_NV_bindless_texture"], capabilities = [5390], id = 5401)

Full example using Shader Playground

fknfilewalker avatar Dec 21 '23 19:12 fknfilewalker

We will have to implement GL_NV_bindless_texture that maps to SPV_NV_bindless_texture. Unfortunately current implmentation of GL_ARB_bindless_texture in glslang has many bugs and it is a bit of work to completely make it work. I can assign this bug to myself and implement GL_NV_bindless_texture.

pmistryNV avatar Dec 22 '23 00:12 pmistryNV

Any updates on this. I saw that there is a old branch in @pmistryNV glslang fork that implements GL_NV_bindless_texture. Are there any infos how this will progress?

fknfilewalker avatar Mar 21 '24 12:03 fknfilewalker

Any updates on this. I saw that there is a old branch in @pmistryNV glslang fork that implements GL_NV_bindless_texture. Are there any infos how this will progress?

if this is urgent can you please open up a bug in GLSLANG to implement the same? That will help me in tracking it. What kind of use cases are you looking at.

pmistryNV avatar Mar 21 '24 16:03 pmistryNV

sure I can do that, not super urgent, though it would be nice to have for experimentation mainly to have an easy way of accessing and tossing around images through pointers

fknfilewalker avatar Mar 21 '24 17:03 fknfilewalker

sure I can do that, not super urgent, though it would be nice to have for experimentation mainly to have an easy way of accessing and tossing around images through pointers

There is an incomplete implementation of ARB_bindless_texture that makes it messy. So I will have to do a clean up.

pmistryNV avatar Mar 21 '24 17:03 pmistryNV