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 | { |
| 150 | // Make sure the uniform index array is large enough |
| 151 | if (static_cast<size_t>(location) >= mUniformIndex.size()) |
| 152 | { |
| 153 | mUniformIndex.resize(location + 1); |
| 154 | } |
| 155 | |
| 156 | mUniformIndex[location] = gl::VariableLocation(uniformName, arrayIndex, static_cast<unsigned int>(mUniforms.size())); |
Geoff Lang | f51bc79 | 2015-05-04 14:57:03 -0400 | [diff] [blame] | 157 | |
| 158 | // If the uniform is a sampler, track it in the sampler bindings array |
| 159 | if (gl::IsSamplerType(uniformType)) |
| 160 | { |
| 161 | SamplerLocation samplerLoc; |
| 162 | samplerLoc.samplerIndex = mSamplerBindings.size(); |
| 163 | samplerLoc.arrayIndex = arrayIndex; |
| 164 | mSamplerUniformMap[location] = samplerLoc; |
| 165 | } |
Geoff Lang | 5ed74cf | 2015-04-14 13:57:07 -0400 | [diff] [blame] | 166 | } |
| 167 | } |
| 168 | |
| 169 | // ANGLE uses 0 to identify an non-array uniform. |
| 170 | unsigned int arraySize = (uniformSize > 1) ? static_cast<unsigned int>(uniformSize) : 0; |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 171 | |
| 172 | // TODO: determine uniform precision |
Geoff Lang | 5ed74cf | 2015-04-14 13:57:07 -0400 | [diff] [blame] | 173 | 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] | 174 | |
| 175 | // If uniform is a sampler type, insert it into the mSamplerBindings array |
| 176 | if (gl::IsSamplerType(uniformType)) |
| 177 | { |
| 178 | SamplerBindingGL samplerBinding; |
| 179 | samplerBinding.textureType = gl::SamplerTypeToTextureType(uniformType); |
| 180 | samplerBinding.boundTextureUnits.resize(uniformSize, 0); |
| 181 | mSamplerBindings.push_back(samplerBinding); |
| 182 | } |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | // Query the attribute information |
| 186 | GLint activeAttributeMaxLength = 0; |
| 187 | mFunctions->getProgramiv(mProgramID, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &activeAttributeMaxLength); |
| 188 | |
| 189 | std::vector<GLchar> attributeNameBuffer(activeAttributeMaxLength); |
| 190 | |
| 191 | GLint attributeCount = 0; |
| 192 | mFunctions->getProgramiv(mProgramID, GL_ACTIVE_ATTRIBUTES, &attributeCount); |
| 193 | for (GLint i = 0; i < attributeCount; i++) |
| 194 | { |
| 195 | GLsizei attributeNameLength = 0; |
| 196 | GLint attributeSize = 0; |
| 197 | GLenum attributeType = GL_NONE; |
| 198 | mFunctions->getActiveAttrib(mProgramID, i, attributeNameBuffer.size(), &attributeNameLength, &attributeSize, &attributeType, &attributeNameBuffer[0]); |
| 199 | |
| 200 | std::string attributeName(&attributeNameBuffer[0], attributeNameLength); |
| 201 | |
Geoff Lang | 0ca5378 | 2015-05-07 13:49:39 -0400 | [diff] [blame] | 202 | GLint location = mFunctions->getAttribLocation(mProgramID, attributeName.c_str()); |
| 203 | |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 204 | // TODO: determine attribute precision |
Geoff Lang | 0ca5378 | 2015-05-07 13:49:39 -0400 | [diff] [blame] | 205 | setShaderAttribute(static_cast<size_t>(i), attributeType, GL_NONE, attributeName, attributeSize, location); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | return LinkResult(true, gl::Error(GL_NO_ERROR)); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 209 | } |
| 210 | |
Geoff Lang | 0ca5378 | 2015-05-07 13:49:39 -0400 | [diff] [blame] | 211 | void ProgramGL::bindAttributeLocation(GLuint index, const std::string &name) |
| 212 | { |
| 213 | mFunctions->bindAttribLocation(mProgramID, index, name.c_str()); |
| 214 | } |
| 215 | |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 216 | void ProgramGL::setUniform1fv(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->uniform1fv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | void ProgramGL::setUniform2fv(GLint location, GLsizei count, const GLfloat *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->uniform2fv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | void ProgramGL::setUniform3fv(GLint location, GLsizei count, const GLfloat *v) |
| 229 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 230 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 231 | mFunctions->uniform3fv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | void ProgramGL::setUniform4fv(GLint location, GLsizei count, const GLfloat *v) |
| 235 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 236 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 237 | mFunctions->uniform4fv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | void ProgramGL::setUniform1iv(GLint location, GLsizei count, const GLint *v) |
| 241 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 242 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 243 | mFunctions->uniform1iv(location, count, v); |
Geoff Lang | f51bc79 | 2015-05-04 14:57:03 -0400 | [diff] [blame] | 244 | |
| 245 | auto iter = mSamplerUniformMap.find(location); |
| 246 | if (iter != mSamplerUniformMap.end()) |
| 247 | { |
| 248 | const SamplerLocation &samplerLoc = iter->second; |
| 249 | std::vector<GLuint> &boundTextureUnits = mSamplerBindings[samplerLoc.samplerIndex].boundTextureUnits; |
| 250 | |
| 251 | size_t copyCount = std::max<size_t>(count, boundTextureUnits.size() - samplerLoc.arrayIndex); |
| 252 | std::copy(v, v + copyCount, boundTextureUnits.begin() + samplerLoc.arrayIndex); |
| 253 | } |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | void ProgramGL::setUniform2iv(GLint location, GLsizei count, const GLint *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->uniform2iv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | void ProgramGL::setUniform3iv(GLint location, GLsizei count, const GLint *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->uniform3iv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | void ProgramGL::setUniform4iv(GLint location, GLsizei count, const GLint *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->uniform4iv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | void ProgramGL::setUniform1uiv(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->uniform1uiv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | void ProgramGL::setUniform2uiv(GLint location, GLsizei count, const GLuint *v) |
| 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->uniform2uiv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | void ProgramGL::setUniform3uiv(GLint location, GLsizei count, const GLuint *v) |
| 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->uniform3uiv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | void ProgramGL::setUniform4uiv(GLint location, GLsizei count, const GLuint *v) |
| 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->uniform4uiv(location, count, v); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | void ProgramGL::setUniformMatrix2fv(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->uniformMatrix2fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | void ProgramGL::setUniformMatrix3fv(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->uniformMatrix3fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | void ProgramGL::setUniformMatrix4fv(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->uniformMatrix4fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | void ProgramGL::setUniformMatrix2x3fv(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->uniformMatrix2x3fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | void ProgramGL::setUniformMatrix3x2fv(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->uniformMatrix3x2fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | void ProgramGL::setUniformMatrix2x4fv(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->uniformMatrix2x4fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | void ProgramGL::setUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 335 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 336 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 337 | mFunctions->uniformMatrix4x2fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | void ProgramGL::setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 341 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 342 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 343 | mFunctions->uniformMatrix3x4fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | void ProgramGL::setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
| 347 | { |
Geoff Lang | 63cbace | 2015-02-26 10:03:12 -0500 | [diff] [blame] | 348 | mStateManager->useProgram(mProgramID); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 349 | mFunctions->uniformMatrix4x3fv(location, count, transpose, value); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | void ProgramGL::getUniformfv(GLint location, GLfloat *params) |
| 353 | { |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 354 | mFunctions->getUniformfv(mProgramID, location, params); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | void ProgramGL::getUniformiv(GLint location, GLint *params) |
| 358 | { |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 359 | mFunctions->getUniformiv(mProgramID, location, params); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | void ProgramGL::getUniformuiv(GLint location, GLuint *params) |
| 363 | { |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 364 | mFunctions->getUniformuiv(mProgramID, location, params); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | GLint ProgramGL::getSamplerMapping(gl::SamplerType type, unsigned int samplerIndex, const gl::Caps &caps) const |
| 368 | { |
| 369 | UNIMPLEMENTED(); |
| 370 | return GLint(); |
| 371 | } |
| 372 | |
| 373 | GLenum ProgramGL::getSamplerTextureType(gl::SamplerType type, unsigned int samplerIndex) const |
| 374 | { |
| 375 | UNIMPLEMENTED(); |
| 376 | return GLenum(); |
| 377 | } |
| 378 | |
| 379 | GLint ProgramGL::getUsedSamplerRange(gl::SamplerType type) const |
| 380 | { |
| 381 | UNIMPLEMENTED(); |
| 382 | return GLint(); |
| 383 | } |
| 384 | |
| 385 | void ProgramGL::updateSamplerMapping() |
| 386 | { |
| 387 | UNIMPLEMENTED(); |
| 388 | } |
| 389 | |
| 390 | bool ProgramGL::validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps) |
| 391 | { |
Geoff Lang | 35d315c | 2015-03-31 12:48:54 -0400 | [diff] [blame] | 392 | //UNIMPLEMENTED(); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 393 | return true; |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | LinkResult ProgramGL::compileProgramExecutables(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader, |
| 397 | int registers) |
| 398 | { |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 399 | //UNIMPLEMENTED(); |
| 400 | return LinkResult(true, gl::Error(GL_NO_ERROR)); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | bool ProgramGL::linkUniforms(gl::InfoLog &infoLog, const gl::Shader &vertexShader, const gl::Shader &fragmentShader, |
| 404 | const gl::Caps &caps) |
| 405 | { |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 406 | //UNIMPLEMENTED(); |
| 407 | return true; |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | bool ProgramGL::defineUniformBlock(gl::InfoLog &infoLog, const gl::Shader &shader, const sh::InterfaceBlock &interfaceBlock, |
| 411 | const gl::Caps &caps) |
| 412 | { |
| 413 | UNIMPLEMENTED(); |
| 414 | return bool(); |
| 415 | } |
| 416 | |
| 417 | gl::Error ProgramGL::applyUniforms() |
| 418 | { |
Geoff Lang | c3ab9f7 | 2015-05-27 14:45:59 -0400 | [diff] [blame^] | 419 | //UNIMPLEMENTED(); |
| 420 | // TODO(geofflang) |
| 421 | return gl::Error(GL_NO_ERROR); |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 422 | } |
| 423 | |
Gregoire Payen de La Garanderie | 68694e9 | 2015-03-24 14:03:37 +0000 | [diff] [blame] | 424 | gl::Error ProgramGL::applyUniformBuffers(const gl::Data &data, GLuint uniformBlockBindings[]) |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 425 | { |
| 426 | UNIMPLEMENTED(); |
| 427 | return gl::Error(GL_INVALID_OPERATION); |
| 428 | } |
| 429 | |
| 430 | bool ProgramGL::assignUniformBlockRegister(gl::InfoLog &infoLog, gl::UniformBlock *uniformBlock, GLenum shader, |
| 431 | unsigned int registerIndex, const gl::Caps &caps) |
| 432 | { |
| 433 | UNIMPLEMENTED(); |
| 434 | return bool(); |
| 435 | } |
| 436 | |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 437 | void ProgramGL::reset() |
| 438 | { |
| 439 | ProgramImpl::reset(); |
Geoff Lang | f51bc79 | 2015-05-04 14:57:03 -0400 | [diff] [blame] | 440 | |
| 441 | mSamplerUniformMap.clear(); |
| 442 | mSamplerBindings.clear(); |
Geoff Lang | b1f435e | 2015-02-20 10:01:01 -0500 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | GLuint ProgramGL::getProgramID() const |
| 446 | { |
| 447 | return mProgramID; |
| 448 | } |
| 449 | |
Geoff Lang | f51bc79 | 2015-05-04 14:57:03 -0400 | [diff] [blame] | 450 | const std::vector<SamplerBindingGL> &ProgramGL::getAppliedSamplerUniforms() const |
| 451 | { |
| 452 | return mSamplerBindings; |
| 453 | } |
| 454 | |
Geoff Lang | f9a6f08 | 2015-01-22 13:32:49 -0500 | [diff] [blame] | 455 | } |