Support for serializing a linked program to binary.
The format has a text section followed by a binary section. The binary section contains an image of the device caps and the two shader executables. The text section has everything else newline deliminated.
Ran WebGL conformance tests with temporary change to glLinkProgram that round trips all linked programs through glGetProgramBinary and glProgramBinary. No regressions.
Review URL: https://codereview.appspot.com/6295092
git-svn-id: https://angleproject.googlecode.com/svn/trunk@1199 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/libGLESv2.cpp b/src/libGLESv2/libGLESv2.cpp
index fba253d..ca4ddff 100644
--- a/src/libGLESv2/libGLESv2.cpp
+++ b/src/libGLESv2/libGLESv2.cpp
@@ -3422,7 +3422,7 @@
*params = programObject->getActiveUniformMaxLength();
return;
case GL_PROGRAM_BINARY_LENGTH_OES:
- *params = 0;
+ *params = programObject->getProgramBinaryLength();
return;
default:
return error(GL_INVALID_ENUM);
@@ -6818,7 +6818,7 @@
void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
GLenum *binaryFormat, void *binary)
{
- EVENT("(GLenum program = 0x%X, bufSize = %s, length = 0x%0.8p, binaryFormat = 0x%0.8p, binary = 0x%0.8p)",
+ EVENT("(GLenum program = 0x%X, bufSize = %d, length = 0x%0.8p, binaryFormat = 0x%0.8p, binary = 0x%0.8p)",
program, bufSize, length, binaryFormat, binary);
try
@@ -6841,12 +6841,12 @@
return error(GL_INVALID_OPERATION);
}
- *binaryFormat = GL_PROGRAM_BINARY_ANGLE;
-
- if (length)
+ if (!programBinary->save(binary, bufSize, length))
{
- *length = 0;
+ return error(GL_INVALID_OPERATION);
}
+
+ *binaryFormat = GL_PROGRAM_BINARY_ANGLE;
}
}
catch(std::bad_alloc&)
@@ -6879,7 +6879,7 @@
return error(GL_INVALID_OPERATION);
}
- programObject->setProgramBinary(NULL);
+ programObject->setProgramBinary(binary, length);
}
}
catch(std::bad_alloc&)