pass
-def lookupHandle(handle, value):
+def lookupHandle(handle, value, lval=False):
if handle.key is None:
return "_%s_map[%s]" % (handle.name, value)
else:
key_name, key_type = handle.key
- return "_%s_map[%s][%s]" % (handle.name, key_name, value)
+ if handle.name == "location" and lval == False:
+ return "_location_map[%s].lookupUniformLocation(%s)" % (key_name, value)
+ else:
+ return "_%s_map[%s][%s]" % (handle.name, key_name, value)
class ValueAllocator(stdapi.Visitor):
OpaqueValueDeserializer().visit(handle.type, '_origResult', rvalue);
if handle.range is None:
rvalue = "_origResult"
- entry = lookupHandle(handle, rvalue)
+ entry = lookupHandle(handle, rvalue, True)
if (entry.startswith('_program_map') or entry.startswith('_shader_map')):
print 'if (glretrace::supportsARBShaderObjects) {'
print ' _handleARB_map[%s] = %s;' % (rvalue, lvalue)
}
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;
+ }
};
} /* namespace retrace */
#endif /* _RETRACE_SWIZZLE_HPP_ */
+