Fixed some warnings
- Changing "char*" to "const char*" when a
function can receive string literals
- Removed some unused variables and members
- Fixed some signed vs unsigned comparisons
- Added braces for safety on code like:
if(...) if(...) ... else ...
to make it:
if(...) { if(...) ... else ... }
otherwise the else is ambiguous
- Reordered some member initializations to
fit the declaration order in the class
- OutDir must end with a backslash in VS
Change-Id: I903bd7afac882090841da0c0f4ebb30db0a5dd37
Reviewed-on: https://swiftshader-review.googlesource.com/3501
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Main/SwiftConfig.cpp b/src/Main/SwiftConfig.cpp
index 444f471..a103c69 100644
--- a/src/Main/SwiftConfig.cpp
+++ b/src/Main/SwiftConfig.cpp
@@ -150,7 +150,7 @@
}
}
- bool match(const char **url, char *string)
+ bool match(const char **url, const char *string)
{
size_t length = strlen(string);
diff --git a/src/Main/SwiftConfig.hpp b/src/Main/SwiftConfig.hpp
index efde23a..14142ec 100644
--- a/src/Main/SwiftConfig.hpp
+++ b/src/Main/SwiftConfig.hpp
@@ -103,7 +103,6 @@
bool newConfig;
Socket *listenSocket;
- Socket *clientSocket;
int bufferLength;
char *receiveBuffer;
diff --git a/src/OpenGL/libGL/Program.cpp b/src/OpenGL/libGL/Program.cpp
index b28d84e..21b7995 100644
--- a/src/OpenGL/libGL/Program.cpp
+++ b/src/OpenGL/libGL/Program.cpp
@@ -2088,11 +2088,11 @@
*type = linkedAttribute[attribute].type;
}
- GLint Program::getActiveAttributeCount() const
+ size_t Program::getActiveAttributeCount() const
{
- int count = 0;
+ size_t count = 0;
- for(int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
+ for(size_t attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; ++attributeIndex)
{
if(!linkedAttribute[attributeIndex].name.empty())
{
@@ -2143,7 +2143,7 @@
*type = uniforms[index]->type;
}
- GLint Program::getActiveUniformCount() const
+ size_t Program::getActiveUniformCount() const
{
return uniforms.size();
}
diff --git a/src/OpenGL/libGL/Program.h b/src/OpenGL/libGL/Program.h
index 01a469f..37eddcb 100644
--- a/src/OpenGL/libGL/Program.h
+++ b/src/OpenGL/libGL/Program.h
@@ -111,11 +111,11 @@
void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders);
void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const;
- GLint getActiveAttributeCount() const;
+ size_t getActiveAttributeCount() const;
GLint getActiveAttributeMaxLength() const;
void getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const;
- GLint getActiveUniformCount() const;
+ size_t getActiveUniformCount() const;
GLint getActiveUniformMaxLength() const;
void addRef();
diff --git a/src/OpenGL/libGL/libGL.cpp b/src/OpenGL/libGL/libGL.cpp
index 60c456f..c33294a 100644
--- a/src/OpenGL/libGL/libGL.cpp
+++ b/src/OpenGL/libGL/libGL.cpp
@@ -2251,7 +2251,7 @@
}
}
- if(index >= (GLuint)programObject->getActiveAttributeCount())
+ if(index >= programObject->getActiveAttributeCount())
{
return error(GL_INVALID_VALUE);
}
@@ -2289,7 +2289,7 @@
}
}
- if(index >= (GLuint)programObject->getActiveUniformCount())
+ if(index >= programObject->getActiveUniformCount())
{
return error(GL_INVALID_VALUE);
}
diff --git a/src/OpenGL/libGLESv2/Program.cpp b/src/OpenGL/libGLESv2/Program.cpp
index 451ea4d..50baf80 100644
--- a/src/OpenGL/libGLESv2/Program.cpp
+++ b/src/OpenGL/libGLESv2/Program.cpp
@@ -2431,7 +2431,7 @@
*type = linkedAttribute[attribute].type;
}
- GLint Program::getActiveAttributeCount() const
+ size_t Program::getActiveAttributeCount() const
{
int count = 0;
@@ -2486,7 +2486,7 @@
*type = uniforms[index]->type;
}
- GLint Program::getActiveUniformCount() const
+ size_t Program::getActiveUniformCount() const
{
return uniforms.size();
}
@@ -2559,7 +2559,7 @@
}
}
- GLint Program::getActiveUniformBlockCount() const
+ size_t Program::getActiveUniformBlockCount() const
{
return uniformBlocks.size();
}
diff --git a/src/OpenGL/libGLESv2/Program.h b/src/OpenGL/libGLESv2/Program.h
index 5a1284f..c05cc92 100644
--- a/src/OpenGL/libGLESv2/Program.h
+++ b/src/OpenGL/libGLESv2/Program.h
@@ -186,16 +186,16 @@
void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders);
void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const;
- GLint getActiveAttributeCount() const;
+ size_t getActiveAttributeCount() const;
GLint getActiveAttributeMaxLength() const;
void getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const;
- GLint getActiveUniformCount() const;
+ size_t getActiveUniformCount() const;
GLint getActiveUniformMaxLength() const;
GLint getActiveUniformi(GLuint index, GLenum pname) const;
void getActiveUniformBlockName(GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name) const;
- GLint getActiveUniformBlockCount() const;
+ size_t getActiveUniformBlockCount() const;
GLint getActiveUniformBlockMaxLength() const;
void setTransformFeedbackVaryings(GLsizei count, const GLchar *const *varyings, GLenum bufferMode);
diff --git a/src/OpenGL/libGLESv2/libGLESv2.cpp b/src/OpenGL/libGLESv2/libGLESv2.cpp
index 6507d9d..e7b1156 100644
--- a/src/OpenGL/libGLESv2/libGLESv2.cpp
+++ b/src/OpenGL/libGLESv2/libGLESv2.cpp
@@ -2589,7 +2589,7 @@
}
}
- if(index >= (GLuint)programObject->getActiveAttributeCount())
+ if(index >= programObject->getActiveAttributeCount())
{
return error(GL_INVALID_VALUE);
}
@@ -2627,7 +2627,7 @@
}
}
- if(index >= (GLuint)programObject->getActiveUniformCount())
+ if(index >= programObject->getActiveUniformCount())
{
return error(GL_INVALID_VALUE);
}
diff --git a/src/OpenGL/libGLESv2/libGLESv3.cpp b/src/OpenGL/libGLESv2/libGLESv3.cpp
index 5832bef..6a27d2b 100644
--- a/src/OpenGL/libGLESv2/libGLESv3.cpp
+++ b/src/OpenGL/libGLESv2/libGLESv3.cpp
@@ -2747,7 +2747,7 @@
{
const GLuint index = uniformIndices[uniformId];
- if(index >= static_cast<GLuint>(programObject->getActiveUniformCount()))
+ if(index >= programObject->getActiveUniformCount())
{
return error(GL_INVALID_VALUE);
}
diff --git a/src/Reactor/Nucleus.hpp b/src/Reactor/Nucleus.hpp
index 6f39e68..17bf1c0 100644
--- a/src/Reactor/Nucleus.hpp
+++ b/src/Reactor/Nucleus.hpp
@@ -2729,7 +2729,6 @@
template<class T>
Pointer<T>::Pointer(const void *external) : alignment((intptr_t)external & 0x0000000F ? 1 : 16)
{
- llvm::Module *module = Nucleus::getModule();
const llvm::GlobalValue *globalPointer = Nucleus::getGlobalValueAtAddress(const_cast<void*>(external)); // FIXME: Const
if(!globalPointer)
diff --git a/src/Renderer/Surface.cpp b/src/Renderer/Surface.cpp
index 9b48ebd..0d74fad 100644
--- a/src/Renderer/Surface.cpp
+++ b/src/Renderer/Surface.cpp
@@ -2469,13 +2469,9 @@
const bool entire = x0 == 0 && y0 == 0 && width == internal.width && height == internal.height;
const Lock lock = entire ? LOCK_DISCARD : LOCK_WRITEONLY;
- int width2 = (internal.width + 1) & ~1;
-
int x1 = x0 + width;
int y1 = y0 + height;
- int bytes = 4 * (x1 - x0);
-
// if(lockable || !quadLayoutEnabled)
{
unsigned char *buffer = (unsigned char*)lockInternal(x0, y0, 0, lock, PUBLIC);
@@ -2713,6 +2709,8 @@
}
/* else
{
+ int width2 = (internal.width + 1) & ~1;
+
// unsigned char *target = (unsigned char*&)buffer;
//
// for(int y = y0; y < y1; y++)
diff --git a/src/Shader/SamplerCore.cpp b/src/Shader/SamplerCore.cpp
index cee93c1..bc8a881 100644
--- a/src/Shader/SamplerCore.cpp
+++ b/src/Shader/SamplerCore.cpp
@@ -916,10 +916,10 @@
{
sampleTexel(c[i][j][k], u[i][j][k], v[i][j][k], s[i][j][k], mipmap, buffer);
- if(componentCount >= 1) if(hasUnsignedTextureComponent(0)) c[i][j][k].x = MulHigh(As<UShort4>(c[i][j][k].x), f[1 - i][1 - j][1 - k]); else c[i][j][k].x = MulHigh(c[i][j][k].x, fs[1 - i][1 - j][1 - k]);
- if(componentCount >= 2) if(hasUnsignedTextureComponent(1)) c[i][j][k].y = MulHigh(As<UShort4>(c[i][j][k].y), f[1 - i][1 - j][1 - k]); else c[i][j][k].y = MulHigh(c[i][j][k].y, fs[1 - i][1 - j][1 - k]);
- if(componentCount >= 3) if(hasUnsignedTextureComponent(2)) c[i][j][k].z = MulHigh(As<UShort4>(c[i][j][k].z), f[1 - i][1 - j][1 - k]); else c[i][j][k].z = MulHigh(c[i][j][k].z, fs[1 - i][1 - j][1 - k]);
- if(componentCount >= 4) if(hasUnsignedTextureComponent(3)) c[i][j][k].w = MulHigh(As<UShort4>(c[i][j][k].w), f[1 - i][1 - j][1 - k]); else c[i][j][k].w = MulHigh(c[i][j][k].w, fs[1 - i][1 - j][1 - k]);
+ if(componentCount >= 1) { if(hasUnsignedTextureComponent(0)) c[i][j][k].x = MulHigh(As<UShort4>(c[i][j][k].x), f[1 - i][1 - j][1 - k]); else c[i][j][k].x = MulHigh(c[i][j][k].x, fs[1 - i][1 - j][1 - k]); }
+ if(componentCount >= 2) { if(hasUnsignedTextureComponent(1)) c[i][j][k].y = MulHigh(As<UShort4>(c[i][j][k].y), f[1 - i][1 - j][1 - k]); else c[i][j][k].y = MulHigh(c[i][j][k].y, fs[1 - i][1 - j][1 - k]); }
+ if(componentCount >= 3) { if(hasUnsignedTextureComponent(2)) c[i][j][k].z = MulHigh(As<UShort4>(c[i][j][k].z), f[1 - i][1 - j][1 - k]); else c[i][j][k].z = MulHigh(c[i][j][k].z, fs[1 - i][1 - j][1 - k]); }
+ if(componentCount >= 4) { if(hasUnsignedTextureComponent(3)) c[i][j][k].w = MulHigh(As<UShort4>(c[i][j][k].w), f[1 - i][1 - j][1 - k]); else c[i][j][k].w = MulHigh(c[i][j][k].w, fs[1 - i][1 - j][1 - k]); }
if(i != 0 || j != 0 || k != 0)
{
diff --git a/src/Shader/Shader.hpp b/src/Shader/Shader.hpp
index d4fd609..8713040 100644
--- a/src/Shader/Shader.hpp
+++ b/src/Shader/Shader.hpp
@@ -367,7 +367,7 @@
};
};
- Parameter() : type(PARAMETER_VOID), index(0)
+ Parameter() : index(0), type(PARAMETER_VOID)
{
rel.type = PARAMETER_VOID;
rel.index = 0;
diff --git a/src/Shader/VertexProgram.cpp b/src/Shader/VertexProgram.cpp
index 5a516c4..d0c7715 100644
--- a/src/Shader/VertexProgram.cpp
+++ b/src/Shader/VertexProgram.cpp
@@ -104,9 +104,6 @@
Src src2 = instruction->src[2];
bool predicate = instruction->predicate;
- int size = shader->size(opcode);
- Usage usage = instruction->usage;
- unsigned char usageIndex = instruction->usageIndex;
Control control = instruction->control;
bool integer = dst.type == Shader::PARAMETER_ADDR;
bool pp = dst.partialPrecision;
@@ -540,7 +537,6 @@
for(int i = 0; i < 12; i++)
{
unsigned char usage = shader->output[i][0].usage;
- unsigned char index = shader->output[i][0].index;
switch(usage)
{
diff --git a/src/Shader/VertexRoutine.hpp b/src/Shader/VertexRoutine.hpp
index e023992..26663d7 100644
--- a/src/Shader/VertexRoutine.hpp
+++ b/src/Shader/VertexRoutine.hpp
@@ -25,8 +25,8 @@
struct Registers
{
Registers(const VertexShader *shader) :
- r(shader && shader->dynamicallyIndexedTemporaries),
v(shader && shader->dynamicallyIndexedInput),
+ r(shader && shader->dynamicallyIndexedTemporaries),
o(shader && shader->dynamicallyIndexedOutput)
{
loopDepth = -1;
diff --git a/src/Shader/VertexShader.cpp b/src/Shader/VertexShader.cpp
index 7bb7f0a..fab6b17 100644
--- a/src/Shader/VertexShader.cpp
+++ b/src/Shader/VertexShader.cpp
@@ -78,7 +78,6 @@
}
unsigned short version = (unsigned short)(token[0] & 0x0000FFFF);
- unsigned char minorVersion = (unsigned char)(token[0] & 0x000000FF);
unsigned char majorVersion = (unsigned char)((token[0] & 0x0000FF00) >> 8);
ShaderType shaderType = (ShaderType)((token[0] & 0xFFFF0000) >> 16);