tryCreate static method

DisjointQueryGpuProfiler? tryCreate(
  1. dynamic gl
)

Create if supported; otherwise return null so the caller can fall back.

Implementation

static DisjointQueryGpuProfiler? tryCreate(dynamic gl) {
  try {
    // Quick capability probe: counter bits for TIME_ELAPSED must be > 0
    final bits = _queryCounterBits(gl);
    if (bits <= 0) return null;

    final profiler = DisjointQueryGpuProfiler._(gl);
    // Pre-allocate a small pool of query objects.
    for (var i = 0; i < _poolSize; i++) {
      profiler._pool.add(profiler._genQuery());
    }
    return profiler;
  } catch (_) {
    // If any symbol is missing or lookup fails, bail out cleanly.
    return null;
  }
}