daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1 | // |
Geoff Lang | 1b6edcb | 2014-02-03 14:27:56 -0500 | [diff] [blame] | 2 | // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // Program.h: Defines the gl::Program class. Implements GL program objects |
| 8 | // and related functionality. [OpenGL ES 2.0.24] section 2.10.3 page 28. |
| 9 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 10 | #ifndef LIBANGLE_PROGRAM_H_ |
| 11 | #define LIBANGLE_PROGRAM_H_ |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 12 | |
Geoff Lang | 0b7eef7 | 2014-06-12 14:10:47 -0400 | [diff] [blame] | 13 | #include <GLES2/gl2.h> |
Jamie Madill | 861ebb3 | 2016-11-17 16:40:22 -0500 | [diff] [blame] | 14 | #include <GLSLANG/ShaderVars.h> |
Geoff Lang | 0b7eef7 | 2014-06-12 14:10:47 -0400 | [diff] [blame] | 15 | |
Jamie Madill | a7d12dc | 2016-12-13 15:08:19 -0500 | [diff] [blame] | 16 | #include <array> |
Jamie Madill | 861ebb3 | 2016-11-17 16:40:22 -0500 | [diff] [blame] | 17 | #include <map> |
Jamie Madill | 63805b4 | 2015-08-25 13:17:39 -0400 | [diff] [blame] | 18 | #include <set> |
Jamie Madill | 71c3b2c | 2015-05-07 11:49:20 -0400 | [diff] [blame] | 19 | #include <sstream> |
Geoff Lang | 0b7eef7 | 2014-06-12 14:10:47 -0400 | [diff] [blame] | 20 | #include <string> |
Jamie Madill | 63805b4 | 2015-08-25 13:17:39 -0400 | [diff] [blame] | 21 | #include <vector> |
Geoff Lang | 0b7eef7 | 2014-06-12 14:10:47 -0400 | [diff] [blame] | 22 | |
Jamie Madill | 3d3d2f2 | 2015-09-23 16:47:51 -0400 | [diff] [blame] | 23 | #include "common/angleutils.h" |
| 24 | #include "common/mathutil.h" |
| 25 | #include "common/Optional.h" |
| 26 | |
| 27 | #include "libANGLE/angletypes.h" |
| 28 | #include "libANGLE/Constants.h" |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 29 | #include "libANGLE/Debug.h" |
Jamie Madill | 3d3d2f2 | 2015-09-23 16:47:51 -0400 | [diff] [blame] | 30 | #include "libANGLE/Error.h" |
| 31 | #include "libANGLE/RefCountObject.h" |
| 32 | |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 33 | namespace rx |
| 34 | { |
Jamie Madill | 7aea7e0 | 2016-05-10 10:39:45 -0400 | [diff] [blame] | 35 | class GLImplFactory; |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 36 | class ProgramImpl; |
Jamie Madill | 5c6b7bf | 2015-08-17 12:53:35 -0400 | [diff] [blame] | 37 | struct TranslatedAttribute; |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 38 | } |
daniel@transgaming.com | e684229 | 2010-04-20 18:52:50 +0000 | [diff] [blame] | 39 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 40 | namespace gl |
| 41 | { |
Brandon Jones | 43a53e2 | 2014-08-28 16:23:22 -0700 | [diff] [blame] | 42 | struct Caps; |
Jamie Madill | a2c7498 | 2016-12-12 11:20:42 -0500 | [diff] [blame] | 43 | class Context; |
Jamie Madill | dfde6ab | 2016-06-09 07:07:18 -0700 | [diff] [blame] | 44 | class ContextState; |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 45 | class Shader; |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 46 | class ShaderProgramManager; |
Jamie Madill | f4f8db8 | 2017-02-15 09:31:39 -0500 | [diff] [blame] | 47 | class State; |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 48 | class InfoLog; |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 49 | class Buffer; |
| 50 | class Framebuffer; |
| 51 | struct UniformBlock; |
| 52 | struct LinkedUniform; |
Jamie Madill | 192745a | 2016-12-22 15:58:21 -0500 | [diff] [blame] | 53 | struct PackedVarying; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 54 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 55 | extern const char * const g_fakepath; |
| 56 | |
Jamie Madill | f0d10f8 | 2015-03-31 12:56:52 -0400 | [diff] [blame] | 57 | class InfoLog : angle::NonCopyable |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 58 | { |
| 59 | public: |
| 60 | InfoLog(); |
| 61 | ~InfoLog(); |
| 62 | |
Jamie Madill | 71c3b2c | 2015-05-07 11:49:20 -0400 | [diff] [blame] | 63 | size_t getLength() const; |
Geoff Lang | e1a2775 | 2015-10-05 13:16:04 -0400 | [diff] [blame] | 64 | void getLog(GLsizei bufSize, GLsizei *length, char *infoLog) const; |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 65 | |
| 66 | void appendSanitized(const char *message); |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 67 | void reset(); |
Jamie Madill | f611316 | 2015-05-07 11:49:21 -0400 | [diff] [blame] | 68 | |
| 69 | // This helper class ensures we append a newline after writing a line. |
| 70 | class StreamHelper : angle::NonCopyable |
| 71 | { |
| 72 | public: |
| 73 | StreamHelper(StreamHelper &&rhs) |
| 74 | : mStream(rhs.mStream) |
| 75 | { |
| 76 | rhs.mStream = nullptr; |
| 77 | } |
| 78 | |
| 79 | StreamHelper &operator=(StreamHelper &&rhs) |
| 80 | { |
| 81 | std::swap(mStream, rhs.mStream); |
| 82 | return *this; |
| 83 | } |
| 84 | |
| 85 | ~StreamHelper() |
| 86 | { |
| 87 | // Write newline when destroyed on the stack |
| 88 | if (mStream) |
| 89 | { |
| 90 | (*mStream) << std::endl; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | template <typename T> |
| 95 | StreamHelper &operator<<(const T &value) |
| 96 | { |
| 97 | (*mStream) << value; |
| 98 | return *this; |
| 99 | } |
| 100 | |
| 101 | private: |
| 102 | friend class InfoLog; |
| 103 | |
| 104 | StreamHelper(std::stringstream *stream) |
| 105 | : mStream(stream) |
| 106 | { |
| 107 | ASSERT(stream); |
| 108 | } |
| 109 | |
| 110 | std::stringstream *mStream; |
| 111 | }; |
| 112 | |
| 113 | template <typename T> |
| 114 | StreamHelper operator<<(const T &value) |
| 115 | { |
| 116 | StreamHelper helper(&mStream); |
| 117 | helper << value; |
| 118 | return helper; |
| 119 | } |
| 120 | |
| 121 | std::string str() const { return mStream.str(); } |
| 122 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 123 | private: |
Jamie Madill | 71c3b2c | 2015-05-07 11:49:20 -0400 | [diff] [blame] | 124 | std::stringstream mStream; |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 125 | }; |
| 126 | |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 127 | // Struct used for correlating uniforms/elements of uniform arrays to handles |
| 128 | struct VariableLocation |
| 129 | { |
| 130 | VariableLocation(); |
| 131 | VariableLocation(const std::string &name, unsigned int element, unsigned int index); |
| 132 | |
| 133 | std::string name; |
| 134 | unsigned int element; |
| 135 | unsigned int index; |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 136 | |
| 137 | // If this is a valid uniform location |
| 138 | bool used; |
| 139 | |
| 140 | // If this location was bound to an unreferenced uniform. Setting data on this uniform is a |
| 141 | // no-op. |
| 142 | bool ignored; |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 143 | }; |
| 144 | |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 145 | // Information about a variable binding. |
| 146 | // Currently used by CHROMIUM_path_rendering |
| 147 | struct BindingInfo |
| 148 | { |
| 149 | // The type of binding, for example GL_FLOAT_VEC3. |
| 150 | // This can be GL_NONE if the variable is optimized away. |
| 151 | GLenum type; |
| 152 | |
| 153 | // This is the name of the variable in |
| 154 | // the translated shader program. Note that |
| 155 | // this can be empty in the case where the |
| 156 | // variable has been optimized away. |
| 157 | std::string name; |
| 158 | |
| 159 | // True if the binding is valid, otherwise false. |
| 160 | bool valid; |
| 161 | }; |
| 162 | |
Jamie Madill | e7d8432 | 2017-01-10 18:21:59 -0500 | [diff] [blame] | 163 | // This small structure encapsulates binding sampler uniforms to active GL textures. |
| 164 | struct SamplerBinding |
| 165 | { |
| 166 | SamplerBinding(GLenum textureTypeIn, size_t elementCount) |
| 167 | : textureType(textureTypeIn), boundTextureUnits(elementCount, 0) |
| 168 | { |
| 169 | } |
| 170 | |
| 171 | // Necessary for retrieving active textures from the GL state. |
| 172 | GLenum textureType; |
| 173 | |
| 174 | // List of all textures bound to this sampler, of type textureType. |
| 175 | std::vector<GLuint> boundTextureUnits; |
| 176 | }; |
| 177 | |
jchen10 | a9042d3 | 2017-03-17 08:50:45 +0800 | [diff] [blame] | 178 | // A varying with tranform feedback enabled. If it's an array, either the whole array or one of its |
| 179 | // elements specified by 'arrayIndex' can set to be enabled. |
| 180 | struct TransformFeedbackVarying : public sh::Varying |
| 181 | { |
| 182 | TransformFeedbackVarying(const sh::Varying &varyingIn, GLuint index) |
| 183 | : sh::Varying(varyingIn), arrayIndex(index) |
| 184 | { |
| 185 | } |
| 186 | std::string nameWithArrayIndex() const |
| 187 | { |
| 188 | std::stringstream fullNameStr; |
| 189 | fullNameStr << name; |
| 190 | if (arrayIndex != GL_INVALID_INDEX) |
| 191 | { |
| 192 | fullNameStr << "[" << arrayIndex << "]"; |
| 193 | } |
| 194 | return fullNameStr.str(); |
| 195 | } |
| 196 | GLsizei size() const { return (arrayIndex == GL_INVALID_INDEX ? elementCount() : 1); } |
| 197 | |
| 198 | GLuint arrayIndex; |
| 199 | }; |
| 200 | |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 201 | class ProgramState final : angle::NonCopyable |
| 202 | { |
| 203 | public: |
| 204 | ProgramState(); |
| 205 | ~ProgramState(); |
| 206 | |
| 207 | const std::string &getLabel(); |
| 208 | |
Jamie Madill | bd044ed | 2017-06-05 12:59:21 -0400 | [diff] [blame] | 209 | Shader *getAttachedVertexShader() const { return mAttachedVertexShader; } |
| 210 | Shader *getAttachedFragmentShader() const { return mAttachedFragmentShader; } |
| 211 | Shader *getAttachedComputeShader() const { return mAttachedComputeShader; } |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 212 | const std::vector<std::string> &getTransformFeedbackVaryingNames() const |
| 213 | { |
| 214 | return mTransformFeedbackVaryingNames; |
| 215 | } |
| 216 | GLint getTransformFeedbackBufferMode() const { return mTransformFeedbackBufferMode; } |
| 217 | GLuint getUniformBlockBinding(GLuint uniformBlockIndex) const |
| 218 | { |
| 219 | ASSERT(uniformBlockIndex < IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS); |
| 220 | return mUniformBlockBindings[uniformBlockIndex]; |
| 221 | } |
| 222 | const UniformBlockBindingMask &getActiveUniformBlockBindingsMask() const |
| 223 | { |
| 224 | return mActiveUniformBlockBindings; |
| 225 | } |
| 226 | const std::vector<sh::Attribute> &getAttributes() const { return mAttributes; } |
| 227 | const AttributesMask &getActiveAttribLocationsMask() const |
| 228 | { |
| 229 | return mActiveAttribLocationsMask; |
| 230 | } |
Corentin Wallez | e755774 | 2017-06-01 13:09:57 -0400 | [diff] [blame] | 231 | DrawBufferMask getActiveOutputVariables() const { return mActiveOutputVariables; } |
Jamie Madill | 4f86d05 | 2017-06-05 12:59:26 -0400 | [diff] [blame] | 232 | const std::vector<sh::OutputVariable> &getOutputVariables() const { return mOutputVariables; } |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 233 | const std::map<int, VariableLocation> &getOutputLocations() const { return mOutputLocations; } |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 234 | const std::vector<LinkedUniform> &getUniforms() const { return mUniforms; } |
| 235 | const std::vector<VariableLocation> &getUniformLocations() const { return mUniformLocations; } |
| 236 | const std::vector<UniformBlock> &getUniformBlocks() const { return mUniformBlocks; } |
Jamie Madill | e7d8432 | 2017-01-10 18:21:59 -0500 | [diff] [blame] | 237 | const std::vector<SamplerBinding> &getSamplerBindings() const { return mSamplerBindings; } |
Jamie Madill | 4f86d05 | 2017-06-05 12:59:26 -0400 | [diff] [blame] | 238 | const sh::WorkGroupSize &getComputeShaderLocalSize() const { return mComputeShaderLocalSize; } |
| 239 | const RangeUI &getSamplerUniformRange() const { return mSamplerUniformRange; } |
| 240 | |
| 241 | using UniformBlockBindingArray = |
| 242 | std::array<GLuint, IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS>; |
| 243 | const UniformBlockBindingArray &getUniformBlockBindings() const |
| 244 | { |
| 245 | return mUniformBlockBindings; |
| 246 | } |
| 247 | const std::vector<TransformFeedbackVarying> &getLinkedTransformFeedbackVaryings() const |
| 248 | { |
| 249 | return mLinkedTransformFeedbackVaryings; |
| 250 | } |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 251 | |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 252 | GLint getUniformLocation(const std::string &name) const; |
Jamie Madill | e7d8432 | 2017-01-10 18:21:59 -0500 | [diff] [blame] | 253 | GLuint getUniformIndexFromName(const std::string &name) const; |
| 254 | GLuint getUniformIndexFromLocation(GLint location) const; |
| 255 | Optional<GLuint> getSamplerIndex(GLint location) const; |
| 256 | bool isSamplerUniformIndex(GLuint index) const; |
| 257 | GLuint getSamplerIndexFromUniformIndex(GLuint uniformIndex) const; |
Jamie Madill | 34ca4f5 | 2017-06-13 11:49:39 -0400 | [diff] [blame] | 258 | GLuint getAttributeLocation(const std::string &name) const; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 259 | |
| 260 | private: |
Jamie Madill | 4f86d05 | 2017-06-05 12:59:26 -0400 | [diff] [blame] | 261 | friend class MemoryProgramCache; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 262 | friend class Program; |
| 263 | |
| 264 | std::string mLabel; |
| 265 | |
Martin Radev | 4c4c8e7 | 2016-08-04 12:25:34 +0300 | [diff] [blame] | 266 | sh::WorkGroupSize mComputeShaderLocalSize; |
| 267 | |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 268 | Shader *mAttachedFragmentShader; |
| 269 | Shader *mAttachedVertexShader; |
Martin Radev | 4c4c8e7 | 2016-08-04 12:25:34 +0300 | [diff] [blame] | 270 | Shader *mAttachedComputeShader; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 271 | |
| 272 | std::vector<std::string> mTransformFeedbackVaryingNames; |
jchen10 | a9042d3 | 2017-03-17 08:50:45 +0800 | [diff] [blame] | 273 | std::vector<TransformFeedbackVarying> mLinkedTransformFeedbackVaryings; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 274 | GLenum mTransformFeedbackBufferMode; |
| 275 | |
Jamie Madill | 4f86d05 | 2017-06-05 12:59:26 -0400 | [diff] [blame] | 276 | UniformBlockBindingArray mUniformBlockBindings; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 277 | UniformBlockBindingMask mActiveUniformBlockBindings; |
| 278 | |
| 279 | std::vector<sh::Attribute> mAttributes; |
Jamie Madill | 6de5185 | 2017-04-12 09:53:01 -0400 | [diff] [blame] | 280 | angle::BitSet<MAX_VERTEX_ATTRIBS> mActiveAttribLocationsMask; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 281 | |
| 282 | // Uniforms are sorted in order: |
| 283 | // 1. Non-sampler uniforms |
| 284 | // 2. Sampler uniforms |
| 285 | // 3. Uniform block uniforms |
| 286 | // This makes sampler validation easier, since we don't need a separate list. |
| 287 | std::vector<LinkedUniform> mUniforms; |
| 288 | std::vector<VariableLocation> mUniformLocations; |
| 289 | std::vector<UniformBlock> mUniformBlocks; |
Jamie Madill | e7d8432 | 2017-01-10 18:21:59 -0500 | [diff] [blame] | 290 | RangeUI mSamplerUniformRange; |
| 291 | |
| 292 | // An array of the samplers that are used by the program |
| 293 | std::vector<gl::SamplerBinding> mSamplerBindings; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 294 | |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 295 | std::vector<sh::OutputVariable> mOutputVariables; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 296 | // TODO(jmadill): use unordered/hash map when available |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 297 | std::map<int, VariableLocation> mOutputLocations; |
Corentin Wallez | e755774 | 2017-06-01 13:09:57 -0400 | [diff] [blame] | 298 | DrawBufferMask mActiveOutputVariables; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 299 | |
Geoff Lang | e0cff19 | 2017-05-30 13:04:56 -0400 | [diff] [blame] | 300 | // Fragment output variable base types: FLOAT, INT, or UINT. Ordered by location. |
| 301 | std::vector<GLenum> mOutputVariableTypes; |
| 302 | |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 303 | bool mBinaryRetrieveableHint; |
Yunchao He | 61afff1 | 2017-03-14 15:34:03 +0800 | [diff] [blame] | 304 | bool mSeparable; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 305 | }; |
| 306 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 307 | class Program final : angle::NonCopyable, public LabeledObject |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 308 | { |
| 309 | public: |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 310 | Program(rx::GLImplFactory *factory, ShaderProgramManager *manager, GLuint handle); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 311 | ~Program(); |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 312 | void destroy(const Context *context); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 313 | |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 314 | GLuint id() const { return mHandle; } |
| 315 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 316 | void setLabel(const std::string &label) override; |
| 317 | const std::string &getLabel() const override; |
| 318 | |
Geoff Lang | 47110bf | 2016-04-20 11:13:22 -0700 | [diff] [blame] | 319 | rx::ProgramImpl *getImplementation() const { return mProgram; } |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 320 | |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 321 | void attachShader(Shader *shader); |
Jamie Madill | c1d770e | 2017-04-13 17:31:24 -0400 | [diff] [blame] | 322 | void detachShader(const Context *context, Shader *shader); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 323 | int getAttachedShadersCount() const; |
| 324 | |
Jamie Madill | ef300b1 | 2016-10-07 15:12:09 -0400 | [diff] [blame] | 325 | const Shader *getAttachedVertexShader() const { return mState.mAttachedVertexShader; } |
| 326 | const Shader *getAttachedFragmentShader() const { return mState.mAttachedFragmentShader; } |
| 327 | const Shader *getAttachedComputeShader() const { return mState.mAttachedComputeShader; } |
| 328 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 329 | void bindAttributeLocation(GLuint index, const char *name); |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 330 | void bindUniformLocation(GLuint index, const char *name); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 331 | |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 332 | // CHROMIUM_path_rendering |
Jamie Madill | bd044ed | 2017-06-05 12:59:21 -0400 | [diff] [blame] | 333 | BindingInfo getFragmentInputBindingInfo(const Context *context, GLint index) const; |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 334 | void bindFragmentInputLocation(GLint index, const char *name); |
Jamie Madill | bd044ed | 2017-06-05 12:59:21 -0400 | [diff] [blame] | 335 | void pathFragmentInputGen(const Context *context, |
| 336 | GLint index, |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 337 | GLenum genMode, |
| 338 | GLint components, |
| 339 | const GLfloat *coeffs); |
| 340 | |
Jamie Madill | 8ecf7f9 | 2017-01-13 17:29:52 -0500 | [diff] [blame] | 341 | Error link(const gl::Context *context); |
Geoff Lang | e1a2775 | 2015-10-05 13:16:04 -0400 | [diff] [blame] | 342 | bool isLinked() const; |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 343 | |
Jamie Madill | a2c7498 | 2016-12-12 11:20:42 -0500 | [diff] [blame] | 344 | Error loadBinary(const Context *context, |
| 345 | GLenum binaryFormat, |
| 346 | const void *binary, |
| 347 | GLsizei length); |
| 348 | Error saveBinary(const Context *context, |
| 349 | GLenum *binaryFormat, |
| 350 | void *binary, |
| 351 | GLsizei bufSize, |
| 352 | GLsizei *length) const; |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 353 | GLint getBinaryLength() const; |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 354 | void setBinaryRetrievableHint(bool retrievable); |
| 355 | bool getBinaryRetrievableHint() const; |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 356 | |
Yunchao He | 61afff1 | 2017-03-14 15:34:03 +0800 | [diff] [blame] | 357 | void setSeparable(bool separable); |
| 358 | bool isSeparable() const; |
| 359 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 360 | int getInfoLogLength() const; |
Geoff Lang | e1a2775 | 2015-10-05 13:16:04 -0400 | [diff] [blame] | 361 | void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog) const; |
| 362 | void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders) const; |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 363 | |
Geoff Lang | e1a2775 | 2015-10-05 13:16:04 -0400 | [diff] [blame] | 364 | GLuint getAttributeLocation(const std::string &name) const; |
Jamie Madill | 63805b4 | 2015-08-25 13:17:39 -0400 | [diff] [blame] | 365 | bool isAttribLocationActive(size_t attribLocation) const; |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 366 | |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 367 | void getActiveAttribute(GLuint index, |
| 368 | GLsizei bufsize, |
| 369 | GLsizei *length, |
| 370 | GLint *size, |
| 371 | GLenum *type, |
| 372 | GLchar *name) const; |
Geoff Lang | e1a2775 | 2015-10-05 13:16:04 -0400 | [diff] [blame] | 373 | GLint getActiveAttributeCount() const; |
| 374 | GLint getActiveAttributeMaxLength() const; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 375 | const std::vector<sh::Attribute> &getAttributes() const { return mState.mAttributes; } |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 376 | |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 377 | GLint getFragDataLocation(const std::string &name) const; |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 378 | size_t getOutputResourceCount() const; |
Geoff Lang | e0cff19 | 2017-05-30 13:04:56 -0400 | [diff] [blame] | 379 | const std::vector<GLenum> &getOutputVariableTypes() const |
| 380 | { |
| 381 | return mState.mOutputVariableTypes; |
| 382 | } |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 383 | |
Geoff Lang | e1a2775 | 2015-10-05 13:16:04 -0400 | [diff] [blame] | 384 | void getActiveUniform(GLuint index, |
| 385 | GLsizei bufsize, |
| 386 | GLsizei *length, |
| 387 | GLint *size, |
| 388 | GLenum *type, |
| 389 | GLchar *name) const; |
| 390 | GLint getActiveUniformCount() const; |
| 391 | GLint getActiveUniformMaxLength() const; |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 392 | GLint getActiveUniformi(GLuint index, GLenum pname) const; |
| 393 | bool isValidUniformLocation(GLint location) const; |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 394 | const LinkedUniform &getUniformByLocation(GLint location) const; |
Jamie Madill | ac4e9c3 | 2017-01-13 14:07:12 -0500 | [diff] [blame] | 395 | const VariableLocation &getUniformLocation(GLint location) const; |
| 396 | const std::vector<VariableLocation> &getUniformLocations() const; |
| 397 | const LinkedUniform &getUniformByIndex(GLuint index) const; |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 398 | |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 399 | GLint getUniformLocation(const std::string &name) const; |
| 400 | GLuint getUniformIndex(const std::string &name) const; |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 401 | void setUniform1fv(GLint location, GLsizei count, const GLfloat *v); |
| 402 | void setUniform2fv(GLint location, GLsizei count, const GLfloat *v); |
| 403 | void setUniform3fv(GLint location, GLsizei count, const GLfloat *v); |
| 404 | void setUniform4fv(GLint location, GLsizei count, const GLfloat *v); |
| 405 | void setUniform1iv(GLint location, GLsizei count, const GLint *v); |
| 406 | void setUniform2iv(GLint location, GLsizei count, const GLint *v); |
| 407 | void setUniform3iv(GLint location, GLsizei count, const GLint *v); |
| 408 | void setUniform4iv(GLint location, GLsizei count, const GLint *v); |
| 409 | void setUniform1uiv(GLint location, GLsizei count, const GLuint *v); |
| 410 | void setUniform2uiv(GLint location, GLsizei count, const GLuint *v); |
| 411 | void setUniform3uiv(GLint location, GLsizei count, const GLuint *v); |
| 412 | void setUniform4uiv(GLint location, GLsizei count, const GLuint *v); |
| 413 | void setUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); |
| 414 | void setUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); |
| 415 | void setUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); |
| 416 | void setUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); |
| 417 | void setUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); |
| 418 | void setUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); |
| 419 | void setUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); |
| 420 | void setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); |
| 421 | void setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); |
| 422 | |
Geoff Lang | e1a2775 | 2015-10-05 13:16:04 -0400 | [diff] [blame] | 423 | void getUniformfv(GLint location, GLfloat *params) const; |
| 424 | void getUniformiv(GLint location, GLint *params) const; |
| 425 | void getUniformuiv(GLint location, GLuint *params) const; |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 426 | |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 427 | void getActiveUniformBlockName(GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName) const; |
Geoff Lang | e1a2775 | 2015-10-05 13:16:04 -0400 | [diff] [blame] | 428 | GLuint getActiveUniformBlockCount() const; |
| 429 | GLint getActiveUniformBlockMaxLength() const; |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 430 | |
Geoff Lang | e1a2775 | 2015-10-05 13:16:04 -0400 | [diff] [blame] | 431 | GLuint getUniformBlockIndex(const std::string &name) const; |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 432 | |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 433 | void bindUniformBlock(GLuint uniformBlockIndex, GLuint uniformBlockBinding); |
| 434 | GLuint getUniformBlockBinding(GLuint uniformBlockIndex) const; |
| 435 | |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 436 | const UniformBlock &getUniformBlockByIndex(GLuint index) const; |
Gregoire Payen de La Garanderie | 68694e9 | 2015-03-24 14:03:37 +0000 | [diff] [blame] | 437 | |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 438 | void setTransformFeedbackVaryings(GLsizei count, const GLchar *const *varyings, GLenum bufferMode); |
| 439 | void getTransformFeedbackVarying(GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name) const; |
Geoff Lang | 1b6edcb | 2014-02-03 14:27:56 -0500 | [diff] [blame] | 440 | GLsizei getTransformFeedbackVaryingCount() const; |
| 441 | GLsizei getTransformFeedbackVaryingMaxLength() const; |
| 442 | GLenum getTransformFeedbackBufferMode() const; |
| 443 | |
Frank Henigman | fccbac2 | 2017-05-28 17:29:26 -0400 | [diff] [blame] | 444 | static bool linkValidateInterfaceBlockFields(InfoLog &infoLog, |
| 445 | const std::string &uniformName, |
| 446 | const sh::InterfaceBlockField &vertexUniform, |
| 447 | const sh::InterfaceBlockField &fragmentUniform, |
| 448 | bool webglCompatibility); |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 449 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 450 | void addRef(); |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 451 | void release(const Context *context); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 452 | unsigned int getRefCount() const; |
| 453 | void flagForDeletion(); |
| 454 | bool isFlaggedForDeletion() const; |
| 455 | |
Brandon Jones | 43a53e2 | 2014-08-28 16:23:22 -0700 | [diff] [blame] | 456 | void validate(const Caps &caps); |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 457 | bool validateSamplers(InfoLog *infoLog, const Caps &caps); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 458 | bool isValidated() const; |
Jamie Madill | a4595b8 | 2017-01-11 17:36:34 -0500 | [diff] [blame] | 459 | bool samplesFromTexture(const gl::State &state, GLuint textureID) const; |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 460 | |
Jamie Madill | 63805b4 | 2015-08-25 13:17:39 -0400 | [diff] [blame] | 461 | const AttributesMask &getActiveAttribLocationsMask() const |
| 462 | { |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 463 | return mState.mActiveAttribLocationsMask; |
Jamie Madill | 63805b4 | 2015-08-25 13:17:39 -0400 | [diff] [blame] | 464 | } |
| 465 | |
Jamie Madill | e7d8432 | 2017-01-10 18:21:59 -0500 | [diff] [blame] | 466 | const std::vector<SamplerBinding> &getSamplerBindings() const |
| 467 | { |
| 468 | return mState.mSamplerBindings; |
| 469 | } |
Jamie Madill | df68a6f | 2017-01-13 17:29:53 -0500 | [diff] [blame] | 470 | const ProgramState &getState() const { return mState; } |
Jamie Madill | e7d8432 | 2017-01-10 18:21:59 -0500 | [diff] [blame] | 471 | |
Olli Etuaho | b78707c | 2017-03-09 15:03:11 +0000 | [diff] [blame] | 472 | static bool linkValidateVariablesBase(InfoLog &infoLog, |
| 473 | const std::string &variableName, |
| 474 | const sh::ShaderVariable &vertexVariable, |
| 475 | const sh::ShaderVariable &fragmentVariable, |
| 476 | bool validatePrecision); |
| 477 | |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 478 | GLuint getInputResourceIndex(const GLchar *name) const; |
| 479 | GLuint getOutputResourceIndex(const GLchar *name) const; |
jchen10 | fd7c3b5 | 2017-03-21 15:36:03 +0800 | [diff] [blame] | 480 | void getInputResourceName(GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name) const; |
| 481 | void getOutputResourceName(GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name) const; |
jchen10 | 15015f7 | 2017-03-16 13:54:21 +0800 | [diff] [blame] | 482 | |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 483 | class Bindings final : angle::NonCopyable |
| 484 | { |
| 485 | public: |
| 486 | void bindLocation(GLuint index, const std::string &name); |
| 487 | int getBinding(const std::string &name) const; |
| 488 | |
| 489 | typedef std::unordered_map<std::string, GLuint>::const_iterator const_iterator; |
| 490 | const_iterator begin() const; |
| 491 | const_iterator end() const; |
| 492 | |
| 493 | private: |
| 494 | std::unordered_map<std::string, GLuint> mBindings; |
| 495 | }; |
| 496 | |
Olli Etuaho | b78707c | 2017-03-09 15:03:11 +0000 | [diff] [blame] | 497 | private: |
Jamie Madill | 192745a | 2016-12-22 15:58:21 -0500 | [diff] [blame] | 498 | struct VaryingRef |
| 499 | { |
| 500 | const sh::Varying *get() const { return vertex ? vertex : fragment; } |
| 501 | |
| 502 | const sh::Varying *vertex = nullptr; |
| 503 | const sh::Varying *fragment = nullptr; |
| 504 | }; |
| 505 | |
| 506 | using MergedVaryings = std::map<std::string, VaryingRef>; |
| 507 | |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 508 | void unlink(); |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 509 | void resetUniformBlockBindings(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 510 | |
Jamie Madill | bd044ed | 2017-06-05 12:59:21 -0400 | [diff] [blame] | 511 | bool linkAttributes(const Context *context, InfoLog &infoLog); |
Martin Radev | 4c4c8e7 | 2016-08-04 12:25:34 +0300 | [diff] [blame] | 512 | bool validateUniformBlocksCount(GLuint maxUniformBlocks, |
| 513 | const std::vector<sh::InterfaceBlock> &block, |
| 514 | const std::string &errorMessage, |
| 515 | InfoLog &infoLog) const; |
| 516 | bool validateVertexAndFragmentInterfaceBlocks( |
| 517 | const std::vector<sh::InterfaceBlock> &vertexInterfaceBlocks, |
| 518 | const std::vector<sh::InterfaceBlock> &fragmentInterfaceBlocks, |
Frank Henigman | fccbac2 | 2017-05-28 17:29:26 -0400 | [diff] [blame] | 519 | InfoLog &infoLog, |
| 520 | bool webglCompatibility) const; |
Jamie Madill | bd044ed | 2017-06-05 12:59:21 -0400 | [diff] [blame] | 521 | bool linkUniformBlocks(const Context *context, InfoLog &infoLog); |
| 522 | bool linkVaryings(const Context *context, InfoLog &infoLog) const; |
Olli Etuaho | 6ca2b65 | 2017-02-19 18:05:10 +0000 | [diff] [blame] | 523 | |
Jamie Madill | bd044ed | 2017-06-05 12:59:21 -0400 | [diff] [blame] | 524 | bool linkUniforms(const Context *context, |
| 525 | InfoLog &infoLog, |
| 526 | const Bindings &uniformLocationBindings); |
Olli Etuaho | 48fed63 | 2017-03-16 12:05:30 +0000 | [diff] [blame] | 527 | void linkSamplerBindings(); |
Olli Etuaho | 6ca2b65 | 2017-02-19 18:05:10 +0000 | [diff] [blame] | 528 | |
Jamie Madill | a2c7498 | 2016-12-12 11:20:42 -0500 | [diff] [blame] | 529 | bool areMatchingInterfaceBlocks(InfoLog &infoLog, |
Martin Radev | 4c4c8e7 | 2016-08-04 12:25:34 +0300 | [diff] [blame] | 530 | const sh::InterfaceBlock &vertexInterfaceBlock, |
Frank Henigman | fccbac2 | 2017-05-28 17:29:26 -0400 | [diff] [blame] | 531 | const sh::InterfaceBlock &fragmentInterfaceBlock, |
| 532 | bool webglCompatibility) const; |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 533 | |
Yuly Novikov | a1f6dc9 | 2016-06-15 23:27:04 -0400 | [diff] [blame] | 534 | static bool linkValidateVaryings(InfoLog &infoLog, |
| 535 | const std::string &varyingName, |
| 536 | const sh::Varying &vertexVarying, |
| 537 | const sh::Varying &fragmentVarying, |
| 538 | int shaderVersion); |
Jamie Madill | bd044ed | 2017-06-05 12:59:21 -0400 | [diff] [blame] | 539 | bool linkValidateBuiltInVaryings(const Context *context, InfoLog &infoLog) const; |
jchen10 | a9042d3 | 2017-03-17 08:50:45 +0800 | [diff] [blame] | 540 | bool linkValidateTransformFeedback(const gl::Context *context, |
| 541 | InfoLog &infoLog, |
Jamie Madill | 192745a | 2016-12-22 15:58:21 -0500 | [diff] [blame] | 542 | const MergedVaryings &linkedVaryings, |
Jamie Madill | ccdf74b | 2015-08-18 10:46:12 -0400 | [diff] [blame] | 543 | const Caps &caps) const; |
| 544 | |
Jamie Madill | 192745a | 2016-12-22 15:58:21 -0500 | [diff] [blame] | 545 | void gatherTransformFeedbackVaryings(const MergedVaryings &varyings); |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 546 | |
Jamie Madill | bd044ed | 2017-06-05 12:59:21 -0400 | [diff] [blame] | 547 | MergedVaryings getMergedVaryings(const Context *context) const; |
Jamie Madill | 192745a | 2016-12-22 15:58:21 -0500 | [diff] [blame] | 548 | std::vector<PackedVarying> getPackedVaryings(const MergedVaryings &mergedVaryings) const; |
Jamie Madill | bd044ed | 2017-06-05 12:59:21 -0400 | [diff] [blame] | 549 | void linkOutputVariables(const Context *context); |
Jamie Madill | ccdf74b | 2015-08-18 10:46:12 -0400 | [diff] [blame] | 550 | |
Olli Etuaho | 48fed63 | 2017-03-16 12:05:30 +0000 | [diff] [blame] | 551 | void setUniformValuesFromBindingQualifiers(); |
| 552 | |
Jamie Madill | bd044ed | 2017-06-05 12:59:21 -0400 | [diff] [blame] | 553 | void gatherInterfaceBlockInfo(const Context *context); |
Jamie Madill | 4a3c234 | 2015-10-08 12:58:45 -0400 | [diff] [blame] | 554 | template <typename VarT> |
| 555 | void defineUniformBlockMembers(const std::vector<VarT> &fields, |
| 556 | const std::string &prefix, |
| 557 | int blockIndex); |
| 558 | |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 559 | void defineUniformBlock(const sh::InterfaceBlock &interfaceBlock, GLenum shaderType); |
| 560 | |
Corentin Wallez | 8b7d814 | 2016-11-15 13:40:37 -0500 | [diff] [blame] | 561 | // Both these function update the cached uniform values and return a modified "count" |
| 562 | // so that the uniform update doesn't overflow the uniform. |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 563 | template <typename T> |
Corentin Wallez | 8b7d814 | 2016-11-15 13:40:37 -0500 | [diff] [blame] | 564 | GLsizei setUniformInternal(GLint location, GLsizei count, int vectorSize, const T *v); |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 565 | template <size_t cols, size_t rows, typename T> |
Corentin Wallez | 8b7d814 | 2016-11-15 13:40:37 -0500 | [diff] [blame] | 566 | GLsizei setMatrixUniformInternal(GLint location, |
| 567 | GLsizei count, |
| 568 | GLboolean transpose, |
| 569 | const T *v); |
Jamie Madill | e7d8432 | 2017-01-10 18:21:59 -0500 | [diff] [blame] | 570 | template <typename T> |
| 571 | void updateSamplerUniform(const VariableLocation &locationInfo, |
| 572 | const uint8_t *destPointer, |
| 573 | GLsizei clampedCount, |
| 574 | const T *v); |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 575 | |
| 576 | template <typename DestT> |
| 577 | void getUniformInternal(GLint location, DestT *dataOut) const; |
| 578 | |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 579 | ProgramState mState; |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 580 | rx::ProgramImpl *mProgram; |
| 581 | |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 582 | bool mValidated; |
| 583 | |
Geoff Lang | d860552 | 2016-04-13 10:19:12 -0400 | [diff] [blame] | 584 | Bindings mAttributeBindings; |
Olli Etuaho | 4a92ceb | 2017-02-19 17:51:24 +0000 | [diff] [blame] | 585 | |
| 586 | // Note that this has nothing to do with binding layout qualifiers that can be set for some |
| 587 | // uniforms in GLES3.1+. It is used to pre-set the location of uniforms. |
| 588 | Bindings mUniformLocationBindings; |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 589 | |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 590 | // CHROMIUM_path_rendering |
| 591 | Bindings mFragmentInputBindings; |
| 592 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 593 | bool mLinked; |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 594 | bool mDeleteStatus; // Flag to indicate that the program can be deleted when no longer in use |
daniel@transgaming.com | 4fa0833 | 2010-05-11 02:29:27 +0000 | [diff] [blame] | 595 | |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 596 | unsigned int mRefCount; |
| 597 | |
Geoff Lang | 4ddf5af | 2016-12-01 14:30:44 -0500 | [diff] [blame] | 598 | ShaderProgramManager *mResourceManager; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 599 | const GLuint mHandle; |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 600 | |
| 601 | InfoLog mInfoLog; |
Jamie Madill | 3d3d2f2 | 2015-09-23 16:47:51 -0400 | [diff] [blame] | 602 | |
| 603 | // Cache for sampler validation |
| 604 | Optional<bool> mCachedValidateSamplersResult; |
| 605 | std::vector<GLenum> mTextureUnitTypesCache; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 606 | }; |
Jamie Madill | a2c7498 | 2016-12-12 11:20:42 -0500 | [diff] [blame] | 607 | } // namespace gl |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 608 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 609 | #endif // LIBANGLE_PROGRAM_H_ |