Fix signed/unsigned comparison warnings.

Bug 15387371

Change-Id: Id4c9b54c5c0b4115479b6710c4d8c91d34e5c002
Reviewed-on: https://swiftshader-review.googlesource.com/4494
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/compiler/OutputASM.cpp b/src/OpenGL/compiler/OutputASM.cpp
index 95069f0..8af200d 100644
--- a/src/OpenGL/compiler/OutputASM.cpp
+++ b/src/OpenGL/compiler/OutputASM.cpp
@@ -2320,7 +2320,7 @@
 		return sw::Shader::PARAMETER_VOID;

 	}

 

-	int OutputASM::registerIndex(TIntermTyped *operand)

+	unsigned int OutputASM::registerIndex(TIntermTyped *operand)

 	{

 		if(isSamplerRegister(operand))

 		{

diff --git a/src/OpenGL/compiler/OutputASM.h b/src/OpenGL/compiler/OutputASM.h
index 47bd4d1..4637f68 100644
--- a/src/OpenGL/compiler/OutputASM.h
+++ b/src/OpenGL/compiler/OutputASM.h
@@ -205,7 +205,7 @@
 		void assignLvalue(TIntermTyped *dst, TIntermTyped *src);

 		int lvalue(sw::Shader::DestinationParameter &dst, Temporary &address, TIntermTyped *node);

 		sw::Shader::ParameterType registerType(TIntermTyped *operand);

-		int registerIndex(TIntermTyped *operand);

+		unsigned int registerIndex(TIntermTyped *operand);

 		int writeMask(TIntermTyped *destination, int index = 0);

 		int readSwizzle(TIntermTyped *argument, int size);

 		bool trivial(TIntermTyped *expression, int budget);   // Fast to compute and no side effects

diff --git a/src/OpenGL/compiler/ParseHelper.cpp b/src/OpenGL/compiler/ParseHelper.cpp
index 2fa4512..522b13e 100644
--- a/src/OpenGL/compiler/ParseHelper.cpp
+++ b/src/OpenGL/compiler/ParseHelper.cpp
@@ -509,7 +509,7 @@
     if(type->isArray()) {
         if(type->getArraySize() == 0) {
             type->setArraySize(function.getParamCount());
-        } else if(type->getArraySize() != function.getParamCount()) {
+        } else if(type->getArraySize() != (int)function.getParamCount()) {
             error(line, "array constructor needs one argument per array element", "constructor");
             return true;
         }
@@ -532,7 +532,7 @@
         return true;
     }
 
-    if (op == EOpConstructStruct && !type->isArray() && int(type->getStruct()->fields().size()) != function.getParamCount()) {
+    if (op == EOpConstructStruct && !type->isArray() && type->getStruct()->fields().size() != function.getParamCount()) {
         error(line, "Number of constructor parameters does not match the number of structure fields", "constructor");
         return true;
     }
@@ -1763,47 +1763,47 @@
 	{
 		switch(publicType.type)
 		{
-		case EbtFloat:

-			if(publicType.isMatrix())

-			{

-				switch(publicType.getCols())

-				{

-				case 2:

-					switch(publicType.getRows())

-					{

-					case 2: op = EOpConstructMat2;  break;

-					case 3: op = EOpConstructMat2x3;  break;

-					case 4: op = EOpConstructMat2x4;  break;

-					}

-					break;

-				case 3:

-					switch(publicType.getRows())

-					{

-					case 2: op = EOpConstructMat3x2;  break;

-					case 3: op = EOpConstructMat3;  break;

-					case 4: op = EOpConstructMat3x4;  break;

-					}

-					break;

-				case 4:

-					switch(publicType.getRows())

-					{

-					case 2: op = EOpConstructMat4x2;  break;

-					case 3: op = EOpConstructMat4x3;  break;

-					case 4: op = EOpConstructMat4;  break;

-					}

-					break;

-				}

-			}

-			else

-			{

-				switch(publicType.getNominalSize())

-				{

-				case 1: op = EOpConstructFloat; break;

-				case 2: op = EOpConstructVec2;  break;

-				case 3: op = EOpConstructVec3;  break;

-				case 4: op = EOpConstructVec4;  break;

-				}

-			}

+		case EbtFloat:
+			if(publicType.isMatrix())
+			{
+				switch(publicType.getCols())
+				{
+				case 2:
+					switch(publicType.getRows())
+					{
+					case 2: op = EOpConstructMat2;  break;
+					case 3: op = EOpConstructMat2x3;  break;
+					case 4: op = EOpConstructMat2x4;  break;
+					}
+					break;
+				case 3:
+					switch(publicType.getRows())
+					{
+					case 2: op = EOpConstructMat3x2;  break;
+					case 3: op = EOpConstructMat3;  break;
+					case 4: op = EOpConstructMat3x4;  break;
+					}
+					break;
+				case 4:
+					switch(publicType.getRows())
+					{
+					case 2: op = EOpConstructMat4x2;  break;
+					case 3: op = EOpConstructMat4x3;  break;
+					case 4: op = EOpConstructMat4;  break;
+					}
+					break;
+				}
+			}
+			else
+			{
+				switch(publicType.getNominalSize())
+				{
+				case 1: op = EOpConstructFloat; break;
+				case 2: op = EOpConstructVec2;  break;
+				case 3: op = EOpConstructVec3;  break;
+				case 4: op = EOpConstructVec4;  break;
+				}
+			}
 			break;
 
 		case EbtInt:
diff --git a/src/OpenGL/libEGL/Config.cpp b/src/OpenGL/libEGL/Config.cpp
index 2ed3feb..337ac9b 100644
--- a/src/OpenGL/libEGL/Config.cpp
+++ b/src/OpenGL/libEGL/Config.cpp
@@ -357,41 +357,41 @@
 			{
 				switch(attribute[0])
 				{
-				case EGL_BUFFER_SIZE:                match = config->mBufferSize >= attribute[1];                      break;
-				case EGL_ALPHA_SIZE:                 match = config->mAlphaSize >= attribute[1];                       break;
-				case EGL_BLUE_SIZE:                  match = config->mBlueSize >= attribute[1];                        break;
-				case EGL_GREEN_SIZE:                 match = config->mGreenSize >= attribute[1];                       break;
-				case EGL_RED_SIZE:                   match = config->mRedSize >= attribute[1];                         break;
-				case EGL_DEPTH_SIZE:                 match = config->mDepthSize >= attribute[1];                       break;
-				case EGL_STENCIL_SIZE:               match = config->mStencilSize >= attribute[1];                     break;
-				case EGL_CONFIG_CAVEAT:              match = config->mConfigCaveat == attribute[1];                    break;
-				case EGL_CONFIG_ID:                  match = config->mConfigID == attribute[1];                        break;
-				case EGL_LEVEL:                      match = config->mLevel >= attribute[1];                           break;
-				case EGL_NATIVE_RENDERABLE:          match = config->mNativeRenderable == attribute[1];                break;
-				case EGL_NATIVE_VISUAL_ID:           match = config->mNativeVisualID == attribute[1];                  break;
-				case EGL_NATIVE_VISUAL_TYPE:         match = config->mNativeVisualType == attribute[1];                break;
-				case EGL_SAMPLES:                    match = config->mSamples >= attribute[1];                         break;
-				case EGL_SAMPLE_BUFFERS:             match = config->mSampleBuffers >= attribute[1];                   break;
-				case EGL_SURFACE_TYPE:               match = (config->mSurfaceType & attribute[1]) == attribute[1];    break;
-				case EGL_TRANSPARENT_TYPE:           match = config->mTransparentType == attribute[1];                 break;
-				case EGL_TRANSPARENT_BLUE_VALUE:     match = config->mTransparentBlueValue == attribute[1];            break;
-				case EGL_TRANSPARENT_GREEN_VALUE:    match = config->mTransparentGreenValue == attribute[1];           break;
-				case EGL_TRANSPARENT_RED_VALUE:      match = config->mTransparentRedValue == attribute[1];             break;
-				case EGL_BIND_TO_TEXTURE_RGB:        match = config->mBindToTextureRGB == attribute[1];                break;
-				case EGL_BIND_TO_TEXTURE_RGBA:       match = config->mBindToTextureRGBA == attribute[1];               break;
-				case EGL_MIN_SWAP_INTERVAL:          match = config->mMinSwapInterval == attribute[1];                 break;
-				case EGL_MAX_SWAP_INTERVAL:          match = config->mMaxSwapInterval == attribute[1];                 break;
-				case EGL_LUMINANCE_SIZE:             match = config->mLuminanceSize >= attribute[1];                   break;
-				case EGL_ALPHA_MASK_SIZE:            match = config->mAlphaMaskSize >= attribute[1];                   break;
-				case EGL_COLOR_BUFFER_TYPE:          match = config->mColorBufferType == attribute[1];                 break;
-				case EGL_RENDERABLE_TYPE:            match = (config->mRenderableType & attribute[1]) == attribute[1]; break;
-				case EGL_MATCH_NATIVE_PIXMAP:        match = false; UNIMPLEMENTED();                                   break;
-				case EGL_CONFORMANT:                 match = (config->mConformant & attribute[1]) == attribute[1];     break;
-				case EGL_MAX_PBUFFER_WIDTH:          match = config->mMaxPBufferWidth >= attribute[1];                 break;
-				case EGL_MAX_PBUFFER_HEIGHT:         match = config->mMaxPBufferHeight >= attribute[1];                break;
-				case EGL_MAX_PBUFFER_PIXELS:         match = config->mMaxPBufferPixels >= attribute[1];                break;
-				case EGL_RECORDABLE_ANDROID:         match = config->mRecordableAndroid == attribute[1];               break;
-				case EGL_FRAMEBUFFER_TARGET_ANDROID: match = config->mFramebufferTargetAndroid == attribute[1];        break;
+				case EGL_BUFFER_SIZE:                match = config->mBufferSize >= attribute[1];                           break;
+				case EGL_ALPHA_SIZE:                 match = config->mAlphaSize >= attribute[1];                            break;
+				case EGL_BLUE_SIZE:                  match = config->mBlueSize >= attribute[1];                             break;
+				case EGL_GREEN_SIZE:                 match = config->mGreenSize >= attribute[1];                            break;
+				case EGL_RED_SIZE:                   match = config->mRedSize >= attribute[1];                              break;
+				case EGL_DEPTH_SIZE:                 match = config->mDepthSize >= attribute[1];                            break;
+				case EGL_STENCIL_SIZE:               match = config->mStencilSize >= attribute[1];                          break;
+				case EGL_CONFIG_CAVEAT:              match = config->mConfigCaveat == (EGLenum)attribute[1];                break;
+				case EGL_CONFIG_ID:                  match = config->mConfigID == attribute[1];                             break;
+				case EGL_LEVEL:                      match = config->mLevel >= attribute[1];                                break;
+				case EGL_NATIVE_RENDERABLE:          match = config->mNativeRenderable == (EGLBoolean)attribute[1];         break;
+				case EGL_NATIVE_VISUAL_ID:           match = config->mNativeVisualID == attribute[1];                       break;
+				case EGL_NATIVE_VISUAL_TYPE:         match = config->mNativeVisualType == attribute[1];                     break;
+				case EGL_SAMPLES:                    match = config->mSamples >= attribute[1];                              break;
+				case EGL_SAMPLE_BUFFERS:             match = config->mSampleBuffers >= attribute[1];                        break;
+				case EGL_SURFACE_TYPE:               match = (config->mSurfaceType & attribute[1]) == attribute[1];         break;
+				case EGL_TRANSPARENT_TYPE:           match = config->mTransparentType == (EGLenum)attribute[1];             break;
+				case EGL_TRANSPARENT_BLUE_VALUE:     match = config->mTransparentBlueValue == attribute[1];                 break;
+				case EGL_TRANSPARENT_GREEN_VALUE:    match = config->mTransparentGreenValue == attribute[1];                break;
+				case EGL_TRANSPARENT_RED_VALUE:      match = config->mTransparentRedValue == attribute[1];                  break;
+				case EGL_BIND_TO_TEXTURE_RGB:        match = config->mBindToTextureRGB == (EGLBoolean)attribute[1];         break;
+				case EGL_BIND_TO_TEXTURE_RGBA:       match = config->mBindToTextureRGBA == (EGLBoolean)attribute[1];        break;
+				case EGL_MIN_SWAP_INTERVAL:          match = config->mMinSwapInterval == attribute[1];                      break;
+				case EGL_MAX_SWAP_INTERVAL:          match = config->mMaxSwapInterval == attribute[1];                      break;
+				case EGL_LUMINANCE_SIZE:             match = config->mLuminanceSize >= attribute[1];                        break;
+				case EGL_ALPHA_MASK_SIZE:            match = config->mAlphaMaskSize >= attribute[1];                        break;
+				case EGL_COLOR_BUFFER_TYPE:          match = config->mColorBufferType == (EGLenum)attribute[1];             break;
+				case EGL_RENDERABLE_TYPE:            match = (config->mRenderableType & attribute[1]) == attribute[1];      break;
+				case EGL_MATCH_NATIVE_PIXMAP:        match = false; UNIMPLEMENTED();                                        break;
+				case EGL_CONFORMANT:                 match = (config->mConformant & attribute[1]) == attribute[1];          break;
+				case EGL_MAX_PBUFFER_WIDTH:          match = config->mMaxPBufferWidth >= attribute[1];                      break;
+				case EGL_MAX_PBUFFER_HEIGHT:         match = config->mMaxPBufferHeight >= attribute[1];                     break;
+				case EGL_MAX_PBUFFER_PIXELS:         match = config->mMaxPBufferPixels >= attribute[1];                     break;
+				case EGL_RECORDABLE_ANDROID:         match = config->mRecordableAndroid == (EGLBoolean)attribute[1];        break;
+				case EGL_FRAMEBUFFER_TARGET_ANDROID: match = config->mFramebufferTargetAndroid == (EGLBoolean)attribute[1]; break;
 				default:
 					*numConfig = 0;
 					return false;
diff --git a/src/OpenGL/libEGL/Display.cpp b/src/OpenGL/libEGL/Display.cpp
index e311662..813cb3c 100644
--- a/src/OpenGL/libEGL/Display.cpp
+++ b/src/OpenGL/libEGL/Display.cpp
@@ -146,13 +146,13 @@
 	sw::Format currentDisplayFormat = getDisplayFormat();
     ConfigSet configSet;
 
-	for(int samplesIndex = 0; samplesIndex < sizeof(samples) / sizeof(int); samplesIndex++)
+	for(unsigned int samplesIndex = 0; samplesIndex < sizeof(samples) / sizeof(int); samplesIndex++)
     {
-		for(int formatIndex = 0; formatIndex < sizeof(renderTargetFormats) / sizeof(sw::Format); formatIndex++)
+		for(unsigned int formatIndex = 0; formatIndex < sizeof(renderTargetFormats) / sizeof(sw::Format); formatIndex++)
 		{
 			sw::Format renderTargetFormat = renderTargetFormats[formatIndex];
 
-			for(int depthStencilIndex = 0; depthStencilIndex < sizeof(depthStencilFormats) / sizeof(sw::Format); depthStencilIndex++)
+			for(unsigned int depthStencilIndex = 0; depthStencilIndex < sizeof(depthStencilFormats) / sizeof(sw::Format); depthStencilIndex++)
 			{
 				sw::Format depthStencilFormat = depthStencilFormats[depthStencilIndex];
 
diff --git a/src/OpenGL/libEGL/libEGL.cpp b/src/OpenGL/libEGL/libEGL.cpp
index 0f44287..a55f5ed 100644
--- a/src/OpenGL/libEGL/libEGL.cpp
+++ b/src/OpenGL/libEGL/libEGL.cpp
@@ -1162,7 +1162,7 @@
 		#undef EXTENSION

 	};

 

-	for(int ext = 0; ext < sizeof(eglExtensions) / sizeof(Extension); ext++)

+	for(unsigned int ext = 0; ext < sizeof(eglExtensions) / sizeof(Extension); ext++)

 	{

 		if(strcmp(procname, eglExtensions[ext].name) == 0)

 		{

diff --git a/src/OpenGL/libGL/VertexDataManager.cpp b/src/OpenGL/libGL/VertexDataManager.cpp
index afdf033..1110abd 100644
--- a/src/OpenGL/libGL/VertexDataManager.cpp
+++ b/src/OpenGL/libGL/VertexDataManager.cpp
@@ -61,20 +61,20 @@
     int elementSize = attribute.typeSize();

     unsigned int streamOffset = 0;

 

-    char *output = NULL;

+    char *output = nullptr;

     

     if(vertexBuffer)

     {

         output = (char*)vertexBuffer->map(attribute, attribute.typeSize() * count, &streamOffset);

     }

 

-    if(output == NULL)

+    if(!output)

     {

         ERR("Failed to map vertex buffer.");

-        return -1;

+        return UINT_MAX;

     }

 

-    const char *input = NULL;

+    const char *input = nullptr;

 

     if(buffer)

     {

@@ -163,7 +163,7 @@
                 {

                     unsigned int streamOffset = writeAttributeData(mStreamingBuffer, start, count, attribs[i]);

 

-					if(streamOffset == -1)

+					if(streamOffset == UINT_MAX)

 					{

 						return GL_OUT_OF_MEMORY;

 					}

diff --git a/src/OpenGL/libGL/libGL.cpp b/src/OpenGL/libGL/libGL.cpp
index 3d85c14..fa8d0aa 100644
--- a/src/OpenGL/libGL/libGL.cpp
+++ b/src/OpenGL/libGL/libGL.cpp
@@ -4241,7 +4241,7 @@
 		return error(GL_INVALID_VALUE);

 	}

 

-	if(internalformat != format)

+	if(internalformat != (GLint)format)

 	{

 		//TRACE("UNIMPLEMENTED!!");

 		//return error(GL_INVALID_OPERATION);

diff --git a/src/OpenGL/libGLES_CM/VertexDataManager.cpp b/src/OpenGL/libGLES_CM/VertexDataManager.cpp
index 55d145c..126c55a 100644
--- a/src/OpenGL/libGLES_CM/VertexDataManager.cpp
+++ b/src/OpenGL/libGLES_CM/VertexDataManager.cpp
@@ -62,20 +62,20 @@
     int elementSize = attribute.typeSize();

     unsigned int streamOffset = 0;

 

-    char *output = NULL;

+    char *output = nullptr;

     

     if(vertexBuffer)

     {

         output = (char*)vertexBuffer->map(attribute, attribute.typeSize() * count, &streamOffset);

     }

 

-    if(output == NULL)

+    if(!output)

     {

         ERR("Failed to map vertex buffer.");

-        return -1;

+        return UINT_MAX;

     }

 

-    const char *input = NULL;

+    const char *input = nullptr;

 

     if(buffer)

     {

@@ -158,7 +158,7 @@
             {

                 unsigned int streamOffset = writeAttributeData(mStreamingBuffer, start, count, attribs[i]);

 

-				if(streamOffset == -1)

+				if(streamOffset == UINT_MAX)

 				{

 					return GL_OUT_OF_MEMORY;

 				}

diff --git a/src/OpenGL/libGLES_CM/libGLES_CM.cpp b/src/OpenGL/libGLES_CM/libGLES_CM.cpp
index 4fadb91..d2b3c0b 100644
--- a/src/OpenGL/libGLES_CM/libGLES_CM.cpp
+++ b/src/OpenGL/libGLES_CM/libGLES_CM.cpp
@@ -4198,7 +4198,7 @@
 		return error(GL_INVALID_VALUE);

 	}

 

-	if(internalformat != format)

+	if(internalformat != (GLint)format)

 	{

 		return error(GL_INVALID_OPERATION);

 	}

@@ -4747,7 +4747,7 @@
 		#undef EXTENSION

 	};

 

-	for(int ext = 0; ext < sizeof(glExtensions) / sizeof(Extension); ext++)

+	for(unsigned int ext = 0; ext < sizeof(glExtensions) / sizeof(Extension); ext++)

 	{

 		if(strcmp(procname, glExtensions[ext].name) == 0)

 		{

diff --git a/src/OpenGL/libGLESv2/Context.cpp b/src/OpenGL/libGLESv2/Context.cpp
index a2414ed..f5b6256 100644
--- a/src/OpenGL/libGLESv2/Context.cpp
+++ b/src/OpenGL/libGLESv2/Context.cpp
@@ -4284,13 +4284,13 @@
 		if((extensionsCat == nullptr) && (numExtensions > 0))

 		{

 			int totalLength = numExtensions; // 1 space between each extension name + terminating null

-			for(int i = 0; i < numExtensions; ++i)

+			for(unsigned int i = 0; i < numExtensions; i++)

 			{

 				totalLength += strlen(reinterpret_cast<const char*>(extensions[i]));

 			}

 			extensionsCat = new GLubyte[totalLength];

 			extensionsCat[0] = '\0';

-			for(int i = 0; i < numExtensions; ++i)

+			for(unsigned int i = 0; i < numExtensions; i++)

 			{

 				if(i != 0)

 				{

diff --git a/src/OpenGL/libGLESv2/Program.cpp b/src/OpenGL/libGLESv2/Program.cpp
index 6d77cab..9e5a5a7 100644
--- a/src/OpenGL/libGLESv2/Program.cpp
+++ b/src/OpenGL/libGLESv2/Program.cpp
@@ -1444,7 +1444,7 @@
 		{

 			const glsl::Uniform &uniform = activeUniforms[uniformIndex];

 

-			int blockIndex = -1;

+			unsigned int blockIndex = GL_INVALID_INDEX;

 			bool isRowMajorMatrix = false;

 			if(uniform.blockId >= 0)

 			{

diff --git a/src/OpenGL/libGLESv2/VertexDataManager.cpp b/src/OpenGL/libGLESv2/VertexDataManager.cpp
index 173b176..f248f6e 100644
--- a/src/OpenGL/libGLESv2/VertexDataManager.cpp
+++ b/src/OpenGL/libGLESv2/VertexDataManager.cpp
@@ -61,20 +61,20 @@
     int elementSize = attribute.typeSize();

     unsigned int streamOffset = 0;

 

-    char *output = NULL;

+    char *output = nullptr;

     

     if(vertexBuffer)

     {

         output = (char*)vertexBuffer->map(attribute, attribute.typeSize() * count, &streamOffset);

     }

 

-    if(output == NULL)

+    if(!output)

     {

         ERR("Failed to map vertex buffer.");

-        return -1;

+        return UINT_MAX;

     }

 

-    const char *input = NULL;

+    const char *input = nullptr;

 

     if(buffer)

     {

@@ -171,7 +171,7 @@
                 {

                     unsigned int streamOffset = writeAttributeData(mStreamingBuffer, firstVertexIndex, isInstanced ? 1 : count, attrib);

 

-					if(streamOffset == -1)

+					if(streamOffset == UINT_MAX)

 					{

 						return GL_OUT_OF_MEMORY;

 					}

diff --git a/src/OpenGL/libGLESv2/libGLESv2.cpp b/src/OpenGL/libGLESv2/libGLESv2.cpp
index 106db2a..7ee66ab 100644
--- a/src/OpenGL/libGLESv2/libGLESv2.cpp
+++ b/src/OpenGL/libGLESv2/libGLESv2.cpp
@@ -5121,7 +5121,7 @@
 		GLint clientVersion = context->getClientVersion();

 		if(clientVersion < 3)

 		{

-			if(internalformat != format)

+			if(internalformat != (GLint)format)

 			{

 				return error(GL_INVALID_OPERATION);

 			}

@@ -7599,7 +7599,7 @@
 		#undef EXTENSION

 	};

 

-	for(int ext = 0; ext < sizeof(glExtensions) / sizeof(Extension); ext++)

+	for(unsigned int ext = 0; ext < sizeof(glExtensions) / sizeof(Extension); ext++)

 	{

 		if(strcmp(procname, glExtensions[ext].name) == 0)

 		{

diff --git a/src/Renderer/PixelProcessor.cpp b/src/Renderer/PixelProcessor.cpp
index ca26106..e2a4764 100644
--- a/src/Renderer/PixelProcessor.cpp
+++ b/src/Renderer/PixelProcessor.cpp
@@ -35,7 +35,7 @@
 		unsigned int *state = (unsigned int*)this;
 		unsigned int hash = 0;
 
-		for(int i = 0; i < sizeof(States) / 4; i++)
+		for(unsigned int i = 0; i < sizeof(States) / 4; i++)
 		{
 			hash ^= state[i];
 		}
diff --git a/src/Renderer/Renderer.cpp b/src/Renderer/Renderer.cpp
index 96a21f0..52589d2 100644
--- a/src/Renderer/Renderer.cpp
+++ b/src/Renderer/Renderer.cpp
@@ -221,7 +221,7 @@
 
 		for(int q = 0; q < ss; q++)
 		{
-			int oldMultiSampleMask = context->multiSampleMask;
+			unsigned int oldMultiSampleMask = context->multiSampleMask;
 			context->multiSampleMask = (context->sampleMask >> (ms * q)) & ((unsigned)0xFFFFFFFF >> (32 - ms));
 
 			if(!context->multiSampleMask)
diff --git a/src/Renderer/SetupProcessor.cpp b/src/Renderer/SetupProcessor.cpp
index 03d3485..34b11be 100644
--- a/src/Renderer/SetupProcessor.cpp
+++ b/src/Renderer/SetupProcessor.cpp
@@ -31,7 +31,7 @@
 		unsigned int *state = (unsigned int*)this;
 		unsigned int hash = 0;
 
-		for(int i = 0; i < sizeof(States) / 4; i++)
+		for(unsigned int i = 0; i < sizeof(States) / 4; i++)
 		{
 			hash ^= state[i];
 		}
diff --git a/src/Renderer/VertexProcessor.cpp b/src/Renderer/VertexProcessor.cpp
index d4b9a99..516fdc5 100644
--- a/src/Renderer/VertexProcessor.cpp
+++ b/src/Renderer/VertexProcessor.cpp
@@ -38,7 +38,7 @@
 		unsigned int *state = (unsigned int*)this;
 		unsigned int hash = 0;
 
-		for(int i = 0; i < sizeof(States) / 4; i++)
+		for(unsigned int i = 0; i < sizeof(States) / 4; i++)
 		{
 			hash ^= state[i];
 		}
diff --git a/src/Shader/PixelProgram.cpp b/src/Shader/PixelProgram.cpp
index f889cfa..bdf6b3e 100644
--- a/src/Shader/PixelProgram.cpp
+++ b/src/Shader/PixelProgram.cpp
@@ -1,30 +1,30 @@
-// SwiftShader Software Renderer

-//

-// Copyright(c) 2015 Google Inc.

-//

-// All rights reserved. No part of this software may be copied, distributed, transmitted,

-// transcribed, stored in a retrieval system, translated into any human or computer

-// language by any means, or disclosed to third parties without the explicit written

-// agreement of Google Inc. Without such an agreement, no rights or licenses, express

-// or implied, including but not limited to any patent rights, are granted to you.

-//

-

-#include "PixelProgram.hpp"

-#include "Primitive.hpp"

-#include "Renderer.hpp"

-#include "SamplerCore.hpp"

-

-namespace sw

-{

-	extern bool postBlendSRGB;

+// SwiftShader Software Renderer
+//
+// Copyright(c) 2015 Google Inc.
+//
+// All rights reserved. No part of this software may be copied, distributed, transmitted,
+// transcribed, stored in a retrieval system, translated into any human or computer
+// language by any means, or disclosed to third parties without the explicit written
+// agreement of Google Inc. Without such an agreement, no rights or licenses, express
+// or implied, including but not limited to any patent rights, are granted to you.
+//
+
+#include "PixelProgram.hpp"
+#include "Primitive.hpp"
+#include "Renderer.hpp"
+#include "SamplerCore.hpp"
+
+namespace sw
+{
+	extern bool postBlendSRGB;
 	extern bool booleanFaceRegister;
 	extern bool halfIntegerCoordinates;     // Pixel centers are not at integer coordinates
-	extern bool fullPixelPositionRegister;

-

-	void PixelProgram::setBuiltins(PixelRoutine::Registers &rBase, Int &x, Int &y, Float4(&z)[4], Float4 &w)

-	{

-		Registers& r = *static_cast<Registers*>(&rBase);

-

+	extern bool fullPixelPositionRegister;
+
+	void PixelProgram::setBuiltins(PixelRoutine::Registers &rBase, Int &x, Int &y, Float4(&z)[4], Float4 &w)
+	{
+		Registers& r = *static_cast<Registers*>(&rBase);
+
 		if(shader->getVersion() >= 0x0300)
 		{
 			if(shader->vPosDeclared)
@@ -57,11 +57,11 @@
 				r.vFace.z = face;
 				r.vFace.w = face;
 			}
-		}

-	}

-

+		}
+	}
+
 	void PixelProgram::applyShader(PixelRoutine::Registers &rBase, Int cMask[4])
-	{

+	{
 		Registers& r = *static_cast<Registers*>(&rBase);
 
 		r.enableIndex = 0;
@@ -513,13 +513,13 @@
 			r.c[i] = r.oC[i];
 		}
 	}
-

-	Bool PixelProgram::alphaTest(PixelRoutine::Registers &rBase, Int cMask[4])

-	{

-		Registers& r = *static_cast<Registers*>(&rBase);

-

+
+	Bool PixelProgram::alphaTest(PixelRoutine::Registers &rBase, Int cMask[4])
+	{
+		Registers& r = *static_cast<Registers*>(&rBase);
+
 		clampColor(r.c);
-

+
 		if(!state.alphaTestActive())
 		{
 			return true;
@@ -551,19 +551,19 @@
 			pass = pass | cMask[q];
 		}
 
-		return pass != 0x0;

-	}

-

-	void PixelProgram::rasterOperation(PixelRoutine::Registers &rBase, Float4 &fog, Pointer<Byte> cBuffer[4], Int &x, Int sMask[4], Int zMask[4], Int cMask[4])

-	{

-		Registers& r = *static_cast<Registers*>(&rBase);

-

+		return pass != 0x0;
+	}
+
+	void PixelProgram::rasterOperation(PixelRoutine::Registers &rBase, Float4 &fog, Pointer<Byte> cBuffer[4], Int &x, Int sMask[4], Int zMask[4], Int cMask[4])
+	{
+		Registers& r = *static_cast<Registers*>(&rBase);
+
 		for(int index = 0; index < RENDERTARGETS; index++)
 		{
 			if(!state.colorWriteActive(index))
 			{
 				continue;
-			}

+			}
 
 			if(!postBlendSRGB && state.writeSRGB)
 			{
@@ -739,10 +739,10 @@
 		return enable;
 	}
 
-	Vector4f PixelProgram::fetchRegisterF(Registers &r, const Src &src, int offset)
+	Vector4f PixelProgram::fetchRegisterF(Registers &r, const Src &src, unsigned int offset)
 	{
 		Vector4f reg;
-		int i = src.index + offset;
+		unsigned int i = src.index + offset;
 
 		switch(src.type)
 		{
@@ -874,11 +874,10 @@
 		return mod;
 	}
 
-	Vector4f PixelProgram::readConstant(Registers &r, const Src &src, int offset)
+	Vector4f PixelProgram::readConstant(Registers &r, const Src &src, unsigned int offset)
 	{
 		Vector4f c;
-
-		int i = src.index + offset;
+		unsigned int i = src.index + offset;
 
 		if(src.rel.type == Shader::PARAMETER_VOID)   // Not relative
 		{
@@ -1673,5 +1672,4 @@
 		// FIXME: Return from function if all instances left
 		// FIXME: Use enableLeave in other control-flow constructs
 	}
-

-}

+}
diff --git a/src/Shader/PixelProgram.hpp b/src/Shader/PixelProgram.hpp
index 41b9c4a..847b379 100644
--- a/src/Shader/PixelProgram.hpp
+++ b/src/Shader/PixelProgram.hpp
@@ -93,8 +93,8 @@
 

 		Int4 enableMask(Registers &r, const Shader::Instruction *instruction);

 

-		Vector4f fetchRegisterF(Registers &r, const Src &src, int offset = 0);

-		Vector4f readConstant(Registers &r, const Src &src, int offset = 0);

+		Vector4f fetchRegisterF(Registers &r, const Src &src, unsigned int offset = 0);

+		Vector4f readConstant(Registers &r, const Src &src, unsigned int offset = 0);

 		Int relativeAddress(Registers &r, const Shader::Parameter &var);
 
 		Float4 linearToSRGB(const Float4 &x);
diff --git a/src/Shader/Shader.cpp b/src/Shader/Shader.cpp
index a0ece65..442e692 100644
--- a/src/Shader/Shader.cpp
+++ b/src/Shader/Shader.cpp
@@ -1734,7 +1734,7 @@
 		}
 	}
 
-	void Shader::markFunctionAnalysis(int functionLabel, Analysis flag)
+	void Shader::markFunctionAnalysis(unsigned int functionLabel, Analysis flag)
 	{
 		bool marker = false;
 		for(unsigned int i = 0; i < instruction.size(); i++)
diff --git a/src/Shader/Shader.hpp b/src/Shader/Shader.hpp
index 588f637..6a57ec5 100644
--- a/src/Shader/Shader.hpp
+++ b/src/Shader/Shader.hpp
@@ -609,7 +609,7 @@
 		void analyzeSamplers();

 		void analyzeCallSites();

 		void analyzeDynamicIndexing();

-		void markFunctionAnalysis(int functionLabel, Analysis flag);

+		void markFunctionAnalysis(unsigned int functionLabel, Analysis flag);

 

 		ShaderType shaderType;

 

diff --git a/src/Shader/VertexProgram.cpp b/src/Shader/VertexProgram.cpp
index 40c0910..e4587cc 100644
--- a/src/Shader/VertexProgram.cpp
+++ b/src/Shader/VertexProgram.cpp
@@ -646,11 +646,10 @@
 		}
 	}
 
-	Vector4f VertexProgram::fetchRegisterF(Registers &r, const Src &src, int offset)
+	Vector4f VertexProgram::fetchRegisterF(Registers &r, const Src &src, unsigned int offset)
 	{
-		int i = src.index + offset;
-
 		Vector4f reg;
+		unsigned int i = src.index + offset;
 
 		switch(src.type)
 		{
@@ -762,11 +761,10 @@
 		return mod;
 	}
 
-	Vector4f VertexProgram::readConstant(Registers &r, const Src &src, int offset)
+	Vector4f VertexProgram::readConstant(Registers &r, const Src &src, unsigned int offset)
 	{
 		Vector4f c;
-
-		int i = src.index + offset;
+		unsigned int i = src.index + offset;
 
 		if(src.rel.type == Shader::PARAMETER_VOID)   // Not relative
 		{
diff --git a/src/Shader/VertexProgram.hpp b/src/Shader/VertexProgram.hpp
index 53427a5..519ee23 100644
--- a/src/Shader/VertexProgram.hpp
+++ b/src/Shader/VertexProgram.hpp
@@ -41,8 +41,8 @@
 		void program(Registers &r);
 		void passThrough(Registers &r);
 
-		Vector4f fetchRegisterF(Registers &r, const Src &src, int offset = 0);
-		Vector4f readConstant(Registers &r, const Src &src, int offset = 0);
+		Vector4f fetchRegisterF(Registers &r, const Src &src, unsigned int offset = 0);
+		Vector4f readConstant(Registers &r, const Src &src, unsigned int offset = 0);
 		Int relativeAddress(Registers &r, const Shader::Parameter &var);
 		Int4 enableMask(Registers &r, const Shader::Instruction *instruction);