Bug 1244611 - "Using named uniform buffer objects in the fragment shader fails". r=jgilbert
authorBrad Kotsopoulos <bkotsopoulos>
Wed, 23 Mar 2016 08:18:00 +0100
changeset 314026 c5a53b4755381106a4d1b4dda9d57c3345bd79a3
parent 314025 9613753f5c1c94b9ccbf0a2003913e17f69f617a
child 314027 fbc5d3de958a63f088f545b79894b7c8d6e17265
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1244611
milestone48.0a1
Bug 1244611 - "Using named uniform buffer objects in the fragment shader fails". r=jgilbert
dom/canvas/WebGLShaderValidator.cpp
--- a/dom/canvas/WebGLShaderValidator.cpp
+++ b/dom/canvas/WebGLShaderValidator.cpp
@@ -469,24 +469,54 @@ ShaderValidator::FindUniformByMappedName
         const sh::ShaderVariable* found;
         if (!itr->findInfoByMappedName(mappedName, &found, out_userName))
             continue;
 
         *out_isArray = found->isArray();
         return true;
     }
 
+    const size_t dotPos = mappedName.find(".");
+
     const std::vector<sh::InterfaceBlock>& interfaces = *ShGetInterfaceBlocks(mHandle);
     for (const auto& interface : interfaces) {
+
+        std::string mappedFieldName;
+        const bool hasInstanceName = !interface.instanceName.empty();
+
+        // If the InterfaceBlock has an instanceName, all variables defined
+        // within the block are qualified with the block name, as opposed
+        // to being placed in the global scope.
+        if (hasInstanceName) {
+
+            // If mappedName has no block name prefix, skip
+            if (std::string::npos == dotPos)
+                continue;
+
+            // If mappedName has a block name prefix that doesn't match, skip
+            const std::string mappedInterfaceBlockName = mappedName.substr(0, dotPos);
+            if (interface.mappedName != mappedInterfaceBlockName)
+                continue;
+
+            mappedFieldName = mappedName.substr(dotPos + 1);
+        } else {
+            mappedFieldName = mappedName;
+        }
+
         for (const auto& field : interface.fields) {
             const sh::ShaderVariable* found;
 
-            if (!field.findInfoByMappedName(mappedName, &found, out_userName))
+            if (!field.findInfoByMappedName(mappedFieldName, &found, out_userName))
                 continue;
 
+            if (hasInstanceName) {
+                // Prepend the user name of the interface that matched
+                *out_userName = interface.name + "." + *out_userName;
+            }
+
             *out_isArray = found->isArray();
             return true;
         }
     }
 
     return false;
 }