CNA-BUG-105: SDL_RENDERER clips to any non-empty ScissorRectangle even when RasterizerState.ScissorTestEnable is false

CNA snapshot 009d40f5  ·  Known Issues › Current bugs  ·  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.

SdlRenderer::SetScissorRect installs SDL_SetRenderClipRect for every non-empty rectangle and the renderer has no ApplyRasterizerState override, so a game that sets a scissor rectangle but draws with the test disabled is still clipped.

Identifier
CNA-BUG-105
Category
Bug
Subsystem
Graphics & renderers
Status
Open
Verified against
CNA 009d40f5 (009d40f5dd085c4e674d3479675fac84b12b3e0a)
Severity
Medium (a triage suggestion, not a project priority)
Evidence basis
Source-verified: read at TARGET, not executed
Tests touching this area
Yes: see Current tests
Affected contract
GraphicsDevice.ScissorRectangle together with RasterizerState.ScissorTestEnable on SDL_RENDERER

Expected behaviour

XNA clips only while RasterizerState.ScissorTestEnable is true; the rectangle may stay set while other draws run unclipped (a common UI pattern).

Actual behaviour at TARGET

SdlRenderer.cpp's SetScissorRect calls SDL_SetRenderClipRect(renderer, &rect) for any rectangle with positive size and clears the clip only for an empty one; the scissor-enable flag arrives through ApplyRasterizerState, which SDL_RENDERER does not override (the interface default ignores it). So the clip follows the rectangle, not the test: disabled-test draws are clipped, and an enabled zero-area rectangle removes clipping entirely.

Source locations

Evidence

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

Focused reproduction

// Illustrative; not compiled or run for this entry.
device.setScissorRectangleProperty(Rectangle(0, 0, 100, 100));
batch.Begin(SpriteSortMode::Deferred, BlendState::AlphaBlend, nullptr, nullptr,
            RasterizerState::CullCounterClockwise);   // ScissorTestEnable = false
batch.Draw(background, Rectangle(0, 0, 800, 600), Color::White);
batch.End();
// XNA: full background.  SDL_RENDERER: only the 100x100 corner is drawn.

Current tests

sdlrenderer_rasterizer_depthstencil_construction_test.cpp checks state construction only; no SDL_RENDERER pixel test toggles ScissorTestEnable.

Regression test

A pixel fixture that sets a small ScissorRectangle and draws full-screen with the test disabled and then enabled, asserting unclipped and clipped results.

Blast radius

UI and HUD code on SDL_RENDERER that leaves a scissor rectangle set between clipped and unclipped passes.

Workaround

Reset ScissorRectangle to the full viewport before unclipped draws.

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

Known issues
Bug index