Bug 1218944. Transform feedback linking should use varyings intead of attribs. r=jgilbert
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Tue, 03 Nov 2015 11:02:29 -0500
changeset 292854 6c14623c763ea5b0f52e4f2d7dfd178147491854
parent 292853 c780a165dca1d72d0a0fdfa82b5504eba120feb2
child 292855 13c39f24d52fe6fc26eefecdebf19226ecb729a8
push id8824
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:18:56 +0000
treeherdermozilla-aurora@e2031358e2a6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1218944
milestone45.0a1
Bug 1218944. Transform feedback linking should use varyings intead of attribs. r=jgilbert
dom/canvas/WebGLShader.cpp
dom/canvas/WebGLShaderValidator.cpp
dom/canvas/WebGLShaderValidator.h
--- a/dom/canvas/WebGLShader.cpp
+++ b/dom/canvas/WebGLShader.cpp
@@ -374,19 +374,18 @@ WebGLShader::ApplyTransformFeedbackVaryi
     const size_t varyingsCount = varyings.size();
     std::vector<std::string> mappedVaryings;
 
     for (size_t i = 0; i < varyingsCount; i++) {
         const nsCString& userName = varyings[i];
         std::string userNameStr(userName.BeginReading());
 
         const std::string* mappedNameStr = &userNameStr;
-        // TODO: Are vertex->fragment shader varyings listed under attribs?
         if (mValidator)
-            mValidator->FindAttribMappedNameByUserName(userNameStr, &mappedNameStr);
+            mValidator->FindVaryingMappedNameByUserName(userNameStr, &mappedNameStr);
 
         mappedVaryings.push_back(*mappedNameStr);
     }
 
     // Temporary, tight packed array of string pointers into mappedVaryings.
     std::vector<const GLchar*> strings;
     strings.resize(varyingsCount);
     for (size_t i = 0; i < varyingsCount; i++) {
--- a/dom/canvas/WebGLShaderValidator.cpp
+++ b/dom/canvas/WebGLShaderValidator.cpp
@@ -356,16 +356,31 @@ ShaderValidator::FindAttribMappedNameByU
             *out_mappedName = &(itr->mappedName);
             return true;
         }
     }
 
     return false;
 }
 
+bool
+ShaderValidator::FindVaryingMappedNameByUserName(const std::string& userName,
+                                                 const std::string** const out_mappedName) const
+{
+    const std::vector<sh::Varying>& attribs = *ShGetVaryings(mHandle);
+    for (auto itr = attribs.begin(); itr != attribs.end(); ++itr) {
+        if (itr->name == userName) {
+            *out_mappedName = &(itr->mappedName);
+            return true;
+        }
+    }
+
+    return false;
+}
+
 // This must handle names like "foo.bar[0]".
 bool
 ShaderValidator::FindUniformByMappedName(const std::string& mappedName,
                                          std::string* const out_userName,
                                          bool* const out_isArray) const
 {
     const std::vector<sh::Uniform>& uniforms = *ShGetUniforms(mHandle);
     for (auto itr = uniforms.begin(); itr != uniforms.end(); ++itr) {
--- a/dom/canvas/WebGLShaderValidator.h
+++ b/dom/canvas/WebGLShaderValidator.h
@@ -45,16 +45,19 @@ public:
     size_t CalcNumSamplerUniforms() const;
 
     bool FindAttribUserNameByMappedName(const std::string& mappedName,
                                         const std::string** const out_userName) const;
 
     bool FindAttribMappedNameByUserName(const std::string& userName,
                                         const std::string** const out_mappedName) const;
 
+    bool FindVaryingMappedNameByUserName(const std::string& userName,
+                                         const std::string** const out_mappedName) const;
+
     bool FindUniformByMappedName(const std::string& mappedName,
                                  std::string* const out_userName,
                                  bool* const out_isArray) const;
 };
 
 } // namespace webgl
 } // namespace mozilla