Commit 1d672448 by Alexis Hetu Committed by Alexis Hétu

Fixed Windows warnings

- Removed unused variables - Removed unreachable code - Fixed size_t <-> int conversions - Fixed uninitialized variables Change-Id: Ifc3912e92b8f0710094e939bd0da4757148b559a Reviewed-on: https://swiftshader-review.googlesource.com/5681Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 46c1b917
...@@ -82,7 +82,7 @@ namespace sw ...@@ -82,7 +82,7 @@ namespace sw
surfaceDescription.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; surfaceDescription.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
surfaceDescription.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; surfaceDescription.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
surfaceDescription.dwBackBufferCount = 1; surfaceDescription.dwBackBufferCount = 1;
long result = directDraw->CreateSurface(&surfaceDescription, &frontBuffer, 0); directDraw->CreateSurface(&surfaceDescription, &frontBuffer, 0);
if(frontBuffer) if(frontBuffer)
{ {
...@@ -352,7 +352,6 @@ namespace sw ...@@ -352,7 +352,6 @@ namespace sw
{ {
int width = DDSD.dwWidth; int width = DDSD.dwWidth;
int height = DDSD.dwHeight; int height = DDSD.dwHeight;
int bitDepth = DDSD.ddpfPixelFormat.dwRGBBitCount;
int stride = DDSD.lPitch; int stride = DDSD.lPitch;
void *sourceBuffer = DDSD.lpSurface; void *sourceBuffer = DDSD.lpSurface;
...@@ -424,7 +423,6 @@ namespace sw ...@@ -424,7 +423,6 @@ namespace sw
{ {
width = DDSD.dwWidth; width = DDSD.dwWidth;
height = DDSD.dwHeight; height = DDSD.dwHeight;
int bitDepth = DDSD.ddpfPixelFormat.dwRGBBitCount;
stride = DDSD.lPitch; stride = DDSD.lPitch;
locked = DDSD.lpSurface; locked = DDSD.lpSurface;
......
...@@ -152,8 +152,6 @@ public: ...@@ -152,8 +152,6 @@ public:
default: default:
return false; return false;
} }
return false;
} }
bool operator!=(const int i) const bool operator!=(const int i) const
...@@ -194,8 +192,6 @@ public: ...@@ -194,8 +192,6 @@ public:
default: default:
return false; // Invalid operation, handled at semantic analysis return false; // Invalid operation, handled at semantic analysis
} }
return false;
} }
bool operator<(const ConstantUnion& constant) const bool operator<(const ConstantUnion& constant) const
...@@ -211,8 +207,6 @@ public: ...@@ -211,8 +207,6 @@ public:
default: default:
return false; // Invalid operation, handled at semantic analysis return false; // Invalid operation, handled at semantic analysis
} }
return false;
} }
bool operator<=(const ConstantUnion& constant) const bool operator<=(const ConstantUnion& constant) const
...@@ -228,8 +222,6 @@ public: ...@@ -228,8 +222,6 @@ public:
default: default:
return false; // Invalid operation, handled at semantic analysis return false; // Invalid operation, handled at semantic analysis
} }
return false;
} }
bool operator>=(const ConstantUnion& constant) const bool operator>=(const ConstantUnion& constant) const
...@@ -245,8 +237,6 @@ public: ...@@ -245,8 +237,6 @@ public:
default: default:
return false; // Invalid operation, handled at semantic analysis return false; // Invalid operation, handled at semantic analysis
} }
return false;
} }
ConstantUnion operator+(const ConstantUnion& constant) const ConstantUnion operator+(const ConstantUnion& constant) const
......
...@@ -542,13 +542,13 @@ bool Display::isValidWindow(EGLNativeWindowType window) ...@@ -542,13 +542,13 @@ bool Display::isValidWindow(EGLNativeWindowType window)
return status == True; return status == True;
} }
return false;
#elif defined(__APPLE__) #elif defined(__APPLE__)
return sw::OSX::IsValidWindow(window); return sw::OSX::IsValidWindow(window);
#else #else
#error "Display::isValidWindow unimplemented for this platform" #error "Display::isValidWindow unimplemented for this platform"
return false;
#endif #endif
return false;
} }
bool Display::hasExistingWindowSurface(EGLNativeWindowType window) bool Display::hasExistingWindowSurface(EGLNativeWindowType window)
......
...@@ -1043,17 +1043,15 @@ EGLDisplay GetPlatformDisplayEXT(EGLenum platform, void *native_display, const E ...@@ -1043,17 +1043,15 @@ EGLDisplay GetPlatformDisplayEXT(EGLenum platform, void *native_display, const E
{ {
TRACE("(EGLenum platform = 0x%X, void *native_display = %p, const EGLint *attrib_list = %p)", platform, native_display, attrib_list); TRACE("(EGLenum platform = 0x%X, void *native_display = %p, const EGLint *attrib_list = %p)", platform, native_display, attrib_list);
switch(platform)
{
#if defined(__linux__) && !defined(__ANDROID__) #if defined(__linux__) && !defined(__ANDROID__)
case EGL_PLATFORM_X11_EXT: break; switch(platform)
case EGL_PLATFORM_GBM_KHR: break; {
#endif case EGL_PLATFORM_X11_EXT: break;
default: case EGL_PLATFORM_GBM_KHR: break;
return error(EGL_BAD_PARAMETER, EGL_NO_DISPLAY); default:
} return error(EGL_BAD_PARAMETER, EGL_NO_DISPLAY);
}
#if defined(__linux__) && !defined(__ANDROID__)
if(platform == EGL_PLATFORM_X11_EXT) if(platform == EGL_PLATFORM_X11_EXT)
{ {
if(!libX11) if(!libX11)
...@@ -1075,9 +1073,11 @@ EGLDisplay GetPlatformDisplayEXT(EGLenum platform, void *native_display, const E ...@@ -1075,9 +1073,11 @@ EGLDisplay GetPlatformDisplayEXT(EGLenum platform, void *native_display, const E
return success(HEADLESS_DISPLAY); return success(HEADLESS_DISPLAY);
} }
#endif
return success(PRIMARY_DISPLAY); // We only support the default display return success(PRIMARY_DISPLAY); // We only support the default display
#else
return error(EGL_BAD_PARAMETER, EGL_NO_DISPLAY);
#endif
} }
EGLSurface CreatePlatformWindowSurfaceEXT(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list) EGLSurface CreatePlatformWindowSurfaceEXT(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list)
......
...@@ -125,7 +125,7 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLuint start, GLuint end, ...@@ -125,7 +125,7 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLuint start, GLuint end,
} }
else else
{ {
unsigned int streamOffset = 0; size_t streamOffset = 0;
int convertCount = count; int convertCount = count;
streamingBuffer->reserveSpace(convertCount * typeSize(type), type); streamingBuffer->reserveSpace(convertCount * typeSize(type), type);
...@@ -143,7 +143,7 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLuint start, GLuint end, ...@@ -143,7 +143,7 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLuint start, GLuint end,
computeRange(type, indices, count, &translated->minIndex, &translated->maxIndex); computeRange(type, indices, count, &translated->minIndex, &translated->maxIndex);
translated->indexBuffer = streamingBuffer->getResource(); translated->indexBuffer = streamingBuffer->getResource();
translated->indexOffset = streamOffset; translated->indexOffset = static_cast<unsigned int>(streamOffset);
} }
if(translated->minIndex < start || translated->maxIndex > end) if(translated->minIndex < start || translated->maxIndex > end)
...@@ -165,7 +165,7 @@ std::size_t IndexDataManager::typeSize(GLenum type) ...@@ -165,7 +165,7 @@ std::size_t IndexDataManager::typeSize(GLenum type)
} }
} }
StreamingIndexBuffer::StreamingIndexBuffer(unsigned int initialSize) : mIndexBuffer(NULL), mBufferSize(initialSize) StreamingIndexBuffer::StreamingIndexBuffer(size_t initialSize) : mIndexBuffer(NULL), mBufferSize(initialSize)
{ {
if(initialSize > 0) if(initialSize > 0)
{ {
...@@ -188,7 +188,7 @@ StreamingIndexBuffer::~StreamingIndexBuffer() ...@@ -188,7 +188,7 @@ StreamingIndexBuffer::~StreamingIndexBuffer()
} }
} }
void *StreamingIndexBuffer::map(unsigned int requiredSpace, unsigned int *offset) void *StreamingIndexBuffer::map(size_t requiredSpace, size_t *offset)
{ {
void *mapPtr = NULL; void *mapPtr = NULL;
...@@ -217,7 +217,7 @@ void StreamingIndexBuffer::unmap() ...@@ -217,7 +217,7 @@ void StreamingIndexBuffer::unmap()
} }
} }
void StreamingIndexBuffer::reserveSpace(unsigned int requiredSpace, GLenum type) void StreamingIndexBuffer::reserveSpace(size_t requiredSpace, GLenum type)
{ {
if(requiredSpace > mBufferSize) if(requiredSpace > mBufferSize)
{ {
......
...@@ -37,19 +37,19 @@ struct TranslatedIndexData ...@@ -37,19 +37,19 @@ struct TranslatedIndexData
class StreamingIndexBuffer class StreamingIndexBuffer
{ {
public: public:
StreamingIndexBuffer(unsigned int initialSize); StreamingIndexBuffer(size_t initialSize);
virtual ~StreamingIndexBuffer(); virtual ~StreamingIndexBuffer();
void *map(unsigned int requiredSpace, unsigned int *offset); void *map(size_t requiredSpace, size_t *offset);
void unmap(); void unmap();
void reserveSpace(unsigned int requiredSpace, GLenum type); void reserveSpace(size_t requiredSpace, GLenum type);
sw::Resource *getResource() const; sw::Resource *getResource() const;
private: private:
sw::Resource *mIndexBuffer; sw::Resource *mIndexBuffer;
unsigned int mBufferSize; size_t mBufferSize;
unsigned int mWritePosition; size_t mWritePosition;
}; };
class IndexDataManager class IndexDataManager
......
...@@ -776,7 +776,7 @@ namespace es2 ...@@ -776,7 +776,7 @@ namespace es2
return error(GL_INVALID_ENUM, false); return error(GL_INVALID_ENUM, false);
} }
if(internalformat != format) if((GLenum)internalformat != format)
{ {
if(clientVersion < 3) if(clientVersion < 3)
{ {
...@@ -993,7 +993,7 @@ namespace es2 ...@@ -993,7 +993,7 @@ namespace es2
#undef VALIDATE_INTERNALFORMAT #undef VALIDATE_INTERNALFORMAT
if(internalformat != format && !validSizedInternalformat) if((GLenum)internalformat != format && !validSizedInternalformat)
{ {
return error(GL_INVALID_OPERATION, false); return error(GL_INVALID_OPERATION, false);
} }
......
...@@ -51,7 +51,7 @@ namespace sw ...@@ -51,7 +51,7 @@ namespace sw
{ {
if(actualSize == 0) // Estimate size if(actualSize == 0) // Estimate size
{ {
int instructionCount = 0; size_t instructionCount = 0;
for(llvm::Function::const_iterator basicBlock = function->begin(); basicBlock != function->end(); basicBlock++) for(llvm::Function::const_iterator basicBlock = function->begin(); basicBlock != function->end(); basicBlock++)
{ {
instructionCount += basicBlock->size(); instructionCount += basicBlock->size();
......
...@@ -133,7 +133,7 @@ namespace sw ...@@ -133,7 +133,7 @@ namespace sw
#else #else
for(int j = 1; j < codeSize - 4; j++) for(int j = 1; j < codeSize - 4; j++)
{ {
unsigned char modRM_SIB = entry[j - 1]; // unsigned char modRM_SIB = entry[j - 1];
uint64_t address = *(uint64_t*)&entry[j]; uint64_t address = *(uint64_t*)&entry[j];
// if((modRM_SIB & 0x05) == 0x05 && (address % 4) == 0) // if((modRM_SIB & 0x05) == 0x05 && (address % 4) == 0)
......
...@@ -2577,8 +2577,6 @@ namespace sw ...@@ -2577,8 +2577,6 @@ namespace sw
default: default:
return bytes(format) * width * height * depth; return bytes(format) * width * height * depth;
} }
return 0;
} }
bool Surface::isStencil(Format format) bool Surface::isStencil(Format format)
...@@ -2834,8 +2832,6 @@ namespace sw ...@@ -2834,8 +2832,6 @@ namespace sw
default: default:
return false; return false;
} }
return false;
} }
bool Surface::isSRGBwritable(Format format) bool Surface::isSRGBwritable(Format format)
......
...@@ -191,7 +191,7 @@ namespace sw ...@@ -191,7 +191,7 @@ namespace sw
} }
} }
void VertexProcessor::setTransformFeedbackBuffer(int index, sw::Resource* buffer, int offset, unsigned int reg, unsigned int row, unsigned int col, size_t stride) void VertexProcessor::setTransformFeedbackBuffer(int index, sw::Resource* buffer, int offset, unsigned int reg, unsigned int row, unsigned int col, unsigned int stride)
{ {
transformFeedbackInfo[index].buffer = buffer; transformFeedbackInfo[index].buffer = buffer;
transformFeedbackInfo[index].offset = offset; transformFeedbackInfo[index].offset = offset;
......
...@@ -195,7 +195,7 @@ namespace sw ...@@ -195,7 +195,7 @@ namespace sw
void setUniformBuffer(int index, sw::Resource* uniformBuffer, int offset); void setUniformBuffer(int index, sw::Resource* uniformBuffer, int offset);
void lockUniformBuffers(byte** u, sw::Resource* uniformBuffers[]); void lockUniformBuffers(byte** u, sw::Resource* uniformBuffers[]);
void setTransformFeedbackBuffer(int index, sw::Resource* transformFeedbackBuffer, int offset, unsigned int reg, unsigned int row, unsigned int col, size_t stride); void setTransformFeedbackBuffer(int index, sw::Resource* transformFeedbackBuffer, int offset, unsigned int reg, unsigned int row, unsigned int col, unsigned int stride);
void lockTransformFeedbackBuffers(byte** t, unsigned int* v, unsigned int* r, unsigned int* c, unsigned int* s, sw::Resource* transformFeedbackBuffers[]); void lockTransformFeedbackBuffers(byte** t, unsigned int* v, unsigned int* r, unsigned int* c, unsigned int* s, sw::Resource* transformFeedbackBuffers[]);
// Transformations // Transformations
...@@ -308,11 +308,11 @@ namespace sw ...@@ -308,11 +308,11 @@ namespace sw
TransformFeedbackInfo(); TransformFeedbackInfo();
Resource* buffer; Resource* buffer;
int offset; unsigned int offset;
int reg; unsigned int reg;
int row; unsigned int row;
int col; unsigned int col;
size_t stride; unsigned int stride;
}; };
TransformFeedbackInfo transformFeedbackInfo[MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]; TransformFeedbackInfo transformFeedbackInfo[MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS];
......
...@@ -378,9 +378,9 @@ namespace sw ...@@ -378,9 +378,9 @@ namespace sw
void PixelPipeline::blendTexture(Vector4s &temp, Vector4s &texture, int stage) void PixelPipeline::blendTexture(Vector4s &temp, Vector4s &texture, int stage)
{ {
Vector4s *arg1; Vector4s *arg1 = nullptr;
Vector4s *arg2; Vector4s *arg2 = nullptr;
Vector4s *arg3; Vector4s *arg3 = nullptr;
Vector4s res; Vector4s res;
Vector4s constant; Vector4s constant;
......
...@@ -1457,7 +1457,7 @@ namespace sw ...@@ -1457,7 +1457,7 @@ namespace sw
usedSamplers |= 1 << i; usedSamplers |= 1 << i;
} }
const Shader::Instruction *Shader::getInstruction(unsigned int i) const const Shader::Instruction *Shader::getInstruction(size_t i) const
{ {
ASSERT(i < instruction.size()); ASSERT(i < instruction.size());
......
...@@ -552,7 +552,7 @@ namespace sw ...@@ -552,7 +552,7 @@ namespace sw
void append(Instruction *instruction); void append(Instruction *instruction);
void declareSampler(int i); void declareSampler(int i);
const Instruction *getInstruction(unsigned int i) const; const Instruction *getInstruction(size_t i) const;
int size(unsigned long opcode) const; int size(unsigned long opcode) const;
static int size(unsigned long opcode, unsigned short version); static int size(unsigned long opcode, unsigned short version);
......
...@@ -30,7 +30,7 @@ namespace sw ...@@ -30,7 +30,7 @@ namespace sw
for(int i = 0; i < MAX_VERTEX_INPUTS; i++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
input[i] = Semantic(-1, -1); input[i] = Semantic();
} }
if(vs) // Make a copy if(vs) // Make a copy
...@@ -62,7 +62,7 @@ namespace sw ...@@ -62,7 +62,7 @@ namespace sw
for(int i = 0; i < MAX_VERTEX_INPUTS; i++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
input[i] = Semantic(-1, -1); input[i] = Semantic();
} }
optimize(); optimize();
......
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