Setting target SPIR-V version

Started by cpope9141, June 05, 2021, 23:49:44

Previous topic - Next topic



I am working on a ray tracer using the KHR extensions. When I attempt to compile my closest hit shader I see this error message: "error: 'GL_EXT_ray_tracing' : not supported for current targeted SPIR-V version". I interpret this to mean that I need to set the target SPIR-V version using shaderc_compile_options_set_target_spirv(long options, int version). Is this correct? If so, what do I use as the argument for 'options'?


Is the underlying Vulkan SDK at least version From my preliminary searches, it sounds like this is the minimum version required for the KHR extensions.


Here are some things I have found:

1. It looks like 'shaderc_compile_options_initialize' can be used to obtain the 'options' argument for 'shaderc_compile_options_set_target_spirv'. However, when I set the target SPIR-V version to 'shaderc_spirv_version_1_4' compilation continues to fail ("error: 'GL_EXT_ray_tracing' : not supported for current targeted SPIR-V version"). When I attempt to check the version by printing the results of 'shaderc_get_spv_version' I get: "66816.4". (Edit: 'shaderc_spirv_version_1_5' is defined as 0x10500, which is 66816. I was printing 'version' + "." + 'revision'. I guess setting to a lower version is ignored?)

2. Using command line glslc from version of the Vulkan SDK successfully compiles the shader: "C:/VulkanSDK/ closestHitBasic.rchit -o closestHitBasic.spv --target-spv=spv1.4". (Edit: I have found that LWJGL 3.3.0 has version 1.2.172 of the Vulkan SDK, so I am confused why ShaderC is telling me GL_EXT_ray_tracing is not supported)

Any assistance is greatly appreciated.


I have found this issue on github:

So far my only work around is to use the command line to compile ray tracing shaders, then create a shader module from that byte code.

Is there an ordering of these function calls (set env/version) that I may have incorrect? I have tried setting env/version before and after 'shaderc_compiler_initialize'.

Constructive suggestions appreciated.


Quote from: KaiHH on June 09, 2021, 14:27:07
Works for me:

I was looking at these examples earlier this morning. The only difference I can see between what I have tried and the demo is your use of 'shaderc_compile_options_set_include_callbacks'.

I'll see if I can get your demos running and continue to debug. Thanks for the response.


long result = shaderc_compile_into_spv(compiler, source, type, absolutePath, "main", NULL);

I never replaced NULL with 'options'... On the up side, I have a better overview of ShaderC now.