CNA-BUG-280: On FNA3D's SDL_GPU driver a TextureCube, Texture3D or mipmapped Texture2D changed between two draws of one frame shows its new contents in the earlier draw too

CNA snapshot 3b43bd86  ·  Known Issues › Current bugs  ·  source links pinned to 3b43bd86

✓

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

SDL_GPU and WEBGPU now order a texture upload after the queued draws that sample it, so SpriteSortMode::Immediate and other mid-frame SetData calls keep XNA's per-draw contents there; FNA3D's SDL_GPU driver still submits uploads ahead of the frame's draws and keeps the old contents only for a whole write of a single-level 2D texture.

Identifier
CNA-BUG-280
Category
Bug
Subsystem
Graphics & renderers
Status
Narrowed (partially fixed; describes only what survives)
Verified against
CNA 3b43bd86 (3b43bd8687ed46523d873f9bec4b32bd8481dcb5)
Severity
Low (a triage suggestion, not a project priority)
Evidence basis
Recorded by CNA: CNA's own recorded run, not repeated here
Tests touching this area
Yes: see Current tests
Affected contract
Texture2D, TextureCube and Texture3D SetData between two draws of one frame (including two Draw calls of one SpriteSortMode::Immediate SpriteBatch) on the FNA3D renderer when FNA3D runs its SDL_GPU driver

Expected behaviour

XNA draws each call with the texture as it is at that call: a texture changed with SetData between two draws of one frame shows its old contents in the first draw and its new contents in the second. For SpriteSortMode::Immediate that means a texture changed between two Draw calls leaves the first sprite with the old contents.

Actual behaviour at TARGET

FNA3D's SDL_GPU driver (the libcna/FNA3D fork CNA pins in ThirdPartyFNA3D.cmake, 10f650b9d0f6) records texture uploads on a command buffer of its own and submits it ahead of the frame's draws. SDLGPU_SetTextureData2D lets SDL cycle the texture, so that draws recorded earlier keep the old resource, only for a whole write of level 0 of a single-level, single-layer texture; SDLGPU_SetTextureDataCube and SDLGPU_SetTextureData3D never cycle. A TextureCube changed between two draws of one frame therefore shows its new contents in the earlier draw too: leg B of CNA's conformance program texture_setdata_after_draw fails on FNA3D (measured by CNA on 2026-10-24, SDL_GPU driver over Vulkan), and fna3d-renderer.md (“Texture upload ordering”) states that by the same source a Texture3D or a mipmapped Texture2D does the same. CNA treats this as the driver's behaviour, reported rather than worked around (handoff.md section 5.3). An Immediate SpriteBatch is affected only through such textures: CNA's FNA3D renderer flushes each Immediate sprite from Draw and uploads whole levels, so a single-level sprite texture keeps XNA's order, and leg B of spritebatch_sort_mode_semantics_test.cpp passes on FNA3D.

Fixed since first recorded: the entry was first published for CNA's own SDL_GPU and WEBGPU renderers, which replayed the sprites of an Immediate batch after a later upload. Since d9b513ee0 SdlGpuRenderer.cpp submits the queued work first when an upload reaches a Texture2D, TextureCube or Texture3D that a queued command still samples (SubmitQueuedSamplersEXT), and since d9b513ee0 and 96577db26 WebGPURenderer.cpp writes such a texture into a fresh one and leaves the old one to the queued commands (RenameForWriteEXT, keyed on QueuedCycleEXT). Leg B of the sort-mode program now asserts XNA's red/blue instead of printing it, and CNA's handoff lists no open defect in section 5.1.

Source locations

Evidence

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

Narrowed by the independent adversarial audit: the entry originally named EasyGL as a renderer that batches below the seam. Commit 515958a7a (2026-09-09) made EasyGL honour immediate submission (FNA3D already did); nothing was executed.

Re-verified at c6dec91f: SetImmediateMode is overridden by every sprite renderer; SdlGpuRenderer.cpp reads immediateMode_ only on the compiled-effect sprite route, WebGPURenderer.cpp's per-Draw flush is compiled only with CNA_WEBGPU_COMPILED_EFFECTS, and D3D9SpriteBatch.cpp calls FlushBatch() per Draw in immediate mode (3b6a2eaf3). The behaviour on SDL_GPU and WEBGPU is CNA's own record in handoff.md section 5.1 (2026-10-17), not re-run here. CNA classes it as a defect; the deliberate-divergence record this entry used to cite is no longer in the tree.

Narrowed at 3b43bd86: read the SDL_GPU and WEBGPU upload paths named above, the rewritten leg B and texture_setdata_after_draw_test.cpp (new, registered through the parity fixture list); the pass results on SDL_GPU, WEBGPU, OPENGLES3, OPENGL33, SOFTWARE and FNA3D and the FNA3D leg-B failure are CNA's own records in d9b513ee0, 96577db26 and handoff.md, not re-run here. FNA3D's driver was read in a clone of the fork at 10f650b9d0f6 (src/FNA3D_Driver_SDL.c: the cycleTexture condition of SDLGPU_SetTextureData2D, no cycling in the cube and volume uploads); the Texture3D and mipmapped Texture2D cases rest on that reading and on CNA's documentation, not on a run. Nothing was built or executed for this entry.

Focused reproduction

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

Current tests

texture_setdata_after_draw (a Texture2D through BasicEffect, a TextureCube through EnvironmentMapEffect) and leg B of spritebatch_sort_mode_semantics_test.cpp assert XNA's per-draw contents; CNA records both passing on SDL_GPU, WEBGPU, OPENGLES3, OPENGL33 and SOFTWARE, the sort-mode leg on FNA3D too, and the cube leg failing on FNA3D. No test covers a Texture3D or a mipmapped Texture2D changed between two draws.

Regression test

Leg B of texture_setdata_after_draw on FNA3D with its SDL_GPU driver, plus a Texture3D and a mipmapped Texture2D leg; they pass once the driver cycles (or orders) every texture upload a recorded draw still samples.

Blast radius

Games on the FNA3D renderer with its SDL_GPU driver (FNA3D's first choice, and its driver on Apple) that change a TextureCube, a Texture3D or a mipmapped Texture2D with SetData between two draws of one frame, including two Draw calls of one Immediate SpriteBatch. A single-level Texture2D, FNA3D's OpenGL driver and every other renderer keep XNA's order.

Workaround

Change such textures before the frame's first draw that samples them, keep a separate texture per state, or pin FNA3D's OpenGL driver with the FNA3D_FORCE_DRIVER hint.

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

Known issues
Bug index