X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=retrace%2Fretrace_swizzle.hpp;h=f013b6a0697bbf3ba9eb8ab24675d20342c4fdd0;hb=c037ae2b4f749aed15ede635a6b517534bc5a901;hp=42e5bf6484a344e31f4b80d35cf93c3759a3b23d;hpb=b35ae0df401ff22e3b2dc9b6bfacf1e23baebde0;p=apitrace diff --git a/retrace/retrace_swizzle.hpp b/retrace/retrace_swizzle.hpp index 42e5bf6..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; + } }; @@ -100,3 +121,4 @@ toObjPointer(trace::Call &call, trace::Value &value); } /* namespace retrace */ #endif /* _RETRACE_SWIZZLE_HPP_ */ +