Commit ffe00c03 by Jamie Madill Committed by Commit Bot

Add program cache transform feedback workaround.

On Qualcomm devices, they don't seem to correctly save transform feedback info. Work around this by disabling caching on these devices. This mirrors a Chromium workaround. BUG=angleproject:2088 Change-Id: I6496d2fb6a03788379a6968bcd5eb3a9cb9d15d4 Reviewed-on: https://chromium-review.googlesource.com/549981 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 761b02c8
......@@ -4400,7 +4400,7 @@ void Context::getProgramiv(GLuint program, GLenum pname, GLint *params)
{
Program *programObject = getProgram(program);
ASSERT(programObject);
QueryProgramiv(programObject, pname, params);
QueryProgramiv(this, programObject, pname, params);
}
void Context::getProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog)
......
......@@ -151,6 +151,15 @@ LinkResult MemoryProgramCache::Deserialize(const Context *context,
}
unsigned int transformFeedbackVaryingCount = stream.readInt<unsigned int>();
// Reject programs that use transform feedback varyings if the hardware cannot support them.
if (transformFeedbackVaryingCount > 0 &&
context->getWorkarounds().disableProgramCachingForTransformFeedback)
{
infoLog << "Current driver does not support transform feedback in binary programs.";
return false;
}
ASSERT(state->mLinkedTransformFeedbackVaryings.empty());
for (unsigned int transformFeedbackVaryingIndex = 0;
transformFeedbackVaryingIndex < transformFeedbackVaryingCount;
......@@ -305,6 +314,14 @@ void MemoryProgramCache::Serialize(const Context *context,
}
}
// Warn the app layer if saving a binary with unsupported transform feedback.
if (!state.getLinkedTransformFeedbackVaryings().empty() &&
context->getWorkarounds().disableProgramCachingForTransformFeedback)
{
WARN() << "Saving program binary with transform feedback, which is not supported on this "
"driver.";
}
stream.writeInt(state.getLinkedTransformFeedbackVaryings().size());
for (const auto &var : state.getLinkedTransformFeedbackVaryings())
{
......
......@@ -849,10 +849,10 @@ Error Program::saveBinary(const Context *context,
return NoError();
}
GLint Program::getBinaryLength() const
GLint Program::getBinaryLength(const Context *context) const
{
GLint length;
Error error = saveBinary(nullptr, nullptr, nullptr, std::numeric_limits<GLint>::max(), &length);
Error error = saveBinary(context, nullptr, nullptr, std::numeric_limits<GLint>::max(), &length);
if (error.isError())
{
return 0;
......
......@@ -356,7 +356,7 @@ class Program final : angle::NonCopyable, public LabeledObject
void *binary,
GLsizei bufSize,
GLsizei *length) const;
GLint getBinaryLength() const;
GLint getBinaryLength(const Context *context) const;
void setBinaryRetrievableHint(bool retrievable);
bool getBinaryRetrievableHint() const;
......
......@@ -19,6 +19,10 @@ struct Workarounds
// driver may be in an inconsistent state if this happens, and some users of ANGLE rely on this
// notification to prevent further execution.
bool loseContextOnOutOfMemory = false;
// Program binaries don't contain transform feedback varyings on Qualcomm GPUs.
// Work around this by disabling the program cache for programs with transform feedback.
bool disableProgramCachingForTransformFeedback = false;
};
} // namespace gl
......
......@@ -563,7 +563,7 @@ void QueryBufferPointerv(const Buffer *buffer, GLenum pname, void **params)
}
}
void QueryProgramiv(const Program *program, GLenum pname, GLint *params)
void QueryProgramiv(const Context *context, const Program *program, GLenum pname, GLint *params)
{
ASSERT(program != nullptr);
......@@ -597,7 +597,7 @@ void QueryProgramiv(const Program *program, GLenum pname, GLint *params)
*params = program->getActiveUniformMaxLength();
return;
case GL_PROGRAM_BINARY_LENGTH_OES:
*params = program->getBinaryLength();
*params = program->getBinaryLength(context);
return;
case GL_ACTIVE_UNIFORM_BLOCKS:
*params = program->getActiveUniformBlockCount();
......
......@@ -39,7 +39,7 @@ void QueryFramebufferAttachmentParameteriv(const Framebuffer *framebuffer,
void QueryBufferParameteriv(const Buffer *buffer, GLenum pname, GLint *params);
void QueryBufferParameteri64v(const Buffer *buffer, GLenum pname, GLint64 *params);
void QueryBufferPointerv(const Buffer *buffer, GLenum pname, void **params);
void QueryProgramiv(const Program *program, GLenum pname, GLint *params);
void QueryProgramiv(const Context *context, const Program *program, GLenum pname, GLint *params);
void QueryRenderbufferiv(const Context *context,
const Renderbuffer *renderbuffer,
GLenum pname,
......
......@@ -1033,7 +1033,14 @@ void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workaround
void ApplyWorkarounds(const FunctionsGL *functions, gl::Workarounds *workarounds)
{
// TODO(jmadill): Workarounds for GL.
#if defined(ANGLE_PLATFORM_ANDROID)
VendorID vendor = GetVendorID(functions);
if (IsQualcomm(vendor))
{
workarounds->disableProgramCachingForTransformFeedback = true;
}
#endif // defined(ANGLE_PLATFORM_ANDROID)
}
} // namespace nativegl_gl
......
......@@ -2155,7 +2155,7 @@ ANGLE_EXPORT void GL_APIENTRY GetProgramivRobustANGLE(GLuint program,
}
Program *programObject = context->getProgram(program);
QueryProgramiv(programObject, pname, params);
QueryProgramiv(context, programObject, pname, params);
SetRobustLengthParam(length, numParams);
}
}
......
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