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.