@@ -10,11 +10,21 @@ using namespace SPIRV_CROSS_NAMESPACE;
10
10
namespace impeller {
11
11
namespace compiler {
12
12
13
+ // This replaces the SPIRV_CROSS_THROW which aborts and drops the
14
+ // error message in non-debug modes.
15
+ void report_and_exit (const std::string& msg) {
16
+ fprintf (stderr, " There was a compiler error: %s\n " , msg.c_str ());
17
+ fflush (stderr);
18
+ exit (1 );
19
+ }
20
+
21
+ #define FLUTTER_CROSS_THROW (x ) report_and_exit(x)
22
+
13
23
std::string CompilerSkSL::compile () {
14
24
ir.fixup_reserved_names ();
15
25
16
26
if (get_execution_model () != ExecutionModelFragment) {
17
- SPIRV_CROSS_THROW (" Only fragment shaders are supported.'" );
27
+ FLUTTER_CROSS_THROW (" Only fragment shaders are supported.'" );
18
28
return " " ;
19
29
}
20
30
@@ -111,7 +121,7 @@ void CompilerSkSL::emit_uniform(const SPIRVariable& var) {
111
121
add_resource_name (var.self );
112
122
statement (variable_decl (var), " ;" );
113
123
114
- // The Flutter FragmentProgram implementation passes additional unifroms along
124
+ // The Flutter FragmentProgram implementation passes additional uniforms along
115
125
// with shader uniforms that encode the shader width and height.
116
126
if (type.basetype == SPIRType::SampledImage) {
117
127
std::string name = to_name (var.self );
@@ -179,8 +189,8 @@ void CompilerSkSL::detect_unsupported_resources() {
179
189
DecorationBlock) ||
180
190
ir.meta [type.self ].decoration .decoration_flags .get (
181
191
DecorationBufferBlock))) {
182
- SPIRV_CROSS_THROW (" SkSL does not support UBOs or SSBOs: '" +
183
- get_name (var.self ) + " '" );
192
+ FLUTTER_CROSS_THROW (" SkSL does not support UBOs or SSBOs: '" +
193
+ get_name (var.self ) + " '" );
184
194
}
185
195
}
186
196
}
@@ -192,8 +202,8 @@ void CompilerSkSL::detect_unsupported_resources() {
192
202
auto & type = get<SPIRType>(var.basetype );
193
203
if (!is_hidden_variable (var) && var.storage != StorageClassFunction &&
194
204
type.pointer && type.storage == StorageClassPushConstant) {
195
- SPIRV_CROSS_THROW (" SkSL does not support push constant blocks: '" +
196
- get_name (var.self ) + " '" );
205
+ FLUTTER_CROSS_THROW (" SkSL does not support push constant blocks: '" +
206
+ get_name (var.self ) + " '" );
197
207
}
198
208
}
199
209
}
@@ -342,8 +352,8 @@ void CompilerSkSL::emit_interface_block(const SPIRVariable& var) {
342
352
bool block =
343
353
ir.meta [type.self ].decoration .decoration_flags .get (DecorationBlock);
344
354
if (block) {
345
- SPIRV_CROSS_THROW (" Interface blocks are not supported: '" +
346
- to_name (var.self ) + " '" );
355
+ FLUTTER_CROSS_THROW (" Interface blocks are not supported: '" +
356
+ to_name (var.self ) + " '" );
347
357
}
348
358
349
359
// The output is emitted as a global variable, which is returned from the
@@ -353,8 +363,8 @@ void CompilerSkSL::emit_interface_block(const SPIRVariable& var) {
353
363
if (output_name_.empty ()) {
354
364
output_name_ = to_name (var.self );
355
365
} else if (to_name (var.self ) != output_name_) {
356
- SPIRV_CROSS_THROW (" Only one output variable is supported: '" +
357
- to_name (var.self ) + " '" );
366
+ FLUTTER_CROSS_THROW (" Only one output variable is supported: '" +
367
+ to_name (var.self ) + " '" );
358
368
}
359
369
}
360
370
@@ -369,11 +379,12 @@ void CompilerSkSL::emit_function_prototype(SPIRFunction& func,
369
379
370
380
auto & type = get<SPIRType>(func.return_type );
371
381
if (type.basetype != SPIRType::Void) {
372
- SPIRV_CROSS_THROW (" Return type of the entrypoint function must be 'void'" );
382
+ FLUTTER_CROSS_THROW (
383
+ " Return type of the entrypoint function must be 'void'" );
373
384
}
374
385
375
386
if (func.arguments .size () != 0 ) {
376
- SPIRV_CROSS_THROW (
387
+ FLUTTER_CROSS_THROW (
377
388
" The entry point function should not acept any parameters." );
378
389
}
379
390
@@ -387,7 +398,7 @@ void CompilerSkSL::emit_function_prototype(SPIRFunction& func,
387
398
388
399
std::string CompilerSkSL::image_type_glsl (const SPIRType& type, uint32_t id) {
389
400
if (type.basetype != SPIRType::SampledImage || type.image .dim != Dim2D) {
390
- SPIRV_CROSS_THROW (" Only sampler2D uniform image types are supported." );
401
+ FLUTTER_CROSS_THROW (" Only sampler2D uniform image types are supported." );
391
402
return " ???" ;
392
403
}
393
404
return " shader" ;
@@ -400,7 +411,7 @@ std::string CompilerSkSL::builtin_to_glsl(BuiltIn builtin,
400
411
case BuiltInFragCoord:
401
412
return " flutter_FragCoord" ;
402
413
default :
403
- SPIRV_CROSS_THROW (" Builtin '" + gl_builtin + " ' is not supported." );
414
+ FLUTTER_CROSS_THROW (" Builtin '" + gl_builtin + " ' is not supported." );
404
415
break ;
405
416
}
406
417
@@ -414,7 +425,7 @@ std::string CompilerSkSL::to_texture_op(
414
425
SmallVector<uint32_t >& inherited_expressions) {
415
426
auto op = static_cast <Op>(i.op );
416
427
if (op != OpImageSampleImplicitLod) {
417
- SPIRV_CROSS_THROW (" Only simple shader sampling is supported." );
428
+ FLUTTER_CROSS_THROW (" Only simple shader sampling is supported." );
418
429
return " ???" ;
419
430
}
420
431
return CompilerGLSL::to_texture_op (i, sparse, forward, inherited_expressions);
@@ -442,8 +453,8 @@ std::string CompilerSkSL::to_function_args(const TextureFunctionArguments& args,
442
453
}
443
454
444
455
if (no_shader.empty ()) {
445
- SPIRV_CROSS_THROW (" Unexpected shader sampling arguments: '(" + glsl_args +
446
- " )'" );
456
+ FLUTTER_CROSS_THROW (" Unexpected shader sampling arguments: '(" + glsl_args +
457
+ " )'" );
447
458
return " ()" ;
448
459
}
449
460
0 commit comments