| OLD | NEW |
| 1 // Copyright 2015 The Shaderc Authors. All rights reserved. | 1 // Copyright 2015 The Shaderc Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 #ifndef SHADERC_H_ | 15 #ifndef SHADERC_SHADERC_H_ |
| 16 #define SHADERC_H_ | 16 #define SHADERC_SHADERC_H_ |
| 17 | 17 |
| 18 #ifdef __cplusplus | 18 #ifdef __cplusplus |
| 19 extern "C" { | 19 extern "C" { |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 #include <stdbool.h> | 22 #include <stdbool.h> |
| 23 #include <stddef.h> | 23 #include <stddef.h> |
| 24 #include <stdint.h> | 24 #include <stdint.h> |
| 25 | 25 |
| 26 typedef enum { | 26 typedef enum { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 56 } shaderc_target_env; | 56 } shaderc_target_env; |
| 57 | 57 |
| 58 typedef enum { | 58 typedef enum { |
| 59 shaderc_profile_none, // Used if and only if GLSL version did not specify | 59 shaderc_profile_none, // Used if and only if GLSL version did not specify |
| 60 // profiles. | 60 // profiles. |
| 61 shaderc_profile_core, | 61 shaderc_profile_core, |
| 62 shaderc_profile_compatibility, | 62 shaderc_profile_compatibility, |
| 63 shaderc_profile_es, | 63 shaderc_profile_es, |
| 64 } shaderc_profile; | 64 } shaderc_profile; |
| 65 | 65 |
| 66 // Used in the result module (shaderc_spv_module) to indicate the status of an | 66 // Indicate the status of a compilation. |
| 67 // compilation. | |
| 68 typedef enum { | 67 typedef enum { |
| 69 shaderc_compilation_status_success = 0, | 68 shaderc_compilation_status_success = 0, |
| 70 shaderc_compilation_status_invalid_stage, // error stage deduction | 69 shaderc_compilation_status_invalid_stage, // error stage deduction |
| 71 shaderc_compilation_status_compilation_error, | 70 shaderc_compilation_status_compilation_error, |
| 72 shaderc_compilation_status_internal_error, // unexpected failure | 71 shaderc_compilation_status_internal_error, // unexpected failure |
| 73 shaderc_compilation_status_null_result_module, | 72 shaderc_compilation_status_null_result_object, |
| 74 } shaderc_compilation_status; | 73 } shaderc_compilation_status; |
| 75 | 74 |
| 76 // Usage examples: | 75 // Usage examples: |
| 77 // | 76 // |
| 78 // Aggressively release compiler resources, but spend time in initialization | 77 // Aggressively release compiler resources, but spend time in initialization |
| 79 // for each new use. | 78 // for each new use. |
| 80 // shaderc_compiler_t compiler = shaderc_compiler_initialize(); | 79 // shaderc_compiler_t compiler = shaderc_compiler_initialize(); |
| 81 // shader_spv_module_t module = shaderc_compile_into_spv(compiler, | 80 // shaderc_compilation_result_t result = shaderc_compile_into_spv( |
| 82 // "int main() {}", 13, shaderc_glsl_vertex_shader, "main"); | 81 // compiler, "int main() {}", 13, shaderc_glsl_vertex_shader, "main"); |
| 83 // // Do stuff with module compilation results. | 82 // // Do stuff with compilation results. |
| 84 // shaderc_module_release(module); | 83 // shaderc_result_release(result); |
| 85 // shaderc_compiler_release(compiler); | 84 // shaderc_compiler_release(compiler); |
| 86 // | 85 // |
| 87 // Keep the compiler object around for a long time, but pay for extra space | 86 // Keep the compiler object around for a long time, but pay for extra space |
| 88 // occupied. | 87 // occupied. |
| 89 // shaderc_compiler_t compiler = shaderc_compiler_initialize(); | 88 // shaderc_compiler_t compiler = shaderc_compiler_initialize(); |
| 90 // // On the same, other or multiple simultaneous threads. | 89 // // On the same, other or multiple simultaneous threads. |
| 91 // shader_spv_module_t module = shaderc_compile_into_spv(compiler, | 90 // shaderc_compilation_result_t result = shaderc_compile_into_spv( |
| 92 // "int main() {}", 13, shaderc_glsl_vertex_shader, "main"); | 91 // compiler, "int main() {}", 13, shaderc_glsl_vertex_shader, "main"); |
| 93 // // Do stuff with module compilation results. | 92 // // Do stuff with compilation results. |
| 94 // shaderc_module_release(module); | 93 // shaderc_result_release(result); |
| 95 // // Once no more compilations are to happen. | 94 // // Once no more compilations are to happen. |
| 96 // shaderc_compiler_release(compiler); | 95 // shaderc_compiler_release(compiler); |
| 97 | 96 |
| 98 // An opaque handle to an object that manages all compiler state. | 97 // An opaque handle to an object that manages all compiler state. |
| 99 typedef struct shaderc_compiler* shaderc_compiler_t; | 98 typedef struct shaderc_compiler* shaderc_compiler_t; |
| 100 | 99 |
| 101 // Returns a shaderc_compiler_t that can be used to compile modules. | 100 // Returns a shaderc_compiler_t that can be used to compile modules. |
| 102 // A return of NULL indicates that there was an error initializing the compiler. | 101 // A return of NULL indicates that there was an error initializing the compiler. |
| 103 // Any function operating on shaderc_compiler_t must offer the basic | 102 // Any function operating on shaderc_compiler_t must offer the basic |
| 104 // thread-safety guarantee. | 103 // thread-safety guarantee. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 129 // If NULL is passed as the parameter the call is the same as | 128 // If NULL is passed as the parameter the call is the same as |
| 130 // shaderc_compile_options_init. | 129 // shaderc_compile_options_init. |
| 131 shaderc_compile_options_t shaderc_compile_options_clone( | 130 shaderc_compile_options_t shaderc_compile_options_clone( |
| 132 const shaderc_compile_options_t options); | 131 const shaderc_compile_options_t options); |
| 133 | 132 |
| 134 // Releases the compilation options. It is invalid to use the given | 133 // Releases the compilation options. It is invalid to use the given |
| 135 // shaderc_compile_options_t object in any future calls. It is safe to pass | 134 // shaderc_compile_options_t object in any future calls. It is safe to pass |
| 136 // NULL to this function, and doing such will have no effect. | 135 // NULL to this function, and doing such will have no effect. |
| 137 void shaderc_compile_options_release(shaderc_compile_options_t options); | 136 void shaderc_compile_options_release(shaderc_compile_options_t options); |
| 138 | 137 |
| 139 // Adds a predefined macro to the compilation options. This has the | 138 // Adds a predefined macro to the compilation options. This has the same |
| 140 // same effect as passing -Dname=value to the command-line compiler. | 139 // effect as passing -Dname=value to the command-line compiler. If value |
| 141 // If value is NULL, it has the effect same as passing -Dname to the | 140 // is NULL, it has the same effect as passing -Dname to the command-line |
| 142 // command-line compiler. If a macro definition with the same name has | 141 // compiler. If a macro definition with the same name has previously been |
| 143 // previously been added, the value is replaced with the new value. | 142 // added, the value is replaced with the new value. The macro name and |
| 144 // The null-terminated strings that the name and value parameters point to | 143 // value are passed in with char pointers, which point to their data, and |
| 145 // must remain valid for the duration of the call, but can be modified or | 144 // the lengths of their data. The strings that the name and value pointers |
| 146 // deleted after this function has returned. | 145 // point to must remain valid for the duration of the call, but can be |
| 146 // modified or deleted after this function has returned. In case of adding |
| 147 // a valueless macro, the value argument should be a null pointer or the |
| 148 // value_length should be 0u. |
| 147 void shaderc_compile_options_add_macro_definition( | 149 void shaderc_compile_options_add_macro_definition( |
| 148 shaderc_compile_options_t options, const char* name, const char* value); | 150 shaderc_compile_options_t options, const char* name, size_t name_length, |
| 151 const char* value, size_t value_length); |
| 149 | 152 |
| 150 // Sets the compiler mode to generate debug information in the output. | 153 // Sets the compiler mode to generate debug information in the output. |
| 151 void shaderc_compile_options_set_generate_debug_info( | 154 void shaderc_compile_options_set_generate_debug_info( |
| 152 shaderc_compile_options_t options); | 155 shaderc_compile_options_t options); |
| 153 | 156 |
| 154 // Sets the compiler mode to emit a disassembly text instead of a binary. In | |
| 155 // this mode, the byte array result in the shaderc_spv_module returned | |
| 156 // from shaderc_compile_into_spv() will consist of SPIR-V assembly text. | |
| 157 // Note the preprocessing only mode overrides this option, and this option | |
| 158 // overrides the default mode generating a SPIR-V binary. | |
| 159 void shaderc_compile_options_set_disassembly_mode( | |
| 160 shaderc_compile_options_t options); | |
| 161 | |
| 162 // Forces the GLSL language version and profile to a given pair. The version | 157 // Forces the GLSL language version and profile to a given pair. The version |
| 163 // number is the same as would appear in the #version annotation in the source. | 158 // number is the same as would appear in the #version annotation in the source. |
| 164 // Version and profile specified here overrides the #version annotation in the | 159 // Version and profile specified here overrides the #version annotation in the |
| 165 // source. Use profile: 'shaderc_profile_none' for GLSL versions that do not | 160 // source. Use profile: 'shaderc_profile_none' for GLSL versions that do not |
| 166 // define profiles, e.g. versions below 150. | 161 // define profiles, e.g. versions below 150. |
| 167 void shaderc_compile_options_set_forced_version_profile( | 162 void shaderc_compile_options_set_forced_version_profile( |
| 168 shaderc_compile_options_t options, int version, shaderc_profile profile); | 163 shaderc_compile_options_t options, int version, shaderc_profile profile); |
| 169 | 164 |
| 170 // To support file inclusion, libshaderc invokes a callback into its client to | 165 // Response to a request for #include content. "Includer" is client code that |
| 171 // resolve the full path and content of the included file. | 166 // resolves #include arguments into objects of this type. |
| 172 // The client callback should follow the specified function signature below, and | 167 // |
| 173 // it should be passed to libshaderc through the corresponding setter function. | 168 // TODO: File inclusion needs to be context-aware. |
| 174 // When the including of a file is done, libshaderc will call another client | 169 // e.g. |
| 175 // callback to clean up the resources used for the including process. The client | 170 // In file: /path/to/main_shader.vert: |
| 176 // should implement the clean up method and pass it to libshaderc together with | 171 // #include "include/a" |
| 177 // the response method. | 172 // In file: /path/to/include/a": |
| 178 | 173 // #include "b" |
| 179 // The struct that contains the information to be returned to the libshaderc. | 174 // When compiling /path/to/main_shader.vert, the compiler should be able to |
| 180 // The client-side implemented response method should return a pointer of this | 175 // go to /path/to/include/b to find the file b. |
| 181 // struct. The underlying data is owned by client code. | 176 // This needs context info from compiler to client includer, and may needs |
| 177 // interface changes. |
| 182 struct shaderc_includer_response { | 178 struct shaderc_includer_response { |
| 183 const char* path; | 179 const char* path; |
| 184 size_t path_length; | 180 size_t path_length; |
| 185 const char* content; | 181 const char* content; |
| 186 size_t content_length; | 182 size_t content_length; |
| 187 }; | 183 }; |
| 188 | 184 |
| 189 // The function signature of the client-side implemented response method. It | 185 // A function mapping a #include argument to its includer response. The |
| 190 // returns a pointer to shaderc_includer_response struct. | 186 // includer retains memory ownership of the response object. |
| 191 typedef shaderc_includer_response* (*shaderc_includer_response_get_fn)( | 187 typedef shaderc_includer_response* (*shaderc_includer_response_get_fn)( |
| 192 void* user_data, const char* filename); | 188 void* user_data, const char* filename); |
| 193 | 189 |
| 194 // The function signature of the client-side implemented clean-up method. | 190 // A function to destroy an includer response when it's no longer needed. |
| 195 // Includer will call this callback function when the including process is done | |
| 196 // with the fullpath and content data. | |
| 197 typedef void (*shaderc_includer_response_release_fn)( | 191 typedef void (*shaderc_includer_response_release_fn)( |
| 198 void* user_data, shaderc_includer_response* data); | 192 void* user_data, shaderc_includer_response* data); |
| 199 | 193 |
| 200 // Sets the callback functions for the includer. When the includer queries for | 194 // Sets includer callback functions. When a compiler encounters a #include in |
| 201 // the full path and content of a file, client's method will be called to | 195 // the source, it will query the includer by invoking getter on user_data and |
| 202 // response. And when the query is done, client will be notified to clean up. | 196 // the #include argument. The includer must respond with a |
| 203 // TODO: File inclusion needs to be context-aware. | 197 // shaderc_includer_response object that remains valid until releaser is invoked |
| 204 // e.g. | 198 // on it. When the compiler is done processing the response, it will invoke |
| 205 // In file: /path/to/main_shader.vert: | 199 // releaser on user_data and the response pointer. |
| 206 // #include "include/a" | |
| 207 // In file: /path/to/include/a": | |
| 208 // #include "b" | |
| 209 // When compiling /path/to/main_shader.vert, the compiler should be able to | |
| 210 // go to /path/to/include/b to find the file b. | |
| 211 // This needs context info from compiler to client includer, and may needs | |
| 212 // interface changes. | |
| 213 void shaderc_compile_options_set_includer_callbacks( | 200 void shaderc_compile_options_set_includer_callbacks( |
| 214 shaderc_compile_options_t options, shaderc_includer_response_get_fn getter, | 201 shaderc_compile_options_t options, shaderc_includer_response_get_fn getter, |
| 215 shaderc_includer_response_release_fn releasor, void* user_data); | 202 shaderc_includer_response_release_fn releaser, void* user_data); |
| 216 | |
| 217 // Sets the compiler mode to do only preprocessing. The byte array result in the | |
| 218 // module returned by the compilation is the text of the preprocessed shader. | |
| 219 // This option overrides all other compilation modes, such as disassembly mode | |
| 220 // and the default mode of compilation to SPIR-V binary. | |
| 221 void shaderc_compile_options_set_preprocessing_only_mode( | |
| 222 shaderc_compile_options_t options); | |
| 223 | 203 |
| 224 // Sets the compiler mode to suppress warnings, overriding warnings-as-errors | 204 // Sets the compiler mode to suppress warnings, overriding warnings-as-errors |
| 225 // mode. When both suppress-warnings and warnings-as-errors modes are | 205 // mode. When both suppress-warnings and warnings-as-errors modes are |
| 226 // turned on, warning messages will be inhibited, and will not be emitted | 206 // turned on, warning messages will be inhibited, and will not be emitted |
| 227 // as error messages. | 207 // as error messages. |
| 228 void shaderc_compile_options_set_suppress_warnings( | 208 void shaderc_compile_options_set_suppress_warnings( |
| 229 shaderc_compile_options_t options); | 209 shaderc_compile_options_t options); |
| 230 | 210 |
| 231 // Sets the target shader environment, affecting which warnings or errors will | 211 // Sets the target shader environment, affecting which warnings or errors will |
| 232 // be issued. The version will be for distinguishing between different versions | 212 // be issued. The version will be for distinguishing between different versions |
| 233 // of the target environment. "0" is the only supported version at this point | 213 // of the target environment. "0" is the only supported version at this point |
| 234 void shaderc_compile_options_set_target_env(shaderc_compile_options_t options, | 214 void shaderc_compile_options_set_target_env(shaderc_compile_options_t options, |
| 235 shaderc_target_env target, | 215 shaderc_target_env target, |
| 236 uint32_t version); | 216 uint32_t version); |
| 237 | 217 |
| 238 // Sets the compiler mode to treat all warnings as errors. Note the | 218 // Sets the compiler mode to treat all warnings as errors. Note the |
| 239 // suppress-warnings mode overrides this option, i.e. if both | 219 // suppress-warnings mode overrides this option, i.e. if both |
| 240 // warning-as-errors and suppress-warnings modes are set, warnings will not | 220 // warning-as-errors and suppress-warnings modes are set, warnings will not |
| 241 // be emitted as error messages. | 221 // be emitted as error messages. |
| 242 void shaderc_compile_options_set_warnings_as_errors( | 222 void shaderc_compile_options_set_warnings_as_errors( |
| 243 shaderc_compile_options_t options); | 223 shaderc_compile_options_t options); |
| 244 | 224 |
| 245 // An opaque handle to the results of a call to shaderc_compile_into_spv(). | 225 // An opaque handle to the results of a call to any shaderc_compile_into_*() |
| 246 typedef struct shaderc_spv_module* shaderc_spv_module_t; | 226 // function. |
| 227 typedef struct shaderc_compilation_result* shaderc_compilation_result_t; |
| 247 | 228 |
| 248 // Takes a GLSL source string and the associated shader kind, input file | 229 // Takes a GLSL source string and the associated shader kind, input file |
| 249 // name, compiles it according to the given additional_options. If the shader | 230 // name, compiles it according to the given additional_options. If the shader |
| 250 // kind is not set to a specified kind, but shaderc_glslc_infer_from_source, | 231 // kind is not set to a specified kind, but shaderc_glslc_infer_from_source, |
| 251 // the compiler will try to deduce the shader kind from the source | 232 // the compiler will try to deduce the shader kind from the source |
| 252 // string and a failure in deducing will generate an error. Currently only | 233 // string and a failure in deducing will generate an error. Currently only |
| 253 // #pragma annotation is supported. If the shader kind is set to one of the | 234 // #pragma annotation is supported. If the shader kind is set to one of the |
| 254 // default shader kinds, the compiler will fall back to the default shader | 235 // default shader kinds, the compiler will fall back to the default shader |
| 255 // kind in case it failed to deduce the shader kind from source string. | 236 // kind in case it failed to deduce the shader kind from source string. |
| 256 // The input_file_name is a null-termintated string. It is used as a tag to | 237 // The input_file_name is a null-termintated string. It is used as a tag to |
| 257 // identify the source string in cases like emitting error messages. It | 238 // identify the source string in cases like emitting error messages. It |
| 258 // doesn't have to be a 'file name'. | 239 // doesn't have to be a 'file name'. |
| 259 // By default the source string will be compiled into SPIR-V binary | 240 // The source string will be compiled into SPIR-V binary and a |
| 260 // and a shaderc_spv_module will be returned to hold the results of the | 241 // shaderc_compilation_result will be returned to hold the results. |
| 261 // compilation. When disassembly mode or preprocessing only mode is enabled | 242 // The entry_point_name null-terminated string defines the name of the entry |
| 262 // in the additional_options, the source string will be compiled into char | 243 // point to associate with this GLSL source. If the additional_options |
| 263 // strings and held by the returned shaderc_spv_module. The entry_point_name | 244 // parameter is not null, then the compilation is modified by any options |
| 264 // null-terminated string defines the name of the entry point to associate | 245 // present. May be safely called from multiple threads without explicit |
| 265 // with this GLSL source. If the additional_options parameter is not NULL, | 246 // synchronization. If there was failure in allocating the compiler object, |
| 266 // then the compilation is modified by any options present. May be safely | 247 // null will be returned. |
| 267 // called from multiple threads without explicit synchronization. If there | 248 shaderc_compilation_result_t shaderc_compile_into_spv( |
| 268 // was failure in allocating the compiler object NULL will be returned. | |
| 269 shaderc_spv_module_t shaderc_compile_into_spv( | |
| 270 const shaderc_compiler_t compiler, const char* source_text, | 249 const shaderc_compiler_t compiler, const char* source_text, |
| 271 size_t source_text_size, shaderc_shader_kind shader_kind, | 250 size_t source_text_size, shaderc_shader_kind shader_kind, |
| 272 const char* input_file_name, const char* entry_point_name, | 251 const char* input_file_name, const char* entry_point_name, |
| 273 const shaderc_compile_options_t additional_options); | 252 const shaderc_compile_options_t additional_options); |
| 274 | 253 |
| 275 // The following functions, operating on shaderc_spv_module_t objects, offer | 254 // Like shaderc_compile_into_spv, but the result contains SPIR-V assembly text |
| 276 // only the basic thread-safety guarantee. | 255 // instead of a SPIR-V binary module. The SPIR-V assembly syntax is as defined |
| 256 // by the SPIRV-Tools open source project. |
| 257 shaderc_compilation_result_t shaderc_compile_into_spv_assembly( |
| 258 const shaderc_compiler_t compiler, const char* source_text, |
| 259 size_t source_text_size, shaderc_shader_kind shader_kind, |
| 260 const char* input_file_name, const char* entry_point_name, |
| 261 const shaderc_compile_options_t additional_options); |
| 277 | 262 |
| 278 // Releases the resources held by module. It is invalid to use module for any | 263 // Like shaderc_compile_into_spv, but the result contains preprocessed source |
| 279 // further operations. | 264 // code instead of a SPIR-V binary module |
| 280 void shaderc_module_release(shaderc_spv_module_t module); | 265 shaderc_compilation_result_t shaderc_compile_into_preprocessed_text( |
| 266 const shaderc_compiler_t compiler, const char* source_text, |
| 267 size_t source_text_size, shaderc_shader_kind shader_kind, |
| 268 const char* input_file_name, const char* entry_point_name, |
| 269 const shaderc_compile_options_t additional_options); |
| 281 | 270 |
| 282 // Returns true if the result in module was a successful compilation. | 271 // The following functions, operating on shaderc_compilation_result_t objects, |
| 283 bool shaderc_module_get_success(const shaderc_spv_module_t module); | 272 // offer only the basic thread-safety guarantee. |
| 284 | 273 |
| 285 // Returns the number of bytes in a SPIR-V module result string. When the module | 274 // Releases the resources held by the result object. It is invalid to use the |
| 286 // is compiled with disassembly mode or preprocessing only mode, the result | 275 // result object for any further operations. |
| 287 // string is a char string. Otherwise, the result string is binary string. | 276 void shaderc_result_release(shaderc_compilation_result_t result); |
| 288 size_t shaderc_module_get_length(const shaderc_spv_module_t module); | 277 |
| 278 // Returns the number of bytes of the compilation output data in a result |
| 279 // object. |
| 280 size_t shaderc_result_get_length(const shaderc_compilation_result_t result); |
| 289 | 281 |
| 290 // Returns the number of warnings generated during the compilation. | 282 // Returns the number of warnings generated during the compilation. |
| 291 size_t shaderc_module_get_num_warnings(const shaderc_spv_module_t module); | 283 size_t shaderc_result_get_num_warnings( |
| 284 const shaderc_compilation_result_t result); |
| 292 | 285 |
| 293 // Returns the number of errors generated during the compilation. | 286 // Returns the number of errors generated during the compilation. |
| 294 size_t shaderc_module_get_num_errors(const shaderc_spv_module_t module); | 287 size_t shaderc_result_get_num_errors(const shaderc_compilation_result_t result); |
| 295 | 288 |
| 296 // Returns the compilation status, indicating whether the compilation succeeded, | 289 // Returns the compilation status, indicating whether the compilation succeeded, |
| 297 // or failed due to some reasons, like invalid shader stage or compilation | 290 // or failed due to some reasons, like invalid shader stage or compilation |
| 298 // errors. | 291 // errors. |
| 299 shaderc_compilation_status shaderc_module_get_compilation_status( | 292 shaderc_compilation_status shaderc_result_get_compilation_status( |
| 300 const shaderc_spv_module_t); | 293 const shaderc_compilation_result_t); |
| 301 | 294 |
| 302 // Returns a pointer to the start of the SPIR-V bytes, either SPIR-V binary or | 295 // Returns a pointer to the start of the compilation output data bytes, either |
| 303 // char string. When the source string is compiled into SPIR-V binary, this is | 296 // SPIR-V binary or char string. When the source string is compiled into SPIR-V |
| 304 // guaranteed to be castable to a uint32_t*. If the source string is compiled in | 297 // binary, this is guaranteed to be castable to a uint32_t*. If the result |
| 305 // disassembly mode or preprocessing only mode, the pointer will point to the | 298 // contains assembly text or preprocessed source text, the pointer will point to |
| 306 // result char string. | 299 // the resulting array of characters. |
| 307 const char* shaderc_module_get_bytes(const shaderc_spv_module_t module); | 300 const char* shaderc_result_get_bytes(const shaderc_compilation_result_t result); |
| 308 | 301 |
| 309 // Returns a null-terminated string that contains any error messages generated | 302 // Returns a null-terminated string that contains any error messages generated |
| 310 // during the compilation. | 303 // during the compilation. |
| 311 const char* shaderc_module_get_error_message(const shaderc_spv_module_t module); | 304 const char* shaderc_result_get_error_message( |
| 305 const shaderc_compilation_result_t result); |
| 312 | 306 |
| 313 // Provides the version & revision of the SPIR-V which will be produced | 307 // Provides the version & revision of the SPIR-V which will be produced |
| 314 void shaderc_get_spv_version(unsigned int* version, unsigned int* revision); | 308 void shaderc_get_spv_version(unsigned int* version, unsigned int* revision); |
| 315 | 309 |
| 316 // Parses the version and profile from a given null-terminated string | 310 // Parses the version and profile from a given null-terminated string |
| 317 // containing both version and profile, like: '450core'. Returns false if | 311 // containing both version and profile, like: '450core'. Returns false if |
| 318 // the string can not be parsed. Returns true when the parsing succeeds. The | 312 // the string can not be parsed. Returns true when the parsing succeeds. The |
| 319 // parsed version and profile are returned through arguments. | 313 // parsed version and profile are returned through arguments. |
| 320 bool shaderc_parse_version_profile(const char* str, int* version, | 314 bool shaderc_parse_version_profile(const char* str, int* version, |
| 321 shaderc_profile* profile); | 315 shaderc_profile* profile); |
| 322 | 316 |
| 323 #ifdef __cplusplus | 317 #ifdef __cplusplus |
| 324 } | 318 } |
| 325 #endif // __cplusplus | 319 #endif // __cplusplus |
| 326 | 320 |
| 327 #endif // SHADERC_H_ | 321 #endif // SHADERC_SHADERC_H_ |
| OLD | NEW |