blob: 1b92896225fb1549e2b82c91a1d87a2ebb1150dc [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();
53 ProgramBinary *getProgramBinary();
54
55 int getInfoLogLength() const;
56 void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog);
57 void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders);
58
59 void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
60 GLint getActiveAttributeCount();
61 GLint getActiveAttributeMaxLength();
62
63 void getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
64 GLint getActiveUniformCount();
65 GLint getActiveUniformMaxLength();
66
67 void addRef();
68 void release();
69 unsigned int getRefCount() const;
70 void flagForDeletion();
71 bool isFlaggedForDeletion() const;
72
73 bool isValidated() const;
74
75 unsigned int getSerial() const;
76
77 private:
78 DISALLOW_COPY_AND_ASSIGN(Program);
79
80 void unlink(bool destroy = false);
81
82 static unsigned int issueSerial();
83
84 FragmentShader *mFragmentShader;
85 VertexShader *mVertexShader;
86
87 AttributeBindings mAttributeBindings;
88
89 ProgramBinary* mProgramBinary;
90 bool mDeleteStatus; // Flag to indicate that the program can be deleted when no longer in use
daniel@transgaming.com4fa08332010-05-11 02:29:27 +000091
daniel@transgaming.comda13f3e2010-07-28 19:20:56 +000092 unsigned int mRefCount;
93
daniel@transgaming.com73a5db62010-10-15 17:58:13 +000094 const unsigned int mSerial;
daniel@transgaming.com4fa08332010-05-11 02:29:27 +000095
96 static unsigned int mCurrentSerial;
daniel@transgaming.comda13f3e2010-07-28 19:20:56 +000097
98 ResourceManager *mResourceManager;
99 const GLuint mHandle;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000100};
101}
102
103#endif // LIBGLESV2_PROGRAM_H_