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 | |
| 10 | #ifndef LIBGLESV2_PROGRAM_H_ |
| 11 | #define LIBGLESV2_PROGRAM_H_ |
| 12 | |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 13 | #include "common/angleutils.h" |
| 14 | #include "common/RefCountObject.h" |
| 15 | #include "libGLESv2/Constants.h" |
Shannon Woods | 53a94a8 | 2014-06-24 15:20:36 -0400 | [diff] [blame] | 16 | #include "libGLESv2/ProgramBinary.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 17 | |
Geoff Lang | 0b7eef7 | 2014-06-12 14:10:47 -0400 | [diff] [blame] | 18 | #include <GLES2/gl2.h> |
| 19 | |
| 20 | #include <vector> |
| 21 | #include <string> |
| 22 | #include <set> |
| 23 | |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 24 | namespace rx |
| 25 | { |
| 26 | class Renderer; |
| 27 | } |
daniel@transgaming.com | e684229 | 2010-04-20 18:52:50 +0000 | [diff] [blame] | 28 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 29 | namespace gl |
| 30 | { |
Brandon Jones | 43a53e2 | 2014-08-28 16:23:22 -0700 | [diff] [blame] | 31 | struct Caps; |
Jamie Madill | de8892b | 2014-11-11 13:00:22 -0500 | [diff] [blame^] | 32 | struct Data; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 33 | class ResourceManager; |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 34 | class Shader; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 35 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 36 | extern const char * const g_fakepath; |
| 37 | |
apatrick@chromium.org | 9a30b09 | 2012-06-06 20:21:55 +0000 | [diff] [blame] | 38 | class AttributeBindings |
| 39 | { |
| 40 | public: |
| 41 | AttributeBindings(); |
| 42 | ~AttributeBindings(); |
| 43 | |
| 44 | void bindAttributeLocation(GLuint index, const char *name); |
| 45 | int getAttributeBinding(const std::string &name) const; |
| 46 | |
| 47 | private: |
| 48 | std::set<std::string> mAttributeBinding[MAX_VERTEX_ATTRIBS]; |
| 49 | }; |
| 50 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 51 | class InfoLog |
| 52 | { |
| 53 | public: |
| 54 | InfoLog(); |
| 55 | ~InfoLog(); |
| 56 | |
| 57 | int getLength() const; |
| 58 | void getLog(GLsizei bufSize, GLsizei *length, char *infoLog); |
| 59 | |
| 60 | void appendSanitized(const char *message); |
| 61 | void append(const char *info, ...); |
| 62 | void reset(); |
| 63 | private: |
| 64 | DISALLOW_COPY_AND_ASSIGN(InfoLog); |
| 65 | char *mInfoLog; |
| 66 | }; |
| 67 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 68 | class Program |
| 69 | { |
| 70 | public: |
daniel@transgaming.com | 70062c9 | 2012-11-28 19:32:30 +0000 | [diff] [blame] | 71 | Program(rx::Renderer *renderer, ResourceManager *manager, GLuint handle); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 72 | |
| 73 | ~Program(); |
| 74 | |
| 75 | bool attachShader(Shader *shader); |
| 76 | bool detachShader(Shader *shader); |
| 77 | int getAttachedShadersCount() const; |
| 78 | |
| 79 | void bindAttributeLocation(GLuint index, const char *name); |
| 80 | |
Jamie Madill | de8892b | 2014-11-11 13:00:22 -0500 | [diff] [blame^] | 81 | Error link(const Data &data); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 82 | bool isLinked(); |
Geoff Lang | b543aff | 2014-09-30 14:52:54 -0400 | [diff] [blame] | 83 | Error setProgramBinary(GLenum binaryFormat, const void *binary, GLsizei length); |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 84 | ProgramBinary *getProgramBinary() const; |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 85 | |
| 86 | int getInfoLogLength() const; |
| 87 | void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog); |
| 88 | void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders); |
| 89 | |
| 90 | void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); |
| 91 | GLint getActiveAttributeCount(); |
| 92 | GLint getActiveAttributeMaxLength(); |
| 93 | |
| 94 | void getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); |
| 95 | GLint getActiveUniformCount(); |
| 96 | GLint getActiveUniformMaxLength(); |
| 97 | |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 98 | GLint getActiveUniformBlockCount(); |
| 99 | GLint getActiveUniformBlockMaxLength(); |
| 100 | |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 101 | void bindUniformBlock(GLuint uniformBlockIndex, GLuint uniformBlockBinding); |
| 102 | GLuint getUniformBlockBinding(GLuint uniformBlockIndex) const; |
| 103 | |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 104 | void setTransformFeedbackVaryings(GLsizei count, const GLchar *const *varyings, GLenum bufferMode); |
| 105 | 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] | 106 | GLsizei getTransformFeedbackVaryingCount() const; |
| 107 | GLsizei getTransformFeedbackVaryingMaxLength() const; |
| 108 | GLenum getTransformFeedbackBufferMode() const; |
| 109 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 110 | void addRef(); |
| 111 | void release(); |
| 112 | unsigned int getRefCount() const; |
| 113 | void flagForDeletion(); |
| 114 | bool isFlaggedForDeletion() const; |
| 115 | |
Brandon Jones | 43a53e2 | 2014-08-28 16:23:22 -0700 | [diff] [blame] | 116 | void validate(const Caps &caps); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 117 | bool isValidated() const; |
| 118 | |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 119 | GLint getProgramBinaryLength() const; |
| 120 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 121 | private: |
| 122 | DISALLOW_COPY_AND_ASSIGN(Program); |
| 123 | |
| 124 | void unlink(bool destroy = false); |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 125 | void resetUniformBlockBindings(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 126 | |
Brandon Jones | 7162096 | 2014-08-20 14:04:59 -0700 | [diff] [blame] | 127 | Shader *mFragmentShader; |
| 128 | Shader *mVertexShader; |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 129 | |
| 130 | AttributeBindings mAttributeBindings; |
| 131 | |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 132 | GLuint mUniformBlockBindings[IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS]; |
| 133 | |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 134 | std::vector<std::string> mTransformFeedbackVaryings; |
| 135 | GLuint mTransformFeedbackBufferMode; |
| 136 | |
daniel@transgaming.com | 989c1c8 | 2012-07-24 18:40:38 +0000 | [diff] [blame] | 137 | BindingPointer<ProgramBinary> mProgramBinary; |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 138 | bool mLinked; |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 139 | 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] | 140 | |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 141 | unsigned int mRefCount; |
| 142 | |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 143 | ResourceManager *mResourceManager; |
daniel@transgaming.com | 70062c9 | 2012-11-28 19:32:30 +0000 | [diff] [blame] | 144 | rx::Renderer *mRenderer; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 145 | const GLuint mHandle; |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 146 | |
| 147 | InfoLog mInfoLog; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 148 | }; |
| 149 | } |
| 150 | |
| 151 | #endif // LIBGLESV2_PROGRAM_H_ |