Ambient
Ambient copied to clipboard
Reduce string allocation on Sampler access
ForwardGlobals::create_bind_group creates a BindGroupEntry Sampler resource by fetching it from the asset cache. This incurs a string allocation with a ~0.5ms per call overhead on the web.
Is this a specific problem with just samplers, or should we consider remaking the asset cache to not use a stringly typed, non type-safe api (with everything being boxed, and different types that have the same debug impl will collide)?
If you use newtypes in the cache that end up having a debug-impl that only prints the inner type, or any other identical debug impl, the asset cache will cause it to collide with the inner type in the cache, and panic when downcasting.
We should fix the main issue as you describe.
What I'm mainly pointing out is the performance aspect of it which impacts user experience. So if we can have a fix for the sampler perf problem in a few hours versus a fix for the main issue in one week, I'd rather take the sampler only fix and address the main issue later. But it we can address the main issue in a reasonable time frame, I'd say let's go for that.
Oh absolutely.
Not sure how we can go about not using a string for fetching it, as that is what every asset needs to go through, but I guess we could be more diligent in saving it in a struct instead of fetching it each time, depending on which system fetches it
Oh I see where it is from now, and I know how that system works. There is a self
in that function that we can stuff the sampler into