Minor bug fixes and cleanup
- Removed unused variables
- Fixed member initialization order in a few classes
- Fixed Surface::setSwapBehavior()
- Removed unused mPixelPackingStateDirty members
- Fixed initialization of "size" member in LinkedVarying class
- Fixed constness of a string
- Removed unused static functions
- Added parenthesis to fix && / || order ambiguity
Change-Id: Ia9ad8eaca335c60871fdc58037e441aa2010a641
Reviewed-on: https://swiftshader-review.googlesource.com/4301
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Main/FrameBufferX11.cpp b/src/Main/FrameBufferX11.cpp
index d4286f1..245805f 100644
--- a/src/Main/FrameBufferX11.cpp
+++ b/src/Main/FrameBufferX11.cpp
@@ -41,7 +41,7 @@
}
}
- FrameBufferX11::FrameBufferX11(Display *display, Window window, int width, int height) : FrameBuffer(width, height, false, false), x_window(window), x_display(display), ownX11(!display)
+ FrameBufferX11::FrameBufferX11(Display *display, Window window, int width, int height) : FrameBuffer(width, height, false, false), ownX11(!display), x_display(display), x_window(window)
{
if(!x_display)
{
diff --git a/src/OpenGL/libEGL/Surface.cpp b/src/OpenGL/libEGL/Surface.cpp
index f85c42d..c4dfeeb 100644
--- a/src/OpenGL/libEGL/Surface.cpp
+++ b/src/OpenGL/libEGL/Surface.cpp
@@ -144,7 +144,7 @@
void Surface::setSwapBehavior(EGLenum swapBehavior)
{
- swapBehavior = swapBehavior;
+ this->swapBehavior = swapBehavior;
}
void Surface::setSwapInterval(EGLint interval)
diff --git a/src/OpenGL/libGLES_CM/Context.h b/src/OpenGL/libGLES_CM/Context.h
index fc15144..b41ecb4 100644
--- a/src/OpenGL/libGLES_CM/Context.h
+++ b/src/OpenGL/libGLES_CM/Context.h
@@ -624,7 +624,6 @@
// state caching flags
bool mDepthStateDirty;
bool mMaskStateDirty;
- bool mPixelPackingStateDirty;
bool mBlendStateDirty;
bool mStencilStateDirty;
bool mPolygonOffsetStateDirty;
diff --git a/src/OpenGL/libGLESv2/Context.h b/src/OpenGL/libGLESv2/Context.h
index 59d8263..9defd50 100644
--- a/src/OpenGL/libGLESv2/Context.h
+++ b/src/OpenGL/libGLESv2/Context.h
@@ -747,7 +747,6 @@
// state caching flags
bool mDepthStateDirty;
bool mMaskStateDirty;
- bool mPixelPackingStateDirty;
bool mBlendStateDirty;
bool mStencilStateDirty;
bool mPolygonOffsetStateDirty;
diff --git a/src/OpenGL/libGLESv2/IndexDataManager.cpp b/src/OpenGL/libGLESv2/IndexDataManager.cpp
index f7ac6fd..3f45936 100644
--- a/src/OpenGL/libGLESv2/IndexDataManager.cpp
+++ b/src/OpenGL/libGLESv2/IndexDataManager.cpp
@@ -162,7 +162,7 @@
}
}
-StreamingIndexBuffer::StreamingIndexBuffer(unsigned int initialSize) : mBufferSize(initialSize), mIndexBuffer(NULL)
+StreamingIndexBuffer::StreamingIndexBuffer(unsigned int initialSize) : mIndexBuffer(NULL), mBufferSize(initialSize)
{
if(initialSize > 0)
{
diff --git a/src/OpenGL/libGLESv2/Program.cpp b/src/OpenGL/libGLESv2/Program.cpp
index 800e82d..fb63e50 100644
--- a/src/OpenGL/libGLESv2/Program.cpp
+++ b/src/OpenGL/libGLESv2/Program.cpp
@@ -147,12 +147,12 @@
{
}
- LinkedVarying::LinkedVarying(const std::string &name, GLenum type, GLsizei sizet)
+ LinkedVarying::LinkedVarying(const std::string &name, GLenum type, GLsizei size)
: name(name), type(type), size(size)
{
}
- Program::Program(ResourceManager *manager, GLuint handle) : resourceManager(manager), handle(handle), serial(issueSerial())
+ Program::Program(ResourceManager *manager, GLuint handle) : serial(issueSerial()), resourceManager(manager), handle(handle)
{
device = getDevice();
@@ -1700,7 +1700,6 @@
if(blockIndex == GL_INVALID_INDEX)
{
- const glsl::ActiveUniforms &activeUniforms = shader->activeUniforms;
const std::vector<int>& fields = block.fields;
std::vector<unsigned int> memberUniformIndexes;
for(size_t i = 0; i < fields.size(); ++i)
diff --git a/src/OpenGL/libGLESv2/Shader.cpp b/src/OpenGL/libGLESv2/Shader.cpp
index ffba4ba..580a91d 100644
--- a/src/OpenGL/libGLESv2/Shader.cpp
+++ b/src/OpenGL/libGLESv2/Shader.cpp
@@ -199,7 +199,7 @@
TranslatorASM *compiler = createCompiler(getType());
// Ensure we don't pass a NULL source to the compiler
- char *source = "\0";
+ const char *source = "\0";
if(mSource)
{
source = mSource;
diff --git a/src/OpenGL/libGLESv2/libGLESv3.cpp b/src/OpenGL/libGLESv2/libGLESv3.cpp
index 3408039..5c5e1c2 100644
--- a/src/OpenGL/libGLESv2/libGLESv3.cpp
+++ b/src/OpenGL/libGLESv2/libGLESv3.cpp
@@ -46,41 +46,6 @@
return true;
}
-static bool validateSubImageParams(bool compressed, GLsizei width, GLsizei height, GLint xoffset, GLint yoffset, GLenum target, GLint level, GLenum format, es2::Texture *texture)
-{
- if(!texture)
- {
- return error(GL_INVALID_OPERATION, false);
- }
-
- if(compressed != texture->isCompressed(target, level))
- {
- return error(GL_INVALID_OPERATION, false);
- }
-
- if(format != GL_NONE && format != texture->getFormat(target, level))
- {
- return error(GL_INVALID_OPERATION, false);
- }
-
- if(compressed)
- {
- if((width % 4 != 0 && width != texture->getWidth(target, 0)) ||
- (height % 4 != 0 && height != texture->getHeight(target, 0)))
- {
- return error(GL_INVALID_OPERATION, false);
- }
- }
-
- if(xoffset + width > texture->getWidth(target, level) ||
- yoffset + height > texture->getHeight(target, level))
- {
- return error(GL_INVALID_VALUE, false);
- }
-
- return true;
-}
-
static bool validateSubImageParams(bool compressed, GLsizei width, GLsizei height, GLsizei depth, GLint xoffset, GLint yoffset, GLint zoffset, GLenum target, GLint level, GLenum format, es2::Texture *texture)
{
if(!texture)
@@ -415,26 +380,6 @@
return true;
}
-static bool ValidateBufferTarget(GLenum target)
-{
- switch(target)
- {
- case GL_ARRAY_BUFFER:
- case GL_COPY_READ_BUFFER:
- case GL_COPY_WRITE_BUFFER:
- case GL_ELEMENT_ARRAY_BUFFER:
- case GL_PIXEL_PACK_BUFFER:
- case GL_PIXEL_UNPACK_BUFFER:
- case GL_TRANSFORM_FEEDBACK_BUFFER:
- case GL_UNIFORM_BUFFER:
- break;
- default:
- return false;
- }
-
- return true;
-}
-
bool ValidateTexParamParameters(GLenum pname, GLint param)
{
switch(pname)
@@ -1624,7 +1569,11 @@
TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %d, GLint level = %d, GLint layer = %d)",
target, attachment, texture, level, layer);
- if(texture != 0 && layer < 0 || level < 0)
+ // GLES 3.0.4 spec, p.209, section 4.4.2
+ // If texture is zero, any image or array of images attached to the attachment point
+ // named by attachment is detached. Any additional parameters(level, textarget,
+ // and / or layer) are ignored when texture is zero.
+ if(texture != 0 && (layer < 0 || level < 0))
{
return error(GL_INVALID_VALUE);
}
@@ -2814,12 +2763,16 @@
{
return error(GL_INVALID_OPERATION);
}
- if((readBuffer == writeBuffer) && // If same buffer, check for overlap
- ((readOffset >= writeOffset) && (readOffset < (writeOffset + size)) ||
- (writeOffset >= readOffset) && (writeOffset < (readOffset + size))))
+ if(readBuffer == writeBuffer)
{
- return error(GL_INVALID_VALUE);
+ // If same buffer, check for overlap
+ if(((readOffset >= writeOffset) && (readOffset < (writeOffset + size))) ||
+ ((writeOffset >= readOffset) && (writeOffset < (readOffset + size))))
+ {
+ return error(GL_INVALID_VALUE);
+ }
}
+
if((static_cast<size_t>(readOffset + size) > readBuffer->size()) ||
(static_cast<size_t>(writeOffset + size) > writeBuffer->size()))
{
diff --git a/src/Renderer/Matrix.cpp b/src/Renderer/Matrix.cpp
index 68aa549..3c3567a 100644
--- a/src/Renderer/Matrix.cpp
+++ b/src/Renderer/Matrix.cpp
@@ -343,9 +343,9 @@
float sxsy = sx * sy;
float sxcy = sx * cy;
- return Matrix(cy * cz - sy * sx * sz, -cy * sz - sy * sx * cz, -sy * cx,
- cx * sz, cx * cz, -sx,
- sy * cz + cy * sx * sz, -sy * sz + cy * sx * cz, cy * cx);
+ return Matrix(cy * cz - sxsy * sz, -cy * sz - sxsy * cz, -sy * cx,
+ cx * sz, cx * cz, -sx,
+ sy * cz + sxcy * sz, -sy * sz + sxcy * cz, cy * cx);
}
Matrix Matrix::eulerRotate(float x, float y, float z)