Commit Graph

1509 Commits

Author SHA1 Message Date
Sam Lantinga
09304831f6 Fixed issues with YUV texture updates in the 2D renderer 2025-12-05 08:30:52 -08:00
Sam Lantinga
c61497b744 Account for indexed formats when matching texture formats
Fixes https://github.com/libsdl-org/SDL/issues/14569
2025-12-03 21:21:52 -08:00
Sam Lantinga
f92435cdb9 Vulkan windows get the Vulkan GPU backend in the gpu renderer by default 2025-12-02 07:29:33 -08:00
Sam Lantinga
c0a2ae2a4a opengles2: fixed swapped colors when using indexed textures 2025-11-23 11:38:35 -08:00
Sam Lantinga
0ae3d7b0b0 Fixed crash in the vulkan renderer when the window is minimized
There's more work to do here in other cases where we can't recreate the swap chain, but this fixes the common minimize case.

Fixes https://github.com/libsdl-org/SDL/issues/14434
2025-11-14 12:35:33 -08:00
Sam Lantinga
5bed8ec603 Implemented render batching for D3D9 2025-11-11 08:31:37 -08:00
Sam Lantinga
dde7fa3b17 Validate the output colorspace before setting up a renderer 2025-11-10 18:30:02 -08:00
Sam Lantinga
6baaa0fe87 Destroy the window surface if a software renderer couldn't be created 2025-11-10 18:30:02 -08:00
Sam Lantinga
33c70af2f8 Fixed SDL_COLORSPACE_SRGB_LINEAR being used for RGBA32 textures 2025-11-10 18:30:02 -08:00
Sam Lantinga
ead02b08dd Skip tonemapping for render targets with unspecified HDR headroom 2025-11-10 18:30:02 -08:00
Sam Lantinga
4e5ba722fd Change the batch if the color scale changes
The color scale is a shader constant so it can be applied in linear space
2025-11-10 18:30:02 -08:00
Sam Lantinga
d29f368ca8 Change the batch if the GPU render state changes 2025-11-10 18:30:02 -08:00
Sam Lantinga
3399bc600e gpu renderer: add color to the point/line vertex data
This allows us to batch color changes in a single draw call
2025-11-10 18:30:02 -08:00
Sam Lantinga
97ebfbf7a0 Only convert color to linear once in VULKAN_QueueDrawPoints() 2025-11-10 18:30:02 -08:00
Sam Lantinga
d9be8b9a00 Implemented render batching for D3D11, D3D12, Metal, and Vulkan
Fixes https://github.com/libsdl-org/SDL/issues/7534
2025-11-10 18:30:02 -08:00
Sam Lantinga
cc2a272d6f Enable RLE more often in the software renderer
We don't need to aggressively disable RLE acceleration anymore because the original pixels remain available for operations that aren't supported by the RLE blitter.
2025-11-08 14:51:27 -08:00
Sam Lantinga
7553d5892e Fixed software renderer 8-bit scaling and rotation (thanks @jroatch!)
Fixes https://github.com/libsdl-org/SDL/issues/14422
2025-11-08 08:46:58 -08:00
Sam Lantinga
1fb663b429 Make sure that SDL_PIXELFORMAT_ARGB8888 is the first texture format for OpenGL
Fixes https://github.com/libsdl-org/SDL/issues/1440
2025-11-07 11:13:50 -08:00
Sam Lantinga
3489a45216 Use srcpixel now that we've set it 2025-11-07 11:12:10 -08:00
Sam Lantinga
294beceec7 Fixed error: 'srcpixel' may be used uninitialized 2025-11-07 11:11:31 -08:00
Sam Lantinga
0f21e46586 Added support for SDL_PIXELFORMAT_INDEX8 to SDL_BlitTriangle_Slow()
Fixes https://github.com/libsdl-org/SDL/issues/14419
2025-11-07 11:01:23 -08:00
Sam Lantinga
547b2a2e37 SDL_SetSurfaceRLE() has a boolean parameter 2025-11-07 11:01:23 -08:00
Sam Lantinga
e24eeefbd1 The default render texture format is SDL_PIXELFORMAT_ARGB8888
We do this for consistency across backends
2025-11-06 09:46:43 -08:00
Mathieu Eyraud
de5b8a1c45 Remove useless call to SetTextureAddressMode() 2025-11-06 08:25:00 -08:00
Mathieu Eyraud
7ad4911584 Remove incorrect and useless call to SetTextureScaleMode()
SetTextureScaleMode() is called a few lines below with correct arguments.
2025-11-06 08:25:00 -08:00
Sam Lantinga
524739900a Fixed potential double-free when creating a renderer (thanks @Sackzement!)
Closes https://github.com/libsdl-org/SDL/pull/14371
2025-11-01 11:24:14 -07:00
Sam Lantinga
aafbf7183f Copy shader params instead of caching a pointer to them
It's possible for a new texture to be allocated with the same address as a previous one, so we can't just cache the pointer value.

