Making proper use of size_t
In a lot of cases, int was being used instead of size_to represent
sizes. That led to some warnings about inconsistencies between int
and size_t usage. While this cl doesn't solve all warnings, it tries
to use size_t and int where it should be appropriate to use them.
Change-Id: Id760df1360f65b2bba60f4075cdf4954fc6bbaf3
Reviewed-on: https://swiftshader-review.googlesource.com/5177
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/OpenGL/compiler/Intermediate.cpp b/src/OpenGL/compiler/Intermediate.cpp
index 14cd5b2..688f84a 100644
--- a/src/OpenGL/compiler/Intermediate.cpp
+++ b/src/OpenGL/compiler/Intermediate.cpp
@@ -1053,8 +1053,8 @@
int index = 0;
for (size_t j = 0; j < structSize; j++) {
- int size = fields[j]->type()->getObjectSize();
- for (int i = 0; i < size; i++) {
+ size_t size = fields[j]->type()->getObjectSize();
+ for(size_t i = 0; i < size; i++) {
if (fields[j]->type()->getBasicType() == EbtStruct) {
if (!CompareStructure(*(fields[j]->type()), &rightUnionArray[index], &leftUnionArray[index]))
return false;
@@ -1078,7 +1078,7 @@
int arraySize = leftNodeType.getArraySize();
for (int i = 0; i < arraySize; ++i) {
- int offset = typeWithoutArrayness.getObjectSize() * i;
+ size_t offset = typeWithoutArrayness.getObjectSize() * i;
if (!CompareStruct(typeWithoutArrayness, &rightUnionArray[offset], &leftUnionArray[offset]))
return false;
}
@@ -1253,7 +1253,7 @@
TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNode, TInfoSink& infoSink)
{
ConstantUnion *unionArray = getUnionArrayPointer();
- int objectSize = getType().getObjectSize();
+ size_t objectSize = getType().getObjectSize();
if (constantNode) { // binary operations
TIntermConstantUnion *node = constantNode->getAsConstantUnion();
@@ -1263,13 +1263,13 @@
// for a case like float f = 1.2 + vec4(2,3,4,5);
if (constantNode->getType().getObjectSize() == 1 && objectSize > 1) {
rightUnionArray = new ConstantUnion[objectSize];
- for (int i = 0; i < objectSize; ++i)
+ for (size_t i = 0; i < objectSize; ++i)
rightUnionArray[i] = *node->getUnionArrayPointer();
returnType = getType();
} else if (constantNode->getType().getObjectSize() > 1 && objectSize == 1) {
// for a case like float f = vec4(2,3,4,5) + 1.2;
unionArray = new ConstantUnion[constantNode->getType().getObjectSize()];
- for (int i = 0; i < constantNode->getType().getObjectSize(); ++i)
+ for (size_t i = 0; i < constantNode->getType().getObjectSize(); ++i)
unionArray[i] = *getUnionArrayPointer();
returnType = node->getType();
objectSize = constantNode->getType().getObjectSize();
@@ -1283,14 +1283,14 @@
case EOpAdd:
tempConstArray = new ConstantUnion[objectSize];
{// support MSVC++6.0
- for (int i = 0; i < objectSize; i++)
+ for (size_t i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] + rightUnionArray[i];
}
break;
case EOpSub:
tempConstArray = new ConstantUnion[objectSize];
{// support MSVC++6.0
- for (int i = 0; i < objectSize; i++)
+ for (size_t i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] - rightUnionArray[i];
}
break;
@@ -1300,7 +1300,7 @@
case EOpMatrixTimesScalar:
tempConstArray = new ConstantUnion[objectSize];
{// support MSVC++6.0
- for (int i = 0; i < objectSize; i++)
+ for (size_t i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] * rightUnionArray[i];
}
break;
@@ -1389,7 +1389,7 @@
{
// Singular matrix, just copy
tempConstArray = new ConstantUnion[objectSize];
- for(int i = 0; i < objectSize; i++)
+ for(size_t i = 0; i < objectSize; i++)
tempConstArray[i] = rightUnionArray[i];
}
}
@@ -1399,7 +1399,7 @@
case EOpIMod:
tempConstArray = new ConstantUnion[objectSize];
{// support MSVC++6.0
- for (int i = 0; i < objectSize; i++) {
+ for (size_t i = 0; i < objectSize; i++) {
switch (getType().getBasicType()) {
case EbtFloat:
if (rightUnionArray[i] == 0.0f) {
@@ -1486,7 +1486,7 @@
case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
tempConstArray = new ConstantUnion[objectSize];
{// support MSVC++6.0
- for (int i = 0; i < objectSize; i++)
+ for (size_t i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] && rightUnionArray[i];
}
break;
@@ -1494,7 +1494,7 @@
case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
tempConstArray = new ConstantUnion[objectSize];
{// support MSVC++6.0
- for (int i = 0; i < objectSize; i++)
+ for (size_t i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] || rightUnionArray[i];
}
break;
@@ -1502,7 +1502,7 @@
case EOpLogicalXor:
tempConstArray = new ConstantUnion[objectSize];
{// support MSVC++6.0
- for (int i = 0; i < objectSize; i++)
+ for (size_t i = 0; i < objectSize; i++)
switch (getType().getBasicType()) {
case EbtBool: tempConstArray[i].setBConst((unionArray[i] == rightUnionArray[i]) ? false : true); break;
default: assert(false && "Default missing");
@@ -1512,51 +1512,51 @@
case EOpBitwiseAnd:
tempConstArray = new ConstantUnion[objectSize];
- for(int i = 0; i < objectSize; i++)
+ for(size_t i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] & rightUnionArray[i];
break;
case EOpBitwiseXor:
tempConstArray = new ConstantUnion[objectSize];
- for(int i = 0; i < objectSize; i++)
+ for(size_t i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] ^ rightUnionArray[i];
break;
case EOpBitwiseOr:
tempConstArray = new ConstantUnion[objectSize];
- for(int i = 0; i < objectSize; i++)
+ for(size_t i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] | rightUnionArray[i];
break;
case EOpBitShiftLeft:
tempConstArray = new ConstantUnion[objectSize];
- for(int i = 0; i < objectSize; i++)
+ for(size_t i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] << rightUnionArray[i];
break;
case EOpBitShiftRight:
tempConstArray = new ConstantUnion[objectSize];
- for(int i = 0; i < objectSize; i++)
+ for(size_t i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] >> rightUnionArray[i];
break;
case EOpLessThan:
tempConstArray = new ConstantUnion[objectSize];
- for(int i = 0; i < objectSize; i++)
+ for(size_t i = 0; i < objectSize; i++)
tempConstArray[i].setBConst(unionArray[i] < rightUnionArray[i]);
returnType = TType(EbtBool, EbpUndefined, EvqConstExpr, objectSize);
break;
case EOpGreaterThan:
tempConstArray = new ConstantUnion[objectSize];
- for(int i = 0; i < objectSize; i++)
+ for(size_t i = 0; i < objectSize; i++)
tempConstArray[i].setBConst(unionArray[i] > rightUnionArray[i]);
returnType = TType(EbtBool, EbpUndefined, EvqConstExpr, objectSize);
break;
case EOpLessThanEqual:
tempConstArray = new ConstantUnion[objectSize];
- for(int i = 0; i < objectSize; i++)
+ for(size_t i = 0; i < objectSize; i++)
tempConstArray[i].setBConst(unionArray[i] <= rightUnionArray[i]);
returnType = TType(EbtBool, EbpUndefined, EvqConstExpr, objectSize);
break;
case EOpGreaterThanEqual:
tempConstArray = new ConstantUnion[objectSize];
- for(int i = 0; i < objectSize; i++)
+ for(size_t i = 0; i < objectSize; i++)
tempConstArray[i].setBConst(unionArray[i] >= rightUnionArray[i]);
returnType = TType(EbtBool, EbpUndefined, EvqConstExpr, objectSize);
break;
@@ -1565,7 +1565,7 @@
if (!CompareStructure(node->getType(), node->getUnionArrayPointer(), unionArray))
boolNodeFlag = true;
} else {
- for (int i = 0; i < objectSize; i++) {
+ for (size_t i = 0; i < objectSize; i++) {
if (unionArray[i] != rightUnionArray[i]) {
boolNodeFlag = true;
break; // break out of for loop
@@ -1591,7 +1591,7 @@
if (CompareStructure(node->getType(), node->getUnionArrayPointer(), unionArray))
boolNodeFlag = true;
} else {
- for (int i = 0; i < objectSize; i++) {
+ for (size_t i = 0; i < objectSize; i++) {
if (unionArray[i] == rightUnionArray[i]) {
boolNodeFlag = true;
break; // break out of for loop
@@ -1614,14 +1614,14 @@
case EOpMax:
tempConstArray = new ConstantUnion[objectSize];
{// support MSVC++6.0
- for (int i = 0; i < objectSize; i++)
+ for (size_t i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] > rightUnionArray[i] ? unionArray[i] : rightUnionArray[i];
}
break;
case EOpMin:
tempConstArray = new ConstantUnion[objectSize];
{// support MSVC++6.0
- for (int i = 0; i < objectSize; i++)
+ for (size_t i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] < rightUnionArray[i] ? unionArray[i] : rightUnionArray[i];
}
break;
@@ -1638,7 +1638,7 @@
//
TIntermConstantUnion *newNode = 0;
ConstantUnion* tempConstArray = new ConstantUnion[objectSize];
- for (int i = 0; i < objectSize; i++) {
+ for (size_t i = 0; i < objectSize; i++) {
switch(op) {
case EOpNegative:
switch (getType().getBasicType()) {
@@ -1678,12 +1678,11 @@
TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermConstantUnion* node)
{
- int size = node->getType().getObjectSize();
+ size_t size = node->getType().getObjectSize();
ConstantUnion *leftUnionArray = new ConstantUnion[size];
- for (int i=0; i < size; i++) {
-
+ for(size_t i = 0; i < size; i++) {
switch (promoteTo) {
case EbtFloat:
switch (node->getType().getBasicType()) {
diff --git a/src/OpenGL/compiler/OutputASM.cpp b/src/OpenGL/compiler/OutputASM.cpp
index 6b1d4f7..f8915c9 100644
--- a/src/OpenGL/compiler/OutputASM.cpp
+++ b/src/OpenGL/compiler/OutputASM.cpp
@@ -165,8 +165,8 @@
}
else
{
- const int numComponents = type.getElementSize();
- baseAlignment = (numComponents == 3 ? 4u : static_cast<size_t>(numComponents));
+ const size_t numComponents = type.getElementSize();
+ baseAlignment = (numComponents == 3 ? 4u : numComponents);
}
mCurrentOffset = sw::align(mCurrentOffset, baseAlignment);
@@ -1114,7 +1114,7 @@
TIntermTyped *result = node;
const TType &resultType = node->getType();
TIntermSequence &arg = node->getSequence();
- int argumentCount = arg.size();
+ size_t argumentCount = arg.size();
switch(node->getOp())
{
@@ -1187,7 +1187,7 @@
TIntermSequence &arguments = *function->arg;
- for(int i = 0; i < argumentCount; i++)
+ for(size_t i = 0; i < argumentCount; i++)
{
TIntermTyped *in = arguments[i]->getAsTyped();
@@ -1208,7 +1208,7 @@
copy(result, function->ret);
}
- for(int i = 0; i < argumentCount; i++)
+ for(size_t i = 0; i < argumentCount; i++)
{
TIntermTyped *argument = arguments[i]->getAsTyped();
TIntermTyped *out = arg[i]->getAsTyped();
@@ -1328,7 +1328,7 @@
{
int component = 0;
- for(int i = 0; i < argumentCount; i++)
+ for(size_t i = 0; i < argumentCount; i++)
{
TIntermTyped *argi = arg[i]->getAsTyped();
int size = argi->getNominalSize();
@@ -1409,7 +1409,7 @@
int column = 0;
int row = 0;
- for(int i = 0; i < argumentCount; i++)
+ for(size_t i = 0; i < argumentCount; i++)
{
TIntermTyped *argi = arg[i]->getAsTyped();
int size = argi->getNominalSize();
@@ -1434,7 +1434,7 @@
if(visit == PostVisit)
{
int offset = 0;
- for(int i = 0; i < argumentCount; i++)
+ for(size_t i = 0; i < argumentCount; i++)
{
TIntermTyped *argi = arg[i]->getAsTyped();
int size = argi->totalRegisterCount();
@@ -2030,8 +2030,8 @@
if(type.isInterfaceBlock())
{
// Offset index to the beginning of the selected instance
- size_t blockRegisters = type.elementRegisterCount();
- size_t bufferOffset = argumentInfo.clampedIndex / blockRegisters;
+ int blockRegisters = type.elementRegisterCount();
+ int bufferOffset = argumentInfo.clampedIndex / blockRegisters;
argumentInfo.bufferIndex += bufferOffset;
argumentInfo.clampedIndex -= bufferOffset * blockRegisters;
}
diff --git a/src/OpenGL/compiler/ParseHelper.cpp b/src/OpenGL/compiler/ParseHelper.cpp
index 40fc794..87f1e2d 100644
--- a/src/OpenGL/compiler/ParseHelper.cpp
+++ b/src/OpenGL/compiler/ParseHelper.cpp
@@ -481,7 +481,7 @@
// again, there is an extra argument, so 'overfull' will become true.
//
- int size = 0;
+ size_t size = 0;
bool full = false;
bool overFull = false;
bool matrixInMatrix = false;
@@ -2221,7 +2221,7 @@
index = 0;
}
- int arrayElementSize = arrayElementType.getObjectSize();
+ size_t arrayElementSize = arrayElementType.getObjectSize();
if (tempConstantNode) {
ConstantUnion* unionArray = tempConstantNode->getUnionArrayPointer();
@@ -2246,11 +2246,10 @@
{
const TFieldList &fields = node->getType().getStruct()->fields();
TIntermTyped *typedNode;
- int instanceSize = 0;
- unsigned int index = 0;
+ size_t instanceSize = 0;
TIntermConstantUnion *tempConstantNode = node->getAsConstantUnion();
- for ( index = 0; index < fields.size(); ++index) {
+ for(size_t index = 0; index < fields.size(); ++index) {
if (fields[index]->name() == identifier) {
break;
} else {
diff --git a/src/OpenGL/compiler/SymbolTable.cpp b/src/OpenGL/compiler/SymbolTable.cpp
index 7932bd5..0d449d9 100644
--- a/src/OpenGL/compiler/SymbolTable.cpp
+++ b/src/OpenGL/compiler/SymbolTable.cpp
@@ -87,7 +87,7 @@
}
}
-int TType::getStructSize() const
+size_t TType::getStructSize() const
{
if (!getStruct()) {
assert(false && "Not a struct");
diff --git a/src/OpenGL/compiler/Types.h b/src/OpenGL/compiler/Types.h
index f7138e7..0131343 100644
--- a/src/OpenGL/compiler/Types.h
+++ b/src/OpenGL/compiler/Types.h
@@ -277,7 +277,7 @@
int getNominalSize() const { return primarySize; }
void setNominalSize(int s) { primarySize = s; }
// Full size of single instance of type
- int getObjectSize() const
+ size_t getObjectSize() const
{
if(isArray())
{
@@ -289,7 +289,7 @@
}
}
- int getElementSize() const
+ size_t getElementSize() const
{
if(getBasicType() == EbtStruct)
{
@@ -467,7 +467,7 @@
protected:
void buildMangledName(TString&);
- int getStructSize() const;
+ size_t getStructSize() const;
void computeDeepestStructNesting();
TBasicType type;
diff --git a/src/OpenGL/compiler/intermOut.cpp b/src/OpenGL/compiler/intermOut.cpp
index 8a65f49..a482175 100644
--- a/src/OpenGL/compiler/intermOut.cpp
+++ b/src/OpenGL/compiler/intermOut.cpp
@@ -349,9 +349,9 @@
{
TInfoSinkBase& out = sink;
- int size = node->getType().getObjectSize();
+ size_t size = node->getType().getObjectSize();
- for (int i = 0; i < size; i++) {
+ for(size_t i = 0; i < size; i++) {
OutputTreeText(out, node, mDepth);
switch (node->getUnionArrayPointer()[i].getType()) {
case EbtBool:
diff --git a/src/OpenGL/compiler/parseConst.cpp b/src/OpenGL/compiler/parseConst.cpp
index f141f54..59b39b4 100644
--- a/src/OpenGL/compiler/parseConst.cpp
+++ b/src/OpenGL/compiler/parseConst.cpp
@@ -37,13 +37,13 @@
bool visitLoop(Visit visit, TIntermLoop*);
bool visitBranch(Visit visit, TIntermBranch*);
- int index;
+ size_t index;
ConstantUnion *unionArray;
TType type;
TOperator constructorType;
bool singleConstantParam;
TInfoSink& infoSink;
- int size; // size of the constructor ( 4 for vec4)
+ size_t size; // size of the constructor ( 4 for vec4)
bool isMatrix;
int matrixSize; // dimension of the matrix (nominal size and not the instance size)
};
@@ -156,17 +156,17 @@
}
ConstantUnion* leftUnionArray = unionArray;
- int instanceSize = type.getObjectSize();
+ size_t instanceSize = type.getObjectSize();
TBasicType basicType = type.getBasicType();
if (index >= instanceSize)
return;
if (!singleConstantParam) {
- int size = node->getType().getObjectSize();
+ size_t size = node->getType().getObjectSize();
ConstantUnion *rightUnionArray = node->getUnionArrayPointer();
- for (int i=0; i < size; i++) {
+ for(size_t i = 0; i < size; i++) {
if (index >= instanceSize)
return;
leftUnionArray[index].cast(basicType, rightUnionArray[i]);
@@ -174,11 +174,11 @@
(index)++;
}
} else {
- int totalSize = index + size;
+ size_t totalSize = index + size;
ConstantUnion *rightUnionArray = node->getUnionArrayPointer();
if (!isMatrix) {
int count = 0;
- for (int i = index; i < totalSize; i++) {
+ for(size_t i = index; i < totalSize; i++) {
if (i >= instanceSize)
return;
@@ -192,7 +192,7 @@
} else { // for matrix constructors
int count = 0;
int element = index;
- for (int i = index; i < totalSize; i++) {
+ for(size_t i = index; i < totalSize; i++) {
if (i >= instanceSize)
return;
if (element - i == 0 || (i - element) % (matrixSize + 1) == 0 )
diff --git a/src/OpenGL/libGLESv2/Context.cpp b/src/OpenGL/libGLESv2/Context.cpp
index cec6b6b..6b01e45 100644
--- a/src/OpenGL/libGLESv2/Context.cpp
+++ b/src/OpenGL/libGLESv2/Context.cpp
@@ -4308,7 +4308,7 @@
static GLubyte* extensionsCat = nullptr;
if(!extensionsCat && (numExtensions > 0))
{
- int totalLength = numExtensions; // 1 space between each extension name + terminating null
+ size_t totalLength = numExtensions; // 1 space between each extension name + terminating null
for(unsigned int i = 0; i < numExtensions; i++)
{
totalLength += strlen(reinterpret_cast<const char*>(extensions[i]));
diff --git a/src/OpenGL/libGLESv2/Program.cpp b/src/OpenGL/libGLESv2/Program.cpp
index c663cd4..9bfee2b 100644
--- a/src/OpenGL/libGLESv2/Program.cpp
+++ b/src/OpenGL/libGLESv2/Program.cpp
@@ -64,7 +64,7 @@
{
if(blockInfo.index == -1)
{
- int bytes = UniformTypeSize(type) * size();
+ size_t bytes = UniformTypeSize(type) * size();
data = new unsigned char[bytes];
memset(data, 0, bytes);
}
@@ -347,8 +347,8 @@
size_t subscript = GL_INVALID_INDEX;
std::string baseName = es2::ParseUniformName(name, &subscript);
- unsigned int numUniforms = uniformIndex.size();
- for(unsigned int location = 0; location < numUniforms; location++)
+ size_t numUniforms = uniformIndex.size();
+ for(size_t location = 0; location < numUniforms; location++)
{
const int index = uniformIndex[location].index;
const bool isArray = uniforms[index]->isArray();
@@ -357,7 +357,7 @@
((isArray && uniformIndex[location].element == subscript) ||
(subscript == GL_INVALID_INDEX)))
{
- return location;
+ return (GLint)location;
}
}
@@ -375,8 +375,8 @@
return GL_INVALID_INDEX;
}
- unsigned int numUniforms = uniforms.size();
- for(unsigned int index = 0; index < numUniforms; index++)
+ size_t numUniforms = uniforms.size();
+ for(GLuint index = 0; index < numUniforms; index++)
{
if(uniforms[index]->name == baseName)
{
@@ -430,8 +430,8 @@
size_t subscript = GL_INVALID_INDEX;
std::string baseName = es2::ParseUniformName(name, &subscript);
- unsigned int numUniformBlocks = getActiveUniformBlockCount();
- for(unsigned int blockIndex = 0; blockIndex < numUniformBlocks; blockIndex++)
+ size_t numUniformBlocks = getActiveUniformBlockCount();
+ for(GLuint blockIndex = 0; blockIndex < numUniformBlocks; blockIndex++)
{
const UniformBlock &uniformBlock = *uniformBlocks[blockIndex];
if(uniformBlock.name == baseName)
@@ -1053,8 +1053,8 @@
void Program::dirtyAllUniforms()
{
- unsigned int numUniforms = uniforms.size();
- for(unsigned int index = 0; index < numUniforms; index++)
+ size_t numUniforms = uniforms.size();
+ for(size_t index = 0; index < numUniforms; index++)
{
uniforms[index]->dirty = true;
}
@@ -1063,8 +1063,8 @@
// Applies all the uniforms set for this program object to the device
void Program::applyUniforms()
{
- unsigned int numUniforms = uniformIndex.size();
- for(unsigned int location = 0; location < numUniforms; location++)
+ GLint numUniforms = uniformIndex.size();
+ for(GLint location = 0; location < numUniforms; location++)
{
if(uniformIndex[location].element != 0)
{
@@ -1075,7 +1075,7 @@
if(targetUniform->dirty && (targetUniform->blockInfo.index == -1))
{
- int size = targetUniform->size();
+ GLsizei size = targetUniform->size();
GLfloat *f = (GLfloat*)targetUniform->data;
GLint *i = (GLint*)targetUniform->data;
GLuint *ui = (GLuint*)targetUniform->data;
@@ -1664,7 +1664,7 @@
if(location == -1) // Not previously defined
{
uniforms.push_back(uniform);
- unsigned int index = uniforms.size() - 1;
+ size_t index = uniforms.size() - 1;
for(int i = 0; i < uniform->size(); i++)
{
@@ -1708,8 +1708,8 @@
{
return false;
}
- const unsigned int numBlockMembers = block1.fields.size();
- for(unsigned int blockMemberIndex = 0; blockMemberIndex < numBlockMembers; blockMemberIndex++)
+ const size_t numBlockMembers = block1.fields.size();
+ for(size_t blockMemberIndex = 0; blockMemberIndex < numBlockMembers; blockMemberIndex++)
{
const glsl::Uniform& member1 = shader1->activeUniforms[block1.fields[blockMemberIndex]];
const glsl::Uniform& member2 = shader2->activeUniforms[block2.fields[blockMemberIndex]];
@@ -2423,7 +2423,7 @@
return currentSerial++;
}
- int Program::getInfoLogLength() const
+ size_t Program::getInfoLogLength() const
{
if(!infoLog)
{
@@ -2578,8 +2578,8 @@
{
int maxLength = 0;
- unsigned int numUniforms = uniforms.size();
- for(unsigned int uniformIndex = 0; uniformIndex < numUniforms; uniformIndex++)
+ size_t numUniforms = uniforms.size();
+ for(size_t uniformIndex = 0; uniformIndex < numUniforms; uniformIndex++)
{
if(!uniforms[uniformIndex]->name.empty())
{
@@ -2649,17 +2649,17 @@
GLint Program::getActiveUniformBlockMaxLength() const
{
- int maxLength = 0;
+ size_t maxLength = 0;
if(isLinked())
{
- unsigned int numUniformBlocks = getActiveUniformBlockCount();
- for(unsigned int uniformBlockIndex = 0; uniformBlockIndex < numUniformBlocks; uniformBlockIndex++)
+ size_t numUniformBlocks = getActiveUniformBlockCount();
+ for(size_t uniformBlockIndex = 0; uniformBlockIndex < numUniformBlocks; uniformBlockIndex++)
{
const UniformBlock &uniformBlock = *uniformBlocks[uniformBlockIndex];
if(!uniformBlock.name.empty())
{
- const int length = uniformBlock.name.length() + 1;
+ size_t length = uniformBlock.name.length() + 1;
// Counting in "[0]".
const int arrayLength = (uniformBlock.isArrayElement() ? 3 : 0);
diff --git a/src/OpenGL/libGLESv2/Program.h b/src/OpenGL/libGLESv2/Program.h
index c035fe4..1ff8f05 100644
--- a/src/OpenGL/libGLESv2/Program.h
+++ b/src/OpenGL/libGLESv2/Program.h
@@ -174,7 +174,7 @@
void link();
bool isLinked() const;
- int getInfoLogLength() const;
+ size_t getInfoLogLength() const;
void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog);
void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders);
diff --git a/src/OpenGL/libGLESv2/Shader.cpp b/src/OpenGL/libGLESv2/Shader.cpp
index 3420758..62cac22 100644
--- a/src/OpenGL/libGLESv2/Shader.cpp
+++ b/src/OpenGL/libGLESv2/Shader.cpp
@@ -84,7 +84,7 @@
mSource[totalLength] = '\0';
}
-int Shader::getInfoLogLength() const
+size_t Shader::getInfoLogLength() const
{
if(infoLog.empty())
{
@@ -117,7 +117,7 @@
}
}
-int Shader::getSourceLength() const
+size_t Shader::getSourceLength() const
{
if(!mSource)
{
diff --git a/src/OpenGL/libGLESv2/Shader.h b/src/OpenGL/libGLESv2/Shader.h
index 963d109..9b0ab79 100644
--- a/src/OpenGL/libGLESv2/Shader.h
+++ b/src/OpenGL/libGLESv2/Shader.h
@@ -49,9 +49,9 @@
void deleteSource();
void setSource(GLsizei count, const char *const *string, const GLint *length);
- int getInfoLogLength() const;
+ size_t getInfoLogLength() const;
void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog);
- int getSourceLength() const;
+ size_t getSourceLength() const;
void getSource(GLsizei bufSize, GLsizei *length, char *source);
void compile();
diff --git a/src/OpenGL/libGLESv2/VertexDataManager.cpp b/src/OpenGL/libGLESv2/VertexDataManager.cpp
index 0fb8f4e..70d89c8 100644
--- a/src/OpenGL/libGLESv2/VertexDataManager.cpp
+++ b/src/OpenGL/libGLESv2/VertexDataManager.cpp
@@ -78,9 +78,7 @@
if(buffer)
{
- int offset = attribute.mOffset;
-
- input = static_cast<const char*>(buffer->data()) + offset;
+ input = static_cast<const char*>(buffer->data()) + attribute.mOffset;
}
else
{
diff --git a/src/OpenGL/libGLESv2/libGLESv2.cpp b/src/OpenGL/libGLESv2/libGLESv2.cpp
index 57414d6..cd721f3 100644
--- a/src/OpenGL/libGLESv2/libGLESv2.cpp
+++ b/src/OpenGL/libGLESv2/libGLESv2.cpp
@@ -2591,7 +2591,7 @@
*params = buffer->usage();
break;
case GL_BUFFER_SIZE:
- *params = buffer->size();
+ *params = (GLint)buffer->size();
break;
case GL_BUFFER_ACCESS_FLAGS:
if(clientVersion >= 3)
@@ -2610,14 +2610,14 @@
case GL_BUFFER_MAP_LENGTH:
if(clientVersion >= 3)
{
- *params = buffer->length();
+ *params = (GLint)buffer->length();
break;
}
else return error(GL_INVALID_ENUM);
case GL_BUFFER_MAP_OFFSET:
if(clientVersion >= 3)
{
- *params = buffer->offset();
+ *params = (GLint)buffer->offset();
break;
}
else return error(GL_INVALID_ENUM);
@@ -3168,19 +3168,19 @@
*params = programObject->isValidated();
return;
case GL_INFO_LOG_LENGTH:
- *params = programObject->getInfoLogLength();
+ *params = (GLint)programObject->getInfoLogLength();
return;
case GL_ATTACHED_SHADERS:
*params = programObject->getAttachedShadersCount();
return;
case GL_ACTIVE_ATTRIBUTES:
- *params = programObject->getActiveAttributeCount();
+ *params = (GLint)programObject->getActiveAttributeCount();
return;
case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
*params = programObject->getActiveAttributeMaxLength();
return;
case GL_ACTIVE_UNIFORMS:
- *params = programObject->getActiveUniformCount();
+ *params = (GLint)programObject->getActiveUniformCount();
return;
case GL_ACTIVE_UNIFORM_MAX_LENGTH:
*params = programObject->getActiveUniformMaxLength();
@@ -3188,7 +3188,7 @@
case GL_ACTIVE_UNIFORM_BLOCKS:
if(clientVersion >= 3)
{
- *params = programObject->getActiveUniformBlockCount();
+ *params = (GLint)programObject->getActiveUniformBlockCount();
return;
}
else return error(GL_INVALID_ENUM);
@@ -3407,10 +3407,10 @@
*params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
return;
case GL_INFO_LOG_LENGTH:
- *params = shaderObject->getInfoLogLength();
+ *params = (GLint)shaderObject->getInfoLogLength();
return;
case GL_SHADER_SOURCE_LENGTH:
- *params = shaderObject->getSourceLength();
+ *params = (GLint)shaderObject->getSourceLength();
return;
default:
return error(GL_INVALID_ENUM);
diff --git a/src/OpenGL/libGLESv2/libGLESv3.cpp b/src/OpenGL/libGLESv2/libGLESv3.cpp
index 7584237..3e0d25f 100644
--- a/src/OpenGL/libGLESv2/libGLESv3.cpp
+++ b/src/OpenGL/libGLESv2/libGLESv3.cpp
@@ -1683,7 +1683,7 @@
return error(GL_INVALID_OPERATION, nullptr);
}
- GLint bufferSize = buffer->size();
+ GLsizeiptr bufferSize = buffer->size();
if((offset < 0) || (length < 0) || ((offset + length) > bufferSize))
{
error(GL_INVALID_VALUE);
@@ -1726,7 +1726,7 @@
return error(GL_INVALID_OPERATION);
}
- GLint bufferSize = buffer->size();
+ GLsizeiptr bufferSize = buffer->size();
if((offset < 0) || (length < 0) || ((offset + length) > bufferSize))
{
error(GL_INVALID_VALUE);