floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
6.63k stars 472 forks source link

Windows OpenGL startup time optimization #886

Closed dtrebilco closed 9 months ago

dtrebilco commented 10 months ago

By doing all attribute queries at once it decreases startup time by ~65ms and also makes my binary 1.5kb smaller. Win10, Nvidia 3070

Tested with code similar to

static void init_userdata_cb(void* in_app) {
  printf("Startup time %f\n", stm_ms(stm_diff(stm_now(), start_ticks)));
}

sapp_desc sokol_main(int argc, char* argv[]) {
  stm_setup();
  start_ticks = stm_now();

  return sapp_desc{
      .init_userdata_cb = init_userdata_cb,
  }
}
floooh commented 10 months ago

Looks like a good change, thanks!

I'll try to give it a whirl on the weekend and then merge.

floooh commented 10 months ago

Just a quick headsup, I'll be without access to a Windows PC for the next week, but will try to take care of the PR in the week after.

floooh commented 9 months ago

Starting to look into this PR now...

floooh commented 9 months ago

Ok merged! I did a couple of small coding style fixes (replaces the hardwired 12 with a define, and changed the consts to lower case. Thanks for the PR!