Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Explicitly set stepMode in Attribute layout #8858

Merged
merged 4 commits into from May 6, 2024

Conversation

Pessimistress
Copy link
Collaborator

@Pessimistress Pessimistress commented Apr 30, 2024

Closes #8849

This proposed fix adds a stepMode attribute setting. If set to dynamic, it will be resolved to one of vertex and instance based on whether the target model is instanced. With this change I'm able to remove much redundancy from layers/extensions where the same buffer is shared between instanced and non-instanced models.

Change List

  • Remove divisor from attribute and shader attribute settings. While this is a breaking change,
    • Setting it does nothing as of v9.0
    • Moving forward, we won't be able to make it work exactly like v8, due to luma API changes
    • Most custom layers use AttributeManager.add and AttributeManager.addInstanced instead of explicitly setting divisor, so the impact will be low
  • Add stepMode to attribute settings
  • SolidPolygonLayer
  • BrushingExtension
  • DataFilterExtension
  • CollisionFilterExtension
  • FillStyleExtension
  • Unit tests
  • Documentation and upgrade guide

@coveralls
Copy link

coveralls commented Apr 30, 2024

Coverage Status

coverage: 89.806% (-0.02%) from 89.826%
when pulling 86b688b on x/instanced-attribute
into fd3aa4c on master.

Copy link
Collaborator

@ibgreen ibgreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This turned out really nice, you took what seemingly would be a hack and turned it into a significant code cleanup!

modules/core/src/lib/attribute/attribute-manager.ts Outdated Show resolved Hide resolved
modules/core/src/lib/attribute/attribute.ts Show resolved Hide resolved
if (stepMode === 'dynamic') {
// If model info is provided, use isInstanced flag to determine step mode
// If no model info is provided, assume it's an instanced model (most common use case)
result.stepMode = modelInfo ? (modelInfo.isInstanced ? 'instance' : 'vertex') : 'instance';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth logging a warning here if falling back to assumptions? We generally want to reduce the amount of magic we rely on...

Or is it too common / convenient to let layers omit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every layer calls attributeManager.getBufferLayouts() when constructing their models. Even if the layer does not contain any attribute with stepMode: 'dynamic', it may be used with an extension that does. Unless you think getBufferLayouts should always be called with a isInstanced argument (which is quite verbose), I'd prefer a quiet fallback.

I am personally not a fan of the noisy luma warnings in v9. Users should not be shown warnings that they cannot do anything about. Log levels should be used for development purpose.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you think getBufferLayouts should always be called with a isInstanced argument (which is quite verbose), I'd prefer a quiet fallback.

Understood. For the longer term. I am suspecting that AttributeManager is perhaps doing too much. One the one had it is a binary table generator and on the other hand it is used to map that binary table to different attribute sets. I suspect that further separating these two steps at some point (e.g. remove addInstanced()) might make it easier to generate precise layouts for each model.That is, whether the binary columns in the table is instanced seems like a technicality that the binary table management shouldn't need to worry about, but should be applied when a layout is requested. So in this sense, all attributes should be dynamic.

I haven't touched this code in a long time so it would probably take some discussion to work it through.

I am personally not a fan of the noisy luma warnings in v9. Users should not be shown warnings that they cannot do anything about. Log levels should be used for development purpose.

Sure, whether those logs are shown at debug level 0 or level 1 is a reasonable separate discussion.

Though in my view that doesn't solve anything. Relying on warnings being suppressed doesn't seem right, and showing them in debug mode even though they are "intentional" isn't helpful either, so I still I feel that until we find a way for deck to generate more precise layouts, we still need options for deck to turn them off.

@felixpalmer
Copy link
Collaborator

Happy to see the number of #ifdefs dropping in the shaders as a result

@Pessimistress Pessimistress merged commit b70e5e5 into master May 6, 2024
2 checks passed
@Pessimistress Pessimistress deleted the x/instanced-attribute branch May 6, 2024 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Doc] AttributeManager.addInstanced behaviour change on upgrade to deck.gl 9.x
4 participants