gl_DrawID support

Greetings,

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

Regards

Hi,

Unfortunately, gl_DrawID is not supported on PowerVR. It requires the extension ARB_shader_draw_parameters which is not part of the supported extensions.

Regards,
Loïs

1 Like

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.

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, 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!

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.

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