xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/gl/ProgramExecutableGL.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1 //
2 // Copyright 2023 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 // ProgramExecutableGL.h: Implementation of ProgramExecutableImpl.
8 
9 #ifndef LIBANGLE_RENDERER_GL_PROGRAMEXECUTABLEGL_H_
10 #define LIBANGLE_RENDERER_GL_PROGRAMEXECUTABLEGL_H_
11 
12 #include "libANGLE/ProgramExecutable.h"
13 #include "libANGLE/renderer/ProgramExecutableImpl.h"
14 
15 namespace angle
16 {
17 struct FeaturesGL;
18 }  // namespace angle
19 
20 namespace rx
21 {
22 class FunctionsGL;
23 class StateManagerGL;
24 
25 class ProgramExecutableGL : public ProgramExecutableImpl
26 {
27   public:
28     ProgramExecutableGL(const gl::ProgramExecutable *executable);
29     ~ProgramExecutableGL() override;
30 
31     void destroy(const gl::Context *context) override;
32 
33     void setUniform1fv(GLint location, GLsizei count, const GLfloat *v) override;
34     void setUniform2fv(GLint location, GLsizei count, const GLfloat *v) override;
35     void setUniform3fv(GLint location, GLsizei count, const GLfloat *v) override;
36     void setUniform4fv(GLint location, GLsizei count, const GLfloat *v) override;
37     void setUniform1iv(GLint location, GLsizei count, const GLint *v) override;
38     void setUniform2iv(GLint location, GLsizei count, const GLint *v) override;
39     void setUniform3iv(GLint location, GLsizei count, const GLint *v) override;
40     void setUniform4iv(GLint location, GLsizei count, const GLint *v) override;
41     void setUniform1uiv(GLint location, GLsizei count, const GLuint *v) override;
42     void setUniform2uiv(GLint location, GLsizei count, const GLuint *v) override;
43     void setUniform3uiv(GLint location, GLsizei count, const GLuint *v) override;
44     void setUniform4uiv(GLint location, GLsizei count, const GLuint *v) override;
45     void setUniformMatrix2fv(GLint location,
46                              GLsizei count,
47                              GLboolean transpose,
48                              const GLfloat *value) override;
49     void setUniformMatrix3fv(GLint location,
50                              GLsizei count,
51                              GLboolean transpose,
52                              const GLfloat *value) override;
53     void setUniformMatrix4fv(GLint location,
54                              GLsizei count,
55                              GLboolean transpose,
56                              const GLfloat *value) override;
57     void setUniformMatrix2x3fv(GLint location,
58                                GLsizei count,
59                                GLboolean transpose,
60                                const GLfloat *value) override;
61     void setUniformMatrix3x2fv(GLint location,
62                                GLsizei count,
63                                GLboolean transpose,
64                                const GLfloat *value) override;
65     void setUniformMatrix2x4fv(GLint location,
66                                GLsizei count,
67                                GLboolean transpose,
68                                const GLfloat *value) override;
69     void setUniformMatrix4x2fv(GLint location,
70                                GLsizei count,
71                                GLboolean transpose,
72                                const GLfloat *value) override;
73     void setUniformMatrix3x4fv(GLint location,
74                                GLsizei count,
75                                GLboolean transpose,
76                                const GLfloat *value) override;
77     void setUniformMatrix4x3fv(GLint location,
78                                GLsizei count,
79                                GLboolean transpose,
80                                const GLfloat *value) override;
81 
82     void getUniformfv(const gl::Context *context, GLint location, GLfloat *params) const override;
83     void getUniformiv(const gl::Context *context, GLint location, GLint *params) const override;
84     void getUniformuiv(const gl::Context *context, GLint location, GLuint *params) const override;
85 
86     void updateEnabledClipDistances(uint8_t enabledClipDistancesPacked) const;
87 
88     void updateEmulatedClipOrigin(gl::ClipOrigin origin) const;
89 
90     void enableLayeredRenderingPath(int baseViewIndex) const;
91 
92     void syncUniformBlockBindings();
93 
getProgramID()94     GLuint getProgramID() const { return mProgramID; }
95 
96   private:
97     friend class ProgramGL;
98 
99     void reset();
100     void postLink(const FunctionsGL *functions,
101                   StateManagerGL *stateManager,
102                   const angle::FeaturesGL &features,
103                   GLuint programID);
104 
105     // Helper function, makes it simpler to type.
uniLoc(GLint glLocation)106     GLint uniLoc(GLint glLocation) const { return mUniformRealLocationMap[glLocation]; }
107 
108     void setUniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockBinding);
109     void reapplyUBOBindings();
110 
111     std::vector<GLint> mUniformRealLocationMap;
112     std::vector<GLuint> mUniformBlockRealLocationMap;
113 
114     bool mHasAppliedTransformFeedbackVaryings;
115 
116     GLint mClipDistanceEnabledUniformLocation;
117 
118     GLint mClipOriginUniformLocation;
119 
120     GLint mMultiviewBaseViewLayerIndexUniformLocation;
121 
122     // Indiciates which uniform blocks have had their bindings changed since last sync.  These
123     // changes are a result of calls to glUniformBlockBinding, and only the GL backend needs to
124     // directly act on them (which is why it's not tracked by the front-end, the other backends
125     // combine this info with the actual buffer bindings).
126     angle::BitSet<gl::IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS>
127         mDirtyUniformBlockBindings;
128 
129     // The program for which the executable was built
130     GLuint mProgramID;
131     const FunctionsGL *mFunctions;
132     StateManagerGL *mStateManager;
133 };
134 
135 }  // namespace rx
136 
137 #endif  // LIBANGLE_RENDERER_GL_PROGRAMEXECUTABLEGL_H_
138