Commit d5451f11 by Geoff Lang

Inline comparison operators of several small ANGLE structs.

Improves draw call overhead of RendererGL. DrawCallPerf_gl: Before: 129779 score After: 136973 score Improvement: 5.543% No noticeable difference in DLL size or draw call perf of the D3D renderers. BUG=angleproject:959 Change-Id: Id54d49e9e2cfb69431ee26d632c58fee2c42b82c Reviewed-on: https://chromium-review.googlesource.com/275408Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 95137842
......@@ -23,24 +23,6 @@ VertexAttribute::VertexAttribute()
{
}
bool operator==(const VertexAttribute &a, const VertexAttribute &b)
{
return a.enabled == b.enabled &&
a.type == b.type &&
a.size == b.size &&
a.normalized == b.normalized &&
a.pureInteger == b.pureInteger &&
a.stride == b.stride &&
a.pointer == b.pointer &&
a.buffer.get() == b.buffer.get() &&
a.divisor == b.divisor;
}
bool operator!=(const VertexAttribute &a, const VertexAttribute &b)
{
return !(a == b);
}
size_t ComputeVertexAttributeTypeSize(const VertexAttribute& attrib)
{
GLuint size = attrib.size;
......
......@@ -40,31 +40,7 @@ bool operator==(const VertexAttribute &a, const VertexAttribute &b);
bool operator!=(const VertexAttribute &a, const VertexAttribute &b);
template <typename T>
T QuerySingleVertexAttributeParameter(const VertexAttribute& attrib, GLenum pname)
{
switch (pname)
{
case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
return static_cast<T>(attrib.enabled ? GL_TRUE : GL_FALSE);
case GL_VERTEX_ATTRIB_ARRAY_SIZE:
return static_cast<T>(attrib.size);
case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
return static_cast<T>(attrib.stride);
case GL_VERTEX_ATTRIB_ARRAY_TYPE:
return static_cast<T>(attrib.type);
case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
return static_cast<T>(attrib.normalized ? GL_TRUE : GL_FALSE);
case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
return static_cast<T>(attrib.buffer.id());
case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
return static_cast<T>(attrib.divisor);
case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
return static_cast<T>(attrib.pureInteger ? GL_TRUE : GL_FALSE);
default:
UNREACHABLE();
return static_cast<T>(0);
}
}
T QuerySingleVertexAttributeParameter(const VertexAttribute& attrib, GLenum pname);
size_t ComputeVertexAttributeTypeSize(const VertexAttribute& attrib);
size_t ComputeVertexAttributeStride(const VertexAttribute& attrib);
......@@ -79,53 +55,18 @@ struct VertexAttribCurrentValueData
};
GLenum Type;
VertexAttribCurrentValueData()
: Type(GL_FLOAT)
{
FloatValues[0] = 0.0f;
FloatValues[1] = 0.0f;
FloatValues[2] = 0.0f;
FloatValues[3] = 1.0f;
}
void setFloatValues(const GLfloat floatValues[4])
{
for (unsigned int valueIndex = 0; valueIndex < 4; valueIndex++)
{
FloatValues[valueIndex] = floatValues[valueIndex];
}
Type = GL_FLOAT;
}
void setIntValues(const GLint intValues[4])
{
for (unsigned int valueIndex = 0; valueIndex < 4; valueIndex++)
{
IntValues[valueIndex] = intValues[valueIndex];
}
Type = GL_INT;
}
void setUnsignedIntValues(const GLuint unsignedIntValues[4])
{
for (unsigned int valueIndex = 0; valueIndex < 4; valueIndex++)
{
UnsignedIntValues[valueIndex] = unsignedIntValues[valueIndex];
}
Type = GL_UNSIGNED_INT;
}
VertexAttribCurrentValueData();
bool operator==(const VertexAttribCurrentValueData &other)
{
return (Type == other.Type && memcmp(FloatValues, other.FloatValues, sizeof(float) * 4) == 0);
}
bool operator!=(const VertexAttribCurrentValueData &other)
{
return !(*this == other);
}
void setFloatValues(const GLfloat floatValues[4]);
void setIntValues(const GLint intValues[4]);
void setUnsignedIntValues(const GLuint unsignedIntValues[4]);
};
bool operator==(const VertexAttribCurrentValueData &a, const VertexAttribCurrentValueData &b);
bool operator!=(const VertexAttribCurrentValueData &a, const VertexAttribCurrentValueData &b);
}
#include "VertexAttribute.inl"
#endif // LIBANGLE_VERTEXATTRIBUTE_H_
//
// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// VertexAttribute.inl: Inline vertex attribute methods
//
namespace gl
{
inline bool operator==(const VertexAttribute &a, const VertexAttribute &b)
{
return a.enabled == b.enabled &&
a.type == b.type &&
a.size == b.size &&
a.normalized == b.normalized &&
a.pureInteger == b.pureInteger &&
a.stride == b.stride &&
a.pointer == b.pointer &&
a.buffer.get() == b.buffer.get() &&
a.divisor == b.divisor;
}
inline bool operator!=(const VertexAttribute &a, const VertexAttribute &b)
{
return !(a == b);
}
template <typename T>
T QuerySingleVertexAttributeParameter(const VertexAttribute& attrib, GLenum pname)
{
switch (pname)
{
case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
return static_cast<T>(attrib.enabled ? GL_TRUE : GL_FALSE);
case GL_VERTEX_ATTRIB_ARRAY_SIZE:
return static_cast<T>(attrib.size);
case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
return static_cast<T>(attrib.stride);
case GL_VERTEX_ATTRIB_ARRAY_TYPE:
return static_cast<T>(attrib.type);
case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
return static_cast<T>(attrib.normalized ? GL_TRUE : GL_FALSE);
case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
return static_cast<T>(attrib.buffer.id());
case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
return static_cast<T>(attrib.divisor);
case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
return static_cast<T>(attrib.pureInteger ? GL_TRUE : GL_FALSE);
default:
UNREACHABLE();
return static_cast<T>(0);
}
}
inline VertexAttribCurrentValueData::VertexAttribCurrentValueData()
: Type(GL_FLOAT)
{
FloatValues[0] = 0.0f;
FloatValues[1] = 0.0f;
FloatValues[2] = 0.0f;
FloatValues[3] = 1.0f;
}
inline void VertexAttribCurrentValueData::setFloatValues(const GLfloat floatValues[4])
{
for (unsigned int valueIndex = 0; valueIndex < 4; valueIndex++)
{
FloatValues[valueIndex] = floatValues[valueIndex];
}
Type = GL_FLOAT;
}
inline void VertexAttribCurrentValueData::setIntValues(const GLint intValues[4])
{
for (unsigned int valueIndex = 0; valueIndex < 4; valueIndex++)
{
IntValues[valueIndex] = intValues[valueIndex];
}
Type = GL_INT;
}
inline void VertexAttribCurrentValueData::setUnsignedIntValues(const GLuint unsignedIntValues[4])
{
for (unsigned int valueIndex = 0; valueIndex < 4; valueIndex++)
{
UnsignedIntValues[valueIndex] = unsignedIntValues[valueIndex];
}
Type = GL_UNSIGNED_INT;
}
inline bool operator==(const VertexAttribCurrentValueData &a, const VertexAttribCurrentValueData &b)
{
return (a.Type == b.Type && memcmp(a.FloatValues, b.FloatValues, sizeof(float) * 4) == 0);
}
inline bool operator!=(const VertexAttribCurrentValueData &a, const VertexAttribCurrentValueData &b)
{
return !(a == b);
}
}
......@@ -15,19 +15,6 @@
namespace gl
{
bool operator==(const Rectangle &a, const Rectangle &b)
{
return a.x == b.x &&
a.y == b.y &&
a.width == b.width &&
a.height == b.height;
}
bool operator!=(const Rectangle &a, const Rectangle &b)
{
return !(a == b);
}
SamplerState::SamplerState()
: minFilter(GL_NEAREST_MIPMAP_LINEAR),
magFilter(GL_LINEAR),
......@@ -53,31 +40,6 @@ bool SamplerState::swizzleRequired() const
swizzleBlue != GL_BLUE || swizzleAlpha != GL_ALPHA;
}
bool SamplerState::operator==(const SamplerState &other) const
{
return minFilter == other.minFilter &&
magFilter == other.magFilter &&
wrapS == other.wrapS &&
wrapT == other.wrapT &&
wrapR == other.wrapR &&
maxAnisotropy == other.maxAnisotropy &&
baseLevel == other.baseLevel &&
maxLevel == other.maxLevel &&
minLod == other.minLod &&
maxLod == other.maxLod &&
compareMode == other.compareMode &&
compareFunc == other.compareFunc &&
swizzleRed == other.swizzleRed &&
swizzleGreen == other.swizzleGreen &&
swizzleBlue == other.swizzleBlue &&
swizzleAlpha == other.swizzleAlpha;
}
bool SamplerState::operator!=(const SamplerState &other) const
{
return !(*this == other);
}
static void MinMax(int a, int b, int *minimum, int *maximum)
{
if (a < b)
......
......@@ -41,19 +41,10 @@ struct Color
};
template <typename T>
bool operator==(const Color<T> &a, const Color<T> &b)
{
return a.red == b.red &&
a.green == b.green &&
a.blue == b.blue &&
a.alpha == b.alpha;
}
bool operator==(const Color<T> &a, const Color<T> &b);
template <typename T>
bool operator!=(const Color<T> &a, const Color<T> &b)
{
return !(a == b);
}
bool operator!=(const Color<T> &a, const Color<T> &b);
typedef Color<float> ColorF;
typedef Color<int> ColorI;
......@@ -196,11 +187,11 @@ struct SamplerState
GLenum swizzleAlpha;
bool swizzleRequired() const;
bool operator==(const SamplerState &other) const;
bool operator!=(const SamplerState &other) const;
};
bool operator==(const SamplerState &a, const SamplerState &b);
bool operator!=(const SamplerState &a, const SamplerState &b);
struct PixelUnpackState
{
BindingPointer<Buffer> pixelBuffer;
......@@ -316,4 +307,6 @@ inline const DestT *GetImplAs(const SrcT *src)
}
#include "angletypes.inl"
#endif // LIBANGLE_ANGLETYPES_H_
//
// Copyright (c) 2012-2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// angletypes.inl : Inline definitions of some functions from angletypes.h
namespace gl
{
template <typename T>
bool operator==(const Color<T> &a, const Color<T> &b)
{
return a.red == b.red &&
a.green == b.green &&
a.blue == b.blue &&
a.alpha == b.alpha;
}
template <typename T>
bool operator!=(const Color<T> &a, const Color<T> &b)
{
return !(a == b);
}
inline bool operator==(const Rectangle &a, const Rectangle &b)
{
return a.x == b.x &&
a.y == b.y &&
a.width == b.width &&
a.height == b.height;
}
inline bool operator!=(const Rectangle &a, const Rectangle &b)
{
return !(a == b);
}
inline bool operator==(const SamplerState &a, const SamplerState &b)
{
return a.minFilter == b.minFilter &&
a.magFilter == b.magFilter &&
a.wrapS == b.wrapS &&
a.wrapT == b.wrapT &&
a.wrapR == b.wrapR &&
a.maxAnisotropy == b.maxAnisotropy &&
a.baseLevel == b.baseLevel &&
a.maxLevel == b.maxLevel &&
a.minLod == b.minLod &&
a.maxLod == b.maxLod &&
a.compareMode == b.compareMode &&
a.compareFunc == b.compareFunc &&
a.swizzleRed == b.swizzleRed &&
a.swizzleGreen == b.swizzleGreen &&
a.swizzleBlue == b.swizzleBlue &&
a.swizzleAlpha == b.swizzleAlpha;
}
inline bool operator!=(const SamplerState &a, const SamplerState &b)
{
return !(a == b);
}
}
......@@ -116,8 +116,10 @@
'libANGLE/VertexArray.h',
'libANGLE/VertexAttribute.cpp',
'libANGLE/VertexAttribute.h',
'libANGLE/VertexAttribute.inl',
'libANGLE/angletypes.cpp',
'libANGLE/angletypes.h',
'libANGLE/angletypes.inl',
'libANGLE/features.h',
'libANGLE/formatutils.cpp',
'libANGLE/formatutils.h',
......
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