• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (c) 2010-2013 The ANGLE Project Authors. All rights reserved.
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 #ifndef LIBGLESV2_UNIFORM_H_
8 #define LIBGLESV2_UNIFORM_H_
9 
10 #include "common/debug.h"
11 #include "common/blocklayout.h"
12 
13 #include "libGLESv2/angletypes.h"
14 
15 #include "angle_gl.h"
16 
17 #include <string>
18 #include <vector>
19 
20 namespace gl
21 {
22 
23 // Helper struct representing a single shader uniform
24 struct LinkedUniform
25 {
26     LinkedUniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize, const int blockIndex, const sh::BlockMemberInfo &blockInfo);
27 
28     ~LinkedUniform();
29 
30     bool isArray() const;
31     unsigned int elementCount() const;
32     bool isReferencedByVertexShader() const;
33     bool isReferencedByFragmentShader() const;
34     bool isInDefaultBlock() const;
35     size_t dataSize() const;
36     bool isSampler() const;
37 
38     const GLenum type;
39     const GLenum precision;
40     const std::string name;
41     const unsigned int arraySize;
42     const int blockIndex;
43     const sh::BlockMemberInfo blockInfo;
44 
45     unsigned char *data;
46     bool dirty;
47 
48     unsigned int psRegisterIndex;
49     unsigned int vsRegisterIndex;
50     unsigned int registerCount;
51 
52     // Register "elements" are used for uniform structs in ES3, to appropriately identify single uniforms
53     // inside aggregate types, which are packed according C-like structure rules.
54     unsigned int registerElement;
55 };
56 
57 // Helper struct representing a single shader uniform block
58 struct UniformBlock
59 {
60     // use GL_INVALID_INDEX for non-array elements
61     UniformBlock(const std::string &name, unsigned int elementIndex, unsigned int dataSize);
62 
63     bool isArrayElement() const;
64     bool isReferencedByVertexShader() const;
65     bool isReferencedByFragmentShader() const;
66 
67     const std::string name;
68     const unsigned int elementIndex;
69     const unsigned int dataSize;
70 
71     std::vector<unsigned int> memberUniformIndexes;
72 
73     unsigned int psRegisterIndex;
74     unsigned int vsRegisterIndex;
75 };
76 
77 }
78 
79 #endif   // LIBGLESV2_UNIFORM_H_
80