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