Fixes https://github.com/libsdl-org/SDL/issues/14369
2025-11-01 11:24:14 -07:00
Kirill Andriiashin
a76fb7b2fb Add support for GPU RGB565 (B5G6R5_UNORM) textures with DX11 (#14358) 2025-10-29 10:39:58 -07:00
Sam Lantinga
933beeb18b Fixed warning: no previous extern declaration for non-static variable 2025-10-27 17:52:05 -07:00
Sam Lantinga
0ea20a5f86 Fix NULL pointer dereference in SDL_RenderGeometryRaw with NPOT textures (thanks @bleeqer!)
Fixes https://github.com/libsdl-org/SDL/issues/14329
Closes https://github.com/libsdl-org/SDL/pull/14331
2025-10-26 08:10:52 -07:00
Sam Lantinga
e18d63a4e2 Added SDL_RotateSurface()
Fixes https://github.com/libsdl-org/SDL/issues/14269
2025-10-22 17:55:02 -07:00
Sam Lantinga
a402af506c Removed SDL_FILE from source code 2025-10-22 10:52:18 -07:00
Sam Lantinga
e58648d592 Removed call to ID3D11DeviceContext1_DiscardView() (thanks @pipiwoaini!)
This is unnecessary and can cause issues after a resize or device removal.

Fixes https://github.com/libsdl-org/SDL/issues/14283
2025-10-21 13:01:30 -07:00
Eddy Jansson
aaee09d6ed Don't do NULL-checks before SDL_free()
Replaces the pattern

  if (ptr) {
    SDL_free(ptr);
  }

with

  SDL_free(ptr);
2025-10-20 00:13:09 -07:00
nmlgc
2ffabb5150 render: Fix texture format selection for color-keyed indexed surfaces
015cc6a broke texture format selection for this kind of surface if the
renderer's first texture format doesn't happen to have an alpha
channel. This happens for on-screen software renderers on Windows,
whose preferred format is the window's own `SDL_PIXELFORMAT_XRGB8888`.
This fixed check also cover the intent behind 015cc6a, assuming that
indexed and alpha formats are mutually exclusive.
2025-10-14 21:23:09 -07:00
Peter0x44
705ced8cf5 Make D3D math functions static inline to reduce likelihood of linking conflicts
Convert SDL_d3dmath.c functions to static inline in SDL_d3dmath.h to make
it less likely to conflict when static linking SDL. raylib's SDL backend
does not work with a "normal" upstream binary static link. It has these
errors:

/usr/bin/ld: /usr/local/lib64/libSDL3.a(SDL_d3dmath.c.o): in function `MatrixIdentity':
SDL/src/render/SDL_d3dmath.c:35: multiple definition of `MatrixIdentity'; CMakeFiles/raylib.dir/rcore.c.o:rcore.c:(.text+0x18470): first defined here
/usr/bin/ld: /usr/local/lib64/libSDL3.a(SDL_d3dmath.c.o): in function `MatrixMultiply':
SDL/src/render/SDL_d3dmath.c:44: multiple definition of `MatrixMultiply'; CMakeFiles/raylib.dir/rcore.c.o:rcore.c:(.text+0x18540): first defined here
collect2: error: ld returned 1 exit status

It works if these functions aren't emitted, (i.e.
!SDL_VIDEO_RENDER_D3D(11|12|GPU|VULKAN)

Or, if SDL is not linked static. Which I know is preferred anyway.

In raylib's case, it doesn't use this code anyway so it's not a problem
to build it yourself with them disabled. But it's a minor hassle to be
incompatible with static linking libraries from upstream.

I can't see any good reason for these functions to not be static inline
already, so I just put them in the header and deleted the .c.

Raylib's conflicting case is a library with a public function exposed to
users. But SDL's case is not.

- Moved all matrix functions from SDL_d3dmath.c to SDL_d3dmath.h as static inline
- Removed SDL_d3dmath.c from all project files (Visual Studio and Xcode)
- Functions affected: MatrixIdentity, MatrixMultiply, MatrixScaling,
  MatrixTranslation, MatrixRotationX, MatrixRotationY, MatrixRotationZ
2025-10-14 16:56:41 -07:00
Sam Lantinga
015cc6aa6c Fixed accidentally using INDEX8 textures for RGB24 surfaces 2025-10-13 15:27:13 -07:00
Sam Lantinga
7a49ce71a1 Handle partial OpenGL shader availability
The pixelart shaders are not supported on OpenGL 2.1 (GLSL 130 isn't available)

Fixes the OpenGL renderer on macOS
2025-10-13 15:27:13 -07:00
Sam Lantinga
d7ad47e2ca Added SDL_PROP_RENDERER_TEXTURE_WRAPPING_BOOLEAN
Fixes https://github.com/libsdl-org/SDL/issues/13908
2025-10-12 11:15:47 -07:00
Sam Lantinga
513de0f0ec Don't allow SDL_TEXTURE_ADDRESS_WRAP if it's not supported
Fixes https://github.com/libsdl-org/SDL/issues/13908
2025-10-12 10:46:48 -07:00
Sam Lantinga
1ed093ad8b Corrected texture colors on PS2 (thanks @Trinth!)
Fixes https://github.com/libsdl-org/SDL/issues/12395
2025-10-12 09:20:00 -07:00
Sam Lantinga
480f069cec Copy the palette instead of referencing it when creating a texture
Fixes https://github.com/libsdl-org/SDL/issues/14213
2025-10-11 11:01:15 -07:00
Sam Lantinga
9d635fe641 Flush rendering if a texture palette is in use when destroyed 2025-10-10 17:42:27 -07:00
Sylvain
2a96997e90 Fixed bug #14173 - Android / SDL_Renderer Vulkan : going background / foreground produces a black screen.
need to recreate the swap chain + send SDL_EVENT_RENDER_DEVICE_RESET event
2025-10-09 08:40:42 -07:00
Roman Fomin
c86cfb0156 Disable D3D feature levels below 11.0 for the D3D11 renderer 2025-10-08 21:10:08 -07:00
Sam Lantinga
84b0565096 Fixed potential memory leak 2025-10-08 19:44:03 -07:00
Sam Lantinga
3316dde0c2 Improved error information when renderer creation fails
On Android, if you create a window with SDL_WINDOW_OPENGL, you can't create a Vulkan surface. The error message has been improved to reflect this, and the error is propagated back up to the application.

Also added warn level logging if the renderer couldn't be created.
2025-10-08 19:36:19 -07:00
Sam Lantinga
edf5f9ec5c Properly upgrade a window to Vulkan when creating a Vulkan renderer 2025-10-08 19:17:11 -07:00
ROllerozxa
f43577bbb5 Fix compiling Metal renderer with SDL_LEAN_AND_MEAN 2025-10-07 16:20:59 -07:00
Sam Lantinga
7877ed1802 Fixed permissions 2025-10-06 17:30:04 -07:00