Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2015 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 | // ProgramGL.cpp: Implements the class methods for ProgramGL. |
| 8 | |
| 9 | #include "libANGLE/renderer/gl/ProgramGL.h" |
| 10 | |
| 11 | #include "common/debug.h" |
Geoff Lang | 5ed74cf | 2015-04-14 13:57:07 -0400 | [diff] [blame] | 12 | #include "common/utilities.h" |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 13 | #include "libANGLE/renderer/gl/FunctionsGL.h" |
| 14 | #include "libANGLE/renderer/gl/ShaderGL.h" |
| 15 | #include "libANGLE/renderer/gl/StateManagerGL.h" |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 16 | |
| 17 | namespace rx |
| 18 | { |
| 19 | |
Jamie Madill | 5c6b7bf | 2015-08-17 12:53:35 -0400 | [diff] [blame] | 20 | ProgramGL::ProgramGL(const gl::Program::Data &data, |
| 21 | const FunctionsGL *functions, |
| 22 | StateManagerGL *stateManager) |
| 23 | : ProgramImpl(data), mFunctions(functions), mStateManager(stateManager), mProgramID(0) |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 24 | { |
| 25 | ASSERT(mFunctions); |
| 26 | ASSERT(mStateManager); |
Geoff Lang | 0ca5378 | 2015-05-07 13:49:39 -0400 | [diff] [blame] | 27 | |
| 28 | mProgramID = mFunctions->createProgram(); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 29 | } |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 30 | |
| 31 | ProgramGL::~ProgramGL() |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 32 | { |
Geoff Lang | 0ca5378 | 2015-05-07 13:49:39 -0400 | [diff] [blame] | 33 | mFunctions->deleteProgram(mProgramID); |
| 34 | mProgramID = 0; |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 35 | } |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 36 | |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 37 | int ProgramGL::getShaderVersion() const |
| 38 | { |
| 39 | UNIMPLEMENTED(); |
| 40 | return int(); |
| 41 | } |
| 42 | |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 43 | GLenum ProgramGL::getBinaryFormat() |
| 44 | { |
| 45 | UNIMPLEMENTED(); |
| 46 | return GLenum(); |
| 47 | } |
| 48 | |
| 49 | LinkResult ProgramGL::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) |
| 50 | { |
| 51 | UNIMPLEMENTED(); |
| 52 | return LinkResult(false, gl::Error(GL_INVALID_OPERATION)); |
| 53 | } |
| 54 | |
| 55 | gl::Error ProgramGL::save(gl::BinaryOutputStream *stream) |
| 56 | { |
| 57 | UNIMPLEMENTED(); |
| 58 | return gl::Error(GL_INVALID_OPERATION); |
| 59 | } |
| 60 | |
Jamie Madill | ccdf74b | 2015-08-18 10:46:12 -0400 | [diff] [blame] | 61 | LinkResult ProgramGL::link(const gl::Data &data, |
| 62 | gl::InfoLog &infoLog, |
| 63 | gl::Shader *fragmentShader, |
| 64 | gl::Shader *vertexShader, |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 65 | std::map<int, gl::VariableLocation> *outputVariables) |
| 66 | { |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 67 | // Reset the program state, delete the current program if one exists |
| 68 | reset(); |
| 69 | |
Jamie Madill | ada9ecc | 2015-08-17 12:53:37 -0400 | [diff] [blame] | 70 | const ShaderGL *vertexShaderGL = GetImplAs<ShaderGL>(vertexShader); |
| 71 | const ShaderGL *fragmentShaderGL = GetImplAs<ShaderGL>(fragmentShader); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 72 | |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 73 | // Attach the shaders |
| 74 | mFunctions->attachShader(mProgramID, vertexShaderGL->getShaderID()); |
| 75 | mFunctions->attachShader(mProgramID, fragmentShaderGL->getShaderID()); |
| 76 | |
Geoff Lang | 1528e56 | 2015-08-24 15:10:58 -0400 | [diff] [blame^] | 77 | // Bind attribute locations to match the GL layer. |
| 78 | for (const sh::Attribute &attribute : mData.getAttributes()) |
| 79 | { |
| 80 | if (!attribute.staticUse) |
| 81 | { |
| 82 | continue; |
| 83 | } |
| 84 | |
| 85 | mFunctions->bindAttribLocation(mProgramID, attribute.location, attribute.name.c_str()); |
| 86 | |
| 87 | int registerCount = gl::VariableRegisterCount(attribute.type); |
| 88 | for (int offset = 0; offset < registerCount; ++offset) |
| 89 | { |
| 90 | mActiveAttributesMask.set(attribute.location + offset); |
| 91 | } |
| 92 | } |
| 93 | |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 94 | // Link and verify |
| 95 | mFunctions->linkProgram(mProgramID); |
| 96 | |
Geoff Lang | 0ca5378 | 2015-05-07 13:49:39 -0400 | [diff] [blame] | 97 | // Detach the shaders |
| 98 | mFunctions->detachShader(mProgramID, vertexShaderGL->getShaderID()); |
| 99 | mFunctions->detachShader(mProgramID, fragmentShaderGL->getShaderID()); |
| 100 | |
| 101 | // Verify the link |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 102 | GLint linkStatus = GL_FALSE; |
| 103 | mFunctions->getProgramiv(mProgramID, GL_LINK_STATUS, &linkStatus); |
| 104 | ASSERT(linkStatus == GL_TRUE); |
| 105 | if (linkStatus == GL_FALSE) |
| 106 | { |
| 107 | // Linking failed, put the error into the info log |
| 108 | GLint infoLogLength = 0; |
| 109 | mFunctions->getProgramiv(mProgramID, GL_INFO_LOG_LENGTH, &infoLogLength); |
| 110 | |
| 111 | std::vector<char> buf(infoLogLength); |
| 112 | mFunctions->getProgramInfoLog(mProgramID, infoLogLength, nullptr, &buf[0]); |
| 113 | |
| 114 | mFunctions->deleteProgram(mProgramID); |
| 115 | mProgramID = 0; |
| 116 | |
Jamie Madill | f611316 | 2015-05-07 11:49:21 -0400 | [diff] [blame] | 117 | infoLog << &buf[0]; |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 118 | TRACE("\n%s", &buf[0]); |
| 119 | |
| 120 | // TODO, return GL_OUT_OF_MEMORY or just fail the link? This is an unexpected case |
| 121 | return LinkResult(false, gl::Error(GL_NO_ERROR)); |
| 122 | } |
| 123 | |
| 124 | // Query the uniform information |
| 125 | // TODO: A lot of this logic should be done at the gl::Program level |
| 126 | GLint activeUniformMaxLength = 0; |
| 127 | mFunctions->getProgramiv(mProgramID, GL_ACTIVE_UNIFORM_MAX_LENGTH, &activeUniformMaxLength); |
| 128 | |
| 129 | std::vector<GLchar> uniformNameBuffer(activeUniformMaxLength); |
| 130 | |
| 131 | GLint uniformCount = 0; |
| 132 | mFunctions->getProgramiv(mProgramID, GL_ACTIVE_UNIFORMS, &uniformCount); |
| 133 | for (GLint i = 0; i < uniformCount; i++) |
| 134 | { |
| 135 | GLsizei uniformNameLength = 0; |
| 136 | GLint uniformSize = 0; |
| 137 | GLenum uniformType = GL_NONE; |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 138 | mFunctions->getActiveUniform(mProgramID, i, static_cast<GLsizei>(uniformNameBuffer.size()), |
| 139 | &uniformNameLength, &uniformSize, &uniformType, |
| 140 | &uniformNameBuffer[0]); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 141 | |
Geoff Lang | 79d059f | 2015-07-28 15:03:28 -0400 | [diff] [blame] | 142 | size_t subscript = 0; |
| 143 | std::string uniformName = gl::ParseUniformName(std::string(&uniformNameBuffer[0], uniformNameLength), &subscript); |
| 144 | |
| 145 | bool isArray = uniformSize > 1 || subscript != GL_INVALID_INDEX; |
Geoff Lang | 5ed74cf | 2015-04-14 13:57:07 -0400 | [diff] [blame] | 146 | |
| 147 | for (size_t arrayIndex = 0; arrayIndex < static_cast<size_t>(uniformSize); arrayIndex++) |
| 148 | { |
| 149 | std::string locationName = uniformName; |
Geoff Lang | 79d059f | 2015-07-28 15:03:28 -0400 | [diff] [blame] | 150 | if (isArray) |
Geoff Lang | 5ed74cf | 2015-04-14 13:57:07 -0400 | [diff] [blame] | 151 | { |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 152 | locationName += "[" + Str(static_cast<int>(arrayIndex)) + "]"; |
Geoff Lang | 5ed74cf | 2015-04-14 13:57:07 -0400 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | GLint location = mFunctions->getUniformLocation(mProgramID, locationName.c_str()); |
| 156 | if (location >= 0) |
| 157 | { |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 158 | mUniformIndex[location] = |
| 159 | gl::VariableLocation(uniformName, static_cast<unsigned int>(arrayIndex), |
| 160 | static_cast<unsigned int>(mUniforms.size())); |
Geoff Lang | f51bc79 | 2015-05-04 14:57:03 -0400 | [diff] [blame] | 161 | |
| 162 | // If the uniform is a sampler, track it in the sampler bindings array |
| 163 | if (gl::IsSamplerType(uniformType)) |
| 164 | { |
| 165 | SamplerLocation samplerLoc; |
| 166 | samplerLoc.samplerIndex = mSamplerBindings.size(); |
| 167 | samplerLoc.arrayIndex = arrayIndex; |
| 168 | mSamplerUniformMap[location] = samplerLoc; |
| 169 | } |
Geoff Lang | 5ed74cf | 2015-04-14 13:57:07 -0400 | [diff] [blame] | 170 | } |
| 171 | } |
| 172 | |
| 173 | // ANGLE uses 0 to identify an non-array uniform. |
Geoff Lang | 79d059f | 2015-07-28 15:03:28 -0400 | [diff] [blame] | 174 | unsigned int arraySize = isArray ? static_cast<unsigned int>(uniformSize) : 0; |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 175 | |
| 176 | // TODO: determine uniform precision |
Geoff Lang | 5ed74cf | 2015-04-14 13:57:07 -0400 | [diff] [blame] | 177 | mUniforms.push_back(new gl::LinkedUniform(uniformType, GL_NONE, uniformName, arraySize, -1, sh::BlockMemberInfo::getDefaultBlockInfo())); |
Geoff Lang | f51bc79 | 2015-05-04 14:57:03 -0400 | [diff] [blame] | 178 | |
| 179 | // If uniform is a sampler type, insert it into the mSamplerBindings array |
| 180 | if (gl::IsSamplerType(uniformType)) |
| 181 | { |
| 182 | SamplerBindingGL samplerBinding; |
| 183 | samplerBinding.textureType = gl::SamplerTypeToTextureType(uniformType); |
| 184 | samplerBinding.boundTextureUnits.resize(uniformSize, 0); |
| 185 | mSamplerBindings.push_back(samplerBinding); |
| 186 | } |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 187 | } |
| 188 | |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 189 | return LinkResult(true, gl::Error(GL_NO_ERROR)); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 190 | } |
| 191 | |
Jamie Madill | 36cfd6a | 2015-08-18 10:46:20 -0400 | [diff] [blame] | 192 | GLboolean ProgramGL::validate(const gl::Caps & /*caps*/, gl::InfoLog * /*infoLog*/) |
| 193 | { |
| 194 | // TODO(jmadill): implement validate |
| 195 | return true; |
| 196 | } |
| 197 | |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 198 | void ProgramGL::setUniform1fv(GLint location, GLsizei count, const GLfloat *v) |
| 199 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 200 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 201 | mFunctions->uniform1fv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | void ProgramGL::setUniform2fv(GLint location, GLsizei count, const GLfloat *v) |
| 205 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 206 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 207 | mFunctions->uniform2fv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | void ProgramGL::setUniform3fv(GLint location, GLsizei count, const GLfloat *v) |
| 211 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 212 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 213 | mFunctions->uniform3fv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | void ProgramGL::setUniform4fv(GLint location, GLsizei count, const GLfloat *v) |
| 217 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 218 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 219 | mFunctions->uniform4fv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | void ProgramGL::setUniform1iv(GLint location, GLsizei count, const GLint *v) |
| 223 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 224 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 225 | mFunctions->uniform1iv(location, count, v); |
Geoff Lang | f51bc79 | 2015-05-04 14:57:03 -0400 | [diff] [blame] | 226 | |
| 227 | auto iter = mSamplerUniformMap.find(location); |
| 228 | if (iter != mSamplerUniformMap.end()) |
| 229 | { |
| 230 | const SamplerLocation &samplerLoc = iter->second; |
| 231 | std::vector<GLuint> &boundTextureUnits = mSamplerBindings[samplerLoc.samplerIndex].boundTextureUnits; |
| 232 | |
| 233 | size_t copyCount = std::max<size_t>(count, boundTextureUnits.size() - samplerLoc.arrayIndex); |
| 234 | std::copy(v, v + copyCount, boundTextureUnits.begin() + samplerLoc.arrayIndex); |
| 235 | } |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | void ProgramGL::setUniform2iv(GLint location, GLsizei count, const GLint *v) |
| 239 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 240 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 241 | mFunctions->uniform2iv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | void ProgramGL::setUniform3iv(GLint location, GLsizei count, const GLint *v) |
| 245 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 246 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 247 | mFunctions->uniform3iv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | void ProgramGL::setUniform4iv(GLint location, GLsizei count, const GLint *v) |
| 251 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 252 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 253 | mFunctions->uniform4iv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | void ProgramGL::setUniform1uiv(GLint location, GLsizei count, const GLuint *v) |
| 257 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 258 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 259 | mFunctions->uniform1uiv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | void ProgramGL::setUniform2uiv(GLint location, GLsizei count, const GLuint *v) |
| 263 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 264 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 265 | mFunctions->uniform2uiv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | void ProgramGL::setUniform3uiv(GLint location, GLsizei count, const GLuint *v) |
| 269 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 270 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 271 | mFunctions->uniform3uiv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | void ProgramGL::setUniform4uiv(GLint location, GLsizei count, const GLuint *v) |
| 275 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 276 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 277 | mFunctions->uniform4uiv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | void ProgramGL::setUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 281 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 282 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 283 | mFunctions->uniformMatrix2fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | void ProgramGL::setUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 287 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 288 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 289 | mFunctions->uniformMatrix3fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | void ProgramGL::setUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 293 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 294 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 295 | mFunctions->uniformMatrix4fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | void ProgramGL::setUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 299 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 300 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 301 | mFunctions->uniformMatrix2x3fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | void ProgramGL::setUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 305 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 306 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 307 | mFunctions->uniformMatrix3x2fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | void ProgramGL::setUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 311 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 312 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 313 | mFunctions->uniformMatrix2x4fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | void ProgramGL::setUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 317 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 318 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 319 | mFunctions->uniformMatrix4x2fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | void ProgramGL::setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 323 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 324 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 325 | mFunctions->uniformMatrix3x4fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | void ProgramGL::setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 329 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 330 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 331 | mFunctions->uniformMatrix4x3fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | void ProgramGL::getUniformfv(GLint location, GLfloat *params) |
| 335 | { |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 336 | mFunctions->getUniformfv(mProgramID, location, params); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | void ProgramGL::getUniformiv(GLint location, GLint *params) |
| 340 | { |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 341 | mFunctions->getUniformiv(mProgramID, location, params); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | void ProgramGL::getUniformuiv(GLint location, GLuint *params) |
| 345 | { |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 346 | mFunctions->getUniformuiv(mProgramID, location, params); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 347 | } |
| 348 | |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 349 | bool ProgramGL::validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps) |
| 350 | { |
Geoff Lang | 35d315c | 2015-03-31 12:48:54 -0400 | [diff] [blame] | 351 | //UNIMPLEMENTED(); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 352 | return true; |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 353 | } |
| 354 | |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 355 | void ProgramGL::reset() |
| 356 | { |
| 357 | ProgramImpl::reset(); |
Geoff Lang | f51bc79 | 2015-05-04 14:57:03 -0400 | [diff] [blame] | 358 | |
| 359 | mSamplerUniformMap.clear(); |
| 360 | mSamplerBindings.clear(); |
Jamie Madill | 0b9e903 | 2015-08-17 11:51:52 +0000 | [diff] [blame] | 361 | mActiveAttributesMask.reset(); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | GLuint ProgramGL::getProgramID() const |
| 365 | { |
| 366 | return mProgramID; |
| 367 | } |
| 368 | |
Geoff Lang | f51bc79 | 2015-05-04 14:57:03 -0400 | [diff] [blame] | 369 | const std::vector<SamplerBindingGL> &ProgramGL::getAppliedSamplerUniforms() const |
| 370 | { |
| 371 | return mSamplerBindings; |
| 372 | } |
| 373 | |
Jamie Madill | 0b9e903 | 2015-08-17 11:51:52 +0000 | [diff] [blame] | 374 | const gl::AttributesMask &ProgramGL::getActiveAttributesMask() const |
Geoff Lang | b61e173 | 2015-06-05 11:49:55 -0400 | [diff] [blame] | 375 | { |
Jamie Madill | 0b9e903 | 2015-08-17 11:51:52 +0000 | [diff] [blame] | 376 | return mActiveAttributesMask; |
Geoff Lang | b61e173 | 2015-06-05 11:49:55 -0400 | [diff] [blame] | 377 | } |
| 378 | |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 379 | } |