<p>I don't know what Apple have done with Metal per se, but as the iOS devices have PowerVR-derived GPUs, normally I would think that doing as much opaque-only drawing "up front" would usually be beneficial, but <em>if</em>, as in your case, only 5% of the screen is covered by opaque geometry, I'm not sure how much the software overhead will affect things.</p>

<blockquote>
  <p>The reason I am unsure is that I know the second you call discard on a fragment you remove the possibility of Metal preforming early depth test which is allegedly quite an optimization. What I dont know is if discards disable early depth test on draw call 1 do they also disable the optimization for draw call 2's geometry?</p>
</blockquote>

<p>With PowerVR devices, a depth test can "always" be done as the first step in the pipeline, so any geometry that was submitted earlier in the scene <em>can</em> cull later things prior to fragment shading. </p>

<p>With alpha-tested (AKA "punch-though"), the Z-test can thus be done against previous geometry, but there may be a cost of then doing the texturing/shading and feeding that back to update the depths for subsequent geometry.</p>

<p>If you aren't doing alpha-test/discards, and are doing your own sorting, then this feedback is not required (but obviously there may be more shading/texturing work to perform).</p>

<p>(Such a pity, though, that we removed the OIT feature from the early PowerVR hardware)</p>

<blockquote>
  <p>Does the fragment stage happen after each draw calls vertex phase or after all of them?</p>
</blockquote>

<p>I'm not sure what you are asking, but for a given scene, all the vertex shading (across multiple calls) is performed**, the geometry buffered, and only then rendering commences on the entire scene.</p>

<p><em>**There are some caveats here but that probably doesn't affect you</em>.</p>

<blockquote>
  <p>Do you think I should explore sorting the triangles and using alpha blending on draw call 1? Again this would be a negligible CPU cost would it actually help the GPU? </p>
</blockquote>

<p>Are you asking "should I profile/time the results and see what is best for my use case?".  Probably "yes".</p>

CC BY-SA 4.0
2018-09-03T09:47:57.040Z
2018-09-04T08:33:02.747Z
2018-09-04T08:33:02.747Z
Simon F
<p>I should preface with currently this question is mostly asking about Metal and iOS GPUs. That being said if this is GPU or OS specific and you can go into detail about other platforms that would be great to as this application will eventually be cross platform.</p>

<p>I am drawing some geometry in two draw calls.</p>

<ol>
<li>Opaque geometry is drawn. Discards happen. No particular triangle draw order. Fragments in this draw call occupy only 5% of the screens pixels.</li>
<li>Transparent geometry is drawn. No discards happen. Triangles are drawn in depth order. Fragments in this call occupy a bulk of the screen pixels.</li>
</ol>

<p>The question is essentially should I convert draw call 1 to ordered triangles with alpha=0 where I would generally discard. There will be a cost to ordering the triangles in draw 1 however it will not be two costly.</p>

<p>The reason I am unsure is that I know the second you call discard on a fragment you remove the possibility of Metal preforming early depth test which is allegedly quite an optimization. What I dont know is if discards disable early depth test on draw call 1 do they also disable the optimization for draw call 2's geometry?</p>

<p>Does the fragment stage happen after each draw calls vertex phase or after all of them?</p>

<p>Do you think I should explore sorting the triangles and using alpha blending on draw call 1? Again this would be a negligible CPU cost would it actually help the GPU? </p>

<metal>
Are the benefits of a Metal early depth test limited to one draw call
J.Doe
# Are the benefits of a Metal early depth test limited to one draw call

(Asked by: username_0 on 2018-09-03)

I should preface with currently this question is mostly asking about Metal and iOS GPUs. That being said if this is GPU or OS specific and you can go into detail about other platforms that would be great to as this application will eventually be cross platform.

I am drawing some geometry in two draw calls.

1. Opaque geometry is drawn. Discards happen. No particular triangle draw order. Fragments in this draw call occupy only 5% of the screens pixels.
2. Transparent geometry is drawn. No discards happen. Triangles are drawn in depth order. Fragments in this call occupy a bulk of the screen pixels.

The question is essentially should I convert draw call 1 to ordered triangles with alpha=0 where I would generally discard. There will be a cost to ordering the triangles in draw 1 however it will not be two costly.

The reason I am unsure is that I know the second you call discard on a fragment you remove the possibility of Metal preforming early depth test which is allegedly quite an optimization. What I dont know is if discards disable early depth test on draw call 1 do they also disable the optimization for draw call 2's geometry?

Does the fragment stage happen after each draw calls vertex phase or after all of them?

Do you think I should explore sorting the triangles and using alpha blending on draw call 1? Again this would be a negligible CPU cost would it actually help the GPU?

**Tags:** metal


---

## 1 answers

### Answer by username_1 on 2018-09-03. Score: 1

I don't know what Apple have done with Metal per se, but as the iOS devices have PowerVR-derived GPUs, normally I would think that doing as much opaque-only drawing "up front" would usually be beneficial, but *if*, as in your case, only 5% of the screen is covered by opaque geometry, I'm not sure how much the software overhead will affect things.

> The reason I am unsure is that I know the second you call discard on a fragment you remove the possibility of Metal preforming early depth test which is allegedly quite an optimization. What I dont know is if discards disable early depth test on draw call 1 do they also disable the optimization for draw call 2's geometry?

With PowerVR devices, a depth test can "always" be done as the first step in the pipeline, so any geometry that was submitted earlier in the scene *can* cull later things prior to fragment shading.

With alpha-tested (AKA "punch-though"), the Z-test can thus be done against previous geometry, but there may be a cost of then doing the texturing/shading and feeding that back to update the depths for subsequent geometry.

If you aren't doing alpha-test/discards, and are doing your own sorting, then this feedback is not required (but obviously there may be more shading/texturing work to perform).

(Such a pity, though, that we removed the OIT feature from the early PowerVR hardware)

> Does the fragment stage happen after each draw calls vertex phase or after all of them?

I'm not sure what you are asking, but for a given scene, all the vertex shading (across multiple calls) is performed\*\*, the geometry buffered, and only then rendering commences on the entire scene.

*\*\*There are some caveats here but that probably doesn't affect you*.

> Do you think I should explore sorting the triangles and using alpha blending on draw call 1? Again this would be a negligible CPU cost would it actually help the GPU?

Are you asking "should I profile/time the results and see what is best for my use case?". Probably "yes".


---

