0
\$\begingroup\$

I am trying to figure out a way to get the Fragment Shader to output a list of gl_VertexID-s.

I want to use the GPU to get a list of vertices in the viewing frustum.

Is there any way I can get a per fragment shader invocation variable or something else that is possible to use as a pointer to a texture? If it is not possible, is there a possibility to use a sparse texture to render to, using gl_VertexID-s as a pointer?.

I will be rendering about a million or two vertices at a time (using GL_POINTS), and the list should be tightly packed to be of use. Some work may be offloaded to the CPU, but this is part of a real-time render engine so the execution times need to be under 10ms.

I am using OpenGL 4.4.

\$\endgroup\$
  • 1
    \$\begingroup\$ What are you trying to do at a higher level? There is probably a better way than this particular... strangeness. \$\endgroup\$ – Josh Feb 4 '15 at 21:59
  • \$\begingroup\$ I am trying to render a large amount of point cloud data stored in octrees and I would use this to traverse the octree. I know it's ambitious, but I didn't want to give up before asking around. \$\endgroup\$ – Andreas Feb 4 '15 at 22:09
  • \$\begingroup\$ I don't think it's unreasonable, I'm just trying to avoid you asking about an XY problem. It helps to know the details of your ultimate goal, because there may be a better way to do this than trying to "output a list" with the fragment shader. \$\endgroup\$ – Josh Feb 4 '15 at 22:28
  • \$\begingroup\$ The rendering part is actually working, but I need this for optimization. I am currently using a 1D texture and gl_VertexID-s and tightly packing the list on the CPU, but this eats away all the bandwidth of the PCIe 3.0 and is creating a huge bottleneck. \$\endgroup\$ – Andreas Feb 4 '15 at 22:57
  • \$\begingroup\$ While it is possible to do what you want using atomics and shader storage buffers, it would be absurdly slow. Why don't you just let the GPU handle culling in the normal pipeline? 1-2 million is reasonable to throw whole at modern chips. \$\endgroup\$ – user41442 Feb 5 '15 at 0:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.