Remove use of iostream in filamat (#549)
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
#include "GLSLPostProcessor.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
@@ -29,6 +28,8 @@
|
||||
#include "sca/builtinResource.h"
|
||||
#include "sca/GLSLTools.h"
|
||||
|
||||
#include <utils/Log.h>
|
||||
|
||||
using namespace glslang;
|
||||
using namespace spirv_cross;
|
||||
using namespace spvtools;
|
||||
@@ -54,7 +55,7 @@ static uint32_t shaderVersionFromModel(filament::driver::ShaderModel model) {
|
||||
}
|
||||
|
||||
static void errorHandler(const std::string& str) {
|
||||
std::cerr << str << std::endl;
|
||||
utils::slog.e << str << utils::io::endl;
|
||||
}
|
||||
|
||||
static std::string stringifySpvOptimizerMessage(spv_message_level_t level, const char* source,
|
||||
@@ -136,7 +137,7 @@ bool GLSLPostProcessor::process(const std::string& inputShader,
|
||||
if (targetApi == TargetApi::OPENGL && mOptimization == MaterialBuilder::Optimization::NONE) {
|
||||
*outputGlsl = inputShader;
|
||||
if (mPrintShaders) {
|
||||
std::cout << *outputGlsl << std::endl;
|
||||
utils::slog.i << *outputGlsl << utils::io::endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -164,7 +165,7 @@ bool GLSLPostProcessor::process(const std::string& inputShader,
|
||||
EShMessages msg = GLSLTools::glslangFlagsFromTargetApi(targetApi);
|
||||
bool ok = tShader.parse(&DefaultTBuiltInResource, mLangVersion, false, msg);
|
||||
if (!ok) {
|
||||
std::cerr << tShader.getInfoLog() << std::endl;
|
||||
utils::slog.e << tShader.getInfoLog() << utils::io::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -173,7 +174,7 @@ bool GLSLPostProcessor::process(const std::string& inputShader,
|
||||
// SPIR-V types
|
||||
bool linkOk = program.link(msg);
|
||||
if (!linkOk) {
|
||||
std::cerr << tShader.getInfoLog() << std::endl;
|
||||
utils::slog.e << tShader.getInfoLog() << utils::io::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -182,8 +183,8 @@ bool GLSLPostProcessor::process(const std::string& inputShader,
|
||||
if (mSpirvOutput) {
|
||||
GlslangToSpv(*program.getIntermediate(mShLang), *mSpirvOutput);
|
||||
} else {
|
||||
std::cerr << "GLSL post-processor invoked with optimization level NONE"
|
||||
<< std::endl;
|
||||
utils::slog.e << "GLSL post-processor invoked with optimization level NONE"
|
||||
<< utils::io::endl;
|
||||
}
|
||||
break;
|
||||
case MaterialBuilder::Optimization::PREPROCESSOR:
|
||||
@@ -198,7 +199,7 @@ bool GLSLPostProcessor::process(const std::string& inputShader,
|
||||
if (mGlslOutput) {
|
||||
*mGlslOutput = shrinkString(*mGlslOutput);
|
||||
if (mPrintShaders) {
|
||||
std::cout << *mGlslOutput << std::endl;
|
||||
utils::slog.i << *mGlslOutput << utils::io::endl;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -218,7 +219,7 @@ void GLSLPostProcessor::preprocessOptimization(glslang::TShader& tShader,
|
||||
msg, &glsl, forbidIncluder);
|
||||
|
||||
if (!ok) {
|
||||
std::cerr << tShader.getInfoLog() << std::endl;
|
||||
utils::slog.e << tShader.getInfoLog() << utils::io::endl;
|
||||
}
|
||||
|
||||
if (mSpirvOutput) {
|
||||
@@ -233,7 +234,7 @@ void GLSLPostProcessor::preprocessOptimization(glslang::TShader& tShader,
|
||||
// SPIR-V types
|
||||
bool linkOk = program.link(msg);
|
||||
if (!ok || !linkOk) {
|
||||
std::cerr << spirvShader.getInfoLog() << std::endl;
|
||||
utils::slog.e << spirvShader.getInfoLog() << utils::io::endl;
|
||||
} else {
|
||||
GlslangToSpv(*program.getIntermediate(mShLang), *mSpirvOutput);
|
||||
}
|
||||
@@ -255,7 +256,8 @@ void GLSLPostProcessor::fullOptimization(const TShader& tShader,
|
||||
Optimizer optimizer(SPV_ENV_UNIVERSAL_1_3);
|
||||
optimizer.SetMessageConsumer([](spv_message_level_t level,
|
||||
const char* source, const spv_position_t& position, const char* message) {
|
||||
std::cerr << stringifySpvOptimizerMessage(level, source, position, message) << std::endl;
|
||||
utils::slog.e << stringifySpvOptimizerMessage(level, source, position, message)
|
||||
<< utils::io::endl;
|
||||
});
|
||||
|
||||
if (mOptimization == MaterialBuilder::Optimization::SIZE) {
|
||||
@@ -265,7 +267,7 @@ void GLSLPostProcessor::fullOptimization(const TShader& tShader,
|
||||
}
|
||||
|
||||
if (!optimizer.Run(spirv.data(), spirv.size(), &spirv)) {
|
||||
std::cerr << "SPIR-V optimizer pass failed" << std::endl;
|
||||
utils::slog.e << "SPIR-V optimizer pass failed" << utils::io::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user