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 | |
| 9 | #ifndef LIBGLESV2_RENDERER_PROGRAMIMPL_H_ |
| 10 | #define LIBGLESV2_RENDERER_PROGRAMIMPL_H_ |
| 11 | |
| 12 | #include "common/angleutils.h" |
Brandon Jones | 22502d5 | 2014-08-29 16:58:36 -0700 | [diff] [blame] | 13 | #include "libGLESv2/BinaryStream.h" |
Brandon Jones | c9610c5 | 2014-08-25 17:02:59 -0700 | [diff] [blame] | 14 | #include "libGLESv2/Constants.h" |
| 15 | #include "libGLESv2/ProgramBinary.h" |
Brandon Jones | 1a8a7e3 | 2014-10-01 12:49:30 -0700 | [diff] [blame^] | 16 | #include "libGLESv2/Shader.h" |
Brandon Jones | 18bd410 | 2014-09-22 14:21:44 -0700 | [diff] [blame] | 17 | #include "libGLESv2/renderer/Renderer.h" |
Brandon Jones | c9610c5 | 2014-08-25 17:02:59 -0700 | [diff] [blame] | 18 | |
Brandon Jones | 1a8a7e3 | 2014-10-01 12:49:30 -0700 | [diff] [blame^] | 19 | #include <map> |
| 20 | |
Brandon Jones | c9610c5 | 2014-08-25 17:02:59 -0700 | [diff] [blame] | 21 | namespace rx |
| 22 | { |
| 23 | |
Brandon Jones | c9610c5 | 2014-08-25 17:02:59 -0700 | [diff] [blame] | 24 | class Renderer; |
| 25 | |
| 26 | class ProgramImpl |
| 27 | { |
Brandon Jones | 1a8a7e3 | 2014-10-01 12:49:30 -0700 | [diff] [blame^] | 28 | public: |
| 29 | ProgramImpl() { } |
| 30 | virtual ~ProgramImpl(); |
| 31 | |
| 32 | const std::vector<gl::LinkedUniform*> &getUniforms() const { return mUniforms; } |
| 33 | const std::vector<gl::VariableLocation> &getUniformIndices() const { return mUniformIndex; } |
| 34 | const std::vector<gl::UniformBlock*> &getUniformBlocks() const { return mUniformBlocks; } |
| 35 | const std::vector<gl::LinkedVarying> &getTransformFeedbackLinkedVaryings() const { return mTransformFeedbackLinkedVaryings; } |
| 36 | const sh::Attribute *getShaderAttributes() const { return mShaderAttributes; } |
| 37 | |
| 38 | std::vector<gl::LinkedUniform*> &getUniforms() { return mUniforms; } |
| 39 | std::vector<gl::VariableLocation> &getUniformIndices() { return mUniformIndex; } |
| 40 | std::vector<gl::UniformBlock*> &getUniformBlocks() { return mUniformBlocks; } |
| 41 | std::vector<gl::LinkedVarying> &getTransformFeedbackLinkedVaryings() { return mTransformFeedbackLinkedVaryings; } |
| 42 | sh::Attribute *getShaderAttributes() { return mShaderAttributes; } |
| 43 | |
| 44 | gl::LinkedUniform *getUniformByLocation(GLint location) const; |
| 45 | gl::LinkedUniform *getUniformByName(const std::string &name) const; |
| 46 | gl::UniformBlock *getUniformBlockByIndex(GLuint blockIndex) const; |
| 47 | |
| 48 | GLint getUniformLocation(std::string name); |
| 49 | GLuint getUniformIndex(std::string name); |
| 50 | GLuint getUniformBlockIndex(std::string name) const; |
Brandon Jones | c9610c5 | 2014-08-25 17:02:59 -0700 | [diff] [blame] | 51 | |
Brandon Jones | 44151a9 | 2014-09-10 11:32:25 -0700 | [diff] [blame] | 52 | virtual bool usesPointSize() const = 0; |
Brandon Jones | 44151a9 | 2014-09-10 11:32:25 -0700 | [diff] [blame] | 53 | virtual int getShaderVersion() const = 0; |
Brandon Jones | eb99436 | 2014-09-24 10:27:28 -0700 | [diff] [blame] | 54 | virtual GLenum getTransformFeedbackBufferMode() const = 0; |
Brandon Jones | 44151a9 | 2014-09-10 11:32:25 -0700 | [diff] [blame] | 55 | |
Brandon Jones | 22502d5 | 2014-08-29 16:58:36 -0700 | [diff] [blame] | 56 | virtual GLenum getBinaryFormat() = 0; |
Geoff Lang | b543aff | 2014-09-30 14:52:54 -0400 | [diff] [blame] | 57 | virtual gl::LinkResult load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) = 0; |
| 58 | virtual gl::Error save(gl::BinaryOutputStream *stream) = 0; |
Brandon Jones | 22502d5 | 2014-08-29 16:58:36 -0700 | [diff] [blame] | 59 | |
Geoff Lang | b543aff | 2014-09-30 14:52:54 -0400 | [diff] [blame] | 60 | virtual gl::LinkResult link(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader, |
| 61 | const std::vector<std::string> &transformFeedbackVaryings, GLenum transformFeedbackBufferMode, |
| 62 | int *registers, std::vector<gl::LinkedVarying> *linkedVaryings, |
| 63 | std::map<int, gl::VariableLocation> *outputVariables, const gl::Caps &caps) = 0; |
Brandon Jones | 44151a9 | 2014-09-10 11:32:25 -0700 | [diff] [blame] | 64 | |
Brandon Jones | 1a8a7e3 | 2014-10-01 12:49:30 -0700 | [diff] [blame^] | 65 | virtual void setUniform1fv(GLint location, GLsizei count, const GLfloat *v) = 0; |
| 66 | virtual void setUniform2fv(GLint location, GLsizei count, const GLfloat *v) = 0; |
| 67 | virtual void setUniform3fv(GLint location, GLsizei count, const GLfloat *v) = 0; |
| 68 | virtual void setUniform4fv(GLint location, GLsizei count, const GLfloat *v) = 0; |
| 69 | virtual void setUniform1iv(GLint location, GLsizei count, const GLint *v) = 0; |
| 70 | virtual void setUniform2iv(GLint location, GLsizei count, const GLint *v) = 0; |
| 71 | virtual void setUniform3iv(GLint location, GLsizei count, const GLint *v) = 0; |
| 72 | virtual void setUniform4iv(GLint location, GLsizei count, const GLint *v) = 0; |
| 73 | virtual void setUniform1uiv(GLint location, GLsizei count, const GLuint *v) = 0; |
| 74 | virtual void setUniform2uiv(GLint location, GLsizei count, const GLuint *v) = 0; |
| 75 | virtual void setUniform3uiv(GLint location, GLsizei count, const GLuint *v) = 0; |
| 76 | virtual void setUniform4uiv(GLint location, GLsizei count, const GLuint *v) = 0; |
| 77 | virtual void setUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
| 78 | virtual void setUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
| 79 | virtual void setUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
| 80 | virtual void setUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
| 81 | virtual void setUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
| 82 | virtual void setUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
| 83 | virtual void setUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
| 84 | virtual void setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) = 0; |
| 85 | 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] | 86 | |
Brandon Jones | 1a8a7e3 | 2014-10-01 12:49:30 -0700 | [diff] [blame^] | 87 | virtual void getUniformfv(GLint location, GLfloat *params) = 0; |
| 88 | virtual void getUniformiv(GLint location, GLint *params) = 0; |
| 89 | virtual void getUniformuiv(GLint location, GLuint *params) = 0; |
| 90 | |
| 91 | virtual void reset(); |
| 92 | |
| 93 | // TODO: The following functions are possibly only applicable to D3D backends. The should be carefully evaluated to |
| 94 | // determine if they can be removed from this interface. |
| 95 | virtual GLint getSamplerMapping(gl::SamplerType type, unsigned int samplerIndex, const gl::Caps &caps) const = 0; |
| 96 | virtual GLenum getSamplerTextureType(gl::SamplerType type, unsigned int samplerIndex) const = 0; |
| 97 | virtual GLint getUsedSamplerRange(gl::SamplerType type) const = 0; |
| 98 | virtual void updateSamplerMapping() = 0; |
| 99 | virtual bool validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps) = 0; |
| 100 | |
| 101 | virtual gl::LinkResult compileProgramExecutables(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader, |
| 102 | int registers) = 0; |
| 103 | |
| 104 | virtual bool linkUniforms(gl::InfoLog &infoLog, const gl::Shader &vertexShader, const gl::Shader &fragmentShader, |
| 105 | const gl::Caps &caps) = 0; |
| 106 | virtual bool defineUniformBlock(gl::InfoLog &infoLog, const gl::Shader &shader, const sh::InterfaceBlock &interfaceBlock, |
| 107 | const gl::Caps &caps) = 0; |
| 108 | |
| 109 | virtual gl::Error applyUniforms() = 0; |
| 110 | virtual gl::Error applyUniformBuffers(const std::vector<gl::Buffer*> boundBuffers, const gl::Caps &caps) = 0; |
Brandon Jones | 18bd410 | 2014-09-22 14:21:44 -0700 | [diff] [blame] | 111 | virtual bool assignUniformBlockRegister(gl::InfoLog &infoLog, gl::UniformBlock *uniformBlock, GLenum shader, |
| 112 | unsigned int registerIndex, const gl::Caps &caps) = 0; |
Brandon Jones | 18bd410 | 2014-09-22 14:21:44 -0700 | [diff] [blame] | 113 | |
Brandon Jones | 1a8a7e3 | 2014-10-01 12:49:30 -0700 | [diff] [blame^] | 114 | protected: |
| 115 | DISALLOW_COPY_AND_ASSIGN(ProgramImpl); |
| 116 | |
| 117 | std::vector<gl::LinkedUniform*> mUniforms; |
| 118 | std::vector<gl::VariableLocation> mUniformIndex; |
| 119 | std::vector<gl::UniformBlock*> mUniformBlocks; |
| 120 | std::vector<gl::LinkedVarying> mTransformFeedbackLinkedVaryings; |
| 121 | |
| 122 | sh::Attribute mShaderAttributes[gl::MAX_VERTEX_ATTRIBS]; |
Brandon Jones | c9610c5 | 2014-08-25 17:02:59 -0700 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | } |
| 126 | |
| 127 | #endif // LIBGLESV2_RENDERER_PROGRAMIMPL_H_ |