Commit 1b2a8f96 by Jamie Madill

Fix binary serialization to use explicit size and type.

Loading program binaries across different architectures would cause runtime errors due to use of size_t. Also fix the ANGLE major and minor version that were clobbered in an earlier commit. BUG=angle:647 BUG=371435 Change-Id: I9473cc7e119592fce336aa47881839543e337b69 Reviewed-on: https://chromium-review.googlesource.com/199633Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 43b00426
......@@ -535,6 +535,12 @@ inline bool IsUnsignedMultiplicationSafe(T lhs, T rhs)
return (lhs == T(0) || rhs == T(0) || (rhs <= std::numeric_limits<T>::max() / lhs));
}
template <class SmallIntT, class BigIntT>
inline bool IsIntegerCastSafe(BigIntT bigValue)
{
return (static_cast<BigIntT>(static_cast<SmallIntT>(bigValue)) == bigValue);
}
}
#endif // LIBGLESV2_MATHUTIL_H_
#include "commit.h"
#define ANGLE_MAJOR_VERSION 1
#define ANGLE_MINOR_VERSION 3
#define ANGLE_MAJOR_VERSION 2
#define ANGLE_MINOR_VERSION 1
#define ANGLE_STRINGIFY(x) #x
#define ANGLE_MACRO_STRINGIFY(x) ANGLE_STRINGIFY(x)
......
......@@ -10,6 +10,7 @@
#define LIBGLESV2_BINARYSTREAM_H_
#include "common/angleutils.h"
#include "common/mathutil.h"
namespace gl
{
......@@ -25,42 +26,49 @@ class BinaryInputStream
mLength = length;
}
template <typename T>
void read(T *v, size_t num)
// readInt will generate an error for bool types
template <class IntT>
IntT readInt()
{
union
{
T dummy; // Compilation error for non-trivial types
} dummy;
(void) dummy;
int value;
read(&value);
return static_cast<IntT>(value);
}
if (mError)
{
return;
}
template <class IntT>
void readInt(IntT *outValue)
{
*outValue = readInt<IntT>();
}
size_t length = num * sizeof(T);
bool readBool()
{
int value;
read(&value);
return (value > 0);
}
if (mOffset + length > mLength)
{
mError = true;
return;
}
void readBool(bool *outValue)
{
*outValue = readBool();
}
memcpy(v, mData + mOffset, length);
mOffset += length;
void readBytes(unsigned char outArray[], size_t count)
{
read<unsigned char>(outArray, count);
}
template <typename T>
void read(T * v)
std::string readString()
{
read(v, 1);
std::string outString;
readString(&outString);
return outString;
}
void read(std::string *v)
void readString(std::string *v)
{
size_t length;
read(&length);
readInt(&length);
if (mError)
{
......@@ -109,6 +117,30 @@ class BinaryInputStream
size_t mOffset;
const char *mData;
size_t mLength;
template <typename T>
void read(T *v, size_t num)
{
META_ASSERT(std::is_fundamental<T>::value);
size_t length = num * sizeof(T);
if (mOffset + length > mLength)
{
mError = true;
return;
}
memcpy(v, mData + mOffset, length);
mOffset += length;
}
template <typename T>
void read(T *v)
{
read(v, 1);
}
};
class BinaryOutputStream
......@@ -118,31 +150,24 @@ class BinaryOutputStream
{
}
template <typename T>
void write(const T *v, size_t num)
// writeInt also handles bool types
template <class IntT>
void writeInt(IntT param)
{
union
{
T dummy; // Compilation error for non-trivial types
} dummy;
(void) dummy;
const char *asBytes = reinterpret_cast<const char*>(v);
mData.insert(mData.end(), asBytes, asBytes + num * sizeof(T));
ASSERT(rx::IsIntegerCastSafe<int>(param));
int intValue = static_cast<int>(param);
write(&intValue, 1);
}
template <typename T>
void write(const T &v)
void writeString(const std::string &v)
{
write(&v, 1);
writeInt(v.length());
write(v.c_str(), v.length());
}
void write(const std::string &v)
void writeBytes(unsigned char *bytes, size_t count)
{
size_t length = v.length();
write(length);
write(v.c_str(), length);
write(bytes, count);
}
size_t length() const
......@@ -158,6 +183,15 @@ class BinaryOutputStream
private:
DISALLOW_COPY_AND_ASSIGN(BinaryOutputStream);
std::vector<char> mData;
template <typename T>
void write(const T *v, size_t num)
{
META_ASSERT(std::is_fundamental<T>::value);
const char *asBytes = reinterpret_cast<const char*>(v);
mData.insert(mData.end(), asBytes, asBytes + num * sizeof(T));
}
};
}
......
......@@ -31,7 +31,7 @@
namespace gl
{
namespace
namespace
{
unsigned int ParseAndStripArrayIndex(std::string* name)
......@@ -78,7 +78,7 @@ void GetInputLayoutFromShader(const std::vector<gl::Attribute> &shaderAttributes
}
VariableLocation::VariableLocation(const std::string &name, unsigned int element, unsigned int index)
VariableLocation::VariableLocation(const std::string &name, unsigned int element, unsigned int index)
: name(name), element(element), index(index)
{
}
......@@ -275,7 +275,7 @@ GLuint ProgramBinary::getAttributeLocation(const char *name)
int ProgramBinary::getSemanticIndex(int attributeIndex)
{
ASSERT(attributeIndex >= 0 && attributeIndex < MAX_VERTEX_ATTRIBS);
return mSemanticIndex[attributeIndex];
}
......@@ -376,7 +376,7 @@ GLint ProgramBinary::getUniformLocation(std::string name)
const int index = mUniformIndex[location].index;
const bool isArray = mUniforms[index]->isArray();
if ((isArray && mUniformIndex[location].element == subscript) ||
if ((isArray && mUniformIndex[location].element == subscript) ||
(subscript == GL_INVALID_INDEX))
{
return location;
......@@ -636,7 +636,7 @@ bool expandMatrix(T *target, const GLfloat *value, int targetWidth, int targetHe
}
template <int cols, int rows>
bool ProgramBinary::setUniformMatrixfv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value, GLenum targetUniformType)
bool ProgramBinary::setUniformMatrixfv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value, GLenum targetUniformType)
{
if (location < 0 || location >= (int)mUniformIndex.size())
{
......@@ -878,7 +878,7 @@ bool ProgramBinary::getUniformv(GLint location, GLsizei *bufSize, T *params, GLe
}
}
break;
case GL_UNSIGNED_INT:
{
GLuint *uintParams = (GLuint*)targetUniform->data + mUniformIndex[location].element * 4;
......@@ -889,7 +889,7 @@ bool ProgramBinary::getUniformv(GLint location, GLsizei *bufSize, T *params, GLe
}
}
break;
default: UNREACHABLE();
}
}
......@@ -1065,18 +1065,15 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length)
{
BinaryInputStream stream(binary, length);
int format = 0;
stream.read(&format);
int format = stream.readInt<int>();
if (format != GL_PROGRAM_BINARY_ANGLE)
{
infoLog.append("Invalid program binary format.");
return false;
}
int majorVersion = 0;
int minorVersion = 0;
stream.read(&majorVersion);
stream.read(&minorVersion);
int majorVersion = stream.readInt<int>();
int minorVersion = stream.readInt<int>();
if (majorVersion != ANGLE_MAJOR_VERSION || minorVersion != ANGLE_MINOR_VERSION)
{
infoLog.append("Invalid program binary version.");
......@@ -1084,15 +1081,14 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length)
}
unsigned char commitString[ANGLE_COMMIT_HASH_SIZE];
stream.read(commitString, ANGLE_COMMIT_HASH_SIZE);
stream.readBytes(commitString, ANGLE_COMMIT_HASH_SIZE);
if (memcmp(commitString, ANGLE_COMMIT_HASH, sizeof(unsigned char) * ANGLE_COMMIT_HASH_SIZE) != 0)
{
infoLog.append("Invalid program binary version.");
return false;
}
int compileFlags = 0;
stream.read(&compileFlags);
int compileFlags = stream.readInt<int>();
if (compileFlags != ANGLE_COMPILE_OPTIMIZATION_LEVEL)
{
infoLog.append("Mismatched compilation flags.");
......@@ -1101,153 +1097,131 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length)
for (int i = 0; i < MAX_VERTEX_ATTRIBS; ++i)
{
stream.read(&mLinkedAttribute[i].type);
std::string name;
stream.read(&name);
mLinkedAttribute[i].name = name;
stream.read(&mShaderAttributes[i].type);
stream.read(&mShaderAttributes[i].name);
stream.read(&mSemanticIndex[i]);
stream.readInt(&mLinkedAttribute[i].type);
stream.readString(&mLinkedAttribute[i].name);
stream.readInt(&mShaderAttributes[i].type);
stream.readString(&mShaderAttributes[i].name);
stream.readInt(&mSemanticIndex[i]);
}
initAttributesByLayout();
for (unsigned int i = 0; i < MAX_TEXTURE_IMAGE_UNITS; ++i)
{
stream.read(&mSamplersPS[i].active);
stream.read(&mSamplersPS[i].logicalTextureUnit);
int textureType;
stream.read(&textureType);
mSamplersPS[i].textureType = (TextureType) textureType;
stream.readBool(&mSamplersPS[i].active);
stream.readInt(&mSamplersPS[i].logicalTextureUnit);
stream.readInt(&mSamplersPS[i].textureType);
}
for (unsigned int i = 0; i < IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS; ++i)
{
stream.read(&mSamplersVS[i].active);
stream.read(&mSamplersVS[i].logicalTextureUnit);
int textureType;
stream.read(&textureType);
mSamplersVS[i].textureType = (TextureType) textureType;
stream.readBool(&mSamplersVS[i].active);
stream.readInt(&mSamplersVS[i].logicalTextureUnit);
stream.readInt(&mSamplersVS[i].textureType);
}
stream.read(&mUsedVertexSamplerRange);
stream.read(&mUsedPixelSamplerRange);
stream.read(&mUsesPointSize);
stream.read(&mShaderVersion);
stream.readInt(&mUsedVertexSamplerRange);
stream.readInt(&mUsedPixelSamplerRange);
stream.readBool(&mUsesPointSize);
stream.readInt(&mShaderVersion);
size_t size;
stream.read(&size);
const unsigned int uniformCount = stream.readInt<unsigned int>();
if (stream.error())
{
infoLog.append("Invalid program binary.");
return false;
}
mUniforms.resize(size);
for (unsigned int i = 0; i < size; ++i)
mUniforms.resize(uniformCount);
for (unsigned int uniformIndex = 0; uniformIndex < uniformCount; uniformIndex++)
{
GLenum type;
GLenum precision;
std::string name;
unsigned int arraySize;
int blockIndex;
GLenum type = stream.readInt<GLenum>();
GLenum precision = stream.readInt<GLenum>();
std::string name = stream.readString();
unsigned int arraySize = stream.readInt<unsigned int>();
int blockIndex = stream.readInt<int>();
stream.read(&type);
stream.read(&precision);
stream.read(&name);
stream.read(&arraySize);
stream.read(&blockIndex);
int offset = stream.readInt<int>();
int arrayStride = stream.readInt<int>();
int matrixStride = stream.readInt<int>();
bool isRowMajorMatrix = stream.readBool();
int offset;
int arrayStride;
int matrixStride;
bool isRowMajorMatrix;
const gl::BlockMemberInfo blockInfo(offset, arrayStride, matrixStride, isRowMajorMatrix);
stream.read(&offset);
stream.read(&arrayStride);
stream.read(&matrixStride);
stream.read(&isRowMajorMatrix);
LinkedUniform *uniform = new LinkedUniform(type, precision, name, arraySize, blockIndex, blockInfo);
const gl::BlockMemberInfo blockInfo(offset, arrayStride, matrixStride, isRowMajorMatrix);
stream.readInt(&uniform->psRegisterIndex);
stream.readInt(&uniform->vsRegisterIndex);
stream.readInt(&uniform->registerCount);
stream.readInt(&uniform->registerElement);
mUniforms[i] = new LinkedUniform(type, precision, name, arraySize, blockIndex, blockInfo);
stream.read(&mUniforms[i]->psRegisterIndex);
stream.read(&mUniforms[i]->vsRegisterIndex);
stream.read(&mUniforms[i]->registerCount);
stream.read(&mUniforms[i]->registerElement);
mUniforms[uniformIndex] = uniform;
}
stream.read(&size);
unsigned int uniformBlockCount = stream.readInt<unsigned int>();
if (stream.error())
{
infoLog.append("Invalid program binary.");
return false;
}
mUniformBlocks.resize(size);
for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < size; ++uniformBlockIndex)
mUniformBlocks.resize(uniformBlockCount);
for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < uniformBlockCount; ++uniformBlockIndex)
{
std::string name;
unsigned int elementIndex;
unsigned int dataSize;
stream.read(&name);
stream.read(&elementIndex);
stream.read(&dataSize);
std::string name = stream.readString();
unsigned int elementIndex = stream.readInt<unsigned int>();
unsigned int dataSize = stream.readInt<unsigned int>();
mUniformBlocks[uniformBlockIndex] = new UniformBlock(name, elementIndex, dataSize);
UniformBlock *uniformBlock = new UniformBlock(name, elementIndex, dataSize);
UniformBlock& uniformBlock = *mUniformBlocks[uniformBlockIndex];
stream.read(&uniformBlock.psRegisterIndex);
stream.read(&uniformBlock.vsRegisterIndex);
stream.readInt(&uniformBlock->psRegisterIndex);
stream.readInt(&uniformBlock->vsRegisterIndex);
size_t numMembers;
stream.read(&numMembers);
uniformBlock.memberUniformIndexes.resize(numMembers);
unsigned int numMembers = stream.readInt<unsigned int>();
uniformBlock->memberUniformIndexes.resize(numMembers);
for (unsigned int blockMemberIndex = 0; blockMemberIndex < numMembers; blockMemberIndex++)
{
stream.read(&uniformBlock.memberUniformIndexes[blockMemberIndex]);
stream.readInt(&uniformBlock->memberUniformIndexes[blockMemberIndex]);
}
mUniformBlocks[uniformBlockIndex] = uniformBlock;
}
stream.read(&size);
const unsigned int uniformIndexCount = stream.readInt<unsigned int>();
if (stream.error())
{
infoLog.append("Invalid program binary.");
return false;
}
mUniformIndex.resize(size);
for (unsigned int i = 0; i < size; ++i)
mUniformIndex.resize(uniformIndexCount);
for (unsigned int uniformIndexIndex = 0; uniformIndexIndex < uniformIndexCount; uniformIndexIndex++)
{
stream.read(&mUniformIndex[i].name);
stream.read(&mUniformIndex[i].element);
stream.read(&mUniformIndex[i].index);
stream.readString(&mUniformIndex[uniformIndexIndex].name);
stream.readInt(&mUniformIndex[uniformIndexIndex].element);
stream.readInt(&mUniformIndex[uniformIndexIndex].index);
}
stream.read(&mTransformFeedbackBufferMode);
stream.read(&size);
mTransformFeedbackLinkedVaryings.resize(size);
for (size_t i = 0; i < mTransformFeedbackLinkedVaryings.size(); i++)
stream.readInt(&mTransformFeedbackBufferMode);
const unsigned int transformFeedbackVaryingCount = stream.readInt<unsigned int>();
mTransformFeedbackLinkedVaryings.resize(transformFeedbackVaryingCount);
for (unsigned int varyingIndex = 0; varyingIndex < transformFeedbackVaryingCount; varyingIndex++)
{
LinkedVarying &varying = mTransformFeedbackLinkedVaryings[i];
LinkedVarying &varying = mTransformFeedbackLinkedVaryings[varyingIndex];
stream.read(&varying.name);
stream.read(&varying.type);
stream.read(&varying.size);
stream.read(&varying.semanticName);
stream.read(&varying.semanticIndex);
stream.read(&varying.semanticIndexCount);
stream.readString(&varying.name);
stream.readInt(&varying.type);
stream.readInt(&varying.size);
stream.readString(&varying.semanticName);
stream.readInt(&varying.semanticIndex);
stream.readInt(&varying.semanticIndexCount);
}
stream.read(&mVertexHLSL);
stream.read(&mVertexWorkarounds);
stream.readString(&mVertexHLSL);
stream.readInt(&mVertexWorkarounds);
unsigned int vertexShaderCount;
stream.read(&vertexShaderCount);
const unsigned int vertexShaderCount = stream.readInt<unsigned int>();
for (unsigned int vertexShaderIndex = 0; vertexShaderIndex < vertexShaderCount; vertexShaderIndex++)
{
......@@ -1256,14 +1230,13 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length)
for (size_t inputIndex = 0; inputIndex < MAX_VERTEX_ATTRIBS; inputIndex++)
{
VertexFormat *vertexInput = &inputLayout[inputIndex];
stream.read(&vertexInput->mType);
stream.read(&vertexInput->mNormalized);
stream.read(&vertexInput->mComponents);
stream.read(&vertexInput->mPureInteger);
stream.readInt(&vertexInput->mType);
stream.readInt(&vertexInput->mNormalized);
stream.readInt(&vertexInput->mComponents);
stream.readBool(&vertexInput->mPureInteger);
}
unsigned int vertexShaderSize;
stream.read(&vertexShaderSize);
unsigned int vertexShaderSize = stream.readInt<unsigned int>();
const char *vertexShaderFunction = (const char*) binary + stream.offset();
......@@ -1287,8 +1260,7 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length)
stream.skip(vertexShaderSize);
}
unsigned int pixelShaderSize;
stream.read(&pixelShaderSize);
unsigned int pixelShaderSize = stream.readInt<unsigned int>();
const char *pixelShaderFunction = (const char*) binary + stream.offset();
mPixelExecutable = mRenderer->loadExecutable(reinterpret_cast<const DWORD*>(pixelShaderFunction),
......@@ -1301,8 +1273,7 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length)
}
stream.skip(pixelShaderSize);
unsigned int geometryShaderSize;
stream.read(&geometryShaderSize);
unsigned int geometryShaderSize = stream.readInt<unsigned int>();
if (geometryShaderSize > 0)
{
......@@ -1340,107 +1311,107 @@ bool ProgramBinary::save(void* binary, GLsizei bufSize, GLsizei *length)
{
BinaryOutputStream stream;
stream.write(GL_PROGRAM_BINARY_ANGLE);
stream.write(ANGLE_MAJOR_VERSION);
stream.write(ANGLE_MINOR_VERSION);
stream.write(ANGLE_COMMIT_HASH, ANGLE_COMMIT_HASH_SIZE);
stream.write(ANGLE_COMPILE_OPTIMIZATION_LEVEL);
stream.writeInt(GL_PROGRAM_BINARY_ANGLE);
stream.writeInt(ANGLE_MAJOR_VERSION);
stream.writeInt(ANGLE_MINOR_VERSION);
stream.writeBytes(reinterpret_cast<unsigned char*>(ANGLE_COMMIT_HASH), ANGLE_COMMIT_HASH_SIZE);
stream.writeInt(ANGLE_COMPILE_OPTIMIZATION_LEVEL);
for (unsigned int i = 0; i < MAX_VERTEX_ATTRIBS; ++i)
{
stream.write(mLinkedAttribute[i].type);
stream.write(mLinkedAttribute[i].name);
stream.write(mShaderAttributes[i].type);
stream.write(mShaderAttributes[i].name);
stream.write(mSemanticIndex[i]);
stream.writeInt(mLinkedAttribute[i].type);
stream.writeString(mLinkedAttribute[i].name);
stream.writeInt(mShaderAttributes[i].type);
stream.writeString(mShaderAttributes[i].name);
stream.writeInt(mSemanticIndex[i]);
}
for (unsigned int i = 0; i < MAX_TEXTURE_IMAGE_UNITS; ++i)
{
stream.write(mSamplersPS[i].active);
stream.write(mSamplersPS[i].logicalTextureUnit);
stream.write((int) mSamplersPS[i].textureType);
stream.writeInt(mSamplersPS[i].active);
stream.writeInt(mSamplersPS[i].logicalTextureUnit);
stream.writeInt(mSamplersPS[i].textureType);
}
for (unsigned int i = 0; i < IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS; ++i)
{
stream.write(mSamplersVS[i].active);
stream.write(mSamplersVS[i].logicalTextureUnit);
stream.write((int) mSamplersVS[i].textureType);
stream.writeInt(mSamplersVS[i].active);
stream.writeInt(mSamplersVS[i].logicalTextureUnit);
stream.writeInt(mSamplersVS[i].textureType);
}
stream.write(mUsedVertexSamplerRange);
stream.write(mUsedPixelSamplerRange);
stream.write(mUsesPointSize);
stream.write(mShaderVersion);
stream.writeInt(mUsedVertexSamplerRange);
stream.writeInt(mUsedPixelSamplerRange);
stream.writeInt(mUsesPointSize);
stream.writeInt(mShaderVersion);
stream.write(mUniforms.size());
stream.writeInt(mUniforms.size());
for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); ++uniformIndex)
{
const LinkedUniform &uniform = *mUniforms[uniformIndex];
stream.write(uniform.type);
stream.write(uniform.precision);
stream.write(uniform.name);
stream.write(uniform.arraySize);
stream.write(uniform.blockIndex);
stream.writeInt(uniform.type);
stream.writeInt(uniform.precision);
stream.writeString(uniform.name);
stream.writeInt(uniform.arraySize);
stream.writeInt(uniform.blockIndex);
stream.write(uniform.blockInfo.offset);
stream.write(uniform.blockInfo.arrayStride);
stream.write(uniform.blockInfo.matrixStride);
stream.write(uniform.blockInfo.isRowMajorMatrix);
stream.writeInt(uniform.blockInfo.offset);
stream.writeInt(uniform.blockInfo.arrayStride);
stream.writeInt(uniform.blockInfo.matrixStride);
stream.writeInt(uniform.blockInfo.isRowMajorMatrix);
stream.write(uniform.psRegisterIndex);
stream.write(uniform.vsRegisterIndex);
stream.write(uniform.registerCount);
stream.write(uniform.registerElement);
stream.writeInt(uniform.psRegisterIndex);
stream.writeInt(uniform.vsRegisterIndex);
stream.writeInt(uniform.registerCount);
stream.writeInt(uniform.registerElement);
}
stream.write(mUniformBlocks.size());
stream.writeInt(mUniformBlocks.size());
for (size_t uniformBlockIndex = 0; uniformBlockIndex < mUniformBlocks.size(); ++uniformBlockIndex)
{
const UniformBlock& uniformBlock = *mUniformBlocks[uniformBlockIndex];
stream.write(uniformBlock.name);
stream.write(uniformBlock.elementIndex);
stream.write(uniformBlock.dataSize);
stream.writeString(uniformBlock.name);
stream.writeInt(uniformBlock.elementIndex);
stream.writeInt(uniformBlock.dataSize);
stream.write(uniformBlock.memberUniformIndexes.size());
stream.writeInt(uniformBlock.memberUniformIndexes.size());
for (unsigned int blockMemberIndex = 0; blockMemberIndex < uniformBlock.memberUniformIndexes.size(); blockMemberIndex++)
{
stream.write(uniformBlock.memberUniformIndexes[blockMemberIndex]);
stream.writeInt(uniformBlock.memberUniformIndexes[blockMemberIndex]);
}
stream.write(uniformBlock.psRegisterIndex);
stream.write(uniformBlock.vsRegisterIndex);
stream.writeInt(uniformBlock.psRegisterIndex);
stream.writeInt(uniformBlock.vsRegisterIndex);
}
stream.write(mUniformIndex.size());
stream.writeInt(mUniformIndex.size());
for (size_t i = 0; i < mUniformIndex.size(); ++i)
{
stream.write(mUniformIndex[i].name);
stream.write(mUniformIndex[i].element);
stream.write(mUniformIndex[i].index);
stream.writeString(mUniformIndex[i].name);
stream.writeInt(mUniformIndex[i].element);
stream.writeInt(mUniformIndex[i].index);
}
stream.write(mTransformFeedbackBufferMode);
stream.write(mTransformFeedbackLinkedVaryings.size());
stream.writeInt(mTransformFeedbackBufferMode);
stream.writeInt(mTransformFeedbackLinkedVaryings.size());
for (size_t i = 0; i < mTransformFeedbackLinkedVaryings.size(); i++)
{
const LinkedVarying &varying = mTransformFeedbackLinkedVaryings[i];
stream.write(varying.name);
stream.write(varying.type);
stream.write(varying.size);
stream.write(varying.semanticName);
stream.write(varying.semanticIndex);
stream.write(varying.semanticIndexCount);
stream.writeString(varying.name);
stream.writeInt(varying.type);
stream.writeInt(varying.size);
stream.writeString(varying.semanticName);
stream.writeInt(varying.semanticIndex);
stream.writeInt(varying.semanticIndexCount);
}
stream.write(mVertexHLSL);
stream.write(mVertexWorkarounds);
stream.writeString(mVertexHLSL);
stream.writeInt(mVertexWorkarounds);
stream.write(mVertexExecutables.size());
stream.writeInt(mVertexExecutables.size());
for (size_t vertexExecutableIndex = 0; vertexExecutableIndex < mVertexExecutables.size(); vertexExecutableIndex++)
{
VertexExecutable *vertexExecutable = mVertexExecutables[vertexExecutableIndex];
......@@ -1448,32 +1419,32 @@ bool ProgramBinary::save(void* binary, GLsizei bufSize, GLsizei *length)
for (size_t inputIndex = 0; inputIndex < gl::MAX_VERTEX_ATTRIBS; inputIndex++)
{
const VertexFormat &vertexInput = vertexExecutable->inputs()[inputIndex];
stream.write(vertexInput.mType);
stream.write(vertexInput.mNormalized);
stream.write(vertexInput.mComponents);
stream.write(vertexInput.mPureInteger);
stream.writeInt(vertexInput.mType);
stream.writeInt(vertexInput.mNormalized);
stream.writeInt(vertexInput.mComponents);
stream.writeInt(vertexInput.mPureInteger);
}
UINT vertexShaderSize = vertexExecutable->shaderExecutable()->getLength();
stream.write(vertexShaderSize);
size_t vertexShaderSize = vertexExecutable->shaderExecutable()->getLength();
stream.writeInt(vertexShaderSize);
unsigned char *vertexBlob = static_cast<unsigned char *>(vertexExecutable->shaderExecutable()->getFunction());
stream.write(vertexBlob, vertexShaderSize);
stream.writeBytes(vertexBlob, vertexShaderSize);
}
UINT pixelShaderSize = mPixelExecutable->getLength();
stream.write(pixelShaderSize);
size_t pixelShaderSize = mPixelExecutable->getLength();
stream.writeInt(pixelShaderSize);
unsigned char *pixelBlob = static_cast<unsigned char *>(mPixelExecutable->getFunction());
stream.write(pixelBlob, pixelShaderSize);
stream.writeBytes(pixelBlob, pixelShaderSize);
UINT geometryShaderSize = (mGeometryExecutable != NULL) ? mGeometryExecutable->getLength() : 0;
stream.write(geometryShaderSize);
size_t geometryShaderSize = (mGeometryExecutable != NULL) ? mGeometryExecutable->getLength() : 0;
stream.writeInt(geometryShaderSize);
if (mGeometryExecutable != NULL && geometryShaderSize > 0)
{
unsigned char *geometryBlob = static_cast<unsigned char *>(mGeometryExecutable->getFunction());
stream.write(geometryBlob, geometryShaderSize);
stream.writeBytes(geometryBlob, geometryShaderSize);
}
GUID identifier = mRenderer->getAdapterIdentifier();
......@@ -1985,7 +1956,7 @@ bool ProgramBinary::defineUniform(GLenum shader, const gl::Uniform &constant, In
if (IsSampler(constant.type))
{
unsigned int samplerIndex = constant.registerIndex;
do
{
if (shader == GL_VERTEX_SHADER)
......@@ -2352,7 +2323,7 @@ bool ProgramBinary::assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *u
return true;
}
bool ProgramBinary::isValidated() const
bool ProgramBinary::isValidated() const
{
return mValidated;
}
......@@ -2620,7 +2591,7 @@ bool ProgramBinary::validateSamplers(InfoLog *infoLog)
if (mSamplersPS[i].active)
{
unsigned int unit = mSamplersPS[i].logicalTextureUnit;
if (unit >= maxCombinedTextureImageUnits)
{
if (infoLog)
......@@ -2655,7 +2626,7 @@ bool ProgramBinary::validateSamplers(InfoLog *infoLog)
if (mSamplersVS[i].active)
{
unsigned int unit = mSamplersVS[i].logicalTextureUnit;
if (unit >= maxCombinedTextureImageUnits)
{
if (infoLog)
......
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