OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gl/GrGLUniformHandler.h" | 8 #include "gl/GrGLUniformHandler.h" |
9 | 9 |
10 #include "gl/GrGLCaps.h" | 10 #include "gl/GrGLCaps.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 for (int i = 0; i < fSamplers.count(); ++i) { | 78 for (int i = 0; i < fSamplers.count(); ++i) { |
79 if (fSamplers[i].visibility() & visibility) { | 79 if (fSamplers[i].visibility() & visibility) { |
80 fSamplers[i].fShaderVar.appendDecl(fProgramBuilder->glslCaps(), out)
; | 80 fSamplers[i].fShaderVar.appendDecl(fProgramBuilder->glslCaps(), out)
; |
81 out->append(";\n"); | 81 out->append(";\n"); |
82 } | 82 } |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 void GrGLUniformHandler::bindUniformLocations(GrGLuint programID, const GrGLCaps
& caps) { | 86 void GrGLUniformHandler::bindUniformLocations(GrGLuint programID, const GrGLCaps
& caps) { |
87 if (caps.bindUniformLocationSupport()) { | 87 if (caps.bindUniformLocationSupport()) { |
88 int count = fUniforms.count(); | 88 int uniformCount = fUniforms.count(); |
89 for (int i = 0; i < count; ++i) { | 89 for (int i = 0; i < uniformCount; ++i) { |
90 GL_CALL(BindUniformLocation(programID, i, fUniforms[i].fVariable.c_s
tr())); | 90 GL_CALL(BindUniformLocation(programID, i, fUniforms[i].fVariable.c_s
tr())); |
91 fUniforms[i].fLocation = i; | 91 fUniforms[i].fLocation = i; |
92 } | 92 } |
93 for (int i = 0; i < fSamplers.count(); ++i) { | 93 for (int i = 0; i < fSamplers.count(); ++i) { |
94 GL_CALL(BindUniformLocation(programID, i, fSamplers[i].fShaderVar.c_
str())); | 94 GrGLint location = i + uniformCount; |
95 fSamplers[i].fLocation = i; | 95 GL_CALL(BindUniformLocation(programID, location, fSamplers[i].fShade
rVar.c_str())); |
| 96 fSamplers[i].fLocation = location; |
96 } | 97 } |
97 } | 98 } |
98 } | 99 } |
99 | 100 |
100 void GrGLUniformHandler::getUniformLocations(GrGLuint programID, const GrGLCaps&
caps) { | 101 void GrGLUniformHandler::getUniformLocations(GrGLuint programID, const GrGLCaps&
caps) { |
101 if (!caps.bindUniformLocationSupport()) { | 102 if (!caps.bindUniformLocationSupport()) { |
102 int count = fUniforms.count(); | 103 int count = fUniforms.count(); |
103 for (int i = 0; i < count; ++i) { | 104 for (int i = 0; i < count; ++i) { |
104 GrGLint location; | 105 GrGLint location; |
105 GL_CALL_RET(location, GetUniformLocation(programID, fUniforms[i].fVa
riable.c_str())); | 106 GL_CALL_RET(location, GetUniformLocation(programID, fUniforms[i].fVa
riable.c_str())); |
106 fUniforms[i].fLocation = location; | 107 fUniforms[i].fLocation = location; |
107 } | 108 } |
108 for (int i = 0; i < fSamplers.count(); ++i) { | 109 for (int i = 0; i < fSamplers.count(); ++i) { |
109 GrGLint location; | 110 GrGLint location; |
110 GL_CALL_RET(location, GetUniformLocation(programID, fSamplers[i].fSh
aderVar.c_str())); | 111 GL_CALL_RET(location, GetUniformLocation(programID, fSamplers[i].fSh
aderVar.c_str())); |
111 fSamplers[i].fLocation = location; | 112 fSamplers[i].fLocation = location; |
112 } | 113 } |
113 } | 114 } |
114 } | 115 } |
115 | 116 |
116 const GrGLGpu* GrGLUniformHandler::glGpu() const { | 117 const GrGLGpu* GrGLUniformHandler::glGpu() const { |
117 GrGLProgramBuilder* glPB = (GrGLProgramBuilder*) fProgramBuilder; | 118 GrGLProgramBuilder* glPB = (GrGLProgramBuilder*) fProgramBuilder; |
118 return glPB->gpu(); | 119 return glPB->gpu(); |
119 } | 120 } |
OLD | NEW |