# gl\_DrawID support

**URL:** <https://forums.imgtec.com/t/gl-drawid-support/3058>\
**Category:** Uncategorized\
**Created:** [August 29, 2019, 10:23am UTC](https://forums.imgtec.com/t/gl-drawid-support/3058 "2019-08-29T10:23:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![desperado](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@desperado](https://forums.imgtec.com/u/desperado)\
**Post date:** [August 29, 2019, 10:23am UTC](https://forums.imgtec.com/t/gl-drawid-support/3058/1 "2019-08-29T10:23:29Z")

</div>

Greetings,

I see that PowerVR gpus support glMulti\* functions via extension. Is there also a way to enable gl\_DrawID for shader?

Regards

---

<div class="post-metadata">

**Author:** ![LoisLano](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/loislano/32/299_2.png) [@LoisLano](https://forums.imgtec.com/u/LoisLano)\
**Post date:** [August 29, 2019, 3:13pm UTC](https://forums.imgtec.com/t/gl-drawid-support/3058/2 "2019-08-29T15:13:21Z")

</div>

Hi,

Unfortunately, gl\_DrawID is not supported on PowerVR. It requires the extension [ARB\_shader\_draw\_parameters](https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_shader_draw_parameters.txt) which is not part of [the supported extensions](http://cdn.imgtec.com/sdk-documentation/PowerVR.Supported%20Extensions.OpenGL%20ES.EGL.pdf).

Regards,  
Loïs

---

<div class="post-metadata">

**Author:** ![desperado](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@desperado](https://forums.imgtec.com/u/desperado)\
**Post date:** [September 3, 2019, 8:48am UTC](https://forums.imgtec.com/t/gl-drawid-support/3058/3 "2019-09-03T08:48:45Z")

</div>

A pity. Do you know if it will be added in the foreseeable future?

Writing stencil from fragment shader would also be a nice feature.

---

<div class="post-metadata">

**Author:** ![LoisLano](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/loislano/32/299_2.png) [@LoisLano](https://forums.imgtec.com/u/LoisLano)\
**Post date:** [September 5, 2019, 2:00pm UTC](https://forums.imgtec.com/t/gl-drawid-support/3058/4 "2019-09-05T14:00:24Z")

</div>

First of all, thank you for showing interest. These two features can indeed be very useful in some situations, and we will discuss it internally.  
The main issue I see here is that developers rarely ever use extensions on mobile, simply because it requires dealing with special cases.

In the case of gl\_DrawID, multi-draw is already an extension on mobile. As far as I know, we are actually the only ones supporting GL\_EXT\_multi\_draw\_arrays (adding glMultiDrawArrays and glMultiDrawElements to GLES). Adding support for gl\_DrawID would require relatively costly changes to the hardware and drivers for something that is rarely used. However, you can emulate it using an additional vertex attribute if you really need to.

As for writing stencil from fragment shaders, the corresponding extension is [ARB\_shader\_stencil\_export](https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_shader_stencil_export.txt), which doesn’t seem to be supported anywhere on mobile. Bear in mind that writing stencil in fragment shaders would have a cost similar to writing depth or using discard. This kind of operation is especially costly on our architectures.

Extension support usually begins with demand from developers. Currently, there doesn’t seem to be much demand for these two, but it is possible there will be in the future. Surely you are not the only person interested in them!

---

<div class="post-metadata">

**Author:** ![desperado](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@desperado](https://forums.imgtec.com/u/desperado)\
**Post date:** [September 5, 2019, 10:35pm UTC](https://forums.imgtec.com/t/gl-drawid-support/3058/5 "2019-09-05T22:35:03Z")

</div>

Hello,

thanks for your answer. The reason why I think stencil output might be interesting is that currently you have to use separate draw calls for objects with different stencil values so you can switch state. If the stencil can be coded into attributes one could reduce the number of draw calls even more.

---

<div class="post-metadata">

**Author:** ![LoisLano](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/loislano/32/299_2.png) [@LoisLano](https://forums.imgtec.com/u/LoisLano)\
**Post date:** [September 9, 2019, 9:18am UTC](https://forums.imgtec.com/t/gl-drawid-support/3058/6 "2019-09-09T09:18:33Z")

</div>

Well, this sounds like an interesting idea. We will think about it. Thanks!
