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
...@@ -165,8 +165,8 @@ namespace glsl ...@@ -165,8 +165,8 @@ namespace glsl
} }
else else
{ {
const int numComponents = type.getElementSize(); const size_t numComponents = type.getElementSize();
baseAlignment = (numComponents == 3 ? 4u : static_cast<size_t>(numComponents)); baseAlignment = (numComponents == 3 ? 4u : numComponents);
} }
mCurrentOffset = sw::align(mCurrentOffset, baseAlignment); mCurrentOffset = sw::align(mCurrentOffset, baseAlignment);
...@@ -1114,7 +1114,7 @@ namespace glsl ...@@ -1114,7 +1114,7 @@ namespace glsl
TIntermTyped *result = node; TIntermTyped *result = node;
const TType &resultType = node->getType(); const TType &resultType = node->getType();
TIntermSequence &arg = node->getSequence(); TIntermSequence &arg = node->getSequence();
int argumentCount = arg.size(); size_t argumentCount = arg.size();
switch(node->getOp()) switch(node->getOp())
{ {
...@@ -1187,7 +1187,7 @@ namespace glsl ...@@ -1187,7 +1187,7 @@ namespace glsl
TIntermSequence &arguments = *function->arg; TIntermSequence &arguments = *function->arg;
for(int i = 0; i < argumentCount; i++) for(size_t i = 0; i < argumentCount; i++)
{ {
TIntermTyped *in = arguments[i]->getAsTyped(); TIntermTyped *in = arguments[i]->getAsTyped();
...@@ -1208,7 +1208,7 @@ namespace glsl ...@@ -1208,7 +1208,7 @@ namespace glsl
copy(result, function->ret); 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 *argument = arguments[i]->getAsTyped();
TIntermTyped *out = arg[i]->getAsTyped(); TIntermTyped *out = arg[i]->getAsTyped();
...@@ -1328,7 +1328,7 @@ namespace glsl ...@@ -1328,7 +1328,7 @@ namespace glsl
{ {
int component = 0; int component = 0;
for(int i = 0; i < argumentCount; i++) for(size_t i = 0; i < argumentCount; i++)
{ {
TIntermTyped *argi = arg[i]->getAsTyped(); TIntermTyped *argi = arg[i]->getAsTyped();
int size = argi->getNominalSize(); int size = argi->getNominalSize();
...@@ -1409,7 +1409,7 @@ namespace glsl ...@@ -1409,7 +1409,7 @@ namespace glsl
int column = 0; int column = 0;
int row = 0; int row = 0;
for(int i = 0; i < argumentCount; i++) for(size_t i = 0; i < argumentCount; i++)
{ {
TIntermTyped *argi = arg[i]->getAsTyped(); TIntermTyped *argi = arg[i]->getAsTyped();
int size = argi->getNominalSize(); int size = argi->getNominalSize();
...@@ -1434,7 +1434,7 @@ namespace glsl ...@@ -1434,7 +1434,7 @@ namespace glsl
if(visit == PostVisit) if(visit == PostVisit)
{ {
int offset = 0; int offset = 0;
for(int i = 0; i < argumentCount; i++) for(size_t i = 0; i < argumentCount; i++)
{ {
TIntermTyped *argi = arg[i]->getAsTyped(); TIntermTyped *argi = arg[i]->getAsTyped();
int size = argi->totalRegisterCount(); int size = argi->totalRegisterCount();
...@@ -2030,8 +2030,8 @@ namespace glsl ...@@ -2030,8 +2030,8 @@ namespace glsl
if(type.isInterfaceBlock()) if(type.isInterfaceBlock())
{ {
// Offset index to the beginning of the selected instance // Offset index to the beginning of the selected instance
size_t blockRegisters = type.elementRegisterCount(); int blockRegisters = type.elementRegisterCount();
size_t bufferOffset = argumentInfo.clampedIndex / blockRegisters; int bufferOffset = argumentInfo.clampedIndex / blockRegisters;
argumentInfo.bufferIndex += bufferOffset; argumentInfo.bufferIndex += bufferOffset;
argumentInfo.clampedIndex -= bufferOffset * blockRegisters; argumentInfo.clampedIndex -= bufferOffset * blockRegisters;
} }
......
...@@ -481,7 +481,7 @@ bool TParseContext::constructorErrorCheck(const TSourceLoc &line, TIntermNode* n ...@@ -481,7 +481,7 @@ bool TParseContext::constructorErrorCheck(const TSourceLoc &line, TIntermNode* n
// again, there is an extra argument, so 'overfull' will become true. // again, there is an extra argument, so 'overfull' will become true.
// //
int size = 0; size_t size = 0;
bool full = false; bool full = false;
bool overFull = false; bool overFull = false;
bool matrixInMatrix = false; bool matrixInMatrix = false;
...@@ -2221,7 +2221,7 @@ TIntermTyped* TParseContext::addConstArrayNode(int index, TIntermTyped* node, co ...@@ -2221,7 +2221,7 @@ TIntermTyped* TParseContext::addConstArrayNode(int index, TIntermTyped* node, co
index = 0; index = 0;
} }
int arrayElementSize = arrayElementType.getObjectSize(); size_t arrayElementSize = arrayElementType.getObjectSize();
if (tempConstantNode) { if (tempConstantNode) {
ConstantUnion* unionArray = tempConstantNode->getUnionArrayPointer(); ConstantUnion* unionArray = tempConstantNode->getUnionArrayPointer();
...@@ -2246,11 +2246,10 @@ TIntermTyped* TParseContext::addConstStruct(const TString& identifier, TIntermTy ...@@ -2246,11 +2246,10 @@ TIntermTyped* TParseContext::addConstStruct(const TString& identifier, TIntermTy
{ {
const TFieldList &fields = node->getType().getStruct()->fields(); const TFieldList &fields = node->getType().getStruct()->fields();
TIntermTyped *typedNode; TIntermTyped *typedNode;
int instanceSize = 0; size_t instanceSize = 0;
unsigned int index = 0;
TIntermConstantUnion *tempConstantNode = node->getAsConstantUnion(); 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) { if (fields[index]->name() == identifier) {
break; break;
} else { } else {
......
...@@ -87,7 +87,7 @@ void TType::buildMangledName(TString& mangledName) ...@@ -87,7 +87,7 @@ void TType::buildMangledName(TString& mangledName)
} }
} }
int TType::getStructSize() const size_t TType::getStructSize() const
{ {
if (!getStruct()) { if (!getStruct()) {
assert(false && "Not a struct"); assert(false && "Not a struct");
......
...@@ -277,7 +277,7 @@ public: ...@@ -277,7 +277,7 @@ public:
int getNominalSize() const { return primarySize; } int getNominalSize() const { return primarySize; }
void setNominalSize(int s) { primarySize = s; } void setNominalSize(int s) { primarySize = s; }
// Full size of single instance of type // Full size of single instance of type
int getObjectSize() const size_t getObjectSize() const
{ {
if(isArray()) if(isArray())
{ {
...@@ -289,7 +289,7 @@ public: ...@@ -289,7 +289,7 @@ public:
} }
} }
int getElementSize() const size_t getElementSize() const
{ {
if(getBasicType() == EbtStruct) if(getBasicType() == EbtStruct)
{ {
...@@ -467,7 +467,7 @@ public: ...@@ -467,7 +467,7 @@ public:
protected: protected:
void buildMangledName(TString&); void buildMangledName(TString&);
int getStructSize() const; size_t getStructSize() const;
void computeDeepestStructNesting(); void computeDeepestStructNesting();
TBasicType type; TBasicType type;
......
...@@ -349,9 +349,9 @@ void TOutputTraverser::visitConstantUnion(TIntermConstantUnion* node) ...@@ -349,9 +349,9 @@ void TOutputTraverser::visitConstantUnion(TIntermConstantUnion* node)
{ {
TInfoSinkBase& out = sink; 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); OutputTreeText(out, node, mDepth);
switch (node->getUnionArrayPointer()[i].getType()) { switch (node->getUnionArrayPointer()[i].getType()) {
case EbtBool: case EbtBool:
......
...@@ -37,13 +37,13 @@ protected: ...@@ -37,13 +37,13 @@ protected:
bool visitLoop(Visit visit, TIntermLoop*); bool visitLoop(Visit visit, TIntermLoop*);
bool visitBranch(Visit visit, TIntermBranch*); bool visitBranch(Visit visit, TIntermBranch*);
int index; size_t index;
ConstantUnion *unionArray; ConstantUnion *unionArray;
TType type; TType type;
TOperator constructorType; TOperator constructorType;
bool singleConstantParam; bool singleConstantParam;
TInfoSink& infoSink; TInfoSink& infoSink;
int size; // size of the constructor ( 4 for vec4) size_t size; // size of the constructor ( 4 for vec4)
bool isMatrix; bool isMatrix;
int matrixSize; // dimension of the matrix (nominal size and not the instance size) int matrixSize; // dimension of the matrix (nominal size and not the instance size)
}; };
...@@ -156,17 +156,17 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node) ...@@ -156,17 +156,17 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
} }
ConstantUnion* leftUnionArray = unionArray; ConstantUnion* leftUnionArray = unionArray;
int instanceSize = type.getObjectSize(); size_t instanceSize = type.getObjectSize();
TBasicType basicType = type.getBasicType(); TBasicType basicType = type.getBasicType();
if (index >= instanceSize) if (index >= instanceSize)
return; return;
if (!singleConstantParam) { if (!singleConstantParam) {
int size = node->getType().getObjectSize(); size_t size = node->getType().getObjectSize();
ConstantUnion *rightUnionArray = node->getUnionArrayPointer(); ConstantUnion *rightUnionArray = node->getUnionArrayPointer();
for (int i=0; i < size; i++) { for(size_t i = 0; i < size; i++) {
if (index >= instanceSize) if (index >= instanceSize)
return; return;
leftUnionArray[index].cast(basicType, rightUnionArray[i]); leftUnionArray[index].cast(basicType, rightUnionArray[i]);
...@@ -174,11 +174,11 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node) ...@@ -174,11 +174,11 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
(index)++; (index)++;
} }
} else { } else {
int totalSize = index + size; size_t totalSize = index + size;
ConstantUnion *rightUnionArray = node->getUnionArrayPointer(); ConstantUnion *rightUnionArray = node->getUnionArrayPointer();
if (!isMatrix) { if (!isMatrix) {
int count = 0; int count = 0;
for (int i = index; i < totalSize; i++) { for(size_t i = index; i < totalSize; i++) {
if (i >= instanceSize) if (i >= instanceSize)
return; return;
...@@ -192,7 +192,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node) ...@@ -192,7 +192,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
} else { // for matrix constructors } else { // for matrix constructors
int count = 0; int count = 0;
int element = index; int element = index;
for (int i = index; i < totalSize; i++) { for(size_t i = index; i < totalSize; i++) {
if (i >= instanceSize) if (i >= instanceSize)
return; return;
if (element - i == 0 || (i - element) % (matrixSize + 1) == 0 ) if (element - i == 0 || (i - element) % (matrixSize + 1) == 0 )
......
...@@ -4308,7 +4308,7 @@ const GLubyte* Context::getExtensions(GLuint index, GLuint* numExt) const ...@@ -4308,7 +4308,7 @@ const GLubyte* Context::getExtensions(GLuint index, GLuint* numExt) const
static GLubyte* extensionsCat = nullptr; static GLubyte* extensionsCat = nullptr;
if(!extensionsCat && (numExtensions > 0)) 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++) for(unsigned int i = 0; i < numExtensions; i++)
{ {
totalLength += strlen(reinterpret_cast<const char*>(extensions[i])); totalLength += strlen(reinterpret_cast<const char*>(extensions[i]));
......
...@@ -64,7 +64,7 @@ namespace es2 ...@@ -64,7 +64,7 @@ namespace es2
{ {
if(blockInfo.index == -1) if(blockInfo.index == -1)
{ {
int bytes = UniformTypeSize(type) * size(); size_t bytes = UniformTypeSize(type) * size();
data = new unsigned char[bytes]; data = new unsigned char[bytes];
memset(data, 0, bytes); memset(data, 0, bytes);
} }
...@@ -347,8 +347,8 @@ namespace es2 ...@@ -347,8 +347,8 @@ namespace es2
size_t subscript = GL_INVALID_INDEX; size_t subscript = GL_INVALID_INDEX;
std::string baseName = es2::ParseUniformName(name, &subscript); std::string baseName = es2::ParseUniformName(name, &subscript);
unsigned int numUniforms = uniformIndex.size(); size_t numUniforms = uniformIndex.size();
for(unsigned int location = 0; location < numUniforms; location++) for(size_t location = 0; location < numUniforms; location++)
{ {
const int index = uniformIndex[location].index; const int index = uniformIndex[location].index;
const bool isArray = uniforms[index]->isArray(); const bool isArray = uniforms[index]->isArray();
...@@ -357,7 +357,7 @@ namespace es2 ...@@ -357,7 +357,7 @@ namespace es2
((isArray && uniformIndex[location].element == subscript) || ((isArray && uniformIndex[location].element == subscript) ||
(subscript == GL_INVALID_INDEX))) (subscript == GL_INVALID_INDEX)))
{ {
return location; return (GLint)location;
} }
} }
...@@ -375,8 +375,8 @@ namespace es2 ...@@ -375,8 +375,8 @@ namespace es2
return GL_INVALID_INDEX; return GL_INVALID_INDEX;
} }
unsigned int numUniforms = uniforms.size(); size_t numUniforms = uniforms.size();
for(unsigned int index = 0; index < numUniforms; index++) for(GLuint index = 0; index < numUniforms; index++)
{ {
if(uniforms[index]->name == baseName) if(uniforms[index]->name == baseName)
{ {
...@@ -430,8 +430,8 @@ namespace es2 ...@@ -430,8 +430,8 @@ namespace es2
size_t subscript = GL_INVALID_INDEX; size_t subscript = GL_INVALID_INDEX;
std::string baseName = es2::ParseUniformName(name, &subscript); std::string baseName = es2::ParseUniformName(name, &subscript);
unsigned int numUniformBlocks = getActiveUniformBlockCount(); size_t numUniformBlocks = getActiveUniformBlockCount();
for(unsigned int blockIndex = 0; blockIndex < numUniformBlocks; blockIndex++) for(GLuint blockIndex = 0; blockIndex < numUniformBlocks; blockIndex++)
{ {
const UniformBlock &uniformBlock = *uniformBlocks[blockIndex]; const UniformBlock &uniformBlock = *uniformBlocks[blockIndex];
if(uniformBlock.name == baseName) if(uniformBlock.name == baseName)
...@@ -1053,8 +1053,8 @@ namespace es2 ...@@ -1053,8 +1053,8 @@ namespace es2
void Program::dirtyAllUniforms() void Program::dirtyAllUniforms()
{ {
unsigned int numUniforms = uniforms.size(); size_t numUniforms = uniforms.size();
for(unsigned int index = 0; index < numUniforms; index++) for(size_t index = 0; index < numUniforms; index++)
{ {
uniforms[index]->dirty = true; uniforms[index]->dirty = true;
} }
...@@ -1063,8 +1063,8 @@ namespace es2 ...@@ -1063,8 +1063,8 @@ namespace es2
// Applies all the uniforms set for this program object to the device // Applies all the uniforms set for this program object to the device
void Program::applyUniforms() void Program::applyUniforms()
{ {
unsigned int numUniforms = uniformIndex.size(); GLint numUniforms = uniformIndex.size();
for(unsigned int location = 0; location < numUniforms; location++) for(GLint location = 0; location < numUniforms; location++)
{ {
if(uniformIndex[location].element != 0) if(uniformIndex[location].element != 0)
{ {
...@@ -1075,7 +1075,7 @@ namespace es2 ...@@ -1075,7 +1075,7 @@ namespace es2
if(targetUniform->dirty && (targetUniform->blockInfo.index == -1)) if(targetUniform->dirty && (targetUniform->blockInfo.index == -1))
{ {
int size = targetUniform->size(); GLsizei size = targetUniform->size();
GLfloat *f = (GLfloat*)targetUniform->data; GLfloat *f = (GLfloat*)targetUniform->data;
GLint *i = (GLint*)targetUniform->data; GLint *i = (GLint*)targetUniform->data;
GLuint *ui = (GLuint*)targetUniform->data; GLuint *ui = (GLuint*)targetUniform->data;
...@@ -1664,7 +1664,7 @@ namespace es2 ...@@ -1664,7 +1664,7 @@ namespace es2
if(location == -1) // Not previously defined if(location == -1) // Not previously defined
{ {
uniforms.push_back(uniform); uniforms.push_back(uniform);
unsigned int index = uniforms.size() - 1; size_t index = uniforms.size() - 1;
for(int i = 0; i < uniform->size(); i++) for(int i = 0; i < uniform->size(); i++)
{ {
...@@ -1708,8 +1708,8 @@ namespace es2 ...@@ -1708,8 +1708,8 @@ namespace es2
{ {
return false; return false;
} }
const unsigned int numBlockMembers = block1.fields.size(); const size_t numBlockMembers = block1.fields.size();
for(unsigned int blockMemberIndex = 0; blockMemberIndex < numBlockMembers; blockMemberIndex++) for(size_t blockMemberIndex = 0; blockMemberIndex < numBlockMembers; blockMemberIndex++)
{ {
const glsl::Uniform& member1 = shader1->activeUniforms[block1.fields[blockMemberIndex]]; const glsl::Uniform& member1 = shader1->activeUniforms[block1.fields[blockMemberIndex]];
const glsl::Uniform& member2 = shader2->activeUniforms[block2.fields[blockMemberIndex]]; const glsl::Uniform& member2 = shader2->activeUniforms[block2.fields[blockMemberIndex]];
...@@ -2423,7 +2423,7 @@ namespace es2 ...@@ -2423,7 +2423,7 @@ namespace es2
return currentSerial++; return currentSerial++;
} }
int Program::getInfoLogLength() const size_t Program::getInfoLogLength() const
{ {
if(!infoLog) if(!infoLog)
{ {
...@@ -2578,8 +2578,8 @@ namespace es2 ...@@ -2578,8 +2578,8 @@ namespace es2
{ {
int maxLength = 0; int maxLength = 0;
unsigned int numUniforms = uniforms.size(); size_t numUniforms = uniforms.size();
for(unsigned int uniformIndex = 0; uniformIndex < numUniforms; uniformIndex++) for(size_t uniformIndex = 0; uniformIndex < numUniforms; uniformIndex++)
{ {
if(!uniforms[uniformIndex]->name.empty()) if(!uniforms[uniformIndex]->name.empty())
{ {
...@@ -2649,17 +2649,17 @@ namespace es2 ...@@ -2649,17 +2649,17 @@ namespace es2
GLint Program::getActiveUniformBlockMaxLength() const GLint Program::getActiveUniformBlockMaxLength() const
{ {
int maxLength = 0; size_t maxLength = 0;
if(isLinked()) if(isLinked())
{ {
unsigned int numUniformBlocks = getActiveUniformBlockCount(); size_t numUniformBlocks = getActiveUniformBlockCount();
for(unsigned int uniformBlockIndex = 0; uniformBlockIndex < numUniformBlocks; uniformBlockIndex++) for(size_t uniformBlockIndex = 0; uniformBlockIndex < numUniformBlocks; uniformBlockIndex++)
{ {
const UniformBlock &uniformBlock = *uniformBlocks[uniformBlockIndex]; const UniformBlock &uniformBlock = *uniformBlocks[uniformBlockIndex];
if(!uniformBlock.name.empty()) if(!uniformBlock.name.empty())
{ {
const int length = uniformBlock.name.length() + 1; size_t length = uniformBlock.name.length() + 1;
// Counting in "[0]". // Counting in "[0]".
const int arrayLength = (uniformBlock.isArrayElement() ? 3 : 0); const int arrayLength = (uniformBlock.isArrayElement() ? 3 : 0);
......
...@@ -174,7 +174,7 @@ namespace es2 ...@@ -174,7 +174,7 @@ namespace es2
void link(); void link();
bool isLinked() const; bool isLinked() const;
int getInfoLogLength() const; size_t getInfoLogLength() const;
void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog); void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog);
void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders); void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders);
......
...@@ -84,7 +84,7 @@ void Shader::setSource(GLsizei count, const char *const *string, const GLint *le ...@@ -84,7 +84,7 @@ void Shader::setSource(GLsizei count, const char *const *string, const GLint *le
mSource[totalLength] = '\0'; mSource[totalLength] = '\0';
} }
int Shader::getInfoLogLength() const size_t Shader::getInfoLogLength() const
{ {
if(infoLog.empty()) if(infoLog.empty())
{ {
...@@ -117,7 +117,7 @@ void Shader::getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLogOut) ...@@ -117,7 +117,7 @@ void Shader::getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLogOut)
} }
} }
int Shader::getSourceLength() const size_t Shader::getSourceLength() const
{ {
if(!mSource) if(!mSource)
{ {
......
...@@ -49,9 +49,9 @@ public: ...@@ -49,9 +49,9 @@ public:
void deleteSource(); void deleteSource();
void setSource(GLsizei count, const char *const *string, const GLint *length); 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); void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog);
int getSourceLength() const; size_t getSourceLength() const;
void getSource(GLsizei bufSize, GLsizei *length, char *source); void getSource(GLsizei bufSize, GLsizei *length, char *source);
void compile(); void compile();
......
...@@ -78,9 +78,7 @@ unsigned int VertexDataManager::writeAttributeData(StreamingVertexBuffer *vertex ...@@ -78,9 +78,7 @@ unsigned int VertexDataManager::writeAttributeData(StreamingVertexBuffer *vertex
if(buffer) if(buffer)
{ {
int offset = attribute.mOffset; input = static_cast<const char*>(buffer->data()) + attribute.mOffset;
input = static_cast<const char*>(buffer->data()) + offset;
} }
else else
{ {
......
...@@ -2591,7 +2591,7 @@ void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) ...@@ -2591,7 +2591,7 @@ void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
*params = buffer->usage(); *params = buffer->usage();
break; break;
case GL_BUFFER_SIZE: case GL_BUFFER_SIZE:
*params = buffer->size(); *params = (GLint)buffer->size();
break; break;
case GL_BUFFER_ACCESS_FLAGS: case GL_BUFFER_ACCESS_FLAGS:
if(clientVersion >= 3) if(clientVersion >= 3)
...@@ -2610,14 +2610,14 @@ void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) ...@@ -2610,14 +2610,14 @@ void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
case GL_BUFFER_MAP_LENGTH: case GL_BUFFER_MAP_LENGTH:
if(clientVersion >= 3) if(clientVersion >= 3)
{ {
*params = buffer->length(); *params = (GLint)buffer->length();
break; break;
} }
else return error(GL_INVALID_ENUM); else return error(GL_INVALID_ENUM);
case GL_BUFFER_MAP_OFFSET: case GL_BUFFER_MAP_OFFSET:
if(clientVersion >= 3) if(clientVersion >= 3)
{ {
*params = buffer->offset(); *params = (GLint)buffer->offset();
break; break;
} }
else return error(GL_INVALID_ENUM); else return error(GL_INVALID_ENUM);
...@@ -3168,19 +3168,19 @@ void GetProgramiv(GLuint program, GLenum pname, GLint* params) ...@@ -3168,19 +3168,19 @@ void GetProgramiv(GLuint program, GLenum pname, GLint* params)
*params = programObject->isValidated(); *params = programObject->isValidated();
return; return;
case GL_INFO_LOG_LENGTH: case GL_INFO_LOG_LENGTH:
*params = programObject->getInfoLogLength(); *params = (GLint)programObject->getInfoLogLength();
return; return;
case GL_ATTACHED_SHADERS: case GL_ATTACHED_SHADERS:
*params = programObject->getAttachedShadersCount(); *params = programObject->getAttachedShadersCount();
return; return;
case GL_ACTIVE_ATTRIBUTES: case GL_ACTIVE_ATTRIBUTES:
*params = programObject->getActiveAttributeCount(); *params = (GLint)programObject->getActiveAttributeCount();
return; return;
case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
*params = programObject->getActiveAttributeMaxLength(); *params = programObject->getActiveAttributeMaxLength();
return; return;
case GL_ACTIVE_UNIFORMS: case GL_ACTIVE_UNIFORMS:
*params = programObject->getActiveUniformCount(); *params = (GLint)programObject->getActiveUniformCount();
return; return;
case GL_ACTIVE_UNIFORM_MAX_LENGTH: case GL_ACTIVE_UNIFORM_MAX_LENGTH:
*params = programObject->getActiveUniformMaxLength(); *params = programObject->getActiveUniformMaxLength();
...@@ -3188,7 +3188,7 @@ void GetProgramiv(GLuint program, GLenum pname, GLint* params) ...@@ -3188,7 +3188,7 @@ void GetProgramiv(GLuint program, GLenum pname, GLint* params)
case GL_ACTIVE_UNIFORM_BLOCKS: case GL_ACTIVE_UNIFORM_BLOCKS:
if(clientVersion >= 3) if(clientVersion >= 3)
{ {
*params = programObject->getActiveUniformBlockCount(); *params = (GLint)programObject->getActiveUniformBlockCount();
return; return;
} }
else return error(GL_INVALID_ENUM); else return error(GL_INVALID_ENUM);
...@@ -3407,10 +3407,10 @@ void GetShaderiv(GLuint shader, GLenum pname, GLint* params) ...@@ -3407,10 +3407,10 @@ void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
*params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
return; return;
case GL_INFO_LOG_LENGTH: case GL_INFO_LOG_LENGTH:
*params = shaderObject->getInfoLogLength(); *params = (GLint)shaderObject->getInfoLogLength();
return; return;
case GL_SHADER_SOURCE_LENGTH: case GL_SHADER_SOURCE_LENGTH:
*params = shaderObject->getSourceLength(); *params = (GLint)shaderObject->getSourceLength();
return; return;
default: default:
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
......
...@@ -1683,7 +1683,7 @@ GL_APICALL void *GL_APIENTRY glMapBufferRange(GLenum target, GLintptr offset, GL ...@@ -1683,7 +1683,7 @@ GL_APICALL void *GL_APIENTRY glMapBufferRange(GLenum target, GLintptr offset, GL
return error(GL_INVALID_OPERATION, nullptr); return error(GL_INVALID_OPERATION, nullptr);
} }
GLint bufferSize = buffer->size(); GLsizeiptr bufferSize = buffer->size();
if((offset < 0) || (length < 0) || ((offset + length) > bufferSize)) if((offset < 0) || (length < 0) || ((offset + length) > bufferSize))
{ {
error(GL_INVALID_VALUE); error(GL_INVALID_VALUE);
...@@ -1726,7 +1726,7 @@ GL_APICALL void GL_APIENTRY glFlushMappedBufferRange(GLenum target, GLintptr off ...@@ -1726,7 +1726,7 @@ GL_APICALL void GL_APIENTRY glFlushMappedBufferRange(GLenum target, GLintptr off
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
GLint bufferSize = buffer->size(); GLsizeiptr bufferSize = buffer->size();
if((offset < 0) || (length < 0) || ((offset + length) > bufferSize)) if((offset < 0) || (length < 0) || ((offset + length) > bufferSize))
{ {
error(GL_INVALID_VALUE); 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