Author Topic: How to configure Vulkan SPIR-V compiler in Code::Blocks  (Read 3933 times)

Offline cdavalillo

  • Multiple posting newcomer
  • *
  • Posts: 27
How to configure Vulkan SPIR-V compiler in Code::Blocks
« on: July 14, 2024, 02:49:04 am »
I want to compile GLSL shader files with the Vulkan SPIR-V compiler as we do with the c/c++ source files. I read some time ago in the Nvidia support pages how to set the CUDA compiler in Code::Blocks (https://forums.developer.nvidia.com/t/how-to-setup-cuda-compiler-on-code-blocks-author-not-me/11760), so I have some idea how to do it. But after putting in the path to the linker and compiler it don't work, so I want to know what I'm missing. I'm on Debian 12 64 bits, after list the files installed for the package spirv-tools I have the following output

Code
/.
/usr
/usr/bin
/usr/bin/spirv-as
/usr/bin/spirv-cfg
/usr/bin/spirv-dis
/usr/bin/spirv-lesspipe.sh
/usr/bin/spirv-link
/usr/bin/spirv-lint
/usr/bin/spirv-opt
/usr/bin/spirv-reduce
/usr/bin/spirv-val
/usr/include
/usr/include/spirv-tools
/usr/include/spirv-tools/instrument.hpp
/usr/include/spirv-tools/libspirv.h
/usr/include/spirv-tools/libspirv.hpp
/usr/include/spirv-tools/linker.hpp
/usr/include/spirv-tools/optimizer.hpp
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools/SPIRV-ToolsConfig.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools/SPIRV-ToolsTarget-release.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools/SPIRV-ToolsTarget.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-diff
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-diff/SPIRV-Tools-diffConfig.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-diff/SPIRV-Tools-diffTargets-release.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-diff/SPIRV-Tools-diffTargets.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-link
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-link/SPIRV-Tools-linkConfig.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-link/SPIRV-Tools-linkTargets-release.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-link/SPIRV-Tools-linkTargets.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-lint
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-lint/SPIRV-Tools-lintConfig.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-lint/SPIRV-Tools-lintTargets-release.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-lint/SPIRV-Tools-lintTargets.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-opt
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-opt/SPIRV-Tools-optConfig.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-opt/SPIRV-Tools-optTargets-release.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-opt/SPIRV-Tools-optTargets.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-reduce
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-reduce/SPIRV-Tools-reduceConfig.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-reduce/SPIRV-Tools-reduceTarget-release.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-reduce/SPIRV-Tools-reduceTarget.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-tools
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-tools/SPIRV-Tools-toolsConfig.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-tools/SPIRV-Tools-toolsTargets-release.cmake
/usr/lib/x86_64-linux-gnu/cmake/SPIRV-Tools-tools/SPIRV-Tools-toolsTargets.cmake
/usr/lib/x86_64-linux-gnu/libSPIRV-Tools-diff.a
/usr/lib/x86_64-linux-gnu/libSPIRV-Tools-link.a
/usr/lib/x86_64-linux-gnu/libSPIRV-Tools-lint.a
/usr/lib/x86_64-linux-gnu/libSPIRV-Tools-opt.a
/usr/lib/x86_64-linux-gnu/libSPIRV-Tools-reduce.a
/usr/lib/x86_64-linux-gnu/libSPIRV-Tools.a
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/SPIRV-Tools.pc
/usr/share
/usr/share/doc
/usr/share/doc/spirv-tools
/usr/share/doc/spirv-tools/changelog.Debian.gz
/usr/share/doc/spirv-tools/changelog.gz
/usr/share/doc/spirv-tools/copyright
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/spirv-tools

So I know that the linker is /usr/bin/spirv-link but not know what to put in the other tool chain executable textboxes. This is what I have so far
« Last Edit: July 14, 2024, 05:25:03 pm by cdavalillo »

Offline cdavalillo

  • Multiple posting newcomer
  • *
  • Posts: 27
Re: How to configure SPIR-V compiler in codeblocks
« Reply #1 on: July 14, 2024, 06:36:47 am »
Ok now I know that the compiler is glslc located at /usr/bin so the tool chain should looks like this image. But how to configure Code::Blocks to run a compilation as it was done by the following command line

Code
glslc /home/User/CodeBlocks_Projects/GLSL/vs_background.vert  -o vert.spv

In which the .vert file is a GLSL shader file and the .spv is the compiled byte code SPIR-V program.
« Last Edit: July 14, 2024, 07:05:48 am by cdavalillo »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7665
    • My Best Post
Re: How to configure SPIR-V compiler in codeblocks
« Reply #2 on: July 14, 2024, 12:54:07 pm »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline cdavalillo

  • Multiple posting newcomer
  • *
  • Posts: 27
Re: How to configure SPIR-V compiler in codeblocks
« Reply #3 on: July 14, 2024, 04:34:47 pm »
Thank you for the help, that is exactly what I was asking for. Now I have the following compilation command

Code
$compiler $options $includes -c $file -o $file_dir/$file_name.$exe_ext

And in the Others tag in the field of object file extension I have the spv extension. This settings yield a .spv compiled file and after checking the compiled file with the SPIR-V visualizer (https://www.khronos.org/spir/visualizer/) I get what is in the following image