Commit 01306fc7 by Geoff Lang

Revert "Implement program binary in ProgramGL."

Causing issues on AMD and Intel bots. This reverts commit 6d892669. Change-Id: Ifb395f78a6a44b874ac13da1f252f604a1a7b0bc Reviewed-on: https://chromium-review.googlesource.com/303439Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 5a85bee2
......@@ -908,11 +908,6 @@ void FunctionsGL::initialize()
AssignGLExtensionEntryPoint(extensions, "GL_ARB_sampler_objects", loadProcAddress("glGetSamplerParameterIiv"), &getSamplerParameterIiv);
AssignGLExtensionEntryPoint(extensions, "GL_ARB_sampler_objects", loadProcAddress("glGetSamplerParameterIuiv"), &getSamplerParameterIuiv);
// GL_ARB_get_program_binary
AssignGLExtensionEntryPoint(extensions, "GL_ARB_get_program_binary", loadProcAddress("glGetProgramBinary"), &getProgramBinary);
AssignGLExtensionEntryPoint(extensions, "GL_ARB_get_program_binary", loadProcAddress("glProgramBinary"), &programBinary);
AssignGLExtensionEntryPoint(extensions, "GL_ARB_get_program_binary", loadProcAddress("glProgramParameteri"), &programParameteri);
// 1.0
if (isAtLeastGL(gl::Version(1, 0)))
{
......
......@@ -36,51 +36,26 @@ ProgramGL::~ProgramGL()
LinkResult ProgramGL::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream)
{
preLink();
// Read the binary format, size and blob
GLenum binaryFormat = stream->readInt<GLenum>();
GLint binaryLength = stream->readInt<GLint>();
const uint8_t *binary = stream->data() + stream->offset();
stream->skip(binaryLength);
// Load the binary
mFunctions->programBinary(mProgramID, binaryFormat, binary, binaryLength);
// Verify that the program linked
if (!checkLinkStatus(infoLog))
{
return LinkResult(false, gl::Error(GL_NO_ERROR));
}
postLink();
return LinkResult(true, gl::Error(GL_NO_ERROR));
UNIMPLEMENTED();
return LinkResult(false, gl::Error(GL_INVALID_OPERATION));
}
gl::Error ProgramGL::save(gl::BinaryOutputStream *stream)
{
GLint binaryLength = 0;
mFunctions->getProgramiv(mProgramID, GL_PROGRAM_BINARY_LENGTH, &binaryLength);
std::vector<uint8_t> binary(binaryLength);
GLenum binaryFormat = GL_NONE;
mFunctions->getProgramBinary(mProgramID, binaryLength, &binaryLength, &binaryFormat,
&binary[0]);
stream->writeInt(binaryFormat);
stream->writeInt(binaryLength);
stream->writeBytes(&binary[0], binaryLength);
return gl::Error(GL_NO_ERROR);
UNIMPLEMENTED();
return gl::Error(GL_INVALID_OPERATION);
}
LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog)
{
preLink();
// Reset the program state, delete the current program if one exists
reset();
const ShaderGL *vertexShaderGL = GetImplAs<ShaderGL>(mData.getAttachedVertexShader());
const ShaderGL *fragmentShaderGL = GetImplAs<ShaderGL>(mData.getAttachedFragmentShader());
const gl::Shader *vertexShader = mData.getAttachedVertexShader();
const gl::Shader *fragmentShader = mData.getAttachedFragmentShader();
const ShaderGL *vertexShaderGL = GetImplAs<ShaderGL>(vertexShader);
const ShaderGL *fragmentShaderGL = GetImplAs<ShaderGL>(fragmentShader);
// Attach the shaders
mFunctions->attachShader(mProgramID, vertexShaderGL->getShaderID());
......@@ -105,12 +80,65 @@ LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog)
mFunctions->detachShader(mProgramID, fragmentShaderGL->getShaderID());
// Verify the link
if (!checkLinkStatus(infoLog))
GLint linkStatus = GL_FALSE;
mFunctions->getProgramiv(mProgramID, GL_LINK_STATUS, &linkStatus);
ASSERT(linkStatus == GL_TRUE);
if (linkStatus == GL_FALSE)
{
// Linking failed, put the error into the info log
GLint infoLogLength = 0;
mFunctions->getProgramiv(mProgramID, GL_INFO_LOG_LENGTH, &infoLogLength);
std::vector<char> buf(infoLogLength);
mFunctions->getProgramInfoLog(mProgramID, infoLogLength, nullptr, &buf[0]);
mFunctions->deleteProgram(mProgramID);
mProgramID = 0;
infoLog << &buf[0];
TRACE("\n%s", &buf[0]);
// TODO, return GL_OUT_OF_MEMORY or just fail the link? This is an unexpected case
return LinkResult(false, gl::Error(GL_NO_ERROR));
}
postLink();
// Query the uniform information
ASSERT(mUniformRealLocationMap.empty());
const auto &uniforms = mData.getUniforms();
for (const gl::VariableLocation &entry : mData.getUniformLocations())
{
// From the spec:
// "Locations for sequential array indices are not required to be sequential."
const gl::LinkedUniform &uniform = uniforms[entry.index];
std::stringstream fullNameStr;
fullNameStr << uniform.name;
if (uniform.isArray())
{
fullNameStr << "[" << entry.element << "]";
}
const std::string &fullName = fullNameStr.str();
GLint realLocation = mFunctions->getUniformLocation(mProgramID, fullName.c_str());
mUniformRealLocationMap.push_back(realLocation);
}
mUniformIndexToSamplerIndex.resize(mData.getUniforms().size(), GL_INVALID_INDEX);
for (size_t uniformId = 0; uniformId < uniforms.size(); ++uniformId)
{
const gl::LinkedUniform &linkedUniform = uniforms[uniformId];
if (!linkedUniform.isSampler() || !linkedUniform.staticUse)
continue;
mUniformIndexToSamplerIndex[uniformId] = mSamplerBindings.size();
// If uniform is a sampler type, insert it into the mSamplerBindings array
SamplerBindingGL samplerBinding;
samplerBinding.textureType = gl::SamplerTypeToTextureType(linkedUniform.type);
samplerBinding.boundTextureUnits.resize(linkedUniform.elementCount(), 0);
mSamplerBindings.push_back(samplerBinding);
}
return LinkResult(true, gl::Error(GL_NO_ERROR));
}
......@@ -265,6 +293,13 @@ void ProgramGL::setUniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformB
uniformBlockBinding);
}
void ProgramGL::reset()
{
mUniformRealLocationMap.clear();
mSamplerBindings.clear();
mUniformIndexToSamplerIndex.clear();
}
GLuint ProgramGL::getProgramID() const
{
return mProgramID;
......@@ -376,78 +411,4 @@ void ProgramGL::gatherUniformBlockInfo(std::vector<gl::UniformBlock> *uniformBlo
}
}
}
void ProgramGL::preLink()
{
// Reset the program state
mUniformRealLocationMap.clear();
mSamplerBindings.clear();
mUniformIndexToSamplerIndex.clear();
}
bool ProgramGL::checkLinkStatus(gl::InfoLog &infoLog)
{
GLint linkStatus = GL_FALSE;
mFunctions->getProgramiv(mProgramID, GL_LINK_STATUS, &linkStatus);
if (linkStatus == GL_FALSE)
{
// Linking failed, put the error into the info log
GLint infoLogLength = 0;
mFunctions->getProgramiv(mProgramID, GL_INFO_LOG_LENGTH, &infoLogLength);
std::vector<char> buf(infoLogLength);
mFunctions->getProgramInfoLog(mProgramID, infoLogLength, nullptr, &buf[0]);
infoLog << &buf[0];
TRACE("\n%s", &buf[0]);
// TODO, return GL_OUT_OF_MEMORY or just fail the link? This is an unexpected case
return false;
}
return true;
}
void ProgramGL::postLink()
{
// Query the uniform information
ASSERT(mUniformRealLocationMap.empty());
const auto &uniforms = mData.getUniforms();
for (const gl::VariableLocation &entry : mData.getUniformLocations())
{
// From the spec:
// "Locations for sequential array indices are not required to be sequential."
const gl::LinkedUniform &uniform = uniforms[entry.index];
std::stringstream fullNameStr;
fullNameStr << uniform.name;
if (uniform.isArray())
{
fullNameStr << "[" << entry.element << "]";
}
const std::string &fullName = fullNameStr.str();
GLint realLocation = mFunctions->getUniformLocation(mProgramID, fullName.c_str());
mUniformRealLocationMap.push_back(realLocation);
}
mUniformIndexToSamplerIndex.resize(mData.getUniforms().size(), GL_INVALID_INDEX);
for (size_t uniformId = 0; uniformId < uniforms.size(); ++uniformId)
{
const gl::LinkedUniform &linkedUniform = uniforms[uniformId];
if (!linkedUniform.isSampler() || !linkedUniform.staticUse)
{
continue;
}
mUniformIndexToSamplerIndex[uniformId] = mSamplerBindings.size();
// If uniform is a sampler type, insert it into the mSamplerBindings array
SamplerBindingGL samplerBinding;
samplerBinding.textureType = gl::SamplerTypeToTextureType(linkedUniform.type);
samplerBinding.boundTextureUnits.resize(linkedUniform.elementCount(), 0);
mSamplerBindings.push_back(samplerBinding);
}
}
}
......@@ -68,9 +68,7 @@ class ProgramGL : public ProgramImpl
const std::vector<SamplerBindingGL> &getAppliedSamplerUniforms() const;
private:
void preLink();
bool checkLinkStatus(gl::InfoLog &infoLog);
void postLink();
void reset();
// Helper function, makes it simpler to type.
GLint uniLoc(GLint glLocation) const { return mUniformRealLocationMap[glLocation]; }
......
......@@ -279,24 +279,6 @@ void GenerateCaps(const FunctionsGL *functions, gl::Caps *caps, gl::TextureCapsM
// Doesn't impact supported version
}
if (functions->isAtLeastGL(gl::Version(4, 1)) ||
functions->hasGLExtension("GL_ARB_get_program_binary") ||
functions->isAtLeastGLES(gl::Version(3, 0)) ||
functions->hasGLExtension("GL_OES_get_program_binary"))
{
// Able to support the GL_PROGRAM_BINARY_ANGLE format as long as another program binary
// format is available.
GLint numBinaryFormats = QuerySingleGLInt(functions, GL_NUM_PROGRAM_BINARY_FORMATS_OES);
if (numBinaryFormats > 0)
{
caps->programBinaryFormats.push_back(GL_PROGRAM_BINARY_ANGLE);
}
}
else
{
// Doesn't impact supported version
}
// glGetShaderPrecisionFormat is not available until desktop GL version 4.1 or GL_ARB_ES2_compatibility exists
if (functions->isAtLeastGL(gl::Version(4, 1)) || functions->hasGLExtension("GL_ARB_ES2_compatibility") ||
functions->isAtLeastGLES(gl::Version(2, 0)))
......@@ -533,7 +515,6 @@ void GenerateCaps(const FunctionsGL *functions, gl::Caps *caps, gl::TextureCapsM
extensions->setTextureExtensionSupport(*textureCapsMap);
extensions->elementIndexUint = functions->standard == STANDARD_GL_DESKTOP ||
functions->isAtLeastGLES(gl::Version(3, 0)) || functions->hasGLESExtension("GL_OES_element_index_uint");
extensions->getProgramBinary = caps->programBinaryFormats.size() > 0;
extensions->readFormatBGRA = functions->isAtLeastGL(gl::Version(1, 2)) || functions->hasGLExtension("GL_EXT_bgra") ||
functions->hasGLESExtension("GL_EXT_read_format_bgra");
extensions->mapBuffer = functions->isAtLeastGL(gl::Version(1, 5)) ||
......
......@@ -164,7 +164,7 @@ TEST_P(ProgramBinaryTest, SaveAndLoadBinary)
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(ProgramBinaryTest, ES2_D3D9(), ES2_D3D11(), ES2_OPENGL());
ANGLE_INSTANTIATE_TEST(ProgramBinaryTest, ES2_D3D9(), ES2_D3D11());
// For the ProgramBinariesAcrossPlatforms tests, we need two sets of params:
// - a set to save the program binary
......
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