compiler: Add SPIR-V remapping to driver for testing
diff --git a/icd/intel/compiler/CMakeLists.txt b/icd/intel/compiler/CMakeLists.txt
index 2ec783b..fc68377 100644
--- a/icd/intel/compiler/CMakeLists.txt
+++ b/icd/intel/compiler/CMakeLists.txt
@@ -8,8 +8,8 @@
# DEBUG and NDEBUG flags are important for proper mesa behavior
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
-set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
-set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
+set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -std=c++11")
+set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -std=c++11")
# LunarG TODO: Get the llvm-config flags hooked up correctly and remove extra definitions from above
diff --git a/icd/intel/compiler/shader/compiler_interface.cpp b/icd/intel/compiler/shader/compiler_interface.cpp
index 7a18633..70ba97c 100644
--- a/icd/intel/compiler/shader/compiler_interface.cpp
+++ b/icd/intel/compiler/shader/compiler_interface.cpp
@@ -441,7 +441,10 @@
bool dump_SPV = false;
bool dump_hir = false;
- _mesa_glsl_compile_shader(ctx, shader, dump_ast, dump_SPV, dump_hir);
+ bool strip_SPV = false;
+ bool canonicalize_SPV = false;
+
+ _mesa_glsl_compile_shader(ctx, shader, dump_ast, dump_SPV, dump_hir, strip_SPV, canonicalize_SPV);
if (strlen(shader->InfoLog) > 0) {
printf("Info log:\n%s\n", shader->InfoLog);
diff --git a/icd/intel/compiler/shader/glsl_parser_extras.cpp b/icd/intel/compiler/shader/glsl_parser_extras.cpp
index f8d4c96..a183926 100644
--- a/icd/intel/compiler/shader/glsl_parser_extras.cpp
+++ b/icd/intel/compiler/shader/glsl_parser_extras.cpp
@@ -32,6 +32,7 @@
#include "Frontends/glslang/GlslangToTop.h"
#include "Frontends/SPIRV/SpvToTop.h"
#include "SPIRV/GlslangToSpv.h"
+#include "SPIRV/SPVRemapper.h"
#include "SPIRV/GLSL450Lib.h"
#include "SPIRV/disassemble.h"
#include "SPIRV/doc.h"
@@ -1573,7 +1574,8 @@
void
_mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
- bool dump_ast, bool dump_SPV, bool dump_hir)
+ bool dump_ast, bool dump_SPV, bool dump_hir,
+ bool strip_SPV, bool canonicalize_SPV)
{
const char* infoLog = "";
@@ -1642,19 +1644,26 @@
} else {
// Verify that the SPV really is SPV
if (((unsigned int *)shader->Source)[0] == spv::MagicNumber) {
- std::vector<unsigned int> spv;
+ std::vector<unsigned int> spirv;
- spv.reserve(shader->Size);
+ spirv.reserve(shader->Size);
for (int x=0; x<shader->Size; ++x)
- spv.push_back(((unsigned int *)shader->Source)[x]);
+ spirv.push_back(((unsigned int *)shader->Source)[x]);
+
+ if (strip_SPV || canonicalize_SPV) {
+ // remap is expensive, just call once with OR'd feature mask
+ spv::spirvbin_t(0).remap(spirv,
+ strip_SPV ? spv::spirvbin_t::STRIP : 0 |
+ canonicalize_SPV ? spv::spirvbin_t::ALL_BUT_STRIP : 0);
+ }
if (dump_SPV) {
spv::Parameterize();
GLSL_STD_450::GetDebugNames(GlslStd450DebugNames);
- spv::Disassemble(std::cout, spv);
+ spv::Disassemble(std::cout, spirv);
}
- gla::SpvToTop(spv, *manager);
+ gla::SpvToTop(spirv, *manager);
} else {
state->error = true;
}
diff --git a/icd/intel/compiler/shader/program.h b/icd/intel/compiler/shader/program.h
index fcd9a45..0dd721e 100644
--- a/icd/intel/compiler/shader/program.h
+++ b/icd/intel/compiler/shader/program.h
@@ -30,7 +30,8 @@
extern void
_mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
- bool dump_ast, bool dump_SPV, bool dump_hir);
+ bool dump_ast, bool dump_SPV, bool dump_hir,
+ bool strip_SPV, bool canonicalize_SPV);
#ifdef __cplusplus
} /* extern "C" */