I have lots of transparent primitives I want to sort before drawing, but to get the Z coordinate, the sorting key, I have perform in software all the transformations performed by the vertex shader in hardware.
I thought I could optimize the process by retrieving the Z coordinate from the shader, and using it to sort the primitives in the next frame. Since the order of primitives is not expected to change drastically between frames, it shall provide fair enough ordering. So, I'd like to know how to get batch of Z coordinates back from the vertex shader? Is it possible?
You can use Transform Feedback to get data from the Vertex Shader output into a Buffer which you can later read, but i don't think this will gain you much, you should profile which solution is best (experimentally).