From 6b249bde4bd5c23054dddf8bbae2b351dcbb7843 Mon Sep 17 00:00:00 2001 From: Philip Rideout Date: Thu, 15 Jul 2021 14:49:07 -0700 Subject: [PATCH] Enable debug info in materials in debug builds. This lets you see highly readable GLSL when transpiling the generated SPIRV back to GLSL, with the original variable names preserved. For now this is only useful when using `matinfo`, but it will soon be useful in `matdbg` too. --- CMakeLists.txt | 3 ++- libs/gltfio/src/MaterialGenerator.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ac68d7ac5..d25f029486 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -448,8 +448,9 @@ if (FILAMENT_SUPPORTS_METAL) set(MATC_API_FLAGS ${MATC_API_FLAGS} -a metal) endif() +# Disable optimizations and enable debug info (preserves names in SPIR-V) if (FILAMENT_DISABLE_MATOPT) - set(MATC_OPT_FLAGS -g) + set(MATC_OPT_FLAGS -gd) endif() set(MATC_BASE_FLAGS ${MATC_API_FLAGS} -p ${MATC_TARGET} ${MATC_OPT_FLAGS}) diff --git a/libs/gltfio/src/MaterialGenerator.cpp b/libs/gltfio/src/MaterialGenerator.cpp index b9b1d1d1a4..54df0d9380 100644 --- a/libs/gltfio/src/MaterialGenerator.cpp +++ b/libs/gltfio/src/MaterialGenerator.cpp @@ -325,6 +325,7 @@ static Material* createMaterial(Engine* engine, const MaterialKey& config, const if (!optimizeShaders) { builder.optimization(MaterialBuilder::Optimization::NONE); + builder.generateDebugInfo(true); } static_assert(std::tuple_size::value == 8, "Badly sized uvset.");