Refactor gfx_ctx_init_first