Commit 98c5ff6b by Jamie Madill Committed by Commit Bot

BinaryStream: Preserve 64-bit integer data.

Previously the code would truncate 64-bit data to fit in 32-bits. This ran into a serialization bug when expanding a 64-bit mask. The new blend state masks for extended range were out of range for the 32-bit promotion that was happening before. Also refactors how we capture bools and enums to be more consistent. size_t is now correctly saved and loaded as 64-bits. Bug: angleproject:5247 Change-Id: I452a98c1b0add4c0cf45493032e9310e7d8321b2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2497561Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 5cbf54da
...@@ -19,6 +19,14 @@ ...@@ -19,6 +19,14 @@
namespace gl namespace gl
{ {
template <typename IntT>
struct PromotedIntegerType
{
using type = typename std::conditional<
std::is_signed<IntT>::value,
typename std::conditional<sizeof(IntT) <= 4, int32_t, int64_t>::type,
typename std::conditional<sizeof(IntT) <= 4, uint32_t, uint64_t>::type>::type;
};
class BinaryInputStream : angle::NonCopyable class BinaryInputStream : angle::NonCopyable
{ {
...@@ -35,8 +43,11 @@ class BinaryInputStream : angle::NonCopyable ...@@ -35,8 +43,11 @@ class BinaryInputStream : angle::NonCopyable
template <class IntT> template <class IntT>
IntT readInt() IntT readInt()
{ {
int value = 0; static_assert(!std::is_same<bool, std::remove_cv<IntT>()>(), "Use readBool");
using PromotedIntT = typename PromotedIntegerType<IntT>::type;
PromotedIntT value = 0;
read(&value); read(&value);
ASSERT(angle::IsValueInRangeForNumericType<IntT>(value));
return static_cast<IntT>(value); return static_cast<IntT>(value);
} }
...@@ -49,8 +60,8 @@ class BinaryInputStream : angle::NonCopyable ...@@ -49,8 +60,8 @@ class BinaryInputStream : angle::NonCopyable
template <class IntT, class VectorElementT> template <class IntT, class VectorElementT>
void readIntVector(std::vector<VectorElementT> *param) void readIntVector(std::vector<VectorElementT> *param)
{ {
unsigned int size = readInt<unsigned int>(); size_t size = readInt<size_t>();
for (unsigned int index = 0; index < size; ++index) for (size_t index = 0; index < size; ++index)
{ {
param->push_back(readInt<IntT>()); param->push_back(readInt<IntT>());
} }
...@@ -186,8 +197,8 @@ class BinaryOutputStream : angle::NonCopyable ...@@ -186,8 +197,8 @@ class BinaryOutputStream : angle::NonCopyable
template <class IntT> template <class IntT>
void writeInt(IntT param) void writeInt(IntT param)
{ {
using PromotedIntT = static_assert(!std::is_same<bool, std::remove_cv<IntT>()>(), "Use writeBool");
typename std::conditional<std::is_signed<IntT>::value, int, unsigned>::type; using PromotedIntT = typename PromotedIntegerType<IntT>::type;
ASSERT(angle::IsValueInRangeForNumericType<PromotedIntT>(param)); ASSERT(angle::IsValueInRangeForNumericType<PromotedIntT>(param));
PromotedIntT intValue = static_cast<PromotedIntT>(param); PromotedIntT intValue = static_cast<PromotedIntT>(param);
write(&intValue, 1); write(&intValue, 1);
...@@ -232,6 +243,12 @@ class BinaryOutputStream : angle::NonCopyable ...@@ -232,6 +243,12 @@ class BinaryOutputStream : angle::NonCopyable
void writeBytes(const unsigned char *bytes, size_t count) { write(bytes, count); } void writeBytes(const unsigned char *bytes, size_t count) { write(bytes, count); }
void writeBool(bool value)
{
int intValue = value ? 1 : 0;
write(&intValue, 1);
}
size_t length() const { return mData.size(); } size_t length() const { return mData.size(); }
const void *data() const { return mData.size() ? &mData[0] : nullptr; } const void *data() const { return mData.size() ? &mData[0] : nullptr; }
...@@ -239,8 +256,6 @@ class BinaryOutputStream : angle::NonCopyable ...@@ -239,8 +256,6 @@ class BinaryOutputStream : angle::NonCopyable
const std::vector<uint8_t> &getData() const { return mData; } const std::vector<uint8_t> &getData() const { return mData; }
private: private:
std::vector<uint8_t> mData;
template <typename T> template <typename T>
void write(const T *v, size_t num) void write(const T *v, size_t num)
{ {
...@@ -248,6 +263,8 @@ class BinaryOutputStream : angle::NonCopyable ...@@ -248,6 +263,8 @@ class BinaryOutputStream : angle::NonCopyable
const char *asBytes = reinterpret_cast<const char *>(v); const char *asBytes = reinterpret_cast<const char *>(v);
mData.insert(mData.end(), asBytes, asBytes + num * sizeof(T)); mData.insert(mData.end(), asBytes, asBytes + num * sizeof(T));
} }
std::vector<uint8_t> mData;
}; };
inline BinaryOutputStream::BinaryOutputStream() {} inline BinaryOutputStream::BinaryOutputStream() {}
......
...@@ -658,7 +658,7 @@ void WriteShaderVariableBuffer(BinaryOutputStream *stream, const ShaderVariableB ...@@ -658,7 +658,7 @@ void WriteShaderVariableBuffer(BinaryOutputStream *stream, const ShaderVariableB
for (ShaderType shaderType : AllShaderTypes()) for (ShaderType shaderType : AllShaderTypes())
{ {
stream->writeInt(var.isActive(shaderType)); stream->writeBool(var.isActive(shaderType));
} }
stream->writeInt(var.memberIndexes.size()); stream->writeInt(var.memberIndexes.size());
...@@ -678,8 +678,8 @@ void LoadShaderVariableBuffer(BinaryInputStream *stream, ShaderVariableBuffer *v ...@@ -678,8 +678,8 @@ void LoadShaderVariableBuffer(BinaryInputStream *stream, ShaderVariableBuffer *v
var->setActive(shaderType, stream->readBool()); var->setActive(shaderType, stream->readBool());
} }
unsigned int numMembers = stream->readInt<unsigned int>(); size_t numMembers = stream->readInt<size_t>();
for (unsigned int blockMemberIndex = 0; blockMemberIndex < numMembers; blockMemberIndex++) for (size_t blockMemberIndex = 0; blockMemberIndex < numMembers; blockMemberIndex++)
{ {
var->memberIndexes.push_back(stream->readInt<unsigned int>()); var->memberIndexes.push_back(stream->readInt<unsigned int>());
} }
...@@ -695,7 +695,7 @@ void WriteBufferVariable(BinaryOutputStream *stream, const BufferVariable &var) ...@@ -695,7 +695,7 @@ void WriteBufferVariable(BinaryOutputStream *stream, const BufferVariable &var)
for (ShaderType shaderType : AllShaderTypes()) for (ShaderType shaderType : AllShaderTypes())
{ {
stream->writeInt(var.isActive(shaderType)); stream->writeBool(var.isActive(shaderType));
} }
} }
...@@ -717,7 +717,7 @@ void WriteInterfaceBlock(BinaryOutputStream *stream, const InterfaceBlock &block ...@@ -717,7 +717,7 @@ void WriteInterfaceBlock(BinaryOutputStream *stream, const InterfaceBlock &block
{ {
stream->writeString(block.name); stream->writeString(block.name);
stream->writeString(block.mappedName); stream->writeString(block.mappedName);
stream->writeInt(block.isArray); stream->writeBool(block.isArray);
stream->writeInt(block.arrayElement); stream->writeInt(block.arrayElement);
WriteShaderVariableBuffer(stream, block); WriteShaderVariableBuffer(stream, block);
...@@ -857,7 +857,7 @@ bool IsActiveInterfaceBlock(const sh::InterfaceBlock &interfaceBlock) ...@@ -857,7 +857,7 @@ bool IsActiveInterfaceBlock(const sh::InterfaceBlock &interfaceBlock)
void WriteBlockMemberInfo(BinaryOutputStream *stream, const sh::BlockMemberInfo &var) void WriteBlockMemberInfo(BinaryOutputStream *stream, const sh::BlockMemberInfo &var)
{ {
stream->writeInt(var.arrayStride); stream->writeInt(var.arrayStride);
stream->writeInt(var.isRowMajorMatrix); stream->writeBool(var.isRowMajorMatrix);
stream->writeInt(var.matrixStride); stream->writeInt(var.matrixStride);
stream->writeInt(var.offset); stream->writeInt(var.offset);
stream->writeInt(var.topLevelArrayStride); stream->writeInt(var.topLevelArrayStride);
...@@ -879,17 +879,17 @@ void WriteShaderVar(BinaryOutputStream *stream, const sh::ShaderVariable &var) ...@@ -879,17 +879,17 @@ void WriteShaderVar(BinaryOutputStream *stream, const sh::ShaderVariable &var)
stream->writeString(var.name); stream->writeString(var.name);
stream->writeString(var.mappedName); stream->writeString(var.mappedName);
stream->writeIntVector(var.arraySizes); stream->writeIntVector(var.arraySizes);
stream->writeInt(var.staticUse); stream->writeBool(var.staticUse);
stream->writeInt(var.active); stream->writeBool(var.active);
stream->writeInt(var.binding); stream->writeInt(var.binding);
stream->writeString(var.structName); stream->writeString(var.structName);
stream->writeInt(var.hasParentArrayIndex() ? var.parentArrayIndex() : -1); stream->writeInt(var.hasParentArrayIndex() ? var.parentArrayIndex() : -1);
stream->writeInt(var.imageUnitFormat); stream->writeInt(var.imageUnitFormat);
stream->writeInt(var.offset); stream->writeInt(var.offset);
stream->writeInt(var.readonly); stream->writeBool(var.readonly);
stream->writeInt(var.writeonly); stream->writeBool(var.writeonly);
stream->writeInt(var.texelFetchStaticUse); stream->writeBool(var.texelFetchStaticUse);
ASSERT(var.fields.empty()); ASSERT(var.fields.empty());
} }
...@@ -5148,7 +5148,7 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi ...@@ -5148,7 +5148,7 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi
stream.writeInt(mState.mGeometryShaderMaxVertices); stream.writeInt(mState.mGeometryShaderMaxVertices);
stream.writeInt(mState.mNumViews); stream.writeInt(mState.mNumViews);
stream.writeInt(mState.mEarlyFramentTestsOptimization); stream.writeBool(mState.mEarlyFramentTestsOptimization);
stream.writeInt(mState.getProgramInputs().size()); stream.writeInt(mState.getProgramInputs().size());
for (const sh::ShaderVariable &attrib : mState.getProgramInputs()) for (const sh::ShaderVariable &attrib : mState.getProgramInputs())
...@@ -5172,7 +5172,7 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi ...@@ -5172,7 +5172,7 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi
// Active shader info // Active shader info
for (ShaderType shaderType : gl::AllShaderTypes()) for (ShaderType shaderType : gl::AllShaderTypes())
{ {
stream.writeInt(uniform.isActive(shaderType)); stream.writeBool(uniform.isActive(shaderType));
} }
} }
...@@ -5181,7 +5181,7 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi ...@@ -5181,7 +5181,7 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi
{ {
stream.writeInt(variable.arrayIndex); stream.writeInt(variable.arrayIndex);
stream.writeIntOrNegOne(variable.index); stream.writeIntOrNegOne(variable.index);
stream.writeInt(variable.ignored); stream.writeBool(variable.ignored);
} }
stream.writeInt(mState.getUniformBlocks().size()); stream.writeInt(mState.getUniformBlocks().size());
...@@ -5202,8 +5202,9 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi ...@@ -5202,8 +5202,9 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi
WriteInterfaceBlock(&stream, shaderStorageBlock); WriteInterfaceBlock(&stream, shaderStorageBlock);
} }
stream.writeInt(mState.mExecutable->getActiveAtomicCounterBufferCount()); stream.writeInt(mState.mExecutable->mAtomicCounterBuffers.size());
for (const auto &atomicCounterBuffer : mState.mExecutable->getAtomicCounterBuffers()) for (const AtomicCounterBuffer &atomicCounterBuffer :
mState.mExecutable->getAtomicCounterBuffers())
{ {
WriteShaderVariableBuffer(&stream, atomicCounterBuffer); WriteShaderVariableBuffer(&stream, atomicCounterBuffer);
} }
...@@ -5241,7 +5242,7 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi ...@@ -5241,7 +5242,7 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi
{ {
stream.writeInt(outputVar.arrayIndex); stream.writeInt(outputVar.arrayIndex);
stream.writeIntOrNegOne(outputVar.index); stream.writeIntOrNegOne(outputVar.index);
stream.writeInt(outputVar.ignored); stream.writeBool(outputVar.ignored);
} }
stream.writeInt(mState.getSecondaryOutputLocations().size()); stream.writeInt(mState.getSecondaryOutputLocations().size());
...@@ -5249,7 +5250,7 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi ...@@ -5249,7 +5250,7 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi
{ {
stream.writeInt(outputVar.arrayIndex); stream.writeInt(outputVar.arrayIndex);
stream.writeIntOrNegOne(outputVar.index); stream.writeIntOrNegOne(outputVar.index);
stream.writeInt(outputVar.ignored); stream.writeBool(outputVar.ignored);
} }
stream.writeInt(mState.mOutputVariableTypes.size()); stream.writeInt(mState.mOutputVariableTypes.size());
...@@ -5276,7 +5277,7 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi ...@@ -5276,7 +5277,7 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi
stream.writeEnum(samplerBinding.textureType); stream.writeEnum(samplerBinding.textureType);
stream.writeEnum(samplerBinding.format); stream.writeEnum(samplerBinding.format);
stream.writeInt(samplerBinding.boundTextureUnits.size()); stream.writeInt(samplerBinding.boundTextureUnits.size());
stream.writeInt(samplerBinding.unreferenced); stream.writeBool(samplerBinding.unreferenced);
} }
stream.writeInt(mState.getImageUniformRange().low()); stream.writeInt(mState.getImageUniformRange().low());
...@@ -5342,11 +5343,11 @@ angle::Result Program::deserialize(const Context *context, ...@@ -5342,11 +5343,11 @@ angle::Result Program::deserialize(const Context *context,
mState.mGeometryShaderMaxVertices = stream.readInt<int>(); mState.mGeometryShaderMaxVertices = stream.readInt<int>();
mState.mNumViews = stream.readInt<int>(); mState.mNumViews = stream.readInt<int>();
mState.mEarlyFramentTestsOptimization = stream.readInt<bool>(); mState.mEarlyFramentTestsOptimization = stream.readBool();
unsigned int attribCount = stream.readInt<unsigned int>(); size_t attribCount = stream.readInt<size_t>();
ASSERT(mState.mExecutable->getProgramInputs().empty()); ASSERT(mState.mExecutable->getProgramInputs().empty());
for (unsigned int attribIndex = 0; attribIndex < attribCount; ++attribIndex) for (size_t attribIndex = 0; attribIndex < attribCount; ++attribIndex)
{ {
sh::ShaderVariable attrib; sh::ShaderVariable attrib;
LoadShaderVar(&stream, &attrib); LoadShaderVar(&stream, &attrib);
...@@ -5354,9 +5355,9 @@ angle::Result Program::deserialize(const Context *context, ...@@ -5354,9 +5355,9 @@ angle::Result Program::deserialize(const Context *context,
mState.mExecutable->mProgramInputs.push_back(attrib); mState.mExecutable->mProgramInputs.push_back(attrib);
} }
unsigned int uniformCount = stream.readInt<unsigned int>(); size_t uniformCount = stream.readInt<size_t>();
ASSERT(mState.mExecutable->getUniforms().empty()); ASSERT(mState.mExecutable->getUniforms().empty());
for (unsigned int uniformIndex = 0; uniformIndex < uniformCount; ++uniformIndex) for (size_t uniformIndex = 0; uniformIndex < uniformCount; ++uniformIndex)
{ {
LinkedUniform uniform; LinkedUniform uniform;
LoadShaderVar(&stream, &uniform); LoadShaderVar(&stream, &uniform);
...@@ -5377,10 +5378,9 @@ angle::Result Program::deserialize(const Context *context, ...@@ -5377,10 +5378,9 @@ angle::Result Program::deserialize(const Context *context,
mState.mExecutable->mUniforms.push_back(uniform); mState.mExecutable->mUniforms.push_back(uniform);
} }
const unsigned int uniformIndexCount = stream.readInt<unsigned int>(); const size_t uniformIndexCount = stream.readInt<size_t>();
ASSERT(mState.mUniformLocations.empty()); ASSERT(mState.mUniformLocations.empty());
for (unsigned int uniformIndexIndex = 0; uniformIndexIndex < uniformIndexCount; for (size_t uniformIndexIndex = 0; uniformIndexIndex < uniformIndexCount; ++uniformIndexIndex)
uniformIndexIndex++)
{ {
VariableLocation variable; VariableLocation variable;
stream.readInt(&variable.arrayIndex); stream.readInt(&variable.arrayIndex);
...@@ -5390,10 +5390,9 @@ angle::Result Program::deserialize(const Context *context, ...@@ -5390,10 +5390,9 @@ angle::Result Program::deserialize(const Context *context,
mState.mUniformLocations.push_back(variable); mState.mUniformLocations.push_back(variable);
} }
unsigned int uniformBlockCount = stream.readInt<unsigned int>(); size_t uniformBlockCount = stream.readInt<size_t>();
ASSERT(mState.mExecutable->getUniformBlocks().empty()); ASSERT(mState.mExecutable->getUniformBlocks().empty());
for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < uniformBlockCount; for (size_t uniformBlockIndex = 0; uniformBlockIndex < uniformBlockCount; ++uniformBlockIndex)
++uniformBlockIndex)
{ {
InterfaceBlock uniformBlock; InterfaceBlock uniformBlock;
LoadInterfaceBlock(&stream, &uniformBlock); LoadInterfaceBlock(&stream, &uniformBlock);
...@@ -5402,19 +5401,19 @@ angle::Result Program::deserialize(const Context *context, ...@@ -5402,19 +5401,19 @@ angle::Result Program::deserialize(const Context *context,
mState.mActiveUniformBlockBindings.set(uniformBlockIndex, uniformBlock.binding != 0); mState.mActiveUniformBlockBindings.set(uniformBlockIndex, uniformBlock.binding != 0);
} }
unsigned int bufferVariableCount = stream.readInt<unsigned int>(); size_t bufferVariableCount = stream.readInt<size_t>();
ASSERT(mState.mBufferVariables.empty()); ASSERT(mState.mBufferVariables.empty());
for (unsigned int index = 0; index < bufferVariableCount; ++index) for (size_t bufferVarIndex = 0; bufferVarIndex < bufferVariableCount; ++bufferVarIndex)
{ {
BufferVariable bufferVariable; BufferVariable bufferVariable;
LoadBufferVariable(&stream, &bufferVariable); LoadBufferVariable(&stream, &bufferVariable);
mState.mBufferVariables.push_back(bufferVariable); mState.mBufferVariables.push_back(bufferVariable);
} }
unsigned int shaderStorageBlockCount = stream.readInt<unsigned int>(); size_t shaderStorageBlockCount = stream.readInt<size_t>();
ASSERT(mState.mExecutable->getShaderStorageBlocks().empty()); ASSERT(mState.mExecutable->getShaderStorageBlocks().empty());
for (unsigned int shaderStorageBlockIndex = 0; for (size_t shaderStorageBlockIndex = 0; shaderStorageBlockIndex < shaderStorageBlockCount;
shaderStorageBlockIndex < shaderStorageBlockCount; ++shaderStorageBlockIndex) ++shaderStorageBlockIndex)
{ {
InterfaceBlock shaderStorageBlock; InterfaceBlock shaderStorageBlock;
LoadInterfaceBlock(&stream, &shaderStorageBlock); LoadInterfaceBlock(&stream, &shaderStorageBlock);
...@@ -5428,9 +5427,9 @@ angle::Result Program::deserialize(const Context *context, ...@@ -5428,9 +5427,9 @@ angle::Result Program::deserialize(const Context *context,
} }
} }
unsigned int atomicCounterBufferCount = stream.readInt<unsigned int>(); size_t atomicCounterBufferCount = stream.readInt<size_t>();
ASSERT(mState.mExecutable->getAtomicCounterBuffers().empty()); ASSERT(mState.mExecutable->getAtomicCounterBuffers().empty());
for (unsigned int bufferIndex = 0; bufferIndex < atomicCounterBufferCount; ++bufferIndex) for (size_t bufferIndex = 0; bufferIndex < atomicCounterBufferCount; ++bufferIndex)
{ {
AtomicCounterBuffer atomicCounterBuffer; AtomicCounterBuffer atomicCounterBuffer;
LoadShaderVariableBuffer(&stream, &atomicCounterBuffer); LoadShaderVariableBuffer(&stream, &atomicCounterBuffer);
...@@ -5438,7 +5437,7 @@ angle::Result Program::deserialize(const Context *context, ...@@ -5438,7 +5437,7 @@ angle::Result Program::deserialize(const Context *context,
mState.mExecutable->mAtomicCounterBuffers.push_back(atomicCounterBuffer); mState.mExecutable->mAtomicCounterBuffers.push_back(atomicCounterBuffer);
} }
unsigned int transformFeedbackVaryingCount = stream.readInt<unsigned int>(); size_t transformFeedbackVaryingCount = stream.readInt<size_t>();
// Reject programs that use transform feedback varyings if the hardware cannot support them. // Reject programs that use transform feedback varyings if the hardware cannot support them.
if (transformFeedbackVaryingCount > 0 && if (transformFeedbackVaryingCount > 0 &&
...@@ -5449,7 +5448,7 @@ angle::Result Program::deserialize(const Context *context, ...@@ -5449,7 +5448,7 @@ angle::Result Program::deserialize(const Context *context,
} }
ASSERT(mState.mExecutable->mLinkedTransformFeedbackVaryings.empty()); ASSERT(mState.mExecutable->mLinkedTransformFeedbackVaryings.empty());
for (unsigned int transformFeedbackVaryingIndex = 0; for (size_t transformFeedbackVaryingIndex = 0;
transformFeedbackVaryingIndex < transformFeedbackVaryingCount; transformFeedbackVaryingIndex < transformFeedbackVaryingCount;
++transformFeedbackVaryingIndex) ++transformFeedbackVaryingIndex)
{ {
...@@ -5465,9 +5464,9 @@ angle::Result Program::deserialize(const Context *context, ...@@ -5465,9 +5464,9 @@ angle::Result Program::deserialize(const Context *context,
stream.readInt(&mState.mExecutable->mTransformFeedbackBufferMode); stream.readInt(&mState.mExecutable->mTransformFeedbackBufferMode);
unsigned int outputCount = stream.readInt<unsigned int>(); size_t outputCount = stream.readInt<size_t>();
ASSERT(mState.mExecutable->getOutputVariables().empty()); ASSERT(mState.mExecutable->getOutputVariables().empty());
for (unsigned int outputIndex = 0; outputIndex < outputCount; ++outputIndex) for (size_t outputIndex = 0; outputIndex < outputCount; ++outputIndex)
{ {
sh::ShaderVariable output; sh::ShaderVariable output;
LoadShaderVar(&stream, &output); LoadShaderVar(&stream, &output);
...@@ -5476,9 +5475,9 @@ angle::Result Program::deserialize(const Context *context, ...@@ -5476,9 +5475,9 @@ angle::Result Program::deserialize(const Context *context,
mState.mExecutable->mOutputVariables.push_back(output); mState.mExecutable->mOutputVariables.push_back(output);
} }
unsigned int outputVarCount = stream.readInt<unsigned int>(); size_t outputVarCount = stream.readInt<size_t>();
ASSERT(mState.mExecutable->getOutputLocations().empty()); ASSERT(mState.mExecutable->getOutputLocations().empty());
for (unsigned int outputIndex = 0; outputIndex < outputVarCount; ++outputIndex) for (size_t outputIndex = 0; outputIndex < outputVarCount; ++outputIndex)
{ {
VariableLocation locationData; VariableLocation locationData;
stream.readInt(&locationData.arrayIndex); stream.readInt(&locationData.arrayIndex);
...@@ -5487,9 +5486,9 @@ angle::Result Program::deserialize(const Context *context, ...@@ -5487,9 +5486,9 @@ angle::Result Program::deserialize(const Context *context,
mState.mExecutable->mOutputLocations.push_back(locationData); mState.mExecutable->mOutputLocations.push_back(locationData);
} }
unsigned int secondaryOutputVarCount = stream.readInt<unsigned int>(); size_t secondaryOutputVarCount = stream.readInt<size_t>();
ASSERT(mState.mSecondaryOutputLocations.empty()); ASSERT(mState.mSecondaryOutputLocations.empty());
for (unsigned int outputIndex = 0; outputIndex < secondaryOutputVarCount; ++outputIndex) for (size_t outputIndex = 0; outputIndex < secondaryOutputVarCount; ++outputIndex)
{ {
VariableLocation locationData; VariableLocation locationData;
stream.readInt(&locationData.arrayIndex); stream.readInt(&locationData.arrayIndex);
...@@ -5498,8 +5497,8 @@ angle::Result Program::deserialize(const Context *context, ...@@ -5498,8 +5497,8 @@ angle::Result Program::deserialize(const Context *context,
mState.mSecondaryOutputLocations.push_back(locationData); mState.mSecondaryOutputLocations.push_back(locationData);
} }
unsigned int outputTypeCount = stream.readInt<unsigned int>(); size_t outputTypeCount = stream.readInt<size_t>();
for (unsigned int outputIndex = 0; outputIndex < outputTypeCount; ++outputIndex) for (size_t outputIndex = 0; outputIndex < outputTypeCount; ++outputIndex)
{ {
mState.mOutputVariableTypes.push_back(stream.readInt<GLenum>()); mState.mOutputVariableTypes.push_back(stream.readInt<GLenum>());
} }
...@@ -5519,8 +5518,8 @@ angle::Result Program::deserialize(const Context *context, ...@@ -5519,8 +5518,8 @@ angle::Result Program::deserialize(const Context *context,
unsigned int samplerRangeLow = stream.readInt<unsigned int>(); unsigned int samplerRangeLow = stream.readInt<unsigned int>();
unsigned int samplerRangeHigh = stream.readInt<unsigned int>(); unsigned int samplerRangeHigh = stream.readInt<unsigned int>();
mState.mExecutable->mSamplerUniformRange = RangeUI(samplerRangeLow, samplerRangeHigh); mState.mExecutable->mSamplerUniformRange = RangeUI(samplerRangeLow, samplerRangeHigh);
unsigned int samplerCount = stream.readInt<unsigned int>(); size_t samplerCount = stream.readInt<size_t>();
for (unsigned int samplerIndex = 0; samplerIndex < samplerCount; ++samplerIndex) for (size_t samplerIndex = 0; samplerIndex < samplerCount; ++samplerIndex)
{ {
TextureType textureType = stream.readEnum<TextureType>(); TextureType textureType = stream.readEnum<TextureType>();
SamplerFormat format = stream.readEnum<SamplerFormat>(); SamplerFormat format = stream.readEnum<SamplerFormat>();
...@@ -5533,14 +5532,14 @@ angle::Result Program::deserialize(const Context *context, ...@@ -5533,14 +5532,14 @@ angle::Result Program::deserialize(const Context *context,
unsigned int imageRangeLow = stream.readInt<unsigned int>(); unsigned int imageRangeLow = stream.readInt<unsigned int>();
unsigned int imageRangeHigh = stream.readInt<unsigned int>(); unsigned int imageRangeHigh = stream.readInt<unsigned int>();
mState.mExecutable->mImageUniformRange = RangeUI(imageRangeLow, imageRangeHigh); mState.mExecutable->mImageUniformRange = RangeUI(imageRangeLow, imageRangeHigh);
unsigned int imageBindingCount = stream.readInt<unsigned int>(); size_t imageBindingCount = stream.readInt<size_t>();
for (unsigned int imageIndex = 0; imageIndex < imageBindingCount; ++imageIndex) for (size_t imageIndex = 0; imageIndex < imageBindingCount; ++imageIndex)
{ {
unsigned int elementCount = stream.readInt<unsigned int>(); size_t elementCount = stream.readInt<size_t>();
ImageBinding imageBinding(elementCount); ImageBinding imageBinding(elementCount);
for (unsigned int i = 0; i < elementCount; ++i) for (size_t elementIndex = 0; elementIndex < elementCount; ++elementIndex)
{ {
imageBinding.boundImageUnits[i] = stream.readInt<unsigned int>(); imageBinding.boundImageUnits[elementIndex] = stream.readInt<unsigned int>();
} }
if (getExecutable().isCompute()) if (getExecutable().isCompute())
{ {
......
...@@ -139,8 +139,8 @@ void ProgramExecutable::load(gl::BinaryInputStream *stream) ...@@ -139,8 +139,8 @@ void ProgramExecutable::load(gl::BinaryInputStream *stream)
"Too many vertex attribs for mask: All bits of mAttributesTypeMask types and " "Too many vertex attribs for mask: All bits of mAttributesTypeMask types and "
"mask fit into 32 bits each"); "mask fit into 32 bits each");
mAttributesTypeMask = gl::ComponentTypeMask(stream->readInt<uint32_t>()); mAttributesTypeMask = gl::ComponentTypeMask(stream->readInt<uint32_t>());
mAttributesMask = stream->readInt<gl::AttributesMask>(); mAttributesMask = gl::AttributesMask(stream->readInt<uint32_t>());
mActiveAttribLocationsMask = stream->readInt<gl::AttributesMask>(); mActiveAttribLocationsMask = gl::AttributesMask(stream->readInt<uint32_t>());
mMaxActiveAttribLocation = stream->readInt<unsigned int>(); mMaxActiveAttribLocation = stream->readInt<unsigned int>();
mLinkedGraphicsShaderStages = ShaderBitSet(stream->readInt<uint8_t>()); mLinkedGraphicsShaderStages = ShaderBitSet(stream->readInt<uint8_t>());
...@@ -163,25 +163,25 @@ void ProgramExecutable::save(gl::BinaryOutputStream *stream) const ...@@ -163,25 +163,25 @@ void ProgramExecutable::save(gl::BinaryOutputStream *stream) const
{ {
static_assert(MAX_VERTEX_ATTRIBS * 2 <= sizeof(uint32_t) * 8, static_assert(MAX_VERTEX_ATTRIBS * 2 <= sizeof(uint32_t) * 8,
"All bits of mAttributesTypeMask types and mask fit into 32 bits each"); "All bits of mAttributesTypeMask types and mask fit into 32 bits each");
stream->writeInt(static_cast<int>(mAttributesTypeMask.to_ulong())); stream->writeInt(static_cast<uint32_t>(mAttributesTypeMask.to_ulong()));
stream->writeInt(static_cast<int>(mAttributesMask.to_ulong())); stream->writeInt(static_cast<uint32_t>(mAttributesMask.to_ulong()));
stream->writeInt(mActiveAttribLocationsMask.to_ulong()); stream->writeInt(static_cast<uint32_t>(mActiveAttribLocationsMask.to_ulong()));
stream->writeInt(mMaxActiveAttribLocation); stream->writeInt(mMaxActiveAttribLocation);
stream->writeInt(mLinkedGraphicsShaderStages.bits()); stream->writeInt(mLinkedGraphicsShaderStages.bits());
stream->writeInt(mLinkedComputeShaderStages.bits()); stream->writeInt(mLinkedComputeShaderStages.bits());
stream->writeInt(static_cast<bool>(mIsCompute)); stream->writeBool(mIsCompute);
stream->writeInt(static_cast<bool>(mPipelineHasGraphicsUniformBuffers)); stream->writeBool(mPipelineHasGraphicsUniformBuffers);
stream->writeInt(static_cast<bool>(mPipelineHasComputeUniformBuffers)); stream->writeBool(mPipelineHasComputeUniformBuffers);
stream->writeInt(static_cast<bool>(mPipelineHasGraphicsStorageBuffers)); stream->writeBool(mPipelineHasGraphicsStorageBuffers);
stream->writeInt(static_cast<bool>(mPipelineHasComputeStorageBuffers)); stream->writeBool(mPipelineHasComputeStorageBuffers);
stream->writeInt(static_cast<bool>(mPipelineHasGraphicsAtomicCounterBuffers)); stream->writeBool(mPipelineHasGraphicsAtomicCounterBuffers);
stream->writeInt(static_cast<bool>(mPipelineHasComputeAtomicCounterBuffers)); stream->writeBool(mPipelineHasComputeAtomicCounterBuffers);
stream->writeInt(static_cast<bool>(mPipelineHasGraphicsDefaultUniforms)); stream->writeBool(mPipelineHasGraphicsDefaultUniforms);
stream->writeInt(static_cast<bool>(mPipelineHasComputeDefaultUniforms)); stream->writeBool(mPipelineHasComputeDefaultUniforms);
stream->writeInt(static_cast<bool>(mPipelineHasGraphicsTextures)); stream->writeBool(mPipelineHasGraphicsTextures);
stream->writeInt(static_cast<bool>(mPipelineHasComputeTextures)); stream->writeBool(mPipelineHasComputeTextures);
} }
int ProgramExecutable::getInfoLogLength() const int ProgramExecutable::getInfoLogLength() const
......
...@@ -131,7 +131,7 @@ Result SerializeFramebufferAttachment(const gl::Context *context, ...@@ -131,7 +131,7 @@ Result SerializeFramebufferAttachment(const gl::Context *context,
SerializeImageIndex(bos, framebufferAttachment.getTextureImageIndex()); SerializeImageIndex(bos, framebufferAttachment.getTextureImageIndex());
} }
bos->writeInt(framebufferAttachment.getNumViews()); bos->writeInt(framebufferAttachment.getNumViews());
bos->writeInt(framebufferAttachment.isMultiview()); bos->writeBool(framebufferAttachment.isMultiview());
bos->writeInt(framebufferAttachment.getBaseViewIndex()); bos->writeInt(framebufferAttachment.getBaseViewIndex());
bos->writeInt(framebufferAttachment.getRenderToTextureSamples()); bos->writeInt(framebufferAttachment.getRenderToTextureSamples());
...@@ -169,7 +169,7 @@ Result SerializeFramebufferState(const gl::Context *context, ...@@ -169,7 +169,7 @@ Result SerializeFramebufferState(const gl::Context *context,
bos->writeInt(framebufferState.getDefaultWidth()); bos->writeInt(framebufferState.getDefaultWidth());
bos->writeInt(framebufferState.getDefaultHeight()); bos->writeInt(framebufferState.getDefaultHeight());
bos->writeInt(framebufferState.getDefaultSamples()); bos->writeInt(framebufferState.getDefaultSamples());
bos->writeInt(framebufferState.getDefaultFixedSampleLocations()); bos->writeBool(framebufferState.getDefaultFixedSampleLocations());
bos->writeInt(framebufferState.getDefaultLayers()); bos->writeInt(framebufferState.getDefaultLayers());
const std::vector<gl::FramebufferAttachment> &colorAttachments = const std::vector<gl::FramebufferAttachment> &colorAttachments =
...@@ -215,16 +215,16 @@ Result SerializeFramebuffer(const gl::Context *context, ...@@ -215,16 +215,16 @@ Result SerializeFramebuffer(const gl::Context *context,
void SerializeRasterizerState(gl::BinaryOutputStream *bos, void SerializeRasterizerState(gl::BinaryOutputStream *bos,
const gl::RasterizerState &rasterizerState) const gl::RasterizerState &rasterizerState)
{ {
bos->writeInt(rasterizerState.cullFace); bos->writeBool(rasterizerState.cullFace);
bos->writeEnum(rasterizerState.cullMode); bos->writeEnum(rasterizerState.cullMode);
bos->writeInt(rasterizerState.frontFace); bos->writeInt(rasterizerState.frontFace);
bos->writeInt(rasterizerState.polygonOffsetFill); bos->writeBool(rasterizerState.polygonOffsetFill);
bos->writeInt(rasterizerState.polygonOffsetFactor); bos->writeInt(rasterizerState.polygonOffsetFactor);
bos->writeInt(rasterizerState.polygonOffsetUnits); bos->writeInt(rasterizerState.polygonOffsetUnits);
bos->writeInt(rasterizerState.pointDrawMode); bos->writeBool(rasterizerState.pointDrawMode);
bos->writeInt(rasterizerState.multiSample); bos->writeBool(rasterizerState.multiSample);
bos->writeInt(rasterizerState.rasterizerDiscard); bos->writeBool(rasterizerState.rasterizerDiscard);
bos->writeInt(rasterizerState.dither); bos->writeBool(rasterizerState.dither);
} }
void SerializeRectangle(gl::BinaryOutputStream *bos, const gl::Rectangle &rectangle) void SerializeRectangle(gl::BinaryOutputStream *bos, const gl::Rectangle &rectangle)
...@@ -250,10 +250,10 @@ void SerializeBlendStateExt(gl::BinaryOutputStream *bos, const gl::BlendStateExt ...@@ -250,10 +250,10 @@ void SerializeBlendStateExt(gl::BinaryOutputStream *bos, const gl::BlendStateExt
void SerializeDepthStencilState(gl::BinaryOutputStream *bos, void SerializeDepthStencilState(gl::BinaryOutputStream *bos,
const gl::DepthStencilState &depthStencilState) const gl::DepthStencilState &depthStencilState)
{ {
bos->writeInt(depthStencilState.depthTest); bos->writeBool(depthStencilState.depthTest);
bos->writeInt(depthStencilState.depthFunc); bos->writeInt(depthStencilState.depthFunc);
bos->writeInt(depthStencilState.depthMask); bos->writeBool(depthStencilState.depthMask);
bos->writeInt(depthStencilState.stencilTest); bos->writeBool(depthStencilState.stencilTest);
bos->writeInt(depthStencilState.stencilFunc); bos->writeInt(depthStencilState.stencilFunc);
bos->writeInt(depthStencilState.stencilMask); bos->writeInt(depthStencilState.stencilMask);
bos->writeInt(depthStencilState.stencilFail); bos->writeInt(depthStencilState.stencilFail);
...@@ -306,7 +306,7 @@ void SerializePixelPackState(gl::BinaryOutputStream *bos, const gl::PixelPackSta ...@@ -306,7 +306,7 @@ void SerializePixelPackState(gl::BinaryOutputStream *bos, const gl::PixelPackSta
bos->writeInt(pixelPackState.skipPixels); bos->writeInt(pixelPackState.skipPixels);
bos->writeInt(pixelPackState.imageHeight); bos->writeInt(pixelPackState.imageHeight);
bos->writeInt(pixelPackState.skipImages); bos->writeInt(pixelPackState.skipImages);
bos->writeInt(pixelPackState.reverseRowOrder); bos->writeBool(pixelPackState.reverseRowOrder);
} }
void SerializePixelUnpackState(gl::BinaryOutputStream *bos, void SerializePixelUnpackState(gl::BinaryOutputStream *bos,
...@@ -341,15 +341,15 @@ void SerializeGLContextStates(gl::BinaryOutputStream *bos, const gl::State &stat ...@@ -341,15 +341,15 @@ void SerializeGLContextStates(gl::BinaryOutputStream *bos, const gl::State &stat
bos->writeInt(state.getDepthClearValue()); bos->writeInt(state.getDepthClearValue());
bos->writeInt(state.getStencilClearValue()); bos->writeInt(state.getStencilClearValue());
SerializeRasterizerState(bos, state.getRasterizerState()); SerializeRasterizerState(bos, state.getRasterizerState());
bos->writeInt(state.isScissorTestEnabled()); bos->writeBool(state.isScissorTestEnabled());
SerializeRectangle(bos, state.getScissor()); SerializeRectangle(bos, state.getScissor());
SerializeBlendStateExt(bos, state.getBlendStateExt()); SerializeBlendStateExt(bos, state.getBlendStateExt());
SerializeColor(bos, state.getBlendColor()); SerializeColor(bos, state.getBlendColor());
bos->writeInt(state.isSampleAlphaToCoverageEnabled()); bos->writeBool(state.isSampleAlphaToCoverageEnabled());
bos->writeInt(state.isSampleCoverageEnabled()); bos->writeBool(state.isSampleCoverageEnabled());
bos->writeInt(state.getSampleCoverageValue()); bos->writeInt(state.getSampleCoverageValue());
bos->writeInt(state.getSampleCoverageInvert()); bos->writeBool(state.getSampleCoverageInvert());
bos->writeInt(state.isSampleMaskEnabled()); bos->writeBool(state.isSampleMaskEnabled());
bos->writeInt(state.getMaxSampleMaskWords()); bos->writeInt(state.getMaxSampleMaskWords());
const auto &sampleMaskValues = state.getSampleMaskValues(); const auto &sampleMaskValues = state.getSampleMaskValues();
for (size_t i = 0; i < sampleMaskValues.size(); i++) for (size_t i = 0; i < sampleMaskValues.size(); i++)
...@@ -363,8 +363,8 @@ void SerializeGLContextStates(gl::BinaryOutputStream *bos, const gl::State &stat ...@@ -363,8 +363,8 @@ void SerializeGLContextStates(gl::BinaryOutputStream *bos, const gl::State &stat
bos->writeInt(state.getGenerateMipmapHint()); bos->writeInt(state.getGenerateMipmapHint());
bos->writeInt(state.getTextureFilteringHint()); bos->writeInt(state.getTextureFilteringHint());
bos->writeInt(state.getFragmentShaderDerivativeHint()); bos->writeInt(state.getFragmentShaderDerivativeHint());
bos->writeInt(state.isBindGeneratesResourceEnabled()); bos->writeBool(state.isBindGeneratesResourceEnabled());
bos->writeInt(state.areClientArraysEnabled()); bos->writeBool(state.areClientArraysEnabled());
SerializeRectangle(bos, state.getViewport()); SerializeRectangle(bos, state.getViewport());
bos->writeInt(state.getNearPlane()); bos->writeInt(state.getNearPlane());
bos->writeInt(state.getFarPlane()); bos->writeInt(state.getFarPlane());
...@@ -428,19 +428,19 @@ void SerializeGLContextStates(gl::BinaryOutputStream *bos, const gl::State &stat ...@@ -428,19 +428,19 @@ void SerializeGLContextStates(gl::BinaryOutputStream *bos, const gl::State &stat
} }
SerializePixelUnpackState(bos, state.getUnpackState()); SerializePixelUnpackState(bos, state.getUnpackState());
SerializePixelPackState(bos, state.getPackState()); SerializePixelPackState(bos, state.getPackState());
bos->writeInt(state.isPrimitiveRestartEnabled()); bos->writeBool(state.isPrimitiveRestartEnabled());
bos->writeInt(state.isMultisamplingEnabled()); bos->writeBool(state.isMultisamplingEnabled());
bos->writeInt(state.isSampleAlphaToOneEnabled()); bos->writeBool(state.isSampleAlphaToOneEnabled());
bos->writeInt(state.getCoverageModulation()); bos->writeInt(state.getCoverageModulation());
bos->writeInt(state.getFramebufferSRGB()); bos->writeBool(state.getFramebufferSRGB());
bos->writeInt(state.isRobustResourceInitEnabled()); bos->writeBool(state.isRobustResourceInitEnabled());
bos->writeInt(state.isProgramBinaryCacheEnabled()); bos->writeBool(state.isProgramBinaryCacheEnabled());
bos->writeInt(state.isTextureRectangleEnabled()); bos->writeBool(state.isTextureRectangleEnabled());
bos->writeInt(state.getMaxShaderCompilerThreads()); bos->writeInt(state.getMaxShaderCompilerThreads());
bos->writeInt(state.getEnabledClipDistances().to_ulong()); bos->writeInt(state.getEnabledClipDistances().to_ulong());
bos->writeInt(state.getBlendFuncConstantAlphaDrawBuffers().to_ulong()); bos->writeInt(state.getBlendFuncConstantAlphaDrawBuffers().to_ulong());
bos->writeInt(state.getBlendFuncConstantColorDrawBuffers().to_ulong()); bos->writeInt(state.getBlendFuncConstantColorDrawBuffers().to_ulong());
bos->writeInt(state.noSimultaneousConstantColorAndAlphaBlendFunc()); bos->writeBool(state.noSimultaneousConstantColorAndAlphaBlendFunc());
} }
void SerializeBufferState(gl::BinaryOutputStream *bos, const gl::BufferState &bufferState) void SerializeBufferState(gl::BinaryOutputStream *bos, const gl::BufferState &bufferState)
...@@ -580,24 +580,24 @@ void SerializeShaderVariable(gl::BinaryOutputStream *bos, const sh::ShaderVariab ...@@ -580,24 +580,24 @@ void SerializeShaderVariable(gl::BinaryOutputStream *bos, const sh::ShaderVariab
bos->writeString(shaderVariable.name); bos->writeString(shaderVariable.name);
bos->writeString(shaderVariable.mappedName); bos->writeString(shaderVariable.mappedName);
bos->writeIntVector(shaderVariable.arraySizes); bos->writeIntVector(shaderVariable.arraySizes);
bos->writeInt(shaderVariable.staticUse); bos->writeBool(shaderVariable.staticUse);
bos->writeInt(shaderVariable.active); bos->writeBool(shaderVariable.active);
for (const sh::ShaderVariable &field : shaderVariable.fields) for (const sh::ShaderVariable &field : shaderVariable.fields)
{ {
SerializeShaderVariable(bos, field); SerializeShaderVariable(bos, field);
} }
bos->writeString(shaderVariable.structName); bos->writeString(shaderVariable.structName);
bos->writeInt(shaderVariable.isRowMajorLayout); bos->writeBool(shaderVariable.isRowMajorLayout);
bos->writeInt(shaderVariable.location); bos->writeInt(shaderVariable.location);
bos->writeInt(shaderVariable.binding); bos->writeInt(shaderVariable.binding);
bos->writeInt(shaderVariable.imageUnitFormat); bos->writeInt(shaderVariable.imageUnitFormat);
bos->writeInt(shaderVariable.offset); bos->writeInt(shaderVariable.offset);
bos->writeInt(shaderVariable.readonly); bos->writeBool(shaderVariable.readonly);
bos->writeInt(shaderVariable.writeonly); bos->writeBool(shaderVariable.writeonly);
bos->writeInt(shaderVariable.index); bos->writeInt(shaderVariable.index);
bos->writeEnum(shaderVariable.interpolation); bos->writeEnum(shaderVariable.interpolation);
bos->writeInt(shaderVariable.isInvariant); bos->writeBool(shaderVariable.isInvariant);
bos->writeInt(shaderVariable.texelFetchStaticUse); bos->writeBool(shaderVariable.texelFetchStaticUse);
} }
void SerializeShaderVariablesVector(gl::BinaryOutputStream *bos, void SerializeShaderVariablesVector(gl::BinaryOutputStream *bos,
...@@ -620,8 +620,8 @@ void SerializeInterfaceBlocksVector(gl::BinaryOutputStream *bos, ...@@ -620,8 +620,8 @@ void SerializeInterfaceBlocksVector(gl::BinaryOutputStream *bos,
bos->writeInt(interfaceBlock.arraySize); bos->writeInt(interfaceBlock.arraySize);
bos->writeEnum(interfaceBlock.layout); bos->writeEnum(interfaceBlock.layout);
bos->writeInt(interfaceBlock.binding); bos->writeInt(interfaceBlock.binding);
bos->writeInt(interfaceBlock.staticUse); bos->writeBool(interfaceBlock.staticUse);
bos->writeInt(interfaceBlock.active); bos->writeBool(interfaceBlock.active);
bos->writeEnum(interfaceBlock.blockType); bos->writeEnum(interfaceBlock.blockType);
SerializeShaderVariablesVector(bos, interfaceBlock.fields); SerializeShaderVariablesVector(bos, interfaceBlock.fields);
} }
...@@ -643,7 +643,7 @@ void SerializeShaderState(gl::BinaryOutputStream *bos, const gl::ShaderState &sh ...@@ -643,7 +643,7 @@ void SerializeShaderState(gl::BinaryOutputStream *bos, const gl::ShaderState &sh
SerializeShaderVariablesVector(bos, shaderState.getAllAttributes()); SerializeShaderVariablesVector(bos, shaderState.getAllAttributes());
SerializeShaderVariablesVector(bos, shaderState.getActiveAttributes()); SerializeShaderVariablesVector(bos, shaderState.getActiveAttributes());
SerializeShaderVariablesVector(bos, shaderState.getActiveOutputVariables()); SerializeShaderVariablesVector(bos, shaderState.getActiveOutputVariables());
bos->writeInt(shaderState.getEarlyFragmentTestsOptimization()); bos->writeBool(shaderState.getEarlyFragmentTestsOptimization());
bos->writeInt(shaderState.getNumViews()); bos->writeInt(shaderState.getNumViews());
if (shaderState.getGeometryShaderInputPrimitiveType().valid()) if (shaderState.getGeometryShaderInputPrimitiveType().valid())
{ {
...@@ -665,7 +665,7 @@ void SerializeShader(gl::BinaryOutputStream *bos, gl::Shader *shader) ...@@ -665,7 +665,7 @@ void SerializeShader(gl::BinaryOutputStream *bos, gl::Shader *shader)
SerializeShaderState(bos, shader->getState()); SerializeShaderState(bos, shader->getState());
bos->writeInt(shader->getHandle().value); bos->writeInt(shader->getHandle().value);
bos->writeInt(shader->getRefCount()); bos->writeInt(shader->getRefCount());
bos->writeInt(shader->isFlaggedForDeletion()); bos->writeBool(shader->isFlaggedForDeletion());
// does not serialize mType because it is already serialized in SerializeShaderState // does not serialize mType because it is already serialized in SerializeShaderState
bos->writeString(shader->getInfoLogString()); bos->writeString(shader->getInfoLogString());
bos->writeString(shader->getCompilerResourcesString()); bos->writeString(shader->getCompilerResourcesString());
...@@ -680,7 +680,7 @@ void SerializeVariableLocationsVector(gl::BinaryOutputStream *bos, ...@@ -680,7 +680,7 @@ void SerializeVariableLocationsVector(gl::BinaryOutputStream *bos,
{ {
bos->writeInt(variableLocation.arrayIndex); bos->writeInt(variableLocation.arrayIndex);
bos->writeInt(variableLocation.index); bos->writeInt(variableLocation.index);
bos->writeInt(variableLocation.ignored); bos->writeBool(variableLocation.ignored);
} }
} }
...@@ -690,7 +690,7 @@ void SerializeBlockMemberInfo(gl::BinaryOutputStream *bos, ...@@ -690,7 +690,7 @@ void SerializeBlockMemberInfo(gl::BinaryOutputStream *bos,
bos->writeInt(blockMemberInfo.offset); bos->writeInt(blockMemberInfo.offset);
bos->writeInt(blockMemberInfo.arrayStride); bos->writeInt(blockMemberInfo.arrayStride);
bos->writeInt(blockMemberInfo.matrixStride); bos->writeInt(blockMemberInfo.matrixStride);
bos->writeInt(blockMemberInfo.isRowMajorMatrix); bos->writeBool(blockMemberInfo.isRowMajorMatrix);
bos->writeInt(blockMemberInfo.topLevelArrayStride); bos->writeInt(blockMemberInfo.topLevelArrayStride);
} }
...@@ -719,7 +719,7 @@ void SerializeProgramAliasedBindings(gl::BinaryOutputStream *bos, ...@@ -719,7 +719,7 @@ void SerializeProgramAliasedBindings(gl::BinaryOutputStream *bos,
{ {
bos->writeString(programAliasedBinding.first); bos->writeString(programAliasedBinding.first);
bos->writeInt(programAliasedBinding.second.location); bos->writeInt(programAliasedBinding.second.location);
bos->writeInt(programAliasedBinding.second.aliased); bos->writeBool(programAliasedBinding.second.aliased);
} }
} }
...@@ -740,7 +740,7 @@ void SerializeProgramState(gl::BinaryOutputStream *bos, const gl::ProgramState & ...@@ -740,7 +740,7 @@ void SerializeProgramState(gl::BinaryOutputStream *bos, const gl::ProgramState &
} }
for (bool isAttached : programState.getAttachedShadersMarkedForDetach()) for (bool isAttached : programState.getAttachedShadersMarkedForDetach())
{ {
bos->writeInt(isAttached); bos->writeBool(isAttached);
} }
bos->writeInt(programState.getLocationsUsedForXfbExtension()); bos->writeInt(programState.getLocationsUsedForXfbExtension());
for (const std::string &transformFeedbackVaryingName : for (const std::string &transformFeedbackVaryingName :
...@@ -759,9 +759,9 @@ void SerializeProgramState(gl::BinaryOutputStream *bos, const gl::ProgramState & ...@@ -759,9 +759,9 @@ void SerializeProgramState(gl::BinaryOutputStream *bos, const gl::ProgramState &
bos->writeInt(outputVariableType); bos->writeInt(outputVariableType);
} }
bos->writeInt(programState.getDrawBufferTypeMask().to_ulong()); bos->writeInt(programState.getDrawBufferTypeMask().to_ulong());
bos->writeInt(programState.hasBinaryRetrieveableHint()); bos->writeBool(programState.hasBinaryRetrieveableHint());
bos->writeInt(programState.isSeparable()); bos->writeBool(programState.isSeparable());
bos->writeInt(programState.hasEarlyFragmentTestsOptimization()); bos->writeBool(programState.hasEarlyFragmentTestsOptimization());
bos->writeInt(programState.getNumViews()); bos->writeInt(programState.getNumViews());
bos->writeEnum(programState.getGeometryShaderInputPrimitiveType()); bos->writeEnum(programState.getGeometryShaderInputPrimitiveType());
bos->writeEnum(programState.getGeometryShaderOutputPrimitiveType()); bos->writeEnum(programState.getGeometryShaderOutputPrimitiveType());
...@@ -786,12 +786,12 @@ void SerializeProgramBindings(gl::BinaryOutputStream *bos, ...@@ -786,12 +786,12 @@ void SerializeProgramBindings(gl::BinaryOutputStream *bos,
void SerializeProgram(gl::BinaryOutputStream *bos, gl::Program *program) void SerializeProgram(gl::BinaryOutputStream *bos, gl::Program *program)
{ {
SerializeProgramState(bos, program->getState()); SerializeProgramState(bos, program->getState());
bos->writeInt(program->isValidated()); bos->writeBool(program->isValidated());
SerializeProgramBindings(bos, program->getAttributeBindings()); SerializeProgramBindings(bos, program->getAttributeBindings());
SerializeProgramAliasedBindings(bos, program->getFragmentOutputLocations()); SerializeProgramAliasedBindings(bos, program->getFragmentOutputLocations());
SerializeProgramAliasedBindings(bos, program->getFragmentOutputIndexes()); SerializeProgramAliasedBindings(bos, program->getFragmentOutputIndexes());
bos->writeInt(program->isLinked()); bos->writeBool(program->isLinked());
bos->writeInt(program->isFlaggedForDeletion()); bos->writeBool(program->isFlaggedForDeletion());
bos->writeInt(program->getRefCount()); bos->writeInt(program->getRefCount());
bos->writeInt(program->id().value); bos->writeInt(program->id().value);
} }
...@@ -801,7 +801,7 @@ void SerializeImageDesc(gl::BinaryOutputStream *bos, const gl::ImageDesc &imageD ...@@ -801,7 +801,7 @@ void SerializeImageDesc(gl::BinaryOutputStream *bos, const gl::ImageDesc &imageD
SerializeExtents(bos, imageDesc.size); SerializeExtents(bos, imageDesc.size);
SerializeFormat(bos, imageDesc.format); SerializeFormat(bos, imageDesc.format);
bos->writeInt(imageDesc.samples); bos->writeInt(imageDesc.samples);
bos->writeInt(imageDesc.fixedSampleLocations); bos->writeBool(imageDesc.fixedSampleLocations);
bos->writeEnum(imageDesc.initState); bos->writeEnum(imageDesc.initState);
} }
...@@ -814,8 +814,8 @@ void SerializeTextureState(gl::BinaryOutputStream *bos, const gl::TextureState & ...@@ -814,8 +814,8 @@ void SerializeTextureState(gl::BinaryOutputStream *bos, const gl::TextureState &
bos->writeInt(textureState.getBaseLevel()); bos->writeInt(textureState.getBaseLevel());
bos->writeInt(textureState.getMaxLevel()); bos->writeInt(textureState.getMaxLevel());
bos->writeInt(textureState.getDepthStencilTextureMode()); bos->writeInt(textureState.getDepthStencilTextureMode());
bos->writeInt(textureState.hasBeenBoundAsImage()); bos->writeBool(textureState.hasBeenBoundAsImage());
bos->writeInt(textureState.getImmutableFormat()); bos->writeBool(textureState.getImmutableFormat());
bos->writeInt(textureState.getImmutableLevels()); bos->writeInt(textureState.getImmutableLevels());
bos->writeInt(textureState.getUsage()); bos->writeInt(textureState.getUsage());
const std::vector<gl::ImageDesc> &imageDescs = textureState.getImageDescs(); const std::vector<gl::ImageDesc> &imageDescs = textureState.getImageDescs();
...@@ -900,7 +900,7 @@ void SerializeVertexAttributeVector(gl::BinaryOutputStream *bos, ...@@ -900,7 +900,7 @@ void SerializeVertexAttributeVector(gl::BinaryOutputStream *bos,
{ {
for (const gl::VertexAttribute &vertexAttribute : vertexAttributes) for (const gl::VertexAttribute &vertexAttribute : vertexAttributes)
{ {
bos->writeInt(vertexAttribute.enabled); bos->writeBool(vertexAttribute.enabled);
ASSERT(vertexAttribute.format); ASSERT(vertexAttribute.format);
SerializeFormat(bos, vertexAttribute.format); SerializeFormat(bos, vertexAttribute.format);
bos->writeInt(vertexAttribute.relativeOffset); bos->writeInt(vertexAttribute.relativeOffset);
...@@ -946,7 +946,7 @@ void SerializeVertexArray(gl::BinaryOutputStream *bos, gl::VertexArray *vertexAr ...@@ -946,7 +946,7 @@ void SerializeVertexArray(gl::BinaryOutputStream *bos, gl::VertexArray *vertexAr
{ {
bos->writeInt(vertexArray->id().value); bos->writeInt(vertexArray->id().value);
SerializeVertexArrayState(bos, vertexArray->getState()); SerializeVertexArrayState(bos, vertexArray->getState());
bos->writeInt(vertexArray->isBufferAccessValidationEnabled()); bos->writeBool(vertexArray->isBufferAccessValidationEnabled());
} }
} // namespace } // namespace
......
...@@ -982,8 +982,8 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context, ...@@ -982,8 +982,8 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context,
for (gl::ShaderType shaderType : gl::AllShaderTypes()) for (gl::ShaderType shaderType : gl::AllShaderTypes())
{ {
const unsigned int samplerCount = stream->readInt<unsigned int>(); size_t samplerCount = stream->readInt<size_t>();
for (unsigned int i = 0; i < samplerCount; ++i) for (size_t sampleIndex = 0; sampleIndex < samplerCount; ++sampleIndex)
{ {
Sampler sampler; Sampler sampler;
stream->readBool(&sampler.active); stream->readBool(&sampler.active);
...@@ -998,8 +998,8 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context, ...@@ -998,8 +998,8 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context,
mUsedShaderSamplerRanges[shaderType] = gl::RangeUI(samplerRangeLow, samplerRangeHigh); mUsedShaderSamplerRanges[shaderType] = gl::RangeUI(samplerRangeLow, samplerRangeHigh);
} }
const unsigned int csImageCount = stream->readInt<unsigned int>(); size_t csImageCount = stream->readInt<size_t>();
for (unsigned int i = 0; i < csImageCount; ++i) for (size_t imageIndex = 0; imageIndex < csImageCount; ++imageIndex)
{ {
Image image; Image image;
stream->readBool(&image.active); stream->readBool(&image.active);
...@@ -1007,8 +1007,8 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context, ...@@ -1007,8 +1007,8 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context,
mImagesCS.push_back(image); mImagesCS.push_back(image);
} }
const unsigned int csReadonlyImageCount = stream->readInt<unsigned int>(); size_t csReadonlyImageCount = stream->readInt<size_t>();
for (unsigned int i = 0; i < csReadonlyImageCount; ++i) for (size_t imageIndex = 0; imageIndex < csReadonlyImageCount; ++imageIndex)
{ {
Image image; Image image;
stream->readBool(&image.active); stream->readBool(&image.active);
...@@ -1031,7 +1031,7 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context, ...@@ -1031,7 +1031,7 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context,
stream->readInt(&atomicCounterRangeHigh); stream->readInt(&atomicCounterRangeHigh);
mUsedComputeAtomicCounterRange = gl::RangeUI(atomicCounterRangeLow, atomicCounterRangeHigh); mUsedComputeAtomicCounterRange = gl::RangeUI(atomicCounterRangeLow, atomicCounterRangeHigh);
const unsigned int shaderStorageBlockCount = stream->readInt<unsigned int>(); size_t shaderStorageBlockCount = stream->readInt<size_t>();
if (stream->error()) if (stream->error())
{ {
infoLog << "Invalid program binary."; infoLog << "Invalid program binary.";
...@@ -1039,7 +1039,7 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context, ...@@ -1039,7 +1039,7 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context,
} }
ASSERT(mD3DShaderStorageBlocks.empty()); ASSERT(mD3DShaderStorageBlocks.empty());
for (unsigned int blockIndex = 0; blockIndex < shaderStorageBlockCount; ++blockIndex) for (size_t blockIndex = 0; blockIndex < shaderStorageBlockCount; ++blockIndex)
{ {
D3DInterfaceBlock shaderStorageBlock; D3DInterfaceBlock shaderStorageBlock;
for (gl::ShaderType shaderType : gl::AllShaderTypes()) for (gl::ShaderType shaderType : gl::AllShaderTypes())
...@@ -1049,7 +1049,7 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context, ...@@ -1049,7 +1049,7 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context,
mD3DShaderStorageBlocks.push_back(shaderStorageBlock); mD3DShaderStorageBlocks.push_back(shaderStorageBlock);
} }
const unsigned int image2DUniformCount = stream->readInt<unsigned int>(); size_t image2DUniformCount = stream->readInt<size_t>();
if (stream->error()) if (stream->error())
{ {
infoLog << "Invalid program binary."; infoLog << "Invalid program binary.";
...@@ -1057,7 +1057,7 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context, ...@@ -1057,7 +1057,7 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context,
} }
ASSERT(mImage2DUniforms.empty()); ASSERT(mImage2DUniforms.empty());
for (unsigned int image2DUniformIndex = 0; image2DUniformIndex < image2DUniformCount; for (size_t image2DUniformIndex = 0; image2DUniformIndex < image2DUniformCount;
++image2DUniformIndex) ++image2DUniformIndex)
{ {
sh::ShaderVariable image2Duniform; sh::ShaderVariable image2Duniform;
...@@ -1071,7 +1071,7 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context, ...@@ -1071,7 +1071,7 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context,
mComputeAtomicCounterBufferRegisterIndices[ii] = index; mComputeAtomicCounterBufferRegisterIndices[ii] = index;
} }
const unsigned int uniformCount = stream->readInt<unsigned int>(); size_t uniformCount = stream->readInt<size_t>();
if (stream->error()) if (stream->error())
{ {
infoLog << "Invalid program binary."; infoLog << "Invalid program binary.";
...@@ -1080,14 +1080,14 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context, ...@@ -1080,14 +1080,14 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context,
const auto &linkedUniforms = mState.getUniforms(); const auto &linkedUniforms = mState.getUniforms();
ASSERT(mD3DUniforms.empty()); ASSERT(mD3DUniforms.empty());
for (unsigned int uniformIndex = 0; uniformIndex < uniformCount; uniformIndex++) for (size_t uniformIndex = 0; uniformIndex < uniformCount; uniformIndex++)
{ {
const gl::LinkedUniform &linkedUniform = linkedUniforms[uniformIndex]; const gl::LinkedUniform &linkedUniform = linkedUniforms[uniformIndex];
D3DUniform *d3dUniform = D3DUniform *d3dUniform =
new D3DUniform(linkedUniform.type, HLSLRegisterType::None, linkedUniform.name, new D3DUniform(linkedUniform.type, HLSLRegisterType::None, linkedUniform.name,
linkedUniform.arraySizes, linkedUniform.isInDefaultBlock()); linkedUniform.arraySizes, linkedUniform.isInDefaultBlock());
stream->readInt<HLSLRegisterType>(&d3dUniform->regType); stream->readEnum(&d3dUniform->regType);
for (gl::ShaderType shaderType : gl::AllShaderTypes()) for (gl::ShaderType shaderType : gl::AllShaderTypes())
{ {
stream->readInt(&d3dUniform->mShaderRegisterIndexes[shaderType]); stream->readInt(&d3dUniform->mShaderRegisterIndexes[shaderType]);
...@@ -1098,7 +1098,7 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context, ...@@ -1098,7 +1098,7 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context,
mD3DUniforms.push_back(d3dUniform); mD3DUniforms.push_back(d3dUniform);
} }
const unsigned int blockCount = stream->readInt<unsigned int>(); size_t blockCount = stream->readInt<size_t>();
if (stream->error()) if (stream->error())
{ {
infoLog << "Invalid program binary."; infoLog << "Invalid program binary.";
...@@ -1106,7 +1106,7 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context, ...@@ -1106,7 +1106,7 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context,
} }
ASSERT(mD3DUniformBlocks.empty()); ASSERT(mD3DUniformBlocks.empty());
for (unsigned int blockIndex = 0; blockIndex < blockCount; ++blockIndex) for (size_t blockIndex = 0; blockIndex < blockCount; ++blockIndex)
{ {
D3DUniformBlock uniformBlock; D3DUniformBlock uniformBlock;
for (gl::ShaderType shaderType : gl::AllShaderTypes()) for (gl::ShaderType shaderType : gl::AllShaderTypes())
...@@ -1119,9 +1119,9 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context, ...@@ -1119,9 +1119,9 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context,
mD3DUniformBlocks.push_back(uniformBlock); mD3DUniformBlocks.push_back(uniformBlock);
} }
const unsigned int streamOutVaryingCount = stream->readInt<unsigned int>(); size_t streamOutVaryingCount = stream->readInt<size_t>();
mStreamOutVaryings.resize(streamOutVaryingCount); mStreamOutVaryings.resize(streamOutVaryingCount);
for (unsigned int varyingIndex = 0; varyingIndex < streamOutVaryingCount; ++varyingIndex) for (size_t varyingIndex = 0; varyingIndex < streamOutVaryingCount; ++varyingIndex)
{ {
D3DVarying *varying = &mStreamOutVaryings[varyingIndex]; D3DVarying *varying = &mStreamOutVaryings[varyingIndex];
...@@ -1145,7 +1145,7 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context, ...@@ -1145,7 +1145,7 @@ std::unique_ptr<rx::LinkEvent> ProgramD3D::load(const gl::Context *context,
stream->readBool(&mUsesPointSize); stream->readBool(&mUsesPointSize);
stream->readBool(&mUsesFlatInterpolation); stream->readBool(&mUsesFlatInterpolation);
const size_t pixelShaderKeySize = stream->readInt<unsigned int>(); const size_t pixelShaderKeySize = stream->readInt<size_t>();
mPixelShaderKey.resize(pixelShaderKeySize); mPixelShaderKey.resize(pixelShaderKeySize);
for (size_t pixelShaderKeyIndex = 0; pixelShaderKeyIndex < pixelShaderKeySize; for (size_t pixelShaderKeyIndex = 0; pixelShaderKeyIndex < pixelShaderKeySize;
pixelShaderKeyIndex++) pixelShaderKeyIndex++)
...@@ -1171,19 +1171,18 @@ angle::Result ProgramD3D::loadBinaryShaderExecutables(d3d::Context *contextD3D, ...@@ -1171,19 +1171,18 @@ angle::Result ProgramD3D::loadBinaryShaderExecutables(d3d::Context *contextD3D,
bool separateAttribs = (mState.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS); bool separateAttribs = (mState.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS);
const unsigned int vertexShaderCount = stream->readInt<unsigned int>(); size_t vertexShaderCount = stream->readInt<size_t>();
for (unsigned int vertexShaderIndex = 0; vertexShaderIndex < vertexShaderCount; for (size_t vertexShaderIndex = 0; vertexShaderIndex < vertexShaderCount; vertexShaderIndex++)
vertexShaderIndex++)
{ {
size_t inputLayoutSize = stream->readInt<size_t>(); size_t inputLayoutSize = stream->readInt<size_t>();
gl::InputLayout inputLayout(inputLayoutSize, angle::FormatID::NONE); gl::InputLayout inputLayout(inputLayoutSize, angle::FormatID::NONE);
for (size_t inputIndex = 0; inputIndex < inputLayoutSize; inputIndex++) for (size_t inputIndex = 0; inputIndex < inputLayoutSize; inputIndex++)
{ {
inputLayout[inputIndex] = stream->readInt<angle::FormatID>(); inputLayout[inputIndex] = stream->readEnum<angle::FormatID>();
} }
unsigned int vertexShaderSize = stream->readInt<unsigned int>(); size_t vertexShaderSize = stream->readInt<size_t>();
const unsigned char *vertexShaderFunction = binary + stream->offset(); const unsigned char *vertexShaderFunction = binary + stream->offset();
ShaderExecutableD3D *shaderExecutable = nullptr; ShaderExecutableD3D *shaderExecutable = nullptr;
...@@ -1209,17 +1208,17 @@ angle::Result ProgramD3D::loadBinaryShaderExecutables(d3d::Context *contextD3D, ...@@ -1209,17 +1208,17 @@ angle::Result ProgramD3D::loadBinaryShaderExecutables(d3d::Context *contextD3D,
stream->skip(vertexShaderSize); stream->skip(vertexShaderSize);
} }
const size_t pixelShaderCount = stream->readInt<unsigned int>(); size_t pixelShaderCount = stream->readInt<size_t>();
for (size_t pixelShaderIndex = 0; pixelShaderIndex < pixelShaderCount; pixelShaderIndex++) for (size_t pixelShaderIndex = 0; pixelShaderIndex < pixelShaderCount; pixelShaderIndex++)
{ {
const size_t outputCount = stream->readInt<unsigned int>(); size_t outputCount = stream->readInt<size_t>();
std::vector<GLenum> outputs(outputCount); std::vector<GLenum> outputs(outputCount);
for (size_t outputIndex = 0; outputIndex < outputCount; outputIndex++) for (size_t outputIndex = 0; outputIndex < outputCount; outputIndex++)
{ {
stream->readInt(&outputs[outputIndex]); stream->readInt(&outputs[outputIndex]);
} }
const size_t pixelShaderSize = stream->readInt<unsigned int>(); size_t pixelShaderSize = stream->readInt<size_t>();
const unsigned char *pixelShaderFunction = binary + stream->offset(); const unsigned char *pixelShaderFunction = binary + stream->offset();
ShaderExecutableD3D *shaderExecutable = nullptr; ShaderExecutableD3D *shaderExecutable = nullptr;
...@@ -1240,9 +1239,9 @@ angle::Result ProgramD3D::loadBinaryShaderExecutables(d3d::Context *contextD3D, ...@@ -1240,9 +1239,9 @@ angle::Result ProgramD3D::loadBinaryShaderExecutables(d3d::Context *contextD3D,
stream->skip(pixelShaderSize); stream->skip(pixelShaderSize);
} }
for (auto &geometryExe : mGeometryExecutables) for (std::unique_ptr<ShaderExecutableD3D> &geometryExe : mGeometryExecutables)
{ {
unsigned int geometryShaderSize = stream->readInt<unsigned int>(); size_t geometryShaderSize = stream->readInt<size_t>();
if (geometryShaderSize == 0) if (geometryShaderSize == 0)
{ {
continue; continue;
...@@ -1266,22 +1265,22 @@ angle::Result ProgramD3D::loadBinaryShaderExecutables(d3d::Context *contextD3D, ...@@ -1266,22 +1265,22 @@ angle::Result ProgramD3D::loadBinaryShaderExecutables(d3d::Context *contextD3D,
stream->skip(geometryShaderSize); stream->skip(geometryShaderSize);
} }
const size_t computeShaderCount = stream->readInt<unsigned int>(); size_t computeShaderCount = stream->readInt<size_t>();
for (size_t computeShaderIndex = 0; computeShaderIndex < computeShaderCount; for (size_t computeShaderIndex = 0; computeShaderIndex < computeShaderCount;
computeShaderIndex++) computeShaderIndex++)
{ {
const size_t signatureCount = stream->readInt<unsigned int>(); size_t signatureCount = stream->readInt<size_t>();
gl::ImageUnitTextureTypeMap signatures; gl::ImageUnitTextureTypeMap signatures;
for (size_t signatureIndex = 0; signatureIndex < signatureCount; signatureIndex++) for (size_t signatureIndex = 0; signatureIndex < signatureCount; signatureIndex++)
{ {
unsigned int imageUint; unsigned int imageUint;
gl::TextureType textureType; gl::TextureType textureType;
stream->readInt<unsigned int>(&imageUint); stream->readInt(&imageUint);
stream->readInt<gl::TextureType>(&textureType); stream->readEnum(&textureType);
signatures.insert(std::pair<unsigned int, gl::TextureType>(imageUint, textureType)); signatures.insert(std::pair<unsigned int, gl::TextureType>(imageUint, textureType));
} }
const size_t computeShaderSize = stream->readInt<unsigned int>(); size_t computeShaderSize = stream->readInt<size_t>();
const unsigned char *computeShaderFunction = binary + stream->offset(); const unsigned char *computeShaderFunction = binary + stream->offset();
ShaderExecutableD3D *computeExecutable = nullptr; ShaderExecutableD3D *computeExecutable = nullptr;
...@@ -1302,7 +1301,7 @@ angle::Result ProgramD3D::loadBinaryShaderExecutables(d3d::Context *contextD3D, ...@@ -1302,7 +1301,7 @@ angle::Result ProgramD3D::loadBinaryShaderExecutables(d3d::Context *contextD3D,
stream->skip(computeShaderSize); stream->skip(computeShaderSize);
} }
const size_t bindLayoutCount = stream->readInt<unsigned int>(); size_t bindLayoutCount = stream->readInt<size_t>();
for (size_t bindLayoutIndex = 0; bindLayoutIndex < bindLayoutCount; bindLayoutIndex++) for (size_t bindLayoutIndex = 0; bindLayoutIndex < bindLayoutCount; bindLayoutIndex++)
{ {
mComputeShaderImage2DBindLayoutCache.insert(std::pair<unsigned int, gl::TextureType>( mComputeShaderImage2DBindLayoutCache.insert(std::pair<unsigned int, gl::TextureType>(
...@@ -1337,7 +1336,7 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream ...@@ -1337,7 +1336,7 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream
stream->writeInt(mShaderSamplers[shaderType].size()); stream->writeInt(mShaderSamplers[shaderType].size());
for (unsigned int i = 0; i < mShaderSamplers[shaderType].size(); ++i) for (unsigned int i = 0; i < mShaderSamplers[shaderType].size(); ++i)
{ {
stream->writeInt(mShaderSamplers[shaderType][i].active); stream->writeBool(mShaderSamplers[shaderType][i].active);
stream->writeInt(mShaderSamplers[shaderType][i].logicalTextureUnit); stream->writeInt(mShaderSamplers[shaderType][i].logicalTextureUnit);
stream->writeEnum(mShaderSamplers[shaderType][i].textureType); stream->writeEnum(mShaderSamplers[shaderType][i].textureType);
} }
...@@ -1347,17 +1346,17 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream ...@@ -1347,17 +1346,17 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream
} }
stream->writeInt(mImagesCS.size()); stream->writeInt(mImagesCS.size());
for (unsigned int i = 0; i < mImagesCS.size(); ++i) for (size_t imageIndex = 0; imageIndex < mImagesCS.size(); ++imageIndex)
{ {
stream->writeInt(mImagesCS[i].active); stream->writeBool(mImagesCS[imageIndex].active);
stream->writeInt(mImagesCS[i].logicalImageUnit); stream->writeInt(mImagesCS[imageIndex].logicalImageUnit);
} }
stream->writeInt(mReadonlyImagesCS.size()); stream->writeInt(mReadonlyImagesCS.size());
for (unsigned int i = 0; i < mReadonlyImagesCS.size(); ++i) for (size_t imageIndex = 0; imageIndex < mReadonlyImagesCS.size(); ++imageIndex)
{ {
stream->writeInt(mReadonlyImagesCS[i].active); stream->writeBool(mReadonlyImagesCS[imageIndex].active);
stream->writeInt(mReadonlyImagesCS[i].logicalImageUnit); stream->writeInt(mReadonlyImagesCS[imageIndex].logicalImageUnit);
} }
stream->writeInt(mUsedComputeImageRange.low()); stream->writeInt(mUsedComputeImageRange.low());
...@@ -1391,7 +1390,7 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream ...@@ -1391,7 +1390,7 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream
for (const D3DUniform *uniform : mD3DUniforms) for (const D3DUniform *uniform : mD3DUniforms)
{ {
// Type, name and arraySize are redundant, so aren't stored in the binary. // Type, name and arraySize are redundant, so aren't stored in the binary.
stream->writeInt(static_cast<unsigned int>(uniform->regType)); stream->writeEnum(uniform->regType);
for (gl::ShaderType shaderType : gl::AllShaderTypes()) for (gl::ShaderType shaderType : gl::AllShaderTypes())
{ {
stream->writeIntOrNegOne(uniform->mShaderRegisterIndexes[shaderType]); stream->writeIntOrNegOne(uniform->mShaderRegisterIndexes[shaderType]);
...@@ -1406,14 +1405,14 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream ...@@ -1406,14 +1405,14 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream
for (gl::ShaderType shaderType : gl::AllShaderTypes()) for (gl::ShaderType shaderType : gl::AllShaderTypes())
{ {
stream->writeIntOrNegOne(uniformBlock.mShaderRegisterIndexes[shaderType]); stream->writeIntOrNegOne(uniformBlock.mShaderRegisterIndexes[shaderType]);
stream->writeInt(uniformBlock.mUseStructuredBuffers[shaderType]); stream->writeBool(uniformBlock.mUseStructuredBuffers[shaderType]);
stream->writeInt(uniformBlock.mByteWidths[shaderType]); stream->writeInt(uniformBlock.mByteWidths[shaderType]);
stream->writeInt(uniformBlock.mStructureByteStrides[shaderType]); stream->writeInt(uniformBlock.mStructureByteStrides[shaderType]);
} }
} }
stream->writeInt(mStreamOutVaryings.size()); stream->writeInt(mStreamOutVaryings.size());
for (const auto &varying : mStreamOutVaryings) for (const D3DVarying &varying : mStreamOutVaryings)
{ {
stream->writeString(varying.semanticName); stream->writeString(varying.semanticName);
stream->writeInt(varying.semanticIndex); stream->writeInt(varying.semanticIndex);
...@@ -1428,12 +1427,12 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream ...@@ -1428,12 +1427,12 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream
sizeof(angle::CompilerWorkaroundsD3D)); sizeof(angle::CompilerWorkaroundsD3D));
} }
stream->writeInt(mUsesFragDepth); stream->writeBool(mUsesFragDepth);
stream->writeInt(mHasANGLEMultiviewEnabled); stream->writeBool(mHasANGLEMultiviewEnabled);
stream->writeInt(mUsesVertexID); stream->writeBool(mUsesVertexID);
stream->writeInt(mUsesViewID); stream->writeBool(mUsesViewID);
stream->writeInt(mUsesPointSize); stream->writeBool(mUsesPointSize);
stream->writeInt(mUsesFlatInterpolation); stream->writeBool(mUsesFlatInterpolation);
const std::vector<PixelShaderOutputVariable> &pixelShaderKey = mPixelShaderKey; const std::vector<PixelShaderOutputVariable> &pixelShaderKey = mPixelShaderKey;
stream->writeInt(pixelShaderKey.size()); stream->writeInt(pixelShaderKey.size());
...@@ -1456,12 +1455,12 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream ...@@ -1456,12 +1455,12 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream
{ {
VertexExecutable *vertexExecutable = mVertexExecutables[vertexExecutableIndex].get(); VertexExecutable *vertexExecutable = mVertexExecutables[vertexExecutableIndex].get();
const auto &inputLayout = vertexExecutable->inputs(); const gl::InputLayout &inputLayout = vertexExecutable->inputs();
stream->writeInt(inputLayout.size()); stream->writeInt(inputLayout.size());
for (size_t inputIndex = 0; inputIndex < inputLayout.size(); inputIndex++) for (size_t inputIndex = 0; inputIndex < inputLayout.size(); inputIndex++)
{ {
stream->writeInt(static_cast<unsigned int>(inputLayout[inputIndex])); stream->writeEnum(inputLayout[inputIndex]);
} }
size_t vertexShaderSize = vertexExecutable->shaderExecutable()->getLength(); size_t vertexShaderSize = vertexExecutable->shaderExecutable()->getLength();
...@@ -1477,7 +1476,7 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream ...@@ -1477,7 +1476,7 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream
{ {
PixelExecutable *pixelExecutable = mPixelExecutables[pixelExecutableIndex].get(); PixelExecutable *pixelExecutable = mPixelExecutables[pixelExecutableIndex].get();
const std::vector<GLenum> outputs = pixelExecutable->outputSignature(); const std::vector<GLenum> &outputs = pixelExecutable->outputSignature();
stream->writeInt(outputs.size()); stream->writeInt(outputs.size());
for (size_t outputIndex = 0; outputIndex < outputs.size(); outputIndex++) for (size_t outputIndex = 0; outputIndex < outputs.size(); outputIndex++)
{ {
...@@ -1495,7 +1494,7 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream ...@@ -1495,7 +1494,7 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream
{ {
if (!geometryExecutable) if (!geometryExecutable)
{ {
stream->writeInt(0); stream->writeInt<size_t>(0);
continue; continue;
} }
...@@ -1515,7 +1514,7 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream ...@@ -1515,7 +1514,7 @@ void ProgramD3D::save(const gl::Context *context, gl::BinaryOutputStream *stream
for (const auto &signature : signatures) for (const auto &signature : signatures)
{ {
stream->writeInt(signature.first); stream->writeInt(signature.first);
stream->writeInt(static_cast<unsigned int>(signature.second)); stream->writeEnum(signature.second);
} }
size_t computeShaderSize = computeExecutable->shaderExecutable()->getLength(); size_t computeShaderSize = computeExecutable->shaderExecutable()->getLength();
......
...@@ -260,23 +260,23 @@ void ProgramExecutableVk::save(gl::BinaryOutputStream *stream) ...@@ -260,23 +260,23 @@ void ProgramExecutableVk::save(gl::BinaryOutputStream *stream)
{ {
for (gl::ShaderType shaderType : gl::AllShaderTypes()) for (gl::ShaderType shaderType : gl::AllShaderTypes())
{ {
stream->writeInt<size_t>(mVariableInfoMap[shaderType].size()); stream->writeInt(mVariableInfoMap[shaderType].size());
for (const auto &it : mVariableInfoMap[shaderType]) for (const auto &it : mVariableInfoMap[shaderType])
{ {
stream->writeString(it.first); stream->writeString(it.first);
stream->writeInt<uint32_t>(it.second.descriptorSet); stream->writeInt(it.second.descriptorSet);
stream->writeInt<uint32_t>(it.second.binding); stream->writeInt(it.second.binding);
stream->writeInt<uint32_t>(it.second.location); stream->writeInt(it.second.location);
stream->writeInt<uint32_t>(it.second.component); stream->writeInt(it.second.component);
// PackedEnumBitSet uses uint8_t // PackedEnumBitSet uses uint8_t
stream->writeInt<uint8_t>(it.second.activeStages.bits()); stream->writeInt(it.second.activeStages.bits());
stream->writeInt<uint32_t>(it.second.xfbBuffer); stream->writeInt(it.second.xfbBuffer);
stream->writeInt<uint32_t>(it.second.xfbOffset); stream->writeInt(it.second.xfbOffset);
stream->writeInt<uint32_t>(it.second.xfbStride); stream->writeInt(it.second.xfbStride);
stream->writeInt<uint8_t>(it.second.useRelaxedPrecision); stream->writeBool(it.second.useRelaxedPrecision);
stream->writeInt<uint8_t>(it.second.varyingIsOutput); stream->writeBool(it.second.varyingIsOutput);
stream->writeInt<uint8_t>(it.second.attributeComponentCount); stream->writeInt(it.second.attributeComponentCount);
stream->writeInt<uint8_t>(it.second.attributeLocationCount); stream->writeInt(it.second.attributeLocationCount);
} }
} }
} }
......
...@@ -212,7 +212,7 @@ void ProgramVk::save(const gl::Context *context, gl::BinaryOutputStream *stream) ...@@ -212,7 +212,7 @@ void ProgramVk::save(const gl::Context *context, gl::BinaryOutputStream *stream)
for (gl::ShaderType shaderType : gl::AllShaderTypes()) for (gl::ShaderType shaderType : gl::AllShaderTypes())
{ {
const size_t uniformCount = mDefaultUniformBlocks[shaderType].uniformLayout.size(); const size_t uniformCount = mDefaultUniformBlocks[shaderType].uniformLayout.size();
stream->writeInt<size_t>(uniformCount); stream->writeInt(uniformCount);
for (unsigned int uniformIndex = 0; uniformIndex < uniformCount; ++uniformIndex) for (unsigned int uniformIndex = 0; uniformIndex < uniformCount; ++uniformIndex)
{ {
sh::BlockMemberInfo &blockInfo = sh::BlockMemberInfo &blockInfo =
......
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