Commit Graph

1603 Commits

Author SHA1 Message Date
Sam Lantinga
855cbec702 Set VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT for planar formats
This allows creating separate image views for the planes of the image if desired.
2026-07-24 16:22:28 -07:00
Sam Lantinga
0f5f708c5a Better check to see whether HDR10 input will have scaling applied 2026-07-23 12:55:14 -07:00
Sam Lantinga
604fe14b87 Make sure the PQ shader will output the input value before using the simple shader
Note that we don't account for vertex color here. If HDR10 content needs to be tinted by vertex color, it can't use the simple shader. I'm assuming that the use case for this will be video content which generally won't use vertex color and this optimization is fine.
2026-07-23 10:25:25 -07:00
Sam Lantinga
148241117b Define SCRGB_NITS for use in HDR color calculations 2026-07-23 10:25:25 -07:00
Sam Lantinga
23b641070c Added HDR10 display support for the direct3d11, direct3d12, and vulkan renderers 2026-07-22 11:36:32 -07:00
meta-legend
ac9ef17bcc Avoid RLE for software render alpha subrect copies (#15982) 2026-07-17 15:09:42 -07:00
Sam Lantinga
6ce3d843fc testffmpeg_vulkan: fixed usage of timeline semaphores 2026-07-10 10:06:48 -07:00
Sam Lantinga
c1d4376d3c Fixed Vulkan validation errors when using ffmpeg video decode 2026-07-10 08:09:15 -07:00
Epifanov Ivan
425c6a2695 VITA: invalidate texture in render state on update (#15957) 2026-07-08 07:10:57 -07:00
Jacul
e1b3c8afd5 metal: check MTLBuffer allocations for nil before using their contents. 2026-07-05 23:53:21 -04:00
Sam Lantinga
dfefce62e2 Get the physical device properties when using an external Vulkan device
Fixes `testffmpeg --sprites 100` when using the Vulkan renderer
2026-06-30 12:53:17 -07:00
Sam Lantinga
2069d5f6bc Fixed formatting 2026-06-30 12:53:17 -07:00
Sam Lantinga
464b90b475 Issue a batch when changing render targets in the Vulkan renderer
Otherwise we get rendering artifacts that look like drawing is being applied to the wrong render target
2026-06-30 09:00:09 -07:00
Sam Lantinga
e0b12bbcea Added a workaround for a crash in NVIDIA drivers when rendering YUV with Vulkan
Fixes https://github.com/libsdl-org/SDL/issues/13878
2026-06-29 14:09:24 -07:00
Sam Lantinga
284afc2c9a Set SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER to the correct texture
Fixes https://github.com/libsdl-org/SDL/issues/15157
2026-06-23 08:57:49 -07:00
Frank Praznik
e26370810b gpu/vulkan renderer: Reconfigure the window on renderer creation if it has the OpenGL flag
In some cases, conflicts can occur at the platform or driver level if a window initially configured for OpenGL is then used with a Vulkan-based renderer. Try to reconfigure or recreate the window in the unlikely event that it has the OpenGL flag set when initializing the Vulkan or GPU renderer to remove any platform or driver-specific OpenGL objects and properties.
2026-06-23 11:03:05 -04:00
Sam Lantinga
07ecc125cf Added SDL_PIXELFORMAT_P408 and SDL_PIXELFORMAT_P416 2026-06-22 17:01:54 -05:00
Frank Praznik
4c28a67cd5 gles: Try to reconfigure the window instead of recreating it
SDL_ReconfigureWindow will fall back to recreation if necessary.
2026-06-19 10:25:39 -04:00
Sam Lantinga
fa2a726cc3 Added SDL_CreateSurfaceUninitialized()
Currently this is an internal API, but we can expose it in the future.
2026-06-05 09:14:07 -07:00
Sam Lantinga
2b0df96f25 Send SDL_EVENT_WINDOW_EXPOSED when the GPU renderer swap chain is resized
In this case the current frame being rendered doesn't match the swapchain size and the application should re-render the frame.

Fixes https://github.com/libsdl-org/SDL/issues/15550
2026-05-29 14:37:32 -07:00
Sam Lantinga
e04bfb4c6e render: an empty clip rect should clip all drawing
Added a test to validate this and fixed the Metal renderer

Fixes https://github.com/libsdl-org/SDL/issues/15434
2026-05-29 13:58:34 -07:00
Sam Lantinga
113e97e193 metal: fixed reading textures with format SDL_PIXELFORMAT_RGBA128_FLOAT 2026-05-28 11:50:03 -07:00
Sylvain Becker
d4236dcd85 opengles: Readd an OpenGL ES 1 renderer to SDL3! (#15185)
This readds the "opengles" renderer, updated from SDL2 to work on SDL3.

Fixes #15661.

Co-authored-by: Ryan C. Gordon <icculus@icculus.org>
Co-authored-by: Cameron Cawley <ccawley2011@gmail.com>
2026-05-25 20:41:13 -04:00
Cameron Cawley
f162c49dc1 Use SDL_PIXELFORMAT_INDEX8 for the debug font atlas 2026-05-24 08:00:21 -07:00
Ozkan Sezer
cbd2917324 SDL_render_d3d11.c: fix another bad use of SDL_FUNCTION 2026-05-17 21:36:20 +03:00
Ozkan Sezer
f76b736e28 SDL_render_d3d12.c: revert an unintended change from commit d70578b9aa 2026-05-17 20:28:56 +03:00
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