Commit 05c32b9b by Alexis Hetu Committed by Alexis Hétu

Fixed more windows warnings

- Fixed uninitialized variables in default cases - Fixed truncation of values to float with static_cast Change-Id: I81f3a243e66eaeb24cd92646c6ef1ca6cb0de9ce Reviewed-on: https://swiftshader-review.googlesource.com/5682Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 183949cd
......@@ -72,12 +72,12 @@ Context::Context(egl::Display *display, const Context *shareContext, EGLint clie
mState.stencilTestEnabled = false;
mState.stencilFunc = GL_ALWAYS;
mState.stencilRef = 0;
mState.stencilMask = -1;
mState.stencilWritemask = -1;
mState.stencilMask = 0xFFFFFFFFu;
mState.stencilWritemask = 0xFFFFFFFFu;
mState.stencilBackFunc = GL_ALWAYS;
mState.stencilBackRef = 0;
mState.stencilBackMask = - 1;
mState.stencilBackWritemask = -1;
mState.stencilBackMask = 0xFFFFFFFFu;
mState.stencilBackWritemask = 0xFFFFFFFFu;
mState.stencilFail = GL_KEEP;
mState.stencilPassDepthFail = GL_KEEP;
mState.stencilPassDepthPass = GL_KEEP;
......@@ -1352,7 +1352,8 @@ void Context::beginQuery(GLenum target, GLuint query)
qType = QUERY_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN;
break;
default:
ASSERT(false);
UNREACHABLE(target);
return error(GL_INVALID_ENUM);
}
Query *queryObject = createQuery(query, target);
......@@ -2278,7 +2279,7 @@ template<typename T> bool Context::getIntegerv(GLenum pname, T *params) const
case GL_UNIFORM_BUFFER_SIZE: // indexed[n] 64-bit integer, initially 0
if(clientVersion >= 3)
{
*params = mState.genericUniformBuffer->size();
*params = static_cast<T>(mState.genericUniformBuffer->size());
}
else
{
......
......@@ -268,7 +268,7 @@ namespace es2
}
}
GLuint Program::getAttributeLocation(const char *name)
GLint Program::getAttributeLocation(const char *name)
{
if(name)
{
......@@ -294,7 +294,7 @@ namespace es2
// Returns the index of the texture image unit (0-19) corresponding to a sampler index (0-15 for the pixel shader and 0-3 for the vertex shader)
GLint Program::getSamplerMapping(sw::SamplerType type, unsigned int samplerIndex)
{
GLuint logicalTextureUnit = -1;
GLint logicalTextureUnit = -1;
switch(type)
{
......@@ -346,7 +346,7 @@ namespace es2
GLint Program::getUniformLocation(const std::string &name) const
{
size_t subscript = GL_INVALID_INDEX;
int subscript = GL_INVALID_INDEX;
std::string baseName = es2::ParseUniformName(name, &subscript);
size_t numUniforms = uniformIndex.size();
......@@ -368,7 +368,7 @@ namespace es2
GLuint Program::getUniformIndex(const std::string &name) const
{
size_t subscript = GL_INVALID_INDEX;
int subscript = GL_INVALID_INDEX;
std::string baseName = es2::ParseUniformName(name, &subscript);
// The app is not allowed to specify array indices other than 0 for arrays of basic types
......@@ -429,7 +429,7 @@ namespace es2
GLuint Program::getUniformBlockIndex(const std::string &name) const
{
size_t subscript = GL_INVALID_INDEX;
int subscript = GL_INVALID_INDEX;
std::string baseName = es2::ParseUniformName(name, &subscript);
size_t numUniformBlocks = getActiveUniformBlockCount();
......@@ -1065,7 +1065,7 @@ namespace es2
// Applies all the uniforms set for this program object to the device
void Program::applyUniforms()
{
GLint numUniforms = uniformIndex.size();
GLint numUniforms = static_cast<GLint>(uniformIndex.size());
for(GLint location = 0; location < numUniforms; location++)
{
if(uniformIndex[location].element != 0)
......@@ -1202,7 +1202,7 @@ namespace es2
return;
}
unsigned int maxVaryings = transformFeedbackLinkedVaryings.size();
unsigned int maxVaryings = static_cast<unsigned int>(transformFeedbackLinkedVaryings.size());
switch(transformFeedbackBufferMode)
{
case GL_SEPARATE_ATTRIBS:
......@@ -1234,10 +1234,10 @@ namespace es2
// written by a vertex shader are written, interleaved, into the buffer object
// bound to the first transform feedback binding point (index = 0).
sw::Resource* resource = transformFeedbackBuffers[0].get()->getResource();
int componentStride = totalLinkedVaryingsComponents;
int componentStride = static_cast<int>(totalLinkedVaryingsComponents);
int baseOffset = transformFeedbackBuffers[0].getOffset() + (transformFeedback->vertexOffset() * componentStride * sizeof(float));
maxVaryings = sw::min(maxVaryings, (unsigned int)sw::MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS);
size_t totalComponents = 0;
int totalComponents = 0;
for(unsigned int index = 0; index < maxVaryings; ++index)
{
int size = transformFeedbackLinkedVaryings[index].size;
......@@ -1366,7 +1366,7 @@ namespace es2
for(const std::string &indexedTfVaryingName : transformFeedbackVaryings)
{
size_t subscript = GL_INVALID_INDEX;
int subscript = GL_INVALID_INDEX;
std::string tfVaryingName = es2::ParseUniformName(indexedTfVaryingName, &subscript);
bool hasSubscript = (subscript != GL_INVALID_INDEX);
......@@ -1394,11 +1394,11 @@ namespace es2
return false;
}
size_t size = hasSubscript ? 1 : varying.size();
int size = hasSubscript ? 1 : varying.size();
size_t rowCount = VariableRowCount(varying.type);
size_t colCount = VariableColumnCount(varying.type);
size_t componentCount = rowCount * colCount * size;
int rowCount = VariableRowCount(varying.type);
int colCount = VariableColumnCount(varying.type);
int componentCount = rowCount * colCount * size;
if(transformFeedbackBufferMode == GL_SEPARATE_ATTRIBS &&
componentCount > sw::MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS)
{
......@@ -1752,7 +1752,7 @@ namespace es2
if(location == -1) // Not previously defined
{
uniforms.push_back(uniform);
size_t index = uniforms.size() - 1;
unsigned int index = static_cast<unsigned int>(uniforms.size() - 1);
for(int i = 0; i < uniform->size(); i++)
{
......@@ -2593,7 +2593,7 @@ namespace es2
if(length)
{
*length = strlen(name);
*length = static_cast<GLsizei>(strlen(name));
}
}
......@@ -2648,7 +2648,7 @@ namespace es2
if(length)
{
*length = strlen(name);
*length = static_cast<GLsizei>(strlen(name));
}
}
......@@ -2725,7 +2725,7 @@ namespace es2
if(length)
{
*length = strlen(name);
*length = static_cast<GLsizei>(strlen(name));
}
}
}
......@@ -2737,7 +2737,7 @@ namespace es2
GLint Program::getActiveUniformBlockMaxLength() const
{
size_t maxLength = 0;
GLint maxLength = 0;
if(isLinked())
{
......@@ -2747,10 +2747,10 @@ namespace es2
const UniformBlock &uniformBlock = *uniformBlocks[uniformBlockIndex];
if(!uniformBlock.name.empty())
{
size_t length = uniformBlock.name.length() + 1;
GLint length = static_cast<GLint>(uniformBlock.name.length() + 1);
// Counting in "[0]".
const int arrayLength = (uniformBlock.isArrayElement() ? 3 : 0);
const GLint arrayLength = (uniformBlock.isArrayElement() ? 3 : 0);
maxLength = std::max(length + arrayLength, maxLength);
}
......
......@@ -132,7 +132,7 @@ namespace es2
sw::VertexShader *getVertexShader();
void bindAttributeLocation(GLuint index, const char *name);
GLuint getAttributeLocation(const char *name);
GLint getAttributeLocation(const char *name);
int getAttributeStream(int attributeIndex);
GLint getSamplerMapping(sw::SamplerType type, unsigned int samplerIndex);
......
......@@ -1180,7 +1180,7 @@ namespace es2
return false;
}
std::string ParseUniformName(const std::string &name, size_t *outSubscript)
std::string ParseUniformName(const std::string &name, int *outSubscript)
{
// Strip any trailing array operator and retrieve the subscript
size_t open = name.find_last_of('[');
......
......@@ -60,7 +60,7 @@ namespace es2
// Parse the base uniform name and array index. Returns the base name of the uniform. outSubscript is
// set to GL_INVALID_INDEX if the provided name is not an array or the array index is invalid.
std::string ParseUniformName(const std::string &name, size_t *outSubscript);
std::string ParseUniformName(const std::string &name, int *outSubscript);
}
namespace es2sw
......
......@@ -989,7 +989,7 @@ namespace sw
scale = vector(0xFFFFFF, 0.0f, 0.0f, 0.0f);
break;
case FORMAT_D32:
scale = vector(0xFFFFFFFF, 0.0f, 0.0f, 0.0f);
scale = vector(static_cast<float>(0xFFFFFFFF), 0.0f, 0.0f, 0.0f);
break;
case FORMAT_D32F:
case FORMAT_D32F_COMPLEMENTARY:
......@@ -1017,10 +1017,10 @@ namespace sw
switch(state.sourceFormat)
{
case FORMAT_A32B32G32R32I:
unscale = vector(0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF);
unscale = replicate(static_cast<float>(0x7FFFFFFF));
break;
case FORMAT_A32B32G32R32UI:
unscale = vector(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
unscale = replicate(static_cast<float>(0xFFFFFFFF));
break;
default:
return false;
......
......@@ -264,7 +264,9 @@ namespace sw
setupPrimitives = &Renderer::setupVertexTriangle;
batch = 1;
break;
default: ASSERT(false);
default:
ASSERT(false);
return;
}
}
else if(context->isDrawLine())
......
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