From d561448d0d862bb7e0a19d63904990452bf424e2 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Mon, 7 Oct 2019 15:47:27 +0000 Subject: [PATCH] Add build time flag to control enabling SPIRV-Cross reflection This adds a flag to enable using the reflection compiler from SPIRV-Cross, and also updates the build rules to make sure that the GLSL compiler is also present when using reflection, since the reflection compiler subclassess the GLSL compiler. BUG=dawn:231 Change-Id: I4e227cb955a3bb794d906dabdadffdaca001352b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11920 Commit-Queue: Corentin Wallez Reviewed-by: Corentin Wallez --- scripts/dawn_features.gni | 7 +++++++ third_party/BUILD.gn | 12 +++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/dawn_features.gni b/scripts/dawn_features.gni index 6897304fe1..aed6c7567b 100644 --- a/scripts/dawn_features.gni +++ b/scripts/dawn_features.gni @@ -37,4 +37,11 @@ declare_args() { # Enables the compilation of Dawn's Vulkan backend dawn_enable_vulkan = is_linux || is_win || is_fuchsia + + # Enable use of reflection compiler in spirv-cross. This is needed + # if performing reflection on systems that the platform language + # shader is SPIR-V, since there isn't an instance of the + # GLSL/HLSL/MSL compiler. This implicitly pulls in the GLSL + # compiler, since it is a sub-class of if. + dawn_enable_cross_reflection = false } diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn index 4c8c262f12..7b0113a62c 100644 --- a/third_party/BUILD.gn +++ b/third_party/BUILD.gn @@ -62,11 +62,10 @@ static_library("spirv_cross") { "${spirv_cross_dir}/spirv_cross_parsed_ir.hpp", "${spirv_cross_dir}/spirv_parser.cpp", "${spirv_cross_dir}/spirv_parser.hpp", - "${spirv_cross_dir}/spirv_reflect.cpp", - "${spirv_cross_dir}/spirv_reflect.hpp", ] - need_glsl_cross = dawn_enable_opengl + need_glsl_cross = dawn_enable_opengl || dawn_enable_cross_reflection + need_reflection_cross = dawn_enable_cross_reflection if (dawn_enable_d3d12) { sources += [ @@ -90,6 +89,13 @@ static_library("spirv_cross") { "${spirv_cross_dir}/spirv_glsl.hpp", ] } + + if (need_reflection_cross) { + sources += [ + "${spirv_cross_dir}/spirv_reflect.cpp", + "${spirv_cross_dir}/spirv_reflect.hpp", + ] + } } static_library("spirv_cross_full_for_fuzzers") {