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

G2 multitexturing #1471

Closed
wants to merge 1 commit into from
Closed

G2 multitexturing #1471

wants to merge 1 commit into from

Conversation

RblSb
Copy link
Contributor

@RblSb RblSb commented Sep 10, 2023

Don't know how to fix sampler warnings

@RobDangerous
Copy link
Member

Sorry but I don't intend to change the G2 implementation like this. There are a thousand options to make 2D rendering faster for different situations and for different hardware. This for example will help in a lot of situations but it will also make the GPU side of things about ten times slower which is really bad for some mobile hardware.
Something like this is better kept as a sample-project than as a replacement for the standard G2 implementation.

@RblSb
Copy link
Contributor Author

RblSb commented Sep 10, 2023

Do you tested it on some project and gpu?
It shows big difference for my mobile gpus.
Since changes are minor, can we make selection between two shaders, with singletextured by default?

@RobDangerous
Copy link
Member

What's faster will depend entirely on what exactly your project is doing so just testing it on some project is pretty much pointless.
We already have functionality for G2 selection - just copy it into your project and use that.

@RblSb RblSb deleted the g2_multi branch September 10, 2023 17:52
@RblSb RblSb restored the g2_multi branch September 11, 2023 11:31
@AndreiRudenko
Copy link
Contributor

I agree that simpler G2 is better. You can use sprite sheets to have less texture switching.

@RblSb
Copy link
Contributor Author

RblSb commented Sep 11, 2023

You can provide your results from different gpus if you want to be helpful with one to ten texture switches, as realistic scenarios, or in real projects.
I'm still don't know how this can be 10 times slower in practice, since i only see no difference or 2-4x fps improvements in my low to high end mobile gpus.

@RobDangerous
Copy link
Member

GPUs don't really do if/else for diverging work across the same wave (aka what's running in one shader unit), they just mark lanes as inactive. And that means you will always do eight texture-samples instead of one aka eight times the work for the slowest part of the GPU. When your bottleneck is texture-switches you are CPU bound so that doesn't matter. But when you are GPU bound (which very easily happens when your project has some overdraw and you run on today's mobile devices with their super high res screens), this is super bad.
You could use actual TextureArrays to avoid that (see https://github.com/Kinc-Samples/TextureArray-Kinc - it's not yet exposed in Kha) but then you need at least WebGL 2 and all textures have to have the same size so that's not an option for G2 in Kha - but it absolutely is an option for a project-specific variation of G2. Or you could use bindless textures but that's not even supported in WebGPU.

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