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

[HdSt] Enhance the current implementation of batching in HdSt #528

Closed

Conversation

yjang
Copy link

@yjang yjang commented Jun 13, 2018

With the current aggregation strategy, there is a chance to end up with one batch per draw item, which could affect rendering performance.
For example, if you have a scene with many draw items, the draw items could map onto the same batchMap key which alternate into multiple different aggregated buffers.
This PR provides managing multiple aggregated buffers for each batchMap key to reduce the number of draw batches.


The test scene has

  • rprims: 8029
  • instancer: 7429 (1 prototype for each instancer)
  • instances: 28132
  • textures: 231

and everything is static with an animated camera.

The current implementation generated

  • 156 draw batches,
  • 8029 draw items

and it attempted to append a batch 3 times.

This PR generated

  • 7 draw batches,
  • still 8029 draw items

and it attempted to append a batch 11,319 times.
The batchMap had 3 keys and the depth of each key's vector was 1, 5, and 1.
The test scene was able to be rendered upto 10fps performance improvement.

With the current aggregation strategy, there is a chance to end up with one batch per draw item, which could affect rendering performance.
For example, if you have a scene with many draw items, the draw items could map onto the same batchMap key which alternate into multiple different aggregated buffers.
This PR provides managing multiple aggregated buffers for each batchMap key to reduce the number of draw batches.

The test scene has
 - rprims: 8029
 - instancer: 7429 (1 prototype for each instancer)
 - instances: 28132
 - textures: 231
and everything is static with an animated camera.

The current implementation generated
 - 156 draw batches,
 - 8029 draw items
and it attempted to append a batch 3 times.

This PR generated
 - 7 draw batches,
 - still 8029 draw items
and it attempted to append a batch 11,319 times.
The batchMap had 3 keys and the depth of each key's vector was 1, 5, and 1.
The test scene was able to be rendered upto 10fps performance improvement.
@jtran56
Copy link

jtran56 commented Jun 15, 2018

GitHub #161889.

pixar-oss pushed a commit that referenced this pull request Jul 17, 2019
Improve batching performance in Hydra GL, adding to PR #528. Thanks to Yoojin Jang for the initial idea.

The draw item "key" used in the map accounts for the geometric shader, buffer array versions and material params. Two draw items sharing the same "key" could use resources that don't aggregate. This checks happens in HdSt_DrawBatch::Append. So, a "key" effectively maps to several batches.

- Use a vector of batches as the value type in the map, instead of a single batch.
- Keep track of the previous draw item's key and batch. If the current draw item's key matches the last one, attempt to append it to the batch. If that fails, create a new batch and append it to the key's batch. If the key doesn't match, create a new entry into the map.

This should reduce the number of HdSt_DrawBatch's created to the necessary minimum, and improve GPU performance since more draw item's are bucketed into a batch than was the case earlier.

(Internal change: 1987160)
@c64kernal
Copy link
Contributor

Thanks so much @yjang for the awesome PR! This is now available in dev, we couldn't do a direct merge so we adapted it a bit. Please let us know if you run into any issues!
Thanks again!

@c64kernal c64kernal closed this Jul 17, 2019
AdamFelt pushed a commit to autodesk-forks/USD that referenced this pull request Apr 16, 2024
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.

3 participants