Commit b26ab825 by Geoff Lang Committed by Commit Bot

Return a program binary size of 0 when the program is not linked.

From the GLES3 spec: "... When a program object's LINK_STATUS is FALSE, its program binary length is zero ..." Querying the size was generating errors in the GL backend. BUG=angleproject:2569 Change-Id: I1be511040331abaec2bba98502d8aa88fb4bd19c Reviewed-on: https://chromium-review.googlesource.com/1076317 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent c2014bce
...@@ -1401,6 +1401,11 @@ Error Program::saveBinary(const Context *context, ...@@ -1401,6 +1401,11 @@ Error Program::saveBinary(const Context *context,
GLint Program::getBinaryLength(const Context *context) const GLint Program::getBinaryLength(const Context *context) const
{ {
if (!mLinked)
{
return 0;
}
GLint length; GLint length;
Error error = saveBinary(context, nullptr, nullptr, std::numeric_limits<GLint>::max(), &length); Error error = saveBinary(context, nullptr, nullptr, std::numeric_limits<GLint>::max(), &length);
if (error.isError()) if (error.isError())
......
...@@ -235,6 +235,17 @@ TEST_P(ProgramBinaryTest, CallProgramBinaryBeforeLink) ...@@ -235,6 +235,17 @@ TEST_P(ProgramBinaryTest, CallProgramBinaryBeforeLink)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
} }
// Test that unlinked programs have a binary size of 0
TEST_P(ProgramBinaryTest, ZeroSizedUnlinkedBinary)
{
ANGLE_SKIP_TEST_IF(!supported());
ANGLE_GL_EMPTY_PROGRAM(program);
GLsizei length = 0;
glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH, &length);
ASSERT_EQ(0, length);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(ProgramBinaryTest, ANGLE_INSTANTIATE_TEST(ProgramBinaryTest,
ES2_D3D9(), ES2_D3D9(),
......
...@@ -101,6 +101,8 @@ class GLProgram ...@@ -101,6 +101,8 @@ class GLProgram
~GLProgram() { glDeleteProgram(mHandle); } ~GLProgram() { glDeleteProgram(mHandle); }
void makeEmpty() { mHandle = glCreateProgram(); }
void makeCompute(const std::string &computeShader) void makeCompute(const std::string &computeShader)
{ {
mHandle = CompileComputeProgram(computeShader); mHandle = CompileComputeProgram(computeShader);
...@@ -152,6 +154,11 @@ class GLProgram ...@@ -152,6 +154,11 @@ class GLProgram
}; };
} // namespace priv } // namespace priv
#define ANGLE_GL_EMPTY_PROGRAM(name) \
priv::GLProgram name; \
name.makeEmpty(); \
ASSERT_TRUE(name.valid());
#define ANGLE_GL_PROGRAM(name, vertex, fragment) \ #define ANGLE_GL_PROGRAM(name, vertex, fragment) \
priv::GLProgram name; \ priv::GLProgram name; \
name.makeRaster(vertex, fragment); \ name.makeRaster(vertex, fragment); \
......
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