Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Reduce the number of vertex attributes used for data-driven styling. #8183

Closed

Description

@anandthakker

@ivovandongen discovered, on his (older?) Nexus device w/ Android 4.3 (Dalvik):

01-01 03:37:46.234 2208-2208/com.mapbox.mapboxsdk.testapp W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41a32700)
01-01 03:37:46.257 2208-2208/com.mapbox.mapboxsdk.testapp E/AndroidRuntime: FATAL EXCEPTION: main
                                                                            java.lang.Error: glBindAttribLocation(id, location, name): Error GL_INVALID_VALUE

Using #8177, it looks like his device has GL_MAX_VERTEX_ATTRIBS = 8. Sounds like this is a common enough device that we need to reduce the number of attributes we're binding for each program.

Couple ways to do this that @jfirebaugh and I discussed for a different issue (which was solved another way):

we can pack the base attributes (a_pos, a_offset, a_texture_pos, a_data) more

make the min/max for float attributes into vectors

Activity

  1. added
    Core
    release blocker
    on Feb 23, 2017
  2. anandthakker commented on Feb 23, 2017

    @anandthakker
    ContributorAuthor

    Based on some quick logging during attribute binding, it looks like the largest number of attributes we're currently using is in the circle program, at 14. Unfortunately, only 5 of the min/max pairs in this program are floats, so even if we packed them into vectors, we'd still be left with 9 > 8 attributes.

  3. added this to the android-v5.0.0 milestone on Feb 23, 2017
  4. jfirebaugh commented on Feb 23, 2017

    @jfirebaugh
    Contributor

    Let's try a temporary branch that tries to bind an OpenGL ES 3.0 context here, and see if we get 16 vertex attributes that way.

  5. anandthakker commented on Feb 24, 2017

    @anandthakker
    ContributorAuthor

    @jfirebaugh it looks like the ES 3.0 route is gonna be problematic:

  6. jfirebaugh commented on Feb 24, 2017

    @jfirebaugh
    Contributor

    Do you actually have to declare API version 18 minimum to be able to create an ES 3.0 context? Or is that just the minimum version where support is guaranteed?

  7. jfirebaugh commented on Feb 24, 2017

    @jfirebaugh
    Contributor

    Also, I would assume that glGetString(GL_VERSION) returns you the version that the current context was created with, not necessarily the maximum supported version.

  8. anandthakker commented on Feb 24, 2017

    @anandthakker
    ContributorAuthor

    Do you actually have to declare API version 18 minimum to be able to create an ES 3.0 context? Or is that just the minimum version where support is guaranteed?

    The docs aren't especially clear on that.

    Also, I would assume that glGetString(GL_VERSION) returns you the version that the current context was created with, not necessarily the maximum supported version.

    These docs, imply that it would show the highest supported version, even when the current context is created with a lower version.

  9. zugaldia commented on Feb 24, 2017

    @zugaldia
    Member

    I don't know if this applies to the GL stack but, in general on Android, you can keep providing support for older API levels while using features only available at a higher API number. You can check for this at runtime. For example:

    private void initFeature() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES. ICE_CREAM_SANDWICH) {
          // Do something only available on ICE_CREAM_SANDWICH and higher.
        }
    }
    
  10. anandthakker commented on Feb 24, 2017

    @anandthakker
    ContributorAuthor

    @zugaldia my assumption was that the devices that are currently only allowing 8 attributes under ES 2.0 (and thus having this problem) would be highly correlated with the ones that have older API levels. If that's true, then unfortunately this wouldn't get us out of the bind we're in.

    @jfirebaugh even without integer attributes, could we encode each color as a pair of (highp) floats? If so, then a min/max pair of colors could be a highp vec4, right? That would actually get us down to exactly 8 in the circle program. That's right at the boundary, which gives us no wiggle room, but the upside is that it's a (relatively) low-burden change...

  11. anandthakker commented on Feb 24, 2017

    @anandthakker
    ContributorAuthor

    a (relatively) low-burden change

    Not that encoding/decoding floats is exactly straightforward

  12. jfirebaugh commented on Feb 24, 2017

    @jfirebaugh
    Contributor

    Yeah, you can pack up to 24 integer bits in a single highp float, so I think that would work.

    What total number of attributes are we looking at for the symbol shaders?

  13. anandthakker commented on Feb 24, 2017

    @anandthakker
    ContributorAuthor

    With the dds paint properties from #7939 it'll be 14 for symbol shaders:

     Program 36 : Attribute a_pos : 0
     Program 36 : Attribute a_offset : 1
     Program 36 : Attribute a_texture_pos : 2
     Program 36 : Attribute a_data : 3
     Program 36 : Attribute a_opacity_min : 4
     Program 36 : Attribute a_fill_color_min : 5
     Program 36 : Attribute a_halo_color_min : 6
     Program 36 : Attribute a_halo_width_min : 7
     Program 36 : Attribute a_halo_blur_min : 8
     Program 36 : Attribute a_opacity_max : 9
     Program 36 : Attribute a_fill_color_max : 10
     Program 36 : Attribute a_halo_color_max : 11
     Program 36 : Attribute a_halo_width_max : 12
     Program 36 : Attribute a_halo_blur_max : 13
    

    Packing min/max pairs together into vec4s would get us down to 9, but we could also combine a_pos and a_offset into a vec4.

    This leaves us no room for more, though, and so we'd be back to this problem soon.

  14. jfirebaugh commented on Feb 24, 2017

    @jfirebaugh
    Contributor

    What's the total number assuming we DDS-enable the rest of the paint properties?

  15. anandthakker commented on Feb 24, 2017

    @anandthakker
    ContributorAuthor

    @jfirebaugh I'm not sure. The remaining paint properties after 7939 are just -translate and -translate-anchor, but we don't have a definite plan for those. One of the proposals in that ticket is to treat these like layout properties, but I don't yet understand what that would entail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Corerelease blocker

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions