diff --git a/CMakeLists.txt b/CMakeLists.txt index 208fad2c..aa8c5723 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,12 @@ option(WIVRN_BUILD_WIVRNCTL "Build wivrnctl" ON) option(WIVRN_BUILD_DISSECTOR "Build Wireshark dissector" OFF) option(WIVRN_BUILD_TEST "Build test binaries" OFF) option(WIVRN_WERROR "Treat warnings as errors" OFF) -option(WIVRN_OPTIMIZE_SHADERS "Run siprv-opt on compiled shaders" ON) +option(WIVRN_OPTIMIZE_SHADERS "Run spirv-opt on compiled shaders" ON) +option(WIVRN_DEBUG_SHADERS "Compile shaders with debug information" OFF) + +if(WIVRN_OPTIMIZE_SHADERS AND WIVRN_DEBUG_SHADERS) + message(FATAL_ERROR "WIVRN_OPTIMIZE_SHADERS and WIVRN_DEBUG_SHADERS are incompatible") +endif() option(WIVRN_USE_NVENC "Enable nvenc (Nvidia) hardware encoder" ON) option(WIVRN_USE_VAAPI "Enable vaapi (AMD/Intel) hardware encoder" ON) diff --git a/cmake/CompileGLSL.cmake b/cmake/CompileGLSL.cmake index 003e00f1..f53c110a 100644 --- a/cmake/CompileGLSL.cmake +++ b/cmake/CompileGLSL.cmake @@ -13,13 +13,20 @@ function(compile_glsl_aux shader_stage shader_name glsl_filename output target_e }}, ") + if (WIVRN_DEBUG_SHADERS) + set(SHADER_FLAGS -gVS) + else() + set(SHADER_FLAGS ) + endif() + add_custom_command( OUTPUT "${SPV_FILE}-nopt" - COMMAND Vulkan::glslangValidator -V --target-env ${target_env} -S ${shader_stage} -D${shader_stage_upper}_SHADER ${in_file} -o "${SPV_FILE}-nopt" --depfile "${SPV_FILE}.d" + COMMAND Vulkan::glslangValidator -V --target-env ${target_env} -S ${shader_stage} -D${shader_stage_upper}_SHADER ${in_file} ${SHADER_FLAGS} -o "${SPV_FILE}-nopt" --depfile "${SPV_FILE}.d" DEPENDS "${glsl_filename}" DEPFILE "${SPV_FILE}.d" VERBATIM ) + if (WIVRN_OPTIMIZE_SHADERS) add_custom_command( OUTPUT "${SPV_FILE}-opt"