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

[do not merge] Testing performance fixes #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mattdesl
Copy link

Using multiple buffers instead of a single buffer seems to drastically improve frame rate when rendering a solid red city. Not sure why; maybe something wrong with the way stride or buffer sizes are set up?

@rolyatmax
Copy link
Owner

First of all, thank you so much for opening this PR! These technical discussions are so helpful for me. ❤️

So I pulled this down, and wow it's handling all those vertices at 60FPS. This is really promising. I don't think I'm completely following where this performance boost is coming from, though. From what I can tell the buffer state logic hasn't changed in this PR. I might be missing something though 🤔

@mattdesl
Copy link
Author

I think the perf boost is almost entirely from the switch to using split buffers - see the way I pass them to the building render function. Instead of attr.position (interleaved) I just pass position (the float array data). For whatever reason the interleaved buffer seemed to be slowing things down a lot.

@mattdesl
Copy link
Author

What that means is you could try using split buffers - all of them will be left unchanged except the state index buffer which needs to be updated in the loading state.

// stateTransitioner.updateLoadingState(latest.buildingIdxToMetadataList)
buffers.update({ positions, barys, randoms, buildings }, stateTransitioner.getStateIndexes())
const attrs = buffers.getAttributes()
renderBuildings = createBuildingsRenderer(regl, positions, barys, randoms, stateTransitioner.getStateIndexes(), settings)
Copy link
Owner

@rolyatmax rolyatmax Apr 24, 2018

Choose a reason for hiding this comment

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

Ohhhhh - this is where I misread. I missed that you're passing these directly to createBuildingsRenderer and line 93 & 94 here are dead. Damn - so maybe there's a bug in the offset/stride stuff, like you said. 🤔 Gonna look into this a bit more tonight.

@rolyatmax
Copy link
Owner

There are two things that still confuse me:

  1. When I switched to interleaving attribute data, I made sure to measure the performance difference between the two techniques, and I swear I had like a 15% improvement in FPS.

  2. The visualization seems to run fine (about 45 FPS) on my personal 13" MacBook Pro (less than a year old). And it runs fine on my 11" MacBook Air from 2012. But it runs rather poorly (less than 20 FPS) on my 15" MacBook Pro at work which is only about a year old. I'm noticing that it uses a Radeon Pro 455 while the others use Intel GPUs. I wonder if there could possibly be an issue in the underlying hardware?

I'm going to go back in the commit history and checkout a version before I started interleaving the attributes to see how that functions.

@rolyatmax
Copy link
Owner

rolyatmax commented Apr 24, 2018

Alright, here's where I added the attribute interleaving (one of the few commits I actually bothered to give a helpful message). I ran the parent of this commit - and it also sucks on my work machine. Gonna have to dig into this more when I get home.

@rolyatmax
Copy link
Owner

rolyatmax commented Apr 24, 2018

Now I'm home looking at this again on my personal laptop and am confused as ever.

So this branch, which gives up the incremental loading and splits the interleaved attributes back into separate Float32Arrays runs at 60 FPS on my (1 year old) 15" MacBook Pro at work - while master runs at a dismal 15-20 FPS. But on my (6-month old) 13" MacBook Pro at home, this perf-improvements branch runs at 30 FPS while master runs at 40-45 FPS.

I have no idea what to do with this, hahaha. All I can think is that the two different GPUs - a Radeon (work) and an Intel (home) - handle things differently and "prefer" the opposite branches. 🙈

Meanwhile, the branch connected to this PR - which drops the incremental loading, interleaved attributes, and the buildingState texture - runs at 60 FPS on both personal and work machines. Hahahaha

@mattdesl Just curious - what hardware are you running this on?

@rolyatmax
Copy link
Owner

Thinking about this a bit more: I'm starting to suspect that this could play a role, given that the performance remained degraded when switching to a previous commit which did separate the attributes into different buffers but also had usage: 'dynamic' set. Unfortunately, I'll have to wait until tomorrow to test this theory.

@rolyatmax
Copy link
Owner

Got into work and tried switching DYNAMIC_DRAW back to STATIC_DRAW, and it runs at a smooth 60FPS again. I think this commit did the trick: ccb57d7

Curious to know how this is running on your machine.

@mattdesl
Copy link
Author

Hmm doesn't seem to make a difference for me :\

@rolyatmax
Copy link
Owner

Linking to this Twitter thread for posterity: https://twitter.com/mattdesl/status/988756029528793089

@rolyatmax
Copy link
Owner

cc @mikolalysenko - you might find this issue interesting. A couple of us have looked at getting this up to 60 FPS but seem to be bound to 40-45 FPS. It's about 3.5M triangles with 11M vertices - rendered just as triangles - not a strip. If you end up taking a look at the code, let me know if anything stands out about the way I'm rendering the buildings. No worries if you can't get to it though! Thanks :-)

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.

2 participants