Jamie Madill | 6a72979 | 2014-07-18 10:33:14 -0400 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
Jamie Madill | a2ad4e8 | 2014-07-17 14:16:32 -0400 | [diff] [blame] | 6 | // ShaderVars.cpp: |
Jamie Madill | 6a72979 | 2014-07-18 10:33:14 -0400 | [diff] [blame] | 7 | // Methods for GL variable types (varyings, uniforms, etc) |
| 8 | // |
| 9 | |
Jamie Madill | e294bb8 | 2014-07-17 14:16:26 -0400 | [diff] [blame] | 10 | #include <GLSLANG/ShaderLang.h> |
Jamie Madill | 6a72979 | 2014-07-18 10:33:14 -0400 | [diff] [blame] | 11 | |
| 12 | namespace sh |
| 13 | { |
| 14 | |
| 15 | ShaderVariable::ShaderVariable() |
| 16 | : type(0), |
| 17 | precision(0), |
| 18 | arraySize(0), |
| 19 | staticUse(false) |
| 20 | {} |
| 21 | |
| 22 | ShaderVariable::ShaderVariable(GLenum typeIn, unsigned int arraySizeIn) |
| 23 | : type(typeIn), |
| 24 | precision(0), |
| 25 | arraySize(arraySizeIn), |
| 26 | staticUse(false) |
| 27 | {} |
| 28 | |
| 29 | ShaderVariable::~ShaderVariable() |
| 30 | {} |
| 31 | |
| 32 | ShaderVariable::ShaderVariable(const ShaderVariable &other) |
| 33 | : type(other.type), |
| 34 | precision(other.precision), |
| 35 | name(other.name), |
| 36 | mappedName(other.mappedName), |
| 37 | arraySize(other.arraySize), |
Jamie Madill | 42bcf32 | 2014-08-25 16:20:46 -0400 | [diff] [blame^] | 38 | staticUse(other.staticUse), |
| 39 | fields(other.fields), |
| 40 | structName(other.structName) |
Jamie Madill | 6a72979 | 2014-07-18 10:33:14 -0400 | [diff] [blame] | 41 | {} |
| 42 | |
| 43 | ShaderVariable &ShaderVariable::operator=(const ShaderVariable &other) |
| 44 | { |
| 45 | type = other.type; |
| 46 | precision = other.precision; |
| 47 | name = other.name; |
| 48 | mappedName = other.mappedName; |
| 49 | arraySize = other.arraySize; |
| 50 | staticUse = other.staticUse; |
Jamie Madill | 42bcf32 | 2014-08-25 16:20:46 -0400 | [diff] [blame^] | 51 | fields = other.fields; |
| 52 | structName = other.structName; |
Jamie Madill | 6a72979 | 2014-07-18 10:33:14 -0400 | [diff] [blame] | 53 | return *this; |
| 54 | } |
| 55 | |
| 56 | Uniform::Uniform() |
| 57 | {} |
| 58 | |
| 59 | Uniform::~Uniform() |
| 60 | {} |
| 61 | |
| 62 | Uniform::Uniform(const Uniform &other) |
Jamie Madill | 42bcf32 | 2014-08-25 16:20:46 -0400 | [diff] [blame^] | 63 | : ShaderVariable(other) |
Jamie Madill | 6a72979 | 2014-07-18 10:33:14 -0400 | [diff] [blame] | 64 | {} |
| 65 | |
| 66 | Uniform &Uniform::operator=(const Uniform &other) |
| 67 | { |
| 68 | ShaderVariable::operator=(other); |
Jamie Madill | 6a72979 | 2014-07-18 10:33:14 -0400 | [diff] [blame] | 69 | return *this; |
| 70 | } |
| 71 | |
| 72 | Attribute::Attribute() |
| 73 | : location(-1) |
| 74 | {} |
| 75 | |
| 76 | Attribute::~Attribute() |
| 77 | {} |
| 78 | |
| 79 | Attribute::Attribute(const Attribute &other) |
| 80 | : ShaderVariable(other), |
| 81 | location(other.location) |
| 82 | {} |
| 83 | |
| 84 | Attribute &Attribute::operator=(const Attribute &other) |
| 85 | { |
| 86 | ShaderVariable::operator=(other); |
| 87 | location = other.location; |
| 88 | return *this; |
| 89 | } |
| 90 | |
| 91 | InterfaceBlockField::InterfaceBlockField() |
| 92 | : isRowMajorMatrix(false) |
| 93 | {} |
| 94 | |
| 95 | InterfaceBlockField::~InterfaceBlockField() |
| 96 | {} |
| 97 | |
| 98 | InterfaceBlockField::InterfaceBlockField(const InterfaceBlockField &other) |
| 99 | : ShaderVariable(other), |
Jamie Madill | 42bcf32 | 2014-08-25 16:20:46 -0400 | [diff] [blame^] | 100 | isRowMajorMatrix(other.isRowMajorMatrix) |
Jamie Madill | 6a72979 | 2014-07-18 10:33:14 -0400 | [diff] [blame] | 101 | {} |
| 102 | |
| 103 | InterfaceBlockField &InterfaceBlockField::operator=(const InterfaceBlockField &other) |
| 104 | { |
| 105 | ShaderVariable::operator=(other); |
| 106 | isRowMajorMatrix = other.isRowMajorMatrix; |
Jamie Madill | 6a72979 | 2014-07-18 10:33:14 -0400 | [diff] [blame] | 107 | return *this; |
| 108 | } |
| 109 | |
| 110 | Varying::Varying() |
Jamie Madill | 42bcf32 | 2014-08-25 16:20:46 -0400 | [diff] [blame^] | 111 | : interpolation(INTERPOLATION_SMOOTH), |
| 112 | isInvariant(false) |
Jamie Madill | 6a72979 | 2014-07-18 10:33:14 -0400 | [diff] [blame] | 113 | {} |
| 114 | |
| 115 | Varying::~Varying() |
| 116 | {} |
| 117 | |
| 118 | Varying::Varying(const Varying &other) |
| 119 | : ShaderVariable(other), |
| 120 | interpolation(other.interpolation), |
Jamie Madill | 42bcf32 | 2014-08-25 16:20:46 -0400 | [diff] [blame^] | 121 | isInvariant(other.isInvariant) |
Jamie Madill | 6a72979 | 2014-07-18 10:33:14 -0400 | [diff] [blame] | 122 | {} |
| 123 | |
| 124 | Varying &Varying::operator=(const Varying &other) |
| 125 | { |
| 126 | ShaderVariable::operator=(other); |
| 127 | interpolation = other.interpolation; |
Jamie Madill | 42bcf32 | 2014-08-25 16:20:46 -0400 | [diff] [blame^] | 128 | isInvariant = other.isInvariant; |
Jamie Madill | 6a72979 | 2014-07-18 10:33:14 -0400 | [diff] [blame] | 129 | return *this; |
| 130 | } |
| 131 | |
| 132 | InterfaceBlock::InterfaceBlock() |
| 133 | : arraySize(0), |
| 134 | layout(BLOCKLAYOUT_PACKED), |
| 135 | isRowMajorLayout(false), |
| 136 | staticUse(false) |
| 137 | {} |
| 138 | |
| 139 | InterfaceBlock::~InterfaceBlock() |
| 140 | {} |
| 141 | |
| 142 | InterfaceBlock::InterfaceBlock(const InterfaceBlock &other) |
| 143 | : name(other.name), |
| 144 | mappedName(other.mappedName), |
Jamie Madill | 42bcf32 | 2014-08-25 16:20:46 -0400 | [diff] [blame^] | 145 | instanceName(other.instanceName), |
Jamie Madill | 6a72979 | 2014-07-18 10:33:14 -0400 | [diff] [blame] | 146 | arraySize(other.arraySize), |
| 147 | layout(other.layout), |
| 148 | isRowMajorLayout(other.isRowMajorLayout), |
| 149 | staticUse(other.staticUse), |
| 150 | fields(other.fields) |
| 151 | {} |
| 152 | |
| 153 | InterfaceBlock &InterfaceBlock::operator=(const InterfaceBlock &other) |
| 154 | { |
| 155 | name = other.name; |
| 156 | mappedName = other.mappedName; |
Jamie Madill | 42bcf32 | 2014-08-25 16:20:46 -0400 | [diff] [blame^] | 157 | instanceName = other.instanceName; |
Jamie Madill | 6a72979 | 2014-07-18 10:33:14 -0400 | [diff] [blame] | 158 | arraySize = other.arraySize; |
| 159 | layout = other.layout; |
| 160 | isRowMajorLayout = other.isRowMajorLayout; |
| 161 | staticUse = other.staticUse; |
| 162 | fields = other.fields; |
| 163 | return *this; |
| 164 | } |
| 165 | |
| 166 | } |