Check for support for #include in GLSL

Is there a way to check at runtime whether the GPU supports #include?
It looks like some AMD GPUs may not support it, but recent-ish NVIDIA ones seem to.

My RayTK library currently depends on using #include when it constructs its shaders. Ideally I’d like to continue using it when it’s supported. When it isn’t supported I can inline those other DATs, but if possible I’d prefer to only do that when it’s necessary.

Or should we not rely on #include support for widely used libraries?

I’ve got a workaround that uses a dedicated glslTOP and checks the compile result for any of these strings:

	'error C7529',
	'OpenGL does not allow #include directives',
	'#include statements are not supported',

But I’m not sure how reliable that is.

Any recent drivers should support it as far as I know, even AMDs (which were the last to add support). Do you know which ones are saying they don’t?

The report was from a user with an AMD Vega64.
Maybe their drivers are just outdated?

Quite possibly. It’s not a hardware feature, so any GPU can in theory support it, as long as the drivers do.

1 Like

Malcom,

I still encounter an “error(#110) Invalid Directive: include” error on an AMD FirePro system.

Radeon Pro Software Version : 20Q4
TD 2020:44350
Windows 10 Build 19042

Well that’s annoying. AMD said it was put into the 18Q4 driver. What GPU specifically?

Nevermind, I’ve confirmed it’s not supported yet. I stand corrected. Seems like the support they said was added only made it into their linux drivers. I would say for now you need to avoid #include statements for anything you want to release publicly. Working on getting this fixed.

Any updates on this? I’ve had quite a few of GP users over the last year who report this on similar gpu hardware. Do you know if there is a ln expectation this will eventually be supported?

Well, the good news is that it’s fully supported on the 2021.30000 series since I’m now in control of the GLSL compiler. No more vendor specific bugs there.
I’ve reached out to AMD to see if they fixed it in their OpenGL drivers

1 Like

! Wow what another awesome piece of good news for .30000
I noticed some odd stuff with the render top btw, is it too early to start posting bugs? I assume a lot of them are known.

Happy to hear any bugs you run into! Lots of things to uncover for sure with this build.

1 Like

Thanks!
Sounds like Vulkan opens up a lot of potential like for things like this.