Commit Graph

1577 Commits

Author SHA1 Message Date
Sam Lantinga
5cf16e4522 Added curved window mode on visionOS 26 (#15298) 2026-05-12 16:48:06 -07:00
Ryan C. Gordon
56e0d052f1 opengles2: Rework render targets.
Now this keeps one FBO for each SDL_TEXTUREACCESS_TARGET texture, and doesn't
reuse it. We check if the FBO is "complete" once, at creation time, and
setting a render target merely has to bind the right FBO and never look back.

This simplifies the code and removes a guaranteed pipeline stall when setting
a new render target.

Fixes #15524.
2026-05-06 13:26:41 -04:00
Michael Fitzmayer
77cd3872c4 [N-Gage] Add missing include, clean-up. 2026-05-06 17:27:12 +02:00
Michael Fitzmayer
b9da2b8d97 [N-Gage] Add Gouraud-shaded triangle rasteriser
Implement DrawGeometry using a software scanline rasteriser that fills
triangles directly into the EColor4K framebuffer. Vertices are sorted by
Y, split into upper/lower halves and filled with per-scanline edge
interpolation. Colour is stepped incrementally across each span (one
division per span edge rather than per pixel) to avoid the cost of
emulated integer division on the ARM920T.
2026-05-06 16:40:50 +02:00
misscelan
37089cf0a8 Update for N-Gage - Audio is now double buffered (#15516)
[N-Gage] Audio is now double buffered to avoid stuttering and glitches. Some audio platform specific variables were exposed through SDL_Hints. Same method was used to display FPS. N-gage functions to obtain the current buffer and screen pitch were added to the render.

Adds hints:

SDL_AUDIO_NGAGE_LATENCY
SDL_AUDIO_NGAGE_SCHEDULER_TICK
SDL_AUDIO_NGAGE_PROCESS_TICK
SDL_AUDIO_NGAGE_PROCESS_PRIORITY
SDL_RENDER_SHOW_FPS

Adds functions to get current buffer address and pitch:

void *NGAGE_GetBackbufferAddress(void);
int NGAGE_GetBackbufferPitch(void);

---------
Co-authored-by: Michael Fitzmayer <mail@michael-fitzmayer.de>
Co-authored-by: Eddy Jansson <eloj@users.noreply.github.com>
2026-05-06 16:39:23 +02:00
Michael Fitzmayer
1cb61df1e5 [N-Gage] Fix image transformations, add color keying, and improve overall rendering performance. Fixes #15427
[N-Gage] Correct SDL_FLIP_HORIZONTAL for sprite sheet textures

- ApplyFlip: swap toward midpoint when dest == source to avoid
  overwriting pixels before they are read
- CopyEx: restore original bitmap pixels after BitBlt so the texture
  is not permanently mutated across frames
- CopyEx: extract srcrect sub-region before transforming so flip/
  rotate/scale operate on the correct pixels, not the full texture

[N-Gage] Use scratch bitmap in CopyEx to avoid mutating source texture.

Replace the write-then-restore pattern on the source texture with a
persistent iScratchBitmap. The transform pipeline operates entirely
within iPixelBufferA/B; the final result is copied into iScratchBitmap
and BitBlt reads from there. The source texture is never written to.

[N-Gage] Fix Copy() for render-target textures by using direct BitBlt

Bypass pixel readback for SDL_TEXTUREACCESS_TARGET textures in CRenderer::Copy().
Reading raw pixels via DataAddress() on a server-side bitmap is unreliable; use
BitBlt directly instead.

[N-Gage] Implement color-key masking using Symbian's BitBltMasked.

This implementation works fine, but relies on a platform specific property. This isn't ideal.
Todo: Add SDL_PIXELFORMAT_ARGB4444 to the N-Gage's rendering back-end.

[N-Gage] Avoid using BitBltMasked to improve performance. Much better!

Write only non-color-key source pixels directly into the destination bitmap
preserving existing destination pixels wherever the color key matches.
This replaces BitBltMasked and avoids the cost of building an EGray2 mask.

[N-Gage] Remove redundant function call since we're not using BitBltMasked() anymore.

[N-Gage] Remove SDL_PROP_TEXTURE_NGAGE_COLOR_KEY_NUMBER

- Promote SDL_PIXELFORMAT_XRGB4444 to SDL_PIXELFORMAT_ARGB4444 instead.
- Remove now unused functions.
2026-05-01 21:50:09 +02:00
Frank Praznik
73fc274ef7 renderer: Check the surface validity flag when re-acquiring the surface in the software renderer
If a size change occurs, the sdl2-compat event handler will flush the renderer, which will cause the software renderer to re-acquire a surface that was invalidated due to the size change. However, if the OnWindowPixelSizeChanged handler is called afterward, the invalid flag will be set on the surface, causing presentation to fail.

Check both for a null surface pointer and an invalid surface flag when checking surface validity in the software renderer.
2026-04-27 12:56:58 -04:00
Michael Fitzmayer
6e65c3fac4 [N-Gage] Remove optimisations except for native texture handling prior to some rework of the rendering back-end
[N-Gage] Set proper brush style to draw filled rects properly.

[N-Gage] Add persistent buffers to avoid per-frame memory allocations (which are expensive)

[N-Gage] Add support for SDL_TEXTURE_ACCESS_TARGET, fixes #13165

[N-Gage] Update README, add hint that the compiler does not support aggregate initializations for structs (knowing this, avoids a lot of headache during debugging)

[N-Gage] Add basic fast-path optimisations for render operations.

[N-Gage] Fix line drawing.
2026-04-18 19:54:30 +02:00
Michael Fitzmayer
badc3b82c5 [N-Gage] Micro-optimize rendering back-end
- Skip SDL_GetRenderScale call in Copy() fast path
- Cache last clear color to avoid redundant SetBrushColor calls
- Add whole-image bounds pre-check to skip per-pixel checks in rotation
- Simplify color packing in DrawPoints/FillRects to reduce overhead
2026-04-16 21:38:08 +02:00
Michael Fitzmayer
87e356f102 [N-Gage] Simplify rendering back-end; more micro-optimization
- Remove redundant null checks
- Use cached texture properties instead of API calls (GetBitmapWidth/Height/Pitch)
- Eliminate duplicate SDL_GetRenderScale() call in Copy()
- Reorder CopyEx() fast paths to check no-transform case first
- Combine operations in NGAGE_ConvertColor() to reduce intermediate steps
2026-04-16 21:38:08 +02:00
Michael Fitzmayer
b53b31b74a [N-Gage] Add various micro-optimizations to rendering back-end
- Add reusable line points buffer to eliminate per-call heap allocations in DrawLines.
- Cache last draw color to skip redundant SetPenColor/SetBrushColor calls.
- Pre-compute cardinal angle constants (0°, 90°, 180°, 270°) for CopyEx fast-path.
- Cache color modulation state to avoid redundant LUT rebuilds.
- Add missing break statement in HandleEvent.
- Initialize previously uninitialized lastTime variable in UpdateFPS.
2026-04-16 21:38:07 +02:00
Michael Fitzmayer
30522e8598 [N-Gage] Optimize renderer even further
- Replace FixDiv with inverse scale factors in ApplyScale
- Improve incremental DDA in ApplyRotation
- Optimize ApplyColorMod bit manipulation and LUT addressing
- Batch color changes in DrawPoints and FillRects to reduce API overhead
- Add early-exit optimizations to Copy/CopyEx for common cases
- Streamline Flip function by removing unnecessary API calls
- Fix vertex indexing bug in FillRects
2026-04-15 21:46:56 +02:00
Michael Fitzmayer
5bd1a65e6f [N-Gage] Add LUT color mod, cardinal rotation cache and loop unrolling
- Implement lookup tables for faster color modulation
- Cache 0°/90°/180°/270° rotations for speedup on common angles
- Add dirty rectangle tracking infrastructure
- Process 4 pixels at a time in all transform operations
2026-04-15 20:36:42 +02:00
Michael Fitzmayer
e5c8523b36 [N-Gage] Preserve source textures and optimize rotation with DDA
- Add temporary render bitmap to avoid destroying source texture data
- Implement incremental DDA algorithm for rotation
- Replaces per-pixel FixMul operations with simple additions and preserves
  textures for reuse.
2026-04-15 20:36:41 +02:00
Michael Fitzmayer
4870f81d9c [N-Gage] Optimize rendering back-end
- Remove SDL_Surface member from NGAGE_TextureData structure and update all functions that currently use
  surface->pixels to instead access bitmap->DataAddress() directly. This eliminates the intermediate copy
  step (Mem::Copy from surface to bitmap) in rendering operations.

- Eliminate per-frame allocations in Copy/CopyEx methods. These buffers are now allocated once and resized
  only when needed.
2026-04-15 20:36:41 +02:00
Sam Lantinga
57f3d2ea0a Don't send any commands to the GPU while hidden
Previously we weren't doing drawing, but we were enqueuing viewport commands and so forth, which were causing GPU permission errors on iOS. We really don't want to be sending any work to the GPU when we're in the background.
2026-04-08 10:08:11 -07:00
Sam Lantinga
173adc1bf6 Enable npot texture wrapping if GL_OES_texture_npot is available 2026-04-04 08:12:51 -07:00
nmlgc
989de77f4f render: Skip UV check when software-rendering untextured quads
Fixes a crash when calling SDL_RenderGeometryRaw() with both `texture`
and `uv` set to `NULL`, and with geometry that is laid out in a way
that passes the quad checks.
2026-03-25 07:24:55 -07:00
Sam Lantinga
0f9292a367 Fixed incorrect sampler when changing Metal draw state 2026-03-21 14:08:40 -07:00
Ethan Lee
ee5c5cf755 render: Add Suspend/Resume calls for GDK support 2026-03-07 11:19:09 -05:00
Ethan Lee
c20a058ff4 Revert "render: Added Xbox DXIL for gpu backend".
Turns out Xbox is okay with the PC DXIL, it just isn't as optimal without the root signature annotations.

This reverts commit f2c4c66429.
2026-03-04 15:52:07 -05:00
Void Star Caster
2e3300e872 Functions to bind GPURenderState storage textures, buffers and sampler bindings (#15150) 2026-03-02 12:50:58 -08:00
MSRPP-dev
4dbf5811e9 Update SDL_render_sw.c
Fix the bug in the standard scaling path, SDL_RENDERCMD_COPY should follow the same pattern as SW_RenderCopyEx.
2026-03-02 09:49:46 -08:00
Ethan Lee
f2c4c66429 render: Added Xbox DXIL for gpu backend 2026-03-01 19:09:55 -05:00
Ethan Lee
a4cd62ef93 render: Reduce scope of D3D12 GDK event watcher to Xbox 2026-02-25 09:23:20 -05:00
Ethan Lee
5770e013c2 gdk: Render/GPU can call SuspendX, document when to call SuspendComplete 2026-02-25 09:20:25 -05:00
Brenton Bostick
a5889b0e44 make sure #endif comment matches the macro name 2026-02-24 09:48:57 -08:00
Void Star Caster
4a4ae4a79d Fix GetSampler() bug for INDEX8 pixel format (#15099) 2026-02-24 08:05:30 -08:00
Gokul Mittal
8d2b6c09c5 undefine ADD_TRIANGLE macro definition
ADD_TRIANGLE macro function in SDL_RenderLines() was never being undefined even after it's purpose was resolved.
2026-02-15 08:37:46 -08:00
Ryan C. Gordon
fc570a1a1c render: opengl and opengles2 renderers try to disable GL_FRAMEBUFFER_SRGB.
Reference Issue #14898.
2026-02-14 16:33:21 -05:00
RaceTheMaSe
f1a7a64eb4 Fix warnings: Extra semi - macro usage (#15015) 2026-02-08 16:58:53 -08:00
Sam Lantinga
6feb0e1333 You can't combine SDL_STRINGIFY_ARG() and SDL_FUNCTION
Removed obsolete documentation that shows this usage and macros that attempt it.

Also allow SDL_FUNCTION to be redefined by the application.

Fixes https://github.com/libsdl-org/SDL/issues/15004
2026-02-08 11:51:34 -08:00
Sam Lantinga
4de62c35c0 Fixed checking against cached shader params (thanks @ccawley2011!) 2026-02-08 10:59:18 -08:00
RaceTheMaSe
7c7ffb9115 tests: Fix unreachable code warnings (#14993) 2026-02-07 20:42:59 +03:00
RaceTheMaSe
863912aa03 PS2, VITA: Fix void pointer arithmetic warnings (#14995) 2026-02-07 20:39:33 +03:00
Max Seidenstücker
8f8880a8eb Merge all occurances of __func__ and __FUNCTION__ to SDL_FUNCTION 2026-02-07 07:34:11 -08:00
Ryan C. Gordon
60690ff829 render: OpenGL and GLES2 should explicitly request a not-sRGB-capable context.
Reference Issue #14898.
2026-02-06 13:44:20 -05:00
Sam Lantinga
fdfcfc0566 Make sure native textures have the same channel precision if possible
Fixes https://github.com/libsdl-org/SDL/issues/14882
2026-02-06 09:50:18 -08:00
Wohlstand
a36ef1f187 SDL_render_psp.c: Also apply the similar fix to PSP
Since this problem is the same here
2026-02-06 09:02:41 -08:00
Wohlstand
87a81bd09d SDL_render_vita_gxm.c: Fixed the black screen due to zero cliprect 2026-02-06 09:02:41 -08:00
Wohlstand
75d1d64c75 Revert "Reverted Vita cliprect changes"
This reverts commit aeb4b3d2fc.
2026-02-06 09:02:41 -08:00
Sam Lantinga
4970067c9a Use SDL_PixelFormat appropriately 2026-02-02 09:46:13 -08:00
Ethan Lee
5640647e14 render: D3D12 Xbox buildfixes 2026-02-02 10:10:08 -05:00
Cameron Gutman
4743f97c39 Fix invalidation of bound textures/shaders across a renderer flush on D3D9 2026-01-31 17:17:07 -08:00
Wouter Wijsman
c1e715439a Fix PSP_QueueGeometry funcion rendering some textures too small 2026-01-28 07:39:04 -08:00
Sam Lantinga
a929eb71b3 Set SDL_PROP_GPU_DEVICE_CREATE_METAL_ALLOW_MACFAMILY1_BOOLEAN for the GPU renderer 2026-01-25 09:14:29 -08:00
Eddy Jansson
248223592a More prefer SDL_zero*()
Transform clearing of arrays into SDL_zeroa(), and
clearing through a T* with size(T) into SDL_zerop().

Extends commit 83fb7b6636.
2026-01-23 16:02:16 -08:00
Eddy Jansson
83fb7b6636 Prefer SDL_zero()/SDL_zerop()
Replace uses of 'SDL_memset(E, 0, sizeof(E))' and similar
with the SDL_zero()/SDL_zerop() macros.
2026-01-23 11:23:27 -08:00
Cameron Cawley
07be29b625 Support 16-bit packed texture formats with the Vulkan renderer 2026-01-19 08:29:01 -08:00
Cameron Cawley
ab7d275113 Support 16-bit packed texture formats with the GPU renderer 2026-01-18 12:48:24 -08:00