Closed wsherman64 closed 9 months ago
Hi @wsherman64, I think the problem lies in how we are calling glslangValidator
in the CMake here:
https://github.com/KhronosGroup/OpenXR-Tutorials/blob/708c6d6397c1e480e02b882e6a74366c305769aa/cmake/glsl_shader.cmake#L95
glslangValidator
is looking for a char
after the -V
argument expecting to find the ver
number, but in our case, it seems to
be reading a space character.
I think there are two options to resolve this:
-V "${_glsl_spv_INPUT}"
"-V100" "${_glsl_spv_INPUT}"
I'd prefer option 1 as we have already defined the Vulkan version with --target-env
, but maybe it might still be tripped up.
Error Message: https://github.com/KhronosGroup/glslang/blob/b820431a2cddd41155d5750e1ae6ec3def2831c0/StandAlone/StandAlone.cpp#L966-L972
Really strange that this never came up in testing. XR_TUTORIAL_GRAPHICS_API
doesn't interact with the CMake configuration or generation.
Commit def8bd8 implements option 1 as a potential fix. Let me know if this works for you. I don't have a Linux system to test on at the moment.
Thanks Andrew, I'm now getting a different error at the same point. I first tried your solution #1, and when that didn't work tried #2 -- so the results below are from trying #2. I turned on CMake Verbose with "export VERBOSE=1", so this has more details:
cd /home/wrs1/Apps/OpenXR/Tutorial/SimulTut/OpenXR-Tutorials_git20231127/Chapter3 && /home/wrs1/Utils/GLSlang/glslang_20220223_Install/bin/glslangValidator -o /home/wrs1/Apps/OpenXR/Tutorial/SimulTut/OpenXR-Tutorials_git20231127/Chapter3/VertexShader.spv -S vert -e main -x -gVS "" "" --target-env vulkan1.0 "-V100 /home/wrs1/Apps/OpenXR/Tutorial/SimulTut/OpenXR-Tutorials_git20231127/Chapter3/../Shaders/VertexShader.glsl"
/home/wrs1/Utils/GLSlang/glslang_20220223_Install/bin/glslangValidator: Error: unable to open input file (use -h for usage)
make[2]: *** [Chapter3/CMakeFiles/OpenXRTutorialChapter3.dir/build.make:75: Chapter3/VertexShader.spv] Error 1
make[2]: Leaving directory '/home/wrs1/Apps/OpenXR/Tutorial/SimulTut/OpenXR-Tutorials_git20231127'
make[1]: *** [CMakeFiles/Makefile2:559: Chapter3/CMakeFiles/OpenXRTutorialChapter3.dir/all] Error 2
make[1]: Leaving directory '/home/wrs1/Apps/OpenXR/Tutorial/SimulTut/OpenXR-Tutorials_git20231127'
make: *** [Makefile:136: all] Error 2
It seems glslangValidator can't find the GLSL file. glslangValidator: Error: unable to open input file (use -h for usage)
I think this is being as a single argument not two:
"-V100 /home/wrs1/Apps/OpenXR/Tutorial/SimulTut/OpenXR-Tutorials_git20231127/Chapter3/../Shaders/VertexShader.glsl"
Okay, I think the issue is with the "-gVS" option. My version of glslangValidator doesn't seem to have that option. (Was this recently added to the build process?)
Here's the version info from my glslangValidator
:
Glslang Version: 10:11.8.0
ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 11.8.0
GLSL Version: 4.60 glslang Khronos. 11.8.0
SPIR-V Version 0x00010600, Revision 1
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
SPIR-V Generator Version 10
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100
I did some more experimentation today on the Linux build process, and I discovered that it's not actually the "-gVS" option that is the problem -- it's the two ""
and ""
that happen because of some null parameters in the CMake setup generate these double-quote pairs, and in the Linux shell, these are seen as actual arguments of strings of length 0, which then glslangValidator
thinks is the name of the file, and so can't find the file.
Here are the lines of the cmake/glsl_shader.cmake
file that cause this -- based on choosing the CMAKE_BUILD_TYPE
whichever one is set gets the associated option, but the other two generate the empty double-quote-pair:
$<$<CONFIG:Debug,RelWithDebInfo>:-gVS>
#$<$<CONFIG:Debug>:-Od>
#$<$<CONFIG:Release>:-g0>
For my current build I have CMAKE_BUILD_TYPE
set to RelWithDebInfo
so I had to comment out the other two settings to prevent them from adding the doulbe-quote-pair.
Otherwise, the command looks like:
cd /home/wrs1/Apps/OpenXR/Tutorial/SimulTut/OpenXR-Tutorials_git20231127/Chapter3 && /home/wrs1/Utils/GLSlang/glslang_20220223_Install/bin/glslangValidator -o /home/wrs1/Apps/OpenXR/Tutorial/SimulTut/OpenXR-Tutorials_git20231127/Chapter3/VertexShader.spv -S vert -e main -x -gVS "" "" --target-env vulkan1.0 -V /home/wrs1/Apps/OpenXR/Tutorial/SimulTut/OpenXR-Tutorials_git20231127/Chapter3/../Shaders/VertexShader.glsl
Commit 5d0ec59 adds COMMAND_EXPAND_LISTS
to all the shader compilations. So if any CMake generator expressions resolve as ""
, COMMAND_EXPAND_LISTS
will expand those ""
arguments into nothing.
I referenced this question on Stack Overflow: https://stackoverflow.com/questions/72157973/cmake-generator-expression-evaluated-to-instead-of-nothing
Let me know if this works for you.
@wsherman64 I'm not able to repro the problem on our Linux machine, it seems to work fine with or without Andrew's change. Can you confirm if this fixes it for you please?
Yes, Andrew's change fixes the problem for me. I also tried with an empty "CMAKE_BUILD_TYPE" with the previous version to see whether that's why Roderick wasn't seeing the problem at all, but I still got the error with that (again, with the version before Andrew's change). So I'm not sure why it worked for Roderick. For the record, I'm running Rocky Linux 8.8, and using CMake version 3.27.1
.
I wonder @rvkennedy if you can set "export VERBOSE=1" before doing a build with the old method and report what make
outputs when doing the Generating VertexShader.spv
step -- which for me happens at 60% of the build process. For me it was as reported above, where glslangValidator is called with these (and more) arguments: -S vert -e main -x -gVS "" "" --target-env vulkan1.0
. I'm curious as to whether it's something CMake is doing, or `glslangValidator is doing.
BTW, I have a couple other questions regarding the CMake options, plus a question about building for Vulkan, but I'll post those as separate issues.
Looks like if you have glslc, that will be used in preference to glslangvalidator. But even disabling this, and using CMAKE_VERBOSE_MAKEFILE to ensure "export VERBOSE=1" is added, I don't see the quote marks. This is CMake 3.27.1 on Ubuntu 20.04:
/usr/bin/glslangValidator -o /home/roderick/openxr-tutorial-src/build/Chapter3/VertexShader.spv -S vert -e main -x -gVS -Od --target-env vulkan1.0 -V /home/roderick/openxr-tutorial-src/Chapter3/../Shaders/VertexShader.glsl
Thanks for checking @rvkennedy. I don't have "glslc" on my system (and it doesn't seem to be in any available packages) -- but I'm not overly worried about that, was just hoping the CMake configuration could be simplified.
Regarding the double quotes -- that does surprise me, given that we're using the same version of CMake, and I don't know what other aspect of Ubuntu vs. Rocky would make a difference.
So I do want to confirm -- that was with the version of the tutorial before Andrew added the COMMAND_EXPAND_LISTS
command to the CMake configuration?
Hi @wsherman64, for me, neither version adds spurious double quotes.
Okay, well I'm not sure why I was seeing the double quotes and Roderick isn't, but regardless, Andrew's changes has fixed it for me.
Hey all, I just did a quick test of a build on Linux using a "git clone" of the repo, and I get an error when the build process hits Chapter 3:
I tried with the Graphics API set to both
VULKAN
andOPENGL
.