blob: 5733e79625a340d7f0e66a9fd52b002aaa7c01a4 [file] [log] [blame]
Brandon Jonesc9610c52014-08-25 17:02:59 -07001//
2// Copyright 2014 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// ProgramImpl.h: Defines the abstract rx::ProgramImpl class.
8
Geoff Lang0a73dd82014-11-19 16:18:08 -05009#ifndef LIBANGLE_RENDERER_PROGRAMIMPL_H_
10#define LIBANGLE_RENDERER_PROGRAMIMPL_H_
Brandon Jonesc9610c52014-08-25 17:02:59 -070011
12#include "common/angleutils.h"
Geoff Lang2b5420c2014-11-19 14:20:15 -050013#include "libANGLE/BinaryStream.h"
14#include "libANGLE/Constants.h"
Geoff Lang7dd2e102014-11-10 15:19:26 -050015#include "libANGLE/Program.h"
Geoff Lang2b5420c2014-11-19 14:20:15 -050016#include "libANGLE/Shader.h"
Brandon Jonesc9610c52014-08-25 17:02:59 -070017
Brandon Jones1a8a7e32014-10-01 12:49:30 -070018#include <map>
19
Jamie Madill192745a2016-12-22 15:58:21 -050020namespace gl
21{
22class VaryingPacking;
23}
24
Jamie Madill53ea9cc2016-05-17 10:12:52 -040025namespace sh
26{
27struct BlockMemberInfo;
28}
29
Brandon Jonesc9610c52014-08-25 17:02:59 -070030namespace rx
31{
Jamie Madill8ecf7f92017-01-13 17:29:52 -050032class ContextImpl;
33
Jamie Madillb0a838b2016-11-13 20:02:12 -050034using LinkResult = gl::ErrorOrResult<bool>;
Geoff Lang7dd2e102014-11-10 15:19:26 -050035
Jamie Madillf0d10f82015-03-31 12:56:52 -040036class ProgramImpl : angle::NonCopyable
Brandon Jonesc9610c52014-08-25 17:02:59 -070037{
Brandon Jones1a8a7e32014-10-01 12:49:30 -070038 public:
Jamie Madill48ef11b2016-04-27 15:21:52 -040039 ProgramImpl(const gl::ProgramState &state) : mState(state) {}
Jamie Madill62d31cb2015-09-11 13:25:51 -040040 virtual ~ProgramImpl() {}
Jamie Madill6c1f6712017-02-14 19:08:04 -050041 virtual void destroy(const ContextImpl *contextImpl) {}
Brandon Jones1a8a7e32014-10-01 12:49:30 -070042
Jamie Madilla7d12dc2016-12-13 15:08:19 -050043 virtual LinkResult load(const ContextImpl *contextImpl,
44 gl::InfoLog &infoLog,
45 gl::BinaryInputStream *stream) = 0;
Geoff Langb543aff2014-09-30 14:52:54 -040046 virtual gl::Error save(gl::BinaryOutputStream *stream) = 0;
Geoff Langc5629752015-12-07 16:29:04 -050047 virtual void setBinaryRetrievableHint(bool retrievable) = 0;
Brandon Jones22502d52014-08-29 16:58:36 -070048
Jamie Madill8ecf7f92017-01-13 17:29:52 -050049 virtual LinkResult link(ContextImpl *contextImpl,
Jamie Madill192745a2016-12-22 15:58:21 -050050 const gl::VaryingPacking &packing,
51 gl::InfoLog &infoLog) = 0;
Jamie Madill36cfd6a2015-08-18 10:46:20 -040052 virtual GLboolean validate(const gl::Caps &caps, gl::InfoLog *infoLog) = 0;
53
Brandon Jones1a8a7e32014-10-01 12:49:30 -070054 virtual void setUniform1fv(GLint location, GLsizei count, const GLfloat *v) = 0;
55 virtual void setUniform2fv(GLint location, GLsizei count, const GLfloat *v) = 0;
56 virtual void setUniform3fv(GLint location, GLsizei count, const GLfloat *v) = 0;
57 virtual void setUniform4fv(GLint location, GLsizei count, const GLfloat *v) = 0;
58 virtual void setUniform1iv(GLint location, GLsizei count, const GLint *v) = 0;
59 virtual void setUniform2iv(GLint location, GLsizei count, const GLint *v) = 0;
60 virtual void setUniform3iv(GLint location, GLsizei count, const GLint *v) = 0;
61 virtual void setUniform4iv(GLint location, GLsizei count, const GLint *v) = 0;
62 virtual void setUniform1uiv(GLint location, GLsizei count, const GLuint *v) = 0;
63 virtual void setUniform2uiv(GLint location, GLsizei count, const GLuint *v) = 0;
64 virtual void setUniform3uiv(GLint location, GLsizei count, const GLuint *v) = 0;
65 virtual void setUniform4uiv(GLint location, GLsizei count, const GLuint *v) = 0;
66 virtual void setUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
67 virtual void setUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
68 virtual void setUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
69 virtual void setUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
70 virtual void setUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
71 virtual void setUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
72 virtual void setUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
73 virtual void setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
74 virtual void setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0;
Brandon Jonesc9610c52014-08-25 17:02:59 -070075
Geoff Lang5d124a62015-09-15 13:03:27 -040076 // TODO: synchronize in syncState when dirty bits exist.
77 virtual void setUniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockBinding) = 0;
78
Jamie Madill4a3c2342015-10-08 12:58:45 -040079 // May only be called after a successful link operation.
80 // Return false for inactive blocks.
81 virtual bool getUniformBlockSize(const std::string &blockName, size_t *sizeOut) const = 0;
82
83 // May only be called after a successful link operation.
84 // Returns false for inactive members.
85 virtual bool getUniformBlockMemberInfo(const std::string &memberUniformName,
86 sh::BlockMemberInfo *memberInfoOut) const = 0;
Sami Väisänen46eaa942016-06-29 10:26:37 +030087 // CHROMIUM_path_rendering
88 // Set parameters to control fragment shader input variable interpolation
89 virtual void setPathFragmentInputGen(const std::string &inputName,
90 GLenum genMode,
91 GLint components,
92 const GLfloat *coeffs) = 0;
Jamie Madill811b6352015-02-09 10:17:09 -050093
Brandon Jones1a8a7e32014-10-01 12:49:30 -070094 protected:
Jamie Madill48ef11b2016-04-27 15:21:52 -040095 const gl::ProgramState &mState;
Brandon Jonesc9610c52014-08-25 17:02:59 -070096};
97
Jamie Madill8ecf7f92017-01-13 17:29:52 -050098} // namespace rx
Brandon Jonesc9610c52014-08-25 17:02:59 -070099
Geoff Lang0a73dd82014-11-19 16:18:08 -0500100#endif // LIBANGLE_RENDERER_PROGRAMIMPL_H_