Search code examples
openglspir-v

Is it possible to use bindless textures in SPIR-V shaders on OpenGL 4.5?


I'm trying to compile the following shader using LunarG Vulkan SDK 1.0.37.0 on Windows:

#version 450 core
#extension GL_ARB_bindless_texture : require

layout(std140, binding=1) uniform LightUbo
{
    vec3 lightDirectionVS;
};

layout(std140, binding=2) uniform TextureUBO
{
    sampler2D samplers[ 10 ];
};

in vec2 vUV;
in vec3 vNormalVS;
out vec4 fragColor;

void main()
{
    vec2 uv = vUV;
    uv.y = 1.0 - uv.y;
    fragColor = texture( samplers[ 0 ], uv ) * max( 0.2, dot( lightDirectionVS, vNormalVS ) );
}

Compile command:

\VulkanSDK\1.0.37.0\Bin\glslangValidator.exe -V assets\shader.frag -o assets\shader.frag.spv

The compiler gives the following output:

Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.

ERROR: assets\shader.frag:2: '#extension' : extension not supported: GL_ARB_bindless_texture

ERROR: assets\shader.frag:2: '#extension' : extra tokens -- expected newline ERROR: assets\shader.frag:2: '' : compilation terminated

Is there a way to use bindless textures with OpenGL 4.5 and SPIR-V shaders?


Solution

  • SPIR-V has no facilities for doing bindless texture stuff. So unless NVIDIA or the ARB adds a SPIR-V extension to allow it, you'll have to use the implementation's GLSL compiler, rather than glslang.