Commit 6a72979f by Jamie Madill

Move shadervars constructors to cpp files.

This avoid unnecessary binary bloat from STL default constructors and assignment operators. BUG=angle:466,697 Change-Id: I679e524d3e3dbd0d3866fc30a5a01967d8769249 Reviewed-on: https://chromium-review.googlesource.com/208356Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarbratell at Opera <bratell@opera.com> Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org>
parent a3fe2b4e
......@@ -158,6 +158,7 @@
<ClCompile Include="..\..\src\common\debug.cpp"/>
<ClCompile Include="..\..\src\common\event_tracer.cpp"/>
<ClCompile Include="..\..\src\common\utilities.cpp"/>
<ClCompile Include="..\..\src\common\shadervars.cpp"/>
<ClCompile Include="..\..\src\common\blocklayout.cpp"/>
</ItemGroup>
<ItemGroup>
......
......@@ -111,6 +111,9 @@
<ClCompile Include="..\..\src\common\utilities.cpp">
<Filter>src\common</Filter>
</ClCompile>
<ClCompile Include="..\..\src\common\shadervars.cpp">
<Filter>src\common</Filter>
</ClCompile>
<ClInclude Include="..\..\src\common\angleutils.h">
<Filter>src\common</Filter>
</ClInclude>
......
......@@ -380,6 +380,7 @@
<ClCompile Include="..\..\src\common\event_tracer.cpp"/>
<ClCompile Include="..\..\src\common\RefCountObject.cpp"/>
<ClCompile Include="..\..\src\common\tls.cpp"/>
<ClCompile Include="..\..\src\common\shadervars.cpp"/>
<ClCompile Include="..\..\src\common\utilities.cpp"/>
<ClCompile Include="..\..\src\common\mathutil.cpp"/>
<ClCompile Include="..\..\src\common\debug.cpp"/>
......
......@@ -798,6 +798,9 @@
<ClInclude Include="..\..\src\common\utilities.h">
<Filter>src\common</Filter>
</ClInclude>
<ClCompile Include="..\..\src\common\shadervars.cpp">
<Filter>src\common</Filter>
</ClCompile>
<ClInclude Include="..\..\src\common\RefCountObject.h">
<Filter>src\common</Filter>
</ClInclude>
......
......@@ -213,6 +213,7 @@
<ClCompile Include="..\..\src\common\RefCountObject.cpp"/>
<ClCompile Include="..\..\src\common\mathutil.cpp"/>
<ClCompile Include="..\..\src\common\debug.cpp"/>
<ClCompile Include="..\..\src\common\shadervars.cpp"/>
<ClCompile Include="..\..\src\common\blocklayout.cpp"/>
<ClCompile Include="..\..\src\compiler\translator\InfoSink.cpp"/>
<ClCompile Include="..\..\src\compiler\translator\OutputESSL.cpp"/>
......
......@@ -102,6 +102,9 @@
<ClInclude Include="..\..\src\common\utilities.h">
<Filter>src\common</Filter>
</ClInclude>
<ClCompile Include="..\..\src\common\shadervars.cpp">
<Filter>src\common</Filter>
</ClCompile>
<ClCompile Include="..\..\src\common\blocklayout.cpp">
<Filter>src\common</Filter>
</ClCompile>
......
//
// Copyright (c) 2014 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.
//
// shadervars.cpp:
// Methods for GL variable types (varyings, uniforms, etc)
//
#include "common/shadervars.h"
namespace sh
{
ShaderVariable::ShaderVariable()
: type(0),
precision(0),
arraySize(0),
staticUse(false)
{}
ShaderVariable::ShaderVariable(GLenum typeIn, unsigned int arraySizeIn)
: type(typeIn),
precision(0),
arraySize(arraySizeIn),
staticUse(false)
{}
ShaderVariable::~ShaderVariable()
{}
ShaderVariable::ShaderVariable(const ShaderVariable &other)
: type(other.type),
precision(other.precision),
name(other.name),
mappedName(other.mappedName),
arraySize(other.arraySize),
staticUse(other.staticUse)
{}
ShaderVariable &ShaderVariable::operator=(const ShaderVariable &other)
{
type = other.type;
precision = other.precision;
name = other.name;
mappedName = other.mappedName;
arraySize = other.arraySize;
staticUse = other.staticUse;
return *this;
}
Uniform::Uniform()
{}
Uniform::~Uniform()
{}
Uniform::Uniform(const Uniform &other)
: ShaderVariable(other),
fields(other.fields)
{}
Uniform &Uniform::operator=(const Uniform &other)
{
ShaderVariable::operator=(other);
fields = other.fields;
return *this;
}
Attribute::Attribute()
: location(-1)
{}
Attribute::~Attribute()
{}
Attribute::Attribute(const Attribute &other)
: ShaderVariable(other),
location(other.location)
{}
Attribute &Attribute::operator=(const Attribute &other)
{
ShaderVariable::operator=(other);
location = other.location;
return *this;
}
InterfaceBlockField::InterfaceBlockField()
: isRowMajorMatrix(false)
{}
InterfaceBlockField::~InterfaceBlockField()
{}
InterfaceBlockField::InterfaceBlockField(const InterfaceBlockField &other)
: ShaderVariable(other),
isRowMajorMatrix(other.isRowMajorMatrix),
fields(other.fields)
{}
InterfaceBlockField &InterfaceBlockField::operator=(const InterfaceBlockField &other)
{
ShaderVariable::operator=(other);
isRowMajorMatrix = other.isRowMajorMatrix;
fields = other.fields;
return *this;
}
Varying::Varying()
: interpolation(INTERPOLATION_SMOOTH)
{}
Varying::~Varying()
{}
Varying::Varying(const Varying &other)
: ShaderVariable(other),
interpolation(other.interpolation),
fields(other.fields),
structName(other.structName)
{}
Varying &Varying::operator=(const Varying &other)
{
ShaderVariable::operator=(other);
interpolation = other.interpolation;
fields = other.fields;
structName = other.structName;
return *this;
}
InterfaceBlock::InterfaceBlock()
: arraySize(0),
layout(BLOCKLAYOUT_PACKED),
isRowMajorLayout(false),
staticUse(false)
{}
InterfaceBlock::~InterfaceBlock()
{}
InterfaceBlock::InterfaceBlock(const InterfaceBlock &other)
: name(other.name),
mappedName(other.mappedName),
arraySize(other.arraySize),
layout(other.layout),
isRowMajorLayout(other.isRowMajorLayout),
staticUse(other.staticUse),
fields(other.fields)
{}
InterfaceBlock &InterfaceBlock::operator=(const InterfaceBlock &other)
{
name = other.name;
mappedName = other.mappedName;
arraySize = other.arraySize;
layout = other.layout;
isRowMajorLayout = other.isRowMajorLayout;
staticUse = other.staticUse;
fields = other.fields;
return *this;
}
}
......@@ -35,21 +35,16 @@ enum BlockLayoutType
};
// Base class for all variables defined in shaders, including Varyings, Uniforms, etc
// Note: we must override the copy constructor and assignment operator so we can
// work around excessive GCC binary bloating:
// See https://code.google.com/p/angleproject/issues/detail?id=697
struct ShaderVariable
{
ShaderVariable()
: type(0),
precision(0),
arraySize(0),
staticUse(false)
{}
ShaderVariable(GLenum typeIn, unsigned int arraySizeIn)
: type(typeIn),
precision(0),
arraySize(arraySizeIn),
staticUse(false)
{}
ShaderVariable();
ShaderVariable(GLenum typeIn, unsigned int arraySizeIn);
~ShaderVariable();
ShaderVariable(const ShaderVariable &other);
ShaderVariable &operator=(const ShaderVariable &other);
bool isArray() const { return arraySize > 0; }
unsigned int elementCount() const { return std::max(1u, arraySize); }
......@@ -64,7 +59,10 @@ struct ShaderVariable
struct Uniform : public ShaderVariable
{
Uniform() {}
Uniform();
~Uniform();
Uniform(const Uniform &other);
Uniform &operator=(const Uniform &other);
bool isStruct() const { return !fields.empty(); }
......@@ -73,18 +71,20 @@ struct Uniform : public ShaderVariable
struct Attribute : public ShaderVariable
{
Attribute()
: location(-1)
{}
Attribute();
~Attribute();
Attribute(const Attribute &other);
Attribute &operator=(const Attribute &other);
int location;
};
struct InterfaceBlockField : public ShaderVariable
{
InterfaceBlockField()
: isRowMajorMatrix(false)
{}
InterfaceBlockField();
~InterfaceBlockField();
InterfaceBlockField(const InterfaceBlockField &other);
InterfaceBlockField &operator=(const InterfaceBlockField &other);
bool isStruct() const { return !fields.empty(); }
......@@ -94,9 +94,10 @@ struct InterfaceBlockField : public ShaderVariable
struct Varying : public ShaderVariable
{
Varying()
: interpolation(INTERPOLATION_SMOOTH)
{}
Varying();
~Varying();
Varying(const Varying &other);
Varying &operator=(const Varying &other);
bool isStruct() const { return !fields.empty(); }
......@@ -107,12 +108,10 @@ struct Varying : public ShaderVariable
struct InterfaceBlock
{
InterfaceBlock()
: arraySize(0),
layout(BLOCKLAYOUT_PACKED),
isRowMajorLayout(false),
staticUse(false)
{}
InterfaceBlock();
~InterfaceBlock();
InterfaceBlock(const InterfaceBlock &other);
InterfaceBlock &operator=(const InterfaceBlock &other);
std::string name;
std::string mappedName;
......
......@@ -32,6 +32,7 @@
'common/mathutil.cpp',
'common/mathutil.h',
'common/platform.h',
'common/shadervars.cpp',
'common/shadervars.h',
'common/tls.cpp',
'common/tls.h',
......
......@@ -34,6 +34,7 @@
'common/mathutil.cpp',
'common/mathutil.h',
'common/platform.h',
'common/shadervars.cpp',
'common/shadervars.h',
'common/tls.cpp',
'common/tls.h',
......
......@@ -34,6 +34,7 @@
'common/mathutil.cpp',
'common/mathutil.h',
'common/platform.h',
'common/shadervars.cpp',
'common/shadervars.h',
'common/tls.cpp',
'common/tls.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