Update shaderc lib and use single combined lib
authorGreg Daniel <egdaniel@google.com>
Thu, 25 Feb 2016 14:47:33 +0000 (09:47 -0500)
committerGreg Daniel <egdaniel@google.com>
Thu, 25 Feb 2016 14:47:33 +0000 (09:47 -0500)
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1737653002
R=jvanverth@google.com

Review URL: https://codereview.chromium.org/1737653002

18 files changed:
gyp/gpu.gyp
src/gpu/vk/GrVkProgramBuilder.cpp
third_party/shaderc/Debug/OGLCompiler.lib [deleted file]
third_party/shaderc/Debug/OSDependent.lib [deleted file]
third_party/shaderc/Debug/SPIRV-Tools.lib [deleted file]
third_party/shaderc/Debug/SPIRV.lib [deleted file]
third_party/shaderc/Debug/shaderc.lib [deleted file]
third_party/shaderc/Debug/shaderc_combined.lib [new file with mode: 0644]
third_party/shaderc/Debug/shaderc_util.lib [deleted file]
third_party/shaderc/Release/OGLCompiler.lib [deleted file]
third_party/shaderc/Release/OSDependent.lib [deleted file]
third_party/shaderc/Release/SPIRV-Tools.lib [deleted file]
third_party/shaderc/Release/SPIRV.lib [deleted file]
third_party/shaderc/Release/glslang.lib [deleted file]
third_party/shaderc/Release/shaderc.lib [deleted file]
third_party/shaderc/Release/shaderc_combined.lib [moved from third_party/shaderc/Debug/glslang.lib with 59% similarity]
third_party/shaderc/Release/shaderc_util.lib [deleted file]
third_party/shaderc/shaderc.h

index e2b7064..43204a4 100644 (file)
                   'VCLinkerTool': {
                     'AdditionalDependencies': [
                       'vulkan-1.lib',
-                      'shaderc.lib',
-                      'shaderc_util.lib',
-                      'glslang.lib',
-                      'OSDependent.lib',
-                      'OGLCompiler.lib',
-                      'SPIRV-Tools.lib',
-                      'SPIRV.lib',
+                      'shaderc_combined.lib'
                     ],
                   },
                 },
