Setting target SPIR-V version

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

Previous topic - Next topic

cpope9141

Hello.

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'?

cpope9141

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

cpope9141

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 1.2.162.1 of the Vulkan SDK successfully compiles the shader: "C:/VulkanSDK/1.2.162.1/Bin32/glslc.exe 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.

cpope9141

I have found this issue on github: https://github.com/google/shaderc/issues/1088

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.


cpope9141

Quote from: KaiHH on June 09, 2021, 14:27:07
Works for me: https://github.com/LWJGL/lwjgl3-demos/blob/main/src/org/lwjgl/demo/vulkan/VKUtil.java#L62-L63

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.

cpope9141

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.