From b97e5fb55bfbb45c275c8d20b3eec015b22cc793 Mon Sep 17 00:00:00 2001 From: Mesonnaise Date: Thu, 2 Aug 2018 11:20:47 -0700 Subject: [PATCH 1/2] Fixed the quatifier and label problem assocated with bake_spirv_by_swapning_glslang_process being split from bake_spirv_blob --- include/misc/glsl_to_spirv.h | 2 +- src/misc/glsl_to_spirv.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/misc/glsl_to_spirv.h b/include/misc/glsl_to_spirv.h index 30c77466..370ba379 100644 --- a/include/misc/glsl_to_spirv.h +++ b/include/misc/glsl_to_spirv.h @@ -332,7 +332,7 @@ namespace Anvil EShLanguage get_glslang_shader_stage () const; #else bool bake_spirv_blob_by_spawning_glslang_process(const std::string& in_glsl_filename_with_path, - const std::string& in_spirv_filename_with_path); + const std::string& in_spirv_filename_with_path) const; #endif /* Private members */ diff --git a/src/misc/glsl_to_spirv.cpp b/src/misc/glsl_to_spirv.cpp index 8006749c..e35a09d8 100644 --- a/src/misc/glsl_to_spirv.cpp +++ b/src/misc/glsl_to_spirv.cpp @@ -561,6 +561,8 @@ bool Anvil::GLSLShaderToSPIRVGenerator::bake_spirv_blob() const } #endif + end: + return result; } @@ -722,12 +724,13 @@ bool Anvil::GLSLShaderToSPIRVGenerator::bake_spirv_blob() const * @return true if successful, false otherwise. **/ bool Anvil::GLSLShaderToSPIRVGenerator::bake_spirv_blob_by_spawning_glslang_process(const std::string& in_glsl_filename_with_path, - const std::string& in_spirv_filename_with_path) + const std::string& in_spirv_filename_with_path) const { auto callback_arg = OnGLSLToSPIRVConversionAboutToBeStartedCallbackArgument(this); std::string glslangvalidator_params; bool result = false; size_t spirv_file_size = 0; + char* spirv_blob_ptr = nullptr; callback(GLSL_SHADER_TO_SPIRV_GENERATOR_CALLBACK_ID_CONVERSION_ABOUT_TO_START, &callback_arg); @@ -818,7 +821,7 @@ bool Anvil::GLSLShaderToSPIRVGenerator::bake_spirv_blob() const #endif /* Now, read the SPIR-V file contents */ - char* spirv_blob_ptr = nullptr; + Anvil::IO::read_file(in_spirv_filename_with_path.c_str(), false, /* is_text_file */ From 917da992116472a6d9d3c27430c3917012b64e31 Mon Sep 17 00:00:00 2001 From: Mesonnaise Date: Thu, 2 Aug 2018 11:50:37 -0700 Subject: [PATCH 2/2] Moved the label to avoid gcc compiling problems --- src/misc/glsl_to_spirv.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/misc/glsl_to_spirv.cpp b/src/misc/glsl_to_spirv.cpp index e35a09d8..1f4c2446 100644 --- a/src/misc/glsl_to_spirv.cpp +++ b/src/misc/glsl_to_spirv.cpp @@ -553,15 +553,18 @@ bool Anvil::GLSLShaderToSPIRVGenerator::bake_spirv_blob() const result = bake_spirv_blob_by_calling_glslang(m_glsl_source_code.c_str() ); } } + #else { /* We need to point glslangvalidator at a location where it can stash the SPIR-V blob. */ result = bake_spirv_blob_by_spawning_glslang_process(glsl_filename_with_path, "temp.spv"); } + +end: #endif - end: + return result; }