Skip to content

Commit

Permalink
Metal: support float16 operations in --optimize-size mode (#7249)
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado authored Oct 9, 2023
1 parent 78d433c commit 6279613
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions libs/filamat/src/GLSLPostProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,13 +587,14 @@ std::shared_ptr<spvtools::Optimizer> GLSLPostProcessor::createOptimizer(
registerSizePasses(*optimizer, config);
} else if (optimization == MaterialBuilder::Optimization::PERFORMANCE) {
registerPerformancePasses(*optimizer, config);
// Metal doesn't support relaxed precision, but does have support for float16 math operations.
if (config.targetApi == MaterialBuilder::TargetApi::METAL) {
optimizer->RegisterPass(CreateConvertRelaxedToHalfPass());
optimizer->RegisterPass(CreateSimplificationPass());
optimizer->RegisterPass(CreateRedundancyEliminationPass());
optimizer->RegisterPass(CreateAggressiveDCEPass());
}
}

// Metal doesn't support relaxed precision, but does have support for float16 math operations.
if (config.targetApi == MaterialBuilder::TargetApi::METAL) {
optimizer->RegisterPass(CreateConvertRelaxedToHalfPass());
optimizer->RegisterPass(CreateSimplificationPass());
optimizer->RegisterPass(CreateRedundancyEliminationPass());
optimizer->RegisterPass(CreateAggressiveDCEPass());
}

return optimizer;
Expand Down

0 comments on commit 6279613

Please sign in to comment.