Is Transform Feedback is possible BGL?

I am trying to write a simple but expensive algorithm for computing Frame-fields on a mesh but python is simply too slow on dense meshes.

This algorithm basically, takes a vector and a normal plus the vector from a neighbor for each vertex and compute some vector math, and outputs one new vector per vertex.
That by itself would be fast but it needs to be repeated a few dozens of times in order to get a smooth vector field.

But I guess vertex shaders could do it almost instantly, so searching about that I found something about Transform Feedbacks, which is available since opengl 3 but BGL doesn’t seem to expose the functions for it.

Is it possible to do transform feedbacks with BGL or GPU modules??

@Hypersomniac, sorry taking your time but could you say if that’s possible?

I’d rather advise trying to use numpy (and maybe scipy), those are optimized for large amounts of simple computations repeated on many items… Just my two cents. :wink:

I tried but there’s some micro-logic involved that depends on the varying number of edges in each vertex which I cant port to a fixed length array without some amount of overhead too…
the complete algorithm looks is like that:

vectors = []
for vert in bm.verts:
    vectors.append( random_tangent_vector(vert.normal) )

for _ in range(interations):
	for i in range( len(bm.verts) )
		u = vectors[i]
		v = u.cross(vert.normal)
		vert_symmetries = (u, v, -u, -v)
		for edge in vert.link_edges:
			neighbor = edge.other_vert(vert)
			n_u = vectors[ neighbor.index ]
			n_v = n_u.cross(neighbor.normal)
			best_vector = None
			best_value = 0
			for sy in vert_symmetries:
				for ny in (n_u, n_v):
					value =
					if value > best_value:
						best_value = value
						best_vector = ny + sy
			if best_vector:
				vectors[i] = best_vector.normalized()