Commit aead8edf by jchen10 Committed by Commit Bot

Mute worker context creation warnings

This moves the warnings to InfoLog. Bug: chromium:931294 Change-Id: I1627aa63bdda6f92fc89b8921eb260302ba9063f Reviewed-on: https://chromium-review.googlesource.com/c/1469721Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
parent 559aaca5
...@@ -108,7 +108,7 @@ class ScopedExit final : angle::NonCopyable ...@@ -108,7 +108,7 @@ class ScopedExit final : angle::NonCopyable
std::function<void()> mExit; std::function<void()> mExit;
}; };
using CompileImplFunctor = std::function<void(const std::string &)>; using CompileImplFunctor = std::function<void(const std::string &, std::string &)>;
class CompileTask : public angle::Closure class CompileTask : public angle::Closure
{ {
public: public:
...@@ -135,10 +135,11 @@ class CompileTask : public angle::Closure ...@@ -135,10 +135,11 @@ class CompileTask : public angle::Closure
mResult = sh::Compile(mHandle, &srcStrings[0], srcStrings.size(), mOptions); mResult = sh::Compile(mHandle, &srcStrings[0], srcStrings.size(), mOptions);
if (mResult) if (mResult)
{ {
mCompileImplFunctor(sh::GetObjectCode(mHandle)); mCompileImplFunctor(sh::GetObjectCode(mHandle), mInfoLog);
} }
} }
bool getResult() { return mResult; } bool getResult() { return mResult; }
const std::string &getInfoLog() { return mInfoLog; }
private: private:
ShHandle mHandle; ShHandle mHandle;
...@@ -147,6 +148,7 @@ class CompileTask : public angle::Closure ...@@ -147,6 +148,7 @@ class CompileTask : public angle::Closure
ShCompileOptions mOptions; ShCompileOptions mOptions;
CompileImplFunctor mCompileImplFunctor; CompileImplFunctor mCompileImplFunctor;
bool mResult; bool mResult;
std::string mInfoLog;
}; };
ShaderState::ShaderState(ShaderType shaderType) ShaderState::ShaderState(ShaderType shaderType)
...@@ -394,16 +396,16 @@ void Shader::compile(const Context *context) ...@@ -394,16 +396,16 @@ void Shader::compile(const Context *context)
mCompilerResourcesString = mShCompilerInstance.getBuiltinResourcesString(); mCompilerResourcesString = mShCompilerInstance.getBuiltinResourcesString();
mWorkerPool = context->getWorkerThreadPool(); mWorkerPool = context->getWorkerThreadPool();
std::function<void(const std::string &)> compileImplFunctor; std::function<void(const std::string &, std::string &)> compileImplFunctor;
if (mWorkerPool->isAsync()) if (mWorkerPool->isAsync())
{ {
compileImplFunctor = [this](const std::string &source) { compileImplFunctor = [this](const std::string &source, std::string &infoLog) {
mImplementation->compileAsync(source); mImplementation->compileAsync(source, infoLog);
}; };
} }
else else
{ {
compileImplFunctor = [](const std::string &source) {}; compileImplFunctor = [](const std::string &source, std::string &infoLog) {};
} }
mCompileTask = mCompileTask =
std::make_shared<CompileTask>(compilerHandle, std::move(sourcePath), std::move(source), std::make_shared<CompileTask>(compilerHandle, std::move(sourcePath), std::move(source),
...@@ -427,6 +429,7 @@ void Shader::resolveCompile() ...@@ -427,6 +429,7 @@ void Shader::resolveCompile()
mWorkerPool.reset(); mWorkerPool.reset();
bool compiled = mCompileTask->getResult(); bool compiled = mCompileTask->getResult();
mInfoLog += mCompileTask->getInfoLog();
mCompileTask.reset(); mCompileTask.reset();
ScopedExit exit([this]() { mBoundCompiler->putInstance(std::move(mShCompilerInstance)); }); ScopedExit exit([this]() { mBoundCompiler->putInstance(std::move(mShCompilerInstance)); });
...@@ -434,7 +437,7 @@ void Shader::resolveCompile() ...@@ -434,7 +437,7 @@ void Shader::resolveCompile()
ShHandle compilerHandle = mShCompilerInstance.getHandle(); ShHandle compilerHandle = mShCompilerInstance.getHandle();
if (!compiled) if (!compiled)
{ {
mInfoLog = sh::GetInfoLog(compilerHandle); mInfoLog += sh::GetInfoLog(compilerHandle);
WARN() << std::endl << mInfoLog; WARN() << std::endl << mInfoLog;
mState.mCompileStatus = CompileStatus::NOT_COMPILED; mState.mCompileStatus = CompileStatus::NOT_COMPILED;
return; return;
......
...@@ -29,7 +29,7 @@ class ShaderImpl : angle::NonCopyable ...@@ -29,7 +29,7 @@ class ShaderImpl : angle::NonCopyable
std::string *sourcePath) = 0; std::string *sourcePath) = 0;
// Uses the GL driver to compile the shader source in a worker thread. // Uses the GL driver to compile the shader source in a worker thread.
virtual void compileAsync(const std::string &source) {} virtual void compileAsync(const std::string &source, std::string &infoLog) {}
// Returns success for compiling on the driver. Returns success. // Returns success for compiling on the driver. Returns success.
virtual bool postTranslateCompile(gl::ShCompilerInstance *compiler, std::string *infoLog) = 0; virtual bool postTranslateCompile(gl::ShCompilerInstance *compiler, std::string *infoLog) = 0;
......
...@@ -130,22 +130,24 @@ void ProgramGL::setSeparable(bool separable) ...@@ -130,22 +130,24 @@ void ProgramGL::setSeparable(bool separable)
mFunctions->programParameteri(mProgramID, GL_PROGRAM_SEPARABLE, separable ? GL_TRUE : GL_FALSE); mFunctions->programParameteri(mProgramID, GL_PROGRAM_SEPARABLE, separable ? GL_TRUE : GL_FALSE);
} }
using LinkImplFunctor = std::function<bool()>; using LinkImplFunctor = std::function<bool(std::string &)>;
class ProgramGL::LinkTask final : public angle::Closure class ProgramGL::LinkTask final : public angle::Closure
{ {
public: public:
LinkTask(LinkImplFunctor &&functor) : mLinkImplFunctor(functor), mFallbackToMainContext(false) LinkTask(LinkImplFunctor &&functor) : mLinkImplFunctor(functor), mFallbackToMainContext(false)
{} {}
void operator()() override { mFallbackToMainContext = mLinkImplFunctor(); } void operator()() override { mFallbackToMainContext = mLinkImplFunctor(mInfoLog); }
bool fallbackToMainContext() { return mFallbackToMainContext; } bool fallbackToMainContext() { return mFallbackToMainContext; }
const std::string &getInfoLog() { return mInfoLog; }
private: private:
LinkImplFunctor mLinkImplFunctor; LinkImplFunctor mLinkImplFunctor;
bool mFallbackToMainContext; bool mFallbackToMainContext;
std::string mInfoLog;
}; };
using PostLinkImplFunctor = std::function<angle::Result(bool)>; using PostLinkImplFunctor = std::function<angle::Result(bool, const std::string &)>;
class ProgramGL::LinkEventGL final : public LinkEvent class ProgramGL::LinkEventGL final : public LinkEvent
{ {
public: public:
...@@ -162,7 +164,7 @@ class ProgramGL::LinkEventGL final : public LinkEvent ...@@ -162,7 +164,7 @@ class ProgramGL::LinkEventGL final : public LinkEvent
angle::Result wait(const gl::Context *context) override angle::Result wait(const gl::Context *context) override
{ {
mWaitableEvent->wait(); mWaitableEvent->wait();
return mPostLinkImplFunctor(mLinkTask->fallbackToMainContext()); return mPostLinkImplFunctor(mLinkTask->fallbackToMainContext(), mLinkTask->getInfoLog());
} }
bool isLinking() override { return !mWaitableEvent->isReady(); } bool isLinking() override { return !mWaitableEvent->isReady(); }
...@@ -358,13 +360,13 @@ std::unique_ptr<LinkEvent> ProgramGL::link(const gl::Context *context, ...@@ -358,13 +360,13 @@ std::unique_ptr<LinkEvent> ProgramGL::link(const gl::Context *context,
} }
} }
auto workerPool = context->getWorkerThreadPool(); auto workerPool = context->getWorkerThreadPool();
auto linkTask = std::make_shared<LinkTask>([this]() { auto linkTask = std::make_shared<LinkTask>([this](std::string &infoLog) {
std::string infoLog; std::string workerInfoLog;
ScopedWorkerContextGL worker(mRenderer.get(), &infoLog); ScopedWorkerContextGL worker(mRenderer.get(), &workerInfoLog);
if (!worker()) if (!worker())
{ {
#if !defined(NDEBUG) #if !defined(NDEBUG)
WARN() << "bindWorkerContext failed." << std::endl << infoLog; infoLog += "bindWorkerContext failed.\n" + workerInfoLog;
#endif #endif
// Fallback to the main context. // Fallback to the main context.
return true; return true;
...@@ -379,7 +381,9 @@ std::unique_ptr<LinkEvent> ProgramGL::link(const gl::Context *context, ...@@ -379,7 +381,9 @@ std::unique_ptr<LinkEvent> ProgramGL::link(const gl::Context *context,
return false; return false;
}); });
auto postLinkImplTask = [this, &infoLog, &resources](bool fallbackToMainContext) { auto postLinkImplTask = [this, &infoLog, &resources](bool fallbackToMainContext,
const std::string &workerInfoLog) {
infoLog << workerInfoLog;
if (fallbackToMainContext) if (fallbackToMainContext)
{ {
mFunctions->linkProgram(mProgramID); mFunctions->linkProgram(mProgramID);
...@@ -433,7 +437,7 @@ std::unique_ptr<LinkEvent> ProgramGL::link(const gl::Context *context, ...@@ -433,7 +437,7 @@ std::unique_ptr<LinkEvent> ProgramGL::link(const gl::Context *context,
} }
else else
{ {
return std::make_unique<LinkEventDone>(postLinkImplTask(true)); return std::make_unique<LinkEventDone>(postLinkImplTask(true, std::string()));
} }
} }
......
...@@ -177,10 +177,10 @@ void ShaderGL::compileAndCheckShader(const char *source) ...@@ -177,10 +177,10 @@ void ShaderGL::compileAndCheckShader(const char *source)
} }
} }
void ShaderGL::compileAsync(const std::string &source) void ShaderGL::compileAsync(const std::string &source, std::string &infoLog)
{ {
std::string infoLog; std::string workerInfoLog;
ScopedWorkerContextGL worker(mRenderer.get(), &infoLog); ScopedWorkerContextGL worker(mRenderer.get(), &workerInfoLog);
if (worker()) if (worker())
{ {
compileAndCheckShader(source.c_str()); compileAndCheckShader(source.c_str());
...@@ -189,7 +189,7 @@ void ShaderGL::compileAsync(const std::string &source) ...@@ -189,7 +189,7 @@ void ShaderGL::compileAsync(const std::string &source)
else else
{ {
#if !defined(NDEBUG) #if !defined(NDEBUG)
WARN() << "bindWorkerContext failed." << std::endl << infoLog; infoLog += "bindWorkerContext failed.\n" + workerInfoLog;
#endif #endif
} }
} }
......
...@@ -32,7 +32,7 @@ class ShaderGL : public ShaderImpl ...@@ -32,7 +32,7 @@ class ShaderGL : public ShaderImpl
ShCompileOptions prepareSourceAndReturnOptions(const gl::Context *context, ShCompileOptions prepareSourceAndReturnOptions(const gl::Context *context,
std::stringstream *sourceStream, std::stringstream *sourceStream,
std::string *sourcePath) override; std::string *sourcePath) override;
void compileAsync(const std::string &source) override; void compileAsync(const std::string &source, std::string &infoLog) override;
bool postTranslateCompile(gl::ShCompilerInstance *compiler, std::string *infoLog) override; bool postTranslateCompile(gl::ShCompilerInstance *compiler, std::string *infoLog) override;
std::string getDebugInfo() const override; std::string getDebugInfo() const override;
......
...@@ -5120,8 +5120,7 @@ TEST_P(GLSLTest_ES3, InitSameNameArray) ...@@ -5120,8 +5120,7 @@ TEST_P(GLSLTest_ES3, InitSameNameArray)
TEST_P(GLSLTest, FragData) TEST_P(GLSLTest, FragData)
{ {
// Ensures that we don't regress and emit Vulkan layer warnings. // Ensures that we don't regress and emit Vulkan layer warnings.
// TODO(http://crbug.com/931294): Fix worker context warnings. treatPlatformWarningsAsErrors();
// treatPlatformWarningsAsErrors();
constexpr char kFS[] = R"(void main() { gl_FragData[0] = vec4(1, 0, 0, 1); })"; constexpr char kFS[] = R"(void main() { gl_FragData[0] = vec4(1, 0, 0, 1); })";
ANGLE_GL_PROGRAM(program, essl1_shaders::vs::Simple(), kFS); ANGLE_GL_PROGRAM(program, essl1_shaders::vs::Simple(), kFS);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment