Commit 08e90f0c by Nicolas Capens Committed by Nicolas Capens

Fix C++11 compilation errors.

Don't rely on friend method injection, and avoid prefixing constants with strings. Change-Id: Ide6ab73d13ba3e3534e47323b21f6e5e3ea9d0ab Reviewed-on: https://swiftshader-review.googlesource.com/1462Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent ba0716cc
...@@ -90,7 +90,6 @@ ...@@ -90,7 +90,6 @@
<Add option="-Wall" /> <Add option="-Wall" />
<Add option="-fexceptions" /> <Add option="-fexceptions" />
<Add option="-fno-operator-names" /> <Add option="-fno-operator-names" />
<Add option="-ffriend-injection" />
<Add option="-msse2" /> <Add option="-msse2" />
<Add option="-D__STDC_LIMIT_MACROS" /> <Add option="-D__STDC_LIMIT_MACROS" />
<Add option="-D__STDC_CONSTANT_MACROS" /> <Add option="-D__STDC_CONSTANT_MACROS" />
......
...@@ -31,21 +31,21 @@ namespace es ...@@ -31,21 +31,21 @@ namespace es
#if defined(ANGLE_DISABLE_TRACE) #if defined(ANGLE_DISABLE_TRACE)
#define TRACE(message, ...) (void(0)) #define TRACE(message, ...) (void(0))
#else #else
#define TRACE(message, ...) es::trace("trace: %s(%d): "message"\n", __FUNCTION__, __LINE__, ##__VA_ARGS__) #define TRACE(message, ...) es::trace("trace: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
#endif #endif
// A macro to output a function call and its arguments to the debugging log, to denote an item in need of fixing. // A macro to output a function call and its arguments to the debugging log, to denote an item in need of fixing.
#if defined(ANGLE_DISABLE_TRACE) #if defined(ANGLE_DISABLE_TRACE)
#define FIXME(message, ...) (void(0)) #define FIXME(message, ...) (void(0))
#else #else
#define FIXME(message, ...) do {es::trace("fixme: %s(%d): "message"\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); assert(false);} while(false) #define FIXME(message, ...) do {es::trace("fixme: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); assert(false);} while(false)
#endif #endif
// A macro to output a function call and its arguments to the debugging log, in case of error. // A macro to output a function call and its arguments to the debugging log, in case of error.
#if defined(ANGLE_DISABLE_TRACE) #if defined(ANGLE_DISABLE_TRACE)
#define ERR(message, ...) (void(0)) #define ERR(message, ...) (void(0))
#else #else
#define ERR(message, ...) do {es::trace("err: %s(%d): "message"\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); assert(false);} while(false) #define ERR(message, ...) do {es::trace("err: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); assert(false);} while(false)
#endif #endif
// A macro asserting a condition and outputting failures to the debug log // A macro asserting a condition and outputting failures to the debug log
......
...@@ -205,7 +205,7 @@ const char *EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name) ...@@ -205,7 +205,7 @@ const char *EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name)
case EGL_VENDOR: case EGL_VENDOR:
return success("TransGaming Inc."); return success("TransGaming Inc.");
case EGL_VERSION: case EGL_VERSION:
return success("1.4 SwiftShader "VERSION_STRING); return success("1.4 SwiftShader " VERSION_STRING);
} }
return error(EGL_BAD_PARAMETER, (const char*)NULL); return error(EGL_BAD_PARAMETER, (const char*)NULL);
...@@ -789,7 +789,7 @@ EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLCon ...@@ -789,7 +789,7 @@ EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLCon
} }
} }
} }
egl::Display *display = static_cast<egl::Display*>(dpy); egl::Display *display = static_cast<egl::Display*>(dpy);
if(!validateConfig(display, config)) if(!validateConfig(display, config))
......
...@@ -106,7 +106,6 @@ ...@@ -106,7 +106,6 @@
<Add option="-Wall" /> <Add option="-Wall" />
<Add option="-fexceptions" /> <Add option="-fexceptions" />
<Add option="-fno-operator-names" /> <Add option="-fno-operator-names" />
<Add option="-ffriend-injection" />
<Add option="-msse2" /> <Add option="-msse2" />
<Add option="-D__STDC_LIMIT_MACROS" /> <Add option="-D__STDC_LIMIT_MACROS" />
<Add option="-D__STDC_CONSTANT_MACROS" /> <Add option="-D__STDC_CONSTANT_MACROS" />
...@@ -163,9 +162,7 @@ ...@@ -163,9 +162,7 @@
<Unit filename="../../Main/Register.hpp" /> <Unit filename="../../Main/Register.hpp" />
<Unit filename="../../Main/SwiftConfig.cpp" /> <Unit filename="../../Main/SwiftConfig.cpp" />
<Unit filename="../../Main/SwiftConfig.hpp" /> <Unit filename="../../Main/SwiftConfig.hpp" />
<Unit filename="../../Main/crc.c"> <Unit filename="../../Main/crc.cpp" />
<Option compilerVar="CC" />
</Unit>
<Unit filename="../../Main/crc.h" /> <Unit filename="../../Main/crc.h" />
<Unit filename="../../Main/serialcommon.h" /> <Unit filename="../../Main/serialcommon.h" />
<Unit filename="../../Main/serialvalid.cpp" /> <Unit filename="../../Main/serialvalid.cpp" />
......
...@@ -62,7 +62,7 @@ static bool validateSubImageParams(bool compressed, GLsizei width, GLsizei heigh ...@@ -62,7 +62,7 @@ static bool validateSubImageParams(bool compressed, GLsizei width, GLsizei heigh
if(compressed) if(compressed)
{ {
if((width % 4 != 0 && width != texture->getWidth(target, 0)) || if((width % 4 != 0 && width != texture->getWidth(target, 0)) ||
(height % 4 != 0 && height != texture->getHeight(target, 0))) (height % 4 != 0 && height != texture->getHeight(target, 0)))
{ {
return error(GL_INVALID_OPERATION, false); return error(GL_INVALID_OPERATION, false);
...@@ -203,10 +203,10 @@ void GL_APIENTRY glBeginQueryEXT(GLenum target, GLuint id) ...@@ -203,10 +203,10 @@ void GL_APIENTRY glBeginQueryEXT(GLenum target, GLuint id)
{ {
switch(target) switch(target)
{ {
case GL_ANY_SAMPLES_PASSED_EXT: case GL_ANY_SAMPLES_PASSED_EXT:
case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
break; break;
default: default:
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
...@@ -319,7 +319,7 @@ void GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer) ...@@ -319,7 +319,7 @@ void GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer)
{ {
context->bindReadFramebuffer(framebuffer); context->bindReadFramebuffer(framebuffer);
} }
if(target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) if(target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
{ {
context->bindDrawFramebuffer(framebuffer); context->bindDrawFramebuffer(framebuffer);
...@@ -862,10 +862,10 @@ void GL_APIENTRY glCompileShader(GLuint shader) ...@@ -862,10 +862,10 @@ void GL_APIENTRY glCompileShader(GLuint shader)
} }
} }
void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
GLint border, GLsizei imageSize, const GLvoid* data) GLint border, GLsizei imageSize, const GLvoid* data)
{ {
TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
"GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
target, level, internalformat, width, height, border, imageSize, data); target, level, internalformat, width, height, border, imageSize, data);
...@@ -1760,7 +1760,7 @@ void GL_APIENTRY glDetachShader(GLuint program, GLuint shader) ...@@ -1760,7 +1760,7 @@ void GL_APIENTRY glDetachShader(GLuint program, GLuint shader)
es2::Program *programObject = context->getProgram(program); es2::Program *programObject = context->getProgram(program);
es2::Shader *shaderObject = context->getShader(shader); es2::Shader *shaderObject = context->getShader(shader);
if(!programObject) if(!programObject)
{ {
es2::Shader *shaderByProgramHandle; es2::Shader *shaderByProgramHandle;
...@@ -1905,7 +1905,7 @@ void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const G ...@@ -1905,7 +1905,7 @@ void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const G
default: default:
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
context->drawElements(mode, count, type, indices); context->drawElements(mode, count, type, indices);
} }
} }
...@@ -1979,10 +1979,10 @@ void GL_APIENTRY glEndQueryEXT(GLenum target) ...@@ -1979,10 +1979,10 @@ void GL_APIENTRY glEndQueryEXT(GLenum target)
{ {
switch(target) switch(target)
{ {
case GL_ANY_SAMPLES_PASSED_EXT: case GL_ANY_SAMPLES_PASSED_EXT:
case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
break; break;
default: default:
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
...@@ -2862,7 +2862,7 @@ void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum att ...@@ -2862,7 +2862,7 @@ void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum att
framebuffer = context->getReadFramebuffer(); framebuffer = context->getReadFramebuffer();
} }
else else
{ {
if(context->getDrawFramebufferHandle() == 0) if(context->getDrawFramebufferHandle() == 0)
{ {
...@@ -2876,15 +2876,15 @@ void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum att ...@@ -2876,15 +2876,15 @@ void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum att
GLuint attachmentHandle; GLuint attachmentHandle;
switch(attachment) switch(attachment)
{ {
case GL_COLOR_ATTACHMENT0: case GL_COLOR_ATTACHMENT0:
attachmentType = framebuffer->getColorbufferType(); attachmentType = framebuffer->getColorbufferType();
attachmentHandle = framebuffer->getColorbufferHandle(); attachmentHandle = framebuffer->getColorbufferHandle();
break; break;
case GL_DEPTH_ATTACHMENT: case GL_DEPTH_ATTACHMENT:
attachmentType = framebuffer->getDepthbufferType(); attachmentType = framebuffer->getDepthbufferType();
attachmentHandle = framebuffer->getDepthbufferHandle(); attachmentHandle = framebuffer->getDepthbufferHandle();
break; break;
case GL_STENCIL_ATTACHMENT: case GL_STENCIL_ATTACHMENT:
attachmentType = framebuffer->getStencilbufferType(); attachmentType = framebuffer->getStencilbufferType();
attachmentHandle = framebuffer->getStencilbufferHandle(); attachmentHandle = framebuffer->getStencilbufferHandle();
break; break;
...@@ -3406,9 +3406,9 @@ const GLubyte* GL_APIENTRY glGetString(GLenum name) ...@@ -3406,9 +3406,9 @@ const GLubyte* GL_APIENTRY glGetString(GLenum name)
case GL_RENDERER: case GL_RENDERER:
return (GLubyte*)"SwiftShader"; return (GLubyte*)"SwiftShader";
case GL_VERSION: case GL_VERSION:
return (GLubyte*)"OpenGL ES 2.0 SwiftShader "VERSION_STRING; return (GLubyte*)"OpenGL ES 2.0 SwiftShader " VERSION_STRING;
case GL_SHADING_LANGUAGE_VERSION: case GL_SHADING_LANGUAGE_VERSION:
return (GLubyte*)"OpenGL ES GLSL ES 1.00 SwiftShader "VERSION_STRING; return (GLubyte*)"OpenGL ES GLSL ES 1.00 SwiftShader " VERSION_STRING;
case GL_EXTENSIONS: case GL_EXTENSIONS:
// Keep list sorted in following order: // Keep list sorted in following order:
// OES extensions // OES extensions
...@@ -3645,7 +3645,7 @@ void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params) ...@@ -3645,7 +3645,7 @@ void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params)
void GL_APIENTRY glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) void GL_APIENTRY glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
{ {
TRACE("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)", TRACE("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
program, location, bufSize, params); program, location, bufSize, params);
try try
...@@ -3921,7 +3921,7 @@ void GL_APIENTRY glHint(GLenum target, GLenum mode) ...@@ -3921,7 +3921,7 @@ void GL_APIENTRY glHint(GLenum target, GLenum mode)
case GL_DONT_CARE: case GL_DONT_CARE:
break; break;
default: default:
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
es2::Context *context = es2::getContext(); es2::Context *context = es2::getContext();
...@@ -4416,7 +4416,7 @@ void GL_APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei sa ...@@ -4416,7 +4416,7 @@ void GL_APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei sa
if(context) if(context)
{ {
if(width > es2::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE || if(width > es2::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE ||
height > es2::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE || height > es2::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE ||
samples > es2::IMPLEMENTATION_MAX_SAMPLES) samples > es2::IMPLEMENTATION_MAX_SAMPLES)
{ {
...@@ -4504,7 +4504,7 @@ void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition) ...@@ -4504,7 +4504,7 @@ void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition)
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
fenceObject->setFence(condition); fenceObject->setFence(condition);
} }
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
...@@ -4804,7 +4804,7 @@ GLboolean GL_APIENTRY glTestFenceNV(GLuint fence) ...@@ -4804,7 +4804,7 @@ GLboolean GL_APIENTRY glTestFenceNV(GLuint fence)
{ {
error(GL_OUT_OF_MEMORY); error(GL_OUT_OF_MEMORY);
} }
return GL_TRUE; return GL_TRUE;
} }
...@@ -4957,7 +4957,7 @@ void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, ...@@ -4957,7 +4957,7 @@ void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat,
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
} }
if(target == GL_TEXTURE_2D) if(target == GL_TEXTURE_2D)
{ {
es2::Texture2D *texture = context->getTexture2D(); es2::Texture2D *texture = context->getTexture2D();
...@@ -5194,7 +5194,7 @@ void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLin ...@@ -5194,7 +5194,7 @@ void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLin
else if(es2::IsCubemapTextureTarget(target)) else if(es2::IsCubemapTextureTarget(target))
{ {
es2::TextureCubeMap *texture = context->getTextureCubeMap(); es2::TextureCubeMap *texture = context->getTextureCubeMap();
if(validateSubImageParams(false, width, height, xoffset, yoffset, target, level, format, texture)) if(validateSubImageParams(false, width, height, xoffset, yoffset, target, level, format, texture))
{ {
texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels); texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
...@@ -5317,7 +5317,7 @@ void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v) ...@@ -5317,7 +5317,7 @@ void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
{ {
return error(GL_INVALID_VALUE); return error(GL_INVALID_VALUE);
} }
if(location == -1) if(location == -1)
{ {
return; return;
...@@ -6136,7 +6136,7 @@ void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image ...@@ -6136,7 +6136,7 @@ void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image
if(context) if(context)
{ {
es2::Texture2D *texture = 0; es2::Texture2D *texture = 0;
switch(target) switch(target)
{ {
case GL_TEXTURE_2D: texture = context->getTexture2D(); break; case GL_TEXTURE_2D: texture = context->getTexture2D(); break;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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