Skip to content

Group all solid triangles independently of color#1538

Merged
hecrj merged 6 commits intomasterfrom
group-solid-triangles
Nov 28, 2022
Merged

Group all solid triangles independently of color#1538
hecrj merged 6 commits intomasterfrom
group-solid-triangles

Conversation

@hecrj
Copy link
Member

@hecrj hecrj commented Nov 16, 2022

This PR enhances our triangle pipelines to batch all solid geometry independently of color.

As a result, all solid geometry drawn sequentially in a Canvas will be batched together into a single draw call independently of color. The previous behavior produced as many draw calls as different colors used.

We achieve this by introducing a new ColoredVertex2D type and separating Mesh into SolidMesh and GradientMesh variants in Primitive.

No user-facing APIs have changed.

@hecrj hecrj added this to the 0.6.0 milestone Nov 16, 2022
@bungoboingo
Copy link
Contributor

bungoboingo commented Nov 16, 2022

Changes seem good, thanks for doing this! Tested on macos M1 glow & wgpu (only computer I have access to at the moment), so cannot speak to old GL versions but I don't see any changes that would break anything there. Also tested WASM build and seems good.

Only nit I have re: nesting solid & gradient mods in the triangle.rs. I found it easier to read when they were separated out into their own files. Realize this is subjective so don't feel particularly strongly about it.

@bungoboingo
Copy link
Contributor

bungoboingo commented Nov 16, 2022

Can also pull in the old Geometry example again from 0.4 branch since we have colors in vertex data again (happy to do this after the merge!)

@artursapek
Copy link
Contributor

did we mention it's fast

Copy link
Contributor

@bungoboingo bungoboingo left a comment

Choose a reason for hiding this comment

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

Unless we want to add those From<Color> & From<Gradient>s in for canvas::style I'd say this is good to go.

@hecrj
Copy link
Member Author

hecrj commented Nov 28, 2022

Only nit I have re: nesting solid & gradient mods in the triangle.rs. I found it easier to read when they were separated out into their own files. Realize this is subjective so don't feel particularly strongly about it.

I know it's pretty subjective, but I felt like the boundaries of the modules were a bit blurry (e.g. only some fields were public, methods needed to be called in a particular order and with correct indices, etc.). I usually prefer no boundaries at all than blurry ones.

We could still move the modules to their own files but, since everything is pretty coupled, I feel the pipelines are easier to edit this way.

@hecrj hecrj merged commit 8d67e21 into master Nov 28, 2022
@hecrj hecrj deleted the group-solid-triangles branch November 28, 2022 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments