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
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
{
public:
......@@ -135,10 +135,11 @@ class CompileTask : public angle::Closure
mResult = sh::Compile(mHandle, &srcStrings[0], srcStrings.size(), mOptions);
if (mResult)
{
mCompileImplFunctor(sh::GetObjectCode(mHandle));
mCompileImplFunctor(sh::GetObjectCode(mHandle), mInfoLog);
}
}
bool getResult() { return mResult; }
const std::string &getInfoLog() { return mInfoLog; }
private:
ShHandle mHandle;
......@@ -147,6 +148,7 @@ class CompileTask : public angle::Closure
ShCompileOptions mOptions;
CompileImplFunctor mCompileImplFunctor;
bool mResult;
std::string mInfoLog;
};
ShaderState::ShaderState(ShaderType shaderType)
......@@ -394,16 +396,16 @@ void Shader::compile(const Context *context)
mCompilerResourcesString = mShCompilerInstance.getBuiltinResourcesString();
mWorkerPool = context->getWorkerThreadPool();
std::function<void(const std::string &)> compileImplFunctor;
std::function<void(const std::string &, std::string &)> compileImplFunctor;
if (mWorkerPool->isAsync())
{
compileImplFunctor = [this](const std::string &source) {
mImplementation->compileAsync(source);
compileImplFunctor = [this](const std::string &source, std::string &infoLog) {
mImplementation->compileAsync(source, infoLog);
};
}
else
{
compileImplFunctor = [](const std::string &source) {};
compileImplFunctor = [](const std::string &source, std::string &infoLog) {};
}
mCompileTask =
std::make_shared<CompileTask>(compilerHandle, std::move(sourcePath), std::move(source),
......@@ -427,6 +429,7 @@ void Shader::resolveCompile()
mWorkerPool.reset();
bool compiled = mCompileTask->getResult();
mInfoLog += mCompileTask->getInfoLog();
mCompileTask.reset();
ScopedExit exit([this]() { mBoundCompiler->putInstance(std::move(mShCompilerInstance)); });
......@@ -434,7 +437,7 @@ void Shader::resolveCompile()
ShHandle compilerHandle = mShCompilerInstance.getHandle();
if (!compiled)
{
mInfoLog = sh::GetInfoLog(compilerHandle);
mInfoLog += sh::GetInfoLog(compilerHandle);
WARN() << std::endl << mInfoLog;
mState.mCompileStatus = CompileStatus::NOT_COMPILED;
return;
......
......@@ -29,7 +29,7 @@ class ShaderImpl : angle::NonCopyable
std::string *sourcePath) = 0;
// 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.
virtual bool postTranslateCompile(gl::ShCompilerInstance *compiler, std::string *infoLog) = 0;
......
......@@ -130,22 +130,24 @@ void ProgramGL::setSeparable(bool separable)
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
{
public:
LinkTask(LinkImplFunctor &&functor) : mLinkImplFunctor(functor), mFallbackToMainContext(false)
{}
void operator()() override { mFallbackToMainContext = mLinkImplFunctor(); }
void operator()() override { mFallbackToMainContext = mLinkImplFunctor(mInfoLog); }
bool fallbackToMainContext() { return mFallbackToMainContext; }
const std::string &getInfoLog() { return mInfoLog; }
private:
LinkImplFunctor mLinkImplFunctor;
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
{
public:
......@@ -162,7 +164,7 @@ class ProgramGL::LinkEventGL final : public LinkEvent
angle::Result wait(const gl::Context *context) override
{
mWaitableEvent->wait();
return mPostLinkImplFunctor(mLinkTask->fallbackToMainContext());
return mPostLinkImplFunctor(mLinkTask->fallbackToMainContext(), mLinkTask->getInfoLog());
}
bool isLinking() override { return !mWaitableEvent->isReady(); }
......@@ -358,13 +360,13 @@ std::unique_ptr<LinkEvent> ProgramGL::link(const gl::Context *context,
}
}
auto workerPool = context->getWorkerThreadPool();
auto linkTask = std::make_shared<LinkTask>([this]() {
std::string infoLog;
ScopedWorkerContextGL worker(mRenderer.get(), &infoLog);
auto linkTask = std::make_shared<LinkTask>([this](std::string &infoLog) {
std::string workerInfoLog;
ScopedWorkerContextGL worker(mRenderer.get(), &workerInfoLog);
if (!worker())
{
#if !defined(NDEBUG)
WARN() << "bindWorkerContext failed." << std::endl << infoLog;
infoLog += "bindWorkerContext failed.\n" + workerInfoLog;
#endif
// Fallback to the main context.
return true;
......@@ -379,7 +381,9 @@ std::unique_ptr<LinkEvent> ProgramGL::link(const gl::Context *context,
return false;
});
auto postLinkImplTask = [this, &infoLog, &resources](bool fallbackToMainContext) {
auto postLinkImplTask = [this, &infoLog, &resources](bool fallbackToMainContext,
const std::string &workerInfoLog) {
infoLog << workerInfoLog;
if (fallbackToMainContext)
{
mFunctions->linkProgram(mProgramID);
......@@ -433,7 +437,7 @@ std::unique_ptr<LinkEvent> ProgramGL::link(const gl::Context *context,
}
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)
}
}
void ShaderGL::compileAsync(const std::string &source)
void ShaderGL::compileAsync(const std::string &source, std::string &infoLog)
{
std::string infoLog;
ScopedWorkerContextGL worker(mRenderer.get(), &infoLog);
std::string workerInfoLog;
ScopedWorkerContextGL worker(mRenderer.get(), &workerInfoLog);
if (worker())
{
compileAndCheckShader(source.c_str());
......@@ -189,7 +189,7 @@ void ShaderGL::compileAsync(const std::string &source)
else
{
#if !defined(NDEBUG)
WARN() << "bindWorkerContext failed." << std::endl << infoLog;
infoLog += "bindWorkerContext failed.\n" + workerInfoLog;
#endif
}
}
......
......@@ -32,7 +32,7 @@ class ShaderGL : public ShaderImpl
ShCompileOptions prepareSourceAndReturnOptions(const gl::Context *context,
std::stringstream *sourceStream,
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;
std::string getDebugInfo() const override;
......
......@@ -5120,8 +5120,7 @@ TEST_P(GLSLTest_ES3, InitSameNameArray)
TEST_P(GLSLTest, FragData)
{
// 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); })";
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