Closed kainino0x closed 3 days ago
Do we know what the cost of a malloc is in emscripten? Something like AdapterGetInfo
happens maybe once per application run so it doesn't seem super worth optimizing by having some arbitrary length hardcoded.
I'm definitely not concerned with the performance cost for AdapterGetInfo, given it should be called basically once. It's more of an ergonomic improvement as you wouldn't need FreeMembers at all for this struct. It's feasible to do similar things for other structs as well, like changing presentModes
to a fixed-size array.
Ah, that would be a problem only for C though and only in a few places so not super important either imho.
Jul 18 meeting:
char vendor[256]
, instead of char const * vendor
+ FreeMembers
In Emscripten there were a few suggestions to use fixed-length arrays for some outputs to avoid needing FreeMembers. In particular AdapterInfo just has a few strings in it - we probably could get away with setting some fixed limit on their size, but
description
is the most unsure, since it might get wrapped repeatedly the way ANGLE does:ANGLE (Apple, ANGLE Metal Renderer: Apple M1 Pro, Version 14.5 (Build 23F79))
Discussion was here: https://github.com/emscripten-core/emscripten/pull/22031#discussion_r1624954986