Brandon Jones | c9610c5 | 2014-08-25 17:02:59 -0700 | [diff] [blame] | 1 | // |
| 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 Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 9 | #ifndef LIBANGLE_RENDERER_PROGRAMIMPL_H_ |
| 10 | #define LIBANGLE_RENDERER_PROGRAMIMPL_H_ |
Brandon Jones | c9610c5 | 2014-08-25 17:02:59 -0700 | [diff] [blame] | 11 | |
| 12 | #include "common/angleutils.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 13 | #include "libANGLE/BinaryStream.h" |
| 14 | #include "libANGLE/Constants.h" |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 15 | #include "libANGLE/Program.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 16 | #include "libANGLE/Shader.h" |
Brandon Jones | c9610c5 | 2014-08-25 17:02:59 -0700 | [diff] [blame] | 17 | |
Brandon Jones | 1a8a7e3 | 2014-10-01 12:49:30 -0700 | [diff] [blame] | 18 | #include <map> |
| 19 | |
Jamie Madill | 192745a | 2016-12-22 15:58:21 -0500 | [diff] [blame] | 20 | namespace gl |
| 21 | { |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame^] | 22 | class Context; |
Jamie Madill | 192745a | 2016-12-22 15:58:21 -0500 | [diff] [blame] | 23 | class VaryingPacking; |
| 24 | } |
| 25 | |
Jamie Madill | 53ea9cc | 2016-05-17 10:12:52 -0400 | [diff] [blame] | 26 | namespace sh |
| 27 | { |
| 28 | struct BlockMemberInfo; |
| 29 | } |
| 30 | |
Brandon Jones | c9610c5 | 2014-08-25 17:02:59 -0700 | [diff] [blame] | 31 | namespace rx |
| 32 | { |
Jamie Madill | 8ecf7f9 | 2017-01-13 17:29:52 -0500 | [diff] [blame] | 33 | |
Jamie Madill | b0a838b | 2016-11-13 20:02:12 -0500 | [diff] [blame] | 34 | using LinkResult = gl::ErrorOrResult<bool>; |
Geoff Lang | 7dd2e10 | 2014-11-10 15:19:26 -0500 | [diff] [blame] | 35 | |
Jamie Madill | f0d10f8 | 2015-03-31 12:56:52 -0400 | [diff] [blame] | 36 | class ProgramImpl : angle::NonCopyable |
Brandon Jones | c9610c5 | 2014-08-25 17:02:59 -0700 | [diff] [blame] | 37 | { |
Brandon Jones | 1a8a7e3 | 2014-10-01 12:49:30 -0700 | [diff] [blame] | 38 | public: |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 39 | ProgramImpl(const gl::ProgramState &state) : mState(state) {} |
Jamie Madill | 62d31cb | 2015-09-11 13:25:51 -0400 | [diff] [blame] | 40 | virtual ~ProgramImpl() {} |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame^] | 41 | virtual void destroy(const gl::Context *context) {} |
Brandon Jones | 1a8a7e3 | 2014-10-01 12:49:30 -0700 | [diff] [blame] | 42 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame^] | 43 | virtual LinkResult load(const gl::Context *context, |
Jamie Madill | a7d12dc | 2016-12-13 15:08:19 -0500 | [diff] [blame] | 44 | gl::InfoLog &infoLog, |
| 45 | gl::BinaryInputStream *stream) = 0; |
Geoff Lang | b543aff | 2014-09-30 14:52:54 -0400 | [diff] [blame] | 46 | virtual gl::Error save(gl::BinaryOutputStream *stream) = 0; |
Geoff Lang | c562975 | 2015-12-07 16:29:04 -0500 | [diff] [blame] | 47 | virtual void setBinaryRetrievableHint(bool retrievable) = 0; |
Yunchao He | 61afff1 | 2017-03-14 15:34:03 +0800 | [diff] [blame] | 48 | virtual void setSeparable(bool separable) = 0; |
Brandon Jones | 22502d5 | 2014-08-29 16:58:36 -0700 | [diff] [blame] | 49 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame^] | 50 | virtual LinkResult link(const gl::Context *context, |
Jamie Madill | 192745a | 2016-12-22 15:58:21 -0500 | [diff] [blame] | 51 | const gl::VaryingPacking &packing, |
| 52 | gl::InfoLog &infoLog) = 0; |
Jamie Madill | 36cfd6a | 2015-08-18 10:46:20 -0400 | [diff] [blame] | 53 | virtual GLboolean validate(const gl::Caps &caps, gl::InfoLog *infoLog) = 0; |
| 54 | |
Brandon Jones | 1a8a7e3 | 2014-10-01 12:49:30 -0700 | [diff] [blame] | 55 | virtual void setUniform1fv(GLint location, GLsizei count, const GLfloat *v) = 0; |
| 56 | virtual void setUniform2fv(GLint location, GLsizei count, const GLfloat *v) = 0; |
| 57 | virtual void setUniform3fv(GLint location, GLsizei count, const GLfloat *v) = 0; |
| 58 | virtual void setUniform4fv(GLint location, GLsizei count, const GLfloat *v) = 0; |
| 59 | virtual void setUniform1iv(GLint location, GLsizei count, const GLint *v) = 0; |
| 60 | virtual void setUniform2iv(GLint location, GLsizei count, const GLint *v) = 0; |
| 61 | virtual void setUniform3iv(GLint location, GLsizei count, const GLint *v) = 0; |
| 62 | virtual void setUniform4iv(GLint location, GLsizei count, const GLint *v) = 0; |
| 63 | virtual void setUniform1uiv(GLint location, GLsizei count, const GLuint *v) = 0; |
| 64 | virtual void setUniform2uiv(GLint location, GLsizei count, const GLuint *v) = 0; |
| 65 | virtual void setUniform3uiv(GLint location, GLsizei count, const GLuint *v) = 0; |
| 66 | virtual void setUniform4uiv(GLint location, GLsizei count, const GLuint *v) = 0; |
| 67 | virtual void setUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
| 68 | virtual void setUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
| 69 | virtual void setUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
| 70 | virtual void setUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
| 71 | virtual void setUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
| 72 | virtual void setUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
| 73 | virtual void setUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
| 74 | virtual void setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
| 75 | virtual void setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
Brandon Jones | c9610c5 | 2014-08-25 17:02:59 -0700 | [diff] [blame] | 76 | |
Geoff Lang | 5d124a6 | 2015-09-15 13:03:27 -0400 | [diff] [blame] | 77 | // TODO: synchronize in syncState when dirty bits exist. |
| 78 | virtual void setUniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockBinding) = 0; |
| 79 | |
Jamie Madill | 4a3c234 | 2015-10-08 12:58:45 -0400 | [diff] [blame] | 80 | // May only be called after a successful link operation. |
| 81 | // Return false for inactive blocks. |
| 82 | virtual bool getUniformBlockSize(const std::string &blockName, size_t *sizeOut) const = 0; |
| 83 | |
| 84 | // May only be called after a successful link operation. |
| 85 | // Returns false for inactive members. |
| 86 | virtual bool getUniformBlockMemberInfo(const std::string &memberUniformName, |
| 87 | sh::BlockMemberInfo *memberInfoOut) const = 0; |
Sami Väisänen | 46eaa94 | 2016-06-29 10:26:37 +0300 | [diff] [blame] | 88 | // CHROMIUM_path_rendering |
| 89 | // Set parameters to control fragment shader input variable interpolation |
| 90 | virtual void setPathFragmentInputGen(const std::string &inputName, |
| 91 | GLenum genMode, |
| 92 | GLint components, |
| 93 | const GLfloat *coeffs) = 0; |
Jamie Madill | 811b635 | 2015-02-09 10:17:09 -0500 | [diff] [blame] | 94 | |
Brandon Jones | 1a8a7e3 | 2014-10-01 12:49:30 -0700 | [diff] [blame] | 95 | protected: |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 96 | const gl::ProgramState &mState; |
Brandon Jones | c9610c5 | 2014-08-25 17:02:59 -0700 | [diff] [blame] | 97 | }; |
| 98 | |
Jamie Madill | 8ecf7f9 | 2017-01-13 17:29:52 -0500 | [diff] [blame] | 99 | } // namespace rx |
Brandon Jones | c9610c5 | 2014-08-25 17:02:59 -0700 | [diff] [blame] | 100 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 101 | #endif // LIBANGLE_RENDERER_PROGRAMIMPL_H_ |