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 | |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 20 | ProgramGL::ProgramGL(const FunctionsGL *functions, StateManagerGL *stateManager) |
| 21 | : ProgramImpl(), |
| 22 | mFunctions(functions), |
| 23 | mStateManager(stateManager), |
| 24 | mProgramID(0) |
| 25 | { |
| 26 | ASSERT(mFunctions); |
| 27 | ASSERT(mStateManager); |
Geoff Lang | 0ca5378 | 2015-05-07 13:49:39 -0400 | [diff] [blame] | 28 | |
| 29 | mProgramID = mFunctions->createProgram(); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 30 | } |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 31 | |
| 32 | ProgramGL::~ProgramGL() |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 33 | { |
Geoff Lang | 0ca5378 | 2015-05-07 13:49:39 -0400 | [diff] [blame] | 34 | mFunctions->deleteProgram(mProgramID); |
| 35 | mProgramID = 0; |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 36 | } |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 37 | |
| 38 | bool ProgramGL::usesPointSize() const |
| 39 | { |
| 40 | UNIMPLEMENTED(); |
| 41 | return bool(); |
| 42 | } |
| 43 | |
| 44 | int ProgramGL::getShaderVersion() const |
| 45 | { |
| 46 | UNIMPLEMENTED(); |
| 47 | return int(); |
| 48 | } |
| 49 | |
| 50 | GLenum ProgramGL::getTransformFeedbackBufferMode() const |
| 51 | { |
| 52 | UNIMPLEMENTED(); |
| 53 | return GLenum(); |
| 54 | } |
| 55 | |
| 56 | GLenum ProgramGL::getBinaryFormat() |
| 57 | { |
| 58 | UNIMPLEMENTED(); |
| 59 | return GLenum(); |
| 60 | } |
| 61 | |
| 62 | LinkResult ProgramGL::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) |
| 63 | { |
| 64 | UNIMPLEMENTED(); |
| 65 | return LinkResult(false, gl::Error(GL_INVALID_OPERATION)); |
| 66 | } |
| 67 | |
| 68 | gl::Error ProgramGL::save(gl::BinaryOutputStream *stream) |
| 69 | { |
| 70 | UNIMPLEMENTED(); |
| 71 | return gl::Error(GL_INVALID_OPERATION); |
| 72 | } |
| 73 | |
| 74 | LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog, |
| 75 | gl::Shader *fragmentShader, gl::Shader *vertexShader, |
| 76 | const std::vector<std::string> &transformFeedbackVaryings, |
| 77 | GLenum transformFeedbackBufferMode, |
| 78 | int *registers, std::vector<gl::LinkedVarying> *linkedVaryings, |
| 79 | std::map<int, gl::VariableLocation> *outputVariables) |
| 80 | { |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 81 | // Reset the program state, delete the current program if one exists |
| 82 | reset(); |
| 83 | |
| 84 | ShaderGL *vertexShaderGL = GetImplAs<ShaderGL>(vertexShader); |
| 85 | ShaderGL *fragmentShaderGL = GetImplAs<ShaderGL>(fragmentShader); |
| 86 | |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 87 | // Attach the shaders |
| 88 | mFunctions->attachShader(mProgramID, vertexShaderGL->getShaderID()); |
| 89 | mFunctions->attachShader(mProgramID, fragmentShaderGL->getShaderID()); |
| 90 | |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 91 | // Link and verify |
| 92 | mFunctions->linkProgram(mProgramID); |
| 93 | |
Geoff Lang | 0ca5378 | 2015-05-07 13:49:39 -0400 | [diff] [blame] | 94 | // Detach the shaders |
| 95 | mFunctions->detachShader(mProgramID, vertexShaderGL->getShaderID()); |
| 96 | mFunctions->detachShader(mProgramID, fragmentShaderGL->getShaderID()); |
| 97 | |
| 98 | // Verify the link |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 99 | GLint linkStatus = GL_FALSE; |
| 100 | mFunctions->getProgramiv(mProgramID, GL_LINK_STATUS, &linkStatus); |
| 101 | ASSERT(linkStatus == GL_TRUE); |
| 102 | if (linkStatus == GL_FALSE) |
| 103 | { |
| 104 | // Linking failed, put the error into the info log |
| 105 | GLint infoLogLength = 0; |
| 106 | mFunctions->getProgramiv(mProgramID, GL_INFO_LOG_LENGTH, &infoLogLength); |
| 107 | |
| 108 | std::vector<char> buf(infoLogLength); |
| 109 | mFunctions->getProgramInfoLog(mProgramID, infoLogLength, nullptr, &buf[0]); |
| 110 | |
| 111 | mFunctions->deleteProgram(mProgramID); |
| 112 | mProgramID = 0; |
| 113 | |
Jamie Madill | f611316 | 2015-05-07 11:49:21 -0400 | [diff] [blame] | 114 | infoLog << &buf[0]; |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 115 | TRACE("\n%s", &buf[0]); |
| 116 | |
| 117 | // TODO, return GL_OUT_OF_MEMORY or just fail the link? This is an unexpected case |
| 118 | return LinkResult(false, gl::Error(GL_NO_ERROR)); |
| 119 | } |
| 120 | |
| 121 | // Query the uniform information |
| 122 | // TODO: A lot of this logic should be done at the gl::Program level |
| 123 | GLint activeUniformMaxLength = 0; |
| 124 | mFunctions->getProgramiv(mProgramID, GL_ACTIVE_UNIFORM_MAX_LENGTH, &activeUniformMaxLength); |
| 125 | |
| 126 | std::vector<GLchar> uniformNameBuffer(activeUniformMaxLength); |
| 127 | |
| 128 | GLint uniformCount = 0; |
| 129 | mFunctions->getProgramiv(mProgramID, GL_ACTIVE_UNIFORMS, &uniformCount); |
| 130 | for (GLint i = 0; i < uniformCount; i++) |
| 131 | { |
| 132 | GLsizei uniformNameLength = 0; |
| 133 | GLint uniformSize = 0; |
| 134 | GLenum uniformType = GL_NONE; |
| 135 | mFunctions->getActiveUniform(mProgramID, i, uniformNameBuffer.size(), &uniformNameLength, &uniformSize, &uniformType, &uniformNameBuffer[0]); |
| 136 | |
Geoff Lang | 5ed74cf | 2015-04-14 13:57:07 -0400 | [diff] [blame] | 137 | std::string uniformName = gl::ParseUniformName(std::string(&uniformNameBuffer[0], uniformNameLength), nullptr); |
| 138 | |
| 139 | for (size_t arrayIndex = 0; arrayIndex < static_cast<size_t>(uniformSize); arrayIndex++) |
| 140 | { |
| 141 | std::string locationName = uniformName; |
| 142 | if (uniformSize > 1) |
| 143 | { |
| 144 | locationName += "[" + Str(arrayIndex) + "]"; |
| 145 | } |
| 146 | |
| 147 | GLint location = mFunctions->getUniformLocation(mProgramID, locationName.c_str()); |
| 148 | if (location >= 0) |
| 149 | { |
Geoff Lang | 5ed74cf | 2015-04-14 13:57:07 -0400 | [diff] [blame] | 150 | mUniformIndex[location] = gl::VariableLocation(uniformName, arrayIndex, static_cast<unsigned int>(mUniforms.size())); |
Geoff Lang | f51bc79 | 2015-05-04 14:57:03 -0400 | [diff] [blame] | 151 | |
| 152 | // If the uniform is a sampler, track it in the sampler bindings array |
| 153 | if (gl::IsSamplerType(uniformType)) |
| 154 | { |
| 155 | SamplerLocation samplerLoc; |
| 156 | samplerLoc.samplerIndex = mSamplerBindings.size(); |
| 157 | samplerLoc.arrayIndex = arrayIndex; |
| 158 | mSamplerUniformMap[location] = samplerLoc; |
| 159 | } |
Geoff Lang | 5ed74cf | 2015-04-14 13:57:07 -0400 | [diff] [blame] | 160 | } |
| 161 | } |
| 162 | |
| 163 | // ANGLE uses 0 to identify an non-array uniform. |
| 164 | unsigned int arraySize = (uniformSize > 1) ? static_cast<unsigned int>(uniformSize) : 0; |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 165 | |
| 166 | // TODO: determine uniform precision |
Geoff Lang | 5ed74cf | 2015-04-14 13:57:07 -0400 | [diff] [blame] | 167 | 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] | 168 | |
| 169 | // If uniform is a sampler type, insert it into the mSamplerBindings array |
| 170 | if (gl::IsSamplerType(uniformType)) |
| 171 | { |
| 172 | SamplerBindingGL samplerBinding; |
| 173 | samplerBinding.textureType = gl::SamplerTypeToTextureType(uniformType); |
| 174 | samplerBinding.boundTextureUnits.resize(uniformSize, 0); |
| 175 | mSamplerBindings.push_back(samplerBinding); |
| 176 | } |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | // Query the attribute information |
| 180 | GLint activeAttributeMaxLength = 0; |
| 181 | mFunctions->getProgramiv(mProgramID, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &activeAttributeMaxLength); |
| 182 | |
| 183 | std::vector<GLchar> attributeNameBuffer(activeAttributeMaxLength); |
| 184 | |
| 185 | GLint attributeCount = 0; |
| 186 | mFunctions->getProgramiv(mProgramID, GL_ACTIVE_ATTRIBUTES, &attributeCount); |
| 187 | for (GLint i = 0; i < attributeCount; i++) |
| 188 | { |
| 189 | GLsizei attributeNameLength = 0; |
| 190 | GLint attributeSize = 0; |
| 191 | GLenum attributeType = GL_NONE; |
| 192 | mFunctions->getActiveAttrib(mProgramID, i, attributeNameBuffer.size(), &attributeNameLength, &attributeSize, &attributeType, &attributeNameBuffer[0]); |
| 193 | |
| 194 | std::string attributeName(&attributeNameBuffer[0], attributeNameLength); |
| 195 | |
Geoff Lang | 0ca5378 | 2015-05-07 13:49:39 -0400 | [diff] [blame] | 196 | GLint location = mFunctions->getAttribLocation(mProgramID, attributeName.c_str()); |
| 197 | |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 198 | // TODO: determine attribute precision |
Geoff Lang | 0ca5378 | 2015-05-07 13:49:39 -0400 | [diff] [blame] | 199 | setShaderAttribute(static_cast<size_t>(i), attributeType, GL_NONE, attributeName, attributeSize, location); |
Geoff Lang | b61e173 | 2015-06-05 11:49:55 -0400 | [diff] [blame^] | 200 | |
| 201 | mActiveAttributeLocations.push_back(location); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | return LinkResult(true, gl::Error(GL_NO_ERROR)); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 205 | } |
| 206 | |
Geoff Lang | 0ca5378 | 2015-05-07 13:49:39 -0400 | [diff] [blame] | 207 | void ProgramGL::bindAttributeLocation(GLuint index, const std::string &name) |
| 208 | { |
| 209 | mFunctions->bindAttribLocation(mProgramID, index, name.c_str()); |
| 210 | } |
| 211 | |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 212 | void ProgramGL::setUniform1fv(GLint location, GLsizei count, const GLfloat *v) |
| 213 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 214 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 215 | mFunctions->uniform1fv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | void ProgramGL::setUniform2fv(GLint location, GLsizei count, const GLfloat *v) |
| 219 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 220 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 221 | mFunctions->uniform2fv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | void ProgramGL::setUniform3fv(GLint location, GLsizei count, const GLfloat *v) |
| 225 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 226 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 227 | mFunctions->uniform3fv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | void ProgramGL::setUniform4fv(GLint location, GLsizei count, const GLfloat *v) |
| 231 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 232 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 233 | mFunctions->uniform4fv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | void ProgramGL::setUniform1iv(GLint location, GLsizei count, const GLint *v) |
| 237 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 238 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 239 | mFunctions->uniform1iv(location, count, v); |
Geoff Lang | f51bc79 | 2015-05-04 14:57:03 -0400 | [diff] [blame] | 240 | |
| 241 | auto iter = mSamplerUniformMap.find(location); |
| 242 | if (iter != mSamplerUniformMap.end()) |
| 243 | { |
| 244 | const SamplerLocation &samplerLoc = iter->second; |
| 245 | std::vector<GLuint> &boundTextureUnits = mSamplerBindings[samplerLoc.samplerIndex].boundTextureUnits; |
| 246 | |
| 247 | size_t copyCount = std::max<size_t>(count, boundTextureUnits.size() - samplerLoc.arrayIndex); |
| 248 | std::copy(v, v + copyCount, boundTextureUnits.begin() + samplerLoc.arrayIndex); |
| 249 | } |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | void ProgramGL::setUniform2iv(GLint location, GLsizei count, const GLint *v) |
| 253 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 254 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 255 | mFunctions->uniform2iv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | void ProgramGL::setUniform3iv(GLint location, GLsizei count, const GLint *v) |
| 259 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 260 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 261 | mFunctions->uniform3iv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | void ProgramGL::setUniform4iv(GLint location, GLsizei count, const GLint *v) |
| 265 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 266 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 267 | mFunctions->uniform4iv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | void ProgramGL::setUniform1uiv(GLint location, GLsizei count, const GLuint *v) |
| 271 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 272 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 273 | mFunctions->uniform1uiv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | void ProgramGL::setUniform2uiv(GLint location, GLsizei count, const GLuint *v) |
| 277 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 278 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 279 | mFunctions->uniform2uiv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | void ProgramGL::setUniform3uiv(GLint location, GLsizei count, const GLuint *v) |
| 283 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 284 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 285 | mFunctions->uniform3uiv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | void ProgramGL::setUniform4uiv(GLint location, GLsizei count, const GLuint *v) |
| 289 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 290 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 291 | mFunctions->uniform4uiv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | void ProgramGL::setUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 295 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 296 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 297 | mFunctions->uniformMatrix2fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | void ProgramGL::setUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 301 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 302 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 303 | mFunctions->uniformMatrix3fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | void ProgramGL::setUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 307 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 308 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 309 | mFunctions->uniformMatrix4fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | void ProgramGL::setUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 313 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 314 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 315 | mFunctions->uniformMatrix2x3fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | void ProgramGL::setUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 319 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 320 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 321 | mFunctions->uniformMatrix3x2fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | void ProgramGL::setUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 325 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 326 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 327 | mFunctions->uniformMatrix2x4fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | void ProgramGL::setUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 331 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 332 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 333 | mFunctions->uniformMatrix4x2fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | void ProgramGL::setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 337 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 338 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 339 | mFunctions->uniformMatrix3x4fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | void ProgramGL::setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 343 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 344 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 345 | mFunctions->uniformMatrix4x3fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | void ProgramGL::getUniformfv(GLint location, GLfloat *params) |
| 349 | { |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 350 | mFunctions->getUniformfv(mProgramID, location, params); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | void ProgramGL::getUniformiv(GLint location, GLint *params) |
| 354 | { |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 355 | mFunctions->getUniformiv(mProgramID, location, params); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | void ProgramGL::getUniformuiv(GLint location, GLuint *params) |
| 359 | { |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 360 | mFunctions->getUniformuiv(mProgramID, location, params); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | GLint ProgramGL::getSamplerMapping(gl::SamplerType type, unsigned int samplerIndex, const gl::Caps &caps) const |
| 364 | { |
| 365 | UNIMPLEMENTED(); |
| 366 | return GLint(); |
| 367 | } |
| 368 | |
| 369 | GLenum ProgramGL::getSamplerTextureType(gl::SamplerType type, unsigned int samplerIndex) const |
| 370 | { |
| 371 | UNIMPLEMENTED(); |
| 372 | return GLenum(); |
| 373 | } |
| 374 | |
| 375 | GLint ProgramGL::getUsedSamplerRange(gl::SamplerType type) const |
| 376 | { |
| 377 | UNIMPLEMENTED(); |
| 378 | return GLint(); |
| 379 | } |
| 380 | |
| 381 | void ProgramGL::updateSamplerMapping() |
| 382 | { |
| 383 | UNIMPLEMENTED(); |
| 384 | } |
| 385 | |
| 386 | bool ProgramGL::validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps) |
| 387 | { |
Geoff Lang | 35d315c | 2015-03-31 12:48:54 -0400 | [diff] [blame] | 388 | //UNIMPLEMENTED(); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 389 | return true; |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | LinkResult ProgramGL::compileProgramExecutables(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader, |
| 393 | int registers) |
| 394 | { |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 395 | //UNIMPLEMENTED(); |
| 396 | return LinkResult(true, gl::Error(GL_NO_ERROR)); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | bool ProgramGL::linkUniforms(gl::InfoLog &infoLog, const gl::Shader &vertexShader, const gl::Shader &fragmentShader, |
| 400 | const gl::Caps &caps) |
| 401 | { |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 402 | //UNIMPLEMENTED(); |
| 403 | return true; |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | bool ProgramGL::defineUniformBlock(gl::InfoLog &infoLog, const gl::Shader &shader, const sh::InterfaceBlock &interfaceBlock, |
| 407 | const gl::Caps &caps) |
| 408 | { |
| 409 | UNIMPLEMENTED(); |
| 410 | return bool(); |
| 411 | } |
| 412 | |
| 413 | gl::Error ProgramGL::applyUniforms() |
| 414 | { |
Geoff Lang | c3ab9f7 | 2015-05-27 14:45:59 -0400 | [diff] [blame] | 415 | //UNIMPLEMENTED(); |
| 416 | // TODO(geofflang) |
| 417 | return gl::Error(GL_NO_ERROR); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 418 | } |
| 419 | |
Gregoire Payen de La Garanderie | 68694e9 | 2015-03-24 14:03:37 +0000 | [diff] [blame] | 420 | gl::Error ProgramGL::applyUniformBuffers(const gl::Data &data, GLuint uniformBlockBindings[]) |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 421 | { |
| 422 | UNIMPLEMENTED(); |
| 423 | return gl::Error(GL_INVALID_OPERATION); |
| 424 | } |
| 425 | |
| 426 | bool ProgramGL::assignUniformBlockRegister(gl::InfoLog &infoLog, gl::UniformBlock *uniformBlock, GLenum shader, |
| 427 | unsigned int registerIndex, const gl::Caps &caps) |
| 428 | { |
| 429 | UNIMPLEMENTED(); |
| 430 | return bool(); |
| 431 | } |
| 432 | |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 433 | void ProgramGL::reset() |
| 434 | { |
| 435 | ProgramImpl::reset(); |
Geoff Lang | f51bc79 | 2015-05-04 14:57:03 -0400 | [diff] [blame] | 436 | |
| 437 | mSamplerUniformMap.clear(); |
| 438 | mSamplerBindings.clear(); |
Geoff Lang | b61e173 | 2015-06-05 11:49:55 -0400 | [diff] [blame^] | 439 | mActiveAttributeLocations.clear(); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | GLuint ProgramGL::getProgramID() const |
| 443 | { |
| 444 | return mProgramID; |
| 445 | } |
| 446 | |
Geoff Lang | f51bc79 | 2015-05-04 14:57:03 -0400 | [diff] [blame] | 447 | const std::vector<SamplerBindingGL> &ProgramGL::getAppliedSamplerUniforms() const |
| 448 | { |
| 449 | return mSamplerBindings; |
| 450 | } |
| 451 | |
Geoff Lang | b61e173 | 2015-06-05 11:49:55 -0400 | [diff] [blame^] | 452 | const std::vector<GLuint> &ProgramGL::getActiveAttributeLocations() const |
| 453 | { |
| 454 | return mActiveAttributeLocations; |
| 455 | } |
| 456 | |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 457 | } |