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 <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/scripts/dawn_features.gni b/scripts/dawn_features.gni
index 6897304..aed6c75 100644
--- a/scripts/dawn_features.gni
+++ b/scripts/dawn_features.gni
@@ -37,4 +37,11 @@
# 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 4c8c262..7b0113a 100644
--- a/third_party/BUILD.gn
+++ b/third_party/BUILD.gn
@@ -62,11 +62,10 @@
"${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 @@
"${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") {