Commit ab752790 by Alexis Hetu Committed by Alexis Hétu

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/5177Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 536f7913
......@@ -1053,8 +1053,8 @@ bool CompareStruct(const TType& leftNodeType, ConstantUnion* rightUnionArray, Co
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 @@ bool CompareStructure(const TType& leftNodeType, ConstantUnion* rightUnionArray,
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 @@ ConstantUnion* CreateInverse(TIntermConstantUnion* node, ConstantUnion* unionArr
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 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
// 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 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
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 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
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 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
{
// 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 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
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 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
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 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
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 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
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 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
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 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
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 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
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 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
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 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
//
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* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
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()) {
......
......@@ -165,8 +165,8 @@ namespace glsl
}
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 @@ namespace glsl
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 @@ namespace glsl
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 @@ namespace glsl
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 @@ namespace glsl
{
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 @@ namespace glsl
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 @@ namespace glsl
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 @@ namespace glsl
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;
}
......
......@@ -481,7 +481,7 @@ bool TParseContext::constructorErrorCheck(const TSourceLoc &line, TIntermNode* n
// 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 @@ TIntermTyped* TParseContext::addConstArrayNode(int index, TIntermTyped* node, co
index = 0;
}
int arrayElementSize = arrayElementType.getObjectSize();
size_t arrayElementSize = arrayElementType.getObjectSize();
if (tempConstantNode) {
ConstantUnion* unionArray = tempConstantNode->getUnionArrayPointer();
......@@ -2246,11 +2246,10 @@ TIntermTyped* TParseContext::addConstStruct(const TString& identifier, TIntermTy
{
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 {
......
......@@ -87,7 +87,7 @@ void TType::buildMangledName(TString& mangledName)
}
}
int TType::getStructSize() const
size_t TType::getStructSize() const
{
if (!getStruct()) {
assert(false && "Not a struct");
......
......@@ -277,7 +277,7 @@ public:
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 @@ public:
}
}
int getElementSize() const
size_t getElementSize() const
{
if(getBasicType() == EbtStruct)
{
......@@ -467,7 +467,7 @@ public:
protected:
void buildMangledName(TString&);
int getStructSize() const;
size_t getStructSize() const;
void computeDeepestStructNesting();
TBasicType type;
......
......@@ -349,9 +349,9 @@ void TOutputTraverser::visitConstantUnion(TIntermConstantUnion* node)
{
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:
......
......@@ -37,13 +37,13 @@ protected:
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 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
}
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 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
(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 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
} 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 )
......
......@@ -4308,7 +4308,7 @@ const GLubyte* Context::getExtensions(GLuint index, GLuint* numExt) const
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]));
......
......@@ -64,7 +64,7 @@ namespace es2
{
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 @@ namespace es2
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 @@ namespace es2
((isArray && uniformIndex[location].element == subscript) ||
(subscript == GL_INVALID_INDEX)))
{
return location;
return (GLint)location;
}
}
......@@ -375,8 +375,8 @@ namespace es2
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 @@ namespace es2
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 @@ namespace es2
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 @@ namespace es2
// 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 @@ namespace es2
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 @@ namespace es2
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 @@ namespace es2
{
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 @@ namespace es2
return currentSerial++;
}
int Program::getInfoLogLength() const
size_t Program::getInfoLogLength() const
{
if(!infoLog)
{
......@@ -2578,8 +2578,8 @@ namespace es2
{
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 @@ namespace es2
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);
......
......@@ -174,7 +174,7 @@ namespace es2
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);
......
......@@ -84,7 +84,7 @@ void Shader::setSource(GLsizei count, const char *const *string, const GLint *le
mSource[totalLength] = '\0';
}
int Shader::getInfoLogLength() const
size_t Shader::getInfoLogLength() const
{
if(infoLog.empty())
{
......@@ -117,7 +117,7 @@ void Shader::getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLogOut)
}
}
int Shader::getSourceLength() const
size_t Shader::getSourceLength() const
{
if(!mSource)
{
......
......@@ -49,9 +49,9 @@ public:
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();
......
......@@ -78,9 +78,7 @@ unsigned int VertexDataManager::writeAttributeData(StreamingVertexBuffer *vertex
if(buffer)
{
int offset = attribute.mOffset;
input = static_cast<const char*>(buffer->data()) + offset;
input = static_cast<const char*>(buffer->data()) + attribute.mOffset;
}
else
{
......
......@@ -2591,7 +2591,7 @@ void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
*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 @@ void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
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 @@ void GetProgramiv(GLuint program, GLenum pname, GLint* params)
*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 @@ void GetProgramiv(GLuint program, GLenum pname, GLint* params)
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 @@ void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
*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);
......
......@@ -1683,7 +1683,7 @@ GL_APICALL void *GL_APIENTRY glMapBufferRange(GLenum target, GLintptr offset, GL
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 @@ GL_APICALL void GL_APIENTRY glFlushMappedBufferRange(GLenum target, GLintptr off
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);
......
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