X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=retrace%2Fretrace_swizzle.hpp;h=f013b6a0697bbf3ba9eb8ab24675d20342c4fdd0;hb=edea899194c441353943c22577bc22bf0e64d187;hp=bab6d562e077dedbdd875eb181e1dcce51fda56b;hpb=53e366e711876c1b7636e861069cb934716aefe0;p=apitrace diff --git a/retrace/retrace_swizzle.hpp b/retrace/retrace_swizzle.hpp index bab6d56..f013b6a 100644 --- a/retrace/retrace_swizzle.hpp +++ b/retrace/retrace_swizzle.hpp @@ -74,6 +74,27 @@ public: } return it->second; } + + /* + * Handle situations where the application declares an array like + * + * uniform vec4 myMatrix[4]; + * + * then calls glGetUniformLocation(..., "myMatrix") and then infer the slot + * numbers rather than explicitly calling glGetUniformLocation(..., + * "myMatrix[0]"), etc. + */ + T lookupUniformLocation(const T &key) { + typename base_type::const_iterator it; + it = base.upper_bound(key); + if (it != base.begin()) { + --it; + } else { + return (base[key] = key); + } + T t = it->second + (key - it->first); + return t; + } }; @@ -88,7 +109,7 @@ toPointer(trace::Value &value, bool bind = false); void -addObj(trace::Value &value, void *obj); +addObj(trace::Call &call, trace::Value &value, void *obj); void delObj(trace::Value &value); @@ -100,3 +121,4 @@ toObjPointer(trace::Call &call, trace::Value &value); } /* namespace retrace */ #endif /* _RETRACE_SWIZZLE_HPP_ */ +