0
$\begingroup$

I was very surprised when I ran my tessellation evaluation shader, which only counts the number of vertices through an atomicAdd command.

for the following tessellation levels:

gl_TessLevelOuter[0] = 10;
gl_TessLevelOuter[1] = 10;
gl_TessLevelOuter[2] = 10;
gl_TessLevelInner[0] = 10;

As we can see (Figure 1), there are only 91 vertices.... but the atomic counter tells me that there are 141 vertices.

enter image description here

Figure 1: generated vertices in the TES stage. all inner and outer TessLevels were set to value 10.

So I used my TES vertex enumeration algorithm to store the variable gl_TessCoord in SSBO along with a uint incremented by the function atomicAdd. I saved the result in an obj file and added a comment telling us how often this vertex is generated.

v 0.0666656 0.866653 0.0666809 #2
v 0.0666656 0.766647 0.166687 #3
v 0.0666656 0.666641 0.266693 #2
v 0.0666656 0.566635 0.366699 #2
v 0.0666656 0.46666 0.466675 #2
v 0.0666656 0.366684 0.56665 #2
v 0.0666656 0.266678 0.666656 #2
v 0.0666656 0.166672 0.766663 #2
v 0.133347 0.733307 0.133347 #2
v 0.133347 0.633301 0.233353 #1
v 0.133347 0.533295 0.333359 #1
v 0.133347 0.433319 0.433334 #1
v 0.133347 0.333344 0.53331 #1
v 0.133347 0.233337 0.633316 #1
v 0.200012 0.599976 0.200012 #1
v 0.200012 0.499969 0.300018 #1
v 0.200012 0.399994 0.399994 #1
v 0.200012 0.300018 0.499969 #1
v 0.266678 0.466629 0.266693 #2
v 0.266678 0.366653 0.366669 #2
v 0.0666656 0.0666656 0.866669 #3
v 0.166672 0.0666656 0.766663 #2
v 0.266678 0.0666656 0.666656 #2
v 0.366684 0.0666656 0.56665 #3
v 0.46666 0.0666656 0.466675 #3
v 0.566635 0.0666656 0.366699 #2
v 0.666641 0.0666656 0.266693 #2
v 0.766647 0.0666656 0.166687 #2
v 0.133331 0.133347 0.733322 #1
v 0.233337 0.133347 0.633316 #1
v 0.333344 0.133347 0.53331 #2
v 0.433319 0.133347 0.433334 #2
v 0.533295 0.133347 0.333359 #1
v 0.633301 0.133347 0.233353 #1
v 0.200012 0.200012 0.599976 #1
v 0.300018 0.200012 0.499969 #2
v 0.399994 0.200012 0.399994 #2
v 0.499969 0.200012 0.300018 #1
v 0.266678 0.266678 0.466644 #2
v 0.366653 0.266678 0.366669 #2
v 0.866653 0.0666809 0.0666656 #2
v 0.766647 0.166687 0.0666656 #2
v 0.666641 0.266693 0.0666656 #2
v 0.566635 0.366699 0.0666656 #3
v 0.46666 0.466675 0.0666656 #3
v 0.366684 0.56665 0.0666656 #2
v 0.266678 0.666656 0.0666656 #2
v 0.166672 0.766663 0.0666656 #2
v 0.733307 0.133347 0.133347 #1
v 0.633301 0.233353 0.133347 #1
v 0.533295 0.333359 0.133347 #1
v 0.433319 0.433334 0.133347 #3
v 0.333344 0.53331 0.133347 #3
v 0.233337 0.633316 0.133347 #2
v 0.599976 0.200012 0.200012 #1
v 0.499969 0.300018 0.200012 #1
v 0.399994 0.399994 0.200012 #2
v 0.300018 0.499969 0.200012 #2
v 0.466629 0.266693 0.266678 #1
v 0.366653 0.366669 0.266678 #2
v 0.333328 0.333328 0.333344 #2
v 0 1 0 #1
v 0 0.899994 0.100006 #1
v 0 0.799988 0.200012 #1
v 0 0.699982 0.300018 #1
v 0 0.599976 0.400024 #1
v 0 0.5 0.5 #1
v 0 0.400024 0.599976 #1
v 0 0.300018 0.699982 #1
v 0 0.200012 0.799988 #1
v 0 0.100006 0.899994 #1
v 0 0 1 #2
v 0.100006 0 0.899994 #1
v 0.200012 0 0.799988 #1
v 0.300018 0 0.699982 #1
v 0.400024 0 0.599976 #1
v 0.5 0 0.5 #1
v 0.599976 0 0.400024 #1
v 0.699982 0 0.300018 #1
v 0.799988 0 0.200012 #1
v 0.899994 0 0.100006 #1
v 1 0 0 #1
v 0.899994 0.100006 0 #1
v 0.799988 0.200012 0 #1
v 0.699982 0.300018 0 #2
v 0.599976 0.400024 0 #1
v 0.5 0.5 0 #1
v 0.400024 0.599976 0 #1
v 0.300018 0.699982 0 #1
v 0.200012 0.799988 0 #1
v 0.100006 0.899994 0 #1

As you can see, some vertices are created up to three times. Is there an option in OpenGL or GLSL to disable the creation of these duplicates?

$\endgroup$
1
  • $\begingroup$ I think it is because the output is a triangle list... which makes sense when using a geometry shader or fragment shader at the end... But I would like to use transform feedback buffer and after TES stage no other stages are used. The rasterizer will be turned off too. $\endgroup$
    – Thomas
    Aug 25 at 13:47

1 Answer 1

2
$\begingroup$

Is there an option in OpenGL or GLSL to disable the creation of these duplicates?

No.

The tessellation system generates primitives. That means that, at the point the primitive is generated, all of its vertices must be available to the next parts of the pipeline. However, that means having storage for all of that vertex data.

Because you can tessellate one primitive into a lot of primitives, OpenGL gives implementations wide latitude over how many TES invocations are used. The TES can be invoked over the same coordinates multiple times. This usually represents contention for the cache memory used to store post-TES vertex data. That is, the system forced a vertex out of the cache, then needed it for a later primitive.

There's no way to guarantee that this never happens.

But I would like to use transform feedback buffer and after TES stage no other stages are used.

The output of transform feedback is always a triangle list (or line list, or point list).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.