CNA-PLAT-004: On OpenGL ES 3.0 and WebGL 2 contexts OcclusionQuery::PixelCount is boolean (0 or 1)

CNA snapshot 009d40f5  ·  Known Issues › Platform limitations  ·  source links pinned to 009d40f5

✓

Evidence basis: source-verified at the pinned commit; tests exist (not executed for this page). Claims on this page were checked by reading the CNA source at commit 009d40f5; unless a sentence says otherwise, nothing here was built or executed. Nothing on this page was executed unless the Evidence section says so.

ES 3.0 and WebGL 2 only offer GL_ANY_SAMPLES_PASSED, so EasyGL reports whether any sample passed rather than how many; the public OcclusionQuery::isPixelCountPreciseEXT() reports which kind of count is in effect, but only after the first query has begun.

Identifier
CNA-PLAT-004
Category
Platform limitation
Subsystem
Graphics & renderers
Status
Open
Verified against
CNA 009d40f5 (009d40f5dd085c4e674d3479675fac84b12b3e0a)
Evidence basis
Source-verified: read at TARGET, not executed
Tests touching this area
Yes: see Current tests
Affected contract
Microsoft::Xna::Framework::Graphics::OcclusionQuery::PixelCount on EasyGL GLES/WebGL profiles

Expected behaviour

XNA's OcclusionQuery.PixelCount is the number of samples that passed.

Actual behaviour at TARGET

EasyGLRenderer.cpp resolves the precise target once per process (ResolvePreciseTarget, at the first EasyGLOcclusionQueryRenderer::Begin); where only GL_ANY_SAMPLES_PASSED exists, PixelCount is 0 or 1 and EasyGLOcclusionQueryRenderer::PixelCountIsPreciseEXT() (behind the public OcclusionQuery::isPixelCountPreciseEXT()) returns false. That accessor reads a process-wide flag that starts unresolved, so it returns false until some query has called Begin(), and it therefore also under-reports on desktop GL before first use.

Source locations

Evidence

Checked by reading the named sources at 009d40f5; nothing was built or executed for this entry.

Independent re-verification: Checked by reading the named sources at 009d40f5; nothing was built or executed for this entry. Tests: OcclusionQueryPixelCountPrecisionTests.cpp (PixelCountMatchesWhatTheQuerySaysItIs) asserts PixelCount <= 1 when isPixelCountPreciseEXT() is false and the viewport area otherwise, and the EasyGL visible-quad example has a boolean branch. The unfiltered general CI job builds the OPENGLES3 identity, which requests an ES context; platform-ci's OPENGL33 leg runs smoke games rather than these fixtures, so no CI job runs them on desktop GL.

Focused reproduction

No focused reproduction is known. Nothing has been invented here; the evidence above is what exists.

Current tests

EasyGL occlusion fixtures run on desktop GL in CI.

Regression test

A GLES/WebGL-context test asserting isPixelCountPreciseEXT() is false and PixelCount is 0 or 1.

Blast radius

Code that uses PixelCount as a coverage ratio (lens flares, visibility fading) on mobile and browser builds.

Workaround

Check isPixelCountPreciseEXT() and treat the result as visible/not visible.

The same subject is explained at several altitudes. These are the neighbouring pages at each one.