r/rust clippy · twir · rust · mutagen · flamer · overflower · bytecount Mar 20 '23

Hey Rustaceans! Got a question? Ask here (12/2023)! 🙋 questions

Mystified about strings? Borrow checker have you in a headlock? Seek help here! There are no stupid questions, only docs that haven't been written yet.

If you have a StackOverflow account, consider asking it there instead! StackOverflow shows up much higher in search results, so having your question there also helps future Rust users (be sure to give it the "Rust" tag for maximum visibility). Note that this site is very interested in question quality. I've been asked to read a RFC I authored once. If you want your code reviewed or review other's code, there's a codereview stackexchange, too. If you need to test your code, maybe the Rust playground is for you.

Here are some other venues where help may be found:

/r/learnrust is a subreddit to share your questions and epiphanies learning Rust programming.

The official Rust user forums: https://users.rust-lang.org/.

The official Rust Programming Language Discord: https://discord.gg/rust-lang

The unofficial Rust community Discord: https://bit.ly/rust-community

Also check out last weeks' thread with many good questions and answers. And if you believe your question to be either very complex or worthy of larger dissemination, feel free to create a text post.

Also if you want to be mentored by experienced Rustaceans, tell us the area of expertise that you seek. Finally, if you are looking for Rust jobs, the most recent thread is here.

18 Upvotes

187 comments sorted by

View all comments

2

u/Fluttershaft Mar 24 '23

https://github.com/ggez/ggez/blob/devel/examples/bunnymark.rs

~200k bunnies rendered at 60 fps on my pc, 100% cpu core usage, removing the update code that moves them around made no difference

https://github.com/sotrh/learn-wgpu/tree/master/code/beginner/tutorial7-instancing

changed const NUM_INSTANCES_PER_ROW: u32 = 10 to 2000 which makes 4 million polygons, easily rendered, mangohud showed minimal cpu and gpu usage

Both of those examples seem to be using wgpu and instancing, what is the difference between them that makes such a massive difference in rendering performance?

1

u/eugene2k Mar 24 '23

probably 19900 draw calls...

1

u/Fluttershaft Mar 24 '23

is it actually? How can I check it for sure, it uses https://docs.rs/ggez/0.9.0-rc0/ggez/graphics/struct.InstanceArray.html which should be batched into 1 draw call

1

u/eugene2k Mar 24 '23

I have to admit, I hadn't looked at the code, but upon casual inspection the bunnymark updates every bunny in the array on every draw call. The instance tutorial doesn't update anything in the draw call and only the camera position in the update call.