index 13daf71..5a3a075 100644 (file)
@@ -107,18 +107,18 @@ bool GrVkProgramBuilder::CreateVkShaderModule(const GrVkGpu* gpu,
     shaderc_compile_options_set_forced_version_profile(options, 140, shaderc_profile_none);
 
     shaderc_shader_kind shadercStage = vk_shader_stage_to_shaderc_kind(stage);
-    shaderc_spv_module_t module = shaderc_compile_into_spv(compiler,
-                                                           shaderString.c_str(),
-                                                           strlen(shaderString.c_str()),
-                                                           shadercStage,
-                                                           "shader",
-                                                           "main",
-                                                           options);
+    shaderc_compilation_result_t result = shaderc_compile_into_spv(compiler,
+                                                                   shaderString.c_str(),
+                                                                   strlen(shaderString.c_str()),
+                                                                   shadercStage,
+                                                                   "shader",
+                                                                   "main",
+                                                                   options);
     shaderc_compile_options_release(options);
 #ifdef SK_DEBUG
-    if (shaderc_module_get_num_errors(module)) {
+    if (shaderc_result_get_num_errors(result)) {
         SkDebugf("%s\n", shaderString.c_str());
-        SkDebugf("%s\n", shaderc_module_get_error_message(module));
+        SkDebugf("%s\n", shaderc_result_get_error_message(result));
         return false;
     }
 #endif
@@ -128,14 +128,14 @@ bool GrVkProgramBuilder::CreateVkShaderModule(const GrVkGpu* gpu,
     moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
     moduleCreateInfo.pNext = nullptr;
     moduleCreateInfo.flags = 0;
-    moduleCreateInfo.codeSize = shaderc_module_get_length(module);
-    moduleCreateInfo.pCode = (const uint32_t*)shaderc_module_get_bytes(module);
+    moduleCreateInfo.codeSize = shaderc_result_get_length(result);
+    moduleCreateInfo.pCode = (const uint32_t*)shaderc_result_get_bytes(result);
 
     VkResult err = GR_VK_CALL(gpu->vkInterface(), CreateShaderModule(gpu->device(),
                                                                      &moduleCreateInfo,
                                                                      nullptr,
                                                                      shaderModule));
-    shaderc_module_release(module);
+    shaderc_result_release(result);
     if (err) {
         return false;
     }
diff --git a/third_party/shaderc/Debug/OGLCompiler.lib b/third_party/shaderc/Debug/OGLCompiler.lib
deleted file mode 100644 (file)
index be64e31..0000000
Binary files a/third_party/shaderc/Debug/OGLCompiler.lib and /dev/null differ
diff --git a/third_party/shaderc/Debug/OSDependent.lib b/third_party/shaderc/Debug/OSDependent.lib
deleted file mode 100644 (file)
index d44dc17..0000000
Binary files a/third_party/shaderc/Debug/OSDependent.lib and /dev/null differ
diff --git a/third_party/shaderc/Debug/SPIRV-Tools.lib b/third_party/shaderc/Debug/SPIRV-Tools.lib
deleted file mode 100644 (file)
index d9827ea..0000000
Binary files a/third_party/shaderc/Debug/SPIRV-Tools.lib and /dev/null differ
diff --git a/third_party/shaderc/Debug/SPIRV.lib b/third_party/shaderc/Debug/SPIRV.lib
deleted file mode 100644 (file)
index 3449c42..0000000
Binary files a/third_party/shaderc/Debug/SPIRV.lib and /dev/null differ
diff --git a/third_party/shaderc/Debug/shaderc.lib b/third_party/shaderc/Debug/shaderc.lib
deleted file mode 100644 (file)
index 034781d..0000000
Binary files a/third_party/shaderc/Debug/shaderc.lib and /dev/null differ
diff --git a/third_party/shaderc/Debug/shaderc_combined.lib b/third_party/shaderc/Debug/shaderc_combined.lib
new file mode 100644 (file)
index 0000000..998f1a0
Binary files /dev/null and b/third_party/shaderc/Debug/shaderc_combined.lib differ
diff --git a/third_party/shaderc/Debug/shaderc_util.lib b/third_party/shaderc/Debug/shaderc_util.lib
deleted file mode 100644 (file)
index 6b54844..0000000
Binary files a/third_party/shaderc/Debug/shaderc_util.lib and /dev/null differ
diff --git a/third_party/shaderc/Release/OGLCompiler.lib b/third_party/shaderc/Release/OGLCompiler.lib
deleted file mode 100644 (file)
index c73f4c1..0000000
Binary files a/third_party/shaderc/Release/OGLCompiler.lib and /dev/null differ
diff --git a/third_party/shaderc/Release/OSDependent.lib b/third_party/shaderc/Release/OSDependent.lib
deleted file mode 100644 (file)
index 2dc2607..0000000
Binary files a/third_party/shaderc/Release/OSDependent.lib and /dev/null differ
diff --git a/third_party/shaderc/Release/SPIRV-Tools.lib b/third_party/shaderc/Release/SPIRV-Tools.lib
deleted file mode 100644 (file)
index c60c624..0000000
Binary files a/third_party/shaderc/Release/SPIRV-Tools.lib and /dev/null differ
diff --git a/third_party/shaderc/Release/SPIRV.lib b/third_party/shaderc/Release/SPIRV.lib
deleted file mode 100644 (file)
index dd91835..0000000
Binary files a/third_party/shaderc/Release/SPIRV.lib and /dev/null differ
diff --git a/third_party/shaderc/Release/glslang.lib b/third_party/shaderc/Release/glslang.lib
deleted file mode 100644 (file)
index e0502cb..0000000
Binary files a/third_party/shaderc/Release/glslang.lib and /dev/null differ
diff --git a/third_party/shaderc/Release/shaderc.lib b/third_party/shaderc/Release/shaderc.lib
deleted file mode 100644 (file)
index 97c9e39..0000000
Binary files a/third_party/shaderc/Release/shaderc.lib and /dev/null differ
similarity index 59%
rename from third_party/shaderc/Debug/glslang.lib
rename to third_party/shaderc/Release/shaderc_combined.lib
index 87cd446..7bc48e9 100644 (file)
Binary files a/third_party/shaderc/Debug/glslang.lib and b/third_party/shaderc/Release/shaderc_combined.lib differ
diff --git a/third_party/shaderc/Release/shaderc_util.lib b/third_party/shaderc/Release/shaderc_util.lib
deleted file mode 100644 (file)
index a2de948..0000000
Binary files a/third_party/shaderc/Release/shaderc_util.lib and /dev/null differ
index 2d2af14..131c3fc 100644 (file)
@@ -12,8 +12,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#ifndef SHADERC_H_
-#define SHADERC_H_
+#ifndef SHADERC_SHADERC_H_
+#define SHADERC_SHADERC_H_
 
 #ifdef __cplusplus
 extern "C" {
@@ -63,14 +63,13 @@ typedef enum {
   shaderc_profile_es,
 } shaderc_profile;
 
-// Used in the result module (shaderc_spv_module) to indicate the status of an
-// compilation.
+// Indicate the status of a compilation.
 typedef enum {
   shaderc_compilation_status_success = 0,
   shaderc_compilation_status_invalid_stage,  // error stage deduction
   shaderc_compilation_status_compilation_error,
-  shaderc_compilation_status_internal_error, // unexpected failure
-  shaderc_compilation_status_null_result_module,
+  shaderc_compilation_status_internal_error,  // unexpected failure
+  shaderc_compilation_status_null_result_object,
 } shaderc_compilation_status;
 
 // Usage examples:
@@ -78,20 +77,20 @@ typedef enum {
 // Aggressively release compiler resources, but spend time in initialization
 // for each new use.
 //      shaderc_compiler_t compiler = shaderc_compiler_initialize();
-//      shader_spv_module_t module = shaderc_compile_into_spv(compiler,
-//                    "int main() {}", 13, shaderc_glsl_vertex_shader, "main");
-//      // Do stuff with module compilation results.
-//      shaderc_module_release(module);
+//      shaderc_compilation_result_t result = shaderc_compile_into_spv(
+//          compiler, "int main() {}", 13, shaderc_glsl_vertex_shader, "main");
+//      // Do stuff with compilation results.
+//      shaderc_result_release(result);
 //      shaderc_compiler_release(compiler);
 //
 // Keep the compiler object around for a long time, but pay for extra space
 // occupied.
 //      shaderc_compiler_t compiler = shaderc_compiler_initialize();
 //      // On the same, other or multiple simultaneous threads.
-//      shader_spv_module_t module = shaderc_compile_into_spv(compiler,
-//                    "int main() {}", 13, shaderc_glsl_vertex_shader, "main");
-//      // Do stuff with module compilation results.
-//      shaderc_module_release(module);
+//      shaderc_compilation_result_t result = shaderc_compile_into_spv(
+//          compiler, "int main() {}", 13, shaderc_glsl_vertex_shader, "main");
+//      // Do stuff with compilation results.
+//      shaderc_result_release(result);
 //      // Once no more compilations are to happen.
 //      shaderc_compiler_release(compiler);
 
@@ -136,29 +135,25 @@ shaderc_compile_options_t shaderc_compile_options_clone(
 // NULL to this function, and doing such will have no effect.
 void shaderc_compile_options_release(shaderc_compile_options_t options);
 
-// Adds a predefined macro to the compilation options. This has the
-// same effect as passing -Dname=value to the command-line compiler.
-// If value is NULL, it has the effect same as passing -Dname to the
-// command-line compiler. If a macro definition with the same name has
-// previously been added, the value is replaced with the new value.
-// The null-terminated strings that the name and value parameters point to
-// must remain valid for the duration of the call, but can be modified or
-// deleted after this function has returned.
+// Adds a predefined macro to the compilation options. This has the same
+// effect as passing -Dname=value to the command-line compiler.  If value
+// is NULL, it has the same effect as passing -Dname to the command-line
+// compiler. If a macro definition with the same name has previously been
+// added, the value is replaced with the new value. The macro name and
+// value are passed in with char pointers, which point to their data, and
+// the lengths of their data. The strings that the name and value pointers
+// point to must remain valid for the duration of the call, but can be
+// modified or deleted after this function has returned. In case of adding
+// a valueless macro, the value argument should be a null pointer or the
+// value_length should be 0u.
 void shaderc_compile_options_add_macro_definition(
-    shaderc_compile_options_t options, const char* name, const char* value);
+    shaderc_compile_options_t options, const char* name, size_t name_length,
+    const char* value, size_t value_length);
 
 // Sets the compiler mode to generate debug information in the output.
 void shaderc_compile_options_set_generate_debug_info(
     shaderc_compile_options_t options);
 
-// Sets the compiler mode to emit a disassembly text instead of a binary. In
-// this mode, the byte array result in the shaderc_spv_module returned
-// from shaderc_compile_into_spv() will consist of SPIR-V assembly text.
-// Note the preprocessing only mode overrides this option, and this option
-// overrides the default mode generating a SPIR-V binary.
-void shaderc_compile_options_set_disassembly_mode(
-    shaderc_compile_options_t options);
-
 // Forces the GLSL language version and profile to a given pair. The version
 // number is the same as would appear in the #version annotation in the source.
 // Version and profile specified here overrides the #version annotation in the
@@ -167,18 +162,19 @@ void shaderc_compile_options_set_disassembly_mode(
 void shaderc_compile_options_set_forced_version_profile(
     shaderc_compile_options_t options, int version, shaderc_profile profile);
 
-// To support file inclusion, libshaderc invokes a callback into its client to
-// resolve the full path and content of the included file.
-// The client callback should follow the specified function signature below, and
-// it should be passed to libshaderc through the corresponding setter function.
-// When the including of a file is done, libshaderc will call another client
-// callback to clean up the resources used for the including process. The client
-// should implement the clean up method and pass it to libshaderc together with
-// the response method.
-
-// The struct that contains the information to be returned to the libshaderc.
-// The client-side implemented response method should return a pointer of this
-// struct. The underlying data is owned by client code.
+// Response to a request for #include content.  "Includer" is client code that
+// resolves #include arguments into objects of this type.
+//
+// TODO: File inclusion needs to be context-aware.
+// e.g.
+//  In file: /path/to/main_shader.vert:
+//  #include "include/a"
+//  In file: /path/to/include/a":
+//  #include "b"
+//  When compiling /path/to/main_shader.vert, the compiler should be able to
+//  go to /path/to/include/b to find the file b.
+//  This needs context info from compiler to client includer, and may needs
+//  interface changes.
 struct shaderc_includer_response {
   const char* path;
   size_t path_length;
@@ -186,40 +182,24 @@ struct shaderc_includer_response {
   size_t content_length;
 };
 
-// The function signature of the client-side implemented response method. It
-// returns a pointer to shaderc_includer_response struct.
+// A function mapping a #include argument to its includer response.  The
+// includer retains memory ownership of the response object.
 typedef shaderc_includer_response* (*shaderc_includer_response_get_fn)(
     void* user_data, const char* filename);
 
-// The function signature of the client-side implemented clean-up method.
-// Includer will call this callback function when the including process is done
-// with the fullpath and content data.
+// A function to destroy an includer response when it's no longer needed.
 typedef void (*shaderc_includer_response_release_fn)(
     void* user_data, shaderc_includer_response* data);
 
-// Sets the callback functions for the includer. When the includer queries for
-// the full path and content of a file, client's method will be called to
-// response. And when the query is done, client will be notified to clean up.
-// TODO: File inclusion needs to be context-aware.
-// e.g.
-//  In file: /path/to/main_shader.vert:
-//  #include "include/a"
-//  In file: /path/to/include/a":
-//  #include "b"
-//  When compiling /path/to/main_shader.vert, the compiler should be able to
-//  go to /path/to/include/b to find the file b.
-//  This needs context info from compiler to client includer, and may needs
-//  interface changes.
+// Sets includer callback functions. When a compiler encounters a #include in
+// the source, it will query the includer by invoking getter on user_data and
+// the #include argument.  The includer must respond with a
+// shaderc_includer_response object that remains valid until releaser is invoked
+// on it.  When the compiler is done processing the response, it will invoke
+// releaser on user_data and the response pointer.
 void shaderc_compile_options_set_includer_callbacks(
     shaderc_compile_options_t options, shaderc_includer_response_get_fn getter,
-    shaderc_includer_response_release_fn releasor, void* user_data);
-
-// Sets the compiler mode to do only preprocessing. The byte array result in the
-// module returned by the compilation is the text of the preprocessed shader.
-// This option overrides all other compilation modes, such as disassembly mode
-// and the default mode of compilation to SPIR-V binary.
-void shaderc_compile_options_set_preprocessing_only_mode(
-    shaderc_compile_options_t options);
+    shaderc_includer_response_release_fn releaser, void* user_data);
 
 // Sets the compiler mode to suppress warnings, overriding warnings-as-errors
 // mode. When both suppress-warnings and warnings-as-errors modes are
@@ -242,8 +222,9 @@ void shaderc_compile_options_set_target_env(shaderc_compile_options_t options,
 void shaderc_compile_options_set_warnings_as_errors(
     shaderc_compile_options_t options);
 
-// An opaque handle to the results of a call to shaderc_compile_into_spv().
-typedef struct shaderc_spv_module* shaderc_spv_module_t;
+// An opaque handle to the results of a call to any shaderc_compile_into_*()
+// function.
+typedef struct shaderc_compilation_result* shaderc_compilation_result_t;
 
 // Takes a GLSL source string and the associated shader kind, input file
 // name, compiles it according to the given additional_options. If the shader
@@ -256,59 +237,72 @@ typedef struct shaderc_spv_module* shaderc_spv_module_t;
 // The input_file_name is a null-termintated string. It is used as a tag to
 // identify the source string in cases like emitting error messages. It
 // doesn't have to be a 'file name'.
-// By default the source string will be compiled into SPIR-V binary
-// and a shaderc_spv_module will be returned to hold the results of the
-// compilation. When disassembly mode or preprocessing only mode is enabled
-// in the additional_options, the source string will be compiled into char
-// strings and held by the returned shaderc_spv_module.  The entry_point_name
-// null-terminated string defines the name of the entry point to associate
-// with this GLSL source. If the additional_options parameter is not NULL,
-// then the compilation is modified by any options present. May be safely
-// called from multiple threads without explicit synchronization. If there
-// was failure in allocating the compiler object NULL will be returned.
-shaderc_spv_module_t shaderc_compile_into_spv(
+// The source string will be compiled into SPIR-V binary and a
+// shaderc_compilation_result will be returned to hold the results.
+// The entry_point_name null-terminated string defines the name of the entry
+// point to associate with this GLSL source. If the additional_options
+// parameter is not null, then the compilation is modified by any options
+// present.  May be safely called from multiple threads without explicit
+// synchronization. If there was failure in allocating the compiler object,
+// null will be returned.
+shaderc_compilation_result_t shaderc_compile_into_spv(
     const shaderc_compiler_t compiler, const char* source_text,
     size_t source_text_size, shaderc_shader_kind shader_kind,
     const char* input_file_name, const char* entry_point_name,
     const shaderc_compile_options_t additional_options);
 
-// The following functions, operating on shaderc_spv_module_t objects, offer
-// only the basic thread-safety guarantee.
+// Like shaderc_compile_into_spv, but the result contains SPIR-V assembly text
+// instead of a SPIR-V binary module.  The SPIR-V assembly syntax is as defined
+// by the SPIRV-Tools open source project.
+shaderc_compilation_result_t shaderc_compile_into_spv_assembly(
+    const shaderc_compiler_t compiler, const char* source_text,
+    size_t source_text_size, shaderc_shader_kind shader_kind,
+    const char* input_file_name, const char* entry_point_name,
+    const shaderc_compile_options_t additional_options);
+
+// Like shaderc_compile_into_spv, but the result contains preprocessed source
+// code instead of a SPIR-V binary module
+shaderc_compilation_result_t shaderc_compile_into_preprocessed_text(
+    const shaderc_compiler_t compiler, const char* source_text,
+    size_t source_text_size, shaderc_shader_kind shader_kind,
+    const char* input_file_name, const char* entry_point_name,
+    const shaderc_compile_options_t additional_options);
 
-// Releases the resources held by module.  It is invalid to use module for any
-// further operations.
-void shaderc_module_release(shaderc_spv_module_t module);
+// The following functions, operating on shaderc_compilation_result_t objects,
+// offer only the basic thread-safety guarantee.
 
-// Returns true if the result in module was a successful compilation.
-bool shaderc_module_get_success(const shaderc_spv_module_t module);
+// Releases the resources held by the result object. It is invalid to use the
+// result object for any further operations.
+void shaderc_result_release(shaderc_compilation_result_t result);
 
-// Returns the number of bytes in a SPIR-V module result string. When the module
-// is compiled with disassembly mode or preprocessing only mode, the result
-// string is a char string. Otherwise, the result string is binary string.
-size_t shaderc_module_get_length(const shaderc_spv_module_t module);
+// Returns the number of bytes of the compilation output data in a result
+// object.
+size_t shaderc_result_get_length(const shaderc_compilation_result_t result);
 
 // Returns the number of warnings generated during the compilation.
-size_t shaderc_module_get_num_warnings(const shaderc_spv_module_t module);
+size_t shaderc_result_get_num_warnings(
+    const shaderc_compilation_result_t result);
 
 // Returns the number of errors generated during the compilation.
-size_t shaderc_module_get_num_errors(const shaderc_spv_module_t module);
+size_t shaderc_result_get_num_errors(const shaderc_compilation_result_t result);
 
 // Returns the compilation status, indicating whether the compilation succeeded,
 // or failed due to some reasons, like invalid shader stage or compilation
 // errors.
-shaderc_compilation_status shaderc_module_get_compilation_status(
-    const shaderc_spv_module_t);
+shaderc_compilation_status shaderc_result_get_compilation_status(
+    const shaderc_compilation_result_t);
 
-// Returns a pointer to the start of the SPIR-V bytes, either SPIR-V binary or
-// char string. When the source string is compiled into SPIR-V binary, this is
-// guaranteed to be castable to a uint32_t*. If the source string is compiled in
-// disassembly mode or preprocessing only mode, the pointer will point to the
-// result char string.
-const char* shaderc_module_get_bytes(const shaderc_spv_module_t module);
+// Returns a pointer to the start of the compilation output data bytes, either
+// SPIR-V binary or char string. When the source string is compiled into SPIR-V
+// binary, this is guaranteed to be castable to a uint32_t*. If the result
+// contains assembly text or preprocessed source text, the pointer will point to
+// the resulting array of characters.
+const char* shaderc_result_get_bytes(const shaderc_compilation_result_t result);
 
 // Returns a null-terminated string that contains any error messages generated
 // during the compilation.
-const char* shaderc_module_get_error_message(const shaderc_spv_module_t module);
+const char* shaderc_result_get_error_message(
+    const shaderc_compilation_result_t result);
 
 // Provides the version & revision of the SPIR-V which will be produced
 void shaderc_get_spv_version(unsigned int* version, unsigned int* revision);
@@ -324,4 +318,4 @@ bool shaderc_parse_version_profile(const char* str, int* version,
 }
 #endif  // __cplusplus
 
-#endif  // SHADERC_H_
+#endif  // SHADERC_SHADERC_H_