blob: 1b4239a628deac95fc3ab7b462c83ecc951cbf82 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
daniel@transgaming.comea7c3452012-06-05 19:51:40 +00002// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003// 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
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000013#include <d3dx9.h>
14#include <string>
daniel@transgaming.comb4ff1f82010-04-22 13:35:18 +000015#include <set>
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000016
daniel@transgaming.com85423182010-04-22 13:35:27 +000017#include "libGLESv2/Shader.h"
daniel@transgaming.come6842292010-04-20 18:52:50 +000018#include "libGLESv2/Context.h"
19
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000020namespace gl
21{
daniel@transgaming.comda13f3e2010-07-28 19:20:56 +000022class ResourceManager;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000023class FragmentShader;
24class VertexShader;
25
apatrick@chromium.org9a30b092012-06-06 20:21:55 +000026class AttributeBindings
27{
28 public:
29 AttributeBindings();
30 ~AttributeBindings();
31
32 void bindAttributeLocation(GLuint index, const char *name);
33 int getAttributeBinding(const std::string &name) const;
34
35 private:
36 std::set<std::string> mAttributeBinding[MAX_VERTEX_ATTRIBS];
37};
38
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +000039class Program
40{
41 public:
42 Program(ResourceManager *manager, GLuint handle);
43
44 ~Program();
45
46 bool attachShader(Shader *shader);
47 bool detachShader(Shader *shader);
48 int getAttachedShadersCount() const;
49
50 void bindAttributeLocation(GLuint index, const char *name);
51
52 void link();
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000053 void setProgramBinary(ProgramBinary *programBinary);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +000054 ProgramBinary *getProgramBinary();
55
56 int getInfoLogLength() const;
57 void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog);
58 void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders);
59
60 void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
61 GLint getActiveAttributeCount();
62 GLint getActiveAttributeMaxLength();
63
64 void getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
65 GLint getActiveUniformCount();
66 GLint getActiveUniformMaxLength();
67
68 void addRef();
69 void release();
70 unsigned int getRefCount() const;
71 void flagForDeletion();
72 bool isFlaggedForDeletion() const;
73
74 bool isValidated() const;
75
76 unsigned int getSerial() const;
77
78 private:
79 DISALLOW_COPY_AND_ASSIGN(Program);
80
81 void unlink(bool destroy = false);
82
83 static unsigned int issueSerial();
84
85 FragmentShader *mFragmentShader;
86 VertexShader *mVertexShader;
87
88 AttributeBindings mAttributeBindings;
89
90 ProgramBinary* mProgramBinary;
91 bool mDeleteStatus; // Flag to indicate that the program can be deleted when no longer in use
daniel@transgaming.com4fa08332010-05-11 02:29:27 +000092
daniel@transgaming.comda13f3e2010-07-28 19:20:56 +000093 unsigned int mRefCount;
94
daniel@transgaming.com73a5db62010-10-15 17:58:13 +000095 const unsigned int mSerial;
daniel@transgaming.com4fa08332010-05-11 02:29:27 +000096
97 static unsigned int mCurrentSerial;
daniel@transgaming.comda13f3e2010-07-28 19:20:56 +000098
99 ResourceManager *mResourceManager;
100 const GLuint mHandle;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000101};
102}
103
104#endif // LIBGLESV2_PROGRAM_H_