OpenGL ES 2.0, Polygon Offset ignored on some devices

Hi! Sorry for my English)

Have trouble with one device - Huawei Ascend P6 with Android 4.4.2.
I set polygon offset, but on rendering it just ignored, frames look like polygon offset turned off. On many another devices with android 4-7 the same program works correctly, problems only on Huawei P6. glIsEnebled(GL_POLYGON_OFFSET_FILL) return true, tried to use different unit and factor values, but its not change anything. Is that possible that polygon offset does not realize in GPU? Is there any way to detect this problem in runtime? Or maybe for some devices i have to do smth else glEnable?

So you’re enabling GL_POLYGON_OFFSET_FILL and calling glPolygonOffset() with different sets of values, right? (Sounds like it.)

On this device/config, are you sure you have a depth buffer, does it have the same bit depth as on other devices, is your pipeline state set up to write/test depth? And I assume you’re not using EXT_polygon_offset_clamp, right?

What are you seeing? Do you see depth fighting?

Could be that polygon offset is just broken in the Vivante GC4000 GPU drivers on that 2013 phone (wouldn’t surprise me; it’s not one of the more common mobile GPU brands), but I’d do some thorough checking before concluding that. Since it seems to work everyplace else, that does suggest the problem is at least specific to your platform/config.

You might also consider posting a question to some dev forums which talk about issues with Vivante’s OpenGL ES drivers. I’m not sure where that is for sure, but check out: https://community.nxp.com/ and https://community.freescale.com/community/imx for starters.

If needed, you can sort of emulate polygon offset with projection matrix tricks. But make sure you really need to do that first.

https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glPolygonOffset.xhtml

Polygon offset is allowed be implementation-dependent. You can’t rely on it working the same on all devices.

Thanks for ypor answers!

[QUOTE=mhagain;1289940]glPolygonOffset - OpenGL ES 3 Reference Pages
Polygon offset is allowed be implementation-dependent. You can’t rely on it working the same on all devices.[/QUOTE]

Where does this noted in specification? Could you quote, pls?

[QUOTE=Dark Photon;1289925]So you’re enabling GL_POLYGON_OFFSET_FILL and calling glPolygonOffset() with different sets of values, right? (Sounds like it.)

On this device/config, are you sure you have a depth buffer, does it have the same bit depth as on other devices, is your pipeline state set up to write/test depth? And I assume you’re not using EXT_polygon_offset_clamp, right?
[/QUOTE]

Yes. When i draw borders i just use glPolygonOffset(1f,1f)< for exmaple. Not usibg extensions.

I draw roofs and waals of building with some offset(-2,-2 on another devices enough) and next draw border without offset(as i can see, there is no offset for lines in openGL ES 2.0). But most of borders are disappearing in polygons. If i use DepthFunc gl_lequal its look better, whatever some borders not visibale. Example

I think you are right. Found another device with the same chip(K3V2, Huawei Honor 3). It have the same problem… But i hav not idea what do what to do whis

I think about emulating polygon offset whit MVP matrix or shaders, but it will reduce productivity, dont want to do that…

If we look for occurrances of the word “implementation” on the link I gave you, we see:

units

Is multiplied by [u][b]an implementation-specific value[/b][/u] to create a constant depth offset

And:

r is the smallest value that is guaranteed to produce a resolvable offset for a given implementation

The full OpenGL 2.0 specification is at https://www.khronos.org/registry/OpenGL/specs/es/2.0/es_full_spec_2.0.pdf and on page 59 we read:

…and units scales an implementation-dependent constant that relates to the usable resolution of the depth buffer.

And:

The minimum resolvable difference r is an implementation-dependent constant.

Oh, i had understood you in wrong way, sorry :slight_smile: I see that constants can be different on another devices, but there is full ignoring of polygon offset. I tried very big values, as ±10000, but it changed nothing. By the way, on this devise depth buffer bits is 16 instead of 24. I had an idea that unit and/or factor values depends on diff between far and near, i use 100000 and 50, but when i change it to 1000 anf 50 it didnt change anything again :slight_smile:

0 is a valid value.

Maybe, but it does not maky sence… How can we detect that is 0 there? Why do other 3D-games and programms works correctly on the same device? Thay dont use polygon offset? Its hard to believe it…

Enable anti-aliasing. Picture looks much better, but somewhere i can see that polygon offset doesnt work. Borders that i show in screenshot before still invisible, for example

It’s not a particularly widely-used feature. It’s not necessary unless you have surfaces which are close relative to the depth buffer resolution (the distance to the near plane affects this).

If you’re attaching an object to a surface, removing the portion of the surface behind the object (re-tessellating the modified surface) will avoid depth fighting between the object and the surface.

Im afraid its impossible to remove portion of surface behind the line, and its very hard operation if there another polygons on surface… I think that not a good idea :slight_smile: